Skip to content

Commit

Permalink
Make claim list command configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
NotRyken committed Jun 18, 2024
1 parent 4a6f022 commit d377664
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private static int setColor(String color) {
private static int getWorlds() {
ClientPacketListener connection = Minecraft.getInstance().getConnection();
if (connection != null) {
connection.sendCommand("claimlist");
connection.sendCommand(Config.get().gpSettings.claimListCommand);
MsgScanner.startWorldScan();
}
return Command.SINGLE_SUCCESS;
Expand All @@ -160,7 +160,7 @@ private static int updateFrom(String world) {
private static int scanFrom(String world, MsgScanner.ScanType scanType) {
ClientPacketListener connection = Minecraft.getInstance().getConnection();
if (connection != null) {
connection.sendCommand("claimlist");
connection.sendCommand(Config.get().gpSettings.claimListCommand);
MsgScanner.startClaimScan(world, scanType);
}
return Command.SINGLE_SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public static class ClaimPointSettings {
}

public static class GriefPreventionSettings {
public static final String defaultClaimListCommand = "claimlist";
public String claimListCommand = defaultClaimListCommand;

public static final String defaultFirstLinePattern =
"^-?\\d+ blocks from play \\+ -?\\d+ bonus = -?\\d+ total.$";
public String firstLinePattern = defaultFirstLinePattern;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ static Screen getConfigScreen(Screen parent) {

ConfigCategory griefPrevention = builder.getOrCreateCategory(Component.literal("GriefPrevention"));

griefPrevention.addEntry(eb.startStrField(Component.literal("Claim list command"),
config.gpSettings.claimListCommand)
.setDefaultValue(Config.GriefPreventionSettings.defaultClaimListCommand)
.setSaveConsumer(var -> config.gpSettings.claimListCommand = var)
.build());

griefPrevention.addEntry(eb.startStrField(Component.literal("First Line Pattern"), config.gpSettings.firstLinePattern)
.setDefaultValue(Config.GriefPreventionSettings.defaultFirstLinePattern)
.setSaveConsumer(var -> config.gpSettings.firstLinePattern = var)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,9 @@ else if (anyMatches(content, Config.get().gpSettings.ignoredLinesCompiled)) {
private static void handleWorlds() {
MutableComponent msg = ClaimPoints.PREFIX.copy();
if (worlds.isEmpty()) {
msg.append(Component.literal("No worlds found using /claimlist. " +
"That might be the wrong command, or you might not have any claims."));
msg.append(Component.literal("No worlds found using /'" +
Config.get().gpSettings.claimListCommand +
"'. That might be the wrong command, or you might not have any claims."));
}
else {
StringBuilder sb = new StringBuilder("Claim worlds (" + worlds.size() + "):");
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Neo/Forge version ranges: https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html

# Project
mod_version=0.1.0
mod_version=0.1.1
mod_group=com.notryken
mod_id=claimpoints
mod_name=ClaimPoints
Expand Down

0 comments on commit d377664

Please sign in to comment.