Delete src/main/java/pers/xanadu/enderdragon/gui directory
This commit is contained in:
@@ -1,203 +0,0 @@
|
||||
package pers.xanadu.enderdragon.gui;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import pers.xanadu.enderdragon.config.Lang;
|
||||
import pers.xanadu.enderdragon.gui.slot.DragonSlot;
|
||||
import pers.xanadu.enderdragon.manager.DragonManager;
|
||||
import pers.xanadu.enderdragon.manager.ItemManager;
|
||||
import pers.xanadu.enderdragon.gui.slot.EmptySlot;
|
||||
import pers.xanadu.enderdragon.gui.slot.ItemSlot;
|
||||
import pers.xanadu.enderdragon.reward.Reward;
|
||||
import pers.xanadu.enderdragon.util.MyDragon;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class GUI {
|
||||
protected String title;
|
||||
protected int maxPage;
|
||||
protected int page;
|
||||
protected int size;
|
||||
protected ArrayList<ItemStack[]> pagedItems;
|
||||
protected ArrayList<String[]> pagedData;
|
||||
protected List<GUISlot> slots;
|
||||
protected Inventory inv;
|
||||
protected HashSet<Integer> dynamics;
|
||||
|
||||
protected GUI(String str,int size,int maxPage){
|
||||
this.slots = new ArrayList<>();
|
||||
this.pagedItems = new ArrayList<>();
|
||||
this.pagedData = new ArrayList<>();
|
||||
this.dynamics = new HashSet<>();
|
||||
this.title = str;
|
||||
this.size = size;
|
||||
this.maxPage = maxPage;
|
||||
this.page = 0;
|
||||
}
|
||||
public GUISlot getSlot(int index){
|
||||
GUISlot slot = this.slots.get(index);
|
||||
if(slot == null) return new EmptySlot();
|
||||
return slot;
|
||||
}
|
||||
public void setPage(int a) {
|
||||
this.page = a;
|
||||
for(int i=0;i<this.slots.size();i++){
|
||||
GUISlot slot = this.slots.get(i);
|
||||
if (slot instanceof ItemSlot) {
|
||||
this.inv.setItem(i, new ItemStack(Material.AIR));
|
||||
}
|
||||
}
|
||||
if (this.pagedItems.isEmpty()) {
|
||||
this.pagedItems.add(new ItemStack[this.size]);
|
||||
}
|
||||
if (this.pagedData.isEmpty()) {
|
||||
this.pagedData.add(new String[this.size]);
|
||||
}
|
||||
ItemStack[] array = this.pagedItems.get(a);
|
||||
for(int i=0 ; i<array.length ; i++){
|
||||
ItemStack itemStack = array[i];
|
||||
if (itemStack != null) {
|
||||
this.inv.setItem(i, itemStack);
|
||||
}
|
||||
}
|
||||
for(Integer n2 : this.dynamics){
|
||||
GUISlotType type = this.getSlot(n2).getType();
|
||||
ItemStack clone;
|
||||
if(type == GUISlotType.PAGE_PREV){
|
||||
if(a == 0) clone = this.slots.get(n2).getItemOnDisable();
|
||||
else clone = this.slots.get(n2).getItem();
|
||||
this.inv.setItem(n2,clone);
|
||||
}
|
||||
else if(type == GUISlotType.PAGE_NEXT){
|
||||
if(a == this.pagedItems.size()-1) clone = this.slots.get(n2).getItemOnDisable();
|
||||
else clone = this.slots.get(n2).getItem();
|
||||
this.inv.setItem(n2,clone);
|
||||
}
|
||||
else if(type == GUISlotType.PAGE_TIP){
|
||||
clone = this.slots.get(n2).getItem().clone();
|
||||
ItemMeta itemMeta = clone.getItemMeta();
|
||||
if (itemMeta != null) {
|
||||
itemMeta.setDisplayName(String.format("§r%d/" + this.pagedItems.size(),a+1));
|
||||
clone.setItemMeta(itemMeta);
|
||||
this.inv.setItem(n2, clone);
|
||||
}
|
||||
}
|
||||
// else if(type == GUISlotType.PAGE_JUMP){
|
||||
// clone = this.slots.get(n2).getItem().clone();
|
||||
// this.inv.setItem(n2,clone);
|
||||
// }
|
||||
}
|
||||
}
|
||||
public Inventory current() {
|
||||
return this.inv;
|
||||
}
|
||||
public Inventory getInventory() {
|
||||
return this.inv;
|
||||
}
|
||||
protected void init() {
|
||||
for(int i=0;i<this.slots.size();i++){
|
||||
GUISlot slot = slots.get(i);
|
||||
inv.setItem(i, slot.getItem());
|
||||
}
|
||||
}
|
||||
public void resetPagedItem(ItemStack item){
|
||||
this.pagedItems.clear();
|
||||
this.pagedItems.add(new ItemStack[]{item});
|
||||
}
|
||||
public void resetPagedItem(int type, String key,boolean cmd){
|
||||
this.pagedItems.clear();
|
||||
this.pagedData.clear();
|
||||
if(type == 1){
|
||||
resetPagedItem(key,cmd);
|
||||
}
|
||||
else if(type == 2){
|
||||
for(MyDragon myDragon : DragonManager.dragons){
|
||||
this.addDragon(myDragon.icon.clone(),myDragon.unique_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void resetPagedItem(String key,boolean cmd){
|
||||
this.pagedItems.clear();
|
||||
MyDragon dragon = DragonManager.mp.get(key);
|
||||
if(dragon == null) return;
|
||||
for(Reward reward : dragon.datum){
|
||||
//if(ItemManager.isEmpty(reward.getItem())) continue;
|
||||
ItemStack item = reward.getItem().clone();
|
||||
if("".equals(Lang.gui_item_lore)) Lang.gui_item_lore = "§6(chance: {drop_chance}%)§r";
|
||||
String lore = Lang.gui_item_lore.replaceAll("\\{drop_chance}",reward.getChance().getStr());
|
||||
if(cmd) {
|
||||
if("".equals(Lang.gui_item_cmd_lore)) Lang.gui_item_cmd_lore = "§6Shift+RightClick§f to remove§r";
|
||||
ItemManager.addLoreFront(item,Lang.gui_item_cmd_lore);
|
||||
}
|
||||
ItemManager.addLoreFront(item,lore);
|
||||
this.addItem(item);
|
||||
}
|
||||
}
|
||||
protected void addItem(ItemStack item) {
|
||||
for(int i = 0 ; i < this.maxPage ; i++){
|
||||
if (i >= this.pagedItems.size()) {
|
||||
this.pagedItems.add(new ItemStack[this.size]);
|
||||
}
|
||||
for(int j = 0 ; j < this.slots.size() ; j++){
|
||||
GUISlot slot = this.slots.get(j);
|
||||
if (slot instanceof ItemSlot) {
|
||||
ItemStack itemStack = this.pagedItems.get(i)[j];
|
||||
if (itemStack == null) {
|
||||
this.pagedItems.get(i)[j] = item;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
protected void addDragon(ItemStack item,String unique_name) {
|
||||
for(int i = 0 ; i < this.maxPage ; i++){
|
||||
if (i >= this.pagedItems.size()) {
|
||||
this.pagedItems.add(new ItemStack[this.size]);
|
||||
this.pagedData.add(new String[this.size]);
|
||||
}
|
||||
for(int j = 0 ; j < this.slots.size() ; j++){
|
||||
if (this.slots.get(j) instanceof DragonSlot) {
|
||||
ItemStack itemStack = this.pagedItems.get(i)[j];
|
||||
if (itemStack == null) {
|
||||
//itemStack = item;(可以吗?)
|
||||
this.pagedItems.get(i)[j] = item;
|
||||
this.pagedData.get(i)[j] = unique_name;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public String getData(int page,int index){
|
||||
return this.pagedData.get(page)[index];
|
||||
}
|
||||
public int getSize() {
|
||||
return this.size;
|
||||
}
|
||||
public int getPage(){
|
||||
return this.page;
|
||||
}
|
||||
public void prev() {
|
||||
if (this.page > 0) {
|
||||
this.setPage(this.page - 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void addPage() {
|
||||
if (this.pagedItems.size() >= this.maxPage) {
|
||||
return;
|
||||
}
|
||||
this.pagedItems.add(new ItemStack[this.size]);
|
||||
}
|
||||
|
||||
public void next() {
|
||||
if (this.page < this.pagedItems.size() - 1) {
|
||||
this.setPage(this.page + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package pers.xanadu.enderdragon.gui;
|
||||
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
public abstract class GUIHolder implements InventoryHolder {
|
||||
private final GUI gui;
|
||||
|
||||
public Inventory getInventory() {
|
||||
return this.gui.getInventory();
|
||||
}
|
||||
|
||||
public GUI getGUI() {
|
||||
return this.gui;
|
||||
}
|
||||
|
||||
public GUIHolder(GUI gui) {
|
||||
this.gui = gui;
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package pers.xanadu.enderdragon.gui;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import pers.xanadu.enderdragon.gui.slot.*;
|
||||
|
||||
public abstract class GUISlot {
|
||||
private final GUISlotType guiSlotType;
|
||||
protected DataType data_type;
|
||||
public abstract ItemStack getItem();
|
||||
public abstract ItemStack getItemOnDisable();
|
||||
protected GUISlot(GUISlotType type){
|
||||
this.guiSlotType = type;
|
||||
}
|
||||
public final GUISlotType getType(){
|
||||
return this.guiSlotType;
|
||||
}
|
||||
public static GUISlot parse(ConfigurationSection section){
|
||||
if(section == null) return new EmptySlot();
|
||||
GUISlotType guiSlotType = GUISlotType.getByName(section.getString("type"));
|
||||
switch (guiSlotType) {
|
||||
case ITEM_SLOT : {
|
||||
return new ItemSlot(section);
|
||||
}
|
||||
case DRAGON_SLOT : {
|
||||
return new DragonSlot(section);
|
||||
}
|
||||
case PAGE_PREV :
|
||||
case PAGE_NEXT :
|
||||
case PAGE_TIP :
|
||||
case TIP : {
|
||||
return new TipSlot(guiSlotType, section);
|
||||
}
|
||||
case PAGE_JUMP : {
|
||||
return new PageJumpSlot(section);
|
||||
}
|
||||
}
|
||||
return new EmptySlot();
|
||||
}
|
||||
protected enum DataType{
|
||||
DEFAULT,NBT,ADVANCED
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package pers.xanadu.enderdragon.gui;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public enum GUISlotType {
|
||||
TIP,
|
||||
PAGE_TIP,
|
||||
PAGE_PREV,
|
||||
PAGE_NEXT,
|
||||
PAGE_JUMP,
|
||||
EMPTY,
|
||||
ITEM_SLOT,
|
||||
DRAGON_SLOT;
|
||||
private static final Map<String,GUISlotType> mp = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
public static GUISlotType getByName(String str){
|
||||
if(str == null) return EMPTY;
|
||||
return mp.getOrDefault(str.replaceAll("_",""),EMPTY);
|
||||
}
|
||||
static{
|
||||
GUISlotType[] values = values();
|
||||
for (GUISlotType guiSlotType : values) {
|
||||
String name = guiSlotType.name();
|
||||
String target = "_";
|
||||
String replacement = "";
|
||||
mp.put(name.replaceAll(target, replacement), guiSlotType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
package pers.xanadu.enderdragon.gui;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import pers.xanadu.enderdragon.config.Lang;
|
||||
import pers.xanadu.enderdragon.gui.holder.MenuEditor;
|
||||
import pers.xanadu.enderdragon.gui.holder.Menu;
|
||||
import pers.xanadu.enderdragon.gui.holder.RewardEditor;
|
||||
import pers.xanadu.enderdragon.gui.slot.EmptySlot;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class GUIWrapper extends GUI{
|
||||
private final String name;
|
||||
private final String key;
|
||||
private int type;
|
||||
private int[] item_idx;
|
||||
private int item_size;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
public GUIWrapper(GUIWrapper a, String key, boolean editor){
|
||||
super(a.title, a.size, a.maxPage);
|
||||
if(editor) this.inv = Bukkit.createInventory(new MenuEditor(this,key), this.size, this.title);
|
||||
else this.inv = Bukkit.createInventory(new Menu(this), this.size, this.title);
|
||||
this.slots.addAll(a.slots);
|
||||
this.dynamics.addAll(a.dynamics);
|
||||
this.name = a.name;
|
||||
this.key = key;
|
||||
this.type = a.type;
|
||||
this.item_idx = a.item_idx;
|
||||
this.item_size = a.item_size;
|
||||
this.init();
|
||||
this.resetPagedItem(type,key,editor);
|
||||
this.setPage(0);
|
||||
}
|
||||
public GUIWrapper(GUIWrapper a, ItemStack item) {
|
||||
super(a.title, a.size, a.maxPage);
|
||||
this.inv = Bukkit.createInventory(new RewardEditor(this), this.size, this.title);
|
||||
this.slots.addAll(a.slots);
|
||||
this.dynamics.addAll(a.dynamics);
|
||||
this.name = a.name;
|
||||
this.key = null;
|
||||
this.type = a.type;
|
||||
this.item_idx = a.item_idx;
|
||||
this.item_size = a.item_size;
|
||||
this.init();
|
||||
this.resetPagedItem(item);
|
||||
this.setPage(0);
|
||||
}
|
||||
@Deprecated
|
||||
public GUIWrapper(GUIWrapper a, String key) {
|
||||
super(a.title, a.size, a.maxPage);
|
||||
this.inv = Bukkit.createInventory(new Menu(this), this.size, this.title);
|
||||
this.slots.addAll(a.slots);
|
||||
this.dynamics.addAll(a.dynamics);
|
||||
this.name = a.name;
|
||||
this.key = key;
|
||||
this.type = a.type;
|
||||
this.item_idx = a.item_idx;
|
||||
this.item_size = a.item_size;
|
||||
this.init();
|
||||
this.resetPagedItem(type,key,false);
|
||||
this.setPage(0);
|
||||
}
|
||||
public GUIWrapper(ConfigurationSection config) {
|
||||
super(config.getString("Title", Lang.gui_default_title).replaceAll("&", "§"), calcline(config.getStringList("Slots").size()) * 9, config.getInt("Page", 1000));
|
||||
this.type = 0;
|
||||
this.name = config.getName();
|
||||
this.key = null;
|
||||
this.inv = Bukkit.createInventory(new Menu(this), this.size, this.title);
|
||||
for(int i = 0 ; i < this.size ; i++){
|
||||
slots.add(new EmptySlot());
|
||||
}
|
||||
ConfigurationSection section = config.getConfigurationSection("Items");
|
||||
HashMap<Character,GUISlot> hash = new HashMap<>();
|
||||
if (section == null) return;
|
||||
for (String s : section.getKeys(false)) {
|
||||
GUISlot slot = GUISlot.parse(section.getConfigurationSection(s));
|
||||
hash.put(s.charAt(0), slot);
|
||||
}
|
||||
int n2 = 0;
|
||||
List<String> stringList = config.getStringList("Slots");
|
||||
for (String line : stringList) {
|
||||
int i;
|
||||
for (i = 0; i < line.length() && i < 9; ++i) {
|
||||
char value = line.charAt(i);
|
||||
this.slots.set(n2++, (hash.getOrDefault(value, new EmptySlot())));
|
||||
}
|
||||
while(i ++ < 9){
|
||||
this.slots.set(n2++, new EmptySlot());
|
||||
}
|
||||
}
|
||||
boolean b = false;
|
||||
for(int i = 0 ; i < slots.size(); i++){
|
||||
GUISlotType type = this.slots.get(i).getType();
|
||||
if(type == GUISlotType.PAGE_PREV || type == GUISlotType.PAGE_NEXT || type == GUISlotType.PAGE_TIP){
|
||||
this.dynamics.add(i);
|
||||
}
|
||||
else if(type == GUISlotType.ITEM_SLOT){
|
||||
this.type = 1;
|
||||
}
|
||||
else if(type == GUISlotType.DRAGON_SLOT){
|
||||
this.type = 2;
|
||||
}
|
||||
else if (type == GUISlotType.PAGE_JUMP) {
|
||||
b = true;
|
||||
}
|
||||
}
|
||||
this.item_idx = new int[size];
|
||||
int cur = -1;
|
||||
for(int i=0;i<size;i++){
|
||||
if(this.slots.get(i).getType()==GUISlotType.ITEM_SLOT) cur++;
|
||||
this.item_idx[i] = cur;
|
||||
}
|
||||
this.item_size = cur+1;
|
||||
}
|
||||
public int getItemSlotIdx(int cur){
|
||||
return this.item_idx[cur];
|
||||
}
|
||||
public int getItemSize(){
|
||||
return this.item_size;
|
||||
}
|
||||
public void updateItemChanges(boolean cmd){
|
||||
this.resetPagedItem(type,key,cmd);
|
||||
this.setPage(page);
|
||||
}
|
||||
|
||||
private static int calcline(final int a) {
|
||||
if (a < 1) {
|
||||
return 1;
|
||||
}
|
||||
return Math.min(a, 6);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package pers.xanadu.enderdragon.gui.holder;
|
||||
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import pers.xanadu.enderdragon.gui.GUI;
|
||||
import pers.xanadu.enderdragon.gui.GUIHolder;
|
||||
|
||||
public class Menu extends GUIHolder implements InventoryHolder {
|
||||
|
||||
public Menu(GUI gui) {
|
||||
super(gui);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package pers.xanadu.enderdragon.gui.holder;
|
||||
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import pers.xanadu.enderdragon.gui.GUI;
|
||||
import pers.xanadu.enderdragon.gui.GUIHolder;
|
||||
|
||||
public class MenuEditor extends GUIHolder implements InventoryHolder {
|
||||
private final String dragon_key;
|
||||
public String getDragon_key(){
|
||||
return this.dragon_key;
|
||||
}
|
||||
|
||||
public MenuEditor(GUI gui, String key) {
|
||||
super(gui);
|
||||
this.dragon_key = key;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package pers.xanadu.enderdragon.gui.holder;
|
||||
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import pers.xanadu.enderdragon.gui.GUI;
|
||||
import pers.xanadu.enderdragon.gui.GUIHolder;
|
||||
|
||||
public class RewardEditor extends GUIHolder implements InventoryHolder {
|
||||
public RewardEditor(GUI gui){
|
||||
super(gui);
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package pers.xanadu.enderdragon.gui.slot;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import pers.xanadu.enderdragon.gui.GUISlot;
|
||||
import pers.xanadu.enderdragon.gui.GUISlotType;
|
||||
|
||||
public class DragonSlot extends GUISlot {
|
||||
private String unique_name;
|
||||
private ItemStack item;
|
||||
|
||||
public DragonSlot(ConfigurationSection section) {
|
||||
super(GUISlotType.DRAGON_SLOT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem() {
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
@Override
|
||||
public ItemStack getItemOnDisable(){
|
||||
return this.item;
|
||||
}
|
||||
public void setUnique_name(String str){
|
||||
this.unique_name = str;
|
||||
}
|
||||
public String getUnique_name(){
|
||||
return this.unique_name;
|
||||
}
|
||||
|
||||
public DragonSlot(GUISlotType a, ItemStack item) {
|
||||
super(a);
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package pers.xanadu.enderdragon.gui.slot;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import pers.xanadu.enderdragon.gui.GUISlot;
|
||||
import pers.xanadu.enderdragon.gui.GUISlotType;
|
||||
|
||||
public class EmptySlot extends GUISlot {
|
||||
@Override
|
||||
public ItemStack getItem(){
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
@Override
|
||||
public ItemStack getItemOnDisable(){
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
public EmptySlot(){
|
||||
super(GUISlotType.EMPTY);
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package pers.xanadu.enderdragon.gui.slot;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import pers.xanadu.enderdragon.gui.GUISlot;
|
||||
import pers.xanadu.enderdragon.gui.GUISlotType;
|
||||
|
||||
public class ItemSlot extends GUISlot {
|
||||
private ItemStack item;
|
||||
|
||||
@Override
|
||||
public ItemStack getItem() {
|
||||
return this.item;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getItemOnDisable(){
|
||||
return this.item;
|
||||
}
|
||||
|
||||
public ItemSlot(ConfigurationSection section) {
|
||||
super(GUISlotType.ITEM_SLOT);
|
||||
String str = section.getString("Item");
|
||||
if(str == null){
|
||||
this.item = new ItemStack(Material.AIR);
|
||||
}
|
||||
else{
|
||||
// this.item = EnderDragon.getInstance().getItemManager().stringToItemStack(str);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package pers.xanadu.enderdragon.gui.slot;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import pers.xanadu.enderdragon.gui.GUISlotType;
|
||||
|
||||
public class PageJumpSlot extends TipSlot{
|
||||
private final String name;
|
||||
public String getGuiName() {
|
||||
return this.name;
|
||||
}
|
||||
public PageJumpSlot(ConfigurationSection section) {
|
||||
super(GUISlotType.PAGE_JUMP, section);
|
||||
this.name = section.getString("gui");
|
||||
}
|
||||
@Override
|
||||
public ItemStack getItemOnDisable(){
|
||||
return this.itemOnDisable;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
package pers.xanadu.enderdragon.gui.slot;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import pers.xanadu.enderdragon.gui.GUISlot;
|
||||
import pers.xanadu.enderdragon.gui.GUISlotType;
|
||||
|
||||
import static pers.xanadu.enderdragon.manager.ItemManager.*;
|
||||
|
||||
public class TipSlot extends GUISlot {
|
||||
private ItemStack item;
|
||||
protected boolean hasDisableMode;
|
||||
protected ItemStack itemOnDisable;
|
||||
|
||||
public TipSlot(GUISlotType slotType, Material material, String str) {
|
||||
super(slotType);
|
||||
this.item = new ItemStack(material);
|
||||
ItemMeta meta = this.item.getItemMeta();
|
||||
meta.setDisplayName(str);
|
||||
this.item.setItemMeta(meta);
|
||||
}
|
||||
|
||||
public TipSlot(GUISlotType slotType, ConfigurationSection section) {
|
||||
super(slotType);
|
||||
if(slotType == GUISlotType.PAGE_PREV || slotType == GUISlotType.PAGE_NEXT){
|
||||
this.hasDisableMode = true;
|
||||
}
|
||||
else this.hasDisableMode = false;
|
||||
if(hasDisableMode){
|
||||
if(data_type == DataType.NBT) this.itemOnDisable = readFromNBT(section,"data_disable");
|
||||
else this.itemOnDisable = readFromBukkit(section,"data_disable");
|
||||
}
|
||||
String data_type = section.getString("data_type");
|
||||
if("nbt".equals(data_type)) {
|
||||
this.data_type = DataType.NBT;
|
||||
this.item = readFromNBT(section,"data");
|
||||
}
|
||||
else if("advanced".equals(data_type)){
|
||||
this.data_type = DataType.ADVANCED;
|
||||
this.item = readFromAdvData(section,"data");
|
||||
}
|
||||
else {
|
||||
this.data_type = DataType.DEFAULT;
|
||||
this.item = readFromBukkit(section,"data");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem() {
|
||||
return this.item;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getItemOnDisable(){
|
||||
if(hasDisableMode) return this.itemOnDisable;
|
||||
return this.item;
|
||||
}
|
||||
|
||||
public TipSlot(GUISlotType a, ItemStack item) {
|
||||
super(a);
|
||||
this.item = item;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user