new config persistentdata.yml

This commit is contained in:
nossr50 2020-10-12 12:40:54 -07:00
parent 916eb76553
commit 29722511b7
5 changed files with 79 additions and 1 deletions

View File

@ -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)

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>2.1.148</version>
<version>2.1.149-SNAPSHOT</version>
<name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url>
<scm>

View File

@ -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);
}
}

View File

@ -21,10 +21,12 @@ import java.util.UUID;
public class SpigotPersistentDataLayer_1_14 extends AbstractPersistentDataLayer {
private final @NotNull EnumMap<MobMetaFlagType, NamespacedKey> 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

View File

@ -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