2021-09-30 00:56:49 -05:00
|
|
|
//
|
|
|
|
|
// Source code recreated from a .class file by IntelliJ IDEA
|
|
|
|
|
// (powered by Fernflower decompiler)
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
package noppes.npcs.controllers.data;
|
|
|
|
|
|
2021-09-30 21:44:30 -05:00
|
|
|
import java.lang.reflect.Array;
|
|
|
|
|
import java.util.*;
|
2021-09-30 00:56:49 -05:00
|
|
|
import java.util.Map.Entry;
|
2021-09-30 21:44:30 -05:00
|
|
|
|
|
|
|
|
import com.google.common.base.Preconditions;
|
2021-10-11 06:49:30 -05:00
|
|
|
import net.minecraft.entity.Entity;
|
2021-09-30 00:56:49 -05:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2021-10-11 06:49:30 -05:00
|
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
2021-09-30 00:56:49 -05:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
|
import cpw.mods.fml.common.eventhandler.Event;
|
2021-10-11 06:49:30 -05:00
|
|
|
import net.minecraft.world.WorldServer;
|
2021-09-30 00:56:49 -05:00
|
|
|
import noppes.npcs.EventHooks;
|
2021-10-17 16:11:29 -05:00
|
|
|
import noppes.npcs.EventScriptContainer;
|
2021-09-30 00:56:49 -05:00
|
|
|
import noppes.npcs.NBTTags;
|
2021-10-21 22:14:12 -05:00
|
|
|
import noppes.npcs.controllers.PlayerData;
|
|
|
|
|
import noppes.npcs.scripted.NpcAPI;
|
2021-10-18 06:33:39 -05:00
|
|
|
import noppes.npcs.scripted.entity.ScriptPlayer;
|
2021-09-30 00:56:49 -05:00
|
|
|
import noppes.npcs.constants.EnumScriptType;
|
|
|
|
|
import noppes.npcs.controllers.IScriptHandler;
|
|
|
|
|
import noppes.npcs.controllers.ScriptController;
|
2021-10-11 06:49:30 -05:00
|
|
|
import noppes.npcs.scripted.ScriptWorld;
|
|
|
|
|
import noppes.npcs.scripted.event.PlayerEvent;
|
2021-10-21 22:14:12 -05:00
|
|
|
import noppes.npcs.scripted.interfaces.IPlayer;
|
|
|
|
|
import noppes.npcs.scripted.interfaces.IWorld;
|
2021-10-18 06:33:39 -05:00
|
|
|
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
2021-09-30 00:56:49 -05:00
|
|
|
|
2021-09-30 21:44:30 -05:00
|
|
|
import javax.annotation.CheckForNull;
|
2021-10-11 06:49:30 -05:00
|
|
|
import javax.script.ScriptEngine;
|
2021-09-30 21:44:30 -05:00
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
public class PlayerDataScript implements IScriptHandler {
|
2021-10-17 16:11:29 -05:00
|
|
|
public List<EventScriptContainer> scripts = new ArrayList();
|
2021-10-11 06:49:30 -05:00
|
|
|
public String scriptLanguage = "ECMAScript";
|
2021-09-30 00:56:49 -05:00
|
|
|
private EntityPlayer player;
|
2021-10-21 22:14:12 -05:00
|
|
|
private IPlayer playerAPI;
|
2021-09-30 00:56:49 -05:00
|
|
|
private long lastPlayerUpdate = 0L;
|
|
|
|
|
public long lastInited = -1L;
|
|
|
|
|
public boolean hadInteract = true;
|
2021-10-15 09:17:31 -05:00
|
|
|
public boolean enabled = false;
|
2021-10-17 16:11:29 -05:00
|
|
|
private Map<Long, String> console = new TreeMap();
|
|
|
|
|
public List<Integer> errored = new ArrayList();
|
2021-09-30 00:56:49 -05:00
|
|
|
|
2021-10-21 22:14:12 -05:00
|
|
|
public IPlayer dummyPlayer;
|
|
|
|
|
public IWorld dummyWorld;
|
2021-10-11 06:49:30 -05:00
|
|
|
|
|
|
|
|
public PlayerDataScript(EntityPlayer player) {
|
|
|
|
|
if(player != null) {
|
|
|
|
|
this.player = player;
|
|
|
|
|
if (player instanceof EntityPlayer)
|
2021-10-21 22:14:12 -05:00
|
|
|
dummyPlayer = (IPlayer) ScriptController.Instance.getScriptForEntity(this.player);
|
2021-10-11 06:49:30 -05:00
|
|
|
if (player.worldObj instanceof WorldServer)
|
2021-10-21 22:14:12 -05:00
|
|
|
dummyWorld = (IWorld) NpcAPI.Instance().getIWorld((WorldServer) this.player.worldObj);
|
2021-10-11 06:49:30 -05:00
|
|
|
}
|
2021-09-30 00:56:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void clear() {
|
2021-10-17 16:11:29 -05:00
|
|
|
this.console = new TreeMap();
|
|
|
|
|
this.errored = new ArrayList();
|
2021-09-30 00:56:49 -05:00
|
|
|
this.scripts = new ArrayList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void readFromNBT(NBTTagCompound compound) {
|
2021-09-30 01:48:54 -05:00
|
|
|
this.scripts = NBTTags.GetScript(compound.getTagList("Scripts", 10), this);
|
|
|
|
|
this.scriptLanguage = compound.getString("ScriptLanguage");
|
|
|
|
|
this.enabled = compound.getBoolean("ScriptEnabled");
|
2021-10-17 16:11:29 -05:00
|
|
|
this.console = NBTTags.GetLongStringMap(compound.getTagList("ScriptConsole", 10));
|
2021-09-30 00:56:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
2021-09-30 01:48:54 -05:00
|
|
|
compound.setTag("Scripts", NBTTags.NBTScript(this.scripts));
|
|
|
|
|
compound.setString("ScriptLanguage", this.scriptLanguage);
|
|
|
|
|
compound.setBoolean("ScriptEnabled", this.enabled);
|
2021-10-17 16:11:29 -05:00
|
|
|
compound.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.console));
|
2021-09-30 00:56:49 -05:00
|
|
|
return compound;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
public void callScript(EnumScriptType type, Event event, Object... obs) {
|
2021-09-30 00:56:49 -05:00
|
|
|
if(this.isEnabled()) {
|
2021-10-17 16:11:29 -05:00
|
|
|
EventScriptContainer script;
|
2021-09-30 00:56:49 -05:00
|
|
|
if(ScriptController.Instance.lastLoaded > this.lastInited || ScriptController.Instance.lastPlayerUpdate > this.lastPlayerUpdate) {
|
|
|
|
|
this.lastInited = ScriptController.Instance.lastLoaded;
|
2021-10-17 16:11:29 -05:00
|
|
|
//ScriptController.Instance.playerScripts.errored.clear();
|
2021-09-30 00:56:49 -05:00
|
|
|
if(this.player != null) {
|
|
|
|
|
this.scripts.clear();
|
|
|
|
|
Iterator i = ScriptController.Instance.playerScripts.scripts.iterator();
|
|
|
|
|
|
|
|
|
|
while(i.hasNext()) {
|
2021-10-17 16:11:29 -05:00
|
|
|
script = (EventScriptContainer)i.next();
|
|
|
|
|
EventScriptContainer s = new EventScriptContainer(this);
|
2021-09-30 00:56:49 -05:00
|
|
|
s.readFromNBT(script.writeToNBT(new NBTTagCompound()));
|
2021-10-11 06:49:30 -05:00
|
|
|
|
2021-09-30 00:56:49 -05:00
|
|
|
this.scripts.add(s);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.lastPlayerUpdate = ScriptController.Instance.lastPlayerUpdate;
|
|
|
|
|
if(type != EnumScriptType.INIT) {
|
|
|
|
|
EventHooks.onPlayerInit(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(int var7 = 0; var7 < this.scripts.size(); ++var7) {
|
2021-10-17 16:11:29 -05:00
|
|
|
script = (EventScriptContainer)this.scripts.get(var7);
|
2021-09-30 00:56:49 -05:00
|
|
|
|
2021-10-17 16:11:29 -05:00
|
|
|
if(!ScriptController.Instance.playerScripts.errored.contains(Integer.valueOf(var7))) {
|
2021-10-11 06:49:30 -05:00
|
|
|
if(script == null || script.errored || !script.hasCode())
|
|
|
|
|
return;
|
|
|
|
|
script.setEngine(scriptLanguage);
|
|
|
|
|
if(script.engine == null)
|
|
|
|
|
return;
|
|
|
|
|
for(int i = 0; i + 1 < obs.length; i += 2){
|
|
|
|
|
Object ob = obs[i + 1];
|
|
|
|
|
if(ob instanceof Entity)
|
|
|
|
|
ob = ScriptController.Instance.getScriptForEntity((Entity)ob);
|
|
|
|
|
script.engine.put(obs[i].toString(), ob);
|
2021-09-30 00:56:49 -05:00
|
|
|
}
|
|
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
ScriptEngine engine = script.engine;
|
|
|
|
|
engine.put("world", dummyWorld);
|
2021-10-21 22:14:12 -05:00
|
|
|
engine.put("player", dummyPlayer);
|
2021-10-11 06:49:30 -05:00
|
|
|
PlayerEvent result = (PlayerEvent) engine.get("event");
|
|
|
|
|
if(result == null)
|
|
|
|
|
engine.put("event", result = new PlayerEvent(this.getPlayer()));
|
2021-10-18 06:33:39 -05:00
|
|
|
script.engine.put("API", new WrapperNpcAPI());
|
2021-10-18 22:01:15 -05:00
|
|
|
script.run(type, event);
|
2021-10-17 16:11:29 -05:00
|
|
|
|
|
|
|
|
if (script.errored) {
|
|
|
|
|
ScriptController.Instance.playerScripts.errored.add(var7);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Iterator var8 = script.console.entrySet().iterator();
|
|
|
|
|
|
|
|
|
|
while(var8.hasNext()) {
|
|
|
|
|
Entry<Long, String> entry = (Entry)var8.next();
|
|
|
|
|
if (!ScriptController.Instance.playerScripts.console.containsKey(entry.getKey())) {
|
|
|
|
|
ScriptController.Instance.playerScripts.console.put(entry.getKey(), " tab " + (var7 + 1) + ":\n" + (String)entry.getValue());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
script.console.clear();
|
2021-09-30 00:56:49 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isEnabled() {
|
2021-09-30 01:48:54 -05:00
|
|
|
return ScriptController.Instance.playerScripts.enabled && ScriptController.HasStart && (this.player == null || !this.player.worldObj.isRemote);
|
2021-09-30 00:56:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isClient() {
|
2021-09-30 01:48:54 -05:00
|
|
|
return this.player.isClientWorld();
|
2021-09-30 00:56:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean getEnabled() {
|
|
|
|
|
return ScriptController.Instance.playerScripts.enabled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setEnabled(boolean bo) {
|
2021-10-15 09:17:31 -05:00
|
|
|
ScriptController.Instance.playerScripts.enabled = bo;
|
2021-09-30 00:56:49 -05:00
|
|
|
this.enabled = bo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getLanguage() {
|
|
|
|
|
return ScriptController.Instance.playerScripts.scriptLanguage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setLanguage(String lang) {
|
|
|
|
|
this.scriptLanguage = lang;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-17 16:11:29 -05:00
|
|
|
public List<EventScriptContainer> getScripts() {
|
2021-09-30 00:56:49 -05:00
|
|
|
return this.scripts;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-17 16:11:29 -05:00
|
|
|
public String noticeString() {
|
|
|
|
|
if(this.player == null) {
|
|
|
|
|
return "Global script";
|
|
|
|
|
} else {
|
|
|
|
|
BlockPos pos = new BlockPos(this.player);
|
|
|
|
|
return PlayerDataScript.toStringHelper(this.player).add("x", pos.getX()).add("y", pos.getY()).add("z", pos.getZ()).toString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-21 22:14:12 -05:00
|
|
|
public IPlayer getPlayer() {
|
|
|
|
|
if (this.playerAPI == null) {
|
|
|
|
|
this.playerAPI = (IPlayer) NpcAPI.Instance().getIEntity(this.player);
|
2021-10-17 16:11:29 -05:00
|
|
|
}
|
2021-10-21 22:14:12 -05:00
|
|
|
|
2021-10-17 16:11:29 -05:00
|
|
|
return this.playerAPI;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map<Long, String> getConsoleText() {
|
|
|
|
|
return this.console;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void clearConsole() {
|
|
|
|
|
this.console.clear();
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-30 21:44:30 -05:00
|
|
|
public static final class ToStringHelper {
|
|
|
|
|
private final String className;
|
2021-10-11 06:49:30 -05:00
|
|
|
private final PlayerDataScript.ToStringHelper.ValueHolder holderHead;
|
|
|
|
|
private PlayerDataScript.ToStringHelper.ValueHolder holderTail;
|
2021-09-30 21:44:30 -05:00
|
|
|
private boolean omitNullValues;
|
|
|
|
|
private boolean omitEmptyValues;
|
|
|
|
|
|
|
|
|
|
private ToStringHelper(String className) {
|
2021-10-11 06:49:30 -05:00
|
|
|
this.holderHead = new PlayerDataScript.ToStringHelper.ValueHolder();
|
2021-09-30 21:44:30 -05:00
|
|
|
this.holderTail = this.holderHead;
|
|
|
|
|
this.omitNullValues = false;
|
|
|
|
|
this.omitEmptyValues = false;
|
|
|
|
|
this.className = (String) Preconditions.checkNotNull(className);
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
public PlayerDataScript.ToStringHelper omitNullValues() {
|
2021-09-30 21:44:30 -05:00
|
|
|
this.omitNullValues = true;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
public PlayerDataScript.ToStringHelper add(String name, @CheckForNull Object value) {
|
2021-09-30 21:44:30 -05:00
|
|
|
return this.addHolder(name, value);
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
public PlayerDataScript.ToStringHelper add(String name, boolean value) {
|
2021-09-30 21:44:30 -05:00
|
|
|
return this.addUnconditionalHolder(name, String.valueOf(value));
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
public PlayerDataScript.ToStringHelper add(String name, char value) {
|
2021-09-30 21:44:30 -05:00
|
|
|
return this.addUnconditionalHolder(name, String.valueOf(value));
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
public PlayerDataScript.ToStringHelper add(String name, double value) {
|
2021-09-30 21:44:30 -05:00
|
|
|
return this.addUnconditionalHolder(name, String.valueOf(value));
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
public PlayerDataScript.ToStringHelper add(String name, float value) {
|
2021-09-30 21:44:30 -05:00
|
|
|
return this.addUnconditionalHolder(name, String.valueOf(value));
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
public PlayerDataScript.ToStringHelper add(String name, int value) {
|
2021-09-30 21:44:30 -05:00
|
|
|
return this.addUnconditionalHolder(name, String.valueOf(value));
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
public PlayerDataScript.ToStringHelper add(String name, long value) {
|
2021-09-30 21:44:30 -05:00
|
|
|
return this.addUnconditionalHolder(name, String.valueOf(value));
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
public PlayerDataScript.ToStringHelper addValue(@CheckForNull Object value) {
|
2021-09-30 21:44:30 -05:00
|
|
|
return this.addHolder(value);
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
public PlayerDataScript.ToStringHelper addValue(boolean value) {
|
2021-09-30 21:44:30 -05:00
|
|
|
return this.addUnconditionalHolder(String.valueOf(value));
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
public PlayerDataScript.ToStringHelper addValue(char value) {
|
2021-09-30 21:44:30 -05:00
|
|
|
return this.addUnconditionalHolder(String.valueOf(value));
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
public PlayerDataScript.ToStringHelper addValue(double value) {
|
2021-09-30 21:44:30 -05:00
|
|
|
return this.addUnconditionalHolder(String.valueOf(value));
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
public PlayerDataScript.ToStringHelper addValue(float value) {
|
2021-09-30 21:44:30 -05:00
|
|
|
return this.addUnconditionalHolder(String.valueOf(value));
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
public PlayerDataScript.ToStringHelper addValue(int value) {
|
2021-09-30 21:44:30 -05:00
|
|
|
return this.addUnconditionalHolder(String.valueOf(value));
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
public PlayerDataScript.ToStringHelper addValue(long value) {
|
2021-09-30 21:44:30 -05:00
|
|
|
return this.addUnconditionalHolder(String.valueOf(value));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static boolean isEmpty(Object value) {
|
|
|
|
|
if (value instanceof CharSequence) {
|
|
|
|
|
return ((CharSequence)value).length() == 0;
|
|
|
|
|
} else if (value instanceof Collection) {
|
|
|
|
|
return ((Collection)value).isEmpty();
|
|
|
|
|
} else if (value instanceof Map) {
|
|
|
|
|
return ((Map)value).isEmpty();
|
|
|
|
|
} else if (value instanceof Optional) {
|
|
|
|
|
return !((Optional)value).isPresent();
|
|
|
|
|
} else if (value instanceof OptionalInt) {
|
|
|
|
|
return !((OptionalInt)value).isPresent();
|
|
|
|
|
} else if (value instanceof OptionalLong) {
|
|
|
|
|
return !((OptionalLong)value).isPresent();
|
|
|
|
|
} else if (value instanceof OptionalDouble) {
|
|
|
|
|
return !((OptionalDouble)value).isPresent();
|
|
|
|
|
} else if (value instanceof com.google.common.base.Optional) {
|
|
|
|
|
return !((com.google.common.base.Optional)value).isPresent();
|
|
|
|
|
} else if (value.getClass().isArray()) {
|
|
|
|
|
return Array.getLength(value) == 0;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String toString() {
|
|
|
|
|
boolean omitNullValuesSnapshot = this.omitNullValues;
|
|
|
|
|
boolean omitEmptyValuesSnapshot = this.omitEmptyValues;
|
|
|
|
|
String nextSeparator = "";
|
|
|
|
|
StringBuilder builder = (new StringBuilder(32)).append(this.className).append('{');
|
|
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
for(PlayerDataScript.ToStringHelper.ValueHolder valueHolder = this.holderHead.next; valueHolder != null; valueHolder = valueHolder.next) {
|
2021-09-30 21:44:30 -05:00
|
|
|
Object value = valueHolder.value;
|
2021-10-11 06:49:30 -05:00
|
|
|
if (!(valueHolder instanceof PlayerDataScript.ToStringHelper.UnconditionalValueHolder)) {
|
2021-09-30 21:44:30 -05:00
|
|
|
if (value == null) {
|
|
|
|
|
if (omitNullValuesSnapshot) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
} else if (omitEmptyValuesSnapshot && isEmpty(value)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
builder.append(nextSeparator);
|
|
|
|
|
nextSeparator = ", ";
|
|
|
|
|
if (valueHolder.name != null) {
|
|
|
|
|
builder.append(valueHolder.name).append('=');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (value != null && value.getClass().isArray()) {
|
|
|
|
|
Object[] objectArray = new Object[]{value};
|
|
|
|
|
String arrayString = Arrays.deepToString(objectArray);
|
|
|
|
|
builder.append(arrayString, 1, arrayString.length() - 1);
|
|
|
|
|
} else {
|
|
|
|
|
builder.append(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return builder.append('}').toString();
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
private PlayerDataScript.ToStringHelper.ValueHolder addHolder() {
|
|
|
|
|
PlayerDataScript.ToStringHelper.ValueHolder valueHolder = new PlayerDataScript.ToStringHelper.ValueHolder();
|
2021-09-30 21:44:30 -05:00
|
|
|
this.holderTail = this.holderTail.next = valueHolder;
|
|
|
|
|
return valueHolder;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
private PlayerDataScript.ToStringHelper addHolder(@CheckForNull Object value) {
|
|
|
|
|
PlayerDataScript.ToStringHelper.ValueHolder valueHolder = this.addHolder();
|
2021-09-30 21:44:30 -05:00
|
|
|
valueHolder.value = value;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
private PlayerDataScript.ToStringHelper addHolder(String name, @CheckForNull Object value) {
|
|
|
|
|
PlayerDataScript.ToStringHelper.ValueHolder valueHolder = this.addHolder();
|
2021-09-30 21:44:30 -05:00
|
|
|
valueHolder.value = value;
|
|
|
|
|
valueHolder.name = (String)Preconditions.checkNotNull(name);
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
private PlayerDataScript.ToStringHelper.UnconditionalValueHolder addUnconditionalHolder() {
|
|
|
|
|
PlayerDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = new PlayerDataScript.ToStringHelper.UnconditionalValueHolder();
|
2021-09-30 21:44:30 -05:00
|
|
|
this.holderTail = this.holderTail.next = valueHolder;
|
|
|
|
|
return valueHolder;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
private PlayerDataScript.ToStringHelper addUnconditionalHolder(Object value) {
|
|
|
|
|
PlayerDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = this.addUnconditionalHolder();
|
2021-09-30 21:44:30 -05:00
|
|
|
valueHolder.value = value;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
private PlayerDataScript.ToStringHelper addUnconditionalHolder(String name, Object value) {
|
|
|
|
|
PlayerDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = this.addUnconditionalHolder();
|
2021-09-30 21:44:30 -05:00
|
|
|
valueHolder.value = value;
|
|
|
|
|
valueHolder.name = (String)Preconditions.checkNotNull(name);
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
private static final class UnconditionalValueHolder extends PlayerDataScript.ToStringHelper.ValueHolder {
|
2021-09-30 21:44:30 -05:00
|
|
|
private UnconditionalValueHolder() {
|
|
|
|
|
super();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static class ValueHolder {
|
|
|
|
|
@CheckForNull
|
|
|
|
|
String name;
|
|
|
|
|
@CheckForNull
|
|
|
|
|
Object value;
|
|
|
|
|
@CheckForNull
|
2021-10-11 06:49:30 -05:00
|
|
|
PlayerDataScript.ToStringHelper.ValueHolder next;
|
2021-09-30 21:44:30 -05:00
|
|
|
|
|
|
|
|
private ValueHolder() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 06:49:30 -05:00
|
|
|
public static PlayerDataScript.ToStringHelper toStringHelper(Object self) {
|
|
|
|
|
return new PlayerDataScript.ToStringHelper(self.getClass().getSimpleName());
|
2021-09-30 21:44:30 -05:00
|
|
|
}
|
2021-09-30 00:56:49 -05:00
|
|
|
}
|