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
3 geänderte Dateien mit 89 neuen und 9 gelöschten Zeilen
Nur Änderungen aus Commit 032a4c75d6 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -104,6 +104,7 @@ public class BauSystem extends JavaPlugin implements Listener {
Bukkit.getPluginManager().registerEvents(new ScriptListener(), this); Bukkit.getPluginManager().registerEvents(new ScriptListener(), this);
Bukkit.getPluginManager().registerEvents(new BauScoreboard(), this); Bukkit.getPluginManager().registerEvents(new BauScoreboard(), this);
Bukkit.getPluginManager().registerEvents(new ClipboardListener(), this); Bukkit.getPluginManager().registerEvents(new ClipboardListener(), this);
Bukkit.getPluginManager().registerEvents(new CommandGUI(), this);
new AFKStopper(); new AFKStopper();
autoShutdown = Bukkit.getScheduler().runTaskLater(this, Bukkit::shutdown, 1200); autoShutdown = Bukkit.getScheduler().runTaskLater(this, Bukkit::shutdown, 1200);

Datei anzeigen

@ -1,6 +1,9 @@
package de.steamwar.bausystem.commands; package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
import de.steamwar.bausystem.tracer.record.RecordStatus;
import de.steamwar.bausystem.tracer.show.TraceShowManager;
import de.steamwar.bausystem.world.Detonator; import de.steamwar.bausystem.world.Detonator;
import de.steamwar.bausystem.world.Region; import de.steamwar.bausystem.world.Region;
import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWAnvilInv;
@ -12,15 +15,20 @@ 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.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
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.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import java.util.*; import java.util.*;
public class CommandGUI implements CommandExecutor { public class CommandGUI implements CommandExecutor, Listener {
private static final Set<Player> OPEN_INVS = new HashSet<>(); private static final Set<Player> OPEN_INVS = new HashSet<>();
private static final Set<Player> OPEN_TRACER_INVS = new HashSet<>();
private static boolean isRefreshing = false; private static boolean isRefreshing = false;
@Override @Override
@ -73,6 +81,13 @@ public class CommandGUI implements CommandExecutor {
anvilInv.setCallback(s -> player.performCommand("speed " + s)); anvilInv.setCallback(s -> player.performCommand("speed " + s));
anvilInv.open(); anvilInv.open();
}); });
inv.setItem(22, Material.OBSERVER, "§7Tracer", Arrays.asList("§7Status: §e" + RecordStateMachine.getRecordStatus().getName()), false, clickType -> {
player.closeInventory();
OPEN_TRACER_INVS.add(player);
traceGUI(player);
});
inv.setItem(27, getMaterial("PLAYER_HEAD", "SKULL_ITEM"), (byte) 3, "§7Spielerkopf geben", Arrays.asList("§8/§7skull §8[§eSpieler§8]"), false, clickType -> { 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"); SWAnvilInv anvilInv = new SWAnvilInv(player, "Spielerköpfe");
anvilInv.setItem(Material.NAME_TAG); anvilInv.setItem(Material.NAME_TAG);
@ -80,7 +95,7 @@ public class CommandGUI implements CommandExecutor {
anvilInv.open(); anvilInv.open();
}); });
if(region == null) { if(region == Region.GlobalRegion.getInstance()) {
inv.setItem(17, Material.BARRIER, "§eKeine Region", clickType -> {}); inv.setItem(17, Material.BARRIER, "§eKeine Region", clickType -> {});
inv.setItem(26, Material.BARRIER, "§eKeine Region", clickType -> {}); inv.setItem(26, Material.BARRIER, "§eKeine Region", clickType -> {});
inv.setItem(35, Material.BARRIER, "§eKeine Region", clickType -> {}); inv.setItem(35, Material.BARRIER, "§eKeine Region", clickType -> {});
@ -129,19 +144,19 @@ public class CommandGUI implements CommandExecutor {
switch (region.getTntMode()) { switch (region.getTntMode()) {
case OFF: case OFF:
inv.setItem(40, Material.MINECART, "§7TNT: §eAusgeschaltet", Arrays.asList("§8/§7tnt §8[" + (Region.buildAreaEnabled()?"§etb§8, ":"") + "§eOff §7oder §eOn§7]"), false, clickType -> { inv.setItem(40, Material.MINECART, "§7TNT: §eAusgeschaltet", Arrays.asList("§8/§7tnt §8[" + (region.buildAreaEnabled()?"§eTB§7, ":"") + "§eOff §7oder §eOn§7]"), false, clickType -> {
region.setTntMode(Region.buildAreaEnabled()?CommandTNT.TNTMode.ONLY_TB: CommandTNT.TNTMode.ON); region.setTntMode(region.buildAreaEnabled()?CommandTNT.TNTMode.ONLY_TB: CommandTNT.TNTMode.ON);
updateInventories(); updateInventories();
}); });
break; break;
case ONLY_TB: 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 -> { inv.setItem(40, Material.TNT_MINECART, "§7TNT: §enur Testblock", Arrays.asList("§8/§7tnt §8[" + (region.buildAreaEnabled()?"§eTB§7, ":"") + "§eOff §7oder §eOn§7]"), false, clickType -> {
region.setTntMode(CommandTNT.TNTMode.ON); region.setTntMode(CommandTNT.TNTMode.ON);
updateInventories(); updateInventories();
}); });
break; break;
default: default:
inv.setItem(40, Material.TNT, "§7TNT: §eEingeschaltet", Arrays.asList("§8/§7tnt §8[" + (Region.buildAreaEnabled()?"§etb§8, ":"") + "§eOff §7oder §eOn§7]"), false, clickType -> { inv.setItem(40, Material.TNT, "§7TNT: §eEingeschaltet", Arrays.asList("§8/§7tnt §8[" + (region.buildAreaEnabled()?"§eTB§7, ":"") + "§eOff §7oder §eOn§7]"), false, clickType -> {
region.setTntMode(CommandTNT.TNTMode.OFF); region.setTntMode(CommandTNT.TNTMode.OFF);
updateInventories(); updateInventories();
}); });
@ -174,9 +189,60 @@ public class CommandGUI implements CommandExecutor {
inv.open(); inv.open();
} }
private static void traceGUI(Player player) {
SWInventory inv = new SWInventory(player, 9, "Tracer");
inv.setCallback(-1, clickType -> {
if(!isRefreshing)
OPEN_TRACER_INVS.remove(player);
});
switch (RecordStateMachine.getRecordStatus()) {
case IDLE:
inv.setItem(0, getMaterial("SNOWBALL", "SNOW_BALL"), "§7Tracerstatus", Arrays.asList("§7Aktuell: §e" + RecordStateMachine.getRecordStatus().getName()), false, clickType -> {
RecordStateMachine.commandAuto();
updateInventories();
});
break;
case IDLE_AUTO:
inv.setItem(0, Material.ENDER_PEARL, "§7Tracerstatus", Arrays.asList("§7Aktuell: §e" + RecordStateMachine.getRecordStatus().getName()), false, clickType -> {
RecordStateMachine.commandStart();
updateInventories();
});
break;
case RECORD:
case RECORD_AUTO:
inv.setItem(0, getMaterial("ENDER_EYE", "EYE_OF_ENDER"), "§7Tracerstatus", Arrays.asList("§7Aktuell: §e" + RecordStateMachine.getRecordStatus().getName()), false, clickType -> {
RecordStateMachine.commandStop();
updateInventories();
});
}
if(TraceShowManager.hasActiveShow(player)) {
inv.setItem(2, Material.TNT, "§7Showstatus", Arrays.asList("§7Aktuell: §eGezeigt"), false, clickType -> {
player.performCommand("trace hide");
traceGUI(player);
});
} else {
inv.setItem(2, Material.GLASS, "§7Showstatus", Arrays.asList("§7Aktuell: §eVersteckt"), false, clickType -> {
player.performCommand("trace show");
traceGUI(player);
});
}
inv.setItem(4, Material.TNT_MINECART, "§7Trace GUI", Collections.singletonList("§8/§7trace show gui"), false, clickType -> {
player.closeInventory();
player.performCommand("trace show gui");
});
inv.setItem(6, getMaterial("GRAY_STAINED_GLASS_PANE", "STAINED_GLASS_PANE"), (byte) 7, "§7Coming soon.", Collections.emptyList(), false, clickType -> {});
inv.setItem(8, Material.BARRIER, "§7Trace löschen", clickType -> confirmationInventory(player, "Trace löschen", () -> player.performCommand("trace delete"), () -> {}));
inv.open();
}
private static void updateInventories() { private static void updateInventories() {
isRefreshing = true; isRefreshing = true;
OPEN_INVS.forEach(CommandGUI::openBauGui); OPEN_INVS.forEach(CommandGUI::openBauGui);
OPEN_TRACER_INVS.forEach(CommandGUI::traceGUI);
isRefreshing = false; isRefreshing = false;
} }
@ -196,10 +262,19 @@ public class CommandGUI implements CommandExecutor {
private static Material getMaterial(String... names) { private static Material getMaterial(String... names) {
for (String name:names) { for (String name:names) {
try { try {
Material mat = Material.valueOf(name); return Material.valueOf(name);
return mat;
}catch (NullPointerException ignored) {} }catch (NullPointerException ignored) {}
} }
return null; return null;
} }
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if(event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if(event.getItem().getType() != Material.NETHER_STAR)
return;
openBauGui(event.getPlayer());
OPEN_INVS.add(event.getPlayer());
}
} }

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import org.bukkit.Material;
import org.bukkit.command.Command; 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;
@ -46,7 +47,10 @@ public class CommandSkull implements CommandExecutor {
assert sm != null; assert sm != null;
sm.setDisplayName("§e" + args[0] + "§8s Kopf"); sm.setDisplayName("§e" + args[0] + "§8s Kopf");
is.setItemMeta(sm); is.setItemMeta(sm);
p.getInventory().setItemInMainHand(is); if(p.getInventory().getItemInMainHand().getType() == Material.AIR)
p.getInventory().setItemInMainHand(is);
else
p.getInventory().setItemInOffHand(is);
Review

Separater PR.

Separater PR.
return false; return false;
} }
} }