@Override public void execute(MapleClient c, MessageCallback mc, String[] splitted) throws Exception, IllegalCommandSyntaxException { if (splitted[0].equals("!whosthere")) { MessageCallback callback = new ServernoticeMapleClientMessageCallback(c); StringBuilder builder = new StringBuilder("Players on Map: "); for (MapleCharacter chr : c.getPlayer().getMap().getCharacters()) { if (builder.length() > 150) { // wild guess :o builder.setLength(builder.length() - 2); callback.dropMessage(builder.toString()); builder = new StringBuilder(); } builder.append(MapleCharacter.makeMapleReadable(chr.getName())); builder.append(", "); } builder.setLength(builder.length() - 2); c.getSession().write(MaplePacketCreator.serverNotice(6, builder.toString())); } else if (splitted[0].equals("!cheaters")) { try { List<CheaterData> cheaters = c.getChannelServer().getWorldInterface().getCheaters(c.getWorld()); for (int x = cheaters.size() - 1; x >= 0; x--) { CheaterData cheater = cheaters.get(x); mc.dropMessage(cheater.getInfo()); } } catch (RemoteException e) { c.getChannelServer().reconnectWorld(); } } }
public static final boolean UseHiredMerchant(MapleClient c, boolean packet) { if ((c.getPlayer().getMap() != null) && (c.getPlayer().getMap().allowPersonalShop())) { byte state = checkExistance(c.getPlayer().getAccountID(), c.getPlayer().getId()); switch (state) { case 1: c.getPlayer().dropMessage(1, "Please claim your items from Fredrick first."); break; case 0: boolean merch = World.hasMerchant(c.getPlayer().getAccountID(), c.getPlayer().getId()); if (!merch) { if (c.getChannelServer().isShutdown()) { c.getPlayer().dropMessage(1, "The server is about to shut down."); return false; } if (packet) { c.getSession().write(PlayerShopPacket.sendTitleBox()); } return true; } c.getPlayer().dropMessage(1, "Please close the existing store and try again."); break; default: c.getPlayer().dropMessage(1, "An unknown error occured."); } } else { c.getSession().close(true); } return false; }
public static void displayMerch(MapleClient c) { int conv = c.getPlayer().getConversation(); boolean merch = World.hasMerchant(c.getPlayer().getAccountID(), c.getPlayer().getId()); MerchItemPackage pack; if (merch) { c.getPlayer().dropMessage(1, "Please close the existing store and try again."); c.getPlayer().setConversation(0); } else if (c.getChannelServer().isShutdown()) { c.getPlayer().dropMessage(1, "The world is going to shut down."); c.getPlayer().setConversation(0); } else if (conv == 3) { pack = loadItemFrom_Database(c.getPlayer().getAccountID()); if (pack == null) { c.getPlayer().dropMessage(1, "You do not have any item(s) with Fredrick."); c.getPlayer().setConversation(0); } else if (pack.getItems().size() <= 0) { if (!check(c.getPlayer(), pack)) { c.getSession().write(PlayerShopPacket.merchItem_Message(33)); return; } if (deletePackage( c.getPlayer().getAccountID(), pack.getPackageid(), c.getPlayer().getId())) { c.getPlayer().fakeRelog(); c.getPlayer().gainMeso(pack.getMesos(), false); c.getSession().write(PlayerShopPacket.merchItem_Message(29)); c.getPlayer().dropMessage(1, "You have retrieved your mesos."); } else { c.getPlayer().dropMessage(1, "An unknown error occured."); } c.getPlayer().setConversation(0); } else { c.getSession().write(PlayerShopPacket.merchItemStore_ItemData(pack)); MapleInventoryManipulator.checkSpace(c, conv, conv, null); for (Item item : pack.getItems()) { if (c.getPlayer() .getInventory(GameConstants.getInventoryType(item.getItemId())) .isFull()) { c.removeClickedNPC(); c.getPlayer().dropMessage(1, "Your inventory is full (Please relog)"); break; } MapleInventoryManipulator.addFromDrop(c, item, true); deletePackage(c.getPlayer().getAccountID(), pack.getPackageid(), c.getPlayer().getId()); c.removeClickedNPC(); } c.getPlayer().dropMessage(1, "Items have been returned to you, please relog."); } } c.getSession().write(CWvsContext.enableActions()); }
private static void requestItems(MapleClient c, boolean request) { if (c.getPlayer().getConversation() != 3) { return; } boolean merch = World.hasMerchant(c.getPlayer().getAccountID(), c.getPlayer().getId()); if (merch) { c.getPlayer().dropMessage(1, "Please close the existing store and try again."); c.getPlayer().setConversation(0); return; } MerchItemPackage pack = loadItemFrom_Database(c.getPlayer().getAccountID()); if (pack == null) { c.getPlayer().dropMessage(1, "An unknown error occured."); return; } if (c.getChannelServer().isShutdown()) { c.getPlayer().dropMessage(1, "The world is going to shut down."); c.getPlayer().setConversation(0); return; } int days = StringUtil.getDaysAmount(pack.getSavedTime(), System.currentTimeMillis()); double percentage = days / 100.0D; int fee = (int) Math.ceil(percentage * pack.getMesos()); if ((request) && (days > 0) && (percentage > 0.0D) && (pack.getMesos() > 0) && (fee > 0)) { c.getSession().write(PlayerShopPacket.merchItemStore((byte) 38, days, fee)); return; } if (fee < 0) { c.getSession().write(PlayerShopPacket.merchItem_Message(33)); return; } if (c.getPlayer().getMeso() < fee) { c.getSession().write(PlayerShopPacket.merchItem_Message(35)); return; } if (!check(c.getPlayer(), pack)) { c.getSession().write(PlayerShopPacket.merchItem_Message(36)); return; } if (deletePackage(c.getPlayer().getAccountID(), pack.getPackageid(), c.getPlayer().getId())) { if (fee > 0) { c.getPlayer().gainMeso(-fee, true); } c.getPlayer().gainMeso(pack.getMesos(), false); for (Item item : pack.getItems()) { MapleInventoryManipulator.addFromDrop(c, item, false); } c.getSession().write(PlayerShopPacket.merchItem_Message(32)); } else { c.getPlayer().dropMessage(1, "An unknown error occured."); } }
@Override public int execute(MapleClient c, String[] splitted) { if (c.getPlayer().getMapId() != 109010100) { c.getPlayer().dropMessage(5, "You may only spawn bomb in the event map."); return 0; } if (!c.getChannelServer().bombermanActive()) { c.getPlayer().dropMessage(5, "You may not spawn bombs yet."); return 0; } c.getPlayer() .getMap() .spawnMonsterOnGroudBelow( MapleLifeFactory.getMonster(9300166), c.getPlayer().getPosition()); return 1; }
public static final void DenyInvite( MapleClient c, final MapleGuild gs) { // playername that invited -> guildname that was invited but we also don't care final int inviteid = World.Guild.getInvitedId(c.getPlayer().getGuildId()); if (inviteid > 0) { final int newAlliance = World.Alliance.getAllianceLeader(inviteid); if (newAlliance > 0) { final MapleCharacter chr = c.getChannelServer().getPlayerStorage().getCharacterById(newAlliance); if (chr != null) { chr.dropMessage(5, gs.getName() + " Guild has rejected the Guild Union invitation."); } World.Guild.setInvitedId(c.getPlayer().getGuildId(), 0); } } // c.getSession().write(CWvsContext.enableActions()); }
@Override public int execute(MapleClient c, String[] splitted) { for (int i : GameConstants.blockedMaps) { if (c.getPlayer().getMapId() == i) { c.getPlayer().dropMessage(5, "You may not use this command here."); return 0; } } if (c.getPlayer().getLevel() < 10 && c.getPlayer().getJob() != 200) { c.getPlayer().dropMessage(5, "You must be over level 10 to use this command."); return 0; } if (c.getPlayer().hasBlockedInventory() || c.getPlayer().getMap().getSquadByMap() != null || c.getPlayer().getEventInstance() != null || c.getPlayer().getMap().getEMByMap() != null || c.getPlayer().getMapId() >= 990000000 /* || FieldLimitType.VipRock.check(c.getPlayer().getMap().getFieldLimit())*/) { c.getPlayer().dropMessage(5, "You may not use this command here."); return 0; } if ((c.getPlayer().getMapId() >= 680000210 && c.getPlayer().getMapId() <= 680000502) || (c.getPlayer().getMapId() / 1000 == 980000 && c.getPlayer().getMapId() != 980000000) || (c.getPlayer().getMapId() / 100 == 1030008) || (c.getPlayer().getMapId() / 100 == 922010) || (c.getPlayer().getMapId() / 10 == 13003000)) { c.getPlayer().dropMessage(5, "You may not use this command here."); return 0; } c.getPlayer() .saveLocation( SavedLocationType.FREE_MARKET, c.getPlayer().getMap().getReturnMap().getId()); MapleMap map = c.getChannelServer().getMapFactory().getMap(910000000); c.getPlayer().changeMap(map, map.getPortal(0)); return 1; }
public void closeShop(MapleClient c, boolean timeout) { map.removeMapObject(this); map.broadcastMessage(MaplePacketCreator.destroyHiredMerchant(ownerId)); c.getChannelServer().removeHiredMerchant(ownerId); try { PreparedStatement ps = DatabaseConnection.getConnection() .prepareStatement( "UPDATE characters SET HasMerchant = 0 WHERE id = ?", Statement.RETURN_GENERATED_KEYS); ps.setInt(1, ownerId); ps.executeUpdate(); ps.close(); if (check(c.getPlayer(), getItems()) && !timeout) { for (MaplePlayerShopItem mpsi : getItems()) { if (mpsi.isExist() && (mpsi.getItem().getType() == IItem.EQUIP)) { MapleInventoryManipulator.addFromDrop(c, mpsi.getItem(), false); } else if (mpsi.isExist()) { MapleInventoryManipulator.addById( c, mpsi.getItem().getItemId(), (short) (mpsi.getBundles() * mpsi.getItem().getQuantity()), null, -1, mpsi.getItem().getExpiration()); } } items.clear(); } try { this.saveItems(false); } catch (Exception e) { } items.clear(); } catch (Exception e) { } schedule.cancel(false); }
@Override public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) { int cid = slea.readInt(); MapleCharacter player = null; try { player = MapleCharacter.loadCharFromDB(cid, c, true); c.setPlayer(player); } catch (SQLException e) { } c.setAccID(player.getAccountID()); int state = c.getLoginState(); boolean allowLogin = true; ChannelServer cserv = c.getChannelServer(); synchronized (this) { try { WorldChannelInterface worldInterface = cserv.getWorldInterface(); if (state == MapleClient.LOGIN_SERVER_TRANSITION) { for (String charName : c.loadCharacterNames(c.getWorld())) { if (worldInterface.isConnected(charName)) { int chanNum = c.getChannelServer().getWorldInterface().getLocation(charName).channel; System.err.print( charName + " on channel " + chanNum + " has been unstuck, for bug-testing purposes."); MapleCharacter player_to_dc = ChannelServer.getInstance(chanNum) .getPlayerStorage() .getCharacterByName(charName); if (player_to_dc.getEventInstance() != null) player_to_dc.getEventInstance().removePlayer(player_to_dc); player_to_dc.getMap().removePlayer(player_to_dc); ChannelServer.getInstance(chanNum).removePlayer(player_to_dc); player_to_dc.getClient().disconnect(); player_to_dc.getClient().getSession().close(); c.disconnect(); allowLogin = false; break; } } } } catch (RemoteException e) { cserv.reconnectWorld(); allowLogin = false; } catch (Exception e) { System.out.println("Error unsticking char:"); e.printStackTrace(); } if (state != MapleClient.LOGIN_SERVER_TRANSITION || !allowLogin) { c.setPlayer(null); c.getSession().close(true); return; } c.updateLoginState(MapleClient.LOGIN_LOGGEDIN); } cserv.addPlayer(player); try { List<PlayerBuffValueHolder> buffs = cserv.getWorldInterface().getBuffsFromStorage(cid); if (buffs != null) { c.getPlayer().silentGiveBuffs(buffs); } } catch (RemoteException e) { cserv.reconnectWorld(); } Connection con = DatabaseConnection.getConnection(); try { PreparedStatement ps = con.prepareStatement("SELECT SkillID,StartTime,length FROM cooldowns WHERE charid = ?"); ps.setInt(1, c.getPlayer().getId()); ResultSet rs = ps.executeQuery(); while (rs.next()) { final long length = rs.getLong("length"), startTime = rs.getLong("StartTime"); if (length + startTime > System.currentTimeMillis()) { c.getPlayer().giveCoolDowns(rs.getInt("SkillID"), startTime, length); } } rs.close(); ps.close(); ps = con.prepareStatement("DELETE FROM cooldowns WHERE charid = ?"); ps.setInt(1, c.getPlayer().getId()); ps.executeUpdate(); ps.close(); ps = con.prepareStatement( "SELECT Mesos FROM dueypackages WHERE RecieverId = ? and Checked = 1"); ps.setInt(1, c.getPlayer().getId()); rs = ps.executeQuery(); if (rs.next()) { try { PreparedStatement pss = DatabaseConnection.getConnection() .prepareStatement("UPDATE dueypackages SET Checked = 0 where RecieverId = ?"); pss.setInt(1, c.getPlayer().getId()); pss.executeUpdate(); pss.close(); } catch (SQLException e) { } c.getSession().write(MaplePacketCreator.sendDueyMSG((byte) 0x1B)); } rs.close(); ps.close(); rs = null; ps = null; } catch (SQLException e) { e.printStackTrace(); } c.getSession().write(MaplePacketCreator.getCharInfo(player)); c.getPlayer().InitiateSaveEvent(); if (player.isGM()) { SkillFactory.getSkill(GM.HIDE).getEffect(1).applyTo(player); } player.sendKeymap(); player.sendMacros(); player.getMap().addPlayer(player); try { int buddyIds[] = player.getBuddylist().getBuddyIds(); cserv .getWorldInterface() .loggedOn(player.getName(), player.getId(), c.getChannel(), buddyIds); for (CharacterIdChannelPair onlineBuddy : cserv.getWorldInterface().multiBuddyFind(player.getId(), buddyIds)) { BuddylistEntry ble = player.getBuddylist().get(onlineBuddy.getCharacterId()); ble.setChannel(onlineBuddy.getChannel()); player.getBuddylist().put(ble); } c.getSession().write(MaplePacketCreator.updateBuddylist(player.getBuddylist().getBuddies())); } catch (RemoteException e) { cserv.reconnectWorld(); } /* c.getSession().write(MaplePacketCreator.loadFamily(player)); if (player.getFamilyId() > 0) { c.getSession().write(MaplePacketCreator.getFamilyInfo(player)); }*/ if (player.getGuildId() > 0) { try { MapleGuild playerGuild = cserv.getWorldInterface().getGuild(player.getGuildId(), player.getMGC()); if (playerGuild == null) { player.deleteGuild(player.getGuildId()); player.resetMGC(); player.setGuildId(0); } else { cserv.getWorldInterface().setGuildMemberOnline(player.getMGC(), true, c.getChannel()); c.getSession().write(MaplePacketCreator.showGuildInfo(player)); int allianceId = player.getGuild().getAllianceId(); if (allianceId > 0) { MapleAlliance newAlliance = cserv.getWorldInterface().getAlliance(allianceId); if (newAlliance == null) { newAlliance = MapleAlliance.loadAlliance(allianceId); if (newAlliance != null) { cserv.getWorldInterface().addAlliance(allianceId, newAlliance); } else { player.getGuild().setAllianceId(0); } } if (newAlliance != null) { c.getSession().write(MaplePacketCreator.getAllianceInfo(newAlliance)); c.getSession().write(MaplePacketCreator.getGuildAlliances(newAlliance, c)); cserv .getWorldInterface() .allianceMessage( allianceId, MaplePacketCreator.allianceMemberOnline(player, true), player.getId(), -1); } } } } catch (RemoteException e) { cserv.reconnectWorld(); } } try { // c.getPlayer().showNote(); if (player.getParty() != null) { cserv .getWorldInterface() .updateParty( player.getParty().getId(), PartyOperation.LOG_ONOFF, new MaplePartyCharacter(player)); } player.updatePartyMemberHP(); } catch (RemoteException e) { cserv.reconnectWorld(); } for (MapleQuestStatus status : player.getStartedQuests()) { if (status.hasMobKills()) { c.getSession().write(MaplePacketCreator.updateQuestMobKills(status)); } } CharacterNameAndId pendingBuddyRequest = player.getBuddylist().pollPendingRequest(); if (pendingBuddyRequest != null) { player .getBuddylist() .put( new BuddylistEntry( pendingBuddyRequest.getName(), "그룹 미지정", pendingBuddyRequest.getId(), -1, false)); c.getSession() .write( MaplePacketCreator.requestBuddylistAdd( pendingBuddyRequest.getId(), c.getPlayer().getId(), pendingBuddyRequest.getName(), 0, 0)); // todo: make actual levels / jobids appear } c.getSession().write(MaplePacketCreator.updateBuddylist(player.getBuddylist().getBuddies())); // c.getSession().write(MaplePacketCreator.updateGender(player)); player.checkMessenger(); // c.getSession().write(MaplePacketCreator.enableReport()); /* if (!player.isGM() && !player.hasWatchedCygnusIntro() && player.getLevel() > 19 && !player.isCygnus() && player.getCygnusLinkId() == 0) { player.startCygnusIntro(); player.setWatchedCygnusIntro(true); }*/ // unneeded in 83+ as cygnus is created at char select ISkill bof = SkillFactory.getSkill( 10000000 * player.getJobType() + 12); // todo: find opcode and re-enable player.changeSkillLevel(bof, player.getLinkedLevel() / 10, bof.getMaxLevel()); player.checkBerserk(); player.expirationTask(); player.setRates(false); }
@Override public int execute(MapleClient c, String[] splitted) { c.getChannelServer().warpToEvent(c.getPlayer()); return 1; }
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) { c.getPlayer().resetAfkTime(); byte operation = slea.readByte(); if (operation == Actions.TOSERVER_SEND_ITEM.getCode()) { final int fee = 5000; byte inventId = slea.readByte(); short itemPos = slea.readShort(); short amount = slea.readShort(); int mesos = slea.readInt(); String recipient = slea.readMapleAsciiString(); if (amount < 0 || amount > 2000 || itemPos < 0 || inventId > 5 || inventId < 0) { return; } if (mesos < 0 || (long) mesos > Integer.MAX_VALUE || ((long) mesos + fee + getFee(mesos)) > Integer.MAX_VALUE) { return; } int finalcost = mesos + fee + getFee(mesos); boolean send = false; if (c.getPlayer().getMeso() >= finalcost) { int accid = getAccIdFromCNAME(recipient, true); if (accid != -1) { if (accid != c.getAccID()) { c.getPlayer().gainMeso(-finalcost, false); c.getSession() .write( MaplePacketCreator.sendDueyMSG(Actions.TOCLIENT_SUCCESSFULLY_SENT.getCode())); send = true; } else { c.getSession() .write(MaplePacketCreator.sendDueyMSG(Actions.TOCLIENT_SAMEACC_ERROR.getCode())); } } else { c.getSession() .write( MaplePacketCreator.sendDueyMSG(Actions.TOCLIENT_NAME_DOES_NOT_EXIST.getCode())); } } else { c.getSession() .write(MaplePacketCreator.sendDueyMSG(Actions.TOCLIENT_NOT_ENOUGH_MESOS.getCode())); } boolean recipientOn = false; MapleClient rClient = null; try { int channel = c.getChannelServer().getWorldInterface().find(recipient); if (channel > -1) { recipientOn = true; ChannelServer rcserv = ChannelServer.getInstance(channel); rClient = rcserv.getPlayerStorage().getCharacterByName(recipient).getClient(); } } catch (RemoteException re) { c.getChannelServer().reconnectWorld(); } if (send) { if (inventId > 0) { MapleInventoryType inv = MapleInventoryType.getByType(inventId); IItem item = c.getPlayer().getInventory(inv).getItem((byte) itemPos); if (item != null && c.getPlayer().getItemQuantity(item.getItemId(), false) > amount) { if (InventoryConstants.isRechargable(item.getItemId())) { MapleInventoryManipulator.removeFromSlot( c, inv, (byte) itemPos, item.getQuantity(), true); } else { MapleInventoryManipulator.removeFromSlot(c, inv, (byte) itemPos, amount, true, false); } addItemToDB( item, amount, mesos, c.getPlayer().getName(), getAccIdFromCNAME(recipient, false)); } else { return; } } else { addMesoToDB(mesos, c.getPlayer().getName(), getAccIdFromCNAME(recipient, false)); } if (recipientOn && rClient != null) { rClient .getSession() .write(MaplePacketCreator.sendDueyMSG(Actions.TOCLIENT_PACKAGE_MSG.getCode())); } c.getPlayer().gainMeso(-fee, false); } } else if (operation == Actions.TOSERVER_REMOVE_PACKAGE.getCode()) { int packageid = slea.readInt(); removeItemFromDB(packageid); c.getSession().write(MaplePacketCreator.removeItemFromDuey(true, packageid)); } else if (operation == Actions.TOSERVER_CLAIM_PACKAGE.getCode()) { int packageid = slea.readInt(); List<DueyPackages> packages = new LinkedList<DueyPackages>(); DueyPackages dp = null; Connection con = DatabaseConnection.getConnection(); try { PreparedStatement ps = con.prepareStatement( "SELECT * FROM dueypackages LEFT JOIN dueyitems USING (PackageId) WHERE PackageId = ?"); // PLEASE WORK D: ps.setInt(1, packageid); ResultSet rs = ps.executeQuery(); DueyPackages dueypack = null; if (rs.next()) { dueypack = getItemByPID(rs); dueypack.setSender(rs.getString("SenderName")); dueypack.setMesos(rs.getInt("Mesos")); dueypack.setSentTime(rs.getString("TimeStamp")); packages.add(dueypack); } rs.close(); ps.close(); dp = dueypack; } catch (SQLException e) { } if (dp.getItem() != null) { if (!MapleInventoryManipulator.checkSpace( c, dp.getItem().getItemId(), dp.getItem().getQuantity(), dp.getItem().getOwner())) { c.getPlayer().dropMessage(1, "Your inventory is full"); c.getSession().write(MaplePacketCreator.enableActions()); return; } else { MapleInventoryManipulator.addFromDrop(c, dp.getItem(), false); } } int gainmesos = 0; long totalmesos = (long) dp.getMesos() + (long) c.getPlayer().getMeso(); if (totalmesos >= Integer.MAX_VALUE) { gainmesos = 2147383647 - c.getPlayer().getMeso(); } else if (totalmesos < 0 || dp.getMesos() < 0) { // do nothing } else { c.getPlayer().gainMeso(gainmesos, false); } removeItemFromDB(packageid); c.getSession().write(MaplePacketCreator.removeItemFromDuey(false, packageid)); } }
public static final void HandleAlliance( final LittleEndianAccessor slea, final MapleClient c, boolean denied) { if (c.getPlayer().getGuildId() <= 0) { c.getSession().write(CWvsContext.enableActions()); return; } final MapleGuild gs = World.Guild.getGuild(c.getPlayer().getGuildId()); if (gs == null) { c.getSession().write(CWvsContext.enableActions()); return; } // System.out.println("Unhandled GuildAlliance \n" + slea.toString()); byte op = slea.readByte(); if (c.getPlayer().getGuildRank() != 1 && op != 1) { // only updating doesn't need guild leader return; } if (op == 22) { denied = true; } int leaderid = 0; if (gs.getAllianceId() > 0) { leaderid = World.Alliance.getAllianceLeader(gs.getAllianceId()); } // accept invite, and deny invite don't need allianceid. if (op != 4 && !denied) { if (gs.getAllianceId() <= 0 || leaderid <= 0) { return; } } else if (leaderid > 0 || gs.getAllianceId() > 0) { // infact, if they have allianceid it's suspicious return; } if (denied) { DenyInvite(c, gs); return; } MapleCharacter chr; int inviteid; switch (op) { case 1: // load... must be in world op for (byte[] pack : World.Alliance.getAllianceInfo(gs.getAllianceId(), false)) { if (pack != null) { c.getSession().write(pack); } } break; case 3: // invite final int newGuild = World.Guild.getGuildLeader(slea.readMapleAsciiString()); if (newGuild > 0 && c.getPlayer().getAllianceRank() == 1 && leaderid == c.getPlayer().getId()) { chr = c.getChannelServer().getPlayerStorage().getCharacterById(newGuild); if (chr != null && chr.getGuildId() > 0 && World.Alliance.canInvite(gs.getAllianceId())) { chr.getClient() .getSession() .write( AlliancePacket.sendAllianceInvite( World.Alliance.getAlliance(gs.getAllianceId()).getName(), c.getPlayer())); World.Guild.setInvitedId(chr.getGuildId(), gs.getAllianceId()); } else { c.getPlayer() .dropMessage(1, "Make sure the leader of the guild is online and in your channel."); } } else { c.getPlayer() .dropMessage( 1, "That Guild was not found. Please enter the correct Guild Name. (Not the player name)"); } break; case 4: // accept invite... guildid that invited(int, a/b check) -> guildname that was // invited? but we dont care about that inviteid = World.Guild.getInvitedId(c.getPlayer().getGuildId()); if (inviteid > 0) { if (!World.Alliance.addGuildToAlliance(inviteid, c.getPlayer().getGuildId())) { c.getPlayer().dropMessage(5, "An error occured when adding guild."); } World.Guild.setInvitedId(c.getPlayer().getGuildId(), 0); } break; case 2: // leave; nothing case 6: // expel, guildid(int) -> allianceid(don't care, a/b check) final int gid; if (op == 6 && slea.available() >= 4) { gid = slea.readInt(); if (slea.available() >= 4 && gs.getAllianceId() != slea.readInt()) { break; } } else { gid = c.getPlayer().getGuildId(); } if (c.getPlayer().getAllianceRank() <= 2 && (c.getPlayer().getAllianceRank() == 1 || c.getPlayer().getGuildId() == gid)) { if (!World.Alliance.removeGuildFromAlliance( gs.getAllianceId(), gid, c.getPlayer().getGuildId() != gid)) { c.getPlayer().dropMessage(5, "An error occured when removing guild."); } } break; case 7: // change leader if (c.getPlayer().getAllianceRank() == 1 && leaderid == c.getPlayer().getId()) { if (!World.Alliance.changeAllianceLeader(gs.getAllianceId(), slea.readInt())) { c.getPlayer().dropMessage(5, "An error occured when changing leader."); } } break; case 8: // title update if (c.getPlayer().getAllianceRank() == 1 && leaderid == c.getPlayer().getId()) { String[] ranks = new String[5]; for (int i = 0; i < 5; i++) { ranks[i] = slea.readMapleAsciiString(); } World.Alliance.updateAllianceRanks(gs.getAllianceId(), ranks); } break; case 9: if (c.getPlayer().getAllianceRank() <= 2) { if (!World.Alliance.changeAllianceRank( gs.getAllianceId(), slea.readInt(), slea.readByte())) { c.getPlayer().dropMessage(5, "An error occured when changing rank."); } } break; case 10: // notice update if (c.getPlayer().getAllianceRank() <= 2) { final String notice = slea.readMapleAsciiString(); if (notice.length() > 100) { break; } World.Alliance.updateAllianceNotice(gs.getAllianceId(), notice); } break; default: System.out.println("Unhandled GuildAlliance op: " + op + ", \n" + slea.toString()); break; } // c.getSession().write(CWvsContext.enableActions()); }