add data_type:simple

This commit is contained in:
Xanadu13
2024-03-18 16:26:42 +08:00
parent 7ed7122c8e
commit 9b1c81fd6d
@@ -6,11 +6,12 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import pers.xanadu.enderdragon.gui.GUISlot; import pers.xanadu.enderdragon.gui.GUISlot;
import pers.xanadu.enderdragon.gui.GUISlotType; import pers.xanadu.enderdragon.gui.GUISlotType;
import pers.xanadu.enderdragon.manager.ItemManager;
import static pers.xanadu.enderdragon.manager.ItemManager.*; import static pers.xanadu.enderdragon.manager.ItemManager.*;
public class TipSlot extends GUISlot { public class TipSlot extends GUISlot {
private ItemStack item; private final ItemStack item;
protected boolean hasDisableMode; protected boolean hasDisableMode;
protected ItemStack itemOnDisable; protected ItemStack itemOnDisable;
@@ -18,6 +19,7 @@ public class TipSlot extends GUISlot {
super(slotType); super(slotType);
this.item = new ItemStack(material); this.item = new ItemStack(material);
ItemMeta meta = this.item.getItemMeta(); ItemMeta meta = this.item.getItemMeta();
assert meta != null;
meta.setDisplayName(str); meta.setDisplayName(str);
this.item.setItemMeta(meta); this.item.setItemMeta(meta);
} }
@@ -28,22 +30,25 @@ public class TipSlot extends GUISlot {
this.hasDisableMode = true; this.hasDisableMode = true;
} }
else this.hasDisableMode = false; else this.hasDisableMode = false;
if(hasDisableMode){ this.data_type = DataType.fromString(section.getString("data_type"));
if(data_type == DataType.NBT) this.itemOnDisable = readFromNBT(section,"data_disable"); switch (data_type) {
else this.itemOnDisable = readFromBukkit(section,"data_disable"); case NBT:
} ItemManager.getLegacy().compareAndSet(false,true);
String data_type = section.getString("data_type"); this.item = readFromNBT(section,"data");
if("nbt".equals(data_type)) { if(hasDisableMode) this.itemOnDisable = readFromNBT(section,"data_disable");
this.data_type = DataType.NBT; break;
this.item = readFromNBT(section,"data"); case ADVANCED:
} ItemManager.getLegacy().compareAndSet(false,true);
else if("advanced".equals(data_type)){ this.item = readFromAdvData(section,"data");
this.data_type = DataType.ADVANCED; if(hasDisableMode) this.itemOnDisable = readFromAdvData(section,"data_disable");
this.item = readFromAdvData(section,"data"); break;
} case SIMPLE:
else { this.item = readFromSimple(section,"data");
this.data_type = DataType.DEFAULT; if(hasDisableMode) this.itemOnDisable = readFromSimple(section,"data_disable");
this.item = readFromBukkit(section,"data"); break;
default:
this.item = readFromBukkit(section,"data");
if(hasDisableMode) this.itemOnDisable = readFromBukkit(section,"data_disable");
} }
} }