Java Code Examples for org.bukkit.ChatColor#BOLD

The following examples show how to use org.bukkit.ChatColor#BOLD . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScoreboardManager.java    From UhcCore with GNU General Public License v3.0 6 votes vote down vote up
public String getScoreboardLine(int line){
    if (line == 0) return ChatColor.UNDERLINE + "" + ChatColor.RESET;
    if (line == 1) return ChatColor.ITALIC + "" + ChatColor.RESET;
    if (line == 2) return ChatColor.BOLD + "" + ChatColor.RESET;
    if (line == 3) return ChatColor.RESET + "" + ChatColor.RESET;
    if (line == 4) return ChatColor.GREEN + "" + ChatColor.RESET;
    if (line == 5) return ChatColor.DARK_GRAY + "" + ChatColor.RESET;
    if (line == 6) return ChatColor.GOLD + "" + ChatColor.RESET;
    if (line == 7) return ChatColor.RED + "" + ChatColor.RESET;
    if (line == 8) return ChatColor.YELLOW + "" + ChatColor.RESET;
    if (line == 9) return ChatColor.WHITE + "" + ChatColor.RESET;
    if (line == 10) return ChatColor.DARK_GREEN + "" + ChatColor.RESET;
    if (line == 11) return ChatColor.BLUE + "" + ChatColor.RESET;
    if (line == 12) return ChatColor.STRIKETHROUGH + "" + ChatColor.RESET;
    if (line == 13) return ChatColor.MAGIC + "" + ChatColor.RESET;
    if (line == 14) return ChatColor.DARK_RED + "" + ChatColor.RESET;
    return null;
}
 
Example 2
Source File: PrefixTest.java    From UHC with MIT License 6 votes vote down vote up
@Test
public void testContainsColoursTwoFormatting() throws Exception {
    Prefix prefix = new Prefix(ChatColor.AQUA, ChatColor.ITALIC, ChatColor.BOLD);

    assertThat(prefix.containsColours(false, ChatColor.AQUA)).isTrue();
    assertThat(prefix.containsColours(true, ChatColor.AQUA)).isFalse();

    assertThat(prefix.containsColours(false, ChatColor.BLUE)).isFalse();
    assertThat(prefix.containsColours(true, ChatColor.BLUE)).isFalse();

    assertThat(prefix.containsColours(false, ChatColor.ITALIC)).isTrue();
    assertThat(prefix.containsColours(true, ChatColor.ITALIC)).isFalse();

    assertThat(prefix.containsColours(false, ChatColor.AQUA, ChatColor.ITALIC)).isTrue();
    assertThat(prefix.containsColours(true, ChatColor.AQUA, ChatColor.ITALIC)).isFalse();

    assertThat(prefix.containsColours(true, ChatColor.BLUE, ChatColor.ITALIC)).isFalse();
    assertThat(prefix.containsColours(true, ChatColor.BLUE, ChatColor.ITALIC)).isFalse();
}
 
Example 3
Source File: Align.java    From CardinalPGM with MIT License 6 votes vote down vote up
/**
 * Returns a dash made out of spaces " " and dashes "-", with the desired len in pixels.
 *
 * @param color color the line should have
 * @param len number of pixels
 * @return A string with the desired length as long as the len is >= 4. Else it returns an empty string.
 */
public static String getDash(ChatColor color, int len) {
    if (len < 4) return "";
    switch (len) {
        case 4:
            return "" + color + ChatColor.STRIKETHROUGH + " ";
        case 5:
            return "" + color + ChatColor.STRIKETHROUGH + ChatColor.BOLD + " ";
        case 6:
            return "" + color + ChatColor.STRIKETHROUGH + "-";
        case 7:
            return "" + color + ChatColor.STRIKETHROUGH + ChatColor.BOLD + "-";
        default:
            if (len % 4 == 0) {
                return "" + color + ChatColor.STRIKETHROUGH + repeat(" ", len / 4);
            } else {
                return "" + color + ChatColor.STRIKETHROUGH + 
                        repeat(" ", (len / 4) - 1) + getDash(color, len % 4 + 4);
            }
    }
}
 
Example 4
Source File: GeneralSection.java    From HeavySpleef with GNU General Public License v3.0 6 votes vote down vote up
public GeneralSection(ConfigurationSection section) {
	String prefix = section.getString("spleef-prefix");
	if (prefix != null) {
		this.spleefPrefix = ChatColor.translateAlternateColorCodes(TRANSLATE_CHAR, prefix);
	} else {
		this.spleefPrefix = ChatColor.DARK_GRAY + "[" + ChatColor.GOLD + ChatColor.BOLD + "Spleef" + ChatColor.DARK_GRAY + "]";
	}
	
	this.whitelistedCommands = section.getStringList("command-whitelist");
	String vipPrefix = section.getString("vip-prefix");
	if (vipPrefix != null) {
		this.vipPrefix = ChatColor.translateAlternateColorCodes(TRANSLATE_CHAR, vipPrefix);
	} else {
		this.vipPrefix = ChatColor.RED.toString();
	}
	
	this.vipJoinFull = section.getBoolean("vip-join-full", true);
	this.pvpTimer = section.getInt("pvp-timer", 0);
	this.broadcastGameStart = section.getBoolean("broadcast-game-start", true);
	this.broadcastGameStartBlacklist = section.getStringList("broadcast-game-start-blacklist");
	this.winMessageToAll = section.getBoolean("win-message-to-all", true);
       this.warmupMode = section.getBoolean("warmup-mode", false);
       this.warmupTime = section.getInt("warmup-time", 10);
       this.adventureMode = section.getBoolean("adventure-mode", true);
}
 
Example 5
Source File: MapPoll.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
public void sendBook(MatchPlayer viewer, boolean forceOpen) {
  String title = ChatColor.GOLD + "" + ChatColor.BOLD;
  title += TextTranslations.translate("vote.title.map", viewer.getBukkit());

  ItemStack is = new ItemStack(Material.WRITTEN_BOOK);
  BookMeta meta = (BookMeta) is.getItemMeta();
  meta.setAuthor("PGM");
  meta.setTitle(title);

  TextComponent.Builder content = TextComponent.builder();
  content.append(TranslatableComponent.of("vote.header.map", TextColor.DARK_PURPLE));
  content.append(TextComponent.of("\n\n"));

  for (MapInfo pgmMap : votes.keySet()) content.append(getMapBookComponent(viewer, pgmMap));

  NMSHacks.setBookPages(
      meta, TextTranslations.toBaseComponent(content.build(), viewer.getBukkit()));
  is.setItemMeta(meta);

  ItemStack held = viewer.getInventory().getItemInHand();
  if (held.getType() != Material.WRITTEN_BOOK
      || !title.equals(((BookMeta) is.getItemMeta()).getTitle())) {
    viewer.getInventory().setHeldItemSlot(2);
  }
  viewer.getInventory().setItemInHand(is);

  if (forceOpen || viewer.getSettings().getValue(SettingKey.VOTE) == SettingValue.VOTE_ON)
    NMSHacks.openBook(is, viewer.getBukkit());
}
 
Example 6
Source File: AttackSpeed.java    From CardinalPGM with MIT License 5 votes vote down vote up
private void sendActionBar(Player player) {
    if (!Settings.getSettingByName("AttackSpeedometer").getValueByPlayer(player).getValue().equalsIgnoreCase("off")) {
        int percent = (int)(player.getAttackCooldownCoefficient() * 100);
        double cps = Math.round((20D / Math.max(1, player.getAttackCooldownTicks())) * 10D);
        String damage = "Damage: " + getColor(percent) + ChatColor.BOLD + percent + "%" + ChatColor.RESET;
        String clicks = "CPS: " + ChatColor.AQUA + ChatColor.BOLD + cps / 10 + ChatColor.RESET + "+  ";
        player.sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(damage + "   " + clicks));
    }
}
 
Example 7
Source File: HeaderModule.java    From CardinalPGM with MIT License 5 votes vote down vote up
public void updateFooter() {
    footer = new UnlocalizedChatMessage(ChatColor.BOLD + message + ChatColor.RESET +
            ChatColor.DARK_GRAY + " - " + ChatColor.GRAY + "{0}: " +
            (GameHandler.getGameHandler().getMatch().isRunning() ? ChatColor.GREEN : ChatColor.GOLD) +
            Strings.formatTime(MatchTimer.getTimeInSeconds()) + ChatColor.DARK_GRAY + " - " +
            ChatColor.WHITE + ChatColor.BOLD + "Cardinal", ChatConstant.UI_TIME.asMessage());
}
 
Example 8
Source File: ScoreboardModule.java    From CardinalPGM with MIT License 5 votes vote down vote up
public String getDisplayTitle() {
    String displayTitle = "";
    boolean hasObjectives = false;
    for (GameObjective obj : GameHandler.getGameHandler().getMatch().getModules().getModules(GameObjective.class)) {
        if (obj.showOnScoreboard()) {
            hasObjectives = true;
        }
    }
    Class objective = getSpecificObjective();
    if (hasObjectives) {
        if (objective != null) {
            if (objective.equals(WoolObjective.class)) {
                displayTitle = "Wools";
            } else if (objective.equals(FlagObjective.class)) {
                displayTitle = "Flags";
            } else if (objective.equals(CoreObjective.class)) {
                displayTitle = "Cores";
            } else if (objective.equals(DestroyableObjective.class)) {
                displayTitle = "Monuments";
            } else if (objective.equals(HillObjective.class)) {
                displayTitle = "Hills";
            }
        } else {
            displayTitle = "Objectives";
        }
    }
    if (ScoreModule.matchHasScoring()) {
        displayTitle = displayTitle.equals("") || displayTitle.equals("Flags")|| displayTitle.equals("Hills") ? "Scores" : "Objectives";
    }
    if (Blitz.matchIsBlitz()) {
        String blitzTitle = GameHandler.getGameHandler().getMatch().getModules().getModule(Blitz.class).getTitle();
        displayTitle = (blitzTitle.equals("Blitz") || blitzTitle.equals("Blitz: Rage")) ? (displayTitle.equals("") ? blitzTitle : "Players Remaining") : blitzTitle;
    }
    if (displayTitle.equals("")) {
        return ChatColor.RED + "" + ChatColor.BOLD + "Invalid";
    }
    return ChatColor.AQUA + displayTitle;
}
 
Example 9
Source File: MapRatingsMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
private static String formatScore(@Nullable Integer score) {
    return score == null ? "" : BUTTON_LABEL_COLORS[score - 1].toString() + ChatColor.BOLD + score;
}
 
Example 10
Source File: CivDiplomacyCommand.java    From civcraft with GNU General Public License v2.0 4 votes vote down vote up
public void capitulate_cmd() throws CivException {
	if (War.isWarTime()) {
		throw new CivException("You cannot use this diplomacy command while it is WarTime.");
	}
	Town town = getNamedTown(1);
	Resident resident = getResident();
	boolean entireCiv = false;
	
	Civilization motherCiv = town.getMotherCiv();
	
	if (motherCiv == null) {
		throw new CivException("Cannot capitulate unless captured by another civilization.");
	}
	
	if (!town.getMotherCiv().getLeaderGroup().hasMember(resident)) {
		throw new CivException("You must be the leader of the captured civilization in order to capitulate.");
	}
	
	if (town.getMotherCiv().getCapitolName().equals(town.getName())) {
		entireCiv = true;
	}
	
	String requestMessage = "";
	CapitulateRequest capitulateResponse = new CapitulateRequest();

	if (args.length < 3 || !args[2].equalsIgnoreCase("yes")) {
		if (entireCiv) {
			CivMessage.send(sender, CivColor.Yellow+ChatColor.BOLD+"Capitualting means that this civ will be DELETED and all of its towns will become a normal towns in "+
					town.getCiv().getName()+" and can no longer revolt. Are you sure?");
			CivMessage.send(sender, CivColor.Yellow+ChatColor.BOLD+"If you're sure, type /civ dip capitulate "+town.getName()+" yes");
		} else {
			CivMessage.send(sender, CivColor.Yellow+ChatColor.BOLD+"Capitualting means that this town will become a normal town in "+town.getCiv().getName()+" and can no longer revolt. Are you sure?");
			CivMessage.send(sender, CivColor.Yellow+ChatColor.BOLD+"If you're sure, type /civ dip capitulate "+town.getName()+" yes");
		}
		return;
	}
	
	if (entireCiv) {
		requestMessage = CivColor.Yellow+ChatColor.BOLD+"The Civilization of "+motherCiv.getName()+" would like to capitulate. Bringing in more towns will increase civ-wide unhappiness. Do we accept?";
		capitulateResponse.from = town.getMotherCiv().getName();
	} else {
		capitulateResponse.from = "Town of "+town.getName();
		requestMessage = CivColor.Yellow+ChatColor.BOLD+"The Town of "+town.getName()+" would like to capitulate. If we accept this town become ours and we"+
				" will have to pay distance upkeep to it. Do we accept?";	
	}
	
	capitulateResponse.playerName = resident.getName();
	capitulateResponse.capitulator = town;
	capitulateResponse.to = town.getCiv().getName();
	
	CivGlobal.requestRelation(motherCiv, town.getCiv(), requestMessage,
			INVITE_TIMEOUT, capitulateResponse);
	CivMessage.sendSuccess(sender, "Sent capitulate request.");
	
}
 
Example 11
Source File: CivDiplomacyCommand.java    From civcraft with GNU General Public License v2.0 4 votes vote down vote up
public void request_cmd() throws CivException {
	validLeaderAdvisor();
	Civilization ourCiv = getSenderCiv();
	if (War.isWarTime()) {
		throw new CivException("You cannot use this diplomacy command while it is WarTime.");
	}
	
	if (args.length < 3) {
		throw new CivException("Enter a civ name followed by 'neutral', 'peace', or 'ally'");
	}
	
	Civilization otherCiv = getNamedCiv(1);
	
	if (ourCiv.getId() == otherCiv.getId()) {
		throw new CivException("Cannot request anything on from your own civilization");
	}
	
	try {
		Relation.Status status = Relation.Status.valueOf(args[2].toUpperCase());
		Relation.Status currentStatus = ourCiv.getDiplomacyManager().getRelationStatus(otherCiv);

		if (currentStatus == status) {
			throw new CivException("Already "+status.name()+" with "+otherCiv.getName());
		}
		
		String message = CivColor.LightGreen+ChatColor.BOLD+ourCiv.getName()+" has requested ";
		switch (status) {
		case NEUTRAL:
			message += "a NEUTRAL relationship";
			break;
		case PEACE:
			message += "a PEACE treaty";
			break;
		case ALLY:
			message += "an ALLY";
			
			if (War.isWithinWarDeclareDays()) {
				if (ourCiv.getDiplomacyManager().isAtWar() || otherCiv.getDiplomacyManager().isAtWar()) {
					throw new CivException("Cannot make new allies within "+War.getTimeDeclareDays()+" before WarTime when one of you is at war.");
				}
			}
			break;
		case WAR:
			if (!CivGlobal.isCasualMode()) {
				throw new CivException("Can only request war in casual mode.");
			}
			
			message += "a WAR";
			break;
		default:
			throw new CivException("Options are 'neutral', 'peace', 'ally' or 'war'");
		}
		message += ". Do we accept?";
		
		ChangeRelationResponse relationresponse = new ChangeRelationResponse();
		relationresponse.fromCiv = ourCiv;
		relationresponse.toCiv = otherCiv;
		relationresponse.status = status;
		
		CivGlobal.requestRelation(ourCiv, otherCiv, 
				message,
				INVITE_TIMEOUT, relationresponse);
		
		CivMessage.sendSuccess(sender, "Request sent.");
	} catch (IllegalArgumentException e) {
		throw new CivException("Unknown relationship type, options are 'neutral', 'peace', 'ally' or 'war'");
	}
	
}
 
Example 12
Source File: Strings.java    From HolographicDisplays with GNU General Public License v3.0 4 votes vote down vote up
public static String formatTitle(String input) {
	return "" + Colors.PRIMARY_SHADOW + ChatColor.BOLD + "----- " + input + Colors.PRIMARY_SHADOW + ChatColor.BOLD + " -----";
}
 
Example 13
Source File: TeamTabEntry.java    From CardinalPGM with MIT License 4 votes vote down vote up
@Override
public String getDisplayName(Player viewer) {
    return team.size() + "" + ChatColor.DARK_GRAY + "/" + ChatColor.GRAY + team.getMax() + " " + team.getColor() + ChatColor.BOLD + team.getName();
}
 
Example 14
Source File: FlagBuilder.java    From CardinalPGM with MIT License 4 votes vote down vote up
private ModuleCollection<? extends Module> getFlag(Element... elements) {
    ModuleCollection<Module> result =  new ModuleCollection<>();
    String id = elements[0].getAttributeValue("id");
    boolean required = Numbers.parseBoolean(Parser.getOrderedAttribute("required", elements), true);
    String name = elements[0].getAttributeValue("name");
    boolean show = Numbers.parseBoolean(Parser.getOrderedAttribute("show", elements), true);
    Post post = Flags.getPostById(Parser.getOrderedAttribute("post", elements));
    if (post == null) post = PostBuilder.parsePostElement(elements[0].getChild("post"));
    result.add(post);
    Set<Net> nets = new HashSet<>();
    if (elements[0].getChildren("net").size() > 0) {
        for (Element netEl : elements[0].getChildren("net")) {
            Net net = NetBuilder.parseNet(Parser.addElement(netEl, elements));
            nets.add(net);
            result.add(net);
        }
    }
    TeamModule owner = Parser.getOrderedAttribute("owner", elements) == null ? null : Teams.getTeamById(Parser.getOrderedAttribute("owner", elements)).orNull();
    boolean shared = Numbers.parseBoolean(Parser.getOrderedAttribute("shared", elements), false);
    DyeColor color = Parser.getOrderedAttribute("color", elements) == null ? ((Banner)post.getInitialBlock().getState()).getBaseColor() : Parser.parseDyeColor(Parser.getOrderedAttribute("color", elements));
    ChatColor chatColor = MiscUtil.convertBannerColorToChatColor(color);
    String carryMessage = ChatColor.AQUA + "" + ChatColor.BOLD + "You are carrying " + chatColor + ChatColor.BOLD + name;
    if (Parser.getOrderedAttributeOrChild("carry-message", elements) != null) carryMessage = ChatColor.translateAlternateColorCodes('`', Parser.getOrderedAttributeOrChild("carry-message", elements));
    int points = Numbers.parseInt(Parser.getOrderedAttribute("points", elements), 0);
    int pointsRate = Numbers.parseInt(Parser.getOrderedAttribute("points-rate", elements), 0);
    FilterModule pickupFilter = FilterModuleBuilder.getAttributeOrChild("pickup-filter", post.getPickupFilter(), elements);
    FilterModule dropFilter = FilterModuleBuilder.getAttributeOrChild("drop-filter", "always", elements);
    FilterModule captureFilter = FilterModuleBuilder.getAttributeOrChild("capture-filter", nets.size() > 0 ? nets.iterator().next().getCaptureFilter() : FilterModuleBuilder.getFilter("always"), elements);
    KitNode pickupKit = getKitOrChild("pickup-kit", result, elements);
    KitNode dropKit = getKitOrChild("drop-kit", result, elements);
    KitNode carryKit = getKitOrChild("carry-kit", result, elements);
    boolean dropOnWater = Numbers.parseBoolean(Parser.getOrderedAttribute("drop-on-water", elements), true);
    boolean beam = Numbers.parseBoolean(Parser.getOrderedAttribute("beam", elements), true);

    String flagProximityMetric = Parser.getOrderedAttribute("flagproximity-metric", elements);
    Boolean flagProximityHorizontal = Numbers.parseBoolean(Parser.getOrderedAttribute("flagproximity-horizontal", elements), false);
    ProximityInfo flagProximityInfo = new ProximityInfo(post.getInitialBlock().getLocation().toVector(), flagProximityHorizontal, false,
        flagProximityMetric == null ? GameObjectiveProximityHandler.ProximityMetric.CLOSEST_KILL : GameObjectiveProximityHandler.ProximityMetric.getByName(flagProximityMetric));

    String netProximityMetric = Parser.getOrderedAttribute("netproximity-metric", elements);
    Boolean netProximityHorizontal = Numbers.parseBoolean(Parser.getOrderedAttribute("netproximity-horizontal", elements), false);
    ProximityInfo netProximityInfo = new ProximityInfo(null, netProximityHorizontal, true,
            netProximityMetric == null ? GameObjectiveProximityHandler.ProximityMetric.CLOSEST_PLAYER : GameObjectiveProximityHandler.ProximityMetric.getByName(netProximityMetric));

    Map<String, GameObjectiveProximityHandler> flagProximityHandlers = new HashMap<>();
    Map<String, GameObjectiveProximityHandler> netProximityHandlers = new HashMap<>();
    for (TeamModule offender : Teams.getTeams()) {
        if (offender.isObserver() || offender == owner || !pickupFilter.evaluate(offender).equals(FilterState.ALLOW)) continue;
        GameObjectiveProximityHandler flagProximityHandler = new GameObjectiveProximityHandler(offender, flagProximityInfo);
        GameObjectiveProximityHandler netProximityHandler = new GameObjectiveProximityHandler(offender, netProximityInfo);
        flagProximityHandlers.put(offender.getId(), flagProximityHandler);
        netProximityHandlers.put(offender.getId(), netProximityHandler);
        result.add(flagProximityHandler);
        result.add(netProximityHandler);
    }
    result.add(new FlagObjective(id, required, name, color, chatColor, show, post, owner, shared, carryMessage, points, pointsRate, pickupFilter, dropFilter, captureFilter, pickupKit, dropKit, carryKit, dropOnWater, beam, nets, flagProximityHandlers, netProximityHandlers));

    return result;
}
 
Example 15
Source File: HeaderModule.java    From CardinalPGM with MIT License 4 votes vote down vote up
public void updateHeader() {
    header = new LocalizedChatMessage(ChatConstant.MISC_BY,
            new UnlocalizedChatMessage("" + ChatColor.AQUA + ChatColor.BOLD + mapName + ChatColor.DARK_GRAY),
            ChatUtil.toChatMessage(authors.stream()
                    .map(Contributor::getDisplayName).collect(Collectors.toList()), ChatColor.RESET, ChatColor.DARK_GRAY));
}
 
Example 16
Source File: ItemQualityColorizer.java    From EliteMobs with GNU General Public License v3.0 3 votes vote down vote up
private static ItemMeta colorizeBoldNameAndLore(ChatColor chatColor, ItemMeta itemMeta) {

        /*
        Cancel colorization in case item already has a color (for custom and unique items)
         */
        if (itemMeta.getDisplayName().equals(ChatColor.stripColor(itemMeta.getDisplayName())))
            itemMeta.setDisplayName(chatColor + "" + ChatColor.BOLD + "" + itemMeta.getDisplayName());

        List list = new ArrayList();

        if (!itemMeta.getLore().isEmpty()) {

            for (String string : itemMeta.getLore()) {

                if (!string.isEmpty()) {

                    String colorizedString = chatColor + "" + ChatColor.BOLD + "" + ChatColor.ITALIC + string;
                    list.add(colorizedString);

                }

            }

            itemMeta.setLore(list);

        }

        return itemMeta;

    }