本文整理汇总了Java中org.bukkit.ChatColor.stripColor方法的典型用法代码示例。如果您正苦于以下问题:Java ChatColor.stripColor方法的具体用法?Java ChatColor.stripColor怎么用?Java ChatColor.stripColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.ChatColor
的用法示例。
在下文中一共展示了ChatColor.stripColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAttributeDoubleValue
import org.bukkit.ChatColor; //导入方法依赖的package包/类
private static double getAttributeDoubleValue(String lore, String prefix) {
if (lore.contains(":") && lore.split(":").length == 2) {
if (lore.split(":")[0].equalsIgnoreCase(prefix)) {
lore = ChatColor.stripColor(lore);
lore = lore.split(":")[1].trim();
if (lore.matches("[+\\-]?[0-9]*(\\.[0-9]*)?")) {
return Double.parseDouble(lore);
} else if (lore.matches("[+\\-]?[0-9]*(\\.[0-9]*)?-[+\\-]?[0-9]*(\\.[0-9]*)?")) {
double first = Double.parseDouble(lore.startsWith("-")
? "-" + lore.substring(1).split("-")[0]
: lore.split("-")[0]);
double last = Double.parseDouble(lore.startsWith("-")
? lore.substring(1).substring(lore.substring(1).indexOf("-") + 1)
: lore.substring(lore.indexOf("-") + 1));
return RandomUtil.random(first, last);
} else if (lore.matches("[0-9]*[Dd][0-9]*")) {
return RandomUtil.rollDice(lore);
}
}
}
return 0;
}
示例2: onClick
import org.bukkit.ChatColor; //导入方法依赖的package包/类
@EventHandler
public void onClick(InventoryClickEvent e){
Player p = (Player) e.getWhoClicked();
WCUser user = new WCUser(p.getUniqueId());
Inventory inv = e.getClickedInventory();
ItemStack i = e.getCurrentItem();
switch (ChatColor.stripColor(inv.getName())){
case "Servidores":
switch (e.getSlot()){
case 21:
user.sendToServer("survival");
break;
default:
break;
}
break;
}
}
示例3: getData
import org.bukkit.ChatColor; //导入方法依赖的package包/类
public EventKeyData getData(List<String> itemLore) {
if (itemLore.size() < 2) {
return null;
}
String first = ChatColor.stripColor(itemLore.get(1));
if (first == null)
return null;
for (EventType eventType : EventType.values()) {
if (first.contains(eventType.getDisplayName())) {
return new EventKeyData(eventType, Character.getNumericValue(first.charAt(first.length() - 1)));
}
}
return null;
}
示例4: onInteractEntity
import org.bukkit.ChatColor; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onInteractEntity(PlayerInteractEntityEvent e) {
TOAUser u = TOA.getPlayer(e.getPlayer());
e.setCancelled(true);
if (e.getRightClicked() instanceof Villager) {
Villager v = (Villager) e.getRightClicked();
if (v.getCustomName().equalsIgnoreCase("") || v.getCustomName() == null) return;
switch (ChatColor.stripColor(v.getCustomName())) {
case "Comprador Variado":
TOAMenu.openMenu(u, TOAMenu.MenuType.VARIADO);
break;
case "Comprador Armas":
TOAMenu.openMenu(u, TOAMenu.MenuType.ARMAS);
break;
}
}
}
示例5: constructPrefix
import org.bukkit.ChatColor; //导入方法依赖的package包/类
/**
* Constructs a prefix from the given source
*
* @param source source
* @return prefix
*/
private String constructPrefix(String source) {
final StringBuilder b = new StringBuilder();
for (int i = 0; i < source.length(); i++) {
final char t = source.charAt(i);
if (t != '%') {
b.append(t);
} else {
return ChatColor.stripColor(b.toString());
}
}
return ChatColor.stripColor(b.toString());
}
示例6: upgrade
import org.bukkit.ChatColor; //导入方法依赖的package包/类
public ItemStack upgrade() {
List<String> lore = new ArrayList<String>();
lore.add("&7&oEnder Infused");
lore.add("");
for (String line: getItem().getItemMeta().getLore()) {
lore.add(line);
}
ItemStack item = new CustomItem(getItem().getType(), "&5Ender " + ChatColor.stripColor(getItem().getItemMeta().getDisplayName()), getItem().getDurability(), lore.toArray(new String[lore.size()]));
return item;
}
示例7: getMessage
import org.bukkit.ChatColor; //导入方法依赖的package包/类
public String getMessage(String key, boolean stripColor, Object... args) {
if (!this.messageCache.containsKey(key)) {
this.messageCache.put(key, new MessageFormat(
ChatColor.translateAlternateColorCodes(
'&', this.language.getProperty(key, "Unknown localization key: \"" + key + "\"")
)
));
}
String out = this.messageCache.get(key).format(args);
return stripColor ? ChatColor.stripColor(out) : out;
}
示例8: pm
import org.bukkit.ChatColor; //导入方法依赖的package包/类
/**
* Sends a plugin message.
* @param msg
*/
public void pm(String msg) {
msg = "[" + ChatColor.DARK_PURPLE + "PSPS" + ChatColor.RESET + "] " + msg;
if (getConfig().getBoolean("logging.disable-colors", false)) {
msg = ChatColor.stripColor(msg);
}
getServer().getConsoleSender().sendMessage(msg);
}
示例9: debug
import org.bukkit.ChatColor; //导入方法依赖的package包/类
/**
* Sends a debug plugin message.
* @param msg
*/
public void debug(String msg) {
if (!getConfig().getBoolean("logging.enable-debug", false)) { return; }
msg = "[" + ChatColor.RED + "PSPS" + ChatColor.RESET + "] " + msg;
if (getConfig().getBoolean("logging.disable-colors", false)) {
msg = ChatColor.stripColor(msg);
}
getServer().getConsoleSender().sendMessage(msg);
}
示例10: createHomes
import org.bukkit.ChatColor; //导入方法依赖的package包/类
public Map<String, TempMarker> createHomes() {
Map<String, TempMarker> ret = new HashMap<>();
// Loop current factions
for (Faction faction : factions.getActive()) {
Location ps = faction.getHome();
if (ps == null) {
continue;
}
DynmapStyle style = faction.getDynmapStyle();
String markerId = factionsHome + faction.getId();
TempMarker temp = new TempMarker();
temp.label = ChatColor.stripColor(faction.getName());
temp.world = ps.getWorld().toString();
temp.x = ps.getX();
temp.y = ps.getY();
temp.z = ps.getZ();
temp.iconName = style.getHomeMarker();
temp.description = getDescription(faction);
ret.put(markerId, temp);
}
return ret;
}
示例11: sendDeathMessage
import org.bukkit.ChatColor; //导入方法依赖的package包/类
private void sendDeathMessage(PlayerDeathEvent event) {
if(!safeToSend(event))
return;
boolean bc = configsManager.getModChannelConfig().getBoolean("See_Player_Death");
String msg = ChatColor.stripColor(event.getDeathMessage());
messenger.sendMessageToAllBoundChannel("```css" + "\n[" + msg + "]\n```");
if (bc)
messenger.sendMessageToAllModChannel("```css" + "\n[" + msg + "]\n```");
}
示例12: onBroadcastCommand
import org.bukkit.ChatColor; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onBroadcastCommand(ServerCommandEvent event) {
String cmd = ChatColor.stripColor(event.getCommand());
if (cmd.equals("broadcast ") || cmd.equals("bc ")) {
String msg = cmd.split(" ", 2)[1];
messenger.sendMessageToAllBoundChannel("\uD83D\uDCE2 " + msg);
boolean seeBc = configsManager.getModChannelConfig().getBoolean("See_Broadcast");
if(seeBc) {
messenger.sendMessageToAllModChannel("\uD83D\uDCE2 " + msg );
}
}
}
示例13: onPlayerAsyncChatEvent2
import org.bukkit.ChatColor; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerAsyncChatEvent2(PlayerChatEvent event) {
if (!Config.getInstance().isAsyncChat() && !Config.getInstance().isHighpriority()) {
if (this.pages.containsKey(event.getPlayer())) {
event.setCancelled(true);
final String message = ChatColor.stripColor(event.getMessage());
this.handleChatMessage(event.getPlayer(), message);
}
}
}
示例14: playerChatEvent
import org.bukkit.ChatColor; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void playerChatEvent(AsyncPlayerChatEvent event) {
if (Config.getInstance().isAsyncChat() && Config.getInstance().isHighpriority()) {
if (this.pages.containsKey(event.getPlayer())) {
event.setCancelled(true);
final String message = ChatColor.stripColor(event.getMessage());
final Player player = event.getPlayer();
this.plugin.getServer().getScheduler().runTaskLater(this.plugin, () -> SChatMenuManager.this.handleChatMessage(player, message), 1L);
}
}
}
示例15: shorten
import org.bukkit.ChatColor; //导入方法依赖的package包/类
public static String shorten(String string, String string2) {
if (ChatColor.stripColor(string + string2).length() > 19) return (string + ChatColor.stripColor(string2)).substring(0, 18) + "...";
else return (string + ChatColor.stripColor(string2));
}