Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.43 KB | None | 0 0
  1. package org.efi.gameserver.network.la2.in;
  2.  
  3. import org.efi.Config;
  4. import org.efi.gameserver.network.la2.L2GameClient;
  5. import org.efi.gameserver.network.la2.L2GameClientPacket;
  6. import org.efi.gameserver.network.la2.out.KeyPacket;
  7. import com.lameguard.LameGuard;
  8. import com.lameguard.exception.LameGuardException;
  9. import java.util.logging.Logger;
  10.  
  11. public final class ProtocolVersion extends L2GameClientPacket
  12. {
  13.     private static final String _C__00_PROTOCOLVERSION = "[C] 00 ProtocolVersion";
  14.    
  15.     static Logger _log _log = Logger.getLogger(ProtocolVersion.class.getName());
  16.    
  17.     private int _version;
  18.     private byte[] __data;
  19.     private int __version;
  20.     private int __patch;
  21.     private int __instances;
  22.  
  23.     public ProtocolVersion()
  24.     {
  25.         __data = null;
  26.         __version = 0;
  27.         __patch = 0;
  28.         __instances = 0;
  29.     }
  30.  
  31.     protected void runImplOld()
  32.     {
  33.         if (_version == -2)
  34.         {
  35.             if (Config.DEBUG)
  36.             {
  37.                 _log.info("Ping received");
  38.             }
  39.  
  40.             ((L2GameClient)getClient()).closeNow();
  41.         }
  42.         else if (_version < Config.MIN_PROTOCOL_REVISION || _version > Config.MAX_PROTOCOL_REVISION)
  43.         {
  44.             _log.info("Client: " + ((L2GameClient)getClient()).toString() + " -> Protocol Revision: " + _version + " is invalid. Minimum is " + Config.MIN_PROTOCOL_REVISION + " and Maximum is " + Config.MAX_PROTOCOL_REVISION + " are supported. Closing connection.");
  45.             _log.warning("Wrong Protocol Version " + _version);
  46.             ((L2GameClient)getClient()).closeNow();
  47.         }
  48.         else
  49.         {
  50.             if (Config.DEBUG)
  51.             {
  52.                 _log.fine("Client Protocol Revision is ok: " + _version);
  53.             }
  54.  
  55.             KeyPacket pk = new KeyPacket(((L2GameClient)getClient()).enableCrypt());
  56.             ((L2GameClient)getClient()).sendPacket(pk);
  57.         }
  58.     }
  59.  
  60.     protected void readImpl()
  61.     {
  62.         __data = new byte[256];
  63.        
  64.         try
  65.         {
  66.             _version = readD();
  67.         }
  68.         catch (Exception localException1)
  69.         {
  70.             getClient().closeNow();
  71.             return;
  72.         }
  73.        
  74.         try
  75.         {
  76.             __version = readH();
  77.             __patch = (readC() & 0xFF);
  78.             __instances = (readC() & 0xFF);
  79.             readB(__data);
  80.         }
  81.         catch (Exception localException2)
  82.         {
  83.             __data = null;
  84.             return;
  85.         }
  86.     }
  87.  
  88.     protected void runImpl()
  89.     {
  90.         try
  91.         {
  92.             LameGuard.getInstance().onProtocolVersionPacket(getClient(), _version, __version, __patch, __instances, __data);
  93.             runImplOld();
  94.         }
  95.         catch (LameGuardException localLameGuardException)
  96.         {
  97.             getClient().closeNow();
  98.             return;
  99.         }
  100.     }
  101.    
  102.     public String getType()
  103.     {
  104.         return _C__00_PROTOCOLVERSION;
  105.     }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement