|
22 | 22 | import org.bukkit.persistence.PersistentDataType; |
23 | 23 | import org.incendo.cloud.execution.ExecutionCoordinator; |
24 | 24 | import org.incendo.cloud.paper.PaperCommandManager; |
| 25 | +import org.bukkit.Location; |
| 26 | +import org.incendo.cloud.parser.standard.DoubleParser; |
25 | 27 | import org.incendo.cloud.parser.standard.EnumParser; |
26 | 28 | import org.incendo.cloud.parser.standard.IntegerParser; |
27 | 29 | import org.incendo.cloud.parser.standard.StringParser; |
@@ -158,6 +160,23 @@ private void registerCommands() { |
158 | 160 | .required("seconds", IntegerParser.integerParser()) |
159 | 161 | .handler(ctx -> handleSetGrace(ctx.sender().source(), ctx.get("arena"), ctx.get("seconds")))); |
160 | 162 |
|
| 163 | + manager.command(setBuilder.literal("hologram") |
| 164 | + .required("arena", StringParser.stringParser(), arenaSuggestions) |
| 165 | + .senderType(PlayerSource.class) |
| 166 | + .handler(ctx -> handleSetHologramHere(ctx.sender().source(), ctx.get("arena")))); |
| 167 | + |
| 168 | + manager.command(setBuilder.literal("hologram") |
| 169 | + .required("arena", StringParser.stringParser(), arenaSuggestions) |
| 170 | + .literal("reset") |
| 171 | + .handler(ctx -> handleSetHologramReset(ctx.sender().source(), ctx.get("arena")))); |
| 172 | + |
| 173 | + manager.command(setBuilder.literal("hologram") |
| 174 | + .required("arena", StringParser.stringParser(), arenaSuggestions) |
| 175 | + .required("x", DoubleParser.doubleParser()) |
| 176 | + .required("y", DoubleParser.doubleParser()) |
| 177 | + .required("z", DoubleParser.doubleParser()) |
| 178 | + .handler(ctx -> handleSetHologramCoords(ctx.sender().source(), ctx.get("arena"), ctx.get("x"), ctx.get("y"), ctx.get("z")))); |
| 179 | + |
161 | 180 | // ── Reward ── |
162 | 181 | var rewardBuilder = base.literal("reward").permission("velkoth.admin"); |
163 | 182 |
|
@@ -490,6 +509,67 @@ private void handleSetGrace(CommandSender sender, String arenaId, int seconds) { |
490 | 509 | .replace("<value>", seconds + "s")); |
491 | 510 | } |
492 | 511 |
|
| 512 | + private void handleSetHologramHere(Player player, String arenaId) { |
| 513 | + Arena arena = plugin.getArenaManager().getArena(arenaId); |
| 514 | + if (arena == null) { |
| 515 | + sendPrefixed(player, plugin.getMessages().getArenaNotFound().replace("<arena>", arenaId)); |
| 516 | + return; |
| 517 | + } |
| 518 | + |
| 519 | + Location loc = player.getLocation(); |
| 520 | + arena.setHologramLocation(loc); |
| 521 | + plugin.getArenaManager().saveArenas(); |
| 522 | + |
| 523 | + // Update the hologram location immediately if it is active |
| 524 | + plugin.getDisplayManager().getHologramManager().updateLocation(arena); |
| 525 | + |
| 526 | + String coordsStr = String.format("%.1f, %.1f, %.1f", loc.getX(), loc.getY(), loc.getZ()); |
| 527 | + sendPrefixed(player, plugin.getMessages().getArenaModified() |
| 528 | + .replace("<arena>", arena.id()) |
| 529 | + .replace("<property>", "hologram-location") |
| 530 | + .replace("<value>", coordsStr)); |
| 531 | + } |
| 532 | + |
| 533 | + private void handleSetHologramReset(CommandSender sender, String arenaId) { |
| 534 | + Arena arena = plugin.getArenaManager().getArena(arenaId); |
| 535 | + if (arena == null) { |
| 536 | + sendPrefixed(sender, plugin.getMessages().getArenaNotFound().replace("<arena>", arenaId)); |
| 537 | + return; |
| 538 | + } |
| 539 | + |
| 540 | + arena.setHologramLocation(null); |
| 541 | + plugin.getArenaManager().saveArenas(); |
| 542 | + |
| 543 | + // Update the hologram location immediately if it is active |
| 544 | + plugin.getDisplayManager().getHologramManager().updateLocation(arena); |
| 545 | + |
| 546 | + sendPrefixed(sender, plugin.getMessages().getArenaModified() |
| 547 | + .replace("<arena>", arena.id()) |
| 548 | + .replace("<property>", "hologram-location") |
| 549 | + .replace("<value>", "default")); |
| 550 | + } |
| 551 | + |
| 552 | + private void handleSetHologramCoords(CommandSender sender, String arenaId, double x, double y, double z) { |
| 553 | + Arena arena = plugin.getArenaManager().getArena(arenaId); |
| 554 | + if (arena == null) { |
| 555 | + sendPrefixed(sender, plugin.getMessages().getArenaNotFound().replace("<arena>", arenaId)); |
| 556 | + return; |
| 557 | + } |
| 558 | + |
| 559 | + Location loc = new Location(arena.region().getWorld(), x, y, z); |
| 560 | + arena.setHologramLocation(loc); |
| 561 | + plugin.getArenaManager().saveArenas(); |
| 562 | + |
| 563 | + // Update the hologram location immediately if it is active |
| 564 | + plugin.getDisplayManager().getHologramManager().updateLocation(arena); |
| 565 | + |
| 566 | + String coordsStr = String.format("%.1f, %.1f, %.1f", x, y, z); |
| 567 | + sendPrefixed(sender, plugin.getMessages().getArenaModified() |
| 568 | + .replace("<arena>", arena.id()) |
| 569 | + .replace("<property>", "hologram-location") |
| 570 | + .replace("<value>", coordsStr)); |
| 571 | + } |
| 572 | + |
493 | 573 | // ── Reward ── |
494 | 574 |
|
495 | 575 | private void handleRewardAdd(CommandSender sender, String arenaId, String rewardStr) { |
@@ -590,6 +670,9 @@ private void handleHelp(CommandSender sender) { |
590 | 670 | sendPrefixed(sender, " <gold>/koth set time <arena> <seconds></gold>"); |
591 | 671 | sendPrefixed(sender, " <gold>/koth set score <arena> <maxScore></gold>"); |
592 | 672 | sendPrefixed(sender, " <gold>/koth set grace <arena> <seconds></gold>"); |
| 673 | + sendPrefixed(sender, " <gold>/koth set hologram <arena></gold>"); |
| 674 | + sendPrefixed(sender, " <gold>/koth set hologram <arena> <x> <y> <z></gold>"); |
| 675 | + sendPrefixed(sender, " <gold>/koth set hologram <arena> reset</gold>"); |
593 | 676 | sendPrefixed(sender, ""); |
594 | 677 | sendPrefixed(sender, "<gold><bold>Reward Commands</bold></gold>"); |
595 | 678 | sendPrefixed(sender, " <gold>/koth reward add <arena> <reward></gold>"); |
|
0 commit comments