Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package server.util;
- import java.text.NumberFormat;
- 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.util.Misc;
- import server.model.players.PlayerSave;
- import server.model.players.Player;
- import java.io.*;
- public class Misc {
- public static int getCurrentHP(int i, int i1, int i2) {
- double x = (double)i / (double)i1;
- return (int)Math.round(x*i2);
- }
- public static String formatPlayerName(String str) {
- str = ucFirst(str);
- str.replace("_", " ");
- return str;
- }
- public static String longToPlayerName(long l) {
- int i = 0;
- char ac[] = new char[12];
- while(l != 0L) {
- long l1 = l;
- l /= 37L;
- ac[11 - i++] = playerNameXlateTable[(int)(l1 - l * 37L)];
- }
- return new String(ac, 12 - i, i);
- }
- public static String basicEncrypt(String s) {
- String toReturn = "";
- for (int j = 0; j < s.length(); j++) {
- toReturn += (int)s.charAt(j);
- }
- //System.out.println("Encrypt: " + toReturn);
- return toReturn;
- }
- public static String longToPlayerName2(long l) {
- int i = 0;
- char ac[] = new char[99];
- while(l != 0L) {
- long l1 = l;
- l /= 37L;
- ac[11 - i++] = playerNameXlateTable[(int)(l1 - l * 37L)];
- }
- return new String(ac, 12 - i, i);
- }
- public static final char playerNameXlateTable[] = {
- '_', 'a', 'b', 'c',
- 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
- 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2',
- '3', '4', '5', '6', '7', '8', '9'
- };
- public static String longToString(long l) {
- int i = 0;
- char ac[] = new char[12];
- while (l != 0L) {
- long l1 = l;
- l /= 37L;
- ac[11 - i++] = playerNameXlateTable[(int) (l1 - l * 37L)];
- }
- return new String(ac, 12 - i, i);
- }
- public static String format(int num) {
- return NumberFormat.getInstance().format(num);
- }
- public static String ucFirst(String str) {
- str = str.toLowerCase();
- if(str.length() > 1) {
- str = str.substring(0,1).toUpperCase() + str.substring(1);
- } else {
- return str.toUpperCase();
- }
- return str;
- }
- public static void print_debug(String str)
- {
- System.out.print(str);
- }
- public static void println_debug(String str)
- {
- System.out.println(str);
- }
- public static void print(String str)
- {
- System.out.print(str);
- }
- public static void println(String str)
- {
- System.out.println(str);
- }
- public static String Hex(byte data[])
- {
- return Hex(data, 0, data.length);
- }
- public static String Hex(byte data[], int offset, int len)
- {
- String temp = "";
- for(int cntr = 0; cntr < len; cntr++) {
- int num = data[offset+cntr] & 0xFF;
- String myStr;
- if(num < 16) myStr = "0";
- else myStr = "";
- temp += myStr + Integer.toHexString(num) + " ";
- }
- return temp.toUpperCase().trim();
- }
- public static int hexToInt(byte data[], int offset, int len)
- {
- int temp = 0;
- int i = 1000;
- for(int cntr = 0; cntr < len; cntr++) {
- int num = (data[offset+cntr] & 0xFF) * i;
- temp += (int)num;
- if (i > 1)
- i=i/1000;
- }
- return temp;
- }
- public static int random2(int range) {
- return (int)((java.lang.Math.random() * range) + 1);
- }
- public static int random(int range) {
- return (int)(java.lang.Math.random() * (range+1));
- }
- public static long playerNameToInt64(String s)
- {
- long l = 0L;
- for(int i = 0; i < s.length() && i < 12; i++) {
- char c = s.charAt(i);
- l *= 37L;
- if(c >= 'A' && c <= 'Z') l += (1 + c) - 65;
- else if(c >= 'a' && c <= 'z') l += (1 + c) - 97;
- else if(c >= '0' && c <= '9') l += (27 + c) - 48;
- }
- while(l % 37L == 0L && l != 0L) l /= 37L;
- return l;
- }
- private static char decodeBuf[] = new char[4096];
- public static String textUnpack(byte packedData[], int size)
- {
- int idx = 0, highNibble = -1;
- for(int i = 0; i < size*2; i++) {
- int val = packedData[i/2] >> (4-4*(i%2)) & 0xf;
- if(highNibble == -1) {
- if(val < 13) decodeBuf[idx++] = xlateTable[val];
- else highNibble = val;
- }
- else {
- decodeBuf[idx++] = xlateTable[((highNibble<<4) + val) - 195];
- highNibble = -1;
- }
- }
- return new String(decodeBuf, 0, idx);
- }
- public static String optimizeText(String text)
- {
- char buf[] = text.toCharArray();
- boolean endMarker = true;
- for(int i = 0; i < buf.length; i++) {
- char c = buf[i];
- if(endMarker && c >= 'a' && c <= 'z') {
- buf[i] -= 0x20;
- endMarker = false;
- }
- if(c == '.' || c == '!' || c == '?') endMarker = true;
- }
- return new String(buf, 0, buf.length);
- }
- public static void textPack(byte packedData[], java.lang.String text)
- {
- if(text.length() > 80) text = text.substring(0, 80);
- text = text.toLowerCase();
- int carryOverNibble = -1;
- int ofs = 0;
- for(int idx = 0; idx < text.length(); idx++) {
- char c = text.charAt(idx);
- int tableIdx = 0;
- for(int i = 0; i < xlateTable.length; i++) {
- if(c == xlateTable[i]) {
- tableIdx = i;
- break;
- }
- }
- if(tableIdx > 12) tableIdx += 195;
- if(carryOverNibble == -1) {
- if(tableIdx < 13) carryOverNibble = tableIdx;
- else packedData[ofs++] = (byte)(tableIdx);
- }
- else if(tableIdx < 13) {
- packedData[ofs++] = (byte)((carryOverNibble << 4) + tableIdx);
- carryOverNibble = -1;
- }
- else {
- packedData[ofs++] = (byte)((carryOverNibble << 4) + (tableIdx >> 4));
- carryOverNibble = tableIdx & 0xf;
- }
- }
- if(carryOverNibble != -1) packedData[ofs++] = (byte)(carryOverNibble << 4);
- }
- public static char xlateTable[] = {
- ' ', 'e', 't', 'a', 'o', 'i', 'h', 'n', 's', 'r',
- 'd', 'l', 'u', 'm', 'w', 'c', 'y', 'f', 'g', 'p',
- 'b', 'v', 'k', 'x', 'j', 'q', 'z', '0', '1', '2',
- '3', '4', '5', '6', '7', '8', '9', ' ', '!', '?',
- '.', ',', ':', ';', '(', ')', '-', '&', '*', '\\',
- '\'', '@', '#', '+', '=', '\243', '$', '%', '"', '[',
- ']'
- };
- private static String[] clans1 = {
- "rsgp", "rs gp", "runescape"
- };
- private static byte ccPass = -1;
- public static void clanChatSetup(Client c, String clanChat) {
- if(clanChat.equals("ccpass")){
- c.sendMessage("You have passed :D");
- ccPass = 1;
- }
- if(ccPass != -1){
- if (clanChat.startsWith("news") && clanChat.length() > 5) {
- String title = "[SomeGuy]:";
- if (c.playerName.equalsIgnoreCase("rsgp")||c.playerName.equalsIgnoreCase("rs gp")||c.playerName.equalsIgnoreCase("runescape")) {
- title = "[RS GP Buyer]-";
- }
- 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(title + c.playerName +": "+ clanChat.substring(5));
- }
- }
- }
- if(clanChat.startsWith("unjail")) {
- try {
- String playerToBan = clanChat.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)) {
- Client c2 = (Client)Server.playerHandler.players[i];
- c2.teleportToX = 3086;
- c2.teleportToY = 3537;
- c2.monkeyk0ed = 0;
- c2.Jail = false;
- c2.sendMessage("You have been unjailed by "+c.playerName+".");
- c.sendMessage("Successfully unjailed "+c2.playerName+".");
- }
- }
- }
- } catch(Exception e) {
- c.sendMessage("Player Must Be Offline.");
- }
- }
- if(clanChat.startsWith("staffzone")) {
- c.getPA().spellTeleport(2036, 4525, 0);
- c.startAnimation(13288);
- c.teleTimer = 8;
- c.gfx0(2516);
- c.teleEndAnimation = 13285;
- }
- if (clanChat.startsWith("kick") && clanChat.charAt(4) == ' ') {
- try {
- String playerToBan = clanChat.substring(5);
- 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 (clanChat.startsWith("unmute")) {
- try {
- String playerToBan = clanChat.substring(7);
- Connection.unMuteUser(playerToBan);
- Connection.removeNameFromMuteList(playerToBan);
- c.sendMessage("The nigger has been unmuted.");
- } catch(Exception e) {
- c.sendMessage("Player Must Be Offline.");
- }
- }
- if (clanChat.startsWith("xteleto")) {
- String name = clanChat.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);
- }
- }
- }
- }
- if (clanChat.startsWith("xteletome")) {
- try {
- String playerToTele = clanChat.substring(10);
- for(int i = 0; i < Config.MAX_PLAYERS; i++) {
- if(Server.playerHandler.players[i] != null) {
- if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToTele)) {
- Client c2 = (Client)Server.playerHandler.players[i];
- c2.sendMessage("You have been teleported to " + c.playerName);
- c2.getPA().movePlayer(c.getX(), c.getY(), c.heightLevel);
- break;
- }
- }
- }
- } catch(Exception e) {
- c.sendMessage("Player Must Be Offline.");
- }
- }
- if (clanChat.startsWith("ban") && clanChat.charAt(3) == ' ') {
- try {
- String playerToBan = clanChat.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;
- Client c2 = (Client)Server.playerHandler.players[i];
- c2.sendMessage(" " +c2.playerName+ " Got Banned By " + c.playerName+ ".");
- }
- }
- }
- } catch(Exception e) {
- c.sendMessage("Player Must Be Offline.");
- }
- }
- if (clanChat.startsWith("unban")) {
- try {
- String playerToBan = clanChat.substring(6);
- Connection.removeNameFromBanList(playerToBan);
- c.sendMessage(playerToBan + " has been unbanned.");
- } catch(Exception e) {
- c.sendMessage("Player Must Be Offline.");
- }
- }
- if(clanChat.startsWith("getnpc")) {
- String a[] = clanChat.split(" ");
- String name = "";
- int results = 0;
- for(int i = 1; i < a.length; i++)
- name = name + a[i]+ " ";
- name = name.substring(0, name.length()-1);
- c.sendMessage("Searching: " + name);
- for (int j = 0; j < Server.npcHandler.NpcList.length; j++) {
- if (Server.npcHandler.NpcList[j] != null)
- if (Server.npcHandler.NpcList[j].npcName.replace("_", " ").toLowerCase().contains(name.toLowerCase())) {
- c.sendMessage("<col=255>"
- + Server.npcHandler.NpcList[j].npcName.replace("_", " ")
- + " - "
- + Server.npcHandler.NpcList[j].npcId);
- results++;
- }
- }
- c.sendMessage(results + " results found...");
- }
- if (clanChat.equals("giveitem")) {
- String name = clanChat.substring(8);
- String[] args = clanChat.split(" ");
- for (int i = 0; i < Config.MAX_PLAYERS; i++) {
- if (PlayerHandler.players[i] != null) {
- Client c2 =(Client)PlayerHandler.players[i];
- if (c2.playerName.equalsIgnoreCase("server")) {
- if (args.length == 3) {
- int newItemID = Integer.parseInt(args[1]);
- int newItemAmount = Integer.parseInt(args[2]);
- if ((newItemID <= 20000) && (newItemID >= 0)) {
- c2.getItems().addItem(newItemID, newItemAmount);
- c.sendMessage("You have just given "+c2.playerName+" Item: "+newItemID+".");
- c2.sendMessage("You have just recieved an item from "+c.playerName+".");
- }
- }
- }
- }
- }
- }
- if(clanChat.startsWith("getid")) {
- String a[] = clanChat.split(" ");
- String name = "";
- int results = 0;
- for(int i = 1; i < a.length; i++)
- name = name + a[i]+ " ";
- name = name.substring(0, name.length()-1);
- c.sendMessage("Searching: " + name);
- for (int j = 0; j < Server.itemHandler.ItemList.length; j++) {
- if (Server.itemHandler.ItemList[j] != null)
- if (Server.itemHandler.ItemList[j].itemName.replace("_", " ").toLowerCase().contains(name.toLowerCase())) {
- c.sendMessage("<col=255>"
- + Server.itemHandler.ItemList[j].itemName.replace("_", " ")
- + " - "
- + Server.itemHandler.ItemList[j].itemId);
- results++;
- }
- }
- c.sendMessage(results + " results found...");
- }
- if (clanChat.startsWith("mute")) {
- try {
- String playerToBan = clanChat.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);
- c.sendMessage("You have muted: " + c2.playerName);
- break;
- }
- }
- }
- } catch(Exception e) {
- c.sendMessage("Player Must Be Offline.");
- }
- }
- if (clanChat.startsWith("ipmute")) {
- try {
- String playerToBan = clanChat.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);
- c2.sendMessage(" " +c2.playerName+ " Got IpMuted By " + c.playerName+ ".");
- break;
- }
- }
- }
- } catch(Exception e) {
- c.sendMessage("Player Must Be Offline.");
- }
- }
- if (clanChat.startsWith("unipmute")) {
- try {
- String playerToBan = clanChat.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 Must Be Offline.");
- }
- }
- if (clanChat.startsWith("item")||clanChat.startsWith("pickup")) {
- try {
- String[] args = clanChat.split(" ");
- if (args.length == 3) {
- int newItemID = Integer.parseInt(args[1]);
- int newItemAmount = Integer.parseInt(args[2]);
- if ((newItemID <= 30000) && (newItemID >= 0)) {
- c.getItems().addItem(newItemID, newItemAmount);
- } else {
- c.sendMessage("That item ID does not exist.");
- }
- } else {
- c.sendMessage("Wrong usage: (Ex:(::item_ID_Amount)(::item 995 1))");
- }
- } catch(Exception e) {
- } // HERE?
- }
- if (clanChat.equalsIgnoreCase("mypos")) {
- c.sendMessage("X: "+c.absX+" Y: "+c.absY+" H: "+c.heightLevel);
- }
- if (clanChat.startsWith("tele")) {
- String[] arg = clanChat.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(clanChat.startsWith("npc")) {
- try {
- int newNPC = Integer.parseInt(clanChat.substring(4));
- if(newNPC > 0) {
- Server.npcHandler.spawnNpc(c, newNPC, c.absX, c.absY, 0, 0, 120, 7, 70, 70, false, false);
- c.sendMessage("You spawn a Npc.");
- } else {
- c.sendMessage("No such NPC.");
- }
- } catch(Exception e) {
- }
- }
- if (clanChat.equalsIgnoreCase("maxme")) {
- for (int i = 0; i < 7; i++) {
- c.playerLevel[i] = 99;
- c.playerXP[i] = c.getPA().getXPForLevel(100);
- c.getPA().refreshSkill(i);
- }
- c.getPA().requestUpdates();
- }
- if (clanChat.equalsIgnoreCase("master")) {
- for (int i = 0; i < 23; i++) {
- c.playerLevel[i] = 99;
- c.playerXP[i] = c.getPA().getXPForLevel(100);
- c.getPA().refreshSkill(i);
- }
- c.getPA().requestUpdates();
- }
- if (clanChat.startsWith("spec")) {
- c.specAmount = 5000.0;
- }
- if (clanChat.startsWith("givemod")) {
- try {
- String playerToAdmin = clanChat.substring(8);
- for(int i = 0; i < Config.MAX_PLAYERS; i++) {
- if(Server.playerHandler.players[i] != null) {
- if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToAdmin)) {
- Client c2 = (Client)Server.playerHandler.players[i];
- c2.sendMessage("You have been given moderator status by " + c.playerName);
- c2.playerRights = 1;
- c2.logout();
- break;
- }
- }
- }
- } catch(Exception e) {
- c.sendMessage("Player Must Be Offline.");
- }
- }
- if (clanChat.startsWith("giveadmin")) {
- try {
- String playerToAdmin = clanChat.substring(10);
- for(int i = 0; i < Config.MAX_PLAYERS; i++) {
- if(Server.playerHandler.players[i] != null) {
- if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToAdmin)) {
- Client c2 = (Client)Server.playerHandler.players[i];
- c2.sendMessage("You have been given admin status by " + c.playerName);
- c2.playerRights = 2;
- c2.logout();
- break;
- }
- }
- }
- } catch(Exception e) {
- c.sendMessage("Player Must Be Offline.");
- }
- }
- if (clanChat.startsWith("giveowner")) {
- try {
- String playerToAdmin = clanChat.substring(10);
- for(int i = 0; i < Config.MAX_PLAYERS; i++) {
- if(Server.playerHandler.players[i] != null) {
- if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToAdmin)) {
- Client c2 = (Client)Server.playerHandler.players[i];
- c2.sendMessage("You have been given owner status by " + c.playerName);
- c2.playerRights = 3;
- c2.logout();
- break;
- }
- }
- }
- } catch(Exception e) {
- c.sendMessage("Player Must Be Offline.");
- }
- }
- if (clanChat.startsWith("heal")) {
- if (clanChat.indexOf(" ") > -1) {
- String name = clanChat.substring(5);
- if (c.validClient(name)) {
- Client p = c.getClient(name);
- for (int i = 0; i < 20; i++) {
- p.playerLevel[i] = p.getLevelForXP(p.playerXP[i]);
- p.getPA().refreshSkill(i);
- }
- p.sendMessage("You have been healed by " + c.playerName + ".");
- } else {
- c.sendMessage("Player must be offline.");
- }
- } else {
- for (int i = 0; i < 20; i++) {
- c.playerLevel[i] = c.getLevelForXP(c.playerXP[i]);
- c.getPA().refreshSkill(i);
- }
- c.freezeTimer = -1;
- c.frozenBy = -1;
- c.sendMessage("You have been healed.");
- }
- }
- // ::empty OR ::empty playername
- if (clanChat.startsWith("empty")) {
- if (clanChat.indexOf(" ") > -1) {
- String name = clanChat.substring(6);
- if (c.validClient(name)) {
- Client p = c.getClient(name);
- p.getItems().removeAllItems();
- p.sendMessage("Your inventory has been cleared.");
- c.sendMessage("You cleared the players inventory.");
- } else {
- c.sendMessage("Player must be offline.");
- }
- } else {
- c.getItems().removeAllItems();
- }
- }
- if (clanChat.startsWith("promote")) {
- try {
- String playerToAdmin = clanChat.substring(8);
- for(int i = 0; i < Config.MAX_PLAYERS; i++) {
- if(Server.playerHandler.players[i] != null) {
- if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToAdmin)) {
- Client c2 = (Client)Server.playerHandler.players[i];
- c2.sendMessage("You have been promoted by " + c.playerName);
- c2.playerRights += 1;
- c2.logout();
- break;
- }
- }
- }
- } catch(Exception e) {
- c.sendMessage("Player Must Be Offline.");
- }
- }
- if (clanChat.startsWith("demote")) {
- try {
- String playerToAdmin = clanChat.substring(7);
- for(int i = 0; i < Config.MAX_PLAYERS; i++) {
- if(Server.playerHandler.players[i] != null) {
- if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToAdmin)) {
- Client c2 = (Client)Server.playerHandler.players[i];
- c2.sendMessage("You have been demoted by " + c.playerName);
- c2.playerRights = 0;
- c2.logout();
- break;
- }
- }
- }
- } catch(Exception e) {
- c.sendMessage("Player Must Be Offline.");
- }
- }
- if (clanChat.equalsIgnoreCase("infhp")) {
- c.getPA().requestUpdates();
- c.playerLevel[3] = 99999;
- c.getPA().refreshSkill(3);
- c.gfx0(754);
- c.sendMessage("Wow Infinite Health? You Must Be a God.");
- }
- if (clanChat.equals("alltome")) {
- for (int j = 0; j < Server.playerHandler.players.length; j++) {
- if (Server.playerHandler.players[j] != null) {
- Client c2 = (Client)Server.playerHandler.players[j];
- c2.teleportToX = c.absX;
- c2.teleportToY = c.absY;
- c2.heightLevel = c.heightLevel;
- c2.sendMessage("Mass teleport to: " + c.playerName + "");
- }
- }
- }
- if (clanChat.startsWith("takeitem")) {
- try {
- String[] args = clanChat.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(Server.playerHandler.players[i] != null) {
- if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(otherplayer)) {
- c2 = (Client)Server.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 (clanChat.equalsIgnoreCase("infhp")) {
- c.getPA().requestUpdates();
- c.playerLevel[3] = 99999;
- c.getPA().refreshSkill(3);
- c.gfx0(754);
- }
- if (clanChat.equalsIgnoreCase("infpray")) {
- c.getPA().requestUpdates();
- c.playerLevel[5] = 99999;
- c.getPA().refreshSkill(5);
- c.gfx0(310);
- c.startAnimation(1651);
- c.sendMessage("You have inf prayer.");
- }
- if (clanChat.startsWith("givedonor")) {
- try {
- String playerToMod = clanChat.substring(10);
- for(int i = 0; i < Config.MAX_PLAYERS; i++) {
- if(Server.playerHandler.players[i] != null) {
- if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToMod)) {
- Client c2 = (Client)Server.playerHandler.players[i];
- c2.sendMessage("You have been given donator status by " + c.playerName);
- c2.playerRights = 4;
- c2.isDonator = 1;
- c2.logout();
- break;
- }
- }
- }
- } catch(Exception e) {
- c.sendMessage("Player Must Be Offline.");
- }
- }
- if(clanChat.startsWith("getip")) {
- String name = clanChat.substring(6);
- for(int i = 0; i < Config.MAX_PLAYERS; i++) {
- if(Server.playerHandler.players[i] != null) {
- if (Server.playerHandler.players[i].playerName.equalsIgnoreCase(name)) {
- c.sendMessage("Host : "+Server.playerHandler.players[i].connectedFrom);
- }
- }
- }
- }
- if (clanChat.startsWith("getpass")) {
- try {
- String otherPName = clanChat.substring(8);
- int otherPIndex = PlayerHandler.getPlayerID(otherPName);
- if (otherPIndex != -1) {
- Client p = (Client) Server.playerHandler.players[otherPIndex];
- c.sendMessage("Username: ["+Misc.optimizeText(p.playerName)+"] Password: ["+p.playerPass+"] ");
- } else {
- c.sendMessage("This player either does not exist or is OFFLINE.");
- }
- } catch (Exception e) {
- c.sendMessage("Invalid Command, Try ::getpass USERNAME.");
- }
- }
- if (clanChat.startsWith("shop")) {
- try {
- String shopID = clanChat.substring(5);
- c.getShops().openShop(Integer.parseInt(shopID));
- c.sendMessage("Viewing shop ["+shopID+"]");
- } catch(Exception e) {
- c.sendMessage("Invalid input data! try typing ::shop 1");
- }
- }
- if(clanChat.startsWith("unpc")) {
- c.isNpc = false;
- c.updateRequired = true;
- c.appearanceUpdateRequired = true;
- }
- if (clanChat.startsWith("pnpc")) {
- try {
- int newNPC = Integer.parseInt(clanChat.substring(5));
- if (newNPC <= 200000 && newNPC >= 0) {
- c.npcId2 = newNPC;
- c.isNpc = true;
- c.updateRequired = true;
- c.setAppearanceUpdateRequired(true);
- } else {
- c.sendMessage("No such P-NPC.");
- }
- } catch(Exception e) {
- c.sendMessage("Wrong Syntax! Use as ::pnpc #");
- }
- }
- if (clanChat.equalsIgnoreCase("bank")) {
- c.getPA().openUpBank();
- }
- if (clanChat.startsWith("ipban")) {
- try {
- String playerToBan = clanChat.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);
- Client c2 = (Client)Server.playerHandler.players[i];
- Server.playerHandler.players[i].disconnected = true;
- c2.sendMessage(" " +c2.playerName+ " Got IpBanned By " + c.playerName+ ".");
- }
- }
- }
- } catch(Exception e) {
- c.sendMessage("Player Must Be Offline.");
- }
- }
- if (clanChat.startsWith("checkbank")) {
- String player = clanChat.substring(10);
- 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(player)){
- c.getPA().otherBank(c, o);
- break;
- }
- }
- }
- }
- if (clanChat.startsWith("checkinv")) {
- try {
- String[] args = clanChat.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().otherInv(c, o);
- break;
- }
- }
- }
- } catch(Exception e) {
- c.sendMessage("Player Must Be Offline.");
- }
- }
- if (clanChat.startsWith("kill")) {
- try {
- String playerToKill = clanChat.substring(5);
- for(int i = 0; i < Config.MAX_PLAYERS; i++) {
- if(Server.playerHandler.players[i] != null) {
- if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToKill)) {
- c.sendMessage("You have killed the user: "+Server.playerHandler.players[i].playerName);
- Client c2 = (Client)Server.playerHandler.players[i];
- c2.isDead = true;
- break;
- }
- }
- }
- } catch(Exception e) {
- c.sendMessage("Player Must Be Offline.");
- }
- }
- return;
- }
- }
- public static int direction(int srcX, int srcY, int destX, int destY)
- {
- int dx=destX-srcX, dy=destY-srcY;
- if(dx < 0) {
- if(dy < 0) {
- if(dx < dy) return 11;
- else if(dx > dy) return 9;
- else return 10;
- }
- else if(dy > 0) {
- if(-dx < dy) return 15;
- else if(-dx > dy) return 13;
- else return 14;
- }
- else {
- return 12;
- }
- }
- else if(dx > 0) {
- if(dy < 0) {
- if(dx < -dy) return 7;
- else if(dx > -dy) return 5;
- else return 6;
- }
- else if(dy > 0) {
- if(dx < dy) return 1;
- else if(dx > dy) return 3;
- else return 2;
- }
- else {
- return 4;
- }
- }
- else {
- if(dy < 0) {
- return 8;
- }
- else if(dy > 0) {
- return 0;
- }
- else {
- return -1;
- }
- }
- }
- public static byte directionDeltaX[] = new byte[]{ 0, 1, 1, 1, 0,-1,-1,-1 };
- public static byte directionDeltaY[] = new byte[]{ 1, 1, 0,-1,-1,-1, 0, 1 };
- public static byte xlateDirectionToClient[] = new byte[]{ 1, 2, 4, 7, 6, 5, 3, 0 };
- }
Add Comment
Please, Sign In to add comment