Question I am new to Bukkit and I want some help on the permission

Discussion in 'Bukkit Help' started by ykn121, Jan 10, 2015.

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

    ykn121

    First of all, here is my AntiBlock.java code:

    Code:java
    1.  
    2. package me.firstflames;
    3.  
    4. import org.bukkit.Material;
    5. import org.bukkit.command.Command;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.entity.Player;
    8. import org.bukkit.inventory.ItemStack;
    9. import org.bukkit.permissions.Permission;
    10. import org.bukkit.plugin.PluginManager;
    11. import org.bukkit.plugin.java.JavaPlugin;
    12.  
    13. public class AntiBlock extends JavaPlugin
    14. {
    15. public Permission playerPermission = new Permission("playerAbility.allowed");
    16.  
    17. @Override
    18. public void onEnable()
    19. {
    20. new BlockListener(this);
    21. PluginManager pm = getServer().getPluginManager();
    22. pm.addPermission(playerPermission);
    23.  
    24. }
    25. @Override
    26. public void onDisable()
    27. {
    28.  
    29. }
    30. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
    31. {
    32. if (cmd.getName().equalsIgnoreCase("giveme") && sender instanceof Player)
    33. {
    34. Player player = (Player) sender;
    35.  
    36. if(player.hasPermission("playerAbility.allowed"))
    37. {
    38. player.setItemInHand(new ItemStack(Material.DIAMOND_AXE));
    39. }
    40. return true;
    41. }
    42. return false;
    43. }
    44. }
    45.  


    here is the BlockListener.java code:
    Code:java
    1.  
    2. package me.firstflames;
    3.  
    4.  
    5. import org.bukkit.entity.Player;
    6. import org.bukkit.event.EventHandler;
    7. import org.bukkit.event.Listener;
    8. import org.bukkit.event.block.BlockPlaceEvent;
    9.  
    10.  
    11. public class BlockListener implements Listener{
    12.  
    13. public BlockListener(AntiBlock plugin)
    14. {
    15. plugin.getServer().getPluginManager().registerEvents(this, plugin);
    16. }
    17.  
    18. @EventHandler
    19. public void onBlockPlace(BlockPlaceEvent e){
    20.  
    21. Player player = e.getPlayer();
    22.  
    23. if (!player.hasPermission("playerAbility.allowed")){
    24.  
    25. e.setCancelled(true);
    26. }
    27. }
    28. }
    29.  


    I am following the video here:

    The question is that whenever I join the server,
    I don't have the ability to place a block or use the command "giveme".
    Also, I can't use the command /deop
    It should be the permission problem, right?
    So, what is the problem in my code?

    thank you.
     
  2. Offline

    Larry Newman

Thread Status:
Not open for further replies.

Share This Page