mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 15:16:45 +01:00
Revert back to ugly-alias in PlayerCommandPreprocessEvent for /skillname
commands.
This commit is contained in:
parent
7a0f8ea2dd
commit
9326921e2a
@ -47,9 +47,6 @@ public final class CommandRegistrationHelper {
|
||||
String commandName = skill.toString().toLowerCase();
|
||||
String localizedName = LocaleLoader.getString(Misc.getCapitalized(commandName) + ".SkillName").toLowerCase();
|
||||
|
||||
List<String> aliasList = new ArrayList<String>();
|
||||
aliasList.add(localizedName);
|
||||
|
||||
PluginCommand command;
|
||||
|
||||
// Make us play nice with Essentials
|
||||
@ -60,7 +57,6 @@ public final class CommandRegistrationHelper {
|
||||
command = mcMMO.p.getCommand(commandName);
|
||||
}
|
||||
|
||||
command.setAliases(aliasList);
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.Skill", Misc.getCapitalized(localizedName)));
|
||||
command.setPermission("mcmmo.commands." + commandName);
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
@ -347,4 +348,32 @@ public class PlayerListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle "ugly" aliasing /skillname commands, since setAliases doesn't work.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
if (!Config.getInstance().getLocale().equalsIgnoreCase("en_US")) {
|
||||
String message = event.getMessage();
|
||||
String command = message.substring(1).split(" ")[0];
|
||||
String lowerCaseCommand = command.toLowerCase();
|
||||
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
String commandName = skill.toString().toLowerCase();
|
||||
String localizedName = LocaleLoader.getString(Misc.getCapitalized(commandName) + ".SkillName").toLowerCase();
|
||||
|
||||
if (lowerCaseCommand.equals(localizedName)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (lowerCaseCommand.equals(commandName)) {
|
||||
event.setMessage(message.replace(command, localizedName));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user