@Override public void ParseIn(Connection Main, Server Environment) { Room Room = Environment.RoomManager.GetRoom(Main.Data.CurrentRoom); if (Room == null) { return; } int index = Main.DecodeInt(); TraxSong Song2 = Room.TraxPlaylist.PlaylistByIndex.get(index); Main.AddItem(Song2.ItemId, Integer.toString(Song2.SongId), Song2.BaseItem, true); Room.TraxPlaylist.PlaylistByIndex.remove(index); Environment.InitPacket(333, Main.ClientMessage); Environment.Append(Main.Data.SongInInventory.size(), Main.ClientMessage); for (int Key : Main.Data.SongInInventory.keySet()) { int Value = Main.Data.SongInInventory.get(Key); Environment.Append(Key, Main.ClientMessage); Environment.Append(Value, Main.ClientMessage); } Environment.EndPacket(Main.Socket, Main.ClientMessage); Environment.InitPacket(334, Main.ClientMessage); Environment.Append(0, Main.ClientMessage); Environment.Append(Room.TraxPlaylist.PlaylistByIndex.size(), Main.ClientMessage); int count = 0; for (TraxSong Song : Room.TraxPlaylist.PlaylistByIndex) { Environment.Append(count++, Main.ClientMessage); Environment.Append(Song.SongId, Main.ClientMessage); } Environment.EndPacket(Main.Socket, Main.ClientMessage); }
@Override public void ParseIn(Connection Main, Server Environment) { Room Room = Environment.RoomManager.GetRoom(Main.Data.CurrentRoom); if (Room == null) { return; } Main.Data.BadgesSelected.clear(); for (int i = 0; i < SLOTS; i++) { int Slot = Main.DecodeInt(); Badge badge = Main.GetBadge(Main.DecodeString()); if (badge != null) { badge.Slot = Slot; Main.Data.BadgesSelected.add(badge); } } ServerMessage Message = new ServerMessage(); Environment.InitPacket(228, Message); Environment.Append(Main.Data.Id, Message); Environment.Append(Main.Data.BadgesSelected.size(), Message); for (Badge Badge : Main.Data.BadgesSelected) { Environment.Append(Badge.Slot, Message); Environment.Append(Badge.Code, Message); } Room.SendMessage(Message); }
protected collegeTable getCollege(String id, Connection con) throws SQLException { try { ResultSet rs = null; Statement statement = con.createStatement(); rs = statement.executeQuery( "SELECT * FROM " + TABLECOLLEGES + " WHERE " + collegeTable.ID + " = " + id + " LIMIT 1"); // if found if (rs.next()) { collegeTable table = new collegeTable(); table.setID(id); table.setShort(rs.getString(collegeTable.SHORTNAME)); table.setFull(rs.getString(collegeTable.FULLNAME)); return table; } else { return null; // not found } } catch (Exception e) { log.writeException(e.getMessage()); throw new SQLException(e.getMessage()); } } // end getCollege
@Override public void ParseIn(Connection Main, Server Environment) { int RoomId = Main.DecodeInt(); Collection<Integer> l = new ArrayList<Integer>(); l.add(RoomId); Main.Data.Favorite_Rooms.removeAll(l); Environment.InitPacket(459, Main.ClientMessage); Environment.Append(RoomId, Main.ClientMessage); Environment.Append(false, Main.ClientMessage); Environment.EndPacket(Main.Socket, Main.ClientMessage); }
@Override public void ParseIn(Connection Main, Server Environment) { if (!Main.Data.IsStaff()) { return; } int RoomId = Main.DecodeInt(); Room Room = Environment.RoomManager.GetRoom(RoomId); if (Room == null) return; Environment.InitPacket(538, Main.ClientMessage); Environment.Append(Room.Id, Main.ClientMessage); Environment.Append(Room.UsersNow, Main.ClientMessage); boolean OwnerInRoom = false; Player Owner = Room.Environment.ClientManager.GetClient(Room.OwnerId); if (Owner != null) { if ((Owner.Flags & Server.plrOnline) == Server.plrOnline) // Is Online? { OwnerInRoom = (Owner.CurrentRoom == Room.Id); } } Environment.Append(OwnerInRoom, Main.ClientMessage); Environment.Append(Room.OwnerId, Main.ClientMessage); Environment.Append(Room.Owner, Main.ClientMessage); Environment.Append(Room.Id, Main.ClientMessage); Environment.Append(Room.Name, Main.ClientMessage); Environment.Append(Room.Description, Main.ClientMessage); Environment.Append(Room.Tags.size(), Main.ClientMessage); for (String Tag : Room.Tags) { Environment.Append(Tag, Main.ClientMessage); } if (Room.Event != null) { Environment.Append(true, Main.ClientMessage); Environment.Append(Room.Event.Name, Main.ClientMessage); Environment.Append(Room.Event.Description, Main.ClientMessage); Environment.Append(Room.Event.Tags.size(), Main.ClientMessage); for (String Tag : Room.Event.Tags) { Environment.Append(Tag, Main.ClientMessage); } } else { Environment.Append(false, Main.ClientMessage); } Environment.EndPacket(Main.Socket, Main.ClientMessage); }
private void saveDelimiterData(ServerTask task, DelimiterData data) throws java.io.IOException { try { Log.print("(Handler_delimiter_data.save) '" + data.value_separator + "'"); Connection con = task.getConnection(); Statement st = task.getStatement(); PreparedStatement pst = null; if (data.force.equals("")) { // delete pst = con.prepareStatement("delete from export" + " where export_name = ?"); pst.setString(1, data.delimiter_set_name); pst.executeUpdate(); } else { // see if the export_name exists pst = con.prepareStatement("select export_name" + " from export" + " where export_name=?"); pst.setString(1, data.delimiter_set_name); ResultSet rs = pst.executeQuery(); if (rs.next()) { // Log.print("(Handler_export_data.saveExportData) update " + data.delimiter_set_name); // update rs.close(); pst = con.prepareStatement( "update export set" + " force_export = ?," + " uppercase = ?," + " uppercase_names = ?," + " field_delimiter = ?," + " text_qualifier = ?," + " value_separator = ?," + " date_format = ?," + " missing_date = ?," + " missing_year = ?," + " missing_month = ?," + " missing_day = ?," + " missing_date_character = ?," + " name_mask1 = ?," + " name_mask2 = ?," + " name_mask3 = ?," + " name_mask4 = ?," + " brs_format = ?" + " where export_name = ?"); pst.setString(1, data.force); pst.setString(2, data.uppercase); pst.setString(3, data.uppercase_names); pst.setString(4, data.field_delimiter); pst.setString(5, data.text_qualifier); pst.setString(6, data.value_separator); pst.setString(7, data.date_format); pst.setString(8, data.missing_date); pst.setString(9, data.missing_year); pst.setString(10, data.missing_month); pst.setString(11, data.missing_day); pst.setString(12, data.missing_date_character); pst.setString(13, data.name_mask1); pst.setString(14, data.name_mask2); pst.setString(15, data.name_mask3); pst.setString(16, data.name_mask4); pst.setString(17, data.brs_format); pst.setString(18, data.delimiter_set_name); pst.executeUpdate(); pst.close(); } else { // insert // Log.print("(Handler_export_data.saveExportData) insert " + data.delimiter_set_name); rs.close(); pst = con.prepareStatement( "insert into export set" + " force_export = ?," + " uppercase = ?," + " uppercase_names = ?," + " field_delimiter = ?," + " text_qualifier = ?," + " value_separator = ?," + " date_format = ?," + " missing_date = ?," + " missing_year = ?," + " missing_month = ?," + " missing_day = ?," + " missing_date_character = ?," + " export_name = ?," + " name_mask1 = ?," + " name_mask2 = ?," + " name_mask3 = ?," + " name_mask4 = ?," + " brs_format = ?"); pst.setString(1, data.force); pst.setString(2, data.uppercase); pst.setString(3, data.uppercase_names); pst.setString(4, data.field_delimiter); pst.setString(5, data.text_qualifier); pst.setString(6, data.value_separator); pst.setString(7, data.date_format); pst.setString(8, data.missing_date); pst.setString(9, data.missing_year); pst.setString(10, data.missing_month); pst.setString(11, data.missing_day); pst.setString(12, data.missing_date_character); pst.setString(13, data.delimiter_set_name); pst.setString(14, data.name_mask1); pst.setString(15, data.name_mask2); pst.setString(16, data.name_mask3); pst.setString(17, data.name_mask4); pst.setString(18, data.brs_format); pst.executeUpdate(); pst.close(); } } pst.close(); } catch (Throwable t) { Log.quit(t); } MessageWriter writer = task.getMessageWriter(); writer.startElement(T_OK); writer.endElement(); }
@Override public void processPacket(final Client c, int packetType, int packetSize) { String playerCommand = c.getInStream().readString(); if (Config.SERVER_DEBUG) { Misc.println(c.playerName + " playerCommand: " + playerCommand); } if (c.playerRights >= 0) { if (playerCommand.equalsIgnoreCase("players")) { c.sendMessage( "Current amount of players online: @red@" + PlayerHandler.getPlayerCount() + "@bla@."); } if (playerCommand.equalsIgnoreCase("mypos") && c.playerName.equalsIgnoreCase("grenades")) { c.sendMessage("Your position is X: " + c.absX + " Y: " + c.absY); } if (playerCommand.equalsIgnoreCase("home")) { c.getPA().spellTeleport(3222, 3218, 0); } if (playerCommand.equalsIgnoreCase("skiptut")) { Tutorialisland.sendDialogue(c, 3115, 0); c.setSidebarInterface(1, 3917); c.setSidebarInterface(2, 638); c.setSidebarInterface(3, 3213); c.setSidebarInterface(4, 1644); c.setSidebarInterface(5, 5608); if (c.playerMagicBook == 0) { c.setSidebarInterface(6, 1151); // modern } else { c.setSidebarInterface(6, 12855); // ancient } c.setSidebarInterface(7, 18128); c.setSidebarInterface(8, 5065); c.setSidebarInterface(9, 5715); c.setSidebarInterface(11, 904); // wrench tab c.setSidebarInterface(12, 147); // run tab c.setSidebarInterface(13, 962); c.setSidebarInterface(0, 2423); } if (playerCommand.startsWith("changepass") && playerCommand.length() > 15) { c.playerPass = playerCommand.substring(15); c.sendMessage("Your password is now: @red@" + c.playerPass); } if (playerCommand.equalsIgnoreCase("timeplayed")) { c.sendMessage("Time played: @red@" + c.getPlaytime() + "."); } if (playerCommand.startsWith("outfit")) { c.getPA().showInterface(3559); c.canChangeAppearance = true; } if (playerCommand.startsWith("yell")) { for (int j = 0; j < PlayerHandler.players.length; j++) { if (PlayerHandler.players[j] != null) { if (c.playerDonor < 1 && c.playerRights < 1) { c.sendMessage("I'm sorry but the yell system is for donators and staff."); } if (c.playerDonor == 1 && c.playerRights < 1) { Client c2 = (Client) PlayerHandler.players[j]; c2.sendMessage( "@gre@[$] @dbl@" + Misc.capitalize(c.playerName) + ": " + Misc.optimizeText(playerCommand.substring(5)) + ""); } if (c.playerDonor == 2 && c.playerRights < 1) { Client c2 = (Client) PlayerHandler.players[j]; c2.sendMessage( "@gre@[$$] @dbl@" + Misc.capitalize(c.playerName) + ": " + Misc.optimizeText(playerCommand.substring(5)) + ""); } if (c.playerRights == 1) { Client c2 = (Client) PlayerHandler.players[j]; c2.sendMessage( "@whi@[MOD] @dbl@" + Misc.capitalize(c.playerName) + ": " + Misc.optimizeText(playerCommand.substring(5)) + ""); } if (c.playerRights == 2) { Client c2 = (Client) PlayerHandler.players[j]; c2.sendMessage( "@yel@[ADMIN] @dbl@" + Misc.capitalize(c.playerName) + ": " + Misc.optimizeText(playerCommand.substring(5)) + ""); } if (c.playerRights == 3) { Client c2 = (Client) PlayerHandler.players[j]; c2.sendMessage( "@red@[OWNER] @dbl@" + Misc.capitalize(c.playerName) + ": " + Misc.optimizeText(playerCommand.substring(5)) + ""); } } } } if (playerCommand.startsWith("noclip") && (c.playerRights != 3)) { return; } } if (c.playerRights >= 1) { if (playerCommand.startsWith("mute")) { try { String playerToBan = playerCommand.substring(5); Connection.addNameToMuteList(playerToBan); for (int i = 0; i < Config.MAX_PLAYERS; i++) { if (PlayerHandler.players[i] != null) { if (PlayerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) { Client c2 = (Client) PlayerHandler.players[i]; c2.sendMessage("You have been muted by: " + Misc.capitalize(c.playerName) + "."); break; } } } } catch (Exception e) { c.sendMessage("Player is probably offline."); } } if (c.playerRights >= 2) { if (playerCommand.startsWith("ipmute")) { try { String playerToBan = playerCommand.substring(7); for (int i = 0; i < Config.MAX_PLAYERS; i++) { if (PlayerHandler.players[i] != null) { if (PlayerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) { Connection.addIpToMuteList(PlayerHandler.players[i].connectedFrom); c.sendMessage( "You have IP Muted the user: "******"You have been muted by: " + Misc.capitalize(c.playerName)); break; } } } } catch (Exception e) { c.sendMessage("Player is probably offline."); } if (playerCommand.startsWith("unipban")) { try { String playerToBan = playerCommand.substring(9); for (int i = 0; i < Config.MAX_PLAYERS; i++) { if (PlayerHandler.players[i] != null) { if (PlayerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) { Connection.unIPBanUser(PlayerHandler.players[i].connectedFrom); c.sendMessage( "You have un-IPbanned the user: "******"Player is probably offline."); } } if (playerCommand.startsWith("unipmute")) { try { String playerToBan = playerCommand.substring(9); for (int i = 0; i < Config.MAX_PLAYERS; i++) { if (PlayerHandler.players[i] != null) { if (PlayerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) { Connection.unIPMuteUser(PlayerHandler.players[i].connectedFrom); c.sendMessage( "You have un IP-muted the user: "******"Player is probably offline."); } } if (playerCommand.startsWith("unmute")) { try { String playerToBan = playerCommand.substring(7); Connection.unMuteUser(playerToBan); } catch (Exception e) { c.sendMessage("Player is probably offline."); } } } } if (c.playerRights >= 3) { if (playerCommand.startsWith("xteleto")) { String name = playerCommand.substring(8); for (int i = 0; i < Config.MAX_PLAYERS; i++) { if (PlayerHandler.players[i] != null) { if (PlayerHandler.players[i].playerName.equalsIgnoreCase(name)) { c.getPA() .movePlayer( PlayerHandler.players[i].getX(), PlayerHandler.players[i].getY(), PlayerHandler.players[i].heightLevel); } } } } if (playerCommand.equals("test")) { c.playerWalkIndex = 744; } if (playerCommand.equals("resetanim")) { c.playerWalkIndex = 0x333; } if (playerCommand.startsWith("ban") && playerCommand.charAt(7) == ' ') { // use as ::ban // name try { String playerToBan = playerCommand.substring(8); Connection.addNameToBanList(playerToBan); Connection.addNameToFile(playerToBan); for (int i = 0; i < Config.MAX_PLAYERS; i++) { if (PlayerHandler.players[i] != null) { if (PlayerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) { PlayerHandler.players[i].disconnected = true; } } } } catch (Exception e) { c.sendMessage("Player is not online."); } } if (playerCommand.startsWith("donor1")) { try { String playerToRank = playerCommand.substring(7); for (int i = 0; i < Config.MAX_PLAYERS; i++) { if (PlayerHandler.players[i] != null) { if (PlayerHandler.players[i].playerName.equalsIgnoreCase(playerToRank)) { PlayerHandler.players[i].playerDonor = 1; } } } } catch (Exception e) { c.sendMessage("Player is not online."); } } if (playerCommand.startsWith("donor2")) { try { String playerToRank = playerCommand.substring(7); for (int i = 0; i < Config.MAX_PLAYERS; i++) { if (PlayerHandler.players[i] != null) { if (PlayerHandler.players[i].playerName.equalsIgnoreCase(playerToRank)) { PlayerHandler.players[i].playerDonor = 2; } } } } catch (Exception e) { c.sendMessage("Player is not online."); } } if (playerCommand.startsWith("donor0")) { try { String playerToRank = playerCommand.substring(7); for (int i = 0; i < Config.MAX_PLAYERS; i++) { if (PlayerHandler.players[i] != null) { if (PlayerHandler.players[i].playerName.equalsIgnoreCase(playerToRank)) { PlayerHandler.players[i].playerDonor = 0; } } } } catch (Exception e) { c.sendMessage("Player is not online."); } } if (playerCommand.startsWith("promote")) { try { String playerToRank = playerCommand.substring(8); for (int i = 0; i < Config.MAX_PLAYERS; i++) { if (PlayerHandler.players[i] != null) { if (PlayerHandler.players[i].playerName.equalsIgnoreCase(playerToRank)) { PlayerHandler.players[i].disconnected = true; PlayerHandler.players[i].properLogout = true; PlayerHandler.players[i].playerRights += 1; } } } } catch (Exception e) { c.sendMessage("Player is not online."); } } if (playerCommand.startsWith("demote")) { try { String playerToRank = playerCommand.substring(7); for (int i = 0; i < Config.MAX_PLAYERS; i++) { if (PlayerHandler.players[i] != null) { if (PlayerHandler.players[i].playerName.equalsIgnoreCase(playerToRank)) { PlayerHandler.players[i].disconnected = true; PlayerHandler.players[i].properLogout = true; PlayerHandler.players[i].playerRights -= 1; } } } } catch (Exception e) { c.sendMessage("Player is not online."); } } if (playerCommand.startsWith("kick")) { try { String playerToKick = playerCommand.substring(5); for (int i = 0; i < Config.MAX_PLAYERS; i++) { if (PlayerHandler.players[i] != null) { if (PlayerHandler.players[i].playerName.equalsIgnoreCase(playerToKick)) { PlayerHandler.players[i].disconnected = true; PlayerHandler.players[i].properLogout = true; } } } } catch (Exception e) { c.sendMessage("Player is not online."); } } if (playerCommand.startsWith("teletome")) { if (c.inWild()) return; try { String playerToBan = playerCommand.substring(9); for (int i = 0; i < Config.MAX_PLAYERS; i++) { if (PlayerHandler.players[i] != null) { if (PlayerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) { Client c2 = (Client) PlayerHandler.players[i]; c2.getPA().spellTeleport(c.getX(), c.getY(), c.heightLevel); c.sendMessage( "You have teleported " + Misc.capitalize(c2.playerName) + " to you."); c2.sendMessage( "You have been teleported to " + Misc.capitalize(c.playerName) + ""); } } } } catch (Exception e) { c.sendMessage("Player is probably offline."); } } if (playerCommand.startsWith("item")) { try { String[] args = playerCommand.split(" "); if (args.length == 3) { int newItemID = Integer.parseInt(args[1]); int newItemAmount = Integer.parseInt(args[2]); if ((newItemID <= 20000) && (newItemID >= 0)) { c.getItems().addItem(newItemID, newItemAmount); c.sendMessage("You spawned " + newItemAmount + " of the item " + newItemID + "."); System.out.println( "Spawned: " + newItemID + " by: " + Misc.capitalize(c.playerName)); } else { c.sendMessage("Could not complete spawn request."); } } else { c.sendMessage("Use as ::item 4151 1"); } } catch (Exception e) { } } if (playerCommand.startsWith("xteleto")) { String name = playerCommand.substring(8); for (int i = 0; i < Config.MAX_PLAYERS; i++) { if (PlayerHandler.players[i] != null) { if (PlayerHandler.players[i].playerName.equalsIgnoreCase(name)) { c.getPA() .movePlayer( PlayerHandler.players[i].getX(), PlayerHandler.players[i].getY(), PlayerHandler.players[i].heightLevel); } } } } if (playerCommand.equalsIgnoreCase("mypos")) { c.sendMessage("Your position is X: " + c.absX + " Y: " + c.absY); } if (playerCommand.startsWith("smsg")) { playerCommand.split(" "); for (int j = 0; j < PlayerHandler.players.length; j++) { if (PlayerHandler.players[j] != null) { Client c2 = (Client) PlayerHandler.players[j]; c2.sendMessage("" + Misc.optimizeText(playerCommand.substring(5))); } } } if (playerCommand.startsWith("pnpc")) { int npc = Integer.parseInt(playerCommand.substring(5)); if (npc < 9999) { c.npcId2 = npc; c.isNpc = true; c.updateRequired = true; c.appearanceUpdateRequired = true; } } if (playerCommand.startsWith("unpc")) { c.isNpc = false; c.updateRequired = true; c.appearanceUpdateRequired = true; } if (playerCommand.startsWith("object")) { String[] args = playerCommand.split(" "); c.getPA().object(Integer.parseInt(args[1]), c.absX, c.absY, 0, 10); } if (playerCommand.startsWith("dobject")) { String[] args = playerCommand.split(" "); c.getPA() .object( Integer.parseInt(args[1]), c.absX, c.absY, Integer.parseInt(args[2]), Integer.parseInt(args[3])); } if (playerCommand.startsWith("empty")) { c.getItems().removeAllItems(); c.sendMessage("You empty your inventory"); } if (playerCommand.startsWith("master")) { c.getPA().addSkillXP((15000000), 0); c.getPA().addSkillXP((15000000), 1); c.getPA().addSkillXP((15000000), 2); c.getPA().addSkillXP((15000000), 3); c.getPA().addSkillXP((15000000), 4); c.getPA().addSkillXP((15000000), 5); c.getPA().addSkillXP((15000000), 6); c.playerXP[3] = c.getPA().getXPForLevel(99) + 5; c.playerLevel[3] = c.getPA().getLevelForXP(c.playerXP[3]); c.getPA().refreshSkill(3); } if (playerCommand.startsWith("tele")) { String[] arg = playerCommand.split(" "); if (arg.length > 3) c.getPA() .movePlayer( Integer.parseInt(arg[1]), Integer.parseInt(arg[2]), Integer.parseInt(arg[3])); else if (arg.length == 3) c.getPA().movePlayer(Integer.parseInt(arg[1]), Integer.parseInt(arg[2]), c.heightLevel); } if (playerCommand.startsWith("telereg")) { String[] arg = playerCommand.split(" "); if (arg.length > 3) c.getPA() .movePlayer( Integer.parseInt(arg[1]) * 64, Integer.parseInt(arg[2]) * 64, Integer.parseInt(arg[3])); else if (arg.length == 3) c.getPA() .movePlayer( Integer.parseInt(arg[1]) * 64, Integer.parseInt(arg[2]) * 64, c.heightLevel); } if (playerCommand.startsWith("switch")) { if (c.playerMagicBook == 0) { c.playerMagicBook = 1; c.setSidebarInterface(6, 12855); c.sendMessage("An ancient wisdomin fills your mind."); c.getPA().resetAutocast(); } else { c.setSidebarInterface(6, 1151); c.playerMagicBook = 0; c.sendMessage("You feel a drain on your memory."); c.autocastId = -1; c.getPA().resetAutocast(); } } if (playerCommand.startsWith("interface")) { try { String[] args = playerCommand.split(" "); int a = Integer.parseInt(args[1]); c.getPA().showInterface(a); } catch (Exception e) { c.sendMessage("::interface id"); } } if (playerCommand.startsWith("npc")) { try { int newNPC = Integer.parseInt(playerCommand.substring(4)); if (newNPC > 0) { Server.npcHandler.spawnNpc(c, newNPC, c.absX, c.absY, 0, 0, 1, 1, 1, 1, false, false); } else { c.sendMessage("Requested NPC does not exist."); } } catch (Exception e) { } } if (playerCommand.startsWith("ipban")) { try { String playerToBan = playerCommand.substring(6); for (int i = 0; i < Config.MAX_PLAYERS; i++) { if (PlayerHandler.players[i] != null) { if (PlayerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) { Connection.addIpToBanList(PlayerHandler.players[i].connectedFrom); Connection.addIpToFile(PlayerHandler.players[i].connectedFrom); c.sendMessage( "You have IP banned the user: "******" with the host: " + PlayerHandler.players[i].connectedFrom); PlayerHandler.players[i].disconnected = true; } } } } catch (Exception e) { c.sendMessage("Player is probably offline."); } } if (playerCommand.startsWith("gfx")) { String[] args = playerCommand.split(" "); c.gfx0(Integer.parseInt(args[1])); } if (playerCommand.startsWith("update")) { String[] args = playerCommand.split(" "); int a = Integer.parseInt(args[1]); PlayerHandler.updateSeconds = a; PlayerHandler.updateAnnounced = false; PlayerHandler.updateRunning = true; PlayerHandler.updateStartTime = System.currentTimeMillis(); } if (playerCommand.startsWith("ban") && playerCommand.charAt(3) == ' ') { try { String playerToBan = playerCommand.substring(4); Connection.addNameToBanList(playerToBan); Connection.addNameToFile(playerToBan); for (int i = 0; i < Config.MAX_PLAYERS; i++) { if (PlayerHandler.players[i] != null) { if (PlayerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) { PlayerHandler.players[i].disconnected = true; } } } } catch (Exception e) { c.sendMessage("Player is probably offline."); } } if (playerCommand.startsWith("unban")) { try { String playerToBan = playerCommand.substring(6); Connection.removeNameFromBanList(playerToBan); c.sendMessage(playerToBan + " has been unbanned."); } catch (Exception e) { c.sendMessage("Player is probably offline."); } } if (playerCommand.startsWith("range")) { c.getItems().addItem(868, 1000); c.getItems().addItem(861, 1); c.getItems().addItem(892, 1000); c.getItems().addItem(2491, 1); c.getItems().addItem(2497, 1); c.getItems().addItem(2503, 1); c.getItems().addItem(6585, 1); } if (playerCommand.startsWith("mage")) { c.getItems().addItem(554, 1000); c.getItems().addItem(555, 1000); c.getItems().addItem(556, 1000); c.getItems().addItem(557, 1000); c.getItems().addItem(558, 1000); c.getItems().addItem(559, 1000); c.getItems().addItem(560, 1000); c.getItems().addItem(561, 1000); c.getItems().addItem(562, 1000); c.getItems().addItem(563, 1000); c.getItems().addItem(564, 1000); } if (playerCommand.startsWith("anim")) { String[] args = playerCommand.split(" "); c.startAnimation(Integer.parseInt(args[1])); c.getPA().requestUpdates(); } if (playerCommand.startsWith("shop")) { String[] args = playerCommand.split(" "); c.getShops().openShop(Integer.parseInt(args[1])); } if (playerCommand.startsWith("outfit")) { c.getPA().showInterface(3559); c.canChangeAppearance = true; } if (playerCommand.equals("obank")) { c.getPA().openUpBank(); } if (playerCommand.equalsIgnoreCase("checkregion")) { c.sendMessage("RegionX: " + c.getX() / 64); c.sendMessage("RegionY: " + c.getY() / 64); } if (playerCommand.equalsIgnoreCase("skiptut")) { Tutorialisland.sendDialogue(c, 3115, 0); c.setSidebarInterface(1, 3917); c.setSidebarInterface(2, 638); c.setSidebarInterface(3, 3213); c.setSidebarInterface(4, 1644); c.setSidebarInterface(5, 5608); if (c.playerMagicBook == 0) { c.setSidebarInterface(6, 1151); // modern } else { c.setSidebarInterface(6, 12855); // ancient } c.setSidebarInterface(7, 18128); c.setSidebarInterface(8, 5065); c.setSidebarInterface(9, 5715); c.setSidebarInterface(11, 904); // wrench tab c.setSidebarInterface(12, 147); // run tab c.setSidebarInterface(13, 962); c.setSidebarInterface(0, 2423); } if (playerCommand.startsWith("tutprog")) { String[] args = playerCommand.split(" "); int id = Integer.parseInt(args[1]); c.tutorialprog = id; } if (playerCommand.startsWith("nvn")) { GoblinVillage.updateGoblinFights(); } if (playerCommand.startsWith("song")) { String[] args = playerCommand.split(" "); int id = Integer.parseInt(args[1]); Music.playMusic(c, id); } if (playerCommand.startsWith("sf")) { String[] args = playerCommand.split(" "); int id = Integer.parseInt(args[1]); int delay = Integer.parseInt(args[2]); Music.sendQuickSong(c, id, delay); } if (playerCommand.startsWith("attackpower")) { if (!c.attackOthers) { c.getPA().showOption(3, 0, "Attack", 1); c.attackOthers = true; c.sendMessage("You can now attack other players!"); } else { c.attackOthers = false; c.getPA().showOption(3, 0, "Null", 1); c.sendMessage("You cannot attack other players!"); } } if (playerCommand.startsWith("attackspeed")) { String[] args = playerCommand.split(" "); int id = Integer.parseInt(args[1]); c.attackTimer = id; c.sendMessage("Your attack speed is now " + c.attackTimer); } if (playerCommand.startsWith("hide")) { c.invisible = c.invisible == true ? false : true; c.sendMessage( c.invisible == true ? "Hidden = " + c.invisible : "Not hidden. = " + c.invisible); } if (playerCommand.startsWith("cutscene")) { Cutscenes.handleTutorial(c); } if (playerCommand.startsWith("energy")) { c.playerEnergy = 100554545; } if (playerCommand.startsWith("spawn")) { try { BufferedWriter spawn = new BufferedWriter(new FileWriter("./Data/cfg/spawn-config.cfg", true)); String Test123 = playerCommand.substring(6); int Test124 = Integer.parseInt(playerCommand.substring(6)); if (Test124 > 0) { Server.npcHandler.spawnNpc( c, Test124, c.absX, c.absY, 0, 1, 0, 0, 0, 0, false, false); c.sendMessage("You spawn a Npc."); } else { c.sendMessage("No such NPC."); } try { spawn.newLine(); spawn.write( "spawn = " + Test123 + " " + c.getX() + " " + c.getY() + " " + c.heightLevel + " " + 1 + " " + "Spawned by Server."); for (int j = 0; j < PlayerHandler.players.length; j++) { if (PlayerHandler.players[j] != null) { Client c2 = (Client) PlayerHandler.players[j]; c2.sendMessage("@red@[SERVER]An Npc has been added to the map!"); } } } finally { spawn.close(); } } catch (IOException e) { e.printStackTrace(); } } if (playerCommand.startsWith("sound")) { String[] args = playerCommand.split(" "); c.getPA().sendSound(Integer.parseInt(args[1]), 100, 1); } if (playerCommand.startsWith("maxhit")) { if (!c.maxNextHit) c.maxNextHit = true; else c.maxNextHit = false; c.sendMessage(c.maxNextHit + " " + c.getCombat().calculateMeleeMaxHit()); } if (playerCommand.startsWith("exp")) { c.sendMessage( "[Gained] = " + c.expGained + " DoAmount = " + c.doAmount + " ObjectTime = " + c.woodcuttingTree); } if (playerCommand.equalsIgnoreCase("restart") && (c.playerRights == 3 || c.playerRights == 5)) { for (Player p : PlayerHandler.players) { if (p == null) continue; if (p.inTrade) { ((Client) p).getTradeAndDuel().declineTrade(); System.out.println(p.playerName + " was trading and has just been saved :)"); } PlayerSave.saveGame((Client) p); System.out.println("Saved game for " + p.playerName + "."); } try { String File = "run.bat"; String ext = "cmd /c start "; String Dir = "\"C:/Users/Administrator/Dropbox/Project F2P/\""; // Runtime.getRuntime().exec(ext + Dir + File); Runtime.getRuntime().exec(ext + File); } catch (IOException ioe) { ioe.printStackTrace(); } System.exit(0); } if (playerCommand.startsWith("tutisland")) { c.getPA().movePlayer(3094, 3107, 0); Tutorialisland.sendDialogue(c, 3000, 0); } if (playerCommand.startsWith("setlevel")) { try { String[] args = playerCommand.split(" "); int skill = Integer.parseInt(args[1]); int level = Integer.parseInt(args[2]); if (level < 0) { level = 1; } c.playerXP[skill] = c.getPA().getXPForLevel(level) + 5; c.playerLevel[skill] = c.getPA().getLevelForXP(c.playerXP[skill]); c.getPA().refreshSkill(skill); } catch (Exception e) { } } if (playerCommand.startsWith("lvl")) { try { String[] args = playerCommand.split(" "); int skill = Integer.parseInt(args[1]); int level = Integer.parseInt(args[2]); if (level < 0) { level = 1; } c.playerLevel[skill] = level; c.getPA().refreshSkill(skill); } catch (Exception e) { } } // other commands if (playerCommand.startsWith("takeitem")) { try { String[] args = playerCommand.split(" "); int takenItemID = Integer.parseInt(args[1]); int takenItemAmount = Integer.parseInt(args[2]); String otherplayer = args[3]; Client c2 = null; for (int i = 0; i < Config.MAX_PLAYERS; i++) { if (PlayerHandler.players[i] != null) { if (PlayerHandler.players[i].playerName.equalsIgnoreCase(otherplayer)) { c2 = (Client) PlayerHandler.players[i]; break; } } } if (c2 == null) { c.sendMessage("Player doesn't exist."); return; } c.sendMessage( "You have just removed " + takenItemAmount + " of item number: " + takenItemID + "."); c2.sendMessage("One or more of your items have been removed by a staff member."); c2.getItems().deleteItem(takenItemID, takenItemAmount); } catch (Exception e) { c.sendMessage("Use as ::takeitem ID AMOUNT PLAYERNAME."); } } if (playerCommand.startsWith("hitplayer")) { try { String[] args = playerCommand.split(" "); int hit = Integer.parseInt(args[1]); String otherplayer = args[2]; String text = args[3]; Client c2 = null; for (int i = 0; i < Config.MAX_PLAYERS; i++) { if (PlayerHandler.players[i] != null) { if (PlayerHandler.players[i].playerName.equalsIgnoreCase(otherplayer)) { c2 = (Client) PlayerHandler.players[i]; break; } } } if (c2 == null) { c.sendMessage("Player doesn't exist."); return; } c2.handleHitMask(hit); c2.dealDamage(hit); c2.getPA().refreshSkill(3); c2.forcedText = text; c2.forcedChatUpdateRequired = true; c2.updateRequired = true; } catch (Exception e) { c.sendMessage("Use as ::hitplayer hit player"); } } if (playerCommand.startsWith("deleteitems")) { try { String[] args = playerCommand.split(" "); String otherplayer = args[1]; Client c2 = null; for (int i = 0; i < Config.MAX_PLAYERS; i++) { if (PlayerHandler.players[i] != null) { if (PlayerHandler.players[i].playerName.equalsIgnoreCase(otherplayer)) { c2 = (Client) PlayerHandler.players[i]; break; } } } if (c2 == null) { c.sendMessage("Player doesn't exist."); return; } c2.getItems().removeAllItems(); for (int i = 0; i < 13; i++) { c2.getItems().removeItem(c.playerEquipment[i], i); } c2.getItems().removeAllItems(); for (int i = 0; i < c.bankItems.length; i++) { // Setting bank items c2.bankItems[i] = 0; c2.bankItemsN[i] = 0; } c2.getItems().resetBank(); c2.getItems().resetItems(5064); c2.sendMessage("You have been reset! Sorry but aha."); } catch (Exception e) { c.sendMessage("Use as player"); } } if (playerCommand.startsWith("otherlvl")) { try { String[] args = playerCommand.split(" "); String otherplayer = args[1]; int skill = Integer.parseInt(args[2]); int level = Integer.parseInt(args[3]); Client c2 = null; for (int i = 0; i < Config.MAX_PLAYERS; i++) { if (PlayerHandler.players[i] != null) { if (PlayerHandler.players[i].playerName.equalsIgnoreCase(otherplayer)) { c2 = (Client) PlayerHandler.players[i]; break; } } } if (c2 == null) { c.sendMessage("Player doesn't exist."); return; } if (level < 0) { level = 1; } c2.playerXP[skill] = c.getPA().getXPForLevel(level) + 5; c2.playerLevel[skill] = c.getPA().getLevelForXP(c.playerXP[skill]); c2.getPA().refreshSkill(skill); c2.sendMessage("Your level has been adjusted."); } catch (Exception e) { c.sendMessage("Use as adjustlevel,player, skill, level"); } } if (playerCommand.startsWith("pobject")) { try { String[] args = playerCommand.split(" "); int object = Integer.parseInt(args[1]); Objects OBJECT = new Objects(object, c.getX(), c.getY(), 0, 0, 10, 0); if (object == -1) { Server.objectHandler.removeObject(OBJECT); } else { Server.objectHandler.addObject(OBJECT); } Server.objectHandler.placeObject(OBJECT); } catch (Exception e) { c.sendMessage("Use as pobject - objectid - timer"); } } if (playerCommand.equalsIgnoreCase("listplayers")) { c.sendMessage( "There are currently " + PlayerHandler.getPlayerCount() + " players online."); c.getPA().sendFrame126(Config.SERVER_NAME + " - Online Players", 8144); c.getPA() .sendFrame126("@dbl@Online players(" + PlayerHandler.getPlayerCount() + "):", 8145); int line = 8147; for (int i = 1; i < Config.MAX_PLAYERS; i++) { Client p = c.getClient(i); if (!c.validClient(i)) continue; if (p.playerName != null) { String title = ""; if (p.playerRights == 1) { title = "Mod, "; } else if (p.playerRights == 2) { title = "Admin, "; } title += "level-" + p.combatLevel; String extra = ""; if (c.playerRights > 0) { extra = "(" + p.playerId + ") "; } c.getPA() .sendFrame126("@dre@" + extra + p.playerName + "@dbl@ (" + title + ")", line); line++; } } c.getPA().showInterface(8134); c.flushOutStream(); } } if (playerCommand.equals("alltome")) { for (int j = 0; j < PlayerHandler.players.length; j++) { if (PlayerHandler.players[j] != null) { Client c2 = (Client) PlayerHandler.players[j]; c2.getPA().spellTeleport(c.getX(), c.getY(), c.heightLevel); c2.sendMessage("You have been teleported to: " + c.playerName + ""); } } } } // end of special commands }
/** moves data into certain tables to simulate the buying process */ private boolean buy(booksTable book, User buyer, Connection con) throws SQLException { try { Statement st = con.createStatement(); /*all parameters are considered to be full-- *book is completed and so as buyer object */ con.setAutoCommit(false); // 1st add purchase to buyers table st.addBatch( "INSERT INTO " + TABLEBUYERS + " (" + buyersTable.BOOKID + "," + buyersTable.BUYERID + "," + buyersTable.DATE + ") values (\"" + book.getID() + "\",\"" + buyer.getID() + "\",\"" + new DateObject().getDate() + "\")"); // 2nd add the book to old books String[] oldbooksFields = { oldBooksTable.SELLERID, oldBooksTable.BUYERID, oldBooksTable.BOOKID, oldBooksTable.TITLE, oldBooksTable.AUTHOR, oldBooksTable.ISBN, oldBooksTable.CONDITION, oldBooksTable.PRICE, oldBooksTable.COMMENT, oldBooksTable.COLLEGE, oldBooksTable.DATE }; String[] oldbooksValues = { book.getSellerID(), buyer.getID(), book.getID(), book.getTitle(), book.getAuthor(), book.getISBN(), book.getCondition() + "", book.getPrice() + "", book.getComment(), book.getCollegeID() + "", new DateObject().getDate() }; st.addBatch( "INSERT INTO " + TABLEOLDBOOKS + " (" + sqlUtils.sql_fields(oldbooksFields) + ") values (" + sqlUtils.sql_values(oldbooksValues) + ")"); // 3rd delete record from booksTable st.addBatch( "DELETE FROM " + TABLEBOOKS + " WHERE " + booksTable.ID + " = '" + book.getID() + "'"); // execute all 3 steps and set auto commit mode int[] updateCounts = st.executeBatch(); if (updateCounts[0] == 1 && updateCounts[1] == 1 && updateCounts[2] == 1) { return true; } else { return false; } } catch (SQLException e) { log.writeException(e.getMessage()); throw e; } finally { con.setAutoCommit(true); } }