Skip to content

Commit

Permalink
FIX reload subarg and bump version number.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbyl140 committed Oct 2, 2024
1 parent b3d59cc commit 86c4afc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = 'com.bobbyl140'
version = '1.2'
version = '1.2.2'

repositories {
mavenCentral()
Expand Down
40 changes: 33 additions & 7 deletions src/main/java/com/bobbyl140/boulder/Boulder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -77,7 +76,31 @@ private void loadWhitelist() {
if (Files.exists(whitelistFile)) {
try {
List<String> 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);
Expand Down Expand Up @@ -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 <UUID>");
return;
Expand All @@ -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 <UUID>");
return;
Expand Down

0 comments on commit 86c4afc

Please sign in to comment.