Пример #1
0
  public boolean func_174882_b(final EntityPlayer p_174882_1_) {
    ICommandSender var2 =
        new ICommandSender() {

          public String getName() {
            return p_174882_1_.getName();
          }

          public IChatComponent getDisplayName() {
            return p_174882_1_.getDisplayName();
          }

          public void addChatMessage(IChatComponent message) {}

          public boolean canCommandSenderUseCommand(int permissionLevel, String command) {
            return true;
          }

          public BlockPos getPosition() {
            return TileEntitySign.this.pos;
          }

          public Vec3 getPositionVector() {
            return new Vec3(
                (double) TileEntitySign.this.pos.getX() + 0.5D,
                (double) TileEntitySign.this.pos.getY() + 0.5D,
                (double) TileEntitySign.this.pos.getZ() + 0.5D);
          }

          public World getEntityWorld() {
            return p_174882_1_.getEntityWorld();
          }

          public Entity getCommandSenderEntity() {
            return p_174882_1_;
          }

          public boolean sendCommandFeedback() {
            return false;
          }

          public void func_174794_a(CommandResultStats.Type p_174794_1_, int p_174794_2_) {
            TileEntitySign.this.field_174883_i.func_179672_a(this, p_174794_1_, p_174794_2_);
          }
        };

    for (int var3 = 0; var3 < this.signText.length; ++var3) {
      ChatStyle var4 = this.signText[var3] == null ? null : this.signText[var3].getChatStyle();

      if (var4 != null && var4.getChatClickEvent() != null) {
        ClickEvent var5 = var4.getChatClickEvent();

        if (var5.getAction() == ClickEvent.Action.RUN_COMMAND) {
          MinecraftServer.getServer().getCommandManager().executeCommand(var2, var5.getValue());
        }
      }
    }

    return true;
  }
Пример #2
0
  public boolean executeCommand(final EntityPlayer playerIn) {
    ICommandSender icommandsender =
        new ICommandSender() {
          public String getName() {
            return playerIn.getName();
          }

          public IChatComponent getDisplayName() {
            return playerIn.getDisplayName();
          }

          public void addChatMessage(IChatComponent component) {}

          public boolean canCommandSenderUseCommand(int permLevel, String commandName) {
            return permLevel <= 2;
          }

          public BlockPos getPosition() {
            return TileEntitySign.this.pos;
          }

          public Vec3 getPositionVector() {
            return new Vec3(
                (double) TileEntitySign.this.pos.getX() + 0.5D,
                (double) TileEntitySign.this.pos.getY() + 0.5D,
                (double) TileEntitySign.this.pos.getZ() + 0.5D);
          }

          public World getEntityWorld() {
            return playerIn.getEntityWorld();
          }

          public Entity getCommandSenderEntity() {
            return playerIn;
          }

          public boolean sendCommandFeedback() {
            return false;
          }

          public void setCommandStat(CommandResultStats.Type type, int amount) {
            TileEntitySign.this.stats.func_179672_a(this, type, amount);
          }
        };

    for (int i = 0; i < this.signText.length; ++i) {
      ChatStyle chatstyle = this.signText[i] == null ? null : this.signText[i].getChatStyle();

      if (chatstyle != null && chatstyle.getChatClickEvent() != null) {
        ClickEvent clickevent = chatstyle.getChatClickEvent();

        if (clickevent.getAction() == ClickEvent.Action.RUN_COMMAND) {
          MinecraftServer.getServer()
              .getCommandManager()
              .executeCommand(icommandsender, clickevent.getValue());
        }
      }
    }

    return true;
  }
Пример #3
0
  /** Executes the click event specified by the given chat component */
  protected boolean handleComponentClick(IChatComponent p_175276_1_) {
    if (p_175276_1_ == null) {
      return false;
    } else {
      ClickEvent clickevent = p_175276_1_.getChatStyle().getChatClickEvent();

      if (isShiftKeyDown()) {
        if (p_175276_1_.getChatStyle().getInsertion() != null) {
          this.setText(p_175276_1_.getChatStyle().getInsertion(), false);
        }
      } else if (clickevent != null) {
        if (clickevent.getAction() == ClickEvent.Action.OPEN_URL) {
          if (!this.mc.gameSettings.chatLinks) {
            return false;
          }

          try {
            URI uri = new URI(clickevent.getValue());
            String s = uri.getScheme();

            if (s == null) {
              throw new URISyntaxException(clickevent.getValue(), "Missing protocol");
            }

            if (!PROTOCOLS.contains(s.toLowerCase())) {
              throw new URISyntaxException(
                  clickevent.getValue(), "Unsupported protocol: " + s.toLowerCase());
            }

            if (this.mc.gameSettings.chatLinksPrompt) {
              this.clickedLinkURI = uri;
              this.mc.displayGuiScreen(
                  new GuiConfirmOpenLink(this, clickevent.getValue(), 31102009, false));
            } else {
              this.openWebLink(uri);
            }
          } catch (URISyntaxException urisyntaxexception) {
            LOGGER.error(
                (String) ("Can\'t open url for " + clickevent), (Throwable) urisyntaxexception);
          }
        } else if (clickevent.getAction() == ClickEvent.Action.OPEN_FILE) {
          URI uri1 = (new File(clickevent.getValue())).toURI();
          this.openWebLink(uri1);
        } else if (clickevent.getAction() == ClickEvent.Action.SUGGEST_COMMAND) {
          this.setText(clickevent.getValue(), true);
        } else if (clickevent.getAction() == ClickEvent.Action.RUN_COMMAND) {
          this.sendChatMessage(clickevent.getValue(), false);
        } else if (clickevent.getAction() == ClickEvent.Action.TWITCH_USER_INFO) {
          ChatUserInfo chatuserinfo =
              this.mc.getTwitchStream().func_152926_a(clickevent.getValue());

          if (chatuserinfo != null) {
            this.mc.displayGuiScreen(
                new GuiTwitchUserMode(this.mc.getTwitchStream(), chatuserinfo));
          } else {
            LOGGER.error("Tried to handle twitch user but couldn\'t find them!");
          }
        } else {
          LOGGER.error("Don\'t know how to handle " + clickevent);
        }

        return true;
      }

      return false;
    }
  }