mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-23 18:55:30 +01:00
A lot of changes. See Commit description
This commit is contained in:
parent
811e0b5d04
commit
24c60dd35d
@ -41,12 +41,14 @@ import com.songoda.update.SongodaUpdate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SkyBlock extends JavaPlugin {
|
||||
|
||||
|
@ -228,12 +228,26 @@ public class IslandManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an Island permanently
|
||||
* Executes the {@link IslandManager#deleteIsland(Island, boolean)} method with <code>island<code> and
|
||||
* <code>true<code> as the parameters
|
||||
* <p>
|
||||
* See {@link IslandManager#deleteIsland(Island, boolean)}
|
||||
*/
|
||||
public void deleteIsland(Island island) {
|
||||
Preconditions.checkArgument(island != null, "Cannot delete island to null island");
|
||||
|
||||
this.islandManager.deleteIsland(island.getIsland());
|
||||
this.islandManager.deleteIsland(island.getIsland(), true);
|
||||
}
|
||||
|
||||
/*
|
||||
* If force is set to true, the island will be deleted and no conditions will be
|
||||
* checked, else it will only delete the island if the island deletion
|
||||
* conditions are met.
|
||||
*/
|
||||
public void deleteIsland(Island island, boolean force) {
|
||||
Preconditions.checkArgument(island != null, "Cannot delete island to null island");
|
||||
|
||||
this.islandManager.deleteIsland(island.getIsland(), force);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -91,7 +91,7 @@ public class DeleteCommand extends SubCommand {
|
||||
}
|
||||
|
||||
island.setDeleted(true);
|
||||
islandManager.deleteIsland(island);
|
||||
islandManager.deleteIsland(island, true);
|
||||
|
||||
messageManager.sendMessage(sender,
|
||||
configLoad.getString("Command.Island.Admin.Delete.Deleted.Message").replace("%player",
|
||||
|
@ -19,6 +19,7 @@ import com.songoda.skyblock.limit.LimitationInstanceHandler;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.scoreboard.ScoreboardManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.item.MenuClickRegistry;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
|
||||
public class ReloadCommand extends SubCommand {
|
||||
@ -40,11 +41,11 @@ public class ReloadCommand extends SubCommand {
|
||||
LimitationInstanceHandler limitHandler = skyblock.getLimitationHandler();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
messageManager.sendMessage(sender, "&cPlease note that this command is not supported and may " +
|
||||
"cause issues that could put the plugin in an unstable state. " +
|
||||
"If you encounter any issues please stop your server, edit the configuration files, " +
|
||||
"and then start your server again. This command does NOT reload all the plugin files, only " +
|
||||
"the config.yml, language.yml, generators.yml, levelling.yml, and limits.yml.");
|
||||
messageManager.sendMessage(sender,
|
||||
"&cPlease note that this command is not supported and may " + "cause issues that could put the plugin in an unstable state. "
|
||||
+ "If you encounter any issues please stop your server, edit the configuration files, "
|
||||
+ "and then start your server again. This command does NOT reload all the plugin files, only "
|
||||
+ "the config.yml, language.yml, generators.yml, levelling.yml, and limits.yml.");
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
@ -56,8 +57,7 @@ public class ReloadCommand extends SubCommand {
|
||||
Config configFileConfig = configs.get(configFileName);
|
||||
String configFilePath = configFileName.replace(configFileConfig.getFile().getName(), "");
|
||||
|
||||
if (configFilePath.equals(skyblock.getDataFolder().toString() + "\\")
|
||||
|| configFilePath.equals(skyblock.getDataFolder().toString() + "/")) {
|
||||
if (configFilePath.equals(skyblock.getDataFolder().toString() + "\\") || configFilePath.equals(skyblock.getDataFolder().toString() + "/")) {
|
||||
configFileConfig.loadFile();
|
||||
}
|
||||
}
|
||||
@ -95,6 +95,7 @@ public class ReloadCommand extends SubCommand {
|
||||
});
|
||||
|
||||
limitHandler.reloadAll();
|
||||
MenuClickRegistry.getInstance().reloadAll();
|
||||
|
||||
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Reload.Reloaded.Message"));
|
||||
soundManager.playSound(sender, Sounds.ANVIL_USE.bukkitSound(), 1.0F, 1.0F);
|
||||
|
@ -9,7 +9,6 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.stackable.Stackable;
|
||||
|
@ -1,5 +1,13 @@
|
||||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.songoda.skyblock.ban.Ban;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
@ -7,19 +15,11 @@ import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.island.IslandWorld;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import com.songoda.skyblock.utils.world.LocationUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BanCommand extends SubCommand {
|
||||
|
||||
@ -40,16 +40,11 @@ public class BanCommand extends SubCommand {
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Visitor.Banning")) {
|
||||
} else if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning")) {
|
||||
if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Ban").getStatus())) {
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId()) && island.getSetting(IslandRole.Operator, "Ban").getStatus())) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
|
||||
if (targetPlayer != null && targetPlayer.hasPermission("fabledskyblock.bypass.ban"))
|
||||
return;
|
||||
|
||||
UUID targetPlayerUUID = null;
|
||||
String targetPlayerName = null;
|
||||
|
||||
@ -58,8 +53,6 @@ public class BanCommand extends SubCommand {
|
||||
targetPlayerUUID = targetPlayerOffline.getUniqueId();
|
||||
targetPlayerName = targetPlayerOffline.getName();
|
||||
|
||||
if (skyblock.getEconomyManager().hasPermission(skyblock.getWorldManager().getWorld(IslandWorld.Normal).getName(), Bukkit.getOfflinePlayer(targetPlayerUUID), "fabledskyblock.bypass.ban"))
|
||||
return;
|
||||
} else {
|
||||
targetPlayerUUID = targetPlayer.getUniqueId();
|
||||
targetPlayerName = targetPlayer.getName();
|
||||
@ -71,39 +64,35 @@ public class BanCommand extends SubCommand {
|
||||
} else if (targetPlayerUUID.equals(player.getUniqueId())) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Yourself.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Member, targetPlayerUUID)
|
||||
|| island.hasRole(IslandRole.Operator, targetPlayerUUID)
|
||||
} else if (island.hasRole(IslandRole.Member, targetPlayerUUID) || island.hasRole(IslandRole.Operator, targetPlayerUUID)
|
||||
|| island.hasRole(IslandRole.Owner, targetPlayerUUID)) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Member.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (island.getBan().isBanned(targetPlayerUUID)) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Already.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Command.Island.Ban.Banned.Sender.Message").replace("%player",
|
||||
targetPlayerName));
|
||||
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Member.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else
|
||||
if (island.getBan().isBanned(targetPlayerUUID)) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Already.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Banned.Sender.Message").replace("%player", targetPlayerName));
|
||||
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
if (island.isCoopPlayer(targetPlayerUUID)) {
|
||||
island.removeCoopPlayer(targetPlayerUUID);
|
||||
}
|
||||
if (island.isCoopPlayer(targetPlayerUUID)) {
|
||||
island.removeCoopPlayer(targetPlayerUUID);
|
||||
}
|
||||
|
||||
Ban ban = island.getBan();
|
||||
ban.addBan(player.getUniqueId(), targetPlayerUUID);
|
||||
ban.save();
|
||||
Ban ban = island.getBan();
|
||||
ban.addBan(player.getUniqueId(), targetPlayerUUID);
|
||||
ban.save();
|
||||
|
||||
if (targetPlayer != null) {
|
||||
if (islandManager.isPlayerAtIsland(island, targetPlayer)) {
|
||||
messageManager.sendMessage(targetPlayer,
|
||||
configLoad.getString("Command.Island.Ban.Banned.Target.Message")
|
||||
.replace("%player", player.getName()));
|
||||
soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
if (targetPlayer != null) {
|
||||
if (islandManager.isPlayerAtIsland(island, targetPlayer)) {
|
||||
messageManager.sendMessage(targetPlayer, configLoad.getString("Command.Island.Ban.Banned.Target.Message").replace("%player", player.getName()));
|
||||
soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
LocationUtil.teleportPlayerToSpawn(targetPlayer);
|
||||
LocationUtil.teleportPlayerToSpawn(targetPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
|
@ -165,12 +165,14 @@ public class ConfirmCommand extends SubCommand {
|
||||
}
|
||||
}
|
||||
|
||||
island.setDeleted(true);
|
||||
islandManager.deleteIsland(island);
|
||||
|
||||
messageManager.sendMessage(player, configLoad
|
||||
.getString("Command.Island.Confirmation.Deletion.Sender.Message"));
|
||||
soundManager.playSound(player, Sounds.EXPLODE.bukkitSound(), 10.0F, 10.0F);
|
||||
if (islandManager.deleteIsland(island, false)) {
|
||||
island.setDeleted(true);
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Deletion.Sender.Message"));
|
||||
soundManager.playSound(player, Sounds.EXPLODE.bukkitSound(), 10.0F, 10.0F);
|
||||
}else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Confirmation.Deletion.Sender.MaxDeletionMessage"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1f, 1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -1,5 +1,16 @@
|
||||
package com.songoda.skyblock.command.commands.island;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.songoda.skyblock.api.event.island.IslandKickEvent;
|
||||
import com.songoda.skyblock.api.utils.APIUtil;
|
||||
import com.songoda.skyblock.command.SubCommand;
|
||||
@ -8,7 +19,6 @@ import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import com.songoda.skyblock.island.IslandWorld;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.playerdata.PlayerData;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
@ -18,16 +28,6 @@ import com.songoda.skyblock.sound.SoundManager;
|
||||
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import com.songoda.skyblock.utils.world.LocationUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class KickCommand extends SubCommand {
|
||||
|
||||
@ -49,210 +49,174 @@ public class KickCommand extends SubCommand {
|
||||
Island island = islandManager.getIsland(player);
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player,
|
||||
languageConfig.getFileConfiguration().getString("Command.Island.Kick.Owner.Message"));
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& island.getSetting(IslandRole.Operator, "Kick").getStatus())) {
|
||||
UUID targetPlayerUUID = null;
|
||||
String targetPlayerName = null;
|
||||
|| (island.hasRole(IslandRole.Operator, player.getUniqueId()) && island.getSetting(IslandRole.Operator, "Kick").getStatus())) {
|
||||
UUID targetPlayerUUID = null;
|
||||
String targetPlayerName = null;
|
||||
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
|
||||
if (targetPlayer != null && targetPlayer.hasPermission("fabledskyblock.bypass.ban"))
|
||||
return;
|
||||
|
||||
Set<UUID> islandMembers = island.getRole(IslandRole.Member),
|
||||
islandOperators = island.getRole(IslandRole.Operator),
|
||||
islandVisitors = islandManager.getVisitorsAtIsland(island);
|
||||
|
||||
if (targetPlayer == null) {
|
||||
OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]);
|
||||
targetPlayerUUID = targetPlayerOffline.getUniqueId();
|
||||
targetPlayerName = targetPlayerOffline.getName();
|
||||
|
||||
if (skyblock.getEconomyManager().hasPermission(skyblock.getWorldManager().getWorld(IslandWorld.Normal).getName(), Bukkit.getOfflinePlayer(targetPlayerUUID), "fabledskyblock.bypass.ban"))
|
||||
return;
|
||||
} else {
|
||||
targetPlayerUUID = targetPlayer.getUniqueId();
|
||||
targetPlayerName = targetPlayer.getName();
|
||||
}
|
||||
|
||||
if (targetPlayerUUID.equals(player.getUniqueId())) {
|
||||
messageManager.sendMessage(player,
|
||||
languageConfig.getFileConfiguration().getString("Command.Island.Kick.Yourself.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (islandOperators.contains(player.getUniqueId())
|
||||
&& islandOperators.contains(targetPlayerUUID)) {
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration()
|
||||
.getString("Command.Island.Kick.Role.Operator.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (island.getOwnerUUID().equals(targetPlayerUUID)) {
|
||||
messageManager.sendMessage(player,
|
||||
languageConfig.getFileConfiguration().getString("Command.Island.Kick.Role.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (island.isOpen() && islandVisitors.contains(targetPlayerUUID) && targetPlayer != null) {
|
||||
if (island.isCoopPlayer(targetPlayerUUID)) {
|
||||
messageManager.sendMessage(player,
|
||||
languageConfig.getFileConfiguration().getString("Command.Island.Kick.Cooped.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
IslandKickEvent islandKickEvent = new IslandKickEvent(island.getAPIWrapper(),
|
||||
APIUtil.fromImplementation(IslandRole.Visitor),
|
||||
Bukkit.getServer().getOfflinePlayer(targetPlayerUUID), player);
|
||||
|
||||
Bukkit.getScheduler().runTask(skyblock, () -> Bukkit.getServer().getPluginManager().callEvent(islandKickEvent));
|
||||
|
||||
if (!islandKickEvent.isCancelled()) {
|
||||
LocationUtil.teleportPlayerToSpawn(targetPlayer);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
languageConfig.getFileConfiguration()
|
||||
.getString("Command.Island.Kick.Kicked.Sender.Message")
|
||||
.replace("%player", targetPlayerName));
|
||||
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
messageManager.sendMessage(targetPlayer,
|
||||
languageConfig.getFileConfiguration()
|
||||
.getString("Command.Island.Kick.Kicked.Target.Message")
|
||||
.replace("%player", player.getName()));
|
||||
soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
} else if (islandMembers.contains(targetPlayerUUID) || islandOperators.contains(targetPlayerUUID)) {
|
||||
IslandRole islandRole = IslandRole.Member;
|
||||
|
||||
if (islandOperators.contains(targetPlayerUUID)) {
|
||||
islandRole = IslandRole.Operator;
|
||||
}
|
||||
|
||||
IslandKickEvent islandKickEvent = new IslandKickEvent(island.getAPIWrapper(),
|
||||
APIUtil.fromImplementation(islandRole),
|
||||
Bukkit.getServer().getOfflinePlayer(targetPlayerUUID), player);
|
||||
|
||||
Bukkit.getScheduler().runTask(skyblock, () -> Bukkit.getServer().getPluginManager().callEvent(islandKickEvent));
|
||||
|
||||
if (!islandKickEvent.isCancelled()) {
|
||||
messageManager.sendMessage(player,
|
||||
languageConfig.getFileConfiguration()
|
||||
.getString("Command.Island.Kick.Kicked.Sender.Message")
|
||||
.replace("%player", targetPlayerName));
|
||||
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
Set<UUID> islandMembers = island.getRole(IslandRole.Member), islandOperators = island.getRole(IslandRole.Operator),
|
||||
islandVisitors = islandManager.getVisitorsAtIsland(island);
|
||||
|
||||
if (targetPlayer == null) {
|
||||
Config config = fileManager
|
||||
.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"),
|
||||
targetPlayerUUID.toString() + ".yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
configLoad.set("Statistics.Island.Playtime", null);
|
||||
configLoad.set("Statistics.Island.Join", null);
|
||||
configLoad.set("Island.Owner", null);
|
||||
|
||||
try {
|
||||
configLoad.save(config.getFile());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
OfflinePlayer targetPlayerOffline = new OfflinePlayer(args[0]);
|
||||
targetPlayerUUID = targetPlayerOffline.getUniqueId();
|
||||
targetPlayerName = targetPlayerOffline.getName();
|
||||
} else {
|
||||
messageManager.sendMessage(targetPlayer,
|
||||
languageConfig.getFileConfiguration()
|
||||
.getString("Command.Island.Kick.Kicked.Target.Message")
|
||||
.replace("%player", player.getName()));
|
||||
soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
if (islandManager.isPlayerAtIsland(island, targetPlayer)) {
|
||||
LocationUtil.teleportPlayerToSpawn(targetPlayer);
|
||||
}
|
||||
|
||||
if (scoreboardManager != null) {
|
||||
Scoreboard scoreboard = scoreboardManager.getScoreboard(targetPlayer);
|
||||
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', languageConfig
|
||||
.getFileConfiguration().getString("Scoreboard.Tutorial.Displayname")));
|
||||
scoreboard.setDisplayList(languageConfig.getFileConfiguration()
|
||||
.getStringList("Scoreboard.Tutorial.Displaylines"));
|
||||
scoreboard.run();
|
||||
}
|
||||
|
||||
playerData = playerDataManager.getPlayerData(targetPlayer);
|
||||
playerData.setPlaytime(0);
|
||||
playerData.setMemberSince(null);
|
||||
playerData.setOwner(null);
|
||||
playerData.setChat(false);
|
||||
playerData.save();
|
||||
targetPlayerUUID = targetPlayer.getUniqueId();
|
||||
targetPlayerName = targetPlayer.getName();
|
||||
}
|
||||
|
||||
if (islandMembers.contains(targetPlayerUUID)) {
|
||||
island.removeRole(IslandRole.Member, targetPlayerUUID);
|
||||
} else if (islandOperators.contains(targetPlayerUUID)) {
|
||||
island.removeRole(IslandRole.Operator, targetPlayerUUID);
|
||||
}
|
||||
if (targetPlayerUUID.equals(player.getUniqueId())) {
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Yourself.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (islandOperators.contains(player.getUniqueId()) && islandOperators.contains(targetPlayerUUID)) {
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Role.Operator.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (island.getOwnerUUID().equals(targetPlayerUUID)) {
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Role.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (island.isOpen() && islandVisitors.contains(targetPlayerUUID) && targetPlayer != null) {
|
||||
if (island.isCoopPlayer(targetPlayerUUID)) {
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Cooped.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
IslandKickEvent islandKickEvent = new IslandKickEvent(island.getAPIWrapper(), APIUtil.fromImplementation(IslandRole.Visitor),
|
||||
Bukkit.getServer().getOfflinePlayer(targetPlayerUUID), player);
|
||||
|
||||
island.save();
|
||||
Bukkit.getScheduler().runTask(skyblock, () -> Bukkit.getServer().getPluginManager().callEvent(islandKickEvent));
|
||||
|
||||
Set<UUID> islandMembersOnline = islandManager.getMembersOnline(island);
|
||||
if (!islandKickEvent.isCancelled()) {
|
||||
LocationUtil.teleportPlayerToSpawn(targetPlayer);
|
||||
|
||||
if (islandMembersOnline.size() == 1) {
|
||||
for (UUID islandMembersOnlineList : islandMembersOnline) {
|
||||
if (!islandMembersOnlineList.equals(player.getUniqueId())) {
|
||||
targetPlayer = Bukkit.getServer().getPlayer(islandMembersOnlineList);
|
||||
PlayerData targetPlayerData = playerDataManager.getPlayerData(targetPlayer);
|
||||
messageManager.sendMessage(player,
|
||||
languageConfig.getFileConfiguration().getString("Command.Island.Kick.Kicked.Sender.Message").replace("%player", targetPlayerName));
|
||||
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
if (targetPlayerData.isChat()) {
|
||||
targetPlayerData.setChat(false);
|
||||
messageManager.sendMessage(targetPlayer, fileManager
|
||||
.getConfig(new File(skyblock.getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Island.Chat.Untoggled.Message"));
|
||||
messageManager.sendMessage(targetPlayer,
|
||||
languageConfig.getFileConfiguration().getString("Command.Island.Kick.Kicked.Target.Message").replace("%player", player.getName()));
|
||||
soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
} else if (islandMembers.contains(targetPlayerUUID) || islandOperators.contains(targetPlayerUUID)) {
|
||||
IslandRole islandRole = IslandRole.Member;
|
||||
|
||||
if (islandOperators.contains(targetPlayerUUID)) {
|
||||
islandRole = IslandRole.Operator;
|
||||
}
|
||||
|
||||
IslandKickEvent islandKickEvent = new IslandKickEvent(island.getAPIWrapper(), APIUtil.fromImplementation(islandRole),
|
||||
Bukkit.getServer().getOfflinePlayer(targetPlayerUUID), player);
|
||||
|
||||
Bukkit.getScheduler().runTask(skyblock, () -> Bukkit.getServer().getPluginManager().callEvent(islandKickEvent));
|
||||
|
||||
if (!islandKickEvent.isCancelled()) {
|
||||
messageManager.sendMessage(player,
|
||||
languageConfig.getFileConfiguration().getString("Command.Island.Kick.Kicked.Sender.Message").replace("%player", targetPlayerName));
|
||||
soundManager.playSound(player, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
if (targetPlayer == null) {
|
||||
Config config = fileManager.getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), targetPlayerUUID.toString() + ".yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
configLoad.set("Statistics.Island.Playtime", null);
|
||||
configLoad.set("Statistics.Island.Join", null);
|
||||
configLoad.set("Island.Owner", null);
|
||||
|
||||
try {
|
||||
configLoad.save(config.getFile());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(targetPlayer,
|
||||
languageConfig.getFileConfiguration().getString("Command.Island.Kick.Kicked.Target.Message").replace("%player", player.getName()));
|
||||
soundManager.playSound(targetPlayer, Sounds.IRONGOLEM_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
if (islandManager.isPlayerAtIsland(island, targetPlayer)) {
|
||||
LocationUtil.teleportPlayerToSpawn(targetPlayer);
|
||||
}
|
||||
|
||||
if (scoreboardManager != null) {
|
||||
Scoreboard scoreboard = scoreboardManager.getScoreboard(targetPlayer);
|
||||
scoreboard.setDisplayName(
|
||||
ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Scoreboard.Tutorial.Displayname")));
|
||||
scoreboard.setDisplayList(languageConfig.getFileConfiguration().getStringList("Scoreboard.Tutorial.Displaylines"));
|
||||
scoreboard.run();
|
||||
}
|
||||
|
||||
playerData = playerDataManager.getPlayerData(targetPlayer);
|
||||
playerData.setPlaytime(0);
|
||||
playerData.setMemberSince(null);
|
||||
playerData.setOwner(null);
|
||||
playerData.setChat(false);
|
||||
playerData.save();
|
||||
}
|
||||
|
||||
if (islandMembers.contains(targetPlayerUUID)) {
|
||||
island.removeRole(IslandRole.Member, targetPlayerUUID);
|
||||
} else if (islandOperators.contains(targetPlayerUUID)) {
|
||||
island.removeRole(IslandRole.Operator, targetPlayerUUID);
|
||||
}
|
||||
|
||||
island.save();
|
||||
|
||||
Set<UUID> islandMembersOnline = islandManager.getMembersOnline(island);
|
||||
|
||||
if (islandMembersOnline.size() == 1) {
|
||||
for (UUID islandMembersOnlineList : islandMembersOnline) {
|
||||
if (!islandMembersOnlineList.equals(player.getUniqueId())) {
|
||||
targetPlayer = Bukkit.getServer().getPlayer(islandMembersOnlineList);
|
||||
PlayerData targetPlayerData = playerDataManager.getPlayerData(targetPlayer);
|
||||
|
||||
if (targetPlayerData.isChat()) {
|
||||
targetPlayerData.setChat(false);
|
||||
messageManager.sendMessage(targetPlayer, fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
|
||||
.getString("Island.Chat.Untoggled.Message"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (scoreboardManager != null) {
|
||||
if (island.getRole(IslandRole.Member).size() == 0 && island.getRole(IslandRole.Operator).size() == 0) {
|
||||
Scoreboard scoreboard = scoreboardManager.getScoreboard(player);
|
||||
scoreboard.setDisplayName(
|
||||
ChatColor.translateAlternateColorCodes('&', languageConfig.getFileConfiguration().getString("Scoreboard.Island.Solo.Displayname")));
|
||||
|
||||
if (islandManager.getVisitorsAtIsland(island).size() == 0) {
|
||||
scoreboard.setDisplayList(languageConfig.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Empty.Displaylines"));
|
||||
} else {
|
||||
scoreboard.setDisplayList(languageConfig.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Occupied.Displaylines"));
|
||||
}
|
||||
|
||||
scoreboard.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (scoreboardManager != null) {
|
||||
if (island.getRole(IslandRole.Member).size() == 0
|
||||
&& island.getRole(IslandRole.Operator).size() == 0) {
|
||||
Scoreboard scoreboard = scoreboardManager.getScoreboard(player);
|
||||
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', languageConfig
|
||||
.getFileConfiguration().getString("Scoreboard.Island.Solo.Displayname")));
|
||||
|
||||
if (islandManager.getVisitorsAtIsland(island).size() == 0) {
|
||||
scoreboard.setDisplayList(languageConfig.getFileConfiguration()
|
||||
.getStringList("Scoreboard.Island.Solo.Empty.Displaylines"));
|
||||
} else {
|
||||
scoreboard.setDisplayList(languageConfig.getFileConfiguration()
|
||||
.getStringList("Scoreboard.Island.Solo.Occupied.Displaylines"));
|
||||
}
|
||||
|
||||
scoreboard.run();
|
||||
} else {
|
||||
if (island.isOpen()) {
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Occupant.Visit.Open.Message"));
|
||||
} else {
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Occupant.Visit.Closed.Message"));
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (island.isOpen()) {
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration()
|
||||
.getString("Command.Island.Kick.Occupant.Visit.Open.Message"));
|
||||
} else {
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration()
|
||||
.getString("Command.Island.Kick.Occupant.Visit.Closed.Message"));
|
||||
if (island.isOpen()) {
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Permission.Visit.Open.Message"));
|
||||
} else {
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Permission.Visit.Closed.Message"));
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
if (island.isOpen()) {
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration()
|
||||
.getString("Command.Island.Kick.Permission.Visit.Open.Message"));
|
||||
} else {
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration()
|
||||
.getString("Command.Island.Kick.Permission.Visit.Closed.Message"));
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player,
|
||||
languageConfig.getFileConfiguration().getString("Command.Island.Kick.Invalid.Message"));
|
||||
messageManager.sendMessage(player, languageConfig.getFileConfiguration().getString("Command.Island.Kick.Invalid.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
});
|
||||
|
@ -114,9 +114,8 @@ public class GeneratorManager {
|
||||
@SuppressWarnings("deprecation")
|
||||
public BlockState generateBlock(Generator generator, Block block) {
|
||||
Materials materials = getRandomMaterials(generator);
|
||||
if (materials == null)
|
||||
return block.getState();
|
||||
|
||||
if (materials == null) return block.getState();
|
||||
|
||||
skyblock.getSoundManager().playSound(block.getLocation(), Sounds.FIZZ.bukkitSound(), 1.0F, 10.0F);
|
||||
|
||||
if (NMSUtil.getVersionNumber() > 12) {
|
||||
@ -127,8 +126,7 @@ public class GeneratorManager {
|
||||
|
||||
try {
|
||||
block.getClass().getMethod("setData", byte.class).invoke(block, (byte) is.getDurability());
|
||||
} catch (IllegalAccessException | IllegalArgumentException
|
||||
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ import com.songoda.skyblock.structure.StructureManager;
|
||||
import com.songoda.skyblock.upgrade.Upgrade;
|
||||
import com.songoda.skyblock.upgrade.UpgradeManager;
|
||||
import com.songoda.skyblock.utils.player.OfflinePlayer;
|
||||
import com.songoda.skyblock.utils.player.PlayerUtil;
|
||||
import com.songoda.skyblock.utils.structure.SchematicUtil;
|
||||
import com.songoda.skyblock.utils.structure.StructureUtil;
|
||||
import com.songoda.skyblock.utils.version.Materials;
|
||||
@ -162,6 +163,21 @@ public class IslandManager {
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
BanManager banManager = skyblock.getBanManager();
|
||||
|
||||
PlayerData data = skyblock.getPlayerDataManager().getPlayerData(player);
|
||||
|
||||
long amt = 0;
|
||||
|
||||
if (data != null) {
|
||||
final int highest = PlayerUtil.getNumberFromPermission(player, "fabledskyblock.limit.create", true, 2);
|
||||
|
||||
if ((amt = data.getIslandCreationCount()) >= highest) {
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Creator.Error.MaxCreationMessage"));
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml")).getFileConfiguration().getString("Location.Spawn") == null) {
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Creator.Error.Message"));
|
||||
@ -170,6 +186,8 @@ public class IslandManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
data.setIslandCreationCount(amt + 1);
|
||||
|
||||
Island island = new Island(player);
|
||||
island.setStructure(structure.getName());
|
||||
islandStorage.put(player.getUniqueId(), island);
|
||||
@ -231,12 +249,6 @@ public class IslandManager {
|
||||
}
|
||||
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(skyblock, () -> {
|
||||
if (structure.getCommands() != null) {
|
||||
for (String commandList : structure.getCommands()) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), commandList.replace("%player", player.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
|
||||
player.setFallDistance(0.0F);
|
||||
}, configLoad.getInt("Island.Creation.TeleportTimeout") * 20);
|
||||
@ -250,7 +262,14 @@ public class IslandManager {
|
||||
}
|
||||
Biome biome = sBiome.getBiome();
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> skyblock.getBiomeManager().setBiome(island, biome), 20L);
|
||||
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> {
|
||||
skyblock.getBiomeManager().setBiome(island, biome);
|
||||
if (structure.getCommands() != null) {
|
||||
for (String commandList : structure.getCommands()) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), commandList.replace("%player", player.getName()));
|
||||
}
|
||||
}
|
||||
}, 20L);
|
||||
|
||||
// Recalculate island level after 5 seconds
|
||||
if (configLoad.getBoolean("Island.Levelling.ScanAutomatically"))
|
||||
@ -373,14 +392,31 @@ public class IslandManager {
|
||||
|
||||
int j = 0;
|
||||
|
||||
public void deleteIsland(Island island) {
|
||||
public boolean deleteIsland(Island island, boolean force) {
|
||||
ScoreboardManager scoreboardManager = skyblock.getScoreboardManager();
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
CooldownManager cooldownManager = skyblock.getCooldownManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
WorldManager worldManager = skyblock.getWorldManager();
|
||||
|
||||
// Delete island from world.
|
||||
if (!force) {
|
||||
PlayerData data = playerDataManager.getPlayerData(island.getOwnerUUID());
|
||||
|
||||
if (data != null) {
|
||||
|
||||
final Player player = data.getPlayer();
|
||||
|
||||
if (player != null) {
|
||||
|
||||
long amt = 0;
|
||||
final int highest = PlayerUtil.getNumberFromPermission(player, "fabledskyblock.limit.delete", true, 1);
|
||||
|
||||
if ((amt = data.getIslandDeletionCount()) >= highest) return false;
|
||||
|
||||
data.setIslandDeletionCount(amt + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final Map<World, List<ChunkSnapshot>> snapshots = new HashMap<>(3);
|
||||
|
||||
@ -462,6 +498,7 @@ public class IslandManager {
|
||||
Bukkit.getServer().getPluginManager().callEvent(new IslandDeleteEvent(island.getAPIWrapper()));
|
||||
|
||||
islandStorage.remove(island.getOwnerUUID());
|
||||
return true;
|
||||
}
|
||||
|
||||
public void deleteIslandData(UUID uuid) {
|
||||
@ -1171,16 +1208,17 @@ public class IslandManager {
|
||||
}
|
||||
|
||||
public Set<UUID> getCoopPlayersAtIsland(Island island) {
|
||||
Set<UUID> coopPlayersAtIsland = new HashSet<>();
|
||||
final Set<UUID> coopPlayersAtIsland = new HashSet<>();
|
||||
|
||||
if (island != null) {
|
||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
if (island.getCoopPlayers().containsKey(all.getUniqueId())) {
|
||||
if (isPlayerAtIsland(island, all)) {
|
||||
coopPlayersAtIsland.add(all.getUniqueId());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (island == null) return coopPlayersAtIsland;
|
||||
|
||||
for (UUID coopUUID : island.getCoopPlayers().keySet()) {
|
||||
|
||||
final Player player = Bukkit.getPlayer(coopUUID);
|
||||
|
||||
if (player == null) continue;
|
||||
|
||||
if (isPlayerAtIsland(island, player)) coopPlayersAtIsland.add(coopUUID);
|
||||
}
|
||||
|
||||
return coopPlayersAtIsland;
|
||||
|
@ -28,8 +28,7 @@ public class LeaderboardManager {
|
||||
this.skyblock = skyblock;
|
||||
|
||||
new LeaderboardTask(skyblock).runTaskTimerAsynchronously(skyblock, 0L,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getInt("Island.Leaderboard.Reset.Time") * 20);
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getInt("Island.Leaderboard.Reset.Time") * 20);
|
||||
|
||||
resetLeaderboard();
|
||||
setupLeaderHeads();
|
||||
@ -43,18 +42,16 @@ public class LeaderboardManager {
|
||||
visitManager.loadIslands();
|
||||
|
||||
int arraySize = visitManager.getIslands().size();
|
||||
|
||||
|
||||
List<LeaderboardPlayer> islandLevels = new ArrayList<>(arraySize);
|
||||
List<LeaderboardPlayer> islandBanks = new ArrayList<>(arraySize);
|
||||
List<LeaderboardPlayer> islandVotes = new ArrayList<>(arraySize);
|
||||
|
||||
boolean enableExemptions = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Leaderboard.Exemptions.Enable");
|
||||
boolean enableExemptions = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Leaderboard.Exemptions.Enable");
|
||||
|
||||
for (UUID ownerUUID : visitManager.getIslands().keySet()) {
|
||||
if (enableExemptions && economyManager.hasPermission(worldManager.getWorld(IslandWorld.Normal).getName(),
|
||||
Bukkit.getOfflinePlayer(ownerUUID),
|
||||
"fabledskyblock.top.exempt"))
|
||||
if (enableExemptions && economyManager.hasPermission(worldManager.getWorld(IslandWorld.Normal).getName(), Bukkit.getOfflinePlayer(ownerUUID), "fabledskyblock.top.exempt"))
|
||||
continue;
|
||||
|
||||
Visit visit = visitManager.getIslands().get(ownerUUID);
|
||||
@ -92,23 +89,23 @@ public class LeaderboardManager {
|
||||
List<LeaderboardPlayer> leaderboardPlayers = new ArrayList<>(visitManager.getIslands().size());
|
||||
|
||||
switch (type) {
|
||||
case Level:
|
||||
for (UUID ownerUUID : visitManager.getIslands().keySet()) {
|
||||
Visit visit = visitManager.getIslands().get(ownerUUID);
|
||||
leaderboardPlayers.add(new LeaderboardPlayer(ownerUUID, visit.getLevel().getLevel()));
|
||||
}
|
||||
break;
|
||||
case Bank:
|
||||
for (UUID ownerUUID : visitManager.getIslands().keySet()) {
|
||||
Visit visit = visitManager.getIslands().get(ownerUUID);
|
||||
leaderboardPlayers.add(new LeaderboardPlayer(ownerUUID, (long) visit.getBankBalance()));
|
||||
}
|
||||
case Votes:
|
||||
for (UUID ownerUUID : visitManager.getIslands().keySet()) {
|
||||
Visit visit = visitManager.getIslands().get(ownerUUID);
|
||||
leaderboardPlayers.add(new LeaderboardPlayer(ownerUUID, visit.getVoters().size()));
|
||||
}
|
||||
break;
|
||||
case Level:
|
||||
for (UUID ownerUUID : visitManager.getIslands().keySet()) {
|
||||
Visit visit = visitManager.getIslands().get(ownerUUID);
|
||||
leaderboardPlayers.add(new LeaderboardPlayer(ownerUUID, visit.getLevel().getLevel()));
|
||||
}
|
||||
break;
|
||||
case Bank:
|
||||
for (UUID ownerUUID : visitManager.getIslands().keySet()) {
|
||||
Visit visit = visitManager.getIslands().get(ownerUUID);
|
||||
leaderboardPlayers.add(new LeaderboardPlayer(ownerUUID, (long) visit.getBankBalance()));
|
||||
}
|
||||
case Votes:
|
||||
for (UUID ownerUUID : visitManager.getIslands().keySet()) {
|
||||
Visit visit = visitManager.getIslands().get(ownerUUID);
|
||||
leaderboardPlayers.add(new LeaderboardPlayer(ownerUUID, visit.getVoters().size()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
leaderboardPlayers.sort(Comparator.comparingLong(LeaderboardPlayer::getValue).reversed());
|
||||
|
@ -17,9 +17,7 @@ public class TopLevel extends DataCollector {
|
||||
|
||||
public TopLevel(SkyBlock skyblock) {
|
||||
super("toplevels", skyblock.getDescription().getName(), BoardType.DEFAULT, "&bTop Level", "toplevel",
|
||||
Arrays.asList(ChatColor.DARK_GRAY + "-=+=-", ChatColor.AQUA + "{name}",
|
||||
ChatColor.WHITE + "{amount} Level", ChatColor.DARK_GRAY + "-=+=-"),
|
||||
true, UUID.class);
|
||||
Arrays.asList(ChatColor.DARK_GRAY + "-=+=-", ChatColor.AQUA + "{name}", ChatColor.WHITE + "{amount} Level", ChatColor.DARK_GRAY + "-=+=-"), true, UUID.class);
|
||||
|
||||
this.skyblock = skyblock;
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import com.songoda.skyblock.levelling.rework.calculator.impl.EpicSpawnerCalculat
|
||||
import com.songoda.skyblock.levelling.rework.calculator.impl.UltimateStackerCalculator;
|
||||
import com.songoda.skyblock.levelling.rework.calculator.impl.WildStackerCalculator;
|
||||
import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.stackable.StackableManager;
|
||||
import com.songoda.skyblock.utils.version.Materials;
|
||||
import com.songoda.skyblock.utils.version.NMSUtil;
|
||||
|
||||
@ -63,12 +64,12 @@ public final class IslandLevelManager {
|
||||
}
|
||||
|
||||
if (attemptScanner != null) {
|
||||
|
||||
if(SkyBlock.getInstance().getIslandManager().getIslandPlayerAt(attemptScanner) != island) {
|
||||
|
||||
if (SkyBlock.getInstance().getIslandManager().getIslandPlayerAt(attemptScanner) != island) {
|
||||
messageManager.sendMessage(attemptScanner, config.getString("Command.Island.Level.Scanning.NotOnIsland.Message"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
messageManager.sendMessage(attemptScanner, config.getString("Command.Island.Level.Scanning.Started.Message"));
|
||||
}
|
||||
|
||||
@ -164,7 +165,9 @@ public final class IslandLevelManager {
|
||||
if (finalType == Materials.SPAWNER) finalType = Materials.getSpawner(((CreatureSpawner) block.getState()).getSpawnedType());
|
||||
|
||||
final List<Calculator> calculators = CalculatorRegistry.getCalculators(blockType);
|
||||
final long stackSize = SkyBlock.getInstance().getStackableManager().getStackSizeOf(block.getLocation(), blockType);
|
||||
final StackableManager stackableManager = SkyBlock.getInstance().getStackableManager();
|
||||
|
||||
final long stackSize = stackableManager == null ? 0 : stackableManager.getStackSizeOf(block.getLocation(), blockType);
|
||||
|
||||
if (calculators == null) {
|
||||
|
||||
|
@ -138,10 +138,13 @@ public final class IslandScan extends BukkitRunnable {
|
||||
|
||||
if (config.getBoolean("Command.Island.Level.Scanning.Progress.Should-Display-Message") && executions == 1 || totalScanned == blocksSize || executions % runEveryX == 0) {
|
||||
|
||||
final double percent = ((double) totalScanned / (double) blocksSize) * 100;
|
||||
|
||||
String message = config.getString("Command.Island.Level.Scanning.Progress.Message");
|
||||
message = message.replace("%current_scanned_blocks%", String.valueOf(totalScanned));
|
||||
message = message.replace("%max_blocks%", String.valueOf(blocksSize));
|
||||
message = message.replace("%percent%", FORMATTER.format(((double) totalScanned / (double) blocksSize) * 100));
|
||||
message = message.replace("%percent_whole%", String.valueOf((int) percent));
|
||||
message = message.replace("%percent%", FORMATTER.format(percent));
|
||||
|
||||
final boolean displayComplete = totalScanned == blocksSize && config.getBoolean("Command.Island.Level.Scanning.Finished.Should-Display-Message");
|
||||
final MessageManager messageManager = SkyBlock.getInstance().getMessageManager();
|
||||
|
@ -3,17 +3,14 @@ package com.songoda.skyblock.limit.impl;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.limit.EnumLimitation;
|
||||
import com.songoda.skyblock.utils.player.PlayerUtil;
|
||||
import com.songoda.skyblock.utils.version.Materials;
|
||||
|
||||
public final class BlockLimitation extends EnumLimitation<Materials> {
|
||||
@ -46,7 +43,7 @@ public final class BlockLimitation extends EnumLimitation<Materials> {
|
||||
final String enumName = key.toUpperCase(Locale.ENGLISH);
|
||||
final Materials type = Materials.fromString(enumName);
|
||||
|
||||
if (type == null) throw new IllegalArgumentException("Unable to parse Materials from '" + enumName + "' in " + loadFrom.getCurrentPath());
|
||||
if (type == null) throw new IllegalArgumentException("Unable to parse Materials from '" + enumName + "' in the Section '" + loadFrom.getCurrentPath() + "'");
|
||||
|
||||
getMap().put(type, loadFrom.getLong(key));
|
||||
}
|
||||
@ -63,25 +60,9 @@ public final class BlockLimitation extends EnumLimitation<Materials> {
|
||||
|
||||
if (material == null) return -1;
|
||||
|
||||
long limit = getMap().getOrDefault(material, getDefault());
|
||||
|
||||
final String name = material.name().toLowerCase();
|
||||
|
||||
Set<PermissionAttachmentInfo> permissions = player.getEffectivePermissions().stream()
|
||||
.filter(x -> x.getPermission().toLowerCase().startsWith("fabledskyblock.limit.block." + name)).collect(Collectors.toSet());
|
||||
|
||||
for (PermissionAttachmentInfo permission : permissions) {
|
||||
try {
|
||||
String permString = permission.getPermission();
|
||||
String numberString = permString.substring(permString.lastIndexOf(".") + 1);
|
||||
if (numberString.equals("*")) return -1;
|
||||
|
||||
limit = Math.max(limit, Integer.parseInt(numberString));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
return limit;
|
||||
return Math.max(getMap().getOrDefault(material, getDefault()), PlayerUtil.getNumberFromPermission(player, "fabledskyblock.limit.block." + name, true, -1));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@ -94,8 +75,7 @@ public final class BlockLimitation extends EnumLimitation<Materials> {
|
||||
final long totalPlaced;
|
||||
|
||||
if (block.getType() == Materials.SPAWNER.parseMaterial()) {
|
||||
totalPlaced = island.getLevel().getMaterials().entrySet().stream().filter(x -> x.getKey().contains("SPAWNER"))
|
||||
.mapToLong(Map.Entry::getValue).sum();
|
||||
totalPlaced = island.getLevel().getMaterials().entrySet().stream().filter(x -> x.getKey().contains("SPAWNER")).mapToLong(Map.Entry::getValue).sum();
|
||||
} else {
|
||||
totalPlaced = island.getLevel().getMaterialAmount(Materials.getMaterials(block.getType(), block.getData()).name());
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -18,202 +18,204 @@ import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
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();
|
||||
if (island != null) {
|
||||
if (islandManager.isLocationAtIsland(island, to)) {
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
boolean keepItemsOnDeath;
|
||||
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.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 (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));
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
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 (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());
|
||||
}
|
||||
if (NMSUtil.getVersionNumber() > 8) {
|
||||
player.setHealth(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
||||
} else {
|
||||
player.setHealth(player.getMaxHealth());
|
||||
}
|
||||
|
||||
player.setFoodLevel(20);
|
||||
player.setFoodLevel(20);
|
||||
|
||||
for (PotionEffect potionEffect : player.getActivePotionEffects()) {
|
||||
player.removePotionEffect(potionEffect.getType());
|
||||
}
|
||||
}
|
||||
for (PotionEffect potionEffect : player.getActivePotionEffects()) {
|
||||
player.removePotionEffect(potionEffect.getType());
|
||||
}
|
||||
}
|
||||
|
||||
player.setFallDistance(0.0F);
|
||||
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);
|
||||
}
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
// 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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onTeleport(PlayerTeleportEvent e) {
|
||||
|
||||
final Player player = e.getPlayer();
|
||||
final WorldManager worldManager = skyblock.getWorldManager();
|
||||
|
||||
if (!worldManager.isIslandWorld(e.getTo().getWorld())) return;
|
||||
if (skyblock.getIslandManager().getIslandAtLocation(e.getTo()) != null) return;
|
||||
|
||||
e.setCancelled(true);
|
||||
|
||||
skyblock.getMessageManager().sendMessage(player,
|
||||
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.WorldBorder.Disappeared.Message"));
|
||||
skyblock.getSoundManager().playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -48,26 +48,25 @@ public class Portal implements Listener {
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
if (from.getX() == to.getX() && from.getY() == to.getY() && from.getZ() == to.getZ()) return;
|
||||
|
||||
Island island = islandManager.getIslandAtLocation(to.getLocation());
|
||||
if (from.getX() == to.getX() && from.getY() == to.getY() && from.getZ() == to.getZ())
|
||||
return;
|
||||
|
||||
if (island == null) return;
|
||||
if ((to.getType().equals(Materials.NETHER_PORTAL.parseMaterial()) ||
|
||||
to.getType().equals(Materials.END_PORTAL.parseMaterial())) &&
|
||||
!islandManager.hasPermission(player, player.getLocation(), "Portal")) {
|
||||
|
||||
if ((to.getType().equals(Materials.NETHER_PORTAL.parseMaterial()) || to.getType().equals(Materials.END_PORTAL.parseMaterial()))
|
||||
&& !islandManager.hasPermission(player, player.getLocation(), "Portal")) {
|
||||
event.setTo(LocationUtil.getRandomLocation(event.getFrom().getWorld(), 5000, 5000, true, true));
|
||||
messageManager.sendMessage(player,
|
||||
fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
|
||||
.getString("Island.Settings.Permission.Message"));
|
||||
fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onEntityPortalEnter(EntityPortalEnterEvent event) {
|
||||
if (!(event.getEntity() instanceof Player))
|
||||
return;
|
||||
if (!(event.getEntity() instanceof Player)) return;
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
org.bukkit.block.Block block = event.getLocation().getBlock();
|
||||
@ -78,8 +77,7 @@ public class Portal implements Listener {
|
||||
WorldManager worldManager = skyblock.getWorldManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
if (!worldManager.isIslandWorld(player.getWorld()))
|
||||
return;
|
||||
if (!worldManager.isIslandWorld(player.getWorld())) return;
|
||||
|
||||
Island island = islandManager.getIslandAtLocation(player.getLocation());
|
||||
|
||||
@ -90,23 +88,22 @@ public class Portal implements Listener {
|
||||
|
||||
if (!islandManager.hasPermission(player, player.getLocation(), "Portal")) {
|
||||
messageManager.sendMessage(player,
|
||||
fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
|
||||
.getString("Island.Settings.Permission.Message"));
|
||||
fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
|
||||
IslandEnvironment spawnEnvironment;
|
||||
switch (island.getRole(player)) {
|
||||
case Operator:
|
||||
case Owner:
|
||||
case Member:
|
||||
case Coop:
|
||||
spawnEnvironment = IslandEnvironment.Island;
|
||||
break;
|
||||
case Operator:
|
||||
case Owner:
|
||||
case Member:
|
||||
case Coop:
|
||||
spawnEnvironment = IslandEnvironment.Island;
|
||||
break;
|
||||
|
||||
default:
|
||||
spawnEnvironment = IslandEnvironment.Visitor;
|
||||
default:
|
||||
spawnEnvironment = IslandEnvironment.Visitor;
|
||||
}
|
||||
|
||||
Tick tick;
|
||||
@ -123,9 +120,7 @@ public class Portal implements Listener {
|
||||
tick.setLast(System.currentTimeMillis());
|
||||
}
|
||||
if (tick.getTick() >= 100) {
|
||||
messageManager.sendMessage(player,
|
||||
fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
|
||||
.getString("Island.Portal.Stuck.Message"));
|
||||
messageManager.sendMessage(player, fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Portal.Stuck.Message"));
|
||||
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||
LocationUtil.teleportPlayerToSpawn(player);
|
||||
return;
|
||||
@ -137,39 +132,37 @@ public class Portal implements Listener {
|
||||
IslandWorld fromWorld = worldManager.getIslandWorld(player.getWorld());
|
||||
IslandWorld toWorld = IslandWorld.Normal;
|
||||
|
||||
if (block.getType().equals(Materials.NETHER_PORTAL.parseMaterial()))
|
||||
toWorld = fromWorld.equals(IslandWorld.Normal) ? IslandWorld.Nether : IslandWorld.Normal;
|
||||
else if (block.getType().equals(Materials.END_PORTAL.parseMaterial()))
|
||||
toWorld = fromWorld.equals(IslandWorld.Normal) ? IslandWorld.End : IslandWorld.Normal;
|
||||
if (block.getType().equals(Materials.NETHER_PORTAL.parseMaterial())) toWorld = fromWorld.equals(IslandWorld.Normal) ? IslandWorld.Nether : IslandWorld.Normal;
|
||||
else if (block.getType().equals(Materials.END_PORTAL.parseMaterial())) toWorld = fromWorld.equals(IslandWorld.Normal) ? IslandWorld.End : IslandWorld.Normal;
|
||||
|
||||
switch (toWorld) {
|
||||
case Nether:
|
||||
if (configLoad.getBoolean("Island.World.Nether.Enable") && island.isRegionUnlocked(player, "Nether")) {
|
||||
IslandWorld toWorldF = toWorld;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> player.teleport(island.getLocation(toWorldF, spawnEnvironment)), 1L);
|
||||
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||
player.setFallDistance(0.0F);
|
||||
tick.setTick(1);
|
||||
}
|
||||
break;
|
||||
|
||||
case End:
|
||||
if (configLoad.getBoolean("Island.World.End.Enable") && island.isRegionUnlocked(player, "End")) {
|
||||
IslandWorld toWorldF = toWorld;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> player.teleport(island.getLocation(toWorldF, spawnEnvironment)), 1L);
|
||||
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||
player.setFallDistance(0.0F);
|
||||
tick.setTick(1);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
case Nether:
|
||||
if (configLoad.getBoolean("Island.World.Nether.Enable") && island.isRegionUnlocked(player, "Nether")) {
|
||||
IslandWorld toWorldF = toWorld;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> player.teleport(island.getLocation(toWorldF, spawnEnvironment)), 1L);
|
||||
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||
player.setFallDistance(0.0F);
|
||||
tick.setTick(1);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case End:
|
||||
if (configLoad.getBoolean("Island.World.End.Enable") && island.isRegionUnlocked(player, "End")) {
|
||||
IslandWorld toWorldF = toWorld;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> player.teleport(island.getLocation(toWorldF, spawnEnvironment)), 1L);
|
||||
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||
player.setFallDistance(0.0F);
|
||||
tick.setTick(1);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
IslandWorld toWorldF = toWorld;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> player.teleport(island.getLocation(toWorldF, spawnEnvironment)), 1L);
|
||||
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||
player.setFallDistance(0.0F);
|
||||
tick.setTick(1);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public class Spawner implements Listener {
|
||||
Object TileEntityMobSpawner = TileEntityMobSpawnerField.get(spawner);
|
||||
MobSpawner = TileEntityMobSpawner.getClass().getMethod("getSpawner")
|
||||
.invoke(TileEntityMobSpawner);
|
||||
} catch (NoSuchFieldException e) {
|
||||
} catch (NoSuchFieldException ignored) {
|
||||
Field snapshotField = spawner.getClass().getSuperclass().getDeclaredField("snapshot");
|
||||
snapshotField.setAccessible(true);
|
||||
Object snapshot = snapshotField.get(spawner);
|
||||
@ -92,6 +92,8 @@ public class Spawner implements Listener {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
spawner.update();
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -57,8 +57,7 @@ public class Teleport implements Listener {
|
||||
if (worldManager.isIslandWorld(player.getWorld())) {
|
||||
boolean isCause = false;
|
||||
|
||||
if (event.getCause() == TeleportCause.ENDER_PEARL || event.getCause() == TeleportCause.NETHER_PORTAL
|
||||
|| event.getCause() == TeleportCause.END_PORTAL) {
|
||||
if (event.getCause() == TeleportCause.ENDER_PEARL || event.getCause() == TeleportCause.NETHER_PORTAL || event.getCause() == TeleportCause.END_PORTAL) {
|
||||
isCause = true;
|
||||
} else {
|
||||
if (NMSUtil.getVersionNumber() > 9) {
|
||||
@ -90,27 +89,23 @@ public class Teleport implements Listener {
|
||||
|
||||
if (island != null) {
|
||||
if (!island.getOwnerUUID().equals(playerData.getOwner())) {
|
||||
if (!player.hasPermission("fabledskyblock.bypass") && !player.hasPermission("fabledskyblock.bypass.*")
|
||||
&& !player.hasPermission("fabledskyblock.*")) {
|
||||
if (!player.hasPermission("fabledskyblock.bypass") && !player.hasPermission("fabledskyblock.bypass.*") && !player.hasPermission("fabledskyblock.*")) {
|
||||
if (!island.isOpen() && !island.isCoopPlayer(player.getUniqueId())) {
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Island.Visit.Closed.Plugin.Message"));
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Visit.Closed.Plugin.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
} else if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Visitor.Banning")
|
||||
} else if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning")
|
||||
&& island.getBan().isBanned(player.getUniqueId())) {
|
||||
event.setCancelled(true);
|
||||
event.setCancelled(true);
|
||||
|
||||
messageManager.sendMessage(player,
|
||||
configLoad.getString("Island.Visit.Banned.Teleport.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Visit.Banned.Teleport.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,8 +119,7 @@ public class Teleport implements Listener {
|
||||
}
|
||||
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerIslandExitEvent(player, exitIsland));
|
||||
Bukkit.getServer().getPluginManager()
|
||||
.callEvent(new PlayerIslandSwitchEvent(player, exitIsland, island.getAPIWrapper()));
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerIslandSwitchEvent(player, exitIsland, island.getAPIWrapper()));
|
||||
|
||||
playerData.setVisitTime(0);
|
||||
}
|
||||
@ -133,8 +127,7 @@ public class Teleport implements Listener {
|
||||
if (worldManager.getIslandWorld(event.getTo().getWorld()) == IslandWorld.Normal) {
|
||||
if (!island.isWeatherSynchronized()) {
|
||||
player.setPlayerTime(island.getTime(),
|
||||
fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
|
||||
.getFileConfiguration().getBoolean("Island.Weather.Time.Cycle"));
|
||||
fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Weather.Time.Cycle"));
|
||||
player.setPlayerWeather(island.getWeather());
|
||||
}
|
||||
}
|
||||
@ -142,17 +135,14 @@ public class Teleport implements Listener {
|
||||
UUID islandOwnerUUID = playerData.getIsland();
|
||||
playerData.setIsland(island.getOwnerUUID());
|
||||
|
||||
if (islandOwnerUUID != null && islandManager.containsIsland(islandOwnerUUID)
|
||||
&& (playerData.getOwner() == null || !playerData.getOwner().equals(islandOwnerUUID))) {
|
||||
islandManager.unloadIsland(
|
||||
islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)), null);
|
||||
if (islandOwnerUUID != null && islandManager.containsIsland(islandOwnerUUID) && (playerData.getOwner() == null || !playerData.getOwner().equals(islandOwnerUUID))) {
|
||||
islandManager.unloadIsland(islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)), null);
|
||||
}
|
||||
|
||||
Visit visit = island.getVisit();
|
||||
|
||||
if (!visit.isVisitor(player.getUniqueId())) {
|
||||
Bukkit.getServer().getPluginManager()
|
||||
.callEvent(new PlayerIslandEnterEvent(player, island.getAPIWrapper()));
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerIslandEnterEvent(player, island.getAPIWrapper()));
|
||||
|
||||
visit.addVisitor(player.getUniqueId());
|
||||
visit.save();
|
||||
@ -180,10 +170,8 @@ public class Teleport implements Listener {
|
||||
UUID islandOwnerUUID = playerData.getIsland();
|
||||
playerData.setIsland(null);
|
||||
|
||||
if (islandOwnerUUID != null && islandManager.containsIsland(islandOwnerUUID)
|
||||
&& (playerData.getOwner() == null || !playerData.getOwner().equals(islandOwnerUUID))) {
|
||||
islandManager.unloadIsland(
|
||||
islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)), null);
|
||||
if (islandOwnerUUID != null && islandManager.containsIsland(islandOwnerUUID) && (playerData.getOwner() == null || !playerData.getOwner().equals(islandOwnerUUID))) {
|
||||
islandManager.unloadIsland(islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,7 @@
|
||||
package com.songoda.skyblock.menus;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.utils.item.nInventoryUtil;
|
||||
import com.songoda.skyblock.utils.version.Materials;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -14,123 +10,116 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.File;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.utils.item.MenuClickRegistry;
|
||||
import com.songoda.skyblock.utils.item.MenuClickRegistry.RegistryKey;
|
||||
import com.songoda.skyblock.utils.item.nInventoryUtil;
|
||||
import com.songoda.skyblock.utils.version.Materials;
|
||||
import com.songoda.skyblock.utils.version.Sounds;
|
||||
|
||||
public class ControlPanel {
|
||||
public final class ControlPanel {
|
||||
|
||||
private static ControlPanel instance;
|
||||
|
||||
public static ControlPanel getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new ControlPanel();
|
||||
}
|
||||
return instance == null ? instance = new ControlPanel() : instance;
|
||||
}
|
||||
|
||||
private ControlPanel() {
|
||||
|
||||
MenuClickRegistry.getInstance().register((executors) -> {
|
||||
|
||||
executors.put(RegistryKey.fromLanguageFile("Menu.ControlPanel.Item.Teleport.Displayname", Materials.OAK_DOOR), (inst, player, e) -> {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(inst, () -> Bukkit.getServer().dispatchCommand(player, "island teleport"), 1L);
|
||||
});
|
||||
|
||||
executors.put(RegistryKey.fromLanguageFile("Menu.ControlPanel.Item.Lock.Displayname", Materials.IRON_DOOR), (inst, player, e) -> {
|
||||
|
||||
final Island island = SkyBlock.getInstance().getIslandManager().getIsland((Player) player);
|
||||
|
||||
if (island.isOpen()) {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(inst, () -> Bukkit.getServer().dispatchCommand(player, "island close"), 1L);
|
||||
} else {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(inst, () -> Bukkit.getServer().dispatchCommand(player, "island open"), 1L);
|
||||
}
|
||||
});
|
||||
|
||||
executors.put(RegistryKey.fromLanguageFile("Menu.ControlPanel.Item.Barrier.Displayname", Materials.BLACK_STAINED_GLASS_PANE), (inst, player, e) -> {
|
||||
inst.getSoundManager().playSound(player, Sounds.GLASS.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
e.setWillClose(false);
|
||||
e.setWillDestroy(false);
|
||||
});
|
||||
|
||||
executors.put(RegistryKey.fromLanguageFile("Menu.ControlPanel.Item.Level.Displayname", Materials.EXPERIENCE_BOTTLE), (inst, player, e) -> {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(inst, () -> Bukkit.getServer().dispatchCommand(player, "island level"), 1L);
|
||||
});
|
||||
executors.put(RegistryKey.fromLanguageFile("Menu.ControlPanel.Item.Settings.Displayname", Materials.NAME_TAG), (inst, player, e) -> {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(inst, () -> Bukkit.getServer().dispatchCommand(player, "island settings"), 1L);
|
||||
});
|
||||
executors.put(RegistryKey.fromLanguageFile("Menu.ControlPanel.Item.Members.Displayname", Materials.ITEM_FRAME), (inst, player, e) -> {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(inst, () -> Bukkit.getServer().dispatchCommand(player, "island members"), 1L);
|
||||
});
|
||||
executors.put(RegistryKey.fromLanguageFile("Menu.ControlPanel.Item.Biome.Displayname", Materials.OAK_SAPLING), (inst, player, e) -> {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(inst, () -> Bukkit.getServer().dispatchCommand(player, "island biome"), 1L);
|
||||
});
|
||||
executors.put(RegistryKey.fromLanguageFile("Menu.ControlPanel.Item.Weather.Displayname", Materials.CLOCK), (inst, player, e) -> {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(inst, () -> Bukkit.getServer().dispatchCommand(player, "island weather"), 1L);
|
||||
});
|
||||
executors.put(RegistryKey.fromLanguageFile("Menu.ControlPanel.Item.Bans.Displayname", Materials.IRON_AXE), (inst, player, e) -> {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(inst, () -> Bukkit.getServer().dispatchCommand(player, "island bans"), 1L);
|
||||
});
|
||||
executors.put(RegistryKey.fromLanguageFile("Menu.ControlPanel.Item.Visitors.Displayname", Materials.OAK_SIGN), (inst, player, e) -> {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(inst, () -> Bukkit.getServer().dispatchCommand(player, "island visitors"), 1L);
|
||||
});
|
||||
executors.put(RegistryKey.fromLanguageFile("Menu.ControlPanel.Item.Upgrades.Displayname", Materials.ANVIL), (inst, player, e) -> {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(inst, () -> Bukkit.getServer().dispatchCommand(player, "island upgrades"), 1L);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void open(Player player) {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
Island island = skyblock.getIslandManager().getIsland(player);
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
nInventoryUtil nInv = new nInventoryUtil(player, event -> {
|
||||
ItemStack is = event.getItem();
|
||||
|
||||
if ((is.getType() == Materials.OAK_DOOR.parseMaterial()) && (is.hasItemMeta())
|
||||
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.ControlPanel.Item.Teleport.Displayname"))))) {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> Bukkit.getServer().dispatchCommand(player, "island teleport"), 1L);
|
||||
} else if ((is.getType() == Materials.IRON_DOOR.parseMaterial()) && (is.hasItemMeta())
|
||||
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.ControlPanel.Item.Lock.Displayname"))))) {
|
||||
if (island.isOpen()) {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> Bukkit.getServer().dispatchCommand(player, "island close"), 1L);
|
||||
} else {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> Bukkit.getServer().dispatchCommand(player, "island open"), 1L);
|
||||
}
|
||||
} else if ((is.getType() == Materials.BLACK_STAINED_GLASS_PANE.parseMaterial()) && (is.hasItemMeta())
|
||||
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"))))) {
|
||||
skyblock.getSoundManager().playSound(player, Sounds.GLASS.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == Materials.EXPERIENCE_BOTTLE.parseMaterial()) && (is.hasItemMeta())
|
||||
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.ControlPanel.Item.Level.Displayname"))))) {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> Bukkit.getServer().dispatchCommand(player, "island level"), 1L);
|
||||
} else if ((is.getType() == Material.NAME_TAG) && (is.hasItemMeta())
|
||||
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.ControlPanel.Item.Settings.Displayname"))))) {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> Bukkit.getServer().dispatchCommand(player, "island settings"), 1L);
|
||||
} else if ((is.getType() == Material.ITEM_FRAME) && (is.hasItemMeta())
|
||||
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.ControlPanel.Item.Members.Displayname"))))) {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> Bukkit.getServer().dispatchCommand(player, "island members"), 1L);
|
||||
} else if ((is.getType() == Materials.OAK_SAPLING.parseMaterial()) && (is.hasItemMeta())
|
||||
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.ControlPanel.Item.Biome.Displayname"))))) {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> Bukkit.getServer().dispatchCommand(player, "island biome"), 1L);
|
||||
} else if ((is.getType() == Materials.CLOCK.parseMaterial()) && (is.hasItemMeta())
|
||||
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.ControlPanel.Item.Weather.Displayname"))))) {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> Bukkit.getServer().dispatchCommand(player, "island weather"), 1L);
|
||||
} else if ((is.getType() == Material.IRON_AXE) && (is.hasItemMeta())
|
||||
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.ControlPanel.Item.Bans.Displayname"))))) {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> Bukkit.getServer().dispatchCommand(player, "island bans"), 1L);
|
||||
} else if ((is.getType() == Materials.OAK_SIGN.parseMaterial()) && (is.hasItemMeta())
|
||||
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.ControlPanel.Item.Visitors.Displayname"))))) {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> Bukkit.getServer().dispatchCommand(player, "island visitors"), 1L);
|
||||
} else if ((is.getType() == Materials.ANVIL.parseMaterial()) && (is.hasItemMeta())
|
||||
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Menu.ControlPanel.Item.Upgrades.Displayname"))))) {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(skyblock, () -> Bukkit.getServer().dispatchCommand(player, "island upgrades"), 1L);
|
||||
}
|
||||
MenuClickRegistry.getInstance().dispatch(player, event);
|
||||
});
|
||||
|
||||
// Teleport to island and open/close island
|
||||
nInv.addItem(nInv.createItem(Materials.OAK_DOOR.parseItem(),
|
||||
configLoad.getString("Menu.ControlPanel.Item.Teleport.Displayname"),
|
||||
nInv.addItem(nInv.createItem(Materials.OAK_DOOR.parseItem(), configLoad.getString("Menu.ControlPanel.Item.Teleport.Displayname"),
|
||||
configLoad.getStringList("Menu.ControlPanel.Item.Teleport.Lore"), null, null, null), 1);
|
||||
nInv.addItem(nInv.createItem(Materials.IRON_DOOR.parseItem(),
|
||||
configLoad.getString("Menu.ControlPanel.Item.Lock.Displayname"),
|
||||
nInv.addItem(nInv.createItem(Materials.IRON_DOOR.parseItem(), configLoad.getString("Menu.ControlPanel.Item.Lock.Displayname"),
|
||||
configLoad.getStringList("Menu.ControlPanel.Item.Lock.Lore"), null, null, null), 10);
|
||||
|
||||
// Glass panes barriers
|
||||
nInv.addItem(nInv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(),
|
||||
configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"), null, null, null, null), 0, 2, 5, 8, 9, 11, 14, 17);
|
||||
nInv.addItem(nInv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(), configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"), null, null, null, null), 0, 2, 5, 8,
|
||||
9, 11, 14, 17);
|
||||
|
||||
// 4 Items at the left
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Materials.EXPERIENCE_BOTTLE.parseMaterial()),
|
||||
configLoad.getString("Menu.ControlPanel.Item.Level.Displayname"),
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Materials.EXPERIENCE_BOTTLE.parseMaterial()), configLoad.getString("Menu.ControlPanel.Item.Level.Displayname"),
|
||||
configLoad.getStringList("Menu.ControlPanel.Item.Level.Lore"), null, null, null), 3);
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.NAME_TAG),
|
||||
configLoad.getString("Menu.ControlPanel.Item.Settings.Displayname"),
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.NAME_TAG), configLoad.getString("Menu.ControlPanel.Item.Settings.Displayname"),
|
||||
configLoad.getStringList("Menu.ControlPanel.Item.Settings.Lore"), null, null, null), 4);
|
||||
nInv.addItem(nInv.createItem(Materials.CLOCK.parseItem(),
|
||||
configLoad.getString("Menu.ControlPanel.Item.Weather.Displayname"),
|
||||
nInv.addItem(nInv.createItem(Materials.CLOCK.parseItem(), configLoad.getString("Menu.ControlPanel.Item.Weather.Displayname"),
|
||||
configLoad.getStringList("Menu.ControlPanel.Item.Weather.Lore"), null, null, null), 12);
|
||||
nInv.addItem(nInv.createItem(Materials.OAK_SAPLING.parseItem(),
|
||||
configLoad.getString("Menu.ControlPanel.Item.Biome.Displayname"),
|
||||
nInv.addItem(nInv.createItem(Materials.OAK_SAPLING.parseItem(), configLoad.getString("Menu.ControlPanel.Item.Biome.Displayname"),
|
||||
configLoad.getStringList("Menu.ControlPanel.Item.Biome.Lore"), null, null, null), 13);
|
||||
|
||||
// 4 Items at the right
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.ITEM_FRAME),
|
||||
configLoad.getString("Menu.ControlPanel.Item.Members.Displayname"),
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.ITEM_FRAME), configLoad.getString("Menu.ControlPanel.Item.Members.Displayname"),
|
||||
configLoad.getStringList("Menu.ControlPanel.Item.Members.Lore"), null, null, null), 16);
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.IRON_AXE),
|
||||
configLoad.getString("Menu.ControlPanel.Item.Bans.Displayname"),
|
||||
configLoad.getStringList("Menu.ControlPanel.Item.Bans.Lore"), null, null,
|
||||
new ItemFlag[]{ItemFlag.HIDE_ATTRIBUTES}), 6);
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Materials.OAK_SIGN.parseMaterial()),
|
||||
configLoad.getString("Menu.ControlPanel.Item.Visitors.Displayname"),
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.IRON_AXE), configLoad.getString("Menu.ControlPanel.Item.Bans.Displayname"),
|
||||
configLoad.getStringList("Menu.ControlPanel.Item.Bans.Lore"), null, null, new ItemFlag[] { ItemFlag.HIDE_ATTRIBUTES }), 6);
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Materials.OAK_SIGN.parseMaterial()), configLoad.getString("Menu.ControlPanel.Item.Visitors.Displayname"),
|
||||
configLoad.getStringList("Menu.ControlPanel.Item.Visitors.Lore"), null, null, null), 7);
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Materials.ANVIL.parseMaterial()),
|
||||
configLoad.getString("Menu.ControlPanel.Item.Upgrades.Displayname"),
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Materials.ANVIL.parseMaterial()), configLoad.getString("Menu.ControlPanel.Item.Upgrades.Displayname"),
|
||||
configLoad.getStringList("Menu.ControlPanel.Item.Upgrades.Lore"), null, null, null), 15);
|
||||
|
||||
nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.ControlPanel.Title")));
|
||||
|
@ -116,14 +116,7 @@ public class PlaceholderManager {
|
||||
.replace("%placeholder", "" + island.getRadius()));
|
||||
}
|
||||
} else if (placeholder.equalsIgnoreCase("fabledskyblock_island_level")) {
|
||||
if (island == null) {
|
||||
return ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Placeholder.fabledskyblock_island_level.Empty.Message"));
|
||||
} else {
|
||||
return ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Placeholder.fabledskyblock_island_level.Non-empty.Message")
|
||||
.replace("%placeholder", "" + island.getLevel().getLevel()));
|
||||
}
|
||||
return island == null ? "0": Long.toString(island.getLevel().getLevel());
|
||||
} else if (placeholder.equalsIgnoreCase("fabledskyblock_island_level_formatted")) {
|
||||
if (island == null) {
|
||||
return ChatColor.translateAlternateColorCodes('&',
|
||||
@ -134,14 +127,7 @@ public class PlaceholderManager {
|
||||
"%placeholder", "" + NumberUtil.formatNumberBySuffix(island.getLevel().getLevel())));
|
||||
}
|
||||
} else if (placeholder.equalsIgnoreCase("fabledskyblock_island_points")) {
|
||||
if (island == null) {
|
||||
return ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Placeholder.fabledskyblock_island_points.Empty.Message"));
|
||||
} else {
|
||||
return ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Placeholder.fabledskyblock_island_points.Non-empty.Message")
|
||||
.replace("%placeholder", "" + island.getLevel().getPoints()));
|
||||
}
|
||||
return island == null ? "0": Long.toString(island.getLevel().getPoints());
|
||||
} else if (placeholder.equalsIgnoreCase("fabledskyblock_island_votes")) {
|
||||
if (island == null) {
|
||||
return ChatColor.translateAlternateColorCodes('&',
|
||||
|
@ -4,6 +4,8 @@ import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.confirmation.Confirmation;
|
||||
import com.songoda.skyblock.utils.structure.Area;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -146,7 +148,7 @@ public class PlayerData {
|
||||
public String[] getTexture() {
|
||||
FileConfiguration configLoad = getConfig().getFileConfiguration();
|
||||
|
||||
return new String[]{configLoad.getString("Texture.Signature"), configLoad.getString("Texture.Value")};
|
||||
return new String[] { configLoad.getString("Texture.Signature"), configLoad.getString("Texture.Value") };
|
||||
}
|
||||
|
||||
public void setTexture(String signature, String value) {
|
||||
@ -161,6 +163,23 @@ public class PlayerData {
|
||||
public void setLastOnline(String date) {
|
||||
getConfig().getFileConfiguration().set("Statistics.Island.LastOnline", date);
|
||||
}
|
||||
|
||||
public long getIslandCreationCount() {
|
||||
return getConfig().getFileConfiguration().getLong("Statistics.Island.IslandCreationCount");
|
||||
}
|
||||
|
||||
public long getIslandDeletionCount() {
|
||||
return getConfig().getFileConfiguration().getLong("Statistics.Island.IslandDeleteCount");
|
||||
}
|
||||
|
||||
public void setIslandCreationCount(long newNumber) {
|
||||
getConfig().getFileConfiguration().set("Statistics.Island.IslandCreationCount", newNumber);
|
||||
}
|
||||
|
||||
public void setIslandDeletionCount(long newNumber) {
|
||||
getConfig().getFileConfiguration().set("Statistics.Island.IslandDeleteCount", newNumber);
|
||||
}
|
||||
|
||||
|
||||
public Area getArea() {
|
||||
return area;
|
||||
@ -197,7 +216,11 @@ public class PlayerData {
|
||||
private Config getConfig() {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
return skyblock.getFileManager().getConfig(
|
||||
new File(new File(skyblock.getDataFolder().toString() + "/player-data"), uuid.toString() + ".yml"));
|
||||
return skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), uuid.toString() + ".yml"));
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return Bukkit.getPlayer(uuid);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -117,12 +117,20 @@ public class PlayerDataManager {
|
||||
return playerDataStorage;
|
||||
}
|
||||
|
||||
public PlayerData getPlayerData(UUID uuid) {
|
||||
return playerDataStorage.get(uuid);
|
||||
}
|
||||
|
||||
public boolean hasPlayerData(UUID uuid) {
|
||||
return playerDataStorage.containsKey(uuid);
|
||||
}
|
||||
|
||||
public PlayerData getPlayerData(Player player) {
|
||||
return playerDataStorage.get(player.getUniqueId());
|
||||
return getPlayerData(player.getUniqueId());
|
||||
}
|
||||
|
||||
public boolean hasPlayerData(Player player) {
|
||||
return playerDataStorage.containsKey(player.getUniqueId());
|
||||
return hasPlayerData(player.getUniqueId());
|
||||
}
|
||||
|
||||
public void storeIsland(Player player) {
|
||||
|
@ -1,13 +1,10 @@
|
||||
package com.songoda.skyblock.scoreboard;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandLevel;
|
||||
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 java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -18,13 +15,20 @@ import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import java.util.*;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandLevel;
|
||||
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;
|
||||
|
||||
public class Scoreboard {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
|
||||
private final Player player;
|
||||
|
||||
private String displayName;
|
||||
private List<String> displayList;
|
||||
private Map<String, String> displayVariables;
|
||||
@ -72,8 +76,7 @@ public class Scoreboard {
|
||||
|
||||
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
|
||||
String formattedDisplayName = ChatColor.translateAlternateColorCodes('&',
|
||||
replaceDisplayName(displayName));
|
||||
String formattedDisplayName = ChatColor.translateAlternateColorCodes('&', replaceDisplayName(displayName));
|
||||
int max = NMSUtil.getVersionNumber() > 8 ? 32 : 16;
|
||||
if (formattedDisplayName.length() > max) {
|
||||
obj.setDisplayName(ChatColor.RED + "Too long...");
|
||||
@ -100,8 +103,7 @@ public class Scoreboard {
|
||||
if (!player.isOnline()) cancel();
|
||||
|
||||
try {
|
||||
String formattedDisplayName = ChatColor.translateAlternateColorCodes('&',
|
||||
replaceDisplayName(displayName));
|
||||
String formattedDisplayName = ChatColor.translateAlternateColorCodes('&', replaceDisplayName(displayName));
|
||||
|
||||
if (formattedDisplayName.length() > max) {
|
||||
obj.setDisplayName(ChatColor.RED + "Too long...");
|
||||
@ -119,50 +121,37 @@ public class Scoreboard {
|
||||
}
|
||||
|
||||
if (displayLine.length() >= 16) {
|
||||
String prefixLine = displayLine.substring(0,
|
||||
Math.min(displayLine.length(), 16));
|
||||
String suffixLine = displayLine.substring(16,
|
||||
Math.min(displayLine.length(), displayLine.length()));
|
||||
String prefixLine = displayLine.substring(0, Math.min(displayLine.length(), 16));
|
||||
String suffixLine = displayLine.substring(16, Math.min(displayLine.length(), displayLine.length()));
|
||||
|
||||
if (prefixLine.substring(prefixLine.length() - 1).equals("&")) {
|
||||
prefixLine = ChatColor.translateAlternateColorCodes('&',
|
||||
prefixLine.substring(0, prefixLine.length() - 1));
|
||||
suffixLine = ChatColor.translateAlternateColorCodes('&',
|
||||
"&" + suffixLine);
|
||||
prefixLine = ChatColor.translateAlternateColorCodes('&', prefixLine.substring(0, prefixLine.length() - 1));
|
||||
suffixLine = ChatColor.translateAlternateColorCodes('&', "&" + suffixLine);
|
||||
} else {
|
||||
String lastColorCodes;
|
||||
|
||||
if (prefixLine.contains("&")) {
|
||||
String[] colorCodes = prefixLine.split("&");
|
||||
String lastColorCodeText = colorCodes[colorCodes.length - 1];
|
||||
lastColorCodes = "&" + lastColorCodeText.substring(0,
|
||||
Math.min(lastColorCodeText.length(), 1));
|
||||
lastColorCodes = "&" + lastColorCodeText.substring(0, Math.min(lastColorCodeText.length(), 1));
|
||||
|
||||
if ((colorCodes.length >= 2) && (lastColorCodes.equals("&l")
|
||||
|| lastColorCodes.equals("&m")
|
||||
|| lastColorCodes.equals("&n")
|
||||
|| lastColorCodes.equals("&o"))) {
|
||||
if ((colorCodes.length >= 2)
|
||||
&& (lastColorCodes.equals("&l") || lastColorCodes.equals("&m") || lastColorCodes.equals("&n") || lastColorCodes.equals("&o"))) {
|
||||
lastColorCodeText = colorCodes[colorCodes.length - 2];
|
||||
lastColorCodes = "&"
|
||||
+ lastColorCodeText.substring(0,
|
||||
Math.min(lastColorCodeText.length(), 1))
|
||||
+ lastColorCodes;
|
||||
lastColorCodes = "&" + lastColorCodeText.substring(0, Math.min(lastColorCodeText.length(), 1)) + lastColorCodes;
|
||||
}
|
||||
} else {
|
||||
lastColorCodes = "&f";
|
||||
}
|
||||
|
||||
prefixLine = ChatColor.translateAlternateColorCodes('&',
|
||||
prefixLine);
|
||||
suffixLine = ChatColor.translateAlternateColorCodes('&',
|
||||
lastColorCodes + suffixLine);
|
||||
prefixLine = ChatColor.translateAlternateColorCodes('&', prefixLine);
|
||||
suffixLine = ChatColor.translateAlternateColorCodes('&', lastColorCodes + suffixLine);
|
||||
}
|
||||
|
||||
scoreboard.getTeam(ranStr + i1).setPrefix(prefixLine);
|
||||
scoreboard.getTeam(ranStr + i1).setSuffix(suffixLine);
|
||||
} else {
|
||||
scoreboard.getTeam(ranStr + i1).setPrefix(
|
||||
ChatColor.translateAlternateColorCodes('&', displayLine));
|
||||
scoreboard.getTeam(ranStr + i1).setPrefix(ChatColor.translateAlternateColorCodes('&', displayLine));
|
||||
}
|
||||
}
|
||||
|
||||
@ -181,8 +170,7 @@ public class Scoreboard {
|
||||
}
|
||||
|
||||
private String replaceDisplayName(String displayName) {
|
||||
displayName = displayName.replace("%players_online", "" + Bukkit.getServer().getOnlinePlayers().size())
|
||||
.replace("%players_max", "" + Bukkit.getServer().getMaxPlayers());
|
||||
displayName = displayName.replace("%players_online", "" + Bukkit.getServer().getOnlinePlayers().size()).replace("%players_max", "" + Bukkit.getServer().getMaxPlayers());
|
||||
|
||||
return displayName;
|
||||
}
|
||||
@ -192,8 +180,7 @@ public class Scoreboard {
|
||||
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
|
||||
displayLine = displayLine.replace("%players_online", "" + Bukkit.getServer().getOnlinePlayers().size())
|
||||
.replace("%players_max", "" + Bukkit.getServer().getMaxPlayers());
|
||||
displayLine = displayLine.replace("%players_online", "" + Bukkit.getServer().getOnlinePlayers().size()).replace("%players_max", "" + Bukkit.getServer().getMaxPlayers());
|
||||
|
||||
Island island = islandManager.getIsland(player);
|
||||
|
||||
@ -201,15 +188,11 @@ public class Scoreboard {
|
||||
IslandLevel level = island.getLevel();
|
||||
|
||||
if (island.getRole(IslandRole.Member).size() == 0 && island.getRole(IslandRole.Operator).size() == 0) {
|
||||
displayLine = displayLine
|
||||
.replace("%island_level", "" + NumberUtil.formatNumberByDecimal(level.getLevel()))
|
||||
.replace("%island_members", ChatColor.RED + "0").replace("%island_role", ChatColor.RED + "null")
|
||||
.replace("%island_visitors", "" + islandManager.getVisitorsAtIsland(island).size())
|
||||
.replace("%island_size", "" + island.getSize())
|
||||
.replace("%island_radius", "" + island.getRadius());
|
||||
displayLine = displayLine.replace("%island_level", "" + NumberUtil.formatNumberByDecimal(level.getLevel())).replace("%island_members", ChatColor.RED + "0")
|
||||
.replace("%island_role", ChatColor.RED + "null").replace("%island_visitors", "" + islandManager.getVisitorsAtIsland(island).size())
|
||||
.replace("%island_size", "" + island.getSize()).replace("%island_radius", "" + island.getRadius());
|
||||
} else {
|
||||
int islandMembers = 1 + island.getRole(IslandRole.Member).size()
|
||||
+ island.getRole(IslandRole.Operator).size();
|
||||
int islandMembers = 1 + island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size();
|
||||
String islandRole = "";
|
||||
|
||||
if (island.hasRole(IslandRole.Owner, player.getUniqueId())) {
|
||||
@ -220,26 +203,20 @@ public class Scoreboard {
|
||||
islandRole = displayVariables.get("%member");
|
||||
}
|
||||
|
||||
displayLine = displayLine
|
||||
.replace("%island_points", "" + NumberUtil.formatNumberByDecimal(level.getPoints()))
|
||||
.replace("%island_level", "" + NumberUtil.formatNumberByDecimal(level.getLevel()))
|
||||
.replace("%island_members", "" + islandMembers).replace("%island_role", islandRole)
|
||||
.replace("%island_visitors", "" + islandManager.getVisitorsAtIsland(island).size())
|
||||
.replace("%island_size", "" + island.getSize())
|
||||
displayLine = displayLine.replace("%island_points", "" + NumberUtil.formatNumberByDecimal(level.getPoints()))
|
||||
.replace("%island_level", "" + NumberUtil.formatNumberByDecimal(level.getLevel())).replace("%island_members", "" + islandMembers).replace("%island_role", islandRole)
|
||||
.replace("%island_visitors", "" + islandManager.getVisitorsAtIsland(island).size()).replace("%island_size", "" + island.getSize())
|
||||
.replace("%island_radius", "" + island.getRadius());
|
||||
}
|
||||
} else {
|
||||
displayLine = displayLine.replace("%island_points", ChatColor.RED + "0")
|
||||
.replace("%island_level", ChatColor.RED + "0").replace("%island_members", ChatColor.RED + "0")
|
||||
.replace("%island_role", ChatColor.RED + "null").replace("%island_size", ChatColor.RED + "0")
|
||||
.replace("%island_radius", ChatColor.RED + "0");
|
||||
displayLine = displayLine.replace("%island_points", ChatColor.RED + "0").replace("%island_level", ChatColor.RED + "0").replace("%island_members", ChatColor.RED + "0")
|
||||
.replace("%island_role", ChatColor.RED + "null").replace("%island_size", ChatColor.RED + "0").replace("%island_radius", ChatColor.RED + "0");
|
||||
}
|
||||
|
||||
PlaceholderManager placeholderManager = skyblock.getPlaceholderManager();
|
||||
|
||||
if (placeholderManager.isPlaceholderAPIEnabled()) {
|
||||
displayLine = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, displayLine.replace("&", "clr"))
|
||||
.replace("clr", "&");
|
||||
displayLine = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, displayLine.replace("&", "clr")).replace("clr", "&");
|
||||
}
|
||||
|
||||
return displayLine;
|
||||
|
@ -1,99 +1,204 @@
|
||||
package com.songoda.skyblock.scoreboard;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import org.bukkit.scoreboard.Team.Option;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.Island;
|
||||
import com.songoda.skyblock.island.IslandManager;
|
||||
import com.songoda.skyblock.island.IslandRole;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import com.songoda.skyblock.utils.version.NMSUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ScoreboardManager {
|
||||
public class ScoreboardManager extends BukkitRunnable {
|
||||
|
||||
private final static int VERSION = NMSUtil.getVersionNumber();
|
||||
private final SkyBlock skyblock;
|
||||
private Map<UUID, Scoreboard> scoreboardStorage = new HashMap<>();
|
||||
private final Map<UUID, Scoreboard> scoreboardStorage;
|
||||
|
||||
private int runTicks = 0;
|
||||
|
||||
private List<String> teamNames;
|
||||
private List<String> objectiveNames;
|
||||
|
||||
public ScoreboardManager(SkyBlock skyblock) {
|
||||
this.skyblock = skyblock;
|
||||
this.scoreboardStorage = new HashMap<>();
|
||||
this.teamNames = new ArrayList<>();
|
||||
this.objectiveNames = new ArrayList<>();
|
||||
this.runTaskTimer(skyblock, 20, 40);
|
||||
}
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Scoreboard.Enable")) {
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
if (runTicks++ == 0) {
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
Scoreboard scoreboard = new Scoreboard(skyblock, all);
|
||||
Island island = islandManager.getIsland(all);
|
||||
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Scoreboard.Enable")) {
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
|
||||
if (island == null) {
|
||||
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&',
|
||||
config.getFileConfiguration().getString("Scoreboard.Tutorial.Displayname")));
|
||||
scoreboard.setDisplayList(
|
||||
config.getFileConfiguration().getStringList("Scoreboard.Tutorial.Displaylines"));
|
||||
} else {
|
||||
if (island.getRole(IslandRole.Member).size() == 0
|
||||
&& island.getRole(IslandRole.Operator).size() == 0) {
|
||||
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&',
|
||||
config.getFileConfiguration().getString("Scoreboard.Island.Solo.Displayname")));
|
||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
Scoreboard scoreboard = new Scoreboard(skyblock, all);
|
||||
Island island = islandManager.getIsland(all);
|
||||
|
||||
if (islandManager.getVisitorsAtIsland(island).size() == 0) {
|
||||
scoreboard.setDisplayList(config.getFileConfiguration()
|
||||
.getStringList("Scoreboard.Island.Solo.Empty.Displaylines"));
|
||||
} else {
|
||||
scoreboard.setDisplayList(config.getFileConfiguration()
|
||||
.getStringList("Scoreboard.Island.Solo.Occupied.Displaylines"));
|
||||
}
|
||||
if (island == null) {
|
||||
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Scoreboard.Tutorial.Displayname")));
|
||||
scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Tutorial.Displaylines"));
|
||||
} else {
|
||||
if (island.getRole(IslandRole.Member).size() == 0 && island.getRole(IslandRole.Operator).size() == 0) {
|
||||
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Scoreboard.Island.Solo.Displayname")));
|
||||
|
||||
if (islandManager.getVisitorsAtIsland(island).size() == 0) {
|
||||
scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Empty.Displaylines"));
|
||||
} else {
|
||||
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&',
|
||||
config.getFileConfiguration().getString("Scoreboard.Island.Team.Displayname")));
|
||||
|
||||
if (islandManager.getVisitorsAtIsland(island).size() == 0) {
|
||||
scoreboard.setDisplayList(config.getFileConfiguration()
|
||||
.getStringList("Scoreboard.Island.Team.Empty.Displaylines"));
|
||||
} else {
|
||||
scoreboard.setDisplayList(config.getFileConfiguration()
|
||||
.getStringList("Scoreboard.Island.Team.Occupied.Displaylines"));
|
||||
}
|
||||
|
||||
Map<String, String> displayVariables = new HashMap<>();
|
||||
displayVariables.put("%owner",
|
||||
config.getFileConfiguration().getString("Scoreboard.Island.Team.Word.Owner"));
|
||||
displayVariables.put("%operator", config.getFileConfiguration()
|
||||
.getString("Scoreboard.Island.Team.Word.Operator"));
|
||||
displayVariables.put("%member",
|
||||
config.getFileConfiguration().getString("Scoreboard.Island.Team.Word.Member"));
|
||||
|
||||
scoreboard.setDisplayVariables(displayVariables);
|
||||
scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Occupied.Displaylines"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Scoreboard.Island.Team.Displayname")));
|
||||
|
||||
scoreboard.run();
|
||||
storeScoreboard(all, scoreboard);
|
||||
if (islandManager.getVisitorsAtIsland(island).size() == 0) {
|
||||
scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Team.Empty.Displaylines"));
|
||||
} else {
|
||||
scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Team.Occupied.Displaylines"));
|
||||
}
|
||||
|
||||
Map<String, String> displayVariables = new HashMap<>();
|
||||
displayVariables.put("%owner", config.getFileConfiguration().getString("Scoreboard.Island.Team.Word.Owner"));
|
||||
displayVariables.put("%operator", config.getFileConfiguration().getString("Scoreboard.Island.Team.Word.Operator"));
|
||||
displayVariables.put("%member", config.getFileConfiguration().getString("Scoreboard.Island.Team.Word.Member"));
|
||||
|
||||
scoreboard.setDisplayVariables(displayVariables);
|
||||
}
|
||||
}
|
||||
|
||||
scoreboard.run();
|
||||
storeScoreboard(all, scoreboard);
|
||||
}
|
||||
}
|
||||
}.runTaskLater(skyblock, 20L);
|
||||
return;
|
||||
}
|
||||
|
||||
final org.bukkit.scoreboard.Scoreboard primary = Bukkit.getScoreboardManager().getMainScoreboard();
|
||||
final Collection<? extends Player> players = Bukkit.getOnlinePlayers();
|
||||
final Set<Objective> objectives = primary.getObjectives();
|
||||
final Set<Team> teams = primary.getTeams();
|
||||
|
||||
for (Player player : players) {
|
||||
|
||||
/*
|
||||
* Unregister all teams or objectives that are no longer present in the main
|
||||
* scoreboard.
|
||||
*/
|
||||
|
||||
final org.bukkit.scoreboard.Scoreboard board = player.getScoreboard();
|
||||
|
||||
for (String name : objectiveNames) {
|
||||
|
||||
if (primary.getObjective(name) != null) continue;
|
||||
|
||||
final Objective objective = board.getObjective(name);
|
||||
|
||||
if (objective != null) objective.unregister();
|
||||
|
||||
}
|
||||
|
||||
for (String name : teamNames) {
|
||||
|
||||
if (primary.getTeam(name) != null) continue;
|
||||
|
||||
final Team team = board.getTeam(name);
|
||||
|
||||
if (team != null) team.unregister();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Update the objective/team names.
|
||||
*/
|
||||
|
||||
objectiveNames.clear();
|
||||
teamNames.clear();
|
||||
|
||||
objectives.forEach(objective -> {
|
||||
if (primary.getObjective(objective.getName()) != null) objectiveNames.add(objective.getName());
|
||||
});
|
||||
teams.forEach(team -> {
|
||||
if (primary.getTeam(team.getName()) != null) teamNames.add(team.getName());
|
||||
});
|
||||
|
||||
/*
|
||||
* Update or add any missing information to the player's scoreboard.
|
||||
*/
|
||||
|
||||
for (Player player : players) {
|
||||
|
||||
final org.bukkit.scoreboard.Scoreboard playerBoard = player.getScoreboard();
|
||||
|
||||
for (Objective primaryObjective : objectives) {
|
||||
|
||||
Objective obj = playerBoard.getObjective(primaryObjective.getName());
|
||||
|
||||
if (obj == null) obj = playerBoard.registerNewObjective(primaryObjective.getName(), primaryObjective.getCriteria());
|
||||
|
||||
obj.setDisplayName(primaryObjective.getDisplayName());
|
||||
obj.setDisplaySlot(primaryObjective.getDisplaySlot());
|
||||
obj.setRenderType(primaryObjective.getRenderType());
|
||||
}
|
||||
|
||||
for (Team primaryTeam : teams) {
|
||||
|
||||
Team obj = playerBoard.getTeam(primaryTeam.getName());
|
||||
|
||||
if (obj == null) obj = playerBoard.registerNewTeam(primaryTeam.getName());
|
||||
|
||||
obj.setAllowFriendlyFire(primaryTeam.allowFriendlyFire());
|
||||
obj.setCanSeeFriendlyInvisibles(primaryTeam.canSeeFriendlyInvisibles());
|
||||
if (VERSION > 11) obj.setColor(primaryTeam.getColor());
|
||||
obj.setDisplayName(primaryTeam.getDisplayName());
|
||||
obj.setNameTagVisibility(primaryTeam.getNameTagVisibility());
|
||||
obj.setPrefix(primaryTeam.getPrefix());
|
||||
obj.setSuffix(primaryTeam.getSuffix());
|
||||
|
||||
for (String primaryEntry : primaryTeam.getEntries()) {
|
||||
obj.addEntry(primaryEntry);
|
||||
}
|
||||
|
||||
if (VERSION > 8) {
|
||||
for (Option option : Option.values()) {
|
||||
obj.setOption(option, primaryTeam.getOption(option));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void resendScoreboard() {
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Scoreboard.Enable")) return;
|
||||
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Scoreboard.Enable")) return;
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
|
||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
@ -104,42 +209,30 @@ public class ScoreboardManager {
|
||||
Island island = islandManager.getIsland(all);
|
||||
|
||||
if (island == null) {
|
||||
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&',
|
||||
config.getFileConfiguration().getString("Scoreboard.Tutorial.Displayname")));
|
||||
scoreboard.setDisplayList(
|
||||
config.getFileConfiguration().getStringList("Scoreboard.Tutorial.Displaylines"));
|
||||
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Scoreboard.Tutorial.Displayname")));
|
||||
scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Tutorial.Displaylines"));
|
||||
} else {
|
||||
if (island.getRole(IslandRole.Member).size() == 0
|
||||
&& island.getRole(IslandRole.Operator).size() == 0) {
|
||||
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&',
|
||||
config.getFileConfiguration().getString("Scoreboard.Island.Solo.Displayname")));
|
||||
if (island.getRole(IslandRole.Member).size() == 0 && island.getRole(IslandRole.Operator).size() == 0) {
|
||||
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Scoreboard.Island.Solo.Displayname")));
|
||||
|
||||
if (islandManager.getVisitorsAtIsland(island).size() == 0) {
|
||||
scoreboard.setDisplayList(config.getFileConfiguration()
|
||||
.getStringList("Scoreboard.Island.Solo.Empty.Displaylines"));
|
||||
scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Empty.Displaylines"));
|
||||
} else {
|
||||
scoreboard.setDisplayList(config.getFileConfiguration()
|
||||
.getStringList("Scoreboard.Island.Solo.Occupied.Displaylines"));
|
||||
scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Occupied.Displaylines"));
|
||||
}
|
||||
} else {
|
||||
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&',
|
||||
config.getFileConfiguration().getString("Scoreboard.Island.Team.Displayname")));
|
||||
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Scoreboard.Island.Team.Displayname")));
|
||||
|
||||
if (islandManager.getVisitorsAtIsland(island).size() == 0) {
|
||||
scoreboard.setDisplayList(config.getFileConfiguration()
|
||||
.getStringList("Scoreboard.Island.Team.Empty.Displaylines"));
|
||||
scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Team.Empty.Displaylines"));
|
||||
} else {
|
||||
scoreboard.setDisplayList(config.getFileConfiguration()
|
||||
.getStringList("Scoreboard.Island.Team.Occupied.Displaylines"));
|
||||
scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Team.Occupied.Displaylines"));
|
||||
}
|
||||
|
||||
Map<String, String> displayVariables = new HashMap<>();
|
||||
displayVariables.put("%owner",
|
||||
config.getFileConfiguration().getString("Scoreboard.Island.Team.Word.Owner"));
|
||||
displayVariables.put("%operator",
|
||||
config.getFileConfiguration().getString("Scoreboard.Island.Team.Word.Operator"));
|
||||
displayVariables.put("%member",
|
||||
config.getFileConfiguration().getString("Scoreboard.Island.Team.Word.Member"));
|
||||
displayVariables.put("%owner", config.getFileConfiguration().getString("Scoreboard.Island.Team.Word.Owner"));
|
||||
displayVariables.put("%operator", config.getFileConfiguration().getString("Scoreboard.Island.Team.Word.Operator"));
|
||||
displayVariables.put("%member", config.getFileConfiguration().getString("Scoreboard.Island.Team.Word.Member"));
|
||||
|
||||
scoreboard.setDisplayVariables(displayVariables);
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
@ -91,14 +92,19 @@ public class Stackable {
|
||||
}
|
||||
|
||||
private void updateDisplay() {
|
||||
// The chunk needs to be loaded otherwise the getNearbyEntities() in removeDisplay() won't find anything
|
||||
if (!this.location.getWorld().isChunkLoaded(this.location.getBlockX() >> 4, this.location.getBlockZ() >> 4))
|
||||
this.location.getChunk().load();
|
||||
// The chunk needs to be loaded otherwise the getNearbyEntities() in
|
||||
// removeDisplay() won't find anything
|
||||
if (!this.location.getWorld().isChunkLoaded(this.location.getBlockX() >> 4, this.location.getBlockZ() >> 4)) this.location.getChunk().load();
|
||||
|
||||
if (this.size > 1) {
|
||||
this.createDisplay();
|
||||
this.display.setCustomName(this.getCustomName());
|
||||
this.display.setCustomNameVisible(true);
|
||||
|
||||
if (display == null || !display.isValid()) {
|
||||
this.createDisplay();
|
||||
} else {
|
||||
this.display.setCustomName(this.getCustomName());
|
||||
this.display.setCustomNameVisible(true);
|
||||
}
|
||||
|
||||
} else {
|
||||
this.removeDisplay();
|
||||
}
|
||||
@ -119,6 +125,7 @@ public class Stackable {
|
||||
as.setHelmet(new ItemStack(this.material));
|
||||
as.setCustomName(this.getCustomName());
|
||||
as.setCustomNameVisible(true);
|
||||
as.setMetadata("StackableArmorStand", new FixedMetadataValue(SkyBlock.getInstance(), ""));
|
||||
this.display = as;
|
||||
}
|
||||
|
||||
@ -129,14 +136,13 @@ public class Stackable {
|
||||
|
||||
// Find any stragglers
|
||||
for (Entity entity : this.location.getWorld().getNearbyEntities(this.location.clone().add(0.5, 0.55, 0.5), 0.25, 0.5, 0.25))
|
||||
if (entity instanceof ArmorStand)
|
||||
entity.remove();
|
||||
if (entity instanceof ArmorStand) entity.remove();
|
||||
}
|
||||
|
||||
private void save() {
|
||||
File configFile = new File(SkyBlock.getInstance().getDataFolder().toString() + "/island-data");
|
||||
FileManager.Config config = SkyBlock.getInstance().getFileManager().getConfig(new File(configFile,
|
||||
SkyBlock.getInstance().getIslandManager().getIslandAtLocation(this.location).getOwnerUUID() + ".yml"));
|
||||
FileManager.Config config = SkyBlock.getInstance().getFileManager()
|
||||
.getConfig(new File(configFile, SkyBlock.getInstance().getIslandManager().getIslandAtLocation(this.location).getOwnerUUID() + ".yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (this.getSize() == 0) {
|
||||
@ -150,10 +156,10 @@ public class Stackable {
|
||||
}
|
||||
|
||||
private String getCustomName() {
|
||||
return ChatColor.translateAlternateColorCodes('&', SkyBlock.getInstance().getFileManager()
|
||||
.getConfig(new File(SkyBlock.getInstance().getDataFolder(), "language.yml"))
|
||||
.getFileConfiguration().getString("Hologram.Stackable.Message"))
|
||||
.replace("%block", WordUtils.capitalize(this.material.name().toLowerCase()).replace("_", " "))
|
||||
.replace("%amount", NumberUtil.formatNumber(this.size));
|
||||
return ChatColor
|
||||
.translateAlternateColorCodes('&',
|
||||
SkyBlock.getInstance().getFileManager().getConfig(new File(SkyBlock.getInstance().getDataFolder(), "language.yml")).getFileConfiguration()
|
||||
.getString("Hologram.Stackable.Message"))
|
||||
.replace("%block", WordUtils.capitalize(this.material.name().toLowerCase()).replace("_", " ")).replace("%amount", NumberUtil.formatNumber(this.size));
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,21 @@
|
||||
package com.songoda.skyblock.stackable;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
|
||||
public class StackableManager {
|
||||
|
||||
|
@ -1,12 +1,5 @@
|
||||
package com.songoda.skyblock.usercache;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.utils.player.NameFetcher;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
@ -14,7 +7,15 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class UserCacheManager {
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.utils.player.NameFetcher;
|
||||
|
||||
public final class UserCacheManager {
|
||||
|
||||
private final SkyBlock skyblock;
|
||||
private final Config config;
|
||||
@ -23,74 +24,62 @@ public class UserCacheManager {
|
||||
this.skyblock = skyblock;
|
||||
this.config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "usercache.yml"));
|
||||
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
File configFile = new File(skyblock.getDataFolder().toString() + "/island-data");
|
||||
final FileManager fileManager = skyblock.getFileManager();
|
||||
final File configFile = new File(skyblock.getDataFolder().toString() + "/island-data");
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> {
|
||||
if (configFile.exists()) {
|
||||
int usersIgnored = 0;
|
||||
|
||||
Bukkit.getServer().getLogger().log(Level.INFO,
|
||||
"SkyBlock | Info: Fetching user information from island data. This may take a while...");
|
||||
Bukkit.getServer().getLogger().log(Level.INFO, "SkyBlock | Info: Fetching user information from island data. This may take a while...");
|
||||
|
||||
for (File fileList : configFile.listFiles()) {
|
||||
if (fileList != null && fileList.getName().contains(".yml")
|
||||
&& fileList.getName().length() > 35) {
|
||||
UUID islandOwnerUUID = null;
|
||||
|
||||
try {
|
||||
Config config = new Config(fileManager, fileList);
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
if (fileList == null) continue;
|
||||
|
||||
islandOwnerUUID = UUID.fromString(fileList.getName().replace(".yml", ""));
|
||||
final String fileName = fileList.getName();
|
||||
|
||||
if (islandOwnerUUID == null) {
|
||||
islandOwnerUUID = UUID.fromString(fileList.getName().replaceFirst("[.][^.]+$", ""));
|
||||
if (fileName.length() < 35 || !fileName.endsWith(".yml")) continue;
|
||||
|
||||
if (islandOwnerUUID == null) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
try {
|
||||
final FileConfiguration configLoad = new Config(fileManager, fileList).getFileConfiguration();
|
||||
final String ownerUUIDString = fileName.substring(0, fileName.indexOf('.'));
|
||||
|
||||
Set<UUID> islandMembers = new HashSet<>();
|
||||
islandMembers.add(islandOwnerUUID);
|
||||
System.out.println(ownerUUIDString);
|
||||
|
||||
if (configLoad.getString("Members") != null) {
|
||||
for (String memberList : configLoad.getStringList("Members")) {
|
||||
islandMembers.add(UUID.fromString(memberList));
|
||||
}
|
||||
}
|
||||
Set<UUID> islandMembers = new HashSet<>();
|
||||
islandMembers.add(UUID.fromString(ownerUUIDString));
|
||||
|
||||
if (configLoad.getString("Operators") != null) {
|
||||
for (String operatorList : configLoad.getStringList("Operators")) {
|
||||
islandMembers.add(UUID.fromString(operatorList));
|
||||
}
|
||||
}
|
||||
|
||||
for (UUID islandMemberList : islandMembers) {
|
||||
if (!hasUser(islandMemberList)) {
|
||||
NameFetcher.Names[] names = NameFetcher.getNames(islandMemberList);
|
||||
|
||||
if (names.length >= 1) {
|
||||
addUser(islandMemberList, names[0].getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
usersIgnored++;
|
||||
for (String memberList : configLoad.getStringList("Members")) {
|
||||
islandMembers.add(UUID.fromString(memberList));
|
||||
}
|
||||
|
||||
for (String operatorList : configLoad.getStringList("Operators")) {
|
||||
islandMembers.add(UUID.fromString(operatorList));
|
||||
}
|
||||
|
||||
for (UUID islandMemberList : islandMembers) {
|
||||
if (!hasUser(islandMemberList)) {
|
||||
NameFetcher.Names[] names = NameFetcher.getNames(islandMemberList);
|
||||
|
||||
if (names.length >= 1) {
|
||||
addUser(islandMemberList, names[0].getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
usersIgnored++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
save();
|
||||
|
||||
if (usersIgnored != 0) {
|
||||
Bukkit.getServer().getLogger().log(Level.INFO,
|
||||
"SkyBlock | Info: Finished fetching user information from island data. There were "
|
||||
+ usersIgnored + " users that were skipped.");
|
||||
"SkyBlock | Info: Finished fetching user information from island data. There were " + usersIgnored + " users that were skipped.");
|
||||
} else {
|
||||
Bukkit.getServer().getLogger().log(Level.INFO,
|
||||
"SkyBlock | Info: Finished fetching user information from island data.");
|
||||
Bukkit.getServer().getLogger().log(Level.INFO, "SkyBlock | Info: Finished fetching user information from island data. No users were ignored.");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -0,0 +1,115 @@
|
||||
package com.songoda.skyblock.utils.item;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.utils.StringUtil;
|
||||
import com.songoda.skyblock.utils.item.nInventoryUtil.ClickEvent;
|
||||
import com.songoda.skyblock.utils.version.Materials;
|
||||
|
||||
public final class MenuClickRegistry {
|
||||
|
||||
private static MenuClickRegistry instance;
|
||||
|
||||
public static MenuClickRegistry getInstance() {
|
||||
return instance == null ? instance = new MenuClickRegistry() : instance;
|
||||
}
|
||||
|
||||
private Set<MenuPopulator> populators;
|
||||
private Map<RegistryKey, MenuExecutor> executors;
|
||||
|
||||
private MenuClickRegistry() {
|
||||
this.executors = new HashMap<>();
|
||||
this.populators = new HashSet<>();
|
||||
}
|
||||
|
||||
public void register(MenuPopulator populator) {
|
||||
populator.populate(executors);
|
||||
populators.add(populator);
|
||||
}
|
||||
|
||||
public void reloadAll() {
|
||||
executors.clear();
|
||||
for (MenuPopulator populator : populators) {
|
||||
populator.populate(executors);
|
||||
}
|
||||
}
|
||||
|
||||
public void dispatch(Player clicker, ClickEvent e) {
|
||||
|
||||
final ItemStack item = e.getItem();
|
||||
|
||||
if (item == null) return;
|
||||
|
||||
final ItemMeta meta = item.getItemMeta();
|
||||
|
||||
if (meta == null) return;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
final MenuExecutor executor = executors.get(RegistryKey.fromName(meta.getDisplayName(), Materials.getMaterials(item.getType(), (byte) item.getDurability())));
|
||||
|
||||
System.out.println(executors.size());
|
||||
|
||||
if (executor == null) return;
|
||||
|
||||
executor.onClick(SkyBlock.getInstance(), clicker, e);
|
||||
}
|
||||
|
||||
public static interface MenuPopulator {
|
||||
|
||||
void populate(Map<RegistryKey, MenuExecutor> executors);
|
||||
|
||||
}
|
||||
|
||||
public static interface MenuExecutor {
|
||||
|
||||
void onClick(SkyBlock skyblock, Player clicker, ClickEvent e);
|
||||
|
||||
}
|
||||
|
||||
public static class RegistryKey {
|
||||
|
||||
private static final File path = new File(SkyBlock.getInstance().getDataFolder(), "language.yml");
|
||||
|
||||
private final String name;
|
||||
private final Materials type;
|
||||
|
||||
private RegistryKey(String name, Materials type) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof RegistryKey)) return false;
|
||||
|
||||
final RegistryKey other = (RegistryKey) obj;
|
||||
|
||||
return Objects.equals(name, other.name) && type == other.type;
|
||||
}
|
||||
|
||||
public static RegistryKey fromName(String name, Materials type) {
|
||||
return new RegistryKey(name, type);
|
||||
}
|
||||
|
||||
public static RegistryKey fromLanguageFile(String namePath, Materials type) {
|
||||
return new RegistryKey(StringUtil.color(SkyBlock.getInstance().getFileManager().getConfig(path).getFileConfiguration().getString(namePath)), type);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -24,6 +24,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class nInventoryUtil {
|
||||
|
||||
@ -55,8 +56,7 @@ public class nInventoryUtil {
|
||||
return;
|
||||
}
|
||||
|
||||
ClickEvent clickEvent = new ClickEvent(event.getClick(), event.getSlot(),
|
||||
event.getCurrentItem());
|
||||
ClickEvent clickEvent = new ClickEvent(event.getClick(), event.getSlot(), event.getCurrentItem());
|
||||
handler.onClick(clickEvent);
|
||||
|
||||
if (!clickEvent.getCancelled()) {
|
||||
@ -115,8 +115,7 @@ public class nInventoryUtil {
|
||||
return items;
|
||||
}
|
||||
|
||||
public Item createItem(ItemStack is, String itemDisplayname, List<String> itemLore, Placeholder[] placeholders,
|
||||
Enchantment[] itemEnchantments, ItemFlag[] itemFlags) {
|
||||
public Item createItem(ItemStack is, String itemDisplayname, List<String> itemLore, Placeholder[] placeholders, Enchantment[] itemEnchantments, ItemFlag[] itemFlags) {
|
||||
return new Item(is, itemDisplayname, itemLore, placeholders, itemEnchantments, itemFlags);
|
||||
}
|
||||
|
||||
@ -136,7 +135,6 @@ public class nInventoryUtil {
|
||||
public void setRows(int rows) {
|
||||
if (rows > 6 || rows < 0) {
|
||||
size = 9;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -162,9 +160,8 @@ public class nInventoryUtil {
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
int slot = (int) items.keySet().toArray()[i];
|
||||
inv.setItem(slot, items.get(slot));
|
||||
for(Entry<Integer, ItemStack> entry : items.entrySet()) {
|
||||
inv.setItem(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@ -193,7 +190,7 @@ public class nInventoryUtil {
|
||||
void onClick(ClickEvent event);
|
||||
}
|
||||
|
||||
public class Item {
|
||||
public static class Item {
|
||||
|
||||
private ItemStack is;
|
||||
private String itemDisplayname;
|
||||
@ -202,8 +199,7 @@ public class nInventoryUtil {
|
||||
private Enchantment[] itemEnchantments;
|
||||
private ItemFlag[] itemFlags;
|
||||
|
||||
public Item(ItemStack is, String itemDisplayname, List<String> itemLore, Placeholder[] placeholders,
|
||||
Enchantment[] itemEnchantments, ItemFlag[] itemFlags) {
|
||||
public Item(ItemStack is, String itemDisplayname, List<String> itemLore, Placeholder[] placeholders, Enchantment[] itemEnchantments, ItemFlag[] itemFlags) {
|
||||
this.is = is;
|
||||
this.itemDisplayname = ChatColor.translateAlternateColorCodes('&', itemDisplayname);
|
||||
this.itemLore = itemLore;
|
||||
@ -214,14 +210,13 @@ public class nInventoryUtil {
|
||||
|
||||
public void setLore() {
|
||||
if (itemLore != null) {
|
||||
ArrayList<String> formattedItemLore = new ArrayList<>();
|
||||
List<String> formattedItemLore = new ArrayList<>(itemLore.size());
|
||||
|
||||
for (String itemLoreList : itemLore) {
|
||||
if (placeholders != null) {
|
||||
for (Placeholder placeholderList : placeholders) {
|
||||
if (itemLoreList.contains(placeholderList.getPlaceholder())) {
|
||||
itemLoreList = ChatColor.translateAlternateColorCodes('&', itemLoreList
|
||||
.replace(placeholderList.getPlaceholder(), placeholderList.getResult()));
|
||||
itemLoreList = ChatColor.translateAlternateColorCodes('&', itemLoreList.replace(placeholderList.getPlaceholder(), placeholderList.getResult()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,18 @@
|
||||
package com.songoda.skyblock.utils.player;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
import java.util.Scanner;
|
||||
import java.util.UUID;
|
||||
|
||||
public class NameFetcher {
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public final class NameFetcher {
|
||||
|
||||
private NameFetcher() {
|
||||
|
||||
}
|
||||
|
||||
public static Names[] getNames(UUID uuid) throws IOException {
|
||||
if (uuid == null) {
|
||||
@ -18,17 +21,14 @@ public class NameFetcher {
|
||||
|
||||
Names[] names = null;
|
||||
|
||||
Scanner jsonScanner = new Scanner(
|
||||
(new URL("https://api.mojang.com/user/profiles/" + uuid.toString().replaceAll("-", "") + "/names"))
|
||||
.openConnection().getInputStream(),
|
||||
"UTF-8");
|
||||
Scanner jsonScanner = new Scanner((new URL("https://api.mojang.com/user/profiles/" + uuid.toString().replaceAll("-", "") + "/names")).openConnection().getInputStream(), "UTF-8");
|
||||
names = new Gson().fromJson(jsonScanner.next(), Names[].class);
|
||||
jsonScanner.close();
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
public class Names {
|
||||
public static class Names {
|
||||
|
||||
public String name;
|
||||
public long changedToAt;
|
||||
|
@ -0,0 +1,79 @@
|
||||
package com.songoda.skyblock.utils.player;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
|
||||
public final class PlayerUtil {
|
||||
|
||||
private PlayerUtil() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will only parse positive numbers and will skip any non digit.
|
||||
*
|
||||
* <p>
|
||||
* An example:
|
||||
* <p>
|
||||
* <code>int number = getPositiveNumber("abc-123", 0, "abc-123".length())</code>
|
||||
* will return 123
|
||||
*
|
||||
* @throws IndexOutOfBoundsException if (input.length() < start ||
|
||||
* input.length() > end) evaluates to true.
|
||||
* @return a positive number for the given input String at the start and end
|
||||
* index.
|
||||
*/
|
||||
public static int getPositiveNumber(String input, int start, int end) {
|
||||
|
||||
if (input.length() < start || input.length() > end) throw new IndexOutOfBoundsException("");
|
||||
|
||||
int num = 0;
|
||||
|
||||
for (int i = start; i < end; i++) {
|
||||
|
||||
final char ch = input.charAt(i);
|
||||
|
||||
if (!Character.isDigit(ch)) continue;
|
||||
|
||||
final int digit = Character.getNumericValue(ch);
|
||||
|
||||
num = num * 10 + digit;
|
||||
}
|
||||
|
||||
return num;
|
||||
|
||||
}
|
||||
|
||||
public static int getNumberFromPermission(Player player, String permission, boolean bypassPermission, int def) {
|
||||
|
||||
final Set<PermissionAttachmentInfo> permissions = player.getEffectivePermissions();
|
||||
|
||||
if (bypassPermission && player.hasPermission(permission + ".bypass")) return Integer.MAX_VALUE;
|
||||
|
||||
boolean set = false;
|
||||
int highest = 0;
|
||||
|
||||
for (PermissionAttachmentInfo info : permissions) {
|
||||
|
||||
final String perm = info.getPermission();
|
||||
|
||||
if (!perm.startsWith(permission)) continue;
|
||||
|
||||
final int index = perm.lastIndexOf('.');
|
||||
|
||||
if (index == -1 || index == perm.length()) continue;
|
||||
|
||||
final int number = getPositiveNumber(perm, index, perm.length());
|
||||
|
||||
if (number >= highest) {
|
||||
highest = number;
|
||||
set = true;
|
||||
}
|
||||
}
|
||||
|
||||
return set ? highest : def;
|
||||
}
|
||||
|
||||
}
|
@ -7,19 +7,32 @@ import java.lang.reflect.Field;
|
||||
|
||||
public class NMSUtil {
|
||||
|
||||
private static final String version;
|
||||
private static final int versionNumber;
|
||||
private static final int versionReleaseNumber;
|
||||
|
||||
static {
|
||||
|
||||
String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
||||
version = packageName.substring(packageName.lastIndexOf('.') + 1) + ".";
|
||||
|
||||
String name = version.substring(3);
|
||||
versionNumber = Integer.parseInt(name.substring(0, name.length() - 4));
|
||||
|
||||
versionReleaseNumber = Integer.parseInt(version.substring(version.length() - 2).replace(".", ""));
|
||||
|
||||
}
|
||||
|
||||
public static String getVersion() {
|
||||
String name = Bukkit.getServer().getClass().getPackage().getName();
|
||||
return name.substring(name.lastIndexOf('.') + 1) + ".";
|
||||
return version;
|
||||
}
|
||||
|
||||
public static int getVersionNumber() {
|
||||
String name = getVersion().substring(3);
|
||||
return Integer.valueOf(name.substring(0, name.length() - 4));
|
||||
return versionNumber;
|
||||
}
|
||||
|
||||
public static int getVersionReleaseNumber() {
|
||||
String NMSVersion = getVersion();
|
||||
return Integer.valueOf(NMSVersion.substring(NMSVersion.length() - 2).replace(".", ""));
|
||||
return versionReleaseNumber;
|
||||
}
|
||||
|
||||
public static Class<?> getNMSClass(String className) {
|
||||
|
@ -25,11 +25,13 @@ public enum Sounds {
|
||||
FIRE("FIRE", "BLOCK_FIRE_AMBIENT", "BLOCK_FIRE_AMBIENT"),
|
||||
FIRE_IGNITE("FIRE_IGNITE", "ITEM_FLINTANDSTEEL_USE", "ITEM_FLINTANDSTEEL_USE"),
|
||||
FIZZ("FIZZ", "BLOCK_FIRE_EXTINGUISH", "BLOCK_FIRE_EXTINGUISH"),
|
||||
FUSE("FUSE", "ENTITY_TNT_PRIMED", "ENTITY_TNT_PRIMED"), GLASS("GLASS", "BLOCK_GLASS_BREAK", "BLOCK_GLASS_BREAK"),
|
||||
FUSE("FUSE", "ENTITY_TNT_PRIMED", "ENTITY_TNT_PRIMED"),
|
||||
GLASS("GLASS", "BLOCK_GLASS_BREAK", "BLOCK_GLASS_BREAK"),
|
||||
HURT_FLESH("HURT_FLESH", "ENTITY_PLAYER_HURT", "ENTITY_PLAYER_HURT"),
|
||||
ITEM_BREAK("ITEM_BREAK", "ENTITY_ITEM_BREAK", "ENTITY_ITEM_BREAK"),
|
||||
ITEM_PICKUP("ITEM_PICKUP", "ENTITY_ITEM_PICKUP", "ENTITY_ITEM_PICKUP"),
|
||||
LAVA("LAVA", "BLOCK_LAVA_AMBIENT", "BLOCK_LAVA_AMBIENT"), LAVA_POP("LAVA_POP", "BLOCK_LAVA_POP", "BLOCK_LAVA_POP"),
|
||||
LAVA("LAVA", "BLOCK_LAVA_AMBIENT", "BLOCK_LAVA_AMBIENT"),
|
||||
LAVA_POP("LAVA_POP", "BLOCK_LAVA_POP", "BLOCK_LAVA_POP"),
|
||||
LEVEL_UP("LEVEL_UP", "ENTITY_PLAYER_LEVELUP", "ENTITY_PLAYER_LEVELUP"),
|
||||
MINECART_BASE("MINECART_BASE", "ENTITY_MINECART_RIDING", "ENTITY_MINECART_RIDING"),
|
||||
MINECART_INSIDE("MINECART_INSIDE", "ENTITY_MINECART_RIDING", "ENTITY_MINECART_RIDING"),
|
||||
@ -163,8 +165,7 @@ public enum Sounds {
|
||||
FIREWORK_BLAST("FIREWORK_BLAST", "ENTITY_FIREWORK_BLAST", "ENTITY_FIREWORK_ROCKET_BLAST"),
|
||||
FIREWORK_BLAST2("FIREWORK_BLAST2", "ENTITY_FIREWORK_BLAST_FAR", "ENTITY_FIREWORK_ROCKET_BLAST_FAR"),
|
||||
FIREWORK_LARGE_BLAST("FIREWORK_LARGE_BLAST", "ENTITY_FIREWORK_LARGE_BLAST", "ENTITY_FIREWORK_ROCKET_LARGE_BLAST"),
|
||||
FIREWORK_LARGE_BLAST2("FIREWORK_LARGE_BLAST2", "ENTITY_FIREWORK_LARGE_BLAST_FAR",
|
||||
"ENTITY_FIREWORK_ROCKET_LARGE_BLAST_FAR"),
|
||||
FIREWORK_LARGE_BLAST2("FIREWORK_LARGE_BLAST2", "ENTITY_FIREWORK_LARGE_BLAST_FAR", "ENTITY_FIREWORK_ROCKET_LARGE_BLAST_FAR"),
|
||||
FIREWORK_TWINKLE("FIREWORK_TWINKLE", "ENTITY_FIREWORK_TWINKLE", "ENTITY_FIREWORK_ROCKET_TWINKLE"),
|
||||
FIREWORK_TWINKLE2("FIREWORK_TWINKLE2", "ENTITY_FIREWORK_TWINKLE_FAR", "ENTITY_FIREWORK_ROCKET_TWINKLE_FAR"),
|
||||
FIREWORK_LAUNCH("FIREWORK_LAUNCH", "ENTITY_FIREWORK_LAUNCH", "ENTITY_FIREWORK_ROCKET_LAUNCH"),
|
||||
|
@ -26,8 +26,7 @@ import java.util.logging.Level;
|
||||
public final class LocationUtil {
|
||||
|
||||
public static boolean isLocationLocation(Location location1, Location location2) {
|
||||
return location1.getBlockX() == location2.getBlockX() && location1.getBlockY() == location2.getBlockY()
|
||||
&& location1.getBlockZ() == location2.getBlockZ();
|
||||
return location1.getBlockX() == location2.getBlockX() && location1.getBlockY() == location2.getBlockY() && location1.getBlockZ() == location2.getBlockZ();
|
||||
}
|
||||
|
||||
public static boolean isLocationAffectingIslandSpawn(Location location, Island island, IslandWorld world) {
|
||||
@ -36,13 +35,14 @@ public final class LocationUtil {
|
||||
}
|
||||
|
||||
private static boolean isLocationAffectingLocation(Location location1, Location location2) {
|
||||
Location headHeight = location2.clone().add(0, 1, 0);
|
||||
Location feetHeight = location2.clone();
|
||||
Location groundHeight = location2.clone().add(0, -1, 0);
|
||||
location2 = location2.clone();
|
||||
|
||||
return isLocationLocation(headHeight, location1)
|
||||
|| isLocationLocation(feetHeight, location1)
|
||||
|| isLocationLocation(groundHeight, location1);
|
||||
/*
|
||||
* First isLocationLocation() call is HeadHeight, second feetHeight, and the
|
||||
* final one is GroundHeight.
|
||||
*/
|
||||
return isLocationLocation(location2.add(0, 1, 0), location1) || isLocationLocation(location2.subtract(0, 1, 0), location1)
|
||||
|| isLocationLocation(location2.subtract(0, 1, 0), location1);
|
||||
}
|
||||
|
||||
public static boolean isLocationAtLocationRadius(Location location1, Location location2, double radius) {
|
||||
@ -58,19 +58,20 @@ public final class LocationUtil {
|
||||
}
|
||||
|
||||
public static List<Location> getLocations(Location minLocation, Location maxLocation) {
|
||||
List<Location> locations = new ArrayList<>();
|
||||
|
||||
int MinX = Math.min(maxLocation.getBlockX(), minLocation.getBlockX());
|
||||
int MinY = Math.min(maxLocation.getBlockY(), minLocation.getBlockY());
|
||||
int MinZ = Math.min(maxLocation.getBlockZ(), minLocation.getBlockZ());
|
||||
int minX = Math.min(maxLocation.getBlockX(), minLocation.getBlockX());
|
||||
int minY = Math.min(maxLocation.getBlockY(), minLocation.getBlockY());
|
||||
int minZ = Math.min(maxLocation.getBlockZ(), minLocation.getBlockZ());
|
||||
|
||||
int MaxX = Math.max(maxLocation.getBlockX(), minLocation.getBlockX());
|
||||
int MaxY = Math.max(maxLocation.getBlockY(), minLocation.getBlockY());
|
||||
int MaxZ = Math.max(maxLocation.getBlockZ(), minLocation.getBlockZ());
|
||||
int maxX = Math.max(maxLocation.getBlockX(), minLocation.getBlockX());
|
||||
int maxY = Math.max(maxLocation.getBlockY(), minLocation.getBlockY());
|
||||
int maxZ = Math.max(maxLocation.getBlockZ(), minLocation.getBlockZ());
|
||||
|
||||
for (int x = MinX; x <= MaxX; x++) {
|
||||
for (int y = MinY; y <= MaxY; y++) {
|
||||
for (int z = MinZ; z <= MaxZ; z++) {
|
||||
List<Location> locations = new ArrayList<>(maxX + maxY + maxZ + 3);
|
||||
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
for (int y = minY; y <= maxY; y++) {
|
||||
for (int z = minZ; z <= maxZ; z++) {
|
||||
locations.add(new Location(minLocation.getWorld(), x, y, z));
|
||||
}
|
||||
}
|
||||
@ -88,8 +89,8 @@ public final class LocationUtil {
|
||||
int MaxY = Math.max(maxLocation.getBlockY(), minLocation.getBlockY());
|
||||
int MaxZ = Math.max(maxLocation.getBlockZ(), minLocation.getBlockZ());
|
||||
|
||||
return MinX < targetLocation.getX() && MaxX > targetLocation.getX() && MinY < targetLocation.getY()
|
||||
&& MaxY > targetLocation.getY() && MinZ < targetLocation.getZ() && MaxZ > targetLocation.getZ();
|
||||
return MinX < targetLocation.getX() && MaxX > targetLocation.getX() && MinY < targetLocation.getY() && MaxY > targetLocation.getY() && MinZ < targetLocation.getZ()
|
||||
&& MaxZ > targetLocation.getZ();
|
||||
}
|
||||
|
||||
public static Location getHighestBlock(Location location) {
|
||||
@ -110,28 +111,25 @@ public final class LocationUtil {
|
||||
int maxY = 0;
|
||||
boolean followY = false;
|
||||
|
||||
final int blockX = location.getBlockX();
|
||||
final int blockZ = location.getBlockZ();
|
||||
final World world = location.getWorld();
|
||||
|
||||
for (int y = 0; y < location.getWorld().getMaxHeight(); y++) {
|
||||
Location loc = new Location(location.getWorld(), location.getBlockX(), y, location.getBlockZ());
|
||||
Block block = loc.getBlock().getRelative(BlockFace.UP);
|
||||
final Block block = world.getBlockAt(blockX, y, blockZ).getRelative(BlockFace.UP);
|
||||
|
||||
if (isNether) {
|
||||
if (y < 127 && (block.getType() == Material.LAVA
|
||||
|| block.getType() == Materials.LEGACY_STATIONARY_LAVA.getPostMaterial()
|
||||
|| block.getType() == Material.AIR)) {
|
||||
if (y < 127 && (block.getType() == Material.LAVA || block.getType() == Materials.LEGACY_STATIONARY_LAVA.getPostMaterial() || block.getType() == Material.AIR)) {
|
||||
maxY = y;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (block.getType() == Materials.OAK_LEAVES.parseMaterial()
|
||||
|| block.getType() == Materials.ACACIA_LEAVES.parseMaterial()) {
|
||||
if (block.getType() == Materials.OAK_LEAVES.parseMaterial() || block.getType() == Materials.ACACIA_LEAVES.parseMaterial()) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (block.getType() == Material.AIR
|
||||
|| block.getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial()
|
||||
|| block.getType() == Material.WATER
|
||||
|| block.getType() == Materials.LEGACY_STATIONARY_LAVA.getPostMaterial()
|
||||
|| block.getType() == Material.LAVA) {
|
||||
if (block.getType() == Material.AIR || block.getType() == Materials.LEGACY_STATIONARY_WATER.getPostMaterial() || block.getType() == Material.WATER
|
||||
|| block.getType() == Materials.LEGACY_STATIONARY_LAVA.getPostMaterial() || block.getType() == Material.LAVA) {
|
||||
if (!followY) {
|
||||
maxY = y;
|
||||
followY = true;
|
||||
@ -191,8 +189,7 @@ public final class LocationUtil {
|
||||
Location spawnLocation = getSpawnLocation();
|
||||
|
||||
if (spawnLocation == null) {
|
||||
Bukkit.getServer().getLogger().log(Level.WARNING,
|
||||
"SkyBlock | Error: The location for the spawn point could not be found.");
|
||||
Bukkit.getServer().getLogger().log(Level.WARNING, "SkyBlock | Error: The location for the spawn point could not be found.");
|
||||
|
||||
return;
|
||||
}
|
||||
@ -230,8 +227,7 @@ public final class LocationUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Location getRandomLocation(World world, int xRange, int zRange, boolean loadChunk,
|
||||
boolean ignoreLiquid) {
|
||||
public static Location getRandomLocation(World world, int xRange, int zRange, boolean loadChunk, boolean ignoreLiquid) {
|
||||
Random rnd = new Random();
|
||||
|
||||
int rndX = rnd.nextInt(xRange);
|
||||
@ -242,16 +238,14 @@ public final class LocationUtil {
|
||||
double rndY = -1;
|
||||
|
||||
if (world.getEnvironment() == Environment.NETHER) {
|
||||
|
||||
|
||||
Location rndLoc = new Location(world, rndX, 0, rndZ);
|
||||
|
||||
|
||||
for (int i = 120; i > 0; i--) {
|
||||
rndLoc.setY(i);
|
||||
|
||||
if (rndLoc.getBlock().getType() != Material.AIR
|
||||
&& rndLoc.clone().add(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.AIR
|
||||
&& rndLoc.clone().add(0.0D, 2.0D, 0.0D).getBlock().getType() == Material.AIR
|
||||
&& rndLoc.clone().add(0.0D, 3.0D, 0.0D).getBlock().getType() == Material.AIR
|
||||
if (rndLoc.getBlock().getType() != Material.AIR && rndLoc.clone().add(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.AIR
|
||||
&& rndLoc.clone().add(0.0D, 2.0D, 0.0D).getBlock().getType() == Material.AIR && rndLoc.clone().add(0.0D, 3.0D, 0.0D).getBlock().getType() == Material.AIR
|
||||
&& rndLoc.clone().add(0.0D, 4.0D, 0.0D).getBlock().getType() == Material.AIR) {
|
||||
rndY = i;
|
||||
break;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -173,11 +173,7 @@ public class VisitManager {
|
||||
}
|
||||
|
||||
public Visit getIsland(UUID islandOwnerUUID) {
|
||||
if (hasIsland(islandOwnerUUID)) {
|
||||
return visitStorage.get(islandOwnerUUID);
|
||||
}
|
||||
|
||||
return null;
|
||||
return visitStorage.get(islandOwnerUUID);
|
||||
}
|
||||
|
||||
public HashMap<UUID, Visit> getIslands() {
|
||||
|
@ -1,10 +1,9 @@
|
||||
package com.songoda.skyblock.visit;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.songoda.skyblock.playerdata.PlayerData;
|
||||
import com.songoda.skyblock.playerdata.PlayerDataManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class VisitTask extends BukkitRunnable {
|
||||
|
||||
@ -16,13 +15,9 @@ public class VisitTask extends BukkitRunnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
if (playerDataManager.hasPlayerData(all)) {
|
||||
PlayerData playerData = playerDataManager.getPlayerData(all);
|
||||
|
||||
if (playerData.getIsland() != null) {
|
||||
playerData.setVisitTime(playerData.getVisitTime() + 1);
|
||||
}
|
||||
for (PlayerData playerData : playerDataManager.getPlayerData().values()) {
|
||||
if (playerData.getIsland() != null) {
|
||||
playerData.setVisitTime(playerData.getVisitTime() + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,28 +44,22 @@ public class WorldManager {
|
||||
endWorld = Bukkit.getServer().getWorld(endWorldName);
|
||||
|
||||
if (normalWorld == null) {
|
||||
Bukkit.getServer().getLogger().log(Level.INFO,
|
||||
"SkyBlock | Info: Generating VoidWorld '" + normalWorldName + "'.");
|
||||
normalWorld = WorldCreator.name(normalWorldName).type(WorldType.FLAT).environment(normalWorldEnvironment)
|
||||
.generator(new VoidGenerator()).createWorld();
|
||||
Bukkit.getServer().getLogger().log(Level.INFO, "SkyBlock | Info: Generating VoidWorld '" + normalWorldName + "'.");
|
||||
normalWorld = WorldCreator.name(normalWorldName).type(WorldType.FLAT).environment(normalWorldEnvironment).generator(new VoidGenerator()).createWorld();
|
||||
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> registerMultiverse(normalWorldName, normalWorldEnvironment));
|
||||
}
|
||||
|
||||
if (netherWorld == null && netherWorldEnabled) {
|
||||
Bukkit.getServer().getLogger().log(Level.INFO,
|
||||
"SkyBlock | Info: Generating VoidWorld '" + netherWorldName + "'.");
|
||||
netherWorld = WorldCreator.name(netherWorldName).type(WorldType.FLAT).environment(netherWorldEnvironment)
|
||||
.generator(new VoidGenerator()).createWorld();
|
||||
Bukkit.getServer().getLogger().log(Level.INFO, "SkyBlock | Info: Generating VoidWorld '" + netherWorldName + "'.");
|
||||
netherWorld = WorldCreator.name(netherWorldName).type(WorldType.FLAT).environment(netherWorldEnvironment).generator(new VoidGenerator()).createWorld();
|
||||
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> registerMultiverse(netherWorldName, netherWorldEnvironment));
|
||||
}
|
||||
|
||||
if (endWorld == null && endWorldEnabled) {
|
||||
Bukkit.getServer().getLogger().log(Level.INFO,
|
||||
"SkyBlock | Info: Generating VoidWorld '" + endWorldName + "'.");
|
||||
endWorld = WorldCreator.name(endWorldName).type(WorldType.FLAT).environment(endWorldEnvironment)
|
||||
.generator(new VoidGenerator()).createWorld();
|
||||
Bukkit.getServer().getLogger().log(Level.INFO, "SkyBlock | Info: Generating VoidWorld '" + endWorldName + "'.");
|
||||
endWorld = WorldCreator.name(endWorldName).type(WorldType.FLAT).environment(endWorldEnvironment).generator(new VoidGenerator()).createWorld();
|
||||
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> registerMultiverse(endWorldName, endWorldEnvironment));
|
||||
}
|
||||
@ -73,10 +67,8 @@ public class WorldManager {
|
||||
|
||||
public void registerMultiverse(String worldName, World.Environment environment) {
|
||||
if (Bukkit.getServer().getPluginManager().getPlugin("Multiverse-Core") != null) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
|
||||
"mv import " + worldName + " " + environment.name().toLowerCase() + " -g " + skyblock.getName());
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
|
||||
"mv modify set generator " + skyblock.getName() + " " + worldName);
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv import " + worldName + " " + environment.name().toLowerCase() + " -g " + skyblock.getName());
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv modify set generator " + skyblock.getName() + " " + worldName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,27 +89,21 @@ public class WorldManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (normalWorld != null && normalWorld.getName().equals(world.getName()))
|
||||
return IslandWorld.Normal;
|
||||
if (normalWorld != null && normalWorld.getName().equals(world.getName())) return IslandWorld.Normal;
|
||||
|
||||
if (netherWorld != null && netherWorld.getName().equals(world.getName()))
|
||||
return IslandWorld.Nether;
|
||||
if (netherWorld != null && netherWorld.getName().equals(world.getName())) return IslandWorld.Nether;
|
||||
|
||||
if (endWorld != null && endWorld.getName().equals(world.getName()))
|
||||
return IslandWorld.End;
|
||||
if (endWorld != null && endWorld.getName().equals(world.getName())) return IslandWorld.End;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isIslandWorld(World world) {
|
||||
if (world == null)
|
||||
return false;
|
||||
if (world == null) return false;
|
||||
|
||||
if (normalWorld != null && normalWorld.getName().equals(world.getName()))
|
||||
return true;
|
||||
if (normalWorld != null && normalWorld.getName().equals(world.getName())) return true;
|
||||
|
||||
if (netherWorld != null && netherWorld.getName().equals(world.getName()))
|
||||
return true;
|
||||
if (netherWorld != null && netherWorld.getName().equals(world.getName())) return true;
|
||||
|
||||
return endWorld != null && endWorld.getName().equals(world.getName());
|
||||
}
|
||||
|
@ -1,40 +1,41 @@
|
||||
package com.songoda.skyblock.world.generator;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.config.FileManager.Config;
|
||||
import com.songoda.skyblock.island.IslandWorld;
|
||||
import com.songoda.skyblock.utils.version.Materials;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.Configuration;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
import com.songoda.skyblock.island.IslandWorld;
|
||||
import com.songoda.skyblock.utils.version.Materials;
|
||||
|
||||
public class VoidGenerator extends ChunkGenerator {
|
||||
|
||||
@Override
|
||||
public ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, BiomeGrid biome) {
|
||||
ChunkData chunkData = createChunkData(world);
|
||||
final ChunkData chunkData = createChunkData(world);
|
||||
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
final SkyBlock skyblock = SkyBlock.getInstance();
|
||||
final Configuration configLoad = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration();
|
||||
final ConfigurationSection worldSection = configLoad.getConfigurationSection("Island.World");
|
||||
|
||||
for (IslandWorld worldList : IslandWorld.values()) {
|
||||
if (world.getEnvironment() == worldList.getUncheckedEnvironment()) {
|
||||
if (configLoad.getBoolean("Island.World." + worldList.name() + ".Liquid.Enable")) {
|
||||
if (configLoad.getBoolean("Island.World." + worldList.name() + ".Liquid.Lava")) {
|
||||
setBlock(chunkData, Materials.LEGACY_STATIONARY_LAVA.parseMaterial(),
|
||||
configLoad.getInt("Island.World." + worldList.name() + ".Liquid.Height"));
|
||||
|
||||
ConfigurationSection section = worldSection.getConfigurationSection(worldList.name());
|
||||
|
||||
if (section.getBoolean("Liquid.Enable")) {
|
||||
if (section.getBoolean("Liquid.Lava")) {
|
||||
setBlock(chunkData, Materials.LEGACY_STATIONARY_LAVA.parseMaterial(), section.getInt("Liquid.Height"));
|
||||
} else {
|
||||
setBlock(chunkData, Materials.LEGACY_STATIONARY_WATER.parseMaterial(),
|
||||
configLoad.getInt("Island.World." + worldList.name() + ".Liquid.Height"));
|
||||
setBlock(chunkData, Materials.LEGACY_STATIONARY_WATER.parseMaterial(), section.getInt("Liquid.Height"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -806,6 +806,7 @@ Command:
|
||||
Message: '&bSkyBlock &8| &cError&8: &eYou must close your Island before deleting it.'
|
||||
Sender:
|
||||
Message: '&bSkyBlock &8| &aInfo&8: &eYou are no longer an Island Owner.'
|
||||
MaxDeletionMessage: '&bSkyBlock &8| &cError&8: &eYou have reach the maximum island deletions. Sorry.'
|
||||
Broadcast:
|
||||
Message: '&bSkyBlock &8| &aInfo&8: &eThe Island Owner has disbanded the Island.'
|
||||
Money:
|
||||
@ -3109,11 +3110,6 @@ Placeholder:
|
||||
Message: '&f&oUnclaimed'
|
||||
Non-empty:
|
||||
Message: '&f[%position] %player [%level]'
|
||||
fabledskyblock_island_points:
|
||||
Non-empty:
|
||||
Message: '&f%placeholder'
|
||||
Empty:
|
||||
Message: '&c0'
|
||||
fabledskyblock_island_visitors:
|
||||
Non-empty:
|
||||
Message: '&f%placeholder'
|
||||
@ -3194,11 +3190,6 @@ Placeholder:
|
||||
Message: '&f&oNone'
|
||||
Non-empty:
|
||||
Message: '&f%placeholder'
|
||||
fabledskyblock_island_level:
|
||||
Empty:
|
||||
Message: '&c0'
|
||||
Non-empty:
|
||||
Message: '&f%placeholder'
|
||||
fabledskyblock_island_level_formatted:
|
||||
Empty:
|
||||
Message: '&c0'
|
||||
@ -3376,6 +3367,7 @@ Island:
|
||||
Message: '&bSkyBlock &8| &cError&8: &eYou must wait &c&o%time &ebefore creating an Island.'
|
||||
Error:
|
||||
Message: '&bSkyBlock &8| &cError&8: &eThe main spawn point must be set before you are able to create an Island by performing the command ''&f&o/island admin setspawn&e''.'
|
||||
MaxCreationMessage: '&bSkyBlock &8| &cError&8: &eYou have reach the maximum island creations. Sorry.'
|
||||
Upgrade:
|
||||
Owner:
|
||||
Message: '&bSkyBlock &8| &cError&8: &eYou are not an Island Owner.'
|
||||
|
Loading…
Reference in New Issue
Block a user