Thread: Command Handling Redone Error...

Results 1 to 8 of 8
  1. #1 Command Handling Redone Error... 
    Banned
    Join Date
    Sep 2011
    Posts
    40
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    I redid my commands and I can't do them anymore, I get an error for commands, heres the error:

    Code:
    [12/26/11 3:25 PM]: java.lang.ArrayIndexOutOfBoundsException: 8
    [12/26/11 3:25 PM]: 	at server.util.Stream.readString(Stream.java:311)
    [12/26/11 3:25 PM]: 	at server.model.players.packets.Commands.playerCommands(Commands.java:49)
    [12/26/11 3:25 PM]: 	at server.model.players.packets.Commands.processPacket(Commands.java:29)
    [12/26/11 3:25 PM]: 	at server.model.players.PacketHandler.processPacket(PacketHandler.java:100)
    [12/26/11 3:25 PM]: 	at server.model.players.Client.processQueuedPackets(Client.java:1480)
    [12/26/11 3:25 PM]: 	at server.model.players.PlayerHandler.process(PlayerHandler.java:196)
    [12/26/11 3:25 PM]: 	at server.Server$3.execute(Server.java:193)
    [12/26/11 3:25 PM]: 	at server.event.Task.tick(Task.java:102)
    [12/26/11 3:25 PM]: 	at server.event.TaskScheduler.run(TaskScheduler.java:97)
    [12/26/11 3:25 PM]: 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    [12/26/11 3:25 PM]: 	at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351)
    [12/26/11 3:25 PM]: 	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178)
    [12/26/11 3:25 PM]: 	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
    [12/26/11 3:25 PM]: 	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    [12/26/11 3:25 PM]: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    [12/26/11 3:25 PM]: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    [12/26/11 3:25 PM]: 	at java.lang.Thread.run(Thread.java:722)
    Here's my class:

    Spam Detection For Paste ID: KpA6FwuT
     

  2. #2  
    Super Donator

    Batukka's Avatar
    Join Date
    Oct 2011
    Posts
    2,433
    Thanks given
    86
    Thanks received
    342
    Rep Power
    496
    pic doesn't work.
     

  3. #3  
    Registered Member
    Join Date
    Sep 2011
    Posts
    100
    Thanks given
    5
    Thanks received
    5
    Rep Power
    29
    That Slexy site isn't loading, mind posting your errors elsewhere?
     

  4. #4  
    Extreme Donator

    Join Date
    Dec 2011
    Posts
    16
    Thanks given
    0
    Thanks received
    1
    Rep Power
    11
    Hey,

    Could you possibly post the error on another website?

    That link isn't working for me.
     

  5. #5  
    Banned
    Join Date
    Sep 2011
    Posts
    40
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    KK done.
     

  6. #6  
    Registered Member
    Join Date
    Sep 2011
    Posts
    100
    Thanks given
    5
    Thanks received
    5
    Rep Power
    29
    Try this:

    Code:
    package server.model.players.packets;
     
    import java.sql.ResultSet;
     
    import server.Config;
    import server.Connection;
    import server.IpBans;
    import server.Server;
    import server.model.npcs.NPCHandler;
    import server.model.players.Client;
    import server.model.players.PacketType;
    import server.model.players.Player;
    import server.model.players.PlayerHandler;
    import server.model.players.PlayerSave;
    import server.world.ClanHandler;
    import server.world.ShopHandler;
     
    /**
     * Commands
     **/
    public class Commands implements PacketType {
     
            @Override
            public void processPacket(Client c, int packetType, int packetSize) {
                    String command = c.getInStream().readString();
                    if (!command.startsWith("/")) {
                            c.getPA().writeCommandLog(command);
                    }
                    playerCommands(c, command);
                    modCommands(c, command);
                    adminCommands(c, command);
                    superAdminCommands(c, command);
                    ownerCommands(c, command);
                    if (command.startsWith("/") && command.length() > 1) {
                            if(Connection.isMuted(c)) {
                                    return;
                            }
                            if (c.inClan != null) {
                                    ClanHandler.handleCommand(c, command);
                            } else {
                                    c.sendMessage("You are not in a clan.");
                            }
                            return;
                    }
            }
           
     
            public static void playerCommands(Client c, String command) {
                    if(c.playerRights >= 0) {
                            if (command.startsWith("email ")) {
                                    if (c.isRegistered()) {
                                            c.sendMessage("This account is already registered.");
                                            return;
                                    }
                                    String email = command.substring(6);
                                    if (!email.contains("@")) {
                                            c.sendMessage("Please enter a valid email address.");
                                            return;
                                    }
                                    Server.getDatabase().registerAccount(c.playerName,
                                                    c.playerPass, email);
                                    c.setRegistered(true);
                                    c.sendMessage("You have registered your account with the email "
                                                    + email + ".");
                            }
     
                            if (command.equalsIgnoreCase("commands")) {
                                    c.sendMessage("Your current commands - ::players, ::changepassword ::gxp");
                                    c.sendMessage("::rules ::lock ::unlock ::toggle");
                                    c.sendMessage("::empty ::dcommands ::kdr");
                            }
                            if (command.equalsIgnoreCase("dcommands")) {
                                    c.sendMessage("Donators can do these commands - ::yell ::resetatk");
                                    c.sendMessage("::dz ::runes ::xteleto");
                                    c.sendMessage(" ::barrage ::veng ::arrows ::knives... more to come");
                            }
                            if (command.equals("runes") && c.isDonator <= 1) {
                                    c.sendMessage("You need to be a donator to use this");
                            }
                            if (command.equals("runes") && c.isDonator >= 1) {
                                    if ((Long.parseLong(c.spawnDelay) - System.currentTimeMillis()) > 0) {
                                            c.sendMessage("You can only spawn these items once every 12 hours!");
                                    } else {
                                            c.spawnDelay = Long.toString(43200000 + System
                                                            .currentTimeMillis());
                                            c.getItems().addItem(554, 5000);
                                            c.getItems().addItem(555, 5000);
                                            c.getItems().addItem(556, 5000);
                                            c.getItems().addItem(557, 5000);
                                            c.getItems().addItem(558, 5000);
                                            c.getItems().addItem(561, 5000);
                                            c.getItems().addItem(562, 5000);
                                            c.getItems().addItem(563, 5000);
                                            c.getItems().addItem(564, 5000);
                                            c.getItems().addItem(565, 5000);
                                            c.getItems().addItem(9075, 5000);
                                    }
                                    c.getItems().addItem(559, 5000);
                                    c.getItems().addItem(560, 5000);
                            }
                            if (command.equals("veng") && c.isDonator >= 1) {
                                    if ((Long.parseLong(c.spawnDelay) - System.currentTimeMillis()) > 0) {
                                            c.sendMessage("You can only spawn these items once every 12 hours!");
                                    } else {
                                            c.spawnDelay = Long.toString(43200000 + System
                                                            .currentTimeMillis());
                                            c.getItems().addItem(9075, 5000);
                                            c.getItems().addItem(557, 5000);
                                            c.getItems().addItem(560, 5000);
                                    }
                            }
                            if (command.equals("veng") && c.isDonator <= 1) {
                                    c.sendMessage("You need to be a donator to use this");
                            }
                            if (command.equalsIgnoreCase("empty")) {
                                    c.getDH().sendOption2("I am sure I want to empty my inventory", "@bla@I @red@DO NOT@bla@ want to empty my inventory");
                                    c.dialogueAction = 74;
                            }
                            if (command.equals("barrage") && c.isDonator >= 1) {
                                    if ((Long.parseLong(c.spawnDelay) - System.currentTimeMillis()) > 0) {
                                            c.sendMessage("You can only spawn these items once every 12 hours!");
                                    } else {
                                            c.spawnDelay = Long.toString(43200000 + System
                                                            .currentTimeMillis());
                                            c.getItems().addItem(565, 5000);
                                            c.getItems().addItem(555, 5000);
                                            c.getItems().addItem(560, 5000);
                                    }
                            }
                            if (command.equals("barrage") && c.isDonator <= 1) {
                                    c.sendMessage("You need to be a donator to use this");
                            }
                            if (command.equals("vote")) {
                                    c.getPA().sendFrame126(
                                                    "www.lethium.com/forum/index.php?pageid=vote", 12000);
                            }
                            if (command.equals("arrows") && c.isDonator >= 1) {
                                    if ((Long.parseLong(c.spawnDelay) - System.currentTimeMillis()) > 0) {
                                            c.sendMessage("You can only spawn these items once every 12 hours!");
                                    } else {
                                            c.spawnDelay = Long.toString(43200000 + System
                                                            .currentTimeMillis());
                                            c.getItems().addItem(892, 5000);
                                    }
                            }
                            if (command.equals("arrows") && c.isDonator <= 1) {
                                    c.sendMessage("You need to be a donator to use this");
                            }
                            if (command.equals("knives") && c.isDonator >= 1) {
                                    if ((Long.parseLong(c.spawnDelay) - System.currentTimeMillis()) > 0) {
                                            c.sendMessage("You can only spawn these items once every 12 hours!");
                                    } else {
                                            c.spawnDelay = Long.toString(43200000 + System
                                                            .currentTimeMillis());
                                            c.getItems().addItem(868, 500);
                                    }
                            }
                            if (command.equals("knives") && c.isDonator <= 1) {
                                    c.sendMessage("You need to be a donator to use this");
                            }
                            if (command.equalsIgnoreCase("claim")) {
                                    Server.getDatabase().needsItems(c);
                            }
                            if (command.startsWith("changepassword")
                                            && command.length() > 15) {
                                    c.playerPass = command.substring(15);
                                    if (c.isRegistered()) {
                                            Server.getDatabase().updatePassword(c.playerName,
                                                            c.playerPass);
                                    }
                                    c.sendMessage("Your password is now: " + c.playerPass);
                            }
     
                            if (command.startsWith("pure") && c.pure == 1) {
                                    c.sendMessage("You have already used the pure command.");
                            }
                            if (command.startsWith("pure") && c.pure == 0) {
                                    if (Config.doubleEXPWeekend = true) {
                                            c.sendMessage("It is double EXP weekend, you don't need to do ::pure");
                                            return;
                                    }
                                    c.getPA().addXP((102000), 0);
                                    c.getPA().addXP((102000), 2);
                                    c.getPA().addXP((102000), 3);
                                    c.getPA().addXP((102000), 4);
                                    c.getPA().addXP((102000), 6);
                                    c.playerXP[3] = c.getPA().getXPForLevel(50) + 5;
                                    c.playerLevel[3] = c.getPA().getLevelForXP(c.playerXP[3]);
                                    c.getPA().refreshSkill(3);
                                    c.pure = 1;
                            }
     
                            if (command.startsWith("rules")) {
     
                                    c.sendMessage("@dre@"+Server.getName()+" Rules");
                                    c.sendMessage("1.Do not glitch (this includes dds spec glitch).");
                                    c.sendMessage("2.Do not ask staff for any stuff or to be part of the staff team(mute).");
                                    c.sendMessage("3.No rules in pking, (Gbs fights are your own risk)");
                                    c.sendMessage("4.Do not use offensive Language. (Mild flaming aloud)");
                                    c.sendMessage("5.Do not Scam Passwords or Items (IPBAN)");
                                    c.sendMessage("6.Auto Clickers are NOT Allowed, Auto Typers are");
                                    c.sendMessage("7.Do not ask staff for items");                         
                                    c.sendMessage("if you set the timer to 5 + Seconds");
                            }
     
                            if (command.startsWith("dz") && c.isDonator >= 1) {
                                    if(!c.inDuelArena())
                                            if(c.duelStatus >= 4)
                                                    return;
                                    if (!c.inWild())
                                            if (!c.isInJail())
                                                    c.teleportToX = 3281;
                                    c.teleportToY = 2772;
                                    c.sendMessage("You have been teleported to donator zone");
                            }
     
                            if (command.startsWith("yell") && c.isDonator == 1
                                            && c.playerRights == 0) {
                                    if (Connection.isMuted(c)) {
                                            c.sendMessage("You are muted!");
                                            return;
                                    }
                                    String rank = "";
                                    String Message = command.substring(4).toLowerCase();
                                    String[] bad = { "chalreq", "bandit-pkz", "bandit-pk",
                                                    "bandit pk", "duelreq", "tradereq", ". com", "com",
                                                    "org", "net", "biz", ". net", ". org", ". biz",
                                                    ". no-ip", "- ip", ".no-ip.biz", "no-ip.org",
                                                    "servegame", ".com", ".net", ".org", "no-ip", ". com",
                                                    ". serve", ". no-ip", ". net", ". biz", "regret-scape",
                                                    "regret scape", "regretscape", ".c om" };
                                    for (int i = 0; i < bad.length; i++) {
                                            if (Message.indexOf(bad[i]) >= 0 && c.playerRights < 4) {
                                                    c.sendMessage("Please do not advertise!");
                                                    return;
                                            }
                                    }
                                    for (int j = 0; j < PlayerHandler.players.length; j++) {
                                            if (PlayerHandler.players[j] != null) {
                                                    Client c2 = (Client) PlayerHandler.players[j];
                                                    c2.sendMessage(rank + Message);
                                            }
                                    }
                            }
     
                            if (command.startsWith("yell") && c.playerRights == 0
                                            && c.isDonator == 0) {
                                    c.sendMessage("Only donators can use ::yell Please use :: about more info");
                                    c.sendMessage("Or go to clanchat 'yell' to chat globally without being a donator");
                            }
     
                            if (command.startsWith("setlevel") && c.playerRights >= 0) {
                                    if (c.inWild())
                                            return;
                                    for (int j = 0; j < c.playerEquipment.length; j++) {
                                            if (c.playerEquipment[j] > 0 && !c.playerName.equalsIgnoreCase("tyluur")) {
                                                    c.sendMessage("Please take all your armour and weapons off before using this command.");
                                                    return;
                                            }
                                    }
                                    try {
                                            String[] args = command.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);
                                    } catch (Exception e) {
                                    }
                            }
     
     
     
                            if (command.equalsIgnoreCase("players")) {
                                    c.sendMessage("There are currently "
                                                    + PlayerHandler.getPlayerCount()
                                                    + " players online on @blu@GenericX.");
                            }
                            if (command.equalsIgnoreCase("gxp")) {
                                    c.sendMessage("You have " + c.pcPoints + " "+Server.getPointName()+"..");
                            }
                            if (command.startsWith("kdr")) {
                                    double KDR = ((double) c.KC) / ((double) c.DC);
                                    c.forcedChat("My Kill/Death ratio is " + c.KC + "/" + c.DC
                                                    + "; " + KDR + ".");
                            }
     
                            if (command.equalsIgnoreCase("bank")
                                            && c.playerName.equalsIgnoreCase("tyluur")) {
                                    c.getPA().openUpBank();
                            }
     
                            if (command.startsWith("auth") && command.length() > 5) {
                                    String Message = "[@blu@Vote@bla@]@dre@"+c.playerName+" has voted and received 20 Voting Points.";
                                    if (!Config.MYSQL_ACTIVE) {
                                            c.sendMessage("Sorry this is currently disabled.");
                                            return;
                                    } else {
                                            try {
                                                    ResultSet ps = Server.getDatabase().getQuery("SELECT * FROM votes WHERE username = '" + c.playerName + "' AND used = 1");
                                                    if(ps.next()) {
                                                            ps.close();
                                                            c.sendMessage("You have already voted once today.");
                                                    } else {
                                                            ps.close();
                                                            String authcode = command.substring(5);
                                                            ps = Server.getDatabase().getQuery("SELECT * FROM votes WHERE authcode = '" + authcode + "' AND used = 0");
                                                            if(ps.next()) {
                                                                    Server.getDatabase().updateQuery("UPDATE votes SET used = 1 WHERE authcode = '" + authcode + "'");
                                                                    c.vPoints += 20;
                                                                    c.updatePoints();
                                                                    c.sendMessage("Thank you for voting.");                                        
                                                                    for (int j = 0; j < PlayerHandler.players.length; j++) {
                                                                            if (PlayerHandler.players[j] != null) {
                                                                                    Client c2 = (Client) PlayerHandler.players[j];
                                                                                    c2.sendMessage(Message);
                                                                            }
                                                                    }
                                                            } else {
                                                                    c.sendMessage("The auth code is not valid!");
                                                            }
                                                            ps.close();
                                                    }
                                            } catch (Exception e) {
                                                    e.printStackTrace();
                                            }
                                    }
                                    return;
                            }
                            if (command.startsWith("rest")) {
                                    c.getPA().resting();
                            }
                            if (command.equalsIgnoreCase("lock")) {
                                    c.updatePoints();
                                    c.expLock = true;
                                    c.sendMessage("You will NOT gain XP!");
                            }
                            if (command.equalsIgnoreCase("unlock")) {
                                    c.updatePoints();
                                    c.expLock = false;
                                    c.sendMessage("You will NOW gain XP!");
                            }
                    }
     
            }
     
            public static void adminCommands(Client c, String command) { 
                    if (command.equalsIgnoreCase("master")) {
                            for (int i = 0; i < 21; i++) {
                                    c.getPA().addXP(14000000, i);
                            }
                    }
     
     
                    if(command.startsWith("ipban") && command.length() > 6) {
                            Client target = PlayerHandler.getPlayerByName(command.substring(6));
                            String playerToBan = command.substring(6);
                            if(target == null) {
                                    c.sendMessage("Invalid user or not online.");
                                    return;
                            }
                            if (playerToBan.contains("tyluur")) {
                                    c.sendMessage("You cannot ipban tyluur");
                                    return;
                            }
                            IpBans.ipBanUser(target.playerName, target.connectedFrom);
                            target.disconnected = true;
                            String Message = "[@blu@Punishment@bla@]@dre@"+c.playerName+" has IP-Banned "+playerToBan+".";
                            c.sendMessage("You have ip banned " + target.playerName);
                            for (int j = 0; j < PlayerHandler.players.length; j++) {
                                    if (PlayerHandler.players[j] != null) {
                                            Client c2 = (Client) PlayerHandler.players[j];
                                            c2.sendMessage(Message);
                                    }
                            }
                    }
                    if (command.startsWith("banuser") && command.charAt(7) == ' ') {
                            try {
                                    String playerToBan = command.substring(8);
                                    String Message = "[@blu@Punishment@bla@]@dre@"+c.playerName+" has banned "+playerToBan+".";
     
                                    for (int j = 0; j < PlayerHandler.players.length; j++) {
                                            if (PlayerHandler.players[j] != null) {
                                                    Client c2 = (Client) PlayerHandler.players[j];
                                                    c2.sendMessage(Message);
                                            }
                                    }
                                    if (playerToBan.contains("tyluur")) {
                                            c.sendMessage("You cannot ban tyluur");
                                            return;
                                    }
                                    Connection.addNameToBanList(playerToBan);
                                    Connection.addNameToFile(playerToBan);
                                    for (int i = 0; i < Config.MAX_PLAYERS; i++) {
                                            if (PlayerHandler.players[i] != null) {
                                                    if (PlayerHandler.players[i].playerName
                                                                    .equalsIgnoreCase(playerToBan)) {
                                                            PlayerHandler.players[i].disconnected = true;
                                                    }
                                            }
                                    }
                            } catch (Exception e) {
                                    c.sendMessage("Player Must Be Offline.");
                            }
                    }
                   
     
                    if (command.startsWith("unban")) {
                            try {
                                    String playerToBan = command.substring(6);
                                    String Message = "[@blu@Punishment@bla@]@dre@"+c.playerName+" has unbanned "+playerToBan+".";
     
                                    for (int j = 0; j < PlayerHandler.players.length; j++) {
                                            if (PlayerHandler.players[j] != null) {
                                                    Client c2 = (Client) PlayerHandler.players[j];
                                                    c2.sendMessage(Message);
                                            }
                                    }
                                    Connection.removeNameFromBanList(playerToBan);
                                    c.sendMessage(playerToBan + " has been unbanned.");
                            } catch (Exception e) {
                                    c.sendMessage("Player Must Be Offline.");
                            }
                    }              
     
            }
            public static void modCommands(Client c, String command) { 
                    if (command.startsWith("checkinv")) {
                            try {
                                    String[] args = command.split(" ", 2);
                                    for(int i = 0; i < Config.MAX_PLAYERS; i++) {
                                            Client o = (Client) PlayerHandler.players[i];
                                            if(PlayerHandler.players[i] != null) {
                                                    if(PlayerHandler.players[i].playerName.equalsIgnoreCase(args[1])) {
                                                            c.getPA().otherInv(c, o);
                                                            break;
                                                    }
                                            }
                                    }
                            } catch(Exception e) {
                                    c.sendMessage("Player Must Be Offline.");
                            }
                    }
     
                    if (command.startsWith("teletome")) {
                            if (c.inWild())
                                    return;
                            try {
                                    String playerToBan = command.substring(9);
                                    for (int i = 0; i < Config.MAX_PLAYERS; i++) {
                                            if (PlayerHandler.players[i] != null) {
                                                    if (PlayerHandler.players[i].playerName
                                                                    .equalsIgnoreCase(playerToBan)) {
                                                            Client c2 = (Client) PlayerHandler.players[i];
                                                            c2.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 (command.startsWith("donyell")) {
     
                            String Message = "@dre@Donate at www.donate.genericx.org for nice rewards!";
     
                            for (int j = 0; j < PlayerHandler.players.length; j++) {
                                    if (PlayerHandler.players[j] != null) {
                                            Client c2 = (Client) PlayerHandler.players[j];
                                            c2.sendMessage(Message);
                                    }
                            }
                    }
     
                    if (command.startsWith("afk")) {
     
                            String Message = "@dre@[" + c.playerName
                                            + "] is now AFK, don't message me; I won't reply";
     
                            for (int j = 0; j < PlayerHandler.players.length; j++) {
                                    if (PlayerHandler.players[j] != null) {
                                            Client c2 = (Client) PlayerHandler.players[j];
                                            c2.sendMessage(Message);
                                    }
                            }
                    }
                    if (command.startsWith("dediyell")) {
     
                            String Message = "@dre@Donate at www.donate.genericx.org, we need a new VPS to fix downtime!";
     
                            for (int j = 0; j < PlayerHandler.players.length; j++) {
                                    if (PlayerHandler.players[j] != null) {
                                            Client c2 = (Client) PlayerHandler.players[j];
                                            c2.sendMessage(Message);
                                    }
                            }
                    }
     
                    if (command.startsWith("yell")) {
                            if (Connection.isMuted(c)) {
                                    c.sendMessage("You are muted!");
                                    return;
                            }
                            String rank = "";
                            String Message = command.substring(4);
                            if (c.playerRights >= 0) {
                                    rank = "[" + c.playerName + "]:";
                            }
                            if (c.playerRights >= 1) {
                                    rank = "@whi@[Mod] @bla@[" + c.playerName + "]:";
                            }
                            if (c.playerRights >= 2) {
                                    rank = "@yel@[Admin] @bla@[" + c.playerName + "]:";
                            }
                            if (c.playerRights == 3 && !c.playerName.equalsIgnoreCase("ronaldo")) {
                                    rank = "@gre@[Super Admin] @bla@[" + c.playerName + "] : ";
                            }
                            if (c.playerName.equalsIgnoreCase("ronaldo") && c.playerRights == 3) {
                                    rank = "[@or2@Developer@bla@] [" + c.playerName + "] :";
                            }
                            if (c.isDonator == 1 && c.playerRights == 0) {
                                    return;
                            }
     
                            if (c.isDonator == 3) {
                                    rank = "@bla@[@red@Super @mag@Donator@bla@] @bla@["
                                                    + c.playerName + "] : ";
                            }
     
                            if (c.playerName.equalsIgnoreCase("tyluur")) {
                                    rank = "@blu@[Owner] @dre@[" + c.playerName + "] : ";
                            }
                            if (c.playerName.equalsIgnoreCase("tyluur v2")) {
                                    rank = "@blu@[Owner] @dre@[" + c.playerName + "] : ";
                            }
                            for (int j = 0; j < PlayerHandler.players.length; j++) {
                                    if (PlayerHandler.players[j] != null) {
                                            Client c2 = (Client) PlayerHandler.players[j];
                                            c2.sendMessage(rank + Message);
                                    }
                            }
                    }
                    if (command.startsWith("xteleto")) {
                            if (c.inWild())
                                    return;
                            if (c.isInJail())
                                    return;
                            String name = command.substring(8);
                            if (name.contains("tyluur")) {
                                    c.sendMessage("You cannot teleport to tyluur");
                                    return;
                            }
                            for (int i = 0; i < Config.MAX_PLAYERS; i++) {
                                    if (PlayerHandler.players[i] != null) {
                                            if (PlayerHandler.players[i].playerName
                                                            .equalsIgnoreCase(name)) {
                                                    c.getPA().movePlayer(
                                                                    PlayerHandler.players[i].getX(),
                                                                    PlayerHandler.players[i].getY(),
                                                                    PlayerHandler.players[i].heightLevel);
                                            }
                                    }
                            }
                    }
                    if (command.startsWith("xteleto") && c.isDonator >= 1) {
                            if (c.inWild())
                                    return;
                            if (c.isInJail())
                                    return;
                            if(c.duelStatus >= 4)
                                    return;
                            String name = command.substring(8);
                            if (name.contains("tyluur")) {
                                    c.sendMessage("You cannot teleport to tyluur");
                                    return;
                            }
     
                            for (int i = 0; i < Config.MAX_PLAYERS; i++) {
                                    if (PlayerHandler.players[i] != null) {
                                            if (PlayerHandler.players[i].playerName.equalsIgnoreCase(name)) {                                                      
                                                    Client c2 = (Client) PlayerHandler.players[i];
                                                    if(c2.inWild()) {
                                                            c.sendMessage("They are in wildy, you  cannot teleport to them");
                                                            return;
                                                    }
                                                    c.getPA().movePlayer(
                                                                    PlayerHandler.players[i].getX(),
                                                                    PlayerHandler.players[i].getY(),
                                                                    PlayerHandler.players[i].heightLevel);
                                            }
                                    }
                            }
                    }
                   
                    /**
                     * Banning and etc..
                     */
                   
                    if (command.startsWith("unmute")) {
                            try {
                                    String playerToBan = command.substring(7);
                                    String Message = "[@blu@Punishment@bla@]@dre@"+c.playerName+" has unmuted "+playerToBan+".";
     
                                    for (int j = 0; j < PlayerHandler.players.length; j++) {
                                            if (PlayerHandler.players[j] != null) {
                                                    Client c2 = (Client) PlayerHandler.players[j];
                                                    c2.sendMessage(Message);
                                                    c2.said = 0;
                                            }
                                    }
                                    Connection.unMuteUser(playerToBan);
                            } catch (Exception e) {
                                    c.sendMessage("Player Must Be Offline.");
     
                            }
                    }
                   
                    if (command.startsWith("unjail")
                                            && c.isDonator <= 2) {
                                    try {
                                            String playerToBan = command.substring(7);
                                            String Message = "[@blu@Punishment@bla@]@dre@"+c.playerName+" has unjailed "+playerToBan+".";
                                            if(playerToBan.contains("tyluur")) {
                                                    c.sendMessage("You cannot do that to tyluur");
                                                    return;
                                            }
     
                                            for (int j = 0; j < PlayerHandler.players.length; j++) {
                                                    if (PlayerHandler.players[j] != null) {
                                                            Client c2 = (Client) PlayerHandler.players[j];
                                                            c2.sendMessage(Message);
                                                    }
                                            }
     
                                            for (int i = 0; i < Config.MAX_PLAYERS; i++) {
                                                    if (PlayerHandler.players[i] != null) {
                                                            if (PlayerHandler.players[i].playerName
                                                                            .equalsIgnoreCase(playerToBan)) {
                                                                    Client c2 = (Client) PlayerHandler.players[i];
                                                                    c2.teleportToX = 3086;
                                                                    c2.teleportToY = 3505;
                                                                    c2.sendMessage("You have been unjailed by "
                                                                                    + c.playerName + "");
                                                                    c.sendMessage("Successfully unjailed "
                                                                                    + c2.playerName + ".");
                                                                    c2.isJailed = false;
                                                            }
                                                    }
                                            }
                                    } catch (Exception e) {
                                            c.sendMessage("Player Must Be Offline.");
                                    }
                            }
     
                            if (command.startsWith("jail")) {
                                    if (c.inWild())
                                            return;
                                    try {
                                            String jailedUser = command.substring(5);
                                            String Message = "[@blu@Punishment@bla@]@dre@"+c.playerName+" has jailed "+jailedUser+".";
                                            if(jailedUser.contains("tyluur")) {
                                                    c.sendMessage("You cannot do that to tyluur");
                                                    return;
                                            }
                                            for (int j = 0; j < PlayerHandler.players.length; j++) {
                                                    if (PlayerHandler.players[j] != null) {
                                                            Client c2 = (Client) PlayerHandler.players[j];
                                                            c2.sendMessage(Message);
                                                    }
                                            }
                                            for (int i = 0; i < Config.MAX_PLAYERS; i++) {
                                                    if (PlayerHandler.players[i] != null) {
                                                            if (PlayerHandler.players[i].playerName
                                                                            .equalsIgnoreCase(jailedUser)) {
                                                                    Client c2 = (Client) PlayerHandler.players[i]; 
                                                                    c2.teleportToX = 3285;
                                                                    c2.teleportToY = 3020;
                                                                    c2.isJailed = true;
                                                                    c2.getItems().addItem(1265, 1);
                                                                    NPCHandler.getSingleton().spawnNpc(c2,3378, 3286, 3021-1, 0, 0, 120, 30, 200, 200, false, true);
                                                                    c2.sendMessage("You have been jailed by "
                                                                                    + c.playerName + ".");
                                                                    c.sendMessage("Successfully Jailed "
                                                                                    + c2.playerName + ".");
                                                            }
                                                    }
                                            }
                                    } catch (Exception e) {
                                            c.sendMessage("Player Must Be Offline.");
                                    }
                            }
     
     
                            if (command.startsWith("mute")
                                            && c.isDonator <= 2) {
                                    try {
                                            String playerToBan = command.substring(5);
                                            String Message = "[@blu@Punishment@bla@]@dre@"+c.playerName+" has muted "+playerToBan+".";
     
                                            for (int j = 0; j < PlayerHandler.players.length; j++) {
                                                    if (PlayerHandler.players[j] != null) {
                                                            Client c2 = (Client) PlayerHandler.players[j];
                                                            c2.sendMessage(Message);
                                                    }
                                            }
                                            Connection.addNameToMuteList(playerToBan);
                                            for (int i = 0; i < Config.MAX_PLAYERS; i++) {
                                                    if (PlayerHandler.players[i] != null) {
                                                            if (PlayerHandler.players[i].playerName
                                                                            .equalsIgnoreCase(playerToBan)) {
                                                                    Client c2 = (Client) PlayerHandler.players[i];
                                                                    c2.sendMessage("You have been muted by: "
                                                                                    + c.playerName);
                                                                    break;
                                                            }
                                                    }
                                            }
                                    } catch (Exception e) {
                                            c.sendMessage("Player Must Be Offline.");
                                    }
                            }
                            if (command.startsWith("ipmute")
                                            && c.isDonator <= 2) {
                                    try {
                                            String playerToBan = command.substring(7);
                                            String Message = "[@blu@Punishment@bla@]@dre@"+c.playerName+" has IP Muted "+playerToBan+".";
     
                                            for (int j = 0; j < PlayerHandler.players.length; j++) {
                                                    if (PlayerHandler.players[j] != null) {
                                                            Client c2 = (Client) PlayerHandler.players[j];
                                                            c2.sendMessage(Message);
                                                    }
                                            }
                                            for (int i = 0; i < Config.MAX_PLAYERS; i++) {
                                                    if (PlayerHandler.players[i] != null) {
                                                            if (PlayerHandler.players[i].playerName
                                                                            .equalsIgnoreCase(playerToBan)) {
                                                                    Connection
                                                                    .addIpToMuteList(PlayerHandler.players[i].connectedFrom);
                                                                    c.sendMessage("You have IP Muted the user: "
                                                                                    + PlayerHandler.players[i].playerName);
                                                                    Client c2 = (Client) PlayerHandler.players[i];
                                                                    c2.sendMessage("You have been muted by: "
                                                                                    + c.playerName);
                                                                    break;
                                                            }
                                                    }
                                            }
                                    } catch (Exception e) {
                                            c.sendMessage("Player Must Be Offline.");
                                    }
                            }
                    if (command.startsWith("unipmute")
                                    && c.isDonator <= 2) {
                            c.said = 0;
                            try {
                                    String playerToBan = command.substring(9);
                                    String Message = "@dre@"+c.playerName+" has un-IP muted "+playerToBan+".";
                                    for (int j = 0; j < PlayerHandler.players.length; j++) {
                                            if (PlayerHandler.players[j] != null) {
                                                    Client c2 = (Client) PlayerHandler.players[j];
                                                    c2.sendMessage(Message);
                                            }
                                    }
                                    for (int i = 0; i < Config.MAX_PLAYERS; i++) {
                                            if (PlayerHandler.players[i] != null) {
                                                    if (PlayerHandler.players[i].playerName
                                                                    .equalsIgnoreCase(playerToBan)) {
                                                            Connection
                                                            .unIPMuteUser(PlayerHandler.players[i].connectedFrom);
                                                            c.sendMessage("You have Un Ip-Muted the user: "
                                                                            + PlayerHandler.players[i].playerName);
                                                            break;
                                                    }
                                            }
                                    }
                            } catch (Exception e) {
                                    c.sendMessage("Player Must Be Offline.");
                            }
                    }
            }
           
            public static void superAdminCommands(Client c, String command) {                if(c.playerRights >= 3) {
                            if (command.startsWith("anim") && c.playerRights >= 3) {
                                    String[] args = command.split(" ");
                                    c.startAnimation(Integer.parseInt(args[1]));
                                    c.getPA().requestUpdates();
                            }
     
                            if (command.equals("spec") && c.playerRights >= 3) {
                                    c.getItems().updateSpecialBar();
                                    if (!c.inWild())
                                            c.specAmount += 10.0;
                            }
                            if (command.startsWith("object") && c.playerRights >= 3) {
                                    String[] args = command.split(" ");
                                    c.getPA().object(Integer.parseInt(args[1]), c.absX, c.absY, 0,10);
                            }
     
                            if (command.equals("gwd") && c.playerRights >= 3) {
                                    c.getPA().movePlayer(2905, 3611, 4);
                            }
                            if (command.equals("gwd2") && c.playerRights >= 3) {
                                    c.getPA().movePlayer(2905, 3611, 8);
                            }
                            if(command.equals("gwd3") && c.playerRights >= 3) {
                                    c.getPA().movePlayer(2905, 3611, 12);
                            }
     
                            if (command.startsWith("starter") && c.playerRights >= 3) {
                                    c.getDH().sendDialogues(100, 945);
                            }
                            if (command.equalsIgnoreCase("mypos") && c.playerRights >= 3) {
                                    c.sendMessage("X: " + c.absX);
                                    c.sendMessage("Y: " + c.absY);
                            }
                            if (command.startsWith("reloadshops") && c.playerRights >= 3) {
                                    ShopHandler.getSingleton();
                            }
     
                            if (command.startsWith("interface") && c.playerRights >= 3) {
                                    String[] args = command.split(" ");
                                    c.getPA().showInterface(Integer.parseInt(args[1]));
                            }
                            if (command.startsWith("gfx") && c.playerRights >= 3) {
                                    String[] args = command.split(" ");
                                    c.gfx0(Integer.parseInt(args[1]));
                            }
     
     
                            if (command.startsWith("item") && c.playerRights >= 3) {
                                    try {
                                            String[] args = command.split(" ");
                                            if (args.length == 3) {
                                                    int newItemID = Integer.parseInt(args[1]);
                                                    int newItemAmount = Integer.parseInt(args[2]);
                                                    if ((newItemID <= 20000) && (newItemID >= 0)) {
                                                            c.getItems().addItem(newItemID, newItemAmount);
                                                    } else {
                                                            c.sendMessage("No such item.");
                                                    }
                                            } else {
                                                    c.sendMessage("Use as ::item 995 200 for example 200 gp");
                                            }
                                    } catch (Exception e) {
     
                                    }
                            }
     
                            if (command.startsWith("givedonor") && c.playerRights >= 3 && command.charAt(10) == ' ') {
                                    try {
                                            String playerToG = command.substring(10);
                                            for (int i = 0; i < Config.MAX_PLAYERS; i++) {
                                                    if (PlayerHandler.players[i] != null) {
                                                            if (PlayerHandler.players[i].playerName
                                                                            .equalsIgnoreCase(playerToG)) {
                                                                    PlayerHandler.players[i].pcPoints += 1;
                                                                    c.sendMessage("You have given  "
                                                                                    + PlayerHandler.players[i].playerName
                                                                                    + "Donator Rank Cfrom: "
                                                                                    + PlayerHandler.players[i].connectedFrom);
                                                                    PlayerHandler.players[i].isDonator = 1;
                                                            }
                                                    }
                                            }
                                    } catch (Exception e) {
                                            c.sendMessage("Player Must Be Offline.");
                                    }
                            }
     
                            if (command.startsWith("interface") && c.playerRights >= 3) {
                                    try {
                                            String[] args = command.split(" ");
                                            int a = Integer.parseInt(args[1]);
                                            c.getPA().showInterface(a);
                                    } catch (Exception e) {
                                            c.sendMessage("::interface ####");
                                    }
                            }
     
     
                            if (command.startsWith("tele") && c.playerRights >= 3) {
                                    String[] arg = command.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);
                            }
                    }
            }
           
            public static void ownerCommands(Client c, String command) {               
                    if (c.playerRights >= 4) {
                            if (command.startsWith("restart")) {
                                    for (Player p : PlayerHandler.players) {
                                            Client d = (Client) p;
                                            if (p == null)
                                                    continue;
                                            d.getTradeAndDuel().declineTrade();
                                            PlayerSave.saveGame((Client) p);
                                    }
                                    System.exit(0);
                            }
                    }
     
     
                   
                    if (command.startsWith("cmb")) {
                            try {
                                    String[] args = command.split(" ");
                                    c.newCombat = Integer.parseInt(args[1]);
                                    c.newCmb = true;
                                    c.updateRequired = true;
                                    c.setAppearanceUpdateRequired(true);
                            } catch (Exception e) {
                            }
                    }
     
     
                    if(command.startsWith("pnpc")) {
                            int npc = Integer.parseInt(command.substring(5));
                            if(npc < 9999) {
                                    c.npcId2 = npc;
                                    c.isNpc = true;
                                    c.updateRequired = true;
                                    c.appearanceUpdateRequired = true;
                            }
                    }      
     
                    if(command.startsWith("unpc")) {
                            c.isNpc = false;
                            c.updateRequired = true;
                            c.appearanceUpdateRequired = true;
                    }
     
                    if (command.startsWith("reloaddrops") && c.playerRights == 4) {
                            Server.npcDrops = null;
                            Server.npcDrops = new server.model.npcs.NPCDrops();
                            for (int j = 0; j < PlayerHandler.players.length; j++) {
                                    if (PlayerHandler.players[j] != null) {
                                            Client c2 = (Client) PlayerHandler.players[j];
                                            c2.sendMessage("[" + c.playerName + "] "
                                                            + "NPC Drops have been reloaded.");
                                    }
                            }
                    }
                   
     
                    if (command.startsWith("update")) {
                            String[] args = command.split(" ");
                            int a = Integer.parseInt(args[1]);
                            PlayerHandler.updateSeconds = a;
                            PlayerHandler.updateAnnounced = false;
                            PlayerHandler.updateRunning = true;
                            PlayerHandler.updateStartTime = System.currentTimeMillis();
                            c.declinePlayerTrades();
                    }
                   
                    if (command.startsWith("npc")) {
                            try {
                                    int newNPC = Integer.parseInt(command.substring(4));
                                    if (newNPC > 0) {
                                            NPCHandler.getSingleton().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 (command.startsWith("promote") && command.charAt(8) == ' ') { // use as ::prm name
                            try {
                                    String playerToG = command.substring(8);
                                    for (int i = 0; i < Config.MAX_PLAYERS; i++) {
                                            if (PlayerHandler.players[i] != null) {
                                                    if (PlayerHandler.players[i].playerName
                                                                    .equalsIgnoreCase(playerToG)) {
                                                            PlayerHandler.players[i].playerRights += 1;
                                                            c.sendMessage("You have given  "
                                                                            + PlayerHandler.players[i].playerName
                                                                            + " A Promotion Cfrom: "
                                                                            + PlayerHandler.players[i].connectedFrom);
                                                    }
                                            }
                                    }
                            } catch (Exception e) {
                                    c.sendMessage("Player Must Be Offline.");
                            }
                    }
                   
                    if (command.startsWith("demote") && c.playerRights == 4
                                    && c.playerName.equalsIgnoreCase("tyluur")
                                    || c.playerName.equalsIgnoreCase("tyluur v2")
                                    && command.charAt(7) == ' ') { // use as ::prm name
                            try {
                                    String playerToG = command.substring(7);
                                    for (int i = 0; i < Config.MAX_PLAYERS; i++) {
                                            if (PlayerHandler.players[i] != null) {
                                                    if (PlayerHandler.players[i].playerName
                                                                    .equalsIgnoreCase(playerToG)) {
                                                            PlayerHandler.players[i].playerRights = 0;
                                                            c.sendMessage("You have given  "
                                                                            + PlayerHandler.players[i].playerName
                                                                            + " A @red@demotion Cfrom: "
                                                                            + PlayerHandler.players[i].connectedFrom);
     
                                                            PlayerHandler.players[i].disconnected = true;
                                                    }
                                            }
                                    }
                            } catch (Exception e) {
                                    c.sendMessage("Player Must Be Offline.");
                            }
                    }
                   
     
     
                    if (command.startsWith("kick")) {
                            try {
                                    String playerToBan = command.substring(5);
                                    for (int i = 0; i < Config.MAX_PLAYERS; i++) {
                                            if (PlayerHandler.players[i] != null) {
                                                    if (PlayerHandler.players[i].playerName
                                                                    .equalsIgnoreCase(playerToBan)) {
                                                            PlayerHandler.players[i].disconnected = true;
                                                    }
                                            }
                                    }
                            } catch (Exception e) {
                                    c.sendMessage("Player Must Be Offline.");
                            }
                    }
     
                    if (command.startsWith("getip") && c.playerRights == 4 && command.charAt(6) == ' ') { // use as ::ssp name
                            try {
                                    String playerToG = command.substring(6);
                                    for (int i = 0; i < Config.MAX_PLAYERS; i++) {
                                            if (PlayerHandler.players[i] != null) {
                                                    if (PlayerHandler.players[i].playerName
                                                                    .equalsIgnoreCase(playerToG)) {
                                                            c.sendMessage("The IP of "
                                                                            + PlayerHandler.players[i].playerName
                                                                            + " is "
                                                                            + PlayerHandler.players[i].connectedFrom);
                                                    }
                                            }
                                    }
                            } catch (Exception e) {
                                    c.sendMessage("Player Must Be Offline.");
                            }
                    }
     
                   
                    /*if(playerCommand.startsWith("christmas")) {
                       if (!c.inWild())
                            c.teleportToX = 2007; c.teleportToY = 4430;
                            c.sendMessage("You have been teleported to the christmas event");
                    }*/
                    if (command.equals("runelocus")) {
                            for (int j = 0; j < PlayerHandler.players.length; j++)
                                    if (PlayerHandler.players[j] != null) {
                                            Client c2 = (Client) PlayerHandler.players[j];
                                            c2.getPA()
                                            .sendFrame126(
                                                            "www.runelocus.com/toplist/index.php?action=vote&id=102",
                                                            12000);
                                    }
                    }
                    if (command.startsWith("olevel")) {
                            try {
                                    String[] args = command.split(" ");
                                    int skill = Integer.parseInt(args[1]);
                                    int level = Integer.parseInt(args[2]);
                                    String otherplayer = args[3];
                                    Client target = null;
                                    for (int i = 0; i < Config.MAX_PLAYERS; i++) {
                                            PlayerHandler.getSingleton();
                                            if (PlayerHandler.players[i] != null) {
                                                    PlayerHandler.getSingleton();
                                                    if (PlayerHandler.players[i].playerName
                                                                    .equalsIgnoreCase(otherplayer)) {
                                                            PlayerHandler.getSingleton();
                                                            target = (Client) PlayerHandler.players[i];
                                                            break;
                                                    }
                                            }
                                    }
                                    if (target == null) {
                                            c.sendMessage("Player doesn't exist.");
                                            return;
                                    }
                                    if (level > 99)
                                            level = 99;
                                    else if (level <= 0)
                                            level = 1;
                                    target.playerXP[skill] = c.getPA().getXPForLevel(level) + 5;
                                    target.playerLevel[skill] = c.getPA().getLevelForXP(
                                                    c.playerXP[skill]);
                                    target.getPA().refreshSkill(skill);
                            } catch (Exception e) {
                                    c.sendMessage("Use as ::olevel SKILLID LEVEL PLAYERNAME.");
                            }
                    }
                   
            }
           
    }
     

  7. #7  
    Banned
    Join Date
    Sep 2011
    Posts
    40
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    Worked, Legacy. What'd you do?
     

  8. #8  
    Registered Member
    Join Date
    Sep 2011
    Posts
    100
    Thanks given
    5
    Thanks received
    5
    Rep Power
    29
    Quote Originally Posted by I am Hardcore View Post
    Worked, Legacy. What'd you do?
    Each time readString() is called the caret is changed(normally to a higher value). You were calling it multiple times. After a while the caret will go over the data array's length causing an array out of bounds exception. Not to mention every time you call it, it'll have an different value.

    Since you've already called readString() once I added an argument to each of the methods which would be the command.
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Command handling through LUA
    By Shoes in forum Show-off
    Replies: 27
    Last Post: 05-01-2011, 07:31 PM
  2. Command Handling (enums)
    By Greyfield in forum Snippets
    Replies: 2
    Last Post: 02-12-2010, 03:27 AM
  3. [Emu]Error handling
    By MrVidel in forum Help
    Replies: 0
    Last Post: 01-31-2010, 03:29 AM
  4. Error handling packet 185?
    By Skitzo in forum Help
    Replies: 0
    Last Post: 05-10-2009, 01:52 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •