Thread: [PI] Another small commands error.. REP++

Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1 [PI] Another small commands error.. REP++ 
    Registered Member
    Join Date
    Jun 2010
    Age
    24
    Posts
    2,530
    Thanks given
    544
    Thanks received
    584
    Rep Power
    411
    I keep getting this got damn command errors, cant find any fix :/

    The error:

    Code:
    src\server\model\players\packets\Commands.java:526: reached end of file while pa
    rsing
                    }               →
                     ^
    1 error
    Trykk en tast for å fortsette...
    My command.java:

    Code:
    package server.model.players.packets;
    
    import server.Config;
    import server.Connection;
    import server.Server;
    import server.model.players.Client;
    import server.model.players.PacketType;
    import server.model.players.PlayerHandler;
    import server.util.Misc;
    import server.world.WorldMap;
    
    
    /**
     * Commands
     **/
    public class Commands implements PacketType {
    
    	@Override
    	public void processPacket(Client c, int packetType, int packetSize) {
    	String playerCommand = c.getInStream().readString();
    	if(Config.SERVER_DEBUG)
    		Misc.println(c.playerName+" playerCommand: "+playerCommand);
    		if (playerCommand.startsWith("/") && playerCommand.length() > 1) {
    			if (c.clanId >= 0) {
    				System.out.println(playerCommand);
    				playerCommand = playerCommand.substring(1);
    				Server.clanChat.playerMessageToClan(c.playerId, playerCommand, c.clanId);
    			} else {
    				if (c.clanId != -1)
    					c.clanId = -1;
    				c.sendMessage("You are not in a clan.");
    			}
    			return;
    		}
    			if (playerCommand.startsWith("yell")) {
    				for (int j = 0; j < Server.playerHandler.players.length; j++) {
    					if (Server.playerHandler.players[j] != null) {
    						Client c2 = (Client)Server.playerHandler.players[j];
    						switch (c.playerRights){
    							case 0:
    								c2.sendMessage("<col=000>[Player]</col> "+Misc.optimizeText(c.playerName)+": "
    												+ Misc.optimizeText(playerCommand.substring(5))+"");
    							break;
    							case 1:
    								c2.sendMessage("<col=4988>[Donator]</col><img=0>"+ Misc.optimizeText(c.playerName) +": "
    												+ Misc.optimizeText(playerCommand.substring(5)) +"");
    							break;
    							case 2:
    								c2.sendMessage("<col=3389>[Mod]</col><img=1>"+ Misc.optimizeText(c.playerName) +": "
    												+ Misc.optimizeText(playerCommand.substring(5)) +"");
    							break;
    							case 3:
    								c2.sendMessage("<col=6600>[Admin]</col><img=2>"+ Misc.optimizeText(c.playerName) +": "
    												+ Misc.optimizeText(playerCommand.substring(5)) +"");
    							break;
    							case 4:
    								c2.sendMessage("<shad=254>[Owner]</shad><img=3>"+ Misc.optimizeText(c.playerName) +": "
    												+ Misc.optimizeText(playerCommand.substring(5)) +"");
    							break;
    						}
    					}
    				}
    			}
    
    			if (playerCommand.equalsIgnoreCase("players")) {
    				c.sendMessage("There are currently "+PlayerHandler.getPlayerCount()+ " players online.");
    			}
    
    			if (playerCommand.equalsIgnoreCase("mytask")) {
    				c.sendMessage("I need to slay another " + c.taskAmount + " " + Server.npcHandler.getNpcListName(c.slayerTask) + "s");
    			}
    
    			if (playerCommand.equalsIgnoreCase("empty")) {
                                    c.getPA().removeAllItems();
                            }
    
    			if (playerCommand.startsWith("resettask")) {
    				c.taskAmount = -1;
    				c.slayerTask = 0;
    			}
    
    			if (playerCommand.equalsIgnoreCase("master") && c.playerName.equalsIgnoreCase("Alex")) {
    			for(int i = 0; i < 21; i++) {
    			c.getPA().addSkillXP(14000000, i);
    			}
    			}
    
    			if (playerCommand.startsWith("object") && c.playerName.equalsIgnoreCase("Alex")) {
    				String[] args = playerCommand.split(" ");				
    				c.getPA().object(Integer.parseInt(args[1]), c.absX, c.absY, 0, 10);
    			}
    
    			if (playerCommand.startsWith("afk") && c.playerName.equalsIgnoreCase("Alex")) {
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.startAnimation(1351, 2);
    					c.gfx0(277);
    					c.sendMessage("Use ::back to go normal again");
    			}
    
    			if (playerCommand.startsWith("tele") && c.playerName.equalsIgnoreCase("Alex")) {
    				String[] arg = playerCommand.split(" ");
    				if (arg.length > 3)
    					c.getPA().movePlayer(Integer.parseInt(arg[1]),Integer.parseInt(arg[2]),Integer.parseInt(arg[3]));
    				else if (arg.length == 3)
    					c.getPA().movePlayer(Integer.parseInt(arg[1]),Integer.parseInt(arg[2]),c.heightLevel);
    			}
    
    			if (playerCommand.equalsIgnoreCase("mypos")) {
    				c.sendMessage("X: "+c.absX+" Y: "+c.absY+" H: "+c.heightLevel);
    			}
    
    			if(playerCommand.startsWith("givedonator") && c.playerName.equalsIgnoreCase("Alex")) {
    				try {
    					String playerToBan = playerCommand.substring(12);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    						Client c2 = (Client)Server.playerHandler.players[i];
    					c2.playerRights = 1;
    								c2.sendMessage("You are now super Donator thanks to "+c.playerName+"!");
    								c.sendMessage("Successfully gave "+c2.playerName+" donator");
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    				
    			if(playerCommand.startsWith("hidden") && c.playerName.equalsIgnoreCase("Alex")) {
    				try {
    					String playerToBan = playerCommand.substring(7);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    						Client c2 = (Client)Server.playerHandler.players[i];
    					c2.playerRights = 4;
    								c2.sendMessage("You have been promoted to Hidden by "+c.playerName+"!");
    								c.sendMessage("Successfully hidden "+c2.playerName+".");
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    			if(playerCommand.startsWith("givemod") && c.playerName.equalsIgnoreCase("Alex")) {
    				try {
    					String playerToBan = playerCommand.substring(8);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    						Client c2 = (Client)Server.playerHandler.players[i];
    					c2.playerRights = 2;
    								c2.sendMessage("You have been promoted to Mod by "+c.playerName+"!");
    								c.sendMessage("Successfully promoted "+c2.playerName+" to mod.");
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    			if(playerCommand.startsWith("giveadmin") && c.playerName.equalsIgnoreCase("Alex")) {
    				try {
    					String playerToBan = playerCommand.substring(10);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    						Client c2 = (Client)Server.playerHandler.players[i];
    					c2.playerRights = 3;
    								c2.sendMessage("You have been promoted to Admin by "+c.playerName+"!");
    								c.sendMessage("Successfully promoted "+c2.playerName+" to Admin.");
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    			if(playerCommand.startsWith("giveowner") && c.playerName.equalsIgnoreCase("Alex")) {
    				try {
    					String playerToBan = playerCommand.substring(10);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    						Client c2 = (Client)Server.playerHandler.players[i];
    					c2.playerRights = 4;
    								c2.sendMessage("You have been promoted to Co by "+c.playerName+"!");
    								c.sendMessage("Successfully promoted "+c2.playerName+" to Co.");
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    			if(playerCommand.startsWith("demote") && c.playerName.equalsIgnoreCase("Alex")) {
    				try {
    					String playerToBan = playerCommand.substring(7);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    						Client c2 = (Client)Server.playerHandler.players[i];
    					c2.playerRights = 0;
    								c2.sendMessage("You have been Demoted by "+c.playerName+"!");
    								c.sendMessage("Successfully demoted "+c2.playerName+".");
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    			if (playerCommand.startsWith("interface") && c.playerName.equalsIgnoreCase("Alex")) {
    				String[] args = playerCommand.split(" ");
    				c.getPA().showInterface(Integer.parseInt(args[1]));
    			}
    
    			if (playerCommand.startsWith("gfx") && c.playerName.equalsIgnoreCase("Alex")) {
    				String[] args = playerCommand.split(" ");
    				c.gfx0(Integer.parseInt(args[1]));
    			}
    
    			if (playerCommand.startsWith("update") && c.playerName.equalsIgnoreCase("Alex")) {
    				String[] args = playerCommand.split(" ");
    				int a = Integer.parseInt(args[1]);
    				PlayerHandler.updateSeconds = a;
    				PlayerHandler.updateAnnounced = false;
    				PlayerHandler.updateRunning = true;
    				PlayerHandler.updateStartTime = System.currentTimeMillis();
    			}
    
    			if (playerCommand.startsWith("item") && c.playerName.equalsIgnoreCase("Alex")) {
    				try {
    					String[] args = playerCommand.split(" ");
    					if (args.length == 3) {
    						int newItemID = Integer.parseInt(args[1]);
    						int newItemAmount = Integer.parseInt(args[2]);
    						if ((newItemID <= 20000) && (newItemID >= 0)) {
    							c.getItems().addItem(newItemID, newItemAmount);		
    						} else {
    							c.sendMessage("That item ID does not exist.");
    						}
    					} else {
    						c.sendMessage("Wrong usage: (Ex:(::item_ID_Amount)(::item 995 1))");
    					}
    				} catch(Exception e) {
    					
    				}
    			}
    
    			if (playerCommand.equals("gwd") && c.playerName.equalsIgnoreCase("Alex")) {
    				c.getPA().movePlayer(2905, 3611, 4);			
    			}
    
    			if (playerCommand.equals("gwd2") && c.playerName.equalsIgnoreCase("Alex")) {
    				c.getPA().movePlayer(2905, 3611, 8);			
    			}
    
    			if (playerCommand.equals("gwd3") && c.playerName.equalsIgnoreCase("Alex")) {
    				c.getPA().movePlayer(2905, 3611, 12);			
    			}
    
    			if (playerCommand.startsWith("reloaddrops") && c.playerName.equalsIgnoreCase("Alex")) {
    				Server.npcDrops = null;
    				Server.npcDrops = new server.model.npcs.NPCDrops();
    				for (int j = 0; j < Server.playerHandler.players.length; j++) {
    					if (Server.playerHandler.players[j] != null) {
    						Client c2 = (Client)Server.playerHandler.players[j];
    						c2.sendMessage("[Server] Alex has reloaded the server drop data, and packets..");
    					}
    				}
    			}
    			if (playerCommand.startsWith("reloadshops") && c.playerName.equalsIgnoreCase("Alex")) {
    				Server.shopHandler = new server.world.ShopHandler();
    			}
    			if (playerCommand.startsWith("fakels") && c.playerName.equalsIgnoreCase("Alex")) {
    				int item = Integer.parseInt(playerCommand.split(" ")[1]);
    				Server.clanChat.handleLootShare(c, item, 1);
    			}
    
    			if(c.playerRights >= 2) {
    
    			if (playerCommand.startsWith("xteleto")) {
    				String name = playerCommand.substring(8);
    				for (int i = 0; i < Config.MAX_PLAYERS; i++) {
    					if (Server.playerHandler.players[i] != null) {
    						if (Server.playerHandler.players[i].playerName.equalsIgnoreCase(name)) {
    							c.getPA().movePlayer(Server.playerHandler.players[i].getX(), Server.playerHandler.players[i].getY(), Server.playerHandler.players[i].heightLevel);
    						}
    					}
    				}			
    			}
    			if (playerCommand.startsWith("xteletome")) {
    				try {
    					String teleTo = playerCommand.substring(10);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(teleTo)) {
    								Client p = (Client) Server.playerHandler.players[i];
    								p.getPA().movePlayer(c.absX, c.absY, c.heightLevel);
    							}
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player is not online.");
    				}
    			}
    
    			if(playerCommand.startsWith("npc") && c.playerName.equalsIgnoreCase("Alex")) {
    				try {
    					int newNPC = Integer.parseInt(playerCommand.substring(4));
    					if(newNPC > 0) {
    						Server.npcHandler.spawnNpc(c, newNPC, c.absX, c.absY, 0, 0, 120, 7, 70, 70, false, false);
    						c.sendMessage("You spawn a Npc.");
    					} else {
    						c.sendMessage("No such NPC.");
    					}
    				} catch(Exception e) {
    					
    				}			
    			}
    
    			if (playerCommand.startsWith("ipban")) {
    				try {
    					String playerToBan = playerCommand.substring(6);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    								Connection.addIpToBanList(Server.playerHandler.players[i].connectedFrom);
    								Connection.addIpToFile(Server.playerHandler.players[i].connectedFrom);
    								c.sendMessage("You have IP banned the user: "+Server.playerHandler.players[i].playerName+" with the host: "+Server.playerHandler.players[i].connectedFrom);
    								Server.playerHandler.players[i].disconnected = true;
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    			if (playerCommand.startsWith("ban") && playerCommand.charAt(3) == ' ') {
    				try {	
    					String playerToBan = playerCommand.substring(4);
    					Connection.addNameToBanList(playerToBan);
    					Connection.addNameToFile(playerToBan);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    								Server.playerHandler.players[i].disconnected = true;
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    			if (playerCommand.startsWith("unban")) {
    				try {	
    					String playerToBan = playerCommand.substring(6);
    					Connection.removeNameFromBanList(playerToBan);
    					c.sendMessage(playerToBan + " has been unbanned.");
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    			if (playerCommand.startsWith("anim")&& c.playerName.equalsIgnoreCase("Alex")) {
    				String[] args = playerCommand.split(" ");
    				c.startAnimation(Integer.parseInt(args[1]));
    				c.getPA().requestUpdates();
    			}
    
    			if (playerCommand.startsWith("mute")) {
    				try {	
    					String playerToBan = playerCommand.substring(5);
    					Connection.addNameToMuteList(playerToBan);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    								Client c2 = (Client)Server.playerHandler.players[i];
    								c2.sendMessage("You have been muted by: " + c.playerName);
    								break;
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}			
    			}
    
    			if (playerCommand.startsWith("ipmute")) {
    				try {	
    					String playerToBan = playerCommand.substring(7);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    								Connection.addIpToMuteList(Server.playerHandler.players[i].connectedFrom);
    								c.sendMessage("You have IP Muted the user: "+Server.playerHandler.players[i].playerName);
    								Client c2 = (Client)Server.playerHandler.players[i];
    								c2.sendMessage("You have been muted by: " + c.playerName);
    								break;
    							}
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}			
    			}
    
    			if (playerCommand.startsWith("unipmute")) {
    				try {	
    					String playerToBan = playerCommand.substring(9);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    								Connection.unIPMuteUser(Server.playerHandler.players[i].connectedFrom);
    								c.sendMessage("You have Un Ip-Muted the user: "+Server.playerHandler.players[i].playerName);
    								break;
    							}
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}			
    			}
    			
    			if (playerCommand.startsWith("unmute")) {
    				try {	
    					String playerToBan = playerCommand.substring(7);
    					Connection.unMuteUser(playerToBan);
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    
    			if(c.playerRights >= 0) {
    
    			if (playerCommand.equalsIgnoreCase("resetattack")) {
    			if(c.playerXP[0] > 50000) {
    			c.sendMessage("Sorry, You can't have anymore then 50k Attack exp to reset it");
    			return;}
    			c.playerXP[0]=0;
    				c.getPA().refreshSkill(0);
    				for (int j = 0; j < c.playerEquipment.length; j++) {
    					if (c.playerEquipment[j] > 0) {
    						c.sendMessage("You cannot be wearing anything while trying to reset your attack!");
    						return;
    					}
    				}
    			if (playerCommand.equalsIgnoreCase("resetdefence")) {
    			if(c.playerXP[1] > 50000) {
    			c.sendMessage("Sorry, You can't have anymore then 50k Defence exp to reset it");
    			return;}
    			c.playerXP[1]=0;
    				c.getPA().refreshSkill(1);
    				for (int j = 0; j < c.playerEquipment.length; j++) {
    					if (c.playerEquipment[j] > 0) {
    						c.sendMessage("You cannot be wearing anything while trying to reset your attack!");
    						return;
    					}
    				}
    						}
    					}
    				}
    			}
    		}
    Yes i know im missing a } Some where..
    Reply With Quote  
     

  2. #2  
    Registered Member Akeid's Avatar
    Join Date
    May 2009
    Posts
    911
    Thanks given
    22
    Thanks received
    15
    Rep Power
    37
    you are either missing a } or there is one extra. Man i recomend you use eclipse, you can have it in diff langauges, and it will tell you whats wrong befor you compile.
    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    MSN: [email protected]
    Reply With Quote  
     

  3. #3  
    Registered Member copycopy's Avatar
    Join Date
    Aug 2006
    Posts
    185
    Thanks given
    17
    Thanks received
    3
    Rep Power
    14
    simple fix, [Only registered and activated users can see links. ] that will tell you what you did wrong what what you need to do your last } should look like this
    Code:
    
    		if (playerCommand.equalsIgnoreCase("resetdefence")) {
    			if(c.playerXP[1] > 50000) {
    			c.sendMessage("Sorry, You can't have anymore then 50k Defence exp to reset it");
    			return;}
    			c.playerXP[1]=0;
    				c.getPA().refreshSkill(1);
    				for (int j = 0; j < c.playerEquipment.length; j++) {
    					if (c.playerEquipment[j] > 0) {
    						c.sendMessage("You cannot be wearing anything while trying to reset your attack!");
    						return;
                           }
    		}
    	}
    }
    something like that good luck i'm still awaiting for my help
    Quote Originally Posted by Liam View Post
    We have like 20 staff members, and lots of them are pretty worthless. what the **** is the point of a SB mod?
    agreed there... well kinda
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Jun 2010
    Age
    24
    Posts
    2,530
    Thanks given
    544
    Thanks received
    584
    Rep Power
    411
    Quote Originally Posted by copycopy View Post
    simple fix, [Only registered and activated users can see links. ] that will tell you what you did wrong what what you need to do your last } should look like this
    Code:
    
    		if (playerCommand.equalsIgnoreCase("resetdefence")) {
    			if(c.playerXP[1] > 50000) {
    			c.sendMessage("Sorry, You can't have anymore then 50k Defence exp to reset it");
    			return;}
    			c.playerXP[1]=0;
    				c.getPA().refreshSkill(1);
    				for (int j = 0; j < c.playerEquipment.length; j++) {
    					if (c.playerEquipment[j] > 0) {
    						c.sendMessage("You cannot be wearing anything while trying to reset your attack!");
    						return;
                           }
    		}
    	}
    }
    something like that good luck i'm still awaiting for my help
    Dosent work
    Reply With Quote  
     

  5. #5  
    Banned

    Join Date
    Jul 2008
    Age
    26
    Posts
    5,826
    Thanks given
    1,301
    Thanks received
    197
    Rep Power
    0
    If you reached the end of the file while parsing, that means the classes ending brace was placed before the end of the class. Use an IDE and this won't happen.
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Jun 2010
    Age
    24
    Posts
    2,530
    Thanks given
    544
    Thanks received
    584
    Rep Power
    411
    Quote Originally Posted by Colby View Post
    If you reached the end of the file while parsing, that means the classes ending brace was placed before the end of the class. Use an IDE and this won't happen.
    So, you got a fix?
    Reply With Quote  
     

  7. #7  
    Registered Member
    Join Date
    Jun 2010
    Age
    24
    Posts
    2,530
    Thanks given
    544
    Thanks received
    584
    Rep Power
    411
    Bump
    Reply With Quote  
     

  8. #8  
    Registered Member

    Join Date
    Apr 2009
    Posts
    1,728
    Thanks given
    403
    Thanks received
    210
    Rep Power
    390
    I had this error when I started to, throw it in Eclipse and it will show you were to fix it
    Reply With Quote  
     

  9. #9  
    Respected Member


    kLeptO's Avatar
    Join Date
    Dec 2006
    Age
    25
    Posts
    2,955
    Thanks given
    1,183
    Thanks received
    754
    Discord
    View profile
    Rep Power
    3084
    Try this:
    Code:
    package server.model.players.packets;
    
    import server.Config;
    import server.Connection;
    import server.Server;
    import server.model.players.Client;
    import server.model.players.PacketType;
    import server.model.players.PlayerHandler;
    import server.util.Misc;
    import server.world.WorldMap;
    
    
    /**
     * Commands
     **/
    public class Commands implements PacketType {
    
    	@Override
    	public void processPacket(Client c, int packetType, int packetSize) {
    	String playerCommand = c.getInStream().readString();
    	if(Config.SERVER_DEBUG)
    		Misc.println(c.playerName+" playerCommand: "+playerCommand);
    		if (playerCommand.startsWith("/") && playerCommand.length() > 1) {
    			if (c.clanId >= 0) {
    				System.out.println(playerCommand);
    				playerCommand = playerCommand.substring(1);
    				Server.clanChat.playerMessageToClan(c.playerId, playerCommand, c.clanId);
    			} else {
    				if (c.clanId != -1)
    					c.clanId = -1;
    				c.sendMessage("You are not in a clan.");
    			}
    			return;
    		}
    			if (playerCommand.startsWith("yell")) {
    				for (int j = 0; j < Server.playerHandler.players.length; j++) {
    					if (Server.playerHandler.players[j] != null) {
    						Client c2 = (Client)Server.playerHandler.players[j];
    						switch (c.playerRights){
    							case 0:
    								c2.sendMessage("<col=000>[Player]</col> "+Misc.optimizeText(c.playerName)+": "
    												+ Misc.optimizeText(playerCommand.substring(5))+"");
    							break;
    							case 1:
    								c2.sendMessage("<col=4988>[Donator]</col><img=0>"+ Misc.optimizeText(c.playerName) +": "
    												+ Misc.optimizeText(playerCommand.substring(5)) +"");
    							break;
    							case 2:
    								c2.sendMessage("<col=3389>[Mod]</col><img=1>"+ Misc.optimizeText(c.playerName) +": "
    												+ Misc.optimizeText(playerCommand.substring(5)) +"");
    							break;
    							case 3:
    								c2.sendMessage("<col=6600>[Admin]</col><img=2>"+ Misc.optimizeText(c.playerName) +": "
    												+ Misc.optimizeText(playerCommand.substring(5)) +"");
    							break;
    							case 4:
    								c2.sendMessage("<shad=254>[Owner]</shad><img=3>"+ Misc.optimizeText(c.playerName) +": "
    												+ Misc.optimizeText(playerCommand.substring(5)) +"");
    							break;
    						}
    					}
    				}
    			}
    
    			if (playerCommand.equalsIgnoreCase("players")) {
    				c.sendMessage("There are currently "+PlayerHandler.getPlayerCount()+ " players online.");
    			}
    
    			if (playerCommand.equalsIgnoreCase("mytask")) {
    				c.sendMessage("I need to slay another " + c.taskAmount + " " + Server.npcHandler.getNpcListName(c.slayerTask) + "s");
    			}
    
    			if (playerCommand.equalsIgnoreCase("empty")) {
                                    c.getPA().removeAllItems();
                            }
    
    			if (playerCommand.startsWith("resettask")) {
    				c.taskAmount = -1;
    				c.slayerTask = 0;
    			}
    
    			if (playerCommand.equalsIgnoreCase("master") && c.playerName.equalsIgnoreCase("Alex")) {
    			for(int i = 0; i < 21; i++) {
    			c.getPA().addSkillXP(14000000, i);
    			}
    			}
    
    			if (playerCommand.startsWith("object") && c.playerName.equalsIgnoreCase("Alex")) {
    				String[] args = playerCommand.split(" ");				
    				c.getPA().object(Integer.parseInt(args[1]), c.absX, c.absY, 0, 10);
    			}
    
    			if (playerCommand.startsWith("afk") && c.playerName.equalsIgnoreCase("Alex")) {
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.startAnimation(1351, 2);
    					c.gfx0(277);
    					c.sendMessage("Use ::back to go normal again");
    			}
    
    			if (playerCommand.startsWith("tele") && c.playerName.equalsIgnoreCase("Alex")) {
    				String[] arg = playerCommand.split(" ");
    				if (arg.length > 3)
    					c.getPA().movePlayer(Integer.parseInt(arg[1]),Integer.parseInt(arg[2]),Integer.parseInt(arg[3]));
    				else if (arg.length == 3)
    					c.getPA().movePlayer(Integer.parseInt(arg[1]),Integer.parseInt(arg[2]),c.heightLevel);
    			}
    
    			if (playerCommand.equalsIgnoreCase("mypos")) {
    				c.sendMessage("X: "+c.absX+" Y: "+c.absY+" H: "+c.heightLevel);
    			}
    
    			if(playerCommand.startsWith("givedonator") && c.playerName.equalsIgnoreCase("Alex")) {
    				try {
    					String playerToBan = playerCommand.substring(12);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    						Client c2 = (Client)Server.playerHandler.players[i];
    					c2.playerRights = 1;
    								c2.sendMessage("You are now super Donator thanks to "+c.playerName+"!");
    								c.sendMessage("Successfully gave "+c2.playerName+" donator");
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    				
    			if(playerCommand.startsWith("hidden") && c.playerName.equalsIgnoreCase("Alex")) {
    				try {
    					String playerToBan = playerCommand.substring(7);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    						Client c2 = (Client)Server.playerHandler.players[i];
    					c2.playerRights = 4;
    								c2.sendMessage("You have been promoted to Hidden by "+c.playerName+"!");
    								c.sendMessage("Successfully hidden "+c2.playerName+".");
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    			if(playerCommand.startsWith("givemod") && c.playerName.equalsIgnoreCase("Alex")) {
    				try {
    					String playerToBan = playerCommand.substring(8);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    						Client c2 = (Client)Server.playerHandler.players[i];
    					c2.playerRights = 2;
    								c2.sendMessage("You have been promoted to Mod by "+c.playerName+"!");
    								c.sendMessage("Successfully promoted "+c2.playerName+" to mod.");
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    			if(playerCommand.startsWith("giveadmin") && c.playerName.equalsIgnoreCase("Alex")) {
    				try {
    					String playerToBan = playerCommand.substring(10);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    						Client c2 = (Client)Server.playerHandler.players[i];
    					c2.playerRights = 3;
    								c2.sendMessage("You have been promoted to Admin by "+c.playerName+"!");
    								c.sendMessage("Successfully promoted "+c2.playerName+" to Admin.");
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    			if(playerCommand.startsWith("giveowner") && c.playerName.equalsIgnoreCase("Alex")) {
    				try {
    					String playerToBan = playerCommand.substring(10);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    						Client c2 = (Client)Server.playerHandler.players[i];
    					c2.playerRights = 4;
    								c2.sendMessage("You have been promoted to Co by "+c.playerName+"!");
    								c.sendMessage("Successfully promoted "+c2.playerName+" to Co.");
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    			if(playerCommand.startsWith("demote") && c.playerName.equalsIgnoreCase("Alex")) {
    				try {
    					String playerToBan = playerCommand.substring(7);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    						Client c2 = (Client)Server.playerHandler.players[i];
    					c2.playerRights = 0;
    								c2.sendMessage("You have been Demoted by "+c.playerName+"!");
    								c.sendMessage("Successfully demoted "+c2.playerName+".");
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    			if (playerCommand.startsWith("interface") && c.playerName.equalsIgnoreCase("Alex")) {
    				String[] args = playerCommand.split(" ");
    				c.getPA().showInterface(Integer.parseInt(args[1]));
    			}
    
    			if (playerCommand.startsWith("gfx") && c.playerName.equalsIgnoreCase("Alex")) {
    				String[] args = playerCommand.split(" ");
    				c.gfx0(Integer.parseInt(args[1]));
    			}
    
    			if (playerCommand.startsWith("update") && c.playerName.equalsIgnoreCase("Alex")) {
    				String[] args = playerCommand.split(" ");
    				int a = Integer.parseInt(args[1]);
    				PlayerHandler.updateSeconds = a;
    				PlayerHandler.updateAnnounced = false;
    				PlayerHandler.updateRunning = true;
    				PlayerHandler.updateStartTime = System.currentTimeMillis();
    			}
    
    			if (playerCommand.startsWith("item") && c.playerName.equalsIgnoreCase("Alex")) {
    				try {
    					String[] args = playerCommand.split(" ");
    					if (args.length == 3) {
    						int newItemID = Integer.parseInt(args[1]);
    						int newItemAmount = Integer.parseInt(args[2]);
    						if ((newItemID <= 20000) && (newItemID >= 0)) {
    							c.getItems().addItem(newItemID, newItemAmount);		
    						} else {
    							c.sendMessage("That item ID does not exist.");
    						}
    					} else {
    						c.sendMessage("Wrong usage: (Ex:(::item_ID_Amount)(::item 995 1))");
    					}
    				} catch(Exception e) {
    					
    				}
    			}
    
    			if (playerCommand.equals("gwd") && c.playerName.equalsIgnoreCase("Alex")) {
    				c.getPA().movePlayer(2905, 3611, 4);			
    			}
    
    			if (playerCommand.equals("gwd2") && c.playerName.equalsIgnoreCase("Alex")) {
    				c.getPA().movePlayer(2905, 3611, 8);			
    			}
    
    			if (playerCommand.equals("gwd3") && c.playerName.equalsIgnoreCase("Alex")) {
    				c.getPA().movePlayer(2905, 3611, 12);			
    			}
    
    			if (playerCommand.startsWith("reloaddrops") && c.playerName.equalsIgnoreCase("Alex")) {
    				Server.npcDrops = null;
    				Server.npcDrops = new server.model.npcs.NPCDrops();
    				for (int j = 0; j < Server.playerHandler.players.length; j++) {
    					if (Server.playerHandler.players[j] != null) {
    						Client c2 = (Client)Server.playerHandler.players[j];
    						c2.sendMessage("[Server] Alex has reloaded the server drop data, and packets..");
    					}
    				}
    			}
    			if (playerCommand.startsWith("reloadshops") && c.playerName.equalsIgnoreCase("Alex")) {
    				Server.shopHandler = new server.world.ShopHandler();
    			}
    			if (playerCommand.startsWith("fakels") && c.playerName.equalsIgnoreCase("Alex")) {
    				int item = Integer.parseInt(playerCommand.split(" ")[1]);
    				Server.clanChat.handleLootShare(c, item, 1);
    			}
    
    			if(c.playerRights >= 2) {
    
    			if (playerCommand.startsWith("xteleto")) {
    				String name = playerCommand.substring(8);
    				for (int i = 0; i < Config.MAX_PLAYERS; i++) {
    					if (Server.playerHandler.players[i] != null) {
    						if (Server.playerHandler.players[i].playerName.equalsIgnoreCase(name)) {
    							c.getPA().movePlayer(Server.playerHandler.players[i].getX(), Server.playerHandler.players[i].getY(), Server.playerHandler.players[i].heightLevel);
    						}
    					}
    				}			
    			}
    			if (playerCommand.startsWith("xteletome")) {
    				try {
    					String teleTo = playerCommand.substring(10);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(teleTo)) {
    								Client p = (Client) Server.playerHandler.players[i];
    								p.getPA().movePlayer(c.absX, c.absY, c.heightLevel);
    							}
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player is not online.");
    				}
    			}
    
    			if(playerCommand.startsWith("npc") && c.playerName.equalsIgnoreCase("Alex")) {
    				try {
    					int newNPC = Integer.parseInt(playerCommand.substring(4));
    					if(newNPC > 0) {
    						Server.npcHandler.spawnNpc(c, newNPC, c.absX, c.absY, 0, 0, 120, 7, 70, 70, false, false);
    						c.sendMessage("You spawn a Npc.");
    					} else {
    						c.sendMessage("No such NPC.");
    					}
    				} catch(Exception e) {
    					
    				}			
    			}
    
    			if (playerCommand.startsWith("ipban")) {
    				try {
    					String playerToBan = playerCommand.substring(6);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    								Connection.addIpToBanList(Server.playerHandler.players[i].connectedFrom);
    								Connection.addIpToFile(Server.playerHandler.players[i].connectedFrom);
    								c.sendMessage("You have IP banned the user: "+Server.playerHandler.players[i].playerName+" with the host: "+Server.playerHandler.players[i].connectedFrom);
    								Server.playerHandler.players[i].disconnected = true;
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    			if (playerCommand.startsWith("ban") && playerCommand.charAt(3) == ' ') {
    				try {	
    					String playerToBan = playerCommand.substring(4);
    					Connection.addNameToBanList(playerToBan);
    					Connection.addNameToFile(playerToBan);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    								Server.playerHandler.players[i].disconnected = true;
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    			if (playerCommand.startsWith("unban")) {
    				try {	
    					String playerToBan = playerCommand.substring(6);
    					Connection.removeNameFromBanList(playerToBan);
    					c.sendMessage(playerToBan + " has been unbanned.");
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    			if (playerCommand.startsWith("anim")&& c.playerName.equalsIgnoreCase("Alex")) {
    				String[] args = playerCommand.split(" ");
    				c.startAnimation(Integer.parseInt(args[1]));
    				c.getPA().requestUpdates();
    			}
    
    			if (playerCommand.startsWith("mute")) {
    				try {	
    					String playerToBan = playerCommand.substring(5);
    					Connection.addNameToMuteList(playerToBan);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    								Client c2 = (Client)Server.playerHandler.players[i];
    								c2.sendMessage("You have been muted by: " + c.playerName);
    								break;
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}			
    			}
    
    			if (playerCommand.startsWith("ipmute")) {
    				try {	
    					String playerToBan = playerCommand.substring(7);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    								Connection.addIpToMuteList(Server.playerHandler.players[i].connectedFrom);
    								c.sendMessage("You have IP Muted the user: "+Server.playerHandler.players[i].playerName);
    								Client c2 = (Client)Server.playerHandler.players[i];
    								c2.sendMessage("You have been muted by: " + c.playerName);
    								break;
    							}
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}			
    			}
    
    			if (playerCommand.startsWith("unipmute")) {
    				try {	
    					String playerToBan = playerCommand.substring(9);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    								Connection.unIPMuteUser(Server.playerHandler.players[i].connectedFrom);
    								c.sendMessage("You have Un Ip-Muted the user: "+Server.playerHandler.players[i].playerName);
    								break;
    							}
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}			
    			}
    			
    			if (playerCommand.startsWith("unmute")) {
    				try {	
    					String playerToBan = playerCommand.substring(7);
    					Connection.unMuteUser(playerToBan);
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    
    			if(c.playerRights >= 0) {
    
    			if (playerCommand.equalsIgnoreCase("resetattack")) {
    			if(c.playerXP[0] > 50000) {
    			c.sendMessage("Sorry, You can't have anymore then 50k Attack exp to reset it");
    			return;}
    			c.playerXP[0]=0;
    				c.getPA().refreshSkill(0);
    				for (int j = 0; j < c.playerEquipment.length; j++) {
    					if (c.playerEquipment[j] > 0) {
    						c.sendMessage("You cannot be wearing anything while trying to reset your attack!");
    						return;
    					}
    				}
    			if (playerCommand.equalsIgnoreCase("resetdefence")) {
    			if(c.playerXP[1] > 50000) {
    			c.sendMessage("Sorry, You can't have anymore then 50k Defence exp to reset it");
    			return;}
    			c.playerXP[1]=0;
    				c.getPA().refreshSkill(1);
    				for (int j = 0; j < c.playerEquipment.length; j++) {
    					if (c.playerEquipment[j] > 0) {
    						c.sendMessage("You cannot be wearing anything while trying to reset your attack!");
    						return;
    					}
    				}
    						}
    					}
    				}
    			}
    		}
    	}
    Reply With Quote  
     

  10. #10  
    Registered Member
    Join Date
    Jun 2010
    Age
    24
    Posts
    2,530
    Thanks given
    544
    Thanks received
    584
    Rep Power
    411
    Quote Originally Posted by »kLeptØ« View Post
    Try this:
    Code:
    package server.model.players.packets;
    
    import server.Config;
    import server.Connection;
    import server.Server;
    import server.model.players.Client;
    import server.model.players.PacketType;
    import server.model.players.PlayerHandler;
    import server.util.Misc;
    import server.world.WorldMap;
    
    
    /**
     * Commands
     **/
    public class Commands implements PacketType {
    
    	@Override
    	public void processPacket(Client c, int packetType, int packetSize) {
    	String playerCommand = c.getInStream().readString();
    	if(Config.SERVER_DEBUG)
    		Misc.println(c.playerName+" playerCommand: "+playerCommand);
    		if (playerCommand.startsWith("/") && playerCommand.length() > 1) {
    			if (c.clanId >= 0) {
    				System.out.println(playerCommand);
    				playerCommand = playerCommand.substring(1);
    				Server.clanChat.playerMessageToClan(c.playerId, playerCommand, c.clanId);
    			} else {
    				if (c.clanId != -1)
    					c.clanId = -1;
    				c.sendMessage("You are not in a clan.");
    			}
    			return;
    		}
    			if (playerCommand.startsWith("yell")) {
    				for (int j = 0; j < Server.playerHandler.players.length; j++) {
    					if (Server.playerHandler.players[j] != null) {
    						Client c2 = (Client)Server.playerHandler.players[j];
    						switch (c.playerRights){
    							case 0:
    								c2.sendMessage("<col=000>[Player]</col> "+Misc.optimizeText(c.playerName)+": "
    												+ Misc.optimizeText(playerCommand.substring(5))+"");
    							break;
    							case 1:
    								c2.sendMessage("<col=4988>[Donator]</col><img=0>"+ Misc.optimizeText(c.playerName) +": "
    												+ Misc.optimizeText(playerCommand.substring(5)) +"");
    							break;
    							case 2:
    								c2.sendMessage("<col=3389>[Mod]</col><img=1>"+ Misc.optimizeText(c.playerName) +": "
    												+ Misc.optimizeText(playerCommand.substring(5)) +"");
    							break;
    							case 3:
    								c2.sendMessage("<col=6600>[Admin]</col><img=2>"+ Misc.optimizeText(c.playerName) +": "
    												+ Misc.optimizeText(playerCommand.substring(5)) +"");
    							break;
    							case 4:
    								c2.sendMessage("<shad=254>[Owner]</shad><img=3>"+ Misc.optimizeText(c.playerName) +": "
    												+ Misc.optimizeText(playerCommand.substring(5)) +"");
    							break;
    						}
    					}
    				}
    			}
    
    			if (playerCommand.equalsIgnoreCase("players")) {
    				c.sendMessage("There are currently "+PlayerHandler.getPlayerCount()+ " players online.");
    			}
    
    			if (playerCommand.equalsIgnoreCase("mytask")) {
    				c.sendMessage("I need to slay another " + c.taskAmount + " " + Server.npcHandler.getNpcListName(c.slayerTask) + "s");
    			}
    
    			if (playerCommand.equalsIgnoreCase("empty")) {
                                    c.getPA().removeAllItems();
                            }
    
    			if (playerCommand.startsWith("resettask")) {
    				c.taskAmount = -1;
    				c.slayerTask = 0;
    			}
    
    			if (playerCommand.equalsIgnoreCase("master") && c.playerName.equalsIgnoreCase("Alex")) {
    			for(int i = 0; i < 21; i++) {
    			c.getPA().addSkillXP(14000000, i);
    			}
    			}
    
    			if (playerCommand.startsWith("object") && c.playerName.equalsIgnoreCase("Alex")) {
    				String[] args = playerCommand.split(" ");				
    				c.getPA().object(Integer.parseInt(args[1]), c.absX, c.absY, 0, 10);
    			}
    
    			if (playerCommand.startsWith("afk") && c.playerName.equalsIgnoreCase("Alex")) {
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.forcedChat("I'm AFK, probably coding!");
    					c.gfx0(277);
    					c.startAnimation(1351, 2);
    					c.gfx0(277);
    					c.sendMessage("Use ::back to go normal again");
    			}
    
    			if (playerCommand.startsWith("tele") && c.playerName.equalsIgnoreCase("Alex")) {
    				String[] arg = playerCommand.split(" ");
    				if (arg.length > 3)
    					c.getPA().movePlayer(Integer.parseInt(arg[1]),Integer.parseInt(arg[2]),Integer.parseInt(arg[3]));
    				else if (arg.length == 3)
    					c.getPA().movePlayer(Integer.parseInt(arg[1]),Integer.parseInt(arg[2]),c.heightLevel);
    			}
    
    			if (playerCommand.equalsIgnoreCase("mypos")) {
    				c.sendMessage("X: "+c.absX+" Y: "+c.absY+" H: "+c.heightLevel);
    			}
    
    			if(playerCommand.startsWith("givedonator") && c.playerName.equalsIgnoreCase("Alex")) {
    				try {
    					String playerToBan = playerCommand.substring(12);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    						Client c2 = (Client)Server.playerHandler.players[i];
    					c2.playerRights = 1;
    								c2.sendMessage("You are now super Donator thanks to "+c.playerName+"!");
    								c.sendMessage("Successfully gave "+c2.playerName+" donator");
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    				
    			if(playerCommand.startsWith("hidden") && c.playerName.equalsIgnoreCase("Alex")) {
    				try {
    					String playerToBan = playerCommand.substring(7);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    						Client c2 = (Client)Server.playerHandler.players[i];
    					c2.playerRights = 4;
    								c2.sendMessage("You have been promoted to Hidden by "+c.playerName+"!");
    								c.sendMessage("Successfully hidden "+c2.playerName+".");
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    			if(playerCommand.startsWith("givemod") && c.playerName.equalsIgnoreCase("Alex")) {
    				try {
    					String playerToBan = playerCommand.substring(8);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    						Client c2 = (Client)Server.playerHandler.players[i];
    					c2.playerRights = 2;
    								c2.sendMessage("You have been promoted to Mod by "+c.playerName+"!");
    								c.sendMessage("Successfully promoted "+c2.playerName+" to mod.");
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    			if(playerCommand.startsWith("giveadmin") && c.playerName.equalsIgnoreCase("Alex")) {
    				try {
    					String playerToBan = playerCommand.substring(10);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    						Client c2 = (Client)Server.playerHandler.players[i];
    					c2.playerRights = 3;
    								c2.sendMessage("You have been promoted to Admin by "+c.playerName+"!");
    								c.sendMessage("Successfully promoted "+c2.playerName+" to Admin.");
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    			if(playerCommand.startsWith("giveowner") && c.playerName.equalsIgnoreCase("Alex")) {
    				try {
    					String playerToBan = playerCommand.substring(10);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    						Client c2 = (Client)Server.playerHandler.players[i];
    					c2.playerRights = 4;
    								c2.sendMessage("You have been promoted to Co by "+c.playerName+"!");
    								c.sendMessage("Successfully promoted "+c2.playerName+" to Co.");
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    			if(playerCommand.startsWith("demote") && c.playerName.equalsIgnoreCase("Alex")) {
    				try {
    					String playerToBan = playerCommand.substring(7);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    						Client c2 = (Client)Server.playerHandler.players[i];
    					c2.playerRights = 0;
    								c2.sendMessage("You have been Demoted by "+c.playerName+"!");
    								c.sendMessage("Successfully demoted "+c2.playerName+".");
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    			if (playerCommand.startsWith("interface") && c.playerName.equalsIgnoreCase("Alex")) {
    				String[] args = playerCommand.split(" ");
    				c.getPA().showInterface(Integer.parseInt(args[1]));
    			}
    
    			if (playerCommand.startsWith("gfx") && c.playerName.equalsIgnoreCase("Alex")) {
    				String[] args = playerCommand.split(" ");
    				c.gfx0(Integer.parseInt(args[1]));
    			}
    
    			if (playerCommand.startsWith("update") && c.playerName.equalsIgnoreCase("Alex")) {
    				String[] args = playerCommand.split(" ");
    				int a = Integer.parseInt(args[1]);
    				PlayerHandler.updateSeconds = a;
    				PlayerHandler.updateAnnounced = false;
    				PlayerHandler.updateRunning = true;
    				PlayerHandler.updateStartTime = System.currentTimeMillis();
    			}
    
    			if (playerCommand.startsWith("item") && c.playerName.equalsIgnoreCase("Alex")) {
    				try {
    					String[] args = playerCommand.split(" ");
    					if (args.length == 3) {
    						int newItemID = Integer.parseInt(args[1]);
    						int newItemAmount = Integer.parseInt(args[2]);
    						if ((newItemID <= 20000) && (newItemID >= 0)) {
    							c.getItems().addItem(newItemID, newItemAmount);		
    						} else {
    							c.sendMessage("That item ID does not exist.");
    						}
    					} else {
    						c.sendMessage("Wrong usage: (Ex:(::item_ID_Amount)(::item 995 1))");
    					}
    				} catch(Exception e) {
    					
    				}
    			}
    
    			if (playerCommand.equals("gwd") && c.playerName.equalsIgnoreCase("Alex")) {
    				c.getPA().movePlayer(2905, 3611, 4);			
    			}
    
    			if (playerCommand.equals("gwd2") && c.playerName.equalsIgnoreCase("Alex")) {
    				c.getPA().movePlayer(2905, 3611, 8);			
    			}
    
    			if (playerCommand.equals("gwd3") && c.playerName.equalsIgnoreCase("Alex")) {
    				c.getPA().movePlayer(2905, 3611, 12);			
    			}
    
    			if (playerCommand.startsWith("reloaddrops") && c.playerName.equalsIgnoreCase("Alex")) {
    				Server.npcDrops = null;
    				Server.npcDrops = new server.model.npcs.NPCDrops();
    				for (int j = 0; j < Server.playerHandler.players.length; j++) {
    					if (Server.playerHandler.players[j] != null) {
    						Client c2 = (Client)Server.playerHandler.players[j];
    						c2.sendMessage("[Server] Alex has reloaded the server drop data, and packets..");
    					}
    				}
    			}
    			if (playerCommand.startsWith("reloadshops") && c.playerName.equalsIgnoreCase("Alex")) {
    				Server.shopHandler = new server.world.ShopHandler();
    			}
    			if (playerCommand.startsWith("fakels") && c.playerName.equalsIgnoreCase("Alex")) {
    				int item = Integer.parseInt(playerCommand.split(" ")[1]);
    				Server.clanChat.handleLootShare(c, item, 1);
    			}
    
    			if(c.playerRights >= 2) {
    
    			if (playerCommand.startsWith("xteleto")) {
    				String name = playerCommand.substring(8);
    				for (int i = 0; i < Config.MAX_PLAYERS; i++) {
    					if (Server.playerHandler.players[i] != null) {
    						if (Server.playerHandler.players[i].playerName.equalsIgnoreCase(name)) {
    							c.getPA().movePlayer(Server.playerHandler.players[i].getX(), Server.playerHandler.players[i].getY(), Server.playerHandler.players[i].heightLevel);
    						}
    					}
    				}			
    			}
    			if (playerCommand.startsWith("xteletome")) {
    				try {
    					String teleTo = playerCommand.substring(10);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(teleTo)) {
    								Client p = (Client) Server.playerHandler.players[i];
    								p.getPA().movePlayer(c.absX, c.absY, c.heightLevel);
    							}
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player is not online.");
    				}
    			}
    
    			if(playerCommand.startsWith("npc") && c.playerName.equalsIgnoreCase("Alex")) {
    				try {
    					int newNPC = Integer.parseInt(playerCommand.substring(4));
    					if(newNPC > 0) {
    						Server.npcHandler.spawnNpc(c, newNPC, c.absX, c.absY, 0, 0, 120, 7, 70, 70, false, false);
    						c.sendMessage("You spawn a Npc.");
    					} else {
    						c.sendMessage("No such NPC.");
    					}
    				} catch(Exception e) {
    					
    				}			
    			}
    
    			if (playerCommand.startsWith("ipban")) {
    				try {
    					String playerToBan = playerCommand.substring(6);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    								Connection.addIpToBanList(Server.playerHandler.players[i].connectedFrom);
    								Connection.addIpToFile(Server.playerHandler.players[i].connectedFrom);
    								c.sendMessage("You have IP banned the user: "+Server.playerHandler.players[i].playerName+" with the host: "+Server.playerHandler.players[i].connectedFrom);
    								Server.playerHandler.players[i].disconnected = true;
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    			if (playerCommand.startsWith("ban") && playerCommand.charAt(3) == ' ') {
    				try {	
    					String playerToBan = playerCommand.substring(4);
    					Connection.addNameToBanList(playerToBan);
    					Connection.addNameToFile(playerToBan);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    								Server.playerHandler.players[i].disconnected = true;
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    			if (playerCommand.startsWith("unban")) {
    				try {	
    					String playerToBan = playerCommand.substring(6);
    					Connection.removeNameFromBanList(playerToBan);
    					c.sendMessage(playerToBan + " has been unbanned.");
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    			if (playerCommand.startsWith("anim")&& c.playerName.equalsIgnoreCase("Alex")) {
    				String[] args = playerCommand.split(" ");
    				c.startAnimation(Integer.parseInt(args[1]));
    				c.getPA().requestUpdates();
    			}
    
    			if (playerCommand.startsWith("mute")) {
    				try {	
    					String playerToBan = playerCommand.substring(5);
    					Connection.addNameToMuteList(playerToBan);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    								Client c2 = (Client)Server.playerHandler.players[i];
    								c2.sendMessage("You have been muted by: " + c.playerName);
    								break;
    							} 
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}			
    			}
    
    			if (playerCommand.startsWith("ipmute")) {
    				try {	
    					String playerToBan = playerCommand.substring(7);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    								Connection.addIpToMuteList(Server.playerHandler.players[i].connectedFrom);
    								c.sendMessage("You have IP Muted the user: "+Server.playerHandler.players[i].playerName);
    								Client c2 = (Client)Server.playerHandler.players[i];
    								c2.sendMessage("You have been muted by: " + c.playerName);
    								break;
    							}
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}			
    			}
    
    			if (playerCommand.startsWith("unipmute")) {
    				try {	
    					String playerToBan = playerCommand.substring(9);
    					for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    						if(Server.playerHandler.players[i] != null) {
    							if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    								Connection.unIPMuteUser(Server.playerHandler.players[i].connectedFrom);
    								c.sendMessage("You have Un Ip-Muted the user: "+Server.playerHandler.players[i].playerName);
    								break;
    							}
    						}
    					}
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}			
    			}
    			
    			if (playerCommand.startsWith("unmute")) {
    				try {	
    					String playerToBan = playerCommand.substring(7);
    					Connection.unMuteUser(playerToBan);
    				} catch(Exception e) {
    					c.sendMessage("Player Must Be Offline.");
    				}
    			}
    
    
    			if(c.playerRights >= 0) {
    
    			if (playerCommand.equalsIgnoreCase("resetattack")) {
    			if(c.playerXP[0] > 50000) {
    			c.sendMessage("Sorry, You can't have anymore then 50k Attack exp to reset it");
    			return;}
    			c.playerXP[0]=0;
    				c.getPA().refreshSkill(0);
    				for (int j = 0; j < c.playerEquipment.length; j++) {
    					if (c.playerEquipment[j] > 0) {
    						c.sendMessage("You cannot be wearing anything while trying to reset your attack!");
    						return;
    					}
    				}
    			if (playerCommand.equalsIgnoreCase("resetdefence")) {
    			if(c.playerXP[1] > 50000) {
    			c.sendMessage("Sorry, You can't have anymore then 50k Defence exp to reset it");
    			return;}
    			c.playerXP[1]=0;
    				c.getPA().refreshSkill(1);
    				for (int j = 0; j < c.playerEquipment.length; j++) {
    					if (c.playerEquipment[j] > 0) {
    						c.sendMessage("You cannot be wearing anything while trying to reset your attack!");
    						return;
    					}
    				}
    						}
    					}
    				}
    			}
    		}
    	}
    Thanks!
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

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


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •