use of com.iridium.iridiumskyblock.managers.IslandManager in project IridiumSkyblock by Iridium-Development.
the class Island method isInIsland.
/**
* Returns if a location is inside this Island or not.
*
* @param location The location we are testing
* @return if the location is inside the island
*/
public boolean isInIsland(@NotNull Location location) {
IslandManager islandManager = IridiumSkyblock.getInstance().getIslandManager();
World world = location.getWorld();
if (Objects.equals(world, islandManager.getWorld()) || Objects.equals(world, islandManager.getNetherWorld()) || Objects.equals(world, islandManager.getEndWorld())) {
return isInIsland(location.getBlockX(), location.getBlockZ());
} else {
return false;
}
}
use of com.iridium.iridiumskyblock.managers.IslandManager in project IridiumSkyblock by Iridium-Development.
the class PlayerPortalListener method onPlayerPortal.
@EventHandler(ignoreCancelled = true)
public void onPlayerPortal(PlayerPortalEvent event) {
IslandManager islandManager = IridiumSkyblock.getInstance().getIslandManager();
final Optional<Island> island = IridiumSkyblock.getInstance().getIslandManager().getIslandViaLocation(event.getFrom());
if (!island.isPresent())
return;
final User user = IridiumSkyblock.getInstance().getUserManager().getUser(event.getPlayer());
if (!IridiumSkyblock.getInstance().getIslandManager().getIslandPermission(island.get(), user, PermissionType.PORTAL)) {
if (hasNoCooldown(event.getPlayer())) {
event.getPlayer().sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().cannotUsePortal.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
}
event.setCancelled(true);
return;
}
if (event.getCause() == PlayerTeleportEvent.TeleportCause.NETHER_PORTAL) {
if (IridiumSkyblock.getInstance().getConfiguration().netherIslands) {
World world = Objects.equals(event.getFrom().getWorld(), islandManager.getNetherWorld()) ? islandManager.getWorld() : islandManager.getNetherWorld();
event.setTo(island.get().getCenter(world));
return;
}
event.setCancelled(true);
if (hasNoCooldown(event.getPlayer())) {
event.getPlayer().sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().netherIslandsDisabled.replace("%prefix", IridiumSkyblock.getInstance().getConfiguration().prefix)));
}
return;
}
if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)) {
event.setCancelled(true);
if (IridiumSkyblock.getInstance().getConfiguration().endIslands) {
World world = Objects.equals(event.getFrom().getWorld(), islandManager.getEndWorld()) ? islandManager.getWorld() : islandManager.getEndWorld();
event.getPlayer().teleport(LocationUtils.getSafeLocation(island.get().getCenter(world), island.get()));
return;
}
if (hasNoCooldown(event.getPlayer())) {
event.getPlayer().sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().endIslandsDisabled.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
}
}
}
Aggregations