Skip to content

Commit

Permalink
Added sound for Outdated order (#126)
Browse files Browse the repository at this point in the history
* Update Order.java

Added play sound once order has been outdated

* Fixed

* Fix 2

* Update RenderUtils.java

* Removed import net.minecraft.client.Minecraft;

* Update README.md

Spelling error on the link that caused a 404

* minor refactoring

---------

Co-authored-by: symt <[email protected]>
  • Loading branch information
UltimateBoi and symt authored Oct 7, 2024
1 parent 3012f5f commit f971428
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ Join the discord server: https://discord.com/invite/wjpJSVSwvD

<hr/>

<sub>[License](https://github.com/symt/BazaarNotifier/blob/master/license.txt) | [Site](https://meyi.dev)</sub>
<sub>[License](https://github.com/symt/BazaarNotifier/blob/master/LICENSE.txt) | [Site](https://meyi.dev)</sub>
5 changes: 5 additions & 0 deletions src/main/java/dev/meyi/bn/config/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ public Configuration() {
)
public boolean showChatMessages = Defaults.SEND_CHAT_MESSAGES;

@JsonName("sendSound")
@Switch(name = "Send Sound for Outdated Orders")

public boolean sendSound = Defaults.SEND_SOUND;

@JsonName("collectionCheck")
@Switch(name = "Collection checks",
category = "Crafting Module",
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/dev/meyi/bn/json/Order.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package dev.meyi.bn.json;


import dev.meyi.bn.BazaarNotifier;
import dev.meyi.bn.json.resp.BazaarItem;
import dev.meyi.bn.utilities.RenderUtils;

public class Order {

public String product;
public int startAmount;
public double pricePerUnit;
Expand Down Expand Up @@ -121,6 +119,7 @@ else if (this.pricePerUnit > bazaarSubItem.pricePerUnit) {
RenderUtils.chatNotification(this, "MATCHED");
} else if (OrderStatus.OUTDATED.equals(newOrderStatus)) {
RenderUtils.chatNotification(this, "OUTDATED");
RenderUtils.sendSound(); // might be loud if multiple become oudated at the same time
}
this.orderStatus = newOrderStatus;
}
Expand All @@ -137,4 +136,4 @@ public enum OrderType {
this.longName = longName;
}
}
}
}
1 change: 1 addition & 0 deletions src/main/java/dev/meyi/bn/utilities/Defaults.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class Defaults {
public static final boolean PROFIT_PER_MIL = true;
public static final boolean COLLECTION_CHECKING = false;
public static final boolean SEND_CHAT_MESSAGES = true;
public static final boolean SEND_SOUND = false;
public static final boolean USE_BUY_ORDERS = true;
public static final boolean SUGGESTION_SHOW_ENCHANTMENTS = true;
public static final boolean BANK_RAW_DIFFERENCE = false;
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/dev/meyi/bn/utilities/RenderUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ public static int getStringWidth(String string) {
return fontRenderer.getStringWidth(string);
}

public static void sendSound() {
if (BazaarNotifier.config.sendSound) {
Minecraft.getMinecraft().thePlayer.playSound("mob.horse.donkey.death", 2.0F, 1.0F);
// TODO: add option for which sound to play (possibly)
}
}
public static void chatNotification(Order order, String notification) {
if (!BazaarNotifier.config.showChatMessages) {
return;
Expand Down

0 comments on commit f971428

Please sign in to comment.