public JSONMessage color(final ChatColor color) { if (!color.isColor()) { throw new IllegalArgumentException(color.name() + " is not a color"); } latest().color = color; return this; }
public static String parseColors(String str) { for (ChatColor color : ChatColor.values()) { String name = "\\[" + color.name().toUpperCase() + "]"; str = str.replaceAll(name, color.toString()); } return str; }
private static String getChatName(ChatColor chat) { String name = ""; String[] parts = chat.name().replace('_', ' ').split(" "); for (String s : parts) name += s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase() + " "; return name.trim(); }
public JSONMessage style(final ChatColor... styles) { for (final ChatColor style : styles) { if (!style.isFormat()) { throw new IllegalArgumentException(style.name() + " is not a style"); } } latest().styles = styles; return this; }
/** * Sets the stylization of the current editing component. * * @param styles The array of styles to apply to the editing component. * @return This builder instance. * @exception IllegalArgumentException If any of the enumeration values in the array do not * represent formatters. */ public FancyMessage style(ChatColor... styles) { for (final ChatColor style : styles) { if (!style.isFormat()) { throw new IllegalArgumentException(style.name() + " is not a style"); } } latest().styles.addAll(Arrays.asList(styles)); dirty = true; return this; }
JsonWriter writeJson(JsonWriter json) { try { json.beginObject().name("text").value(text); json.name("color").value(color.name().toLowerCase()); for (final ChatColor style : styles) { String styleName; switch (style) { case MAGIC: styleName = "obfuscated"; break; case UNDERLINE: styleName = "underlined"; break; default: styleName = style.name().toLowerCase(); break; } json.name(styleName).value(true); } if (clickActionName != null && clickActionData != null) { json.name("clickEvent") .beginObject() .name("action") .value(clickActionName) .name("value") .value(clickActionData) .endObject(); } if (hoverActionName != null && hoverActionData != null) { json.name("hoverEvent") .beginObject() .name("action") .value(hoverActionName) .name("value") .value(hoverActionData) .endObject(); } return json.endObject(); } catch (Exception e) { e.printStackTrace(); return json; } }
public CItem( String originalName, ChatColor color, String lDescription, long lCooldown, Material mat) { this.typeString = "Items"; this.itemMaterial = mat; this.originalName = originalName; this.description = new ArrayList<String>(Arrays.asList(lDescription.split(";"))); this.configEntries.add("DisplayName: " + originalName); this.configEntries.add("Color: " + color.name()); this.configEntries.add("Description: " + lDescription); this.configEntries.add("Cooldown: " + lCooldown); this.configEntries.add("Cost: 0"); }
static { for (EntityType type : EntityType.values()) { try { if (TFM_DepreciationAggregator.getName_EntityType(type) != null) { if (Creature.class.isAssignableFrom(type.getEntityClass())) { mobtypes.put(TFM_DepreciationAggregator.getName_EntityType(type).toLowerCase(), type); } } } catch (Exception ex) { } } for (ChatColor chatColor : CHAT_COLOR_POOL) { CHAT_COLOR_NAMES.put(chatColor.name().toLowerCase().replace("_", ""), chatColor); } }
private void attachColorLabels(PopupScreen popup) { int y = 5; for (ChatColor color : ChatColor.values()) { GenericLabel label = new GenericLabel(); label.setText( color + color.name().replace('_', ' ').toLowerCase() + ChatColor.RESET + ": &" + color.getChar()); label.setHeight(25).setWidth(80).setX(300).setY(y); popup.attachWidget(plugin, label); y += 10; } }
static { ImmutableBiMap.Builder<ChatColor, String> builder = ImmutableBiMap.builder(); for (ChatColor style : ChatColor.values()) { if (!style.isFormat()) { continue; } String styleName; switch (style) { case MAGIC: styleName = "obfuscated"; break; case UNDERLINE: styleName = "underlined"; break; default: styleName = style.name().toLowerCase(); break; } builder.put(style, styleName); } stylesToNames = builder.build(); }
/** * Send the title to a player * * @param player Player */ public void send(Player player) { if (packetTitle != null) { // First reset previous settings resetTitle(player); try { // Send timings first Object handle = getHandle(player); Object connection = getField(handle.getClass(), "playerConnection").get(handle); Object[] actions = packetActions.getEnumConstants(); Method sendPacket = getMethod(connection.getClass(), "sendPacket"); Object packet = packetTitle .getConstructor( packetActions, chatBaseComponent, Integer.TYPE, Integer.TYPE, Integer.TYPE) .newInstance( actions[2], null, fadeInTime * (ticks ? 1 : 20), stayTime * (ticks ? 1 : 20), fadeOutTime * (ticks ? 1 : 20)); // Send if set if (fadeInTime != -1 && fadeOutTime != -1 && stayTime != -1) sendPacket.invoke(connection, packet); // Send title Object serialized = getMethod(nmsChatSerializer, "a", String.class) .invoke( null, "{text:\"" + ChatColor.translateAlternateColorCodes('&', title) + "\",color:" + titleColor.name().toLowerCase() + "}"); packet = packetTitle .getConstructor(packetActions, chatBaseComponent) .newInstance(actions[0], serialized); sendPacket.invoke(connection, packet); if (subtitle != "") { // Send subtitle if present serialized = getMethod(nmsChatSerializer, "a", String.class) .invoke( null, "{text:\"" + ChatColor.translateAlternateColorCodes('&', subtitle) + "\",color:" + subtitleColor.name().toLowerCase() + "}"); packet = packetTitle .getConstructor(packetActions, chatBaseComponent) .newInstance(actions[1], serialized); sendPacket.invoke(connection, packet); } } catch (Exception e) { e.printStackTrace(); } } }
private void printStackTraceSync(Throwable t, boolean expected) { BukkitScheduler bs = plugin.getServer().getScheduler(); try { String prefix = plugin.getName() + " [AutoUpdate] "; StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); t.printStackTrace(pw); String[] sts = sw.toString().replace("\r", "").split("\n"); String[] out; if (expected) out = new String[sts.length + 31]; else out = new String[sts.length + 33]; out[0] = prefix; out[1] = prefix + "Internal error!"; out[2] = prefix + "If this bug hasn't been reported please open a ticket at http://dev.bukkit.org/server-mods/iFail"; out[3] = prefix + "Include the following into your bug report:"; out[4] = prefix + " ======= SNIP HERE ======="; int i = 5; for (; i - 5 < sts.length; i++) out[i] = prefix + sts[i - 5]; out[++i] = prefix + " ======= DUMP ======="; out[++i] = prefix + "version : " + version; out[++i] = prefix + "delay : " + delay; out[++i] = prefix + "ymlPrefix : " + ymlPrefix; out[++i] = prefix + "ymlSuffix : " + ymlSuffix; out[++i] = prefix + "bukkitdevPrefix: " + bukkitdevPrefix; out[++i] = prefix + "bukkitdevSuffix: " + bukkitdevSuffix; out[++i] = prefix + "bukkitdevSlug : " + bukkitdevSlug; out[++i] = prefix + "COLOR_INFO : " + COLOR_INFO.name(); out[++i] = prefix + "COLO_OK : " + COLOR_OK.name(); out[++i] = prefix + "COLOR_ERROR : " + COLOR_ERROR.name(); out[++i] = prefix + "bukget : " + bukget; out[++i] = prefix + "bukgetFallback : " + bukgetFallback; out[++i] = prefix + "pid : " + pid; out[++i] = prefix + "av : " + av; out[++i] = prefix + "config : " + config; out[++i] = prefix + "lock : " + lock.get(); out[++i] = prefix + "needUpdate : " + needUpdate; out[++i] = prefix + "updatePending : " + updatePending; out[++i] = prefix + "UpdateUrl : " + updateURL; out[++i] = prefix + "updateVersion : " + updateVersion; out[++i] = prefix + "pluginURL : " + pluginURL; out[++i] = prefix + "type : " + type; out[++i] = prefix + " ======= SNIP HERE ======="; out[++i] = prefix; if (!expected) { out[++i] = prefix + "DISABLING UPDATER!"; out[++i] = prefix; } bs.scheduleSyncDelayedTask(plugin, new SyncMessageDelayer(null, out)); } catch (Throwable e) // This prevents endless loops. { e.printStackTrace(); } if (!expected) { bs.cancelTask(pid); bs.scheduleAsyncDelayedTask( plugin, new Runnable() { public void run() { while (!lock.compareAndSet(false, true)) { try { Thread.sleep(1L); } catch (InterruptedException e) { } } pid = -1; config = null; needUpdate = updatePending = false; updateURL = updateVersion = pluginURL = type = null; } }); } }
/** Draws the screen and all the components in it. */ public void drawScreen(int x, int y, float z) { drawDefaultBackground(); drawCenteredString(fontRenderer, screenTitle, width / 2, 40, 0xffffff); // Spout Start if (org.spoutcraft.client.config.ConfigReader.showChatColors) { for (int c = 0; c < 16; c++) { ChatColor value = ChatColor.getByCode(c); String name = value.name().toLowerCase(); boolean lastUnderscore = true; String parsedName = ""; for (int chr = 0; chr < name.length(); chr++) { char ch = name.charAt(chr); if (lastUnderscore) { ch = Character.toUpperCase(ch); } if (ch == '_') { lastUnderscore = true; ch = ' '; } else { lastUnderscore = false; } parsedName += ch; } char code = (char) ('0' + c); if (c >= 10) { code = (char) ('a' + c - 10); } fontRenderer.drawStringWithShadow( "&" + code + " - " + value + parsedName, width - 90, 70 + c * 10, 0xffffffff); } } // Spout end GL11.glPushMatrix(); GL11.glTranslatef(width / 2, 0.0F, 50F); float f = 93.75F; GL11.glScalef(-f, -f, -f); GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); Block block = entitySign.getBlockType(); if (block == Block.signPost) { float f1 = (float) (entitySign.getBlockMetadata() * 360) / 16F; GL11.glRotatef(f1, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(0.0F, -1.0625F, 0.0F); } else { int i = entitySign.getBlockMetadata(); float f2 = 0.0F; if (i == 2) { f2 = 180F; } if (i == 4) { f2 = 90F; } if (i == 5) { f2 = -90F; } GL11.glRotatef(f2, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(0.0F, -1.0625F, 0.0F); } // Spout start // if(this.updateCounter / 6 % 2 == 0) { this.entitySign.lineBeingEdited = this.editLine; entitySign.columnBeingEdited = editColumn; // } // Spout end TileEntityRenderer.instance.renderTileEntityAt(entitySign, -0.5D, -0.75D, -0.5D, 0.0F); // Spout start this.entitySign.lineBeingEdited = -1; entitySign.columnBeingEdited = -1; // Spout end GL11.glPopMatrix(); super.drawScreen(x, y, z); // Spout start if (unicode.enabled && isInBoundingRect( unicode.xPosition, unicode.yPosition, unicode.field_52007_b, unicode.field_52008_a, x, y)) { this.drawTooltip( "Some servers censor unicode characters. \nIf yours does, try sending as plain text.", x, y); } // Spout end }
public void setColor(ChatColor color, String player) { this.colors.put(player, color.name()); refreshTag(getNPC()); }
public Text setColor(ChatColor color) { getChatModifier().setColor(EnumChatFormat.valueOf(color.name())); return this; }