mirror of
https://github.com/aikar/commands.git
synced 2026-05-31 06:11:55 +00:00
fix the format API's and add setFormat(type, i, color)
This commit is contained in:
@@ -106,17 +106,26 @@ public class BukkitCommandManager extends CommandManager {
|
||||
return this.plugin;
|
||||
}
|
||||
|
||||
public BukkitMessageFormatter setFormat(MessageType type, BukkitMessageFormatter formatter) {
|
||||
return (BukkitMessageFormatter) formatters.put(type, formatter);
|
||||
}
|
||||
|
||||
public BukkitMessageFormatter getFormat(MessageType type) {
|
||||
return (BukkitMessageFormatter) formatters.getOrDefault(type, defaultFormatter);
|
||||
}
|
||||
|
||||
public void setFormat(MessageType type, ChatColor... colors) {
|
||||
MessageFormatter format = getFormat(type);
|
||||
if (format instanceof BukkitMessageFormatter) {
|
||||
for (int i = 0; i < colors.length; i++) {
|
||||
((BukkitMessageFormatter) format).setColor(i, colors[i]);
|
||||
}
|
||||
} else {
|
||||
setFormat(type, new BukkitMessageFormatter(colors));
|
||||
BukkitMessageFormatter format = getFormat(type);
|
||||
for (int i = 0; i < colors.length; i++) {
|
||||
format.setColor(i, colors[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void setFormat(MessageType type, int i, ChatColor color) {
|
||||
BukkitMessageFormatter format = getFormat(type);
|
||||
format.setColor(i, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandIssuer(Class<?> type) {
|
||||
return CommandSender.class.isAssignableFrom(type);
|
||||
|
||||
@@ -58,17 +58,26 @@ public class BungeeCommandManager extends CommandManager {
|
||||
return this.plugin;
|
||||
}
|
||||
|
||||
public BungeeMessageFormatter setFormat(MessageType type, BungeeMessageFormatter formatter) {
|
||||
return (BungeeMessageFormatter) formatters.put(type, formatter);
|
||||
}
|
||||
|
||||
public BungeeMessageFormatter getFormat(MessageType type) {
|
||||
return (BungeeMessageFormatter) formatters.getOrDefault(type, defaultFormatter);
|
||||
}
|
||||
|
||||
public void setFormat(MessageType type, ChatColor... colors) {
|
||||
MessageFormatter format = getFormat(type);
|
||||
if (format instanceof BungeeMessageFormatter) {
|
||||
for (int i = 0; i < colors.length; i++) {
|
||||
((BungeeMessageFormatter) format).setColor(i, colors[i]);
|
||||
}
|
||||
} else {
|
||||
setFormat(type, new BungeeMessageFormatter(colors));
|
||||
BungeeMessageFormatter format = getFormat(type);
|
||||
for (int i = 0; i < colors.length; i++) {
|
||||
format.setColor(i, colors[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void setFormat(MessageType type, int i, ChatColor color) {
|
||||
BungeeMessageFormatter format = getFormat(type);
|
||||
format.setColor(i, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized CommandContexts<BungeeCommandExecutionContext> getCommandContexts() {
|
||||
if (this.contexts == null) {
|
||||
|
||||
@@ -166,22 +166,6 @@ public abstract class CommandManager {
|
||||
return result;
|
||||
}
|
||||
|
||||
public MessageFormatter setFormat(MessageType type, MessageFormatter formatter) {
|
||||
return formatters.put(type, formatter);
|
||||
}
|
||||
|
||||
public MessageFormatter getFormat(MessageType type) {
|
||||
return formatters.get(type);
|
||||
}
|
||||
|
||||
public MessageFormatter getDefaultFormatter() {
|
||||
return defaultFormatter;
|
||||
}
|
||||
|
||||
public void setDefaultFormatter(MessageFormatter defaultFormatter) {
|
||||
this.defaultFormatter = defaultFormatter;
|
||||
}
|
||||
|
||||
public void sendMessage(Object issuerArg, MessageType type, MessageKeyProvider key, String... replacements) {
|
||||
sendMessage(issuerArg, type, key.getMessageKey(), replacements);
|
||||
}
|
||||
|
||||
@@ -65,17 +65,26 @@ public class SpongeCommandManager extends CommandManager {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public SpongeMessageFormatter setFormat(MessageType type, SpongeMessageFormatter formatter) {
|
||||
return (SpongeMessageFormatter) formatters.put(type, formatter);
|
||||
}
|
||||
|
||||
public SpongeMessageFormatter getFormat(MessageType type) {
|
||||
return (SpongeMessageFormatter) formatters.getOrDefault(type, defaultFormatter);
|
||||
}
|
||||
|
||||
public void setFormat(MessageType type, TextColor... colors) {
|
||||
MessageFormatter format = getFormat(type);
|
||||
if (format instanceof SpongeMessageFormatter) {
|
||||
for (int i = 0; i < colors.length; i++) {
|
||||
((SpongeMessageFormatter) format).setColor(i, colors[i]);
|
||||
}
|
||||
} else {
|
||||
setFormat(type, new SpongeMessageFormatter(colors));
|
||||
SpongeMessageFormatter format = getFormat(type);
|
||||
for (int i = 0; i < colors.length; i++) {
|
||||
format.setColor(i, colors[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void setFormat(MessageType type, int i, TextColor color) {
|
||||
SpongeMessageFormatter format = getFormat(type);
|
||||
format.setColor(i, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandIssuer(Class<?> type) {
|
||||
return CommandSource.class.isAssignableFrom(type);
|
||||
|
||||
Reference in New Issue
Block a user