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();
}
}
}
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;
}
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));
}
}
}
}
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();
}
}
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()));
}
}
}
Aggregations