mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Fixed /<skill> command being processed twice when an alias was used
This commit is contained in:
parent
112a0df8c2
commit
68b9857409
@ -341,9 +341,6 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dynamically aliasing commands need to be re-done.
|
|
||||||
// For now, using a command with an alias will send both the original command, and the mcMMO command
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitor PlayerCommandPreprocess events.
|
* Monitor PlayerCommandPreprocess events.
|
||||||
*
|
*
|
||||||
@ -352,18 +349,15 @@ public class PlayerListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||||
String message = event.getMessage();
|
String message = event.getMessage();
|
||||||
|
|
||||||
if (!message.startsWith("/")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String command = message.substring(1).split(" ")[0];
|
String command = message.substring(1).split(" ")[0];
|
||||||
|
|
||||||
if (plugin.aliasMap.containsKey(command)) {
|
if (plugin.aliasMap.containsKey(command.toLowerCase())) {
|
||||||
if (command.equalsIgnoreCase(plugin.aliasMap.get(command))) {
|
//We should find a better way to avoid string replacement where the alias is equals to the command
|
||||||
|
if (command.equals(plugin.aliasMap.get(command.toLowerCase()))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
event.getPlayer().chat(message.replaceFirst(command, plugin.aliasMap.get(command)));
|
|
||||||
|
event.setMessage(message.replace(command, plugin.aliasMap.get(command.toLowerCase())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
aliasMap.put(LocaleLoader.getString("Swords.SkillName").toLowerCase(), "swords");
|
aliasMap.put(LocaleLoader.getString("Swords.SkillName").toLowerCase(), "swords");
|
||||||
aliasMap.put(LocaleLoader.getString("Taming.SkillName").toLowerCase(), "taming");
|
aliasMap.put(LocaleLoader.getString("Taming.SkillName").toLowerCase(), "taming");
|
||||||
aliasMap.put(LocaleLoader.getString("Unarmed.SkillName").toLowerCase(), "unarmed");
|
aliasMap.put(LocaleLoader.getString("Unarmed.SkillName").toLowerCase(), "unarmed");
|
||||||
aliasMap.put(LocaleLoader.getString("WoodCutting.SkillName").toLowerCase(), "woodcutting");
|
aliasMap.put(LocaleLoader.getString("Woodcutting.SkillName").toLowerCase(), "woodcutting");
|
||||||
|
|
||||||
//Register commands
|
//Register commands
|
||||||
//Skills commands
|
//Skills commands
|
||||||
|
Loading…
Reference in New Issue
Block a user