diff --git a/build.gradle b/build.gradle index a01fd4e..8693f47 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { } group = 'com.bobbyl140' -version = '1.2' +version = '1.2.2' repositories { mavenCentral() diff --git a/src/main/java/com/bobbyl140/boulder/Boulder.java b/src/main/java/com/bobbyl140/boulder/Boulder.java index 6af1729..e60f3b8 100644 --- a/src/main/java/com/bobbyl140/boulder/Boulder.java +++ b/src/main/java/com/bobbyl140/boulder/Boulder.java @@ -16,7 +16,6 @@ import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.format.TextColor; import org.slf4j.Logger; - import com.velocitypowered.api.event.connection.PreLoginEvent; import com.velocitypowered.api.event.connection.PostLoginEvent; @@ -77,7 +76,31 @@ private void loadWhitelist() { if (Files.exists(whitelistFile)) { try { List lines = Files.readAllLines(whitelistFile); - whitelist.addAll(lines); + whitelist.clear(); + + for (String line : lines) { + String uuid = line.trim(); + if (uuid.isEmpty()) { + continue; + } + if (uuid.startsWith("#") || uuid.startsWith("//")) { + continue; + } + + try { + try { + if (UUID.fromString(line).toString().equals(line)) { + whitelist.add(line); + } + } catch (IllegalArgumentException e) { + logger.info("Invalid UUID: {}", line); + } + } catch (IllegalArgumentException e) { + logger.warn("Invalid UUID format: {}", uuid); + } + + } + logger.info("Whitelist loaded with {} entries", whitelist.size()); } catch (IOException e) { logger.error("Failed to load whitelist.", e); @@ -161,17 +184,16 @@ public void execute(Invocation invocation) { String action = args[0]; - if (!isValidUUID(args[1])) { - source.sendPlainMessage("Invalid UUID."); - return; - } - switch (action.toLowerCase()) { case "reload": loadWhitelist(); source.sendPlainMessage("Whitelist reloaded."); break; case "add": + if (!isValidUUID(args[1])) { + source.sendPlainMessage("Invalid UUID."); + return; + } if (args.length < 2) { source.sendPlainMessage("Usage: /whitelist add "); return; @@ -189,6 +211,10 @@ public void execute(Invocation invocation) { } break; case "remove": + if (!isValidUUID(args[1])) { + source.sendPlainMessage("Invalid UUID."); + return; + } if (args.length < 2) { source.sendPlainMessage("Usage: /whitelist remove "); return;