Teleporting to island by coordinates, change some event priorities

This commit is contained in:
Esophose 2019-05-27 10:28:42 -06:00
parent f451ea8912
commit c193d2d7c5
5 changed files with 24 additions and 11 deletions

View File

@ -2,7 +2,7 @@ import org.apache.tools.ant.filters.ReplaceTokens
apply plugin: 'java'
group 'com.songoda.fabledskyblock'
version 'Build-75'
version 'Build-76'
sourceCompatibility = 1.8

View File

@ -555,11 +555,12 @@ public class IslandManager {
return null;
}
public void loadIslandAtLocation(Location location) {
public Island loadIslandAtLocation(Location location) {
FileManager fileManager = skyblock.getFileManager();
File configFile = new File(skyblock.getDataFolder().toString() + "/island-data");
if (!configFile.exists()) return;
if (!configFile.exists())
return null;
for (File fileList : configFile.listFiles()) {
if (fileList != null && fileList.getName().contains(".yml") && fileList.getName().length() > 35) {
@ -576,14 +577,15 @@ public class IslandManager {
if (LocationUtil.isLocationAtLocationRadius(location, islandLocation, size)) {
UUID islandOwnerUUID = UUID.fromString(fileList.getName().replace(".yml", ""));
this.loadIsland(Bukkit.getOfflinePlayer(islandOwnerUUID));
return;
return this.loadIsland(Bukkit.getOfflinePlayer(islandOwnerUUID));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
return null;
}
public void unloadIsland(Island island, org.bukkit.OfflinePlayer player) {

View File

@ -45,7 +45,7 @@ public class Block implements Listener {
}
@SuppressWarnings("deprecation")
@EventHandler
@EventHandler(priority = EventPriority.LOW)
public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
org.bukkit.block.Block block = event.getBlock();
@ -159,7 +159,7 @@ public class Block implements Listener {
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@EventHandler(priority = EventPriority.LOW)
public void onBlockPlace(BlockPlaceEvent event) {
Player player = event.getPlayer();
org.bukkit.block.Block block = event.getBlock();

View File

@ -49,7 +49,7 @@ public class Interact implements Listener {
}
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
org.bukkit.block.Block block = event.getClickedBlock();

View File

@ -40,7 +40,7 @@ public class Move implements Listener {
Location from = event.getFrom();
Location to = event.getTo();
if (from.getX() == to.getX() && from.getY() == to.getY() && from.getZ() == to.getZ()) {
if (to == null || (from.getBlockX() == to.getBlockX() && from.getBlockY() == to.getBlockY() && from.getBlockZ() == to.getBlockZ())) {
return;
}
@ -51,7 +51,8 @@ public class Move implements Listener {
WorldManager worldManager = skyblock.getWorldManager();
FileManager fileManager = skyblock.getFileManager();
if (!worldManager.isIslandWorld(player.getWorld())) return;
if (!worldManager.isIslandWorld(player.getWorld()))
return;
IslandWorld world = worldManager.getIslandWorld(player.getWorld());
@ -187,7 +188,7 @@ public class Move implements Listener {
if (LocationUtil.isLocationAtLocationRadius(to,
island.getLocation(world, IslandEnvironment.Island), island.getRadius() + 2)) {
if (!configLoad.getBoolean("Island.WorldBorder.Enable")) {
if (!configLoad.getBoolean("Island.WorldBorder.Enable") || !island.isBorder()) {
player.teleport(player.getLocation()
.add(from.toVector().subtract(to.toVector()).normalize().multiply(2.0D)));
player.setFallDistance(0.0F);
@ -212,6 +213,16 @@ public class Move implements Listener {
}
}
// Load the island they are now on if one exists
if (player.hasPermission("fabledskyblock.bypass")) {
Island loadedIsland = islandManager.loadIslandAtLocation(player.getLocation());
if (loadedIsland != null) {
Bukkit.broadcastMessage("Sidestepped normal rules for bypass user");
playerData.setIsland(loadedIsland.getOwnerUUID());
return;
}
}
LocationUtil.teleportPlayerToSpawn(player);
messageManager.sendMessage(player,