mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Messy fix for now, code cleanup will happen later
This commit is contained in:
parent
29722511b7
commit
bc71f586d7
@ -1,5 +1,5 @@
|
|||||||
Version 2.1.149
|
Version 2.1.149
|
||||||
Added new config file 'persistentdata.yml'
|
Added new config file 'persistent_data.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
|
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:
|
NOTES:
|
||||||
@ -8,6 +8,9 @@ Version 2.1.149
|
|||||||
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.
|
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.
|
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.
|
||||||
|
|
||||||
|
For now it is not recommended to use persistent data without monitoring performance of ticks afterwards to make sure it was something your server could handle.
|
||||||
|
I have a solution in mind to make persistent data not so expensive, but writing the code for that will take some time. This will serve as an interim fix.
|
||||||
|
|
||||||
Version 2.1.148
|
Version 2.1.148
|
||||||
Fixed a memory leak involving entity metadata
|
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)
|
Alchemy progression is now more reasonable (delete skillranks.yml or edit it yourself to receive the change, see notes)
|
||||||
|
@ -6,7 +6,7 @@ public class PersistentDataConfig extends AutoUpdateConfigLoader {
|
|||||||
private static PersistentDataConfig instance;
|
private static PersistentDataConfig instance;
|
||||||
|
|
||||||
private PersistentDataConfig() {
|
private PersistentDataConfig() {
|
||||||
super("persistentdata.yml");
|
super("persistent_data.yml");
|
||||||
validate();
|
validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,9 +29,9 @@ public class PersistentDataConfig extends AutoUpdateConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Persistent Data Toggles
|
//Persistent Data Toggles
|
||||||
|
|
||||||
public boolean isMobPersistent(MobMetaFlagType mobMetaFlagType) {
|
public boolean isMobPersistent(MobMetaFlagType mobMetaFlagType) {
|
||||||
String key = "Persistent_Data.Mobs.Flags." + mobMetaFlagType.toString() + ".Saved_To_Disk";
|
String key = "Persistent_Data.Mobs.Flags." + mobMetaFlagType.toString() + ".Saved_To_Disk";
|
||||||
return config.getBoolean(key, false);
|
return config.getBoolean(key, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.util.compat.layers.persistentdata;
|
package com.gmail.nossr50.util.compat.layers.persistentdata;
|
||||||
|
|
||||||
import com.gmail.nossr50.api.exceptions.IncompleteNamespacedKeyRegister;
|
import com.gmail.nossr50.api.exceptions.IncompleteNamespacedKeyRegister;
|
||||||
|
import com.gmail.nossr50.config.PersistentDataConfig;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
@ -69,13 +70,17 @@ public class SpigotPersistentDataLayer_1_14 extends AbstractPersistentDataLayer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasMobFlag(@NotNull MobMetaFlagType flag, @NotNull LivingEntity livingEntity) {
|
public boolean hasMobFlag(@NotNull MobMetaFlagType flag, @NotNull LivingEntity livingEntity) {
|
||||||
return livingEntity.getPersistentDataContainer().has(mobFlagKeyMap.get(flag), PersistentDataType.BYTE);
|
if(PersistentDataConfig.getInstance().isMobPersistent(flag)) {
|
||||||
|
return livingEntity.getPersistentDataContainer().has(mobFlagKeyMap.get(flag), PersistentDataType.BYTE);
|
||||||
|
} else {
|
||||||
|
return transientLayer.hasMobFlag(flag, livingEntity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasMobFlags(@NotNull LivingEntity livingEntity) {
|
public boolean hasMobFlags(@NotNull LivingEntity livingEntity) {
|
||||||
for(NamespacedKey currentKey : mobFlagKeyMap.values()) {
|
for(MobMetaFlagType currentFlag : MobMetaFlagType.values()) {
|
||||||
if(livingEntity.getPersistentDataContainer().has(currentKey, PersistentDataType.BYTE)) {
|
if(hasMobFlag(currentFlag, livingEntity)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,17 +99,25 @@ public class SpigotPersistentDataLayer_1_14 extends AbstractPersistentDataLayer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void flagMetadata(@NotNull MobMetaFlagType flag, @NotNull LivingEntity livingEntity) {
|
public void flagMetadata(@NotNull MobMetaFlagType flag, @NotNull LivingEntity livingEntity) {
|
||||||
if(!hasMobFlag(flag, livingEntity)) {
|
if(PersistentDataConfig.getInstance().isMobPersistent(flag)) {
|
||||||
PersistentDataContainer persistentDataContainer = livingEntity.getPersistentDataContainer();
|
if(!hasMobFlag(flag, livingEntity)) {
|
||||||
persistentDataContainer.set(mobFlagKeyMap.get(flag), PersistentDataType.BYTE, SIMPLE_FLAG_VALUE);
|
PersistentDataContainer persistentDataContainer = livingEntity.getPersistentDataContainer();
|
||||||
|
persistentDataContainer.set(mobFlagKeyMap.get(flag), PersistentDataType.BYTE, SIMPLE_FLAG_VALUE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
transientLayer.flagMetadata(flag, livingEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeMobFlag(@NotNull MobMetaFlagType flag, @NotNull LivingEntity livingEntity) {
|
public void removeMobFlag(@NotNull MobMetaFlagType flag, @NotNull LivingEntity livingEntity) {
|
||||||
if(hasMobFlag(flag, livingEntity)) {
|
if(PersistentDataConfig.getInstance().isMobPersistent(flag)) {
|
||||||
PersistentDataContainer persistentDataContainer = livingEntity.getPersistentDataContainer();
|
if(hasMobFlag(flag, livingEntity)) {
|
||||||
persistentDataContainer.remove(mobFlagKeyMap.get(flag));
|
PersistentDataContainer persistentDataContainer = livingEntity.getPersistentDataContainer();
|
||||||
|
persistentDataContainer.remove(mobFlagKeyMap.get(flag));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
transientLayer.removeMobFlag(flag, livingEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
# 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)
|
# 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
|
# 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.
|
# 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.
|
||||||
|
#
|
||||||
|
# I am considering alternative to using Spigots NBT API to avoid this performance cost, but the code for those will take some time to write and test, for now it is not recommended
|
||||||
|
# to turn any of these settings on without monitoring the TPS of your server afterwards. With the exception of the COTW setting which will probably have almost no performance impact if left on.
|
||||||
Persistent_Data:
|
Persistent_Data:
|
||||||
Mobs:
|
Mobs:
|
||||||
Flags:
|
Flags:
|
Loading…
Reference in New Issue
Block a user