VIPAddMapHandler.java
资源名称:src.rar [点击查看]
上传用户:gwt600
上传日期:2021-06-03
资源大小:704k
文件大小:2k
源码类别:
游戏
开发平台:
Java
- package net.sf.odinms.net.channel.handler;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.SQLException;
- import net.sf.odinms.client.MapleCharacter;
- import net.sf.odinms.client.MapleClient;
- import net.sf.odinms.database.DatabaseConnection;
- import net.sf.odinms.net.AbstractMaplePacketHandler;
- import net.sf.odinms.tools.MaplePacketCreator;
- import net.sf.odinms.tools.Pair;
- import net.sf.odinms.tools.data.input.SeekableLittleEndianAccessor;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- /**
- *
- * @author XoticMS
- */
- public class VIPAddMapHandler extends AbstractMaplePacketHandler {
- private static Logger log = LoggerFactory.getLogger(VIPAddMapHandler.class);
- @Override
- public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
- c.getPlayer().resetAfkTime();
- Connection con = DatabaseConnection.getConnection();
- int operation = slea.readByte();
- int type = slea.readByte();
- MapleCharacter player = c.getPlayer();
- switch (operation) {
- case 0: // Remove map
- int mapid = slea.readInt();
- try {
- PreparedStatement ps = con.prepareStatement("DELETE FROM VIPRockMaps WHERE cid = ? AND mapid = ? AND type = ?");
- ps.setInt(1, player.getId());
- ps.setInt(2, mapid);
- ps.setInt(3, type);
- ps.executeUpdate();
- ps.close();
- } catch (SQLException lawl) {
- }
- break;
- case 1: // Add map
- try {
- PreparedStatement ps = con.prepareStatement("INSERT INTO VIPRockMaps (`cid`, `mapid`, `type`) VALUES (?, ?, ?)");
- ps.setInt(1, player.getId());
- ps.setInt(2, player.getMapId());
- ps.setInt(3, type);
- ps.executeUpdate();
- ps.close();
- } catch (SQLException lawl) {
- }
- break;
- default:
- log.info("Unhandled VIP Rock operation: " + slea.toString());
- break;
- }
- c.getSession().write(MaplePacketCreator.refreshVIPRockMapList(player.getVIPRockMaps(type), type));
- }
- }