Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor /towny command. #5666

Merged
merged 2 commits into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion resources/lang/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,7 @@ msg_err_outlawed_players_no_teleport: '&4You are outlawed in the town you are cu
msg_err_you_cannot_use_command_while_in_outlaw_town: '&4You cannot use that command while in a town you are outlawed in.'

#Added in 0.110
msg_safe_mode: "[Error] Locked in safe mode!"
msg_safe_mode_base: '[Error] Towny is locked in Safe Mode due to an error! '
msg_safe_mode_player: 'Tell an admin to check the server''s console.'
msg_safe_mode_admin: 'Check the server''s console for more information.'
Expand Down Expand Up @@ -1642,4 +1643,6 @@ did_you_want_to_toggle_unlimited_claims: 'You do not have enough townblocks to c
#Added in 0.145

#Message shown when a conquered town tries to leave their nation.
msg_err_your_conquered_town_cannot_leave_the_nation_yet: 'You cannot leave your nation, your town is conquered.'
msg_err_your_conquered_town_cannot_leave_the_nation_yet: 'You cannot leave your nation, your town is conquered.'
msg_err_console_only: 'This command can only be used by console.'
msg_err_player_only: 'This command can only be used by a player.'
11 changes: 11 additions & 0 deletions src/com/palmergames/bukkit/towny/command/BaseCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -295,4 +296,14 @@ private static List<Resident> getOnlinePlayersWithoutTown() {
}
return townlessResidents;
}

public static void catchPlayer(CommandSender sender) throws TownyException {
if (sender instanceof Player)
throw new TownyException(Translatable.of("msg_err_console_only"));
}

public static void catchConsole(CommandSender sender) throws TownyException {
if (sender instanceof ConsoleCommandSender)
throw new TownyException(Translatable.of("msg_err_player_only"));
}
}
Loading