Skip to content

Commit

Permalink
- Fix worlds not being saved after using /tw set usedefault.
Browse files Browse the repository at this point in the history
  - Remove ability for /tw set wild being able to set a world to the
default settings when no arguments are supplied.
  • Loading branch information
LlmDl committed Dec 3, 2024
1 parent 1e5b4a8 commit 35aaf92
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ public void worldSet(CommandSender sender, TownyWorld world, String[] split) thr
private void setUseDefaults(CommandSender sender, TownyWorld world) {
Confirmation.runOnAccept(() -> {
world.setUsingDefault();
world.save();
plugin.resetCache();
TownyMessaging.sendMsg(sender, Translatable.of("msg_usedefault", world.getName()));
})
Expand All @@ -431,22 +432,21 @@ private void setUseDefaults(CommandSender sender, TownyWorld world) {

private void setWildPerm(CommandSender sender, TownyWorld world, String[] split) {
if (split.length < 2) {
// set default wildperm settings (/tw set wildperm)
world.setUsingDefault();
TownyMessaging.sendMsg(sender, Translatable.of("msg_usedefault", world.getName()));
} else
try {
List<String> perms = Arrays.asList(String.join(",", StringMgmt.remFirstArg(split)).toLowerCase(Locale.ROOT).split(","));
world.setUnclaimedZoneBuild(perms.contains("build"));
world.setUnclaimedZoneDestroy(perms.contains("destroy"));
world.setUnclaimedZoneSwitch(perms.contains("switch"));
world.setUnclaimedZoneItemUse(perms.contains("itemuse") || perms.contains("item_use"));
TownyMessaging.sendErrorMsg(sender, "Eg: /townyworld set wildperm build destroy <world>");
return;
}
try {
List<String> perms = Arrays.asList(String.join(",", StringMgmt.remFirstArg(split)).toLowerCase(Locale.ROOT).split(","));
world.setUnclaimedZoneBuild(perms.contains("build"));
world.setUnclaimedZoneDestroy(perms.contains("destroy"));
world.setUnclaimedZoneSwitch(perms.contains("switch"));
world.setUnclaimedZoneItemUse(perms.contains("itemuse") || perms.contains("item_use"));

plugin.resetCache();
TownyMessaging.sendMsg(sender, Translatable.of("msg_set_wild_perms", world.getName(), perms.toString()));
} catch (Exception e) {
TownyMessaging.sendErrorMsg(sender, "Eg: /townyworld set wildperm build destroy <world>");
}
plugin.resetCache();
TownyMessaging.sendMsg(sender, Translatable.of("msg_set_wild_perms", world.getName(), perms.toString()));
} catch (Exception e) {
TownyMessaging.sendErrorMsg(sender, "Eg: /townyworld set wildperm build destroy <world>");
}
}

private void setWildIgnore(CommandSender sender, TownyWorld world, String[] split) {
Expand Down
4 changes: 3 additions & 1 deletion Towny/src/main/resources/ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10166,4 +10166,6 @@ v0.92.0.11:
- %townyadvanced_nation_formatted_with_nation_minimessage_colour%
- These will use the Towny config's town and nation placeholder formatting, but insert the town or nation's colour code before the town or nation name.
- %townyadvanced_towny_tag_override_with_minimessage_colour%
- This will use the town or nation's tag if they have a tag in use.
- This will use the town or nation's tag if they have a tag in use.
- Fix worlds not being saved after using /tw set usedefault.
- Remove ability for /tw set wild being able to set a world to the default settings when no arguments are supplied.

0 comments on commit 35aaf92

Please sign in to comment.