Exemplo n.º 1
0
 public static void inviteTrade(MapleCharacter c1, MapleCharacter c2) {
   if (c2.getTrade() == null) {
     c2.setTrade(new MapleTrade((byte) 1, c2));
     c2.getTrade().setPartner(c1.getTrade());
     c1.getTrade().setPartner(c2.getTrade());
     c2.getClient().getSession().write(MaplePacketCreator.getTradeInvite(c1));
   } else {
     c1.message("The other player is already trading with someone else.");
     cancelTrade(c1);
   }
 }
Exemplo n.º 2
0
 public static void completeTrade(MapleCharacter c) {
   c.getTrade().lock();
   MapleTrade local = c.getTrade();
   MapleTrade partner = local.getPartner();
   if (partner.isLocked()) {
     local.complete1();
     partner.complete1();
     if (!local.fitsInInventory() || !partner.fitsInInventory()) {
       cancelTrade(c);
       c.message("There is not enough inventory space to complete the trade.");
       partner.getChr().message("There is not enough inventory space to complete the trade.");
       return;
     }
     if (local.getChr().getLevel() < 15) {
       if (local.getChr().getMesosTraded() + local.exchangeMeso > 1000000) {
         cancelTrade(c);
         local.getChr().getClient().getSession().write(MaplePacketCreator.sendMesoLimit());
         return;
       } else {
         local.getChr().addMesosTraded(local.exchangeMeso);
       }
     } else if (c.getTrade().getChr().getLevel() < 15) {
       if (c.getMesosTraded() + c.getTrade().exchangeMeso > 1000000) {
         cancelTrade(c);
         c.getClient().getSession().write(MaplePacketCreator.sendMesoLimit());
         return;
       } else {
         c.addMesosTraded(local.exchangeMeso);
       }
     }
     local.complete2();
     partner.complete2();
     partner.getChr().setTrade(null);
     c.setTrade(null);
   }
 }
Exemplo n.º 3
0
 public void disconnect() {
   if (player != null && isLoggedIn()) {
     if (player.getTrade() != null) {
       MapleTrade.cancelTrade(player);
     }
     player.saveCooldowns();
     //            player.getFamily().setPlayer(null);
     MapleMiniGame game = player.getMiniGame();
     if (game != null) {
       player.setMiniGame(null);
       if (game.isOwner(player)) {
         player.getMap().broadcastMessage(MaplePacketCreator.removeCharBox(player));
         game.broadcastToVisitor(MaplePacketCreator.getMiniGameClose((byte) 0));
       } else {
         game.removeVisitor(player);
       }
     }
     player.cancelAllBuffs();
     if (player.getEventInstance() != null) {
       player.getEventInstance().playerDisconnected(player);
     }
     HiredMerchant merchant = player.getHiredMerchant();
     if (merchant != null) {
       if (merchant.isOwner(player)) {
         merchant.setOpen(true);
       } else {
         merchant.removeVisitor(player);
       }
     }
     player.unequipAllPets();
     try {
       WorldChannelInterface wci = getChannelServer().getWorldInterface();
       if (player.getMessenger() != null) {
         MapleMessengerCharacter messengerplayer = new MapleMessengerCharacter(player);
         wci.leaveMessenger(player.getMessenger().getId(), messengerplayer);
         player.setMessenger(null);
       }
     } catch (RemoteException e) {
       getChannelServer().reconnectWorld();
       e.printStackTrace();
     }
     NPCScriptManager npcsm = NPCScriptManager.getInstance();
     if (npcsm != null) {
       npcsm.dispose(this);
     }
     if (!player.isAlive()) {
       player.setHp(50, true);
     }
     player.setMessenger(null);
     player.saveToDB(true);
     player.getMap().removePlayer(player);
     try {
       WorldChannelInterface wci = getChannelServer().getWorldInterface();
       if (player.getParty() != null) {
         MaplePartyCharacter chrp = new MaplePartyCharacter(player);
         chrp.setOnline(false);
         wci.updateParty(player.getParty().getId(), PartyOperation.LOG_ONOFF, chrp);
       }
     } catch (RemoteException e) {
       getChannelServer().reconnectWorld();
       e.printStackTrace();
     }
     try {
       WorldChannelInterface wci = getChannelServer().getWorldInterface();
       if (!this.serverTransition && isLoggedIn()) {
         wci.loggedOff(
             player.getName(), player.getId(), channel, player.getBuddylist().getBuddyIds());
       } else {
         wci.loggedOn(
             player.getName(), player.getId(), channel, player.getBuddylist().getBuddyIds());
       }
       if (player.getGuildId() > 0) {
         wci.setGuildMemberOnline(player.getMGC(), false, -1);
         int allianceId = player.getGuild().getAllianceId();
         if (allianceId > 0) {
           wci.allianceMessage(
               allianceId,
               MaplePacketCreator.allianceMemberOnline(player, false),
               player.getId(),
               -1);
         }
       }
     } catch (RemoteException e) {
       getChannelServer().reconnectWorld();
     } catch (Exception e) {
       e.printStackTrace();
     } finally {
       if (getChannelServer() != null) {
         getChannelServer().removePlayer(player);
       }
       this.getSession().close();
     }
   }
   if (!this.serverTransition && isLoggedIn()) {
     this.updateLoginState(LOGIN_NOTLOGGEDIN);
   }
 }