Added support for localising command descriptions

This commit is contained in:
William committed 2022-01-15 17:54:24 +00:00
1 parent 2f167ff612
commit 5aef844173
19 files changed
+173 -50

No files matched your search

+6
View File
@@ -196,5 +196,11 @@
<version>5.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>23.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
@@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import org.jetbrains.annotations.NotNull;
/**
* An event, fired when a home is updated
@@ -31,7 +32,7 @@ public class PlayerHomeUpdateEvent extends PlayerEvent implements Cancellable {
}
@Override
public HandlerList getHandlers() {
public @NotNull HandlerList getHandlers() {
return HANDLER_LIST;
}
@@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import org.jetbrains.annotations.NotNull;
public class PlayerPreTeleportEvent extends PlayerEvent implements Cancellable {
@@ -25,7 +26,7 @@ public class PlayerPreTeleportEvent extends PlayerEvent implements Cancellable {
}
@Override
public HandlerList getHandlers() {
public @NotNull HandlerList getHandlers() {
return HANDLER_LIST;
}
@@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import org.jetbrains.annotations.NotNull;
/**
* An event, fired when a player sets a new home
@@ -28,7 +29,7 @@ public class PlayerSetHomeEvent extends PlayerEvent implements Cancellable {
}
@Override
public HandlerList getHandlers() {
public @NotNull HandlerList getHandlers() {
return HANDLER_LIST;
}
@@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import org.jetbrains.annotations.NotNull;
/**
* An event, fired when a player sets a new warp
@@ -28,7 +29,7 @@ public class PlayerSetWarpEvent extends PlayerEvent implements Cancellable {
}
@Override
public HandlerList getHandlers() {
public @NotNull HandlerList getHandlers() {
return HANDLER_LIST;
}
@@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import org.jetbrains.annotations.NotNull;
/**
* An event, fired when a warp is updated
@@ -32,7 +33,7 @@ public class PlayerWarpUpdateEvent extends PlayerEvent implements Cancellable {
}
@Override
public HandlerList getHandlers() {
public @NotNull HandlerList getHandlers() {
return HANDLER_LIST;
}
@@ -1,15 +1,18 @@
package me.william278.huskhomes2.commands;
import me.william278.huskhomes2.MessageManager;
import org.bukkit.command.*;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
public abstract class CommandBase implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (sender instanceof Player) {
onCommand((Player) sender, command, label, args);
return true;
@@ -21,20 +24,28 @@ public abstract class CommandBase implements CommandExecutor {
/**
* Register base for bukkit command
*
* @param command Command for registration
*/
public PluginCommand register(PluginCommand command) {
Objects.requireNonNull(command);
// Set command executor
command.setExecutor(this);
// Set the appropriate tab completer
if (this instanceof TabCompleter) {
command.setTabCompleter((TabCompleter) this);
}
// Get localised command description
command.setDescription(MessageManager.getRawMessage(command.getName() + "_command_description"));
return command;
}
public static class EmptyTab implements TabCompleter {
@Override
public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] strings) {
public List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, String[] strings) {
return Collections.emptyList();
}
}
@@ -13,6 +13,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Arrays;
@@ -62,7 +63,7 @@ public class HuskHomesCommand extends CommandBase implements TabCompleter {
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (args.length == 0) {
if (sender instanceof Player) {
showHelpMenu((Player) sender, 1);
@@ -174,7 +175,7 @@ public class HuskHomesCommand extends CommandBase implements TabCompleter {
final static String[] COMMAND_TAB_ARGS = {"help", "about", "update", "reload"};
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
public List<String> onTabComplete(@NotNull CommandSender sender, Command command, @NotNull String alias, String[] args) {
Player p = (Player) sender;
if (command.getPermission() != null) {
if (!p.hasPermission(command.getPermission())) {
@@ -12,6 +12,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.sql.Connection;
import java.sql.SQLException;
@@ -69,7 +70,7 @@ public class PublicHomeCommand extends CommandBase implements TabCompleter {
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (!(sender instanceof Player p)) {
handleConsolePublicHomeTeleport(sender, args);
return true;
@@ -134,7 +135,7 @@ public class PublicHomeCommand extends CommandBase implements TabCompleter {
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
public List<String> onTabComplete(CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
if (!sender.hasPermission("huskhomes.publichome")) {
return Collections.emptyList();
}
@@ -11,6 +11,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.sql.Connection;
import java.sql.SQLException;
@@ -26,7 +27,7 @@ public class WarpCommand extends CommandBase {
private static final HuskHomes plugin = HuskHomes.getInstance();
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (!(sender instanceof Player p)) {
handleConsoleWarp(sender, args);
return true;
@@ -116,7 +117,7 @@ public class WarpCommand extends CommandBase {
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
public List<String> onTabComplete(CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
if (!sender.hasPermission("huskhomes.warp")) {
return Collections.emptyList();
}
@@ -7,6 +7,7 @@ import me.william278.huskhomes2.data.message.CrossServerMessageHandler;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
import org.jetbrains.annotations.NotNull;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
@@ -15,7 +16,7 @@ import java.io.IOException;
public class PluginMessageReceiver implements PluginMessageListener {
@Override @SuppressWarnings("UnstableApiUsage")
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
public void onPluginMessageReceived(String channel, @NotNull Player player, byte[] message) {
// Return if the message is not a Bungee message
if (!channel.equals("BungeeCord")) {
return;
@@ -8,10 +8,7 @@ import me.william278.huskhomes2.integrations.VanishChecker;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.logging.Level;
public class TeleportRequestHandler {
@@ -93,7 +93,7 @@ public class TimedTeleport {
sendWarmupMessage(player, "teleporting_action_bar_cancelled");
return;
}
if (hasDamagedPlayers(executablePlayer)) {
if (hasDealtDamage(executablePlayer)) {
cancel();
executablePlayer.playSound(executablePlayer.getLocation(), HuskHomes.getSettings().getTeleportCancelledSound(), 1, 1);
MessageManager.sendMessage(player, "teleporting_cancelled_pvp");
@@ -202,8 +202,8 @@ public class TimedTeleport {
return totalDiff > movementThreshold;
}
// This returns if the player has damaged other players
public boolean hasDamagedPlayers(Player p) {
// This returns if the player has dealt damage
public boolean hasDealtDamage(Player p) {
final int damageDealt = p.getStatistic(Statistic.DAMAGE_DEALT);
return damageDealt > initialDamageDealt;
}
+26 -1
View File
@@ -120,4 +120,29 @@ error_invalid_player: '[Error:](#ff3300) [Please specify the name of a valid pla
error_no_homes_set_other: '[Error:](#ff3300) [%1% hasn''t set any homes!](#ff7e5e)'
error_home_invalid_other: '[Error:](#ff3300) [%1% doesn''t have a home set named "%2%"](#ff7e5e)'
error_edit_home_maximum_public_homes: '[Error:](#ff3300) [You can only make a maximum of %1% homes public.](#ff7e5e)'
teleporting_cancelled_pvp: '[Teleportation cancelled; you engaged in combat!](#ff7e5e)'
teleporting_cancelled_pvp: '[Teleportation cancelled; you engaged in combat!](#ff7e5e)'
home_command_description: 'Teleport to one of your homes'
sethome_command_description: 'Set a new home with given name'
delhome_command_description: 'Delete a home you previously set'
edithome_command_description: 'Edit one of your homes'
warp_command_description: 'Teleport to a warp'
setwarp_command_description: 'Set a new warp with given name'
delwarp_command_description: 'Delete a warp'
editwarp_command_description: 'Edit a warp'
back_command_description: 'Return to your previous position, or where you died'
homelist_command_description: 'Get a list of your homes'
warplist_command_description: 'View the list of warps'
publichomelist_command_description: 'View the list of public homes'
publichome_command_description: 'Teleport to a public home'
tp_command_description: 'Teleport to another player or location'
tphere_command_description: 'Teleport another player to you'
tpa_command_description: 'Request to teleport to another player'
tpahere_command_description: 'Request another player to teleport to you'
tpaccept_command_description: 'Accept a teleport request'
tpdeny_command_description: 'Deny a teleport request'
tpignore_command_description: 'Ignore incoming teleport requests'
tpoffline_command_description: 'Teleport to where a player was last online'
rtp_command_description: 'Teleport randomly into the wild'
spawn_command_description: 'Teleport to spawn'
setspawn_command_description: 'Set the spawn position'
huskhomes_command_description: 'View plugin information & reload configs'
+26 -1
View File
@@ -119,4 +119,29 @@ error_no_homes_set_other: '[Errore:](#ff3300) [%1% non ha nessuna home!](#ff7e5e
error_home_invalid_other: '[Errore:](#ff3300) [%1% non ha una home chiamata "%2%"](#ff7e5e)'
home_deleted_other: '[Hai cancellato la home](#00fb9a)[%2%](#00fb9a bold)[di %1%](#00fb9a) '
edit_home_privacy_private_other: '• Accesso: &#ff7e5e&Privato &7(Solo %1% può usarla)'
error_edit_home_maximum_public_homes: '[Error:](#ff3300) [You can only make a maximum of %1% homes public.](#ff7e5e)'
error_edit_home_maximum_public_homes: '[Error:](#ff3300) [You can only make a maximum of %1% homes public.](#ff7e5e)'
home_command_description: 'Teleport to one of your homes'
sethome_command_description: 'Set a new home with given name'
delhome_command_description: 'Delete a home you previously set'
edithome_command_description: 'Edit one of your homes'
warp_command_description: 'Teleport to a warp'
setwarp_command_description: 'Set a new warp with given name'
delwarp_command_description: 'Delete a warp'
editwarp_command_description: 'Edit a warp'
back_command_description: 'Return to your previous position, or where you died'
homelist_command_description: 'Get a list of your homes'
warplist_command_description: 'View the list of warps'
publichomelist_command_description: 'View the list of public homes'
publichome_command_description: 'Teleport to a public home'
tp_command_description: 'Teleport to another player or location'
tphere_command_description: 'Teleport another player to you'
tpa_command_description: 'Request to teleport to another player'
tpahere_command_description: 'Request another player to teleport to you'
tpaccept_command_description: 'Accept a teleport request'
tpdeny_command_description: 'Deny a teleport request'
tpignore_command_description: 'Ignore incoming teleport requests'
tpoffline_command_description: 'Teleport to where a player was last online'
rtp_command_description: 'Teleport randomly into the wild'
spawn_command_description: 'Teleport to spawn'
setspawn_command_description: 'Set the spawn position'
huskhomes_command_description: 'View plugin information & reload configs'
+26 -1
View File
@@ -119,4 +119,29 @@ error_no_homes_set_other: '[Błąd:](#ff3300) [%1% nie ma żadnych domów!](#ff7
error_home_invalid_other: '[Błąd:](#ff3300) [%1% nie ma domu nazwanego "%2%"](#ff7e5e)'
home_deleted_other: '[Pomyślnie usunięto dom %1%,](#00fb9a) [%2%](#00fb9a bold)'
edit_home_privacy_private_other: '• Dostęp: &#ff7e5e&Prywatny &7(Tylko %1% może to użyć)'
error_edit_home_maximum_public_homes: '[Błąd:](#ff3300) [Możesz maksymalnie utworzyć %1% publicznych domów.](#ff7e5e)'
error_edit_home_maximum_public_homes: '[Błąd:](#ff3300) [Możesz maksymalnie utworzyć %1% publicznych domów.](#ff7e5e)'
home_command_description: 'Teleport to one of your homes'
sethome_command_description: 'Set a new home with given name'
delhome_command_description: 'Delete a home you previously set'
edithome_command_description: 'Edit one of your homes'
warp_command_description: 'Teleport to a warp'
setwarp_command_description: 'Set a new warp with given name'
delwarp_command_description: 'Delete a warp'
editwarp_command_description: 'Edit a warp'
back_command_description: 'Return to your previous position, or where you died'
homelist_command_description: 'Get a list of your homes'
warplist_command_description: 'View the list of warps'
publichomelist_command_description: 'View the list of public homes'
publichome_command_description: 'Teleport to a public home'
tp_command_description: 'Teleport to another player or location'
tphere_command_description: 'Teleport another player to you'
tpa_command_description: 'Request to teleport to another player'
tpahere_command_description: 'Request another player to teleport to you'
tpaccept_command_description: 'Accept a teleport request'
tpdeny_command_description: 'Deny a teleport request'
tpignore_command_description: 'Ignore incoming teleport requests'
tpoffline_command_description: 'Teleport to where a player was last online'
rtp_command_description: 'Teleport randomly into the wild'
spawn_command_description: 'Teleport to spawn'
setspawn_command_description: 'Set the spawn position'
huskhomes_command_description: 'View plugin information & reload configs'
+26 -1
View File
@@ -119,4 +119,29 @@ error_no_homes_set_other: '[错误:](#ff3300) [%1% 没有设置任何一个家!]
error_home_invalid_other: '[错误:](#ff3300) [%1% 没有叫做 "%2%" 的家](#ff7e5e)'
home_deleted_other: '[成功删除了 %1% 的名字叫](#00fb9a) [%2%](#00fb9a bold) [的家](#00fb9a)'
edit_home_privacy_private_other: '• 隐私性: &#ff7e5e&私有的 &7(只有 %1% 可以使用该家)'
error_edit_home_maximum_public_homes: '[Error:](#ff3300) [You can only make a maximum of %1% homes public.](#ff7e5e)'
error_edit_home_maximum_public_homes: '[Error:](#ff3300) [You can only make a maximum of %1% homes public.](#ff7e5e)'
home_command_description: 'Teleport to one of your homes'
sethome_command_description: 'Set a new home with given name'
delhome_command_description: 'Delete a home you previously set'
edithome_command_description: 'Edit one of your homes'
warp_command_description: 'Teleport to a warp'
setwarp_command_description: 'Set a new warp with given name'
delwarp_command_description: 'Delete a warp'
editwarp_command_description: 'Edit a warp'
back_command_description: 'Return to your previous position, or where you died'
homelist_command_description: 'Get a list of your homes'
warplist_command_description: 'View the list of warps'
publichomelist_command_description: 'View the list of public homes'
publichome_command_description: 'Teleport to a public home'
tp_command_description: 'Teleport to another player or location'
tphere_command_description: 'Teleport another player to you'
tpa_command_description: 'Request to teleport to another player'
tpahere_command_description: 'Request another player to teleport to you'
tpaccept_command_description: 'Accept a teleport request'
tpdeny_command_description: 'Deny a teleport request'
tpignore_command_description: 'Ignore incoming teleport requests'
tpoffline_command_description: 'Teleport to where a player was last online'
rtp_command_description: 'Teleport randomly into the wild'
spawn_command_description: 'Teleport to spawn'
setspawn_command_description: 'Set the spawn position'
huskhomes_command_description: 'View plugin information & reload configs'
+26 -1
View File
@@ -119,4 +119,29 @@ home_deleted_other: '[Successfully deleted %1%''s home,](#00fb9a) [%2%](#00fb9a
edit_home_privacy_private_other: '• Access: &#ff7e5e&Private &7(Only %1% can use it)'
edit_home_title_other: '\n[Edit home details for %1%''s home,](#00fb9a) [%2%](#00fb9a bold)[:](#00fb9a)'
command_list_item: '[/%1%](#00fb9a show_text=&#00fb9a&%2% suggest_command=/%1%) [•](white) [%3%](gray)'
error_edit_home_maximum_public_homes: '[Error:](#ff3300) [You can only make a maximum of %1% homes public.](#ff7e5e)'
error_edit_home_maximum_public_homes: '[Error:](#ff3300) [You can only make a maximum of %1% homes public.](#ff7e5e)'
home_command_description: 'Teleport to one of your homes'
sethome_command_description: 'Set a new home with given name'
delhome_command_description: 'Delete a home you previously set'
edithome_command_description: 'Edit one of your homes'
warp_command_description: 'Teleport to a warp'
setwarp_command_description: 'Set a new warp with given name'
delwarp_command_description: 'Delete a warp'
editwarp_command_description: 'Edit a warp'
back_command_description: 'Return to your previous position, or where you died'
homelist_command_description: 'Get a list of your homes'
warplist_command_description: 'View the list of warps'
publichomelist_command_description: 'View the list of public homes'
publichome_command_description: 'Teleport to a public home'
tp_command_description: 'Teleport to another player or location'
tphere_command_description: 'Teleport another player to you'
tpa_command_description: 'Request to teleport to another player'
tpahere_command_description: 'Request another player to teleport to you'
tpaccept_command_description: 'Accept a teleport request'
tpdeny_command_description: 'Deny a teleport request'
tpignore_command_description: 'Ignore incoming teleport requests'
tpoffline_command_description: 'Teleport to where a player was last online'
rtp_command_description: 'Teleport randomly into the wild'
spawn_command_description: 'Teleport to spawn'
setspawn_command_description: 'Set the spawn position'
huskhomes_command_description: 'View plugin information & reload configs'
-25
View File
@@ -11,115 +11,90 @@ libraries:
commands:
home:
description: Teleport to one of your homes
usage: /<command> <home>
permission: huskhomes.home
sethome:
description: Set a new home with given name
usage: /<command> <name>
permission: huskhomes.sethome
delhome:
description: Delete a home you previously set
usage: /<command> <name/all>
permission: huskhomes.delhome
edithome:
description: Edit one of your homes
usage: /<command> <home> <rename/description/location/public/private> [arguments]
permission: huskhomes.edithome
warp:
description: Teleport to a warp
usage: /<command> <warp>
permission: huskhomes.warp
setwarp:
description: Set a new warp with given name
usage: /<command> <name>
permission: huskhomes.setwarp
delwarp:
description: Delete a warp
usage: /<command> <name/all>
permission: huskhomes.delwarp
editwarp:
description: Edit a warp
usage: /<command> <warp> <rename/description/location> [arguments]
permission: huskhomes.editwarp
back:
description: Return to your previous position, or where you died
usage: /<command>
permission: huskhomes.back
homelist:
description: Get a list of your homes
usage: /<command> <page>
permission: huskhomes.home
aliases: [homes, listhomes]
warplist:
description: View the list of warps
usage: /<command> <page>
permission: huskhomes.warp
aliases: [warps, listwarps]
publichomelist:
description: View the list of public homes
usage: /<command> <page>
permission: huskhomes.publichome
aliases: [phomes, phomelist, listphomes, listpublichomes]
publichome:
description: Teleport to a public home
usage: /<command> <owner.home>
permission: huskhomes.publichome
aliases: [phome]
tp:
description: Teleport to another player or location
usage: /<command> <player/coordinates>
permission: huskhomes.tp
aliases: [tpo]
tphere:
description: Teleport another player to you
usage: /<command> <player>
permission: huskhomes.tphere
aliases: [tpohere]
tpa:
description: Request to teleport to another player
usage: /<command> <player>
permission: huskhomes.tpa
aliases: [tprequest, tpask]
tpahere:
description: Request another player to teleport to you
usage: /<command> <player>
permission: huskhomes.tpahere
aliases: [tphererequest, tpaskhere]
tpaccept:
description: Accept a teleport request
usage: /<command> [player]
permission: huskhomes.tpaccept
aliases: [tpyes]
tpdeny:
description: Deny a teleport request
usage: /<command> [player]
permission: huskhomes.tpdeny
aliases: [tpno]
tpignore:
description: Ignore incoming teleport requests
usage: /<command>
permission: huskhomes.tpignore
aliases: [tpaignore, ignoretprequests]
tpoffline:
description: Teleport to where a player was last online
usage: /<command> <player>
permission: huskhomes.tpoffline
rtp:
description: Teleport randomly into the wild
usage: /<command>
permission: huskhomes.rtp
aliases: [randomtp, randomteleport, wild]
spawn:
description: Teleport to spawn
usage: /<command>
permission: huskhomes.spawn
setspawn:
description: Set the spawn position
usage: /<command>
permission: huskhomes.spawn.set
huskhomes:
description: Plugin information & reload configs.
usage: /<command> <about/update/reload/migrate>
permissions: