mirror of
https://github.com/aikar/commands.git
synced 2026-05-31 06:11:55 +00:00
add setFormat API's
This commit is contained in:
@@ -101,6 +101,17 @@ public class BukkitCommandManager extends CommandManager {
|
||||
return this.plugin;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandIssuer(Class<?> type) {
|
||||
return CommandSender.class.isAssignableFrom(type);
|
||||
|
||||
@@ -57,6 +57,17 @@ public class BungeeCommandManager extends CommandManager {
|
||||
return this.plugin;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized CommandContexts<BungeeCommandExecutionContext> getCommandContexts() {
|
||||
if (this.contexts == null) {
|
||||
|
||||
@@ -167,7 +167,7 @@ public abstract class CommandManager {
|
||||
return result;
|
||||
}
|
||||
|
||||
public MessageFormatter setFormat(MessageType type, MessageFormatter formatter) {
|
||||
public MessageFormatter setFormat(MessageType type, MessageFormatter formatter) {
|
||||
return formatters.put(type, formatter);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.slf4j.Logger;
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.command.CommandSource;
|
||||
import org.spongepowered.api.plugin.PluginContainer;
|
||||
import org.spongepowered.api.text.format.TextColor;
|
||||
import org.spongepowered.api.text.format.TextColors;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
@@ -59,6 +60,21 @@ public class SpongeCommandManager extends CommandManager {
|
||||
this.formatters.put(MessageType.INFO, new SpongeMessageFormatter(TextColors.BLUE, TextColors.DARK_GREEN, TextColors.GREEN));
|
||||
}
|
||||
|
||||
public PluginContainer getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandIssuer(Class<?> type) {
|
||||
return CommandSource.class.isAssignableFrom(type);
|
||||
|
||||
Reference in New Issue
Block a user