Search in sources :

Example 11 with World

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

the class MapleCharacter method checkMessenger.

public void checkMessenger() {
    if (messenger != null && messengerposition < 4 && messengerposition > -1) {
        World worldz = Server.getInstance().getWorld(world);
        worldz.silentJoinMessenger(messenger.getId(), new MapleMessengerCharacter(this, messengerposition), messengerposition);
        worldz.updateMessenger(getMessenger().getId(), name, client.getChannel());
    }
}
Also used : MapleMessengerCharacter(net.server.world.MapleMessengerCharacter) World(net.server.world.World)

Example 12 with World

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

the class MessengerHandler method handlePacket.

@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    String input;
    byte mode = slea.readByte();
    MapleCharacter player = c.getPlayer();
    World world = c.getWorldServer();
    MapleMessenger messenger = player.getMessenger();
    switch(mode) {
        case 0x00:
            if (messenger == null) {
                int messengerid = slea.readInt();
                if (messengerid == 0) {
                    MapleMessengerCharacter messengerplayer = new MapleMessengerCharacter(player, 0);
                    messenger = world.createMessenger(messengerplayer);
                    player.setMessenger(messenger);
                    player.setMessengerPosition(0);
                } else {
                    messenger = world.getMessenger(messengerid);
                    int position = messenger.getLowestPosition();
                    MapleMessengerCharacter messengerplayer = new MapleMessengerCharacter(player, position);
                    if (messenger.getMembers().size() < 3) {
                        player.setMessenger(messenger);
                        player.setMessengerPosition(position);
                        world.joinMessenger(messenger.getId(), messengerplayer, player.getName(), messengerplayer.getChannel());
                    }
                }
            }
            break;
        case 0x02:
            player.closePlayerMessenger();
            break;
        case 0x03:
            if (messenger.getMembers().size() < 3) {
                input = slea.readMapleAsciiString();
                MapleCharacter target = c.getChannelServer().getPlayerStorage().getCharacterByName(input);
                if (target != null) {
                    if (target.getMessenger() == null) {
                        target.getClient().announce(MaplePacketCreator.messengerInvite(c.getPlayer().getName(), messenger.getId()));
                        c.announce(MaplePacketCreator.messengerNote(input, 4, 1));
                    } else {
                        c.announce(MaplePacketCreator.messengerChat(player.getName() + " : " + input + " is already using Maple Messenger"));
                    }
                } else {
                    if (world.find(input) > -1) {
                        world.messengerInvite(c.getPlayer().getName(), messenger.getId(), input, c.getChannel());
                    } else {
                        c.announce(MaplePacketCreator.messengerNote(input, 4, 0));
                    }
                }
            } else {
                c.announce(MaplePacketCreator.messengerChat(player.getName() + " : You cannot have more than 3 people in the Maple Messenger"));
            }
            break;
        case 0x05:
            String targeted = slea.readMapleAsciiString();
            MapleCharacter target = c.getChannelServer().getPlayerStorage().getCharacterByName(targeted);
            if (target != null) {
                if (target.getMessenger() != null) {
                    target.getClient().announce(MaplePacketCreator.messengerNote(player.getName(), 5, 0));
                }
            } else {
                world.declineChat(targeted, player.getName());
            }
            break;
        case 0x06:
            if (messenger != null) {
                MapleMessengerCharacter messengerplayer = new MapleMessengerCharacter(player, player.getMessengerPosition());
                input = slea.readMapleAsciiString();
                world.messengerChat(messenger, input, messengerplayer.getName());
            }
            break;
    }
}
Also used : MapleCharacter(client.MapleCharacter) MapleMessengerCharacter(net.server.world.MapleMessengerCharacter) World(net.server.world.World) MapleMessenger(net.server.world.MapleMessenger)

Example 13 with World

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

the class Server method reloadGuildCharacters.

public void reloadGuildCharacters(int world) {
    World worlda = getWorld(world);
    for (MapleCharacter mc : worlda.getPlayerStorage().getAllCharacters()) {
        if (mc.getGuildId() > 0) {
            setGuildMemberOnline(mc, true, worlda.getId());
            memberLevelJobUpdate(mc.getMGC());
        }
    }
    worlda.reloadGuildSummary();
}
Also used : MapleCharacter(client.MapleCharacter) World(net.server.world.World)

Example 14 with World

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

the class PlayerLoggedinHandler method handlePacket.

@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    final int cid = slea.readInt();
    final Server server = Server.getInstance();
    MapleCharacter player = c.getWorldServer().getPlayerStorage().getCharacterById(cid);
    boolean newcomer = false;
    if (player == null) {
        try {
            player = MapleCharacter.loadCharFromDB(cid, c, true);
            newcomer = true;
        } catch (SQLException e) {
            e.printStackTrace();
        }
    } else {
        player.newClient(c);
    }
    if (player == null) {
        // If you are still getting null here then please just uninstall the game >.>, we dont need you fucking with the logs
        c.disconnect(true, false);
        return;
    }
    c.setPlayer(player);
    c.setAccID(player.getAccountID());
    int state = c.getLoginState();
    boolean allowLogin = true;
    Channel cserv = c.getChannelServer();
    if (state == MapleClient.LOGIN_SERVER_TRANSITION || state == MapleClient.LOGIN_NOTLOGGEDIN) {
        for (String charName : c.loadCharacterNames(c.getWorld())) {
            for (Channel ch : c.getWorldServer().getChannels()) {
                if (ch.isConnected(charName)) {
                    allowLogin = false;
                }
            }
            break;
        }
    }
    if (state != MapleClient.LOGIN_SERVER_TRANSITION || !allowLogin) {
        c.setPlayer(null);
        c.announce(MaplePacketCreator.getAfterLoginError(7));
        return;
    }
    c.updateLoginState(MapleClient.LOGIN_LOGGEDIN);
    cserv.addPlayer(player);
    List<PlayerBuffValueHolder> buffs = server.getPlayerBuffStorage().getBuffsFromStorage(cid);
    if (buffs != null) {
        List<Pair<Long, PlayerBuffValueHolder>> timedBuffs = getLocalStartTimes(buffs);
        player.silentGiveBuffs(timedBuffs);
    }
    c.announce(MaplePacketCreator.getCharInfo(player));
    if (!player.isHidden()) {
        player.toggleHide(true);
    }
    player.sendKeymap();
    player.sendMacros();
    if (player.getKeymap().get(91) != null)
        player.announce(MaplePacketCreator.sendAutoHpPot(player.getKeymap().get(91).getAction()));
    if (player.getKeymap().get(92) != null)
        player.announce(MaplePacketCreator.sendAutoMpPot(player.getKeymap().get(92).getAction()));
    player.getMap().addPlayer(player);
    World world = server.getWorld(c.getWorld());
    world.getPlayerStorage().addPlayer(player);
    player.setAwayFromWorld(false);
    int[] buddyIds = player.getBuddylist().getBuddyIds();
    world.loggedOn(player.getName(), player.getId(), c.getChannel(), buddyIds);
    for (CharacterIdChannelPair onlineBuddy : server.getWorld(c.getWorld()).multiBuddyFind(player.getId(), buddyIds)) {
        BuddylistEntry ble = player.getBuddylist().get(onlineBuddy.getCharacterId());
        ble.setChannel(onlineBuddy.getChannel());
        player.getBuddylist().put(ble);
    }
    c.announce(MaplePacketCreator.updateBuddylist(player.getBuddylist().getBuddies()));
    c.announce(MaplePacketCreator.loadFamily(player));
    if (player.getFamilyId() > 0) {
        MapleFamily f = world.getFamily(player.getFamilyId());
        if (f == null) {
            f = new MapleFamily(player.getId());
            world.addFamily(player.getFamilyId(), f);
        }
        player.setFamily(f);
        c.announce(MaplePacketCreator.getFamilyInfo(f.getMember(player.getId())));
    }
    if (player.getGuildId() > 0) {
        MapleGuild playerGuild = server.getGuild(player.getGuildId(), player.getWorld(), player);
        if (playerGuild == null) {
            player.deleteGuild(player.getGuildId());
            player.getMGC().setGuildId(0);
        } else {
            playerGuild.getMGC(player.getId()).setCharacter(player);
            player.setMGC(playerGuild.getMGC(player.getId()));
            server.setGuildMemberOnline(player, true, c.getChannel());
            c.announce(MaplePacketCreator.showGuildInfo(player));
            int allianceId = player.getGuild().getAllianceId();
            if (allianceId > 0) {
                MapleAlliance newAlliance = server.getAlliance(allianceId);
                if (newAlliance == null) {
                    newAlliance = MapleAlliance.loadAlliance(allianceId);
                    if (newAlliance != null) {
                        server.addAlliance(allianceId, newAlliance);
                    } else {
                        player.getGuild().setAllianceId(0);
                    }
                }
                if (newAlliance != null) {
                    c.announce(MaplePacketCreator.updateAllianceInfo(newAlliance, c));
                    c.announce(MaplePacketCreator.allianceNotice(newAlliance.getId(), newAlliance.getNotice()));
                    if (newcomer) {
                        server.allianceMessage(allianceId, MaplePacketCreator.allianceMemberOnline(player, true), player.getId(), -1);
                    }
                }
            }
        }
    }
    player.showNote();
    if (player.getParty() != null) {
        MaplePartyCharacter pchar = player.getMPC();
        // Use this in case of enabling party HPbar HUD when logging in, however "you created a party" will appear on chat.
        // c.announce(MaplePacketCreator.partyCreated(pchar));
        pchar.setChannel(c.getChannel());
        pchar.setMapId(player.getMapId());
        pchar.setOnline(true);
        world.updateParty(player.getParty().getId(), PartyOperation.LOG_ONOFF, pchar);
        player.updatePartyMemberHP();
    }
    if (player.getInventory(MapleInventoryType.EQUIPPED).findById(1122017) != null) {
        player.equipPendantOfSpirit();
    }
    c.announce(MaplePacketCreator.updateBuddylist(player.getBuddylist().getBuddies()));
    CharacterNameAndId pendingBuddyRequest = c.getPlayer().getBuddylist().pollPendingRequest();
    if (pendingBuddyRequest != null) {
        c.announce(MaplePacketCreator.requestBuddylistAdd(pendingBuddyRequest.getId(), c.getPlayer().getId(), pendingBuddyRequest.getName()));
    }
    if (newcomer) {
        for (MaplePet pet : player.getPets()) {
            if (pet != null)
                world.registerPetHunger(player, player.getPetIndex(pet));
        }
        player.reloadQuestExpirations();
    }
    c.announce(MaplePacketCreator.updateGender(player));
    player.checkMessenger();
    c.announce(MaplePacketCreator.enableReport());
    player.changeSkillLevel(SkillFactory.getSkill(10000000 * player.getJobType() + 12), (byte) (player.getLinkedLevel() / 10), 20, -1);
    player.checkBerserk(player.isHidden());
    player.buffExpireTask();
    player.diseaseExpireTask();
    player.skillCooldownTask();
    player.expirationTask();
    player.questExpirationTask();
    if (GameConstants.hasSPTable(player.getJob()) && player.getJob().getId() != 2001) {
        player.createDragon();
    }
    player.commitExcludedItems();
    if (newcomer) {
        /*
            if (!c.hasVotedAlready()){
            	player.announce(MaplePacketCreator.earnTitleMessage("You can vote now! Vote and earn a vote point!"));
            }
                    */
        if (player.isGM()) {
            Server.getInstance().broadcastGMMessage(c.getWorld(), MaplePacketCreator.earnTitleMessage((player.gmLevel() < 6 ? "GM " : "Admin ") + player.getName() + " has logged in"));
        }
    }
    showDueyNotification(c, player);
    if (player.getMap().getHPDec() > 0)
        player.resetHpDecreaseTask();
    player.resetPlayerRates();
    if (ServerConstants.USE_ADD_RATES_BY_LEVEL == true)
        player.setPlayerRates();
    player.setWorldRates();
    player.updateCouponRates();
    player.receivePartyMemberHP();
}
Also used : MapleCharacter(client.MapleCharacter) PlayerBuffValueHolder(net.server.PlayerBuffValueHolder) CharacterIdChannelPair(net.server.channel.CharacterIdChannelPair) Server(net.server.Server) SQLException(java.sql.SQLException) MapleFamily(client.MapleFamily) Channel(net.server.channel.Channel) World(net.server.world.World) BuddylistEntry(client.BuddylistEntry) MapleGuild(net.server.guild.MapleGuild) MapleAlliance(net.server.guild.MapleAlliance) MaplePet(client.inventory.MaplePet) CharacterIdChannelPair(net.server.channel.CharacterIdChannelPair) Pair(tools.Pair) MaplePartyCharacter(net.server.world.MaplePartyCharacter) CharacterNameAndId(client.CharacterNameAndId)

Example 15 with World

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

the class PartyChatHandler method handlePacket.

public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    MapleCharacter player = c.getPlayer();
    if (player.getAutobanManager().getLastSpam(7) + 200 > System.currentTimeMillis()) {
        return;
    }
    // 0 for buddys, 1 for partys
    int type = slea.readByte();
    int numRecipients = slea.readByte();
    int[] recipients = new int[numRecipients];
    for (int i = 0; i < numRecipients; i++) {
        recipients[i] = slea.readInt();
    }
    String chattext = slea.readMapleAsciiString();
    if (chattext.length() > Byte.MAX_VALUE && !player.isGM()) {
        AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit chats.");
        FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to send text with length of " + chattext.length() + "\r\n");
        c.disconnect(true, false);
        return;
    }
    World world = c.getWorldServer();
    if (type == 0) {
        world.buddyChat(recipients, player.getId(), player.getName(), chattext);
    } else if (type == 1 && player.getParty() != null) {
        world.partyChat(player.getParty(), chattext, player.getName());
    } else if (type == 2 && player.getGuildId() > 0) {
        Server.getInstance().guildChat(player.getGuildId(), player.getName(), player.getId(), chattext);
    } else if (type == 3 && player.getGuild() != null) {
        int allianceId = player.getGuild().getAllianceId();
        if (allianceId > 0) {
            Server.getInstance().allianceMessage(allianceId, MaplePacketCreator.multiChat(player.getName(), chattext, 3), player.getId(), -1);
        }
    }
    player.getAutobanManager().spam(7);
}
Also used : MapleCharacter(client.MapleCharacter) World(net.server.world.World)

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