コード例 #1
0
ファイル: JSONMessage.java プロジェクト: Trist95/Herotowns
 public JSONMessage color(final ChatColor color) {
   if (!color.isColor()) {
     throw new IllegalArgumentException(color.name() + " is not a color");
   }
   latest().color = color;
   return this;
 }
コード例 #2
0
ファイル: LocaleParser.java プロジェクト: BangL/MinecartMania
 public static String parseColors(String str) {
   for (ChatColor color : ChatColor.values()) {
     String name = "\\[" + color.name().toUpperCase() + "]";
     str = str.replaceAll(name, color.toString());
   }
   return str;
 }
コード例 #3
0
 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();
 }
コード例 #4
0
ファイル: JSONMessage.java プロジェクト: Trist95/Herotowns
 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;
 }
コード例 #5
0
 /**
  * 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;
 }
コード例 #6
0
 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;
   }
 }
コード例 #7
0
ファイル: CItem.java プロジェクト: paul-palmer/ce
 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");
 }
コード例 #8
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);
    }
  }
コード例 #9
0
  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;
    }
  }
コード例 #10
0
ファイル: MessagePart.java プロジェクト: sgdc3/PlotSquared
  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();
  }
コード例 #11
0
ファイル: Title.java プロジェクト: kwek20/LoginPremium2
  /**
   * 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();
      }
    }
  }
コード例 #12
0
ファイル: AutoUpdate.java プロジェクト: russjr08/NewBukkit
 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;
           }
         });
   }
 }
コード例 #13
0
ファイル: GuiEditSign.java プロジェクト: Nakor420/Spoutcraft
  /** 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
  }
コード例 #14
0
 public void setColor(ChatColor color, String player) {
   this.colors.put(player, color.name());
   refreshTag(getNPC());
 }
コード例 #15
0
ファイル: Text.java プロジェクト: ulchm/Kiosk
 public Text setColor(ChatColor color) {
   getChatModifier().setColor(EnumChatFormat.valueOf(color.name()));
   return this;
 }