mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-11 02:02:04 -07:00
@@ -1,13 +1,8 @@
|
||||
package org.bukkit.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.server.RemoteServerCommandEvent;
|
||||
import org.bukkit.event.server.ServerCommandEvent;
|
||||
|
||||
public class FormattedCommandAlias extends Command {
|
||||
private final String[] formatStrings;
|
||||
@@ -42,13 +37,13 @@ public class FormattedCommandAlias extends Command {
|
||||
}
|
||||
|
||||
private String buildCommand(String formatString, String[] args) {
|
||||
int index = formatString.indexOf("$");
|
||||
int index = formatString.indexOf('$');
|
||||
while (index != -1) {
|
||||
int start = index;
|
||||
|
||||
if (index > 0 && formatString.charAt(start - 1) == '\\') {
|
||||
formatString = formatString.substring(0, start - 1) + formatString.substring(start);
|
||||
index = formatString.indexOf("$", index);
|
||||
index = formatString.indexOf('$', index);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -72,7 +67,7 @@ public class FormattedCommandAlias extends Command {
|
||||
throw new IllegalArgumentException("Invalid replacement token");
|
||||
}
|
||||
|
||||
int position = Integer.valueOf(formatString.substring(argStart, index));
|
||||
int position = Integer.parseInt(formatString.substring(argStart, index));
|
||||
|
||||
// Arguments are not 0 indexed
|
||||
if (position == 0) {
|
||||
@@ -112,7 +107,7 @@ public class FormattedCommandAlias extends Command {
|
||||
index = start + replacement.length();
|
||||
|
||||
// Move to the next replacement token
|
||||
index = formatString.indexOf("$", index);
|
||||
index = formatString.indexOf('$', index);
|
||||
}
|
||||
|
||||
return formatString;
|
||||
|
@@ -225,13 +225,14 @@ public class SimpleCommandMap implements CommandMap {
|
||||
public void registerServerAliases() {
|
||||
Map<String, String[]> values = server.getCommandAliases();
|
||||
|
||||
for (String alias : values.keySet()) {
|
||||
for (Map.Entry<String, String[]> entry : values.entrySet()) {
|
||||
String alias = entry.getKey();
|
||||
if (alias.contains(" ")) {
|
||||
server.getLogger().warning("Could not register alias " + alias + " because it contains illegal characters");
|
||||
continue;
|
||||
}
|
||||
|
||||
String[] commandStrings = values.get(alias);
|
||||
String[] commandStrings = entry.getValue();
|
||||
List<String> targets = new ArrayList<String>();
|
||||
StringBuilder bad = new StringBuilder();
|
||||
|
||||
|
Reference in New Issue
Block a user