fix: 10 bug fixes — healing dead players, kick bypass, gate race, swimming ghost, regression config, dead code cleanup, gate zone detection
This commit is contained in:
parent
b666f1b0fa
commit
d2b174b94c
35 changed files with 587 additions and 773 deletions
|
|
@ -3,6 +3,7 @@ package dev.loki.command;
|
|||
import dev.loki.mdbd;
|
||||
import dev.loki.util.SpawnUtil;
|
||||
import dev.loki.util.TextUtil;
|
||||
import dev.loki.config.LocationsConfig;
|
||||
import dev.loki.config.MessagesConfig;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
|
@ -70,7 +71,8 @@ public class SetupCommand implements TabExecutor {
|
|||
return switch (args[0].toLowerCase()) {
|
||||
case "wand" -> giveWand(player);
|
||||
case "set" -> handleSet(player, args);
|
||||
case "clear" -> clearMap(player);
|
||||
case "clear" -> handleClear(player, args);
|
||||
case "delete" -> handleDelete(player, args);
|
||||
case "clear-spawns" -> clearSpawns(player);
|
||||
case "lobby" -> setLobby(player);
|
||||
default -> { sendUsage(sender); yield true; }
|
||||
|
|
@ -331,6 +333,147 @@ public class SetupCommand implements TabExecutor {
|
|||
return true;
|
||||
}
|
||||
|
||||
// ── Clear ────────────────────────────────────────────────────────
|
||||
|
||||
private boolean handleClear(Player player, String[] args) {
|
||||
var locations = plugin.getConfigManager().getLocations();
|
||||
|
||||
if (args.length >= 2) {
|
||||
String type = args[1].toLowerCase();
|
||||
return clearObjectsByType(player, locations, type);
|
||||
}
|
||||
|
||||
// Clear ALL object data from config (no block destruction)
|
||||
locations.clearLocationList("generators");
|
||||
locations.clearLocationList("hooks");
|
||||
locations.clearLocationList("chests");
|
||||
locations.clearLocationList("killer-spawn");
|
||||
for (String id : List.of("a", "b")) {
|
||||
locations.getConfig().set("gate-" + id, null);
|
||||
locations.getConfig().set("gate-" + id + "-corner1", null);
|
||||
locations.getConfig().set("gate-" + id + "-corner2", null);
|
||||
}
|
||||
locations.clearSurvivorSpawns();
|
||||
plugin.getGeneratorData().clearGenerators();
|
||||
plugin.getConfigManager().saveConfig("locations.yml", locations.getConfig());
|
||||
player.sendMessage(messages().get("setup.cleared"));
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean clearObjectsByType(Player player, LocationsConfig locations, String type) {
|
||||
String path = switch (type) {
|
||||
case "generator" -> "generators";
|
||||
case "hook" -> "hooks";
|
||||
case "chest" -> "chests";
|
||||
case "gate" -> null;
|
||||
case "killer-spawn" -> "killer-spawn";
|
||||
case "survivor-spawn" -> null;
|
||||
default -> { player.sendMessage(messages().get("setup.unknown-type", type)); yield null; }
|
||||
};
|
||||
if (path == null) {
|
||||
if (type.equals("gate")) {
|
||||
for (String id : List.of("a", "b")) {
|
||||
locations.getConfig().set("gate-" + id, null);
|
||||
locations.getConfig().set("gate-" + id + "-corner1", null);
|
||||
locations.getConfig().set("gate-" + id + "-corner2", null);
|
||||
}
|
||||
} else if (type.equals("survivor-spawn")) {
|
||||
locations.clearSurvivorSpawns();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
locations.clearLocationList(path);
|
||||
if (type.equals("generator")) {
|
||||
plugin.getGeneratorData().clearGenerators();
|
||||
}
|
||||
}
|
||||
plugin.getConfigManager().saveConfig("locations.yml", locations.getConfig());
|
||||
player.sendMessage(messages().get("setup.cleared-type", type));
|
||||
return true;
|
||||
}
|
||||
|
||||
// ── Delete ───────────────────────────────────────────────────────
|
||||
|
||||
private boolean handleDelete(Player player, String[] args) {
|
||||
if (args.length < 3) {
|
||||
player.sendMessage(messages().get("setup.delete-usage"));
|
||||
return true;
|
||||
}
|
||||
|
||||
String type = args[1].toLowerCase();
|
||||
int index;
|
||||
try {
|
||||
index = Integer.parseInt(args[2]);
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(messages().get("setup.invalid-number", args[2]));
|
||||
return true;
|
||||
}
|
||||
|
||||
var locations = plugin.getConfigManager().getLocations();
|
||||
|
||||
switch (type) {
|
||||
case "generator" -> {
|
||||
var gens = locations.getGenerators();
|
||||
if (index < 0 || index >= gens.size()) {
|
||||
player.sendMessage(messages().get("setup.out-of-range", index));
|
||||
return true;
|
||||
}
|
||||
locations.removeLocationAtIndex("generators", index);
|
||||
plugin.getGeneratorData().removeGenerator(index);
|
||||
player.sendMessage(messages().get("setup.deleted", "generator #" + index));
|
||||
}
|
||||
case "hook" -> {
|
||||
var hooks = locations.getHooks();
|
||||
if (index < 0 || index >= hooks.size()) {
|
||||
player.sendMessage(messages().get("setup.out-of-range", index));
|
||||
return true;
|
||||
}
|
||||
locations.removeLocationAtIndex("hooks", index);
|
||||
player.sendMessage(messages().get("setup.deleted", "hook #" + index));
|
||||
}
|
||||
case "chest" -> {
|
||||
var chests = locations.getChests();
|
||||
if (index < 0 || index >= chests.size()) {
|
||||
player.sendMessage(messages().get("setup.out-of-range", index));
|
||||
return true;
|
||||
}
|
||||
locations.removeLocationAtIndex("chests", index);
|
||||
player.sendMessage(messages().get("setup.deleted", "chest #" + index));
|
||||
}
|
||||
case "killer-spawn" -> {
|
||||
locations.clearLocationList("killer-spawn");
|
||||
player.sendMessage(messages().get("setup.deleted", "killer-spawn"));
|
||||
}
|
||||
case "survivor-spawn" -> {
|
||||
if (index < 1 || index > 4) {
|
||||
player.sendMessage(messages().get("setup.out-of-range", index));
|
||||
return true;
|
||||
}
|
||||
locations.clearSurvivorSpawn(index);
|
||||
player.sendMessage(messages().get("setup.deleted", "survivor-spawn #" + index));
|
||||
}
|
||||
case "gate" -> {
|
||||
String id = index == 1 ? "a" : index == 2 ? "b" : null;
|
||||
if (id == null) {
|
||||
player.sendMessage(messages().get("setup.out-of-range", index));
|
||||
return true;
|
||||
}
|
||||
locations.getConfig().set("gate-" + id, null);
|
||||
locations.getConfig().set("gate-" + id + "-corner1", null);
|
||||
locations.getConfig().set("gate-" + id + "-corner2", null);
|
||||
player.sendMessage(messages().get("setup.deleted", "gate-" + id));
|
||||
}
|
||||
default -> {
|
||||
player.sendMessage(messages().get("setup.unknown-type", type));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getConfigManager().saveConfig("locations.yml", locations.getConfig());
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean clearSpawns(Player player) {
|
||||
var locations = plugin.getConfigManager().getLocations();
|
||||
locations.clearLocationList("killer-spawn");
|
||||
|
|
@ -359,6 +502,8 @@ public class SetupCommand implements TabExecutor {
|
|||
sender.sendMessage(messages().get("usage.setup-killer-spawn"));
|
||||
sender.sendMessage(messages().get("usage.setup-survivor-spawn"));
|
||||
sender.sendMessage(messages().get("usage.setup-gate"));
|
||||
sender.sendMessage(messages().get("usage.setup-clear"));
|
||||
sender.sendMessage(messages().get("usage.setup-delete"));
|
||||
sender.sendMessage(messages().get("usage.setup-clear-spawns"));
|
||||
sender.sendMessage(messages().get("usage.setup-lobby"));
|
||||
}
|
||||
|
|
@ -373,12 +518,14 @@ public class SetupCommand implements TabExecutor {
|
|||
@NotNull String label, @NotNull String[] args) {
|
||||
if (!sender.hasPermission("mdbd.admin")) return List.of();
|
||||
if (args.length == 1) {
|
||||
return List.of("wand", "set", "clear", "clear-spawns", "lobby").stream()
|
||||
return List.of("wand", "set", "clear", "delete", "clear-spawns", "lobby").stream()
|
||||
.filter(s -> s.startsWith(args[0].toLowerCase())).toList();
|
||||
}
|
||||
if (args.length == 2 && args[0].equalsIgnoreCase("set")) {
|
||||
return List.of("hook", "chest", "generator", "killer-spawn", "survivor-spawn", "gate").stream()
|
||||
.filter(s -> s.startsWith(args[1].toLowerCase())).toList();
|
||||
if (args.length == 2) {
|
||||
if (args[0].equalsIgnoreCase("set") || args[0].equalsIgnoreCase("clear") || args[0].equalsIgnoreCase("delete")) {
|
||||
return List.of("generator", "hook", "chest", "killer-spawn", "survivor-spawn", "gate").stream()
|
||||
.filter(s -> s.startsWith(args[1].toLowerCase())).toList();
|
||||
}
|
||||
}
|
||||
return List.of();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue