Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0dddc0dfb5 | |||
| 7fe5bd62c7 | |||
| f7f0a0d532 | |||
| 35dded973b | |||
| 43dac083d4 |
2
pom.xml
2
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>de.nexuslobby</groupId>
|
<groupId>de.nexuslobby</groupId>
|
||||||
<artifactId>NexusLobby</artifactId>
|
<artifactId>NexusLobby</artifactId>
|
||||||
<version>1.1.1</version>
|
<version>1.1.4</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>NexusLobby</name>
|
<name>NexusLobby</name>
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
|||||||
private BorderModule borderModule;
|
private BorderModule borderModule;
|
||||||
private ParkourManager parkourManager;
|
private ParkourManager parkourManager;
|
||||||
private SoccerModule soccerModule;
|
private SoccerModule soccerModule;
|
||||||
|
private ArmorStandLookAtModule armorStandLookAtModule;
|
||||||
|
|
||||||
private ConversationManager conversationManager;
|
private ConversationManager conversationManager;
|
||||||
|
|
||||||
@@ -135,7 +136,7 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
|||||||
|
|
||||||
ServerChecker.startGlobalChecker();
|
ServerChecker.startGlobalChecker();
|
||||||
|
|
||||||
new ArmorStandLookAtModule();
|
armorStandLookAtModule = new ArmorStandLookAtModule();
|
||||||
|
|
||||||
startAutoConversationTimer();
|
startAutoConversationTimer();
|
||||||
|
|
||||||
@@ -192,7 +193,10 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ServerChecker.startGlobalChecker();
|
ServerChecker.startGlobalChecker();
|
||||||
new ArmorStandLookAtModule();
|
// FIX: ArmorStandLookAtModule als Feld tracken. Bukkit.getScheduler().cancelTasks()
|
||||||
|
// am Anfang von reloadPlugin() cancelt den alten Task bereits – hier nur
|
||||||
|
// neu starten und Referenz aktualisieren, damit kein doppelter Task läuft.
|
||||||
|
armorStandLookAtModule = new ArmorStandLookAtModule();
|
||||||
startAutoConversationTimer();
|
startAutoConversationTimer();
|
||||||
|
|
||||||
getLogger().info("Plugin Reload abgeschlossen. Änderungen wurden übernommen.");
|
getLogger().info("Plugin Reload abgeschlossen. Änderungen wurden übernommen.");
|
||||||
|
|||||||
@@ -28,65 +28,116 @@ public class LobbyTabCompleter implements TabCompleter {
|
|||||||
List<String> suggestions = new ArrayList<>();
|
List<String> suggestions = new ArrayList<>();
|
||||||
String cmdName = command.getName().toLowerCase();
|
String cmdName = command.getName().toLowerCase();
|
||||||
|
|
||||||
// --- NexusLobby Hauptbefehl (/nexus) ---
|
// ── NexusLobby Hauptbefehl (/nexus oder /nexuslobby) ──────────────────
|
||||||
if (cmdName.equals("nexuslobby") || cmdName.equals("nexus")) {
|
if (cmdName.equals("nexuslobby") || cmdName.equals("nexus")) {
|
||||||
|
|
||||||
|
// /nexuslobby <?>
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
if (sender.hasPermission("nexuslobby.admin")) {
|
if (sender.hasPermission("nexuslobby.admin")) {
|
||||||
suggestions.addAll(Arrays.asList("reload", "setspawn", "silentjoin", "parkour", "ball")); // NEU: ball
|
suggestions.addAll(Arrays.asList(
|
||||||
|
"reload", "setspawn", "silentjoin", "parkour", "ball", "cleanbubbles", "gadgetshield"
|
||||||
|
));
|
||||||
}
|
}
|
||||||
suggestions.add("sb");
|
suggestions.add("sb");
|
||||||
|
|
||||||
|
// /nexuslobby <sub> <?>
|
||||||
} else if (args.length == 2) {
|
} else if (args.length == 2) {
|
||||||
if (args[0].equalsIgnoreCase("sb")) {
|
switch (args[0].toLowerCase()) {
|
||||||
|
case "sb" -> {
|
||||||
suggestions.addAll(Arrays.asList("on", "off"));
|
suggestions.addAll(Arrays.asList("on", "off"));
|
||||||
if (sender.hasPermission("nexuslobby.scoreboard.admin")) {
|
if (sender.hasPermission("nexuslobby.scoreboard.admin"))
|
||||||
suggestions.addAll(Arrays.asList("admin", "spieler"));
|
suggestions.addAll(Arrays.asList("admin", "spieler"));
|
||||||
}
|
}
|
||||||
} else if (args[0].equalsIgnoreCase("silentjoin")) {
|
case "silentjoin" -> suggestions.addAll(Arrays.asList("on", "off"));
|
||||||
suggestions.addAll(Arrays.asList("on", "off"));
|
case "parkour" -> {
|
||||||
} else if (args[0].equalsIgnoreCase("parkour")) {
|
|
||||||
suggestions.addAll(Arrays.asList("setstart", "setfinish", "setcheckpoint", "reset", "clear", "removeall"));
|
|
||||||
} else if (args[0].equalsIgnoreCase("ball")) {
|
|
||||||
if (sender.hasPermission("nexuslobby.admin")) {
|
if (sender.hasPermission("nexuslobby.admin")) {
|
||||||
suggestions.addAll(Arrays.asList("setspawn", "respawn", "remove"));
|
suggestions.addAll(Arrays.asList(
|
||||||
|
"setstart", "setfinish", "setcheckpoint",
|
||||||
|
"reset", "clear", "removeall", "info"
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
// Normale Spieler können nur ihren Run abbrechen
|
||||||
|
suggestions.add("reset");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (args.length == 3) {
|
case "ball" -> {
|
||||||
if (args[0].equalsIgnoreCase("parkour") && args[1].equalsIgnoreCase("setcheckpoint")) {
|
if (sender.hasPermission("nexuslobby.admin")) {
|
||||||
suggestions.addAll(Arrays.asList("1", "2", "3", "4", "5", "6", "7", "8", "9"));
|
suggestions.addAll(Arrays.asList(
|
||||||
|
"setspawn", "respawn", "remove", "goal", "score"
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Hologram Befehl ---
|
// /nexuslobby <sub> <sub2> <?>
|
||||||
|
} else if (args.length == 3) {
|
||||||
|
switch (args[0].toLowerCase()) {
|
||||||
|
// Für setstart / setfinish / setcheckpoint → Strecken-Nummer 1 oder 2
|
||||||
|
case "parkour" -> {
|
||||||
|
String parkSub = args[1].toLowerCase();
|
||||||
|
if (parkSub.equals("setstart")
|
||||||
|
|| parkSub.equals("setfinish")
|
||||||
|
|| parkSub.equals("setcheckpoint")) {
|
||||||
|
suggestions.addAll(Arrays.asList("1", "2"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case "ball" -> {
|
||||||
|
switch (args[1].toLowerCase()) {
|
||||||
|
case "goal" -> suggestions.addAll(Arrays.asList(
|
||||||
|
"pos1", "pos2", "save", "delete", "list", "show", "debug"
|
||||||
|
));
|
||||||
|
case "score" -> suggestions.add("reset");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// /nexuslobby <sub> <sub2> <sub3> <?>
|
||||||
|
} else if (args.length == 4) {
|
||||||
|
if (args[0].equalsIgnoreCase("ball") && args[1].equalsIgnoreCase("goal")) {
|
||||||
|
switch (args[2].toLowerCase()) {
|
||||||
|
case "save" -> suggestions.add("<TorName>");
|
||||||
|
case "delete" -> {
|
||||||
|
var section = NexusLobby.getInstance().getConfig()
|
||||||
|
.getConfigurationSection("ball.goals");
|
||||||
|
if (section != null) suggestions.addAll(section.getKeys(false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// /nexuslobby ball goal save <Name> <?> → Team 1 oder 2
|
||||||
|
} else if (args.length == 5) {
|
||||||
|
if (args[0].equalsIgnoreCase("ball")
|
||||||
|
&& args[1].equalsIgnoreCase("goal")
|
||||||
|
&& args[2].equalsIgnoreCase("save")) {
|
||||||
|
suggestions.addAll(Arrays.asList("1", "2"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Hologram Befehl ───────────────────────────────────────────────────
|
||||||
else if (cmdName.equals("holo")) {
|
else if (cmdName.equals("holo")) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
suggestions.addAll(Arrays.asList("create", "delete"));
|
suggestions.addAll(Arrays.asList("create", "delete"));
|
||||||
} else if (args.length == 2 && args[0].equalsIgnoreCase("delete")) {
|
} else if (args.length == 2 && args[0].equalsIgnoreCase("delete")) {
|
||||||
if (hologramModule != null) {
|
if (hologramModule != null) suggestions.addAll(hologramModule.getHologramIds());
|
||||||
suggestions.addAll(hologramModule.getHologramIds());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Wartungsmodus ---
|
// ── Wartungsmodus ─────────────────────────────────────────────────────
|
||||||
else if (cmdName.equals("maintenance")) {
|
else if (cmdName.equals("maintenance")) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) suggestions.addAll(Arrays.asList("on", "off"));
|
||||||
suggestions.addAll(Arrays.asList("on", "off"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Portalsystem ---
|
// ── Portalsystem ──────────────────────────────────────────────────────
|
||||||
else if (cmdName.equals("portal")) {
|
else if (cmdName.equals("portal")) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
suggestions.addAll(Arrays.asList("create", "delete", "list"));
|
suggestions.addAll(Arrays.asList("create", "delete", "list"));
|
||||||
} else if (args.length == 2 && args[0].equalsIgnoreCase("delete")) {
|
} else if (args.length == 2 && args[0].equalsIgnoreCase("delete")) {
|
||||||
if (portalManager != null) {
|
if (portalManager != null) suggestions.addAll(portalManager.getPortalNames());
|
||||||
suggestions.addAll(portalManager.getPortalNames());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- MapArt ---
|
// ── MapArt ────────────────────────────────────────────────────────────
|
||||||
else if (cmdName.equals("mapart")) {
|
else if (cmdName.equals("mapart")) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
suggestions.add("https://");
|
suggestions.add("https://");
|
||||||
@@ -95,14 +146,12 @@ public class LobbyTabCompleter implements TabCompleter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Intro System ---
|
// ── Intro System ──────────────────────────────────────────────────────
|
||||||
else if (cmdName.equals("intro")) {
|
else if (cmdName.equals("intro")) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) suggestions.addAll(Arrays.asList("add", "clear", "start"));
|
||||||
suggestions.addAll(Arrays.asList("add", "clear", "start"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- WorldBorder ---
|
// ── WorldBorder ───────────────────────────────────────────────────────
|
||||||
else if (cmdName.equals("border")) {
|
else if (cmdName.equals("border")) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
suggestions.addAll(Arrays.asList("circle", "square", "disable"));
|
suggestions.addAll(Arrays.asList("circle", "square", "disable"));
|
||||||
@@ -111,62 +160,51 @@ public class LobbyTabCompleter implements TabCompleter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- NexusCmd / ArmorStandTools ---
|
// ── NexusCmd / ArmorStandTools ────────────────────────────────────────
|
||||||
else if (cmdName.equals("nexuscmd") || cmdName.equals("ncmd") || cmdName.equals("ascmd") || cmdName.equals("conv")) {
|
else if (cmdName.equals("nexuscmd") || cmdName.equals("ncmd")
|
||||||
|
|| cmdName.equals("ascmd") || cmdName.equals("conv")) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
suggestions.addAll(Arrays.asList("add", "remove", "list", "name", "lookat", "conv", "say"));
|
suggestions.addAll(Arrays.asList("add", "remove", "list", "name", "lookat", "conv", "say", "clearbubbles"));
|
||||||
|
} else if (args.length == 2) {
|
||||||
|
switch (args[0].toLowerCase()) {
|
||||||
|
case "add" -> suggestions.addAll(Arrays.asList("0","1","2","3","4","5","6","7","8","9"));
|
||||||
|
case "name" -> suggestions.addAll(Arrays.asList("<Anzeigename>", "none"));
|
||||||
|
case "conv" -> suggestions.addAll(Arrays.asList("select1","select2","select3","select4","link","unlink","start"));
|
||||||
|
case "remove" -> suggestions.addAll(Arrays.asList("0","1","2","3","4","5","6","7","8","9","all"));
|
||||||
|
case "say" -> suggestions.add("<Nachricht>");
|
||||||
}
|
}
|
||||||
else if (args.length == 2) {
|
} else if (args.length == 3) {
|
||||||
if (args[0].equalsIgnoreCase("add")) {
|
if (args[0].equalsIgnoreCase("add")) {
|
||||||
suggestions.addAll(Arrays.asList("0","1","2","3","4","5","6","7","8","9"));
|
suggestions.addAll(Arrays.asList("0","1","2","3","4","5","6","7","8","9"));
|
||||||
} else if (args[0].equalsIgnoreCase("name")) {
|
} else if (args[0].equalsIgnoreCase("conv")
|
||||||
suggestions.addAll(Arrays.asList("<Anzeigename>", "none"));
|
&& (args[1].equalsIgnoreCase("start") || args[1].equalsIgnoreCase("link"))) {
|
||||||
} else if (args[0].equalsIgnoreCase("conv")) {
|
if (NexusLobby.getInstance().getConversationManager() != null)
|
||||||
suggestions.addAll(Arrays.asList("select1", "select2", "select3", "select4", "link", "unlink", "start"));
|
|
||||||
} else if (args[0].equalsIgnoreCase("remove")) {
|
|
||||||
suggestions.addAll(Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "all"));
|
|
||||||
} else if (args[0].equalsIgnoreCase("say")) {
|
|
||||||
suggestions.add("<Nachricht>");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (args.length == 3) {
|
|
||||||
if (args[0].equalsIgnoreCase("add")) {
|
|
||||||
suggestions.addAll(Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"));
|
|
||||||
} else if (args[0].equalsIgnoreCase("conv")) {
|
|
||||||
if (args[1].equalsIgnoreCase("start") || args[1].equalsIgnoreCase("link")) {
|
|
||||||
if (NexusLobby.getInstance().getConversationManager() != null) {
|
|
||||||
suggestions.addAll(NexusLobby.getInstance().getConversationManager().getConversationIds());
|
suggestions.addAll(NexusLobby.getInstance().getConversationManager().getConversationIds());
|
||||||
}
|
}
|
||||||
}
|
} else if (args.length == 4 && args[0].equalsIgnoreCase("add")) {
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (args.length == 4 && args[0].equalsIgnoreCase("add")) {
|
|
||||||
suggestions.addAll(Arrays.asList("bungee", "console", "player"));
|
suggestions.addAll(Arrays.asList("bungee", "console", "player"));
|
||||||
}
|
} else if (args.length == 5 && args[0].equalsIgnoreCase("add")
|
||||||
else if (args.length == 5 && args[0].equalsIgnoreCase("add") && args[3].equalsIgnoreCase("bungee")) {
|
&& args[3].equalsIgnoreCase("bungee")) {
|
||||||
if (NexusLobby.getInstance().getConfig().getConfigurationSection("servers") != null) {
|
var section = NexusLobby.getInstance().getConfig().getConfigurationSection("servers");
|
||||||
suggestions.addAll(NexusLobby.getInstance().getConfig().getConfigurationSection("servers").getKeys(false));
|
if (section != null) suggestions.addAll(section.getKeys(false));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- ArmorStandTools Alternate ---
|
// ── ArmorStandTools Alternate ─────────────────────────────────────────
|
||||||
else if (cmdName.equals("astools") || cmdName.equals("nt") || cmdName.equals("ntools")) {
|
else if (cmdName.equals("astools") || cmdName.equals("nt") || cmdName.equals("ntools")) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
suggestions.addAll(Arrays.asList("dynamic","lookat","addplayer","addconsole","remove","reload","say"));
|
suggestions.addAll(Arrays.asList("dynamic","lookat","addplayer","addconsole","remove","reload","say"));
|
||||||
}
|
} else if (args.length == 2) {
|
||||||
else if (args.length == 2 && args[0].equalsIgnoreCase("say")) {
|
if (args[0].equalsIgnoreCase("say"))
|
||||||
suggestions.add("<Nachricht>");
|
suggestions.add("<Nachricht>");
|
||||||
}
|
else if (args[0].equalsIgnoreCase("addplayer") || args[0].equalsIgnoreCase("addconsole"))
|
||||||
else if (args.length == 2 && (args[0].equalsIgnoreCase("addplayer") || args[0].equalsIgnoreCase("addconsole"))) {
|
|
||||||
suggestions.addAll(Arrays.asList("0","1","2","3","4","5","6","7","8","9"));
|
suggestions.addAll(Arrays.asList("0","1","2","3","4","5","6","7","8","9"));
|
||||||
}
|
} else if (args.length == 3) {
|
||||||
else if (args.length == 3 && (args[0].equalsIgnoreCase("addplayer") || args[0].equalsIgnoreCase("addconsole"))) {
|
if (args[0].equalsIgnoreCase("addplayer") || args[0].equalsIgnoreCase("addconsole"))
|
||||||
suggestions.addAll(Arrays.asList("0","1","2","3","4","5","6","7","8","9"));
|
suggestions.addAll(Arrays.asList("0","1","2","3","4","5","6","7","8","9"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filtert die Liste basierend auf der bisherigen Eingabe
|
|
||||||
return suggestions.stream()
|
return suggestions.stream()
|
||||||
.filter(s -> s.toLowerCase().startsWith(args[args.length - 1].toLowerCase()))
|
.filter(s -> s.toLowerCase().startsWith(args[args.length - 1].toLowerCase()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|||||||
@@ -34,19 +34,18 @@ public class NexusLobbyCommand implements CommandExecutor {
|
|||||||
// --- DIREKTE KURZ-BEFEHLE ---
|
// --- DIREKTE KURZ-BEFEHLE ---
|
||||||
if (cmdName.equalsIgnoreCase("setstart")) {
|
if (cmdName.equalsIgnoreCase("setstart")) {
|
||||||
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
||||||
handleSetStart(player, pm);
|
// Standard: Strecke 1 setzen
|
||||||
|
pm.setStartLocation(player, 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (cmdName.equalsIgnoreCase("setcheckpoint")) {
|
if (cmdName.equalsIgnoreCase("setcheckpoint")) {
|
||||||
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
||||||
pm.setCheckpoint(player, player.getLocation());
|
pm.setCheckpoint(player, 1);
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_checkpoint_set"));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (cmdName.equalsIgnoreCase("setfinish")) {
|
if (cmdName.equalsIgnoreCase("setfinish")) {
|
||||||
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
||||||
pm.setFinishLocation(player.getLocation());
|
pm.setFinishLocation(player, 1);
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_finish_set"));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,6 +74,7 @@ public class NexusLobbyCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (args[0].toLowerCase()) {
|
switch (args[0].toLowerCase()) {
|
||||||
|
|
||||||
case "reload":
|
case "reload":
|
||||||
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
||||||
NexusLobby.getInstance().reloadPlugin();
|
NexusLobby.getInstance().reloadPlugin();
|
||||||
@@ -82,6 +82,11 @@ public class NexusLobbyCommand implements CommandExecutor {
|
|||||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1f, 1.5f);
|
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1f, 1.5f);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "cleanbubbles":
|
||||||
|
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
||||||
|
handleCleanBubbles(player);
|
||||||
|
break;
|
||||||
|
|
||||||
case "setspawn":
|
case "setspawn":
|
||||||
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
||||||
Location loc = player.getLocation();
|
Location loc = player.getLocation();
|
||||||
@@ -111,7 +116,12 @@ public class NexusLobbyCommand implements CommandExecutor {
|
|||||||
handleScoreboard(player, args);
|
handleScoreboard(player, args);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "ball": // NEU: Weiterleitung an das SoccerModule
|
case "gadgetshield":
|
||||||
|
if (!player.hasPermission("nexuslobby.admin") && !player.isOp()) return noPerm(player);
|
||||||
|
de.nexuslobby.modules.gadgets.GadgetShield.toggle(player);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "ball":
|
||||||
if (NexusLobby.getInstance().getSoccerModule() != null) {
|
if (NexusLobby.getInstance().getSoccerModule() != null) {
|
||||||
return NexusLobby.getInstance().getSoccerModule().onCommand(sender, command, label, args);
|
return NexusLobby.getInstance().getSoccerModule().onCommand(sender, command, label, args);
|
||||||
}
|
}
|
||||||
@@ -119,42 +129,7 @@ public class NexusLobbyCommand implements CommandExecutor {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "parkour":
|
case "parkour":
|
||||||
if (args.length < 2) {
|
handleParkour(player, args, pm);
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_usage"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
String sub = args[1].toLowerCase();
|
|
||||||
if (!player.hasPermission("nexuslobby.admin") && !sub.equals("reset")) return noPerm(player);
|
|
||||||
|
|
||||||
switch (sub) {
|
|
||||||
case "setstart":
|
|
||||||
handleSetStart(player, pm);
|
|
||||||
break;
|
|
||||||
case "setfinish":
|
|
||||||
pm.setFinishLocation(player.getLocation());
|
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_finish_set"));
|
|
||||||
break;
|
|
||||||
case "setcheckpoint":
|
|
||||||
pm.setCheckpoint(player, player.getLocation());
|
|
||||||
break;
|
|
||||||
case "reset":
|
|
||||||
pm.stopParkour(player);
|
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_run_aborted"));
|
|
||||||
break;
|
|
||||||
case "clear":
|
|
||||||
pm.clearStats();
|
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_besttimes_cleared"));
|
|
||||||
break;
|
|
||||||
case "removeall":
|
|
||||||
pm.removeAllPoints();
|
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_track_removed"));
|
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1f, 1f);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("unknown_subcommand"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -165,13 +140,109 @@ public class NexusLobbyCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleSetStart(Player player, ParkourManager pm) {
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
// NPC Erkennung (Blickrichtung auf ArmorStand)
|
// Parkour-Handler
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
private void handleParkour(Player player, String[] args, ParkourManager pm) {
|
||||||
|
if (args.length < 2) {
|
||||||
|
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_usage"));
|
||||||
|
// Strecken-Info ausgeben
|
||||||
|
player.sendMessage(pm.getTrackInfo());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String sub = args[1].toLowerCase();
|
||||||
|
|
||||||
|
// Nur "reset" kann auch ohne Admin-Recht ausgeführt werden (eigenen Lauf abbrechen)
|
||||||
|
if (!player.hasPermission("nexuslobby.admin") && !sub.equals("reset")) {
|
||||||
|
noPerm(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (sub) {
|
||||||
|
|
||||||
|
// /nexus parkour setstart <1|2>
|
||||||
|
case "setstart": {
|
||||||
|
int track = parseTrack(args, 2, player);
|
||||||
|
if (track == -1) return;
|
||||||
|
handleSetStart(player, pm, track);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// /nexus parkour setfinish <1|2>
|
||||||
|
case "setfinish": {
|
||||||
|
int track = parseTrack(args, 2, player);
|
||||||
|
if (track == -1) return;
|
||||||
|
pm.setFinishLocation(player, track);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// /nexus parkour setcheckpoint <1|2>
|
||||||
|
case "setcheckpoint": {
|
||||||
|
int track = parseTrack(args, 2, player);
|
||||||
|
if (track == -1) return;
|
||||||
|
pm.setCheckpoint(player, track);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case "reset":
|
||||||
|
pm.stopParkour(player);
|
||||||
|
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_run_aborted"));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "clear":
|
||||||
|
pm.clearStats();
|
||||||
|
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_besttimes_cleared"));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "removeall":
|
||||||
|
pm.removeAllPoints();
|
||||||
|
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_track_removed"));
|
||||||
|
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1f, 1f);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "info":
|
||||||
|
player.sendMessage(pm.getTrackInfo());
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
player.sendMessage(de.nexuslobby.utils.LangManager.get("unknown_subcommand"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Liest die Track-Nummer aus args[index].
|
||||||
|
* Gibt 1 oder 2 zurück; bei Fehler sendet er eine Nachricht und gibt -1 zurück.
|
||||||
|
*/
|
||||||
|
private int parseTrack(String[] args, int index, Player player) {
|
||||||
|
if (args.length <= index) {
|
||||||
|
player.sendMessage("§8[§6Nexus§8] §cBitte gib eine Strecken-Nummer an: §e1 §7oder §e2");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
int track;
|
||||||
|
try {
|
||||||
|
track = Integer.parseInt(args[index]);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
player.sendMessage("§8[§6Nexus§8] §cUngültige Strecken-Nummer. Bitte §e1 §7oder §e2 §7verwenden.");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (track < 1 || track > 2) {
|
||||||
|
player.sendMessage("§8[§6Nexus§8] §cNur Strecke §e1 §7oder §e2 §7sind erlaubt.");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return track;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleSetStart(Player player, ParkourManager pm, int track) {
|
||||||
|
// NPC-Erkennung: schaut der Spieler auf einen ArmorStand?
|
||||||
ArmorStand targetAs = null;
|
ArmorStand targetAs = null;
|
||||||
List<Entity> nearby = player.getNearbyEntities(4, 4, 4);
|
List<Entity> nearby = player.getNearbyEntities(4, 4, 4);
|
||||||
for (Entity e : nearby) {
|
for (Entity e : nearby) {
|
||||||
if (e instanceof ArmorStand as) {
|
if (e instanceof ArmorStand as) {
|
||||||
double dot = player.getLocation().getDirection().dot(as.getLocation().toVector().subtract(player.getLocation().toVector()).normalize());
|
double dot = player.getLocation().getDirection()
|
||||||
|
.dot(as.getLocation().toVector().subtract(player.getLocation().toVector()).normalize());
|
||||||
if (dot > 0.9) {
|
if (dot > 0.9) {
|
||||||
targetAs = as;
|
targetAs = as;
|
||||||
break;
|
break;
|
||||||
@@ -183,8 +254,23 @@ public class NexusLobbyCommand implements CommandExecutor {
|
|||||||
targetAs.addScoreboardTag("parkour_npc");
|
targetAs.addScoreboardTag("parkour_npc");
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_npc_marked"));
|
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_npc_marked"));
|
||||||
}
|
}
|
||||||
pm.setStartLocation(player.getLocation());
|
pm.setStartLocation(player, track);
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_start_set"));
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
|
// Sonstige Handler
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
private void handleCleanBubbles(Player player) {
|
||||||
|
de.nexuslobby.modules.armorstandtools.ConversationManager cm =
|
||||||
|
NexusLobby.getInstance().getConversationManager();
|
||||||
|
if (cm == null) {
|
||||||
|
player.sendMessage("§8[§6Nexus§8] §cConversationManager ist nicht aktiv.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cm.clearHangingBubbles();
|
||||||
|
player.sendMessage("§8[§6Nexus§8] §aAlle hängengebliebenen Sprechblasen wurden entfernt.");
|
||||||
|
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1f, 2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean noPerm(Player player) {
|
private boolean noPerm(Player player) {
|
||||||
@@ -202,18 +288,17 @@ public class NexusLobbyCommand implements CommandExecutor {
|
|||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("scoreboard_module_disabled"));
|
player.sendMessage(de.nexuslobby.utils.LangManager.get("scoreboard_module_disabled"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String sub = args[1].toLowerCase();
|
switch (args[1].toLowerCase()) {
|
||||||
switch (sub) {
|
case "on" -> sbModule.setVisibility(player, true);
|
||||||
case "on": sbModule.setVisibility(player, true); break;
|
case "off" -> sbModule.setVisibility(player, false);
|
||||||
case "off": sbModule.setVisibility(player, false); break;
|
case "admin" -> {
|
||||||
case "admin":
|
|
||||||
if (player.hasPermission("nexuslobby.scoreboard.admin")) sbModule.setAdminMode(player, true);
|
if (player.hasPermission("nexuslobby.scoreboard.admin")) sbModule.setAdminMode(player, true);
|
||||||
else player.sendMessage(de.nexuslobby.utils.LangManager.get("no_permission"));
|
else player.sendMessage(de.nexuslobby.utils.LangManager.get("no_permission"));
|
||||||
break;
|
}
|
||||||
case "spieler":
|
case "spieler" -> {
|
||||||
if (player.hasPermission("nexuslobby.scoreboard.admin")) sbModule.setAdminMode(player, false);
|
if (player.hasPermission("nexuslobby.scoreboard.admin")) sbModule.setAdminMode(player, false);
|
||||||
else player.sendMessage(de.nexuslobby.utils.LangManager.get("no_permission"));
|
else player.sendMessage(de.nexuslobby.utils.LangManager.get("no_permission"));
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,12 +315,19 @@ public class NexusLobbyCommand implements CommandExecutor {
|
|||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_title"));
|
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_title"));
|
||||||
player.sendMessage("");
|
player.sendMessage("");
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_spawn"));
|
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_spawn"));
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_parkour"));
|
player.sendMessage("§e/nexus parkour setstart <1|2> §7- Start setzen");
|
||||||
|
player.sendMessage("§e/nexus parkour setcheckpoint <1|2> §7- Checkpoint setzen");
|
||||||
|
player.sendMessage("§e/nexus parkour setfinish <1|2> §7- Ziel setzen");
|
||||||
|
player.sendMessage("§e/nexus parkour reset §7- Eigenen Run abbrechen");
|
||||||
|
player.sendMessage("§e/nexus parkour clear §7- §cTop-10 Liste löschen");
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_removeall"));
|
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_removeall"));
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_ball"));
|
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_ball"));
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_setspawn"));
|
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_setspawn"));
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_scoreboard"));
|
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_scoreboard"));
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_reload"));
|
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_reload"));
|
||||||
|
player.sendMessage("§e/nexuslobby cleanbubbles §7- Hängende Sprechblasen entfernen");
|
||||||
|
if (player.hasPermission("nexuslobby.admin") || player.isOp())
|
||||||
|
player.sendMessage("§e/nexuslobby gadgetshield §7- Gadget-Schutz für Admins ein/ausschalten");
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_footer"));
|
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_footer"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,11 +6,14 @@ import de.nexuslobby.commands.BuildCommand;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.event.block.BlockExplodeEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.event.entity.EntityPickupItemEvent;
|
import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
@@ -30,7 +33,11 @@ public class ProtectionModule implements Module, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {}
|
public void onDisable() {
|
||||||
|
// FIX: Listener nach dem Deaktivieren abmelden, damit nach /reload
|
||||||
|
// keine doppelten Events ausgelöst werden.
|
||||||
|
HandlerList.unregisterAll(this);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
@@ -91,4 +98,22 @@ public class ProtectionModule implements Module, Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIX: Fehlender Explosionsschutz - settings.yml hat allowExplosions: false,
|
||||||
|
// aber bisher gab es keinen Handler dafür.
|
||||||
|
@EventHandler
|
||||||
|
public void onEntityExplode(EntityExplodeEvent event) {
|
||||||
|
if (!getSettings().getBoolean("allowExplosions", false)) {
|
||||||
|
event.blockList().clear();
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockExplode(BlockExplodeEvent event) {
|
||||||
|
if (!getSettings().getBoolean("allowExplosions", false)) {
|
||||||
|
event.blockList().clear();
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -10,8 +10,10 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.scoreboard.*;
|
import org.bukkit.scoreboard.*;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@@ -24,10 +26,12 @@ public class ScoreboardModule implements Module, Listener {
|
|||||||
private final NexusLobby plugin = NexusLobby.getInstance();
|
private final NexusLobby plugin = NexusLobby.getInstance();
|
||||||
private boolean placeholderAPIEnabled;
|
private boolean placeholderAPIEnabled;
|
||||||
|
|
||||||
// Speicher für die aktuellen Spieler-Einstellungen (bis zum Restart/Reload)
|
|
||||||
private final Set<UUID> hiddenPlayers = new HashSet<>();
|
private final Set<UUID> hiddenPlayers = new HashSet<>();
|
||||||
private final Set<UUID> adminModePlayers = new HashSet<>();
|
private final Set<UUID> adminModePlayers = new HashSet<>();
|
||||||
|
|
||||||
|
// WICHTIG: Hier speichern wir die Scoreboards pro Spieler, um sie wiederzuverwenden
|
||||||
|
private final Map<UUID, Scoreboard> playerBoards = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Scoreboard";
|
return "Scoreboard";
|
||||||
@@ -38,7 +42,6 @@ public class ScoreboardModule implements Module, Listener {
|
|||||||
FileConfiguration vConfig = plugin.getVisualsConfig();
|
FileConfiguration vConfig = plugin.getVisualsConfig();
|
||||||
if (!vConfig.getBoolean("scoreboard.enabled", true)) return;
|
if (!vConfig.getBoolean("scoreboard.enabled", true)) return;
|
||||||
|
|
||||||
// Listener registrieren
|
|
||||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||||
|
|
||||||
placeholderAPIEnabled = Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null;
|
placeholderAPIEnabled = Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null;
|
||||||
@@ -53,9 +56,6 @@ public class ScoreboardModule implements Module, Listener {
|
|||||||
}.runTaskTimer(plugin, 0L, vConfig.getLong("scoreboard.update_ticks", 20L));
|
}.runTaskTimer(plugin, 0L, vConfig.getLong("scoreboard.update_ticks", 20L));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Setzt Scoreboard-Status beim Join gemäß config.yml (scoreboard-default-visible)
|
|
||||||
*/
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
@@ -63,13 +63,19 @@ public class ScoreboardModule implements Module, Listener {
|
|||||||
if (!defaultVisible) {
|
if (!defaultVisible) {
|
||||||
hiddenPlayers.add(player.getUniqueId());
|
hiddenPlayers.add(player.getUniqueId());
|
||||||
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
|
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
|
||||||
|
// Sicherstellen, dass kein altes Board gespeichert ist
|
||||||
|
playerBoards.remove(player.getUniqueId());
|
||||||
} else {
|
} else {
|
||||||
hiddenPlayers.remove(player.getUniqueId());
|
hiddenPlayers.remove(player.getUniqueId());
|
||||||
|
// Beim Einloggen initialisieren, damit es nicht beim ersten Tick flackert
|
||||||
|
if (!playerBoards.containsKey(player.getUniqueId())) {
|
||||||
|
playerBoards.put(player.getUniqueId(), Bukkit.getScoreboardManager().getNewScoreboard());
|
||||||
|
player.setScoreboard(playerBoards.get(player.getUniqueId()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSidebar(Player player) {
|
private void updateSidebar(Player player) {
|
||||||
// 1. Prüfen, ob der Spieler das Scoreboard ausgeblendet hat
|
|
||||||
if (hiddenPlayers.contains(player.getUniqueId())) {
|
if (hiddenPlayers.contains(player.getUniqueId())) {
|
||||||
if (player.getScoreboard() != Bukkit.getScoreboardManager().getMainScoreboard()) {
|
if (player.getScoreboard() != Bukkit.getScoreboardManager().getMainScoreboard()) {
|
||||||
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
|
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
|
||||||
@@ -78,49 +84,50 @@ public class ScoreboardModule implements Module, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FileConfiguration vConfig = plugin.getVisualsConfig();
|
FileConfiguration vConfig = plugin.getVisualsConfig();
|
||||||
Scoreboard board = player.getScoreboard();
|
|
||||||
|
|
||||||
if (board == Bukkit.getScoreboardManager().getMainScoreboard()) {
|
String configPath = (adminModePlayers.contains(player.getUniqueId())
|
||||||
|
&& player.hasPermission("nexuslobby.scoreboard.admin"))
|
||||||
|
? "scoreboard.owner"
|
||||||
|
: "scoreboard.default";
|
||||||
|
|
||||||
|
String title = vConfig.getString(configPath + ".title", "&6&lNexusLobby");
|
||||||
|
List<String> lines = vConfig.getStringList(configPath + ".lines");
|
||||||
|
|
||||||
|
// ---------------------------------------------------------
|
||||||
|
// FIX: Statt getNewScoreboard() holen wir das gespeicherte Board
|
||||||
|
// oder erstellen es genau einmal beim ersten Mal.
|
||||||
|
// ---------------------------------------------------------
|
||||||
|
Scoreboard board = playerBoards.get(player.getUniqueId());
|
||||||
|
|
||||||
|
if (board == null) {
|
||||||
board = Bukkit.getScoreboardManager().getNewScoreboard();
|
board = Bukkit.getScoreboardManager().getNewScoreboard();
|
||||||
|
playerBoards.put(player.getUniqueId(), board);
|
||||||
player.setScoreboard(board);
|
player.setScoreboard(board);
|
||||||
}
|
}
|
||||||
|
|
||||||
Objective obj = board.getObjective("lobby");
|
// Altes Objective entfernen, damit wir die Zeilen aktualisieren können
|
||||||
if (obj == null) {
|
// Dasboard selbst bleibt bestehen (wichtig für Tablist-Teams!)
|
||||||
obj = board.registerNewObjective("lobby", "dummy", "title");
|
Objective oldObj = board.getObjective("lobby");
|
||||||
|
if (oldObj != null) {
|
||||||
|
oldObj.unregister();
|
||||||
|
}
|
||||||
|
|
||||||
|
Objective obj = board.registerNewObjective("lobby", "dummy",
|
||||||
|
translate(player, title));
|
||||||
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||||
}
|
|
||||||
|
|
||||||
// 2. Pfad-Logik basierend auf dem Modus (/nexus sb admin/spieler)
|
|
||||||
String configPath = "scoreboard.default";
|
|
||||||
|
|
||||||
// Wenn im Admin-Modus UND Rechte vorhanden -> owner Sektion
|
|
||||||
if (adminModePlayers.contains(player.getUniqueId()) && player.hasPermission("nexuslobby.scoreboard.admin")) {
|
|
||||||
configPath = "scoreboard.owner";
|
|
||||||
} else {
|
|
||||||
// Standardmäßig default nutzen
|
|
||||||
configPath = "scoreboard.default";
|
|
||||||
}
|
|
||||||
|
|
||||||
String title = vConfig.getString(configPath + ".title", "&6&lNexusLobby");
|
|
||||||
obj.setDisplayName(translate(player, title));
|
|
||||||
|
|
||||||
List<String> lines = vConfig.getStringList(configPath + ".lines");
|
|
||||||
|
|
||||||
// Scores zurücksetzen um Duplikate zu vermeiden
|
|
||||||
board.getEntries().forEach(board::resetScores);
|
|
||||||
|
|
||||||
for (int i = 0; i < lines.size(); i++) {
|
for (int i = 0; i < lines.size(); i++) {
|
||||||
String line = translate(player, lines.get(i));
|
String line = translate(player, lines.get(i));
|
||||||
|
|
||||||
// Verhindert das Verschwinden leerer Zeilen
|
if (line.isEmpty() || line.isBlank()) {
|
||||||
if (line.isEmpty() || line.trim().isEmpty()) {
|
line = ChatColor.values()[i % ChatColor.values().length].toString();
|
||||||
line = "" + ChatColor.values()[i] + ChatColor.RESET;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Score score = obj.getScore(line);
|
obj.getScore(line).setScore(lines.size() - i);
|
||||||
score.setScore(lines.size() - i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Kein player.setScoreboard(board) nötig, da wir das Objekt 'board'
|
||||||
|
// direkt verändert haben, das der Spieler bereits hat.
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Methoden für den /nexus sb Befehl ---
|
// --- Methoden für den /nexus sb Befehl ---
|
||||||
@@ -128,7 +135,13 @@ public class ScoreboardModule implements Module, Listener {
|
|||||||
public void setVisibility(Player player, boolean visible) {
|
public void setVisibility(Player player, boolean visible) {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
hiddenPlayers.remove(player.getUniqueId());
|
hiddenPlayers.remove(player.getUniqueId());
|
||||||
|
// Wenn wir es wieder einschalten, ggf. Board zurücksetzen oder neu holen
|
||||||
|
if (!playerBoards.containsKey(player.getUniqueId())) {
|
||||||
|
playerBoards.put(player.getUniqueId(), Bukkit.getScoreboardManager().getNewScoreboard());
|
||||||
|
}
|
||||||
|
player.setScoreboard(playerBoards.get(player.getUniqueId()));
|
||||||
player.sendMessage("§7[§6Nexus§7] §aScoreboard eingeschaltet.");
|
player.sendMessage("§7[§6Nexus§7] §aScoreboard eingeschaltet.");
|
||||||
|
updateSidebar(player); // Sofort aktualisieren
|
||||||
} else {
|
} else {
|
||||||
hiddenPlayers.add(player.getUniqueId());
|
hiddenPlayers.add(player.getUniqueId());
|
||||||
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
|
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
|
||||||
@@ -144,7 +157,6 @@ public class ScoreboardModule implements Module, Listener {
|
|||||||
adminModePlayers.remove(player.getUniqueId());
|
adminModePlayers.remove(player.getUniqueId());
|
||||||
player.sendMessage("§7[§6Nexus§7] §eModus: §6Spieler-Scoreboard §7(Default-Sektion)");
|
player.sendMessage("§7[§6Nexus§7] §eModus: §6Spieler-Scoreboard §7(Default-Sektion)");
|
||||||
}
|
}
|
||||||
// Sofortiges Update erzwingen
|
|
||||||
updateSidebar(player);
|
updateSidebar(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,19 +165,19 @@ public class ScoreboardModule implements Module, Listener {
|
|||||||
if (placeholderAPIEnabled) {
|
if (placeholderAPIEnabled) {
|
||||||
try {
|
try {
|
||||||
translated = PlaceholderAPI.setPlaceholders(player, text);
|
translated = PlaceholderAPI.setPlaceholders(player, text);
|
||||||
} catch (NoClassDefFoundError ignored) {
|
} catch (NoClassDefFoundError ignored) {}
|
||||||
// PlaceholderAPI fehlt zur Laufzeit
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ChatColor.translateAlternateColorCodes('&', translated);
|
return ChatColor.translateAlternateColorCodes('&', translated);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
org.bukkit.event.HandlerList.unregisterAll(this);
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
|
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
|
||||||
}
|
}
|
||||||
hiddenPlayers.clear();
|
hiddenPlayers.clear();
|
||||||
adminModePlayers.clear();
|
adminModePlayers.clear();
|
||||||
|
playerBoards.clear(); // Speicher freigeben
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,32 +70,34 @@ public class ASTListener implements Listener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Prüft, ob der ArmorStand Dialog-Tags hat und startet das Gespräch über den Manager.
|
* Prüft, ob der ArmorStand Dialog-Tags hat und startet das Gespräch über den Manager.
|
||||||
* Nutzt nun die Gruppen-Logik (z.B. owner_suche).
|
* FIX: Liest jetzt alle Partner-Tags (conv_partner, conv_partner2, conv_partner3)
|
||||||
|
* und verwendet playConversationGroup statt nur die 2-NPC-Methode.
|
||||||
|
* Vorher wurden Gruppen-Gespräche mit 3-4 NPCs als 2-NPC-Gespräch ausgeführt.
|
||||||
*/
|
*/
|
||||||
private void checkAndTriggerDialog(ArmorStand as, Player p) {
|
private void checkAndTriggerDialog(ArmorStand as, Player p) {
|
||||||
String groupName = null;
|
String groupName = null;
|
||||||
String partnerUUIDString = null;
|
String partner1 = null, partner2 = null, partner3 = null;
|
||||||
|
|
||||||
for (String tag : as.getScoreboardTags()) {
|
for (String tag : as.getScoreboardTags()) {
|
||||||
// conv_id enthält jetzt den Gruppennamen aus der conversations.yml
|
if (tag.startsWith("conv_id:")) groupName = tag.split(":", 2)[1];
|
||||||
if (tag.startsWith("conv_id:")) groupName = tag.split(":")[1];
|
if (tag.startsWith("conv_partner:")) partner1 = tag.split(":", 2)[1];
|
||||||
if (tag.startsWith("conv_partner:")) partnerUUIDString = tag.split(":")[1];
|
if (tag.startsWith("conv_partner2:")) partner2 = tag.split(":", 2)[1];
|
||||||
|
if (tag.startsWith("conv_partner3:")) partner3 = tag.split(":", 2)[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (groupName != null && partnerUUIDString != null) {
|
if (groupName == null || partner1 == null) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
UUID partnerUUID = UUID.fromString(partnerUUIDString);
|
java.util.List<UUID> participants = new java.util.ArrayList<>();
|
||||||
|
participants.add(as.getUniqueId());
|
||||||
|
participants.add(UUID.fromString(partner1));
|
||||||
|
if (partner2 != null) participants.add(UUID.fromString(partner2));
|
||||||
|
if (partner3 != null) participants.add(UUID.fromString(partner3));
|
||||||
|
|
||||||
// Wir rufen playConversation auf. Der Manager entscheidet selbst
|
NexusLobby.getInstance().getConversationManager()
|
||||||
// anhand der Uhrzeit, ob er morgens, mittags oder nachts abspielt.
|
.playConversationGroup(participants, groupName);
|
||||||
NexusLobby.getInstance().getConversationManager().playConversation(
|
|
||||||
as.getUniqueId(),
|
|
||||||
partnerUUID,
|
|
||||||
groupName
|
|
||||||
);
|
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
// Falls die UUID oder Gruppe ungültig ist
|
// Ungültige UUID oder fehlende Gruppe – still ignorieren
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -238,6 +238,18 @@ public class ArmorStandCmdExecutor implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("clearbubbles")) {
|
||||||
|
ConversationManager cm = NexusLobby.getInstance().getConversationManager();
|
||||||
|
if (cm == null) {
|
||||||
|
p.sendMessage(prefix + "§cConversationManager ist nicht aktiv.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
cm.clearHangingBubbles();
|
||||||
|
p.sendMessage(prefix + "§aAlle hängenden Sprechblasen wurden entfernt.");
|
||||||
|
p.playSound(p.getLocation(), org.bukkit.Sound.BLOCK_NOTE_BLOCK_PLING, 1f, 2f);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return sendHelp(p);
|
return sendHelp(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,6 +296,7 @@ public class ArmorStandCmdExecutor implements CommandExecutor {
|
|||||||
p.sendMessage("§e/nexuscmd conv §7- Gesprächs-Menü");
|
p.sendMessage("§e/nexuscmd conv §7- Gesprächs-Menü");
|
||||||
p.sendMessage("§e/nexuscmd list §7- Zeigt alle Tags");
|
p.sendMessage("§e/nexuscmd list §7- Zeigt alle Tags");
|
||||||
p.sendMessage("§e/nexuscmd remove §7- Löscht Befehle");
|
p.sendMessage("§e/nexuscmd remove §7- Löscht Befehle");
|
||||||
|
p.sendMessage("§e/nexuscmd clearbubbles §7- Entfernt hängende Sprechblasen");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -99,8 +99,11 @@ public enum ArmorStandTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ArmorStandTool get(ItemStack item) {
|
public static ArmorStandTool get(ItemStack item) {
|
||||||
if (item == null || !item.hasItemMeta() || !item.getItemMeta().hasDisplayName()) return null;
|
if (item == null || !item.hasItemMeta()) return null;
|
||||||
String name = ChatColor.stripColor(item.getItemMeta().getDisplayName()).replace(" ", "_");
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
// FIX: getItemMeta() kann null zurückgeben; hasDisplayName() vor getDisplayName() prüfen
|
||||||
|
if (meta == null || !meta.hasDisplayName()) return null;
|
||||||
|
String name = ChatColor.stripColor(meta.getDisplayName()).replace(" ", "_");
|
||||||
if (name.equals("Pose_Editor_öffnen")) return OPEN_POSE_EDITOR;
|
if (name.equals("Pose_Editor_öffnen")) return OPEN_POSE_EDITOR;
|
||||||
if (name.equals("Gesprächs-Setup")) return CONV_SETUP;
|
if (name.equals("Gesprächs-Setup")) return CONV_SETUP;
|
||||||
try { return valueOf(name); } catch (Exception e) { return null; }
|
try { return valueOf(name); } catch (Exception e) { return null; }
|
||||||
|
|||||||
@@ -45,13 +45,15 @@ public class ConversationManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Entfernt alle verwaisten Sprechblasen in allen Welten.
|
* Entfernt alle verwaisten Sprechblasen in allen Welten.
|
||||||
|
* FIX: Nur ArmorStands mit dem Tag "nexus_bubble" werden entfernt.
|
||||||
|
* Die alte Bedingung (!isVisible && isMarker && customName != null) war
|
||||||
|
* zu breit und hätte auch legitime Marker-ArmorStands anderer Systeme gelöscht.
|
||||||
*/
|
*/
|
||||||
public void clearHangingBubbles() {
|
public void clearHangingBubbles() {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (World world : Bukkit.getWorlds()) {
|
for (World world : Bukkit.getWorlds()) {
|
||||||
for (ArmorStand as : world.getEntitiesByClass(ArmorStand.class)) {
|
for (ArmorStand as : world.getEntitiesByClass(ArmorStand.class)) {
|
||||||
if (as.getScoreboardTags().contains("nexus_bubble") ||
|
if (as.getScoreboardTags().contains("nexus_bubble")) {
|
||||||
(!as.isVisible() && as.isMarker() && as.getCustomName() != null)) {
|
|
||||||
as.remove();
|
as.remove();
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.bukkit.block.Block;
|
|||||||
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;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@@ -23,17 +24,18 @@ import org.bukkit.util.Vector;
|
|||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.UUID;
|
import java.util.*;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class SoccerModule implements Module, Listener, CommandExecutor {
|
public class SoccerModule implements Module, Listener, CommandExecutor {
|
||||||
|
|
||||||
// Ball Konstanten
|
// =========================================================================
|
||||||
private static final String TEXTURE_URL = "http://textures.minecraft.net/texture/451f8cfcfb85d77945dc6a3618414093e70436b46d2577b28c727f1329b7265e";
|
// KONSTANTEN
|
||||||
|
// =========================================================================
|
||||||
|
private static final String TEXTURE_URL =
|
||||||
|
"http://textures.minecraft.net/texture/451f8cfcfb85d77945dc6a3618414093e70436b46d2577b28c727f1329b7265e";
|
||||||
private static final String BALL_TAG = "nexusball_entity";
|
private static final String BALL_TAG = "nexusball_entity";
|
||||||
private static final String BALL_NAME = "NexusBall";
|
private static final String BALL_NAME = "NexusBall";
|
||||||
|
|
||||||
// Physik Konstanten
|
|
||||||
private static final double DRIBBLE_DETECTION_RADIUS = 0.7;
|
private static final double DRIBBLE_DETECTION_RADIUS = 0.7;
|
||||||
private static final double DRIBBLE_HEIGHT = 0.5;
|
private static final double DRIBBLE_HEIGHT = 0.5;
|
||||||
private static final double DRIBBLE_FORCE = 0.35;
|
private static final double DRIBBLE_FORCE = 0.35;
|
||||||
@@ -45,353 +47,696 @@ public class SoccerModule implements Module, Listener, CommandExecutor {
|
|||||||
private static final double VOID_THRESHOLD = -5.0;
|
private static final double VOID_THRESHOLD = -5.0;
|
||||||
private static final double CLEANUP_RADIUS = 5.0;
|
private static final double CLEANUP_RADIUS = 5.0;
|
||||||
|
|
||||||
// Particle Konstanten
|
|
||||||
private static final double PARTICLE_SPEED_HIGH = 0.85;
|
private static final double PARTICLE_SPEED_HIGH = 0.85;
|
||||||
private static final double PARTICLE_SPEED_MEDIUM = 0.45;
|
private static final double PARTICLE_SPEED_MEDIUM = 0.45;
|
||||||
private static final double PARTICLE_SPEED_MIN = 0.05;
|
private static final double PARTICLE_SPEED_MIN = 0.05;
|
||||||
|
|
||||||
|
// Tor-Erkennung: Schrittweite beim Segment-Check in Blöcken.
|
||||||
|
// 0.1 → bei 1.35 b/t Kick-Speed ~14 Prüfpunkte pro Tick. Sehr sicher.
|
||||||
|
private static final double CHECK_STEP = 0.1;
|
||||||
|
|
||||||
|
// ── Tor-Partikel ──────────────────────────────────────────────────────────
|
||||||
|
private static final Particle.DustOptions DUST_TEAM1 = new Particle.DustOptions(Color.fromRGB(30, 120, 255), 1.2f);
|
||||||
|
private static final Particle.DustOptions DUST_TEAM2 = new Particle.DustOptions(Color.fromRGB(255, 50, 50), 1.2f);
|
||||||
|
private static final Particle.DustOptions DUST_GOAL_FLASH = new Particle.DustOptions(Color.YELLOW, 2.0f);
|
||||||
|
private static final double PARTICLE_STEP = 0.35;
|
||||||
|
private static final long GOAL_RESPAWN_DELAY = 80L;
|
||||||
|
private static final long GOAL_COOLDOWN_MS = 3_000L;
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// LAUFZEIT-ZUSTAND
|
||||||
|
// =========================================================================
|
||||||
private ArmorStand ball;
|
private ArmorStand ball;
|
||||||
private Location spawnLocation;
|
private Location spawnLocation;
|
||||||
private long lastMoveTime;
|
private long lastMoveTime;
|
||||||
|
private long lastGoalTime = 0L;
|
||||||
|
|
||||||
@Override
|
// ── Tor-Erkennung: Position aus dem VORHERIGEN Tick ───────────────────────
|
||||||
public String getName() { return "Soccer"; }
|
//
|
||||||
|
// WARUM DAS FUNKTIONIERT:
|
||||||
|
// getLocation() eines ArmorStands liefert in Tick N die Position aus Tick N-1.
|
||||||
|
// Das klingt wie ein Problem, ist aber tatsächlich die Lösung:
|
||||||
|
//
|
||||||
|
// Wenn wir in jedem Tick:
|
||||||
|
// 1. prevPos = die aktuelle getLocation() merken (= echte Position aus letztem Tick)
|
||||||
|
// 2. Am ENDE des Ticks: currPos = getLocation() lesen
|
||||||
|
// 3. Das Segment prevPos→currPos prüfen
|
||||||
|
//
|
||||||
|
// Dann deckt dieses Segment exakt den Weg ab den der Ball in Minecraft
|
||||||
|
// in den letzten 50ms zurückgelegt hat – egal wie schnell, egal ob Kick
|
||||||
|
// oder Dribble oder geschoben.
|
||||||
|
//
|
||||||
|
// WICHTIG: prevPos wird am ANFANG des Ticks gesetzt (bevor Physik-Berechnungen
|
||||||
|
// die Velocity ändern), currPos am ENDE. So ist das Segment vollständig.
|
||||||
|
private Location prevPos = null;
|
||||||
|
|
||||||
|
private final Map<String, SoccerGoal> goals = new LinkedHashMap<>();
|
||||||
|
private final Map<Integer, Integer> scores = new HashMap<>();
|
||||||
|
private final Map<UUID, Location> selPos1 = new HashMap<>();
|
||||||
|
private final Map<UUID, Location> selPos2 = new HashMap<>();
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// MODULE-LIFECYCLE
|
||||||
|
// =========================================================================
|
||||||
|
|
||||||
|
@Override public String getName() { return "Soccer"; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
||||||
if (NexusLobby.getInstance().getCommand("nexuslobby") != null) {
|
|
||||||
Objects.requireNonNull(NexusLobby.getInstance().getCommand("nexuslobby")).setExecutor(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
loadConfigLocation();
|
loadConfigLocation();
|
||||||
|
loadGoals();
|
||||||
|
scores.put(1, 0);
|
||||||
|
scores.put(2, 0);
|
||||||
|
|
||||||
// Optimiertes Cleanup-System: 3 Phasen statt 6
|
|
||||||
removeAllOldBalls();
|
removeAllOldBalls();
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), () -> {
|
||||||
removeAllOldBalls();
|
removeAllOldBalls();
|
||||||
spawnBall();
|
spawnBall();
|
||||||
}, 40L); // Nach 2 Sekunden
|
}, 40L);
|
||||||
|
Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), this::removeAllOldBalls, 100L);
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), this::removeAllOldBalls, 100L); // Finaler Check nach 5 Sekunden
|
// ── Physik-Tick ────────────────────────────────────────────────────────
|
||||||
|
|
||||||
// Haupt-Physik & Anti-Duplikat System
|
|
||||||
Bukkit.getScheduler().runTaskTimer(NexusLobby.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskTimer(NexusLobby.getInstance(), () -> {
|
||||||
// Anti-Duplikat-Check (optimiert: nur in Ball-Welt)
|
if (ball != null && ball.isValid()) removeDuplicateBalls();
|
||||||
if (ball != null && ball.isValid()) {
|
|
||||||
removeDuplicateBalls();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ball == null || !ball.isValid()) return;
|
if (ball == null || !ball.isValid()) return;
|
||||||
|
|
||||||
|
// ── SCHRITT 1: Aktuelle Position als "vorherige" speichern ─────────
|
||||||
|
// getLocation() ist hier die Position aus dem letzten Server-Tick –
|
||||||
|
// d.h. die Position BEVOR die Physik dieses Ticks berechnet wurde.
|
||||||
|
Location currentPos = ball.getLocation().clone();
|
||||||
|
|
||||||
|
// ── SCHRITT 2: Physik und Spieler-Interaktion verarbeiten ──────────
|
||||||
Vector vel = ball.getVelocity();
|
Vector vel = ball.getVelocity();
|
||||||
double speed = vel.length();
|
double speed = vel.length();
|
||||||
|
|
||||||
handleWallBounce(vel);
|
handleWallBounce(vel);
|
||||||
handleParticles(speed);
|
handleParticles(speed);
|
||||||
handleDribbling();
|
handleDribbling();
|
||||||
|
|
||||||
// Automatischer Respawn bei Inaktivität oder Void
|
// ── SCHRITT 3: Nach Physik die neue Position lesen ─────────────────
|
||||||
long respawnDelayMs = NexusLobby.getInstance().getConfig().getLong("ball.respawn_delay", 60) * 1000;
|
// Minecraft hat jetzt die Position um vel verschoben.
|
||||||
if (System.currentTimeMillis() - lastMoveTime > respawnDelayMs || ball.getLocation().getY() < VOID_THRESHOLD) {
|
// Da getLocation() einen Tick verzögert ist, lesen wir hier noch
|
||||||
|
// currentPos – aber über den Velocity-Vektor wissen wir die neue Pos.
|
||||||
|
// Wir nutzen deshalb: newPos = currentPos + velocity (vor Drag)
|
||||||
|
// Das ist die tatsächliche neue Ballposition nach diesem Tick.
|
||||||
|
Location newPos = currentPos.clone().add(vel);
|
||||||
|
|
||||||
|
// ── SCHRITT 4: Segment prüfen ─────────────────────────────────────
|
||||||
|
// Das Segment prevPos → newPos deckt den vollständigen Weg ab den
|
||||||
|
// der Ball seit dem letzten Tor-Check zurückgelegt hat.
|
||||||
|
if (!goals.isEmpty()
|
||||||
|
&& System.currentTimeMillis() - lastGoalTime >= GOAL_COOLDOWN_MS
|
||||||
|
&& prevPos != null) {
|
||||||
|
checkSegment(prevPos, newPos, currentPos.getWorld());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── SCHRITT 5: prevPos für nächsten Tick aktualisieren ─────────────
|
||||||
|
prevPos = newPos.clone();
|
||||||
|
|
||||||
|
// ── Respawn-Check ──────────────────────────────────────────────────
|
||||||
|
long respawnDelayMs = NexusLobby.getInstance().getConfig()
|
||||||
|
.getLong("ball.respawn_delay", 60) * 1_000L;
|
||||||
|
if (System.currentTimeMillis() - lastMoveTime > respawnDelayMs
|
||||||
|
|| ball.getLocation().getY() < VOID_THRESHOLD) {
|
||||||
respawnBall();
|
respawnBall();
|
||||||
}
|
}
|
||||||
}, 1L, 1L);
|
}, 1L, 1L);
|
||||||
|
|
||||||
|
// ── Tor-Partikel ──────────────────────────────────────────────────────
|
||||||
|
Bukkit.getScheduler().runTaskTimer(NexusLobby.getInstance(),
|
||||||
|
this::drawAllGoalParticles, 4L, 4L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
org.bukkit.event.HandlerList.unregisterAll(this);
|
||||||
|
if (ball != null && ball.isValid()) { ball.remove(); ball = null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// TOR-ERKENNUNG
|
||||||
|
// =========================================================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prüft das Segment von {@code from} nach {@code to} auf Tor-Treffer.
|
||||||
|
*
|
||||||
|
* Das Segment wird in CHECK_STEP (0.1 Block) Schritte unterteilt.
|
||||||
|
* An jedem Punkt werden drei Y-Höhen geprüft (Fuß / Mitte / Kopf des Balls).
|
||||||
|
*
|
||||||
|
* @param from Position am Anfang des Ticks
|
||||||
|
* @param to Position am Ende des Ticks (= from + velocity)
|
||||||
|
* @param world Welt des Balls
|
||||||
|
*/
|
||||||
|
private void checkSegment(Location from, Location to, World world) {
|
||||||
|
if (world == null) return;
|
||||||
|
|
||||||
|
double dx = to.getX() - from.getX();
|
||||||
|
double dy = to.getY() - from.getY();
|
||||||
|
double dz = to.getZ() - from.getZ();
|
||||||
|
double len = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
||||||
|
|
||||||
|
// Ball steht fast still → nur aktuellen Punkt prüfen
|
||||||
|
if (len < 0.001) {
|
||||||
|
checkPoint(from.getX(), from.getY(), from.getZ(), world);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int steps = Math.max(1, (int) Math.ceil(len / CHECK_STEP));
|
||||||
|
double sx = dx / steps;
|
||||||
|
double sy = dy / steps;
|
||||||
|
double sz = dz / steps;
|
||||||
|
|
||||||
|
for (int i = 0; i <= steps; i++) {
|
||||||
|
double x = from.getX() + sx * i;
|
||||||
|
double y = from.getY() + sy * i;
|
||||||
|
double z = from.getZ() + sz * i;
|
||||||
|
if (checkPoint(x, y, z, world)) return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optimierte Dribbel-Logik: Ball folgt nahen Spielern
|
* Prüft einen Punkt in drei Y-Höhen gegen alle Tore.
|
||||||
|
* @return true wenn ein Tor gewertet wurde (Schleife soll abbrechen)
|
||||||
*/
|
*/
|
||||||
|
private boolean checkPoint(double x, double y, double z, World world) {
|
||||||
|
for (double yOff : new double[]{0.0, 0.45, 0.9}) {
|
||||||
|
Location check = new Location(world, x, y + yOff, z);
|
||||||
|
for (SoccerGoal goal : goals.values()) {
|
||||||
|
if (goal.contains(check)) {
|
||||||
|
scoreGoal(goal);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// TOR WERTEN
|
||||||
|
// =========================================================================
|
||||||
|
|
||||||
|
private void scoreGoal(SoccerGoal goal) {
|
||||||
|
if (System.currentTimeMillis() - lastGoalTime < GOAL_COOLDOWN_MS) return;
|
||||||
|
lastGoalTime = System.currentTimeMillis();
|
||||||
|
scores.merge(goal.team, 1, Integer::sum);
|
||||||
|
|
||||||
|
String teamColor = goal.team == 1 ? "§9" : "§c";
|
||||||
|
String teamName = goal.team == 1 ? "Team Blau" : "Team Rot";
|
||||||
|
|
||||||
|
if (ball != null && ball.isValid()) ball.setVelocity(new Vector(0, 0, 0));
|
||||||
|
prevPos = null; // Reset damit kein Doppel-Trigger aus altem Segment
|
||||||
|
|
||||||
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
|
p.sendTitle(teamColor + "§lTOR!", teamColor + teamName + " §8| §fStand: " + getScoreString(), 5, 50, 15);
|
||||||
|
p.sendMessage("§8[§6Soccer§8] " + teamColor + "§lTOR! §r§7für " + teamName + " §8| §fStand: " + getScoreString());
|
||||||
|
p.playSound(p.getLocation(), Sound.UI_TOAST_CHALLENGE_COMPLETE, 1f, 1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
spawnGoalCelebration(goal);
|
||||||
|
Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), this::respawnBall, GOAL_RESPAWN_DELAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void spawnGoalCelebration(SoccerGoal goal) {
|
||||||
|
Location center = goal.getCenter();
|
||||||
|
World world = center.getWorld();
|
||||||
|
if (world == null) return;
|
||||||
|
for (int wave = 0; wave < 6; wave++) {
|
||||||
|
final double offsetY = wave * 0.25;
|
||||||
|
Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), () -> {
|
||||||
|
Location wLoc = center.clone().add(0, offsetY, 0);
|
||||||
|
world.spawnParticle(Particle.DUST, wLoc, 50, 1.2, 0.6, 1.2, 0, DUST_GOAL_FLASH);
|
||||||
|
world.spawnParticle(Particle.FIREWORK, wLoc, 25, 1.0, 0.8, 1.0, 0.25);
|
||||||
|
world.spawnParticle(Particle.EXPLOSION, center, 2, 0.4, 0.4, 0.4, 0.05);
|
||||||
|
}, wave * 7L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// PHYSIK
|
||||||
|
// =========================================================================
|
||||||
|
|
||||||
private void handleDribbling() {
|
private void handleDribbling() {
|
||||||
if (ball == null || !ball.isValid()) return;
|
if (ball == null || !ball.isValid()) return;
|
||||||
|
|
||||||
for (Entity nearby : ball.getNearbyEntities(DRIBBLE_DETECTION_RADIUS, DRIBBLE_HEIGHT, DRIBBLE_DETECTION_RADIUS)) {
|
for (Entity nearby : ball.getNearbyEntities(DRIBBLE_DETECTION_RADIUS, DRIBBLE_HEIGHT, DRIBBLE_DETECTION_RADIUS)) {
|
||||||
if (nearby instanceof Player p) {
|
if (nearby instanceof Player player) {
|
||||||
Vector direction = ball.getLocation().toVector().subtract(p.getLocation().toVector());
|
Vector dir = ball.getLocation().toVector().subtract(player.getLocation().toVector());
|
||||||
if (direction.lengthSquared() > 0) {
|
if (dir.lengthSquared() > 0) {
|
||||||
direction.normalize();
|
dir.normalize().setY(DRIBBLE_LIFT);
|
||||||
direction.setY(DRIBBLE_LIFT);
|
ball.setVelocity(dir.multiply(DRIBBLE_FORCE));
|
||||||
ball.setVelocity(direction.multiply(DRIBBLE_FORCE));
|
|
||||||
lastMoveTime = System.currentTimeMillis();
|
lastMoveTime = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Entfernt Duplikate in der Umgebung des aktiven Balls (Performance-optimiert)
|
|
||||||
*/
|
|
||||||
private void removeDuplicateBalls() {
|
|
||||||
if (ball == null || !ball.isValid() || ball.getLocation().getWorld() == null) return;
|
|
||||||
|
|
||||||
for (Entity entity : ball.getLocation().getWorld().getNearbyEntities(ball.getLocation(), 50, 50, 50)) {
|
|
||||||
if (entity instanceof ArmorStand stand && isBallEntity(stand)) {
|
|
||||||
if (!stand.getUniqueId().equals(ball.getUniqueId())) {
|
|
||||||
stand.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Entfernt alle Ball-Entities (nur in relevanter Welt wenn Spawn gesetzt)
|
|
||||||
*/
|
|
||||||
private void removeAllOldBalls() {
|
|
||||||
int removed = 0;
|
|
||||||
|
|
||||||
// Wenn Spawn-Location gesetzt ist, nur diese Welt durchsuchen (Performance!)
|
|
||||||
if (spawnLocation != null && spawnLocation.getWorld() != null) {
|
|
||||||
removed = cleanupBallsInWorld(spawnLocation.getWorld());
|
|
||||||
} else {
|
|
||||||
// Sonst alle Welten durchsuchen
|
|
||||||
for (World world : Bukkit.getWorlds()) {
|
|
||||||
removed += cleanupBallsInWorld(world);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (removed > 0) {
|
|
||||||
Bukkit.getLogger().info("[NexusLobby] " + removed + " alte Ball-Entities entfernt.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cleanup für eine einzelne Welt
|
|
||||||
*/
|
|
||||||
private int cleanupBallsInWorld(World world) {
|
|
||||||
int removed = 0;
|
|
||||||
for (Entity entity : world.getEntities()) {
|
|
||||||
if (entity instanceof ArmorStand stand && isBallEntity(stand)) {
|
|
||||||
if (ball == null || !stand.getUniqueId().equals(ball.getUniqueId())) {
|
|
||||||
stand.remove();
|
|
||||||
removed++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return removed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prüft ob ein ArmorStand ein Ball ist (Mehrere Erkennungsmethoden)
|
|
||||||
*/
|
|
||||||
private boolean isBallEntity(ArmorStand stand) {
|
|
||||||
// Methode 1: Tag-basiert (primär)
|
|
||||||
if (stand.getScoreboardTags().contains(BALL_TAG)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Methode 2: Name-basiert
|
|
||||||
if (stand.getCustomName() != null && stand.getCustomName().equals(BALL_NAME)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Methode 3: Profil-basiert (Kopf-Textur)
|
|
||||||
if (stand.getEquipment() != null && stand.getEquipment().getHelmet() != null) {
|
|
||||||
ItemStack helmet = stand.getEquipment().getHelmet();
|
|
||||||
if (helmet.getType() == Material.PLAYER_HEAD && helmet.hasItemMeta()) {
|
|
||||||
SkullMeta meta = (SkullMeta) helmet.getItemMeta();
|
|
||||||
if (meta.hasOwner() && meta.getOwnerProfile() != null) {
|
|
||||||
if (BALL_NAME.equals(meta.getOwnerProfile().getName())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Methode 4: Eigenschaften-basiert (nur wenn Spawn gesetzt)
|
|
||||||
if (spawnLocation != null && spawnLocation.getWorld() != null &&
|
|
||||||
stand.getWorld().equals(spawnLocation.getWorld()) &&
|
|
||||||
stand.isSmall() && stand.isInvisible() && !stand.hasBasePlate()) {
|
|
||||||
|
|
||||||
double distance = stand.getLocation().distance(spawnLocation);
|
|
||||||
if (distance < CLEANUP_RADIUS && stand.getEquipment() != null &&
|
|
||||||
stand.getEquipment().getHelmet() != null &&
|
|
||||||
stand.getEquipment().getHelmet().getType() == Material.PLAYER_HEAD) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleWallBounce(Vector vel) {
|
private void handleWallBounce(Vector vel) {
|
||||||
if (vel.lengthSquared() < 0.001) return;
|
if (vel.lengthSquared() < 0.001) return;
|
||||||
|
|
||||||
Location loc = ball.getLocation();
|
Location loc = ball.getLocation();
|
||||||
Block nextX = loc.clone().add(vel.getX() * WALL_CHECK_DISTANCE, 0.5, 0).getBlock();
|
Block nx = loc.clone().add(vel.getX() * WALL_CHECK_DISTANCE, 0.5, 0).getBlock();
|
||||||
Block nextZ = loc.clone().add(0, 0.5, vel.getZ() * WALL_CHECK_DISTANCE).getBlock();
|
Block nz = loc.clone().add(0, 0.5, vel.getZ() * WALL_CHECK_DISTANCE).getBlock();
|
||||||
|
|
||||||
boolean bounced = false;
|
boolean bounced = false;
|
||||||
if (nextX.getType().isSolid()) {
|
if (nx.getType().isSolid()) { vel.setX(-vel.getX() * WALL_BOUNCE_DAMPING); bounced = true; }
|
||||||
vel.setX(-vel.getX() * WALL_BOUNCE_DAMPING);
|
if (nz.getType().isSolid()) { vel.setZ(-vel.getZ() * WALL_BOUNCE_DAMPING); bounced = true; }
|
||||||
bounced = true;
|
|
||||||
}
|
|
||||||
if (nextZ.getType().isSolid()) {
|
|
||||||
vel.setZ(-vel.getZ() * WALL_BOUNCE_DAMPING);
|
|
||||||
bounced = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bounced) {
|
if (bounced) {
|
||||||
ball.setVelocity(vel);
|
ball.setVelocity(vel);
|
||||||
ball.getWorld().playSound(ball.getLocation(), Sound.BLOCK_WOOD_BREAK, 0.6f, 1.3f);
|
ball.getWorld().playSound(loc, Sound.BLOCK_WOOD_BREAK, 0.6f, 1.3f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleParticles(double speed) {
|
private void handleParticles(double speed) {
|
||||||
if (speed < PARTICLE_SPEED_MIN) return;
|
if (speed < PARTICLE_SPEED_MIN) return;
|
||||||
|
|
||||||
Location loc = ball.getLocation().add(0, 0.2, 0);
|
Location loc = ball.getLocation().add(0, 0.2, 0);
|
||||||
World world = loc.getWorld();
|
World w = loc.getWorld();
|
||||||
if (world == null) return;
|
if (w == null) return;
|
||||||
|
if (speed > PARTICLE_SPEED_HIGH) w.spawnParticle(Particle.SONIC_BOOM, loc, 1, 0, 0, 0, 0);
|
||||||
|
else if (speed > PARTICLE_SPEED_MEDIUM) w.spawnParticle(Particle.CRIT, loc, 3, 0.1, 0.1, 0.1, 0.08);
|
||||||
|
else w.spawnParticle(Particle.SMOKE, loc, 1, 0.05, 0, 0.05, 0.02);
|
||||||
|
}
|
||||||
|
|
||||||
if (speed > PARTICLE_SPEED_HIGH) {
|
// =========================================================================
|
||||||
world.spawnParticle(Particle.SONIC_BOOM, loc, 1, 0, 0, 0, 0);
|
// TOR-PARTIKEL ZEICHNEN
|
||||||
} else if (speed > PARTICLE_SPEED_MEDIUM) {
|
// =========================================================================
|
||||||
world.spawnParticle(Particle.CRIT, loc, 3, 0.1, 0.1, 0.1, 0.08);
|
|
||||||
} else {
|
private void drawAllGoalParticles() {
|
||||||
world.spawnParticle(Particle.SMOKE, loc, 1, 0.05, 0, 0.05, 0.02);
|
for (SoccerGoal goal : goals.values()) drawGoalFrame(goal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void drawGoalFrame(SoccerGoal goal) {
|
||||||
|
World world = goal.getWorld();
|
||||||
|
if (world == null) return;
|
||||||
|
Particle.DustOptions dust = goal.team == 1 ? DUST_TEAM1 : DUST_TEAM2;
|
||||||
|
|
||||||
|
double x1 = Math.min(goal.pos1.getX(), goal.pos2.getX()), x2 = Math.max(goal.pos1.getX(), goal.pos2.getX());
|
||||||
|
double y1 = Math.min(goal.pos1.getY(), goal.pos2.getY()), y2 = Math.max(goal.pos1.getY(), goal.pos2.getY());
|
||||||
|
double z1 = Math.min(goal.pos1.getZ(), goal.pos2.getZ()), z2 = Math.max(goal.pos1.getZ(), goal.pos2.getZ());
|
||||||
|
|
||||||
|
line(world, x1,y1,z1, x2,y1,z1, dust); line(world, x1,y1,z2, x2,y1,z2, dust);
|
||||||
|
line(world, x1,y1,z1, x1,y1,z2, dust); line(world, x2,y1,z1, x2,y1,z2, dust);
|
||||||
|
line(world, x1,y2,z1, x2,y2,z1, dust); line(world, x1,y2,z2, x2,y2,z2, dust);
|
||||||
|
line(world, x1,y2,z1, x1,y2,z2, dust); line(world, x2,y2,z1, x2,y2,z2, dust);
|
||||||
|
line(world, x1,y1,z1, x1,y2,z1, dust); line(world, x2,y1,z1, x2,y2,z1, dust);
|
||||||
|
line(world, x1,y1,z2, x1,y2,z2, dust); line(world, x2,y1,z2, x2,y2,z2, dust);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void line(World world, double ax, double ay, double az,
|
||||||
|
double bx, double by, double bz, Particle.DustOptions dust) {
|
||||||
|
double dx = bx-ax, dy = by-ay, dz = bz-az;
|
||||||
|
double len = Math.sqrt(dx*dx + dy*dy + dz*dz);
|
||||||
|
if (len < 0.01) return;
|
||||||
|
int steps = (int) Math.ceil(len / PARTICLE_STEP);
|
||||||
|
dx /= steps; dy /= steps; dz /= steps;
|
||||||
|
for (int i = 0; i <= steps; i++)
|
||||||
|
world.spawnParticle(Particle.DUST, ax+dx*i, ay+dy*i, az+dz*i, 1, 0,0,0,0, dust, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// DATEN-KLASSE: SoccerGoal
|
||||||
|
// =========================================================================
|
||||||
|
|
||||||
|
private static class SoccerGoal {
|
||||||
|
final String name; final Location pos1, pos2; final int team;
|
||||||
|
|
||||||
|
SoccerGoal(String name, Location pos1, Location pos2, int team) {
|
||||||
|
this.name = name; this.pos1 = pos1; this.pos2 = pos2; this.team = team;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean contains(Location loc) {
|
||||||
|
if (loc.getWorld() == null || !loc.getWorld().equals(pos1.getWorld())) return false;
|
||||||
|
return loc.getX() >= Math.min(pos1.getX(), pos2.getX())
|
||||||
|
&& loc.getX() <= Math.max(pos1.getX(), pos2.getX())
|
||||||
|
&& loc.getY() >= Math.min(pos1.getY(), pos2.getY())
|
||||||
|
&& loc.getY() <= Math.max(pos1.getY(), pos2.getY())
|
||||||
|
&& loc.getZ() >= Math.min(pos1.getZ(), pos2.getZ())
|
||||||
|
&& loc.getZ() <= Math.max(pos1.getZ(), pos2.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
Location getCenter() {
|
||||||
|
return new Location(pos1.getWorld(),
|
||||||
|
(pos1.getX()+pos2.getX())/2.0,
|
||||||
|
(pos1.getY()+pos2.getY())/2.0,
|
||||||
|
(pos1.getZ()+pos2.getZ())/2.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
World getWorld() { return pos1.getWorld(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// CONFIG: TORE
|
||||||
|
// =========================================================================
|
||||||
|
|
||||||
|
private void loadGoals() {
|
||||||
|
goals.clear();
|
||||||
|
FileConfiguration config = NexusLobby.getInstance().getConfig();
|
||||||
|
ConfigurationSection section = config.getConfigurationSection("ball.goals");
|
||||||
|
if (section == null) return;
|
||||||
|
for (String name : section.getKeys(false)) {
|
||||||
|
String path = "ball.goals." + name;
|
||||||
|
Location pos1 = loadLoc(config, path + ".pos1");
|
||||||
|
Location pos2 = loadLoc(config, path + ".pos2");
|
||||||
|
if (pos1 == null || pos2 == null) continue;
|
||||||
|
goals.put(name, new SoccerGoal(name, pos1, pos2, config.getInt(path + ".team", 1)));
|
||||||
|
}
|
||||||
|
Bukkit.getLogger().info("[Soccer] " + goals.size() + " Tor(e) geladen.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveGoal(SoccerGoal g) {
|
||||||
|
String path = "ball.goals." + g.name;
|
||||||
|
FileConfiguration c = NexusLobby.getInstance().getConfig();
|
||||||
|
saveLoc(c, path + ".pos1", g.pos1); saveLoc(c, path + ".pos2", g.pos2);
|
||||||
|
c.set(path + ".team", g.team);
|
||||||
|
NexusLobby.getInstance().saveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteGoal(String name) {
|
||||||
|
NexusLobby.getInstance().getConfig().set("ball.goals." + name, null);
|
||||||
|
NexusLobby.getInstance().saveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void saveLoc(FileConfiguration c, String path, Location loc) {
|
||||||
|
if (loc == null || loc.getWorld() == null) return;
|
||||||
|
c.set(path + ".world", loc.getWorld().getName());
|
||||||
|
c.set(path + ".x", loc.getX()); c.set(path + ".y", loc.getY()); c.set(path + ".z", loc.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Location loadLoc(FileConfiguration c, String path) {
|
||||||
|
String wName = c.getString(path + ".world");
|
||||||
|
if (wName == null) return null;
|
||||||
|
World world = Bukkit.getWorld(wName);
|
||||||
|
if (world == null) { Bukkit.getLogger().warning("[Soccer] Welt nicht gefunden: " + wName); return null; }
|
||||||
|
return new Location(world, c.getDouble(path + ".x"), c.getDouble(path + ".y"), c.getDouble(path + ".z"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// BALL SPAWNEN / RESPAWNEN
|
||||||
|
// =========================================================================
|
||||||
|
|
||||||
private void spawnBall() {
|
private void spawnBall() {
|
||||||
if (spawnLocation == null || spawnLocation.getWorld() == null) {
|
if (spawnLocation == null || spawnLocation.getWorld() == null) return;
|
||||||
// Keine Warnung mehr in der Konsole ausgeben
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ball != null && ball.isValid()) return;
|
if (ball != null && ball.isValid()) return;
|
||||||
|
ball = (ArmorStand) spawnLocation.getWorld().spawnEntity(spawnLocation.clone(), EntityType.ARMOR_STAND);
|
||||||
Location spawnLoc = spawnLocation.clone();
|
ball.setInvisible(true); ball.setGravity(true); ball.setBasePlate(false);
|
||||||
ball = (ArmorStand) spawnLoc.getWorld().spawnEntity(spawnLoc, EntityType.ARMOR_STAND);
|
ball.setSmall(true); ball.setInvulnerable(false); ball.setArms(false);
|
||||||
|
ball.setCustomNameVisible(false); ball.setCustomName(BALL_NAME);
|
||||||
ball.setInvisible(true);
|
ball.setPersistent(false); ball.addScoreboardTag(BALL_TAG);
|
||||||
ball.setGravity(true);
|
if (ball.getEquipment() != null) ball.getEquipment().setHelmet(getSoccerHead());
|
||||||
ball.setBasePlate(false);
|
prevPos = spawnLocation.clone();
|
||||||
ball.setSmall(true);
|
lastMoveTime = System.currentTimeMillis();
|
||||||
ball.setInvulnerable(false);
|
|
||||||
ball.setArms(false);
|
|
||||||
ball.setCustomNameVisible(false);
|
|
||||||
ball.setCustomName(BALL_NAME);
|
|
||||||
ball.setPersistent(false);
|
|
||||||
ball.addScoreboardTag(BALL_TAG);
|
|
||||||
|
|
||||||
ItemStack ballHead = getSoccerHead();
|
|
||||||
if (ball.getEquipment() != null) {
|
|
||||||
ball.getEquipment().setHelmet(ballHead);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lastMoveTime = System.currentTimeMillis();
|
public void respawnBall() {
|
||||||
|
if (ball != null && ball.isValid()) { ball.remove(); ball = null; }
|
||||||
|
removeAllOldBalls();
|
||||||
|
prevPos = null;
|
||||||
|
spawnBall();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ItemStack getSoccerHead() {
|
private ItemStack getSoccerHead() {
|
||||||
ItemStack head = new ItemStack(Material.PLAYER_HEAD);
|
ItemStack head = new ItemStack(Material.PLAYER_HEAD);
|
||||||
SkullMeta meta = (SkullMeta) head.getItemMeta();
|
SkullMeta meta = (SkullMeta) head.getItemMeta();
|
||||||
if (meta == null) return head;
|
if (meta == null) return head;
|
||||||
|
|
||||||
PlayerProfile profile = Bukkit.createPlayerProfile(UUID.randomUUID(), BALL_NAME);
|
PlayerProfile profile = Bukkit.createPlayerProfile(UUID.randomUUID(), BALL_NAME);
|
||||||
try {
|
try { profile.getTextures().setSkin(new URL(TEXTURE_URL)); }
|
||||||
profile.getTextures().setSkin(new URL(TEXTURE_URL));
|
catch (MalformedURLException e) { Bukkit.getLogger().warning("[NexusLobby] Ungültige Ball-Textur URL!"); }
|
||||||
} catch (MalformedURLException e) {
|
|
||||||
Bukkit.getLogger().warning("[NexusLobby] Ungültige Ball-Textur URL!");
|
|
||||||
}
|
|
||||||
meta.setOwnerProfile(profile);
|
meta.setOwnerProfile(profile);
|
||||||
head.setItemMeta(meta);
|
head.setItemMeta(meta);
|
||||||
return head;
|
return head;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void respawnBall() {
|
// =========================================================================
|
||||||
if (ball != null && ball.isValid()) {
|
// CLEANUP
|
||||||
ball.remove();
|
// =========================================================================
|
||||||
ball = null;
|
|
||||||
|
private void removeDuplicateBalls() {
|
||||||
|
if (ball == null || !ball.isValid() || ball.getLocation().getWorld() == null) return;
|
||||||
|
for (Entity e : ball.getLocation().getWorld().getNearbyEntities(ball.getLocation(), 50, 50, 50)) {
|
||||||
|
if (e instanceof ArmorStand s && isBallEntity(s) && !s.getUniqueId().equals(ball.getUniqueId()))
|
||||||
|
s.remove();
|
||||||
}
|
}
|
||||||
removeAllOldBalls();
|
|
||||||
spawnBall();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeAllOldBalls() {
|
||||||
|
int removed = 0;
|
||||||
|
if (spawnLocation != null && spawnLocation.getWorld() != null)
|
||||||
|
removed = cleanupWorld(spawnLocation.getWorld());
|
||||||
|
else
|
||||||
|
for (World w : Bukkit.getWorlds()) removed += cleanupWorld(w);
|
||||||
|
if (removed > 0) Bukkit.getLogger().info("[NexusLobby] " + removed + " alte Ball-Entities entfernt.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private int cleanupWorld(World world) {
|
||||||
|
int n = 0;
|
||||||
|
for (Entity e : world.getEntities()) {
|
||||||
|
if (e instanceof ArmorStand s && isBallEntity(s)
|
||||||
|
&& (ball == null || !s.getUniqueId().equals(ball.getUniqueId()))) {
|
||||||
|
s.remove(); n++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isBallEntity(ArmorStand s) {
|
||||||
|
if (s.getScoreboardTags().contains(BALL_TAG)) return true;
|
||||||
|
if (BALL_NAME.equals(s.getCustomName())) return true;
|
||||||
|
if (s.getEquipment() != null && s.getEquipment().getHelmet() != null) {
|
||||||
|
ItemStack h = s.getEquipment().getHelmet();
|
||||||
|
if (h.getType() == Material.PLAYER_HEAD && h.hasItemMeta()) {
|
||||||
|
SkullMeta m = (SkullMeta) h.getItemMeta();
|
||||||
|
if (m.hasOwner() && m.getOwnerProfile() != null
|
||||||
|
&& BALL_NAME.equals(m.getOwnerProfile().getName())) return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (spawnLocation != null && spawnLocation.getWorld() != null
|
||||||
|
&& s.getWorld().equals(spawnLocation.getWorld())
|
||||||
|
&& s.isSmall() && s.isInvisible() && !s.hasBasePlate()
|
||||||
|
&& s.getLocation().distance(spawnLocation) < CLEANUP_RADIUS
|
||||||
|
&& s.getEquipment() != null && s.getEquipment().getHelmet() != null
|
||||||
|
&& s.getEquipment().getHelmet().getType() == Material.PLAYER_HEAD)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// EVENTS
|
||||||
|
// =========================================================================
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBallPunch(EntityDamageByEntityEvent event) {
|
public void onBallPunch(EntityDamageByEntityEvent event) {
|
||||||
if (ball == null || !event.getEntity().equals(ball)) return;
|
if (ball == null || !event.getEntity().equals(ball)) return;
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
if (!(event.getDamager() instanceof Player p)) return;
|
||||||
|
|
||||||
|
Vector dir = p.getLocation().getDirection().normalize();
|
||||||
|
dir.multiply(KICK_FORCE).setY(KICK_LIFT);
|
||||||
|
|
||||||
|
// prevPos auf aktuelle Position setzen bevor der Ball sich bewegt –
|
||||||
|
// so startet das nächste Segment am richtigen Punkt.
|
||||||
|
prevPos = ball.getLocation().clone();
|
||||||
|
ball.setVelocity(dir);
|
||||||
|
|
||||||
if (event.getDamager() instanceof Player p) {
|
|
||||||
Vector shootDir = p.getLocation().getDirection();
|
|
||||||
if (shootDir.lengthSquared() > 0) {
|
|
||||||
shootDir.normalize().multiply(KICK_FORCE).setY(KICK_LIFT);
|
|
||||||
ball.setVelocity(shootDir);
|
|
||||||
ball.getWorld().playSound(ball.getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 0.6f, 1.5f);
|
ball.getWorld().playSound(ball.getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 0.6f, 1.5f);
|
||||||
lastMoveTime = System.currentTimeMillis();
|
lastMoveTime = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBallInteract(PlayerInteractAtEntityEvent event) {
|
public void onBallInteract(PlayerInteractAtEntityEvent event) {
|
||||||
if (ball != null && event.getRightClicked().equals(ball)) {
|
if (ball != null && event.getRightClicked().equals(ball)) event.setCancelled(true);
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadConfigLocation() {
|
// =========================================================================
|
||||||
FileConfiguration config = NexusLobby.getInstance().getConfig();
|
// COMMANDS
|
||||||
if (config.contains("ball.spawn")) {
|
// =========================================================================
|
||||||
spawnLocation = config.getLocation("ball.spawn");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (!(sender instanceof Player p)) {
|
if (!(sender instanceof Player p)) { sender.sendMessage("§cNur Spieler."); return true; }
|
||||||
sender.sendMessage("§cNur Spieler können diesen Befehl ausführen.");
|
if (!p.hasPermission("nexuslobby.admin")) { p.sendMessage("§cKeine Berechtigung!"); return true; }
|
||||||
return true;
|
if (args.length < 2 || !args[0].equalsIgnoreCase("ball")) return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (!p.hasPermission("nexuslobby.admin")) {
|
|
||||||
p.sendMessage("§cKeine Berechtigung!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length >= 2 && args[0].equalsIgnoreCase("ball")) {
|
|
||||||
switch (args[1].toLowerCase()) {
|
switch (args[1].toLowerCase()) {
|
||||||
case "setspawn" -> {
|
case "setspawn" -> cmdSetSpawn(p);
|
||||||
|
case "respawn" -> { respawnBall(); p.sendMessage("§8[§6Soccer§8] §eBall neu gespawnt."); }
|
||||||
|
case "remove" -> cmdRemove(p);
|
||||||
|
case "goal" -> cmdGoal(p, args);
|
||||||
|
case "score" -> cmdScore(p, args);
|
||||||
|
default -> sendHelp(p);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cmdSetSpawn(Player p) {
|
||||||
spawnLocation = p.getLocation();
|
spawnLocation = p.getLocation();
|
||||||
NexusLobby.getInstance().getConfig().set("ball.spawn", spawnLocation);
|
FileConfiguration c = NexusLobby.getInstance().getConfig();
|
||||||
|
c.set("ball.spawn.world", spawnLocation.getWorld().getName());
|
||||||
|
c.set("ball.spawn.x", spawnLocation.getX());
|
||||||
|
c.set("ball.spawn.y", spawnLocation.getY());
|
||||||
|
c.set("ball.spawn.z", spawnLocation.getZ());
|
||||||
NexusLobby.getInstance().saveConfig();
|
NexusLobby.getInstance().saveConfig();
|
||||||
respawnBall();
|
respawnBall();
|
||||||
p.sendMessage("§8[§6Nexus§8] §aBall-Spawn gesetzt und Ball respawnt!");
|
p.sendMessage("§8[§6Soccer§8] §aBall-Spawn gesetzt und Ball respawnt!");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "respawn" -> {
|
|
||||||
respawnBall();
|
|
||||||
p.sendMessage("§8[§6Nexus§8] §eBall manuell respawnt.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (ball != null) {
|
|
||||||
ball.remove();
|
|
||||||
ball = null;
|
|
||||||
}
|
|
||||||
removeAllOldBalls();
|
|
||||||
p.sendMessage("§8[§6Nexus§8] §cBall entfernt und Cleanup durchgeführt.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
p.sendMessage("§8[§6Nexus§8] §7Verwendung:");
|
|
||||||
p.sendMessage("§e/nexuslobby ball setspawn §7- Setzt den Ball-Spawn");
|
|
||||||
p.sendMessage("§e/nexuslobby ball respawn §7- Spawnt den Ball neu");
|
|
||||||
p.sendMessage("§e/nexuslobby ball remove §7- Entfernt den Ball");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void cmdRemove(Player p) {
|
||||||
public void onDisable() {
|
if (ball != null) { ball.remove(); ball = null; }
|
||||||
if (ball != null && ball.isValid()) {
|
removeAllOldBalls();
|
||||||
ball.remove();
|
p.sendMessage("§8[§6Soccer§8] §cBall entfernt.");
|
||||||
ball = null;
|
}
|
||||||
|
|
||||||
|
private void cmdGoal(Player p, String[] args) {
|
||||||
|
if (args.length < 3) { sendGoalHelp(p); return; }
|
||||||
|
|
||||||
|
switch (args[2].toLowerCase()) {
|
||||||
|
|
||||||
|
case "pos1" -> {
|
||||||
|
selPos1.put(p.getUniqueId(), p.getLocation().clone());
|
||||||
|
p.sendMessage("§8[§6Soccer§8] §aPos1 §7gesetzt bei §e" + fmt(p.getLocation()));
|
||||||
|
p.sendMessage("§8[§6Soccer§8] §7Zur gegenüberliegenden Ecke und §e/nexuslobby ball goal pos2§7 eingeben.");
|
||||||
|
}
|
||||||
|
|
||||||
|
case "pos2" -> {
|
||||||
|
selPos2.put(p.getUniqueId(), p.getLocation().clone());
|
||||||
|
p.sendMessage("§8[§6Soccer§8] §aPos2 §7gesetzt bei §e" + fmt(p.getLocation()));
|
||||||
|
p.sendMessage("§8[§6Soccer§8] §7Speichern mit §e/nexuslobby ball goal save <n> <1|2>§7.");
|
||||||
|
}
|
||||||
|
|
||||||
|
case "save" -> {
|
||||||
|
if (args.length < 5) { p.sendMessage("§cVerwendung: /nexuslobby ball goal save <n> <1|2>"); return; }
|
||||||
|
Location p1 = selPos1.get(p.getUniqueId());
|
||||||
|
Location p2 = selPos2.get(p.getUniqueId());
|
||||||
|
if (p1 == null || p2 == null) { p.sendMessage("§cZuerst pos1 und pos2 setzen!"); return; }
|
||||||
|
int team;
|
||||||
|
try { team = Integer.parseInt(args[4]); }
|
||||||
|
catch (NumberFormatException e) { p.sendMessage("§cTeam muss 1 oder 2 sein!"); return; }
|
||||||
|
if (team != 1 && team != 2) { p.sendMessage("§cTeam muss 1 §9(Blau)§c oder 2 §c(Rot) sein!"); return; }
|
||||||
|
String name = args[3];
|
||||||
|
SoccerGoal goal = new SoccerGoal(name, p1, p2, team);
|
||||||
|
goals.put(name, goal);
|
||||||
|
saveGoal(goal);
|
||||||
|
selPos1.remove(p.getUniqueId()); selPos2.remove(p.getUniqueId());
|
||||||
|
p.sendMessage("§8[§6Soccer§8] §aTor §e" + name + " §afür " + (team==1?"§9":"§c") + "Team " + team + " §aerstellt!");
|
||||||
|
p.sendMessage("§8[§6Soccer§8] §7Nutze §e/nexuslobby ball goal show §7um die Box zu sehen.");
|
||||||
|
drawGoalFrame(goal);
|
||||||
|
}
|
||||||
|
|
||||||
|
case "delete" -> {
|
||||||
|
if (args.length < 4) { p.sendMessage("§cVerwendung: /nexuslobby ball goal delete <n>"); return; }
|
||||||
|
String name = args[3];
|
||||||
|
if (goals.remove(name) != null) {
|
||||||
|
deleteGoal(name);
|
||||||
|
p.sendMessage("§8[§6Soccer§8] §cTor §e" + name + " §cgelöscht.");
|
||||||
|
} else {
|
||||||
|
p.sendMessage("§cTor '" + name + "' nicht gefunden. Tore: " + String.join(", ", goals.keySet()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case "list" -> {
|
||||||
|
if (goals.isEmpty()) { p.sendMessage("§8[§6Soccer§8] §7Keine Tore gesetzt."); return; }
|
||||||
|
p.sendMessage("§8[§6Soccer§8] §6Registrierte Tore §8(" + goals.size() + ")§6:");
|
||||||
|
goals.forEach((name, g) -> p.sendMessage(
|
||||||
|
"§8 » §e" + name + " §8— " + (g.team==1?"§9Blau":"§cRot") +
|
||||||
|
" §8| §7" + fmt(g.pos1) + " §8→ §7" + fmt(g.pos2)));
|
||||||
|
}
|
||||||
|
|
||||||
|
case "show" -> {
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
final int tick = i * 4;
|
||||||
|
Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), this::drawAllGoalParticles, tick);
|
||||||
|
}
|
||||||
|
p.sendMessage("§8[§6Soccer§8] §aTore werden für ~2 Sekunden angezeigt.");
|
||||||
|
}
|
||||||
|
|
||||||
|
case "debug" -> {
|
||||||
|
if (ball == null || !ball.isValid()) { p.sendMessage("§8[§6Soccer§8] §cKein Ball."); return; }
|
||||||
|
Location bl = ball.getLocation();
|
||||||
|
Vector bv = ball.getVelocity();
|
||||||
|
p.sendMessage("§8[§6Soccer§8] §6Ball getLocation(): §f" + fmtFull(bl));
|
||||||
|
p.sendMessage("§8[§6Soccer§8] §6Ball getVelocity(): §f" + fmtVec(bv) + " §7(speed=" + String.format("%.4f", bv.length()) + ")");
|
||||||
|
p.sendMessage("§8[§6Soccer§8] §6prevPos: §f" + (prevPos != null ? fmtFull(prevPos) : "null"));
|
||||||
|
if (!goals.isEmpty()) {
|
||||||
|
p.sendMessage("§8[§6Soccer§8] §7Direkter Punkt-Check:");
|
||||||
|
for (SoccerGoal g : goals.values()) {
|
||||||
|
boolean h0 = g.contains(bl.clone());
|
||||||
|
boolean h1 = g.contains(bl.clone().add(0, 0.45, 0));
|
||||||
|
boolean h2 = g.contains(bl.clone().add(0, 0.9, 0));
|
||||||
|
p.sendMessage(" §e" + g.name + " §7Fuß=" + cb(h0) + " Mitte=" + cb(h1) + " Kopf=" + cb(h2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default -> sendGoalHelp(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cmdScore(Player p, String[] args) {
|
||||||
|
if (args.length >= 3 && args[2].equalsIgnoreCase("reset")) {
|
||||||
|
scores.put(1, 0);
|
||||||
|
scores.put(2, 0);
|
||||||
|
for (Player pl : Bukkit.getOnlinePlayers()) {
|
||||||
|
pl.sendMessage("§8[§6Soccer§8] §eStand wurde zurückgesetzt! §8| §fNeuer Stand: " + getScoreString());
|
||||||
|
pl.sendTitle("§eStand zurückgesetzt!", "§90 §8: §c0", 5, 40, 10);
|
||||||
|
pl.playSound(pl.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1f, 1.2f);
|
||||||
|
}
|
||||||
|
Bukkit.getLogger().info("[Soccer] Stand von " + p.getName() + " zurückgesetzt.");
|
||||||
|
} else {
|
||||||
|
p.sendMessage("§8[§6Soccer§8] §6Aktueller Stand: §f" + getScoreString());
|
||||||
|
p.sendMessage("§8[§6Soccer§8] §7Reset: §e/nexuslobby ball score reset");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================================
|
||||||
|
// HILFSMETHODEN
|
||||||
|
// =========================================================================
|
||||||
|
|
||||||
|
private String getScoreString() {
|
||||||
|
return "§9" + scores.getOrDefault(1, 0) + " §8: §c" + scores.getOrDefault(2, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String fmt(Location l) {
|
||||||
|
return String.format("%.0f/%.0f/%.0f", l.getX(), l.getY(), l.getZ());
|
||||||
|
}
|
||||||
|
private static String fmtFull(Location l) {
|
||||||
|
return String.format("%.3f/%.3f/%.3f", l.getX(), l.getY(), l.getZ());
|
||||||
|
}
|
||||||
|
private static String fmtVec(Vector v) {
|
||||||
|
return String.format("%.3f/%.3f/%.3f", v.getX(), v.getY(), v.getZ());
|
||||||
|
}
|
||||||
|
private static String cb(boolean b) { return b ? "§atrue §r" : "§cfalse §r"; }
|
||||||
|
|
||||||
|
private void loadConfigLocation() {
|
||||||
|
FileConfiguration c = NexusLobby.getInstance().getConfig();
|
||||||
|
if (!c.contains("ball.spawn.world")) return;
|
||||||
|
String wName = c.getString("ball.spawn.world");
|
||||||
|
World world = Bukkit.getWorld(wName);
|
||||||
|
if (world == null) {
|
||||||
|
Bukkit.getLogger().warning("[Soccer] Spawn-Welt '" + wName + "' nicht gefunden!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
spawnLocation = new Location(world,
|
||||||
|
c.getDouble("ball.spawn.x"), c.getDouble("ball.spawn.y"), c.getDouble("ball.spawn.z"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendHelp(Player p) {
|
||||||
|
p.sendMessage("§8§m─────────────§r §6§lSoccer §r§8§m─────────────");
|
||||||
|
p.sendMessage("§e/nexuslobby ball setspawn §7Ball-Spawn setzen");
|
||||||
|
p.sendMessage("§e/nexuslobby ball respawn §7Ball neu spawnen");
|
||||||
|
p.sendMessage("§e/nexuslobby ball remove §7Ball entfernen");
|
||||||
|
p.sendMessage("§e/nexuslobby ball goal ... §7Tore verwalten");
|
||||||
|
p.sendMessage("§e/nexuslobby ball score §7Stand anzeigen");
|
||||||
|
p.sendMessage("§e/nexuslobby ball score reset §7Stand zurücksetzen");
|
||||||
|
p.sendMessage("§8§m─────────────────────────────────────────");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendGoalHelp(Player p) {
|
||||||
|
p.sendMessage("§8§m─────────────§r §6§lTore einrichten §r§8§m─────────────");
|
||||||
|
p.sendMessage("§71. §7Stehe in eine Ecke des Tors:");
|
||||||
|
p.sendMessage(" §e/nexuslobby ball goal pos1");
|
||||||
|
p.sendMessage("§72. §7Zur gegenüberliegenden Ecke gehen:");
|
||||||
|
p.sendMessage(" §e/nexuslobby ball goal pos2");
|
||||||
|
p.sendMessage("§73. §7Speichern §8(Team 1=§9Blau§8, 2=§cRot§8)§7:");
|
||||||
|
p.sendMessage(" §e/nexuslobby ball goal save <n> <1|2>");
|
||||||
|
p.sendMessage("§e/nexuslobby ball goal delete <n> §7Tor löschen");
|
||||||
|
p.sendMessage("§e/nexuslobby ball goal list §7Alle Tore");
|
||||||
|
p.sendMessage("§e/nexuslobby ball goal show §7Tore anzeigen");
|
||||||
|
p.sendMessage("§e/nexuslobby ball goal debug §7Ball-Position debuggen");
|
||||||
|
p.sendMessage("§8§m─────────────────────────────────────────────────");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -40,10 +40,21 @@ public class BorderCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
double radius = Double.parseDouble(args[1]);
|
double radius = Double.parseDouble(args[1]);
|
||||||
|
Location loc = p.getLocation();
|
||||||
|
|
||||||
config.set("worldborder.type", "CIRCLE");
|
config.set("worldborder.type", "CIRCLE");
|
||||||
config.set("worldborder.center", p.getLocation());
|
|
||||||
config.set("worldborder.radius", radius);
|
|
||||||
config.set("worldborder.enabled", true);
|
config.set("worldborder.enabled", true);
|
||||||
|
config.set("worldborder.radius", radius);
|
||||||
|
|
||||||
|
// FIX: Location als einzelne Werte speichern statt als Objekt.
|
||||||
|
// config.set(key, Location) ist nach Neustarts unzuverlässig,
|
||||||
|
// weil config.getLocation() die Welt zum Deserialisierungs-
|
||||||
|
// zeitpunkt auflösen muss und das fehlschlagen kann.
|
||||||
|
config.set("worldborder.center.world", loc.getWorld().getName());
|
||||||
|
config.set("worldborder.center.x", loc.getX());
|
||||||
|
config.set("worldborder.center.y", loc.getY());
|
||||||
|
config.set("worldborder.center.z", loc.getZ());
|
||||||
|
|
||||||
p.sendMessage("§8[§6Nexus§8] §aKreis-Grenze (Radius: " + radius + ") gesetzt.");
|
p.sendMessage("§8[§6Nexus§8] §aKreis-Grenze (Radius: " + radius + ") gesetzt.");
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
p.sendMessage("§cUngültige Zahl.");
|
p.sendMessage("§cUngültige Zahl.");
|
||||||
@@ -57,10 +68,21 @@ public class BorderCommand implements CommandExecutor {
|
|||||||
p.sendMessage("§8[§6Nexus§8] §cBitte markiere erst 2 Punkte mit der Portalwand!");
|
p.sendMessage("§8[§6Nexus§8] §cBitte markiere erst 2 Punkte mit der Portalwand!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
config.set("worldborder.type", "SQUARE");
|
config.set("worldborder.type", "SQUARE");
|
||||||
config.set("worldborder.pos1", l1);
|
|
||||||
config.set("worldborder.pos2", l2);
|
|
||||||
config.set("worldborder.enabled", true);
|
config.set("worldborder.enabled", true);
|
||||||
|
|
||||||
|
// FIX: Beide Positionen als einzelne Werte speichern
|
||||||
|
config.set("worldborder.pos1.world", l1.getWorld().getName());
|
||||||
|
config.set("worldborder.pos1.x", l1.getX());
|
||||||
|
config.set("worldborder.pos1.y", l1.getY());
|
||||||
|
config.set("worldborder.pos1.z", l1.getZ());
|
||||||
|
|
||||||
|
config.set("worldborder.pos2.world", l2.getWorld().getName());
|
||||||
|
config.set("worldborder.pos2.x", l2.getX());
|
||||||
|
config.set("worldborder.pos2.y", l2.getY());
|
||||||
|
config.set("worldborder.pos2.z", l2.getZ());
|
||||||
|
|
||||||
p.sendMessage("§8[§6Nexus§8] §aViereckige Grenze erfolgreich gesetzt.");
|
p.sendMessage("§8[§6Nexus§8] §aViereckige Grenze erfolgreich gesetzt.");
|
||||||
}
|
}
|
||||||
case "disable" -> {
|
case "disable" -> {
|
||||||
|
|||||||
@@ -9,19 +9,29 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verwaltet die Lobby-Begrenzung (Kreis oder Rechteck).
|
* Verwaltet die Lobby-Begrenzung (Kreis oder Rechteck).
|
||||||
* Speichert Daten in der Haupt-config.yml unter 'worldborder'.
|
* Speichert Daten in der Haupt-config.yml unter 'worldborder'.
|
||||||
|
*
|
||||||
|
* FIX: Locations werden als einzelne Werte (worldName, x, y, z) gespeichert
|
||||||
|
* statt als serialisiertes Location-Objekt, da config.getLocation()
|
||||||
|
* nach einem Neustart unzuverlässig ist.
|
||||||
*/
|
*/
|
||||||
public class BorderModule implements Module, Listener {
|
public class BorderModule implements Module, Listener {
|
||||||
|
|
||||||
private String type;
|
private String type;
|
||||||
private Location pos1, pos2, center;
|
// FIX: Statt Location-Objekte die rohen Werte cachen
|
||||||
|
private String pos1World, pos2World, centerWorld;
|
||||||
|
private double pos1X, pos1Y, pos1Z;
|
||||||
|
private double pos2X, pos2Y, pos2Z;
|
||||||
|
private double centerX, centerZ;
|
||||||
private double radius;
|
private double radius;
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
|
private boolean hasPos1, hasPos2, hasCenter;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() { return "WorldBorder"; }
|
public String getName() { return "WorldBorder"; }
|
||||||
@@ -34,74 +44,96 @@ public class BorderModule implements Module, Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
// Aufräumarbeiten falls nötig
|
// FIX: Listener beim Deaktivieren abmelden, damit nach /reload
|
||||||
|
// keine doppelten Events gefeuert werden.
|
||||||
|
HandlerList.unregisterAll(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lädt die Border-Einstellungen aus der config.yml.
|
* Lädt die Border-Einstellungen aus der config.yml.
|
||||||
* Wird auch von NexusLobby.reloadPlugin() aufgerufen.
|
* Wird auch von BorderCommand und NexusLobby.reloadPlugin() aufgerufen.
|
||||||
|
*
|
||||||
|
* FIX: Robuste Methode - liest world-Name und einzelne Koordinaten,
|
||||||
|
* kein config.getLocation() mehr (das nach Neustarts versagen kann).
|
||||||
*/
|
*/
|
||||||
public void reloadConfig() {
|
public void reloadConfig() {
|
||||||
FileConfiguration config = NexusLobby.getInstance().getConfig();
|
FileConfiguration config = NexusLobby.getInstance().getConfig();
|
||||||
|
|
||||||
// Pfad in der config.yml: worldborder.enabled etc.
|
|
||||||
this.enabled = config.getBoolean("worldborder.enabled", false);
|
this.enabled = config.getBoolean("worldborder.enabled", false);
|
||||||
this.type = config.getString("worldborder.type", "CIRCLE");
|
this.type = config.getString("worldborder.type", "CIRCLE").toUpperCase();
|
||||||
this.radius = config.getDouble("worldborder.radius", 50.0);
|
this.radius = config.getDouble("worldborder.radius", 50.0);
|
||||||
|
|
||||||
// Locations laden
|
// --- CIRCLE-Daten laden ---
|
||||||
this.center = config.getLocation("worldborder.center");
|
this.hasCenter = config.contains("worldborder.center.world");
|
||||||
this.pos1 = config.getLocation("worldborder.pos1");
|
if (hasCenter) {
|
||||||
this.pos2 = config.getLocation("worldborder.pos2");
|
this.centerWorld = config.getString("worldborder.center.world");
|
||||||
|
this.centerX = config.getDouble("worldborder.center.x");
|
||||||
|
this.centerZ = config.getDouble("worldborder.center.z");
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- SQUARE-Daten laden ---
|
||||||
|
this.hasPos1 = config.contains("worldborder.pos1.world");
|
||||||
|
this.hasPos2 = config.contains("worldborder.pos2.world");
|
||||||
|
if (hasPos1) {
|
||||||
|
this.pos1World = config.getString("worldborder.pos1.world");
|
||||||
|
this.pos1X = config.getDouble("worldborder.pos1.x");
|
||||||
|
this.pos1Y = config.getDouble("worldborder.pos1.y");
|
||||||
|
this.pos1Z = config.getDouble("worldborder.pos1.z");
|
||||||
|
}
|
||||||
|
if (hasPos2) {
|
||||||
|
this.pos2World = config.getString("worldborder.pos2.world");
|
||||||
|
this.pos2X = config.getDouble("worldborder.pos2.x");
|
||||||
|
this.pos2Y = config.getDouble("worldborder.pos2.y");
|
||||||
|
this.pos2Z = config.getDouble("worldborder.pos2.z");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onMove(PlayerMoveEvent event) {
|
public void onMove(PlayerMoveEvent event) {
|
||||||
if (!enabled || event.getTo() == null) return;
|
if (!enabled || event.getTo() == null) return;
|
||||||
|
|
||||||
// Performance: Nur prüfen, wenn sich die Block-Koordinaten ändern
|
// Performance: Nur prüfen wenn sich Block-Koordinaten ändern
|
||||||
if (event.getFrom().getBlockX() == event.getTo().getBlockX() &&
|
if (event.getFrom().getBlockX() == event.getTo().getBlockX() &&
|
||||||
event.getFrom().getBlockZ() == event.getTo().getBlockZ() &&
|
event.getFrom().getBlockZ() == event.getTo().getBlockZ() &&
|
||||||
event.getFrom().getBlockY() == event.getTo().getBlockY()) return;
|
event.getFrom().getBlockY() == event.getTo().getBlockY()) return;
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
// Admins und Spectators ignorieren
|
// FIX: nexuslobby.border.bypass statt nur nexuslobby.admin prüfen
|
||||||
if (player.hasPermission("nexuslobby.admin") || player.getGameMode().name().equals("SPECTATOR")) return;
|
if (player.hasPermission("nexuslobby.border.bypass") ||
|
||||||
|
player.hasPermission("nexuslobby.admin") ||
|
||||||
|
player.getGameMode().name().equals("SPECTATOR")) return;
|
||||||
|
|
||||||
Location to = event.getTo();
|
Location to = event.getTo();
|
||||||
boolean outside = false;
|
boolean outside = false;
|
||||||
|
|
||||||
// --- Prüfung: Kreis-Border ---
|
// --- Prüfung: Kreis-Border ---
|
||||||
if (type.equalsIgnoreCase("CIRCLE") && center != null) {
|
if (type.equals("CIRCLE") && hasCenter) {
|
||||||
if (to.getWorld().equals(center.getWorld())) {
|
World cWorld = Bukkit.getWorld(centerWorld);
|
||||||
double distSq = Math.pow(to.getX() - center.getX(), 2) + Math.pow(to.getZ() - center.getZ(), 2);
|
if (cWorld != null && to.getWorld().equals(cWorld)) {
|
||||||
if (distSq > Math.pow(radius, 2)) outside = true;
|
double distSq = Math.pow(to.getX() - centerX, 2) + Math.pow(to.getZ() - centerZ, 2);
|
||||||
|
if (distSq > radius * radius) outside = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// --- Prüfung: Rechteck-Border (Square) ---
|
// --- Prüfung: Rechteck-Border (Square) ---
|
||||||
else if (type.equalsIgnoreCase("SQUARE") && pos1 != null && pos2 != null) {
|
else if (type.equals("SQUARE") && hasPos1 && hasPos2) {
|
||||||
if (to.getWorld().equals(pos1.getWorld())) {
|
World bWorld = Bukkit.getWorld(pos1World);
|
||||||
double minX = Math.min(pos1.getX(), pos2.getX());
|
if (bWorld != null && to.getWorld().equals(bWorld)) {
|
||||||
double maxX = Math.max(pos1.getX(), pos2.getX());
|
double minX = Math.min(pos1X, pos2X);
|
||||||
double minZ = Math.min(pos1.getZ(), pos2.getZ());
|
double maxX = Math.max(pos1X, pos2X);
|
||||||
double maxZ = Math.max(pos1.getZ(), pos2.getZ());
|
double minZ = Math.min(pos1Z, pos2Z);
|
||||||
|
double maxZ = Math.max(pos1Z, pos2Z);
|
||||||
if (to.getX() < minX || to.getX() > maxX || to.getZ() < minZ || to.getZ() > maxZ) {
|
if (to.getX() < minX || to.getX() > maxX ||
|
||||||
|
to.getZ() < minZ || to.getZ() > maxZ) {
|
||||||
outside = true;
|
outside = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Aktion wenn außerhalb ---
|
|
||||||
if (outside) {
|
if (outside) {
|
||||||
Location spawnLocation = getMainSpawnLocation();
|
Location spawnLocation = getMainSpawnLocation();
|
||||||
|
|
||||||
if (spawnLocation != null) {
|
if (spawnLocation != null) {
|
||||||
// Sofortiger Teleport zum definierten Spawn
|
|
||||||
player.teleport(spawnLocation);
|
player.teleport(spawnLocation);
|
||||||
|
|
||||||
// Feedback an den Spieler
|
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1.0f, 0.5f);
|
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1.0f, 0.5f);
|
||||||
player.sendMessage("§8[§6Nexus§8] §cDu hast den Lobby-Bereich verlassen!");
|
player.sendMessage("§8[§6Nexus§8] §cDu hast den Lobby-Bereich verlassen!");
|
||||||
}
|
}
|
||||||
@@ -109,12 +141,11 @@ public class BorderModule implements Module, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holt den zentralen Spawnpunkt aus der Config (Pfad: spawn.world, spawn.x, etc.)
|
* Holt den Spawnpunkt aus der Config (Pfad: spawn.world, spawn.x, etc.)
|
||||||
*/
|
*/
|
||||||
private Location getMainSpawnLocation() {
|
private Location getMainSpawnLocation() {
|
||||||
FileConfiguration config = NexusLobby.getInstance().getConfig();
|
FileConfiguration config = NexusLobby.getInstance().getConfig();
|
||||||
String worldName = config.getString("spawn.world");
|
String worldName = config.getString("spawn.world");
|
||||||
|
|
||||||
if (worldName != null) {
|
if (worldName != null) {
|
||||||
World w = Bukkit.getWorld(worldName);
|
World w = Bukkit.getWorld(worldName);
|
||||||
if (w != null) {
|
if (w != null) {
|
||||||
@@ -126,7 +157,6 @@ public class BorderModule implements Module, Listener {
|
|||||||
(float) config.getDouble("spawn.pitch"));
|
(float) config.getDouble("spawn.pitch"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Fallback falls kein Spawn gesetzt ist
|
|
||||||
return Bukkit.getWorlds().isEmpty() ? null : Bukkit.getWorlds().get(0).getSpawnLocation();
|
return Bukkit.getWorlds().isEmpty() ? null : Bukkit.getWorlds().get(0).getSpawnLocation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -28,6 +28,8 @@ public class Balloon {
|
|||||||
this.balloonEntity.setInvulnerable(true);
|
this.balloonEntity.setInvulnerable(true);
|
||||||
this.balloonEntity.setGravity(false);
|
this.balloonEntity.setGravity(false);
|
||||||
this.balloonEntity.setLeashHolder(player);
|
this.balloonEntity.setLeashHolder(player);
|
||||||
|
// Tag damit GadgetModule Rechtsklicks auf den Ballon abfangen kann
|
||||||
|
this.balloonEntity.addScoreboardTag("nexus_balloon");
|
||||||
|
|
||||||
// Der ArmorStand, der den farbigen Block trägt
|
// Der ArmorStand, der den farbigen Block trägt
|
||||||
this.headStand = (ArmorStand) loc.getWorld().spawnEntity(loc, EntityType.ARMOR_STAND);
|
this.headStand = (ArmorStand) loc.getWorld().spawnEntity(loc, EntityType.ARMOR_STAND);
|
||||||
|
|||||||
@@ -14,7 +14,15 @@ import java.util.Random;
|
|||||||
|
|
||||||
public class ChickenRain {
|
public class ChickenRain {
|
||||||
|
|
||||||
|
// FIX: Verhindert, dass ein Spieler den Regen mehrfach gleichzeitig starten kann.
|
||||||
|
// Ohne diese Prüfung konnten beliebig viele parallele Tasks gestartet werden,
|
||||||
|
// was zu hunderten gespawnten Entities in Sekunden führte.
|
||||||
|
private static final java.util.Set<java.util.UUID> activeRains =
|
||||||
|
java.util.Collections.synchronizedSet(new java.util.HashSet<>());
|
||||||
|
|
||||||
public static void start(Player player) {
|
public static void start(Player player) {
|
||||||
|
if (activeRains.contains(player.getUniqueId())) return; // bereits aktiv
|
||||||
|
activeRains.add(player.getUniqueId());
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
int ticks = 0;
|
int ticks = 0;
|
||||||
final Random random = new Random();
|
final Random random = new Random();
|
||||||
@@ -22,6 +30,7 @@ public class ChickenRain {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!player.isOnline() || ticks > 100) { // 100 Ticks = 5 Sekunden
|
if (!player.isOnline() || ticks > 100) { // 100 Ticks = 5 Sekunden
|
||||||
|
activeRains.remove(player.getUniqueId());
|
||||||
this.cancel();
|
this.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,32 +13,40 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class FreezeRay {
|
public class FreezeRay {
|
||||||
// Auf public gesetzt, damit das GadgetModule im PlayerMoveEvent darauf prüfen kann
|
|
||||||
public static final Set<UUID> frozenPlayers = new HashSet<>();
|
private static final Set<UUID> frozenPlayers = new HashSet<>();
|
||||||
|
|
||||||
|
public static boolean isFrozen(UUID uuid) { return frozenPlayers.contains(uuid); }
|
||||||
|
|
||||||
|
/** Beim Disconnect aufrufen, damit kein Ghost-Eintrag bleibt. */
|
||||||
|
public static void unfreeze(UUID uuid) { frozenPlayers.remove(uuid); }
|
||||||
|
|
||||||
public static void shoot(Player shooter) {
|
public static void shoot(Player shooter) {
|
||||||
Location start = shooter.getEyeLocation();
|
Location start = shooter.getEyeLocation();
|
||||||
Vector direction = start.getDirection();
|
Vector direction = start.getDirection();
|
||||||
|
|
||||||
// Sound beim Schießen
|
|
||||||
shooter.getWorld().playSound(start, Sound.ENTITY_SNOW_GOLEM_SHOOT, 1.0f, 1.5f);
|
shooter.getWorld().playSound(start, Sound.ENTITY_SNOW_GOLEM_SHOOT, 1.0f, 1.5f);
|
||||||
|
|
||||||
// Wir prüfen in 0.3er Schritten bis zu 15 Blöcke weit
|
|
||||||
for (double d = 0; d < 15; d += 0.3) {
|
for (double d = 0; d < 15; d += 0.3) {
|
||||||
Location point = start.clone().add(direction.clone().multiply(d));
|
Location point = start.clone().add(direction.clone().multiply(d));
|
||||||
|
|
||||||
// Partikel-Strahl sichtbar machen
|
|
||||||
point.getWorld().spawnParticle(Particle.SNOWFLAKE, point, 1, 0, 0, 0, 0);
|
point.getWorld().spawnParticle(Particle.SNOWFLAKE, point, 1, 0, 0, 0, 0);
|
||||||
|
|
||||||
// Prüfung auf Spieler im Umkreis von 0.8 Blöcken (etwas großzügiger)
|
|
||||||
for (Entity entity : point.getWorld().getNearbyEntities(point, 0.8, 0.8, 0.8)) {
|
for (Entity entity : point.getWorld().getNearbyEntities(point, 0.8, 0.8, 0.8)) {
|
||||||
if (entity instanceof Player target && target != shooter) {
|
if (entity instanceof Player target && target != shooter) {
|
||||||
|
// Schutz: Parkour-Spieler und Admins mit aktivem Gadget-Schutz
|
||||||
|
if (GadgetShield.isProtected(target)) {
|
||||||
|
String reason = GadgetShield.isAdminShielded(target)
|
||||||
|
? "Dieser Spieler hat Gadget-Schutz aktiviert."
|
||||||
|
: "Dieser Spieler ist gerade im Parkour.";
|
||||||
|
shooter.sendMessage("§8[§6Nexus§8] §7" + reason);
|
||||||
|
return;
|
||||||
|
}
|
||||||
applyFreeze(target);
|
applyFreeze(target);
|
||||||
return; // Stoppt den Strahl beim ersten Treffer
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stoppe den Strahl, falls er eine Wand trifft
|
|
||||||
if (point.getBlock().getType().isSolid()) {
|
if (point.getBlock().getType().isSolid()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -49,11 +57,8 @@ public class FreezeRay {
|
|||||||
if (frozenPlayers.contains(target.getUniqueId())) return;
|
if (frozenPlayers.contains(target.getUniqueId())) return;
|
||||||
|
|
||||||
frozenPlayers.add(target.getUniqueId());
|
frozenPlayers.add(target.getUniqueId());
|
||||||
|
|
||||||
// Fixiere die Position für den Stasis-Effekt
|
|
||||||
final Location freezeLocation = target.getLocation();
|
final Location freezeLocation = target.getLocation();
|
||||||
|
|
||||||
// Feedback für getroffenen Spieler
|
|
||||||
target.sendMessage("§8[§6Nexus§8] §bDu wurdest eingefroren!");
|
target.sendMessage("§8[§6Nexus§8] §bDu wurdest eingefroren!");
|
||||||
target.getWorld().playSound(target.getLocation(), Sound.BLOCK_GLASS_BREAK, 1.0f, 0.5f);
|
target.getWorld().playSound(target.getLocation(), Sound.BLOCK_GLASS_BREAK, 1.0f, 0.5f);
|
||||||
|
|
||||||
@@ -61,18 +66,21 @@ public class FreezeRay {
|
|||||||
int ticks = 0;
|
int ticks = 0;
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// Sicherheitscheck: Ist der Spieler noch online?
|
|
||||||
if (!target.isOnline() || ticks >= 60) {
|
if (!target.isOnline() || ticks >= 60) {
|
||||||
frozenPlayers.remove(target.getUniqueId());
|
frozenPlayers.remove(target.getUniqueId());
|
||||||
this.cancel();
|
this.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stasis-Effekt: Bewegung auf 0 setzen und Position fixieren
|
// Falls der Spieler während des Einfrierens geschützt wird → sofort freigeben
|
||||||
|
if (GadgetShield.isProtected(target)) {
|
||||||
|
frozenPlayers.remove(target.getUniqueId());
|
||||||
|
this.cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
target.setVelocity(new Vector(0, 0, 0));
|
target.setVelocity(new Vector(0, 0, 0));
|
||||||
|
|
||||||
// Alle 2 Ticks zurückteleportieren, falls er versucht zu laufen
|
|
||||||
// (Behält die Blickrichtung des Spielers bei)
|
|
||||||
Location current = target.getLocation();
|
Location current = target.getLocation();
|
||||||
if (current.getX() != freezeLocation.getX() || current.getZ() != freezeLocation.getZ()) {
|
if (current.getX() != freezeLocation.getX() || current.getZ() != freezeLocation.getZ()) {
|
||||||
freezeLocation.setYaw(current.getYaw());
|
freezeLocation.setYaw(current.getYaw());
|
||||||
@@ -80,7 +88,6 @@ public class FreezeRay {
|
|||||||
target.teleport(freezeLocation);
|
target.teleport(freezeLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Optischer Käfig (Ring-Effekt)
|
|
||||||
Location loc = target.getLocation();
|
Location loc = target.getLocation();
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
double angle = i * Math.PI / 4;
|
double angle = i * Math.PI / 4;
|
||||||
|
|||||||
@@ -11,10 +11,12 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.entity.PlayerLeashEntityEvent;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.player.PlayerFishEvent;
|
import org.bukkit.event.player.PlayerFishEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
import org.bukkit.event.player.PlayerUnleashEntityEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemFlag;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -34,6 +36,18 @@ public class GadgetModule implements Module, Listener {
|
|||||||
private final Map<UUID, ParticleEffect> activeEffects = new HashMap<>();
|
private final Map<UUID, ParticleEffect> activeEffects = new HashMap<>();
|
||||||
private final Set<UUID> activeShields = new HashSet<>();
|
private final Set<UUID> activeShields = new HashSet<>();
|
||||||
|
|
||||||
|
// ── Cooldowns ─────────────────────────────────────────────────────────────
|
||||||
|
/** Letzter Einsatz-Zeitstempel pro Spieler */
|
||||||
|
private final Map<UUID, Long> meteorCooldowns = new HashMap<>();
|
||||||
|
private final Map<UUID, Long> freezeCooldowns = new HashMap<>();
|
||||||
|
private final Map<UUID, Long> grapplingCooldowns = new HashMap<>();
|
||||||
|
|
||||||
|
/** Cooldown-Dauer in Millisekunden */
|
||||||
|
private static final long METEOR_CD_MS = 15_000L; // 15 Sekunden
|
||||||
|
private static final long FREEZE_CD_MS = 10_000L; // 10 Sekunden
|
||||||
|
private static final long GRAPPLING_CD_MS = 3_000L; // 3 Sekunden
|
||||||
|
// ──────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
private final String MAIN_TITLE = "§b§lGadgets §8- §7Menü";
|
private final String MAIN_TITLE = "§b§lGadgets §8- §7Menü";
|
||||||
private final String BALLOON_TITLE = "§b§lGadgets §8- §eBallons";
|
private final String BALLOON_TITLE = "§b§lGadgets §8- §eBallons";
|
||||||
private final String PARTICLE_TITLE = "§b§lGadgets §8- §dPartikel";
|
private final String PARTICLE_TITLE = "§b§lGadgets §8- §dPartikel";
|
||||||
@@ -47,11 +61,11 @@ public class GadgetModule implements Module, Listener {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
||||||
|
PetManager.register();
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskTimer(NexusLobby.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskTimer(NexusLobby.getInstance(), () -> {
|
||||||
PetManager.updatePets();
|
PetManager.updatePets();
|
||||||
activeBalloons.values().forEach(Balloon::update);
|
activeBalloons.values().forEach(Balloon::update);
|
||||||
|
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
UUID uuid = p.getUniqueId();
|
UUID uuid = p.getUniqueId();
|
||||||
handleSpecialHatEffects(p);
|
handleSpecialHatEffects(p);
|
||||||
@@ -61,35 +75,130 @@ public class GadgetModule implements Module, Listener {
|
|||||||
}, 1L, 1L);
|
}, 1L, 1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
|
// Cooldown-Hilfsmethoden
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prüft ob der Spieler noch im Cooldown ist.
|
||||||
|
* @return true → Gadget darf benutzt werden (Cooldown abgelaufen / nicht gesetzt)
|
||||||
|
* false → Cooldown noch aktiv, Nachricht wird gesendet
|
||||||
|
*/
|
||||||
|
private boolean checkAndSetCooldown(Player player, Map<UUID, Long> cdMap, long durationMs, String gadgetName) {
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
long last = cdMap.getOrDefault(player.getUniqueId(), 0L);
|
||||||
|
long remaining = durationMs - (now - last);
|
||||||
|
if (remaining > 0) {
|
||||||
|
long secLeft = (long) Math.ceil(remaining / 1000.0);
|
||||||
|
player.sendMessage("§8[§6Nexus§8] §c" + gadgetName + " §7hat noch §e" + secLeft + "s §7Cooldown.");
|
||||||
|
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 0.5f, 0.8f);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
cdMap.put(player.getUniqueId(), now);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
|
// Event Handler
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verhindert Rechtsklick auf den unsichtbaren Ballon-Pig
|
||||||
|
* (verhindert Leine lösen, Inventar-Öffnen, etc.).
|
||||||
|
*/
|
||||||
|
@EventHandler
|
||||||
|
public void onInteractAtEntity(org.bukkit.event.player.PlayerInteractAtEntityEvent event) {
|
||||||
|
if (event.getRightClicked().getScoreboardTags().contains("nexus_balloon")) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verhindert das Ablösen der Leine vom Ballon-Pig durch Rechtsklick.
|
||||||
|
* Ohne diesen Handler wird die Leine gedroppt und der Ballon verschwindet.
|
||||||
|
*/
|
||||||
|
@EventHandler
|
||||||
|
public void onUnleash(PlayerUnleashEntityEvent event) {
|
||||||
|
if (event.getEntity().getScoreboardTags().contains("nexus_balloon")) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInteract(PlayerInteractEvent event) {
|
public void onInteract(PlayerInteractEvent event) {
|
||||||
ItemStack item = event.getItem();
|
ItemStack item = event.getItem();
|
||||||
if (item == null || !item.hasItemMeta() || !item.getItemMeta().hasDisplayName()) return;
|
if (item == null || !item.hasItemMeta() || !item.getItemMeta().hasDisplayName()) return;
|
||||||
String name = item.getItemMeta().getDisplayName();
|
String name = item.getItemMeta().getDisplayName();
|
||||||
|
|
||||||
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) return;
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
// Wenn der Schütze selbst geschützt ist (Parkour oder Admin-Schutz) → kampfbezogene Gadgets sperren
|
||||||
|
if (GadgetShield.isProtected(player)) {
|
||||||
|
if (name.equals("§b§lFreeze-Ray") || name.equals("§c§lMeteorit")) {
|
||||||
|
player.sendMessage("§8[§6Parkour§8] §cGadgets können während des Parkours nicht benutzt werden.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (name.equals("§b§lFreeze-Ray")) {
|
if (name.equals("§b§lFreeze-Ray")) {
|
||||||
FreezeRay.shoot(event.getPlayer());
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
if (checkAndSetCooldown(player, freezeCooldowns, FREEZE_CD_MS, "§b§lFreeze-Ray")) {
|
||||||
|
FreezeRay.shoot(player);
|
||||||
|
}
|
||||||
|
|
||||||
} else if (name.equals("§6§lPaintball-Gun")) {
|
} else if (name.equals("§6§lPaintball-Gun")) {
|
||||||
PaintballGun.shoot(event.getPlayer());
|
PaintballGun.shoot(player);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
} else if (name.equals("§c§lMeteorit")) {
|
} else if (name.equals("§c§lMeteorit")) {
|
||||||
MeteorStrike.launch(event.getPlayer());
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
if (checkAndSetCooldown(player, meteorCooldowns, METEOR_CD_MS, "§c§lMeteorit")) {
|
||||||
|
MeteorStrike.launch(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onFish(PlayerFishEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
ItemStack item = player.getInventory().getItemInMainHand();
|
||||||
|
if (item.getType() != Material.FISHING_ROD || !item.hasItemMeta() || !item.getItemMeta().hasDisplayName()) return;
|
||||||
|
if (!item.getItemMeta().getDisplayName().equals("§b§lEnterhaken")) return;
|
||||||
|
|
||||||
|
if (event.getState() == PlayerFishEvent.State.IN_GROUND
|
||||||
|
|| event.getState() == PlayerFishEvent.State.REEL_IN
|
||||||
|
|| event.getState() == PlayerFishEvent.State.CAUGHT_ENTITY) {
|
||||||
|
|
||||||
|
if (event.getHook() == null) return;
|
||||||
|
|
||||||
|
// Parkour-Check: Schütze im Parkour oder Admin-Schutz → nicht benutzen
|
||||||
|
if (GadgetShield.isProtected(player)) {
|
||||||
|
player.sendMessage("§8[§6Nexus§8] §cDer Enterhaken ist gerade nicht verfügbar.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!checkAndSetCooldown(player, grapplingCooldowns, GRAPPLING_CD_MS, "§b§lEnterhaken")) return;
|
||||||
|
|
||||||
|
GrapplingHook.pullPlayer(player, event.getHook().getLocation());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
if (FreezeRay.frozenPlayers.contains(event.getPlayer().getUniqueId())) {
|
if (FreezeRay.isFrozen(event.getPlayer().getUniqueId())) {
|
||||||
if (event.getFrom().getX() != event.getTo().getX() || event.getFrom().getZ() != event.getTo().getZ()) {
|
if (event.getFrom().getX() != event.getTo().getX() || event.getFrom().getZ() != event.getTo().getZ()) {
|
||||||
event.setTo(event.getFrom().setDirection(event.getTo().getDirection()));
|
event.setTo(event.getFrom().setDirection(event.getTo().getDirection()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
|
// GUI
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
private void handleSpecialHatEffects(Player p) {
|
private void handleSpecialHatEffects(Player p) {
|
||||||
ItemStack hat = p.getInventory().getHelmet();
|
ItemStack hat = p.getInventory().getHelmet();
|
||||||
if (hat == null || hat.getType() == Material.AIR) return;
|
if (hat == null || hat.getType() == Material.AIR) return;
|
||||||
@@ -106,13 +215,11 @@ public class GadgetModule implements Module, Listener {
|
|||||||
public void openGUI(Player player) {
|
public void openGUI(Player player) {
|
||||||
Inventory gui = Bukkit.createInventory(null, 27, MAIN_TITLE);
|
Inventory gui = Bukkit.createInventory(null, 27, MAIN_TITLE);
|
||||||
fillEdges(gui);
|
fillEdges(gui);
|
||||||
|
|
||||||
gui.setItem(10, createItem(Material.LEAD, "§e§lBallons", "§7Wähle einen fliegenden Begleiter"));
|
gui.setItem(10, createItem(Material.LEAD, "§e§lBallons", "§7Wähle einen fliegenden Begleiter"));
|
||||||
gui.setItem(11, createItem(Material.GOLDEN_HELMET, "§a§lHüte", "§7Setze dir etwas auf den Kopf"));
|
gui.setItem(11, createItem(Material.GOLDEN_HELMET, "§a§lHüte", "§7Setze dir etwas auf den Kopf"));
|
||||||
gui.setItem(13, createItem(Material.BONE, "§d§lBegleiter", "§7Echte Tiere, die dir folgen"));
|
gui.setItem(13, createItem(Material.BONE, "§d§lBegleiter", "§7Echte Tiere, die dir folgen"));
|
||||||
gui.setItem(15, createItem(Material.FIREWORK_ROCKET,"§6§lLustiges", "§7Witzige Effekte"));
|
gui.setItem(15, createItem(Material.FIREWORK_ROCKET,"§6§lLustiges", "§7Witzige Effekte"));
|
||||||
gui.setItem(16, createItem(Material.NETHER_STAR, "§d§lPartikel", "§7Magische Auren & Effekte"));
|
gui.setItem(16, createItem(Material.NETHER_STAR, "§d§lPartikel", "§7Magische Auren & Effekte"));
|
||||||
|
|
||||||
gui.setItem(22, createItem(Material.BARRIER, "§c§lStopp", "§7Alle Gadgets entfernen"));
|
gui.setItem(22, createItem(Material.BARRIER, "§c§lStopp", "§7Alle Gadgets entfernen"));
|
||||||
player.openInventory(gui);
|
player.openInventory(gui);
|
||||||
}
|
}
|
||||||
@@ -120,7 +227,6 @@ public class GadgetModule implements Module, Listener {
|
|||||||
private void openHatGUI(Player player) {
|
private void openHatGUI(Player player) {
|
||||||
Inventory gui = Bukkit.createInventory(null, 45, HAT_TITLE);
|
Inventory gui = Bukkit.createInventory(null, 45, HAT_TITLE);
|
||||||
fillEdges(gui);
|
fillEdges(gui);
|
||||||
|
|
||||||
gui.setItem(10, createItem(Material.JACK_O_LANTERN, "§6Kürbis-Hut", "§7Es ist immer Halloween!"));
|
gui.setItem(10, createItem(Material.JACK_O_LANTERN, "§6Kürbis-Hut", "§7Es ist immer Halloween!"));
|
||||||
gui.setItem(11, createItem(Material.SEA_LANTERN, "§bMeeres-Leuchten", "§7§oEffekt: Glitzern"));
|
gui.setItem(11, createItem(Material.SEA_LANTERN, "§bMeeres-Leuchten", "§7§oEffekt: Glitzern"));
|
||||||
gui.setItem(12, createItem(Material.GLOWSTONE, "§eGlowstone-Kopf", "§7Werde zur Lampe"));
|
gui.setItem(12, createItem(Material.GLOWSTONE, "§eGlowstone-Kopf", "§7Werde zur Lampe"));
|
||||||
@@ -142,7 +248,6 @@ public class GadgetModule implements Module, Listener {
|
|||||||
gui.setItem(32, createItem(Material.ENCHANTING_TABLE,"§dMagier", "§7§oEffekt: Runen"));
|
gui.setItem(32, createItem(Material.ENCHANTING_TABLE,"§dMagier", "§7§oEffekt: Runen"));
|
||||||
gui.setItem(33, createItem(Material.CAMPFIRE, "§cHeißer Kopf", "§7§oEffekt: Rauch"));
|
gui.setItem(33, createItem(Material.CAMPFIRE, "§cHeißer Kopf", "§7§oEffekt: Rauch"));
|
||||||
gui.setItem(34, createItem(Material.SKELETON_SKULL, "§7Skelett", "§7Ein wenig gruselig"));
|
gui.setItem(34, createItem(Material.SKELETON_SKULL, "§7Skelett", "§7Ein wenig gruselig"));
|
||||||
|
|
||||||
gui.setItem(40, createItem(Material.ARROW, "§7Zurück", "§8Zum Hauptmenü"));
|
gui.setItem(40, createItem(Material.ARROW, "§7Zurück", "§8Zum Hauptmenü"));
|
||||||
player.openInventory(gui);
|
player.openInventory(gui);
|
||||||
}
|
}
|
||||||
@@ -160,10 +265,10 @@ public class GadgetModule implements Module, Listener {
|
|||||||
private void openBalloonGUI(Player player) {
|
private void openBalloonGUI(Player player) {
|
||||||
Inventory gui = Bukkit.createInventory(null, 36, BALLOON_TITLE);
|
Inventory gui = Bukkit.createInventory(null, 36, BALLOON_TITLE);
|
||||||
fillEdges(gui);
|
fillEdges(gui);
|
||||||
Material[] wools = {Material.WHITE_WOOL, Material.ORANGE_WOOL, Material.MAGENTA_WOOL, Material.LIGHT_BLUE_WOOL,
|
Material[] wools = {Material.WHITE_WOOL, Material.ORANGE_WOOL, Material.MAGENTA_WOOL,
|
||||||
Material.YELLOW_WOOL, Material.LIME_WOOL, Material.PINK_WOOL, Material.GRAY_WOOL,
|
Material.LIGHT_BLUE_WOOL, Material.YELLOW_WOOL, Material.LIME_WOOL, Material.PINK_WOOL,
|
||||||
Material.CYAN_WOOL, Material.PURPLE_WOOL, Material.BLUE_WOOL, Material.BROWN_WOOL,
|
Material.GRAY_WOOL, Material.CYAN_WOOL, Material.PURPLE_WOOL, Material.BLUE_WOOL,
|
||||||
Material.GREEN_WOOL, Material.RED_WOOL};
|
Material.BROWN_WOOL, Material.GREEN_WOOL, Material.RED_WOOL};
|
||||||
int slot = 10;
|
int slot = 10;
|
||||||
for (Material m : wools) {
|
for (Material m : wools) {
|
||||||
if (slot == 17) slot = 19;
|
if (slot == 17) slot = 19;
|
||||||
@@ -186,10 +291,10 @@ public class GadgetModule implements Module, Listener {
|
|||||||
private void openFunGUI(Player player) {
|
private void openFunGUI(Player player) {
|
||||||
Inventory gui = Bukkit.createInventory(null, 27, FUN_TITLE);
|
Inventory gui = Bukkit.createInventory(null, 27, FUN_TITLE);
|
||||||
fillEdges(gui);
|
fillEdges(gui);
|
||||||
gui.setItem(10, createItem(Material.FISHING_ROD, "§b§lEnterhaken", "§7Zieh dich durch die Luft!"));
|
gui.setItem(10, createItem(Material.FISHING_ROD, "§b§lEnterhaken", "§7Zieh dich durch die Luft! §8(3s CD)"));
|
||||||
gui.setItem(11, createItem(Material.PACKED_ICE, "§b§lFreeze-Ray", "§7Friere andere Spieler ein!"));
|
gui.setItem(11, createItem(Material.PACKED_ICE, "§b§lFreeze-Ray", "§7Friere andere ein! §8(10s CD)"));
|
||||||
gui.setItem(12, createItem(Material.GOLDEN_HOE, "§6§lPaintball-Gun","§7Male die Lobby bunt aus!"));
|
gui.setItem(12, createItem(Material.GOLDEN_HOE, "§6§lPaintball-Gun","§7Male die Lobby bunt aus!"));
|
||||||
gui.setItem(14, createItem(Material.FIRE_CHARGE, "§c§lMeteorit", "§7Lass es krachen!"));
|
gui.setItem(14, createItem(Material.FIRE_CHARGE, "§c§lMeteorit", "§7Lass es krachen! §8(15s CD)"));
|
||||||
gui.setItem(15, createItem(Material.SHIELD, "§5§lSchutzzone", "§7Halte andere auf Distanz"));
|
gui.setItem(15, createItem(Material.SHIELD, "§5§lSchutzzone", "§7Halte andere auf Distanz"));
|
||||||
gui.setItem(16, createItem(Material.EGG, "§f§lChicken-Rain","§7Gack-Gack! Hühner überall!"));
|
gui.setItem(16, createItem(Material.EGG, "§f§lChicken-Rain","§7Gack-Gack! Hühner überall!"));
|
||||||
gui.setItem(22, createItem(Material.ARROW, "§7Zurück", "§8Zum Hauptmenü"));
|
gui.setItem(22, createItem(Material.ARROW, "§7Zurück", "§8Zum Hauptmenü"));
|
||||||
@@ -216,10 +321,8 @@ public class GadgetModule implements Module, Listener {
|
|||||||
else if (item.getType() == Material.BARRIER) { removeGadgets(player); player.closeInventory(); }
|
else if (item.getType() == Material.BARRIER) { removeGadgets(player); player.closeInventory(); }
|
||||||
} else if (title.equals(HAT_TITLE)) {
|
} else if (title.equals(HAT_TITLE)) {
|
||||||
if (item.getType() != Material.GRAY_STAINED_GLASS_PANE) {
|
if (item.getType() != Material.GRAY_STAINED_GLASS_PANE) {
|
||||||
String hatName = item.getType().name();
|
String hatName = item.hasItemMeta() && item.getItemMeta().hasDisplayName()
|
||||||
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()) {
|
? item.getItemMeta().getDisplayName() : item.getType().name();
|
||||||
hatName = item.getItemMeta().getDisplayName();
|
|
||||||
}
|
|
||||||
HatManager.setHat(player, item.getType(), hatName);
|
HatManager.setHat(player, item.getType(), hatName);
|
||||||
player.playSound(player.getLocation(), Sound.ITEM_ARMOR_EQUIP_GENERIC, 1, 1);
|
player.playSound(player.getLocation(), Sound.ITEM_ARMOR_EQUIP_GENERIC, 1, 1);
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
@@ -249,16 +352,16 @@ public class GadgetModule implements Module, Listener {
|
|||||||
player.sendMessage("§8[§6Nexus§8] §fHühnerregen gestartet!");
|
player.sendMessage("§8[§6Nexus§8] §fHühnerregen gestartet!");
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
} else if (item.getType() == Material.FISHING_ROD) {
|
} else if (item.getType() == Material.FISHING_ROD) {
|
||||||
player.getInventory().addItem(createItem(Material.FISHING_ROD, "§b§lEnterhaken", "§7Rechtsklick zum Katapultieren"));
|
player.getInventory().addItem(createItem(Material.FISHING_ROD, "§b§lEnterhaken", "§7Rechtsklick zum Katapultieren §8(3s CD)"));
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
} else if (item.getType() == Material.PACKED_ICE) {
|
} else if (item.getType() == Material.PACKED_ICE) {
|
||||||
player.getInventory().addItem(createItem(Material.PACKED_ICE, "§b§lFreeze-Ray", "§7Rechtsklick zum Einfrieren"));
|
player.getInventory().addItem(createItem(Material.PACKED_ICE, "§b§lFreeze-Ray", "§7Rechtsklick zum Einfrieren §8(10s CD)"));
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
} else if (item.getType() == Material.GOLDEN_HOE) {
|
} else if (item.getType() == Material.GOLDEN_HOE) {
|
||||||
player.getInventory().addItem(createItem(Material.GOLDEN_HOE, "§6§lPaintball-Gun", "§7Rechtsklick zum Schießen"));
|
player.getInventory().addItem(createItem(Material.GOLDEN_HOE, "§6§lPaintball-Gun", "§7Rechtsklick zum Schießen"));
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
} else if (item.getType() == Material.FIRE_CHARGE) {
|
} else if (item.getType() == Material.FIRE_CHARGE) {
|
||||||
player.getInventory().addItem(createItem(Material.FIRE_CHARGE, "§c§lMeteorit", "§7Rechtsklick zum Markieren"));
|
player.getInventory().addItem(createItem(Material.FIRE_CHARGE, "§c§lMeteorit", "§7Rechtsklick zum Markieren §8(15s CD)"));
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
} else if (item.getType() == Material.SHIELD) {
|
} else if (item.getType() == Material.SHIELD) {
|
||||||
if (activeShields.contains(player.getUniqueId())) {
|
if (activeShields.contains(player.getUniqueId())) {
|
||||||
@@ -273,20 +376,6 @@ public class GadgetModule implements Module, Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onFish(PlayerFishEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
ItemStack item = player.getInventory().getItemInMainHand();
|
|
||||||
if (item.getType() == Material.FISHING_ROD && item.hasItemMeta() && item.getItemMeta().hasDisplayName()
|
|
||||||
&& item.getItemMeta().getDisplayName().equals("§b§lEnterhaken")) {
|
|
||||||
if (event.getState() == PlayerFishEvent.State.IN_GROUND || event.getState() == PlayerFishEvent.State.REEL_IN || event.getState() == PlayerFishEvent.State.CAUGHT_ENTITY) {
|
|
||||||
if (event.getHook() != null) {
|
|
||||||
GrapplingHook.pullPlayer(player, event.getHook().getLocation());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void removeGadgets(Player player) {
|
private void removeGadgets(Player player) {
|
||||||
if (activeBalloons.containsKey(player.getUniqueId())) {
|
if (activeBalloons.containsKey(player.getUniqueId())) {
|
||||||
activeBalloons.get(player.getUniqueId()).remove();
|
activeBalloons.get(player.getUniqueId()).remove();
|
||||||
@@ -295,6 +384,7 @@ public class GadgetModule implements Module, Listener {
|
|||||||
activeEffects.remove(player.getUniqueId());
|
activeEffects.remove(player.getUniqueId());
|
||||||
activeShields.remove(player.getUniqueId());
|
activeShields.remove(player.getUniqueId());
|
||||||
PetManager.removePet(player);
|
PetManager.removePet(player);
|
||||||
|
FreezeRay.unfreeze(player.getUniqueId());
|
||||||
HatManager.removeHat(player);
|
HatManager.removeHat(player);
|
||||||
player.getInventory().remove(Material.FISHING_ROD);
|
player.getInventory().remove(Material.FISHING_ROD);
|
||||||
player.getInventory().remove(Material.PACKED_ICE);
|
player.getInventory().remove(Material.PACKED_ICE);
|
||||||
@@ -304,7 +394,6 @@ public class GadgetModule implements Module, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void fillEdges(Inventory inv) {
|
private void fillEdges(Inventory inv) {
|
||||||
// Bedrock braucht einen Space, um den Namen korrekt anzuzeigen
|
|
||||||
ItemStack glass = createItem(Material.GRAY_STAINED_GLASS_PANE, " ", null);
|
ItemStack glass = createItem(Material.GRAY_STAINED_GLASS_PANE, " ", null);
|
||||||
for (int i = 0; i < inv.getSize(); i++) {
|
for (int i = 0; i < inv.getSize(); i++) {
|
||||||
if (i < 9 || i >= inv.getSize() - 9 || i % 9 == 0 || (i + 1) % 9 == 0) inv.setItem(i, glass);
|
if (i < 9 || i >= inv.getSize() - 9 || i % 9 == 0 || (i + 1) % 9 == 0) inv.setItem(i, glass);
|
||||||
@@ -316,19 +405,14 @@ public class GadgetModule implements Module, Listener {
|
|||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
if (meta != null) {
|
if (meta != null) {
|
||||||
meta.setDisplayName(name);
|
meta.setDisplayName(name);
|
||||||
|
|
||||||
// WICHTIG FÜR BEDROCK: Saubere ArrayList für Lore
|
|
||||||
List<String> l = new ArrayList<>();
|
List<String> l = new ArrayList<>();
|
||||||
if (lore != null && !lore.isEmpty()) {
|
if (lore != null && !lore.isEmpty()) {
|
||||||
l.add(ChatColor.translateAlternateColorCodes('&', lore));
|
l.add(ChatColor.translateAlternateColorCodes('&', lore));
|
||||||
meta.setLore(l);
|
meta.setLore(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
// VERSTECKT ATTRIBUTE: Verhindert "+Armor" etc., was bei Bedrock die Lore überdeckt
|
|
||||||
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
||||||
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
|
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
|
||||||
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||||
|
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
@@ -336,10 +420,13 @@ public class GadgetModule implements Module, Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
org.bukkit.event.HandlerList.unregisterAll(this);
|
||||||
|
PetManager.unregister();
|
||||||
PetManager.clearAll();
|
PetManager.clearAll();
|
||||||
activeBalloons.values().forEach(Balloon::remove);
|
activeBalloons.values().forEach(Balloon::remove);
|
||||||
activeBalloons.clear();
|
activeBalloons.clear();
|
||||||
activeEffects.clear();
|
activeEffects.clear();
|
||||||
activeShields.clear();
|
activeShields.clear();
|
||||||
|
GadgetShield.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package de.nexuslobby.modules.gadgets;
|
||||||
|
|
||||||
|
import de.nexuslobby.NexusLobby;
|
||||||
|
import de.nexuslobby.modules.parkour.ParkourManager;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verwaltet den Gadget-Schutz für Admins und Parkour-Spieler.
|
||||||
|
* Eigenständige Klasse – kein Eingriff in GadgetModule nötig.
|
||||||
|
*/
|
||||||
|
public class GadgetShield {
|
||||||
|
|
||||||
|
/** UUIDs der Admins, die ihren Gadget-Schutz aktiviert haben */
|
||||||
|
private static final Set<UUID> shielded = new HashSet<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schaltet den Gadget-Schutz ein oder aus.
|
||||||
|
* Gibt true zurück wenn der Schutz jetzt aktiv ist.
|
||||||
|
*/
|
||||||
|
public static boolean toggle(Player player) {
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
if (shielded.contains(uuid)) {
|
||||||
|
shielded.remove(uuid);
|
||||||
|
player.sendMessage("§8[§6Nexus§8] §cGadget-Schutz §7deaktiviert.");
|
||||||
|
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1f, 1f);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
shielded.add(uuid);
|
||||||
|
player.sendMessage("§8[§6Nexus§8] §aGadget-Schutz §7aktiviert. §8Du bist nun immun gegen Gadgets.");
|
||||||
|
player.playSound(player.getLocation(), Sound.BLOCK_AMETHYST_BLOCK_CHIME, 1f, 1.5f);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Gibt zurück ob ein Spieler explizit durch den Admin-Schutz geschützt ist. */
|
||||||
|
public static boolean isAdminShielded(Player player) {
|
||||||
|
return shielded.contains(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt zurück ob ein Spieler durch irgendeinen Schutz immun gegen Gadgets ist
|
||||||
|
* (Admin-Schutz ODER aktiver Parkour-Run).
|
||||||
|
*/
|
||||||
|
public static boolean isProtected(Player player) {
|
||||||
|
if (shielded.contains(player.getUniqueId())) return true;
|
||||||
|
ParkourManager pm = NexusLobby.getInstance().getParkourManager();
|
||||||
|
return pm != null && pm.isIngame(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Beim Server-Stop / Plugin-Disable aufrufen */
|
||||||
|
public static void clear() {
|
||||||
|
shielded.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,14 +30,26 @@ public class MeteorStrike {
|
|||||||
shooter.sendMessage("§8[§6Nexus§8] §cMeteorit im Anflug...");
|
shooter.sendMessage("§8[§6Nexus§8] §cMeteorit im Anflug...");
|
||||||
|
|
||||||
org.bukkit.Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), () -> {
|
org.bukkit.Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), () -> {
|
||||||
// EXPLOSION_EMITTER ist der moderne Name für HUGE_EXPLOSION
|
|
||||||
finalTarget.getWorld().spawnParticle(Particle.EXPLOSION_EMITTER, finalTarget, 1);
|
finalTarget.getWorld().spawnParticle(Particle.EXPLOSION_EMITTER, finalTarget, 1);
|
||||||
finalTarget.getWorld().spawnParticle(Particle.LAVA, finalTarget, 30, 0.5, 0.5, 0.5, 0.1);
|
finalTarget.getWorld().spawnParticle(Particle.LAVA, finalTarget, 30, 0.5, 0.5, 0.5, 0.1);
|
||||||
finalTarget.getWorld().playSound(finalTarget, Sound.ENTITY_GENERIC_EXPLODE, 1.0f, 0.8f);
|
finalTarget.getWorld().playSound(finalTarget, Sound.ENTITY_GENERIC_EXPLODE, 1.0f, 0.8f);
|
||||||
|
|
||||||
for (Entity entity : finalTarget.getWorld().getNearbyEntities(finalTarget, 4, 4, 4)) {
|
for (Entity entity : finalTarget.getWorld().getNearbyEntities(finalTarget, 4, 4, 4)) {
|
||||||
if (entity instanceof Player p) {
|
if (entity instanceof Player p) {
|
||||||
Vector v = p.getLocation().toVector().subtract(finalTarget.toVector()).normalize().multiply(1.5).setY(0.5);
|
// Schutz: Admins mit Gadget-Schutz und Parkour-Spieler werden nicht weggeschleudert
|
||||||
|
if (GadgetShield.isProtected(p)) {
|
||||||
|
if (GadgetShield.isAdminShielded(p)) {
|
||||||
|
p.sendMessage("§8[§6Nexus§8] §7Dein Gadget-Schutzschild hat den Meteoriten abgelenkt!");
|
||||||
|
} else {
|
||||||
|
p.sendMessage("§8[§6Parkour§8] §7Dein Parkour-Schutzschild hat den Meteoriten abgelenkt!");
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Vector v = p.getLocation().toVector()
|
||||||
|
.subtract(finalTarget.toVector())
|
||||||
|
.normalize()
|
||||||
|
.multiply(1.5)
|
||||||
|
.setY(0.5);
|
||||||
p.setVelocity(v);
|
p.setVelocity(v);
|
||||||
p.sendMessage("§cBUMM!");
|
p.sendMessage("§cBUMM!");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,10 +22,30 @@ public class PetManager implements Listener {
|
|||||||
|
|
||||||
private static final Map<UUID, Entity> activePets = new HashMap<>();
|
private static final Map<UUID, Entity> activePets = new HashMap<>();
|
||||||
|
|
||||||
|
// Singleton-Instanz, damit registerEvents() nur einmal aufgerufen wird
|
||||||
|
private static PetManager instance;
|
||||||
|
|
||||||
public PetManager() {
|
public PetManager() {
|
||||||
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registriert den PetManager als Listener, falls noch nicht geschehen.
|
||||||
|
* Muss einmalig beim Plugin-Start aufgerufen werden (z.B. aus GadgetModule.onEnable).
|
||||||
|
*/
|
||||||
|
public static void register() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new PetManager();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void unregister() {
|
||||||
|
if (instance != null) {
|
||||||
|
org.bukkit.event.HandlerList.unregisterAll(instance);
|
||||||
|
instance = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spawnt ein echtes Tier-Entity für den Spieler.
|
* Spawnt ein echtes Tier-Entity für den Spieler.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -6,8 +6,19 @@ import org.bukkit.entity.Entity;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ShieldTask {
|
public class ShieldTask {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cooldown: Ein Spieler darf nur alle 3 Sekunden weggedrückt werden.
|
||||||
|
* Verhindert das permanente "Kleben" am Schutzschild-Träger.
|
||||||
|
*/
|
||||||
|
private static final Map<UUID, Long> pushCooldowns = new HashMap<>();
|
||||||
|
private static final long PUSH_COOLDOWN_MS = 3_000L;
|
||||||
|
|
||||||
public static void handleShield(Player owner) {
|
public static void handleShield(Player owner) {
|
||||||
// Erzeuge einen Partikel-Ring um den Spieler
|
// Erzeuge einen Partikel-Ring um den Spieler
|
||||||
for (double i = 0; i < Math.PI * 2; i += Math.PI / 8) {
|
for (double i = 0; i < Math.PI * 2; i += Math.PI / 8) {
|
||||||
@@ -16,12 +27,23 @@ public class ShieldTask {
|
|||||||
owner.getWorld().spawnParticle(Particle.WITCH, owner.getLocation().add(x, 0.5, z), 1, 0, 0, 0, 0);
|
owner.getWorld().spawnParticle(Particle.WITCH, owner.getLocation().add(x, 0.5, z), 1, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
|
||||||
// Stoße andere Spieler weg
|
// Stoße andere Spieler weg
|
||||||
for (Entity entity : owner.getNearbyEntities(2.2, 2.0, 2.2)) {
|
for (Entity entity : owner.getNearbyEntities(2.2, 2.0, 2.2)) {
|
||||||
if (entity instanceof Player && entity != owner) {
|
if (!(entity instanceof Player target) || entity == owner) continue;
|
||||||
Player target = (Player) entity;
|
|
||||||
|
|
||||||
Vector direction = target.getLocation().toVector().subtract(owner.getLocation().toVector()).normalize();
|
// FIX: OP-Admins mit aktivem Gadget-Schutz und Parkour-Spieler sind immun
|
||||||
|
if (GadgetShield.isProtected(target)) continue;
|
||||||
|
|
||||||
|
// FIX: 3-Sekunden-Cooldown – jedes Ziel wird max. 1x alle 3s weggedrückt
|
||||||
|
long lastPush = pushCooldowns.getOrDefault(target.getUniqueId(), 0L);
|
||||||
|
if (now - lastPush < PUSH_COOLDOWN_MS) continue;
|
||||||
|
pushCooldowns.put(target.getUniqueId(), now);
|
||||||
|
|
||||||
|
Vector direction = target.getLocation().toVector()
|
||||||
|
.subtract(owner.getLocation().toVector())
|
||||||
|
.normalize();
|
||||||
direction.multiply(0.4).setY(0.2);
|
direction.multiply(0.4).setY(0.2);
|
||||||
|
|
||||||
target.setVelocity(direction);
|
target.setVelocity(direction);
|
||||||
@@ -29,4 +51,3 @@ public class ShieldTask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -172,6 +172,7 @@ public class HologramModule implements Module, Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
org.bukkit.event.HandlerList.unregisterAll(this);
|
||||||
holograms.values().forEach(NexusHologram::removeAll);
|
holograms.values().forEach(NexusHologram::removeAll);
|
||||||
holograms.clear();
|
holograms.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ public class IntroModule implements Module, Listener, CommandExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
org.bukkit.event.HandlerList.unregisterAll(this);
|
||||||
activeIntro.clear();
|
activeIntro.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ import java.awt.image.BufferedImage;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
@@ -38,8 +40,18 @@ public class MapArtModule implements Module, CommandExecutor {
|
|||||||
private File storageFile;
|
private File storageFile;
|
||||||
private FileConfiguration storageConfig;
|
private FileConfiguration storageConfig;
|
||||||
|
|
||||||
// RAM-Schutz: Cache für bereits geladene Bild-Kacheln
|
// FIX: Unbegrenzter Cache führt bei vielen verschiedenen Bild-URLs zu einem
|
||||||
private final Map<String, BufferedImage> tileCache = new ConcurrentHashMap<>();
|
// OutOfMemoryError. Stattdessen nutzen wir einen LRU-Cache mit max. 50 Einträgen.
|
||||||
|
// Älteste Kacheln werden automatisch verdrängt.
|
||||||
|
private static final int MAX_CACHE_SIZE = 50;
|
||||||
|
private final Map<String, BufferedImage> tileCache = Collections.synchronizedMap(
|
||||||
|
new LinkedHashMap<String, BufferedImage>(MAX_CACHE_SIZE + 1, 0.75f, true) {
|
||||||
|
@Override
|
||||||
|
protected boolean removeEldestEntry(Map.Entry<String, BufferedImage> eldest) {
|
||||||
|
return size() > MAX_CACHE_SIZE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
// Hilfs-Set um parallele Downloads der gleichen URL zu verhindern
|
// Hilfs-Set um parallele Downloads der gleichen URL zu verhindern
|
||||||
private final Map<String, Boolean> loadingShield = new ConcurrentHashMap<>();
|
private final Map<String, Boolean> loadingShield = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
|||||||
@@ -25,18 +25,14 @@ public class ParkourListener implements Listener {
|
|||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Startet den Parkour per Rechtsklick auf den ArmorStand
|
|
||||||
*/
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInteract(PlayerInteractAtEntityEvent event) {
|
public void onInteract(PlayerInteractAtEntityEvent event) {
|
||||||
if (!(event.getRightClicked() instanceof ArmorStand as)) return;
|
if (!(event.getRightClicked() instanceof ArmorStand as)) return;
|
||||||
|
if (!as.getScoreboardTags().contains(NPC_TAG)) return;
|
||||||
|
|
||||||
// Prüfen, ob der ArmorStand den richtigen Tag hat
|
|
||||||
if (as.getScoreboardTags().contains(NPC_TAG)) {
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
// Abbrechen, wenn der Spieler schon im Parkour ist
|
|
||||||
if (manager.isIngame(player)) return;
|
if (manager.isIngame(player)) return;
|
||||||
|
|
||||||
// Cooldown-Check (3 Sekunden)
|
// Cooldown-Check (3 Sekunden)
|
||||||
@@ -47,19 +43,18 @@ public class ParkourListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parkour starten
|
|
||||||
manager.startParkour(player, as.getLocation());
|
manager.startParkour(player, as.getLocation());
|
||||||
player.sendMessage("§8[§6Parkour§8] §eViel Erfolg! Erreiche das Ziel so schnell wie möglich.");
|
// Strecken-Nummer dem Spieler mitteilen
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1f, 1f);
|
int track = manager.getActiveTrack(player);
|
||||||
|
if (track != -1) {
|
||||||
// Event abbrechen, damit man keine Ausrüstung vom ArmorStand klaut
|
player.sendMessage("§8[§6Parkour§8] §eViel Erfolg auf §bStrecke " + track + "§e! Erreiche das Ziel so schnell wie möglich.");
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
|
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1f, 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onMove(PlayerMoveEvent event) {
|
public void onMove(PlayerMoveEvent event) {
|
||||||
// Performance: Nur berechnen, wenn ein voller Block gewechselt wurde
|
// Performance: Nur bei Block-Wechsel berechnen
|
||||||
if (event.getFrom().getBlockX() == event.getTo().getBlockX() &&
|
if (event.getFrom().getBlockX() == event.getTo().getBlockX() &&
|
||||||
event.getFrom().getBlockY() == event.getTo().getBlockY() &&
|
event.getFrom().getBlockY() == event.getTo().getBlockY() &&
|
||||||
event.getFrom().getBlockZ() == event.getTo().getBlockZ()) return;
|
event.getFrom().getBlockZ() == event.getTo().getBlockZ()) return;
|
||||||
@@ -70,7 +65,6 @@ public class ParkourListener implements Listener {
|
|||||||
Location loc = player.getLocation();
|
Location loc = player.getLocation();
|
||||||
|
|
||||||
// --- 1. ABSTURZ-CHECK ---
|
// --- 1. ABSTURZ-CHECK ---
|
||||||
// Passe die Höhe '50' an deine Map an!
|
|
||||||
if (loc.getY() < 50) {
|
if (loc.getY() < 50) {
|
||||||
Location lastCp = manager.getCheckpoint(player);
|
Location lastCp = manager.getCheckpoint(player);
|
||||||
if (lastCp != null) {
|
if (lastCp != null) {
|
||||||
@@ -81,27 +75,25 @@ public class ParkourListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- 2. CHECKPOINT-CHECK ---
|
// --- 2. CHECKPOINT-CHECK (Track-spezifisch) ---
|
||||||
List<Location> cps = manager.getOrderedCheckpoints();
|
List<Location> cps = manager.getOrderedCheckpoints(player);
|
||||||
for (int i = 0; i < cps.size(); i++) {
|
for (int i = 0; i < cps.size(); i++) {
|
||||||
if (isNearby(loc, cps.get(i))) {
|
if (isNearby(loc, cps.get(i))) {
|
||||||
manager.reachCheckpoint(player, i);
|
manager.reachCheckpoint(player, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- 3. ZIEL-CHECK ---
|
// --- 3. ZIEL-CHECK (Track-spezifisch) ---
|
||||||
Location finish = manager.getFinishLocation();
|
Location finish = manager.getFinishLocation(player);
|
||||||
if (finish != null && isNearby(loc, finish)) {
|
if (finish != null && isNearby(loc, finish)) {
|
||||||
manager.finishParkour(player);
|
manager.finishParkour(player);
|
||||||
// Nach dem Ziel setzen wir einen Cooldown
|
|
||||||
startCooldown.put(player.getUniqueId(), System.currentTimeMillis());
|
startCooldown.put(player.getUniqueId(), System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isNearby(Location playerLoc, Location targetLoc) {
|
private boolean isNearby(Location playerLoc, Location targetLoc) {
|
||||||
if (playerLoc.getWorld() == null || !playerLoc.getWorld().equals(targetLoc.getWorld())) return false;
|
if (playerLoc.getWorld() == null || !playerLoc.getWorld().equals(targetLoc.getWorld())) return false;
|
||||||
// 2.25 entspricht einem Radius von ca. 1.5 Blöcken
|
return playerLoc.distanceSquared(targetLoc) <= 2.25; // ~1.5 Blöcke Radius
|
||||||
return playerLoc.distanceSquared(targetLoc) <= 2.25;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|||||||
@@ -17,15 +17,47 @@ import java.io.IOException;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ParkourManager – unterstützt zwei Strecken (Track 1 & 2).
|
||||||
|
*
|
||||||
|
* Config-Struktur (parkour.yml):
|
||||||
|
* tracks:
|
||||||
|
* 1:
|
||||||
|
* start: <Location>
|
||||||
|
* finish: <Location>
|
||||||
|
* checkpoints:
|
||||||
|
* 1: <Location>
|
||||||
|
* 2: <Location>
|
||||||
|
* ...
|
||||||
|
* 2:
|
||||||
|
* start: <Location>
|
||||||
|
* finish: <Location>
|
||||||
|
* checkpoints:
|
||||||
|
* 1: <Location>
|
||||||
|
* ...
|
||||||
|
* besttimes:
|
||||||
|
* <uuid>: <seconds>
|
||||||
|
* names:
|
||||||
|
* <uuid>: <playerName>
|
||||||
|
*
|
||||||
|
* Beim Start wird zufällig eine der beiden konfigurierten Strecken ausgewählt.
|
||||||
|
* Beide Strecken müssen die gleiche Anzahl an Checkpoints haben – andernfalls
|
||||||
|
* wird nur die vollständige gewählt.
|
||||||
|
*/
|
||||||
public class ParkourManager {
|
public class ParkourManager {
|
||||||
|
|
||||||
private final NexusLobby plugin;
|
private final NexusLobby plugin;
|
||||||
private final File file;
|
private final File file;
|
||||||
private FileConfiguration config;
|
private FileConfiguration config;
|
||||||
|
|
||||||
|
// Aktive Läufe
|
||||||
private final Map<UUID, Long> startTime = new HashMap<>();
|
private final Map<UUID, Long> startTime = new HashMap<>();
|
||||||
private final Map<UUID, Location> lastCheckpointLoc = new HashMap<>();
|
private final Map<UUID, Location> lastCheckpointLoc = new HashMap<>();
|
||||||
private final Map<UUID, Integer> nextCheckpointIndex= new HashMap<>();
|
private final Map<UUID, Integer> nextCheckpointIndex= new HashMap<>();
|
||||||
|
/** Welche Track-Nummer (1 oder 2) der Spieler gerade läuft */
|
||||||
|
private final Map<UUID, Integer> activeTrack = new HashMap<>();
|
||||||
|
|
||||||
|
private final Random random = new Random();
|
||||||
|
|
||||||
public ParkourManager(NexusLobby plugin) {
|
public ParkourManager(NexusLobby plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
@@ -34,6 +66,10 @@ public class ParkourManager {
|
|||||||
startParticleTask();
|
startParticleTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
|
// Config I/O
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
private void loadConfig() {
|
private void loadConfig() {
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
file.getParentFile().mkdirs();
|
file.getParentFile().mkdirs();
|
||||||
@@ -46,41 +82,120 @@ public class ParkourManager {
|
|||||||
config = YamlConfiguration.loadConfiguration(file);
|
config = YamlConfiguration.loadConfiguration(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCheckpoint(Player player, Location loc) {
|
private void save() {
|
||||||
int nextId = 1;
|
try {
|
||||||
if (config.contains("locations.checkpoints") && config.getConfigurationSection("locations.checkpoints") != null) {
|
config.save(file);
|
||||||
nextId = config.getConfigurationSection("locations.checkpoints").getKeys(false).size() + 1;
|
} catch (IOException e) {
|
||||||
|
plugin.getLogger().severe("Fehler beim Speichern der Parkour-Config: " + e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addCheckpointLocation(String.valueOf(nextId), loc);
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
player.sendMessage("§8[§6Parkour§8] §7Checkpoint §e#" + nextId + " §7an deiner Position gesetzt.");
|
// Setup-Befehle (Admin)
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
public void setStartLocation(Player player, int track) {
|
||||||
|
config.set("tracks." + track + ".start", player.getLocation());
|
||||||
|
save();
|
||||||
|
player.sendMessage("§8[§6Parkour§8] §7Start von §eStrecke " + track + " §7an deiner Position gesetzt.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFinishLocation(Player player, int track) {
|
||||||
|
config.set("tracks." + track + ".finish", player.getLocation());
|
||||||
|
save();
|
||||||
|
player.sendMessage("§8[§6Parkour§8] §7Ziel von §eStrecke " + track + " §7an deiner Position gesetzt.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCheckpoint(Player player, int track) {
|
||||||
|
String cpBase = "tracks." + track + ".checkpoints";
|
||||||
|
int nextId = 1;
|
||||||
|
if (config.contains(cpBase) && config.getConfigurationSection(cpBase) != null) {
|
||||||
|
nextId = config.getConfigurationSection(cpBase).getKeys(false).size() + 1;
|
||||||
|
}
|
||||||
|
config.set(cpBase + "." + nextId, player.getLocation());
|
||||||
|
save();
|
||||||
|
player.sendMessage("§8[§6Parkour§8] §7Checkpoint §e#" + nextId + " §7(Strecke " + track + ") §7gesetzt.");
|
||||||
player.playSound(player.getLocation(), Sound.BLOCK_AMETHYST_BLOCK_CHIME, 1.0f, 1.5f);
|
player.playSound(player.getLocation(), Sound.BLOCK_AMETHYST_BLOCK_CHIME, 1.0f, 1.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Löscht die gesamte Strecke (Checkpoints und Ziel) und bricht aktuelle Läufe ab.
|
* Löscht alle Punkte beider Strecken und bricht laufende Runs ab.
|
||||||
*/
|
*/
|
||||||
public void removeAllPoints() {
|
public void removeAllPoints() {
|
||||||
config.set("locations.checkpoints", null);
|
config.set("tracks", null);
|
||||||
config.set("locations.finish", null);
|
|
||||||
save();
|
save();
|
||||||
|
|
||||||
// Alle Spieler aus dem Parkour werfen, damit keine Partikel zu gelöschten Zielen führen
|
|
||||||
for (UUID uuid : new HashSet<>(startTime.keySet())) {
|
for (UUID uuid : new HashSet<>(startTime.keySet())) {
|
||||||
Player p = Bukkit.getPlayer(uuid);
|
Player p = Bukkit.getPlayer(uuid);
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
stopParkour(p);
|
stopParkour(p);
|
||||||
p.sendMessage("§8[§6Parkour§8] §cDie aktuelle Strecke wurde soeben gelöscht.");
|
p.sendMessage("§8[§6Parkour§8] §cDie Strecken wurden soeben gelöscht.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startParkour(Player player, Location startLoc) {
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
|
// Getter (Track-spezifisch)
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
public Location getStartLocation(int track) {
|
||||||
|
return config.getLocation("tracks." + track + ".start");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getFinishLocation(int track) {
|
||||||
|
return config.getLocation("tracks." + track + ".finish");
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Location> getOrderedCheckpoints(int track) {
|
||||||
|
String cpBase = "tracks." + track + ".checkpoints";
|
||||||
|
if (!config.contains(cpBase) || config.getConfigurationSection(cpBase) == null)
|
||||||
|
return new ArrayList<>();
|
||||||
|
|
||||||
|
return config.getConfigurationSection(cpBase).getKeys(false).stream()
|
||||||
|
.sorted(Comparator.comparingInt(Integer::parseInt))
|
||||||
|
.map(key -> config.getLocation(cpBase + "." + key))
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt die aktive Track-Nummer des Spielers zurück (1 oder 2), oder -1 wenn nicht aktiv.
|
||||||
|
*/
|
||||||
|
public int getActiveTrack(Player player) {
|
||||||
|
return activeTrack.getOrDefault(player.getUniqueId(), -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convenience-Wrapper für ParkourListener (nutzt den aktiven Track des Spielers)
|
||||||
|
public List<Location> getOrderedCheckpoints(Player player) {
|
||||||
|
return getOrderedCheckpoints(getActiveTrack(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getFinishLocation(Player player) {
|
||||||
|
return getFinishLocation(getActiveTrack(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
|
// Parkour-Ablauf
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Startet den Parkour für den Spieler.
|
||||||
|
* Es wird zufällig eine der beiden Strecken gewählt, sofern beide vollständig
|
||||||
|
* konfiguriert sind (Start + Finish + mindestens gleiche Checkpoint-Anzahl).
|
||||||
|
* Falls nur eine Strecke konfiguriert ist, wird diese gewählt.
|
||||||
|
*/
|
||||||
|
public void startParkour(Player player, Location npcLocation) {
|
||||||
if (startTime.containsKey(player.getUniqueId())) return;
|
if (startTime.containsKey(player.getUniqueId())) return;
|
||||||
|
|
||||||
|
int chosenTrack = pickRandomTrack();
|
||||||
|
if (chosenTrack == -1) {
|
||||||
|
player.sendMessage("§8[§6Parkour§8] §cKeine Strecke konfiguriert. Bitte einen Admin kontaktieren.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
startTime.put(player.getUniqueId(), System.currentTimeMillis());
|
startTime.put(player.getUniqueId(), System.currentTimeMillis());
|
||||||
lastCheckpointLoc.put(player.getUniqueId(), startLoc);
|
lastCheckpointLoc.put(player.getUniqueId(), npcLocation);
|
||||||
nextCheckpointIndex.put(player.getUniqueId(), 0);
|
nextCheckpointIndex.put(player.getUniqueId(), 0);
|
||||||
|
activeTrack.put(player.getUniqueId(), chosenTrack);
|
||||||
|
|
||||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_CHIME, 1.0f, 1.2f);
|
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_CHIME, 1.0f, 1.2f);
|
||||||
|
|
||||||
@@ -99,6 +214,39 @@ public class ParkourManager {
|
|||||||
}.runTaskTimer(plugin, 0L, 1L);
|
}.runTaskTimer(plugin, 0L, 1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wählt zufällig einen validen Track (1 oder 2).
|
||||||
|
* Bevorzugt Tracks mit gleichem Checkpoint-Count; fällt auf jeden konfigurierten zurück.
|
||||||
|
* Gibt -1 zurück, wenn kein Track konfiguriert ist.
|
||||||
|
*/
|
||||||
|
private int pickRandomTrack() {
|
||||||
|
boolean t1 = isTrackReady(1);
|
||||||
|
boolean t2 = isTrackReady(2);
|
||||||
|
|
||||||
|
if (t1 && t2) {
|
||||||
|
// Beide vollständig – prüfen ob gleiche Länge
|
||||||
|
int len1 = getOrderedCheckpoints(1).size();
|
||||||
|
int len2 = getOrderedCheckpoints(2).size();
|
||||||
|
if (len1 != len2) {
|
||||||
|
// Warnung ins Log, aber trotzdem zufällig wählen
|
||||||
|
plugin.getLogger().warning("[Parkour] Strecke 1 hat " + len1 + " Checkpoints, Strecke 2 hat " + len2 + ". Bitte angleichen!");
|
||||||
|
}
|
||||||
|
return random.nextBoolean() ? 1 : 2;
|
||||||
|
} else if (t1) {
|
||||||
|
return 1;
|
||||||
|
} else if (t2) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Gibt zurück, ob Start, Finish und mindestens 1 Checkpoint für den Track gesetzt sind. */
|
||||||
|
public boolean isTrackReady(int track) {
|
||||||
|
return getStartLocation(track) != null
|
||||||
|
&& getFinishLocation(track) != null
|
||||||
|
&& !getOrderedCheckpoints(track).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
private void startParticleTask() {
|
private void startParticleTask() {
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
@@ -107,8 +255,9 @@ public class ParkourManager {
|
|||||||
Player p = Bukkit.getPlayer(uuid);
|
Player p = Bukkit.getPlayer(uuid);
|
||||||
if (p == null) continue;
|
if (p == null) continue;
|
||||||
|
|
||||||
|
int track = activeTrack.getOrDefault(uuid, 1);
|
||||||
int nextIdx = nextCheckpointIndex.getOrDefault(uuid, 0);
|
int nextIdx = nextCheckpointIndex.getOrDefault(uuid, 0);
|
||||||
List<Location> cps = getOrderedCheckpoints();
|
List<Location> cps = getOrderedCheckpoints(track);
|
||||||
|
|
||||||
if (nextIdx < cps.size()) {
|
if (nextIdx < cps.size()) {
|
||||||
Location nextCp = cps.get(nextIdx);
|
Location nextCp = cps.get(nextIdx);
|
||||||
@@ -116,7 +265,7 @@ public class ParkourManager {
|
|||||||
p.spawnParticle(Particle.SOUL_FIRE_FLAME, nextCp.clone().add(0, 0.5, 0), 5, 0.1, 0.3, 0.1, 0.02);
|
p.spawnParticle(Particle.SOUL_FIRE_FLAME, nextCp.clone().add(0, 0.5, 0), 5, 0.1, 0.3, 0.1, 0.02);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Location finish = getFinishLocation();
|
Location finish = getFinishLocation(track);
|
||||||
if (finish != null && p.getWorld().equals(finish.getWorld())) {
|
if (finish != null && p.getWorld().equals(finish.getWorld())) {
|
||||||
p.spawnParticle(Particle.HAPPY_VILLAGER, finish.clone().add(0, 0.5, 0), 8, 0.2, 0.5, 0.2, 0.02);
|
p.spawnParticle(Particle.HAPPY_VILLAGER, finish.clone().add(0, 0.5, 0), 8, 0.2, 0.5, 0.2, 0.02);
|
||||||
}
|
}
|
||||||
@@ -128,23 +277,24 @@ public class ParkourManager {
|
|||||||
|
|
||||||
public void reachCheckpoint(Player player, int reachedIndex) {
|
public void reachCheckpoint(Player player, int reachedIndex) {
|
||||||
int currentNext = nextCheckpointIndex.getOrDefault(player.getUniqueId(), 0);
|
int currentNext = nextCheckpointIndex.getOrDefault(player.getUniqueId(), 0);
|
||||||
|
if (reachedIndex != currentNext) return;
|
||||||
|
|
||||||
|
int track = activeTrack.getOrDefault(player.getUniqueId(), 1);
|
||||||
|
List<Location> cps = getOrderedCheckpoints(track);
|
||||||
|
if (reachedIndex >= cps.size()) return;
|
||||||
|
|
||||||
if (reachedIndex == currentNext) {
|
|
||||||
List<Location> cps = getOrderedCheckpoints();
|
|
||||||
if (reachedIndex < cps.size()) {
|
|
||||||
lastCheckpointLoc.put(player.getUniqueId(), cps.get(reachedIndex));
|
lastCheckpointLoc.put(player.getUniqueId(), cps.get(reachedIndex));
|
||||||
nextCheckpointIndex.put(player.getUniqueId(), reachedIndex + 1);
|
nextCheckpointIndex.put(player.getUniqueId(), reachedIndex + 1);
|
||||||
|
|
||||||
player.sendMessage("§8[§6Parkour§8] §bCheckpoint #" + (reachedIndex + 1) + " erreicht!");
|
player.sendMessage("§8[§6Parkour§8] §bCheckpoint #" + (reachedIndex + 1) + " erreicht!");
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 0.8f, 1.5f);
|
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 0.8f, 1.5f);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void finishParkour(Player player) {
|
public void finishParkour(Player player) {
|
||||||
if (!startTime.containsKey(player.getUniqueId())) return;
|
if (!startTime.containsKey(player.getUniqueId())) return;
|
||||||
|
|
||||||
if (nextCheckpointIndex.getOrDefault(player.getUniqueId(), 0) < getOrderedCheckpoints().size()) {
|
int track = activeTrack.getOrDefault(player.getUniqueId(), 1);
|
||||||
|
if (nextCheckpointIndex.getOrDefault(player.getUniqueId(), 0) < getOrderedCheckpoints(track).size()) {
|
||||||
player.sendMessage("§cDu hast Checkpoints übersprungen! Folge den Partikeln.");
|
player.sendMessage("§cDu hast Checkpoints übersprungen! Folge den Partikeln.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -153,7 +303,7 @@ public class ParkourManager {
|
|||||||
double seconds = duration / 1000.0;
|
double seconds = duration / 1000.0;
|
||||||
|
|
||||||
player.sendMessage("§8§m--------------------------------------");
|
player.sendMessage("§8§m--------------------------------------");
|
||||||
player.sendMessage("§8[§6Parkour§8] §a§lZiel erreicht!");
|
player.sendMessage("§8[§6Parkour§8] §a§lZiel erreicht! §8(Strecke " + track + ")");
|
||||||
player.sendMessage("§7Deine Zeit: §e" + String.format("%.2f", seconds) + "s");
|
player.sendMessage("§7Deine Zeit: §e" + String.format("%.2f", seconds) + "s");
|
||||||
player.sendMessage("§8§m--------------------------------------");
|
player.sendMessage("§8§m--------------------------------------");
|
||||||
|
|
||||||
@@ -167,42 +317,12 @@ public class ParkourManager {
|
|||||||
startTime.remove(player.getUniqueId());
|
startTime.remove(player.getUniqueId());
|
||||||
lastCheckpointLoc.remove(player.getUniqueId());
|
lastCheckpointLoc.remove(player.getUniqueId());
|
||||||
nextCheckpointIndex.remove(player.getUniqueId());
|
nextCheckpointIndex.remove(player.getUniqueId());
|
||||||
|
activeTrack.remove(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStartLocation(Location loc) { config.set("locations.start", loc); save(); }
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
public void setFinishLocation(Location loc) { config.set("locations.finish", loc); save(); }
|
// Bestzeiten
|
||||||
public void addCheckpointLocation(String id, Location loc) { config.set("locations.checkpoints." + id, loc); save(); }
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
public Location getStartLocation() { return config.getLocation("locations.start"); }
|
|
||||||
public Location getFinishLocation() { return config.getLocation("locations.finish"); }
|
|
||||||
|
|
||||||
public List<Location> getOrderedCheckpoints() {
|
|
||||||
if (!config.contains("locations.checkpoints") || config.getConfigurationSection("locations.checkpoints") == null)
|
|
||||||
return new ArrayList<>();
|
|
||||||
|
|
||||||
return config.getConfigurationSection("locations.checkpoints").getKeys(false).stream()
|
|
||||||
.sorted(Comparator.comparingInt(Integer::parseInt))
|
|
||||||
.map(key -> config.getLocation("locations.checkpoints." + key))
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void save() {
|
|
||||||
try {
|
|
||||||
config.save(file);
|
|
||||||
} catch (IOException e) {
|
|
||||||
plugin.getLogger().severe("Fehler beim Speichern der Parkour-Config: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearStats() {
|
|
||||||
config.set("besttimes", null);
|
|
||||||
config.set("names", null);
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isIngame(Player player) { return startTime.containsKey(player.getUniqueId()); }
|
|
||||||
public Location getCheckpoint(Player player) { return lastCheckpointLoc.get(player.getUniqueId()); }
|
|
||||||
|
|
||||||
private void saveBestTime(Player player, double time) {
|
private void saveBestTime(Player player, double time) {
|
||||||
String path = "besttimes." + player.getUniqueId();
|
String path = "besttimes." + player.getUniqueId();
|
||||||
@@ -215,6 +335,17 @@ public class ParkourManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Löscht NUR die Bestzeiten-Liste (besttimes + names).
|
||||||
|
* Die Strecken-Konfiguration (tracks) bleibt vollständig erhalten.
|
||||||
|
* Wird durch "/nexus parkour clear" aufgerufen.
|
||||||
|
*/
|
||||||
|
public void clearStats() {
|
||||||
|
config.set("besttimes", null);
|
||||||
|
config.set("names", null);
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
public String getTopTen() {
|
public String getTopTen() {
|
||||||
if (!config.contains("besttimes") || config.getConfigurationSection("besttimes") == null)
|
if (!config.contains("besttimes") || config.getConfigurationSection("besttimes") == null)
|
||||||
return "§6§l🏆 TOP 10 PARKOUR 🏆\n§7Noch keine Rekorde.";
|
return "§6§l🏆 TOP 10 PARKOUR 🏆\n§7Noch keine Rekorde.";
|
||||||
@@ -233,9 +364,31 @@ public class ParkourManager {
|
|||||||
int rank = 1;
|
int rank = 1;
|
||||||
for (Map.Entry<String, Double> entry : sortedList) {
|
for (Map.Entry<String, Double> entry : sortedList) {
|
||||||
String name = config.getString("names." + entry.getKey(), "Unbekannt");
|
String name = config.getString("names." + entry.getKey(), "Unbekannt");
|
||||||
builder.append("\n§e#").append(rank).append(" §f").append(name).append(" §8» §a").append(String.format("%.2f", entry.getValue())).append("s");
|
builder.append("\n§e#").append(rank).append(" §f").append(name)
|
||||||
|
.append(" §8» §a").append(String.format("%.2f", entry.getValue())).append("s");
|
||||||
rank++;
|
rank++;
|
||||||
}
|
}
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
|
// Hilfsmethoden
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
public boolean isIngame(Player player) { return startTime.containsKey(player.getUniqueId()); }
|
||||||
|
public Location getCheckpoint(Player player) { return lastCheckpointLoc.get(player.getUniqueId()); }
|
||||||
|
|
||||||
|
/** Gibt die Strecken-Info als lesbaren String aus (für Admin-Feedback). */
|
||||||
|
public String getTrackInfo() {
|
||||||
|
StringBuilder sb = new StringBuilder("§8[§6Parkour§8] §7Track-Status:\n");
|
||||||
|
for (int t = 1; t <= 2; t++) {
|
||||||
|
int cps = getOrderedCheckpoints(t).size();
|
||||||
|
boolean ready = isTrackReady(t);
|
||||||
|
sb.append(" §eStrecke ").append(t).append(": ")
|
||||||
|
.append(ready ? "§a✔" : "§c✘")
|
||||||
|
.append(" §7(").append(cps).append(" Checkpoints)");
|
||||||
|
if (t < 2) sb.append("\n");
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,9 @@ public class PlayerInspectModule implements Module, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {}
|
public void onDisable() {
|
||||||
|
org.bukkit.event.HandlerList.unregisterAll(this);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEntityEvent event) {
|
public void onPlayerInteract(PlayerInteractEntityEvent event) {
|
||||||
|
|||||||
@@ -5,12 +5,15 @@ 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.player.PlayerQuitEvent;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PortalCommand implements CommandExecutor {
|
public class PortalCommand implements CommandExecutor, Listener {
|
||||||
|
|
||||||
private final PortalManager portalManager;
|
private final PortalManager portalManager;
|
||||||
|
|
||||||
@@ -20,6 +23,17 @@ public class PortalCommand implements CommandExecutor {
|
|||||||
|
|
||||||
public PortalCommand(PortalManager portalManager) {
|
public PortalCommand(PortalManager portalManager) {
|
||||||
this.portalManager = portalManager;
|
this.portalManager = portalManager;
|
||||||
|
// FIX: Listener registrieren, damit Selektionen beim Verlassen bereinigt werden
|
||||||
|
de.nexuslobby.NexusLobby.getInstance().getServer().getPluginManager()
|
||||||
|
.registerEvents(this, de.nexuslobby.NexusLobby.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIX: Selektionen beim Quit entfernen – statische Maps wuchsen sonst ewig
|
||||||
|
@EventHandler
|
||||||
|
public void onQuit(PlayerQuitEvent event) {
|
||||||
|
UUID uuid = event.getPlayer().getUniqueId();
|
||||||
|
selection1.remove(uuid);
|
||||||
|
selection2.remove(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Statische Hilfsmethoden für andere Klassen
|
// Statische Hilfsmethoden für andere Klassen
|
||||||
|
|||||||
@@ -31,7 +31,12 @@ import java.util.UUID;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PortalManager - Verwaltet Portale, Markierungen und den globalen Grenzschutz.
|
* PortalManager - Verwaltet Portale und Wand-Markierungen.
|
||||||
|
*
|
||||||
|
* FIX: Die doppelte Border-Logik wurde entfernt. Der BorderModule ist
|
||||||
|
* der alleinige Verantwortliche für die Lobby-Grenze. Hätte der
|
||||||
|
* PortalManager die Border ebenfalls geprüft, wären Spieler doppelt
|
||||||
|
* teleportiert worden und hätten zwei Nachrichten erhalten.
|
||||||
*/
|
*/
|
||||||
public class PortalManager implements Module, Listener {
|
public class PortalManager implements Module, Listener {
|
||||||
|
|
||||||
@@ -42,12 +47,6 @@ public class PortalManager implements Module, Listener {
|
|||||||
private final NamespacedKey wandKey;
|
private final NamespacedKey wandKey;
|
||||||
private BukkitTask particleTask;
|
private BukkitTask particleTask;
|
||||||
|
|
||||||
// Boundary Cache
|
|
||||||
private Location borderMin;
|
|
||||||
private Location borderMax;
|
|
||||||
private boolean borderEnabled = false;
|
|
||||||
private String borderType;
|
|
||||||
|
|
||||||
public PortalManager(NexusLobby plugin) {
|
public PortalManager(NexusLobby plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.wandKey = new NamespacedKey(plugin, "nexuslobby_portal_wand");
|
this.wandKey = new NamespacedKey(plugin, "nexuslobby_portal_wand");
|
||||||
@@ -61,7 +60,6 @@ public class PortalManager implements Module, Listener {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
loadPortals();
|
loadPortals();
|
||||||
loadBorderSettings();
|
|
||||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||||
startParticleTask();
|
startParticleTask();
|
||||||
}
|
}
|
||||||
@@ -76,28 +74,6 @@ public class PortalManager implements Module, Listener {
|
|||||||
plugin.getLogger().info("PortalManager deaktiviert.");
|
plugin.getLogger().info("PortalManager deaktiviert.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadBorderSettings() {
|
|
||||||
this.borderType = plugin.getConfig().getString("worldborder.type", "SQUARE");
|
|
||||||
boolean enabled = plugin.getConfig().getBoolean("worldborder.enabled", false);
|
|
||||||
if (!enabled || !"SQUARE".equalsIgnoreCase(borderType)) {
|
|
||||||
this.borderEnabled = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (plugin.getConfig().contains("worldborder.pos1") && plugin.getConfig().contains("worldborder.pos2")) {
|
|
||||||
Location p1 = plugin.getConfig().getLocation("worldborder.pos1");
|
|
||||||
Location p2 = plugin.getConfig().getLocation("worldborder.pos2");
|
|
||||||
if (p1 != null && p2 != null) {
|
|
||||||
this.borderMin = getMinLocation(p1, p2);
|
|
||||||
this.borderMax = getMaxLocation(p1, p2);
|
|
||||||
this.borderEnabled = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.borderEnabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<String> getPortalNames() {
|
public Set<String> getPortalNames() {
|
||||||
return portals.keySet();
|
return portals.keySet();
|
||||||
}
|
}
|
||||||
@@ -156,7 +132,7 @@ public class PortalManager implements Module, Listener {
|
|||||||
p.sendMessage("§7§m----------------------------------");
|
p.sendMessage("§7§m----------------------------------");
|
||||||
if (volume < 500) {
|
if (volume < 500) {
|
||||||
p.sendMessage("§e[Nexus] Kleiner Bereich erkannt (Portal-Größe)");
|
p.sendMessage("§e[Nexus] Kleiner Bereich erkannt (Portal-Größe)");
|
||||||
p.sendMessage("§fBefehl: §b/portal create <Name> <server|world>");
|
p.sendMessage("§fBefehl: §b/portal create <n> <server|world>");
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage("§6[Nexus] Großer Bereich erkannt (WorldBorder-Größe)");
|
p.sendMessage("§6[Nexus] Großer Bereich erkannt (WorldBorder-Größe)");
|
||||||
p.sendMessage("§fBefehl: §a/border square");
|
p.sendMessage("§fBefehl: §a/border square");
|
||||||
@@ -190,12 +166,9 @@ public class PortalManager implements Module, Listener {
|
|||||||
String type = portalConfig.getString("portals." + key + ".type", "WORLD");
|
String type = portalConfig.getString("portals." + key + ".type", "WORLD");
|
||||||
Portal portal = new Portal(key, type);
|
Portal portal = new Portal(key, type);
|
||||||
|
|
||||||
if (portalConfig.contains("portals." + key + ".pos1")) {
|
portal.setPos1(loadLocation(portalConfig, "portals." + key + ".pos1"));
|
||||||
portal.setPos1(portalConfig.getLocation("portals." + key + ".pos1"));
|
portal.setPos2(loadLocation(portalConfig, "portals." + key + ".pos2"));
|
||||||
}
|
portal.setReturnSpawn(loadLocation(portalConfig, "portals." + key + ".returnSpawn"));
|
||||||
if (portalConfig.contains("portals." + key + ".pos2")) {
|
|
||||||
portal.setPos2(portalConfig.getLocation("portals." + key + ".pos2"));
|
|
||||||
}
|
|
||||||
|
|
||||||
portal.setDestination(portalConfig.getString("portals." + key + ".destination", ""));
|
portal.setDestination(portalConfig.getString("portals." + key + ".destination", ""));
|
||||||
try {
|
try {
|
||||||
@@ -204,10 +177,6 @@ public class PortalManager implements Module, Listener {
|
|||||||
portal.setParticle(Particle.PORTAL);
|
portal.setParticle(Particle.PORTAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (portalConfig.contains("portals." + key + ".returnSpawn")) {
|
|
||||||
portal.setReturnSpawn(portalConfig.getLocation("portals." + key + ".returnSpawn"));
|
|
||||||
}
|
|
||||||
|
|
||||||
portals.put(key, portal);
|
portals.put(key, portal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -219,11 +188,11 @@ public class PortalManager implements Module, Listener {
|
|||||||
for (Portal portal : portals.values()) {
|
for (Portal portal : portals.values()) {
|
||||||
String path = "portals." + portal.getName() + ".";
|
String path = "portals." + portal.getName() + ".";
|
||||||
config.set(path + "type", portal.getType());
|
config.set(path + "type", portal.getType());
|
||||||
config.set(path + "pos1", portal.getPos1());
|
saveLocation(config, path + "pos1", portal.getPos1());
|
||||||
config.set(path + "pos2", portal.getPos2());
|
saveLocation(config, path + "pos2", portal.getPos2());
|
||||||
config.set(path + "destination", portal.getDestination());
|
config.set(path + "destination", portal.getDestination());
|
||||||
config.set(path + "particle", portal.getParticle() != null ? portal.getParticle().name() : "PORTAL");
|
config.set(path + "particle", portal.getParticle() != null ? portal.getParticle().name() : "PORTAL");
|
||||||
config.set(path + "returnSpawn", portal.getReturnSpawn());
|
saveLocation(config, path + "returnSpawn", portal.getReturnSpawn());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -233,6 +202,35 @@ public class PortalManager implements Module, Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIX: Hilfsmethoden für robustes Location-Speichern/Laden.
|
||||||
|
// Speichert world + x/y/z als einzelne Keys statt als serialisiertes
|
||||||
|
// Location-Objekt, was nach Neustarts zu null führen kann.
|
||||||
|
private void saveLocation(YamlConfiguration config, String path, Location loc) {
|
||||||
|
if (loc == null || loc.getWorld() == null) return;
|
||||||
|
config.set(path + ".world", loc.getWorld().getName());
|
||||||
|
config.set(path + ".x", loc.getX());
|
||||||
|
config.set(path + ".y", loc.getY());
|
||||||
|
config.set(path + ".z", loc.getZ());
|
||||||
|
config.set(path + ".yaw", (double) loc.getYaw());
|
||||||
|
config.set(path + ".pitch", (double) loc.getPitch());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Location loadLocation(YamlConfiguration config, String path) {
|
||||||
|
if (!config.contains(path + ".world")) return null;
|
||||||
|
String worldName = config.getString(path + ".world");
|
||||||
|
World world = Bukkit.getWorld(worldName);
|
||||||
|
if (world == null) {
|
||||||
|
plugin.getLogger().warning("Welt '" + worldName + "' nicht gefunden für Pfad: " + path);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Location(world,
|
||||||
|
config.getDouble(path + ".x"),
|
||||||
|
config.getDouble(path + ".y"),
|
||||||
|
config.getDouble(path + ".z"),
|
||||||
|
(float) config.getDouble(path + ".yaw"),
|
||||||
|
(float) config.getDouble(path + ".pitch"));
|
||||||
|
}
|
||||||
|
|
||||||
// --- CRUD ---
|
// --- CRUD ---
|
||||||
public boolean createPortal(String name, String type, Player creator) {
|
public boolean createPortal(String name, String type, Player creator) {
|
||||||
Location[] sel = selectionMap.getOrDefault(creator.getUniqueId(), new Location[2]);
|
Location[] sel = selectionMap.getOrDefault(creator.getUniqueId(), new Location[2]);
|
||||||
@@ -295,7 +293,7 @@ public class PortalManager implements Module, Listener {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Movement / Teleport / Boundary Logic ---
|
// --- Movement / Teleport Logic ---
|
||||||
@org.bukkit.event.EventHandler
|
@org.bukkit.event.EventHandler
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
if (event.getFrom().getX() == event.getTo().getX() &&
|
if (event.getFrom().getX() == event.getTo().getX() &&
|
||||||
@@ -307,20 +305,7 @@ public class PortalManager implements Module, Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Location loc = event.getTo();
|
Location loc = event.getTo();
|
||||||
|
|
||||||
// 1. Grenzschutz (Boundary Protection)
|
// Portal-Logik
|
||||||
if (borderEnabled && !player.hasPermission("nexuslobby.border.bypass")) {
|
|
||||||
if (!isWithinBorder(loc)) {
|
|
||||||
Location spawn = getMainSpawnLocation();
|
|
||||||
if (spawn != null) {
|
|
||||||
player.teleport(spawn);
|
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1.0f, 0.5f);
|
|
||||||
player.sendMessage("§c§lHEY! §7Du hast den erlaubten Bereich verlassen.");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. Portal Logik
|
|
||||||
for (Portal portal : portals.values()) {
|
for (Portal portal : portals.values()) {
|
||||||
if (portal.getPos1() == null || portal.getPos2() == null) continue;
|
if (portal.getPos1() == null || portal.getPos2() == null) continue;
|
||||||
if (!isInArea(loc, portal.getPos1(), portal.getPos2())) continue;
|
if (!isInArea(loc, portal.getPos1(), portal.getPos2())) continue;
|
||||||
@@ -336,14 +321,6 @@ public class PortalManager implements Module, Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isWithinBorder(Location loc) {
|
|
||||||
if (borderMin == null || borderMax == null) return true;
|
|
||||||
if (!loc.getWorld().equals(borderMin.getWorld())) return true;
|
|
||||||
return loc.getX() >= borderMin.getX() && loc.getX() <= borderMax.getX() &&
|
|
||||||
loc.getY() >= borderMin.getY() && loc.getY() <= borderMax.getY() &&
|
|
||||||
loc.getZ() >= borderMin.getZ() && loc.getZ() <= borderMax.getZ();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void executeTeleport(Player player, Portal portal) {
|
private void executeTeleport(Player player, Portal portal) {
|
||||||
if ("SERVER".equalsIgnoreCase(portal.getType())) {
|
if ("SERVER".equalsIgnoreCase(portal.getType())) {
|
||||||
String serverName = portal.getDestination();
|
String serverName = portal.getDestination();
|
||||||
@@ -352,7 +329,7 @@ public class PortalManager implements Module, Listener {
|
|||||||
Location loc = portal.getReturnSpawn();
|
Location loc = portal.getReturnSpawn();
|
||||||
if (loc == null) {
|
if (loc == null) {
|
||||||
Location pos2 = portal.getPos2();
|
Location pos2 = portal.getPos2();
|
||||||
loc = player.getLocation();
|
loc = player.getLocation().clone();
|
||||||
if (pos2 != null) {
|
if (pos2 != null) {
|
||||||
double dx = loc.getX() - pos2.getX();
|
double dx = loc.getX() - pos2.getX();
|
||||||
double dz = loc.getZ() - pos2.getZ();
|
double dz = loc.getZ() - pos2.getZ();
|
||||||
@@ -393,7 +370,7 @@ public class PortalManager implements Module, Listener {
|
|||||||
double x = Double.parseDouble(parts[1]);
|
double x = Double.parseDouble(parts[1]);
|
||||||
double y = Double.parseDouble(parts[2]);
|
double y = Double.parseDouble(parts[2]);
|
||||||
double z = Double.parseDouble(parts[3]);
|
double z = Double.parseDouble(parts[3]);
|
||||||
float yaw = parts.length >= 6 ? Float.parseFloat(parts[4]) : 0f;
|
float yaw = parts.length >= 5 ? Float.parseFloat(parts[4]) : 0f;
|
||||||
float pitch = parts.length >= 6 ? Float.parseFloat(parts[5]) : 0f;
|
float pitch = parts.length >= 6 ? Float.parseFloat(parts[5]) : 0f;
|
||||||
player.teleport(new Location(world, x, y, z, yaw, pitch));
|
player.teleport(new Location(world, x, y, z, yaw, pitch));
|
||||||
player.sendMessage("§aDu wurdest teleportiert!");
|
player.sendMessage("§aDu wurdest teleportiert!");
|
||||||
@@ -461,6 +438,7 @@ public class PortalManager implements Module, Listener {
|
|||||||
Location min = getMinLocation(portal.getPos1(), portal.getPos2());
|
Location min = getMinLocation(portal.getPos1(), portal.getPos2());
|
||||||
Location max = getMaxLocation(portal.getPos1(), portal.getPos2());
|
Location max = getMaxLocation(portal.getPos1(), portal.getPos2());
|
||||||
World world = portal.getPos1().getWorld();
|
World world = portal.getPos1().getWorld();
|
||||||
|
if (world == null) return;
|
||||||
for (int i = 0; i < 15; i++) {
|
for (int i = 0; i < 15; i++) {
|
||||||
double x = min.getX() + Math.random() * (max.getX() - min.getX() + 1);
|
double x = min.getX() + Math.random() * (max.getX() - min.getX() + 1);
|
||||||
double y = min.getY() + Math.random() * (max.getY() - min.getY() + 1);
|
double y = min.getY() + Math.random() * (max.getY() - min.getY() + 1);
|
||||||
|
|||||||
@@ -115,5 +115,7 @@ public class SecurityModule implements Module, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {}
|
public void onDisable() {
|
||||||
|
org.bukkit.event.HandlerList.unregisterAll(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -231,5 +231,8 @@ public class LobbySettingsModule implements Module, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() { saveSettings(); }
|
public void onDisable() {
|
||||||
|
org.bukkit.event.HandlerList.unregisterAll(this);
|
||||||
|
saveSettings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -47,6 +47,7 @@ public class GlobalChatSuppressor implements Module, PluginMessageListener, List
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
org.bukkit.event.HandlerList.unregisterAll(this);
|
||||||
plugin.getServer().getMessenger().unregisterIncomingPluginChannel(plugin, CHANNEL_CONTROL);
|
plugin.getServer().getMessenger().unregisterIncomingPluginChannel(plugin, CHANNEL_CONTROL);
|
||||||
plugin.getServer().getMessenger().unregisterIncomingPluginChannel(plugin, CHANNEL_CHAT);
|
plugin.getServer().getMessenger().unregisterIncomingPluginChannel(plugin, CHANNEL_CHAT);
|
||||||
plugin.getServer().getMessenger().unregisterOutgoingPluginChannel(plugin, CHANNEL_CONTROL);
|
plugin.getServer().getMessenger().unregisterOutgoingPluginChannel(plugin, CHANNEL_CONTROL);
|
||||||
|
|||||||
@@ -65,12 +65,12 @@ worldborder:
|
|||||||
|
|
||||||
# Zentrum der Weltgrenze (optional, kann leer bleiben)
|
# Zentrum der Weltgrenze (optional, kann leer bleiben)
|
||||||
# Wenn nicht gesetzt, wird der Spawn-Punkt als Zentrum verwendet
|
# Wenn nicht gesetzt, wird der Spawn-Punkt als Zentrum verwendet
|
||||||
center:
|
# center wird automatisch über /border circle gesetzt
|
||||||
|
|
||||||
# Alternative: Definiere Eckpunkte (für rechteckige Border)
|
# Alternative: Definiere Eckpunkte (für rechteckige Border)
|
||||||
# Format: x,y,z
|
# Format: x,y,z
|
||||||
pos1:
|
# pos1 wird automatisch über /border square gesetzt
|
||||||
pos2:
|
# pos2 wird automatisch über /border square gesetzt
|
||||||
|
|
||||||
# ══════════════════════════════════════════════════════════════════════════════
|
# ══════════════════════════════════════════════════════════════════════════════
|
||||||
# LOBBY EINSTELLUNGEN
|
# LOBBY EINSTELLUNGEN
|
||||||
@@ -162,7 +162,7 @@ items:
|
|||||||
# Kompass (Server-Auswahl / Teleporter)
|
# Kompass (Server-Auswahl / Teleporter)
|
||||||
compass:
|
compass:
|
||||||
# Aktiviert das Kompass-Item (true = an, false = aus)
|
# Aktiviert das Kompass-Item (true = an, false = aus)
|
||||||
enabled: true
|
enabled: false
|
||||||
|
|
||||||
# Anzeigename des Items (unterstützt Farbcodes)
|
# Anzeigename des Items (unterstützt Farbcodes)
|
||||||
displayname: "&eTeleporter"
|
displayname: "&eTeleporter"
|
||||||
@@ -184,7 +184,7 @@ items:
|
|||||||
# Gadget-Menü (Spezialeffekte und Extras)
|
# Gadget-Menü (Spezialeffekte und Extras)
|
||||||
gadget:
|
gadget:
|
||||||
# Aktiviert das Gadget-Item (true = an, false = aus)
|
# Aktiviert das Gadget-Item (true = an, false = aus)
|
||||||
enabled: false
|
enabled: true
|
||||||
|
|
||||||
# Anzeigename des Items (unterstützt Farbcodes)
|
# Anzeigename des Items (unterstützt Farbcodes)
|
||||||
displayname: "&bGadgets"
|
displayname: "&bGadgets"
|
||||||
@@ -283,7 +283,7 @@ player_inspect:
|
|||||||
# Join/Quit-Nachrichten Unterdrückung und BungeeCord-Messaging
|
# Join/Quit-Nachrichten Unterdrückung und BungeeCord-Messaging
|
||||||
suppressor:
|
suppressor:
|
||||||
# Aktiviert das Suppressor-System (true = an, false = aus)
|
# Aktiviert das Suppressor-System (true = an, false = aus)
|
||||||
enabled: true
|
enabled: false
|
||||||
|
|
||||||
# Unterdrückt Join- und Quit-Nachrichten für neue Spieler temporär
|
# Unterdrückt Join- und Quit-Nachrichten für neue Spieler temporär
|
||||||
# true = Nachrichten werden unterdrückt, false = normale Anzeige
|
# true = Nachrichten werden unterdrückt, false = normale Anzeige
|
||||||
@@ -402,7 +402,7 @@ ball:
|
|||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
# Spawn-Position des Balls
|
# Spawn-Position des Balls
|
||||||
# Tipp: Nutze /nexus ball setspawn um diese Position automatisch zu setzen
|
# Tipp: Nutze /nexuslobby ball setspawn um diese Position automatisch zu setzen
|
||||||
spawn:
|
spawn:
|
||||||
# Name der Welt in der der Ball spawnt
|
# Name der Welt in der der Ball spawnt
|
||||||
world: "world"
|
world: "world"
|
||||||
@@ -425,6 +425,57 @@ ball:
|
|||||||
# 0 = Kein automatischer Respawn
|
# 0 = Kein automatischer Respawn
|
||||||
respawn_delay: 60
|
respawn_delay: 60
|
||||||
|
|
||||||
|
# ══════════════════════════════════════════════════════════════════════════
|
||||||
|
# TOR-DEFINITIONEN
|
||||||
|
# ══════════════════════════════════════════════════════════════════════════
|
||||||
|
# Tore werden automatisch per Befehl gesetzt und hier gespeichert.
|
||||||
|
# Manuell bearbeiten ist möglich, aber der Befehlsweg ist empfohlen.
|
||||||
|
#
|
||||||
|
# Anleitung zum Einrichten eines Tores:
|
||||||
|
# 1. Gehe zur INNEREN Ecke des Torrahmens (z.B. linke untere Ecke)
|
||||||
|
# /nexuslobby ball goal pos1
|
||||||
|
# 2. Gehe zur GEGENÜBERLIEGENDEN Ecke (rechte obere Ecke, auch 1-2 Blöcke
|
||||||
|
# hinter dem Tor in Schussrichtung für bessere Erkennung!)
|
||||||
|
# /nexuslobby ball goal pos2
|
||||||
|
# 3. Speichern (Team 1 = Blau, Team 2 = Rot):
|
||||||
|
# /nexuslobby ball goal save torBlau 1
|
||||||
|
#
|
||||||
|
# WICHTIG für zuverlässige Erkennung:
|
||||||
|
# - Die Box muss MINDESTENS 1.5 Blöcke Tiefe in Schussrichtung haben
|
||||||
|
# - Die Box muss MINDESTENS 3 Blöcke hoch sein (Y-Achse)
|
||||||
|
# - Nutze /nexuslobby ball goal show um die Box sichtbar zu machen
|
||||||
|
# - Nutze /nexuslobby ball goal debug um die Ball-Position live zu prüfen
|
||||||
|
#
|
||||||
|
# Beispiel-Eintrag (wird vom Plugin automatisch befüllt):
|
||||||
|
# goals:
|
||||||
|
# torBlau:
|
||||||
|
# pos1:
|
||||||
|
# world: world
|
||||||
|
# x: 100.0
|
||||||
|
# y: 64.0
|
||||||
|
# z: 198.0
|
||||||
|
# pos2:
|
||||||
|
# world: world
|
||||||
|
# x: 106.0
|
||||||
|
# y: 68.0
|
||||||
|
# z: 200.5 # <-- 2.5 Blöcke Tiefe in Z-Richtung!
|
||||||
|
# team: 1
|
||||||
|
# torRot:
|
||||||
|
# pos1:
|
||||||
|
# world: world
|
||||||
|
# x: 100.0
|
||||||
|
# y: 64.0
|
||||||
|
# z: -198.0
|
||||||
|
# pos2:
|
||||||
|
# world: world
|
||||||
|
# x: 106.0
|
||||||
|
# y: 68.0
|
||||||
|
# z: -200.5
|
||||||
|
# team: 2
|
||||||
|
#
|
||||||
|
# Tore werden hier automatisch eingetragen sobald du den save-Befehl nutzt:
|
||||||
|
goals: {}
|
||||||
|
|
||||||
# ══════════════════════════════════════════════════════════════════════════════
|
# ══════════════════════════════════════════════════════════════════════════════
|
||||||
# Links
|
# Links
|
||||||
# ══════════════════════════════════════════════════════════════════════════════
|
# ══════════════════════════════════════════════════════════════════════════════
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name: NexusLobby
|
name: NexusLobby
|
||||||
main: de.nexuslobby.NexusLobby
|
main: de.nexuslobby.NexusLobby
|
||||||
version: "1.1.1"
|
version: "1.1.4"
|
||||||
api-version: "1.21"
|
api-version: "1.21"
|
||||||
author: M_Viper
|
author: M_Viper
|
||||||
description: Modular Lobby Plugin with an invisible Particle-Parkour system.
|
description: Modular Lobby Plugin with an invisible Particle-Parkour system.
|
||||||
|
|||||||
Reference in New Issue
Block a user