Java Code Examples for org.bukkit.ChatColor#RESET

The following examples show how to use org.bukkit.ChatColor#RESET . 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: ItemInfoCommandExecutor.java    From UhcCore with GNU General Public License v3.0 6 votes vote down vote up
private void sendJsonItemMessage(Player player, ItemStack item){
    String json = JsonItemUtils.getItemJson(item);

    if (json.length() > 100){
        player.sendMessage(ChatColor.GREEN + "Item Json is too big for chat, uploading to paste bin ...");

        String url;
        try{
            url = FileUtils.uploadTextFile(new StringBuilder(json));
        }catch (IOException ex){
            player.sendMessage(ChatColor.RED + "Failed to upload item json to paste bin, check console for more detail.");
            ex.printStackTrace();
            return;
        }

        player.sendMessage(ChatColor.DARK_GREEN + " Json-Item: " + ChatColor.GREEN + url);
        return;
    }

    String text = ChatColor.DARK_GREEN + " Json-Item: " + ChatColor.RESET + json;
    if (UhcCore.isSpigotServer()){
        SpigotUtils.sendMessage(player, text, ChatColor.GREEN + "Click to copy", json, SpigotUtils.Action.SUGGEST);
    }else{
        player.sendMessage(text);
    }
}
 
Example 2
Source File: ListCommand.java    From CardinalPGM with MIT License 6 votes vote down vote up
@Command(aliases = {"list"}, desc = "Lists all online players.", flags = "v")
public static void list(final CommandContext args, CommandSender sender) {
    boolean version = args.hasFlag('v');
    String result = ChatColor.GRAY + ChatConstant.MISC_ONLINE.asMessage().getMessage(ChatUtil.getLocale(sender)) +
            " (" + Bukkit.getOnlinePlayers().size() + "/" + Bukkit.getMaxPlayers() + "): " + ChatColor.RESET;
    for (Player player : Bukkit.getOnlinePlayers()) {
        result += player.getDisplayName();
        if (version) {
            result += ChatColor.GRAY + " (" + Protocols.getName(player.getProtocolVersion()) + ")";
        }
        result += ChatColor.RESET + ", ";
    }
    if (result.endsWith(", ")) {
        result = result.substring(0, result.length() - 2);
    }
    sender.sendMessage(result);
}
 
Example 3
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 4
Source File: AbstractScoreboardTeam.java    From ProtocolSupport with GNU Affero General Public License v3.0 6 votes vote down vote up
protected Any<String, String> formatDisplayLinePrefixSuffix() {
	String prefix = this.prefix.toLegacyText(clientCache.getLocale());

	if ((format != ChatColor.RESET) && !isStringFormatOverride(prefix, format)) {
		prefix = format + prefix;
	}

	if (prefix.length() <= NFIX_LIMIT) {
		return new Any<>(prefix, "");
	}

	int limit = prefix.charAt(NFIX_LIMIT_FCUT) == ChatColor.COLOR_CHAR ? NFIX_LIMIT_FCUT : NFIX_LIMIT;

	String sPrefix = prefix.substring(0, limit);

	String sSuffix = ChatColor.getLastColors(sPrefix) + prefix.substring(limit);
	if (!isStringFormatOverride(sSuffix, ChatColor.RESET)) {
		sSuffix = ChatColor.RESET + sSuffix;
	}
	sSuffix = LegacyChat.clampLegacyText(sSuffix, NFIX_LIMIT);

	return new Any<>(sPrefix, sSuffix);
}
 
Example 5
Source File: VariableString.java    From Skript with GNU General Public License v3.0 6 votes vote down vote up
@Nullable
private static ChatColor getLastColor(final CharSequence s) {
	for (int i = s.length() - 2; i >= 0; i--) {
		if (s.charAt(i) == ChatColor.COLOR_CHAR) {
			final ChatColor c = ChatColor.getByChar(s.charAt(i + 1));
			if (c != null && (c.isColor() || c == ChatColor.RESET))
				return c;
		}
	}
	return null;
}
 
Example 6
Source File: ScoreboardModule.java    From CardinalPGM with MIT License 6 votes vote down vote up
public void renderObjective(GameObjective objective) {
    if (!objective.showOnScoreboard()) return;
    int score = currentScore;
    Team team = scoreboard.getTeam(objective.getScoreboardHandler().getNumber() + "-o");
    String prefix = objective.getScoreboardHandler().getPrefix(this.team);
    team.setPrefix(prefix);
    if (team.getEntries().size() > 0) {
        setScore(this.objective, new ArrayList<>(team.getEntries()).get(0), score);
    } else {
        String raw = (objective instanceof HillObjective ? "" : ChatColor.RESET) + " " + WordUtils.capitalizeFully(objective.getName().replaceAll("_", " "));
        while (used.contains(raw)) {
            raw =  raw + ChatColor.RESET;
        }
        team.addEntry(raw);
        setScore(this.objective, raw, score);
        used.add(raw);
    }
    currentScore++;
}
 
Example 7
Source File: CommandHelp.java    From DiscordSRV with GNU General Public License v3.0 6 votes vote down vote up
private static void help(CommandSender sender) {
    ChatColor titleColor = ChatColor.RESET, commandColor = ChatColor.RESET;
    while (disallowedChatColorCharacters.contains(titleColor))
        titleColor = ChatColor.values()[DiscordSRV.getPlugin().getRandom().nextInt(ChatColor.values().length)];
    while (disallowedChatColorCharacters.contains(commandColor) || commandColor == titleColor)
        commandColor = ChatColor.values()[DiscordSRV.getPlugin().getRandom().nextInt(ChatColor.values().length)];

    List<Method> commandMethods = new ArrayList<>();
    for (Method method : DiscordSRV.getPlugin().getCommandManager().getCommands().values())
        if (!commandMethods.contains(method)) commandMethods.add(method);

    sender.sendMessage(ChatColor.DARK_GRAY + "================[ " + titleColor + "DiscordSRV" + ChatColor.DARK_GRAY + " ]================");
    for (Method commandMethod : commandMethods) {
        Command commandAnnotation = commandMethod.getAnnotation(Command.class);

        // make sure sender has permission to run the commands before showing them permissions for it
        if (!GamePermissionUtil.hasPermission(sender, commandAnnotation.permission())) continue;

        sender.sendMessage(ChatColor.GRAY + "- " + commandColor + "/discord " + String.join("/", commandAnnotation.commandNames()));
        sender.sendMessage("    " + ChatColor.ITALIC + commandAnnotation.helpMessage());
        if (!commandAnnotation.usageExample().equals("")) sender.sendMessage("    " + ChatColor.GRAY + ChatColor.ITALIC + "ex. /discord " + commandAnnotation.usageExample());
    }
}
 
Example 8
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 9
Source File: AbstractScoreboardTeam.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
protected String formatLegacyClampedSuffix() {
	String suffix = this.suffix.toLegacyText(clientCache.getLocale());

	if (!isStringFormatOverride(suffix, format)) {
		suffix = format + suffix;
		if (format.isFormat()) {
			suffix = ChatColor.RESET + suffix;
		}
	}

	return LegacyChat.clampLegacyText(suffix, NFIX_LIMIT);
}
 
Example 10
Source File: GridManager.java    From askyblock with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get name of the island owned by owner
 * @param owner island owner UUID
 * @return Returns the name of owner's island, or the owner's name if there is none.
 */
public String getIslandName(UUID owner) {
    if (owner == null) {
        return "";
    }
    return ChatColor.translateAlternateColorCodes('&', islandNames.getString(owner.toString(), plugin.getPlayers().getName(owner))) + ChatColor.RESET;
}
 
Example 11
Source File: MessageHandler.java    From CratesPlus with GNU General Public License v3.0 5 votes vote down vote up
private static String getMessageFromConfig(String message) {
    if (testMessages) {
        return "TRANSLATED(" + message + ChatColor.RESET + ") ";
    }
    if (messages.containsKey(message))
        return message;
    // TODO Insert into config reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
    return message;
}
 
Example 12
Source File: ScoreboardModule.java    From CardinalPGM with MIT License 5 votes vote down vote up
public void renderCompactObjectives(ModuleCollection<GameObjective> objectives) {
    int score = currentScore;
    Team team = scoreboard.getTeam(objectives.get(0).getScoreboardHandler().getNumber() + "-o");
    if (team != null) {
        String compact = "";
        for (GameObjective obj : objectives) {
            compact += obj.getScoreboardHandler().getCompactPrefix(this.team) + " ";
        }
        while (compact.length() > 32) {
            compact = Strings.removeLastWord(compact);
        }
        if (compact.length() < 16){
            team.setPrefix(Strings.trimTo(compact, 0, 16));
            team.setSuffix("r");
        } else if (compact.charAt(15) == '\u00A7') {
            team.setPrefix(Strings.trimTo(compact, 0, 15));
            team.setSuffix(Strings.trimTo(compact, 15, 31));
        } else {
            team.setPrefix(Strings.trimTo(compact, 0, 16));
            team.setSuffix(Strings.getCurrentChatColor(compact, 16).charAt(1) + Strings.trimTo(compact, 16, 31));
        }
        if (team.getEntries().size() > 0) {
            setScore(objective, new ArrayList<>(team.getEntries()).get(0), currentScore);
        } else {
            String name = "\u00A7";
            while (used.contains(name)) {
                name = ChatColor.RESET + name;
            }
            team.addEntry(name);
            setScore(objective, name, score);
            used.add(name);
        }
        currentScore++;
    }
}
 
Example 13
Source File: ImageMessage.java    From AnnihilationPro with MIT License 5 votes vote down vote up
private String[] toImgMessage(ChatColor[][] colors, char imgchar) {
    String[] lines = new String[colors[0].length];
    for (int y = 0; y < colors[0].length; y++) {
        String line = "";
        for (int x = 0; x < colors.length; x++) {
            ChatColor color = colors[x][y];
            line += (color != null) ? colors[x][y].toString() + imgchar : TRANSPARENT_CHAR;
        }
        lines[y] = line + ChatColor.RESET;
    }
    return lines;
}
 
Example 14
Source File: PluginUtils.java    From TabooLib with MIT License 5 votes vote down vote up
public static String getFormattedName(Plugin plugin, boolean includeVersions) {
    ChatColor color = plugin.isEnabled() ? ChatColor.GREEN : ChatColor.RED;
    String pluginName = color + plugin.getName() + ChatColor.RESET;
    if (includeVersions) {
        pluginName = pluginName + " (" + plugin.getDescription().getVersion() + ")";
    }
    return pluginName;
}
 
Example 15
Source File: BrandHider.java    From AACAdditionPro with GNU General Public License v3.0 4 votes vote down vote up
public static void setBrand(String brand)
{
    BrandHider.brand = ChatColor.translateAlternateColorCodes('&', brand) + ChatColor.RESET;
    updateAllBrands();
}
 
Example 16
Source File: MissionBook.java    From civcraft with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private static void performInvestigateTown(Player player, ConfigMission mission) throws CivException {
	
	Resident resident = CivGlobal.getResident(player);
	if (resident == null || !resident.hasTown()) {
		throw new CivException("Only residents of towns can perform spy missions.");
	}
	
	// Must be within enemy town borders.
	ChunkCoord coord = new ChunkCoord(player.getLocation());
	TownChunk tc = CivGlobal.getTownChunk(coord);
	
	if (tc == null || tc.getTown().getCiv() == resident.getTown().getCiv()) {
		throw new CivException("Must be in another civilization's town's borders.");
	}
	
	if(processMissionResult(player, tc.getTown(), mission)) {
		ItemStack book = new ItemStack(Material.WRITTEN_BOOK, 1);
		BookMeta meta = (BookMeta) book.getItemMeta();
		ArrayList<String> lore = new ArrayList<String>();
		lore.add("Mission Report");
		
		meta.setAuthor("Mission Reports");
		meta.setTitle("Investigate Town");
		
	//	ArrayList<String> out = new ArrayList<String>();
		String out = "";
		
		out += ChatColor.UNDERLINE+"Town:"+tc.getTown().getName()+"\n"+ChatColor.RESET;
		out += ChatColor.UNDERLINE+"Civ:"+tc.getTown().getCiv().getName()+"\n\n"+ChatColor.RESET;
		
		SimpleDateFormat sdf = new SimpleDateFormat("M/dd h:mm:ss a z");
		out += "Time: "+sdf.format(new Date())+"\n";
		out += ("Treasury: "+tc.getTown().getTreasury().getBalance()+"\n");
		out += ("Hammers: "+tc.getTown().getHammers().total+"\n");
		out += ("Culture: "+tc.getTown().getCulture().total+"\n");
		out += ("Growth: "+tc.getTown().getGrowth().total+"\n");
		out += ("Beakers(civ): "+tc.getTown().getBeakers().total+"\n");
		if (tc.getTown().getCiv().getResearchTech() != null) {
			out += ("Researching: "+tc.getTown().getCiv().getResearchTech().name+"\n");
		} else {
			out += ("Researching:Nothing"+"\n");
		}
		
		BookUtil.paginate(meta, out);
		
		out = ChatColor.UNDERLINE+"Upkeep Info\n\n"+ChatColor.RESET;
		try {
			out += "From Spread:"+tc.getTown().getSpreadUpkeep()+"\n";
			out += "From Structures:"+tc.getTown().getStructureUpkeep()+"\n";
			out += "Total:"+tc.getTown().getTotalUpkeep();
			BookUtil.paginate(meta, out);
		} catch (InvalidConfiguration e) {
			e.printStackTrace();
			throw new CivException("Internal configuration exception.");
		}
		
		
		meta.setLore(lore);
		book.setItemMeta(meta);
		
		HashMap<Integer, ItemStack> leftovers = player.getInventory().addItem(book);
		for (ItemStack stack : leftovers.values()) {
			player.getWorld().dropItem(player.getLocation(), stack);
		}
		
		player.updateInventory();
		
		CivMessage.sendSuccess(player, "Mission Accomplished");
	}
}
 
Example 17
Source File: ProgrammableAndroid.java    From Slimefun4 with GNU General Public License v3.0 4 votes vote down vote up
protected String getScriptRatingPercentage(Script script) {
    float percentage = script.getRating();
    return NumberUtils.getColorFromPercentage(percentage) + String.valueOf(percentage) + ChatColor.RESET + "% ";
}
 
Example 18
Source File: ElevatorPlate.java    From Slimefun4 with GNU General Public License v3.0 4 votes vote down vote up
public void open(Player p, Block b) {
    if (users.remove(p.getUniqueId())) {
        return;
    }

    CustomBookInterface book = new CustomBookInterface(SlimefunPlugin.instance);
    ChatComponent page = null;

    List<Block> floors = getFloors(b);

    if (floors.size() < 2) {
        SlimefunPlugin.getLocalization().sendMessage(p, "machines.ELEVATOR.no-destinations", true);
    }

    for (int i = 0; i < floors.size(); i++) {
        if (i % 10 == 0) {
            if (page != null) {
                book.addPage(page);
            }

            page = new ChatComponent(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.pick-a-floor")) + "\n");
        }

        Block block = floors.get(i);
        String floor = ChatColors.color(BlockStorage.getLocationInfo(block.getLocation(), DATA_KEY));
        ChatComponent line;

        if (block.getY() == b.getY()) {
            line = new ChatComponent("\n" + ChatColor.GRAY + "> " + (floors.size() - i) + ". " + ChatColor.RESET + floor);
            line.setHoverEvent(new HoverEvent(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.current-floor")), "", ChatColor.RESET + floor, ""));
        }
        else {
            line = new ChatComponent("\n" + ChatColor.GRAY.toString() + (floors.size() - i) + ". " + ChatColor.RESET + floor);
            line.setHoverEvent(new HoverEvent(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.click-to-teleport")), "", ChatColor.RESET + floor, ""));
            line.setClickEvent(new ClickEvent(new NamespacedKey(SlimefunPlugin.instance, DATA_KEY + i), player -> Slimefun.runSync(() -> {
                users.add(player.getUniqueId());

                float yaw = player.getEyeLocation().getYaw() + 180;

                if (yaw > 180) {
                    yaw = -180 + (yaw - 180);
                }

                player.teleport(new Location(player.getWorld(), block.getX() + 0.5, block.getY() + 0.4, block.getZ() + 0.5, yaw, player.getEyeLocation().getPitch()));
                player.sendTitle(ChatColor.RESET + ChatColors.color(floor), " ", 20, 60, 20);
            })));
        }

        page.append(line);
    }

    if (page != null) {
        book.addPage(page);
    }

    book.open(p);
}
 
Example 19
Source File: CustomItem.java    From AdditionsAPI with MIT License 2 votes vote down vote up
/**
 * Set the display name of the Custom Item. By default, it will add
 * ChatColor.RESET in front to prevent the slanted text. You can override that
 * by adding another ChatColor afterwards, however be aware that it will show up
 * if you rename the item in an anvil.
 */
public CustomItem setDisplayName(String displayName) {
	this.displayName = ChatColor.RESET + displayName;
	return this;
}
 
Example 20
Source File: ImageMessage.java    From HolographicDisplays with GNU General Public License v3.0 2 votes vote down vote up
private String[] toImgMessage(ChatColor[][] colors) {
	
    String[] lines = new String[colors[0].length];
    ChatColor transparencyColor = Configuration.transparencyColor;
    String transparencySymbol = Configuration.transparencySymbol;
    String imageSymbol = Configuration.imageSymbol;
    
    for (int y = 0; y < colors[0].length; y++) {
    	
        StringBuffer line = new StringBuffer();
        
        ChatColor previous = ChatColor.RESET;
        
        for (int x = 0; x < colors.length; x++) {
        	
            ChatColor currentColor = colors[x][y];
            
            if (currentColor == null) {
            	
            	// Use the trasparent char
            	if (previous != transparencyColor) {
            		
            		// Change the previous chat color and append the newer
            		line.append(transparencyColor);
            		previous = transparencyColor;
            		
            	}
            	line.append(transparencySymbol);
            	
            } else {
            	
            	if (previous != currentColor) {
            		line.append(currentColor.toString());
            		previous = currentColor;
            	}
            	
            	line.append(imageSymbol);
            }
        }
        
        lines[y] = line.toString();
    }
    
    return lines;
}