From 85ee6a843d966818d0a07b814b7853a693cb56d4 Mon Sep 17 00:00:00 2001 From: Shyanne Date: Sun, 29 Dec 2024 02:43:01 -0500 Subject: [PATCH] fixed spawner runaway (exponential) (very scary) --- .../java/com/iridium/iridiumteams/configs/Enhancements.java | 6 +++--- .../iridiumteams/enhancements/SpawnerEnhancementData.java | 4 +++- .../iridiumteams/listeners/SpawnerSpawnListener.java | 3 +++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iridium/iridiumteams/configs/Enhancements.java b/src/main/java/com/iridium/iridiumteams/configs/Enhancements.java index 1a24fe6c..b0d84f72 100755 --- a/src/main/java/com/iridium/iridiumteams/configs/Enhancements.java +++ b/src/main/java/com/iridium/iridiumteams/configs/Enhancements.java @@ -54,9 +54,9 @@ public Enhancements(String color) { color + "[!] &7Must be level %minLevel% to purchase", color + "&l[!] " + color + "Left Click to Purchase Level %next_level%." )), new ImmutableMap.Builder() - .put(1, new SpawnerEnhancementData(5, 10000, new HashMap<>(), 6, 0)) - .put(2, new SpawnerEnhancementData(10, 10000, new HashMap<>(), 8, 0)) - .put(3, new SpawnerEnhancementData(15, 10000, new HashMap<>(), 10, 0)) + .put(1, new SpawnerEnhancementData(5, 10000, new HashMap<>(), 6, 0, 800)) + .put(2, new SpawnerEnhancementData(10, 10000, new HashMap<>(), 8, 0, 600)) + .put(3, new SpawnerEnhancementData(15, 10000, new HashMap<>(), 10, 0, 400)) .build()); experienceEnhancement = new Enhancement<>(true, EnhancementType.BOOSTER, new Item(XMaterial.EXPERIENCE_BOTTLE, 14, 1, color + "&lExperience Booster", Arrays.asList( diff --git a/src/main/java/com/iridium/iridiumteams/enhancements/SpawnerEnhancementData.java b/src/main/java/com/iridium/iridiumteams/enhancements/SpawnerEnhancementData.java index be1f7f67..b8c33b03 100755 --- a/src/main/java/com/iridium/iridiumteams/enhancements/SpawnerEnhancementData.java +++ b/src/main/java/com/iridium/iridiumteams/enhancements/SpawnerEnhancementData.java @@ -8,10 +8,12 @@ public class SpawnerEnhancementData extends EnhancementData { public int spawnCount; public int spawnMultiplier; + public int spawnDelay; - public SpawnerEnhancementData(int minLevel, int money, Map bankCosts, int spawnCount, int spawnMultiplier) { + public SpawnerEnhancementData(int minLevel, int money, Map bankCosts, int spawnCount, int spawnMultiplier, int spawnDelay) { super(minLevel, money, bankCosts); this.spawnCount = spawnCount; this.spawnMultiplier = spawnMultiplier; + this.spawnDelay = spawnDelay; } } diff --git a/src/main/java/com/iridium/iridiumteams/listeners/SpawnerSpawnListener.java b/src/main/java/com/iridium/iridiumteams/listeners/SpawnerSpawnListener.java index 0a4161c3..e72bad64 100755 --- a/src/main/java/com/iridium/iridiumteams/listeners/SpawnerSpawnListener.java +++ b/src/main/java/com/iridium/iridiumteams/listeners/SpawnerSpawnListener.java @@ -28,8 +28,11 @@ public void onCreatureSpawn(SpawnerSpawnEvent event) { if (!teamEnhancement.isActive(spawnerEnhancement.type)) return; if (data == null) return; + int spawnCount = spawner.getSpawnCount(); spawner.setSpawnCount((spawner.getSpawnCount() * data.spawnMultiplier) + data.spawnCount); + if(spawner.getMaxSpawnDelay() != data.spawnDelay) { spawner.setMaxSpawnDelay(data.spawnDelay); } spawner.update(true); + spawner.setSpawnCount(spawnCount); }); } }