Java Code Examples for org.bukkit.event.player.PlayerArmorStandManipulateEvent#getRightClicked()

The following examples show how to use org.bukkit.event.player.PlayerArmorStandManipulateEvent#getRightClicked() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LWCPlayerListener.java    From Modern-LWC with MIT License 6 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerArmorStandManipulate(PlayerArmorStandManipulateEvent e) {
    Entity entity = e.getRightClicked();
    if (plugin.getLWC().isProtectable(e.getRightClicked().getType())) {
        int A = 50000 + entity.getUniqueId().hashCode();

        LWC lwc = LWC.getInstance();
        Protection protection = lwc.getPhysicalDatabase().loadProtection(entity.getWorld().getName(), A, A, A);
        Player p = e.getPlayer();
        boolean canAccess = lwc.canAccessProtection(p, protection);
        if (onPlayerEntityInteract(p, entity, e.isCancelled())) {
            e.setCancelled(true);
        }
        if (protection != null) {
            if (canAccess)
                return;
            e.setCancelled(true);
        }
    }
}
 
Example 2
Source File: DeathStandsModule.java    From UHC with MIT License 6 votes vote down vote up
@EventHandler
public void on(PlayerArmorStandManipulateEvent event) {
    final ArmorStand stand = event.getRightClicked();

    if (!isProtectedArmourStand(stand)) return;

    final ItemStack players = event.getPlayerItem();
    final ItemStack stands = event.getArmorStandItem();

    // if the player is holding something it will be a swap
    if (players == null || players.getType() != Material.AIR) return;

    // if the stand hasn't got something then the player is adding
    // items or nothing will happen
    if (stands == null || stands.getType() == Material.AIR) return;

    // they're removing an item from the armour stand. If there
    // is only 1 item on the stand then this is the final item
    // on the armour stand so kill it (fire optional)
    if (Maps.filterValues(getItems(stand), Predicates.not(EMPTY_ITEM)).values().size() == 1)  {
        stand.remove();
    }
}