Example #1
0
  public static void updatePlayer(Player p) {
    if (!p.isOnline()) {
      return;
    }
    r = 0;
    e = 0;
    if (protocolManager.getProtocolVersion(p) >= 47) {
      TabObject47 tabo = (TabObject47) playerTab47.get(p.getName());
      TabHolder47 tab = tabo.getTab();
      if (tab == null) {
        return;
      }

      clearTab(p);
      for (int b = 0; b < tab.maxv; b++) {
        for (int a = 0; a < tab.maxh; a++) {
          if (tab.tabs[a][b] == null) {
            tab.tabs[a][b] = nextNull();
          }
          String msg = tab.tabs[a][b];
          int ping = tab.tabPings[a][b];
          WrappedGameProfile gameProfile = tab.tabGameProfiles[a][b];
          addPacket(
              p,
              msg == null ? " " : msg.substring(0, Math.min(msg.length(), 16)),
              getSlotId(b, a),
              gameProfile,
              true,
              ping);
        }
      }
      flushPackets(p, tab.getCopy());
    } else {
      TabObject tabo = (TabObject) playerTab.get(p.getName());
      TabHolder tab = tabo.getTab();
      if (tab == null) {
        return;
      }

      clearTab(p);
      for (int b = 0; b < tab.maxv; b++) {
        for (int a = 0; a < tab.maxh; a++) {
          if (tab.tabs[a][b] == null) {
            tab.tabs[a][b] = nextNull();
          }
          String msg = tab.tabs[a][b];
          int ping = tab.tabPings[a][b];
          addPacket(
              p,
              msg == null ? " " : msg.substring(0, Math.min(msg.length(), 16)),
              0,
              null,
              true,
              ping);
        }
      }
      flushPackets(p, tab.getCopy());
    }
  }
Example #2
0
 public static void setTabString(
     Plugin plugin, Player p, int x, int y, String msg, int ping, WrappedGameProfile gameProfile) {
   try {
     if (protocolManager.getProtocolVersion(p) >= 47) {
       TabObject47 tabo = getTab47(p);
       tabo.setTab(plugin, x, y, msg, ping, gameProfile);
       playerTab47.put(p.getName(), tabo);
     } else {
       TabObject tabo = getTab(p);
       tabo.setTab(plugin, x, y, msg, ping);
       playerTab.put(p.getName(), tabo);
     }
   } catch (Exception ex) {
     ex.printStackTrace();
   }
 }