Search in sources :

Example 71 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class World method runPetSchedule.

public void runPetSchedule() {
    Map<Integer, Byte> deployedPets;
    activePetsLock.lock();
    try {
        petUpdate = System.currentTimeMillis();
        deployedPets = Collections.unmodifiableMap(activePets);
    } finally {
        activePetsLock.unlock();
    }
    for (Map.Entry<Integer, Byte> dp : deployedPets.entrySet()) {
        MapleCharacter chr = this.getPlayerStorage().getCharacterById(dp.getKey() / 4);
        if (chr == null || !chr.isLoggedin() || chr.isAwayFromWorld())
            continue;
        Byte dpVal = (byte) (dp.getValue() + 1);
        if (dpVal == ServerConstants.PET_EXHAUST_COUNT) {
            chr.runFullnessSchedule(dp.getKey() % 4);
            dpVal = 0;
        }
        activePetsLock.lock();
        try {
            activePets.put(dp.getKey(), dpVal);
        } finally {
            activePetsLock.unlock();
        }
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MapleCharacter(client.MapleCharacter) MapleMap(server.maps.MapleMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 72 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class World method find.

public int find(int id) {
    int channel = -1;
    MapleCharacter chr = getPlayerStorage().getCharacterById(id);
    if (chr != null) {
        channel = chr.getClient().getChannel();
    }
    return channel;
}
Also used : MapleCharacter(client.MapleCharacter)

Example 73 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class World method updateBuddies.

private void updateBuddies(int characterId, int channel, int[] buddies, boolean offline) {
    PlayerStorage playerStorage = getPlayerStorage();
    for (int buddy : buddies) {
        MapleCharacter chr = playerStorage.getCharacterById(buddy);
        if (chr != null) {
            BuddylistEntry ble = chr.getBuddylist().get(characterId);
            if (ble != null && ble.isVisible()) {
                int mcChannel;
                if (offline) {
                    ble.setChannel((byte) -1);
                    mcChannel = -1;
                } else {
                    ble.setChannel(channel);
                    mcChannel = (byte) (channel - 1);
                }
                chr.getBuddylist().put(ble);
                chr.getClient().announce(MaplePacketCreator.updateBuddyChannel(ble.getCharacterId(), mcChannel));
            }
        }
    }
}
Also used : MapleCharacter(client.MapleCharacter) BuddylistEntry(client.BuddylistEntry) PlayerStorage(net.server.PlayerStorage)

Example 74 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class World method setMesoRate.

public void setMesoRate(int meso) {
    List<MapleCharacter> list = new LinkedList<>(getPlayerStorage().getAllCharacters());
    for (MapleCharacter chr : list) {
        if (!chr.isLoggedin())
            continue;
        chr.revertWorldRates();
    }
    this.mesorate = meso;
    for (MapleCharacter chr : list) {
        if (!chr.isLoggedin())
            continue;
        chr.setWorldRates();
    }
}
Also used : MapleCharacter(client.MapleCharacter) LinkedList(java.util.LinkedList)

Example 75 with MapleCharacter

use of client.MapleCharacter in project HeavenMS by ronancpl.

the class World method addMessengerPlayer.

public void addMessengerPlayer(MapleMessenger messenger, String namefrom, int fromchannel, int position) {
    for (MapleMessengerCharacter messengerchar : messenger.getMembers()) {
        MapleCharacter chr = getPlayerStorage().getCharacterByName(messengerchar.getName());
        if (chr == null) {
            continue;
        }
        if (!messengerchar.getName().equals(namefrom)) {
            MapleCharacter from = getChannel(fromchannel).getPlayerStorage().getCharacterByName(namefrom);
            chr.getClient().announce(MaplePacketCreator.addMessengerPlayer(namefrom, from, position, (byte) (fromchannel - 1)));
            from.getClient().announce(MaplePacketCreator.addMessengerPlayer(chr.getName(), chr, messengerchar.getPosition(), (byte) (messengerchar.getChannel() - 1)));
        } else {
            chr.getClient().announce(MaplePacketCreator.joinMessenger(messengerchar.getPosition()));
        }
    }
}
Also used : MapleCharacter(client.MapleCharacter)

Aggregations

MapleCharacter (client.MapleCharacter)163 Point (java.awt.Point)32 SQLException (java.sql.SQLException)22 Item (client.inventory.Item)21 Connection (java.sql.Connection)15 PreparedStatement (java.sql.PreparedStatement)15 MapleMonster (server.life.MapleMonster)15 MapleMapObject (server.maps.MapleMapObject)15 DatabaseConnection (tools.DatabaseConnection)15 MapleMap (server.maps.MapleMap)14 ArrayList (java.util.ArrayList)13 Skill (client.Skill)12 SpawnPoint (server.life.SpawnPoint)12 LinkedList (java.util.LinkedList)11 MapleInventory (client.inventory.MapleInventory)10 World (net.server.world.World)10 MapleStatEffect (server.MapleStatEffect)10 MapleInventoryType (client.inventory.MapleInventoryType)9 ResultSet (java.sql.ResultSet)9 MapleItemInformationProvider (server.MapleItemInformationProvider)9