diff --git a/Changelog.txt b/Changelog.txt index 2af936383..f5f942c67 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,13 @@ +Version 2.1.149 + Added new config file 'persistentdata.yml' + Almost all persistent mob data is now off by default and needs to be turned on in persistentdata.yml (new config file) for performance concerns + + NOTES: + There are some performance issues with how mcMMO saves NBT when you start adding NBT to mobs, because of this I have decided that persistent data is opt-in. + Not every server will suffer from these issues, most probably will not, I am making it opt-in so only those aware of the performance risk will be using this feature. + Persistent data on mobs is a new feature that was introduced in 2.1.148, it was not in mcMMO for the last 10 years and most of you probably didn't even know that it was missing. + An example of persistent data would be, normally mcMMO would give 0 XP for a mob from a mob spawner, in the last 10 years if the server rebooted then those existing mobs would give XP again. But with the persistent data option turned on in persistentdata.yml they will be saved to disk, and mcMMO will not forget about them upon reboot. + Version 2.1.148 Fixed a memory leak involving entity metadata Alchemy progression is now more reasonable (delete skillranks.yml or edit it yourself to receive the change, see notes) diff --git a/pom.xml b/pom.xml index bc07c3d11..fed15ea34 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.148 + 2.1.149-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/config/PersistentDataConfig.java b/src/main/java/com/gmail/nossr50/config/PersistentDataConfig.java new file mode 100644 index 000000000..37de7605e --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/PersistentDataConfig.java @@ -0,0 +1,37 @@ +package com.gmail.nossr50.config; + +import com.gmail.nossr50.util.compat.layers.persistentdata.MobMetaFlagType; + +public class PersistentDataConfig extends AutoUpdateConfigLoader { + private static PersistentDataConfig instance; + + private PersistentDataConfig() { + super("persistentdata.yml"); + validate(); + } + + public static PersistentDataConfig getInstance() { + if (instance == null) { + instance = new PersistentDataConfig(); + } + + return instance; + } + + @Override + protected void loadKeys() { + //Sigh this old config system... + } + + @Override + protected boolean validateKeys() { + return true; + } + + //Persistent Data Toggles + + public boolean isMobPersistent(MobMetaFlagType mobMetaFlagType) { + String key = "Persistent_Data.Mobs.Flags." + mobMetaFlagType.toString() + ".Saved_To_Disk"; + return config.getBoolean(key, false); + } +} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/util/compat/layers/persistentdata/SpigotPersistentDataLayer_1_14.java b/src/main/java/com/gmail/nossr50/util/compat/layers/persistentdata/SpigotPersistentDataLayer_1_14.java index 9dd420890..00fd303cc 100644 --- a/src/main/java/com/gmail/nossr50/util/compat/layers/persistentdata/SpigotPersistentDataLayer_1_14.java +++ b/src/main/java/com/gmail/nossr50/util/compat/layers/persistentdata/SpigotPersistentDataLayer_1_14.java @@ -21,10 +21,12 @@ import java.util.UUID; public class SpigotPersistentDataLayer_1_14 extends AbstractPersistentDataLayer { private final @NotNull EnumMap mobFlagKeyMap; + private final @NotNull SpigotPersistentDataLayer_1_13 transientLayer; public SpigotPersistentDataLayer_1_14() { mobFlagKeyMap = new EnumMap<>(MobMetaFlagType.class); initMobFlagKeyMap(); + transientLayer = new SpigotPersistentDataLayer_1_13(); //For disabled persistent types } @Override diff --git a/src/main/resources/persistentdata.yml b/src/main/resources/persistentdata.yml new file mode 100644 index 000000000..6a37871c1 --- /dev/null +++ b/src/main/resources/persistentdata.yml @@ -0,0 +1,29 @@ +# This config allows servers to change which data is persistent and which data isn't +# For 10 years mcMMO had transient data (temporary) for a lot of things and recently in October 2020 I added the option to have things be persistent (saved to disk and permanently remembered) +# However, this is Minecraft, and Minecraft has a lot of entities, and when you start to make data persistent there is a performance cost associated with that +# Any option you turn on, is another thing your disk has to save when a chunk is being unloaded with that entity inside of it, Minecraft can quickly build up tens of thousands of entities so keep this in mind. +Persistent_Data: + Mobs: + Flags: + # By default mcMMO gives 0 XP for this type of mob, adjust in experience.yml + MOB_SPAWNER_MOB: + Saved_To_Disk: false + # By default mcMMO gives 0 XP for this type of mob, adjust in experience.yml + EGG_MOB: + Saved_To_Disk: false + # By default mcMMO gives 0 XP for this type of mob, adjust in experience.yml + NETHER_PORTAL_MOB: + Saved_To_Disk: false + # These mobs have low impact on performance and thus it is recommended you leave this on true + COTW_SUMMONED_MOB: + Saved_To_Disk: true + # By default mcMMO gives normal XP for player bred mobs, adjust in experience.yml + PLAYER_BRED_MOB: + Saved_To_Disk: false + # By default mcMMO gives 0 XP for this type of mob, due to an exploit in Minecraft you can spawn 1000 endermen in seconds using this trick. + # Adjust in experience.yml under the section labeled exploit fix + EXPLOITED_ENDERMEN: + Saved_To_Disk: false + # By default mcMMO gives 0 XP for this type of mob, not adjustable currently + PLAYER_TAMED_MOB: + Saved_To_Disk: false \ No newline at end of file