geforkt von Mirrors/FastAsyncWorldEdit
When sorting commands for //help, ignore / characters.
Dieser Commit ist enthalten in:
Ursprung
75b1fe6090
Commit
2effc57b78
@ -35,6 +35,7 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.CommandManager;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
import com.sk89q.worldedit.patterns.SingleBlockPattern;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
@ -44,12 +45,12 @@ import com.sk89q.worldedit.util.command.CommandMapping;
|
||||
import com.sk89q.worldedit.util.command.Dispatcher;
|
||||
import com.sk89q.worldedit.util.command.PrimaryAliasComparator;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
import com.sk89q.worldedit.util.formatting.components.Code;
|
||||
import com.sk89q.worldedit.util.formatting.ColorCodeBuilder;
|
||||
import com.sk89q.worldedit.util.formatting.components.CommandListBox;
|
||||
import com.sk89q.worldedit.util.formatting.components.CommandUsageBox;
|
||||
import com.sk89q.worldedit.util.formatting.Style;
|
||||
import com.sk89q.worldedit.util.formatting.StyledFragment;
|
||||
import com.sk89q.worldedit.util.formatting.components.Code;
|
||||
import com.sk89q.worldedit.util.formatting.components.CommandListBox;
|
||||
import com.sk89q.worldedit.util.formatting.components.CommandUsageBox;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -606,7 +607,7 @@ public class UtilityCommands {
|
||||
|
||||
// Get a list of aliases
|
||||
List<CommandMapping> aliases = new ArrayList<CommandMapping>(dispatcher.getCommands());
|
||||
Collections.sort(aliases, PrimaryAliasComparator.INSTANCE);
|
||||
Collections.sort(aliases, new PrimaryAliasComparator(CommandManager.COMMAND_CLEAN_PATTERN));
|
||||
|
||||
// Calculate pagination
|
||||
int offset = perPage * page;
|
||||
|
@ -52,6 +52,7 @@ import java.io.IOException;
|
||||
import java.util.logging.FileHandler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@ -62,6 +63,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*/
|
||||
public final class CommandManager {
|
||||
|
||||
public static final Pattern COMMAND_CLEAN_PATTERN = Pattern.compile("^[/]+");
|
||||
private static final Logger logger = Logger.getLogger(CommandManager.class.getCanonicalName());
|
||||
private static final java.util.regex.Pattern numberFormatExceptionPattern = java.util.regex.Pattern.compile("^For input string: \"(.*)\"$");
|
||||
|
||||
|
@ -19,7 +19,9 @@
|
||||
|
||||
package com.sk89q.worldedit.util.command;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Comparator;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Compares the primary aliases of two {@link CommandMapping} using
|
||||
@ -30,14 +32,28 @@ public final class PrimaryAliasComparator implements Comparator<CommandMapping>
|
||||
/**
|
||||
* An instance of this class.
|
||||
*/
|
||||
public static final PrimaryAliasComparator INSTANCE = new PrimaryAliasComparator();
|
||||
public static final PrimaryAliasComparator INSTANCE = new PrimaryAliasComparator(null);
|
||||
private final @Nullable Pattern removalPattern;
|
||||
|
||||
private PrimaryAliasComparator() {
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param removalPattern a regex to remove unwanted characters from the compared aliases
|
||||
*/
|
||||
public PrimaryAliasComparator(@Nullable Pattern removalPattern) {
|
||||
this.removalPattern = removalPattern;
|
||||
}
|
||||
|
||||
private String clean(String alias) {
|
||||
if (removalPattern != null) {
|
||||
return removalPattern.matcher(alias).replaceAll("");
|
||||
}
|
||||
return alias;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(CommandMapping o1, CommandMapping o2) {
|
||||
return o1.getPrimaryAlias().compareTo(o2.getPrimaryAlias());
|
||||
return clean(o1.getPrimaryAlias()).compareTo(clean(o2.getPrimaryAlias()));
|
||||
}
|
||||
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren