Java Code Examples for org.bukkit.event.entity.EntityPortalEvent#setCancelled()
The following examples show how to use
org.bukkit.event.entity.EntityPortalEvent#setCancelled() .
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: EntityPortalEventListener.java From PerWorldInventory with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.NORMAL) public void onEntityPortalTeleport(EntityPortalEvent event) { if (!(event.getEntity() instanceof Item)) return; ConsoleLogger.debug("[ENTITYPORTALEVENT] A '" + event.getEntity().getName() + "' is going through a portal!"); String worldFrom = event.getFrom().getWorld().getName(); // For some reason, event.getTo().getWorld().getName() is sometimes null if (event.getTo() == null || event.getTo().getWorld() == null) { // Not gonna bother checking name; its already a WTF that this is needed ConsoleLogger.debug("[ENTITYPORTALEVENT] event.getTo().getWorld().getName() would throw a NPE! Exiting method!"); return; } String worldTo = event.getTo().getWorld().getName(); Group from = groupManager.getGroupFromWorld(worldFrom); Group to = groupManager.getGroupFromWorld(worldTo); // If the groups are different, cancel the event if (!from.equals(to)) { ConsoleLogger.debug("[ENTITYPORTALEVENT] Group '" + from.getName() + "' and group '" + to.getName() + "' are different! Canceling event!"); event.setCancelled(true); } }
Example 2
Source File: EntityPortalEventListener.java From PerWorldInventory with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.NORMAL) public void onEntityPortalTeleport(EntityPortalEvent event) { if (!(event.getEntity() instanceof Item)) return; ConsoleLogger.debug("[ENTITYPORTALEVENT] A '" + event.getEntity().getName() + "' is going through a portal!"); String worldFrom = event.getFrom().getWorld().getName(); // For some reason, event.getTo().getWorld().getName() is sometimes null if (event.getTo() == null || event.getTo().getWorld() == null) { // Not gonna bother checking name; its already a WTF that this is needed ConsoleLogger.debug("[ENTITYPORTALEVENT] event.getTo().getWorld().getName() would throw a NPE! Exiting method!"); return; } String worldTo = event.getTo().getWorld().getName(); Group from = groupManager.getGroupFromWorld(worldFrom); Group to = groupManager.getGroupFromWorld(worldTo); // If the groups are different, cancel the event if (!from.equals(to)) { ConsoleLogger.debug("[ENTITYPORTALEVENT] Group '" + from.getName() + "' and group '" + to.getName() + "' are different! Canceling event!"); event.setCancelled(true); } }
Example 3
Source File: EndModule.java From UHC with MIT License | 5 votes |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void on(EntityPortalEvent event) { if (isEnabled()) return; if (event.getTo() == null) return; if (event.getTo().getWorld().getEnvironment() == World.Environment.THE_END) { event.setCancelled(true); } }
Example 4
Source File: NetherModule.java From UHC with MIT License | 5 votes |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void on(EntityPortalEvent event) { if (isEnabled()) return; if (event.getTo() == null) return; if (event.getTo().getWorld().getEnvironment() == World.Environment.NETHER) { event.setCancelled(true); } }
Example 5
Source File: NetherPortals.java From askyblock with GNU General Public License v2.0 | 5 votes |
/** * This handles non-player portal use * Currently disables portal use by entities * * @param event */ @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onEntityPortal(final EntityPortalEvent event) { if (DEBUG) plugin.getLogger().info("DEBUG: nether portal entity " + event.getFrom().getBlock().getType()); // If the nether is disabled then quit immediately if (!Settings.createNether || ASkyBlock.getNetherWorld() == null) { if (DEBUG) plugin.getLogger().info("DEBUG: Disabled nether: Settings create nether = " + Settings.createNether + " " + (ASkyBlock.getNetherWorld() == null ? "Nether world is null": "Nether world is not null")); return; } // Disable entity portal transfer due to dupe glitching event.setCancelled(true); }
Example 6
Source File: EffectEventHandlers.java From EliteMobs with GNU General Public License v3.0 | 4 votes |
@EventHandler public void portalPickupSafeguard(EntityPortalEvent event) { if (EntityTracker.isItemVisualEffect(event.getEntity()) || EntityTracker.isEliteMob(event.getEntity())) event.setCancelled(true); }
Example 7
Source File: LivingEntityShopListener.java From Shopkeepers with GNU General Public License v3.0 | 4 votes |
@EventHandler(ignoreCancelled = true) void onEntityPortalTeleport(EntityPortalEvent event) { if (plugin.isShopkeeper(event.getEntity())) { event.setCancelled(true); } }