当前位置: 首页>>代码示例>>Java>>正文


Java ChatColor.getLastColors方法代码示例

本文整理汇总了Java中org.bukkit.ChatColor.getLastColors方法的典型用法代码示例。如果您正苦于以下问题:Java ChatColor.getLastColors方法的具体用法?Java ChatColor.getLastColors怎么用?Java ChatColor.getLastColors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.ChatColor的用法示例。


在下文中一共展示了ChatColor.getLastColors方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyText

import org.bukkit.ChatColor; //导入方法依赖的package包/类
private void applyText(Team team, String text, OfflinePlayer result) {
    Iterator<String> iterator = Splitter.fixedLength(16).split(text).iterator();
    String prefix = iterator.next();

    team.setPrefix(prefix);

    if (!team.hasEntry(result.getName()))
        team.addEntry(result.getName());

    if (text.length() > 16) {
        String prefixColor = ChatColor.getLastColors(prefix);
        String suffix = iterator.next();

        //TODO Change to the symbols

        if (prefix.endsWith("nn")) {
            prefix = prefix.substring(0, prefix.length() - 1);
            team.setPrefix(prefix);
            prefixColor = ChatColor.getByChar(suffix.charAt(0)).toString();
            suffix = suffix.substring(1);
        }

        if (prefixColor == null)
            prefixColor = "";

        if (suffix.length() > 16) {
            suffix = suffix.substring(0, (13 - prefixColor.length())); // cut off suffix, done if text is over 30 characters
        }

        team.setSuffix((prefixColor.equals("") ? ChatColor.RESET : prefixColor) + suffix);
    }
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:33,代码来源:SimpleScoreboard.java

示例2: onSignChange

import org.bukkit.ChatColor; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public final void onSignChange(SignChangeEvent event) {

	String[] lines = event.getLines();
	Player player = (Player) event.getPlayer();

	if (!player.hasPermission("emojix.sign.use"))
		return;

	/*
	 * This loop allows detection for emotes mixed with words and also
	 * eliminates emotes appearing in URL's - emotes must have a space on
	 * both sides if applicable
	 */
	for (Object obj : EmojiConfig.emoji.getConfigurationSection("emoji").getKeys(false)) {
		for (int i = 0; i < lines.length; i++) {

			String[] words = lines[i].split(" ");

			// If player has colored prefix we obtain that color
			String color = ChatColor.getLastColors(words[0]);

			for (String word : words) {

				// This is so the user can use an emoji singularly or at the start of line
				if (word == words[0])
					word = ChatColor.stripColor(word);

				if (word.equals(obj.toString()) && player.hasPermission("emojix.chat." + word))
					lines[i] = lines[i].replace(word,
							ChatColor.RESET + EmojiConfig.emoji.getString("emoji." + obj.toString()) + color);
			}

			event.setLine(i, lines[i]);
			// TODO: Plugin works as intended - 1. Fix any bugs should they occur 2. Add extra functionality
		}
	}
}
 
开发者ID:pphelix,项目名称:emojix-spigot,代码行数:39,代码来源:SignEvent.java

示例3: onChat

import org.bukkit.ChatColor; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public final void onChat(AsyncPlayerChatEvent event) {

	String message = event.getMessage();
	Player player = (Player) event.getPlayer();
	String[] words = message.split(" ");

	// If player has colored prefix we obtain that color
	String color = ChatColor.getLastColors(words[0]);

	/*
	 * This loop allows detection for emotes mixed with words and also
	 * eliminates emotes appearing in URL's - emotes must have a space on
	 * both sides if applicable
	 */
	for (Object obj : EmojiConfig.emoji.getConfigurationSection("emoji").getKeys(false)) {
		for (String word : words) {

			// This is so the user can use an emoji singularly or at the start of line
			if (word == words[0])
				word = ChatColor.stripColor(word);

			if (word.equals(obj.toString()) && player.hasPermission("emojix.chat." + word))
				message = message.replace(word,
						ChatColor.RESET + EmojiConfig.emoji.getString("emoji." + obj.toString()) + color);
		}
	}

	event.setMessage(message);
	// TODO: Plugin works as intended - 1. Fix any bugs should they occur 2. Add extra functionality
}
 
开发者ID:pphelix,项目名称:emojix-spigot,代码行数:32,代码来源:ChatEvent.java

示例4: setValue

import org.bukkit.ChatColor; //导入方法依赖的package包/类
@Override
// thanks to this random gist https://gist.github.com/mkotb/d99eccdcc78a43ffb707
public void setValue(@Nonnull String value) {
    super.setValue(value);

    Iterator<String> iterator = Splitter.fixedLength(16).split(value).iterator();
    String prefix = iterator.next();

    team.setPrefix(prefix);

    if (!team.hasEntry(entry)) {
        team.addEntry(entry);
    }

    if (value.length() > 16) {
        String prefixColor = ChatColor.getLastColors(prefix);
        String suffix = iterator.next();

        if (prefix.endsWith(String.valueOf(ChatColor.COLOR_CHAR))) {
            prefix = prefix.substring(0, prefix.length() - 1);
            team.setPrefix(prefix);
            prefixColor = ChatColor.getByChar(suffix.charAt(0)).toString();
            suffix = suffix.substring(1);
        }

        if (prefixColor == null) {
            prefixColor = "";
        }

        if (suffix.length() > 15) {
            suffix = suffix.substring(0, (16 - Math.max(prefixColor.length(), ChatColor.RESET.toString()
                    .length()))); // cut off suffix, done if text is over 30 characters
        }

        team.setSuffix((prefixColor.equals("") ? ChatColor.RESET : prefixColor) + suffix);
    }
}
 
开发者ID:VoxelGamesLib,项目名称:VoxelGamesLibv2,代码行数:38,代码来源:BukkitStringScoreboardLine.java

示例5: send

import org.bukkit.ChatColor; //导入方法依赖的package包/类
public TabEntry send() {
    if (!(setup)) {
        return setup();
    }

    text = ChatColor.translateAlternateColorCodes('&', text);

    if (text.length() > 16) {
        team.setPrefix(text.substring(0, 16));

        String suffix = ChatColor.getLastColors(team.getPrefix()) + text.substring(16, text.length());

        if (suffix.length() > 16) {
            if (suffix.length() <= 16) {
                suffix = text.substring(16, text.length());
                team.setSuffix(suffix.substring(0, suffix.length()));
            } else {
                team.setSuffix(suffix.substring(0, 16));
            }
        } else {
            team.setSuffix(suffix);
        }
    } else {
        team.setPrefix(text);
        team.setSuffix("");
    }

    return this;
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:30,代码来源:TabEntry.java

示例6: update

import org.bukkit.ChatColor; //导入方法依赖的package包/类
void update() {
	if (!isActive()) {
		return;
	}
	ScoreboardProvider provider = ScoreboardWrapper.instance.provider;
	String title = provider.getTitle(player);
	if (!objective.getDisplayName().equals(title)) {
		objective.setDisplayName(title);
	}
	List<String> lines = provider.getLines(player);
	Collections.reverse(lines);
	int currentLine = 1;
	if (lines.size() != scoreboard.getEntries().size()) {
		scoreboard.getEntries().forEach(entry -> scoreboard.resetScores(entry));
	}
	if (currentLine > 14) {
		return;
	}
	for (String line : lines) {
		final String code = nextString(currentLine);
		String left = "", right = "";
		if (line.length() > 16) {
			left = line.substring(0, 16);
			String suffix = ChatColor.getLastColors(left) + line.substring(16, line.length());
			if (suffix.length() > 16) {
				if (suffix.length() <= 16) {
					suffix = line.substring(16, line.length());
					right = suffix.substring(0, suffix.length());
				} else {
					right = suffix.substring(0, 16);
				}
			} else {
				right = suffix;
			}
		} else {
			left = line;
			right = "";
		}
		applyTeam(code, left, right);
		objective.getScore(code).setScore(currentLine++);
	}
}
 
开发者ID:HuliPvP,项目名称:Chambers,代码行数:43,代码来源:PlayerScoreboard.java


注:本文中的org.bukkit.ChatColor.getLastColors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。