VIPAddMapHandler.java
上传用户:gwt600
上传日期:2021-06-03
资源大小:704k
文件大小:2k
源码类别:

游戏

开发平台:

Java

  1. package net.sf.odinms.net.channel.handler;
  2. import java.sql.Connection;
  3. import java.sql.PreparedStatement;
  4. import java.sql.SQLException;
  5. import net.sf.odinms.client.MapleCharacter;
  6. import net.sf.odinms.client.MapleClient;
  7. import net.sf.odinms.database.DatabaseConnection;
  8. import net.sf.odinms.net.AbstractMaplePacketHandler;
  9. import net.sf.odinms.tools.MaplePacketCreator;
  10. import net.sf.odinms.tools.Pair;
  11. import net.sf.odinms.tools.data.input.SeekableLittleEndianAccessor;
  12. import org.slf4j.Logger;
  13. import org.slf4j.LoggerFactory;
  14. /**
  15.  *
  16.  * @author XoticMS
  17.  */
  18. public class VIPAddMapHandler extends AbstractMaplePacketHandler {
  19.     private static Logger log = LoggerFactory.getLogger(VIPAddMapHandler.class);
  20.     @Override
  21.     public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
  22.         c.getPlayer().resetAfkTime();
  23.         Connection con = DatabaseConnection.getConnection();
  24.         int operation = slea.readByte();
  25.         int type = slea.readByte();
  26.         MapleCharacter player = c.getPlayer();
  27.         switch (operation) {
  28.             case 0: // Remove map
  29.                 int mapid = slea.readInt();
  30.                 try {
  31.                     PreparedStatement ps = con.prepareStatement("DELETE FROM VIPRockMaps WHERE cid = ? AND mapid = ? AND type = ?");
  32.                     ps.setInt(1, player.getId());
  33.                     ps.setInt(2, mapid);
  34.                     ps.setInt(3, type);
  35.                     ps.executeUpdate();
  36.                     ps.close();
  37.                 } catch (SQLException lawl) {
  38.                 }
  39.                 break;
  40.             case 1: // Add map
  41.                 try {
  42.                     PreparedStatement ps = con.prepareStatement("INSERT INTO VIPRockMaps (`cid`, `mapid`, `type`) VALUES (?, ?, ?)");
  43.                     ps.setInt(1, player.getId());
  44.                     ps.setInt(2, player.getMapId());
  45.                     ps.setInt(3, type);
  46.                     ps.executeUpdate();
  47.                     ps.close();
  48.                 } catch (SQLException lawl) {
  49.                 }
  50.                 break;
  51.             default:
  52.                 log.info("Unhandled VIP Rock operation: " + slea.toString());
  53.                 break;
  54.         }
  55.         c.getSession().write(MaplePacketCreator.refreshVIPRockMapList(player.getVIPRockMaps(type), type));
  56.     }
  57. }