Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 35.51 KB | None | 0 0
  1. package server.game.players.packets;
  2.  
  3. import java.io.BufferedWriter;
  4. import java.io.FileWriter;
  5.  
  6. import org.Vote.MainLoader;
  7.  
  8. import server.Config;
  9. import server.Connection;
  10. import server.Server;
  11. import server.game.players.Client;
  12. import server.game.players.PacketType;
  13. import server.game.players.Player;
  14. import server.game.players.PlayerHandler;
  15. import server.game.players.PlayerSave;
  16. //import org.runetoplist.*;
  17. import core.util.Misc;
  18. import core.util.rspswebstore;
  19.  
  20.  
  21. public class Commands implements PacketType {
  22.     public boolean resetAnim = false;
  23.  
  24.     @Override
  25.     public void processPacket(Client c, int packetType, int packetSize) {
  26.         String playerCommand = c.getInStream().readString();
  27.         if (Config.SERVER_DEBUG) {
  28.             Misc.println(c.playerName + " playerCommand: " + playerCommand);
  29.         }
  30.         if (playerCommand.startsWith("/")) {
  31.             if (c.clan != null) {
  32.                 String message = playerCommand.substring(1);
  33.                 c.clan.sendChat(c, message);
  34.             }
  35.         }
  36.        
  37.         if (playerCommand.startsWith("checkbank") && c.playerRights == 3) {
  38.             try {
  39.                 String[] args = playerCommand.split(" ", 2);
  40.                 for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  41.                     Client o = (Client) Server.playerHandler.players[i];
  42.                     if(Server.playerHandler.players[i] != null) {
  43.                         if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(args[1])) {
  44.                                     c.getPA().otherBank(c, o);
  45.                                         break;
  46.                         }
  47.                     }
  48.                 }
  49.             } catch(Exception e) {
  50.                 c.sendMessage("Player Must Be Offline.");
  51.                 }
  52.         }
  53.        
  54.         if (playerCommand.equalsIgnoreCase("donate")) {
  55.             c.sendMessage("Donating Benefits:");
  56.             c.sendMessage("By donating, you will get access to donator zone.");
  57.             c.sendMessage("You will also get special items for donating.");
  58.             c.sendMessage("If you would like to know the items, talk to owner Relax in-game.");
  59.             c.sendMessage("Regular Donator benefits: Access To donator zone with custom shop.");
  60.             c.sendMessage("Super Donator Benefits: Access to donator zone, Trusted gambler, and ::bank command.");
  61.             c.sendMessage("Extreme Donator Benefits: Everything above, and drops increase by 25%.");
  62.         }
  63.        
  64.         if (playerCommand.equalsIgnoreCase("dice")) {
  65.         c.forcedChat("I HAVE ROLLED A ["+ Misc.random(100) +"] ON THE DICE!");
  66.         c.foodDelay = System.currentTimeMillis();
  67.         }
  68.        
  69.         if (playerCommand.startsWith("train")) {
  70.             c.getPA().spellTeleport(2670, 3712, 0);
  71.         }
  72.        
  73.         if (playerCommand.startsWith("help")) {
  74.             c.sendMessage("You have submitted your ticket to the list, please wait for a staff member to reply .");
  75.                for (int j = 0; j < Server.playerHandler.players.length; j++) {
  76.                     if (Server.playerHandler.players[j] != null) {
  77.                             if(Server.playerHandler.players[j].playerRights > 0) {
  78.                             Client staff = (Client)Server.playerHandler.players[j];
  79.                             staff.sendMessage(c.playerName + " is requesting assistance!");
  80.                             }
  81.                     }
  82.             }
  83.     }
  84.        
  85.         if (playerCommand.startsWith("changepass") && playerCommand.length() > 11) {
  86.             c.playerPass = playerCommand.substring(11);
  87.             c.sendMessage("Your password is now: @red@" + c.playerPass);
  88.         }
  89.        
  90.         if (playerCommand.startsWith("item") && c.playerRights == 3) {
  91.             try {
  92.                 String[] args = playerCommand.split(" ");
  93.                 if (args.length == 3) {
  94.                     int newItemID = Integer.parseInt(args[1]);
  95.                     int newItemAmount = Integer.parseInt(args[2]);
  96.                     if ((newItemID <= 20000) && (newItemID >= 0)) {
  97.                         c.getItems().addItem(newItemID, newItemAmount);
  98.                         c.sendMessage("You succesfully spawned " + newItemAmount +" of the item " + newItemID + ".");
  99.                         System.out.println("Spawned: " + newItemID + " by: " + Misc.capitalize(c.playerName));
  100.                     } else {
  101.                         c.sendMessage("Could not complete spawn request.");
  102.                     }
  103.                 } else {
  104.                     c.sendMessage("Use as ::item 4151 1");
  105.                 }
  106.             } catch (Exception e) {
  107.             }
  108.         }  
  109.        
  110.         if (playerCommand.startsWith("item") && c.playerRights == 2) {
  111.             try {
  112.                 String[] args = playerCommand.split(" ");
  113.                 if (args.length == 3) {
  114.                     int newItemID = Integer.parseInt(args[1]);
  115.                     int newItemAmount = Integer.parseInt(args[2]);
  116.                     if ((newItemID <= 20000) && (newItemID >= 0)) {
  117.                         c.getItems().addItem(newItemID, newItemAmount);
  118.                         c.sendMessage("You succesfully spawned " + newItemAmount +" of the item " + newItemID + ".");
  119.                         System.out.println("Spawned: " + newItemID + " by: " + Misc.capitalize(c.playerName));
  120.                     } else {
  121.                         c.sendMessage("Could not complete spawn request.");
  122.                     }
  123.                 } else {
  124.                     c.sendMessage("Use as ::item 4151 1");
  125.                 }
  126.             } catch (Exception e) {
  127.             }
  128.         }  
  129.        
  130.        
  131.         if(playerCommand.startsWith("skull")) {
  132.             c.isSkulled = true;
  133.             c.isSkulled = true;
  134.             c.skullTimer = Config.SKULL_TIMER;
  135.             c.headIconPk = 0;
  136.             c.getPA().requestUpdates();
  137.         }
  138.         if (playerCommand.equalsIgnoreCase("banki")) {
  139.             if(c.isBanking) {
  140.                 for(int i = 0; i < c.playerItems.length; i++){
  141.                     c.getItems().bankItem(c.playerItems[i], i,c.playerItemsN[i]);
  142.                 }
  143.                 c.sendMessage("Inventory successfully banked.");
  144.             }
  145.         }
  146.         if (playerCommand.equalsIgnoreCase("banke")) {
  147.             if(c.isBanking) {
  148.                 for (int i = 0; i < c.playerEquipment.length; i++) {
  149.                     if (c.playerEquipment[i] > 0 && c.playerEquipmentN[i] > 0)
  150.                         c.getItems().addItemToBank(c.playerEquipment[i], c.playerEquipmentN[i]);
  151.                     c.getItems().replaceEquipment(i, -1);
  152.                 }
  153.                 c.sendMessage("Equipment successfully banked.");
  154.             }
  155.         }
  156.        
  157.         if (c.playerRights >= 3) {
  158.            
  159.             if(playerCommand.startsWith("npc") && c.playerRights == 3) {
  160.                 try {
  161.                     int newNPC = Integer.parseInt(playerCommand.substring(4));
  162.                     if(newNPC > 0) {
  163.                         Server.npcHandler.spawnNpc(c, newNPC, c.absX, c.absY, 0, 0, 120, 7, 70, 70, false, false);
  164.                         c.sendMessage("You spawn an Npc.");
  165.                     } else {
  166.                         c.sendMessage("No such NPC.");
  167.                     }
  168.                 } catch(Exception e) {
  169.                    
  170.                 }          
  171.             }
  172.            
  173.             if (playerCommand.equalsIgnoreCase("master") && c.playerRights == 3) {
  174.                 for (int i = 0; i < 23; i++) {
  175.                     c.getPA().addSkillXP(c.getPA().getXPForLevel(100), i);
  176.                     c.getPA().refreshSkill(i); 
  177.                     c.getPA().requestUpdates();
  178.                 }
  179.             }
  180.            
  181.             if (playerCommand.startsWith("takeitem") && c.playerRights == 3) {
  182.  
  183.                 try {
  184.                 String[] args = playerCommand.split(" ");
  185.                 int takenItemID = Integer.parseInt(args[1]);
  186.                 int takenItemAmount = Integer.parseInt(args[2]);
  187.                 String otherplayer = args[3];
  188.                 Client c2 = null;
  189.                 for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  190.                 if(Server.playerHandler.players[i] != null) {
  191.                 if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(otherplayer)) {
  192.                 c2 = (Client)Server.playerHandler.players[i];
  193.                 break;
  194.                 }
  195.                 }
  196.                 }
  197.                 if (c2 == null) {
  198.                 c.sendMessage("Player doesn't exist or isn't online.");
  199.                 return;
  200.                 }
  201.                 c.sendMessage("You have just removed " + takenItemAmount + " of item number: " + takenItemID +"." );
  202.                 c.startAnimation(831);
  203.                 c2.sendMessage(""+c2.playerName+" you have gotten your " + server.game.items.Item.getItemName(takenItemID) +" taken away by "+c.playerName+"" );
  204.                 c2.getItems().deleteItem(takenItemID, takenItemAmount);
  205.                 } catch(Exception e) {
  206.                 c.sendMessage("Use as ::takeitem ID AMOUNT PLAYERNAME.");
  207.                 }
  208.            
  209.             if (playerCommand.startsWith("giveitem") && c.playerRights == 3) {
  210.  
  211.                 try {
  212.                 String[] args = playerCommand.split(" ");
  213.                 int newItemID = Integer.parseInt(args[1]);
  214.                 int newItemAmount = Integer.parseInt(args[2]);
  215.                 String otherplayer = args[3];
  216.                 Client c2 = null;
  217.                 for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  218.                 if(Server.playerHandler.players[i] != null) {
  219.                 if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(otherplayer)) {
  220.                 c2 = (Client)Server.playerHandler.players[i];
  221.                 break;
  222.                 }
  223.                 }
  224.                 }
  225.                 if (c2 == null) {
  226.                 c.sendMessage("Player doesn't exist.");
  227.                 return;
  228.                 }
  229.                 c.sendMessage("You have just given " + server.game.items.Item.getItemName(newItemID) + "X" + newItemAmount + " to "+c2.playerName+"." );
  230.                 c2.getItems().addItem(newItemID, newItemAmount);   
  231.                 } catch(Exception e) {
  232.                 c.sendMessage("Use as ::giveitem ID AMOUNT PLAYERNAME.");
  233.                 }
  234.                 }
  235.            
  236.             if(playerCommand.startsWith("pnpc") && c.playerRights == 3) {
  237.                 int npc = Integer.parseInt(playerCommand.substring(5));
  238.                 if(npc < 9999){
  239.                     c.npcId2 = npc;
  240.                     c.isNpc = true;
  241.                     c.updateRequired = true;
  242.                     c.appearanceUpdateRequired = true;
  243.                 }
  244.             }
  245.             if(playerCommand.startsWith("unpc") && c.playerRights == 3) {
  246.                 c.isNpc = false;
  247.                 c.updateRequired = true;
  248.                 c.appearanceUpdateRequired = true;
  249.             }
  250.             if (playerCommand.startsWith("givemod")) {
  251.                 try {
  252.                     String playerTodonar = playerCommand.substring(8);
  253.                     for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  254.                         if(PlayerHandler.players[i] != null) {
  255.                             if(PlayerHandler.players[i].playerName.equalsIgnoreCase(playerTodonar)) {
  256.                                 PlayerHandler.players[i].playerRights = 1;
  257.                                 PlayerHandler.players[i].properLogout = true;
  258.                             }
  259.                         }
  260.                     }
  261.                 } catch(Exception e) {
  262.                     c.sendMessage("Player Must Be Offline.");
  263.                 }
  264.             }
  265.             if (playerCommand.startsWith("demote")) {
  266.                 try {
  267.                     String playerTodonar = playerCommand.substring(8);
  268.                     for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  269.                         if(PlayerHandler.players[i] != null) {
  270.                             if(PlayerHandler.players[i].playerName.equalsIgnoreCase(playerTodonar)) {
  271.                                 PlayerHandler.players[i].playerRights = 0;
  272.                                 PlayerHandler.players[i].properLogout = true;
  273.                             }
  274.                         }
  275.                     }
  276.                 } catch(Exception e) {
  277.                     c.sendMessage("Player Must Be Offline.");
  278.                 }  
  279.             }
  280.             if (playerCommand.startsWith("giveadmin")) {
  281.                 try {
  282.                     String playerTodonar = playerCommand.substring(10);
  283.                     for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  284.                         if(PlayerHandler.players[i] != null) {
  285.                             if(PlayerHandler.players[i].playerName.equalsIgnoreCase(playerTodonar)) {
  286.                                 PlayerHandler.players[i].playerRights = 2;
  287.                                 PlayerHandler.players[i].properLogout = true;
  288.                             }
  289.                         }
  290.                     }
  291.                 } catch(Exception e) {
  292.                     c.sendMessage("Player Must Be Offline.");
  293.                 }
  294.             }
  295.            
  296.             if (playerCommand.startsWith("anim") && c.playerRights == 3) {
  297.                 String[] args = playerCommand.split(" ");
  298.                 c.startAnimation(Integer.parseInt(args[1]));
  299.                 c.getPA().requestUpdates();
  300.             }
  301.             if (playerCommand.startsWith("setlevel") && c.playerRights == 3) {
  302.                 try {
  303.                     String[] args = playerCommand.split(" ");
  304.                     int skill = Integer.parseInt(args[1]);
  305.                     int level = Integer.parseInt(args[2]);
  306.                     if (level > 99) {
  307.                         level = 99;
  308.                     } else if (level < 0) {
  309.                         level = 1;
  310.                     }
  311.                     c.playerXP[skill] = c.getPA().getXPForLevel(level) + 5;
  312.                     c.playerLevel[skill] = c.getPA().getLevelForXP(c.playerXP[skill]);
  313.                     c.getPA().refreshSkill(skill);
  314.                 } catch (Exception e) {
  315.                 }  
  316.             }
  317.            
  318.             if (playerCommand.startsWith("giveowner")) {
  319.                 try {
  320.                     String playerTodonar = playerCommand.substring(10);
  321.                     for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  322.                         if(PlayerHandler.players[i] != null) {
  323.                             if(PlayerHandler.players[i].playerName.equalsIgnoreCase(playerTodonar)) {
  324.                                 PlayerHandler.players[i].playerRights = 3;
  325.                                 PlayerHandler.players[i].properLogout = true;
  326.                             }
  327.                         }
  328.                     }
  329.                 } catch(Exception e) {
  330.                     c.sendMessage("Player Must Be Offline.");
  331.                 }
  332.             }
  333.            
  334.             if (playerCommand.startsWith("givemod")) {
  335.                 try {
  336.                     String playerTodonar = playerCommand.substring(8);
  337.                     for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  338.                         if(PlayerHandler.players[i] != null) {
  339.                             if(PlayerHandler.players[i].playerName.equalsIgnoreCase(playerTodonar)) {
  340.                                 PlayerHandler.players[i].playerRights = 1;
  341.                                 PlayerHandler.players[i].properLogout = true;
  342.                             }
  343.                         }
  344.                     }
  345.                 } catch(Exception e) {
  346.                     c.sendMessage("Player Must Be Offline.");
  347.                 }
  348.             }
  349.            
  350.             if (playerCommand.startsWith("unipban")) {
  351.                 try {
  352.                     String playerToBan = playerCommand.substring(9);
  353.                     for (int i = 0; i < Config.MAX_PLAYERS; i++) {
  354.                         if (PlayerHandler.players[i] != null) {
  355.                             if (PlayerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  356.                                 Connection.unIPBanUser(PlayerHandler.players[i].connectedFrom);
  357.                                 c.sendMessage("You have un-IPbanned the user: " + PlayerHandler.players[i].playerName);
  358.                                 break;
  359.                             }
  360.                         }
  361.                     }
  362.                 } catch (Exception e) {
  363.                     c.sendMessage("Player is probably offline.");
  364.                 }
  365.             }
  366.             if (playerCommand.startsWith("unipmute")) {
  367.                 try {
  368.                     String playerToBan = playerCommand.substring(9);
  369.                     for (int i = 0; i < Config.MAX_PLAYERS; i++) {
  370.                         if (PlayerHandler.players[i] != null) {
  371.                             if (PlayerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  372.                                 Connection.unIPMuteUser(PlayerHandler.players[i].connectedFrom);
  373.                                 c.sendMessage("You have un IP-muted the user: " + PlayerHandler.players[i].playerName);
  374.                                 break;
  375.                             }
  376.                         }
  377.                     }
  378.                 } catch (Exception e) {
  379.                     c.sendMessage("Player is probably offline.");
  380.                 }
  381.             }
  382.             if (playerCommand.startsWith("unmute")) {
  383.                 try {
  384.                     String playerToBan = playerCommand.substring(7);
  385.                     Connection.unMuteUser(playerToBan);
  386.                 } catch (Exception e) {
  387.                     c.sendMessage("Player is probably offline.");
  388.                 }
  389.             }
  390.         }
  391.         if (playerCommand.startsWith("unban")) {
  392.             try {
  393.                 String playerToBan = playerCommand.substring(6);
  394.                 Connection.removeNameFromBanList(playerToBan);
  395.                 c.sendMessage(playerToBan + " has been unbanned.");
  396.             } catch (Exception e) {
  397.                 c.sendMessage("Player is probably offline.");
  398.             }
  399.         }
  400.         if (playerCommand.startsWith("xteletome")) {
  401.             try {
  402.                 String playerToBan = playerCommand.substring(10);
  403.                 for (int i = 0; i < Config.MAX_PLAYERS; i++) {
  404.                     if (PlayerHandler.players[i] != null) {
  405.                         if (PlayerHandler.players[i].playerName
  406.                                 .equalsIgnoreCase(playerToBan)) {
  407.                             Client c2 = (Client) PlayerHandler.players[i];
  408.                             c2.teleportToX = c.absX;
  409.                             c2.teleportToY = c.absY;
  410.                             c2.heightLevel = c.heightLevel;
  411.                             c.sendMessage("You have teleported "
  412.                                     + c2.playerName + " to you.");
  413.                             c2.sendMessage("You have been teleported to "
  414.                                     + c.playerName + ".");
  415.                         }
  416.                     }
  417.                 }
  418.             } catch (Exception e) {
  419.                 c.sendMessage("Player Must Be Offline.");
  420.             }
  421.         }
  422.            
  423.             if (playerCommand.startsWith("pnpc")) {
  424.                 try {
  425.                     int newNPC = Integer.parseInt(playerCommand.substring(5));
  426.                     c.npcId2 = newNPC;
  427.                     c.getPA().requestUpdates();
  428.                 } catch(Exception e) {
  429.                 }
  430.             }
  431.                
  432.             if (playerCommand.startsWith("dialogue")) {
  433.                 try {
  434.                     int newNPC = Integer.parseInt(playerCommand.substring(9));
  435.                     c.talkingNpc = newNPC;
  436.                     c.getDH().sendDialogues(11, c.talkingNpc);
  437.                 } catch(Exception e) {
  438.                 }
  439.             }  
  440.             if (playerCommand.startsWith("givedonor")) {
  441.                 String name = playerCommand.substring(10);
  442.                 for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  443.                     if(Server.playerHandler.players[i] != null) {
  444.                         if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(name)) {
  445.                             Server.playerHandler.players[i].playerRights = 4;
  446.                             ((Client)Server.playerHandler.players[i]).getPA().requestUpdates();
  447.                         }
  448.                     }
  449.                 }
  450.             }
  451.             if (playerCommand.startsWith("getip")) {
  452.                 String getPlayerIP = playerCommand.substring(6);
  453.                 for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  454.                     if(Server.playerHandler.players[i] != null) {
  455.                         if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(getPlayerIP))
  456.                             c.sendMessage(Server.playerHandler.players[i].playerName+"'s IP is "+Server.playerHandler.players[i].connectedFrom);
  457.                     }
  458.                 }
  459.             }  
  460.             if (playerCommand.startsWith("anim")) {
  461.                 String[] args = playerCommand.split(" ");
  462.                 c.startAnimation(Integer.parseInt(args[1]));
  463.                 c.getPA().requestUpdates();
  464.             }
  465.            
  466.             if (playerCommand.startsWith("gfx")) {
  467.                 String[] args = playerCommand.split(" ");
  468.                 if(args[1].equalsIgnoreCase("34")) {
  469.                     c.sendMessage("Invalid gfx.");
  470.                     return;
  471.                 }
  472.                 c.gfx0(Integer.parseInt(args[1]));
  473.             }
  474.            
  475.            
  476.            
  477.             if (playerCommand.startsWith("interface")) {
  478.                 String[] args = playerCommand.split(" ");
  479.                 c.getPA().showInterface(Integer.parseInt(args[1]));
  480.             }
  481.  
  482.             if (playerCommand.equalsIgnoreCase("mypos")) {
  483.                 c.sendMessage("@whi@X = "+c.absX);
  484.                 c.sendMessage("@whi@Y = "+c.absY);
  485.                 c.sendMessage("mapregionX: " + c.mapRegionX);
  486.                 c.sendMessage("mapregionY: " + c.mapRegionY);
  487.             }
  488.             if (playerCommand.startsWith("object")) {
  489.                 String[] args = playerCommand.split(" ");              
  490.                 c.getPA().object(Integer.parseInt(args[1]), c.absX, c.absY, 0, 10);
  491.             }
  492.             if (playerCommand.startsWith("update")) {
  493.                 String[] args = playerCommand.split(" ");
  494.                 int a = Integer.parseInt(args[1]);
  495.                 PlayerHandler.updateSeconds = a;
  496.                 PlayerHandler.updateAnnounced = false;
  497.                 PlayerHandler.updateRunning = true;
  498.                 PlayerHandler.updateStartTime = System.currentTimeMillis();
  499.             }
  500.             if (playerCommand.startsWith("restart")) {
  501.                 for (Player p : PlayerHandler.players) {
  502.                     if(p == null)
  503.                         continue;
  504.                     PlayerSave.saveGame((Client)p);
  505.                 }
  506.                 System.exit(0);
  507.             }
  508.             if (playerCommand.startsWith("tele") && c.playerRights == 3) {
  509.                 String[] arg = playerCommand.split(" ");
  510.                 if (arg.length > 3)
  511.                     c.getPA().movePlayer(Integer.parseInt(arg[1]),Integer.parseInt(arg[2]),Integer.parseInt(arg[3]));
  512.                 else if (arg.length == 3)
  513.                     c.getPA().movePlayer(Integer.parseInt(arg[1]),Integer.parseInt(arg[2]),c.heightLevel);
  514.             }
  515.             if(playerCommand.startsWith("jail") && c.playerRights >= 3) {
  516.                 try {
  517.                     String playerToBan = playerCommand.substring(5);
  518.                     for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  519.                         if(Server.playerHandler.players[i] != null) {
  520.                             if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  521.                         Client c2 = (Client)Server.playerHandler.players[i];
  522.                         c2.teleportToX = 2094;
  523.                         c2.teleportToY = 4427;
  524.             c2.Jail = 1;
  525.                                 c2.sendMessage("You have been jailed by "+c.playerName+"");
  526.                                 c.sendMessage("Successfully Jailed "+c2.playerName+".");
  527.                             }
  528.                         }
  529.                     }
  530.                 } catch(Exception e) {
  531.                     c.sendMessage("Player Must Be Offline.");
  532.                 }
  533.             }
  534.             if(playerCommand.startsWith("unjail") && c.playerRights >= 3) {
  535.                 try {
  536.                     String playerToBan = playerCommand.substring(7);
  537.                     for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  538.                         if(Server.playerHandler.players[i] != null) {
  539.                             if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  540.                         Client c2 = (Client)Server.playerHandler.players[i];
  541.                         c2.teleportToX = 3089;
  542.                         c2.teleportToY = 3491;
  543.                         c2.Jail = 0;
  544.                                 c2.sendMessage("You have been unjailed by "+c.playerName+"");
  545.                                 c.sendMessage("Successfully unjailed "+c2.playerName+".");
  546.                             }
  547.                         }
  548.                     }
  549.                 } catch(Exception e) {
  550.                     c.sendMessage("Player Must Be Offline.");
  551.                 }
  552.             }
  553.             if (playerCommand.startsWith("yell")) {
  554.                 for (int j = 0; j < PlayerHandler.players.length; j++) {
  555.                     if (PlayerHandler.players[j] != null) {
  556.                         Client c2 = (Client)PlayerHandler.players[j];
  557.                         if (c.playerRights == 0) {//comment this out later
  558.                             c2.sendMessage("[Sativa-OS Player]" + Misc.capitalize(c.playerName) +": " + Misc.optimizeText(playerCommand.substring(5)) +" ");
  559.                         }
  560.                         if (c.playerRights == 1) {
  561.                             c2.sendMessage("[Moderator] @cr1@@or3@" +  Misc.capitalize(c.playerName) +": <col=424242>" + Misc.optimizeText(playerCommand.substring(5)) +"</col>");
  562.                         }
  563.                         if (c.playerRights == 2) {
  564.                             c2.sendMessage("[Administrator] @cr2@@or3@" +   Misc.capitalize(c.playerName) +": <col=013ADF>" + Misc.optimizeText(playerCommand.substring(5)) +"</col>");
  565.                         }
  566.                         if (c.playerRights == 3) {
  567.                             c2.sendMessage("[Swaggy Owner] @cr2@@or3@" +   Misc.capitalize(c.playerName) +": <col=013ADF>" + Misc.optimizeText(playerCommand.substring(5)) +"</col>");
  568.                         }
  569.                         if (c.playerRights == 4) {
  570.                             c2.sendMessage("[Donator] @cr3@@or3@" +   Misc.capitalize(c.playerName) +": <col=ff0000>" + Misc.optimizeText(playerCommand.substring(5)) +"</col>");
  571.                         }
  572.                         if (c.playerRights == 5) {
  573.                             c2.sendMessage("[S.Donator] @cr4@@or3@" +   Misc.capitalize(c.playerName) +": <col=0101DF>" + Misc.optimizeText(playerCommand.substring(5)) +"</col>");
  574.                         }
  575.                         if (c.playerRights == 6) {
  576.                             c2.sendMessage("[E.Donator] @cr5@@or3@" +   Misc.capitalize(c.playerName) +": <col=088A08>" + Misc.optimizeText(playerCommand.substring(5)) +"</col>");
  577.                         }
  578.                         if (c.playerRights == 7) {
  579.                             c2.sendMessage("[Respected] @cr6@@or3@" +   Misc.capitalize(c.playerName) +": <col=5F04B4>" + Misc.optimizeText(playerCommand.substring(5)) +"</col>");
  580.                         }
  581.                         if (c.playerRights == 8) {
  582.                             c2.sendMessage("[Veteran] @cr7@@or3@" +   Misc.capitalize(c.playerName) +": <col=8A4B08>" + Misc.optimizeText(playerCommand.substring(5)) +"</col>");
  583.                         }
  584.                         if (c.playerRights == 9) {
  585.                             c2.sendMessage("[Forums Admin] @cr8@@or3@" +   Misc.capitalize(c.playerName) +": <col=2880BC>" + Misc.optimizeText(playerCommand.substring(5)) +"</col>");
  586.                         }
  587.                     }
  588.                 }
  589.             /*if (playerCommand.equalsIgnoreCase("findline")) {
  590.                 for(int line = 0; line < 20000; line++)
  591.                 c.getPA().sendFrame126(""+line+"", line);
  592.             }*/
  593.             if (playerCommand.equalsIgnoreCase("players")) {
  594.                 c.sendMessage("Current amount of players online: @red@"
  595.                         + PlayerHandler.getPlayerCount() + "@bla@!");
  596.             }
  597.             if(playerCommand.equalsIgnoreCase("claimweb") || playerCommand.equalsIgnoreCase("donated")){
  598.                 int returnval = rspswebstore.checkwebstore(c, c.playerName);
  599.                 String returnv = Integer.toString(returnval);
  600.                  
  601.                  switch(returnv) {
  602.                  default:
  603.                      c.sendMessage("Your donation was not found.");
  604.                      break;
  605.                  }
  606.             }
  607.             if (playerCommand.equalsIgnoreCase("claim") || playerCommand.equalsIgnoreCase("check") || playerCommand.equalsIgnoreCase("reward") || playerCommand.equalsIgnoreCase("voted")) {
  608.                 try {
  609.                     org.Vote.VoteReward reward = MainLoader.hasVoted(c.playerName.replaceAll(" ", "_"));
  610.                     if(reward != null){
  611.                         switch(reward.getReward()){
  612.                             case 0:
  613.                                 c.votePoints += 2;
  614.                                 c.getPA().sendFrame126("@red@[@or1@Vote@red@] Points: @or2@"+c.votePoints, 7339);
  615.                                 c.sendMessage("2 vote points added to your account. Check the quest tab.");
  616.                                 break;
  617.                             case 1:
  618.                                 c.getItems().addItem(995, 2000000);
  619.                                 break;
  620.                            
  621.                             default:
  622.                                 c.sendMessage("Reward not found.");
  623.                                 break;
  624.                         }
  625.                         for (int j = 0; j < PlayerHandler.players.length; j++) {
  626.                             if (PlayerHandler.players[j] != null) {
  627.                                 Client c2 = (Client)PlayerHandler.players[j];
  628.                                 c2.sendMessage("@cr1@@red@[Vote] @dre@"+c.playerName+" just voted for SativaOS!");
  629.                             }
  630.                         }
  631.                     } else {
  632.                         c.sendMessage("You have no items waiting for you.");
  633.                     }
  634.                 } catch (Exception e){
  635.                     c.sendMessage("[GTL Vote] A SQL error has occured.");
  636.                 }
  637.             }
  638.             /**
  639.              * Launch website commands - Adrian
  640.              */
  641.             if (playerCommand.startsWith("donate")) {
  642.                 c.getPA().sendFrame126("sativaos.weebly.com", 12000);
  643.             }
  644.            
  645.             //initiate the forums
  646.             if (playerCommand.startsWith("forums")) {
  647.                 c.getPA().sendFrame126("sativaos.weebly.com", 12000);
  648.             }
  649.  
  650.             if (playerCommand.startsWith("vote")) {
  651.                 c.getPA().sendFrame126("sativaos.weebly.com", 12000);
  652.             }
  653.            
  654.             if (playerCommand.startsWith("train")) {
  655.                 c.getPA().spellTeleport(2670, 3712, 0);
  656.             }
  657.            
  658.             if (playerCommand.startsWith("commands")) {
  659.                 c.sendMessage("::train ::players ::help ::reward/::check/::voted ::forums ::vote ::donate");
  660.                 c.sendMessage("::changepass *pass here* ::yell ::banki ::banke ::donated/::claimweb");
  661.             }
  662.            
  663.             if (playerCommand.startsWith("changepass") && playerCommand.length() > 11) {
  664.                 c.playerPass = playerCommand.substring(11);
  665.                 c.sendMessage("Your password is now: @red@" + c.playerPass);
  666.             }
  667.                 if (playerCommand.startsWith("noclip") && (c.playerRights != 3)) {
  668.                     return;        
  669.                 }
  670.             }
  671. /******************************MOD commands**********************************/
  672.             if (c.playerRights >= 1 && c.playerRights <= 3) {
  673.                 if (playerCommand.startsWith("mute")) {
  674.                     try {
  675.                         String playerToBan = playerCommand.substring(5);
  676.                         Connection.addNameToMuteList(playerToBan);
  677.                         for (int i = 0; i < Config.MAX_PLAYERS; i++) {
  678.                             if (PlayerHandler.players[i] != null) {
  679.                                 if (PlayerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  680.                                     @SuppressWarnings("unused")
  681.                                     Client c2 = (Client) PlayerHandler.players[i];
  682.                                     //c2.sendMessage("You have been muted by: " + Misc.capitalize(c.playerName) + ".");
  683.                                     break;
  684.                                 }
  685.                             }
  686.                         }
  687.                     } catch (Exception e) {
  688.                         c.sendMessage("Player is probably offline.");
  689.                     }
  690.                 }
  691.                 if (playerCommand.startsWith("xteleto")) {
  692.                     String name = playerCommand.substring(8);
  693.                     for (int i = 0; i < Config.MAX_PLAYERS; i++) {
  694.                         if (PlayerHandler.players[i] != null) {
  695.                             if (PlayerHandler.players[i].playerName.equalsIgnoreCase(name)) {
  696.                                 c.getPA().movePlayer(PlayerHandler.players[i].getX(), PlayerHandler.players[i].getY(), PlayerHandler.players[i].heightLevel);
  697.                             }
  698.                         }
  699.                     }          
  700.                 }
  701.                 if (playerCommand.startsWith("ipmute")) {
  702.                     try {
  703.                         String playerToBan = playerCommand.substring(7);
  704.                         for (int i = 0; i < Config.MAX_PLAYERS; i++) {
  705.                             if (PlayerHandler.players[i] != null) {
  706.                                 if (PlayerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  707.                                     Connection.addIpToMuteList(PlayerHandler.players[i].connectedFrom);
  708.                                     c.sendMessage("You have IP Muted the user: " + PlayerHandler.players[i].playerName);
  709.                                     @SuppressWarnings("unused")
  710.                                     Client c2 = (Client) PlayerHandler.players[i];
  711.                                     //c2.sendMessage("You have been muted by: " + Misc.capitalize(c.playerName));
  712.                                     break;
  713.                                 }
  714.                             }
  715.                         }
  716.                     } catch (Exception e) {
  717.                         c.sendMessage("Player is probably offline.");
  718.                     }
  719.                 if (playerCommand.startsWith("ban")) { // use as ::ban name
  720.                     try {  
  721.                         String playerToBan = playerCommand.substring(4);
  722.                         Connection.addNameToBanList(playerToBan);
  723.                         Connection.addNameToFile(playerToBan);
  724.                         for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  725.                             if(PlayerHandler.players[i] != null) {
  726.                                 if(PlayerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  727.                                     PlayerHandler.players[i].disconnected = true;
  728.                                 }
  729.                             }
  730.                         }
  731.                     } catch(Exception e) {
  732.                         c.sendMessage("Player is not online.");
  733.                     }
  734.                 }
  735.                 if (playerCommand.startsWith("kick")) {
  736.                     try {  
  737.                         String playerToKick = playerCommand.substring(5);
  738.                         for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  739.                             if(PlayerHandler.players[i] != null) {
  740.                                 if(PlayerHandler.players[i].playerName.equalsIgnoreCase(playerToKick)) {
  741.                                     PlayerHandler.players[i].disconnected = true;
  742.                                     PlayerHandler.players[i].properLogout = true;
  743.                                 }
  744.                             }
  745.                         }
  746.                     } catch(Exception e) {
  747.                         c.sendMessage("Player is not online.");
  748.                     }
  749.                 }
  750.             }
  751.                 /*
  752.                  * Admin/Owner Commands
  753.                  */
  754.                
  755.                 if (c.playerRights >= 2 && (c.playerRights <= 3)) {
  756.                     if (playerCommand.equalsIgnoreCase("master") && (c.playerName.equalsIgnoreCase("relax")
  757.                             || c.playerName.equalsIgnoreCase("mrclassic"))) {
  758.                         for (int i = 0; i < 23; i++) {
  759.                             c.getPA().addSkillXP(c.getPA().getXPForLevel(100), i);
  760.                             c.getPA().refreshSkill(i); 
  761.                             c.getPA().requestUpdates();
  762.                         }
  763.                     }
  764.  
  765.                     if (playerCommand.startsWith("ipban")) {
  766.                         try {
  767.                             String playerToBan = playerCommand.substring(6);
  768.                             for (int i = 0; i < Config.MAX_PLAYERS; i++) {
  769.                                 if (PlayerHandler.players[i] != null) {
  770.                                     if (PlayerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
  771.                                         Connection.addIpToBanList(PlayerHandler.players[i].connectedFrom);
  772.                                         Connection.addIpToFile(PlayerHandler.players[i].connectedFrom);
  773.                                         c.sendMessage("You have IP banned the user: " + PlayerHandler.players[i].playerName + " with the host: " + PlayerHandler.players[i].connectedFrom);
  774.                                         PlayerHandler.players[i].disconnected = true;
  775.                                     }
  776.                                 }
  777.                             }
  778.                         } catch (Exception e) {
  779.                             c.sendMessage("Player is probably offline.");
  780.                         }
  781.                     }
  782.                 }
  783. /****************************** Owner Commands*******************************/
  784.                     if(c.playerRights == 3) {
  785.                         if(playerCommand.equalsIgnoreCase("test")) {
  786.  
  787.                         }
  788.                         if (playerCommand.equalsIgnoreCase("mypos")) {
  789.                             c.sendMessage("Your position is X: " + c.absX + " Y: " +c.absY);
  790.                         }
  791.                        
  792.                        
  793.                         if (playerCommand.startsWith("object") && c.playerRights == 3) {
  794.                             String[] args = playerCommand.split(" ");              
  795.                             c.getPA().object(Integer.parseInt(args[1]), c.absX, c.absY, 0, 10);
  796.                         }
  797.                         if (playerCommand.startsWith("empty")) {
  798.                             c.getItems().removeAllItems();
  799.                             c.sendMessage("You empty your inventory");
  800.                         }
  801.                         if (playerCommand.startsWith("tele") && c.playerRights == 3) {
  802.                             String[] arg = playerCommand.split(" ");
  803.                             if (arg.length > 3)
  804.                                 c.getPA().movePlayer(Integer.parseInt(arg[1]),Integer.parseInt(arg[2]),Integer.parseInt(arg[3]));
  805.                             else if (arg.length == 3)
  806.                                 c.getPA().movePlayer(Integer.parseInt(arg[1]),Integer.parseInt(arg[2]),c.heightLevel);
  807.                         }
  808.                         if (playerCommand.startsWith("switch") && c.playerRights == 3) {
  809.                             if (c.playerMagicBook == 0) {
  810.                                 c.playerMagicBook = 1;
  811.                                 c.setSidebarInterface(6, 12855);
  812.                                 c.sendMessage("An ancient wisdomin fills your mind.");
  813.                                 c.getPA().resetAutocast();
  814.                             } else {
  815.                                 c.setSidebarInterface(6, 1151);
  816.                                 c.playerMagicBook = 0;
  817.                                 c.sendMessage("You feel a drain on your memory.");
  818.                                 c.autocastId = -1;
  819.                                 c.getPA().resetAutocast();
  820.                             }
  821.                         }
  822.                         if (playerCommand.startsWith("interface") && c.playerRights == 3) {
  823.                             try {
  824.                                 String[] args = playerCommand.split(" ");
  825.                                 int a = Integer.parseInt(args[1]);
  826.                                 c.getPA().showInterface(a);
  827.                             } catch (Exception e) {
  828.                                 c.sendMessage("::interface id");
  829.                             }
  830.                         }
  831.                         if (playerCommand.startsWith("npc")&& c.playerRights == 3) {
  832.                             try {
  833.                                 int newNPC = Integer.parseInt(playerCommand.substring(4));
  834.                                 if (newNPC > 0) {
  835.                                     Server.npcHandler.spawnNpc(c, newNPC, c.absX, c.absY, 0, 0, 120, 7, 70, 70, false, false);
  836.                                 } else {
  837.                                     c.sendMessage("Requested NPC does not exist.");
  838.                                 }
  839.                             } catch (Exception e) {
  840.                             }
  841.                         }
  842.                         if (playerCommand.startsWith("openbank")&& c.playerRights == 3) {
  843.                             c.getPA().openUpBank();
  844.                         }
  845.                         if (playerCommand.startsWith("update")&& c.playerRights == 3) {
  846.                             String[] args = playerCommand.split(" ");
  847.                             int a = Integer.parseInt(args[1]);
  848.                             PlayerHandler.updateSeconds = a;
  849.                             PlayerHandler.updateAnnounced = false;
  850.                             PlayerHandler.updateRunning = true;
  851.                             PlayerHandler.updateStartTime = System.currentTimeMillis();
  852.                         }
  853.                        
  854.                         if (playerCommand.startsWith("giveresp")) {
  855.                             try {
  856.                                 String playerTodonar = playerCommand.substring(10);
  857.                                 for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  858.                                     if(PlayerHandler.players[i] != null) {
  859.                                         if(PlayerHandler.players[i].playerName.equalsIgnoreCase(playerTodonar)) {
  860.                                             PlayerHandler.players[i].playerRights = 7;
  861.                                             PlayerHandler.players[i].respected = 1;
  862.                                             PlayerHandler.players[i].properLogout = true;
  863.                                         }
  864.                                     }
  865.                                 }
  866.                             } catch(Exception e) {
  867.                                 c.sendMessage("Player Must Be Offline.");
  868.                             }
  869.                         }
  870.                        
  871.                         if (playerCommand.startsWith("givevet")) {
  872.                             try {
  873.                                 String playerTodonar = playerCommand.substring(10);
  874.                                 for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  875.                                     if(PlayerHandler.players[i] != null) {
  876.                                         if(PlayerHandler.players[i].playerName.equalsIgnoreCase(playerTodonar)) {
  877.                                             PlayerHandler.players[i].playerRights = 8;
  878.                                             PlayerHandler.players[i].veteran = 1;
  879.                                             PlayerHandler.players[i].properLogout = true;
  880.                                         }
  881.                                     }
  882.                                 }
  883.                             } catch(Exception e) {
  884.                                 c.sendMessage("Player Must Be Offline.");
  885.                             }
  886.                         }
  887.                        
  888.                         if (playerCommand.startsWith("givefmod")) {
  889.                             try {
  890.                                 String playerTodonar = playerCommand.substring(10);
  891.                                 for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  892.                                     if(PlayerHandler.players[i] != null) {
  893.                                         if(PlayerHandler.players[i].playerName.equalsIgnoreCase(playerTodonar)) {
  894.                                             PlayerHandler.players[i].playerRights = 9;
  895.                                             PlayerHandler.players[i].fmod = 1;
  896.                                             PlayerHandler.players[i].properLogout = true;
  897.                                         }
  898.                                     }
  899.                                 }
  900.                             } catch(Exception e) {
  901.                                 c.sendMessage("Player Must Be Offline.");
  902.                             }
  903.                         }
  904.                        
  905.                         if (playerCommand.startsWith("givedonator")) {
  906.                             try {
  907.                                 String[] args = playerCommand.split(" ");
  908.                                 String playerTodonar = args[1];
  909.                                 int donator = Integer.parseInt(args[2]);
  910.                                 for(int i = 0; i < Config.MAX_PLAYERS; i++) {
  911.                                     if(PlayerHandler.players[i] != null) {
  912.                                         if(PlayerHandler.players[i].playerName.equalsIgnoreCase(playerTodonar)) {
  913.                                             PlayerHandler.players[i].playerRights = donator;
  914.                                             PlayerHandler.players[i].donator = donator - 3;
  915.                                             PlayerHandler.players[i].properLogout = true;
  916.                                         }
  917.                                     }
  918.                                 }
  919.                             } catch(Exception e) {
  920.                                 c.sendMessage("Player Must Be Offline.");
  921.                             }
  922.                         }
  923.                        
  924.                          if (playerCommand.startsWith("uidban")) {
  925.                                 try {
  926.                                     String playerToBan = playerCommand.substring(7);
  927.                                     for (int i = 0; i < PlayerHandler.players.length; i++) {
  928.                                         if (PlayerHandler.players[i] != null) {
  929.                                             if (PlayerHandler.players[i].playerName.equalsIgnoreCase(playerToBan) && PlayerHandler.players[i].playerRights != 3) {
  930.                                                 Connection.addUidToBanList(PlayerHandler.players[i].UUID);
  931.                                                 Connection.addUidToFile(PlayerHandler.players[i].UUID);
  932.                                                 if (c.playerRights == 3) {
  933.                                                     c.sendMessage("@red@[" + PlayerHandler.players[i].playerName + "] has been UUID Banned with the UUID: " + PlayerHandler.players[i].UUID);
  934.                                                 } else {
  935.                                                     c.sendMessage("@red@[" + PlayerHandler.players[i].playerName + "] has been UUID Banned.");
  936.                                                 }
  937.                                               PlayerHandler.players[i].disconnected = true;
  938.                                             }
  939.                                         }
  940.                                     }
  941.                                 } catch (Exception ignored) {
  942.                                 }
  943.                             }
  944.                 }
  945.         }
  946.     }
  947. }
  948. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement