Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
24 kB
2
Indexable
Never
package ballistickemu.Tools;

import ballistickemu.Lobby.LobbyServer;
import ballistickemu.Main;
import ballistickemu.Types.StickClient;
import ballistickemu.Types.StickClientRegistry;
import ballistickemu.Types.StickColour;
import ballistickemu.Types.StickItem;
import ballistickemu.Types.StickPacket;
import ballistickemu.Types.StickRoomRegistry;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;

public class StickPacketMaker
{
  public static StickPacket ServerHello()
  {
/*  38 */     StickPacket localStickPacket = new StickPacket();
/*  39 */     localStickPacket.Append("08\000");
/*  40 */     return localStickPacket;
  }
  
  public static StickPacket getNewPlayerUID(String paramString)
  {
/*  45 */     StickPacket localStickPacket = new StickPacket();
/*  46 */     localStickPacket.Append("C");
/*  47 */     localStickPacket.Append(paramString);
/*  48 */     localStickPacket.Append("\000");
/*  49 */     return localStickPacket;
  }
  


  public static StickPacket getRoomList()
  {
/*  56 */     StickPacket localStickPacket = new StickPacket();
/*  57 */     localStickPacket.Append("01");
/*  58 */     localStickPacket.Append(Main.getLobbyServer().getRoomRegistry().GetRoomPacketInfo());
/*  59 */     localStickPacket.Append("\000");
/*  60 */     return localStickPacket;
  }
  
  public static StickPacket GenericSendPacket(String paramString1, String paramString2)
  {
/*  65 */     StickPacket localStickPacket = new StickPacket();
/*  66 */     localStickPacket.Append("M");
/*  67 */     localStickPacket.Append(paramString1);
/*  68 */     localStickPacket.Append(paramString2);
/*  69 */     return localStickPacket;
  }
  
  public static void EchoPacket(byte[] paramArrayOfByte)
  {
/*  74 */     for (int i = 0; i < paramArrayOfByte.length; i++)
    {
/*  76 */       System.out.printf("{0:X} ", new Object[] { Byte.valueOf(paramArrayOfByte[i]) });
    }
/*  78 */     System.out.println("\n");
  }
  

  public static StickPacket GeneralChat(String paramString1, String paramString2)
  {
/*  84 */     StickPacket localStickPacket = new StickPacket();
/*  85 */     localStickPacket.Append("M");
/*  86 */     localStickPacket.Append(paramString1);
/*  87 */     localStickPacket.Append("9");
/*  88 */     localStickPacket.Append(paramString2);
/*  89 */     return localStickPacket;
  }
  
  public static StickPacket Disconnected(String paramString)
  {
/*  94 */     StickPacket localStickPacket = new StickPacket();
/*  95 */     localStickPacket.Append("D");
/*  96 */     localStickPacket.Append(paramString);
/*  97 */     localStickPacket.Append("\000");
/*  98 */     return localStickPacket;
  }
  
  public static StickPacket getSendRoundDetail(String paramString, int paramInt1, int paramInt2, int paramInt3)
  {
/* 103 */     StickPacket localStickPacket = new StickPacket();
/* 104 */     localStickPacket.Append("04");
/* 105 */     localStickPacket.Append(paramString);
/* 106 */     localStickPacket.Append(Integer.toString(paramInt1));
    
/* 108 */     localStickPacket.Append(Integer.toString(paramInt2));
/* 109 */     localStickPacket.Append(Integer.toString(paramInt3 + 31));
/* 110 */     localStickPacket.Append("\000");
/* 111 */     return localStickPacket;
  }
  
  public static StickPacket getMapCycleRequestResponse(String paramString)
  {
/* 116 */     StickPacket localStickPacket = new StickPacket();
/* 117 */     localStickPacket.Append("06mp=");
/* 118 */     localStickPacket.Append(paramString);
/* 119 */     localStickPacket.Append("\000");
/* 120 */     return localStickPacket;
  }
  
  public static StickPacket getSendRoundTimeTest(int paramInt)
  {
/* 125 */     StickPacket localStickPacket = new StickPacket();
/* 126 */     localStickPacket.Append("04");
/* 127 */     localStickPacket.Append(Integer.toString(paramInt));
/* 128 */     localStickPacket.Append("\000");
/* 129 */     return localStickPacket;
  }
  
  public static StickPacket getBroadcastPacket(String paramString1, String paramString2)
  {
/* 134 */     StickPacket localStickPacket = new StickPacket();
/* 135 */     localStickPacket.Append("M");
/* 136 */     localStickPacket.Append(paramString2);
/* 137 */     localStickPacket.Append(paramString1);
/* 138 */     return localStickPacket;
  }
  
  public static StickPacket getMessagePacket(String paramString1, String paramString2)
  {
/* 143 */     StickPacket localStickPacket = new StickPacket();
/* 144 */     localStickPacket.Append("M");
/* 145 */     localStickPacket.Append(paramString2);
/* 146 */     localStickPacket.Append("9");
/* 147 */     localStickPacket.Append(paramString1);
/* 148 */     localStickPacket.Append("\000");
/* 149 */     return localStickPacket;
  }
  
  public static StickPacket getLoginFailed()
  {
/* 154 */     StickPacket localStickPacket = new StickPacket();
/* 155 */     localStickPacket.Append("09");
/* 156 */     localStickPacket.Append("\000");
/* 157 */     return localStickPacket;
  }
  
  public static StickPacket getErrorPacket(String paramString)
  {
/* 162 */     StickPacket localStickPacket = new StickPacket();
/* 163 */     localStickPacket.Append("09");
/* 164 */     localStickPacket.Append(paramString);
/* 165 */     localStickPacket.Append("\000");
/* 166 */     return localStickPacket;
  }
  

  public static StickPacket getLoginSuccess(String paramString1, String paramString2, String paramString3, String paramString4, int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6, int paramInt7, int paramInt8, int paramInt9, int paramInt10)
  {
/* 172 */     StickPacket localStickPacket = new StickPacket();
/* 173 */     localStickPacket.Append("A");
/* 174 */     localStickPacket.Append(paramString1);
/* 175 */     localStickPacket.Append(paramString2);
/* 176 */     localStickPacket.Append(paramString3);
/* 177 */     localStickPacket.Append(paramString4);
/* 178 */     localStickPacket.Append(paramInt1);
/* 179 */     localStickPacket.Append(";");
/* 180 */     localStickPacket.Append(paramInt2);
/* 181 */     localStickPacket.Append(";");
/* 182 */     localStickPacket.Append(paramInt3);
/* 183 */     localStickPacket.Append(";");
/* 184 */     localStickPacket.Append(paramInt4);
/* 185 */     localStickPacket.Append(";");
/* 186 */     localStickPacket.Append(paramInt5);
/* 187 */     localStickPacket.Append(";");
/* 188 */     localStickPacket.Append(paramInt6);
/* 189 */     localStickPacket.Append(";");
/* 190 */     localStickPacket.Append(paramInt7);
/* 191 */     localStickPacket.Append(";");
/* 192 */     localStickPacket.Append(paramInt8);
/* 193 */     localStickPacket.Append(";");
/* 194 */     localStickPacket.Append(paramInt9);
/* 195 */     localStickPacket.Append(";");
/* 196 */     localStickPacket.Append(paramInt10);
/* 197 */     localStickPacket.Append("\000");
/* 198 */     return localStickPacket;
  }
  


  public static StickPacket getClientInfo(String paramString1, String paramString2, String paramString3, int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6, int paramInt7)
  {
/* 205 */     StickPacket localStickPacket = new StickPacket();
    
/* 207 */     localStickPacket.Append("U");
/* 208 */     localStickPacket.Append(paramString1);
/* 209 */     localStickPacket.Append(StringTool.PadStringLeft(paramString2, "#", 20));
/* 210 */     localStickPacket.Append(paramString3);
/* 211 */     localStickPacket.Append(Integer.toString(paramInt1));
/* 212 */     localStickPacket.Append(";");
/* 213 */     localStickPacket.Append(Integer.toString(paramInt2));
/* 214 */     localStickPacket.Append(";");
/* 215 */     localStickPacket.Append(Integer.toString(paramInt3));
/* 216 */     localStickPacket.Append(";");
/* 217 */     localStickPacket.Append(Integer.toString(paramInt4));
/* 218 */     localStickPacket.Append(";");
/* 219 */     localStickPacket.Append(Integer.toString(paramInt5));
/* 220 */     localStickPacket.Append(";");
/* 221 */     localStickPacket.Append(Integer.toString(paramInt6));
/* 222 */     localStickPacket.Append(";");
/* 223 */     localStickPacket.Append(Integer.toString(paramInt7));
/* 224 */     localStickPacket.Append("\000");
    
/* 226 */     return localStickPacket;
  }
  
  public static StickPacket getUserList(StickClientRegistry paramStickClientRegistry, String paramString, Boolean paramBoolean, StickClient paramStickClient)
  {
/* 231 */     StickPacket localStickPacket = new StickPacket();
/* 232 */     ArrayList localArrayList = new ArrayList();
/* 233 */     paramStickClientRegistry.ClientsLock.readLock().lock();
    StickClient localStickClient;
    try {
/* 236 */       for (localIterator = paramStickClientRegistry.getAllClients().iterator(); localIterator.hasNext();) { localStickClient = (StickClient)localIterator.next();
        
        try
        {
/* 240 */           int i = 0;
/* 241 */           if ((paramBoolean.booleanValue()) && (localStickClient.getLobbyStatus().booleanValue()) && (localStickClient.getIoSession() != null) && (localStickClient.getReal().booleanValue()) && (!localStickClient.getUID().equalsIgnoreCase(paramString)))
          {

/* 244 */             if (localStickClient.getPass().booleanValue())
/* 245 */               i = 1;
/* 246 */             localStickPacket.Append("C");
/* 247 */             localStickPacket.Append(localStickClient.getUID());
/* 248 */             localStickPacket.Append("\000");
/* 249 */             localStickPacket.Append("U");
/* 250 */             localStickPacket.Append(localStickClient.getUID());
/* 251 */             localStickPacket.Append(StringTool.PadStringLeft(localStickClient.getName(), "#", 20));
/* 252 */             localStickPacket.Append(localStickClient.getSelectedSpinner().getColour().getColour1AsString().substring(0, 9));
/* 253 */             localStickPacket.Append(Integer.toString(localStickClient.getKills()));
/* 254 */             localStickPacket.Append(";");
/* 255 */             localStickPacket.Append(Integer.toString(localStickClient.getDeaths()));
/* 256 */             localStickPacket.Append(";");
/* 257 */             localStickPacket.Append(Integer.toString(localStickClient.getWins()));
/* 258 */             localStickPacket.Append(";");
/* 259 */             localStickPacket.Append(Integer.toString(localStickClient.getLosses()));
/* 260 */             localStickPacket.Append(";");
/* 261 */             localStickPacket.Append(Integer.toString(localStickClient.getRounds()));
/* 262 */             localStickPacket.Append(";");
/* 263 */             localStickPacket.Append(i);
/* 264 */             localStickPacket.Append(";");
/* 265 */             localStickPacket.Append(Integer.toString(localStickClient.getUserLevel()));
/* 266 */             localStickPacket.Append("\000");
          }
        }
        catch (Exception localException)
        {
/* 271 */           localException.printStackTrace();
/* 272 */           localArrayList.add(localStickClient);
        }
      }
    }
    finally
    {
/* 278 */       paramStickClientRegistry.ClientsLock.readLock().unlock();
    }
    
/* 281 */     for (Iterator localIterator = localArrayList.iterator(); localIterator.hasNext();) { localStickClient = (StickClient)localIterator.next();
      
/* 283 */       paramStickClientRegistry.deregisterClient(localStickClient);
    }
/* 285 */     localArrayList.removeAll(localArrayList);
/* 286 */     return localStickPacket;
  }
  
  public static StickPacket getUpdateUserList(StickClientRegistry paramStickClientRegistry, String paramString, Boolean paramBoolean, StickClient paramStickClient) {
/* 290 */     StickPacket localStickPacket = new StickPacket();
/* 291 */     ArrayList localArrayList = new ArrayList();
/* 292 */     paramStickClientRegistry.ClientsLock.readLock().lock();
    StickClient localStickClient;
    try {
/* 295 */       for (localIterator = paramStickClientRegistry.getAllClients().iterator(); localIterator.hasNext();) { localStickClient = (StickClient)localIterator.next();
        
        try
        {
/* 299 */           int i = 0;
/* 300 */           if ((paramBoolean.booleanValue()) && (localStickClient.getLobbyStatus().booleanValue()) && (localStickClient.getIoSession() != null) && (localStickClient.getReal().booleanValue()) && (!localStickClient.getUID().equalsIgnoreCase(paramString)))
          {

/* 303 */             if (localStickClient.getPass().booleanValue())
/* 304 */               i = 1;
/* 305 */             localStickPacket.Append("U");
/* 306 */             localStickPacket.Append(localStickClient.getUID());
/* 307 */             localStickPacket.Append(StringTool.PadStringLeft(localStickClient.getName(), "#", 20));
/* 308 */             localStickPacket.Append(localStickClient.getSelectedSpinner().getColour().getColour1AsString().substring(0, 9));
/* 309 */             localStickPacket.Append(Integer.toString(localStickClient.getKills()));
/* 310 */             localStickPacket.Append(";");
/* 311 */             localStickPacket.Append(Integer.toString(localStickClient.getDeaths()));
/* 312 */             localStickPacket.Append(";");
/* 313 */             localStickPacket.Append(Integer.toString(localStickClient.getWins()));
/* 314 */             localStickPacket.Append(";");
/* 315 */             localStickPacket.Append(Integer.toString(localStickClient.getLosses()));
/* 316 */             localStickPacket.Append(";");
/* 317 */             localStickPacket.Append(Integer.toString(localStickClient.getRounds()));
/* 318 */             localStickPacket.Append(";");
/* 319 */             localStickPacket.Append(i);
/* 320 */             localStickPacket.Append(";");
/* 321 */             localStickPacket.Append(Integer.toString(localStickClient.getUserLevel()));
/* 322 */             localStickPacket.Append("\000");
          }
        }
        catch (Exception localException)
        {
/* 327 */           localArrayList.add(localStickClient);
        }
      }
    }
    finally
    {
/* 333 */       paramStickClientRegistry.ClientsLock.readLock().unlock();
    }
    
/* 336 */     for (Iterator localIterator = localArrayList.iterator(); localIterator.hasNext();) { localStickClient = (StickClient)localIterator.next();
      
/* 338 */       paramStickClientRegistry.deregisterClient(localStickClient);
    }
/* 340 */     localArrayList.removeAll(localArrayList);
/* 341 */     return localStickPacket;
  }
  


  public static StickPacket getUserListGame(StickClientRegistry paramStickClientRegistry, String paramString, Boolean paramBoolean, StickClient paramStickClient)
  {
/* 348 */     StickPacket localStickPacket = new StickPacket();
/* 349 */     String str = paramStickClient.getUID();
/* 350 */     ArrayList localArrayList = new ArrayList();
/* 351 */     paramStickClientRegistry.ClientsLock.readLock().lock();
    StickClient localStickClient;
    try {
/* 354 */       for (localIterator = paramStickClientRegistry.getAllClients().iterator(); localIterator.hasNext();) { localStickClient = (StickClient)localIterator.next();
        
/* 356 */         if (localStickClient.getName() == null) {
/* 357 */           localStickClient.setName("QuickplayChar");
        }
        try {
/* 360 */           if (!str.equalsIgnoreCase(localStickClient.getUID()))
          {
/* 362 */             localStickPacket.Append("C");
/* 363 */             localStickPacket.Append(localStickClient.getUID());
/* 364 */             localStickPacket.Append("\000");
/* 365 */             localStickPacket.Append("U");
/* 366 */             localStickPacket.Append(localStickClient.getUID());
/* 367 */             localStickPacket.Append(localStickClient.getGameWins());
/* 368 */             localStickPacket.Append(StringTool.PadStringLeft(String.valueOf(localStickClient.getGameKills()), "0", 2));
/* 369 */             localStickPacket.Append(StringTool.PadStringLeft(String.valueOf(localStickClient.getGameDeaths()), "0", 2));
/* 370 */             localStickPacket.Append(StringTool.PadStringLeft(localStickClient.getName(), "#", 20));
/* 371 */             localStickPacket.Append(StringTool.PadStringLeft(String.valueOf(localStickClient.getSelectedSpinner().getItemID() - 100), "0", 2));
/* 372 */             localStickPacket.Append(localStickClient.getSelectedSpinner().getColour().getColour1AsString());
/* 373 */             localStickPacket.Append(localStickClient.getSelectedSpinner().getColour().getColour2AsString());
/* 374 */             localStickPacket.Append(StringTool.PadStringLeft(String.valueOf(localStickClient.getSelectedPet().getItemID() - 200), "0", 2));
/* 375 */             localStickPacket.Append(localStickClient.getSelectedPet().getColour().getColour1AsString());
/* 376 */             localStickPacket.Append(localStickClient.getSelectedPet().getColour().getColour2AsString());
/* 377 */             localStickPacket.Append(localStickClient.getKills());
/* 378 */             localStickPacket.Append("\000");
          }
          
        }
        catch (Exception localException)
        {
/* 384 */           localException.printStackTrace();
/* 385 */           localArrayList.add(localStickClient);
        }
        
      }
    }
    finally
    {
/* 392 */       paramStickClientRegistry.ClientsLock.readLock().unlock();
    }
    

/* 396 */     for (Iterator localIterator = localArrayList.iterator(); localIterator.hasNext();) { localStickClient = (StickClient)localIterator.next();
      
/* 398 */       paramStickClientRegistry.deregisterClient(localStickClient);
    }
/* 400 */     localArrayList.removeAll(localArrayList);
    
/* 402 */     return localStickPacket;
  }
  

  public static StickPacket getUserDataGame(String paramString1, int paramInt1, int paramInt2, int paramInt3, String paramString2, String paramString3, String paramString4, String paramString5, int paramInt4, String paramString6, String paramString7, String paramString8)
  {
/* 408 */     StickPacket localStickPacket = new StickPacket();
/* 409 */     localStickPacket.Append("U");
/* 410 */     localStickPacket.Append(paramString1);
/* 411 */     localStickPacket.Append(paramInt1);
/* 412 */     localStickPacket.Append(StringTool.PadStringLeft(String.valueOf(paramInt2), "0", 2));
/* 413 */     localStickPacket.Append(StringTool.PadStringLeft(String.valueOf(paramInt3), "0", 2));
/* 414 */     localStickPacket.Append(paramString2);
/* 415 */     localStickPacket.Append(paramString3);
/* 416 */     localStickPacket.Append(paramString4);
/* 417 */     localStickPacket.Append(paramString5);
/* 418 */     localStickPacket.Append(paramString6);
/* 419 */     localStickPacket.Append(paramString7);
/* 420 */     localStickPacket.Append(paramString8);
/* 421 */     localStickPacket.Append(paramInt4);
/* 422 */     localStickPacket.Append("\000");
/* 423 */     return localStickPacket;
  }
  
  public static StickPacket getRoomCreatorResponse(String paramString)
  {
/* 428 */     StickPacket localStickPacket = new StickPacket();
/* 429 */     localStickPacket.Append("06rc=");
/* 430 */     localStickPacket.Append(paramString);
/* 431 */     localStickPacket.Append("\000");
/* 432 */     return localStickPacket;
  }
  
  public static StickPacket getDefaultInventoryPacket()
  {
/* 437 */     StickPacket localStickPacket = new StickPacket();
    
/* 439 */     localStickPacket.Append("0c10010430262280430262282598819;20000000000000000000002598820");
/* 440 */     localStickPacket.Append("\000");
/* 441 */     return localStickPacket;
  }
  
  public static StickPacket getInventoryPacket(String paramString)
  {
/* 446 */     StickPacket localStickPacket = new StickPacket();
    
/* 448 */     localStickPacket.Append("0c");
/* 449 */     localStickPacket.Append(paramString);
/* 450 */     localStickPacket.Append("\000");
/* 451 */     return localStickPacket;
  }
  
  public static StickPacket getAnnouncePacket(String paramString)
  {
/* 456 */     StickPacket localStickPacket = new StickPacket();
/* 457 */     localStickPacket.Append("0j");
/* 458 */     localStickPacket.Append(paramString);
/* 459 */     localStickPacket.Append("\000");
/* 460 */     return localStickPacket;
  }
  
  public static StickPacket getPrize(String paramString)
  {
/* 465 */     StickPacket localStickPacket = new StickPacket();
/* 466 */     localStickPacket.Append("0a");
/* 467 */     localStickPacket.Append(paramString);
/* 468 */     localStickPacket.Append("\000");
/* 469 */     return localStickPacket;
  }
  
  public static StickPacket getDLogin()
  {
/* 474 */     StickPacket localStickPacket = new StickPacket();
/* 475 */     localStickPacket.Append("093");
/* 476 */     localStickPacket.Append("\000");
/* 477 */     return localStickPacket;
  }
  
  public static StickPacket getMaps(String paramString1, String paramString2, String paramString3, String paramString4, String paramString5)
  {
/* 482 */     StickPacket localStickPacket = new StickPacket();
/* 483 */     localStickPacket.Append("HTTP/1.1 200 OK..Date: Wed, 16 Nov 2016 11:56:33 GMT..Server: Apache/2.2.3 (CentOS)..X-Powered-By: PHP/5.1.6..Expires: 0..Last-Modified: Wed, 16 Nov 2016 11:56:33 GMT..cache-control: no-store, no-cache, must-revalidate..Pragma: no-cache..Content-Length: 351..Connection: close..Content-Type: text/xml....<?xml version='1.0' encoding='utf-8' ?><rsp stat='ok'>..<maps>...<map slot_id='0'>....<name>");
/* 484 */     localStickPacket.Append(paramString1);
/* 485 */     localStickPacket.Append("</name>...</map>...<map slot_id='1'>....<name>");
/* 486 */     localStickPacket.Append(paramString2);
/* 487 */     localStickPacket.Append("</name>...</map>...<map slot_id='2'>....<name>");
/* 488 */     localStickPacket.Append(paramString3);
/* 489 */     localStickPacket.Append("</name>...</map>...<map slot_id='3'>....<name>");
/* 490 */     localStickPacket.Append(paramString4);
/* 491 */     localStickPacket.Append("</name>...</map>...<map slot_id='4'>....<name>");
/* 492 */     localStickPacket.Append(paramString5);
/* 493 */     localStickPacket.Append("</name>...</map>..</maps>.</rsp>");
/* 494 */     localStickPacket.Append("\000");
/* 495 */     return localStickPacket;
  }
  
  public static StickPacket getModWarn(String paramString)
  {
/* 500 */     StickPacket localStickPacket = new StickPacket();
/* 501 */     localStickPacket.Append("0g");
/* 502 */     localStickPacket.Append(paramString);
/* 503 */     return localStickPacket;
  }
  
  public static StickPacket getBanMsg(String paramString)
  {
/* 508 */     StickPacket localStickPacket = new StickPacket();
/* 509 */     localStickPacket.Append("0e");
/* 510 */     localStickPacket.Append(paramString);
/* 511 */     localStickPacket.Append(";");
/* 512 */     localStickPacket.Append("Until admin unban");
/* 513 */     return localStickPacket;
  }
  
  public static StickPacket getCallbackPacket(String paramString)
  {
/* 518 */     StickPacket localStickPacket = new StickPacket();
/* 519 */     localStickPacket.Append("0h");
/* 520 */     localStickPacket.Append(paramString);
/* 521 */     localStickPacket.Append("\000");
/* 522 */     return localStickPacket;
  }
}