Example #1
0
  @SubscribeEvent
  public void tickStart(PlayerTickEvent evt) {

    if (evt.phase != Phase.START) {
      return;
    }
    if (lastPoll > 0) {
      --lastPoll;
      return;
    }
    lastPoll = 400;

    if (!_notificationDisplayed && _updateThread.checkComplete()) {
      _notificationDisplayed = true;
      FMLCommonHandler.instance().bus().unregister(this);
      if (_updateThread.newVersionAvailable()) {
        if (!CoFHProps.enableUpdateNotice && !_updateThread.isCriticalUpdate()) {
          return;
        }
        ModVersion newVersion = _updateThread.newVersion();

        EntityPlayer player = evt.player;
        player.addChatMessage(
            new ChatComponentText(GOLD + "[" + _mod.getModName() + "]")
                .appendText(WHITE + " A new version is available:"));
        IChatComponent chat;
        String text = newVersion.modVersion().toString();
        if (Strings.isNullOrEmpty(_downloadUrl)) {
          chat = new ChatComponentText(text).setChatStyle(version);
        } else {
          chat =
              IChatComponent.Serializer.func_150699_a(
                  "[{\"text\":\""
                      + text
                      + "\",\"color\":\"aqua\"},"
                      + "{\"text\":\" "
                      + WHITE
                      + "["
                      + GREEN
                      + "Download"
                      + WHITE
                      + "]\","
                      + "\"color\":\"green\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":"
                      + "{\"text\":\"Click this to download the latest version\",\"color\":\"yellow\"}},"
                      + "\"clickEvent\":{\"action\":\"open_url\",\"value\":\""
                      + _downloadUrl
                      + "\"}}]");
        }
        player.addChatMessage(chat);
        player.addChatMessage(
            new ChatComponentText(newVersion.description()).setChatStyle(description));
      }
    }
  }
  public void func_71515_b(ICommandSender p_71515_1_, String[] p_71515_2_) throws CommandException {
    if (p_71515_2_.length < 2) {
      throw new WrongUsageException("commands.tellraw.usage", new Object[0]);
    } else {
      EntityPlayerMP var3 = func_82359_c(p_71515_1_, p_71515_2_[0]);
      String var4 = func_180529_a(p_71515_2_, 1);

      try {
        IChatComponent var5 = IChatComponent.Serializer.func_150699_a(var4);
        var3.func_145747_a(ChatComponentProcessor.func_179985_a(p_71515_1_, var5, var3));
      } catch (JsonParseException var7) {
        Throwable var6 = ExceptionUtils.getRootCause(var7);
        throw new SyntaxErrorException(
            "commands.tellraw.jsonException", new Object[] {var6 == null ? "" : var6.getMessage()});
      }
    }
  }
  /** Draws all of the hovering texts for the buttons that need explanation in the booklet */
  @SuppressWarnings("unchecked")
  public static void doHoverTexts(GuiBooklet booklet, int mouseX, int mouseY) {
    // Achievements Hover Text
    if (booklet.buttonAchievements.func_146115_a()) {
      booklet.drawHoveringText(
          Collections.singletonList(EnumChatFormatting.GOLD + "Show Achievements"), mouseX, mouseY);
    }
    // Config Hover Text
    else if (booklet.buttonConfig.func_146115_a()) {
      ArrayList list = new ArrayList();
      list.add(EnumChatFormatting.GOLD + "Show Configuration GUI");
      list.addAll(
          booklet
              .getFontRenderer()
              .listFormattedStringToWidth(
                  "It is highly recommended that you restart your game after changing anything as that prevents possible bugs occuring!",
                  GuiBooklet.TOOLTIP_SPLIT_LENGTH));
      booklet.drawHoveringText(list, mouseX, mouseY);

    }
    // Twitter Hover Text
    else if (booklet.buttonTwitter.func_146115_a()) {
      booklet.drawHoveringText(
          Collections.singletonList(
              EnumChatFormatting.GOLD + "Open @ActAddMod on Twitter in Browser"),
          mouseX,
          mouseY);
    }
    // Forum Hover Text
    else if (booklet.buttonForum.func_146115_a()) {
      booklet.drawHoveringText(
          Collections.singletonList(
              EnumChatFormatting.GOLD + "Open Minecraft Forum Post in Browser"),
          mouseX,
          mouseY);
    }
    // Update Checker Hover Text
    else if (booklet.buttonUpdate.func_146115_a()) {
      ArrayList list = new ArrayList();
      if (UpdateChecker.checkFailed) {
        list.add(
            IChatComponent.Serializer.func_150699_a(
                    StringUtil.localize("info." + ModUtil.MOD_ID_LOWER + ".update.failed"))
                .getFormattedText());
      } else if (UpdateChecker.needsUpdateNotify) {
        list.add(
            IChatComponent.Serializer.func_150699_a(
                    StringUtil.localize("info." + ModUtil.MOD_ID_LOWER + ".update.generic"))
                .getFormattedText());
        list.add(
            IChatComponent.Serializer.func_150699_a(
                    StringUtil.localizeFormatted(
                        "info." + ModUtil.MOD_ID_LOWER + ".update.versionCompare",
                        ModUtil.VERSION,
                        UpdateChecker.updateVersion))
                .getFormattedText());
        list.add(StringUtil.localize("info." + ModUtil.MOD_ID_LOWER + ".update.buttonOptions"));
      }
      booklet.drawHoveringText(list, mouseX, mouseY);
    } else {
      for (GuiButton button : booklet.bookmarkButtons) {
        if (button instanceof BookmarkButton && button.func_146115_a()) {
          ((BookmarkButton) button).drawHover(mouseX, mouseY);
        }
      }
    }
  }