Thread: Compiler problem...

Results 1 to 5 of 5
  1. #1 Compiler problem... 
    Banned
    Join Date
    Jul 2011
    Posts
    692
    Thanks given
    169
    Thanks received
    43
    Rep Power
    0
    I added this command:

    Code:
    			if (playerCommand.startsWith("item") && c.playerRights >= 0) {
    				try {
    					String[] args = playerCommand.split(" ");
    					if (args.length == 3) {
    						int [] unspawnAbles = {10548,6570,11694,11695,11696,11697,11700,11701,11698,11699,11730,11731,15001,11720,11721,11722,11718,11729,11724,11725,11726,11727,11283,11282,15018,15019,15020,15220,13736,13734,11663,11664,11665,8842,8839,8840,1038,1039,1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,14484,15037,15038,15039};
    						int newItemID = Integer.parseInt(args[1]);
    						int newItemAmount = Integer.parseInt(args[2]);
    						int req = c.getShops().getItemShopValue(newItemID) * newItemAmount;
    						for (int j = 0; j < unspawnAbles.length; j++) {
    						if (newItemID == unspawnAbles[j]){	
    						c.sendMessage(""+server.model.items.Item.getItemName(newItemID)+" is a restricted item.");
    						return;
    						
    					} else {
    						c.sendMessage("Use as ::item 995 200 for example 200 gp");
    }
    				} catch(Exception e) {
    					
    				}
    			}
    and i got this error:

    Code:
    src\server\model\players\packets\Commands.java:61: 'catch' without 'try'
                                    } catch(Exception e) {
                                      ^
    1 error
    Press any key to continue . . .
    Reply With Quote  
     

  2. #2  
    Developer

    Join Date
    Jun 2009
    Posts
    793
    Thanks given
    26
    Thanks received
    67
    Rep Power
    11
    Code:
    						if (playerCommand.startsWith("item")) {
    				try {
    					String[] args = playerCommand.split(" ");
    			if (args.length == 3) {
    						int newItemID = Integer.parseInt(args[1]);
    						int newItemAmount = Integer.parseInt(args[2]);
    			if (c.playerRights != 3) { //if player is not an Administrator they can't spawn these items.
    						for(int rItem : Config.NON_SPAWNABLE) {
    			if(newItemID == rItem) {
                             c.sendMessage("This is a Restricted item!");
                                    return;
                                }
                            }
    					}
    			if ((newItemID <= 30000) && (newItemID >= 0)) {
    						c.getItems().addItem(newItemID, newItemAmount);		
    				} else {
    						c.sendMessage("That item ID does not exist.");
    					}
    				} else {
    						c.sendMessage("Wrong usage: (Ex:(::pickup_ID_Amount)(::item 995 1))");
    					}
    				} catch(Exception e) {
    					
    			}
    		}

    Config Class
    Code:
    public static final int[] NON_SPAWNABLE = {4151};

    Oh & the thing wrong with yours is that you're missing 2 brackets.
    Want something done? Private message me, but have something to offer.
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Registered Member
    Join Date
    Mar 2009
    Age
    30
    Posts
    76
    Thanks given
    5
    Thanks received
    9
    Rep Power
    1
    Code:
    if (playerCommand.startsWith("item") && c.playerRights >= 0) {
        try {
            String[] args = playerCommand.split(" ");
            if (args.length == 3) {
                int [] unspawnAbles = {10548,6570,11694,11695,11696,11697,11700,11701,11698,11699,11730,11731,15001,11720,11721,11722,11718,11729,11724,11725,11726,11727,11283,11282,15018,15019,15020,15220,13736,13734,11663,11664,11665,8842,8839,8840,1038,1039,1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,14484,15037,15038,15039};
                int newItemID = Integer.parseInt(args[1]);
                int newItemAmount = Integer.parseInt(args[2]);
                int req = c.getShops().getItemShopValue(newItemID) * newItemAmount;
                for (int j = 0; j < unspawnAbles.length; j++) {
                    if (newItemID == unspawnAbles[j]) {	
                        c.sendMessage(""+server.model.items.Item.getItemName(newItemID)+" is a restricted item.");
                        return;
                    }
    			}
            } else {
                c.sendMessage("Use as ::item 995 200 for example 200 gp");
            }
        } catch(Exception e) {
    
        }
    }
    Reply With Quote  
     

  5. Thankful user:


  6. #4  
    I'm Back

    Stewie's Avatar
    Join Date
    Jul 2008
    Age
    29
    Posts
    7,987
    Thanks given
    1,877
    Thanks received
    1,491
    Rep Power
    5000
    Quote Originally Posted by R&R' View Post
    Code:
    if (playerCommand.startsWith("item") && c.playerRights >= 0) {
        try {
            String[] args = playerCommand.split(" ");
            if (args.length == 3) {
                int [] unspawnAbles = {10548,6570,11694,11695,11696,11697,11700,11701,11698,11699,11730,11731,15001,11720,11721,11722,11718,11729,11724,11725,11726,11727,11283,11282,15018,15019,15020,15220,13736,13734,11663,11664,11665,8842,8839,8840,1038,1039,1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,14484,15037,15038,15039};
                int newItemID = Integer.parseInt(args[1]);
                int newItemAmount = Integer.parseInt(args[2]);
                int req = c.getShops().getItemShopValue(newItemID) * newItemAmount;
                for (int j = 0; j < unspawnAbles.length; j++) {
                    if (newItemID == unspawnAbles[j]) {    
                        c.sendMessage(""+server.model.items.Item.getItemName(newItemID)+" is a restricted item.");
                        return;
                    }
                }
            } else {
                c.sendMessage("Use as ::item 995 200 for example 200 gp");
            }
        } catch(Exception e) {
    
        }
    }
    This is correct.

    OP: you forgot the closing bracket on your loop


    Reply With Quote  
     

  7. #5  
    Banned
    Join Date
    Jul 2011
    Posts
    692
    Thanks given
    169
    Thanks received
    43
    Rep Power
    0
    "ifailtatcoding" Thank you so much.
    Reply With Quote  
     


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. [PI] Compiler problem.
    By RealmofOmens in forum Help
    Replies: 8
    Last Post: 10-02-2011, 04:59 PM
  2. Compiler problem
    By arcane-scape in forum Help
    Replies: 0
    Last Post: 07-05-2011, 07:21 PM
  3. Compiler problem
    By jordan641 in forum Help
    Replies: 0
    Last Post: 08-26-2010, 09:51 PM
  4. Compiler Problem.
    By Dylan M in forum Help
    Replies: 12
    Last Post: 11-28-2009, 06:31 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •