I'm a bit new to this but what I'm trying to achieve is to create a permission node for placing a block type which should be fairly simple but I'm kinda of making a balls of it. Hopefully someone can point me in the right direction. Currently I have this for the event Code: @EventHandler(priority = EventPriority.HIGH) public void onBlockPlace(BlockPlaceEvent event){ if (event.isCancelled()) return; if(sender instanceof Player){ if(!permCheck(Player)sender, "bp.TNT")){ } if (event.getBlock().getType() == Material.TNT){ event.setCancelled(true); } if (event.isCancelled()) return;
I've gotten it to work now all I need to do is invert how the permissions work. Currently, if a player has the permission then only can they place the block. What I want to do is if they HAVE the permission they can't place the block. If they don't have the permission they can place the block Suggestions? I thought I was meant to use an exclamation mark to invert my statement
Didn't seem to work. Here's my code currently for the tnt block PHP: @EventHandler(priority = EventPriority.HIGH) public void onLavaBlockPlace(BlockPlaceEvent event){ Player player = event.getPlayer(); Block block = event.getBlockPlaced(); if(block.getType() == Material.LAVA){ if(((Player) player).hasPermission("bp.TNT")) { } else { if ((player.isOp())) { }else{ event.setCancelled(true); player.sendMessage(ChatColor.RED + ("You don't have permission to place this block!")); } event.setCancelled(true); } } }
This should do it. Code: @EventHandler(priority = EventPriority.HIGH) public void onLavaBlockPlace(BlockPlaceEvent event){ Player player = event.getPlayer(); Block block = event.getBlockPlaced(); if(block.getType() != Material.LAVA) return; if(!player.hasPermission("bp.TNT")) { player.sendMessage(ChatColor.RED + "You don't have permission to place this block!"); event.setCancelled(true); } }
Awk. It didn't work and then I realized I was standing in the spawn on my test server >.< Working now though HTML: @EventHandler(priority = EventPriority.HIGH) public void onLavaBlockPlace(BlockPlaceEvent event){ Player player = event.getPlayer(); Block block = event.getBlockPlaced(); if(block.getType() == Material.LAVA) { if ((player.hasPermission("bp.lava"))) { player.sendMessage(ChatColor.RED + "You don't have permission to place this block!"); event.setCancelled(true); } else { player.sendMessage(ChatColor.GREEN + ("Block Was placed Successfully!!")); event.setCancelled(false); } } } Thank you for your help!
Try adding a check to see if player isOp something like: || if player.isOp() && !player.hasPermission("Your.Node.Here") event.setCancelled(true);
I have done this and it is working as it should PHP: @EventHandler(priority = EventPriority.HIGH) public void SMOOTHSTAIRS(BlockPlaceEvent event){ Player player = event.getPlayer(); Block block = event.getBlockPlaced(); if(player.isOp() || block.getType() != Material.SMOOTH_STAIRS) return; if(player.hasPermission("bp.smoothstairs")) { player.sendMessage(ChatColor.RED + "You don't have permission to place this block!"); event.setCancelled(true); } } @V10lator I'm a bit new to the using the config.yml for things other than the main, version. author + permissions. Currently what I'm trying to do now is to use a global permission like bp.* to give all the permissions of the plugin to the user/group. Do I have to group all the permission nodes somehow or is there a relatively quick way to grab everything? Currently 100+ permissions associated with this plugin
@Willbbz 100+ permissions? Wow... Well,there is some child/parent system, I think, but I never worked with it.
You've probably deduced I'm quite new to this but I have a permission node set for every placeable block type in the game where if a group or player has the permission node it means they cannot place the block. All of the nodes follow bp.<blockname> Although I think this will require a system like bp.ores.diamondore so I can group all the ores together like bp.ores.*