SteamWar/BauSystem
Archiviert
13
0

ChaosBauGUI #183

Manuell gemergt
YoyoNow hat 20 Commits von ChaosBauGUI nach master 2021-02-24 19:16:17 +01:00 zusammengeführt
2 geänderte Dateien mit 144 neuen und 50 gelöschten Zeilen
Nur Änderungen aus Commit 0b95df4bda werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -2,7 +2,8 @@ package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.world.Detonator; import de.steamwar.bausystem.world.Detonator;
import de.steamwar.core.VersionedCallable; import de.steamwar.bausystem.world.Region;
import de.steamwar.inventory.SWAnvilInv;
import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
@ -11,100 +12,184 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import java.util.*;
public class CommandGUI implements CommandExecutor { public class CommandGUI implements CommandExecutor {
private static final Set<Player> OPEN_INVS = new HashSet<>();
private static boolean isRefreshing = false;
@Override @Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) { public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if(!(commandSender instanceof Player)) if(!(commandSender instanceof Player))
return false; return false;
Player player = ((Player) commandSender); Player player = ((Player) commandSender);
openBauGui(player); openBauGui(player);
OPEN_INVS.add(player);
return true; return true;
} }
public static void openBauGui(Player player) { public static void openBauGui(Player player) {
Region region = Region.getRegionIn(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");
inv.setCallback(-1, clickType -> {
inv.setItem(3, Detonator.WAND, clickType -> { if(!isRefreshing)
player.closeInventory(); OPEN_INVS.remove(player);
player.getInventory().setItemInMainHand(Detonator.WAND);
}); });
inv.setItem(4, getMaterial("WOODEN_AXE", "WOOD_AXE"), "§eWorldedit Axt", clickType -> { inv.setItem(2, Material.GLASS_PANE, "§7Platzhalter", clickType -> {});
ItemStack dtWand = Detonator.WAND.clone();
ItemMeta meta = dtWand.getItemMeta();
List<String> lore = meta.getLore();
lore.add("§8/§7dt wand");
meta.setLore(lore);
dtWand.setItemMeta(meta);
inv.setItem(3, dtWand, clickType -> {
player.closeInventory();
player.performCommand("dt wand");
});
inv.setItem(4, getMaterial("WOODEN_AXE", "WOOD_AXE"), "§eWorldedit Axt", Arrays.asList("§8//§7wand"), false, clickType -> {
player.closeInventory(); player.closeInventory();
player.performCommand("/wand"); player.performCommand("/wand");
}); });
inv.setItem(5, Material.GLASS_PANE, "§7Platzhalter", clickType -> {});
inv.setItem(6, Material.GLASS_PANE, "§7Platzhalter", clickType -> {});
if(CommandFreeze.getInstance().isOn()) { inv.setItem(9, Material.COMPASS, "§7TPS Limitieren", Arrays.asList("§7Aktuell: §e" + CommandTPSLimiter.getCurrentTPSLimit(), "§8/§7tpslimit §8[§e1 - 20§8]"), false, clickType -> {
inv.setItem(30, Material.GUNPOWDER, "§7Freeze: §eEingeschaltet", clickType -> { SWAnvilInv anvilInv = new SWAnvilInv(player, "TPS Limitieren");
CommandFreeze.getInstance().toggle(); anvilInv.setItem(Material.COMPASS);
openBauGui(player); anvilInv.setCallback(s -> player.performCommand("tpslimit " + s));
anvilInv.open();
}); });
inv.setItem(18, Material.FEATHER, "§7Geschwindigkeit", Arrays.asList("§7Aktuell: §e" + player.getFlySpeed() * 10, "§8/§7speed §8[§e1 - 10§8]"), false, clickType -> {
SWAnvilInv anvilInv = new SWAnvilInv(player, "Geschwindigkeit");
anvilInv.setItem(Material.FEATHER);
anvilInv.setCallback(s -> player.performCommand("speed " + s));
anvilInv.open();
});
inv.setItem(27, getMaterial("PLAYER_HEAD", "SKULL_ITEM"), (byte) 3, "§7Spielerkopf geben", Arrays.asList("§8/§7skull §8[§eSpieler§8]"), false, clickType -> {
SWAnvilInv anvilInv = new SWAnvilInv(player, "Spielerköpfe");
anvilInv.setItem(Material.NAME_TAG);
anvilInv.setCallback(s -> player.performCommand("skull " + s));
anvilInv.open();
});
if(region == null) {
inv.setItem(17, Material.BARRIER, "§eKeine Region", clickType -> {});
inv.setItem(26, Material.BARRIER, "§eKeine Region", clickType -> {});
inv.setItem(35, Material.BARRIER, "§eKeine Region", clickType -> {});
}else {
inv.setItem(17, Material.HEAVY_WEIGHTED_PRESSURE_PLATE, "§eRegion Reseten", Arrays.asList("§8/§7reset"), false, clickType ->
confirmationInventory(player, "Region Reseten?", () -> player.performCommand("reset"), () -> openBauGui(player)));
if(region.hasProtection()) {
inv.setItem(26, Material.OBSIDIAN, "§eRegion Protecten", Arrays.asList("§8/§7protect"), false, clickType ->
confirmationInventory(player, "Region Protecten", () -> player.performCommand("protect"), () -> openBauGui(player)));
} else { } else {
inv.setItem(30, Material.REDSTONE, "§7Freeze: §eAusgeschaltet", clickType -> { inv.setItem(26, Material.BARRIER, "§eRegion nicht Protect bar", clickType -> {});
CommandFreeze.getInstance().toggle();
openBauGui(player);
});
} }
switch (CommandTNT.getTntMode()) { if(region.hasTestblock()) {
case OFF: inv.setItem(35, getMaterial("END_STONE", "ENDER_STONE"), "§eTestblock erneuern", Arrays.asList("§8/§7testblock"), false, clickType ->
inv.setItem(31, Material.MINECART, "§7TNT: §eAusgeschaltet", clickType -> { confirmationInventory(player, "Testblock erneuern", () -> player.performCommand("testblock"), () -> openBauGui(player)));
CommandTNT.setTntMode(CommandTNT.TNTMode.ONLY_TB);
openBauGui(player);
});
break;
case ONLY_TB:
inv.setItem(31, Material.TNT_MINECART, "§7TNT: §enur Testblock", clickType -> {
CommandTNT.setTntMode(CommandTNT.TNTMode.ON);
openBauGui(player);
});
break;
default:
inv.setItem(31, Material.TNT, "§7TNT: §eEingeschaltet", clickType -> {
CommandTNT.setTntMode(CommandTNT.TNTMode.OFF);
openBauGui(player);
});
}
if(CommandFire.getInstance().isOn()) {
inv.setItem(32, getMaterial("FIREWORK_STAR", "FIREWORK_CHARGE"), "§7Fire: §eAusgeschaltet", clickType -> {
CommandFire.getInstance().toggle();
openBauGui(player);
});
} else { } else {
inv.setItem(32, Material.FIRE_CHARGE, "§7Fire: §eEingeschaltet", clickType -> { inv.setItem(35, Material.BARRIER, "§eDie Region hat keinen Testblock", clickType -> {});
CommandFire.getInstance().toggle(); }
openBauGui(player);
});
} }
if(player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) { if(player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
inv.setItem(38, Material.POTION, "§7Nightvision: §eEingeschaltet", clickType -> { inv.setItem(38, Material.POTION, "§7Nightvision: §eEingeschaltet", Arrays.asList("§8/§7nv"), false, clickType -> {
CommandNV.toggleNightvision(player); CommandNV.toggleNightvision(player);
openBauGui(player); openBauGui(player);
}); });
} else { } else {
inv.setItem(38, Material.GLASS_BOTTLE, "§7Nightvision: §eAusgeschaltet", clickType -> { inv.setItem(38, Material.GLASS_BOTTLE, "§7Nightvision: §eAusgeschaltet", Arrays.asList("§8/§7nv"), false, clickType -> {
CommandNV.toggleNightvision(player); CommandNV.toggleNightvision(player);
openBauGui(player); openBauGui(player);
}); });
} }
if(player.hasPotionEffect(PotionEffectType.WATER_BREATHING)) { if(player.hasPotionEffect(PotionEffectType.WATER_BREATHING)) {
inv.setItem(40, Material.WATER_BUCKET, "§7Waterbreathing: §eEingeschaltet", clickType -> { inv.setItem(39, Material.WATER_BUCKET, "§7Waterbreathing: §eEingeschaltet", Arrays.asList("§8/§7wv"), false, clickType -> {
CommandGills.toggleGills(player); CommandGills.toggleGills(player);
openBauGui(player); openBauGui(player);
}); });
} else { } else {
inv.setItem(40, Material.BUCKET, "§7Waterbreathing: §eAusgeschaltet", clickType -> { inv.setItem(39, Material.BUCKET, "§7Waterbreathing: §eAusgeschaltet", Arrays.asList("§8/§7wv"), false, clickType -> {
CommandGills.toggleGills(player); CommandGills.toggleGills(player);
openBauGui(player); openBauGui(player);
}); });
} }
switch (CommandTNT.getTntMode()) {
case OFF:
inv.setItem(40, Material.MINECART, "§7TNT: §eAusgeschaltet", Arrays.asList("§8/§7tnt §8[" + (Region.buildAreaEnabled()?"§etb§8, ":"") + "§eOff §7oder §eOn§7]"), false, clickType -> {
CommandTNT.setTntMode(Region.buildAreaEnabled()?CommandTNT.TNTMode.ONLY_TB: CommandTNT.TNTMode.ON);
updateInventories();
});
break;
case ONLY_TB:
inv.setItem(40, Material.TNT_MINECART, "§7TNT: §enur Testblock", Arrays.asList("§8/§7tnt §8[" + (Region.buildAreaEnabled()?"§etb§8, ":"") + "§eOff §7oder §eOn§7]"), false, clickType -> {
CommandTNT.setTntMode(CommandTNT.TNTMode.ON);
updateInventories();
});
break;
default:
inv.setItem(40, Material.TNT, "§7TNT: §eEingeschaltet", Arrays.asList("§8/§7tnt §8[" + (Region.buildAreaEnabled()?"§etb§8, ":"") + "§eOff §7oder §eOn§7]"), false, clickType -> {
CommandTNT.setTntMode(CommandTNT.TNTMode.OFF);
updateInventories();
});
}
if(CommandFreeze.getInstance().isOn()) {
inv.setItem(41, Material.GUNPOWDER, "§7Freeze: §eEingeschaltet", Arrays.asList("§8/§7freeze"), false, clickType -> {
CommandFreeze.getInstance().toggle();
updateInventories();
});
} else {
inv.setItem(41, Material.REDSTONE, "§7Freeze: §eAusgeschaltet", Arrays.asList("§8/§7freeze"), false, clickType -> {
CommandFreeze.getInstance().toggle();
updateInventories();
});
}
if(CommandFire.getInstance().isOn()) {
inv.setItem(42, getMaterial("FIREWORK_STAR", "FIREWORK_CHARGE"), "§7Fire: §eAusgeschaltet", Arrays.asList("§8/§7fire"), false, clickType -> {
CommandFire.getInstance().toggle();
updateInventories();
});
} else {
inv.setItem(42, Material.FIRE_CHARGE, "§7Fire: §eEingeschaltet", Arrays.asList("§8/§7fire"), false, clickType -> {
CommandFire.getInstance().toggle();
updateInventories();
});
}
inv.open();
}
private static void updateInventories() {
isRefreshing = true;
OPEN_INVS.forEach(CommandGUI::openBauGui);
isRefreshing = false;
}
private static void confirmationInventory(Player player, String title, Runnable confirm, Runnable decline) {
SWInventory inv = new SWInventory(player, 9, title);
inv.setItem(0, SWItem.getDye(1), "§cAbbrechen", clickType -> {
player.closeInventory();
decline.run();
});
inv.setItem(8, SWItem.getDye(10), "§aBestätigen", clickType -> {
player.closeInventory();
confirm.run();
});
inv.open(); inv.open();
} }

Datei anzeigen

@ -68,6 +68,15 @@ public class Region {
return regions; return regions;
} }
public static Region getRegionIn(Location location) {
for(Region region : Region.getRegions()) {
if (region.inRegion(location)) {
return region;
}
}
return null;
}
private final int minX; private final int minX;
private final int minY; private final int minY;
private final int minZ; private final int minZ;