mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-02-18 20:51:42 +01:00
Fix scoreboards and liquid check
This commit is contained in:
parent
586abfab8d
commit
e27b4f86ea
@ -26,197 +26,194 @@ import java.io.File;
|
|||||||
|
|
||||||
public class Move implements Listener {
|
public class Move implements Listener {
|
||||||
|
|
||||||
private final SkyBlock skyblock;
|
private final SkyBlock skyblock;
|
||||||
|
|
||||||
public Move(SkyBlock skyblock) {
|
public Move(SkyBlock skyblock) {
|
||||||
this.skyblock = skyblock;
|
this.skyblock = skyblock;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
Location from = event.getFrom();
|
Location from = event.getFrom();
|
||||||
Location to = event.getTo();
|
Location to = event.getTo();
|
||||||
|
|
||||||
if (to == null || (from.getBlockX() == to.getBlockX() && from.getBlockY() == to.getBlockY() && from.getBlockZ() == to.getBlockZ())) {
|
if (to == null || (from.getBlockX() == to.getBlockX() && from.getBlockY() == to.getBlockY() && from.getBlockZ() == to.getBlockZ())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||||
MessageManager messageManager = skyblock.getMessageManager();
|
MessageManager messageManager = skyblock.getMessageManager();
|
||||||
IslandManager islandManager = skyblock.getIslandManager();
|
IslandManager islandManager = skyblock.getIslandManager();
|
||||||
SoundManager soundManager = skyblock.getSoundManager();
|
SoundManager soundManager = skyblock.getSoundManager();
|
||||||
WorldManager worldManager = skyblock.getWorldManager();
|
WorldManager worldManager = skyblock.getWorldManager();
|
||||||
FileManager fileManager = skyblock.getFileManager();
|
FileManager fileManager = skyblock.getFileManager();
|
||||||
|
|
||||||
if (!worldManager.isIslandWorld(player.getWorld()))
|
if (!worldManager.isIslandWorld(player.getWorld()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
IslandWorld world = worldManager.getIslandWorld(player.getWorld());
|
IslandWorld world = worldManager.getIslandWorld(player.getWorld());
|
||||||
|
|
||||||
if (world == IslandWorld.Nether || world == IslandWorld.End) {
|
if (world == IslandWorld.Nether || world == IslandWorld.End) {
|
||||||
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||||
.getBoolean("Island.World." + world.name() + ".Enable")) {
|
.getBoolean("Island.World." + world.name() + ".Enable")) {
|
||||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||||
FileConfiguration configLoad = config.getFileConfiguration();
|
FileConfiguration configLoad = config.getFileConfiguration();
|
||||||
|
|
||||||
messageManager.sendMessage(player, configLoad.getString("Island.World.Message")
|
messageManager.sendMessage(player, configLoad.getString("Island.World.Message")
|
||||||
.replace(configLoad.getString("Island.World.Word." + world.name()), world.name()));
|
.replace(configLoad.getString("Island.World.Word." + world.name()), world.name()));
|
||||||
|
|
||||||
if (playerDataManager.hasPlayerData(player)) {
|
if (playerDataManager.hasPlayerData(player)) {
|
||||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||||
|
|
||||||
if (playerData.getIsland() != null) {
|
if (playerData.getIsland() != null) {
|
||||||
Island island = islandManager
|
Island island = islandManager
|
||||||
.getIsland(Bukkit.getServer().getOfflinePlayer(playerData.getIsland()));
|
.getIsland(Bukkit.getServer().getOfflinePlayer(playerData.getIsland()));
|
||||||
|
|
||||||
if (island != null) {
|
if (island != null) {
|
||||||
if (island.hasRole(IslandRole.Member, player.getUniqueId())
|
if (island.hasRole(IslandRole.Member, player.getUniqueId())
|
||||||
|| island.hasRole(IslandRole.Operator, player.getUniqueId())
|
|| island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||||
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
|
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
|
||||||
} else {
|
} else {
|
||||||
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor));
|
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor));
|
||||||
}
|
}
|
||||||
|
|
||||||
player.setFallDistance(0.0F);
|
player.setFallDistance(0.0F);
|
||||||
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LocationUtil.teleportPlayerToSpawn(player);
|
LocationUtil.teleportPlayerToSpawn(player);
|
||||||
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerDataManager.hasPlayerData(player)) {
|
if (playerDataManager.hasPlayerData(player)) {
|
||||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||||
|
|
||||||
if (playerData.getIsland() != null) {
|
if (playerData.getIsland() != null) {
|
||||||
Island island = islandManager
|
Island island = islandManager
|
||||||
.getIsland(Bukkit.getServer().getOfflinePlayer(playerData.getIsland()));
|
.getIsland(Bukkit.getServer().getOfflinePlayer(playerData.getIsland()));
|
||||||
|
|
||||||
|
if (island != null) {
|
||||||
|
if (islandManager.isLocationAtIsland(island, to)) {
|
||||||
|
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||||
|
FileConfiguration configLoad = config.getFileConfiguration();
|
||||||
|
|
||||||
|
boolean keepItemsOnDeath;
|
||||||
|
|
||||||
|
if (configLoad.getBoolean("Island.Settings.KeepItemsOnDeath.Enable")) {
|
||||||
|
keepItemsOnDeath = island.getSetting(IslandRole.Owner, "KeepItemsOnDeath").getStatus();
|
||||||
|
} else {
|
||||||
|
keepItemsOnDeath = configLoad.getBoolean("Island.KeepItemsOnDeath.Enable");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configLoad.getBoolean("Island.World." + world.name() + ".Liquid.Enable")) {
|
||||||
|
if (to.getY() <= configLoad.getInt("Island.World." + world.name() + ".Liquid.Height")) {
|
||||||
|
if (keepItemsOnDeath && configLoad.getBoolean("Island.Liquid.Teleport.Enable")) {
|
||||||
|
player.setFallDistance(0.0F);
|
||||||
|
|
||||||
|
if (island.hasRole(IslandRole.Member, player.getUniqueId())
|
||||||
|
|| island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||||
|
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||||
|
player.teleport(
|
||||||
|
island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
|
||||||
|
} else {
|
||||||
|
player.teleport(
|
||||||
|
island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor));
|
||||||
|
}
|
||||||
|
|
||||||
|
player.setFallDistance(0.0F);
|
||||||
|
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F,
|
||||||
|
1.0F);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configLoad.getBoolean("Island.Void.Teleport.Enable")) {
|
||||||
|
if (to.getY() <= configLoad.getInt("Island.Void.Teleport.Offset")) {
|
||||||
|
if (configLoad.getBoolean("Island.Void.Teleport.ClearInventory")) {
|
||||||
|
player.getInventory().clear();
|
||||||
|
player.setLevel(0);
|
||||||
|
player.setExp(0.0F);
|
||||||
|
|
||||||
|
if (NMSUtil.getVersionNumber() > 8) {
|
||||||
|
player.setHealth(
|
||||||
|
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
||||||
|
} else {
|
||||||
|
player.setHealth(player.getMaxHealth());
|
||||||
|
}
|
||||||
|
|
||||||
|
player.setFoodLevel(20);
|
||||||
|
|
||||||
|
for (PotionEffect potionEffect : player.getActivePotionEffects()) {
|
||||||
|
player.removePotionEffect(potionEffect.getType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
player.setFallDistance(0.0F);
|
||||||
|
|
||||||
|
if (configLoad.getBoolean("Island.Void.Teleport.Island")) {
|
||||||
|
if (island.hasRole(IslandRole.Member, player.getUniqueId())
|
||||||
|
|| island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||||
|
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||||
|
player.teleport(
|
||||||
|
island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
|
||||||
|
} else {
|
||||||
|
player.teleport(
|
||||||
|
island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LocationUtil.teleportPlayerToSpawn(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
player.setFallDistance(0.0F);
|
||||||
|
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!LocationUtil.isLocationAtLocationRadius(island.getLocation(world, IslandEnvironment.Island), to, island.getRadius() + 0.5)) {
|
||||||
|
if (island.getVisit().isVisitor(player.getUniqueId())) {
|
||||||
|
player.teleport(island.getLocation(world, IslandEnvironment.Visitor));
|
||||||
|
} else {
|
||||||
|
player.teleport(island.getLocation(world, IslandEnvironment.Main));
|
||||||
|
}
|
||||||
|
|
||||||
|
player.setFallDistance(0.0F);
|
||||||
|
messageManager.sendMessage(player, skyblock.getFileManager()
|
||||||
|
.getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||||
|
.getFileConfiguration().getString("Island.WorldBorder.Outside.Message"));
|
||||||
|
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load the island they are now on if one exists
|
||||||
|
if (player.hasPermission("fabledskyblock.bypass")) {
|
||||||
|
Island loadedIsland = islandManager.loadIslandAtLocation(player.getLocation());
|
||||||
|
if (loadedIsland != null) {
|
||||||
|
playerData.setIsland(loadedIsland.getOwnerUUID());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (island != null) {
|
LocationUtil.teleportPlayerToSpawn(player);
|
||||||
if (islandManager.isLocationAtIsland(island, to)) {
|
|
||||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
|
||||||
FileConfiguration configLoad = config.getFileConfiguration();
|
|
||||||
|
|
||||||
boolean keepItemsOnDeath;
|
messageManager.sendMessage(player,
|
||||||
|
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||||
if (configLoad.getBoolean("Island.Settings.KeepItemsOnDeath.Enable")) {
|
.getFileConfiguration().getString("Island.WorldBorder.Disappeared.Message"));
|
||||||
keepItemsOnDeath = island.getSetting(IslandRole.Owner, "KeepItemsOnDeath").getStatus();
|
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||||
} else {
|
}
|
||||||
keepItemsOnDeath = configLoad.getBoolean("Island.KeepItemsOnDeath.Enable");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (configLoad.getBoolean("Island.World." + world.name() + ".Liquid.Enable")) {
|
|
||||||
if (to.getY() <= configLoad.getInt("Island.World." + world.name() + ".Liquid.Height")) {
|
|
||||||
if (!configLoad.getBoolean("Island.Liquid.Teleport.Enable")) return;
|
|
||||||
if (keepItemsOnDeath) {
|
|
||||||
player.setFallDistance(0.0F);
|
|
||||||
|
|
||||||
if (island.hasRole(IslandRole.Member, player.getUniqueId())
|
|
||||||
|| island.hasRole(IslandRole.Operator, player.getUniqueId())
|
|
||||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
|
||||||
player.teleport(
|
|
||||||
island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
|
|
||||||
} else {
|
|
||||||
player.teleport(
|
|
||||||
island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor));
|
|
||||||
}
|
|
||||||
|
|
||||||
player.setFallDistance(0.0F);
|
|
||||||
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F,
|
|
||||||
1.0F);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (configLoad.getBoolean("Island.Void.Teleport.Enable")) {
|
|
||||||
if (to.getY() <= configLoad.getInt("Island.Void.Teleport.Offset")) {
|
|
||||||
if (configLoad.getBoolean("Island.Void.Teleport.ClearInventory")) {
|
|
||||||
player.getInventory().clear();
|
|
||||||
player.setLevel(0);
|
|
||||||
player.setExp(0.0F);
|
|
||||||
|
|
||||||
if (NMSUtil.getVersionNumber() > 8) {
|
|
||||||
player.setHealth(
|
|
||||||
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
|
||||||
} else {
|
|
||||||
player.setHealth(player.getMaxHealth());
|
|
||||||
}
|
|
||||||
|
|
||||||
player.setFoodLevel(20);
|
|
||||||
|
|
||||||
for (PotionEffect potionEffect : player.getActivePotionEffects()) {
|
|
||||||
player.removePotionEffect(potionEffect.getType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
player.setFallDistance(0.0F);
|
|
||||||
|
|
||||||
if (configLoad.getBoolean("Island.Void.Teleport.Island")) {
|
|
||||||
if (island.hasRole(IslandRole.Member, player.getUniqueId())
|
|
||||||
|| island.hasRole(IslandRole.Operator, player.getUniqueId())
|
|
||||||
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
|
||||||
player.teleport(
|
|
||||||
island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
|
|
||||||
} else {
|
|
||||||
player.teleport(
|
|
||||||
island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
LocationUtil.teleportPlayerToSpawn(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
player.setFallDistance(0.0F);
|
|
||||||
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!LocationUtil.isLocationAtLocationRadius(island.getLocation(world, IslandEnvironment.Island), to, island.getRadius() + 0.5)) {
|
|
||||||
if (island.getVisit().isVisitor(player.getUniqueId())) {
|
|
||||||
player.teleport(island.getLocation(world, IslandEnvironment.Visitor));
|
|
||||||
} else {
|
|
||||||
player.teleport(island.getLocation(world, IslandEnvironment.Main));
|
|
||||||
}
|
|
||||||
|
|
||||||
player.setFallDistance(0.0F);
|
|
||||||
messageManager.sendMessage(player, skyblock.getFileManager()
|
|
||||||
.getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
|
||||||
.getFileConfiguration().getString("Island.WorldBorder.Outside.Message"));
|
|
||||||
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the island they are now on if one exists
|
|
||||||
if (player.hasPermission("fabledskyblock.bypass")) {
|
|
||||||
Island loadedIsland = islandManager.loadIslandAtLocation(player.getLocation());
|
|
||||||
if (loadedIsland != null) {
|
|
||||||
playerData.setIsland(loadedIsland.getOwnerUUID());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
LocationUtil.teleportPlayerToSpawn(player);
|
|
||||||
|
|
||||||
messageManager.sendMessage(player,
|
|
||||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
|
||||||
.getFileConfiguration().getString("Island.WorldBorder.Disappeared.Message"));
|
|
||||||
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ import com.songoda.skyblock.island.IslandManager;
|
|||||||
import com.songoda.skyblock.island.IslandRole;
|
import com.songoda.skyblock.island.IslandRole;
|
||||||
import com.songoda.skyblock.placeholder.PlaceholderManager;
|
import com.songoda.skyblock.placeholder.PlaceholderManager;
|
||||||
import com.songoda.skyblock.utils.NumberUtil;
|
import com.songoda.skyblock.utils.NumberUtil;
|
||||||
|
import com.songoda.skyblock.utils.version.NMSUtil;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -72,8 +74,8 @@ public class Scoreboard {
|
|||||||
|
|
||||||
String formattedDisplayName = ChatColor.translateAlternateColorCodes('&',
|
String formattedDisplayName = ChatColor.translateAlternateColorCodes('&',
|
||||||
replaceDisplayName(displayName));
|
replaceDisplayName(displayName));
|
||||||
|
int max = NMSUtil.getVersionNumber() > 8 ? 32 : 16;
|
||||||
if (formattedDisplayName.length() > 32) {
|
if (formattedDisplayName.length() > max) {
|
||||||
obj.setDisplayName(ChatColor.RED + "Too long...");
|
obj.setDisplayName(ChatColor.RED + "Too long...");
|
||||||
} else {
|
} else {
|
||||||
obj.setDisplayName(formattedDisplayName);
|
obj.setDisplayName(formattedDisplayName);
|
||||||
@ -101,7 +103,7 @@ public class Scoreboard {
|
|||||||
String formattedDisplayName = ChatColor.translateAlternateColorCodes('&',
|
String formattedDisplayName = ChatColor.translateAlternateColorCodes('&',
|
||||||
replaceDisplayName(displayName));
|
replaceDisplayName(displayName));
|
||||||
|
|
||||||
if (formattedDisplayName.length() > 32) {
|
if (formattedDisplayName.length() > max) {
|
||||||
obj.setDisplayName(ChatColor.RED + "Too long...");
|
obj.setDisplayName(ChatColor.RED + "Too long...");
|
||||||
} else {
|
} else {
|
||||||
obj.setDisplayName(formattedDisplayName);
|
obj.setDisplayName(formattedDisplayName);
|
||||||
|
Loading…
Reference in New Issue
Block a user