Code example for DatagramPacket

Methods: getData, getLength, getSocketAddress

0
      this.field_109871_s = new HashMap();
      this.field_109870_t = (new Date()).getTime();
   } 
 
   private void func_109850_a(byte[] var1, DatagramPacket var2) {
      this.field_109863_m.send(new DatagramPacket(var1, var1.length, var2.getSocketAddress()));
   } 
 
   private boolean func_109851_a(DatagramPacket var1) {
      byte[] var2 = var1.getData();
      int var3 = var1.getLength();
      SocketAddress var4 = var1.getSocketAddress();
      this.func_109837_a("Packet len " + var3 + " [" + var4 + "]");
      if(3 <= var3 && -2 == var2[0] && -3 == var2[1]) {
         this.func_109837_a("Packet \'" + C_100807_ip.func_109983_a(var2[2]) + "\' [" + var4 + "]");
         switch(var2[2]) {
         case 0: 
            if(!this.func_109857_c(var1).booleanValue()) {
               this.func_109837_a("Invalid challenge [" + var4 + "]");
               return false; 
            } else if(15 == var3) {
               this.func_109850_a(this.func_109854_b(var1), var1);
               this.func_109837_a("Rules [" + var4 + "]");
            } else { 
               C_100805_io var5 = new C_100805_io(1460);
               var5.func_109973_a(0);
               var5.func_109976_a(this.func_109855_a(var1.getSocketAddress()));
               var5.func_109977_a(this.field_109865_k);
               var5.func_109977_a("SMP");
               var5.func_109977_a(this.field_109862_l);
               var5.func_109977_a(Integer.toString(this.func_109833_d()));
               var5.func_109977_a(Integer.toString(this.field_109864_j));
               var5.func_109974_a((short)this.field_109867_i);
               var5.func_109977_a(this.field_109873_q);
               this.func_109850_a(var5.func_109978_a(), var1);
               this.func_109837_a("Status [" + var4 + "]");
            } 
         case 9: 
            this.func_109852_d(var1);
            this.func_109837_a("Challenge [" + var4 + "]");
            return true; 
         default: 
            return true; 
         } 
      } else { 
         this.func_109837_a("Invalid packet [" + var4 + "]");
         return false; 
      } 
   } 
 
   private byte[] func_109854_b(DatagramPacket var1) {
      long var2 = System.currentTimeMillis();
      if(var2 < this.field_109868_v + 5000L) {
         byte[] var7 = this.field_109869_u.func_109978_a();
         byte[] var8 = this.func_109855_a(var1.getSocketAddress());
         var7[1] = var8[0];
         var7[2] = var8[1];
         var7[3] = var8[2];
         var7[4] = var8[3];
         return var7;
      } else { 
         this.field_109868_v = var2;
         this.field_109869_u.func_109975_b();
         this.field_109869_u.func_109973_a(0);
         this.field_109869_u.func_109976_a(this.func_109855_a(var1.getSocketAddress()));
         this.field_109869_u.func_109977_a("splitnum");
         this.field_109869_u.func_109973_a(128);
         this.field_109869_u.func_109973_a(0);
         this.field_109869_u.func_109977_a("hostname");
         this.field_109869_u.func_109977_a(this.field_109865_k);
         this.field_109869_u.func_109977_a("gametype");
         this.field_109869_u.func_109977_a("SMP");
         this.field_109869_u.func_109977_a("game_id");
         this.field_109869_u.func_109977_a("MINECRAFT");
         this.field_109869_u.func_109977_a("version");
         this.field_109869_u.func_109977_a(this.field_109847_b.func_104895_x());
         this.field_109869_u.func_109977_a("plugins");
         this.field_109869_u.func_109977_a(this.field_109847_b.func_104892_B());
         this.field_109869_u.func_109977_a("map");
         this.field_109869_u.func_109977_a(this.field_109862_l);
         this.field_109869_u.func_109977_a("numplayers");
         this.field_109869_u.func_109977_a("" + this.func_109833_d());
         this.field_109869_u.func_109977_a("maxplayers");
         this.field_109869_u.func_109977_a("" + this.field_109864_j);
         this.field_109869_u.func_109977_a("hostport");
         this.field_109869_u.func_109977_a("" + this.field_109867_i);
         this.field_109869_u.func_109977_a("hostip");
         this.field_109869_u.func_109977_a(this.field_109873_q);
         this.field_109869_u.func_109973_a(0);
         this.field_109869_u.func_109973_a(1);
         this.field_109869_u.func_109977_a("player_");
         this.field_109869_u.func_109973_a(0);
         String[] var4 = this.field_109847_b.func_104890_A();
         byte var5 = (byte)var4.length;
 
         for(byte var6 = (byte)(var5 - 1); var6 >= 0; --var6) {
            this.field_109869_u.func_109977_a(var4[var6]);
         } 
 
         this.field_109869_u.func_109973_a(0);
         return this.field_109869_u.func_109978_a();
      } 
   } 
 
   private byte[] func_109855_a(SocketAddress var1) {
      return ((C_100784_it)this.field_109871_s.get(var1)).func_109891_c();
   } 
 
   private Boolean func_109857_c(DatagramPacket var1) {
      SocketAddress var2 = var1.getSocketAddress();
      if(!this.field_109871_s.containsKey(var2)) {
         return Boolean.valueOf(false);
      } else { 
         byte[] var3 = var1.getData();
         return ((C_100784_it)this.field_109871_s.get(var2)).func_109892_a() != C_100807_ip.func_109984_c(var3, 7, var1.getLength())?Boolean.valueOf(false):Boolean.valueOf(true);
      } 
   } 
 
   private void func_109852_d(DatagramPacket var1) {
      C_100784_it var2 = new C_100784_it(this, var1);
      this.field_109871_s.put(var1.getSocketAddress(), var2);
      this.func_109850_a(var2.func_109894_b(), var1);
   } 
 
   private void func_109858_f() { 
      if(this.field_109849_a) {