mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-09-03 18:40:35 +02: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 {
|
||||
|
||||
private final SkyBlock skyblock;
|
||||
private final SkyBlock skyblock;
|
||||
|
||||
public Move(SkyBlock skyblock) {
|
||||
this.skyblock = skyblock;
|
||||
}
|
||||
public Move(SkyBlock skyblock) {
|
||||
this.skyblock = skyblock;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
Location from = event.getFrom();
|
||||
Location to = event.getTo();
|
||||
Location from = event.getFrom();
|
||||
Location to = event.getTo();
|
||||
|
||||
if (to == null || (from.getBlockX() == to.getBlockX() && from.getBlockY() == to.getBlockY() && from.getBlockZ() == to.getBlockZ())) {
|
||||
return;
|
||||
}
|
||||
if (to == null || (from.getBlockX() == to.getBlockX() && from.getBlockY() == to.getBlockY() && from.getBlockZ() == to.getBlockZ())) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
WorldManager worldManager = skyblock.getWorldManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
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());
|
||||
IslandWorld world = worldManager.getIslandWorld(player.getWorld());
|
||||
|
||||
if (world == IslandWorld.Nether || world == IslandWorld.End) {
|
||||
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.World." + world.name() + ".Enable")) {
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
if (world == IslandWorld.Nether || world == IslandWorld.End) {
|
||||
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.World." + world.name() + ".Enable")) {
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.World.Message")
|
||||
.replace(configLoad.getString("Island.World.Word." + world.name()), world.name()));
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.World.Message")
|
||||
.replace(configLoad.getString("Island.World.Word." + world.name()), world.name()));
|
||||
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
|
||||
if (playerData.getIsland() != null) {
|
||||
Island island = islandManager
|
||||
.getIsland(Bukkit.getServer().getOfflinePlayer(playerData.getIsland()));
|
||||
if (playerData.getIsland() != null) {
|
||||
Island island = islandManager
|
||||
.getIsland(Bukkit.getServer().getOfflinePlayer(playerData.getIsland()));
|
||||
|
||||
if (island != null) {
|
||||
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));
|
||||
}
|
||||
if (island != null) {
|
||||
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);
|
||||
player.setFallDistance(0.0F);
|
||||
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LocationUtil.teleportPlayerToSpawn(player);
|
||||
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
LocationUtil.teleportPlayerToSpawn(player);
|
||||
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
|
||||
if (playerData.getIsland() != null) {
|
||||
Island island = islandManager
|
||||
.getIsland(Bukkit.getServer().getOfflinePlayer(playerData.getIsland()));
|
||||
if (playerData.getIsland() != null) {
|
||||
Island island = islandManager
|
||||
.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) {
|
||||
if (islandManager.isLocationAtIsland(island, to)) {
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
LocationUtil.teleportPlayerToSpawn(player);
|
||||
|
||||
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 (!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);
|
||||
}
|
||||
}
|
||||
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.placeholder.PlaceholderManager;
|
||||
import com.songoda.skyblock.utils.NumberUtil;
|
||||
import com.songoda.skyblock.utils.version.NMSUtil;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -72,8 +74,8 @@ public class Scoreboard {
|
|||
|
||||
String formattedDisplayName = ChatColor.translateAlternateColorCodes('&',
|
||||
replaceDisplayName(displayName));
|
||||
|
||||
if (formattedDisplayName.length() > 32) {
|
||||
int max = NMSUtil.getVersionNumber() > 8 ? 32 : 16;
|
||||
if (formattedDisplayName.length() > max) {
|
||||
obj.setDisplayName(ChatColor.RED + "Too long...");
|
||||
} else {
|
||||
obj.setDisplayName(formattedDisplayName);
|
||||
|
@ -101,7 +103,7 @@ public class Scoreboard {
|
|||
String formattedDisplayName = ChatColor.translateAlternateColorCodes('&',
|
||||
replaceDisplayName(displayName));
|
||||
|
||||
if (formattedDisplayName.length() > 32) {
|
||||
if (formattedDisplayName.length() > max) {
|
||||
obj.setDisplayName(ChatColor.RED + "Too long...");
|
||||
} else {
|
||||
obj.setDisplayName(formattedDisplayName);
|
||||
|
|
Loading…
Reference in New Issue
Block a user