예제 #1
0
 public static void declineTrade(MapleCharacter c) {
   MapleTrade trade = c.getTrade();
   if (trade != null) {
     if (trade.getPartner() != null) {
       MapleCharacter other = trade.getPartner().getChr();
       other.getTrade().cancel();
       other.setTrade(null);
       other.message(c.getName() + " has declined your trade request.");
     }
     trade.cancel();
     c.setTrade(null);
   }
 }
예제 #2
0
 public void chat(String message) {
   chr.getClient().getSession().write(MaplePacketCreator.getTradeChat(chr, message, true));
   if (partner != null) {
     partner
         .getChr()
         .getClient()
         .getSession()
         .write(MaplePacketCreator.getTradeChat(chr, message, false));
   }
 }
예제 #3
0
 public void addItem(IItem item) {
   items.add(item);
   chr.getClient().getSession().write(MaplePacketCreator.getTradeItemAdd((byte) 0, item));
   if (partner != null) {
     partner
         .getChr()
         .getClient()
         .getSession()
         .write(MaplePacketCreator.getTradeItemAdd((byte) 1, item));
   }
 }
예제 #4
0
 public void setMeso(int meso) {
   if (locked) {
     throw new RuntimeException("Trade is locked.");
   }
   if (meso < 0) {
     System.out.println("[h4x] " + chr.getName() + " Trying to trade < 0 mesos");
     return;
   }
   if (chr.getMeso() >= meso) {
     chr.gainMeso(-meso, false, true, false);
     this.meso += meso;
     chr.getClient().getSession().write(MaplePacketCreator.getTradeMesoSet((byte) 0, this.meso));
     if (partner != null) {
       partner
           .getChr()
           .getClient()
           .getSession()
           .write(MaplePacketCreator.getTradeMesoSet((byte) 1, this.meso));
     }
   } else {
   }
 }
예제 #5
0
 private void complete1() {
   exchangeItems = partner.getItems();
   exchangeMeso = partner.getMeso();
 }
예제 #6
0
 private void lock() {
   locked = true;
   partner.getChr().getClient().getSession().write(MaplePacketCreator.getTradeConfirmation());
 }
예제 #7
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);
   }
 }
예제 #8
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);
   }
 }