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);
   }
 }
 public static void cancelTrade(MapleCharacter c) {
   c.getTrade().cancel();
   if (c.getTrade().getPartner() != null) {
     c.getTrade().getPartner().cancel();
     c.getTrade().getPartner().getChr().setTrade(null);
   }
   c.setTrade(null);
 }
 public static void startTrade(MapleCharacter c) {
   if (c.getTrade() == null) {
     c.setTrade(new MapleTrade((byte) 0, c));
     c.getClient()
         .getSession()
         .write(MaplePacketCreator.getTradeStart(c.getClient(), c.getTrade(), (byte) 0));
   } else {
     c.message("You are already in a trade.");
   }
 }
 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);
   }
 }
 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);
   }
 }