Search in sources :

Example 1 with World

use of net.server.world.World in project HeavenMS by ronancpl.

the class MapleCharacter method setWorldRates.

public void setWorldRates() {
    World worldz = Server.getInstance().getWorld(world);
    this.expRate *= worldz.getExpRate();
    this.mesoRate *= worldz.getMesoRate();
    this.dropRate *= worldz.getDropRate();
}
Also used : World(net.server.world.World)

Example 2 with World

use of net.server.world.World in project HeavenMS by ronancpl.

the class MapleCharacter method revertWorldRates.

public void revertWorldRates() {
    World worldz = Server.getInstance().getWorld(world);
    this.expRate /= worldz.getExpRate();
    this.mesoRate /= worldz.getMesoRate();
    this.dropRate /= worldz.getDropRate();
}
Also used : World(net.server.world.World)

Example 3 with World

use of net.server.world.World in project HeavenMS by ronancpl.

the class MapleClient method disconnect.

public final synchronized void disconnect(boolean shutdown, boolean cashshop) {
    // once per MapleClient instance
    if (disconnecting) {
        return;
    }
    disconnecting = true;
    if (player != null && player.isLoggedin() && player.getClient() != null) {
        MapleMap map = player.getMap();
        final MapleParty party = player.getParty();
        final int idz = player.getId();
        final int messengerid = player.getMessenger() == null ? 0 : player.getMessenger().getId();
        // final int fid = player.getFamilyId();
        final BuddyList bl = player.getBuddylist();
        final MaplePartyCharacter chrp = new MaplePartyCharacter(player);
        final MapleMessengerCharacter chrm = new MapleMessengerCharacter(player, 0);
        final MapleGuildCharacter chrg = player.getMGC();
        final MapleGuild guild = player.getGuild();
        player.cancelMagicDoor();
        if (channel == -1 || shutdown) {
            if (chrg != null)
                chrg.setCharacter(null);
            removePlayer();
            player.saveCooldowns();
            player.saveToDB(true);
            player = null;
            return;
        }
        removePlayer();
        final World worlda = getWorldServer();
        try {
            if (!cashshop) {
                if (!this.serverTransition) {
                    // meaning not changing channels
                    if (messengerid > 0) {
                        worlda.leaveMessenger(messengerid, chrm);
                    }
                    /*      
						if (fid > 0) {
                                                        final MapleFamily family = worlda.getFamily(fid);
                                                        family.
                                                }
                                                */
                    for (MapleQuestStatus status : player.getStartedQuests()) {
                        // This is for those quests that you have to stay logged in for a certain amount of time
                        MapleQuest quest = status.getQuest();
                        if (quest.getTimeLimit() > 0) {
                            MapleQuestStatus newStatus = new MapleQuestStatus(quest, MapleQuestStatus.Status.NOT_STARTED);
                            newStatus.setForfeited(player.getQuest(quest).getForfeited() + 1);
                            player.updateQuest(newStatus);
                        }
                    }
                    if (guild != null) {
                        final Server server = Server.getInstance();
                        server.setGuildMemberOnline(player, false, player.getClient().getChannel());
                        player.getClient().announce(MaplePacketCreator.showGuildInfo(player));
                    }
                    if (party != null) {
                        chrp.setOnline(false);
                        worlda.updateParty(party.getId(), PartyOperation.LOG_ONOFF, chrp);
                        if (map != null && party.getLeader().getId() == idz) {
                            MaplePartyCharacter lchr = null;
                            for (MaplePartyCharacter pchr : party.getMembers()) {
                                if (pchr != null && map.getCharacterById(pchr.getId()) != null && (lchr == null || lchr.getLevel() <= pchr.getLevel())) {
                                    lchr = pchr;
                                }
                            }
                            if (lchr != null) {
                                worlda.updateParty(party.getId(), PartyOperation.CHANGE_LEADER, lchr);
                            }
                        }
                    }
                    if (bl != null) {
                        worlda.loggedOff(player.getName(), player.getId(), channel, player.getBuddylist().getBuddyIds());
                    }
                }
            } else {
                if (!this.serverTransition) {
                    // if dc inside of cash shop.
                    if (party != null) {
                        chrp.setOnline(false);
                        worlda.updateParty(party.getId(), PartyOperation.LOG_ONOFF, chrp);
                        if (map != null && party.getLeader().getId() == idz) {
                            MaplePartyCharacter lchr = null;
                            for (MaplePartyCharacter pchr : party.getMembers()) {
                                if (pchr != null && map.getCharacterById(pchr.getId()) != null && (lchr == null || lchr.getLevel() <= pchr.getLevel())) {
                                    lchr = pchr;
                                }
                            }
                            if (lchr != null) {
                                worlda.updateParty(party.getId(), PartyOperation.CHANGE_LEADER, lchr);
                            }
                        }
                    }
                    if (bl != null) {
                        worlda.loggedOff(player.getName(), player.getId(), channel, player.getBuddylist().getBuddyIds());
                    }
                }
            }
        } catch (final Exception e) {
            FilePrinter.printError(FilePrinter.ACCOUNT_STUCK, e);
        } finally {
            getChannelServer().removePlayer(player);
            if (!this.serverTransition) {
                worlda.removePlayer(player);
                player.saveCooldowns();
                player.saveToDB(true);
                if (player != null) {
                    // no idea, occur :(
                    player.empty(false);
                }
                player.logOff();
            } else {
                player.saveCooldowns();
                player.saveToDB();
            }
            player = null;
        }
    }
    if (!serverTransition && isLoggedIn()) {
        updateLoginState(MapleClient.LOGIN_NOTLOGGEDIN);
        // prevents double dcing during login
        session.removeAttribute(MapleClient.CLIENT_KEY);
        session.close(false);
    }
    engines.clear();
}
Also used : MapleQuest(server.quest.MapleQuest) Server(net.server.Server) MapleGuildCharacter(net.server.guild.MapleGuildCharacter) MapleParty(net.server.world.MapleParty) MapleMessengerCharacter(net.server.world.MapleMessengerCharacter) World(net.server.world.World) SQLException(java.sql.SQLException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) MapleGuild(net.server.guild.MapleGuild) MaplePartyCharacter(net.server.world.MaplePartyCharacter)

Example 4 with World

use of net.server.world.World in project HeavenMS by ronancpl.

the class MapleCharacter method closePlayerMessenger.

public void closePlayerMessenger() {
    MapleMessenger m = this.getMessenger();
    if (m == null)
        return;
    World w = client.getWorldServer();
    MapleMessengerCharacter messengerplayer = new MapleMessengerCharacter(this, this.getMessengerPosition());
    w.leaveMessenger(m.getId(), messengerplayer);
    this.setMessenger(null);
    this.setMessengerPosition(4);
}
Also used : MapleMessengerCharacter(net.server.world.MapleMessengerCharacter) World(net.server.world.World) MapleMessenger(net.server.world.MapleMessenger)

Example 5 with World

use of net.server.world.World in project HeavenMS by ronancpl.

the class PartyOperationHandler method handlePacket.

@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    int operation = slea.readByte();
    MapleCharacter player = c.getPlayer();
    World world = c.getWorldServer();
    MapleParty party = player.getParty();
    MaplePartyCharacter partyplayer = player.getMPC();
    switch(operation) {
        case 1:
            {
                // create
                if (player.getLevel() < 10 && !ServerConstants.USE_PARTY_FOR_STARTERS) {
                    c.announce(MaplePacketCreator.partyStatusMessage(10));
                    return;
                }
                if (player.getParty() == null) {
                    partyplayer = new MaplePartyCharacter(player);
                    party = world.createParty(partyplayer);
                    player.setParty(party);
                    player.setMPC(partyplayer);
                    player.getMap().addPartyMember(player);
                    player.silentPartyUpdate();
                    c.announce(MaplePacketCreator.partyCreated(partyplayer));
                } else {
                    c.announce(MaplePacketCreator.serverNotice(5, "You can't create a party as you are already in one."));
                }
                break;
            }
        case 2:
            {
                // leave/disband
                leaveParty(party, partyplayer, c);
                break;
            }
        case 3:
            {
                // join
                int partyid = slea.readInt();
                if (c.getPlayer().getParty() == null) {
                    party = world.getParty(partyid);
                    if (party != null) {
                        if (party.getMembers().size() < 6) {
                            partyplayer = new MaplePartyCharacter(player);
                            player.getMap().addPartyMember(player);
                            world.updateParty(party.getId(), PartyOperation.JOIN, partyplayer);
                            player.receivePartyMemberHP();
                            player.updatePartyMemberHP();
                        } else {
                            c.announce(MaplePacketCreator.partyStatusMessage(17));
                        }
                    } else {
                        c.announce(MaplePacketCreator.serverNotice(5, "The person you have invited to the party is already in one."));
                    }
                } else {
                    c.announce(MaplePacketCreator.serverNotice(5, "You can't join the party as you are already in one."));
                }
                break;
            }
        case 4:
            {
                // invite
                String name = slea.readMapleAsciiString();
                MapleCharacter invited = world.getPlayerStorage().getCharacterByName(name);
                if (invited != null) {
                    if (invited.getLevel() < 10 && (!ServerConstants.USE_PARTY_FOR_STARTERS || player.getLevel() >= 10)) {
                        // min requirement is level 10
                        c.announce(MaplePacketCreator.serverNotice(5, "The player you have invited does not meet the requirements."));
                        return;
                    }
                    if (ServerConstants.USE_PARTY_FOR_STARTERS && invited.getLevel() >= 10 && player.getLevel() < 10) {
                        // trying to invite high level
                        c.announce(MaplePacketCreator.serverNotice(5, "The player you have invited does not meet the requirements."));
                        return;
                    }
                    if (invited.getParty() == null) {
                        if (player.getParty() == null) {
                            if (player.getLevel() < 10 && !ServerConstants.USE_PARTY_FOR_STARTERS) {
                                c.announce(MaplePacketCreator.partyStatusMessage(10));
                                return;
                            }
                            partyplayer = new MaplePartyCharacter(player);
                            party = world.createParty(partyplayer);
                            player.setParty(party);
                            player.setMPC(partyplayer);
                            player.getMap().addPartyMember(player);
                            c.announce(MaplePacketCreator.partyCreated(partyplayer));
                        }
                        if (party.getMembers().size() < 6) {
                            invited.getClient().announce(MaplePacketCreator.partyInvite(player));
                        } else {
                            c.announce(MaplePacketCreator.partyStatusMessage(17));
                        }
                    } else {
                        c.announce(MaplePacketCreator.partyStatusMessage(16));
                    }
                } else {
                    c.announce(MaplePacketCreator.partyStatusMessage(19));
                }
                break;
            }
        case 5:
            {
                // expel
                int cid = slea.readInt();
                if (partyplayer.equals(party.getLeader())) {
                    MaplePartyCharacter expelled = party.getMemberById(cid);
                    if (expelled != null) {
                        MapleCharacter emc = expelled.getPlayer();
                        if (emc != null) {
                            MapleMap map = emc.getMap();
                            if (map != null)
                                map.removePartyMember(emc);
                            EventInstanceManager eim = emc.getEventInstance();
                            if (eim != null) {
                                eim.leftParty(emc);
                            }
                            emc.setParty(null);
                        }
                        world.updateParty(party.getId(), PartyOperation.EXPEL, expelled);
                    }
                }
                break;
            }
        case 6:
            {
                // change leader
                int newLeader = slea.readInt();
                MaplePartyCharacter newLeadr = party.getMemberById(newLeader);
                world.updateParty(party.getId(), PartyOperation.CHANGE_LEADER, newLeadr);
                break;
            }
    }
}
Also used : MapleMap(server.maps.MapleMap) MapleCharacter(client.MapleCharacter) EventInstanceManager(scripting.event.EventInstanceManager) MapleParty(net.server.world.MapleParty) World(net.server.world.World) MaplePartyCharacter(net.server.world.MaplePartyCharacter)

Aggregations

World (net.server.world.World)18 MapleCharacter (client.MapleCharacter)10 SQLException (java.sql.SQLException)5 Server (net.server.Server)4 MapleMessengerCharacter (net.server.world.MapleMessengerCharacter)4 MaplePartyCharacter (net.server.world.MaplePartyCharacter)4 Connection (java.sql.Connection)3 PreparedStatement (java.sql.PreparedStatement)3 Channel (net.server.channel.Channel)3 MapleParty (net.server.world.MapleParty)3 DatabaseConnection (tools.DatabaseConnection)3 BuddylistEntry (client.BuddylistEntry)2 ResultSet (java.sql.ResultSet)2 MapleGuild (net.server.guild.MapleGuild)2 MapleMessenger (net.server.world.MapleMessenger)2 MapleMap (server.maps.MapleMap)2 BuddyList (client.BuddyList)1 BuddyAddResult (client.BuddyList.BuddyAddResult)1 CharacterNameAndId (client.CharacterNameAndId)1 MapleFamily (client.MapleFamily)1