Reworked portal setting handle

This commit is contained in:
Fabrizio La Rosa 2020-06-18 00:51:32 +02:00
parent e6cd8558c9
commit cb3e16031e
2 changed files with 22 additions and 9 deletions

View File

@ -169,12 +169,17 @@ public class Move implements Listener {
} }
// Load the island they are now on if one exists // Load the island they are now on if one exists
if (player.hasPermission("fabledskyblock.bypass")) {
Island loadedIsland = islandManager.loadIslandAtLocation(player.getLocation()); Island loadedIsland = islandManager.loadIslandAtLocation(player.getLocation());
if (loadedIsland != null) { if (loadedIsland != null) {
if (player.hasPermission("fabledskyblock.bypass")) {
playerData.setIsland(loadedIsland.getOwnerUUID()); playerData.setIsland(loadedIsland.getOwnerUUID());
return; return;
} }
if(loadedIsland.isOpen()){
loadedIsland.getVisit().addVisitor(player.getUniqueId());
return;
}
} }
LocationUtil.teleportPlayerToSpawn(player); LocationUtil.teleportPlayerToSpawn(player);

View File

@ -12,6 +12,7 @@ import com.songoda.skyblock.permission.event.events.PlayerEnterPortalEvent;
import com.songoda.skyblock.utils.world.LocationUtil; import com.songoda.skyblock.utils.world.LocationUtil;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
@ -33,18 +34,25 @@ public class PortalPermission extends ListeningPermission {
Player player = (Player) event.getEntity(); Player player = (Player) event.getEntity();
cancelAndMessage(event, player, plugin, messageManager); cancelAndMessage(event, player, plugin, messageManager);
Bukkit.getScheduler().runTask(plugin, () -> {
player.teleport(getToLocation(event.getLocation(), player)); player.teleport(getToLocation(event.getLocation(), player));
});
} }
} }
@PermissionHandler @PermissionHandler
public void onTeleport(PlayerTeleportEvent event) { public void onTeleport(PlayerTeleportEvent event) {
if (event.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.ENDER_PEARL)
|| event.getCause() == PlayerTeleportEvent.TeleportCause.NETHER_PORTAL || event.getCause().equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL)
|| event.getCause() == PlayerTeleportEvent.TeleportCause.END_PORTAL || event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)
|| ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9) && || (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)
event.getCause() == PlayerTeleportEvent.TeleportCause.END_GATEWAY){ && event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_GATEWAY))){
event.getPlayer().teleport(getToLocation(event.getFrom(), event.getPlayer())); event.getPlayer().teleport(getToLocation(event.getFrom(), event.getPlayer()));
Location to = getToLocation(event.getFrom(), event.getPlayer());
Bukkit.getScheduler().runTask(plugin, () -> {
event.getPlayer().teleport(to);
});
event.setTo(to);
cancelAndMessage(event, event.getPlayer(), plugin, messageManager); cancelAndMessage(event, event.getPlayer(), plugin, messageManager);
} }