Faction Permission node

Discussion in 'Plugin Development' started by matty258987, Sep 27, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    matty258987

    well I'm working on a custom plugin and I need it to check when a player right clicks first, where the player is, and if they are in faction land, it needs to check if the player has perms to build in that faction land and if not deny the right click. how would I do that? this is the code i have but it doesn't seem to work:
    Code:
       
    public void onPlayerInteract(PlayerInteractEvent event) {
            if (event.getAction() == Action.RIGHT_CLICK_AIR) {
                Location location = Player.getLocation();
                getFactionAt FLocation = getFactionAt(location);
                if (FLocation == location) {
                    if (player.hasPermission(build)){
                    }else {
                        setEvent.canceled(True);
                        player.sendMessage(ChatColor.RED + "You do Not Have Permission to Use that Item Here!");
                    }
                   
                }
            }
        }
    
     
  2. Offline

    CraftCreeper6

    matty258987
    You're saying setEvent.canceled(True)
    Use
    event.setCanceled(true);
     
  3. Offline

    matty258987

    CraftCreeper6
    Then would it work perfectly?
    also how would I make it so I could put item IDs in a config and it would check what items are in the config and if the item Isn't in the config it allows the right click
     
  4. Offline

    CraftCreeper6

    matty258987
    Well, setEvent.canceled(True); wont do anything... so yes.
    EDIT:
    You might also want to add a check to make sure the item your checking for isn't air.
     
  5. Offline

    matty258987

    CraftCreeper6
    thats what I want to do. I want it so i can put an item in a config and when a player is in faction land that they don't have build permissions for, it would deny the right click. I need it like that so I don't have to duplicate the code.
     
  6. Offline

    CraftCreeper6

    matty258987
    Oh! That is for something else that is not canceling the event? Should've said :)
    Just add event.setCanceled(true); underneath that then :)
     
  7. Offline

    matty258987

    what no i want it so if they have build permission it will allow the right click but if not it will cancel it.
    but I want it to check the item in hand and if it matches any of the IDs in the config it would only deny those. and if it's not in the config even if they don't have permission it will allow it

    CraftCreeper6

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
  8. Offline

    Da_Co0k1eZ

    matty258987 Do event.getPlayer().getItemInHand() and compare it to whatever items you have in your configuration. Then just check and see if they have the permissions.
     
  9. Offline

    matty258987

    Da_Co0k1eZ
    thats the trouble. I don't know HOW to do that
     
  10. Offline

    SacredWaste

    This is for plugin development help. Not "give me all the source codes." If you want to learn how, learn. You need to compare the item in hand to a list of items in your configuration.
     
  11. Offline

    matty258987

  12. Offline

    SacredWaste

    There are thousands of tutorials. If you can't understand any, I'm afraid it's not up to us to give you the code required. Maybe if someone wants to, they will.
     
  13. Offline

    matty258987

    SacredWaste
    well you clearly aren't going to help....
     
  14. Offline

    Da_Co0k1eZ

  15. Offline

    matty258987

    Da_Co0k1eZ
    SacredWaste
    let me get to the point if you know the code to do what I am asking please just post it...
     
  16. Offline

    CraftCreeper6

    matty258987
    Check IF the CONFIG contains the PLAYERS ITEM IN HAND
    IF true; SETCANCELED to TRUE.

    If you haven't got it already, I gave you some Psuedo. Figure it out.
     
  17. Offline

    matty258987

    CraftCreeper6
    ok that helped but how would the code read the config...
    so if i put:
    1.* # Too OP

    would it recognize stone (ID 1) and the the * as including ALL meta data (if it had any) and the part after the # as a comment for why it's restricted
     
  18. Offline

    Hawktasard

    Material m = Material.valueOf(somePlugin.getConfig().getString("path.to.itemstack.type"));

    Something like that should work for getting the material type,
    I think you're pretty new to Bukkit, If you are you should check some tutorials.

    I personally recommend either of these channels:
    https://www.youtube.com/user/PogoStick29Dev
    https://www.youtube.com/user/TheBCBroz

    If you're completely new to java, You should read a java book, Or find a java tutorial and learn that first.
     
  19. Offline

    matty258987

    Hawktasard
    thank you and also i PMed you :) plz check it xD
     
Thread Status:
Not open for further replies.

Share This Page