Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed spawner runaway (exponential) (very scary) #139

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<Integer, SpawnerEnhancementData>()
.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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Double> bankCosts, int spawnCount, int spawnMultiplier) {
public SpawnerEnhancementData(int minLevel, int money, Map<String, Double> bankCosts, int spawnCount, int spawnMultiplier, int spawnDelay) {
super(minLevel, money, bankCosts);
this.spawnCount = spawnCount;
this.spawnMultiplier = spawnMultiplier;
this.spawnDelay = spawnDelay;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Comment on lines +33 to 34
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if its not active, do we need to set it back to the default?

What is the default?

spawner.setSpawnCount(spawnCount);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work?

might be worth adding a comment explaining this.

And do we need to do a final .update for when its no longer active?

});
}
}
Loading