use of org.bukkit.ChatColor in project BKCommonLib by bergerhealer.
the class TemplateTest method testChatColor.
private static void testChatColor(ChatColor expectedColor, int expectedIndex) {
String token = Character.toString(StringUtil.CHAT_STYLE_CHAR) + Character.toString(expectedColor.getChar());
Object nmsEnumChatFormat = HandleConversion.chatColorToEnumChatFormatHandle(expectedColor);
assertNotNull(nmsEnumChatFormat);
assertEquals(token, nmsEnumChatFormat.toString());
ChatColor color = WrapperConversion.chatColorFromEnumChatFormatHandle(nmsEnumChatFormat);
assertNotNull(color);
assertEquals(expectedColor, color);
int index = HandleConversion.chatColorToEnumChatFormatIndex(expectedColor);
assertEquals(expectedIndex, index);
color = WrapperConversion.chatColorFromEnumChatFormatIndex(index);
assertNotNull(color);
assertEquals(expectedColor, color);
}
use of org.bukkit.ChatColor in project DiamondKing-AIB by Zedo-Corp.
the class AIBScoreboard method playersAmount.
public static void playersAmount(int amount, boolean join) {
int change = join ? -1 : 1;
List<UUID> set = new ArrayList<UUID>(players.keySet());
Game game;
for (UUID u : set) {
game = players.get(u).getGame();
if (game.getState() == "starting") {
ChatColor c;
Lambda reset = (ChatColor color) -> getByPlayer(Bukkit.getPlayer(u)).scoreboard.resetScores(Props.MESSAGE_SCOREBOARD_PLAYERS.toString().replace("#", String.valueOf(amount + change)).replace("%c%", color.toString()));
if (amount < 4) {
c = ChatColor.RED;
reset.playersAmount(c);
} else if (amount == 4) {
c = ChatColor.YELLOW;
reset.playersAmount(ChatColor.RED);
} else {
c = ChatColor.GREEN;
reset.playersAmount(ChatColor.YELLOW);
}
getByPlayer(Bukkit.getPlayer(u)).setSlot(-3, (Props.MESSAGE_SCOREBOARD_PLAYERS.toString().replace("#", String.valueOf(amount))).replace("%c%", c.toString()));
} else if (game.getState() == "started") {
}
}
}
use of org.bukkit.ChatColor in project Bukkit_Bungee_PluginLib by GeorgH93.
the class MessageBuilder method style.
/**
* Sets the style of the current component.
*
* @param styles The array of styles to apply to the current component.
* @return The message builder instance (for chaining).
* @deprecated Use {@link at.pcgamingfreaks.Message.MessageBuilder#format(MessageFormat...)} or {@link at.pcgamingfreaks.Message.MessageBuilder#color(MessageColor)} instead!
*/
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "1.0.40")
public MessageBuilder style(ChatColor... styles) {
for (ChatColor style : styles) {
if (style == ChatColor.RESET) {
color(MessageColor.RESET);
format(MessageFormat.RESET);
} else if (style.isColor())
color(style);
else
format(style);
}
return this;
}
use of org.bukkit.ChatColor in project PvPManager by ChanceSD.
the class TeamProfile method setupTeams.
private void setupTeams() {
final String id = "PVP-" + pvPlayer.getUUID().toString().replaceAll("-", "").substring(0, 12);
if (Settings.isUseCombatTeam()) {
if (scoreboard.getTeam(id) != null) {
inCombat = scoreboard.getTeam(id);
} else {
inCombat = scoreboard.registerNewTeam(id);
if (Settings.isUseNameTag()) {
inCombat.setPrefix(ChatColor.translateAlternateColorCodes('&', Settings.getNameTagColor()));
}
if (Settings.getTeamColor() != null) {
inCombat.setColor(Settings.getTeamColor());
}
}
}
if (Settings.isToggleNametagsEnabled()) {
if (!Settings.getToggleColorOn().equalsIgnoreCase("none")) {
if (scoreboard.getTeam("PvPOn") != null) {
pvpOn = scoreboard.getTeam("PvPOn");
} else {
pvpOn = scoreboard.registerNewTeam("PvPOn");
pvpOn.setCanSeeFriendlyInvisibles(false);
final String pvpOnPrefix = ChatColor.translateAlternateColorCodes('&', Settings.getToggleColorOn());
pvpOn.setPrefix(pvpOnPrefix);
if (CombatUtils.isVersionAtLeast(Settings.getMinecraftVersion(), "1.13")) {
final ChatColor nameColor = getLastColor(pvpOnPrefix);
if (nameColor != null) {
pvpOn.setColor(nameColor);
}
}
}
}
if (!Settings.getToggleColorOff().equalsIgnoreCase("none")) {
if (scoreboard.getTeam("PvPOff") != null) {
pvpOff = scoreboard.getTeam("PvPOff");
} else {
pvpOff = scoreboard.registerNewTeam("PvPOff");
pvpOff.setCanSeeFriendlyInvisibles(false);
final String pvpOffPrefix = ChatColor.translateAlternateColorCodes('&', Settings.getToggleColorOff());
pvpOff.setPrefix(pvpOffPrefix);
if (CombatUtils.isVersionAtLeast(Settings.getMinecraftVersion(), "1.13")) {
final ChatColor nameColor = getLastColor(pvpOffPrefix);
if (nameColor != null) {
pvpOff.setColor(nameColor);
}
}
}
}
// set pvp tag if player has pvp nametags on
setPvP(pvPlayer.hasPvPEnabled());
}
}
use of org.bukkit.ChatColor in project Citizens2 by CitizensDev.
the class NPCCommands method glowing.
@Command(aliases = { "npc" }, usage = "glowing --color [minecraft chat color]", desc = "Toggles an NPC's glowing status", modifiers = { "glowing" }, min = 1, max = 1, permission = "citizens.npc.glowing")
@Requirements(selected = true, ownership = true)
public void glowing(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
if (args.hasValueFlag("color")) {
ChatColor chatColor = Util.matchEnum(ChatColor.values(), args.getFlag("color"));
npc.getOrAddTrait(ScoreboardTrait.class).setColor(chatColor);
if (!npc.data().has(NPC.Metadata.GLOWING)) {
npc.data().setPersistent(NPC.Metadata.GLOWING, true);
}
Messaging.sendTr(sender, Messages.GLOWING_COLOR_SET, npc.getName(), chatColor == null ? ChatColor.WHITE + "white" : chatColor + Util.prettyEnum(chatColor));
return;
}
npc.data().setPersistent(NPC.Metadata.GLOWING, !npc.data().get(NPC.Metadata.GLOWING, false));
boolean glowing = npc.data().get(NPC.Metadata.GLOWING);
Messaging.sendTr(sender, glowing ? Messages.GLOWING_SET : Messages.GLOWING_UNSET, npc.getName());
}
Aggregations