add setFormat API's

This commit is contained in:
Aikar
2017-07-17 23:57:04 -04:00
parent eec47ea701
commit 9ee590026f
4 changed files with 39 additions and 1 deletions
@@ -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);