Egging

Discussion in 'Community Discussion' started by mtp1997, Jun 18, 2012.

  1. @EventHandler
    public void PlayerInteractEggUse(PlayerInteractEvent event){
    Player p = event.getPlayer();
    ItemStack stack = event.getItem();
    if((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) && (stack != null)){
    if(stack.getTypeId() == 344 && !hasPermission && !event.getPlayer().isOp()){
    event.setCancelled(true);
    p.sendMessage(ChatColor.RED+"You have insufficient permissions to do that!");
    }
    }
    }

    What this is typically saying is that "IF an event of an action being right clicking air or right clicking a block and the stack in your hand is not empty and IF the stack in your hand equals to 344(egg) and does not have permission (hasPermission represents build) and the player is not an Operator the event is cancelled".

    There is a much more efficient way to catch the egg throw event but I feel lazy so this is a code that represents how to prevent the egg throw. Its a very easy code to add in the Residence plugin but that code might not be right because I really don't know anything about the Residence API.