コード例 #1
0
  @Override
  public boolean isPlayerOnline(String username) {
    NetHandlerPlayClient netclienthandler = Minecraft.getMinecraft().thePlayer.sendQueue;
    Collection collection = netclienthandler.getPlayerInfoMap();

    Iterator<NetworkPlayerInfo> iterator = collection.iterator();

    while (iterator.hasNext()) {
      NetworkPlayerInfo info = iterator.next();

      if (info.getGameProfile().getName().toLowerCase().equals(username.toLowerCase())) {
        return true;
      }
    }

    return false;
  }
コード例 #2
0
ファイル: SkyNet.java プロジェクト: TealNerd/SkyNet
 @SubscribeEvent
 public void onTick(ClientTickEvent event) {
   if (event.phase == TickEvent.Phase.START) {
     if (isEnabled) {
       if (mc.theWorld != null) {
         ArrayList<String> playerList = new ArrayList();
         Collection<NetworkPlayerInfo> players = mc.getConnection().getPlayerInfoMap();
         for (NetworkPlayerInfo info : players) {
           playerList.add(filterChatColors(info.getGameProfile().getName()));
         }
         ArrayList<String> temp = (ArrayList) playerList.clone();
         playerList.removeAll(previousPlayerList);
         previousPlayerList.removeAll(temp);
         for (String player : previousPlayerList) {
           onPlayerLeave(player);
         }
         for (String player : playerList) {
           onPlayerJoin(player);
         }
         previousPlayerList = temp;
       }
     }
   }
 }