geforkt von Mirrors/Paper
[Bleeding] Add direct addresses for command aliases.
By: t00thpick1 <t00thpick1dirko@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
71ae039e05
Commit
8ea6ca64d1
@ -102,12 +102,11 @@ public class SimpleCommandMap implements CommandMap {
|
|||||||
public boolean register(String label, String fallbackPrefix, Command command) {
|
public boolean register(String label, String fallbackPrefix, Command command) {
|
||||||
label = label.toLowerCase().trim();
|
label = label.toLowerCase().trim();
|
||||||
fallbackPrefix = fallbackPrefix.toLowerCase().trim();
|
fallbackPrefix = fallbackPrefix.toLowerCase().trim();
|
||||||
boolean registered = register(label, command, false);
|
boolean registered = register(label, command, false, fallbackPrefix);
|
||||||
knownCommands.put(fallbackPrefix + ":" + label, command);
|
|
||||||
|
|
||||||
Iterator<String> iterator = command.getAliases().iterator();
|
Iterator<String> iterator = command.getAliases().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
if (!register(iterator.next(), command, true)) {
|
if (!register(iterator.next(), command, true, fallbackPrefix)) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,13 +123,18 @@ public class SimpleCommandMap implements CommandMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a command with the given name is possible.
|
* Registers a command with the given name is possible. Also uses
|
||||||
|
* fallbackPrefix to create a unique name.
|
||||||
*
|
*
|
||||||
* @param label the name of the command, without the '/'-prefix.
|
* @param label the name of the command, without the '/'-prefix.
|
||||||
* @param command the command to register
|
* @param command the command to register
|
||||||
|
* @param isAlias whether the command is an alias
|
||||||
|
* @param fallbackPrefix a prefix which is prepended to the command for a
|
||||||
|
* unique address
|
||||||
* @return true if command was registered, false otherwise.
|
* @return true if command was registered, false otherwise.
|
||||||
*/
|
*/
|
||||||
private synchronized boolean register(String label, Command command, boolean isAlias) {
|
private synchronized boolean register(String label, Command command, boolean isAlias, String fallbackPrefix) {
|
||||||
|
knownCommands.put(fallbackPrefix + ":" + label, command);
|
||||||
if ((command instanceof VanillaCommand || isAlias) && knownCommands.containsKey(label)) {
|
if ((command instanceof VanillaCommand || isAlias) && knownCommands.containsKey(label)) {
|
||||||
// Request is for an alias/fallback command and it conflicts with
|
// Request is for an alias/fallback command and it conflicts with
|
||||||
// a existing command or previous alias ignore it
|
// a existing command or previous alias ignore it
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren