use of org.bukkit.ChatColor in project Essentials by EssentialsX.
the class Commandgc method run.
@Override
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
final double tps = ess.getTimer().getAverageTPS();
final ChatColor color;
if (tps >= 18.0) {
color = ChatColor.GREEN;
} else if (tps >= 15.0) {
color = ChatColor.YELLOW;
} else {
color = ChatColor.RED;
}
sender.sendMessage(tl("uptime", DateUtil.formatDateDiff(ManagementFactory.getRuntimeMXBean().getStartTime())));
sender.sendMessage(tl("tps", "" + color + NumberUtil.formatDouble(tps)));
sender.sendMessage(tl("gcmax", Runtime.getRuntime().maxMemory() / 1024 / 1024));
sender.sendMessage(tl("gctotal", Runtime.getRuntime().totalMemory() / 1024 / 1024));
sender.sendMessage(tl("gcfree", Runtime.getRuntime().freeMemory() / 1024 / 1024));
final List<World> worlds = server.getWorlds();
for (final World w : worlds) {
String worldType = "World";
switch(w.getEnvironment()) {
case NETHER:
worldType = "Nether";
break;
case THE_END:
worldType = "The End";
break;
}
int tileEntities = 0;
try {
for (final Chunk chunk : w.getLoadedChunks()) {
tileEntities += chunk.getTileEntities().length;
}
} catch (final java.lang.ClassCastException ex) {
Bukkit.getLogger().log(Level.SEVERE, "Corrupted chunk data on world " + w, ex);
}
sender.sendMessage(tl("gcWorld", worldType, w.getName(), w.getLoadedChunks().length, w.getEntities().size(), tileEntities));
}
}
use of org.bukkit.ChatColor in project Essentials by EssentialsX.
the class Settings method _getOperatorColor.
private String _getOperatorColor() {
final String colorName = config.getString("ops-name-color", null);
if (colorName == null) {
return ChatColor.RED.toString();
} else if (colorName.equalsIgnoreCase("none") || colorName.isEmpty()) {
return null;
}
try {
return FormatUtil.parseHexColor(colorName);
} catch (final NumberFormatException ignored) {
}
try {
return ChatColor.valueOf(colorName.toUpperCase(Locale.ENGLISH)).toString();
} catch (final IllegalArgumentException ignored) {
}
final ChatColor lastResort = ChatColor.getByChar(colorName);
if (lastResort != null) {
return lastResort.toString();
}
return null;
}
use of org.bukkit.ChatColor in project Essentials by EssentialsX.
the class FormatUtil method stripColor.
static String stripColor(final String input, final Set<ChatColor> strip) {
final StringBuffer builder = new StringBuffer();
final Matcher matcher = STRIP_ALL_PATTERN.matcher(input);
searchLoop: while (matcher.find()) {
final char code = matcher.group(1).toLowerCase(Locale.ROOT).charAt(0);
for (final ChatColor color : strip) {
if (color.getChar() == code) {
matcher.appendReplacement(builder, "");
continue searchLoop;
}
}
// Don't replace
matcher.appendReplacement(builder, "$0");
}
matcher.appendTail(builder);
return builder.toString();
}
use of org.bukkit.ChatColor in project VoxelGamesLibv2 by VoxelGamesLib.
the class TeamSelectFeature method enable.
@Override
public void enable() {
// create default teams
List<String> teamNames = new ArrayList<>();
teamNames.add("BLUE");
teamNames.add("RED");
teamNames.add("GREEN");
teamNames.add("YELLOW");
teamNames.add("LIGHT_PURPLE");
teamNames.add("BLACK");
List<ChatColor> teamColors = new ArrayList<>();
teamColors.add(ChatColor.BLUE);
teamColors.add(ChatColor.RED);
teamColors.add(ChatColor.GREEN);
teamColors.add(ChatColor.YELLOW);
teamColors.add(ChatColor.LIGHT_PURPLE);
teamColors.add(ChatColor.BLACK);
for (int i = 0; i < teamCount; i++) {
teams.add(new Team(teamSize, teamNames.get(i), teamColors.get(i), getPhase().getGame()));
}
}
use of org.bukkit.ChatColor in project Essentials by drtshock.
the class FormatUtil method getSupported.
private static EnumSet<ChatColor> getSupported(final IUser user, final String permBase) {
final EnumSet<ChatColor> supported = EnumSet.noneOf(ChatColor.class);
if (user.isAuthorized(permBase + ".color")) {
supported.addAll(COLORS);
}
if (user.isAuthorized(permBase + ".format")) {
supported.addAll(FORMATS);
}
if (user.isAuthorized(permBase + ".magic")) {
supported.addAll(MAGIC);
}
for (final ChatColor chatColor : ChatColor.values()) {
String colorName = chatColor.name();
if (chatColor == ChatColor.MAGIC) {
// Bukkit's name doesn't match with vanilla's
colorName = "obfuscated";
}
final String node = permBase + "." + colorName.toLowerCase(Locale.ROOT);
// Only handle individual colors that are explicitly added or removed.
if (!user.isPermissionSet(node)) {
continue;
}
if (user.isAuthorized(node)) {
supported.add(chatColor);
} else {
supported.remove(chatColor);
}
}
return supported;
}
Aggregations