SteamWar/BauSystem
Archiviert
13
0
Dieser Commit ist enthalten in:
Chaoscaot 2021-02-17 14:32:27 +01:00
Ursprung 8f176cd8cd
Commit 8c216527f7

Datei anzeigen

@ -44,25 +44,6 @@ public class CommandGUI implements CommandExecutor, Listener {
Bukkit.getScheduler().runTaskTimerAsynchronously(BauSystem.getPlugin(), LAST_F_PLAYER::clear, 0, 20); Bukkit.getScheduler().runTaskTimerAsynchronously(BauSystem.getPlugin(), LAST_F_PLAYER::clear, 0, 20);
} }
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if(!(commandSender instanceof Player))
return false;
Player player = ((Player) commandSender);
if(strings.length == 0) {
openBauGui(player);
OPEN_INVS.add(player);
}else {
if ("item".equalsIgnoreCase(strings[0])) {
if (player.getInventory().getItemInMainHand().getType() == Material.AIR)
player.getInventory().setItemInMainHand(new ItemStack(Material.NETHER_STAR));
else
player.getInventory().addItem(new ItemStack(Material.NETHER_STAR));
}
}
return true;
}
public static void openBauGui(Player player) { public static void openBauGui(Player player) {
Region region = Region.getRegion(player.getLocation()); Region region = Region.getRegion(player.getLocation());
SWInventory inv = new SWInventory(player, 5 * 9, SteamwarUser.get(BauSystem.getOwner()).getUserName() + "s Bau"); SWInventory inv = new SWInventory(player, 5 * 9, SteamwarUser.get(BauSystem.getOwner()).getUserName() + "s Bau");
@ -71,9 +52,12 @@ public class CommandGUI implements CommandExecutor, Listener {
OPEN_INVS.remove(player); OPEN_INVS.remove(player);
}); });
inv.setItem(37, getMaterial("GLASS_PANE", "THIN_GLASS"), "§7Platzhalter", clickType -> {}); inv.setItem(37, getMaterial("GLASS_PANE", "THIN_GLASS"), "§7Platzhalter", clickType -> {
inv.setItem(38, getMaterial("GLASS_PANE", "THIN_GLASS"), "§7Platzhalter", clickType -> {}); });
inv.setItem(43, getMaterial("GLASS_PANE", "THIN_GLASS"), "§7Platzhalter", clickType -> {}); inv.setItem(38, getMaterial("GLASS_PANE", "THIN_GLASS"), "§7Platzhalter", clickType -> {
});
inv.setItem(43, getMaterial("GLASS_PANE", "THIN_GLASS"), "§7Platzhalter", clickType -> {
});
inv.setItem(42, Material.NETHER_STAR, "§7Bau GUI Item", Arrays.asList("§7Du kannst dieses Item zum Öffnen der BauGUI nutzen", "§7oder Doppel F (Swap hands) drücken."), false, clickType -> { inv.setItem(42, Material.NETHER_STAR, "§7Bau GUI Item", Arrays.asList("§7Du kannst dieses Item zum Öffnen der BauGUI nutzen", "§7oder Doppel F (Swap hands) drücken."), false, clickType -> {
player.closeInventory(); player.closeInventory();
player.performCommand("gui item"); player.performCommand("gui item");
@ -166,9 +150,12 @@ public class CommandGUI implements CommandExecutor, Listener {
}); });
if (Region.GlobalRegion.isGlobalRegion(region)) { if (Region.GlobalRegion.isGlobalRegion(region)) {
inv.setItem(9, Material.BARRIER, "§eKeine Region", clickType -> {}); inv.setItem(9, Material.BARRIER, "§eKeine Region", clickType -> {
inv.setItem(18, Material.BARRIER, "§eKeine Region", clickType -> {}); });
inv.setItem(27, Material.BARRIER, "§eKeine Region", clickType -> {}); inv.setItem(18, Material.BARRIER, "§eKeine Region", clickType -> {
});
inv.setItem(27, Material.BARRIER, "§eKeine Region", clickType -> {
});
} else { } else {
inv.setItem(27, getMaterial("HEAVY_WEIGHTED_PRESSURE_PLATE", "IRON_PLATE"), "§eRegion Reseten", getNoPermsLore(Arrays.asList("§8/§7reset"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> { inv.setItem(27, getMaterial("HEAVY_WEIGHTED_PRESSURE_PLATE", "IRON_PLATE"), "§eRegion Reseten", getNoPermsLore(Arrays.asList("§8/§7reset"), player, "§cDu hast keine Worldrechte", Permission.world), false, clickType -> {
if (Welt.noPermission(player, Permission.world)) if (Welt.noPermission(player, Permission.world))
@ -183,7 +170,8 @@ public class CommandGUI implements CommandExecutor, Listener {
confirmationInventory(player, "Region Protecten", () -> player.performCommand("protect"), () -> openBauGui(player)); confirmationInventory(player, "Region Protecten", () -> player.performCommand("protect"), () -> openBauGui(player));
}); });
} else { } else {
inv.setItem(18, Material.BARRIER, "§eRegion nicht Protect bar", clickType -> {}); inv.setItem(18, Material.BARRIER, "§eRegion nicht Protect bar", clickType -> {
});
} }
if (region.hasTestblock()) { if (region.hasTestblock()) {
@ -193,7 +181,8 @@ public class CommandGUI implements CommandExecutor, Listener {
confirmationInventory(player, "Testblock erneuern", () -> player.performCommand("testblock"), () -> openBauGui(player)); confirmationInventory(player, "Testblock erneuern", () -> player.performCommand("testblock"), () -> openBauGui(player));
}); });
} else { } else {
inv.setItem(9, Material.BARRIER, "§eDie Region hat keinen Testblock", clickType -> {}); inv.setItem(9, Material.BARRIER, "§eDie Region hat keinen Testblock", clickType -> {
});
} }
} }
@ -344,7 +333,8 @@ public class CommandGUI implements CommandExecutor, Listener {
player.performCommand("trace show gui"); player.performCommand("trace show gui");
}); });
inv.setItem(6, Material.BARRIER, "§7Trace löschen", Arrays.asList("§8/§7trace delete"), false, clickType -> confirmationInventory(player, "Trace löschen", () -> player.performCommand("trace delete"), () -> {})); inv.setItem(6, Material.BARRIER, "§7Trace löschen", Arrays.asList("§8/§7trace delete"), false, clickType -> confirmationInventory(player, "Trace löschen", () -> player.performCommand("trace delete"), () -> {
}));
inv.setItem(8, Material.ARROW, "§7Zurück", clickType -> { inv.setItem(8, Material.ARROW, "§7Zurück", clickType -> {
player.closeInventory(); player.closeInventory();
@ -358,7 +348,8 @@ public class CommandGUI implements CommandExecutor, Listener {
private static void scriptBooksGUI(Player player) { private static void scriptBooksGUI(Player player) {
List<SWListInv.SWListEntry<PredefinedBook>> entries = new ArrayList<>(); List<SWListInv.SWListEntry<PredefinedBook>> entries = new ArrayList<>();
List<PredefinedBook> books = PredefinedBook.getBooks(); List<PredefinedBook> books = PredefinedBook.getBooks();
books.forEach(predefinedBook -> entries.add(new SWListInv.SWListEntry<>(new SWItem(predefinedBook.getBookMat(), predefinedBook.getName(), predefinedBook.getLore(), false, clickType -> {}), predefinedBook))); books.forEach(predefinedBook -> entries.add(new SWListInv.SWListEntry<>(new SWItem(predefinedBook.getBookMat(), predefinedBook.getName(), predefinedBook.getLore(), false, clickType -> {
}), predefinedBook)));
SWListInv<PredefinedBook> inv = new SWListInv<>(player, "Script Bücher", entries, (clickType, predefinedBook) -> { SWListInv<PredefinedBook> inv = new SWListInv<>(player, "Script Bücher", entries, (clickType, predefinedBook) -> {
player.closeInventory(); player.closeInventory();
player.getInventory().addItem(predefinedBook.toItemStack()); player.getInventory().addItem(predefinedBook.toItemStack());
@ -565,11 +556,32 @@ public class CommandGUI implements CommandExecutor, Listener {
for (String name : names) { for (String name : names) {
try { try {
return Material.valueOf(name); return Material.valueOf(name);
}catch (IllegalArgumentException ignored) {} } catch (IllegalArgumentException ignored) {
//Ignored /\
}
} }
return null; return null;
} }
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if (!(commandSender instanceof Player))
return false;
Player player = ((Player) commandSender);
if (strings.length == 0) {
openBauGui(player);
OPEN_INVS.add(player);
} else {
if ("item".equalsIgnoreCase(strings[0])) {
if (player.getInventory().getItemInMainHand().getType() == Material.AIR)
player.getInventory().setItemInMainHand(new ItemStack(Material.NETHER_STAR));
else
player.getInventory().addItem(new ItemStack(Material.NETHER_STAR));
}
}
return true;
}
@EventHandler @EventHandler
public void onPlayerInteract(PlayerInteractEvent event) { public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)