mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-01-05 23:37:39 +01:00
Fixed Portals
This commit is contained in:
parent
bb62bc5617
commit
9fbbca4a13
@ -26,6 +26,7 @@ import org.bukkit.WeatherType;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -864,7 +865,7 @@ public class Island {
|
||||
getLevel().save();
|
||||
}
|
||||
|
||||
public boolean isRegionUnlocked(Player player, String type) {
|
||||
public boolean isRegionUnlocked(Player player, IslandWorld type) {
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
@ -874,22 +875,26 @@ public class Island {
|
||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"),
|
||||
ownerUUID.toString() + ".yml"));
|
||||
FileConfiguration configLoadIslandData = islandData.getFileConfiguration();
|
||||
double price = configLoad.getDouble("Island.World." + type + ".UnlockPrice");
|
||||
double price = configLoad.getDouble("Island.World." + type.name() + ".UnlockPrice");
|
||||
|
||||
boolean unlocked = configLoadIslandData.getBoolean("Unlocked." + type);
|
||||
boolean unlocked = configLoadIslandData.getBoolean("Unlocked." + type.name());
|
||||
if (price == -1) {
|
||||
configLoadIslandData.set("Unlocked." + type, true);
|
||||
configLoadIslandData.set("Unlocked." + type.name(), true);
|
||||
unlocked = true;
|
||||
}
|
||||
|
||||
if (!unlocked) {
|
||||
messageManager.sendMessage(player,
|
||||
fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
|
||||
.getString("Island.Unlock." + type + ".Message").replace(
|
||||
.getString("Island.Unlock." + type.name() + ".Message").replace(
|
||||
"%cost%", NumberUtil.formatNumberByDecimal(price)));
|
||||
|
||||
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
|
||||
player.setVelocity(player.getLocation().getDirection().multiply(-.50));
|
||||
if(type.equals(IslandWorld.End)){
|
||||
player.setVelocity(player.getLocation().getDirection().multiply(-.50).setY(.6f));
|
||||
} else if(type.equals(IslandWorld.Nether)) {
|
||||
player.setVelocity(player.getLocation().getDirection().multiply(-.50));
|
||||
}
|
||||
}
|
||||
return unlocked;
|
||||
}
|
||||
|
@ -81,12 +81,6 @@ public class Portal implements Listener {
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
PlayerEnterPortalEvent playerEnterPortalEvent = new PlayerEnterPortalEvent(player, player.getLocation()); // TODO Why?? - Fabrimat
|
||||
// Check permissions.
|
||||
if (!skyblock.getPermissionManager().processPermission(playerEnterPortalEvent,
|
||||
player, island) || playerEnterPortalEvent.isCancelled())
|
||||
return;
|
||||
|
||||
IslandEnvironment spawnEnvironment;
|
||||
switch (island.getRole(player)) {
|
||||
case Operator:
|
||||
@ -123,23 +117,25 @@ public class Portal implements Listener {
|
||||
|
||||
if (tick == null) return;
|
||||
|
||||
PlayerEnterPortalEvent playerEnterPortalEvent = new PlayerEnterPortalEvent(player, player.getLocation()); // TODO Why?? - Fabrimat
|
||||
// Check permissions.
|
||||
if (!skyblock.getPermissionManager().processPermission(playerEnterPortalEvent,
|
||||
player, island))
|
||||
return;
|
||||
|
||||
IslandWorld fromWorld = worldManager.getIslandWorld(player.getWorld());
|
||||
IslandWorld toWorld = IslandWorld.Normal;
|
||||
|
||||
if (CompatibleMaterial.getMaterial(block.getType()).equals(CompatibleMaterial.NETHER_PORTAL))
|
||||
if (block.getType().equals(CompatibleMaterial.NETHER_PORTAL.getMaterial())) {
|
||||
toWorld = fromWorld.equals(IslandWorld.Normal) ? IslandWorld.Nether : IslandWorld.Normal;
|
||||
else if (CompatibleMaterial.getMaterial(block.getType()).equals(CompatibleMaterial.END_PORTAL))
|
||||
} else if (block.getType().equals(CompatibleMaterial.END_PORTAL.getMaterial())) {
|
||||
toWorld = fromWorld.equals(IslandWorld.Normal) ? IslandWorld.End : IslandWorld.Normal;
|
||||
}
|
||||
|
||||
switch (toWorld) {
|
||||
case Nether:
|
||||
if (configLoad.getBoolean("Island.World.Nether.Enable") && island.isRegionUnlocked(player, "Nether")) {
|
||||
teleportPlayerToWorld(player, soundManager, island, spawnEnvironment, tick, toWorld);
|
||||
}
|
||||
break;
|
||||
|
||||
case End:
|
||||
if (configLoad.getBoolean("Island.World.End.Enable") && island.isRegionUnlocked(player, "End")) {
|
||||
case Nether:
|
||||
if (configLoad.getBoolean("Island.World." + toWorld.name() + ".Enable") && island.isRegionUnlocked(player, toWorld)) {
|
||||
teleportPlayerToWorld(player, soundManager, island, spawnEnvironment, tick, toWorld);
|
||||
}
|
||||
break;
|
||||
|
@ -12,6 +12,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@ -158,11 +159,13 @@ public class PermissionManager {
|
||||
Method handler = wrapper.getHandler();
|
||||
if (handler.getParameterTypes()[0] != cancellable.getClass()) continue;
|
||||
|
||||
// if (cancellable.isCancelled()) return false;
|
||||
if (cancellable.isCancelled()) return false;
|
||||
if (cancellable instanceof Stoppable && ((Stoppable) cancellable).isStopped()) return true;
|
||||
|
||||
BasicPermission permission = wrapper.getPermission();
|
||||
|
||||
//if(cancellable instanceof PlayerMoveEvent) Bukkit.broadcastMessage("A " + permission.getName());
|
||||
|
||||
if (hasPermission(player, island, permission, reversePermission))
|
||||
continue;
|
||||
|
||||
@ -172,7 +175,7 @@ public class PermissionManager {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return cancellable.isCancelled();
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasPermission(Player player, Island island, BasicPermission permission, boolean reversePermission){
|
||||
|
@ -35,11 +35,24 @@ public class PortalPermission extends ListeningPermission {
|
||||
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
player.teleport(getToLocation(event.getLocation(), player));
|
||||
//player.teleport(getToLocation(event.getLocation(), player));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onMove(PlayerMoveEvent event) {
|
||||
if(event.getTo() != null){
|
||||
CompatibleMaterial toMaterial = CompatibleMaterial.getMaterial(event.getTo().getBlock().getType());
|
||||
|
||||
if (toMaterial == CompatibleMaterial.NETHER_PORTAL || toMaterial == CompatibleMaterial.END_PORTAL) {
|
||||
//event.setTo(LocationUtil.getRandomLocation(event.getFrom().getWorld(), 5000, 5000, true, true));
|
||||
cancelAndMessage(event, event.getPlayer(), plugin, messageManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@PermissionHandler
|
||||
public void onTeleport(PlayerTeleportEvent event) {
|
||||
if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.ENDER_PEARL)
|
||||
@ -47,12 +60,12 @@ public class PortalPermission extends ListeningPermission {
|
||||
|| event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)
|
||||
|| (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)
|
||||
&& 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);
|
||||
event.setTo(to);*/
|
||||
|
||||
cancelAndMessage(event, event.getPlayer(), plugin, messageManager);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user