Search in sources :

Example 81 with ChatColor

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);
}
Also used : ChatColor(org.bukkit.ChatColor)

Example 82 with ChatColor

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") {
        }
    }
}
Also used : Game(fr.zedocorp.aib.game.Game) ArrayList(java.util.ArrayList) UUID(java.util.UUID) ChatColor(org.bukkit.ChatColor)

Example 83 with ChatColor

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;
}
Also used : ChatColor(org.bukkit.ChatColor)

Example 84 with ChatColor

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());
    }
}
Also used : ChatColor(org.bukkit.ChatColor)

Example 85 with ChatColor

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());
}
Also used : ScoreboardTrait(net.citizensnpcs.trait.ScoreboardTrait) ChatColor(org.bukkit.ChatColor) Command(net.citizensnpcs.api.command.Command) Requirements(net.citizensnpcs.api.command.Requirements)

Aggregations

ChatColor (org.bukkit.ChatColor)182 ArrayList (java.util.ArrayList)34 Player (org.bukkit.entity.Player)31 World (org.bukkit.World)12 Team (org.bukkit.scoreboard.Team)11 Matcher (java.util.regex.Matcher)10 ItemStack (org.bukkit.inventory.ItemStack)10 List (java.util.List)9 JSONObject (org.json.simple.JSONObject)9 ConfigurationSection (org.bukkit.configuration.ConfigurationSection)8 DyeColor (org.bukkit.DyeColor)7 Material (org.bukkit.Material)7 ItemMeta (org.bukkit.inventory.meta.ItemMeta)7 HashMap (java.util.HashMap)6 Scoreboard (org.bukkit.scoreboard.Scoreboard)6 IOException (java.io.IOException)4 DecimalFormat (java.text.DecimalFormat)4 UUID (java.util.UUID)4 OfflinePlayer (org.bukkit.OfflinePlayer)4 Score (org.bukkit.scoreboard.Score)4