コード例 #1
0
  private byte[] getFullReply(DatagramPacket datagrampacket) {
    long i = MinecraftServer.aq();

    if (i < this.cacheTime + 5000L) {
      byte[] abyte = this.cachedReply.getBytes();
      byte[] abyte1 = this.getIdentityToken(datagrampacket.getSocketAddress());

      abyte[1] = abyte1[0];
      abyte[2] = abyte1[1];
      abyte[3] = abyte1[2];
      abyte[4] = abyte1[3];
      return abyte;
    } else {
      this.cacheTime = i;
      this.cachedReply.reset();
      this.cachedReply.write((int) 0);
      this.cachedReply.write(this.getIdentityToken(datagrampacket.getSocketAddress()));
      this.cachedReply.write("splitnum");
      this.cachedReply.write((int) 128);
      this.cachedReply.write((int) 0);
      this.cachedReply.write("hostname");
      this.cachedReply.write(this.localAddress);
      this.cachedReply.write("gametype");
      this.cachedReply.write("SMP");
      this.cachedReply.write("game_id");
      this.cachedReply.write("MINECRAFT");
      this.cachedReply.write("version");
      this.cachedReply.write(this.server.getVersion());
      this.cachedReply.write("plugins");
      this.cachedReply.write(this.server.getPlugins());
      this.cachedReply.write("map");
      this.cachedReply.write(this.worldName);
      this.cachedReply.write("numplayers");
      this.cachedReply.write("" + this.d());
      this.cachedReply.write("maxplayers");
      this.cachedReply.write("" + this.maxPlayers);
      this.cachedReply.write("hostport");
      this.cachedReply.write("" + this.serverPort);
      this.cachedReply.write("hostip");
      this.cachedReply.write(this.hostname);
      this.cachedReply.write((int) 0);
      this.cachedReply.write((int) 1);
      this.cachedReply.write("player_");
      this.cachedReply.write((int) 0);
      String[] astring = this.server.getPlayers();
      byte b0 = (byte) astring.length;

      for (byte b1 = (byte) (b0 - 1); b1 >= 0; --b1) {
        this.cachedReply.write(astring[b1]);
      }

      this.cachedReply.write((int) 0);
      return this.cachedReply.getBytes();
    }
  }
コード例 #2
0
  private void cleanChallenges() {
    if (this.running) {
      long i = MinecraftServer.aq();

      if (i >= this.clearedTime + 30000L) {
        this.clearedTime = i;
        Iterator iterator = this.challenges.entrySet().iterator();

        while (iterator.hasNext()) {
          Entry entry = (Entry) iterator.next();

          if (((RemoteStatusChallenge) entry.getValue()).isExpired(i).booleanValue()) {
            iterator.remove();
          }
        }
      }
    }
  }
コード例 #3
0
  public void run() {
    this.info("Query running on " + this.motd + ":" + this.bindPort);
    this.clearedTime = MinecraftServer.aq();
    this.o = new DatagramPacket(this.n, this.n.length);

    try {
      while (this.running) {
        try {
          this.socket.receive(this.o);
          this.cleanChallenges();
          this.parsePacket(this.o);
        } catch (SocketTimeoutException sockettimeoutexception) {
          this.cleanChallenges();
        } catch (PortUnreachableException portunreachableexception) {;
        } catch (IOException ioexception) {
          this.a(ioexception);
        }
      }
    } finally {
      this.e();
    }
  }