org.bukkit.event.player.PlayerArmorStandManipulateEvent Java Examples

The following examples show how to use org.bukkit.event.player.PlayerArmorStandManipulateEvent. 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: ArmorStandListener.java    From CloudNet with 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 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 #3
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();
    }
}
 
Example #4
Source File: DisplayProtectionListener.java    From QuickShop-Reremake with GNU General Public License v3.0 5 votes vote down vote up
@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
Source File: RegionInteractListener.java    From NovaGuilds with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 File: QuestItemHandler.java    From BetonQuest with 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
Source File: BukkitPlotListener.java    From PlotMe-Core with GNU General Public License v3.0 5 votes vote down vote up
@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 File: PlayerEventHandler.java    From GriefDefender with MIT License 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerArmorStandManipulateEvent(PlayerArmorStandManipulateEvent event) {
    onPlayerInteractEntity(event);
}
 
Example #9
Source File: EventFilterMatchModule.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onArmorStandInteract(final PlayerArmorStandManipulateEvent event) {
  cancelUnlessInteracting(event, event.getPlayer());
}
 
Example #10
Source File: EventFilterMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onArmorStandInteract(final PlayerArmorStandManipulateEvent event) {
    cancelUnlessInteracting(event, event.getPlayer());
}
 
Example #11
Source File: DWorldListener.java    From DungeonsXL with 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);
}