mirror of
https://github.com/aikar/commands.git
synced 2026-06-20 22:10:38 +00:00
Massive i18n work, not fully finished set but resolves #53
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
|
||||
package co.aikar.commands;
|
||||
|
||||
import co.aikar.locales.MessageKey;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
@@ -38,6 +39,12 @@ public class ACFBungeeUtil {
|
||||
return ChatColor.translateAlternateColorCodes('&', message);
|
||||
}
|
||||
|
||||
public static void sendMsg(CommandIssuer issuer, MessageKey key, String... replacements) {
|
||||
sendMsg(issuer, MessageType.INFO, key, replacements);
|
||||
}
|
||||
public static void sendMsg(CommandIssuer issuer, MessageType type, MessageKey key, String... replacements) {
|
||||
issuer.sendMessage(type, key, replacements);
|
||||
}
|
||||
public static void sendMsg(CommandSender player, String message) {
|
||||
message = color(message);
|
||||
for (String msg : ACFPatterns.NEWLINE.split(message)) {
|
||||
|
||||
@@ -44,7 +44,8 @@ public class BungeeCommandContexts extends CommandContexts<BungeeCommandExecutio
|
||||
if (c.hasAnnotation(Optional.class)) {
|
||||
return null;
|
||||
}
|
||||
ACFBungeeUtil.sendMsg(c.getSender(), "§cCould not find a player by the name " + playercheck);
|
||||
c.getIssuer().sendMessage(MessageType.ERROR, MessageKeys.COULD_NOT_FIND_PLAYER,
|
||||
"{search}", playercheck);
|
||||
throw new InvalidCommandArgument(false);
|
||||
}
|
||||
return new OnlineProxiedPlayer(proxiedPlayer);
|
||||
@@ -53,7 +54,7 @@ public class BungeeCommandContexts extends CommandContexts<BungeeCommandExecutio
|
||||
registerSenderAwareContext(ProxiedPlayer.class, (c) -> {
|
||||
ProxiedPlayer proxiedPlayer = c.getSender() instanceof ProxiedPlayer ? (ProxiedPlayer) c.getSender() : null;
|
||||
if (proxiedPlayer == null && !c.hasAnnotation(Optional.class)) {
|
||||
throw new InvalidCommandArgument("Requires a player to run this command", false);
|
||||
throw new InvalidCommandArgument(MessageKeys.NOT_ALLOWED_ON_CONSOLE, false);
|
||||
}
|
||||
return proxiedPlayer;
|
||||
});
|
||||
@@ -74,9 +75,9 @@ public class BungeeCommandContexts extends CommandContexts<BungeeCommandExecutio
|
||||
if (match == null) {
|
||||
String valid = colors
|
||||
.map(color -> ChatColor.YELLOW + ACFUtil.simplifyString(color.name()))
|
||||
.collect(Collectors.joining("&c, "));
|
||||
.collect(Collectors.joining("<c2>,</c2> "));
|
||||
|
||||
throw new InvalidCommandArgument("Please specify one of: " + valid);
|
||||
throw new InvalidCommandArgument(MessageKeys.PLEASE_SPECIFY_ONE_OF, "{valid}", valid);
|
||||
}
|
||||
return match;
|
||||
});
|
||||
|
||||
@@ -29,9 +29,9 @@ import java.lang.reflect.Parameter;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class BungeeCommandExecutionContext extends CommandExecutionContext<BungeeCommandExecutionContext> {
|
||||
public class BungeeCommandExecutionContext extends CommandExecutionContext<BungeeCommandExecutionContext, BungeeCommandIssuer> {
|
||||
|
||||
BungeeCommandExecutionContext(RegisteredCommand cmd, Parameter param, CommandIssuer sender, List<String> args, int index, Map<String, Object> passedArgs) {
|
||||
BungeeCommandExecutionContext(RegisteredCommand cmd, Parameter param, BungeeCommandIssuer sender, List<String> args, int index, Map<String, Object> passedArgs) {
|
||||
super(cmd, param, sender, args, index, passedArgs);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Parameter;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -47,6 +48,7 @@ public class BungeeCommandManager extends CommandManager {
|
||||
|
||||
public BungeeCommandManager(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.locales.addMessageBundle("acf-minecraft", Locale.ENGLISH);
|
||||
this.formatters.put(MessageType.ERROR, new BungeeMessageFormatter(ChatColor.RED, ChatColor.YELLOW, ChatColor.RED));
|
||||
this.formatters.put(MessageType.SYNTAX, new BungeeMessageFormatter(ChatColor.YELLOW, ChatColor.GREEN, ChatColor.WHITE));
|
||||
this.formatters.put(MessageType.INFO, new BungeeMessageFormatter(ChatColor.BLUE, ChatColor.DARK_GREEN, ChatColor.GREEN));
|
||||
@@ -112,7 +114,7 @@ public class BungeeCommandManager extends CommandManager {
|
||||
@Override
|
||||
public <R extends CommandExecutionContext> R createCommandContext(RegisteredCommand command, Parameter parameter, CommandIssuer sender, List<String> args, int i, Map<String, Object> passedArgs) {
|
||||
//noinspection unchecked
|
||||
return (R) new BungeeCommandExecutionContext(command, parameter, sender, args, i, passedArgs);
|
||||
return (R) new BungeeCommandExecutionContext(command, parameter, (BungeeCommandIssuer) sender, args, i, passedArgs);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user