|
|
@ -39,6 +39,7 @@ import org.bukkit.event.inventory.InventoryDragEvent;
|
|
|
|
import org.bukkit.event.player.PlayerMoveEvent;
|
|
|
|
import org.bukkit.event.player.PlayerMoveEvent;
|
|
|
|
import org.bukkit.event.player.PlayerQuitEvent;
|
|
|
|
import org.bukkit.event.player.PlayerQuitEvent;
|
|
|
|
import org.bukkit.inventory.Inventory;
|
|
|
|
import org.bukkit.inventory.Inventory;
|
|
|
|
|
|
|
|
import org.bukkit.inventory.InventoryView;
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
import org.bukkit.inventory.meta.ItemMeta;
|
|
|
|
import org.bukkit.inventory.meta.ItemMeta;
|
|
|
|
import org.bukkit.persistence.PersistentDataType;
|
|
|
|
import org.bukkit.persistence.PersistentDataType;
|
|
|
@ -72,6 +73,7 @@ public class BauGuiEditor implements Listener {
|
|
|
|
inv.setItem(mapping.getSize() + 5, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_TRASH", p), Arrays.asList(BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_TRASH_LORE", p)), false, clickType -> {
|
|
|
|
inv.setItem(mapping.getSize() + 5, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_TRASH", p), Arrays.asList(BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_TRASH_LORE", p)), false, clickType -> {
|
|
|
|
}).getItemStack());
|
|
|
|
}).getItemStack());
|
|
|
|
inv.setItem(mapping.getSize() + 6, new SWItem(Material.SCUTE, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_MORE", p)).getItemStack());
|
|
|
|
inv.setItem(mapping.getSize() + 6, new SWItem(Material.SCUTE, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_MORE", p)).getItemStack());
|
|
|
|
|
|
|
|
inv.setItem(mapping.getSize() + 8, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_CLOSE", p)).getItemStack());
|
|
|
|
|
|
|
|
|
|
|
|
p.openInventory(inv);
|
|
|
|
p.openInventory(inv);
|
|
|
|
p.getOpenInventory().setCursor(cursor == null ? new SWItem().getItemStack() : cursor);
|
|
|
|
p.getOpenInventory().setCursor(cursor == null ? new SWItem().getItemStack() : cursor);
|
|
|
@ -155,6 +157,10 @@ public class BauGuiEditor implements Listener {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
inv.open();
|
|
|
|
inv.open();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
|
|
|
|
saveMapping(p);
|
|
|
|
|
|
|
|
BauGUI.openBauGui(p);
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -188,14 +194,17 @@ public class BauGuiEditor implements Listener {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void saveMapping(Player p) {
|
|
|
|
private void saveMapping(Player p) {
|
|
|
|
BauGuiMapping mapping = BauGuiMapping.getGuiMapping(p);
|
|
|
|
saveMapping(p.getOpenInventory(), BauGuiMapping.getGuiMapping(p));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void saveMapping(InventoryView view, BauGuiMapping mapping) {
|
|
|
|
if (mapping.isSaved()) {
|
|
|
|
if (mapping.isSaved()) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
HashMap<Integer, Integer> newMapping = new HashMap<>();
|
|
|
|
HashMap<Integer, Integer> newMapping = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < p.getOpenInventory().getTopInventory().getContents().length; i++) {
|
|
|
|
for (int i = 0; i < view.getTopInventory().getContents().length; i++) {
|
|
|
|
ItemStack itemStack = p.getOpenInventory().getTopInventory().getContents()[i];
|
|
|
|
ItemStack itemStack = view.getTopInventory().getContents()[i];
|
|
|
|
if (itemStack == null || itemStack.getType() == Material.AIR || i >= mapping.getSize()) continue;
|
|
|
|
if (itemStack == null || itemStack.getType() == Material.AIR || i >= mapping.getSize()) continue;
|
|
|
|
newMapping.put(getId(itemStack), i);
|
|
|
|
newMapping.put(getId(itemStack), i);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -218,7 +227,7 @@ public class BauGuiEditor implements Listener {
|
|
|
|
|
|
|
|
|
|
|
|
Player p = (Player) event.getPlayer();
|
|
|
|
Player p = (Player) event.getPlayer();
|
|
|
|
|
|
|
|
|
|
|
|
saveMapping(p);
|
|
|
|
saveMapping(event.getView(), BauGuiMapping.getGuiMapping(p));
|
|
|
|
open_Edits.remove(p);
|
|
|
|
open_Edits.remove(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|