Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package server.model.players.packets;
- import java.io.*;
- import java.util.*;
- import java.text.DateFormat;
- import java.text.SimpleDateFormat;
- import server.Config;
- import server.Connection;
- import server.Server;
- import server.model.players.Client;
- import server.model.players.PacketType;
- import server.model.players.PlayerHandler;
- import server.model.players.Player;
- import server.util.Misc;
- import server.world.WorldMap;
- import java.io.BufferedWriter;
- import java.io.BufferedReader;
- import java.io.FileWriter;
- import java.io.FileReader;
- import server.event.EventManager;
- import server.event.Event;
- import server.event.EventContainer;
- /**
- * Commands
- **/
- public class Commands implements PacketType {
- @Override
- public void processPacket(Client c, int packetType, int packetSize) {
- String playerCommand = c.getInStream().readString();
- if(c.playerRights >= 1 && c.playerRights != 4 && !playerCommand.startsWith("/")) {
- try {
- DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
- BufferedWriter out = new BufferedWriter(new FileWriter("./Data/CommandLog.txt", true));
- try {
- out.newLine();
- out.write("[] " + c.properName + " used command (" + playerCommand + ")");
- } finally {
- out.close();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- if(Config.SERVER_DEBUG)
- Misc.println(c.playerName+" playerCommand: "+playerCommand);
- if (playerCommand.startsWith("/") && playerCommand.length() > 1) {
- if (c.clanId >= 0) {
- System.out.println(playerCommand);
- playerCommand = playerCommand.substring(1);
- Server.clanChat.playerMessageToClan(c.playerId, playerCommand, c.clanId);
- } else {
- if (c.clanId != -1)
- c.clanId = -1;
- c.sendMessage("You are not in a clan.");
- }
- return;
- }
- if(c.playerRights >= 0) {
- /* I have a serious issue with idiots adding commands that can potentially ruin a server and cost donators items they donated for.
- Please think twice about adding stupid and useless commands that can be easily abused by faggots like Bryce.
- Thanks,
- Underoath
- */
- if (playerCommand.startsWith("cckick")) {
- String name = playerCommand.substring(7);
- Server.clanChat.kickPlayerFromClan(c,name);
- }
- if (playerCommand.startsWith("clipon")) {
- c.sendMessage("Go reload your client.");
- c.freezeTimer = Integer.MAX_VALUE;
- }
- if (playerCommand.startsWith("ccpassword")) {
- String pass = playerCommand.substring(11);
- if(c.clanId == -1) {
- c.clanPass = pass;
- } else {
- Server.clanChat.setClanPassword(c,pass,true);
- }
- }
- if (playerCommand.startsWith("ccmute")) {
- String name = playerCommand.substring(7);
- if(c.clanId == -1){
- c.sendMessage("You are not in a clan!");
- } else {
- Server.clanChat.mutePlayer(c,name);
- }
- }
- if (playerCommand.equalsIgnoreCase("ccclear")) {
- if(c.clanId != -1) {
- Server.clanChat.setClanPassword(c,null,false);
- c.clanPass = null;
- c.sendMessage("Clan chat passwords have been cleared.");
- } else {
- c.clanPass = null;
- c.sendMessage("Clan chat passwords have been cleared.");
- }
- }
- if (playerCommand.equalsIgnoreCase("ccowner")) {
- String name = playerCommand.substring(8);
- Server.clanChat.changeOwner(c,name);
- }
- if (playerCommand.startsWith("ccunmute")) {
- String name = playerCommand.substring(9);
- if(c.clanId == -1){
- c.sendMessage("You are not in a clan!");
- } else {
- Server.clanChat.unmutePlayer(c,name);
- }
- }
- if (playerCommand.equalsIgnoreCase("players"))
- c.sendMessage("There are currently "+ PlayerHandler.getPlayerCount()+" players online.");
- if (playerCommand.equalsIgnoreCase("flip") || playerCommand.equalsIgnoreCase("switch") || playerCommand.equalsIgnoreCase("swap")) {
- if(c.inWild()) {
- c.sendMessage("You can't switch your prayers in the wilderness.");
- return;
- }
- if (c.playerPrayerBook) {
- c.playerPrayerBook = false;
- c.setSidebarInterface(5, 5608);
- c.sendMessage("[DEBUG]: Normal.");
- } else {
- c.playerPrayerBook = true;
- c.setSidebarInterface(5, 22500);
- c.sendMessage("[DEBUG]: Curses.");
- }
- c.sendMessage("[DEBUG]: Prayers Refreshed");
- c.getCombat().resetPrayers();
- }
- if (playerCommand.startsWith("changepassword") && playerCommand.length() > 15) {
- c.playerPass = playerCommand.substring(15);
- c.sendMessage("Your password is now: " + c.playerPass);
- }
- if (playerCommand.equalsIgnoreCase("explock")) {
- c.expLock = !c.expLock;
- c.sendMessage("Experience lock " + (c.expLock ? "activated." : "deactivated."));
- }
- if (playerCommand.equals("vote")) {
- c.getPA().sendFrame126("", 12000);
- }
- if (playerCommand.equalsIgnoreCase("commands")) {
- c.sendMessage("");
- c.sendMessage("");
- c.sendMessage("");
- c.sendMessage("");
- c.sendMessage("");
- }
- String[] args = playerCommand.split(" ");
- int skill = Integer.parseInt(args[1]);
- int level = Integer.parseInt(args[2]);
- if (level > 99)
- level = 99;
- else 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);
- c.getPA().requestUpdates();
- }
- for (int skill = 0; skill < 7; skill++) {
- c.playerXP[skill] = c.getPA().getXPForLevel(99)+5;
- c.playerLevel[skill] = c.getPA().getLevelForXP(c.playerXP[skill]);
- c.getPA().refreshSkill(skill);
- }
- c.constitution = 990;
- c.getPA().requestUpdates();
- }
- if (playerCommand.startsWith("interface")) {
- String[] args = playerCommand.split(" ");
- c.getPA().showInterface(Integer.parseInt(args[1]));
- }
- if (playerCommand.startsWith("gfx")) {
- String[] args = playerCommand.split(" ");
- c.gfx0(Integer.parseInt(args[1]));
- }
- if (playerCommand.equalsIgnoreCase("mypos")) {
- c.sendMessage("X: "+c.absX);
- c.sendMessage("Y: "+c.absY);
- c.sendMessage("mapregionX: " + c.mapRegionX);
- c.sendMessage("mapregionY: " + c.mapRegionY);
- }
- if (playerCommand.startsWith("yell") && c.playerRights >= 1) {
- if (!Connection.isMuted(c)) {
- if (playerCommand.substring(5).contains("@")) {
- c.sendMessage("You may not use the symbol '@'.");
- return;
- }
- for (int j = 0; j < Server.playerHandler.players.length; j++) {
- if (Server.playerHandler.players[j] != null) {
- Client c2 = (Client)Server.playerHandler.players[j];
- c2.sendMessage(c.getPA().getYellRank() + " " + c.playerName + ": " + Misc.optimize(playerCommand.substring(5)));
- }
- }
- }
- }
- if (playerCommand.startsWith("settag") && c.playerRights >= 1) {
- String tag = playerCommand.substring(7);
- if(tag.length() > 15) {
- c.sendMessage("Your tag can be no longer than 15 characters.");
- return;
- }
- if (tag.contains("@")) {
- c.sendMessage("You may not use the symbol '@' in your tag.");
- return;
- }
- c.donorTag = tag;
- c.sendMessage("You have edited your tag to " + c.donorTag + ".");
- }
- }
- if (c.playerRights >= 1 && c.playerRights <= 3) {
- if (playerCommand.startsWith("staff")) {
- for (int j = 0; j < Server.playerHandler.players.length; j++) {
- if (Server.playerHandler.players[j] != null) {
- Client c2 = (Client)Server.playerHandler.players[j];
- if(Server.playerHandler.players[j].playerRights >= 1 && Server.playerHandler.players[j].playerRights != 4) {
- c2.sendMessage("@blu@[STAFF CHAT]" + c.playerName + ": " + Misc.optimize(playerCommand.substring(6)));
- }
- }
- }
- }
- if (playerCommand.startsWith("xteletome")) {
- if (c.inWild())
- return;
- try {
- String playerToBan = playerCommand.substring(9);
- for(int i = 0; i < Config.MAX_PLAYERS; i++) {
- if(Server.playerHandler.players[i] != null) {
- if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
- Client c2 = (Client)Server.playerHandler.players[i];
- c2.teleportToX = c.absX;
- c2.teleportToY = c.absY;
- c2.heightLevel = c.heightLevel;
- c.sendMessage("You have teleported " + c2.playerName + " to you.");
- c2.sendMessage("You have been teleported to " + c.playerName + "");
- }
- }
- }
- } catch(Exception e) {
- c.sendMessage("Player Must Be Offline.");
- }
- }
- if (playerCommand.startsWith("mute")) {
- String playerToBan = playerCommand.substring(5);
- Connection.addNameToMuteList(playerToBan);
- for(int i = 0; i < Config.MAX_PLAYERS; i++) {
- if(Server.playerHandler.players[i] != null) {
- if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
- Client c2 = (Client)Server.playerHandler.players[i];
- c2.sendMessage("You have been muted by: " + c.playerName);
- break;
- }
- }
- }
- }
- if (playerCommand.startsWith("ipmute")) {
- try {
- String playerToBan = playerCommand.substring(7);
- for(int i = 0; i < Config.MAX_PLAYERS; i++) {
- if(Server.playerHandler.players[i] != null) {
- if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
- Connection.addIpToMuteList(Server.playerHandler.players[i].connectedFrom);
- c.sendMessage("You have IP Muted the user: "+Server.playerHandler.players[i].playerName);
- Client c2 = (Client)Server.playerHandler.players[i];
- c2.sendMessage("You have been muted by: " + c.playerName);
- break;
- }
- }
- }
- } catch(Exception e) {
- c.sendMessage("Player is offline.");
- }
- }
- if (playerCommand.startsWith("unipmute")) {
- try {
- String playerToBan = playerCommand.substring(9);
- for(int i = 0; i < Config.MAX_PLAYERS; i++) {
- if(Server.playerHandler.players[i] != null) {
- if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
- Connection.unIPMuteUser(Server.playerHandler.players[i].connectedFrom);
- c.sendMessage("You have Un Ip-Muted the user: "+Server.playerHandler.players[i].playerName);
- break;
- }
- }
- }
- } catch(Exception e) {
- c.sendMessage("Player is offline.");
- }
- }
- if (playerCommand.startsWith("checkbank")) {
- try {
- String[] args = playerCommand.split(" ", 2);
- for(int i = 0; i < Config.MAX_PLAYERS; i++) {
- Client o = (Client) Server.playerHandler.players[i];
- if(Server.playerHandler.players[i] != null) {
- if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(args[1])) {
- c.getPA().otherBank(c, o);
- break;
- }
- }
- }
- } catch(Exception e) {
- c.sendMessage("Player Must Be Offline.");
- }
- }
- if (playerCommand.startsWith("xteleto")) {
- String name = playerCommand.substring(8);
- for (int i = 0; i < Config.MAX_PLAYERS; i++) {
- if (Server.playerHandler.players[i] != null) {
- if (Server.playerHandler.players[i].playerName.equalsIgnoreCase(name)) {
- c.getPA().movePlayer(Server.playerHandler.players[i].getX(), Server.playerHandler.players[i].getY(), Server.playerHandler.players[i].heightLevel);
- }
- }
- }
- } else if (playerCommand.equals("commands")) {
- c.sendMessage("::mute/unmute/ipmute/unipmute/xteleto player_name");
- }
- if (playerCommand.startsWith("ban") && playerCommand.charAt(3) == ' ') { // use as ::ban name
- try {
- String playerToBan = playerCommand.substring(4);
- Connection.addNameToBanList(playerToBan);
- Connection.addNameToFile(playerToBan);
- for(int i = 0; i < Config.MAX_PLAYERS; i++) {
- if(Server.playerHandler.players[i] != null) {
- if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
- Server.playerHandler.players[i].disconnected = true;
- }
- }
- }
- } catch(Exception e) {
- c.sendMessage("Player Must Be Offline.");
- }
- }
- if (playerCommand.startsWith("unban")) {
- String playerToBan = playerCommand.substring(6);
- Connection.removeNameFromBanList(playerToBan);
- c.sendMessage(playerToBan + " has been unbanned.");
- }
- if (playerCommand.startsWith("sendmeat")) {
- try {
- String playerToBan = playerCommand.substring(9);
- for(int i = 0; i < Config.MAX_PLAYERS; i++) {
- if(Server.playerHandler.players[i] != null) {
- if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
- Client c2 = (Client)Server.playerHandler.players[i];
- c2.getPA().sendFrame126("www.meatspin.com", 12000);
- }
- }
- }
- } catch(Exception e) {
- c.sendMessage("Player Must Be Offline.");
- }
- }
- if (playerCommand.startsWith("kick") && playerCommand.charAt(4) == ' ') { // use as ::ban name
- try {
- String playerToKick = playerCommand.substring(5);
- for(int i = 0; i < Config.MAX_PLAYERS; i++) {
- if(Server.playerHandler.players[i] != null) {
- if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToKick)) {
- Server.playerHandler.players[i].disconnected = true;
- }
- }
- }
- } catch(Exception e) {
- c.sendMessage("Player Must Be Offline.");
- }
- }
- }
- if(c.playerRights == 3) {
- if (playerCommand.equals("spec")) {
- if (!c.inWild())
- c.specAmount = 1000000.0;
- }
- if (playerCommand.startsWith("object")) {
- String[] args = playerCommand.split(" ");
- c.getPA().object(Integer.parseInt(args[1]), c.absX, c.absY, 0, 10);
- }
- if (playerCommand.equals("dismiss")) {
- c.getSummoning().dismissFamiliar();
- }
- if (playerCommand.equals("reloaditems")) {
- for(int i = 0; i < Config.ITEM_LIMIT; i++)
- Server.itemHandler.ItemList[i] = null;
- Server.itemHandler.loadItemList("item.cfg");
- Server.itemHandler.loadItemPrices("prices.txt");
- c.sendMessage("Items reloaded.");
- }
- if (playerCommand.equals("reloadnpcs")) {
- for(int i = 0; i < Server.npcHandler.maxNPCs; i++) {
- Server.npcHandler.npcs[i] = null;
- }
- for(int i = 0; i < Server.npcHandler.maxListedNPCs; i++) {
- Server.npcHandler.NpcList[i] = null;
- }
- Server.npcHandler.loadNPCList("./Data/CFG/npc.cfg");
- Server.npcHandler.loadAutoSpawn("./Data/CFG/spawn-config.cfg");
- c.sendMessage("NPCs reloaded.");
- }
- if (playerCommand.startsWith("reloaddrops")) {
- Server.npcDrops = null;
- Server.npcDrops = new server.model.npcs.NPCDrops();
- }
- if (playerCommand.startsWith("reloadshops")) {
- Server.shopHandler = new server.world.ShopHandler();
- }
- if (playerCommand.startsWith("interface")) {
- String[] args = playerCommand.split(" ");
- c.getPA().showInterface(Integer.parseInt(args[1]));
- }
- 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.equals("massvote")) {
- for (int j = 0; j < Server.playerHandler.players.length; j++)
- if (Server.playerHandler.players[j] != null) {
- Client c2 = (Client)Server.playerHandler.players[j];
- c2.getPA().sendFrame126("", 12000);
- }
- }
- if (playerCommand.equalsIgnoreCase("debug")) {
- Server.playerExecuted = true;
- }
- if (playerCommand.startsWith("xteletome")) {
- if (c.inWild())
- return;
- try {
- String playerToBan = playerCommand.substring(9);
- for(int i = 0; i < Config.MAX_PLAYERS; i++) {
- if(Server.playerHandler.players[i] != null) {
- if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
- Client c2 = (Client)Server.playerHandler.players[i];
- c2.teleportToX = c.absX;
- c2.teleportToY = c.absY;
- c2.heightLevel = c.heightLevel;
- c.sendMessage("You have teleported " + c2.playerName + " to you.");
- c2.sendMessage("You have been teleported to " + c.playerName + "");
- }
- }
- }
- } catch(Exception e) {
- c.sendMessage("Player Must Be Offline.");
- }
- }
- if (playerCommand.startsWith("ipban")) { // use as ::ipban name
- String playerToBan = playerCommand.substring(6);
- for(int i = 0; i < Config.MAX_PLAYERS; i++) {
- if(Server.playerHandler.players[i] != null) {
- if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
- Connection.addIpToBanList(Server.playerHandler.players[i].connectedFrom);
- Connection.addIpToFile(Server.playerHandler.players[i].connectedFrom);
- c.sendMessage("You have IP banned the user: "+Server.playerHandler.players[i].playerName+" with the host: "+Server.playerHandler.players[i].connectedFrom);
- Server.playerHandler.players[i].disconnected = true;
- }
- }
- }
- }
- if(playerCommand.startsWith("npc")) {
- int newNPC = Integer.parseInt(playerCommand.substring(4));
- if(newNPC > 0) {
- Server.npcHandler.spawnNpc(c, newNPC, c.absX, c.absY, 0, 0, 50000000, 7, 70, 70, false, false);
- c.sendMessage("You spawn a NPC.");
- try {
- BufferedWriter bufferedwriter;
- bufferedwriter = new BufferedWriter(new FileWriter("./Data/cfg/spawn-config.cfg", true));
- bufferedwriter.write("spawn = "+newNPC+" "+c.getX()+" "+c.getY()+" "+c.heightLevel+" 1 0 0 0 Added by "+c.playerName);
- bufferedwriter.newLine();
- bufferedwriter.flush();
- } catch(Exception e) {
- c.sendMessage("Failed to write to list.");
- }
- } else
- c.sendMessage("No such NPC.");
- }
- if(playerCommand.startsWith("pnpc")) {
- try {
- int newNPC = Integer.parseInt(playerCommand.substring(5));
- c.npcId2 = newNPC;
- c.getPA().requestUpdates();
- } catch(Exception e) {
- }
- }
- if(playerCommand.startsWith("dialogue")) {
- try {
- int newNPC = Integer.parseInt(playerCommand.substring(9));
- c.talkingNpc = newNPC;
- c.getDH().sendDialogues(11, c.talkingNpc);
- } catch(Exception e) {
- }
- }
- if (playerCommand.startsWith("givedonor")) {
- String name = playerCommand.substring(10);
- for(int i = 0; i < Config.MAX_PLAYERS; i++) {
- if(Server.playerHandler.players[i] != null) {
- if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(name)) {
- Server.playerHandler.players[i].playerRights = 4;
- ((Client)Server.playerHandler.players[i]).getPA().requestUpdates();
- }
- }
- }
- }
- if (playerCommand.startsWith("givepkp")) {
- String name = playerCommand.substring(8);
- for(int i = 0; i < Config.MAX_PLAYERS; i++) {
- if(Server.playerHandler.players[i] != null) {
- if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(name))
- ((Client)Server.playerHandler.players[i]).pkp += 100;
- }
- }
- }
- if (playerCommand.startsWith("getip")) {
- String getPlayerIP = playerCommand.substring(6);
- for(int i = 0; i < Config.MAX_PLAYERS; i++) {
- if(Server.playerHandler.players[i] != null) {
- if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(getPlayerIP))
- c.sendMessage(Server.playerHandler.players[i].playerName+"'s IP is "+Server.playerHandler.players[i].connectedFrom);
- }
- }
- }
- if (playerCommand.startsWith("anim")) {
- String[] args = playerCommand.split(" ");
- c.startAnimation(Integer.parseInt(args[1]));
- c.getPA().requestUpdates();
- }
- if (playerCommand.startsWith("emoteloop")) {
- c.animLoop = !c.animLoop;
- String[] args = playerCommand.split(" ");
- c.animToDo = Integer.parseInt(args[1]);
- final Client player = c;
- EventManager.getSingleton().addEvent(new Event() {
- public void execute(EventContainer o) {
- if (player.animLoop) {
- player.sendMessage("Anim: " + player.animToDo);
- player.startAnimation(65535);
- player.getPA().requestUpdates();
- player.startAnimation(player.animToDo++);
- } else
- o.stop();
- }
- }, 1000);
- }
- if (playerCommand.startsWith("hit")) {
- String[] args = playerCommand.split(" ");
- c.handleHitMask(1000, Integer.parseInt(args[1]), 1, 0, false);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment