// TODO only notify channels where partymembers are?
 public void updateParty(int partyid, PartyOperation operation, MaplePartyCharacter target)
     throws RemoteException {
   MapleParty party = WorldRegistryImpl.getInstance().getParty(partyid);
   if (party == null) {
     throw new IllegalArgumentException("no party with the specified partyid exists");
   }
   switch (operation) {
     case JOIN:
       party.addMember(target);
       break;
     case EXPEL:
     case LEAVE:
       party.removeMember(target);
       break;
     case DISBAND:
       WorldRegistryImpl.getInstance().disbandParty(partyid);
       break;
     case SILENT_UPDATE:
     case LOG_ONOFF:
       party.updateMember(target);
       break;
     default:
       throw new RuntimeException("Unhandeled updateParty operation " + operation.name());
   }
   for (int i : WorldRegistryImpl.getInstance().getChannelServer()) {
     ChannelWorldInterface cwi = WorldRegistryImpl.getInstance().getChannel(i);
     try {
       cwi.updateParty(party, operation, target);
     } catch (RemoteException e) {
       WorldRegistryImpl.getInstance().deregisterChannelServer(i);
     }
   }
 }
Ejemplo n.º 2
0
 public static final void partySearchStart(SeekableLittleEndianAccessor slea, MapleClient c) {
   int min = slea.readInt();
   int max = slea.readInt();
   slea.readInt(); // members
   int jobs = slea.readInt();
   MapleCharacter chr = c.getPlayer();
   MapleMap map = chr.getMap();
   Collection<MapleMapObject> mapobjs = map.getAllPlayer();
   for (MapleMapObject mapobj : mapobjs) {
     if (chr.getParty().getMembers().size() > 5) {
       break;
     }
     if (mapobj instanceof MapleCharacter) {
       MapleCharacter tchar = (MapleCharacter) mapobj;
       int charlvl = tchar.getLevel();
       if (charlvl >= min && charlvl <= max && isValidJob(tchar.getJob(), jobs)) {
         if (c.getPlayer().getParty() == null) {
           try {
             WorldChannelInterface wci = c.getChannelServer().getWorldInterface();
             MapleParty party = c.getPlayer().getParty();
             int partyid = party.getId();
             party = wci.getParty(partyid);
             if (party != null) {
               if (party.getMembers().size() < 6) {
                 MaplePartyCharacter partyplayer = new MaplePartyCharacter(tchar);
                 wci.updateParty(party.getId(), PartyOperation.JOIN, partyplayer);
                 c.getPlayer().receivePartyMemberHP();
                 c.getPlayer().updatePartyMemberHP();
               } else {
                 c.getSession().write(MaplePacketCreator.partyStatusMessage(17));
               }
             }
           } catch (Exception e) {
             c.getChannelServer().reconnectWorld();
           }
         }
       }
     }
   }
 }
Ejemplo n.º 3
0
  public final void registerCarnivalParty(
      final MapleCharacter leader, final MapleMap map, final byte team) {
    leader.clearCarnivalRequests();
    List<MapleCharacter> characters = new LinkedList<MapleCharacter>();
    final MapleParty party = leader.getParty();

    if (party == null) {
      return;
    }
    for (MaplePartyCharacter pc : party.getMembers()) {
      final MapleCharacter c = map.getCharacterById_InMap(pc.getId());
      characters.add(c);
      registerPlayer(c);
      c.resetCP();
    }
    final MapleCarnivalParty carnivalParty = new MapleCarnivalParty(leader, characters, team);
    try {
      em.getIv().invokeFunction("registerCarnivalParty", this, carnivalParty);
    } catch (ScriptException ex) {
      ex.printStackTrace();
    } catch (NoSuchMethodException ex) {
      ex.printStackTrace();
    }
  }
Ejemplo n.º 4
0
  public static final void PartyOperatopn(
      final SeekableLittleEndianAccessor slea, final MapleClient c) {
    final int operation = slea.readByte();
    final WorldChannelInterface wci = ChannelServer.getInstance(c.getChannel()).getWorldInterface();
    MapleParty party = c.getPlayer().getParty();
    MaplePartyCharacter partyplayer = new MaplePartyCharacter(c.getPlayer());

    switch (operation) {
      case 1: // create
        if (c.getPlayer().getParty() == null) {
          try {
            party = wci.createParty(partyplayer);
            c.getPlayer().setParty(party);
          } catch (RemoteException e) {
            c.getChannelServer().reconnectWorld();
          }
          c.getSession().write(MaplePacketCreator.partyCreated());
        } else {
          c.getPlayer().dropMessage(5, "You can't create a party as you are already in one");
        }
        break;
      case 2: // leave
        if (party != null) { // are we in a party? o.O"
          try {
            if (partyplayer.equals(party.getLeader())) { // disband
              wci.updateParty(party.getId(), PartyOperation.DISBAND, partyplayer);
              if (c.getPlayer().getEventInstance() != null) {
                c.getPlayer().getEventInstance().disbandParty();
              }
            } else {
              wci.updateParty(party.getId(), PartyOperation.LEAVE, partyplayer);
              if (c.getPlayer().getEventInstance() != null) {
                c.getPlayer().getEventInstance().leftParty(c.getPlayer());
              }
            }
          } catch (RemoteException e) {
            c.getChannelServer().reconnectWorld();
          }
          c.getPlayer().setParty(null);
        }
        break;
      case 3: // accept invitation
        final int partyid = slea.readInt();
        if (c.getPlayer().getParty() == null) {
          try {
            party = wci.getParty(partyid);
            if (party != null) {
              if (party.getMembers().size() < 6) {
                wci.updateParty(party.getId(), PartyOperation.JOIN, partyplayer);
                c.getPlayer().receivePartyMemberHP();
                c.getPlayer().updatePartyMemberHP();
              } else {
                c.getSession().write(MaplePacketCreator.partyStatusMessage(17));
              }
            } else {
              c.getPlayer().dropMessage(5, "The party you are trying to join does not exist");
            }
          } catch (RemoteException e) {
            c.getChannelServer().reconnectWorld();
          }
        } else {
          c.getPlayer().dropMessage(5, "You can't join the party as you are already in one");
        }
        break;
      case 4: // invite
        // TODO store pending invitations and check against them
        final MapleCharacter invited =
            c.getChannelServer().getPlayerStorage().getCharacterByName(slea.readMapleAsciiString());
        if (invited != null && c.getPlayer().canFuck(invited)) {
          if (invited.getParty() == null) {
            if (party.getMembers().size() < 6) {
              invited.getClient().getSession().write(MaplePacketCreator.partyInvite(c.getPlayer()));
            } else {
              c.getSession().write(MaplePacketCreator.partyStatusMessage(16));
            }
          } else {
            c.getSession().write(MaplePacketCreator.partyStatusMessage(17));
          }
        } else {
          c.getSession().write(MaplePacketCreator.partyStatusMessage(19));
        }
        break;
      case 5: // expel
        if (partyplayer.equals(party.getLeader())) {
          final MaplePartyCharacter expelled = party.getMemberById(slea.readInt());
          if (expelled != null) {
            try {
              wci.updateParty(party.getId(), PartyOperation.EXPEL, expelled);
              if (c.getPlayer().getEventInstance() != null) {
                /*if leader wants to boot someone, then the whole party gets expelled
                TODO: Find an easier way to get the character behind a MaplePartyCharacter
                possibly remove just the expellee.*/
                if (expelled.isOnline()) {
                  c.getPlayer().getEventInstance().disbandParty();
                }
              }

            } catch (RemoteException e) {
              c.getChannelServer().reconnectWorld();
            }
          }
        }
        break;
      case 6: // change leader
        final MaplePartyCharacter newleader = party.getMemberById(slea.readInt());
        try {
          wci.updateParty(party.getId(), PartyOperation.CHANGE_LEADER, newleader);
        } catch (RemoteException e) {
          c.getChannelServer().reconnectWorld();
        }
        break;
      default:
        System.out.println("Unhandled Party function." + operation + "");
        break;
    }
  }
Ejemplo n.º 5
0
 public void registerParty(MapleParty party, MapleMap map) {
   for (MaplePartyCharacter pc : party.getMembers()) {
     MapleCharacter c = map.getCharacterById_InMap(pc.getId());
     registerPlayer(c);
   }
 }