Java Code Examples for org.bukkit.event.player.PlayerArmorStandManipulateEvent

The following examples show how to use org.bukkit.event.player.PlayerArmorStandManipulateEvent. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: CloudNet   Source File: ArmorStandListener.java    License: Apache License 2.0 6 votes vote down vote up
@EventHandler
public void handle(PlayerArmorStandManipulateEvent e) {
    MobSelector.MobImpl mob = CollectionWrapper.filter(MobSelector.getInstance().getMobs().values(),
                                                       new Acceptable<MobSelector.MobImpl>() {
                                                           @Override
                                                           public boolean isAccepted(MobSelector.MobImpl value) {
                                                               try {
                                                                   return e.getRightClicked()
                                                                           .getUniqueId()
                                                                           .equals(value.getDisplayMessage()
                                                                                        .getClass()
                                                                                        .getMethod("getUniqueId")
                                                                                        .invoke(value.getDisplayMessage()));
                                                               } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e1) {
                                                                   return false;
                                                               }
                                                           }
                                                       });
    if (mob != null) {
        e.setCancelled(true);
    }
}
 
Example 2
Source Project: Modern-LWC   Source File: LWCPlayerListener.java    License: 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 3
Source Project: UHC   Source File: DeathStandsModule.java    License: 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();
    }
}
 
Example 4
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void player(PlayerArmorStandManipulateEvent event) {
    if (!DisplayItem.checkIsGuardItemStack(event.getArmorStandItem())) {
        return;
    }
    if (DisplayItem.getNowUsing() != DisplayType.REALITEM) {
        return;
    }
    event.setCancelled(true);
    Util.inventoryCheck(event.getPlayer().getInventory());
    sendAlert(
            "[DisplayGuard] Player  "
                    + event.getPlayer().getName()
                    + " trying mainipulate armorstand contains displayItem.");
}
 
Example 5
/**
 * Handles editing items on an ArmorStand
 *
 * @param event The event
 */
@EventHandler
public void onPlayerManipulateArmorStand(PlayerArmorStandManipulateEvent event) {
	Player player = event.getPlayer();
	NovaPlayer nPlayer = PlayerManager.getPlayer(player);
	Location location = event.getRightClicked().getLocation();

	if(RegionManager.get(location) != null
			&& (!plugin.getRegionManager().canInteract(player, location) || (!nPlayer.getPreferences().getBypass() && !nPlayer.hasPermission(GuildPermission.INTERACT)))) {
		event.setCancelled(true);
		Message.CHAT_REGION_DENY_INTERACT.send(player);
	}
}
 
Example 6
Source Project: BetonQuest   Source File: QuestItemHandler.java    License: GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onArmorStandEquip(final PlayerArmorStandManipulateEvent event) {
    if (event.getPlayer().getGameMode() == GameMode.CREATIVE) {
        return;
    }
    final ItemStack item = event.getPlayerItem();
    final String playerID = PlayerConverter.getID(event.getPlayer());
    if (item != null && (Journal.isJournal(playerID, item) || Utils.isQuestItem(item))) {
        event.setCancelled(true);
    }
}
 
Example 7
@EventHandler
public void onArmorStand(PlayerArmorStandManipulateEvent event) {
    Location location = BukkitUtil.adapt(event.getRightClicked().getLocation());

    if (manager.isPlotWorld(location)) {
        if (event.getPlayer().hasPermission(PermissionNames.ADMIN_BUILDANYWHERE)) {
            return;
        }

        Plot plot = manager.getPlot(location);

        if (plot == null) {
            event.getPlayer().sendMessage(api.C("CannotBuild"));
            event.setCancelled(true);
        } else {
            if (plot.getOwnerId().equals(event.getPlayer().getUniqueId())) {
                return;
            }
            Optional<Plot.AccessLevel> member = plot.isMember(event.getPlayer().getUniqueId());
            if (member.isPresent()) {
                if (member.get().equals(Plot.AccessLevel.TRUSTED) && !api.getServerBridge().getOfflinePlayer(plot.getOwnerId()).isOnline()) {
                    event.getPlayer().sendMessage(api.C("CannotBuild"));
                    event.setCancelled(true);
                } else if (api.isPlotLocked(plot.getId())) {
                    event.getPlayer().sendMessage(api.C("PlotLocked"));
                    event.setCancelled(true);
                }
            } else {
                event.getPlayer().sendMessage(api.C("CannotBuild"));
                event.setCancelled(true);
            }
        }
    }
}
 
Example 8
Source Project: GriefDefender   Source File: PlayerEventHandler.java    License: MIT License 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerArmorStandManipulateEvent(PlayerArmorStandManipulateEvent event) {
    onPlayerInteractEntity(event);
}
 
Example 9
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onArmorStandInteract(final PlayerArmorStandManipulateEvent event) {
  cancelUnlessInteracting(event, event.getPlayer());
}
 
Example 10
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onArmorStandInteract(final PlayerArmorStandManipulateEvent event) {
    cancelUnlessInteracting(event, event.getPlayer());
}
 
Example 11
Source Project: DungeonsXL   Source File: DWorldListener.java    License: GNU General Public License v3.0 4 votes vote down vote up
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onArmorStandManipulate(PlayerArmorStandManipulateEvent event) {
    onTouch(event, event.getRightClicked(), true);
}