From 4aad7fa929f8e058b7215b4a320ce6fa8a0851a7 Mon Sep 17 00:00:00 2001 From: Brianna Date: Fri, 8 May 2020 17:04:01 -0400 Subject: [PATCH] Disable meta carry over on grinders to improve performance. --- .../com/songoda/ultimatestacker/entity/EntityStack.java | 5 ++++- .../com/songoda/ultimatestacker/settings/Settings.java | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/ultimatestacker/entity/EntityStack.java b/src/main/java/com/songoda/ultimatestacker/entity/EntityStack.java index 9c442f7..9c0d9d0 100644 --- a/src/main/java/com/songoda/ultimatestacker/entity/EntityStack.java +++ b/src/main/java/com/songoda/ultimatestacker/entity/EntityStack.java @@ -175,10 +175,13 @@ public class EntityStack { } } + static final int metaCarryOverMin = Settings.META_CARRY_OVER_MIN.getInt() * 20; + public Map getMetadata(LivingEntity subject) { Map v = new HashMap<>(); + if (subject.getTicksLived() >= metaCarryOverMin) return v; - Map> metadataMap = null; + Map> metadataMap = null; try { Object entityMetadata = methodGetEntityMetadata.invoke(Bukkit.getServer()); metadataMap = (Map) fieldMetadataMap.get(entityMetadata); diff --git a/src/main/java/com/songoda/ultimatestacker/settings/Settings.java b/src/main/java/com/songoda/ultimatestacker/settings/Settings.java index 428daae..34ccfaa 100644 --- a/src/main/java/com/songoda/ultimatestacker/settings/Settings.java +++ b/src/main/java/com/songoda/ultimatestacker/settings/Settings.java @@ -145,6 +145,13 @@ public class Settings { "With this enabled any metadata assigned from supported plugins such", "as EpicSpawners and mcMMO will be preserved when the entity is killed."); + public static final ConfigSetting META_CARRY_OVER_MIN = new ConfigSetting(config, "Entities.Meta Carry Over Min", 10, + "The amount of time in seconds an entity needs to have lived", + "for in order for their metadata to be carried over to their next", + "stack on death. Setting this value to zero may improve compatibility", + "with other plugins but this will be at the cost of performance if you", + "have a lot of grinders on your server."); + public static final ConfigSetting WEAPONS_ARENT_EQUIPMENT = new ConfigSetting(config, "Entities.Weapons Arent Equipment", false, "This allows entities holding weapons to stack. Enchanted weapons are excluded.", "If you would like to disable the stacked entity check you can do that by removing",