Thread: Taking Command away from Players

Results 1 to 3 of 3
  1. #1 Taking Command away from Players 
    Registered Member
    Join Date
    Jul 2015
    Posts
    16
    Thanks given
    2
    Thanks received
    0
    Rep Power
    11
    I have just got a new source but the problem is it's the immunity source so it's practically NR, but normal players can use ::item -how would I go of fixing this? Thanks.
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Feb 2015
    Posts
    97
    Thanks given
    8
    Thanks received
    0
    Rep Power
    11
    Change the player rights permission for the command.

    Code:
    if (playerCommand.startsWith("item") && c.playerRights == 3) //Change the number to match your 'owner' right.
    {
    	try
    	{
    		String args[] = playerCommand.split(" ");		
    		int itemId = Integer.parseInt(args[1]);
    		int amount = Integer.parseInt(args[2]);
    		
    		if (amount > Integer.MAX_VALUE)
    			return;
    			
    		if (itemId > Config.ITEM_LIMIT)
    			return;
    			
    		c.getItems().addItem(itemId, amount);
    		c.sendMessage("You have spawned x" + amount + " " + c.getItems().getItemName(itemId) + ".");
    	}
    	catch (Exception e)
    	{
    		c.sendMessage("Incorrect syntax, please use the command as demonstrated -> ::item id amount.");
    		e.printStackTrace();
    	}
    }
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Mar 2015
    Posts
    138
    Thanks given
    22
    Thanks received
    13
    Rep Power
    13
    Quote Originally Posted by Azuline View Post
    Change the player rights permission for the command.

    Code:
    if (playerCommand.startsWith("item") && c.playerRights == 3) //Change the number to match your 'owner' right.
    {
    	try
    	{
    		String args[] = playerCommand.split(" ");		
    		int itemId = Integer.parseInt(args[1]);
    		int amount = Integer.parseInt(args[2]);
    		
    		if (amount > Integer.MAX_VALUE)
    			return;
    			
    		if (itemId > Config.ITEM_LIMIT)
    			return;
    			
    		c.getItems().addItem(itemId, amount);
    		c.sendMessage("You have spawned x" + amount + " " + c.getItems().getItemName(itemId) + ".");
    	}
    	catch (Exception e)
    	{
    		c.sendMessage("Incorrect syntax, please use the command as demonstrated -> ::item id amount.");
    		e.printStackTrace();
    	}
    }
    You could do this but shouldn't.

    Make different sections to corner off commands:

    Code:
    if( c.playerRights >= 1 )
    {
             //moderator commands here
    }
    
    if( c.playerRights >= 2 )
    {
             //admin commands here
    }
    
    if( c.playerRights == 3 )
    {
             //owner commands here
    }
    You don't need to do anything with commands that are for everyone (normal players included), just put all moderator commands in the playerRights >= 1 etc.
    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. Replies: 5
    Last Post: 02-03-2014, 05:58 AM
  2. Replies: 7
    Last Post: 12-14-2010, 06:52 PM
  3. Replies: 4
    Last Post: 02-29-2008, 10:57 PM
  4. Replies: 4
    Last Post: 02-27-2008, 07:38 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
  •