Java Code Examples for org.bukkit.event.entity.EntityPortalEvent#getTo()
The following examples show how to use
org.bukkit.event.entity.EntityPortalEvent#getTo() .
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); } }