org.bukkit.event.entity.EntityInteractEvent Java Examples
The following examples show how to use
org.bukkit.event.entity.EntityInteractEvent.
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: EntityListener.java From BedwarsRel with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onEntityInteract(EntityInteractEvent event) { if (!(event.getEntity() instanceof Player)) { return; } if (event.getBlock().getType() != Material.SOIL && event.getBlock().getType() != Material.WHEAT) { return; } Player player = (Player) event.getEntity(); Game game = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(player); if (game == null) { return; } if (game.getState() == GameState.WAITING) { event.setCancelled(true); } }
Example #2
Source File: LWCEntityListener.java From Modern-LWC with MIT License | 5 votes |
@EventHandler public void entityInteract(EntityInteractEvent event) { Block block = event.getBlock(); Protection protection = plugin.getLWC().findProtection(block.getLocation()); if (protection != null) { boolean allowEntityInteract = Boolean .parseBoolean(plugin.getLWC().resolveProtectionConfiguration(block, "allowEntityInteract")); if (!allowEntityInteract) { event.setCancelled(true); } } }
Example #3
Source File: BlockListener.java From civcraft with GNU General Public License v2.0 | 5 votes |
@EventHandler(priority = EventPriority.NORMAL) public void OnEntityInteractEvent(EntityInteractEvent event) { if (event.getBlock() != null) { if (CivSettings.switchItems.contains(event.getBlock().getType())) { coord.setFromLocation(event.getBlock().getLocation()); TownChunk tc = CivGlobal.getTownChunk(coord); if (tc == null) { return; } /* A non-player entity is trying to trigger something, if interact permission is * off for others then disallow it. */ if (tc.perms.interact.isPermitOthers()) { return; } if (event.getEntity() instanceof Player) { CivMessage.sendErrorNoRepeat((Player)event.getEntity(), "You do not have permission to interact here..."); } event.setCancelled(true); } } }
Example #4
Source File: EntityListenerTest.java From AuthMeReloaded with GNU General Public License v3.0 | 5 votes |
@Test public void shouldHandleSimpleEvents() { withServiceMock(listenerService) .check(listener::onFoodLevelChange, FoodLevelChangeEvent.class) .check(listener::onShoot, EntityShootBowEvent.class) .check(listener::onEntityInteract, EntityInteractEvent.class) .check(listener::onLowestEntityInteract, EntityInteractEvent.class); }
Example #5
Source File: DebugListener.java From civcraft with GNU General Public License v2.0 | 4 votes |
@EventHandler(priority = EventPriority.MONITOR) public void onEntityInteractEvent(EntityInteractEvent event) { }
Example #6
Source File: IslandGuard.java From askyblock with GNU General Public License v2.0 | 4 votes |
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onProjectileHit(EntityInteractEvent e) { if (e.getEntity() == null || !(e.getEntity() instanceof Projectile)) { return; } Projectile p = (Projectile)e.getEntity(); if (p.getShooter() != null && p.getShooter() instanceof Player && e.getBlock() != null) { Player player = (Player)p.getShooter(); if (!inWorld(player) || player.isOp() || VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypassprotect") || plugin.getGrid().playerIsOnIsland(player)) { return; } Island island = plugin.getGrid().getProtectedIslandAt(e.getBlock().getLocation()); switch(e.getBlock().getType()) { case WOOD_BUTTON: case STONE_BUTTON: if ((island == null && Settings.defaultWorldSettings.get(SettingsFlag.LEVER_BUTTON))) { return; } if (island != null && island.getIgsFlag(SettingsFlag.LEVER_BUTTON)) { return; } Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).islandProtected); e.setCancelled(true); break; case WOOD_PLATE: case STONE_PLATE: case GOLD_PLATE: case IRON_PLATE: // Pressure plates if ((island == null && Settings.defaultWorldSettings.get(SettingsFlag.PRESSURE_PLATE))) { return; } if (island != null && island.getIgsFlag(SettingsFlag.PRESSURE_PLATE)) { return; } Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).islandProtected); e.setCancelled(true); break; default: break; } } }
Example #7
Source File: EntityListener.java From AuthMeReloaded with GNU General Public License v3.0 | 4 votes |
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) public void onEntityInteract(EntityInteractEvent event) { if (listenerService.shouldCancelEvent(event)) { event.setCancelled(true); } }
Example #8
Source File: EntityListener.java From AuthMeReloaded with GNU General Public License v3.0 | 4 votes |
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onLowestEntityInteract(EntityInteractEvent event) { if (listenerService.shouldCancelEvent(event)) { event.setCancelled(true); } }