use of net.server.world.MapleParty 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();
}
use of net.server.world.MapleParty 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;
}
}
}
use of net.server.world.MapleParty in project HeavenMS by ronancpl.
the class Channel method startDojoSchedule.
public void startDojoSchedule(final int dojoMapId) {
final int slot = getDojoSlot(dojoMapId);
final int stage = (dojoMapId / 100) % 100;
if (stage <= dojoStage[slot])
return;
long clockTime = (stage > 36 ? 15 : (stage / 6) + 5) * 60000;
this.dojoTask[slot] = TimerManager.getInstance().schedule(new Runnable() {
@Override
public void run() {
final int delta = (dojoMapId) % 100;
final int dojoBaseMap = (slot < 5) ? 925030000 : 925020000;
MapleParty party = null;
for (int i = 0; i < 5; i++) {
// only 32 stages, but 38 maps
for (MapleCharacter chr : getMapFactory().getMap(dojoBaseMap + (100 * (stage + i)) + delta).getAllPlayers()) {
if (chr.getMap().isDojoMap()) {
chr.timeoutFromDojo();
}
party = chr.getParty();
}
}
freeDojoSlot(slot, party);
}
}, // let the TIMES UP display for 3 seconds, then warp
clockTime + 3000);
dojoFinishTime[slot] = System.currentTimeMillis() + clockTime;
}
use of net.server.world.MapleParty in project HeavenMS by ronancpl.
the class AbstractPlayerInteraction method givePartyExp.
public void givePartyExp(String PQ, boolean instance) {
// 1 player = +0% bonus (100)
// 2 players = +0% bonus (100)
// 3 players = +0% bonus (100)
// 4 players = +10% bonus (110)
// 5 players = +20% bonus (120)
// 6 players = +30% bonus (130)
MapleParty party = getPlayer().getParty();
int size = party.getMembers().size();
if (instance) {
for (MaplePartyCharacter member : party.getMembers()) {
if (member == null || !member.isOnline() || member.getPlayer().getEventInstance() == null) {
size--;
}
}
}
int bonus = size < 4 ? 100 : 70 + (size * 10);
for (MaplePartyCharacter member : party.getMembers()) {
if (member == null || !member.isOnline()) {
continue;
}
MapleCharacter player = member.getPlayer();
if (instance && player.getEventInstance() == null) {
// They aren't in the instance, don't give EXP.
continue;
}
int base = PartyQuest.getExp(PQ, player.getLevel());
int exp = base * bonus / 100;
player.gainExp(exp, true, true);
if (ServerConstants.PQ_BONUS_EXP_RATE > 0 && System.currentTimeMillis() <= ServerConstants.EVENT_END_TIMESTAMP) {
player.gainExp((int) (exp * ServerConstants.PQ_BONUS_EXP_RATE), true, true);
}
}
}
use of net.server.world.MapleParty in project HeavenMS by ronancpl.
the class NPCConversationManager method createPyramid.
public boolean createPyramid(String mode, boolean party) {
// lol
PyramidMode mod = PyramidMode.valueOf(mode);
MapleParty partyz = getPlayer().getParty();
MapleMapFactory mf = c.getChannelServer().getMapFactory();
MapleMap map = null;
int mapid = 926010100;
if (party) {
mapid += 10000;
}
mapid += (mod.getMode() * 1000);
for (byte b = 0; b < 5; b++) {
// They cannot warp to the next map before the timer ends (:
map = mf.getMap(mapid + b);
if (map.getCharacters().size() > 0) {
continue;
} else {
break;
}
}
if (map == null) {
return false;
}
if (!party) {
partyz = new MapleParty(-1, new MaplePartyCharacter(getPlayer()));
}
Pyramid py = new Pyramid(partyz, mod, map.getId());
getPlayer().setPartyQuest(py);
py.warp(mapid);
dispose();
return true;
}
Aggregations