Advertisement
VANPER

Protocol Version

Dec 12th, 2020
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.90 KB | None | 0 0
  1. /*
  2.  * This file is part of the L2J Dev project.
  3.  *
  4.  * This program is free software: you can redistribute it and/or modify
  5.  * it under the terms of the GNU General Public License as published by
  6.  * the Free Software Foundation, either version 3 of the License, or
  7.  * (at your option) any later version.
  8.  *
  9.  * This program is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12.  * General Public License for more details.
  13.  *
  14.  * You should have received a copy of the GNU General Public License
  15.  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16.  */
  17. package l2j.dev.gameserver.network.clientpackets;
  18.  
  19. import java.util.logging.Logger;
  20.  
  21. import l2j.dev.Config;
  22. import l2j.dev.gameserver.network.serverpackets.GameServerPacket;
  23. import l2j.dev.gameserver.network.serverpackets.KeyPacket;
  24.  
  25. public class ProtocolVersion extends GameClientPacket
  26. {
  27.     static Logger LOGGER = Logger.getLogger(ProtocolVersion.class.getName());
  28.     private int _version;
  29.    
  30.     @Override
  31.     protected void readImpl()
  32.     {
  33.         _version = readD();
  34.     }
  35.    
  36.     @Override
  37.     protected void runImpl()
  38.     {
  39.         if ((_version == 65534) || (_version == -2)) // Ping
  40.         {
  41.             getClient().close((GameServerPacket) null);
  42.         }
  43.         else if ((_version < Config.MIN_PROTOCOL_REVISION) || (_version > Config.MAX_PROTOCOL_REVISION))
  44.         {
  45.             LOGGER.info("Client: " + getClient() + " -> Protocol Revision: " + _version + " is invalid. Minimum is " + Config.MIN_PROTOCOL_REVISION + " and Maximum is " + Config.MAX_PROTOCOL_REVISION + " are supported. Closing connection.");
  46.             LOGGER.warning("Wrong Protocol Version " + _version);
  47.             getClient().close((GameServerPacket) null);
  48.         }
  49.         else
  50.         {
  51.             getClient().setProtocolVersion(_version);
  52.             getClient().sendPacket(new KeyPacket(getClient().enableCrypt()));
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement