1
0
mirror of https://github.com/nkomarn/harbor.git synced 2024-12-20 07:17:39 +01:00

Move GUI-related items to GUI package

This commit is contained in:
Mykyta 2019-05-08 06:58:23 -07:00
parent 73df60d41a
commit 0f80c831f4
4 changed files with 13 additions and 13 deletions

View File

@ -16,9 +16,9 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import mykyta.Harbor.Config; import mykyta.Harbor.Config;
import mykyta.Harbor.GUIType;
import mykyta.Harbor.Holder;
import mykyta.Harbor.Util; import mykyta.Harbor.Util;
import mykyta.Harbor.GUI.GUIHolder;
import mykyta.Harbor.GUI.GUIType;
public class Sleeping implements CommandExecutor { public class Sleeping implements CommandExecutor {
@ -33,7 +33,7 @@ public class Sleeping implements CommandExecutor {
Config config = new Config(); Config config = new Config();
ArrayList<Player> sleeping = Util.sleeping.get(w); ArrayList<Player> sleeping = Util.sleeping.get(w);
int slots = Math.min(54, ((sleeping.size() - 1) / 9 + 1) * 9); int slots = Math.min(54, ((sleeping.size() - 1) / 9 + 1) * 9);
gui = Bukkit.createInventory(new Holder(GUIType.SLEEPING), slots, config.getString("gui.sleeping")); gui = Bukkit.createInventory(new GUIHolder(GUIType.SLEEPING), slots, config.getString("gui.sleeping"));
if (sleeping.size() > 0) sleeping.forEach(pl -> { if (sleeping.size() > 0) sleeping.forEach(pl -> {
ItemStack item = new ItemStack(Material.PLAYER_HEAD, 1); ItemStack item = new ItemStack(Material.PLAYER_HEAD, 1);

View File

@ -6,15 +6,15 @@ import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent; import org.bukkit.event.inventory.InventoryDragEvent;
import mykyta.Harbor.GUIType; import mykyta.Harbor.GUI.GUIType;
import mykyta.Harbor.Holder; import mykyta.Harbor.GUI.GUIHolder;
public class GUIEvent implements Listener { public class GUIEvent implements Listener {
@EventHandler @EventHandler
public void onClick(InventoryClickEvent event) { public void onClick(InventoryClickEvent event) {
if (event.getInventory().getHolder() != null && event.getInventory().getHolder() instanceof Holder) { if (event.getInventory().getHolder() != null && event.getInventory().getHolder() instanceof Holder) {
Player p = ((Player) event.getWhoClicked()); Player p = ((Player) event.getWhoClicked());
GUIType t = ((Holder) event.getInventory().getHolder()).getType(); GUIType t = ((GUIHolder) event.getInventory().getHolder()).getType();
if (t.equals(GUIType.SLEEPING)) event.setCancelled(true); if (t.equals(GUIType.SLEEPING)) event.setCancelled(true);
} }
} }
@ -23,7 +23,7 @@ public class GUIEvent implements Listener {
public void onDrag(InventoryDragEvent event) { public void onDrag(InventoryDragEvent event) {
if (event.getInventory().getHolder() != null && event.getInventory().getHolder() instanceof Holder) { if (event.getInventory().getHolder() != null && event.getInventory().getHolder() instanceof Holder) {
Player p = ((Player) event.getWhoClicked()); Player p = ((Player) event.getWhoClicked());
GUIType t = ((Holder) event.getInventory().getHolder()).getType(); GUIType t = ((GUIHolder) event.getInventory().getHolder()).getType();
if (t.equals(GUIType.SLEEPING)) event.setCancelled(true); if (t.equals(GUIType.SLEEPING)) event.setCancelled(true);
} }
} }

View File

@ -1,13 +1,13 @@
package mykyta.Harbor; package mykyta.Harbor.GUI;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryHolder;
public class Holder implements InventoryHolder { public class GUIHolder implements InventoryHolder {
Inventory inv; private Inventory inv;
GUIType type; private GUIType type;
public Holder(GUIType type) { public GUIHolder(GUIType type) {
this.type = type; this.type = type;
} }

View File

@ -1,4 +1,4 @@
package mykyta.Harbor; package mykyta.Harbor.GUI;
public enum GUIType { public enum GUIType {
SLEEPING SLEEPING