aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
authorjani270 <69345714+jani270@users.noreply.github.com>2023-12-14 18:06:24 +0100
committerGitHub <noreply@github.com>2023-12-14 18:06:24 +0100
commit57666e9c49734d89332e987259a5ff48bc29c66d (patch)
tree6060c48f2a97eb017fa3fbbb41e16912f19be78c /src/main/java/io
parent27bfa73de7df93814ca7e60c7d8c25ac6fed6edd (diff)
downloadNotEnoughUpdates-57666e9c49734d89332e987259a5ff48bc29c66d.tar.gz
NotEnoughUpdates-57666e9c49734d89332e987259a5ff48bc29c66d.tar.bz2
NotEnoughUpdates-57666e9c49734d89332e987259a5ff48bc29c66d.zip
Added spray cooldown preview (#961)
* Added spray cooldown preview * Change around some if statements for better performance, also fixed the config description being wrong lol --------- Co-authored-by: nopo <nopotheemail@gmail.com>
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java42
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/Garden.java8
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/ItemOverlays.java6
3 files changed, 45 insertions, 11 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java
index 3e28717b..eebfc28c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java
@@ -52,12 +52,16 @@ public class ItemCooldowns {
private static final Pattern SPIRIT_ABILITY_ACTIVATION =
Pattern.compile("\\u00a7r\\u00a76Second Wind Activated\\u00a7r\\u00a7a! \\u00a7r\\u00a7aYour Spirit Mask saved your life!\\u00a7r");
+ private static final Pattern SPRAYONATOR_ACTIVATION =
+ Pattern.compile("§r§a§lSPRAYONATOR! §r§7You sprayed §r§aPlot §r§7- §r§b.* §r§7with §r§a.*§r§7!§r");
+
private static final Map<ItemStack, Float> durabilityOverrideMap = new HashMap<>();
public static long pickaxeUseCooldownMillisRemaining = -1;
private static long treecapitatorCooldownMillisRemaining = -1;
private static long bonzomaskCooldownMillisRemaining = -1;
private static long spiritMaskCooldownMillisRemaining = -1;
+ private static long sprayonatorCooldownMillisRemaining = -1;
public static boolean firstLoad = true;
public static long firstLoadMillis = 0;
@@ -67,6 +71,7 @@ public class ItemCooldowns {
public static long pickaxeCooldown = -1;
private static long bonzoMaskCooldown = -1;
private static long spiritMaskCooldown = -1;
+ private static long sprayonatorCooldown = -1;
public static TreeMap<Long, BlockData> blocksClicked = new TreeMap<>();
@@ -89,7 +94,8 @@ public class ItemCooldowns {
enum Item {
PICKAXES,
BONZO_MASK,
- SPIRIT_MASK
+ SPIRIT_MASK,
+ SPRAYONATOR
}
@SubscribeEvent
@@ -100,6 +106,7 @@ public class ItemCooldowns {
pickaxeCooldown = -1;
bonzoMaskCooldown = -1;
spiritMaskCooldown = -1;
+ sprayonatorCooldown = -1;
}
long currentTime = System.currentTimeMillis();
@@ -130,6 +137,9 @@ public class ItemCooldowns {
if (spiritMaskCooldownMillisRemaining >= 0) {
spiritMaskCooldownMillisRemaining -= millisDelta;
}
+ if (sprayonatorCooldownMillisRemaining >= 0) {
+ sprayonatorCooldownMillisRemaining -= millisDelta;
+ }
}
}
@@ -210,22 +220,28 @@ public class ItemCooldowns {
@SubscribeEvent
public void onChatMessage(ClientChatReceivedEvent event) {
- if (PICKAXE_ABILITY_ACTIVATION.matcher(event.message.getFormattedText()).matches() && pickaxeCooldown != 0) {
+ if (pickaxeCooldown != 0 && PICKAXE_ABILITY_ACTIVATION.matcher(event.message.getFormattedText()).matches()) {
findCooldownInTooltip(Item.PICKAXES);
pickaxeUseCooldownMillisRemaining = pickaxeCooldown * 1000;
}
- if (BONZO_ABILITY_ACTIVATION.matcher(event.message.getFormattedText()).matches() &&
- NotEnoughUpdates.INSTANCE.config.itemOverlays.bonzoAbility && bonzoMaskCooldown != 0) {
+ if (NotEnoughUpdates.INSTANCE.config.itemOverlays.bonzoAbility && bonzoMaskCooldown != 0 &&
+ BONZO_ABILITY_ACTIVATION.matcher(event.message.getFormattedText()).matches()) {
findCooldownInTooltip(Item.BONZO_MASK);
bonzomaskCooldownMillisRemaining = bonzoMaskCooldown * 1000;
}
- if (SPIRIT_ABILITY_ACTIVATION.matcher(event.message.getFormattedText()).matches() &&
- NotEnoughUpdates.INSTANCE.config.itemOverlays.spiritAbility && spiritMaskCooldown != 0) {
+ if (NotEnoughUpdates.INSTANCE.config.itemOverlays.spiritAbility && spiritMaskCooldown != 0 &&
+ SPIRIT_ABILITY_ACTIVATION.matcher(event.message.getFormattedText()).matches()) {
findCooldownInTooltip(Item.SPIRIT_MASK);
spiritMaskCooldownMillisRemaining = spiritMaskCooldown * 1000;
}
+
+ if (NotEnoughUpdates.INSTANCE.config.garden.sprayonatorCooldown && sprayonatorCooldown != 0 &&
+ SPRAYONATOR_ACTIVATION.matcher(event.message.getFormattedText()).matches()) {
+ findCooldownInTooltip(Item.SPIRIT_MASK);
+ sprayonatorCooldownMillisRemaining = sprayonatorCooldown * 1000;
+ }
}
private static void findCooldownInTooltip(Item item) {
@@ -254,6 +270,9 @@ public class ItemCooldowns {
case SPIRIT_MASK:
if (internalname.equals("SPIRIT_MASK") || internalname.equals("STARRED_SPIRIT_MASK")) spiritMaskCooldown = setCooldown(stack);
break;
+ case SPRAYONATOR:
+ if (internalname.equals("SPRAYONATOR")) sprayonatorCooldown = setCooldown(stack);
+ break;
}
}
}
@@ -311,18 +330,25 @@ public class ItemCooldowns {
return durability;
}
// Bonzo Mask
- if ((internalname.equals("BONZO_MASK") || internalname.equals("STARRED_BONZO_MASK")) && NotEnoughUpdates.INSTANCE.config.itemOverlays.bonzoAbility) {
+ if (NotEnoughUpdates.INSTANCE.config.itemOverlays.bonzoAbility &&
+ (internalname.equals("BONZO_MASK") || internalname.equals("STARRED_BONZO_MASK"))) {
findCooldownInTooltip(Item.BONZO_MASK);
return durabilityOverride(bonzomaskCooldownMillisRemaining, bonzoMaskCooldown, stack);
}
// Spirit Mask
- if (internalname.equals("SPIRIT_MASK") && NotEnoughUpdates.INSTANCE.config.itemOverlays.spiritAbility) {
+ if (NotEnoughUpdates.INSTANCE.config.itemOverlays.spiritAbility && internalname.equals("SPIRIT_MASK")) {
findCooldownInTooltip(Item.SPIRIT_MASK);
return durabilityOverride(spiritMaskCooldownMillisRemaining, spiritMaskCooldown, stack);
}
+ if (NotEnoughUpdates.INSTANCE.config.garden.sprayonatorCooldown && internalname.equals("SPRAYONATOR")) {
+ findCooldownInTooltip(Item.SPRAYONATOR);
+
+ return durabilityOverride(sprayonatorCooldownMillisRemaining, sprayonatorCooldown, stack);
+ }
+
durabilityOverrideMap.put(stack, -1f);
return -1;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/Garden.java b/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/Garden.java
index 77c40a30..bc3475c2 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/Garden.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/Garden.java
@@ -39,4 +39,12 @@ public class Garden {
)
@ConfigEditorBoolean
public boolean presetDeleteWarning = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Sprayonator Cooldown",
+ desc = "Show the cooldown duration of the sprayonator."
+ )
+ @ConfigEditorBoolean
+ public boolean sprayonatorCooldown = false;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/ItemOverlays.java b/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/ItemOverlays.java
index a5cd6cb7..84a63022 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/ItemOverlays.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/ItemOverlays.java
@@ -473,7 +473,7 @@ public class ItemOverlays {
@Expose
@ConfigOption(
name = "Pickaxe Ability Cooldown",
- desc = "Show the cooldown duration of the pickaxe ability as the durability."
+ desc = "Show the cooldown duration of the pickaxe ability."
)
@ConfigEditorBoolean
public boolean pickaxeAbility = true;
@@ -481,7 +481,7 @@ public class ItemOverlays {
@Expose
@ConfigOption(
name = "Bonzo Mask Ability Cooldown",
- desc = "Show the cooldown duration of a bonzo mask ability as the durability."
+ desc = "Show the cooldown duration of a bonzo mask ability."
)
@ConfigEditorBoolean
public boolean bonzoAbility = true;
@@ -489,7 +489,7 @@ public class ItemOverlays {
@Expose
@ConfigOption(
name = "Spirit Mask Ability Cooldown",
- desc = "Show the cooldown duration of the spirit mask ability as the durability."
+ desc = "Show the cooldown duration of the spirit mask ability."
)
@ConfigEditorBoolean
public boolean spiritAbility = true;