mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-01-10 09:47:42 +01:00
Build 30
# Added the permission note 'skyblock.information' to open the 'Island Information' menu for other Islands. # Added the command '/island information [<player>]' to open the 'Island Information' menu. # Fixed Island Settings menu not allowing players to change settings when the menus share the same titles. # Fixed IAE when opening the a menu that contains a skull when the texture isn't set. # Fixed UE when teleporting to a players Island with the command '/island teleport'. # Fixed ICE when having '#' characters in the 'language.yml' file. # Fixed chunk error on Island creation when biome is set. # Recorded all the menus.
This commit is contained in:
parent
123070e1c9
commit
94170b0ca9
145
language.yml
145
language.yml
@ -403,6 +403,17 @@ Command:
|
||||
Message: "&bSkyBlock &8| &cError&8: &eYou do not have the right to access this setting."
|
||||
Change:
|
||||
Message: "&bSkyBlock &8| &cError&8: &eYou do not have the right to change this setting."
|
||||
Information:
|
||||
Info:
|
||||
Message: "&f&oOpens the Island Information menu."
|
||||
Invalid:
|
||||
Message: "&bSkyBlock &8| &cError&8: &eInvalid: /island information [<player>]"
|
||||
Permission:
|
||||
Message: "&bSkyBlock &8| &cError&8: &eYou don't have permission to teleport to other players Islands."
|
||||
Owner:
|
||||
Message: "&bSkyBlock &8| &cError&8: &eYou are not an Island owner."
|
||||
Island:
|
||||
Message: "&bSkyBlock &8| &cError&8: &eThat player is not a Member or owns an Island."
|
||||
Members:
|
||||
Info:
|
||||
Message: "&f&oOpen the Island Members menu."
|
||||
@ -697,6 +708,13 @@ Island:
|
||||
Minute: "minute(s)"
|
||||
Second: "second(s)"
|
||||
Message: "&bSkyBlock &8| &cError&8: &eYou must wait &c&o%time &ebefore changing your Island biome."
|
||||
Information:
|
||||
Island:
|
||||
Message: "&bSkyBlock &8| &cError&8: &eThe player you selected no longer has an Island."
|
||||
Visitors:
|
||||
Message: "&bSkyBlock &8| &cError&8: &eThere are no visitors at the selected Island."
|
||||
Closed:
|
||||
Message: "&bSkyBlock &8| &cError&8: &eThe selected Island is closed to visitors."
|
||||
Settings:
|
||||
Permission:
|
||||
Message: "&bSkyBlock &8| &cError&8: &eYou do not have the right to do that on this Island."
|
||||
@ -1571,6 +1589,133 @@ Menu:
|
||||
Displayname: "&aPortal Use"
|
||||
Hopper:
|
||||
Displayname: "&aHopper Use"
|
||||
Information:
|
||||
Categories:
|
||||
Title: "&8Island Information"
|
||||
Item:
|
||||
Exit:
|
||||
Displayname: "&cExit Island Information"
|
||||
Members:
|
||||
Displayname: "&aMembers"
|
||||
Lore:
|
||||
- "&7View the members of the"
|
||||
- "&7Island and find their"
|
||||
- "&7role."
|
||||
- ""
|
||||
- "&eClick to view members!"
|
||||
Visitors:
|
||||
Displayname: "&aVisitors"
|
||||
Lore:
|
||||
- "&7View the players that are"
|
||||
- "&7currently visiting the"
|
||||
- "&7Island."
|
||||
- ""
|
||||
- "&eClick to view visitors!"
|
||||
Information:
|
||||
Displayname: "&aInformation"
|
||||
Vote:
|
||||
Word:
|
||||
Empty: "&f&oEmpty"
|
||||
Enabled:
|
||||
Signature:
|
||||
Word:
|
||||
Add: "add"
|
||||
Remove: "remove"
|
||||
Enabled:
|
||||
Lore:
|
||||
- "&7Owner&8: &f%owner"
|
||||
- ""
|
||||
- "&7Signature&8:"
|
||||
- "%signature"
|
||||
- ""
|
||||
- "&7Players At Island&8: &f%players&7/&f%player_capacity"
|
||||
- ""
|
||||
- "&7Level&8: &b%level"
|
||||
- "&7Members&8: &e%members"
|
||||
- "&7Visits&8: &e%visits"
|
||||
- "&7Votes&8: &6%votes"
|
||||
Disabled:
|
||||
Lore:
|
||||
- "&7Owner&8: &f%owner"
|
||||
- ""
|
||||
- "&7Players At Island&8: &f%players&7/&f%player_capacity"
|
||||
- ""
|
||||
- "&7Level&8: &b%level"
|
||||
- "&7Members&8: &e%members"
|
||||
- "&7Visits&8: &e%visits"
|
||||
- "&7Votes&8: &6%votes"
|
||||
Disabled:
|
||||
Signature:
|
||||
Enabled:
|
||||
Lore:
|
||||
- "&7Owner&8: &f%owner"
|
||||
- ""
|
||||
- "&7Signature&8:"
|
||||
- "%signature"
|
||||
- ""
|
||||
- "&7Players At Island&8: &f%players&7/&f%player_capacity"
|
||||
- ""
|
||||
- "&7Level&8: &b%level"
|
||||
- "&7Members&8: &e%members"
|
||||
- "&7Visits&8: &e%visits"
|
||||
Disabled:
|
||||
Lore:
|
||||
- "&7Owner&8: &f%owner"
|
||||
- ""
|
||||
- "&7Players At Island&8: &f%players&7/&f%player_capacity"
|
||||
- ""
|
||||
- "&7Level&8: &b%level"
|
||||
- "&7Members&8: &e%members"
|
||||
- "&7Visits&8: &e%visits"
|
||||
Members:
|
||||
Title: "&8Island Information - Members"
|
||||
Item:
|
||||
Return:
|
||||
Displayname: "&cReturn to Island Information"
|
||||
Previous:
|
||||
Displayname: "&a< Previous Page"
|
||||
Next:
|
||||
Displayname: "&aNext Page >"
|
||||
Barrier:
|
||||
Displayname: "&cIsland Members Below"
|
||||
Statistics:
|
||||
Displayname: "&3&nStatistics"
|
||||
Lore:
|
||||
- "&bIsland Members:"
|
||||
- "&e%island_members/%island_capacity"
|
||||
- ""
|
||||
- "&bMembers:"
|
||||
- "&e%members"
|
||||
- ""
|
||||
- "&bOperators:"
|
||||
- "&e%operators"
|
||||
Member:
|
||||
Word:
|
||||
Member: "&aMember"
|
||||
Operator: "&bOperator"
|
||||
Owner: "&6Owner"
|
||||
Displayname: "&b%player"
|
||||
Lore:
|
||||
- "&7Role&8:"
|
||||
- "%role"
|
||||
Visitors:
|
||||
Title: "&8Island Information - Visitors"
|
||||
Item:
|
||||
Return:
|
||||
Displayname: "&cReturn to Island Information"
|
||||
Previous:
|
||||
Displayname: "&a< Previous Page"
|
||||
Next:
|
||||
Displayname: "&aNext Page >"
|
||||
Barrier:
|
||||
Displayname: "&cIsland Visitors Below"
|
||||
Statistics:
|
||||
Displayname: "&3&nStatistics"
|
||||
Lore:
|
||||
- "&bIsland Visitors:"
|
||||
- "&e%island_visitors"
|
||||
Visitor:
|
||||
Displayname: "&b%player"
|
||||
Members:
|
||||
Title: "&8Island Members"
|
||||
Item:
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: SkyBlock
|
||||
main: me.goodandevil.skyblock.SkyBlock
|
||||
version: 29
|
||||
version: 30
|
||||
api-version: 1.13
|
||||
description: A unique SkyBlock plugin
|
||||
author: GoodAndEvil
|
||||
|
@ -32,19 +32,7 @@ import me.goodandevil.skyblock.listeners.Projectile;
|
||||
import me.goodandevil.skyblock.listeners.Quit;
|
||||
import me.goodandevil.skyblock.listeners.Respawn;
|
||||
import me.goodandevil.skyblock.listeners.Teleport;
|
||||
import me.goodandevil.skyblock.menus.Bans;
|
||||
import me.goodandevil.skyblock.menus.Biome;
|
||||
import me.goodandevil.skyblock.menus.ControlPanel;
|
||||
import me.goodandevil.skyblock.menus.Creator;
|
||||
import me.goodandevil.skyblock.menus.Leaderboard;
|
||||
import me.goodandevil.skyblock.menus.Levelling;
|
||||
import me.goodandevil.skyblock.menus.Members;
|
||||
import me.goodandevil.skyblock.menus.Ownership;
|
||||
import me.goodandevil.skyblock.menus.Rollback;
|
||||
import me.goodandevil.skyblock.menus.Settings;
|
||||
import me.goodandevil.skyblock.menus.Visit;
|
||||
import me.goodandevil.skyblock.menus.Visitors;
|
||||
import me.goodandevil.skyblock.menus.Weather;
|
||||
import me.goodandevil.skyblock.menus.admin.Generator;
|
||||
import me.goodandevil.skyblock.message.MessageManager;
|
||||
import me.goodandevil.skyblock.placeholder.PlaceholderManager;
|
||||
@ -135,19 +123,7 @@ public class SkyBlock extends JavaPlugin {
|
||||
pluginManager.registerEvents(new Respawn(this), this);
|
||||
pluginManager.registerEvents(new Chat(this), this);
|
||||
|
||||
pluginManager.registerEvents(new Biome(), this);
|
||||
pluginManager.registerEvents(new Weather(), this);
|
||||
pluginManager.registerEvents(new Rollback(), this);
|
||||
pluginManager.registerEvents(new Levelling(), this);
|
||||
pluginManager.registerEvents(new Settings(), this);
|
||||
pluginManager.registerEvents(new Members(), this);
|
||||
pluginManager.registerEvents(new Ownership(), this);
|
||||
pluginManager.registerEvents(new Visit(), this);
|
||||
pluginManager.registerEvents(new Visitors(), this);
|
||||
pluginManager.registerEvents(new Bans(), this);
|
||||
pluginManager.registerEvents(new ControlPanel(), this);
|
||||
pluginManager.registerEvents(new Creator(), this);
|
||||
pluginManager.registerEvents(new Leaderboard(), this);
|
||||
|
||||
pluginManager.registerEvents(new me.goodandevil.skyblock.menus.admin.Levelling(), this);
|
||||
pluginManager.registerEvents(new me.goodandevil.skyblock.menus.admin.Creator(), this);
|
||||
|
@ -57,32 +57,30 @@ public class BiomeManager {
|
||||
Location location = island.getLocation(me.goodandevil.skyblock.island.Location.World.Normal, me.goodandevil.skyblock.island.Location.Environment.Island);
|
||||
|
||||
for (Location locationList : LocationUtil.getLocations(new Location(location.getWorld(), location.getBlockX() - island.getRadius(), 0, location.getBlockZ() - island.getRadius()), new Location(location.getWorld(), location.getBlockX() + island.getRadius(), location.getWorld().getMaxHeight(), location.getBlockZ() + island.getRadius()))) {
|
||||
try {
|
||||
Block block = locationList.getBlock();
|
||||
|
||||
if (!block.getChunk().isLoaded()) {
|
||||
block.getChunk().load(true);
|
||||
}
|
||||
|
||||
if (block != null) {
|
||||
block.setBiome(biome);
|
||||
|
||||
boolean containsChunk = false;
|
||||
|
||||
for (Chunk chunkList : chunks) {
|
||||
if (chunkList.getX() == block.getChunk().getX() && chunkList.getZ() == block.getChunk().getZ()) {
|
||||
containsChunk = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!containsChunk) {
|
||||
chunks.add(block.getChunk());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
Block block = locationList.getBlock();
|
||||
boolean containsChunk = false;
|
||||
|
||||
for (Chunk chunkList : chunks) {
|
||||
if (chunkList.getX() == block.getChunk().getX() && chunkList.getZ() == block.getChunk().getZ()) {
|
||||
containsChunk = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!containsChunk) {
|
||||
chunks.add(block.getChunk());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (Chunk chunkList : chunks) {
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
location.getWorld().setBiome(chunkList.getX(), chunkList.getZ(), biome);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (player != null) {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
|
@ -31,6 +31,7 @@ import me.goodandevil.skyblock.command.commands.CurrentCommand;
|
||||
import me.goodandevil.skyblock.command.commands.DeleteCommand;
|
||||
import me.goodandevil.skyblock.command.commands.DemoteCommand;
|
||||
import me.goodandevil.skyblock.command.commands.DenyCommand;
|
||||
import me.goodandevil.skyblock.command.commands.InformationCommand;
|
||||
import me.goodandevil.skyblock.command.commands.InviteCommand;
|
||||
import me.goodandevil.skyblock.command.commands.KickAllCommand;
|
||||
import me.goodandevil.skyblock.command.commands.KickCommand;
|
||||
@ -109,6 +110,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
//subCommands.add(new RollbackCommand(skyblock).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Rollback.Info.Message"))));
|
||||
subCommands.add(new LevelCommand(skyblock).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Level.Info.Message"))));
|
||||
subCommands.add(new SettingsCommand(skyblock).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Settings.Info.Message"))));
|
||||
subCommands.add(new InformationCommand(skyblock).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Information.Info.Message"))));
|
||||
subCommands.add(new MembersCommand(skyblock).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Members.Info.Message"))));
|
||||
subCommands.add(new OwnerCommand(skyblock).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Ownership.Info.Message"))));
|
||||
subCommands.add(new ConfirmCommand(skyblock).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Confirmation.Info.Message"))));
|
||||
|
@ -0,0 +1,121 @@
|
||||
package me.goodandevil.skyblock.command.commands;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.goodandevil.skyblock.SkyBlock;
|
||||
import me.goodandevil.skyblock.command.CommandManager;
|
||||
import me.goodandevil.skyblock.command.SubCommand;
|
||||
import me.goodandevil.skyblock.command.CommandManager.Type;
|
||||
import me.goodandevil.skyblock.config.FileManager.Config;
|
||||
import me.goodandevil.skyblock.island.IslandManager;
|
||||
import me.goodandevil.skyblock.menus.Information;
|
||||
import me.goodandevil.skyblock.message.MessageManager;
|
||||
import me.goodandevil.skyblock.playerdata.PlayerData;
|
||||
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
|
||||
import me.goodandevil.skyblock.sound.SoundManager;
|
||||
import me.goodandevil.skyblock.utils.OfflinePlayer;
|
||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||
|
||||
public class InformationCommand extends SubCommand {
|
||||
|
||||
private final SkyBlock skyblock;
|
||||
private String info;
|
||||
|
||||
public InformationCommand(SkyBlock skyblock) {
|
||||
this.skyblock = skyblock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(Player player, String[] args) {
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
UUID islandOwnerUUID = null;
|
||||
|
||||
if (args.length == 1) {
|
||||
if (player.hasPermission("skyblock.teleport") || player.hasPermission("skyblock.*")) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
|
||||
|
||||
if (targetPlayer == null) {
|
||||
OfflinePlayer targetOfflinePlayer = new OfflinePlayer(args[0]);
|
||||
islandOwnerUUID = targetOfflinePlayer.getOwner();
|
||||
} else {
|
||||
islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner();
|
||||
}
|
||||
|
||||
if (islandOwnerUUID == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Information.Island.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Information.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (args.length != 0) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Information.Invalid.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player);
|
||||
|
||||
if (islandOwnerUUID == null) {
|
||||
if (islandManager.hasIsland(player)) {
|
||||
islandOwnerUUID = playerData.getOwner();
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Information.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
playerData.setViewer(new Information.Viewer(islandOwnerUUID, Information.Viewer.Type.Categories));
|
||||
Information.getInstance().open(player);
|
||||
soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "information";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubCommand setInfo(String info) {
|
||||
this.info = info;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[] { "info" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return CommandManager.Type.Default;
|
||||
}
|
||||
}
|
@ -99,7 +99,7 @@ public class FileChecker {
|
||||
this.configLoad = configLoad;
|
||||
configKeys = new HashMap<>();
|
||||
|
||||
if (configFile != null) {
|
||||
if (configFile != null && configFile.getName().equals("config.yml")) {
|
||||
this.configLoad = YamlConfiguration.loadConfiguration(new InputStreamReader(fileManager.getConfigContent(configFile)));
|
||||
}
|
||||
}
|
||||
|
@ -531,7 +531,12 @@ public class IslandManager {
|
||||
}
|
||||
}
|
||||
|
||||
player.teleport(island.getLocation(Location.World.Normal, Location.Environment.Visitor));
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.teleport(island.getLocation(Location.World.Normal, Location.Environment.Visitor));
|
||||
}
|
||||
});
|
||||
|
||||
List<String> islandWelcomeMessage = island.getMessage(Message.Welcome);
|
||||
|
||||
|
@ -9,11 +9,7 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import me.goodandevil.skyblock.SkyBlock;
|
||||
import me.goodandevil.skyblock.config.FileManager;
|
||||
@ -27,12 +23,14 @@ import me.goodandevil.skyblock.playerdata.PlayerData;
|
||||
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
|
||||
import me.goodandevil.skyblock.sound.SoundManager;
|
||||
import me.goodandevil.skyblock.utils.OfflinePlayer;
|
||||
import me.goodandevil.skyblock.utils.item.InventoryUtil;
|
||||
import me.goodandevil.skyblock.utils.item.SkullUtil;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEvent;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEventHandler;
|
||||
import me.goodandevil.skyblock.utils.version.Materials;
|
||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||
|
||||
public class Bans implements Listener {
|
||||
public class Bans {
|
||||
|
||||
private static Bans instance;
|
||||
|
||||
@ -48,140 +46,154 @@ public class Bans implements Listener {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
|
||||
Island island = skyblock.getIslandManager().getIsland(playerData.getOwner());
|
||||
|
||||
Config languageConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = languageConfig.getFileConfiguration();
|
||||
|
||||
List<UUID> islandBans = island.getBan().getBans();
|
||||
|
||||
InventoryUtil inv = new InventoryUtil(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Bans.Title")), null, 6);
|
||||
inv.addItem(inv.createItem(Materials.OAK_FENCE_GATE.parseItem(), configLoad.getString("Menu.Bans.Item.Exit.Displayname"), null, null, null, null), 0, 8);
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.PAINTING), configLoad.getString("Menu.Bans.Item.Statistics.Displayname"), configLoad.getStringList("Menu.Bans.Item.Statistics.Lore"), inv.createItemLoreVariable(new String[] { "%bans#" + islandBans.size() }), null, null), 4);
|
||||
inv.addItem(inv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(), configLoad.getString("Menu.Bans.Item.Barrier.Displayname"), null, null, null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
|
||||
int playerMenuPage = playerData.getPage(), nextEndIndex = islandBans.size() - playerMenuPage * 36;
|
||||
|
||||
if (playerMenuPage != 1) {
|
||||
inv.addItem(inv.createItem(SkullUtil.create("ToR1w9ZV7zpzCiLBhoaJH3uixs5mAlMhNz42oaRRvrG4HRua5hC6oyyOPfn2HKdSseYA9b1be14fjNRQbSJRvXF3mlvt5/zct4sm+cPVmX8K5kbM2vfwHJgCnfjtPkzT8sqqg6YFdT35mAZGqb9/xY/wDSNSu/S3k2WgmHrJKirszaBZrZfnVnqITUOgM9TmixhcJn2obeqICv6tl7/Wyk/1W62wXlXGm9+WjS+8rRNB+vYxqKR3XmH2lhAiyVGbADsjjGtBVUTWjq+aPw670SjXkoii0YE8sqzUlMMGEkXdXl9fvGtnWKk3APSseuTsjedr7yq+AkXFVDqqkqcUuXwmZl2EjC2WRRbhmYdbtY5nEfqh5+MiBrGdR/JqdEUL4yRutyRTw8mSUAI6X2oSVge7EdM/8f4HwLf33EO4pTocTqAkNbpt6Z54asLe5Y12jSXbvd2dFsgeJbrslK7e4uy/TK8CXf0BP3KLU20QELYrjz9I70gtj9lJ9xwjdx4/xJtxDtrxfC4Afmpu+GNYA/mifpyP3GDeBB5CqN7btIvEWyVvRNH7ppAqZIPqYJ7dSDd2RFuhAId5Yq98GUTBn+eRzeigBvSi1bFkkEgldfghOoK5WhsQtQbXuBBXITMME3NaWCN6zG7DxspS6ew/rZ8E809Xe0ArllquIZ0sP+k=", "eyJ0aW1lc3RhbXAiOjE0OTU3NTE5MTYwNjksInByb2ZpbGVJZCI6ImE2OGYwYjY0OGQxNDQwMDBhOTVmNGI5YmExNGY4ZGY5IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dMZWZ0Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zZWJmOTA3NDk0YTkzNWU5NTViZmNhZGFiODFiZWFmYjkwZmI5YmU0OWM3MDI2YmE5N2Q3OThkNWYxYTIzIn19fQ=="), configLoad.getString("Menu.Bans.Item.Previous.Displayname"), null, null, null, null), 1);
|
||||
}
|
||||
|
||||
if (!(nextEndIndex == 0 || nextEndIndex < 0)) {
|
||||
inv.addItem(inv.createItem(SkullUtil.create("wZPrsmxckJn4/ybw/iXoMWgAe+1titw3hjhmf7bfg9vtOl0f/J6YLNMOI0OTvqeRKzSQVCxqNOij6k2iM32ZRInCQyblDIFmFadQxryEJDJJPVs7rXR6LRXlN8ON2VDGtboRTL7LwMGpzsrdPNt0oYDJLpR0huEeZKc1+g4W13Y4YM5FUgEs8HvMcg4aaGokSbvrYRRcEh3LR1lVmgxtbiUIr2gZkR3jnwdmZaIw/Ujw28+Et2pDMVCf96E5vC0aNY0KHTdMYheT6hwgw0VAZS2VnJg+Gz4JCl4eQmN2fs4dUBELIW2Rdnp4U1Eb+ZL8DvTV7ofBeZupknqPOyoKIjpInDml9BB2/EkD3zxFtW6AWocRphn03Z203navBkR6ztCMz0BgbmQU/m8VL/s8o4cxOn+2ppjrlj0p8AQxEsBdHozrBi8kNOGf1j97SDHxnvVAF3X8XDso+MthRx5pbEqpxmLyKKgFh25pJE7UaMSnzH2lc7aAZiax67MFw55pDtgfpl+Nlum4r7CK2w5Xob2QTCovVhu78/6SV7qM2Lhlwx/Sjqcl8rn5UIoyM49QE5Iyf1tk+xHXkIvY0m7q358oXsfca4eKmxMe6DFRjUDo1VuWxdg9iVjn22flqz1LD1FhGlPoqv0k4jX5Q733LwtPPI6VOTK+QzqrmiuR6e8=", "eyJ0aW1lc3RhbXAiOjE0OTM4NjgxMDA2NzMsInByb2ZpbGVJZCI6IjUwYzg1MTBiNWVhMDRkNjBiZTlhN2Q1NDJkNmNkMTU2IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dSaWdodCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ=="), configLoad.getString("Menu.Bans.Item.Next.Displayname"), null, null, null, null), 7);
|
||||
}
|
||||
|
||||
if (islandBans.size() == 0) {
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.BARRIER), configLoad.getString("Menu.Bans.Item.Nothing.Displayname"), null, null, null, null), 31);
|
||||
} else {
|
||||
int index = playerMenuPage * 36 - 36, endIndex = index >= islandBans.size() ? islandBans.size() - 1 : index + 36, inventorySlot = 17;
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
Island island = skyblock.getIslandManager().getIsland(playerData.getOwner());
|
||||
|
||||
Config languageConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = languageConfig.getFileConfiguration();
|
||||
|
||||
for (; index < endIndex; index++) {
|
||||
if (islandBans.size() > index) {
|
||||
inventorySlot++;
|
||||
|
||||
UUID targetPlayerUUID = islandBans.get(index);
|
||||
String targetPlayerName;
|
||||
String[] targetPlayerTexture;
|
||||
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(targetPlayerUUID);
|
||||
|
||||
if (targetPlayer == null) {
|
||||
OfflinePlayer offlinePlayer = new OfflinePlayer(targetPlayerUUID);
|
||||
targetPlayerName = offlinePlayer.getName();
|
||||
targetPlayerTexture = offlinePlayer.getTexture();
|
||||
} else {
|
||||
targetPlayerName = targetPlayer.getName();
|
||||
targetPlayerTexture = playerDataManager.getPlayerData(targetPlayer).getTexture();
|
||||
}
|
||||
|
||||
inv.addItem(inv.createItem(SkullUtil.create(targetPlayerTexture[0], targetPlayerTexture[1]), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Bans.Item.Ban.Displayname").replace("%player", targetPlayerName)), configLoad.getStringList("Menu.Bans.Item.Ban.Lore"), null, null, null), inventorySlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
player.openInventory(inv.getInventory());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
ItemStack is = event.getCurrentItem();
|
||||
|
||||
if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR) {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Bans.Title")))) {
|
||||
event.setCancelled(true);
|
||||
|
||||
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player);
|
||||
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
Island island = null;
|
||||
|
||||
if (islandManager.hasIsland(player)) {
|
||||
island = islandManager.getIsland(playerData.getOwner());
|
||||
|
||||
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning")) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bans.Disabled.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
nInventoryUtil nInv = new nInventoryUtil(player, new ClickEventHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
Island island = null;
|
||||
|
||||
return;
|
||||
if (islandManager.hasIsland(player)) {
|
||||
island = islandManager.getIsland(playerData.getOwner());
|
||||
|
||||
if (!fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning")) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bans.Disabled.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bans.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack is = event.getItem();
|
||||
|
||||
if ((is.getType() == Materials.BLACK_STAINED_GLASS_PANE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Bans.Item.Barrier.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.GLASS.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == Materials.OAK_FENCE_GATE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Bans.Item.Exit.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
} else if ((is.getType() == Material.PAINTING) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Bans.Item.Statistics.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == Material.BARRIER) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Bans.Item.Nothing.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
|
||||
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Bans.Item.Previous.Displayname")))) {
|
||||
playerData.setPage(playerData.getPage() - 1);
|
||||
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}, 1L);
|
||||
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Bans.Item.Next.Displayname")))) {
|
||||
playerData.setPage(playerData.getPage() + 1);
|
||||
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}, 1L);
|
||||
} else {
|
||||
if ((island.isRole(Role.Operator, player.getUniqueId()) && island.getSetting(Settings.Role.Operator, "Unban").getStatus()) || island.isRole(Role.Owner, player.getUniqueId())) {
|
||||
String playerName = ChatColor.stripColor(is.getItemMeta().getDisplayName());
|
||||
Bukkit.getServer().dispatchCommand(player, "island unban " + playerName);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}, 3L);
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bans.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bans.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ((event.getCurrentItem().getType() == Materials.BLACK_STAINED_GLASS_PANE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Bans.Item.Barrier.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.GLASS.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == Materials.OAK_FENCE_GATE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Bans.Item.Exit.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
} else if ((event.getCurrentItem().getType() == Material.PAINTING) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Bans.Item.Statistics.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == Material.BARRIER) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Bans.Item.Nothing.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
|
||||
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Bans.Item.Previous.Displayname")))) {
|
||||
playerData.setPage(playerData.getPage() - 1);
|
||||
open(player);
|
||||
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Bans.Item.Next.Displayname")))) {
|
||||
playerData.setPage(playerData.getPage() + 1);
|
||||
open(player);
|
||||
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
if ((island.isRole(Role.Operator, player.getUniqueId()) && island.getSetting(Settings.Role.Operator, "Unban").getStatus()) || island.isRole(Role.Owner, player.getUniqueId())) {
|
||||
String playerName = ChatColor.stripColor(is.getItemMeta().getDisplayName());
|
||||
Bukkit.getServer().dispatchCommand(player, "island unban " + playerName);
|
||||
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}.runTaskLater(skyblock, 3L);
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bans.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
List<UUID> islandBans = island.getBan().getBans();
|
||||
|
||||
nInv.addItem(nInv.createItem(Materials.OAK_FENCE_GATE.parseItem(), configLoad.getString("Menu.Bans.Item.Exit.Displayname"), null, null, null, null), 0, 8);
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING), configLoad.getString("Menu.Bans.Item.Statistics.Displayname"), configLoad.getStringList("Menu.Bans.Item.Statistics.Lore"), nInv.createItemLoreVariable(new String[] { "%bans#" + islandBans.size() }), null, null), 4);
|
||||
nInv.addItem(nInv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(), configLoad.getString("Menu.Bans.Item.Barrier.Displayname"), null, null, null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
|
||||
int playerMenuPage = playerData.getPage(), nextEndIndex = islandBans.size() - playerMenuPage * 36;
|
||||
|
||||
if (playerMenuPage != 1) {
|
||||
nInv.addItem(nInv.createItem(SkullUtil.create("ToR1w9ZV7zpzCiLBhoaJH3uixs5mAlMhNz42oaRRvrG4HRua5hC6oyyOPfn2HKdSseYA9b1be14fjNRQbSJRvXF3mlvt5/zct4sm+cPVmX8K5kbM2vfwHJgCnfjtPkzT8sqqg6YFdT35mAZGqb9/xY/wDSNSu/S3k2WgmHrJKirszaBZrZfnVnqITUOgM9TmixhcJn2obeqICv6tl7/Wyk/1W62wXlXGm9+WjS+8rRNB+vYxqKR3XmH2lhAiyVGbADsjjGtBVUTWjq+aPw670SjXkoii0YE8sqzUlMMGEkXdXl9fvGtnWKk3APSseuTsjedr7yq+AkXFVDqqkqcUuXwmZl2EjC2WRRbhmYdbtY5nEfqh5+MiBrGdR/JqdEUL4yRutyRTw8mSUAI6X2oSVge7EdM/8f4HwLf33EO4pTocTqAkNbpt6Z54asLe5Y12jSXbvd2dFsgeJbrslK7e4uy/TK8CXf0BP3KLU20QELYrjz9I70gtj9lJ9xwjdx4/xJtxDtrxfC4Afmpu+GNYA/mifpyP3GDeBB5CqN7btIvEWyVvRNH7ppAqZIPqYJ7dSDd2RFuhAId5Yq98GUTBn+eRzeigBvSi1bFkkEgldfghOoK5WhsQtQbXuBBXITMME3NaWCN6zG7DxspS6ew/rZ8E809Xe0ArllquIZ0sP+k=", "eyJ0aW1lc3RhbXAiOjE0OTU3NTE5MTYwNjksInByb2ZpbGVJZCI6ImE2OGYwYjY0OGQxNDQwMDBhOTVmNGI5YmExNGY4ZGY5IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dMZWZ0Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zZWJmOTA3NDk0YTkzNWU5NTViZmNhZGFiODFiZWFmYjkwZmI5YmU0OWM3MDI2YmE5N2Q3OThkNWYxYTIzIn19fQ=="), configLoad.getString("Menu.Bans.Item.Previous.Displayname"), null, null, null, null), 1);
|
||||
}
|
||||
|
||||
if (!(nextEndIndex == 0 || nextEndIndex < 0)) {
|
||||
nInv.addItem(nInv.createItem(SkullUtil.create("wZPrsmxckJn4/ybw/iXoMWgAe+1titw3hjhmf7bfg9vtOl0f/J6YLNMOI0OTvqeRKzSQVCxqNOij6k2iM32ZRInCQyblDIFmFadQxryEJDJJPVs7rXR6LRXlN8ON2VDGtboRTL7LwMGpzsrdPNt0oYDJLpR0huEeZKc1+g4W13Y4YM5FUgEs8HvMcg4aaGokSbvrYRRcEh3LR1lVmgxtbiUIr2gZkR3jnwdmZaIw/Ujw28+Et2pDMVCf96E5vC0aNY0KHTdMYheT6hwgw0VAZS2VnJg+Gz4JCl4eQmN2fs4dUBELIW2Rdnp4U1Eb+ZL8DvTV7ofBeZupknqPOyoKIjpInDml9BB2/EkD3zxFtW6AWocRphn03Z203navBkR6ztCMz0BgbmQU/m8VL/s8o4cxOn+2ppjrlj0p8AQxEsBdHozrBi8kNOGf1j97SDHxnvVAF3X8XDso+MthRx5pbEqpxmLyKKgFh25pJE7UaMSnzH2lc7aAZiax67MFw55pDtgfpl+Nlum4r7CK2w5Xob2QTCovVhu78/6SV7qM2Lhlwx/Sjqcl8rn5UIoyM49QE5Iyf1tk+xHXkIvY0m7q358oXsfca4eKmxMe6DFRjUDo1VuWxdg9iVjn22flqz1LD1FhGlPoqv0k4jX5Q733LwtPPI6VOTK+QzqrmiuR6e8=", "eyJ0aW1lc3RhbXAiOjE0OTM4NjgxMDA2NzMsInByb2ZpbGVJZCI6IjUwYzg1MTBiNWVhMDRkNjBiZTlhN2Q1NDJkNmNkMTU2IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dSaWdodCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ=="), configLoad.getString("Menu.Bans.Item.Next.Displayname"), null, null, null, null), 7);
|
||||
}
|
||||
|
||||
if (islandBans.size() == 0) {
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.BARRIER), configLoad.getString("Menu.Bans.Item.Nothing.Displayname"), null, null, null, null), 31);
|
||||
} else {
|
||||
int index = playerMenuPage * 36 - 36, endIndex = index >= islandBans.size() ? islandBans.size() - 1 : index + 36, inventorySlot = 17;
|
||||
|
||||
for (; index < endIndex; index++) {
|
||||
if (islandBans.size() > index) {
|
||||
inventorySlot++;
|
||||
|
||||
UUID targetPlayerUUID = islandBans.get(index);
|
||||
String targetPlayerName;
|
||||
String[] targetPlayerTexture;
|
||||
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(targetPlayerUUID);
|
||||
|
||||
if (targetPlayer == null) {
|
||||
OfflinePlayer offlinePlayer = new OfflinePlayer(targetPlayerUUID);
|
||||
targetPlayerName = offlinePlayer.getName();
|
||||
targetPlayerTexture = offlinePlayer.getTexture();
|
||||
} else {
|
||||
targetPlayerName = targetPlayer.getName();
|
||||
targetPlayerTexture = playerDataManager.getPlayerData(targetPlayer).getTexture();
|
||||
}
|
||||
|
||||
nInv.addItem(nInv.createItem(SkullUtil.create(targetPlayerTexture[0], targetPlayerTexture[1]), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Bans.Item.Ban.Displayname").replace("%player", targetPlayerName)), configLoad.getStringList("Menu.Bans.Item.Ban.Lore"), null, null, null), inventorySlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Bans.Title")));
|
||||
nInv.setRows(6);
|
||||
nInv.open();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,15 +2,12 @@ package me.goodandevil.skyblock.menus;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@ -23,16 +20,19 @@ import me.goodandevil.skyblock.island.IslandManager;
|
||||
import me.goodandevil.skyblock.island.Role;
|
||||
import me.goodandevil.skyblock.island.Settings;
|
||||
import me.goodandevil.skyblock.message.MessageManager;
|
||||
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
|
||||
import me.goodandevil.skyblock.sound.SoundManager;
|
||||
import me.goodandevil.skyblock.utils.NumberUtil;
|
||||
import me.goodandevil.skyblock.utils.item.InventoryUtil;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEvent;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEventHandler;
|
||||
import me.goodandevil.skyblock.utils.version.Biomes;
|
||||
import me.goodandevil.skyblock.utils.version.Materials;
|
||||
import me.goodandevil.skyblock.utils.version.NMSUtil;
|
||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||
import me.goodandevil.skyblock.utils.world.LocationUtil;
|
||||
|
||||
public class Biome implements Listener {
|
||||
public class Biome {
|
||||
|
||||
private static Biome instance;
|
||||
|
||||
@ -47,184 +47,182 @@ public class Biome implements Listener {
|
||||
public void open(Player player) {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
Island island = skyblock.getIslandManager().getIsland(skyblock.getPlayerDataManager().getPlayerData(player).getOwner());
|
||||
String islandBiomeName = island.getBiomeName();
|
||||
int NMSVersion = NMSUtil.getVersionNumber();
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
BiomeManager biomeManager = skyblock.getBiomeManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
InventoryUtil inv = new InventoryUtil(configLoad.getString("Menu.Biome.Title"), null, 1);
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.NAME_TAG, 1), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Info.Displayname")), configLoad.getStringList("Menu.Biome.Item.Info.Lore"), inv.createItemLoreVariable(new String[] { "%biome_type#" + islandBiomeName }), null, null), 0);
|
||||
inv.addItem(inv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Barrier.Displayname")), null, null, null, null), 1);
|
||||
|
||||
if (islandBiomeName.equals("Plains")) {
|
||||
inv.addItem(inv.createItem(Materials.SUNFLOWER.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Current.Displayname").replace("%biome_type", islandBiomeName)), configLoad.getStringList("Menu.Biome.Item.Biome.Current.Lore"), null, new Enchantment[] { Enchantment.THORNS }, new ItemFlag[] { ItemFlag.HIDE_ENCHANTS }), 2);
|
||||
} else {
|
||||
inv.addItem(inv.createItem(Materials.SUNFLOWER.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname").replace("%biome_type", "Plains")), configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null), 2);
|
||||
}
|
||||
|
||||
if (islandBiomeName.equals("Forest")) {
|
||||
inv.addItem(inv.createItem(Materials.FERN.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Current.Displayname").replace("%biome_type", islandBiomeName)), configLoad.getStringList("Menu.Biome.Item.Biome.Current.Lore"), null, new Enchantment[] { Enchantment.THORNS }, new ItemFlag[] { ItemFlag.HIDE_ENCHANTS }), 3);
|
||||
} else {
|
||||
inv.addItem(inv.createItem(Materials.FERN.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname").replace("%biome_type", "Forest")), configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null), 3);
|
||||
}
|
||||
|
||||
if (islandBiomeName.equals("Swampland") || islandBiomeName.equals("Swamp")) {
|
||||
inv.addItem(inv.createItem(Materials.LILY_PAD.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Current.Displayname").replace("%biome_type", islandBiomeName)), configLoad.getStringList("Menu.Biome.Item.Biome.Current.Lore"), null, new Enchantment[] { Enchantment.THORNS }, new ItemFlag[] { ItemFlag.HIDE_ENCHANTS }), 4);
|
||||
} else {
|
||||
if (NMSVersion < 13) {
|
||||
inv.addItem(inv.createItem(Materials.LILY_PAD.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname").replace("%biome_type", "Swampland")), configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null), 4);
|
||||
} else {
|
||||
inv.addItem(inv.createItem(Materials.LILY_PAD.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname").replace("%biome_type", "Swamp")), configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null), 4);
|
||||
}
|
||||
}
|
||||
|
||||
if (islandBiomeName.equals("Desert")) {
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.DEAD_BUSH, 1), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Current.Displayname").replace("%biome_type", islandBiomeName)), configLoad.getStringList("Menu.Biome.Item.Biome.Current.Lore"), null, new Enchantment[] { Enchantment.THORNS }, new ItemFlag[] { ItemFlag.HIDE_ENCHANTS }), 5);
|
||||
} else {
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.DEAD_BUSH, 1), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname").replace("%biome_type", "Desert")), configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null), 5);
|
||||
}
|
||||
|
||||
if (islandBiomeName.equals("Cold Beach") || islandBiomeName.equals("Snowy Beach")) {
|
||||
inv.addItem(inv.createItem(Materials.SNOWBALL.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Current.Displayname").replace("%biome_type", islandBiomeName)), configLoad.getStringList("Menu.Biome.Item.Biome.Current.Lore"), null, new Enchantment[] { Enchantment.THORNS }, new ItemFlag[] { ItemFlag.HIDE_ENCHANTS }), 6);
|
||||
} else {
|
||||
if (NMSVersion < 13) {
|
||||
inv.addItem(inv.createItem(Materials.SNOWBALL.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname").replace("%biome_type", "Cold Beach")), configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null), 6);
|
||||
} else {
|
||||
inv.addItem(inv.createItem(Materials.SNOWBALL.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname").replace("%biome_type", "Snowy Beach")), configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null), 6);
|
||||
}
|
||||
}
|
||||
|
||||
if (islandBiomeName.equals("Jungle")) {
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.VINE, 1), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Current.Displayname").replace("%biome_type", islandBiomeName)), configLoad.getStringList("Menu.Biome.Item.Biome.Current.Lore"), null, new Enchantment[] { Enchantment.THORNS }, new ItemFlag[] { ItemFlag.HIDE_ENCHANTS }), 7);
|
||||
} else {
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.VINE, 1), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname").replace("%biome_type", "Jungle")), configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null), 7);
|
||||
}
|
||||
|
||||
if (islandBiomeName.equals("Roofed Forest") || islandBiomeName.equals("Dark Forest")) {
|
||||
inv.addItem(inv.createItem(Materials.DARK_OAK_SAPLING.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Current.Displayname").replace("%biome_type", islandBiomeName)), configLoad.getStringList("Menu.Biome.Item.Biome.Current.Lore"), null, new Enchantment[] { Enchantment.THORNS }, new ItemFlag[] { ItemFlag.HIDE_ENCHANTS }), 8);
|
||||
} else {
|
||||
if (NMSVersion < 13) {
|
||||
inv.addItem(inv.createItem(Materials.DARK_OAK_SAPLING.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname").replace("%biome_type", "Roofed Forest")), configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null), 8);
|
||||
} else {
|
||||
inv.addItem(inv.createItem(Materials.DARK_OAK_SAPLING.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname").replace("%biome_type", "Dark Forest")), configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null), 8);
|
||||
}
|
||||
}
|
||||
|
||||
player.openInventory(inv.getInventory());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
ItemStack is = event.getCurrentItem();
|
||||
|
||||
if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR) {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Title")))) {
|
||||
event.setCancelled(true);
|
||||
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
BiomeManager biomeManager = skyblock.getBiomeManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
Island island = null;
|
||||
|
||||
if (islandManager.hasIsland(player)) {
|
||||
island = islandManager.getIsland(skyblock.getPlayerDataManager().getPlayerData(player).getOwner());
|
||||
nInventoryUtil nInv = new nInventoryUtil(player, new ClickEventHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Island island = null;
|
||||
|
||||
if (!((island.isRole(Role.Operator, player.getUniqueId()) && island.getSetting(Settings.Role.Operator, "Biome").getStatus()) || island.isRole(Role.Owner, player.getUniqueId()))) {
|
||||
messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Biome.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
if (playerDataManager.hasPlayerData(player) && islandManager.hasIsland(player)) {
|
||||
island = islandManager.getIsland(playerDataManager.getPlayerData(player).getOwner());
|
||||
|
||||
if (!((island.isRole(Role.Operator, player.getUniqueId()) && island.getSetting(Settings.Role.Operator, "Biome").getStatus()) || island.isRole(Role.Owner, player.getUniqueId()))) {
|
||||
messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Biome.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Biome.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Biome.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ((event.getCurrentItem().getType() == Material.NAME_TAG) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Info.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == Materials.BLACK_STAINED_GLASS_PANE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Barrier.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.GLASS.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
if (is.getItemMeta().hasEnchant(Enchantment.THORNS)) {
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
if (biomeManager.hasPlayer(player)) {
|
||||
me.goodandevil.skyblock.biome.Biome biome = biomeManager.getPlayer(player);
|
||||
|
||||
if (biome.getTime() < 60) {
|
||||
messageManager.sendMessage(player, config.getFileConfiguration().getString("Island.Biome.Cooldown.Message").replace("%time", biome.getTime() + " " + config.getFileConfiguration().getString("Island.Biome.Cooldown.Word.Second")));
|
||||
} else {
|
||||
long[] durationTime = NumberUtil.getDuration(biome.getTime());
|
||||
messageManager.sendMessage(player, config.getFileConfiguration().getString("Island.Biome.Cooldown.Message").replace("%time", durationTime[2] + " " + config.getFileConfiguration().getString("Island.Biome.Cooldown.Word.Minute") + " " + durationTime[3] + " " + config.getFileConfiguration().getString("Island.Biome.Cooldown.Word.Second")));
|
||||
ItemStack is = event.getItem();
|
||||
|
||||
if ((is.getType() == Material.NAME_TAG) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Info.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == Materials.BLACK_STAINED_GLASS_PANE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Barrier.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.GLASS.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else {
|
||||
if (is.getItemMeta().hasEnchant(Enchantment.THORNS)) {
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else {
|
||||
if (biomeManager.hasPlayer(player)) {
|
||||
me.goodandevil.skyblock.biome.Biome biome = biomeManager.getPlayer(player);
|
||||
|
||||
if (biome.getTime() < 60) {
|
||||
messageManager.sendMessage(player, config.getFileConfiguration().getString("Island.Biome.Cooldown.Message").replace("%time", biome.getTime() + " " + config.getFileConfiguration().getString("Island.Biome.Cooldown.Word.Second")));
|
||||
} else {
|
||||
long[] durationTime = NumberUtil.getDuration(biome.getTime());
|
||||
messageManager.sendMessage(player, config.getFileConfiguration().getString("Island.Biome.Cooldown.Message").replace("%time", durationTime[2] + " " + config.getFileConfiguration().getString("Island.Biome.Cooldown.Word.Minute") + " " + durationTime[3] + " " + config.getFileConfiguration().getString("Island.Biome.Cooldown.Word.Second")));
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
org.bukkit.block.Biome selectedBiomeType = null;
|
||||
|
||||
if (is.getType() == Materials.SUNFLOWER.parseMaterial()) {
|
||||
selectedBiomeType = org.bukkit.block.Biome.PLAINS;
|
||||
} else if (is.getType() == Materials.FERN.parseMaterial()) {
|
||||
selectedBiomeType = org.bukkit.block.Biome.FOREST;
|
||||
} else if (is.getType() == Materials.LILY_PAD.parseMaterial()) {
|
||||
selectedBiomeType = Biomes.SWAMPLAMD.bukkitBiome();
|
||||
} else if (is.getType() == Material.DEAD_BUSH) {
|
||||
selectedBiomeType = org.bukkit.block.Biome.DESERT;
|
||||
} else if (is.getType() == Materials.SNOWBALL.parseMaterial()) {
|
||||
selectedBiomeType = Biomes.COLD_BEACH.bukkitBiome();
|
||||
} else if (is.getType() == Material.VINE) {
|
||||
selectedBiomeType = org.bukkit.block.Biome.JUNGLE;
|
||||
} else if (is.getType() == Materials.DARK_OAK_SAPLING.parseMaterial()) {
|
||||
selectedBiomeType = Biomes.ROOFED_FOREST.bukkitBiome();
|
||||
}
|
||||
|
||||
biomeManager.createPlayer(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getInt("Island.Biome.Cooldown"));
|
||||
biomeManager.setBiome(player, island, selectedBiomeType);
|
||||
|
||||
island.setBiome(selectedBiomeType);
|
||||
island.save();
|
||||
|
||||
soundManager.playSound(island.getLocation(Location.World.Normal, Location.Environment.Island), Sounds.SPLASH.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
open(player);
|
||||
|
||||
if (!LocationUtil.isLocationAtLocationRadius(player.getLocation(), island.getLocation(Location.World.Normal, Location.Environment.Island), island.getRadius())) {
|
||||
soundManager.playSound(player, Sounds.SPLASH.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
org.bukkit.block.Biome selectedBiomeType = null;
|
||||
|
||||
if (is.getType() == Materials.SUNFLOWER.parseMaterial()) {
|
||||
selectedBiomeType = org.bukkit.block.Biome.PLAINS;
|
||||
} else if (is.getType() == Materials.FERN.parseMaterial()) {
|
||||
selectedBiomeType = org.bukkit.block.Biome.FOREST;
|
||||
} else if (is.getType() == Materials.LILY_PAD.parseMaterial()) {
|
||||
selectedBiomeType = Biomes.SWAMPLAMD.bukkitBiome();
|
||||
} else if (is.getType() == Material.DEAD_BUSH) {
|
||||
selectedBiomeType = org.bukkit.block.Biome.DESERT;
|
||||
} else if (is.getType() == Materials.SNOWBALL.parseMaterial()) {
|
||||
selectedBiomeType = Biomes.COLD_BEACH.bukkitBiome();
|
||||
} else if (is.getType() == Material.VINE) {
|
||||
selectedBiomeType = org.bukkit.block.Biome.JUNGLE;
|
||||
} else if (is.getType() == Materials.DARK_OAK_SAPLING.parseMaterial()) {
|
||||
selectedBiomeType = Biomes.ROOFED_FOREST.bukkitBiome();
|
||||
}
|
||||
|
||||
biomeManager.createPlayer(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getInt("Island.Biome.Cooldown"));
|
||||
biomeManager.setBiome(player, island, selectedBiomeType);
|
||||
|
||||
island.setBiome(selectedBiomeType);
|
||||
island.save();
|
||||
|
||||
soundManager.playSound(island.getLocation(Location.World.Normal, Location.Environment.Island), Sounds.SPLASH.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
if (!LocationUtil.isLocationAtLocationRadius(player.getLocation(), island.getLocation(Location.World.Normal, Location.Environment.Island), island.getRadius())) {
|
||||
soundManager.playSound(player, Sounds.SPLASH.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}, 1L);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Island island = islandManager.getIsland(playerDataManager.getPlayerData(player).getOwner());
|
||||
String islandBiomeName = island.getBiomeName();
|
||||
|
||||
int NMSVersion = NMSUtil.getVersionNumber();
|
||||
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.NAME_TAG, 1), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Info.Displayname")), configLoad.getStringList("Menu.Biome.Item.Info.Lore"), nInv.createItemLoreVariable(new String[] { "%biome_type#" + islandBiomeName }), null, null), 0);
|
||||
nInv.addItem(nInv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Barrier.Displayname")), null, null, null, null), 1);
|
||||
|
||||
if (islandBiomeName.equals("Plains")) {
|
||||
nInv.addItem(nInv.createItem(Materials.SUNFLOWER.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Current.Displayname").replace("%biome_type", islandBiomeName)), configLoad.getStringList("Menu.Biome.Item.Biome.Current.Lore"), null, new Enchantment[] { Enchantment.THORNS }, new ItemFlag[] { ItemFlag.HIDE_ENCHANTS }), 2);
|
||||
} else {
|
||||
nInv.addItem(nInv.createItem(Materials.SUNFLOWER.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname").replace("%biome_type", "Plains")), configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null), 2);
|
||||
}
|
||||
|
||||
if (islandBiomeName.equals("Forest")) {
|
||||
nInv.addItem(nInv.createItem(Materials.FERN.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Current.Displayname").replace("%biome_type", islandBiomeName)), configLoad.getStringList("Menu.Biome.Item.Biome.Current.Lore"), null, new Enchantment[] { Enchantment.THORNS }, new ItemFlag[] { ItemFlag.HIDE_ENCHANTS }), 3);
|
||||
} else {
|
||||
nInv.addItem(nInv.createItem(Materials.FERN.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname").replace("%biome_type", "Forest")), configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null), 3);
|
||||
}
|
||||
|
||||
if (islandBiomeName.equals("Swampland") || islandBiomeName.equals("Swamp")) {
|
||||
nInv.addItem(nInv.createItem(Materials.LILY_PAD.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Current.Displayname").replace("%biome_type", islandBiomeName)), configLoad.getStringList("Menu.Biome.Item.Biome.Current.Lore"), null, new Enchantment[] { Enchantment.THORNS }, new ItemFlag[] { ItemFlag.HIDE_ENCHANTS }), 4);
|
||||
} else {
|
||||
if (NMSVersion < 13) {
|
||||
nInv.addItem(nInv.createItem(Materials.LILY_PAD.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname").replace("%biome_type", "Swampland")), configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null), 4);
|
||||
} else {
|
||||
nInv.addItem(nInv.createItem(Materials.LILY_PAD.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname").replace("%biome_type", "Swamp")), configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null), 4);
|
||||
}
|
||||
}
|
||||
|
||||
if (islandBiomeName.equals("Desert")) {
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.DEAD_BUSH, 1), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Current.Displayname").replace("%biome_type", islandBiomeName)), configLoad.getStringList("Menu.Biome.Item.Biome.Current.Lore"), null, new Enchantment[] { Enchantment.THORNS }, new ItemFlag[] { ItemFlag.HIDE_ENCHANTS }), 5);
|
||||
} else {
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.DEAD_BUSH, 1), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname").replace("%biome_type", "Desert")), configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null), 5);
|
||||
}
|
||||
|
||||
if (islandBiomeName.equals("Cold Beach") || islandBiomeName.equals("Snowy Beach")) {
|
||||
nInv.addItem(nInv.createItem(Materials.SNOWBALL.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Current.Displayname").replace("%biome_type", islandBiomeName)), configLoad.getStringList("Menu.Biome.Item.Biome.Current.Lore"), null, new Enchantment[] { Enchantment.THORNS }, new ItemFlag[] { ItemFlag.HIDE_ENCHANTS }), 6);
|
||||
} else {
|
||||
if (NMSVersion < 13) {
|
||||
nInv.addItem(nInv.createItem(Materials.SNOWBALL.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname").replace("%biome_type", "Cold Beach")), configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null), 6);
|
||||
} else {
|
||||
nInv.addItem(nInv.createItem(Materials.SNOWBALL.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname").replace("%biome_type", "Snowy Beach")), configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null), 6);
|
||||
}
|
||||
}
|
||||
|
||||
if (islandBiomeName.equals("Jungle")) {
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.VINE, 1), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Current.Displayname").replace("%biome_type", islandBiomeName)), configLoad.getStringList("Menu.Biome.Item.Biome.Current.Lore"), null, new Enchantment[] { Enchantment.THORNS }, new ItemFlag[] { ItemFlag.HIDE_ENCHANTS }), 7);
|
||||
} else {
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.VINE, 1), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname").replace("%biome_type", "Jungle")), configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null), 7);
|
||||
}
|
||||
|
||||
if (islandBiomeName.equals("Roofed Forest") || islandBiomeName.equals("Dark Forest")) {
|
||||
nInv.addItem(nInv.createItem(Materials.DARK_OAK_SAPLING.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Current.Displayname").replace("%biome_type", islandBiomeName)), configLoad.getStringList("Menu.Biome.Item.Biome.Current.Lore"), null, new Enchantment[] { Enchantment.THORNS }, new ItemFlag[] { ItemFlag.HIDE_ENCHANTS }), 8);
|
||||
} else {
|
||||
if (NMSVersion < 13) {
|
||||
nInv.addItem(nInv.createItem(Materials.DARK_OAK_SAPLING.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname").replace("%biome_type", "Roofed Forest")), configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null), 8);
|
||||
} else {
|
||||
nInv.addItem(nInv.createItem(Materials.DARK_OAK_SAPLING.parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Item.Biome.Select.Displayname").replace("%biome_type", "Dark Forest")), configLoad.getStringList("Menu.Biome.Item.Biome.Select.Lore"), null, null, null), 8);
|
||||
}
|
||||
}
|
||||
|
||||
nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Title")));
|
||||
nInv.setRows(1);
|
||||
nInv.open();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClose(InventoryCloseEvent event) {
|
||||
Player player = (Player) event.getPlayer();
|
||||
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
Config languageConfig = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = languageConfig.getFileConfiguration();
|
||||
|
||||
if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Biome.Title")))) {
|
||||
skyblock.getSoundManager().playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,19 +7,18 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.goodandevil.skyblock.SkyBlock;
|
||||
import me.goodandevil.skyblock.config.FileManager.Config;
|
||||
import me.goodandevil.skyblock.utils.item.InventoryUtil;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEvent;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEventHandler;
|
||||
import me.goodandevil.skyblock.utils.version.Materials;
|
||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||
|
||||
public class ControlPanel implements Listener {
|
||||
public class ControlPanel {
|
||||
|
||||
private static ControlPanel instance;
|
||||
|
||||
@ -37,62 +36,88 @@ public class ControlPanel implements Listener {
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
InventoryUtil inv = new InventoryUtil(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.ControlPanel.Title")), null, 1);
|
||||
inv.addItem(inv.createItem(Materials.OAK_DOOR.parseItem(), configLoad.getString("Menu.ControlPanel.Item.Teleport.Displayname"), configLoad.getStringList("Menu.ControlPanel.Item.Teleport.Lore"), null, null, null), 0);
|
||||
inv.addItem(inv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(), configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"), null, null, null, null), 1);
|
||||
inv.addItem(inv.createItem(new ItemStack(Materials.EXPERIENCE_BOTTLE.parseMaterial()), configLoad.getString("Menu.ControlPanel.Item.Level.Displayname"), configLoad.getStringList("Menu.ControlPanel.Item.Level.Lore"), null, null, null), 2);
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.NAME_TAG), configLoad.getString("Menu.ControlPanel.Item.Settings.Displayname"), configLoad.getStringList("Menu.ControlPanel.Item.Settings.Lore"), null, null, null), 3);
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.ITEM_FRAME), configLoad.getString("Menu.ControlPanel.Item.Members.Displayname"), configLoad.getStringList("Menu.ControlPanel.Item.Members.Lore"), null, null, null), 4);
|
||||
inv.addItem(inv.createItem(Materials.OAK_SAPLING.parseItem(), configLoad.getString("Menu.ControlPanel.Item.Biome.Displayname"), configLoad.getStringList("Menu.ControlPanel.Item.Biome.Lore"), null, null, null), 5);
|
||||
inv.addItem(inv.createItem(Materials.CLOCK.parseItem(), configLoad.getString("Menu.ControlPanel.Item.Weather.Displayname"), configLoad.getStringList("Menu.ControlPanel.Item.Weather.Lore"), null, null, null), 6);
|
||||
inv.addItem(inv.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 }), 7);
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.SIGN), configLoad.getString("Menu.ControlPanel.Item.Visitors.Displayname"), configLoad.getStringList("Menu.ControlPanel.Item.Visitors.Lore"), null, null, null), 8);
|
||||
|
||||
player.openInventory(inv.getInventory());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
ItemStack is = event.getCurrentItem();
|
||||
|
||||
if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR) {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.ControlPanel.Title")))) {
|
||||
event.setCancelled(true);
|
||||
nInventoryUtil nInv = new nInventoryUtil(player, new ClickEventHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
ItemStack is = event.getItem();
|
||||
|
||||
if ((event.getCurrentItem().getType() == Materials.OAK_DOOR.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.ControlPanel.Item.Teleport.Displayname"))))) {
|
||||
player.closeInventory();
|
||||
Bukkit.getServer().dispatchCommand(player, "island teleport");
|
||||
} else if ((event.getCurrentItem().getType() == Materials.BLACK_STAINED_GLASS_PANE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"))))) {
|
||||
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, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getServer().dispatchCommand(player, "island teleport");
|
||||
}
|
||||
}, 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);
|
||||
} else if ((event.getCurrentItem().getType() == Materials.EXPERIENCE_BOTTLE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.ControlPanel.Item.Level.Displayname"))))) {
|
||||
player.closeInventory();
|
||||
Bukkit.getServer().dispatchCommand(player, "island level");
|
||||
} else if ((event.getCurrentItem().getType() == Material.NAME_TAG) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.ControlPanel.Item.Settings.Displayname"))))) {
|
||||
player.closeInventory();
|
||||
Bukkit.getServer().dispatchCommand(player, "island settings");
|
||||
} else if ((event.getCurrentItem().getType() == Material.ITEM_FRAME) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.ControlPanel.Item.Members.Displayname"))))) {
|
||||
player.closeInventory();
|
||||
Bukkit.getServer().dispatchCommand(player, "island members");
|
||||
} else if ((event.getCurrentItem().getType() == Materials.OAK_SAPLING.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.ControlPanel.Item.Biome.Displayname"))))) {
|
||||
player.closeInventory();
|
||||
Bukkit.getServer().dispatchCommand(player, "island biome");
|
||||
} else if ((event.getCurrentItem().getType() == Materials.CLOCK.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.ControlPanel.Item.Weather.Displayname"))))) {
|
||||
player.closeInventory();
|
||||
Bukkit.getServer().dispatchCommand(player, "island weather");
|
||||
} else if ((event.getCurrentItem().getType() == Material.IRON_AXE) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.ControlPanel.Item.Bans.Displayname"))))) {
|
||||
player.closeInventory();
|
||||
Bukkit.getServer().dispatchCommand(player, "island bans");
|
||||
} else if ((event.getCurrentItem().getType() == Material.SIGN) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.ControlPanel.Item.Visitors.Displayname"))))) {
|
||||
player.closeInventory();
|
||||
Bukkit.getServer().dispatchCommand(player, "island visitors");
|
||||
|
||||
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, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
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, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
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, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
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, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
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, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
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, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getServer().dispatchCommand(player, "island bans");
|
||||
}
|
||||
}, 1L);
|
||||
} else if ((is.getType() == Material.SIGN) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.ControlPanel.Item.Visitors.Displayname"))))) {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getServer().dispatchCommand(player, "island visitors");
|
||||
}
|
||||
}, 1L);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
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), 0);
|
||||
nInv.addItem(nInv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(), configLoad.getString("Menu.ControlPanel.Item.Barrier.Displayname"), null, null, null, null), 1);
|
||||
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), 2);
|
||||
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), 3);
|
||||
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), 4);
|
||||
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), 5);
|
||||
nInv.addItem(nInv.createItem(Materials.CLOCK.parseItem(), configLoad.getString("Menu.ControlPanel.Item.Weather.Displayname"), configLoad.getStringList("Menu.ControlPanel.Item.Weather.Lore"), null, null, null), 6);
|
||||
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 }), 7);
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.SIGN), configLoad.getString("Menu.ControlPanel.Item.Visitors.Displayname"), configLoad.getStringList("Menu.ControlPanel.Item.Visitors.Lore"), null, null, null), 8);
|
||||
|
||||
nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.ControlPanel.Title")));
|
||||
nInv.setRows(1);
|
||||
nInv.open();
|
||||
}
|
||||
}
|
||||
|
@ -6,12 +6,8 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.goodandevil.skyblock.SkyBlock;
|
||||
@ -24,10 +20,12 @@ import me.goodandevil.skyblock.message.MessageManager;
|
||||
import me.goodandevil.skyblock.sound.SoundManager;
|
||||
import me.goodandevil.skyblock.structure.Structure;
|
||||
import me.goodandevil.skyblock.utils.NumberUtil;
|
||||
import me.goodandevil.skyblock.utils.item.InventoryUtil;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEvent;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEventHandler;
|
||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||
|
||||
public class Creator implements Listener {
|
||||
public class Creator {
|
||||
|
||||
private static Creator instance;
|
||||
|
||||
@ -42,7 +40,13 @@ public class Creator implements Listener {
|
||||
public void open(Player player) {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
CreationManager creationManager = skyblock.getCreationManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
List<Structure> availableStructures = new ArrayList<>();
|
||||
@ -82,7 +86,77 @@ public class Creator implements Listener {
|
||||
inventoryRows = 6;
|
||||
}
|
||||
|
||||
InventoryUtil inv = new InventoryUtil(configLoad.getString("Menu.Creator.Selector.Title"), null, inventoryRows);
|
||||
nInventoryUtil nInv = new nInventoryUtil(player, new ClickEventHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (islandManager.hasIsland(player)) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Create.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ItemStack is = event.getItem();
|
||||
|
||||
for (Structure structureList : skyblock.getStructureManager().getStructures()) {
|
||||
if ((is.getType() == structureList.getMaterials().parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Creator.Selector.Item.Island.Displayname").replace("%displayname", structureList.getDisplayname()))))) {
|
||||
if (structureList.isPermission() && structureList.getPermission() != null && !structureList.getPermission().isEmpty()) {
|
||||
if (!player.hasPermission(structureList.getPermission()) && !player.hasPermission("skyblock.island.*") && !player.hasPermission("skyblock.*")) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Creator.Selector.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}, 1L);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!fileManager.isFileExist(new File(new File(skyblock.getDataFolder().toString() + "/structures"), structureList.getFile()))) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Creator.Selector.File.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
|
||||
return;
|
||||
} else if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Creation.Cooldown.Creation.Enable") && creationManager.hasPlayer(player)) {
|
||||
Creation creation = creationManager.getPlayer(player);
|
||||
|
||||
if (creation.getTime() < 60) {
|
||||
messageManager.sendMessage(player, config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Message").replace("%time", creation.getTime() + " " + config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Word.Second")));
|
||||
} else {
|
||||
long[] durationTime = NumberUtil.getDuration(creation.getTime());
|
||||
messageManager.sendMessage(player, config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Message").replace("%time", durationTime[2] + " " + config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Word.Minute") + " " + durationTime[3] + " " + config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Word.Second")));
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
islandManager.createIsland(player, structureList);
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Creator.Selector.Created.Message"));
|
||||
soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
for (int i = 0; i < availableStructures.size(); i++) {
|
||||
Structure structure = availableStructures.get(i);
|
||||
@ -102,94 +176,11 @@ public class Creator implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
inv.addItem(inv.createItem(structure.getMaterials().parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Creator.Selector.Item.Island.Displayname").replace("%displayname", structure.getDisplayname())), itemLore, null, null, null), i);
|
||||
nInv.addItem(nInv.createItem(structure.getMaterials().parseItem(), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Creator.Selector.Item.Island.Displayname").replace("%displayname", structure.getDisplayname())), itemLore, null, null, null), i);
|
||||
}
|
||||
|
||||
player.openInventory(inv.getInventory());
|
||||
nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Creator.Selector.Title")));
|
||||
nInv.setRows(inventoryRows);
|
||||
nInv.open();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
ItemStack is = event.getCurrentItem();
|
||||
|
||||
if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR) {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Creator.Selector.Title")))) {
|
||||
event.setCancelled(true);
|
||||
|
||||
CreationManager creationManager = skyblock.getCreationManager();
|
||||
|
||||
if (islandManager.hasIsland(player)) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Create.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Structure structureList : skyblock.getStructureManager().getStructures()) {
|
||||
if ((event.getCurrentItem().getType() == structureList.getMaterials().parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Creator.Selector.Item.Island.Displayname").replace("%displayname", structureList.getDisplayname()))))) {
|
||||
if (structureList.isPermission() && structureList.getPermission() != null && !structureList.getPermission().isEmpty()) {
|
||||
if (!player.hasPermission(structureList.getPermission()) && !player.hasPermission("skyblock.island.*") && !player.hasPermission("skyblock.*")) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Creator.Selector.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!fileManager.isFileExist(new File(new File(skyblock.getDataFolder().toString() + "/structures"), structureList.getFile()))) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Creator.Selector.File.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.Creation.Cooldown.Creation.Enable") && creationManager.hasPlayer(player)) {
|
||||
Creation creation = creationManager.getPlayer(player);
|
||||
|
||||
if (creation.getTime() < 60) {
|
||||
messageManager.sendMessage(player, config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Message").replace("%time", creation.getTime() + " " + config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Word.Second")));
|
||||
} else {
|
||||
long[] durationTime = NumberUtil.getDuration(creation.getTime());
|
||||
messageManager.sendMessage(player, config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Message").replace("%time", durationTime[2] + " " + config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Word.Minute") + " " + durationTime[3] + " " + config.getFileConfiguration().getString("Island.Creator.Selector.Cooldown.Word.Second")));
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
islandManager.createIsland(player, structureList);
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Creator.Selector.Created.Message"));
|
||||
soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
player.closeInventory();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,39 @@
|
||||
package me.goodandevil.skyblock.menus;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Information implements Listener {
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.goodandevil.skyblock.SkyBlock;
|
||||
import me.goodandevil.skyblock.config.FileManager;
|
||||
import me.goodandevil.skyblock.config.FileManager.Config;
|
||||
import me.goodandevil.skyblock.island.Island;
|
||||
import me.goodandevil.skyblock.island.IslandManager;
|
||||
import me.goodandevil.skyblock.island.Role;
|
||||
import me.goodandevil.skyblock.message.MessageManager;
|
||||
import me.goodandevil.skyblock.playerdata.PlayerData;
|
||||
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
|
||||
import me.goodandevil.skyblock.sound.SoundManager;
|
||||
import me.goodandevil.skyblock.utils.OfflinePlayer;
|
||||
import me.goodandevil.skyblock.utils.item.SkullUtil;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEvent;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEventHandler;
|
||||
import me.goodandevil.skyblock.utils.version.Materials;
|
||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||
|
||||
public class Information {
|
||||
|
||||
private static Information instance;
|
||||
|
||||
@ -16,19 +46,472 @@ public class Information implements Listener {
|
||||
}
|
||||
|
||||
public void open(Player player) {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
|
||||
if (playerData.getViewer() != null) {
|
||||
Information.Viewer viewer = (Information.Viewer) playerData.getViewer();
|
||||
|
||||
if (!islandManager.hasIsland(viewer.getOwner())) {
|
||||
islandManager.loadIsland(viewer.getOwner());
|
||||
}
|
||||
|
||||
FileConfiguration configLoad = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration();
|
||||
Island island = islandManager.getIsland(viewer.getOwner());
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Information.Island.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (viewer.getType() == Information.Viewer.Type.Visitors) {
|
||||
if (island.isOpen()) {
|
||||
if (island.getVisitors().size() == 0) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Information.Visitors.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
playerData.setViewer(new Information.Viewer(viewer.getOwner(), Information.Viewer.Type.Categories));
|
||||
open(player);
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Information.Closed.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
playerData.setViewer(new Information.Viewer(viewer.getOwner(), Information.Viewer.Type.Categories));
|
||||
open(player);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
me.goodandevil.skyblock.visit.Visit visit = island.getVisit();
|
||||
|
||||
String islandOwnerName = "";
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(viewer.getOwner());
|
||||
|
||||
if (targetPlayer == null) {
|
||||
islandOwnerName = new OfflinePlayer(viewer.getOwner()).getName();
|
||||
} else {
|
||||
islandOwnerName = targetPlayer.getName();
|
||||
}
|
||||
|
||||
if (viewer.getType() == Information.Viewer.Type.Categories) {
|
||||
nInventoryUtil nInv = new nInventoryUtil(player, new ClickEventHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
ItemStack is = event.getItem();
|
||||
|
||||
if ((is.getType() == Materials.OAK_FENCE_GATE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Information.Categories.Item.Exit.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((is.getType() == Materials.ITEM_FRAME.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Information.Categories.Item.Members.Displayname"))))) {
|
||||
playerData.setViewer(new Information.Viewer(((Information.Viewer) playerData.getViewer()).getOwner(), Information.Viewer.Type.Members));
|
||||
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}, 1L);
|
||||
} else if ((is.getType() == Materials.LEGACY_EMPTY_MAP.getPostMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Information.Categories.Item.Information.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == Materials.PAINTING.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Information.Categories.Item.Visitors.Displayname"))))) {
|
||||
playerData.setViewer(new Information.Viewer(((Information.Viewer) playerData.getViewer()).getOwner(), Information.Viewer.Type.Visitors));
|
||||
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}, 1L);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
nInv.addItem(nInv.createItem(Materials.OAK_FENCE_GATE.parseItem(), configLoad.getString("Menu.Information.Categories.Item.Exit.Displayname"), null, null, null, null), 0, 4);
|
||||
nInv.addItem(nInv.createItem(Materials.ITEM_FRAME.parseItem(), configLoad.getString("Menu.Information.Categories.Item.Members.Displayname"), configLoad.getStringList("Menu.Information.Categories.Item.Members.Lore"), null, null, null), 1);
|
||||
nInv.addItem(nInv.createItem(Materials.PAINTING.parseItem(), configLoad.getString("Menu.Information.Categories.Item.Visitors.Displayname"), configLoad.getStringList("Menu.Information.Categories.Item.Visitors.Lore"), null, null, null), 3);
|
||||
|
||||
Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
List<String> itemLore = new ArrayList<>();
|
||||
|
||||
if (mainConfig.getFileConfiguration().getBoolean("Island.Visitor.Vote")) {
|
||||
if (mainConfig.getFileConfiguration().getBoolean("Island.Visitor.Signature.Enable")) {
|
||||
for (String itemLoreList : configLoad.getStringList("Menu.Information.Categories.Item.Information.Vote.Enabled.Signature.Enabled.Lore")) {
|
||||
if (itemLoreList.contains("%signature")) {
|
||||
List<String> islandSignature = visit.getSiganture();
|
||||
|
||||
if (islandSignature.size() == 0) {
|
||||
itemLore.add(configLoad.getString("Menu.Information.Categories.Item.Information.Vote.Word.Empty"));
|
||||
} else {
|
||||
for (String signatureList : islandSignature) {
|
||||
itemLore.add(signatureList);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
itemLore.add(itemLoreList);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
itemLore.addAll(configLoad.getStringList("Menu.Information.Categories.Item.Information.Vote.Enabled.Signature.Disabled.Lore"));
|
||||
}
|
||||
|
||||
nInv.addItem(nInv.createItem(Materials.LEGACY_EMPTY_MAP.getPostItem(), configLoad.getString("Menu.Information.Categories.Item.Information.Displayname"), itemLore, nInv.createItemLoreVariable(new String[] { "%level#" + visit.getLevel().getLevel(), "%members#" + visit.getMembers(), "%votes#" + visit.getVoters().size(), "%visits#" + visit.getVisitors().size(), "%players#" + islandManager.getPlayersAtIsland(island).size(), "%player_capacity#" + mainConfig.getFileConfiguration().getInt("Island.Visitor.Capacity"), "%owner#" + islandOwnerName }), null, null), 2);
|
||||
} else {
|
||||
if (mainConfig.getFileConfiguration().getBoolean("Island.Visitor.Signature.Enable")) {
|
||||
for (String itemLoreList : configLoad.getStringList("Menu.Information.Categories.Item.Information.Vote.Disabled.Signature.Enabled.Lore")) {
|
||||
if (itemLoreList.contains("%signature")) {
|
||||
List<String> islandSignature = visit.getSiganture();
|
||||
|
||||
if (islandSignature.size() == 0) {
|
||||
itemLore.add(configLoad.getString("Menu.Information.Categories.Item.Information.Vote.Word.Empty"));
|
||||
} else {
|
||||
for (String signatureList : islandSignature) {
|
||||
itemLore.add(signatureList);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
itemLore.add(itemLoreList);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
itemLore.addAll(configLoad.getStringList("Menu.Information.Categories.Item.Information.Vote.Disabled.Signature.Disabled.Lore"));
|
||||
}
|
||||
|
||||
nInv.addItem(nInv.createItem(Materials.LEGACY_EMPTY_MAP.getPostItem(), configLoad.getString("Menu.Information.Categories.Item.Information.Displayname"), itemLore, nInv.createItemLoreVariable(new String[] { "%level#" + visit.getLevel().getLevel(), "%members#" + visit.getMembers(), "%visits#" + visit.getVisitors().size(), "%players#" + islandManager.getPlayersAtIsland(island).size(), "%player_capacity#" + mainConfig.getFileConfiguration().getInt("Island.Visitor.Capacity"), "%owner#" + islandOwnerName }), null, null), 2);
|
||||
}
|
||||
|
||||
nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Information.Categories.Title")));
|
||||
nInv.setType(InventoryType.HOPPER);
|
||||
nInv.open();
|
||||
} else if (viewer.getType() == Information.Viewer.Type.Members) {
|
||||
nInventoryUtil nInv = new nInventoryUtil(player, new ClickEventHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
ItemStack is = event.getItem();
|
||||
|
||||
if ((is.getType() == Materials.OAK_FENCE_GATE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Information.Members.Item.Return.Displayname"))))) {
|
||||
playerData.setViewer(new Information.Viewer(((Information.Viewer) playerData.getViewer()).getOwner(), Information.Viewer.Type.Categories));
|
||||
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}, 1L);
|
||||
} else if ((is.getType() == Materials.PAINTING.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Information.Members.Item.Statistics.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == Materials.BLACK_STAINED_GLASS_PANE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Information.Members.Item.Barrier.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.GLASS.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
|
||||
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Information.Members.Item.Previous.Displayname")))) {
|
||||
playerData.setPage(playerData.getPage() - 1);
|
||||
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}, 1L);
|
||||
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Information.Members.Item.Next.Displayname")))) {
|
||||
playerData.setPage(playerData.getPage() + 1);
|
||||
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}, 1L);
|
||||
} else {
|
||||
soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
List<UUID> displayedMembers = new ArrayList<>();
|
||||
List<UUID> islandMembers = island.getRole(Role.Member);
|
||||
List<UUID> islandOperators = island.getRole(Role.Operator);
|
||||
|
||||
displayedMembers.add(island.getOwnerUUID());
|
||||
displayedMembers.addAll(islandOperators);
|
||||
displayedMembers.addAll(islandMembers);
|
||||
|
||||
nInv.addItem(nInv.createItem(Materials.OAK_FENCE_GATE.parseItem(), configLoad.getString("Menu.Information.Members.Item.Return.Displayname"), null, null, null, null), 0, 8);
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING), configLoad.getString("Menu.Information.Members.Item.Statistics.Displayname"), configLoad.getStringList("Menu.Information.Members.Item.Statistics.Lore"), nInv.createItemLoreVariable(new String[] { "%island_members#" + (islandMembers.size() + islandOperators.size() + 1), "%island_capacity#" + skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getInt("Island.Member.Capacity"), "%members#" + islandMembers.size(), "%operators#" + islandOperators.size()}), null, null), 4);
|
||||
nInv.addItem(nInv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(), configLoad.getString("Menu.Information.Members.Item.Barrier.Displayname"), null, null, null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
|
||||
int playerMenuPage = playerData.getPage(), nextEndIndex = displayedMembers.size() - playerMenuPage * 36;
|
||||
|
||||
if (playerMenuPage != 1) {
|
||||
nInv.addItem(nInv.createItem(SkullUtil.create("ToR1w9ZV7zpzCiLBhoaJH3uixs5mAlMhNz42oaRRvrG4HRua5hC6oyyOPfn2HKdSseYA9b1be14fjNRQbSJRvXF3mlvt5/zct4sm+cPVmX8K5kbM2vfwHJgCnfjtPkzT8sqqg6YFdT35mAZGqb9/xY/wDSNSu/S3k2WgmHrJKirszaBZrZfnVnqITUOgM9TmixhcJn2obeqICv6tl7/Wyk/1W62wXlXGm9+WjS+8rRNB+vYxqKR3XmH2lhAiyVGbADsjjGtBVUTWjq+aPw670SjXkoii0YE8sqzUlMMGEkXdXl9fvGtnWKk3APSseuTsjedr7yq+AkXFVDqqkqcUuXwmZl2EjC2WRRbhmYdbtY5nEfqh5+MiBrGdR/JqdEUL4yRutyRTw8mSUAI6X2oSVge7EdM/8f4HwLf33EO4pTocTqAkNbpt6Z54asLe5Y12jSXbvd2dFsgeJbrslK7e4uy/TK8CXf0BP3KLU20QELYrjz9I70gtj9lJ9xwjdx4/xJtxDtrxfC4Afmpu+GNYA/mifpyP3GDeBB5CqN7btIvEWyVvRNH7ppAqZIPqYJ7dSDd2RFuhAId5Yq98GUTBn+eRzeigBvSi1bFkkEgldfghOoK5WhsQtQbXuBBXITMME3NaWCN6zG7DxspS6ew/rZ8E809Xe0ArllquIZ0sP+k=", "eyJ0aW1lc3RhbXAiOjE0OTU3NTE5MTYwNjksInByb2ZpbGVJZCI6ImE2OGYwYjY0OGQxNDQwMDBhOTVmNGI5YmExNGY4ZGY5IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dMZWZ0Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zZWJmOTA3NDk0YTkzNWU5NTViZmNhZGFiODFiZWFmYjkwZmI5YmU0OWM3MDI2YmE5N2Q3OThkNWYxYTIzIn19fQ=="), configLoad.getString("Menu.Information.Members.Item.Previous.Displayname"), null, null, null, null), 1);
|
||||
}
|
||||
|
||||
if (!(nextEndIndex == 0 || nextEndIndex < 0)) {
|
||||
nInv.addItem(nInv.createItem(SkullUtil.create("wZPrsmxckJn4/ybw/iXoMWgAe+1titw3hjhmf7bfg9vtOl0f/J6YLNMOI0OTvqeRKzSQVCxqNOij6k2iM32ZRInCQyblDIFmFadQxryEJDJJPVs7rXR6LRXlN8ON2VDGtboRTL7LwMGpzsrdPNt0oYDJLpR0huEeZKc1+g4W13Y4YM5FUgEs8HvMcg4aaGokSbvrYRRcEh3LR1lVmgxtbiUIr2gZkR3jnwdmZaIw/Ujw28+Et2pDMVCf96E5vC0aNY0KHTdMYheT6hwgw0VAZS2VnJg+Gz4JCl4eQmN2fs4dUBELIW2Rdnp4U1Eb+ZL8DvTV7ofBeZupknqPOyoKIjpInDml9BB2/EkD3zxFtW6AWocRphn03Z203navBkR6ztCMz0BgbmQU/m8VL/s8o4cxOn+2ppjrlj0p8AQxEsBdHozrBi8kNOGf1j97SDHxnvVAF3X8XDso+MthRx5pbEqpxmLyKKgFh25pJE7UaMSnzH2lc7aAZiax67MFw55pDtgfpl+Nlum4r7CK2w5Xob2QTCovVhu78/6SV7qM2Lhlwx/Sjqcl8rn5UIoyM49QE5Iyf1tk+xHXkIvY0m7q358oXsfca4eKmxMe6DFRjUDo1VuWxdg9iVjn22flqz1LD1FhGlPoqv0k4jX5Q733LwtPPI6VOTK+QzqrmiuR6e8=", "eyJ0aW1lc3RhbXAiOjE0OTM4NjgxMDA2NzMsInByb2ZpbGVJZCI6IjUwYzg1MTBiNWVhMDRkNjBiZTlhN2Q1NDJkNmNkMTU2IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dSaWdodCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ=="), configLoad.getString("Menu.Information.Members.Item.Next.Displayname"), null, null, null, null), 7);
|
||||
}
|
||||
|
||||
int index = playerMenuPage * 36 - 36, endIndex = index >= displayedMembers.size() ? displayedMembers.size() - 1 : index + 36, inventorySlot = 17;
|
||||
|
||||
for (; index < endIndex; index++) {
|
||||
if (displayedMembers.size() > index) {
|
||||
inventorySlot++;
|
||||
|
||||
UUID playerUUID = displayedMembers.get(index);
|
||||
|
||||
String[] playerTexture;
|
||||
String playerName, islandRole;
|
||||
|
||||
targetPlayer = Bukkit.getServer().getPlayer(playerUUID);
|
||||
|
||||
if (targetPlayer == null) {
|
||||
OfflinePlayer offlinePlayer = new OfflinePlayer(playerUUID);
|
||||
playerName = offlinePlayer.getName();
|
||||
playerTexture = offlinePlayer.getTexture();
|
||||
} else {
|
||||
playerName = targetPlayer.getName();
|
||||
playerData = skyblock.getPlayerDataManager().getPlayerData(targetPlayer);
|
||||
playerTexture = playerData.getTexture();
|
||||
}
|
||||
|
||||
if (islandMembers.contains(playerUUID)) {
|
||||
islandRole = configLoad.getString("Menu.Information.Members.Item.Member.Word.Member");
|
||||
} else if (islandOperators.contains(playerUUID)) {
|
||||
islandRole = configLoad.getString("Menu.Information.Members.Item.Member.Word.Operator");
|
||||
} else {
|
||||
islandRole = configLoad.getString("Menu.Information.Members.Item.Member.Word.Owner");
|
||||
}
|
||||
|
||||
nInv.addItem(nInv.createItem(SkullUtil.create(playerTexture[0], playerTexture[1]), configLoad.getString("Menu.Information.Members.Item.Member.Displayname").replace("%player", playerName), configLoad.getStringList("Menu.Information.Members.Item.Member.Lore"), nInv.createItemLoreVariable(new String[] { "%role#" + islandRole }), null, null), inventorySlot);
|
||||
}
|
||||
}
|
||||
|
||||
nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Information.Members.Title")));
|
||||
nInv.setRows(6);
|
||||
nInv.open();
|
||||
} else if (viewer.getType() == Information.Viewer.Type.Visitors) {
|
||||
nInventoryUtil nInv = new nInventoryUtil(player, new ClickEventHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
ItemStack is = event.getItem();
|
||||
|
||||
if ((is.getType() == Materials.OAK_FENCE_GATE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Information.Visitors.Item.Return.Displayname"))))) {
|
||||
playerData.setViewer(new Information.Viewer(((Information.Viewer) playerData.getViewer()).getOwner(), Information.Viewer.Type.Categories));
|
||||
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}, 1L);
|
||||
} else if ((is.getType() == Materials.PAINTING.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Information.Visitors.Item.Statistics.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == Materials.BLACK_STAINED_GLASS_PANE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Information.Visitors.Item.Barrier.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.GLASS.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
|
||||
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Information.Visitors.Item.Previous.Displayname")))) {
|
||||
playerData.setPage(playerData.getPage() - 1);
|
||||
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}, 1L);
|
||||
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Information.Visitors.Item.Next.Displayname")))) {
|
||||
playerData.setPage(playerData.getPage() + 1);
|
||||
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}, 1L);
|
||||
} else {
|
||||
soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
List<UUID> displayedVisitors = new ArrayList<>();
|
||||
displayedVisitors.addAll(island.getVisitors());
|
||||
|
||||
nInv.addItem(nInv.createItem(Materials.OAK_FENCE_GATE.parseItem(), configLoad.getString("Menu.Information.Visitors.Item.Return.Displayname"), null, null, null, null), 0, 8);
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING), configLoad.getString("Menu.Information.Visitors.Item.Statistics.Displayname"), configLoad.getStringList("Menu.Information.Visitors.Item.Statistics.Lore"), nInv.createItemLoreVariable(new String[] { "%island_visitors#" + displayedVisitors.size() }), null, null), 4);
|
||||
nInv.addItem(nInv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(), configLoad.getString("Menu.Information.Visitors.Item.Barrier.Displayname"), null, null, null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
|
||||
int playerMenuPage = playerData.getPage(), nextEndIndex = displayedVisitors.size() - playerMenuPage * 36;
|
||||
|
||||
if (playerMenuPage != 1) {
|
||||
nInv.addItem(nInv.createItem(SkullUtil.create("ToR1w9ZV7zpzCiLBhoaJH3uixs5mAlMhNz42oaRRvrG4HRua5hC6oyyOPfn2HKdSseYA9b1be14fjNRQbSJRvXF3mlvt5/zct4sm+cPVmX8K5kbM2vfwHJgCnfjtPkzT8sqqg6YFdT35mAZGqb9/xY/wDSNSu/S3k2WgmHrJKirszaBZrZfnVnqITUOgM9TmixhcJn2obeqICv6tl7/Wyk/1W62wXlXGm9+WjS+8rRNB+vYxqKR3XmH2lhAiyVGbADsjjGtBVUTWjq+aPw670SjXkoii0YE8sqzUlMMGEkXdXl9fvGtnWKk3APSseuTsjedr7yq+AkXFVDqqkqcUuXwmZl2EjC2WRRbhmYdbtY5nEfqh5+MiBrGdR/JqdEUL4yRutyRTw8mSUAI6X2oSVge7EdM/8f4HwLf33EO4pTocTqAkNbpt6Z54asLe5Y12jSXbvd2dFsgeJbrslK7e4uy/TK8CXf0BP3KLU20QELYrjz9I70gtj9lJ9xwjdx4/xJtxDtrxfC4Afmpu+GNYA/mifpyP3GDeBB5CqN7btIvEWyVvRNH7ppAqZIPqYJ7dSDd2RFuhAId5Yq98GUTBn+eRzeigBvSi1bFkkEgldfghOoK5WhsQtQbXuBBXITMME3NaWCN6zG7DxspS6ew/rZ8E809Xe0ArllquIZ0sP+k=", "eyJ0aW1lc3RhbXAiOjE0OTU3NTE5MTYwNjksInByb2ZpbGVJZCI6ImE2OGYwYjY0OGQxNDQwMDBhOTVmNGI5YmExNGY4ZGY5IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dMZWZ0Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zZWJmOTA3NDk0YTkzNWU5NTViZmNhZGFiODFiZWFmYjkwZmI5YmU0OWM3MDI2YmE5N2Q3OThkNWYxYTIzIn19fQ=="), configLoad.getString("Menu.Information.Visitors.Item.Previous.Displayname"), null, null, null, null), 1);
|
||||
}
|
||||
|
||||
if (!(nextEndIndex == 0 || nextEndIndex < 0)) {
|
||||
nInv.addItem(nInv.createItem(SkullUtil.create("wZPrsmxckJn4/ybw/iXoMWgAe+1titw3hjhmf7bfg9vtOl0f/J6YLNMOI0OTvqeRKzSQVCxqNOij6k2iM32ZRInCQyblDIFmFadQxryEJDJJPVs7rXR6LRXlN8ON2VDGtboRTL7LwMGpzsrdPNt0oYDJLpR0huEeZKc1+g4W13Y4YM5FUgEs8HvMcg4aaGokSbvrYRRcEh3LR1lVmgxtbiUIr2gZkR3jnwdmZaIw/Ujw28+Et2pDMVCf96E5vC0aNY0KHTdMYheT6hwgw0VAZS2VnJg+Gz4JCl4eQmN2fs4dUBELIW2Rdnp4U1Eb+ZL8DvTV7ofBeZupknqPOyoKIjpInDml9BB2/EkD3zxFtW6AWocRphn03Z203navBkR6ztCMz0BgbmQU/m8VL/s8o4cxOn+2ppjrlj0p8AQxEsBdHozrBi8kNOGf1j97SDHxnvVAF3X8XDso+MthRx5pbEqpxmLyKKgFh25pJE7UaMSnzH2lc7aAZiax67MFw55pDtgfpl+Nlum4r7CK2w5Xob2QTCovVhu78/6SV7qM2Lhlwx/Sjqcl8rn5UIoyM49QE5Iyf1tk+xHXkIvY0m7q358oXsfca4eKmxMe6DFRjUDo1VuWxdg9iVjn22flqz1LD1FhGlPoqv0k4jX5Q733LwtPPI6VOTK+QzqrmiuR6e8=", "eyJ0aW1lc3RhbXAiOjE0OTM4NjgxMDA2NzMsInByb2ZpbGVJZCI6IjUwYzg1MTBiNWVhMDRkNjBiZTlhN2Q1NDJkNmNkMTU2IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dSaWdodCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ=="), configLoad.getString("Menu.Information.Visitors.Item.Next.Displayname"), null, null, null, null), 7);
|
||||
}
|
||||
|
||||
int index = playerMenuPage * 36 - 36, endIndex = index >= displayedVisitors.size() ? displayedVisitors.size() - 1 : index + 36, inventorySlot = 17;
|
||||
|
||||
for (; index < endIndex; index++) {
|
||||
if (displayedVisitors.size() > index) {
|
||||
inventorySlot++;
|
||||
|
||||
UUID playerUUID = displayedVisitors.get(index);
|
||||
|
||||
String[] playerTexture;
|
||||
String playerName;
|
||||
|
||||
targetPlayer = Bukkit.getServer().getPlayer(playerUUID);
|
||||
|
||||
if (targetPlayer == null) {
|
||||
OfflinePlayer offlinePlayer = new OfflinePlayer(playerUUID);
|
||||
playerName = offlinePlayer.getName();
|
||||
playerTexture = offlinePlayer.getTexture();
|
||||
} else {
|
||||
playerName = targetPlayer.getName();
|
||||
playerData = skyblock.getPlayerDataManager().getPlayerData(targetPlayer);
|
||||
playerTexture = playerData.getTexture();
|
||||
}
|
||||
|
||||
nInv.addItem(nInv.createItem(SkullUtil.create(playerTexture[0], playerTexture[1]), configLoad.getString("Menu.Information.Visitors.Item.Visitor.Displayname").replace("%player", playerName), null, null, null, null), inventorySlot);
|
||||
}
|
||||
}
|
||||
|
||||
nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Information.Visitors.Title")));
|
||||
nInv.setRows(6);
|
||||
nInv.open();
|
||||
}
|
||||
|
||||
islandManager.unloadIsland(viewer.getOwner());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
ItemStack is = event.getCurrentItem();
|
||||
|
||||
if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR) {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Information.Categories.Title"))) || event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Information.Members.Title")))) {
|
||||
event.setCancelled(true);
|
||||
|
||||
PlayerData playerData;
|
||||
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
playerData = playerDataManager.getPlayerData(player);
|
||||
|
||||
if (playerData.getViewer() == null) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Information.Categories.Title")))) {
|
||||
if ((event.getCurrentItem().getType() == Materials.OAK_FENCE_GATE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Information.Categories.Item.Exit.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
} else if ((event.getCurrentItem().getType() == Materials.ITEM_FRAME.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Information.Categories.Item.Members.Displayname"))))) {
|
||||
playerData.setViewer(new Information.Viewer(((Information.Viewer) playerData.getViewer()).getOwner(), Information.Viewer.Type.Members));
|
||||
open(player);
|
||||
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == Materials.LEGACY_EMPTY_MAP.getPostMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Information.Categories.Item.Information.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == Materials.ITEM_FRAME.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Information.Categories.Item.Visitors.Displayname"))))) {
|
||||
playerData.setViewer(new Information.Viewer(((Information.Viewer) playerData.getViewer()).getOwner(), Information.Viewer.Type.Visitors));
|
||||
open(player);
|
||||
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Information.Members.Title")))) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Viewer {
|
||||
public static class Viewer {
|
||||
|
||||
private String name;
|
||||
private UUID islandOwnerUUID;
|
||||
private Type type;
|
||||
|
||||
public Viewer(String name) {
|
||||
this.name = name;
|
||||
public Viewer(UUID islandOwnerUUID, Type type) {
|
||||
this.islandOwnerUUID = islandOwnerUUID;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
public UUID getOwner() {
|
||||
return islandOwnerUUID;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
|
||||
Categories,
|
||||
Members,
|
||||
Visitors;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,9 +9,6 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@ -21,12 +18,14 @@ import me.goodandevil.skyblock.config.FileManager.Config;
|
||||
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
|
||||
import me.goodandevil.skyblock.sound.SoundManager;
|
||||
import me.goodandevil.skyblock.utils.OfflinePlayer;
|
||||
import me.goodandevil.skyblock.utils.item.InventoryUtil;
|
||||
import me.goodandevil.skyblock.utils.item.SkullUtil;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEvent;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEventHandler;
|
||||
import me.goodandevil.skyblock.utils.version.Materials;
|
||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||
|
||||
public class Leaderboard implements Listener {
|
||||
public class Leaderboard {
|
||||
|
||||
private static Leaderboard instance;
|
||||
|
||||
@ -42,160 +41,172 @@ public class Leaderboard implements Listener {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Viewer viewer = (Viewer) playerDataManager.getPlayerData(player).getViewer();
|
||||
|
||||
InventoryUtil inv;
|
||||
|
||||
if (viewer.getType() == Viewer.Type.Browse) {
|
||||
inv = new InventoryUtil(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard." + viewer.getType().name() + ".Title")), InventoryType.HOPPER, 1);
|
||||
inv.addItem(inv.createItem(Materials.OAK_FENCE_GATE.parseItem(), configLoad.getString("Menu.Leaderboard." + viewer.getType().name() + ".Item.Exit.Displayname"), null, null, null, null), 0, 4);
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.DIAMOND), configLoad.getString("Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Displayname").replace("%leaderboard", Viewer.Type.Level.name()), configLoad.getStringList("Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Lore"), inv.createItemLoreVariable(new String[] { "%leaderboard#" + Viewer.Type.Level.name() }), null, null), 1);
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.EMERALD), configLoad.getString("Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Displayname").replace("%leaderboard", Viewer.Type.Votes.name()), configLoad.getStringList("Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Lore"), inv.createItemLoreVariable(new String[] { "%leaderboard#" + Viewer.Type.Votes.name() }), null, null), 3);
|
||||
} else {
|
||||
inv = new InventoryUtil(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard.Leaderboard.Title").replace("%leaderboard", viewer.getType().name())), null, 6);
|
||||
|
||||
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Vote")) {
|
||||
inv.addItem(inv.createItem(Materials.OAK_FENCE_GATE.parseItem(), configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Return.Displayname"), null, null, null, null), 0, 8);
|
||||
} else {
|
||||
inv.addItem(inv.createItem(Materials.OAK_FENCE_GATE.parseItem(), configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Exit.Displayname"), null, null, null, null), 0, 8);
|
||||
}
|
||||
|
||||
List<me.goodandevil.skyblock.leaderboard.Leaderboard> leaderboardIslands = skyblock.getLeaderboardManager().getLeaderboard(me.goodandevil.skyblock.leaderboard.Leaderboard.Type.valueOf(viewer.getType().name()));
|
||||
|
||||
for (int i = 0; i < leaderboardIslands.size(); i++) {
|
||||
me.goodandevil.skyblock.leaderboard.Leaderboard leaderboard = leaderboardIslands.get(i);
|
||||
me.goodandevil.skyblock.visit.Visit visit = leaderboard.getVisit();
|
||||
|
||||
int itemSlot = 0;
|
||||
|
||||
String playerName;
|
||||
String[] playerTexture;
|
||||
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(visit.getOwnerUUID());
|
||||
|
||||
if (targetPlayer == null) {
|
||||
OfflinePlayer offlinePlayer = new OfflinePlayer(visit.getOwnerUUID());
|
||||
playerName = offlinePlayer.getName();
|
||||
playerTexture = offlinePlayer.getTexture();
|
||||
} else {
|
||||
playerName = targetPlayer.getName();
|
||||
playerTexture = playerDataManager.getPlayerData(targetPlayer).getTexture();
|
||||
}
|
||||
|
||||
if (leaderboard.getPosition() == 0) {
|
||||
itemSlot = 13;
|
||||
} else if (leaderboard.getPosition() == 1) {
|
||||
itemSlot = 21;
|
||||
} else if (leaderboard.getPosition() == 2) {
|
||||
itemSlot = 22;
|
||||
} else if (leaderboard.getPosition() == 3) {
|
||||
itemSlot = 23;
|
||||
} else if (leaderboard.getPosition() == 4) {
|
||||
itemSlot = 29;
|
||||
} else if (leaderboard.getPosition() == 5) {
|
||||
itemSlot = 31;
|
||||
} else if (leaderboard.getPosition() == 6) {
|
||||
itemSlot = 33;
|
||||
} else if (leaderboard.getPosition() == 7) {
|
||||
itemSlot = 37;
|
||||
} else if (leaderboard.getPosition() == 8) {
|
||||
itemSlot = 40;
|
||||
} else if (leaderboard.getPosition() == 9) {
|
||||
itemSlot = 43;
|
||||
}
|
||||
|
||||
List<String> itemLore = new ArrayList<>();
|
||||
|
||||
for (String itemLoreList : configLoad.getStringList("Menu.Leaderboard.Leaderboard.Item.Island." + viewer.getType().name() + ".Lore")) {
|
||||
if (itemLoreList.contains("%signature")) {
|
||||
if (visit.getSiganture() == null || visit.getSiganture().size() == 0) {
|
||||
itemLore.add(configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Island.Word.Empty"));
|
||||
} else {
|
||||
for (String signatureList : visit.getSiganture()) {
|
||||
itemLore.add(signatureList);
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
Viewer viewer = (Viewer) playerDataManager.getPlayerData(player).getViewer();
|
||||
|
||||
if (viewer.getType() == Viewer.Type.Browse) {
|
||||
nInventoryUtil nInv = new nInventoryUtil(player, new ClickEventHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
ItemStack is = event.getItem();
|
||||
|
||||
if ((is.getType() == Materials.OAK_FENCE_GATE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard." + Viewer.Type.Browse.name() + ".Item.Exit.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
} else if ((is.getType() == Material.DIAMOND) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard." + Viewer.Type.Browse.name() + ".Item.Leaderboard.Displayname").replace("%leaderboard", Viewer.Type.Level.name()))))) {
|
||||
playerDataManager.getPlayerData(player).setViewer(new Viewer(Viewer.Type.Level));
|
||||
} else if ((is.getType() == Material.EMERALD) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard." + Viewer.Type.Browse.name() + ".Item.Leaderboard.Displayname").replace("%leaderboard", Viewer.Type.Votes.name()))))) {
|
||||
playerDataManager.getPlayerData(player).setViewer(new Viewer(Viewer.Type.Votes));
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}, 1L);
|
||||
}
|
||||
} else {
|
||||
itemLore.add(itemLoreList);
|
||||
}
|
||||
}
|
||||
|
||||
inv.addItem(inv.createItem(SkullUtil.create(playerTexture[0], playerTexture[1]), configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Island.Displayname").replace("%position", "" + (leaderboard.getPosition() + 1)), itemLore, inv.createItemLoreVariable(new String[] { "%position#" + (leaderboard.getPosition() + 1), "%owner#" + playerName, "%level#" + visit.getLevel().getLevel(), "%votes#" + visit.getVoters().size(), "%members#" + visit.getMembers() }), null, null), itemSlot);
|
||||
}
|
||||
|
||||
int[] itemSlots = new int[] { 13, 21, 22, 23, 29, 31, 33, 37, 40, 43 };
|
||||
|
||||
for (int i = 0; i < itemSlots.length; i++) {
|
||||
if (inv.getInventory().getItem(itemSlots[i]) == null) {
|
||||
inv.addItem(inv.createItem(SkullUtil.create("gi+wnQt/y4Z6E9rn65iDWmt8vUOM2WXY66XvtydqDJZTzwgFrjVcx2c5YwdzvtOIRtiX2nZt4n2uWesUFKb59xS24YWbxCDXnalHhCpPFcIP58SQbCm9AYp3UPzkcRNWzuV4BddrS608QQZGyIFOUaLPOPasGITZu51VLcOKcTyFOCKu1QE2yRo1orTH8bWfdpE769BB/VYGdny0qJtm1amc12wGiVifMJRutZmYo2ZdA0APhIJVaNsPppNESVcbeBCvk60l4QK43C/p98/QEe5U6UJ6Z6N01pBQcswubMu8lCuPLasep+vX3v2K+Ui9jnTQNreGNIZPWVjf6V1GH4xMbbUVQJsoPdcaXG855VdzyoW+kyHdWYEojSn0qAY/moH6JCLnx6PLCv9mITSvOIUHq8ITet0M7Z9KALY5s6eg6VdA8TvClRy2TTm9tIRt//TJo5JxBoTYujawGNSR7ryODj2UEDQ2xOyWSagxAXZpispdrO5jHxRmBZUwX9vxnAp+CNWxifpu9sINJTlqYsT/KlGOJQC483gv5B6Nm5VBB1DRFmQkohzO6Wc2eDixgEbaU795GlLxrNaFfNjVH6Bwr1e7df2H3nE0P0bexs4wYdWplijn4gPyHwjT2LDBPGFQK3Vo2SlaXfPYbkIHX21c9qaz3eWHpLEXUBQfnWc=", "eyJ0aW1lc3RhbXAiOjE1MzE3MTcxNjY3MDAsInByb2ZpbGVJZCI6IjYwNmUyZmYwZWQ3NzQ4NDI5ZDZjZTFkMzMyMWM3ODM4IiwicHJvZmlsZU5hbWUiOiJNSEZfUXVlc3Rpb24iLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2QzNGUwNjNjYWZiNDY3YTVjOGRlNDNlYzc4NjE5Mzk5ZjM2OWY0YTUyNDM0ZGE4MDE3YTk4M2NkZDkyNTE2YTAifX19"), configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Empty.Displayname").replace("%position", "" + (i + 1)), configLoad.getStringList("Menu.Leaderboard.Leaderboard.Item.Empty.Lore"), inv.createItemLoreVariable(new String[] { "%position#" + (i + 1) }), null, null), itemSlots[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
player.openInventory(inv.getInventory());
|
||||
});
|
||||
|
||||
nInv.addItem(nInv.createItem(Materials.OAK_FENCE_GATE.parseItem(), configLoad.getString("Menu.Leaderboard." + viewer.getType().name() + ".Item.Exit.Displayname"), null, null, null, null), 0, 4);
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.DIAMOND), configLoad.getString("Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Displayname").replace("%leaderboard", Viewer.Type.Level.name()), configLoad.getStringList("Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Lore"), nInv.createItemLoreVariable(new String[] { "%leaderboard#" + Viewer.Type.Level.name() }), null, null), 1);
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.EMERALD), configLoad.getString("Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Displayname").replace("%leaderboard", Viewer.Type.Votes.name()), configLoad.getStringList("Menu.Leaderboard." + viewer.getType().name() + ".Item.Leaderboard.Lore"), nInv.createItemLoreVariable(new String[] { "%leaderboard#" + Viewer.Type.Votes.name() }), null, null), 3);
|
||||
|
||||
nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard." + viewer.getType().name() + ".Title")));
|
||||
nInv.setType(InventoryType.HOPPER);
|
||||
nInv.open();
|
||||
} else {
|
||||
nInventoryUtil nInv = new nInventoryUtil(player, new ClickEventHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
ItemStack is = event.getItem();
|
||||
|
||||
if ((is.getType() == Materials.OAK_FENCE_GATE.parseMaterial()) && (is.hasItemMeta())) {
|
||||
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Exit.Displayname")))) {
|
||||
soundManager.playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Return.Displayname")))) {
|
||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Vote")) {
|
||||
playerDataManager.getPlayerData(player).setViewer(new Viewer(Viewer.Type.Browse));
|
||||
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}, 1L);
|
||||
} else {
|
||||
soundManager.playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Vote")) {
|
||||
nInv.addItem(nInv.createItem(Materials.OAK_FENCE_GATE.parseItem(), configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Return.Displayname"), null, null, null, null), 0, 8);
|
||||
} else {
|
||||
nInv.addItem(nInv.createItem(Materials.OAK_FENCE_GATE.parseItem(), configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Exit.Displayname"), null, null, null, null), 0, 8);
|
||||
}
|
||||
|
||||
List<me.goodandevil.skyblock.leaderboard.Leaderboard> leaderboardIslands = skyblock.getLeaderboardManager().getLeaderboard(me.goodandevil.skyblock.leaderboard.Leaderboard.Type.valueOf(viewer.getType().name()));
|
||||
|
||||
for (int i = 0; i < leaderboardIslands.size(); i++) {
|
||||
me.goodandevil.skyblock.leaderboard.Leaderboard leaderboard = leaderboardIslands.get(i);
|
||||
me.goodandevil.skyblock.visit.Visit visit = leaderboard.getVisit();
|
||||
|
||||
int itemSlot = 0;
|
||||
|
||||
String playerName;
|
||||
String[] playerTexture;
|
||||
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(visit.getOwnerUUID());
|
||||
|
||||
if (targetPlayer == null) {
|
||||
OfflinePlayer offlinePlayer = new OfflinePlayer(visit.getOwnerUUID());
|
||||
playerName = offlinePlayer.getName();
|
||||
playerTexture = offlinePlayer.getTexture();
|
||||
} else {
|
||||
playerName = targetPlayer.getName();
|
||||
playerTexture = playerDataManager.getPlayerData(targetPlayer).getTexture();
|
||||
}
|
||||
|
||||
if (leaderboard.getPosition() == 0) {
|
||||
itemSlot = 13;
|
||||
} else if (leaderboard.getPosition() == 1) {
|
||||
itemSlot = 21;
|
||||
} else if (leaderboard.getPosition() == 2) {
|
||||
itemSlot = 22;
|
||||
} else if (leaderboard.getPosition() == 3) {
|
||||
itemSlot = 23;
|
||||
} else if (leaderboard.getPosition() == 4) {
|
||||
itemSlot = 29;
|
||||
} else if (leaderboard.getPosition() == 5) {
|
||||
itemSlot = 31;
|
||||
} else if (leaderboard.getPosition() == 6) {
|
||||
itemSlot = 33;
|
||||
} else if (leaderboard.getPosition() == 7) {
|
||||
itemSlot = 37;
|
||||
} else if (leaderboard.getPosition() == 8) {
|
||||
itemSlot = 40;
|
||||
} else if (leaderboard.getPosition() == 9) {
|
||||
itemSlot = 43;
|
||||
}
|
||||
|
||||
List<String> itemLore = new ArrayList<>();
|
||||
|
||||
for (String itemLoreList : configLoad.getStringList("Menu.Leaderboard.Leaderboard.Item.Island." + viewer.getType().name() + ".Lore")) {
|
||||
if (itemLoreList.contains("%signature")) {
|
||||
if (visit.getSiganture() == null || visit.getSiganture().size() == 0) {
|
||||
itemLore.add(configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Island.Word.Empty"));
|
||||
} else {
|
||||
for (String signatureList : visit.getSiganture()) {
|
||||
itemLore.add(signatureList);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
itemLore.add(itemLoreList);
|
||||
}
|
||||
}
|
||||
|
||||
nInv.addItem(nInv.createItem(SkullUtil.create(playerTexture[0], playerTexture[1]), configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Island.Displayname").replace("%position", "" + (leaderboard.getPosition() + 1)), itemLore, nInv.createItemLoreVariable(new String[] { "%position#" + (leaderboard.getPosition() + 1), "%owner#" + playerName, "%level#" + visit.getLevel().getLevel(), "%votes#" + visit.getVoters().size(), "%members#" + visit.getMembers() }), null, null), itemSlot);
|
||||
}
|
||||
|
||||
int[] itemSlots = new int[] { 13, 21, 22, 23, 29, 31, 33, 37, 40, 43 };
|
||||
|
||||
for (int i = 0; i < itemSlots.length; i++) {
|
||||
if (!nInv.getItems().containsKey(itemSlots[i])) {
|
||||
nInv.addItem(nInv.createItem(SkullUtil.create("gi+wnQt/y4Z6E9rn65iDWmt8vUOM2WXY66XvtydqDJZTzwgFrjVcx2c5YwdzvtOIRtiX2nZt4n2uWesUFKb59xS24YWbxCDXnalHhCpPFcIP58SQbCm9AYp3UPzkcRNWzuV4BddrS608QQZGyIFOUaLPOPasGITZu51VLcOKcTyFOCKu1QE2yRo1orTH8bWfdpE769BB/VYGdny0qJtm1amc12wGiVifMJRutZmYo2ZdA0APhIJVaNsPppNESVcbeBCvk60l4QK43C/p98/QEe5U6UJ6Z6N01pBQcswubMu8lCuPLasep+vX3v2K+Ui9jnTQNreGNIZPWVjf6V1GH4xMbbUVQJsoPdcaXG855VdzyoW+kyHdWYEojSn0qAY/moH6JCLnx6PLCv9mITSvOIUHq8ITet0M7Z9KALY5s6eg6VdA8TvClRy2TTm9tIRt//TJo5JxBoTYujawGNSR7ryODj2UEDQ2xOyWSagxAXZpispdrO5jHxRmBZUwX9vxnAp+CNWxifpu9sINJTlqYsT/KlGOJQC483gv5B6Nm5VBB1DRFmQkohzO6Wc2eDixgEbaU795GlLxrNaFfNjVH6Bwr1e7df2H3nE0P0bexs4wYdWplijn4gPyHwjT2LDBPGFQK3Vo2SlaXfPYbkIHX21c9qaz3eWHpLEXUBQfnWc=", "eyJ0aW1lc3RhbXAiOjE1MzE3MTcxNjY3MDAsInByb2ZpbGVJZCI6IjYwNmUyZmYwZWQ3NzQ4NDI5ZDZjZTFkMzMyMWM3ODM4IiwicHJvZmlsZU5hbWUiOiJNSEZfUXVlc3Rpb24iLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2QzNGUwNjNjYWZiNDY3YTVjOGRlNDNlYzc4NjE5Mzk5ZjM2OWY0YTUyNDM0ZGE4MDE3YTk4M2NkZDkyNTE2YTAifX19"), configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Empty.Displayname").replace("%position", "" + (i + 1)), configLoad.getStringList("Menu.Leaderboard.Leaderboard.Item.Empty.Lore"), nInv.createItemLoreVariable(new String[] { "%position#" + (i + 1) }), null, null), itemSlots[i]);
|
||||
}
|
||||
}
|
||||
|
||||
nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard.Leaderboard.Title").replace("%leaderboard", viewer.getType().name())));
|
||||
nInv.setRows(6);
|
||||
nInv.open();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
ItemStack is = event.getCurrentItem();
|
||||
|
||||
if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR) {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard." + Viewer.Type.Browse.name() + ".Title")))) {
|
||||
event.setCancelled(true);
|
||||
|
||||
if ((event.getCurrentItem().getType() == Materials.OAK_FENCE_GATE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard." + Viewer.Type.Browse.name() + ".Item.Exit.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
} else if ((event.getCurrentItem().getType() == Material.DIAMOND) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard." + Viewer.Type.Browse.name() + ".Item.Leaderboard.Displayname").replace("%leaderboard", Viewer.Type.Level.name()))))) {
|
||||
playerDataManager.getPlayerData(player).setViewer(new Viewer(Viewer.Type.Level));
|
||||
open(player);
|
||||
soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == Material.EMERALD) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard." + Viewer.Type.Browse.name() + ".Item.Leaderboard.Displayname").replace("%leaderboard", Viewer.Type.Votes.name()))))) {
|
||||
playerDataManager.getPlayerData(player).setViewer(new Viewer(Viewer.Type.Votes));
|
||||
open(player);
|
||||
soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard.Leaderboard.Title").replace("%leaderboard", Viewer.Type.Level.name()))) || event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard.Leaderboard.Title").replace("%leaderboard", Viewer.Type.Votes.name())))) {
|
||||
event.setCancelled(true);
|
||||
|
||||
if ((event.getCurrentItem().getType() == Materials.OAK_FENCE_GATE.parseMaterial()) && (is.hasItemMeta())) {
|
||||
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Exit.Displayname")))) {
|
||||
soundManager.playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Return.Displayname")))) {
|
||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Vote")) {
|
||||
playerDataManager.getPlayerData(player).setViewer(new Viewer(Viewer.Type.Browse));
|
||||
open(player);
|
||||
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
soundManager.playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Viewer {
|
||||
|
||||
private Type type;
|
||||
|
@ -4,17 +4,13 @@ import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import me.goodandevil.skyblock.SkyBlock;
|
||||
import me.goodandevil.skyblock.config.FileManager;
|
||||
@ -25,15 +21,18 @@ import me.goodandevil.skyblock.island.Level;
|
||||
import me.goodandevil.skyblock.levelling.LevellingManager;
|
||||
import me.goodandevil.skyblock.message.MessageManager;
|
||||
import me.goodandevil.skyblock.playerdata.PlayerData;
|
||||
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
|
||||
import me.goodandevil.skyblock.sound.SoundManager;
|
||||
import me.goodandevil.skyblock.utils.NumberUtil;
|
||||
import me.goodandevil.skyblock.utils.item.InventoryUtil;
|
||||
import me.goodandevil.skyblock.utils.item.MaterialUtil;
|
||||
import me.goodandevil.skyblock.utils.item.SkullUtil;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEvent;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEventHandler;
|
||||
import me.goodandevil.skyblock.utils.version.Materials;
|
||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||
|
||||
public class Levelling implements Listener {
|
||||
public class Levelling {
|
||||
|
||||
private static Levelling instance;
|
||||
|
||||
@ -48,171 +47,179 @@ public class Levelling implements Listener {
|
||||
public void open(Player player) {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player);
|
||||
|
||||
Island island = skyblock.getIslandManager().getIsland(playerData.getOwner());
|
||||
Level level = island.getLevel();
|
||||
|
||||
Map<String, Integer> islandMaterials = level.getMaterials();
|
||||
|
||||
int playerMenuPage = playerData.getPage(), nextEndIndex = islandMaterials.size() - playerMenuPage * 36;
|
||||
|
||||
Config languageConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = languageConfig.getFileConfiguration();
|
||||
|
||||
InventoryUtil inv = new InventoryUtil(configLoad.getString("Menu.Levelling.Title"), null, 6);
|
||||
inv.addItem(inv.createItem(Materials.OAK_FENCE_GATE.parseItem(), configLoad.getString("Menu.Levelling.Item.Exit.Displayname"), null, null, null, null), 0, 8);
|
||||
inv.addItem(inv.createItem(Materials.FIREWORK_STAR.parseItem(), configLoad.getString("Menu.Levelling.Item.Rescan.Displayname"), configLoad.getStringList("Menu.Levelling.Item.Rescan.Lore"), null, null, new ItemFlag[] { ItemFlag.HIDE_POTION_EFFECTS }), 3, 5);
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.PAINTING), configLoad.getString("Menu.Levelling.Item.Statistics.Displayname"), configLoad.getStringList("Menu.Levelling.Item.Statistics.Lore"), inv.createItemLoreVariable(new String[] { "%level_points#" + NumberUtil.formatNumber(level.getPoints()), "%level#" + NumberUtil.formatNumber(level.getLevel()) }), null, null), 4);
|
||||
inv.addItem(inv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(), configLoad.getString("Menu.Levelling.Item.Barrier.Displayname"), null, null, null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
|
||||
if (playerMenuPage != 1) {
|
||||
inv.addItem(inv.createItem(SkullUtil.create("ToR1w9ZV7zpzCiLBhoaJH3uixs5mAlMhNz42oaRRvrG4HRua5hC6oyyOPfn2HKdSseYA9b1be14fjNRQbSJRvXF3mlvt5/zct4sm+cPVmX8K5kbM2vfwHJgCnfjtPkzT8sqqg6YFdT35mAZGqb9/xY/wDSNSu/S3k2WgmHrJKirszaBZrZfnVnqITUOgM9TmixhcJn2obeqICv6tl7/Wyk/1W62wXlXGm9+WjS+8rRNB+vYxqKR3XmH2lhAiyVGbADsjjGtBVUTWjq+aPw670SjXkoii0YE8sqzUlMMGEkXdXl9fvGtnWKk3APSseuTsjedr7yq+AkXFVDqqkqcUuXwmZl2EjC2WRRbhmYdbtY5nEfqh5+MiBrGdR/JqdEUL4yRutyRTw8mSUAI6X2oSVge7EdM/8f4HwLf33EO4pTocTqAkNbpt6Z54asLe5Y12jSXbvd2dFsgeJbrslK7e4uy/TK8CXf0BP3KLU20QELYrjz9I70gtj9lJ9xwjdx4/xJtxDtrxfC4Afmpu+GNYA/mifpyP3GDeBB5CqN7btIvEWyVvRNH7ppAqZIPqYJ7dSDd2RFuhAId5Yq98GUTBn+eRzeigBvSi1bFkkEgldfghOoK5WhsQtQbXuBBXITMME3NaWCN6zG7DxspS6ew/rZ8E809Xe0ArllquIZ0sP+k=", "eyJ0aW1lc3RhbXAiOjE0OTU3NTE5MTYwNjksInByb2ZpbGVJZCI6ImE2OGYwYjY0OGQxNDQwMDBhOTVmNGI5YmExNGY4ZGY5IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dMZWZ0Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zZWJmOTA3NDk0YTkzNWU5NTViZmNhZGFiODFiZWFmYjkwZmI5YmU0OWM3MDI2YmE5N2Q3OThkNWYxYTIzIn19fQ=="), configLoad.getString("Menu.Levelling.Item.Previous.Displayname"), null, null, null, null), 1);
|
||||
}
|
||||
|
||||
if (!(nextEndIndex == 0 || nextEndIndex < 0)) {
|
||||
inv.addItem(inv.createItem(SkullUtil.create("wZPrsmxckJn4/ybw/iXoMWgAe+1titw3hjhmf7bfg9vtOl0f/J6YLNMOI0OTvqeRKzSQVCxqNOij6k2iM32ZRInCQyblDIFmFadQxryEJDJJPVs7rXR6LRXlN8ON2VDGtboRTL7LwMGpzsrdPNt0oYDJLpR0huEeZKc1+g4W13Y4YM5FUgEs8HvMcg4aaGokSbvrYRRcEh3LR1lVmgxtbiUIr2gZkR3jnwdmZaIw/Ujw28+Et2pDMVCf96E5vC0aNY0KHTdMYheT6hwgw0VAZS2VnJg+Gz4JCl4eQmN2fs4dUBELIW2Rdnp4U1Eb+ZL8DvTV7ofBeZupknqPOyoKIjpInDml9BB2/EkD3zxFtW6AWocRphn03Z203navBkR6ztCMz0BgbmQU/m8VL/s8o4cxOn+2ppjrlj0p8AQxEsBdHozrBi8kNOGf1j97SDHxnvVAF3X8XDso+MthRx5pbEqpxmLyKKgFh25pJE7UaMSnzH2lc7aAZiax67MFw55pDtgfpl+Nlum4r7CK2w5Xob2QTCovVhu78/6SV7qM2Lhlwx/Sjqcl8rn5UIoyM49QE5Iyf1tk+xHXkIvY0m7q358oXsfca4eKmxMe6DFRjUDo1VuWxdg9iVjn22flqz1LD1FhGlPoqv0k4jX5Q733LwtPPI6VOTK+QzqrmiuR6e8=", "eyJ0aW1lc3RhbXAiOjE0OTM4NjgxMDA2NzMsInByb2ZpbGVJZCI6IjUwYzg1MTBiNWVhMDRkNjBiZTlhN2Q1NDJkNmNkMTU2IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dSaWdodCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ=="), configLoad.getString("Menu.Levelling.Item.Next.Displayname"), null, null, null, null), 7);
|
||||
}
|
||||
|
||||
if (islandMaterials.size() == 0) {
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.BARRIER), configLoad.getString("Menu.Levelling.Item.Nothing.Displayname"), null, null, null, null), 31);
|
||||
} else {
|
||||
int index = playerMenuPage * 36 - 36, endIndex = index >= islandMaterials.size() ? islandMaterials.size() - 1 : index + 36, inventorySlot = 17;
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "levelling.yml"));
|
||||
|
||||
for (; index < endIndex; index++) {
|
||||
if (islandMaterials.size() > index) {
|
||||
String material = (String) islandMaterials.keySet().toArray()[index];
|
||||
Materials materials = Materials.fromString(material);
|
||||
|
||||
if (materials != null) {
|
||||
int materialAmount = islandMaterials.get(material);
|
||||
|
||||
if (config.getFileConfiguration().getString("Materials." + material + ".Points") != null) {
|
||||
int pointsRequired = config.getFileConfiguration().getInt("Materials." + material + ".Points");
|
||||
|
||||
if (pointsRequired != 0) {
|
||||
inventorySlot++;
|
||||
|
||||
int pointsEarned = materialAmount*pointsRequired;
|
||||
|
||||
ItemStack is = materials.parseItem();
|
||||
is.setAmount(materialAmount);
|
||||
is.setType(MaterialUtil.correctMaterial(is.getType()));
|
||||
|
||||
inv.addItem(inv.createItem(is, configLoad.getString("Menu.Levelling.Item.Material.Displayname").replace("%points", NumberUtil.formatNumber(pointsEarned)).replace("%material", WordUtils.capitalize(material.toLowerCase().replace("_", " ").replace("item", "").replace("block", ""))), null, null, null, null), inventorySlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
player.openInventory(inv.getInventory());
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player);
|
||||
FileConfiguration configLoad = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration();
|
||||
|
||||
nInventoryUtil nInv = new nInventoryUtil(player, new ClickEventHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (!islandManager.hasIsland(player)) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Level.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
ItemStack is = event.getItem();
|
||||
|
||||
if ((is.getType() == Materials.BLACK_STAINED_GLASS_PANE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Barrier.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.GLASS.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == Materials.OAK_FENCE_GATE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Exit.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((is.getType() == Material.PAINTING) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Statistics.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == Material.BARRIER) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Nothing.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == Materials.FIREWORK_STAR.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Rescan.Displayname"))))) {
|
||||
LevellingManager levellingManager = skyblock.getLevellingManager();
|
||||
Island island = islandManager.getIsland(skyblock.getPlayerDataManager().getPlayerData(player).getOwner());
|
||||
|
||||
if (levellingManager.hasLevelling(island.getOwnerUUID())) {
|
||||
me.goodandevil.skyblock.levelling.Levelling levelling = levellingManager.getLevelling(island.getOwnerUUID());
|
||||
long[] durationTime = NumberUtil.getDuration(levelling.getTime());
|
||||
|
||||
if (levelling.getTime() >= 3600) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Level.Cooldown.Message").replace("%time", durationTime[1] + " " + configLoad.getString("Command.Island.Level.Cooldown.Word.Minute") + " " + durationTime[2] + " " + configLoad.getString("Command.Island.Level.Cooldown.Word.Minute") + " " + durationTime[3] + " " + configLoad.getString("Command.Island.Level.Cooldown.Word.Second")));
|
||||
} else if (levelling.getTime() >= 60) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Level.Cooldown.Message").replace("%time", durationTime[2] + " " + configLoad.getString("Command.Island.Level.Cooldown.Word.Minute") + " " + durationTime[3] + " " + configLoad.getString("Command.Island.Level.Cooldown.Word.Second")));
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Level.Cooldown.Message").replace("%time", levelling.getTime() + " " + configLoad.getString("Command.Island.Level.Cooldown.Word.Second")));
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Level.Processing.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
levellingManager.createLevelling(island.getOwnerUUID());
|
||||
levellingManager.loadLevelling(island.getOwnerUUID());
|
||||
levellingManager.calculatePoints(player, island);
|
||||
}
|
||||
});
|
||||
} else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
|
||||
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player);
|
||||
|
||||
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Previous.Displayname")))) {
|
||||
playerData.setPage(playerData.getPage() - 1);
|
||||
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}, 1L);
|
||||
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Next.Displayname")))) {
|
||||
playerData.setPage(playerData.getPage() + 1);
|
||||
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}, 1L);
|
||||
} else {
|
||||
soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
}
|
||||
} else {
|
||||
soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Island island = islandManager.getIsland(playerData.getOwner());
|
||||
Level level = island.getLevel();
|
||||
|
||||
Map<String, Integer> islandMaterials = level.getMaterials();
|
||||
|
||||
int playerMenuPage = playerData.getPage(), nextEndIndex = islandMaterials.size() - playerMenuPage * 36;
|
||||
|
||||
nInv.addItem(nInv.createItem(Materials.OAK_FENCE_GATE.parseItem(), configLoad.getString("Menu.Levelling.Item.Exit.Displayname"), null, null, null, null), 0, 8);
|
||||
nInv.addItem(nInv.createItem(Materials.FIREWORK_STAR.parseItem(), configLoad.getString("Menu.Levelling.Item.Rescan.Displayname"), configLoad.getStringList("Menu.Levelling.Item.Rescan.Lore"), null, null, new ItemFlag[] { ItemFlag.HIDE_POTION_EFFECTS }), 3, 5);
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING), configLoad.getString("Menu.Levelling.Item.Statistics.Displayname"), configLoad.getStringList("Menu.Levelling.Item.Statistics.Lore"), nInv.createItemLoreVariable(new String[] { "%level_points#" + NumberUtil.formatNumber(level.getPoints()), "%level#" + NumberUtil.formatNumber(level.getLevel()) }), null, null), 4);
|
||||
nInv.addItem(nInv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(), configLoad.getString("Menu.Levelling.Item.Barrier.Displayname"), null, null, null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
|
||||
if (playerMenuPage != 1) {
|
||||
nInv.addItem(nInv.createItem(SkullUtil.create("ToR1w9ZV7zpzCiLBhoaJH3uixs5mAlMhNz42oaRRvrG4HRua5hC6oyyOPfn2HKdSseYA9b1be14fjNRQbSJRvXF3mlvt5/zct4sm+cPVmX8K5kbM2vfwHJgCnfjtPkzT8sqqg6YFdT35mAZGqb9/xY/wDSNSu/S3k2WgmHrJKirszaBZrZfnVnqITUOgM9TmixhcJn2obeqICv6tl7/Wyk/1W62wXlXGm9+WjS+8rRNB+vYxqKR3XmH2lhAiyVGbADsjjGtBVUTWjq+aPw670SjXkoii0YE8sqzUlMMGEkXdXl9fvGtnWKk3APSseuTsjedr7yq+AkXFVDqqkqcUuXwmZl2EjC2WRRbhmYdbtY5nEfqh5+MiBrGdR/JqdEUL4yRutyRTw8mSUAI6X2oSVge7EdM/8f4HwLf33EO4pTocTqAkNbpt6Z54asLe5Y12jSXbvd2dFsgeJbrslK7e4uy/TK8CXf0BP3KLU20QELYrjz9I70gtj9lJ9xwjdx4/xJtxDtrxfC4Afmpu+GNYA/mifpyP3GDeBB5CqN7btIvEWyVvRNH7ppAqZIPqYJ7dSDd2RFuhAId5Yq98GUTBn+eRzeigBvSi1bFkkEgldfghOoK5WhsQtQbXuBBXITMME3NaWCN6zG7DxspS6ew/rZ8E809Xe0ArllquIZ0sP+k=", "eyJ0aW1lc3RhbXAiOjE0OTU3NTE5MTYwNjksInByb2ZpbGVJZCI6ImE2OGYwYjY0OGQxNDQwMDBhOTVmNGI5YmExNGY4ZGY5IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dMZWZ0Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zZWJmOTA3NDk0YTkzNWU5NTViZmNhZGFiODFiZWFmYjkwZmI5YmU0OWM3MDI2YmE5N2Q3OThkNWYxYTIzIn19fQ=="), configLoad.getString("Menu.Levelling.Item.Previous.Displayname"), null, null, null, null), 1);
|
||||
}
|
||||
|
||||
if (!(nextEndIndex == 0 || nextEndIndex < 0)) {
|
||||
nInv.addItem(nInv.createItem(SkullUtil.create("wZPrsmxckJn4/ybw/iXoMWgAe+1titw3hjhmf7bfg9vtOl0f/J6YLNMOI0OTvqeRKzSQVCxqNOij6k2iM32ZRInCQyblDIFmFadQxryEJDJJPVs7rXR6LRXlN8ON2VDGtboRTL7LwMGpzsrdPNt0oYDJLpR0huEeZKc1+g4W13Y4YM5FUgEs8HvMcg4aaGokSbvrYRRcEh3LR1lVmgxtbiUIr2gZkR3jnwdmZaIw/Ujw28+Et2pDMVCf96E5vC0aNY0KHTdMYheT6hwgw0VAZS2VnJg+Gz4JCl4eQmN2fs4dUBELIW2Rdnp4U1Eb+ZL8DvTV7ofBeZupknqPOyoKIjpInDml9BB2/EkD3zxFtW6AWocRphn03Z203navBkR6ztCMz0BgbmQU/m8VL/s8o4cxOn+2ppjrlj0p8AQxEsBdHozrBi8kNOGf1j97SDHxnvVAF3X8XDso+MthRx5pbEqpxmLyKKgFh25pJE7UaMSnzH2lc7aAZiax67MFw55pDtgfpl+Nlum4r7CK2w5Xob2QTCovVhu78/6SV7qM2Lhlwx/Sjqcl8rn5UIoyM49QE5Iyf1tk+xHXkIvY0m7q358oXsfca4eKmxMe6DFRjUDo1VuWxdg9iVjn22flqz1LD1FhGlPoqv0k4jX5Q733LwtPPI6VOTK+QzqrmiuR6e8=", "eyJ0aW1lc3RhbXAiOjE0OTM4NjgxMDA2NzMsInByb2ZpbGVJZCI6IjUwYzg1MTBiNWVhMDRkNjBiZTlhN2Q1NDJkNmNkMTU2IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dSaWdodCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ=="), configLoad.getString("Menu.Levelling.Item.Next.Displayname"), null, null, null, null), 7);
|
||||
}
|
||||
|
||||
if (islandMaterials.size() == 0) {
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.BARRIER), configLoad.getString("Menu.Levelling.Item.Nothing.Displayname"), null, null, null, null), 31);
|
||||
} else {
|
||||
int index = playerMenuPage * 36 - 36, endIndex = index >= islandMaterials.size() ? islandMaterials.size() - 1 : index + 36, inventorySlot = 17;
|
||||
|
||||
Config mainConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "levelling.yml"));
|
||||
|
||||
for (; index < endIndex; index++) {
|
||||
if (islandMaterials.size() > index) {
|
||||
String material = (String) islandMaterials.keySet().toArray()[index];
|
||||
Materials materials = Materials.fromString(material);
|
||||
|
||||
if (materials != null) {
|
||||
int materialAmount = islandMaterials.get(material);
|
||||
|
||||
if (mainConfig.getFileConfiguration().getString("Materials." + material + ".Points") != null) {
|
||||
int pointsRequired = mainConfig.getFileConfiguration().getInt("Materials." + material + ".Points");
|
||||
|
||||
if (pointsRequired != 0) {
|
||||
inventorySlot++;
|
||||
|
||||
int pointsEarned = materialAmount*pointsRequired;
|
||||
|
||||
ItemStack is = materials.parseItem();
|
||||
is.setAmount(materialAmount);
|
||||
is.setType(MaterialUtil.correctMaterial(is.getType()));
|
||||
|
||||
nInv.addItem(nInv.createItem(is, configLoad.getString("Menu.Levelling.Item.Material.Displayname").replace("%points", NumberUtil.formatNumber(pointsEarned)).replace("%material", WordUtils.capitalize(material.toLowerCase().replace("_", " ").replace("item", "").replace("block", ""))), null, null, null, null), inventorySlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Title")));
|
||||
nInv.setRows(6);
|
||||
nInv.open();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
ItemStack is = event.getCurrentItem();
|
||||
|
||||
if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR) {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Title")))) {
|
||||
event.setCancelled(true);
|
||||
|
||||
if (!islandManager.hasIsland(player)) {
|
||||
messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Level.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ((event.getCurrentItem().getType() == Materials.BLACK_STAINED_GLASS_PANE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Barrier.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.GLASS.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == Materials.OAK_FENCE_GATE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Exit.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
} else if ((event.getCurrentItem().getType() == Material.PAINTING) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Statistics.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == Material.BARRIER) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Nothing.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == Materials.FIREWORK_STAR.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Rescan.Displayname"))))) {
|
||||
LevellingManager levellingManager = skyblock.getLevellingManager();
|
||||
Island island = islandManager.getIsland(skyblock.getPlayerDataManager().getPlayerData(player).getOwner());
|
||||
|
||||
if (levellingManager.hasLevelling(island.getOwnerUUID())) {
|
||||
me.goodandevil.skyblock.levelling.Levelling levelling = levellingManager.getLevelling(island.getOwnerUUID());
|
||||
long[] durationTime = NumberUtil.getDuration(levelling.getTime());
|
||||
|
||||
if (levelling.getTime() >= 3600) {
|
||||
messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Message").replace("%time", durationTime[1] + " " + config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Word.Minute") + " " + durationTime[2] + " " + config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Word.Minute") + " " + durationTime[3] + " " + config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Word.Second")));
|
||||
} else if (levelling.getTime() >= 60) {
|
||||
messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Message").replace("%time", durationTime[2] + " " + config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Word.Minute") + " " + durationTime[3] + " " + config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Word.Second")));
|
||||
} else {
|
||||
messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Message").replace("%time", levelling.getTime() + " " + config.getFileConfiguration().getString("Command.Island.Level.Cooldown.Word.Second")));
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
player.closeInventory();
|
||||
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Level.Processing.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
levellingManager.createLevelling(island.getOwnerUUID());
|
||||
levellingManager.loadLevelling(island.getOwnerUUID());
|
||||
levellingManager.calculatePoints(player, island);
|
||||
}
|
||||
}.runTaskAsynchronously(skyblock);
|
||||
} else if ((event.getCurrentItem().getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
|
||||
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player);
|
||||
|
||||
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Previous.Displayname")))) {
|
||||
playerData.setPage(playerData.getPage() - 1);
|
||||
open(player);
|
||||
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Next.Displayname")))) {
|
||||
playerData.setPage(playerData.getPage() + 1);
|
||||
open(player);
|
||||
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClose(InventoryCloseEvent event) {
|
||||
Player player = (Player) event.getPlayer();
|
||||
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Title")))) {
|
||||
skyblock.getSoundManager().playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,31 +16,29 @@ import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import me.goodandevil.skyblock.SkyBlock;
|
||||
import me.goodandevil.skyblock.config.FileManager.Config;
|
||||
import me.goodandevil.skyblock.config.FileManager;
|
||||
import me.goodandevil.skyblock.island.Island;
|
||||
import me.goodandevil.skyblock.island.IslandManager;
|
||||
import me.goodandevil.skyblock.island.Role;
|
||||
import me.goodandevil.skyblock.island.Settings;
|
||||
import me.goodandevil.skyblock.playerdata.PlayerData;
|
||||
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
|
||||
import me.goodandevil.skyblock.sound.SoundManager;
|
||||
import me.goodandevil.skyblock.utils.NumberUtil;
|
||||
import me.goodandevil.skyblock.utils.OfflinePlayer;
|
||||
import me.goodandevil.skyblock.utils.StringUtil;
|
||||
import me.goodandevil.skyblock.utils.item.InventoryUtil;
|
||||
import me.goodandevil.skyblock.utils.item.SkullUtil;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEvent;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEventHandler;
|
||||
import me.goodandevil.skyblock.utils.version.Materials;
|
||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||
|
||||
public class Members implements Listener {
|
||||
public class Members {
|
||||
|
||||
private static Members instance;
|
||||
|
||||
@ -55,400 +53,407 @@ public class Members implements Listener {
|
||||
public void open(Player player, Members.Type type, Members.Sort sort) {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player);
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Island island = skyblock.getIslandManager().getIsland(playerData.getOwner());
|
||||
|
||||
List<UUID> displayedMembers = new ArrayList<>();
|
||||
|
||||
List<UUID> islandMembers = island.getRole(Role.Member);
|
||||
List<UUID> islandOperators = island.getRole(Role.Operator);
|
||||
|
||||
if (type == Members.Type.Default) {
|
||||
displayedMembers.add(island.getOwnerUUID());
|
||||
displayedMembers.addAll(islandOperators);
|
||||
displayedMembers.addAll(islandMembers);
|
||||
} else if (type == Members.Type.Members) {
|
||||
displayedMembers.addAll(islandMembers);
|
||||
} else if (type == Members.Type.Operators) {
|
||||
displayedMembers.addAll(islandOperators);
|
||||
} else if (type == Members.Type.Owner) {
|
||||
displayedMembers.add(island.getOwnerUUID());
|
||||
}
|
||||
|
||||
if (sort == Members.Sort.Playtime) {
|
||||
Map<Integer, UUID> sortedPlaytimes = new TreeMap<>();
|
||||
|
||||
for (UUID displayedMemberList : displayedMembers) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(displayedMemberList);
|
||||
|
||||
if (targetPlayer == null) {
|
||||
sortedPlaytimes.put(YamlConfiguration.loadConfiguration(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), displayedMemberList.toString() + ".yml")).getInt("Statistics.Island.Playtime"), displayedMemberList);
|
||||
} else {
|
||||
sortedPlaytimes.put(skyblock.getPlayerDataManager().getPlayerData(targetPlayer).getPlaytime(), displayedMemberList);
|
||||
}
|
||||
}
|
||||
|
||||
displayedMembers.clear();
|
||||
|
||||
for (Integer sortedPlaytimeList : sortedPlaytimes.keySet()) {
|
||||
displayedMembers.add(sortedPlaytimes.get(sortedPlaytimeList));
|
||||
}
|
||||
} else if (sort == Members.Sort.MemberSince) {
|
||||
Map<Date, UUID> sortedDates = new TreeMap<>();
|
||||
|
||||
for (UUID displayedMemberList : displayedMembers) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(displayedMemberList);
|
||||
|
||||
try {
|
||||
if (targetPlayer == null) {
|
||||
sortedDates.put(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").parse(YamlConfiguration.loadConfiguration(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), displayedMemberList.toString() + ".yml")).getString("Statistics.Island.Join")), displayedMemberList);
|
||||
} else {
|
||||
sortedDates.put(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").parse(skyblock.getPlayerDataManager().getPlayerData(targetPlayer).getMemberSince()), displayedMemberList);
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
displayedMembers.clear();
|
||||
|
||||
for (Date sortedDateList : sortedDates.keySet()) {
|
||||
displayedMembers.add(sortedDates.get(sortedDateList));
|
||||
}
|
||||
} else if (sort == Members.Sort.LastOnline) {
|
||||
List<UUID> onlineMembers = new ArrayList<>(displayedMembers);
|
||||
Map<Date, UUID> sortedDates = new TreeMap<>();
|
||||
|
||||
for (UUID displayedMemberList : displayedMembers) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(displayedMemberList);
|
||||
|
||||
if (targetPlayer == null) {
|
||||
onlineMembers.remove(displayedMemberList);
|
||||
|
||||
try {
|
||||
sortedDates.put(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").parse(YamlConfiguration.loadConfiguration(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), displayedMemberList.toString() + ".yml")).getString("Statistics.Island.LastOnline")), displayedMemberList);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
displayedMembers.clear();
|
||||
displayedMembers.addAll(onlineMembers);
|
||||
|
||||
for (Date sortedDateList : sortedDates.keySet()) {
|
||||
displayedMembers.add(sortedDates.get(sortedDateList));
|
||||
}
|
||||
}
|
||||
|
||||
boolean[] operatorActions = new boolean[] { false, false };
|
||||
|
||||
if (island.isRole(Role.Owner, player.getUniqueId())) {
|
||||
operatorActions = new boolean[] { true, true };
|
||||
} else if (island.isRole(Role.Operator, player.getUniqueId())) {
|
||||
if (island.getSetting(Settings.Role.Operator, "Kick").getStatus()) {
|
||||
operatorActions = new boolean[] { false, true };
|
||||
}
|
||||
}
|
||||
|
||||
int playerMenuPage = playerData.getPage(), nextEndIndex = displayedMembers.size() - playerMenuPage * 36;
|
||||
|
||||
Config languageConfig = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = languageConfig.getFileConfiguration();
|
||||
|
||||
InventoryUtil inv = new InventoryUtil(configLoad.getString("Menu.Members.Title"), null, 6);
|
||||
inv.addItem(inv.createItem(Materials.OAK_FENCE_GATE.parseItem(), configLoad.getString("Menu.Members.Item.Exit.Displayname"), null, null, null, null), 0, 8);
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.HOPPER), configLoad.getString("Menu.Members.Item.Type.Displayname"), configLoad.getStringList("Menu.Members.Item.Type.Lore"), inv.createItemLoreVariable(new String[] { "%type#" + type.name() }), null, null), 3);
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.PAINTING), configLoad.getString("Menu.Members.Item.Statistics.Displayname"), configLoad.getStringList("Menu.Members.Item.Statistics.Lore"), inv.createItemLoreVariable(new String[] { "%island_members#" + (islandMembers.size() + islandOperators.size() + 1), "%island_capacity#" + skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getInt("Island.Member.Capacity"), "%members#" + islandMembers.size(), "%operators#" + islandOperators.size()}), null, null), 4);
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.HOPPER), configLoad.getString("Menu.Members.Item.Sort.Displayname"), configLoad.getStringList("Menu.Members.Item.Sort.Lore"), inv.createItemLoreVariable(new String[] { "%sort#" + StringUtil.capatilizeUppercaseLetters(sort.name()) }), null, null), 5);
|
||||
inv.addItem(inv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(), configLoad.getString("Menu.Members.Item.Barrier.Displayname"), null, null, null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
|
||||
if (playerMenuPage != 1) {
|
||||
inv.addItem(inv.createItem(SkullUtil.create("ToR1w9ZV7zpzCiLBhoaJH3uixs5mAlMhNz42oaRRvrG4HRua5hC6oyyOPfn2HKdSseYA9b1be14fjNRQbSJRvXF3mlvt5/zct4sm+cPVmX8K5kbM2vfwHJgCnfjtPkzT8sqqg6YFdT35mAZGqb9/xY/wDSNSu/S3k2WgmHrJKirszaBZrZfnVnqITUOgM9TmixhcJn2obeqICv6tl7/Wyk/1W62wXlXGm9+WjS+8rRNB+vYxqKR3XmH2lhAiyVGbADsjjGtBVUTWjq+aPw670SjXkoii0YE8sqzUlMMGEkXdXl9fvGtnWKk3APSseuTsjedr7yq+AkXFVDqqkqcUuXwmZl2EjC2WRRbhmYdbtY5nEfqh5+MiBrGdR/JqdEUL4yRutyRTw8mSUAI6X2oSVge7EdM/8f4HwLf33EO4pTocTqAkNbpt6Z54asLe5Y12jSXbvd2dFsgeJbrslK7e4uy/TK8CXf0BP3KLU20QELYrjz9I70gtj9lJ9xwjdx4/xJtxDtrxfC4Afmpu+GNYA/mifpyP3GDeBB5CqN7btIvEWyVvRNH7ppAqZIPqYJ7dSDd2RFuhAId5Yq98GUTBn+eRzeigBvSi1bFkkEgldfghOoK5WhsQtQbXuBBXITMME3NaWCN6zG7DxspS6ew/rZ8E809Xe0ArllquIZ0sP+k=", "eyJ0aW1lc3RhbXAiOjE0OTU3NTE5MTYwNjksInByb2ZpbGVJZCI6ImE2OGYwYjY0OGQxNDQwMDBhOTVmNGI5YmExNGY4ZGY5IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dMZWZ0Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zZWJmOTA3NDk0YTkzNWU5NTViZmNhZGFiODFiZWFmYjkwZmI5YmU0OWM3MDI2YmE5N2Q3OThkNWYxYTIzIn19fQ=="), configLoad.getString("Menu.Members.Item.Previous.Displayname"), null, null, null, null), 1);
|
||||
}
|
||||
|
||||
if (!(nextEndIndex == 0 || nextEndIndex < 0)) {
|
||||
inv.addItem(inv.createItem(SkullUtil.create("wZPrsmxckJn4/ybw/iXoMWgAe+1titw3hjhmf7bfg9vtOl0f/J6YLNMOI0OTvqeRKzSQVCxqNOij6k2iM32ZRInCQyblDIFmFadQxryEJDJJPVs7rXR6LRXlN8ON2VDGtboRTL7LwMGpzsrdPNt0oYDJLpR0huEeZKc1+g4W13Y4YM5FUgEs8HvMcg4aaGokSbvrYRRcEh3LR1lVmgxtbiUIr2gZkR3jnwdmZaIw/Ujw28+Et2pDMVCf96E5vC0aNY0KHTdMYheT6hwgw0VAZS2VnJg+Gz4JCl4eQmN2fs4dUBELIW2Rdnp4U1Eb+ZL8DvTV7ofBeZupknqPOyoKIjpInDml9BB2/EkD3zxFtW6AWocRphn03Z203navBkR6ztCMz0BgbmQU/m8VL/s8o4cxOn+2ppjrlj0p8AQxEsBdHozrBi8kNOGf1j97SDHxnvVAF3X8XDso+MthRx5pbEqpxmLyKKgFh25pJE7UaMSnzH2lc7aAZiax67MFw55pDtgfpl+Nlum4r7CK2w5Xob2QTCovVhu78/6SV7qM2Lhlwx/Sjqcl8rn5UIoyM49QE5Iyf1tk+xHXkIvY0m7q358oXsfca4eKmxMe6DFRjUDo1VuWxdg9iVjn22flqz1LD1FhGlPoqv0k4jX5Q733LwtPPI6VOTK+QzqrmiuR6e8=", "eyJ0aW1lc3RhbXAiOjE0OTM4NjgxMDA2NzMsInByb2ZpbGVJZCI6IjUwYzg1MTBiNWVhMDRkNjBiZTlhN2Q1NDJkNmNkMTU2IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dSaWdodCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ=="), configLoad.getString("Menu.Members.Item.Next.Displayname"), null, null, null, null), 7);
|
||||
}
|
||||
|
||||
if (displayedMembers.size() == 0) {
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.BARRIER), configLoad.getString("Menu.Members.Item.Nothing.Displayname"), null, null, null, null), 31);
|
||||
} else {
|
||||
int index = playerMenuPage * 36 - 36, endIndex = index >= displayedMembers.size() ? displayedMembers.size() - 1 : index + 36, inventorySlot = 17;
|
||||
|
||||
for (; index < endIndex; index++) {
|
||||
if (displayedMembers.size() > index) {
|
||||
inventorySlot++;
|
||||
|
||||
UUID playerUUID = displayedMembers.get(index);
|
||||
|
||||
String[] playerTexture;
|
||||
String playerName, islandRole, islandPlaytimeFormatted, memberSinceFormatted, lastOnlineFormatted = "";
|
||||
|
||||
long[] playTimeDurationTime, memberSinceDurationTime = null, lastOnlineDurationTime = null;
|
||||
|
||||
int islandPlaytime;
|
||||
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(playerUUID);
|
||||
|
||||
if (targetPlayer == null) {
|
||||
OfflinePlayer offlinePlayer = new OfflinePlayer(playerUUID);
|
||||
playerName = offlinePlayer.getName();
|
||||
playerTexture = offlinePlayer.getTexture();
|
||||
islandPlaytime = offlinePlayer.getPlaytime();
|
||||
playTimeDurationTime = NumberUtil.getDuration(Integer.valueOf(islandPlaytime));
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
FileConfiguration configLoad = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration();
|
||||
|
||||
nInventoryUtil nInv = new nInventoryUtil(player, new ClickEventHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
|
||||
try {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
||||
memberSinceDurationTime = NumberUtil.getDuration(simpleDateFormat.parse(offlinePlayer.getMemberSince()), new Date());
|
||||
lastOnlineDurationTime = NumberUtil.getDuration(simpleDateFormat.parse(offlinePlayer.getLastOnline()), new Date());
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
if (playerData.getType() == null || playerData.getSort() == null) {
|
||||
playerData.setType(Members.Type.Default);
|
||||
playerData.setSort(Members.Sort.Default);
|
||||
}
|
||||
} else {
|
||||
playerName = targetPlayer.getName();
|
||||
|
||||
playerData = skyblock.getPlayerDataManager().getPlayerData(targetPlayer);
|
||||
playerTexture = playerData.getTexture();
|
||||
islandPlaytime = playerData.getPlaytime();
|
||||
playTimeDurationTime = NumberUtil.getDuration(Integer.valueOf(islandPlaytime));
|
||||
ItemStack is = event.getItem();
|
||||
Island island = null;
|
||||
|
||||
try {
|
||||
memberSinceDurationTime = NumberUtil.getDuration(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").parse(playerData.getMemberSince()), new Date());
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (islandMembers.contains(playerUUID)) {
|
||||
islandRole = configLoad.getString("Menu.Members.Item.Member.Role.Word.Member");
|
||||
} else if (islandOperators.contains(playerUUID)) {
|
||||
islandRole = configLoad.getString("Menu.Members.Item.Member.Role.Word.Operator");
|
||||
} else {
|
||||
islandRole = configLoad.getString("Menu.Members.Item.Member.Role.Word.Owner");
|
||||
}
|
||||
|
||||
if (islandPlaytime >= 86400) {
|
||||
islandPlaytimeFormatted = playTimeDurationTime[0] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Days") + ", " + playTimeDurationTime[1] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Hours") + ", " + playTimeDurationTime[2] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Minutes") + ", " + playTimeDurationTime[3] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Seconds");
|
||||
} else if (islandPlaytime >= 3600) {
|
||||
islandPlaytimeFormatted = playTimeDurationTime[1] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Hours") + ", " + playTimeDurationTime[2] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Minutes") + ", " + playTimeDurationTime[3] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Seconds");
|
||||
} else if (islandPlaytime >= 60) {
|
||||
islandPlaytimeFormatted = playTimeDurationTime[2] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Minutes") + ", " + playTimeDurationTime[3] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Seconds");
|
||||
} else {
|
||||
islandPlaytimeFormatted = playTimeDurationTime[3] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Seconds");
|
||||
}
|
||||
|
||||
if (memberSinceDurationTime[0] != 0L) {
|
||||
memberSinceFormatted = memberSinceDurationTime[0] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Days") + ", " + memberSinceDurationTime[1] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Hours") + ", " + memberSinceDurationTime[2] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Minutes") + ", " + memberSinceDurationTime[3] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Seconds");
|
||||
} else if (memberSinceDurationTime[1] != 0L) {
|
||||
memberSinceFormatted = memberSinceDurationTime[1] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Hours") + ", " + memberSinceDurationTime[2] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Minutes") + ", " + memberSinceDurationTime[3] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Seconds");
|
||||
} else if (memberSinceDurationTime[2] != 0L) {
|
||||
memberSinceFormatted = memberSinceDurationTime[2] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Minutes") + ", " + memberSinceDurationTime[3] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Seconds");
|
||||
} else {
|
||||
memberSinceFormatted = memberSinceDurationTime[3] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Seconds");
|
||||
}
|
||||
|
||||
if (lastOnlineDurationTime != null) {
|
||||
if (lastOnlineDurationTime[0] != 0L) {
|
||||
lastOnlineFormatted = lastOnlineDurationTime[0] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Days") + ", " + lastOnlineDurationTime[1] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Hours") + ", " + lastOnlineDurationTime[2] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Minutes") + ", " + lastOnlineDurationTime[3] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Seconds");
|
||||
} else if (lastOnlineDurationTime[1] != 0L) {
|
||||
lastOnlineFormatted = lastOnlineDurationTime[1] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Hours") + ", " + lastOnlineDurationTime[2] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Minutes") + ", " + lastOnlineDurationTime[3] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Seconds");
|
||||
} else if (lastOnlineDurationTime[2] != 0L) {
|
||||
lastOnlineFormatted = lastOnlineDurationTime[2] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Minutes") + ", " + lastOnlineDurationTime[3] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Seconds");
|
||||
if (islandManager.hasIsland(player)) {
|
||||
island = islandManager.getIsland(playerData.getOwner());
|
||||
} else {
|
||||
lastOnlineFormatted = lastOnlineDurationTime[3] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Seconds");
|
||||
skyblock.getMessageManager().sendMessage(player, configLoad.getString("Command.Island.Members.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
List<String> itemLore = new ArrayList<>();
|
||||
itemLore.addAll(configLoad.getStringList("Menu.Members.Item.Member.Role.Lore"));
|
||||
itemLore.addAll(configLoad.getStringList("Menu.Members.Item.Member.Playtime.Lore"));
|
||||
itemLore.addAll(configLoad.getStringList("Menu.Members.Item.Member.Since.Lore"));
|
||||
|
||||
if (lastOnlineDurationTime != null) {
|
||||
itemLore.addAll(configLoad.getStringList("Menu.Members.Item.Member.LastOnline.Lore"));
|
||||
}
|
||||
|
||||
if (!(playerUUID.equals(player.getUniqueId()) || island.isRole(Role.Owner, playerUUID))) {
|
||||
if (operatorActions[0] && operatorActions[1]) {
|
||||
if (!island.isRole(Role.Owner, playerUUID)) {
|
||||
itemLore.add("");
|
||||
|
||||
if (island.isRole(Role.Member, playerUUID)) {
|
||||
itemLore.add(configLoad.getString("Menu.Members.Item.Member.Action.Lore").replace("%click", configLoad.getString("Menu.Members.Item.Member.Word.Left-Click")).replace("%action", configLoad.getString("Menu.Members.Item.Member.Action.Word.Promote")));
|
||||
} else {
|
||||
itemLore.add(configLoad.getString("Menu.Members.Item.Member.Action.Lore").replace("%click", configLoad.getString("Menu.Members.Item.Member.Word.Left-Click")).replace("%action", configLoad.getString("Menu.Members.Item.Member.Action.Word.Demote")));
|
||||
|
||||
if ((is.getType() == Materials.BLACK_STAINED_GLASS_PANE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Members.Item.Barrier.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.GLASS.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == Materials.OAK_FENCE_GATE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Members.Item.Exit.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((is.getType() == Material.HOPPER) && (is.hasItemMeta())) {
|
||||
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Members.Item.Type.Displayname")))) {
|
||||
Members.Type type = (Members.Type) playerData.getType();
|
||||
|
||||
if (type.ordinal()+1 == Members.Type.values().length) {
|
||||
playerData.setType(Members.Type.Default);
|
||||
} else {
|
||||
playerData.setType(Members.Type.values()[type.ordinal() + 1]);
|
||||
}
|
||||
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Members.Item.Sort.Displayname")))) {
|
||||
Members.Sort sort = (Members.Sort) playerData.getSort();
|
||||
|
||||
if (sort.ordinal()+1 == Members.Sort.values().length) {
|
||||
playerData.setSort(Members.Sort.Default);
|
||||
} else {
|
||||
playerData.setSort(Members.Sort.values()[sort.ordinal() + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player, (Members.Type) playerData.getType(), (Members.Sort) playerData.getSort());
|
||||
}
|
||||
|
||||
itemLore.add(configLoad.getString("Menu.Members.Item.Member.Action.Lore").replace("%click", configLoad.getString("Menu.Members.Item.Member.Word.Right-Click")).replace("%action", configLoad.getString("Menu.Members.Item.Member.Action.Word.Kick")));
|
||||
}
|
||||
} else if (!operatorActions[0] && operatorActions[1]) {
|
||||
if (!(playerUUID.equals(player.getUniqueId()) && island.getRole(Role.Operator).contains(playerUUID) && island.isRole(Role.Owner, playerUUID))) {
|
||||
itemLore.add("");
|
||||
itemLore.add(configLoad.getString("Menu.Members.Item.Member.Action.Lore").replace("%click", configLoad.getString("Menu.Members.Item.Member.Word.Click")).replace("%action", configLoad.getString("Menu.Members.Item.Member.Action.Word.Kick")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inv.addItem(inv.createItem(SkullUtil.create(playerTexture[0], playerTexture[1]), configLoad.getString("Menu.Members.Item.Member.Displayname").replace("%player", playerName), itemLore, inv.createItemLoreVariable(new String[] { "%role#" + islandRole, "%playtime#" + islandPlaytimeFormatted, "%since#" + memberSinceFormatted, "%last_online#" + lastOnlineFormatted }), null, null), inventorySlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
player.openInventory(inv.getInventory());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
ItemStack is = event.getCurrentItem();
|
||||
|
||||
if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR) {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Members.Title")))) {
|
||||
event.setCancelled(true);
|
||||
|
||||
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player);
|
||||
|
||||
if (playerData.getType() == null || playerData.getSort() == null) {
|
||||
playerData.setType(Members.Type.Default);
|
||||
playerData.setSort(Members.Sort.Default);
|
||||
}
|
||||
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
Island island = null;
|
||||
|
||||
if (islandManager.hasIsland(player)) {
|
||||
island = islandManager.getIsland(playerData.getOwner());
|
||||
} else {
|
||||
skyblock.getMessageManager().sendMessage(player, config.getFileConfiguration().getString("Command.Island.Members.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ((event.getCurrentItem().getType() == Materials.BLACK_STAINED_GLASS_PANE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Members.Item.Barrier.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.GLASS.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == Materials.OAK_FENCE_GATE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Members.Item.Exit.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
} else if ((event.getCurrentItem().getType() == Material.HOPPER) && (is.hasItemMeta())) {
|
||||
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Members.Item.Type.Displayname")))) {
|
||||
Members.Type type = (Members.Type) playerData.getType();
|
||||
|
||||
if (type.ordinal()+1 == Members.Type.values().length) {
|
||||
playerData.setType(Members.Type.Default);
|
||||
} else {
|
||||
playerData.setType(Members.Type.values()[type.ordinal() + 1]);
|
||||
}
|
||||
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Members.Item.Sort.Displayname")))) {
|
||||
Members.Sort sort = (Members.Sort) playerData.getSort();
|
||||
|
||||
if (sort.ordinal()+1 == Members.Sort.values().length) {
|
||||
playerData.setSort(Members.Sort.Default);
|
||||
} else {
|
||||
playerData.setSort(Members.Sort.values()[sort.ordinal() + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
open(player, (Members.Type) playerData.getType(), (Members.Sort) playerData.getSort());
|
||||
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == Material.PAINTING) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Members.Item.Statistics.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == Material.BARRIER) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Members.Item.Nothing.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
|
||||
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Members.Item.Previous.Displayname")))) {
|
||||
playerData.setPage(playerData.getPage() - 1);
|
||||
open(player, (Members.Type) playerData.getType(), (Members.Sort) playerData.getSort());
|
||||
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Members.Item.Next.Displayname")))) {
|
||||
playerData.setPage(playerData.getPage() + 1);
|
||||
open(player, (Members.Type) playerData.getType(), (Members.Sort) playerData.getSort());
|
||||
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
String playerName = ChatColor.stripColor(is.getItemMeta().getDisplayName());
|
||||
UUID playerUUID;
|
||||
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(playerName);
|
||||
|
||||
if (targetPlayer == null) {
|
||||
playerUUID = new OfflinePlayer(playerName).getUUID();
|
||||
} else {
|
||||
playerUUID = targetPlayer.getUniqueId();
|
||||
}
|
||||
|
||||
if (!(playerUUID.equals(player.getUniqueId()) || island.isRole(Role.Owner, playerUUID))) {
|
||||
if (island.isRole(Role.Owner, player.getUniqueId())) {
|
||||
if (event.getClick() == ClickType.LEFT) {
|
||||
if (island.isRole(Role.Member, playerUUID)) {
|
||||
Bukkit.getServer().dispatchCommand(player, "island promote " + playerName);
|
||||
} else {
|
||||
Bukkit.getServer().dispatchCommand(player, "island demote " + playerName);
|
||||
}
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player, (Members.Type) playerData.getType(), (Members.Sort) playerData.getSort());
|
||||
}
|
||||
}.runTaskLater(skyblock, 3L);
|
||||
|
||||
return;
|
||||
} else if (event.getClick() == ClickType.RIGHT) {
|
||||
Bukkit.getServer().dispatchCommand(player, "island kick " + playerName);
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player, (Members.Type) playerData.getType(), (Members.Sort) playerData.getSort());
|
||||
}
|
||||
}.runTaskLater(skyblock, 3L);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (island.isRole(Role.Operator, player.getUniqueId()) && island.getSetting(Settings.Role.Operator, "Kick").getStatus()) {
|
||||
Bukkit.getServer().dispatchCommand(player, "island kick " + playerName);
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
}, 1L);
|
||||
} else if ((is.getType() == Material.PAINTING) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Members.Item.Statistics.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == Material.BARRIER) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Members.Item.Nothing.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
|
||||
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Members.Item.Previous.Displayname")))) {
|
||||
playerData.setPage(playerData.getPage() - 1);
|
||||
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player, (Members.Type) playerData.getType(), (Members.Sort) playerData.getSort());
|
||||
}
|
||||
}.runTaskLater(skyblock, 3L);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClose(InventoryCloseEvent event) {
|
||||
Player player = (Player) event.getPlayer();
|
||||
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Members.Title")))) {
|
||||
skyblock.getSoundManager().playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
open(player, (Members.Type) playerData.getType(), (Members.Sort) playerData.getSort());
|
||||
}
|
||||
}, 1L);
|
||||
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Members.Item.Next.Displayname")))) {
|
||||
playerData.setPage(playerData.getPage() + 1);
|
||||
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player, (Members.Type) playerData.getType(), (Members.Sort) playerData.getSort());
|
||||
}
|
||||
}, 1L);
|
||||
} else {
|
||||
String playerName = ChatColor.stripColor(is.getItemMeta().getDisplayName());
|
||||
UUID playerUUID;
|
||||
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(playerName);
|
||||
|
||||
if (targetPlayer == null) {
|
||||
playerUUID = new OfflinePlayer(playerName).getUUID();
|
||||
} else {
|
||||
playerUUID = targetPlayer.getUniqueId();
|
||||
}
|
||||
|
||||
if (!(playerUUID.equals(player.getUniqueId()) || island.isRole(Role.Owner, playerUUID))) {
|
||||
if (island.isRole(Role.Owner, player.getUniqueId())) {
|
||||
if (event.getClick() == ClickType.LEFT) {
|
||||
if (island.isRole(Role.Member, playerUUID)) {
|
||||
Bukkit.getServer().dispatchCommand(player, "island promote " + playerName);
|
||||
} else {
|
||||
Bukkit.getServer().dispatchCommand(player, "island demote " + playerName);
|
||||
}
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player, (Members.Type) playerData.getType(), (Members.Sort) playerData.getSort());
|
||||
}
|
||||
}, 3L);
|
||||
|
||||
return;
|
||||
} else if (event.getClick() == ClickType.RIGHT) {
|
||||
Bukkit.getServer().dispatchCommand(player, "island kick " + playerName);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player, (Members.Type) playerData.getType(), (Members.Sort) playerData.getSort());
|
||||
}
|
||||
}, 3L);
|
||||
|
||||
return;
|
||||
}
|
||||
} else if (island.isRole(Role.Operator, player.getUniqueId()) && island.getSetting(Settings.Role.Operator, "Kick").getStatus()) {
|
||||
Bukkit.getServer().dispatchCommand(player, "island kick " + playerName);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player, (Members.Type) playerData.getType(), (Members.Sort) playerData.getSort());
|
||||
}
|
||||
}, 3L);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
Island island = islandManager.getIsland(playerData.getOwner());
|
||||
|
||||
List<UUID> displayedMembers = new ArrayList<>();
|
||||
List<UUID> islandMembers = island.getRole(Role.Member);
|
||||
List<UUID> islandOperators = island.getRole(Role.Operator);
|
||||
|
||||
if (type == Members.Type.Default) {
|
||||
displayedMembers.add(island.getOwnerUUID());
|
||||
displayedMembers.addAll(islandOperators);
|
||||
displayedMembers.addAll(islandMembers);
|
||||
} else if (type == Members.Type.Members) {
|
||||
displayedMembers.addAll(islandMembers);
|
||||
} else if (type == Members.Type.Operators) {
|
||||
displayedMembers.addAll(islandOperators);
|
||||
} else if (type == Members.Type.Owner) {
|
||||
displayedMembers.add(island.getOwnerUUID());
|
||||
}
|
||||
|
||||
if (sort == Members.Sort.Playtime) {
|
||||
Map<Integer, UUID> sortedPlaytimes = new TreeMap<>();
|
||||
|
||||
for (UUID displayedMemberList : displayedMembers) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(displayedMemberList);
|
||||
|
||||
if (targetPlayer == null) {
|
||||
sortedPlaytimes.put(YamlConfiguration.loadConfiguration(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), displayedMemberList.toString() + ".yml")).getInt("Statistics.Island.Playtime"), displayedMemberList);
|
||||
} else {
|
||||
sortedPlaytimes.put(skyblock.getPlayerDataManager().getPlayerData(targetPlayer).getPlaytime(), displayedMemberList);
|
||||
}
|
||||
}
|
||||
|
||||
displayedMembers.clear();
|
||||
|
||||
for (Integer sortedPlaytimeList : sortedPlaytimes.keySet()) {
|
||||
displayedMembers.add(sortedPlaytimes.get(sortedPlaytimeList));
|
||||
}
|
||||
} else if (sort == Members.Sort.MemberSince) {
|
||||
Map<Date, UUID> sortedDates = new TreeMap<>();
|
||||
|
||||
for (UUID displayedMemberList : displayedMembers) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(displayedMemberList);
|
||||
|
||||
try {
|
||||
if (targetPlayer == null) {
|
||||
sortedDates.put(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").parse(YamlConfiguration.loadConfiguration(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), displayedMemberList.toString() + ".yml")).getString("Statistics.Island.Join")), displayedMemberList);
|
||||
} else {
|
||||
sortedDates.put(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").parse(skyblock.getPlayerDataManager().getPlayerData(targetPlayer).getMemberSince()), displayedMemberList);
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
displayedMembers.clear();
|
||||
|
||||
for (Date sortedDateList : sortedDates.keySet()) {
|
||||
displayedMembers.add(sortedDates.get(sortedDateList));
|
||||
}
|
||||
} else if (sort == Members.Sort.LastOnline) {
|
||||
List<UUID> onlineMembers = new ArrayList<>(displayedMembers);
|
||||
Map<Date, UUID> sortedDates = new TreeMap<>();
|
||||
|
||||
for (UUID displayedMemberList : displayedMembers) {
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(displayedMemberList);
|
||||
|
||||
if (targetPlayer == null) {
|
||||
onlineMembers.remove(displayedMemberList);
|
||||
|
||||
try {
|
||||
sortedDates.put(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").parse(YamlConfiguration.loadConfiguration(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), displayedMemberList.toString() + ".yml")).getString("Statistics.Island.LastOnline")), displayedMemberList);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
displayedMembers.clear();
|
||||
displayedMembers.addAll(onlineMembers);
|
||||
|
||||
for (Date sortedDateList : sortedDates.keySet()) {
|
||||
displayedMembers.add(sortedDates.get(sortedDateList));
|
||||
}
|
||||
}
|
||||
|
||||
boolean[] operatorActions = new boolean[] { false, false };
|
||||
|
||||
if (island.isRole(Role.Owner, player.getUniqueId())) {
|
||||
operatorActions = new boolean[] { true, true };
|
||||
} else if (island.isRole(Role.Operator, player.getUniqueId())) {
|
||||
if (island.getSetting(Settings.Role.Operator, "Kick").getStatus()) {
|
||||
operatorActions = new boolean[] { false, true };
|
||||
}
|
||||
}
|
||||
|
||||
int playerMenuPage = playerData.getPage(), nextEndIndex = displayedMembers.size() - playerMenuPage * 36;
|
||||
|
||||
nInv.addItem(nInv.createItem(Materials.OAK_FENCE_GATE.parseItem(), configLoad.getString("Menu.Members.Item.Exit.Displayname"), null, null, null, null), 0, 8);
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.HOPPER), configLoad.getString("Menu.Members.Item.Type.Displayname"), configLoad.getStringList("Menu.Members.Item.Type.Lore"), nInv.createItemLoreVariable(new String[] { "%type#" + type.name() }), null, null), 3);
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING), configLoad.getString("Menu.Members.Item.Statistics.Displayname"), configLoad.getStringList("Menu.Members.Item.Statistics.Lore"), nInv.createItemLoreVariable(new String[] { "%island_members#" + (islandMembers.size() + islandOperators.size() + 1), "%island_capacity#" + fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getInt("Island.Member.Capacity"), "%members#" + islandMembers.size(), "%operators#" + islandOperators.size()}), null, null), 4);
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.HOPPER), configLoad.getString("Menu.Members.Item.Sort.Displayname"), configLoad.getStringList("Menu.Members.Item.Sort.Lore"), nInv.createItemLoreVariable(new String[] { "%sort#" + StringUtil.capatilizeUppercaseLetters(sort.name()) }), null, null), 5);
|
||||
nInv.addItem(nInv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(), configLoad.getString("Menu.Members.Item.Barrier.Displayname"), null, null, null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
|
||||
if (playerMenuPage != 1) {
|
||||
nInv.addItem(nInv.createItem(SkullUtil.create("ToR1w9ZV7zpzCiLBhoaJH3uixs5mAlMhNz42oaRRvrG4HRua5hC6oyyOPfn2HKdSseYA9b1be14fjNRQbSJRvXF3mlvt5/zct4sm+cPVmX8K5kbM2vfwHJgCnfjtPkzT8sqqg6YFdT35mAZGqb9/xY/wDSNSu/S3k2WgmHrJKirszaBZrZfnVnqITUOgM9TmixhcJn2obeqICv6tl7/Wyk/1W62wXlXGm9+WjS+8rRNB+vYxqKR3XmH2lhAiyVGbADsjjGtBVUTWjq+aPw670SjXkoii0YE8sqzUlMMGEkXdXl9fvGtnWKk3APSseuTsjedr7yq+AkXFVDqqkqcUuXwmZl2EjC2WRRbhmYdbtY5nEfqh5+MiBrGdR/JqdEUL4yRutyRTw8mSUAI6X2oSVge7EdM/8f4HwLf33EO4pTocTqAkNbpt6Z54asLe5Y12jSXbvd2dFsgeJbrslK7e4uy/TK8CXf0BP3KLU20QELYrjz9I70gtj9lJ9xwjdx4/xJtxDtrxfC4Afmpu+GNYA/mifpyP3GDeBB5CqN7btIvEWyVvRNH7ppAqZIPqYJ7dSDd2RFuhAId5Yq98GUTBn+eRzeigBvSi1bFkkEgldfghOoK5WhsQtQbXuBBXITMME3NaWCN6zG7DxspS6ew/rZ8E809Xe0ArllquIZ0sP+k=", "eyJ0aW1lc3RhbXAiOjE0OTU3NTE5MTYwNjksInByb2ZpbGVJZCI6ImE2OGYwYjY0OGQxNDQwMDBhOTVmNGI5YmExNGY4ZGY5IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dMZWZ0Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zZWJmOTA3NDk0YTkzNWU5NTViZmNhZGFiODFiZWFmYjkwZmI5YmU0OWM3MDI2YmE5N2Q3OThkNWYxYTIzIn19fQ=="), configLoad.getString("Menu.Members.Item.Previous.Displayname"), null, null, null, null), 1);
|
||||
}
|
||||
|
||||
if (!(nextEndIndex == 0 || nextEndIndex < 0)) {
|
||||
nInv.addItem(nInv.createItem(SkullUtil.create("wZPrsmxckJn4/ybw/iXoMWgAe+1titw3hjhmf7bfg9vtOl0f/J6YLNMOI0OTvqeRKzSQVCxqNOij6k2iM32ZRInCQyblDIFmFadQxryEJDJJPVs7rXR6LRXlN8ON2VDGtboRTL7LwMGpzsrdPNt0oYDJLpR0huEeZKc1+g4W13Y4YM5FUgEs8HvMcg4aaGokSbvrYRRcEh3LR1lVmgxtbiUIr2gZkR3jnwdmZaIw/Ujw28+Et2pDMVCf96E5vC0aNY0KHTdMYheT6hwgw0VAZS2VnJg+Gz4JCl4eQmN2fs4dUBELIW2Rdnp4U1Eb+ZL8DvTV7ofBeZupknqPOyoKIjpInDml9BB2/EkD3zxFtW6AWocRphn03Z203navBkR6ztCMz0BgbmQU/m8VL/s8o4cxOn+2ppjrlj0p8AQxEsBdHozrBi8kNOGf1j97SDHxnvVAF3X8XDso+MthRx5pbEqpxmLyKKgFh25pJE7UaMSnzH2lc7aAZiax67MFw55pDtgfpl+Nlum4r7CK2w5Xob2QTCovVhu78/6SV7qM2Lhlwx/Sjqcl8rn5UIoyM49QE5Iyf1tk+xHXkIvY0m7q358oXsfca4eKmxMe6DFRjUDo1VuWxdg9iVjn22flqz1LD1FhGlPoqv0k4jX5Q733LwtPPI6VOTK+QzqrmiuR6e8=", "eyJ0aW1lc3RhbXAiOjE0OTM4NjgxMDA2NzMsInByb2ZpbGVJZCI6IjUwYzg1MTBiNWVhMDRkNjBiZTlhN2Q1NDJkNmNkMTU2IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dSaWdodCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ=="), configLoad.getString("Menu.Members.Item.Next.Displayname"), null, null, null, null), 7);
|
||||
}
|
||||
|
||||
if (displayedMembers.size() == 0) {
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.BARRIER), configLoad.getString("Menu.Members.Item.Nothing.Displayname"), null, null, null, null), 31);
|
||||
} else {
|
||||
int index = playerMenuPage * 36 - 36, endIndex = index >= displayedMembers.size() ? displayedMembers.size() - 1 : index + 36, inventorySlot = 17;
|
||||
|
||||
for (; index < endIndex; index++) {
|
||||
if (displayedMembers.size() > index) {
|
||||
inventorySlot++;
|
||||
|
||||
UUID playerUUID = displayedMembers.get(index);
|
||||
|
||||
String[] playerTexture;
|
||||
String playerName, islandRole, islandPlaytimeFormatted, memberSinceFormatted, lastOnlineFormatted = "";
|
||||
|
||||
long[] playTimeDurationTime, memberSinceDurationTime = null, lastOnlineDurationTime = null;
|
||||
|
||||
int islandPlaytime;
|
||||
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(playerUUID);
|
||||
|
||||
if (targetPlayer == null) {
|
||||
OfflinePlayer offlinePlayer = new OfflinePlayer(playerUUID);
|
||||
playerName = offlinePlayer.getName();
|
||||
playerTexture = offlinePlayer.getTexture();
|
||||
islandPlaytime = offlinePlayer.getPlaytime();
|
||||
playTimeDurationTime = NumberUtil.getDuration(Integer.valueOf(islandPlaytime));
|
||||
|
||||
try {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
||||
memberSinceDurationTime = NumberUtil.getDuration(simpleDateFormat.parse(offlinePlayer.getMemberSince()), new Date());
|
||||
lastOnlineDurationTime = NumberUtil.getDuration(simpleDateFormat.parse(offlinePlayer.getLastOnline()), new Date());
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
playerName = targetPlayer.getName();
|
||||
|
||||
playerData = skyblock.getPlayerDataManager().getPlayerData(targetPlayer);
|
||||
playerTexture = playerData.getTexture();
|
||||
islandPlaytime = playerData.getPlaytime();
|
||||
playTimeDurationTime = NumberUtil.getDuration(Integer.valueOf(islandPlaytime));
|
||||
|
||||
try {
|
||||
memberSinceDurationTime = NumberUtil.getDuration(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").parse(playerData.getMemberSince()), new Date());
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (islandMembers.contains(playerUUID)) {
|
||||
islandRole = configLoad.getString("Menu.Members.Item.Member.Role.Word.Member");
|
||||
} else if (islandOperators.contains(playerUUID)) {
|
||||
islandRole = configLoad.getString("Menu.Members.Item.Member.Role.Word.Operator");
|
||||
} else {
|
||||
islandRole = configLoad.getString("Menu.Members.Item.Member.Role.Word.Owner");
|
||||
}
|
||||
|
||||
if (islandPlaytime >= 86400) {
|
||||
islandPlaytimeFormatted = playTimeDurationTime[0] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Days") + ", " + playTimeDurationTime[1] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Hours") + ", " + playTimeDurationTime[2] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Minutes") + ", " + playTimeDurationTime[3] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Seconds");
|
||||
} else if (islandPlaytime >= 3600) {
|
||||
islandPlaytimeFormatted = playTimeDurationTime[1] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Hours") + ", " + playTimeDurationTime[2] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Minutes") + ", " + playTimeDurationTime[3] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Seconds");
|
||||
} else if (islandPlaytime >= 60) {
|
||||
islandPlaytimeFormatted = playTimeDurationTime[2] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Minutes") + ", " + playTimeDurationTime[3] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Seconds");
|
||||
} else {
|
||||
islandPlaytimeFormatted = playTimeDurationTime[3] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Seconds");
|
||||
}
|
||||
|
||||
if (memberSinceDurationTime[0] != 0L) {
|
||||
memberSinceFormatted = memberSinceDurationTime[0] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Days") + ", " + memberSinceDurationTime[1] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Hours") + ", " + memberSinceDurationTime[2] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Minutes") + ", " + memberSinceDurationTime[3] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Seconds");
|
||||
} else if (memberSinceDurationTime[1] != 0L) {
|
||||
memberSinceFormatted = memberSinceDurationTime[1] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Hours") + ", " + memberSinceDurationTime[2] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Minutes") + ", " + memberSinceDurationTime[3] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Seconds");
|
||||
} else if (memberSinceDurationTime[2] != 0L) {
|
||||
memberSinceFormatted = memberSinceDurationTime[2] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Minutes") + ", " + memberSinceDurationTime[3] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Seconds");
|
||||
} else {
|
||||
memberSinceFormatted = memberSinceDurationTime[3] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Seconds");
|
||||
}
|
||||
|
||||
if (lastOnlineDurationTime != null) {
|
||||
if (lastOnlineDurationTime[0] != 0L) {
|
||||
lastOnlineFormatted = lastOnlineDurationTime[0] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Days") + ", " + lastOnlineDurationTime[1] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Hours") + ", " + lastOnlineDurationTime[2] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Minutes") + ", " + lastOnlineDurationTime[3] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Seconds");
|
||||
} else if (lastOnlineDurationTime[1] != 0L) {
|
||||
lastOnlineFormatted = lastOnlineDurationTime[1] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Hours") + ", " + lastOnlineDurationTime[2] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Minutes") + ", " + lastOnlineDurationTime[3] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Seconds");
|
||||
} else if (lastOnlineDurationTime[2] != 0L) {
|
||||
lastOnlineFormatted = lastOnlineDurationTime[2] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Minutes") + ", " + lastOnlineDurationTime[3] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Seconds");
|
||||
} else {
|
||||
lastOnlineFormatted = lastOnlineDurationTime[3] + " " + configLoad.getString("Menu.Members.Item.Member.Word.Seconds");
|
||||
}
|
||||
}
|
||||
|
||||
List<String> itemLore = new ArrayList<>();
|
||||
itemLore.addAll(configLoad.getStringList("Menu.Members.Item.Member.Role.Lore"));
|
||||
itemLore.addAll(configLoad.getStringList("Menu.Members.Item.Member.Playtime.Lore"));
|
||||
itemLore.addAll(configLoad.getStringList("Menu.Members.Item.Member.Since.Lore"));
|
||||
|
||||
if (lastOnlineDurationTime != null) {
|
||||
itemLore.addAll(configLoad.getStringList("Menu.Members.Item.Member.LastOnline.Lore"));
|
||||
}
|
||||
|
||||
if (!(playerUUID.equals(player.getUniqueId()) || island.isRole(Role.Owner, playerUUID))) {
|
||||
if (operatorActions[0] && operatorActions[1]) {
|
||||
if (!island.isRole(Role.Owner, playerUUID)) {
|
||||
itemLore.add("");
|
||||
|
||||
if (island.isRole(Role.Member, playerUUID)) {
|
||||
itemLore.add(configLoad.getString("Menu.Members.Item.Member.Action.Lore").replace("%click", configLoad.getString("Menu.Members.Item.Member.Word.Left-Click")).replace("%action", configLoad.getString("Menu.Members.Item.Member.Action.Word.Promote")));
|
||||
} else {
|
||||
itemLore.add(configLoad.getString("Menu.Members.Item.Member.Action.Lore").replace("%click", configLoad.getString("Menu.Members.Item.Member.Word.Left-Click")).replace("%action", configLoad.getString("Menu.Members.Item.Member.Action.Word.Demote")));
|
||||
}
|
||||
|
||||
itemLore.add(configLoad.getString("Menu.Members.Item.Member.Action.Lore").replace("%click", configLoad.getString("Menu.Members.Item.Member.Word.Right-Click")).replace("%action", configLoad.getString("Menu.Members.Item.Member.Action.Word.Kick")));
|
||||
}
|
||||
} else if (!operatorActions[0] && operatorActions[1]) {
|
||||
if (!(playerUUID.equals(player.getUniqueId()) && island.getRole(Role.Operator).contains(playerUUID) && island.isRole(Role.Owner, playerUUID))) {
|
||||
itemLore.add("");
|
||||
itemLore.add(configLoad.getString("Menu.Members.Item.Member.Action.Lore").replace("%click", configLoad.getString("Menu.Members.Item.Member.Word.Click")).replace("%action", configLoad.getString("Menu.Members.Item.Member.Action.Word.Kick")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nInv.addItem(nInv.createItem(SkullUtil.create(playerTexture[0], playerTexture[1]), configLoad.getString("Menu.Members.Item.Member.Displayname").replace("%player", playerName), itemLore, nInv.createItemLoreVariable(new String[] { "%role#" + islandRole, "%playtime#" + islandPlaytimeFormatted, "%since#" + memberSinceFormatted, "%last_online#" + lastOnlineFormatted }), null, null), inventorySlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Members.Title")));
|
||||
nInv.setRows(6);
|
||||
nInv.open();
|
||||
}
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
|
||||
|
@ -8,17 +8,13 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import me.goodandevil.skyblock.SkyBlock;
|
||||
import me.goodandevil.skyblock.config.FileManager.Config;
|
||||
import me.goodandevil.skyblock.config.FileManager;
|
||||
import me.goodandevil.skyblock.island.Island;
|
||||
import me.goodandevil.skyblock.island.IslandManager;
|
||||
import me.goodandevil.skyblock.island.Role;
|
||||
@ -28,12 +24,14 @@ import me.goodandevil.skyblock.playerdata.PlayerDataManager;
|
||||
import me.goodandevil.skyblock.sound.SoundManager;
|
||||
import me.goodandevil.skyblock.utils.AnvilGUI;
|
||||
import me.goodandevil.skyblock.utils.OfflinePlayer;
|
||||
import me.goodandevil.skyblock.utils.item.InventoryUtil;
|
||||
import me.goodandevil.skyblock.utils.item.SkullUtil;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEvent;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEventHandler;
|
||||
import me.goodandevil.skyblock.utils.version.Materials;
|
||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||
|
||||
public class Ownership implements Listener {
|
||||
public class Ownership {
|
||||
|
||||
private static Ownership instance;
|
||||
|
||||
@ -48,221 +46,244 @@ public class Ownership implements Listener {
|
||||
public void open(Player player) {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Island island = skyblock.getIslandManager().getIsland(playerDataManager.getPlayerData(player).getOwner());
|
||||
|
||||
UUID originalOwnerUUID = island.getOriginalOwnerUUID();
|
||||
|
||||
String originalOwnerName, ownershipPassword = island.getPassword();
|
||||
String[] playerTexture;
|
||||
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(island.getOriginalOwnerUUID());
|
||||
|
||||
if (targetPlayer == null) {
|
||||
OfflinePlayer offlinePlayer = new OfflinePlayer(originalOwnerUUID);
|
||||
originalOwnerName = offlinePlayer.getName();
|
||||
playerTexture = offlinePlayer.getTexture();
|
||||
} else {
|
||||
originalOwnerName = targetPlayer.getName();
|
||||
playerTexture = playerDataManager.getPlayerData(targetPlayer).getTexture();
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
FileConfiguration configLoad = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration();
|
||||
|
||||
nInventoryUtil nInv = new nInventoryUtil(player, new ClickEventHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player);
|
||||
Island island = null;
|
||||
|
||||
if (islandManager.hasIsland(player)) {
|
||||
island = islandManager.getIsland(playerData.getOwner());
|
||||
|
||||
if (!island.isRole(Role.Owner, player.getUniqueId())) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ownership.Role.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ownership.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (playerData.getType() == null) {
|
||||
playerData.setType(Ownership.Visibility.Hidden);
|
||||
}
|
||||
|
||||
ItemStack is = event.getItem();
|
||||
|
||||
if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Ownership.Item.Original.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == Materials.BLACK_STAINED_GLASS_PANE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Ownership.Item.Barrier.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.GLASS.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == Materials.WRITABLE_BOOK.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Ownership.Item.Assign.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AnvilGUI gui = new AnvilGUI(player, new AnvilGUI.AnvilClickEventHandler() {
|
||||
@Override
|
||||
public void onAnvilClick(final AnvilGUI.AnvilClickEvent event) {
|
||||
if (event.getSlot() == AnvilGUI.AnvilSlot.OUTPUT) {
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
Island island;
|
||||
|
||||
if (islandManager.hasIsland(player)) {
|
||||
island = islandManager.getIsland(playerDataManager.getPlayerData(player).getOwner());
|
||||
|
||||
if (!island.isRole(Role.Owner, player.getUniqueId())) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ownership.Role.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ownership.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTask(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getServer().dispatchCommand(player, "island ownership " + event.getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ItemStack is = new ItemStack(Material.NAME_TAG);
|
||||
ItemMeta im = is.getItemMeta();
|
||||
im.setDisplayName(configLoad.getString("Menu.Ownership.Item.Assign.Word.Enter"));
|
||||
is.setItemMeta(im);
|
||||
|
||||
gui.setSlot(AnvilGUI.AnvilSlot.INPUT_LEFT, is);
|
||||
gui.open();
|
||||
}
|
||||
}, 1L);
|
||||
} else if ((is.getType() == Materials.LEGACY_EMPTY_MAP.getPostMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Ownership.Item.Password.Displayname"))))) {
|
||||
if (island.hasPassword()) {
|
||||
if (event.getClick() == ClickType.MIDDLE) {
|
||||
Ownership.Visibility visibility = (Ownership.Visibility) playerData.getType();
|
||||
|
||||
if (visibility == Ownership.Visibility.Hidden) {
|
||||
playerData.setType(Ownership.Visibility.Visible);
|
||||
} else {
|
||||
playerData.setType(Ownership.Visibility.Hidden);
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}, 1L);
|
||||
|
||||
return;
|
||||
} else if (event.getClick() == ClickType.RIGHT) {
|
||||
island.setPassword(null);
|
||||
soundManager.playSound(player, Sounds.EXPLODE.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}, 1L);
|
||||
|
||||
return;
|
||||
} else if (event.getClick() != ClickType.LEFT) {
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AnvilGUI gui = new AnvilGUI(player, new AnvilGUI.AnvilClickEventHandler() {
|
||||
@Override
|
||||
public void onAnvilClick(final AnvilGUI.AnvilClickEvent event) {
|
||||
if (event.getSlot() == AnvilGUI.AnvilSlot.OUTPUT) {
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
Island island;
|
||||
|
||||
if (islandManager.hasIsland(player)) {
|
||||
island = islandManager.getIsland(playerDataManager.getPlayerData(player).getOwner());
|
||||
|
||||
if (!island.isRole(Role.Owner, player.getUniqueId())) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ownership.Role.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ownership.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
island.setPassword(event.getName().replace("&", "").replace(" ", ""));
|
||||
soundManager.playSound(player, Sounds.ANVIL_USE.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}, 1L);
|
||||
}
|
||||
} else {
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ItemStack is = new ItemStack(Material.NAME_TAG);
|
||||
ItemMeta im = is.getItemMeta();
|
||||
im.setDisplayName(configLoad.getString("Menu.Ownership.Item.Password.Hidden.Word.Enter"));
|
||||
is.setItemMeta(im);
|
||||
|
||||
gui.setSlot(AnvilGUI.AnvilSlot.INPUT_LEFT, is);
|
||||
gui.open();
|
||||
}
|
||||
}, 1L);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Island island = skyblock.getIslandManager().getIsland(playerDataManager.getPlayerData(player).getOwner());
|
||||
|
||||
UUID originalOwnerUUID = island.getOriginalOwnerUUID();
|
||||
|
||||
String originalOwnerName, ownershipPassword = island.getPassword();
|
||||
String[] playerTexture;
|
||||
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(island.getOriginalOwnerUUID());
|
||||
|
||||
if (targetPlayer == null) {
|
||||
OfflinePlayer offlinePlayer = new OfflinePlayer(originalOwnerUUID);
|
||||
originalOwnerName = offlinePlayer.getName();
|
||||
playerTexture = offlinePlayer.getTexture();
|
||||
} else {
|
||||
originalOwnerName = targetPlayer.getName();
|
||||
playerTexture = playerDataManager.getPlayerData(targetPlayer).getTexture();
|
||||
}
|
||||
|
||||
nInv.addItem(nInv.createItem(SkullUtil.create(playerTexture[0], playerTexture[1]), configLoad.getString("Menu.Ownership.Item.Original.Displayname"), configLoad.getStringList("Menu.Ownership.Item.Original.Lore"), nInv.createItemLoreVariable(new String[] { "%player#" + originalOwnerName }), null, null), 0);
|
||||
nInv.addItem(nInv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(), configLoad.getString("Menu.Ownership.Item.Barrier.Displayname"), null, null, null, null), 1);
|
||||
nInv.addItem(nInv.createItem(Materials.WRITABLE_BOOK.parseItem(), configLoad.getString("Menu.Ownership.Item.Assign.Displayname"), configLoad.getStringList("Menu.Ownership.Item.Assign.Lore"), null, null, null), 2);
|
||||
|
||||
if (island.hasPassword()) {
|
||||
if (playerDataManager.getPlayerData(player).getType() == Ownership.Visibility.Hidden) {
|
||||
nInv.addItem(nInv.createItem(Materials.LEGACY_EMPTY_MAP.getPostItem(), configLoad.getString("Menu.Ownership.Item.Password.Displayname"), configLoad.getStringList("Menu.Ownership.Item.Password.Hidden.Lore"), null, null, null), 3);
|
||||
} else {
|
||||
nInv.addItem(nInv.createItem(Materials.LEGACY_EMPTY_MAP.getPostItem(), configLoad.getString("Menu.Ownership.Item.Password.Displayname"), configLoad.getStringList("Menu.Ownership.Item.Password.Visible.Lore"), nInv.createItemLoreVariable(new String[] { "%password#" + ownershipPassword }), null, null), 3);
|
||||
}
|
||||
} else {
|
||||
nInv.addItem(nInv.createItem(Materials.LEGACY_EMPTY_MAP.getPostItem(), configLoad.getString("Menu.Ownership.Item.Password.Displayname"), configLoad.getStringList("Menu.Ownership.Item.Password.Unset.Lore"), null, null, null), 3);
|
||||
}
|
||||
|
||||
nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Ownership.Title")));
|
||||
nInv.setType(InventoryType.HOPPER);
|
||||
nInv.open();
|
||||
}
|
||||
|
||||
Config languageConfig = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = languageConfig.getFileConfiguration();
|
||||
|
||||
InventoryUtil inv = new InventoryUtil(configLoad.getString("Menu.Ownership.Title"), InventoryType.HOPPER, 0);
|
||||
inv.addItem(inv.createItem(SkullUtil.create(playerTexture[0], playerTexture[1]), configLoad.getString("Menu.Ownership.Item.Original.Displayname"), configLoad.getStringList("Menu.Ownership.Item.Original.Lore"), inv.createItemLoreVariable(new String[] { "%player#" + originalOwnerName }), null, null), 0);
|
||||
inv.addItem(inv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(), configLoad.getString("Menu.Ownership.Item.Barrier.Displayname"), null, null, null, null), 1);
|
||||
inv.addItem(inv.createItem(Materials.WRITABLE_BOOK.parseItem(), configLoad.getString("Menu.Ownership.Item.Assign.Displayname"), configLoad.getStringList("Menu.Ownership.Item.Assign.Lore"), null, null, null), 2);
|
||||
|
||||
if (island.hasPassword()) {
|
||||
if (playerDataManager.getPlayerData(player).getType() == Ownership.Visibility.Hidden) {
|
||||
inv.addItem(inv.createItem(Materials.LEGACY_EMPTY_MAP.getPostItem(), configLoad.getString("Menu.Ownership.Item.Password.Displayname"), configLoad.getStringList("Menu.Ownership.Item.Password.Hidden.Lore"), null, null, null), 3);
|
||||
} else {
|
||||
inv.addItem(inv.createItem(Materials.LEGACY_EMPTY_MAP.getPostItem(), configLoad.getString("Menu.Ownership.Item.Password.Displayname"), configLoad.getStringList("Menu.Ownership.Item.Password.Visible.Lore"), inv.createItemLoreVariable(new String[] { "%password#" + ownershipPassword }), null, null), 3);
|
||||
}
|
||||
} else {
|
||||
inv.addItem(inv.createItem(Materials.LEGACY_EMPTY_MAP.getPostItem(), configLoad.getString("Menu.Ownership.Item.Password.Displayname"), configLoad.getStringList("Menu.Ownership.Item.Password.Unset.Lore"), null, null, null), 3);
|
||||
}
|
||||
|
||||
player.openInventory(inv.getInventory());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
ItemStack is = event.getCurrentItem();
|
||||
|
||||
if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR) {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Ownership.Title")))) {
|
||||
event.setCancelled(true);
|
||||
|
||||
Island island = null;
|
||||
|
||||
if (islandManager.hasIsland(player)) {
|
||||
island = islandManager.getIsland(playerDataManager.getPlayerData(player).getOwner());
|
||||
|
||||
if (!island.isRole(Role.Owner, player.getUniqueId())) {
|
||||
messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Ownership.Role.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Ownership.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player);
|
||||
|
||||
if (playerData.getType() == null) {
|
||||
playerData.setType(Ownership.Visibility.Hidden);
|
||||
}
|
||||
|
||||
if ((event.getCurrentItem().getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Ownership.Item.Original.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == Materials.BLACK_STAINED_GLASS_PANE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Ownership.Item.Barrier.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.GLASS.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == Materials.WRITABLE_BOOK.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Ownership.Item.Assign.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
AnvilGUI gui = new AnvilGUI(player, new AnvilGUI.AnvilClickEventHandler() {
|
||||
@Override
|
||||
public void onAnvilClick(final AnvilGUI.AnvilClickEvent event) {
|
||||
if (event.getSlot() == AnvilGUI.AnvilSlot.OUTPUT) {
|
||||
Island island;
|
||||
|
||||
player.closeInventory();
|
||||
|
||||
if (islandManager.hasIsland(player)) {
|
||||
island = islandManager.getIsland(playerDataManager.getPlayerData(player).getOwner());
|
||||
|
||||
if (!island.isRole(Role.Owner, player.getUniqueId())) {
|
||||
messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Ownership.Role.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Ownership.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.getServer().dispatchCommand(player, "island ownership " + event.getName());
|
||||
|
||||
event.setWillClose(true);
|
||||
event.setWillDestroy(true);
|
||||
} else {
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
is = new ItemStack(Material.NAME_TAG);
|
||||
ItemMeta im = is.getItemMeta();
|
||||
im.setDisplayName(configLoad.getString("Menu.Ownership.Item.Assign.Word.Enter"));
|
||||
is.setItemMeta(im);
|
||||
|
||||
gui.setSlot(AnvilGUI.AnvilSlot.INPUT_LEFT, is);
|
||||
gui.open();
|
||||
} else if ((event.getCurrentItem().getType() == Materials.LEGACY_EMPTY_MAP.getPostMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Ownership.Item.Password.Displayname"))))) {
|
||||
if (island.hasPassword()) {
|
||||
if (event.getClick() == ClickType.MIDDLE) {
|
||||
Ownership.Visibility visibility = (Ownership.Visibility) playerData.getType();
|
||||
|
||||
if (visibility == Ownership.Visibility.Hidden) {
|
||||
playerData.setType(Ownership.Visibility.Visible);
|
||||
} else {
|
||||
playerData.setType(Ownership.Visibility.Hidden);
|
||||
}
|
||||
|
||||
open(player);
|
||||
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
|
||||
return;
|
||||
} else if (event.getClick() == ClickType.RIGHT) {
|
||||
island.setPassword(null);
|
||||
open(player);
|
||||
soundManager.playSound(player, Sounds.EXPLODE.bukkitSound(), 1.0F, 1.0F);
|
||||
return;
|
||||
} else if (event.getClick() != ClickType.LEFT) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
AnvilGUI gui = new AnvilGUI(player, new AnvilGUI.AnvilClickEventHandler() {
|
||||
@Override
|
||||
public void onAnvilClick(final AnvilGUI.AnvilClickEvent event) {
|
||||
if (event.getSlot() == AnvilGUI.AnvilSlot.OUTPUT) {
|
||||
Island island;
|
||||
|
||||
if (islandManager.hasIsland(player)) {
|
||||
island = islandManager.getIsland(playerDataManager.getPlayerData(player).getOwner());
|
||||
|
||||
if (!island.isRole(Role.Owner, player.getUniqueId())) {
|
||||
messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Ownership.Role.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Ownership.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
island.setPassword(event.getName().replace("&", "").replace(" ", ""));
|
||||
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
open(player);
|
||||
soundManager.playSound(player, Sounds.ANVIL_USE.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
}.runTaskLater(skyblock, 3L);
|
||||
|
||||
event.setWillClose(true);
|
||||
event.setWillDestroy(true);
|
||||
} else {
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
is = new ItemStack(Material.NAME_TAG);
|
||||
ItemMeta im = is.getItemMeta();
|
||||
im.setDisplayName(configLoad.getString("Menu.Ownership.Item.Password.Hidden.Word.Enter"));
|
||||
is.setItemMeta(im);
|
||||
|
||||
gui.setSlot(AnvilGUI.AnvilSlot.INPUT_LEFT, is);
|
||||
gui.open();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum Visibility {
|
||||
|
||||
Visible,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -14,10 +14,7 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.goodandevil.skyblock.SkyBlock;
|
||||
@ -34,14 +31,16 @@ import me.goodandevil.skyblock.sound.SoundManager;
|
||||
import me.goodandevil.skyblock.utils.NumberUtil;
|
||||
import me.goodandevil.skyblock.utils.OfflinePlayer;
|
||||
import me.goodandevil.skyblock.utils.StringUtil;
|
||||
import me.goodandevil.skyblock.utils.item.InventoryUtil;
|
||||
import me.goodandevil.skyblock.utils.item.SkullUtil;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEvent;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEventHandler;
|
||||
import me.goodandevil.skyblock.utils.version.Materials;
|
||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||
import me.goodandevil.skyblock.utils.world.LocationUtil;
|
||||
import me.goodandevil.skyblock.visit.VisitManager;
|
||||
|
||||
public class Visit implements Listener {
|
||||
public class Visit {
|
||||
|
||||
private static Visit instance;
|
||||
|
||||
@ -57,10 +56,182 @@ public class Visit implements Listener {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
VisitManager visitManager = skyblock.getVisitManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
FileConfiguration configLoad = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration();
|
||||
|
||||
nInventoryUtil nInv = new nInventoryUtil(player, new ClickEventHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
|
||||
if (playerData.getType() == null || playerData.getSort() == null) {
|
||||
playerData.setType(Visit.Type.Default);
|
||||
playerData.setSort(Visit.Sort.Default);
|
||||
}
|
||||
|
||||
ItemStack is = event.getItem();
|
||||
|
||||
if ((is.getType() == Materials.BLACK_STAINED_GLASS_PANE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visit.Item.Barrier.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.GLASS.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == Materials.OAK_FENCE_GATE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visit.Item.Exit.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((is.getType() == Material.PAINTING) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visit.Item.Statistics.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == Material.HOPPER) && (is.hasItemMeta())) {
|
||||
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visit.Item.Type.Displayname")))) {
|
||||
Visit.Type type = (Visit.Type) playerData.getType();
|
||||
|
||||
if (type.ordinal()+1 == Visit.Type.values().length) {
|
||||
playerData.setType(Visit.Type.Default);
|
||||
} else {
|
||||
playerData.setType(Visit.Type.values()[type.ordinal() + 1]);
|
||||
}
|
||||
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visit.Item.Sort.Displayname")))) {
|
||||
Visit.Sort sort = (Visit.Sort) playerData.getSort();
|
||||
|
||||
if (sort.ordinal()+1 == Visit.Sort.values().length) {
|
||||
playerData.setSort(Visit.Sort.Default);
|
||||
} else {
|
||||
playerData.setSort(Visit.Sort.values()[sort.ordinal() + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player, (Visit.Type) playerData.getType(), (Visit.Sort) playerData.getSort());
|
||||
}
|
||||
}, 1L);
|
||||
} else if ((is.getType() == Material.BARRIER) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visit.Item.Nothing.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
|
||||
VisitManager visitManager = skyblock.getVisitManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
|
||||
String targetPlayerName = ChatColor.stripColor(is.getItemMeta().getDisplayName());
|
||||
UUID targetPlayerUUID;
|
||||
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(targetPlayerName);
|
||||
|
||||
if (targetPlayer == null) {
|
||||
targetPlayerUUID = new OfflinePlayer(targetPlayerName).getUniqueId();
|
||||
} else {
|
||||
targetPlayerUUID = targetPlayer.getUniqueId();
|
||||
}
|
||||
|
||||
if (visitManager.hasIsland(targetPlayerUUID)) {
|
||||
me.goodandevil.skyblock.visit.Visit visit = visitManager.getIsland(targetPlayerUUID);
|
||||
|
||||
if (visit.isOpen()) {
|
||||
if (!islandManager.containsIsland(targetPlayerUUID)) {
|
||||
islandManager.loadIsland(targetPlayerUUID);
|
||||
}
|
||||
|
||||
Island island = islandManager.getIsland(targetPlayerUUID);
|
||||
|
||||
if ((!island.isRole(Role.Member, player.getUniqueId()) && !island.isRole(Role.Operator, player.getUniqueId()) && !island.isRole(Role.Owner, player.getUniqueId())) && fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Vote")) {
|
||||
if (event.getClick() == ClickType.RIGHT) {
|
||||
if (playerData.getIsland() != null && playerData.getIsland().equals(island.getOwnerUUID())) {
|
||||
List<UUID> islandVotes = visit.getVoters();
|
||||
|
||||
if (islandVotes.contains(player.getUniqueId())) {
|
||||
visit.removeVoter(player.getUniqueId());
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Visit.Vote.Removed.Message").replace("%player", targetPlayerName));
|
||||
soundManager.playSound(player, Sounds.EXPLODE.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
visit.addVoter(player.getUniqueId());
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Visit.Vote.Added.Message").replace("%player", targetPlayerName));
|
||||
soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player, (Visit.Type) playerData.getType(), (Visit.Sort) playerData.getSort());
|
||||
}
|
||||
}, 1L);
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Visit.Vote.Island.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
}
|
||||
|
||||
islandManager.unloadIsland(targetPlayerUUID);
|
||||
|
||||
return;
|
||||
} else if (event.getClick() != ClickType.LEFT) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (Location.World worldList : Location.World.values()) {
|
||||
if (LocationUtil.isLocationAtLocationRadius(player.getLocation(), island.getLocation(worldList, Location.Environment.Island), island.getRadius())) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Visit.Already.Message").replace("%player", targetPlayerName));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
islandManager.visitIsland(player, island);
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Visit.Teleported.Message").replace("%player", targetPlayerName));
|
||||
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Visit.Closed.Menu.Message").replace("%player", targetPlayerName));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player, (Visit.Type) playerData.getType(), (Visit.Sort) playerData.getSort());
|
||||
}
|
||||
}, 1L);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Visit.Exist.Message").replace("%player", targetPlayerName));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player, (Visit.Type) playerData.getType(), (Visit.Sort) playerData.getSort());
|
||||
}
|
||||
}, 1L);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Map<UUID, me.goodandevil.skyblock.visit.Visit> displayedIslands = new HashMap<>();
|
||||
Map<UUID, me.goodandevil.skyblock.visit.Visit> visitIslands = visitManager.getOpenIslands();
|
||||
|
||||
@ -121,26 +292,22 @@ public class Visit implements Listener {
|
||||
|
||||
int playerMenuPage = playerDataManager.getPlayerData(player).getPage(), nextEndIndex = displayedIslands.size() - playerMenuPage * 36, totalIslands = visitManager.getIslands().size();
|
||||
|
||||
Config languageConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = languageConfig.getFileConfiguration();
|
||||
|
||||
InventoryUtil inv = new InventoryUtil(configLoad.getString("Menu.Visit.Title"), null, 6);
|
||||
inv.addItem(inv.createItem(Materials.OAK_FENCE_GATE.parseItem(), configLoad.getString("Menu.Visit.Item.Exit.Displayname"), null, null, null, null), 0, 8);
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.HOPPER), configLoad.getString("Menu.Visit.Item.Type.Displayname"), configLoad.getStringList("Menu.Visit.Item.Type.Lore"), inv.createItemLoreVariable(new String[] { "%type#" + StringUtil.capatilizeUppercaseLetters(type.name()) }), null, null), 3);
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.PAINTING), configLoad.getString("Menu.Visit.Item.Statistics.Displayname"), configLoad.getStringList("Menu.Visit.Item.Statistics.Lore"), inv.createItemLoreVariable(new String[] { "%islands_open#" + NumberUtil.formatNumber(visitIslands.size()), "%islands_closed#" + NumberUtil.formatNumber(totalIslands - visitIslands.size()), "%islands#" + NumberUtil.formatNumber(totalIslands) }), null, null), 4);
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.HOPPER), configLoad.getString("Menu.Visit.Item.Sort.Displayname"), configLoad.getStringList("Menu.Visit.Item.Sort.Lore"), inv.createItemLoreVariable(new String[] { "%sort#" + StringUtil.capatilizeUppercaseLetters(sort.name()) }), null, null), 5);
|
||||
inv.addItem(inv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(), configLoad.getString("Menu.Visit.Item.Barrier.Displayname"), null, null, null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
nInv.addItem(nInv.createItem(Materials.OAK_FENCE_GATE.parseItem(), configLoad.getString("Menu.Visit.Item.Exit.Displayname"), null, null, null, null), 0, 8);
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.HOPPER), configLoad.getString("Menu.Visit.Item.Type.Displayname"), configLoad.getStringList("Menu.Visit.Item.Type.Lore"), nInv.createItemLoreVariable(new String[] { "%type#" + StringUtil.capatilizeUppercaseLetters(type.name()) }), null, null), 3);
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING), configLoad.getString("Menu.Visit.Item.Statistics.Displayname"), configLoad.getStringList("Menu.Visit.Item.Statistics.Lore"), nInv.createItemLoreVariable(new String[] { "%islands_open#" + NumberUtil.formatNumber(visitIslands.size()), "%islands_closed#" + NumberUtil.formatNumber(totalIslands - visitIslands.size()), "%islands#" + NumberUtil.formatNumber(totalIslands) }), null, null), 4);
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.HOPPER), configLoad.getString("Menu.Visit.Item.Sort.Displayname"), configLoad.getStringList("Menu.Visit.Item.Sort.Lore"), nInv.createItemLoreVariable(new String[] { "%sort#" + StringUtil.capatilizeUppercaseLetters(sort.name()) }), null, null), 5);
|
||||
nInv.addItem(nInv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(), configLoad.getString("Menu.Visit.Item.Barrier.Displayname"), null, null, null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
|
||||
if (playerMenuPage != 1) {
|
||||
inv.addItem(inv.createItem(SkullUtil.create("ToR1w9ZV7zpzCiLBhoaJH3uixs5mAlMhNz42oaRRvrG4HRua5hC6oyyOPfn2HKdSseYA9b1be14fjNRQbSJRvXF3mlvt5/zct4sm+cPVmX8K5kbM2vfwHJgCnfjtPkzT8sqqg6YFdT35mAZGqb9/xY/wDSNSu/S3k2WgmHrJKirszaBZrZfnVnqITUOgM9TmixhcJn2obeqICv6tl7/Wyk/1W62wXlXGm9+WjS+8rRNB+vYxqKR3XmH2lhAiyVGbADsjjGtBVUTWjq+aPw670SjXkoii0YE8sqzUlMMGEkXdXl9fvGtnWKk3APSseuTsjedr7yq+AkXFVDqqkqcUuXwmZl2EjC2WRRbhmYdbtY5nEfqh5+MiBrGdR/JqdEUL4yRutyRTw8mSUAI6X2oSVge7EdM/8f4HwLf33EO4pTocTqAkNbpt6Z54asLe5Y12jSXbvd2dFsgeJbrslK7e4uy/TK8CXf0BP3KLU20QELYrjz9I70gtj9lJ9xwjdx4/xJtxDtrxfC4Afmpu+GNYA/mifpyP3GDeBB5CqN7btIvEWyVvRNH7ppAqZIPqYJ7dSDd2RFuhAId5Yq98GUTBn+eRzeigBvSi1bFkkEgldfghOoK5WhsQtQbXuBBXITMME3NaWCN6zG7DxspS6ew/rZ8E809Xe0ArllquIZ0sP+k=", "eyJ0aW1lc3RhbXAiOjE0OTU3NTE5MTYwNjksInByb2ZpbGVJZCI6ImE2OGYwYjY0OGQxNDQwMDBhOTVmNGI5YmExNGY4ZGY5IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dMZWZ0Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zZWJmOTA3NDk0YTkzNWU5NTViZmNhZGFiODFiZWFmYjkwZmI5YmU0OWM3MDI2YmE5N2Q3OThkNWYxYTIzIn19fQ=="), configLoad.getString("Menu.Visit.Item.Previous.Displayname"), null, null, null, null), 1);
|
||||
nInv.addItem(nInv.createItem(SkullUtil.create("ToR1w9ZV7zpzCiLBhoaJH3uixs5mAlMhNz42oaRRvrG4HRua5hC6oyyOPfn2HKdSseYA9b1be14fjNRQbSJRvXF3mlvt5/zct4sm+cPVmX8K5kbM2vfwHJgCnfjtPkzT8sqqg6YFdT35mAZGqb9/xY/wDSNSu/S3k2WgmHrJKirszaBZrZfnVnqITUOgM9TmixhcJn2obeqICv6tl7/Wyk/1W62wXlXGm9+WjS+8rRNB+vYxqKR3XmH2lhAiyVGbADsjjGtBVUTWjq+aPw670SjXkoii0YE8sqzUlMMGEkXdXl9fvGtnWKk3APSseuTsjedr7yq+AkXFVDqqkqcUuXwmZl2EjC2WRRbhmYdbtY5nEfqh5+MiBrGdR/JqdEUL4yRutyRTw8mSUAI6X2oSVge7EdM/8f4HwLf33EO4pTocTqAkNbpt6Z54asLe5Y12jSXbvd2dFsgeJbrslK7e4uy/TK8CXf0BP3KLU20QELYrjz9I70gtj9lJ9xwjdx4/xJtxDtrxfC4Afmpu+GNYA/mifpyP3GDeBB5CqN7btIvEWyVvRNH7ppAqZIPqYJ7dSDd2RFuhAId5Yq98GUTBn+eRzeigBvSi1bFkkEgldfghOoK5WhsQtQbXuBBXITMME3NaWCN6zG7DxspS6ew/rZ8E809Xe0ArllquIZ0sP+k=", "eyJ0aW1lc3RhbXAiOjE0OTU3NTE5MTYwNjksInByb2ZpbGVJZCI6ImE2OGYwYjY0OGQxNDQwMDBhOTVmNGI5YmExNGY4ZGY5IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dMZWZ0Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zZWJmOTA3NDk0YTkzNWU5NTViZmNhZGFiODFiZWFmYjkwZmI5YmU0OWM3MDI2YmE5N2Q3OThkNWYxYTIzIn19fQ=="), configLoad.getString("Menu.Visit.Item.Previous.Displayname"), null, null, null, null), 1);
|
||||
}
|
||||
|
||||
if (!(nextEndIndex == 0 || nextEndIndex < 0)) {
|
||||
inv.addItem(inv.createItem(SkullUtil.create("wZPrsmxckJn4/ybw/iXoMWgAe+1titw3hjhmf7bfg9vtOl0f/J6YLNMOI0OTvqeRKzSQVCxqNOij6k2iM32ZRInCQyblDIFmFadQxryEJDJJPVs7rXR6LRXlN8ON2VDGtboRTL7LwMGpzsrdPNt0oYDJLpR0huEeZKc1+g4W13Y4YM5FUgEs8HvMcg4aaGokSbvrYRRcEh3LR1lVmgxtbiUIr2gZkR3jnwdmZaIw/Ujw28+Et2pDMVCf96E5vC0aNY0KHTdMYheT6hwgw0VAZS2VnJg+Gz4JCl4eQmN2fs4dUBELIW2Rdnp4U1Eb+ZL8DvTV7ofBeZupknqPOyoKIjpInDml9BB2/EkD3zxFtW6AWocRphn03Z203navBkR6ztCMz0BgbmQU/m8VL/s8o4cxOn+2ppjrlj0p8AQxEsBdHozrBi8kNOGf1j97SDHxnvVAF3X8XDso+MthRx5pbEqpxmLyKKgFh25pJE7UaMSnzH2lc7aAZiax67MFw55pDtgfpl+Nlum4r7CK2w5Xob2QTCovVhu78/6SV7qM2Lhlwx/Sjqcl8rn5UIoyM49QE5Iyf1tk+xHXkIvY0m7q358oXsfca4eKmxMe6DFRjUDo1VuWxdg9iVjn22flqz1LD1FhGlPoqv0k4jX5Q733LwtPPI6VOTK+QzqrmiuR6e8=", "eyJ0aW1lc3RhbXAiOjE0OTM4NjgxMDA2NzMsInByb2ZpbGVJZCI6IjUwYzg1MTBiNWVhMDRkNjBiZTlhN2Q1NDJkNmNkMTU2IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dSaWdodCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ=="), configLoad.getString("Menu.Visit.Item.Next.Displayname"), null, null, null, null), 7);
|
||||
nInv.addItem(nInv.createItem(SkullUtil.create("wZPrsmxckJn4/ybw/iXoMWgAe+1titw3hjhmf7bfg9vtOl0f/J6YLNMOI0OTvqeRKzSQVCxqNOij6k2iM32ZRInCQyblDIFmFadQxryEJDJJPVs7rXR6LRXlN8ON2VDGtboRTL7LwMGpzsrdPNt0oYDJLpR0huEeZKc1+g4W13Y4YM5FUgEs8HvMcg4aaGokSbvrYRRcEh3LR1lVmgxtbiUIr2gZkR3jnwdmZaIw/Ujw28+Et2pDMVCf96E5vC0aNY0KHTdMYheT6hwgw0VAZS2VnJg+Gz4JCl4eQmN2fs4dUBELIW2Rdnp4U1Eb+ZL8DvTV7ofBeZupknqPOyoKIjpInDml9BB2/EkD3zxFtW6AWocRphn03Z203navBkR6ztCMz0BgbmQU/m8VL/s8o4cxOn+2ppjrlj0p8AQxEsBdHozrBi8kNOGf1j97SDHxnvVAF3X8XDso+MthRx5pbEqpxmLyKKgFh25pJE7UaMSnzH2lc7aAZiax67MFw55pDtgfpl+Nlum4r7CK2w5Xob2QTCovVhu78/6SV7qM2Lhlwx/Sjqcl8rn5UIoyM49QE5Iyf1tk+xHXkIvY0m7q358oXsfca4eKmxMe6DFRjUDo1VuWxdg9iVjn22flqz1LD1FhGlPoqv0k4jX5Q733LwtPPI6VOTK+QzqrmiuR6e8=", "eyJ0aW1lc3RhbXAiOjE0OTM4NjgxMDA2NzMsInByb2ZpbGVJZCI6IjUwYzg1MTBiNWVhMDRkNjBiZTlhN2Q1NDJkNmNkMTU2IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dSaWdodCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ=="), configLoad.getString("Menu.Visit.Item.Next.Displayname"), null, null, null, null), 7);
|
||||
}
|
||||
|
||||
if (displayedIslands.size() == 0) {
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.BARRIER), configLoad.getString("Menu.Visit.Item.Nothing.Displayname"), null, null, null, null), 31);
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.BARRIER), configLoad.getString("Menu.Visit.Item.Nothing.Displayname"), null, null, null, null), 31);
|
||||
} else {
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
|
||||
@ -170,12 +337,10 @@ public class Visit implements Listener {
|
||||
targetPlayerTexture = playerDataManager.getPlayerData(targetPlayer).getTexture();
|
||||
}
|
||||
|
||||
int playersAtIsland = 0;
|
||||
Island island = null;
|
||||
|
||||
if (islandManager.containsIsland(targetPlayerUUID)) {
|
||||
island = islandManager.getIsland(targetPlayerUUID);
|
||||
playersAtIsland = islandManager.getPlayersAtIsland(island).size();
|
||||
}
|
||||
|
||||
List<String> itemLore = new ArrayList<>();
|
||||
@ -205,7 +370,7 @@ public class Visit implements Listener {
|
||||
if (islandSignature.size() == 0) {
|
||||
itemLore.add(configLoad.getString("Menu.Visit.Item.Island.Vote.Word.Empty"));
|
||||
} else {
|
||||
for (String signatureList : visit.getSiganture()) {
|
||||
for (String signatureList : islandSignature) {
|
||||
itemLore.add(signatureList);
|
||||
}
|
||||
}
|
||||
@ -221,7 +386,7 @@ public class Visit implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
inv.addItem(inv.createItem(SkullUtil.create(targetPlayerTexture[0], targetPlayerTexture[1]), configLoad.getString("Menu.Visit.Item.Island.Displayname").replace("%player", targetPlayerName), itemLore, inv.createItemLoreVariable(new String[] { "%level#" + visit.getLevel().getLevel(), "%members#" + visit.getMembers(), "%votes#" + visit.getVoters().size(), "%visits#" + visit.getVisitors().size(), "%players#" + playersAtIsland, "%player_capacity#" + playerCapacity, "%action#" + voteAction }), null, null), inventorySlot);
|
||||
nInv.addItem(nInv.createItem(SkullUtil.create(targetPlayerTexture[0], targetPlayerTexture[1]), configLoad.getString("Menu.Visit.Item.Island.Displayname").replace("%player", targetPlayerName), itemLore, nInv.createItemLoreVariable(new String[] { "%level#" + visit.getLevel().getLevel(), "%members#" + visit.getMembers(), "%votes#" + visit.getVoters().size(), "%visits#" + visit.getVisitors().size(), "%players#" + islandManager.getPlayersAtIsland(island).size(), "%player_capacity#" + playerCapacity, "%action#" + voteAction }), null, null), inventorySlot);
|
||||
} else {
|
||||
if (signatureEnabled) {
|
||||
for (String itemLoreList : configLoad.getStringList("Menu.Visit.Item.Island.Vote.Disabled.Signature.Enabled.Lore")) {
|
||||
@ -231,7 +396,7 @@ public class Visit implements Listener {
|
||||
if (islandSignature.size() == 0) {
|
||||
itemLore.add(configLoad.getString("Menu.Visit.Item.Island.Vote.Word.Empty"));
|
||||
} else {
|
||||
for (String signatureList : visit.getSiganture()) {
|
||||
for (String signatureList : islandSignature) {
|
||||
itemLore.add(signatureList);
|
||||
}
|
||||
}
|
||||
@ -243,156 +408,15 @@ public class Visit implements Listener {
|
||||
itemLore.addAll(configLoad.getStringList("Menu.Visit.Item.Island.Vote.Disabled.Signature.Disabled.Lore"));
|
||||
}
|
||||
|
||||
inv.addItem(inv.createItem(SkullUtil.create(targetPlayerTexture[0], targetPlayerTexture[1]), configLoad.getString("Menu.Visit.Item.Island.Displayname").replace("%player", targetPlayerName), itemLore, inv.createItemLoreVariable(new String[] { "%level#" + visit.getLevel().getLevel(), "%members#" + visit.getMembers(), "%visits#" + visit.getVisitors().size(), "%players#" + playersAtIsland, "%player_capacity#" + playerCapacity }), null, null), inventorySlot);
|
||||
nInv.addItem(nInv.createItem(SkullUtil.create(targetPlayerTexture[0], targetPlayerTexture[1]), configLoad.getString("Menu.Visit.Item.Island.Displayname").replace("%player", targetPlayerName), itemLore, nInv.createItemLoreVariable(new String[] { "%level#" + visit.getLevel().getLevel(), "%members#" + visit.getMembers(), "%visits#" + visit.getVisitors().size(), "%players#" + islandManager.getPlayersAtIsland(island).size(), "%player_capacity#" + playerCapacity }), null, null), inventorySlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
player.openInventory(inv.getInventory());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
ItemStack is = event.getCurrentItem();
|
||||
|
||||
if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR) {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config languageConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = languageConfig.getFileConfiguration();
|
||||
|
||||
if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visit.Title")))) {
|
||||
event.setCancelled(true);
|
||||
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
|
||||
if (playerData.getType() == null || playerData.getSort() == null) {
|
||||
playerData.setType(Visit.Type.Default);
|
||||
playerData.setSort(Visit.Sort.Default);
|
||||
}
|
||||
|
||||
if ((event.getCurrentItem().getType() == Materials.BLACK_STAINED_GLASS_PANE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visit.Item.Barrier.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.GLASS.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == Materials.OAK_FENCE_GATE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visit.Item.Exit.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
} else if ((event.getCurrentItem().getType() == Material.PAINTING) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visit.Item.Statistics.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == Material.HOPPER) && (is.hasItemMeta())) {
|
||||
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visit.Item.Type.Displayname")))) {
|
||||
Visit.Type type = (Visit.Type) playerData.getType();
|
||||
|
||||
if (type.ordinal()+1 == Visit.Type.values().length) {
|
||||
playerData.setType(Visit.Type.Default);
|
||||
} else {
|
||||
playerData.setType(Visit.Type.values()[type.ordinal() + 1]);
|
||||
}
|
||||
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visit.Item.Sort.Displayname")))) {
|
||||
Visit.Sort sort = (Visit.Sort) playerData.getSort();
|
||||
|
||||
if (sort.ordinal()+1 == Visit.Sort.values().length) {
|
||||
playerData.setSort(Visit.Sort.Default);
|
||||
} else {
|
||||
playerData.setSort(Visit.Sort.values()[sort.ordinal() + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
open(player, (Visit.Type) playerData.getType(), (Visit.Sort) playerData.getSort());
|
||||
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == Material.BARRIER) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visit.Item.Nothing.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
|
||||
VisitManager visitManager = skyblock.getVisitManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
|
||||
String targetPlayerName = ChatColor.stripColor(is.getItemMeta().getDisplayName());
|
||||
UUID targetPlayerUUID;
|
||||
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(targetPlayerName);
|
||||
|
||||
if (targetPlayer == null) {
|
||||
targetPlayerUUID = new OfflinePlayer(targetPlayerName).getUniqueId();
|
||||
} else {
|
||||
targetPlayerUUID = targetPlayer.getUniqueId();
|
||||
}
|
||||
|
||||
if (visitManager.hasIsland(targetPlayerUUID)) {
|
||||
me.goodandevil.skyblock.visit.Visit visit = visitManager.getIsland(targetPlayerUUID);
|
||||
|
||||
if (visit.isOpen()) {
|
||||
if (!islandManager.containsIsland(targetPlayerUUID)) {
|
||||
islandManager.loadIsland(targetPlayerUUID);
|
||||
}
|
||||
|
||||
Island island = islandManager.getIsland(targetPlayerUUID);
|
||||
|
||||
if ((!island.isRole(Role.Member, player.getUniqueId()) && !island.isRole(Role.Operator, player.getUniqueId()) && !island.isRole(Role.Owner, player.getUniqueId())) && fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Vote")) {
|
||||
if (event.getClick() == ClickType.RIGHT) {
|
||||
if (playerData.getIsland() != null && playerData.getIsland().equals(island.getOwnerUUID())) {
|
||||
List<UUID> islandVotes = visit.getVoters();
|
||||
|
||||
if (islandVotes.contains(player.getUniqueId())) {
|
||||
visit.removeVoter(player.getUniqueId());
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Visit.Vote.Removed.Message").replace("%player", targetPlayerName));
|
||||
soundManager.playSound(player, Sounds.EXPLODE.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
visit.addVoter(player.getUniqueId());
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Visit.Vote.Added.Message").replace("%player", targetPlayerName));
|
||||
soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
open(player, (Visit.Type) playerData.getType(), (Visit.Sort) playerData.getSort());
|
||||
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Visit.Vote.Island.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
islandManager.unloadIsland(targetPlayerUUID);
|
||||
|
||||
return;
|
||||
} else if (event.getClick() != ClickType.LEFT) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (Location.World worldList : Location.World.values()) {
|
||||
if (LocationUtil.isLocationAtLocationRadius(player.getLocation(), island.getLocation(worldList, Location.Environment.Island), island.getRadius())) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Visit.Already.Message").replace("%player", targetPlayerName));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
islandManager.visitIsland(player, island);
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Visit.Teleported.Message").replace("%player", targetPlayerName));
|
||||
soundManager.playSound(player, Sounds.ENDERMAN_TELEPORT.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Visit.Closed.Menu.Message").replace("%player", targetPlayerName));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
open(player, (Visit.Type) playerData.getType(), (Visit.Sort) playerData.getSort());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Island.Visit.Exist.Message").replace("%player", targetPlayerName));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
open(player, (Visit.Type) playerData.getType(), (Visit.Sort) playerData.getSort());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visit.Title")));
|
||||
nInv.setRows(6);
|
||||
nInv.open();
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
|
@ -12,16 +12,11 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import me.goodandevil.skyblock.SkyBlock;
|
||||
import me.goodandevil.skyblock.config.FileManager;
|
||||
import me.goodandevil.skyblock.config.FileManager.Config;
|
||||
import me.goodandevil.skyblock.island.Island;
|
||||
import me.goodandevil.skyblock.island.IslandManager;
|
||||
import me.goodandevil.skyblock.island.Role;
|
||||
@ -30,12 +25,14 @@ import me.goodandevil.skyblock.playerdata.PlayerData;
|
||||
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
|
||||
import me.goodandevil.skyblock.sound.SoundManager;
|
||||
import me.goodandevil.skyblock.utils.NumberUtil;
|
||||
import me.goodandevil.skyblock.utils.item.InventoryUtil;
|
||||
import me.goodandevil.skyblock.utils.item.SkullUtil;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEvent;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEventHandler;
|
||||
import me.goodandevil.skyblock.utils.version.Materials;
|
||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||
|
||||
public class Visitors implements Listener {
|
||||
public class Visitors {
|
||||
|
||||
private static Visitors instance;
|
||||
|
||||
@ -51,184 +48,197 @@ public class Visitors implements Listener {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
|
||||
Island island = skyblock.getIslandManager().getIsland(playerData.getOwner());
|
||||
|
||||
Config languageConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = languageConfig.getFileConfiguration();
|
||||
|
||||
Map<Integer, UUID> sortedIslandVisitors = new TreeMap<>();
|
||||
List<UUID> islandVisitors = island.getVisitors();
|
||||
|
||||
InventoryUtil inv = new InventoryUtil(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visitors.Title")), null, 6);
|
||||
inv.addItem(inv.createItem(Materials.OAK_FENCE_GATE.parseItem(), configLoad.getString("Menu.Visitors.Item.Exit.Displayname"), null, null, null, null), 0, 8);
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.PAINTING), configLoad.getString("Menu.Visitors.Item.Statistics.Displayname"), configLoad.getStringList("Menu.Visitors.Item.Statistics.Lore"), inv.createItemLoreVariable(new String[] { "%visitors#" + islandVisitors.size() }), null, null), 4);
|
||||
inv.addItem(inv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(), configLoad.getString("Menu.Visitors.Item.Barrier.Displayname"), null, null, null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
|
||||
for (UUID islandVisitorList : islandVisitors) {
|
||||
sortedIslandVisitors.put(playerDataManager.getPlayerData(Bukkit.getServer().getPlayer(islandVisitorList)).getVisitTime(), islandVisitorList);
|
||||
}
|
||||
|
||||
islandVisitors.clear();
|
||||
|
||||
for (int sortedIslandVisitorList : sortedIslandVisitors.keySet()) {
|
||||
islandVisitors.add(sortedIslandVisitors.get(sortedIslandVisitorList));
|
||||
}
|
||||
|
||||
int playerMenuPage = playerData.getPage(), nextEndIndex = sortedIslandVisitors.size() - playerMenuPage * 36;
|
||||
|
||||
if (playerMenuPage != 1) {
|
||||
inv.addItem(inv.createItem(SkullUtil.create("ToR1w9ZV7zpzCiLBhoaJH3uixs5mAlMhNz42oaRRvrG4HRua5hC6oyyOPfn2HKdSseYA9b1be14fjNRQbSJRvXF3mlvt5/zct4sm+cPVmX8K5kbM2vfwHJgCnfjtPkzT8sqqg6YFdT35mAZGqb9/xY/wDSNSu/S3k2WgmHrJKirszaBZrZfnVnqITUOgM9TmixhcJn2obeqICv6tl7/Wyk/1W62wXlXGm9+WjS+8rRNB+vYxqKR3XmH2lhAiyVGbADsjjGtBVUTWjq+aPw670SjXkoii0YE8sqzUlMMGEkXdXl9fvGtnWKk3APSseuTsjedr7yq+AkXFVDqqkqcUuXwmZl2EjC2WRRbhmYdbtY5nEfqh5+MiBrGdR/JqdEUL4yRutyRTw8mSUAI6X2oSVge7EdM/8f4HwLf33EO4pTocTqAkNbpt6Z54asLe5Y12jSXbvd2dFsgeJbrslK7e4uy/TK8CXf0BP3KLU20QELYrjz9I70gtj9lJ9xwjdx4/xJtxDtrxfC4Afmpu+GNYA/mifpyP3GDeBB5CqN7btIvEWyVvRNH7ppAqZIPqYJ7dSDd2RFuhAId5Yq98GUTBn+eRzeigBvSi1bFkkEgldfghOoK5WhsQtQbXuBBXITMME3NaWCN6zG7DxspS6ew/rZ8E809Xe0ArllquIZ0sP+k=", "eyJ0aW1lc3RhbXAiOjE0OTU3NTE5MTYwNjksInByb2ZpbGVJZCI6ImE2OGYwYjY0OGQxNDQwMDBhOTVmNGI5YmExNGY4ZGY5IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dMZWZ0Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zZWJmOTA3NDk0YTkzNWU5NTViZmNhZGFiODFiZWFmYjkwZmI5YmU0OWM3MDI2YmE5N2Q3OThkNWYxYTIzIn19fQ=="), configLoad.getString("Menu.Visitors.Item.Previous.Displayname"), null, null, null, null), 1);
|
||||
}
|
||||
|
||||
if (!(nextEndIndex == 0 || nextEndIndex < 0)) {
|
||||
inv.addItem(inv.createItem(SkullUtil.create("wZPrsmxckJn4/ybw/iXoMWgAe+1titw3hjhmf7bfg9vtOl0f/J6YLNMOI0OTvqeRKzSQVCxqNOij6k2iM32ZRInCQyblDIFmFadQxryEJDJJPVs7rXR6LRXlN8ON2VDGtboRTL7LwMGpzsrdPNt0oYDJLpR0huEeZKc1+g4W13Y4YM5FUgEs8HvMcg4aaGokSbvrYRRcEh3LR1lVmgxtbiUIr2gZkR3jnwdmZaIw/Ujw28+Et2pDMVCf96E5vC0aNY0KHTdMYheT6hwgw0VAZS2VnJg+Gz4JCl4eQmN2fs4dUBELIW2Rdnp4U1Eb+ZL8DvTV7ofBeZupknqPOyoKIjpInDml9BB2/EkD3zxFtW6AWocRphn03Z203navBkR6ztCMz0BgbmQU/m8VL/s8o4cxOn+2ppjrlj0p8AQxEsBdHozrBi8kNOGf1j97SDHxnvVAF3X8XDso+MthRx5pbEqpxmLyKKgFh25pJE7UaMSnzH2lc7aAZiax67MFw55pDtgfpl+Nlum4r7CK2w5Xob2QTCovVhu78/6SV7qM2Lhlwx/Sjqcl8rn5UIoyM49QE5Iyf1tk+xHXkIvY0m7q358oXsfca4eKmxMe6DFRjUDo1VuWxdg9iVjn22flqz1LD1FhGlPoqv0k4jX5Q733LwtPPI6VOTK+QzqrmiuR6e8=", "eyJ0aW1lc3RhbXAiOjE0OTM4NjgxMDA2NzMsInByb2ZpbGVJZCI6IjUwYzg1MTBiNWVhMDRkNjBiZTlhN2Q1NDJkNmNkMTU2IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dSaWdodCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ=="), configLoad.getString("Menu.Visitors.Item.Next.Displayname"), null, null, null, null), 7);
|
||||
}
|
||||
|
||||
if (islandVisitors.size() == 0) {
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.BARRIER), configLoad.getString("Menu.Visitors.Item.Nothing.Displayname"), null, null, null, null), 31);
|
||||
} else {
|
||||
boolean isOperator = island.isRole(Role.Operator, player.getUniqueId()), isOwner = island.isRole(Role.Owner, player.getUniqueId()), canKick = island.getSetting(Settings.Role.Operator, "Kick").getStatus(), canBan = island.getSetting(Settings.Role.Operator, "Ban").getStatus(), banningEnabled = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning");
|
||||
int index = playerMenuPage * 36 - 36, endIndex = index >= islandVisitors.size() ? islandVisitors.size() - 1 : index + 36, inventorySlot = 17;
|
||||
|
||||
for (; index < endIndex; index++) {
|
||||
if (islandVisitors.size() > index) {
|
||||
inventorySlot++;
|
||||
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(islandVisitors.get(index));
|
||||
PlayerData targetPlayerData = playerDataManager.getPlayerData(targetPlayer);
|
||||
|
||||
String[] targetPlayerTexture = targetPlayerData.getTexture();
|
||||
String islandVisitTimeFormatted;
|
||||
|
||||
long[] islandVisitTime = NumberUtil.getDuration(targetPlayerData.getVisitTime());
|
||||
|
||||
if (islandVisitTime[0] != 0) {
|
||||
islandVisitTimeFormatted = islandVisitTime[0] + " " + configLoad.getString("Menu.Visitors.Item.Visitor.Word.Days") + ", " + islandVisitTime[1] + " " + configLoad.getString("Menu.Visitors.Item.Visitor.Word.Hours") + ", " + islandVisitTime[2] + " " + configLoad.getString("Menu.Visitors.Item.Visitor.Word.Minutes") + ", " + islandVisitTime[3] + " " + configLoad.getString("Menu.Visitors.Item.Visitor.Word.Seconds");
|
||||
} else if (islandVisitTime[1] != 0) {
|
||||
islandVisitTimeFormatted = islandVisitTime[1] + " " + configLoad.getString("Menu.Visitors.Item.Visitor.Word.Hours") + ", " + islandVisitTime[2] + " " + configLoad.getString("Menu.Visitors.Item.Visitor.Word.Minutes") + ", " + islandVisitTime[3] + " " + configLoad.getString("Menu.Visitors.Item.Visitor.Word.Seconds");
|
||||
} else if (islandVisitTime[2] != 0) {
|
||||
islandVisitTimeFormatted = islandVisitTime[2] + " " + configLoad.getString("Menu.Visitors.Item.Visitor.Word.Minutes") + ", " + islandVisitTime[3] + " " + configLoad.getString("Menu.Visitors.Item.Visitor.Word.Seconds");
|
||||
} else {
|
||||
islandVisitTimeFormatted = islandVisitTime[3] + " " + configLoad.getString("Menu.Visitors.Item.Visitor.Word.Seconds");
|
||||
}
|
||||
|
||||
List<String> itemLore = new ArrayList<>();
|
||||
|
||||
if ((isOperator && canKick) || isOwner) {
|
||||
if (banningEnabled && ((isOperator && canBan) || isOwner)) {
|
||||
itemLore.addAll(configLoad.getStringList("Menu.Visitors.Item.Visitor.Kick.Permission.Ban.Permission.Lore"));
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
FileConfiguration configLoad = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration();
|
||||
|
||||
nInventoryUtil nInv = new nInventoryUtil(player, new ClickEventHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player);
|
||||
Island island = null;
|
||||
|
||||
if (islandManager.hasIsland(player)) {
|
||||
island = islandManager.getIsland(playerData.getOwner());
|
||||
} else {
|
||||
itemLore.addAll(configLoad.getStringList("Menu.Visitors.Item.Visitor.Kick.Permission.Ban.NoPermission.Lore"));
|
||||
}
|
||||
} else {
|
||||
if (banningEnabled && ((isOperator && canBan) || isOwner)) {
|
||||
itemLore.addAll(configLoad.getStringList("Menu.Visitors.Item.Visitor.Kick.NoPermission.Ban.Permission.Lore"));
|
||||
} else {
|
||||
itemLore.addAll(configLoad.getStringList("Menu.Visitors.Item.Visitor.Kick.NoPermission.Ban.NoPermission.Lore"));
|
||||
}
|
||||
}
|
||||
|
||||
inv.addItem(inv.createItem(SkullUtil.create(targetPlayerTexture[0], targetPlayerTexture[1]), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visitors.Item.Visitor.Displayname").replace("%player", targetPlayer.getName())), itemLore, inv.createItemLoreVariable(new String[] { "%time#" + islandVisitTimeFormatted }), null, null), inventorySlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
player.openInventory(inv.getInventory());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
ItemStack is = event.getCurrentItem();
|
||||
|
||||
if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR) {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visitors.Title")))) {
|
||||
event.setCancelled(true);
|
||||
|
||||
PlayerData playerData = skyblock.getPlayerDataManager().getPlayerData(player);
|
||||
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
|
||||
Island island = null;
|
||||
|
||||
if (islandManager.hasIsland(player)) {
|
||||
island = islandManager.getIsland(playerData.getOwner());
|
||||
} else {
|
||||
skyblock.getMessageManager().sendMessage(player, configLoad.getString("Command.Island.Visitors.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ((event.getCurrentItem().getType() == Materials.BLACK_STAINED_GLASS_PANE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visitors.Item.Barrier.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.GLASS.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == Materials.OAK_FENCE_GATE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visitors.Item.Exit.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
} else if ((event.getCurrentItem().getType() == Material.PAINTING) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visitors.Item.Statistics.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == Material.BARRIER) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visitors.Item.Nothing.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
|
||||
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visitors.Item.Previous.Displayname")))) {
|
||||
playerData.setPage(playerData.getPage() - 1);
|
||||
open(player);
|
||||
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visitors.Item.Next.Displayname")))) {
|
||||
playerData.setPage(playerData.getPage() + 1);
|
||||
open(player);
|
||||
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
} else {
|
||||
String playerName = ChatColor.stripColor(is.getItemMeta().getDisplayName());
|
||||
|
||||
boolean isOperator = island.isRole(Role.Operator, player.getUniqueId()), isOwner = island.isRole(Role.Owner, player.getUniqueId()), canKick = island.getSetting(Settings.Role.Operator, "Kick").getStatus(), canBan = island.getSetting(Settings.Role.Operator, "Ban").getStatus(), banningEnabled = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning");
|
||||
|
||||
if ((isOperator && canKick) || isOwner) {
|
||||
if (banningEnabled && ((isOperator && canBan) || isOwner)) {
|
||||
if (event.getClick() == ClickType.LEFT) {
|
||||
Bukkit.getServer().dispatchCommand(player, "island kick " + playerName);
|
||||
} else if (event.getClick() == ClickType.RIGHT) {
|
||||
Bukkit.getServer().dispatchCommand(player, "island ban " + playerName);
|
||||
} else {
|
||||
soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
Bukkit.getServer().dispatchCommand(player, "island kick " + playerName);
|
||||
}
|
||||
} else {
|
||||
if (banningEnabled && ((isOperator && canBan) || isOwner)) {
|
||||
Bukkit.getServer().dispatchCommand(player, "island ban " + playerName);
|
||||
} else {
|
||||
soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 1.0F, 1.0F);
|
||||
skyblock.getMessageManager().sendMessage(player, configLoad.getString("Command.Island.Visitors.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}.runTaskLater(skyblock, 3L);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ItemStack is = event.getItem();
|
||||
|
||||
if ((is.getType() == Materials.BLACK_STAINED_GLASS_PANE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visitors.Item.Barrier.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.GLASS.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == Materials.OAK_FENCE_GATE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visitors.Item.Exit.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((is.getType() == Material.PAINTING) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visitors.Item.Statistics.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == Material.BARRIER) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visitors.Item.Nothing.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
|
||||
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visitors.Item.Previous.Displayname")))) {
|
||||
playerData.setPage(playerData.getPage() - 1);
|
||||
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}, 1L);
|
||||
} else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visitors.Item.Next.Displayname")))) {
|
||||
playerData.setPage(playerData.getPage() + 1);
|
||||
soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}, 1L);
|
||||
} else {
|
||||
boolean isOperator = island.isRole(Role.Operator, player.getUniqueId()), isOwner = island.isRole(Role.Owner, player.getUniqueId()), canKick = island.getSetting(Settings.Role.Operator, "Kick").getStatus(), canBan = island.getSetting(Settings.Role.Operator, "Ban").getStatus(), banningEnabled = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning");
|
||||
String playerName = ChatColor.stripColor(is.getItemMeta().getDisplayName());
|
||||
|
||||
if ((isOperator && canKick) || isOwner) {
|
||||
if (banningEnabled && ((isOperator && canBan) || isOwner)) {
|
||||
if (event.getClick() == ClickType.LEFT) {
|
||||
Bukkit.getServer().dispatchCommand(player, "island kick " + playerName);
|
||||
} else if (event.getClick() == ClickType.RIGHT) {
|
||||
Bukkit.getServer().dispatchCommand(player, "island ban " + playerName);
|
||||
} else {
|
||||
soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
Bukkit.getServer().dispatchCommand(player, "island kick " + playerName);
|
||||
}
|
||||
} else {
|
||||
if (banningEnabled && ((isOperator && canBan) || isOwner)) {
|
||||
Bukkit.getServer().dispatchCommand(player, "island ban " + playerName);
|
||||
} else {
|
||||
soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}, 1L);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
PlayerData playerData = playerDataManager.getPlayerData(player);
|
||||
Island island = skyblock.getIslandManager().getIsland(playerData.getOwner());
|
||||
|
||||
Map<Integer, UUID> sortedIslandVisitors = new TreeMap<>();
|
||||
List<UUID> islandVisitors = island.getVisitors();
|
||||
|
||||
nInv.addItem(nInv.createItem(Materials.OAK_FENCE_GATE.parseItem(), configLoad.getString("Menu.Visitors.Item.Exit.Displayname"), null, null, null, null), 0, 8);
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING), configLoad.getString("Menu.Visitors.Item.Statistics.Displayname"), configLoad.getStringList("Menu.Visitors.Item.Statistics.Lore"), nInv.createItemLoreVariable(new String[] { "%visitors#" + islandVisitors.size() }), null, null), 4);
|
||||
nInv.addItem(nInv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(), configLoad.getString("Menu.Visitors.Item.Barrier.Displayname"), null, null, null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
|
||||
for (UUID islandVisitorList : islandVisitors) {
|
||||
sortedIslandVisitors.put(playerDataManager.getPlayerData(Bukkit.getServer().getPlayer(islandVisitorList)).getVisitTime(), islandVisitorList);
|
||||
}
|
||||
|
||||
islandVisitors.clear();
|
||||
|
||||
for (int sortedIslandVisitorList : sortedIslandVisitors.keySet()) {
|
||||
islandVisitors.add(sortedIslandVisitors.get(sortedIslandVisitorList));
|
||||
}
|
||||
|
||||
int playerMenuPage = playerData.getPage(), nextEndIndex = sortedIslandVisitors.size() - playerMenuPage * 36;
|
||||
|
||||
if (playerMenuPage != 1) {
|
||||
nInv.addItem(nInv.createItem(SkullUtil.create("ToR1w9ZV7zpzCiLBhoaJH3uixs5mAlMhNz42oaRRvrG4HRua5hC6oyyOPfn2HKdSseYA9b1be14fjNRQbSJRvXF3mlvt5/zct4sm+cPVmX8K5kbM2vfwHJgCnfjtPkzT8sqqg6YFdT35mAZGqb9/xY/wDSNSu/S3k2WgmHrJKirszaBZrZfnVnqITUOgM9TmixhcJn2obeqICv6tl7/Wyk/1W62wXlXGm9+WjS+8rRNB+vYxqKR3XmH2lhAiyVGbADsjjGtBVUTWjq+aPw670SjXkoii0YE8sqzUlMMGEkXdXl9fvGtnWKk3APSseuTsjedr7yq+AkXFVDqqkqcUuXwmZl2EjC2WRRbhmYdbtY5nEfqh5+MiBrGdR/JqdEUL4yRutyRTw8mSUAI6X2oSVge7EdM/8f4HwLf33EO4pTocTqAkNbpt6Z54asLe5Y12jSXbvd2dFsgeJbrslK7e4uy/TK8CXf0BP3KLU20QELYrjz9I70gtj9lJ9xwjdx4/xJtxDtrxfC4Afmpu+GNYA/mifpyP3GDeBB5CqN7btIvEWyVvRNH7ppAqZIPqYJ7dSDd2RFuhAId5Yq98GUTBn+eRzeigBvSi1bFkkEgldfghOoK5WhsQtQbXuBBXITMME3NaWCN6zG7DxspS6ew/rZ8E809Xe0ArllquIZ0sP+k=", "eyJ0aW1lc3RhbXAiOjE0OTU3NTE5MTYwNjksInByb2ZpbGVJZCI6ImE2OGYwYjY0OGQxNDQwMDBhOTVmNGI5YmExNGY4ZGY5IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dMZWZ0Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zZWJmOTA3NDk0YTkzNWU5NTViZmNhZGFiODFiZWFmYjkwZmI5YmU0OWM3MDI2YmE5N2Q3OThkNWYxYTIzIn19fQ=="), configLoad.getString("Menu.Visitors.Item.Previous.Displayname"), null, null, null, null), 1);
|
||||
}
|
||||
|
||||
if (!(nextEndIndex == 0 || nextEndIndex < 0)) {
|
||||
nInv.addItem(nInv.createItem(SkullUtil.create("wZPrsmxckJn4/ybw/iXoMWgAe+1titw3hjhmf7bfg9vtOl0f/J6YLNMOI0OTvqeRKzSQVCxqNOij6k2iM32ZRInCQyblDIFmFadQxryEJDJJPVs7rXR6LRXlN8ON2VDGtboRTL7LwMGpzsrdPNt0oYDJLpR0huEeZKc1+g4W13Y4YM5FUgEs8HvMcg4aaGokSbvrYRRcEh3LR1lVmgxtbiUIr2gZkR3jnwdmZaIw/Ujw28+Et2pDMVCf96E5vC0aNY0KHTdMYheT6hwgw0VAZS2VnJg+Gz4JCl4eQmN2fs4dUBELIW2Rdnp4U1Eb+ZL8DvTV7ofBeZupknqPOyoKIjpInDml9BB2/EkD3zxFtW6AWocRphn03Z203navBkR6ztCMz0BgbmQU/m8VL/s8o4cxOn+2ppjrlj0p8AQxEsBdHozrBi8kNOGf1j97SDHxnvVAF3X8XDso+MthRx5pbEqpxmLyKKgFh25pJE7UaMSnzH2lc7aAZiax67MFw55pDtgfpl+Nlum4r7CK2w5Xob2QTCovVhu78/6SV7qM2Lhlwx/Sjqcl8rn5UIoyM49QE5Iyf1tk+xHXkIvY0m7q358oXsfca4eKmxMe6DFRjUDo1VuWxdg9iVjn22flqz1LD1FhGlPoqv0k4jX5Q733LwtPPI6VOTK+QzqrmiuR6e8=", "eyJ0aW1lc3RhbXAiOjE0OTM4NjgxMDA2NzMsInByb2ZpbGVJZCI6IjUwYzg1MTBiNWVhMDRkNjBiZTlhN2Q1NDJkNmNkMTU2IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dSaWdodCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ=="), configLoad.getString("Menu.Visitors.Item.Next.Displayname"), null, null, null, null), 7);
|
||||
}
|
||||
|
||||
if (islandVisitors.size() == 0) {
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.BARRIER), configLoad.getString("Menu.Visitors.Item.Nothing.Displayname"), null, null, null, null), 31);
|
||||
} else {
|
||||
boolean isOperator = island.isRole(Role.Operator, player.getUniqueId()), isOwner = island.isRole(Role.Owner, player.getUniqueId()), canKick = island.getSetting(Settings.Role.Operator, "Kick").getStatus(), canBan = island.getSetting(Settings.Role.Operator, "Ban").getStatus(), banningEnabled = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning");
|
||||
int index = playerMenuPage * 36 - 36, endIndex = index >= islandVisitors.size() ? islandVisitors.size() - 1 : index + 36, inventorySlot = 17;
|
||||
|
||||
for (; index < endIndex; index++) {
|
||||
if (islandVisitors.size() > index) {
|
||||
inventorySlot++;
|
||||
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(islandVisitors.get(index));
|
||||
PlayerData targetPlayerData = playerDataManager.getPlayerData(targetPlayer);
|
||||
|
||||
String[] targetPlayerTexture = targetPlayerData.getTexture();
|
||||
String islandVisitTimeFormatted;
|
||||
|
||||
long[] islandVisitTime = NumberUtil.getDuration(targetPlayerData.getVisitTime());
|
||||
|
||||
if (islandVisitTime[0] != 0) {
|
||||
islandVisitTimeFormatted = islandVisitTime[0] + " " + configLoad.getString("Menu.Visitors.Item.Visitor.Word.Days") + ", " + islandVisitTime[1] + " " + configLoad.getString("Menu.Visitors.Item.Visitor.Word.Hours") + ", " + islandVisitTime[2] + " " + configLoad.getString("Menu.Visitors.Item.Visitor.Word.Minutes") + ", " + islandVisitTime[3] + " " + configLoad.getString("Menu.Visitors.Item.Visitor.Word.Seconds");
|
||||
} else if (islandVisitTime[1] != 0) {
|
||||
islandVisitTimeFormatted = islandVisitTime[1] + " " + configLoad.getString("Menu.Visitors.Item.Visitor.Word.Hours") + ", " + islandVisitTime[2] + " " + configLoad.getString("Menu.Visitors.Item.Visitor.Word.Minutes") + ", " + islandVisitTime[3] + " " + configLoad.getString("Menu.Visitors.Item.Visitor.Word.Seconds");
|
||||
} else if (islandVisitTime[2] != 0) {
|
||||
islandVisitTimeFormatted = islandVisitTime[2] + " " + configLoad.getString("Menu.Visitors.Item.Visitor.Word.Minutes") + ", " + islandVisitTime[3] + " " + configLoad.getString("Menu.Visitors.Item.Visitor.Word.Seconds");
|
||||
} else {
|
||||
islandVisitTimeFormatted = islandVisitTime[3] + " " + configLoad.getString("Menu.Visitors.Item.Visitor.Word.Seconds");
|
||||
}
|
||||
|
||||
List<String> itemLore = new ArrayList<>();
|
||||
|
||||
if ((isOperator && canKick) || isOwner) {
|
||||
if (banningEnabled && ((isOperator && canBan) || isOwner)) {
|
||||
itemLore.addAll(configLoad.getStringList("Menu.Visitors.Item.Visitor.Kick.Permission.Ban.Permission.Lore"));
|
||||
} else {
|
||||
itemLore.addAll(configLoad.getStringList("Menu.Visitors.Item.Visitor.Kick.Permission.Ban.NoPermission.Lore"));
|
||||
}
|
||||
} else {
|
||||
if (banningEnabled && ((isOperator && canBan) || isOwner)) {
|
||||
itemLore.addAll(configLoad.getStringList("Menu.Visitors.Item.Visitor.Kick.NoPermission.Ban.Permission.Lore"));
|
||||
} else {
|
||||
itemLore.addAll(configLoad.getStringList("Menu.Visitors.Item.Visitor.Kick.NoPermission.Ban.NoPermission.Lore"));
|
||||
}
|
||||
}
|
||||
|
||||
nInv.addItem(nInv.createItem(SkullUtil.create(targetPlayerTexture[0], targetPlayerTexture[1]), ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visitors.Item.Visitor.Displayname").replace("%player", targetPlayer.getName())), itemLore, nInv.createItemLoreVariable(new String[] { "%time#" + islandVisitTimeFormatted }), null, null), inventorySlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Visitors.Title")));
|
||||
nInv.setRows(6);
|
||||
nInv.open();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,32 +2,32 @@ package me.goodandevil.skyblock.menus;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.WeatherType;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.goodandevil.skyblock.SkyBlock;
|
||||
import me.goodandevil.skyblock.config.FileManager;
|
||||
import me.goodandevil.skyblock.config.FileManager.Config;
|
||||
import me.goodandevil.skyblock.island.Island;
|
||||
import me.goodandevil.skyblock.island.Location;
|
||||
import me.goodandevil.skyblock.island.IslandManager;
|
||||
import me.goodandevil.skyblock.island.Role;
|
||||
import me.goodandevil.skyblock.island.Settings;
|
||||
import me.goodandevil.skyblock.message.MessageManager;
|
||||
import me.goodandevil.skyblock.playerdata.PlayerDataManager;
|
||||
import me.goodandevil.skyblock.sound.SoundManager;
|
||||
import me.goodandevil.skyblock.utils.item.InventoryUtil;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEvent;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEventHandler;
|
||||
import me.goodandevil.skyblock.utils.version.Materials;
|
||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||
|
||||
public class Weather implements Listener {
|
||||
public class Weather {
|
||||
|
||||
private static Weather instance;
|
||||
|
||||
@ -42,169 +42,188 @@ public class Weather implements Listener {
|
||||
public void open(Player player) {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
Island island = skyblock.getIslandManager().getIsland(skyblock.getPlayerDataManager().getPlayerData(player).getOwner());
|
||||
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config languageConfig = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = languageConfig.getFileConfiguration();
|
||||
|
||||
int islandTime = island.getTime();
|
||||
String timeName = "", timeChoice = "", weatherSynchronised, weatherChoice, synchronisedChoice;
|
||||
|
||||
if (island.isWeatherSynchronised()) {
|
||||
weatherSynchronised = configLoad.getString("Menu.Weather.Item.Info.Synchronised.Enabled");
|
||||
} else {
|
||||
weatherSynchronised = configLoad.getString("Menu.Weather.Item.Info.Synchronised.Disabled");
|
||||
}
|
||||
|
||||
if (islandTime == 0) {
|
||||
timeName = configLoad.getString("Menu.Weather.Item.Info.Time.Dawn");
|
||||
timeChoice = configLoad.getString("Menu.Weather.Item.Time.Choice.Day");
|
||||
} else if (islandTime == 1000) {
|
||||
timeName = configLoad.getString("Menu.Weather.Item.Info.Time.Day");
|
||||
timeChoice = configLoad.getString("Menu.Weather.Item.Time.Choice.Noon");
|
||||
} else if (islandTime == 6000) {
|
||||
timeName = configLoad.getString("Menu.Weather.Item.Info.Time.Noon");
|
||||
timeChoice = configLoad.getString("Menu.Weather.Item.Time.Choice.Dusk");
|
||||
} else if (islandTime == 12000) {
|
||||
timeName = configLoad.getString("Menu.Weather.Item.Info.Time.Dusk");
|
||||
timeChoice = configLoad.getString("Menu.Weather.Item.Time.Choice.Night");
|
||||
} else if (islandTime == 13000) {
|
||||
timeName = configLoad.getString("Menu.Weather.Item.Info.Time.Night");
|
||||
timeChoice = configLoad.getString("Menu.Weather.Item.Time.Choice.Midnight");
|
||||
} else if (islandTime == 18000) {
|
||||
timeName = configLoad.getString("Menu.Weather.Item.Info.Time.Midnight");
|
||||
timeChoice = configLoad.getString("Menu.Weather.Item.Time.Choice.Dawn");
|
||||
}
|
||||
|
||||
if (island.getWeather() == WeatherType.CLEAR) {
|
||||
weatherChoice = configLoad.getString("Menu.Weather.Item.Weather.Choice.Downfall");
|
||||
} else {
|
||||
weatherChoice = configLoad.getString("Menu.Weather.Item.Weather.Choice.Clear");
|
||||
}
|
||||
|
||||
if (island.isWeatherSynchronised()) {
|
||||
synchronisedChoice = configLoad.getString("Menu.Weather.Item.Synchronised.Choice.Disable");
|
||||
} else {
|
||||
synchronisedChoice = configLoad.getString("Menu.Weather.Item.Synchronised.Choice.Enable");
|
||||
}
|
||||
|
||||
InventoryUtil inv = new InventoryUtil(configLoad.getString("Menu.Weather.Title"), InventoryType.HOPPER, 0);
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.NAME_TAG), configLoad.getString("Menu.Weather.Item.Info.Displayname"), configLoad.getStringList("Menu.Weather.Item.Info.Lore"), inv.createItemLoreVariable(new String[] { "%synchronised#" + weatherSynchronised, "%time_name#" + timeName, "%time#" + island.getTime(), "%weather#" + island.getWeatherName() }), null, null), 0);
|
||||
inv.addItem(inv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(), configLoad.getString("Menu.Weather.Item.Barrier.Displayname"), null, null, null, null), 1);
|
||||
inv.addItem(inv.createItem(Materials.SUNFLOWER.parseItem(), configLoad.getString("Menu.Weather.Item.Time.Displayname"), configLoad.getStringList("Menu.Weather.Item.Time.Lore"), inv.createItemLoreVariable(new String[] { "%choice#" + timeChoice }), null, null), 2);
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.GHAST_TEAR), configLoad.getString("Menu.Weather.Item.Weather.Displayname"), configLoad.getStringList("Menu.Weather.Item.Weather.Lore"), inv.createItemLoreVariable(new String[] { "%choice#" + weatherChoice }), null, null), 3);
|
||||
inv.addItem(inv.createItem(new ItemStack(Material.TRIPWIRE_HOOK), configLoad.getString("Menu.Weather.Item.Synchronised.Displayname"), configLoad.getStringList("Menu.Weather.Item.Synchronised.Lore"), inv.createItemLoreVariable(new String[] { "%choice#" + synchronisedChoice }), null, null), 4);
|
||||
|
||||
player.openInventory(inv.getInventory());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
ItemStack is = event.getCurrentItem();
|
||||
|
||||
if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR) {
|
||||
SkyBlock skyblock = SkyBlock.getInstance();
|
||||
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Weather.Title")))) {
|
||||
event.setCancelled(true);
|
||||
|
||||
Island island = null;
|
||||
|
||||
if (islandManager.hasIsland(player)) {
|
||||
island = islandManager.getIsland(skyblock.getPlayerDataManager().getPlayerData(player).getOwner());
|
||||
|
||||
if (!((island.isRole(Role.Operator, player.getUniqueId()) && island.getSetting(Settings.Role.Operator, "Biome").getStatus()) || island.isRole(Role.Owner, player.getUniqueId()))) {
|
||||
messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Weather.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
FileConfiguration configLoad = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration();
|
||||
|
||||
nInventoryUtil nInv = new nInventoryUtil(player, new ClickEventHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (playerDataManager.hasPlayerData(player)) {
|
||||
Island island = null;
|
||||
|
||||
return;
|
||||
if (islandManager.hasIsland(player)) {
|
||||
island = islandManager.getIsland(playerDataManager.getPlayerData(player).getOwner());
|
||||
|
||||
if (!((island.isRole(Role.Operator, player.getUniqueId()) && island.getSetting(Settings.Role.Operator, "Biome").getStatus()) || island.isRole(Role.Owner, player.getUniqueId()))) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Weather.Permission.Message"));
|
||||
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Weather.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack is = event.getItem();
|
||||
|
||||
if ((is.getType() == Material.NAME_TAG) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Weather.Item.Info.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == Materials.BLACK_STAINED_GLASS_PANE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Weather.Item.Barrier.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.GLASS.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
event.setWillClose(false);
|
||||
event.setWillDestroy(false);
|
||||
} else if ((is.getType() == Materials.SUNFLOWER.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Weather.Item.Time.Displayname"))))) {
|
||||
int islandTime = island.getTime();
|
||||
|
||||
if (islandTime == 0) {
|
||||
island.setTime(1000);
|
||||
} else if (islandTime == 1000) {
|
||||
island.setTime(6000);
|
||||
} else if (islandTime == 6000) {
|
||||
island.setTime(12000);
|
||||
} else if (islandTime == 12000) {
|
||||
island.setTime(13000);
|
||||
} else if (islandTime == 13000) {
|
||||
island.setTime(18000);
|
||||
} else if (islandTime == 18000) {
|
||||
island.setTime(0);
|
||||
}
|
||||
|
||||
if (!island.isWeatherSynchronised()) {
|
||||
for (Player all : islandManager.getPlayersAtIsland(island, Location.World.Normal)) {
|
||||
all.setPlayerTime(island.getTime(), fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Weather.Time.Cycle"));
|
||||
}
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}, 1L);
|
||||
} else if ((is.getType() == Material.GHAST_TEAR) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Weather.Item.Weather.Displayname"))))) {
|
||||
if (island.getWeather() == WeatherType.DOWNFALL) {
|
||||
island.setWeather(WeatherType.CLEAR);
|
||||
} else {
|
||||
island.setWeather(WeatherType.DOWNFALL);
|
||||
}
|
||||
|
||||
if (!island.isWeatherSynchronised()) {
|
||||
for (Player all : islandManager.getPlayersAtIsland(island, Location.World.Normal)) {
|
||||
all.setPlayerWeather(island.getWeather());
|
||||
}
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}, 1L);
|
||||
} else if ((is.getType() == Material.TRIPWIRE_HOOK) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Weather.Item.Synchronised.Displayname"))))) {
|
||||
if (island.isWeatherSynchronised()) {
|
||||
island.setWeatherSynchronised(false);
|
||||
|
||||
int islandTime = island.getTime();
|
||||
WeatherType islandWeather = island.getWeather();
|
||||
|
||||
for (Player all : islandManager.getPlayersAtIsland(island, Location.World.Normal)) {
|
||||
all.setPlayerTime(islandTime, fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Weather.Time.Cycle"));
|
||||
all.setPlayerWeather(islandWeather);
|
||||
}
|
||||
} else {
|
||||
island.setWeatherSynchronised(true);
|
||||
|
||||
for (Player all : islandManager.getPlayersAtIsland(island, Location.World.Normal)) {
|
||||
all.resetPlayerTime();
|
||||
all.resetPlayerWeather();
|
||||
}
|
||||
}
|
||||
|
||||
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
open(player);
|
||||
}
|
||||
}, 1L);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
messageManager.sendMessage(player, config.getFileConfiguration().getString("Command.Island.Weather.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
player.closeInventory();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ((event.getCurrentItem().getType() == Material.NAME_TAG) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Weather.Item.Info.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == Materials.BLACK_STAINED_GLASS_PANE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Weather.Item.Barrier.Displayname"))))) {
|
||||
soundManager.playSound(player, Sounds.GLASS.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == Materials.SUNFLOWER.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Weather.Item.Time.Displayname"))))) {
|
||||
int islandTime = island.getTime();
|
||||
|
||||
if (islandTime == 0) {
|
||||
island.setTime(1000);
|
||||
} else if (islandTime == 1000) {
|
||||
island.setTime(6000);
|
||||
} else if (islandTime == 6000) {
|
||||
island.setTime(12000);
|
||||
} else if (islandTime == 12000) {
|
||||
island.setTime(13000);
|
||||
} else if (islandTime == 13000) {
|
||||
island.setTime(18000);
|
||||
} else if (islandTime == 18000) {
|
||||
island.setTime(0);
|
||||
}
|
||||
|
||||
if (!island.isWeatherSynchronised()) {
|
||||
for (Player all : islandManager.getPlayersAtIsland(island, Location.World.Normal)) {
|
||||
all.setPlayerTime(island.getTime(), fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Weather.Time.Cycle"));
|
||||
}
|
||||
}
|
||||
|
||||
open(player);
|
||||
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == Material.GHAST_TEAR) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Weather.Item.Weather.Displayname"))))) {
|
||||
if (island.getWeather() == WeatherType.DOWNFALL) {
|
||||
island.setWeather(WeatherType.CLEAR);
|
||||
} else {
|
||||
island.setWeather(WeatherType.DOWNFALL);
|
||||
}
|
||||
|
||||
if (!island.isWeatherSynchronised()) {
|
||||
for (Player all : islandManager.getPlayersAtIsland(island, Location.World.Normal)) {
|
||||
all.setPlayerWeather(island.getWeather());
|
||||
}
|
||||
}
|
||||
|
||||
open(player);
|
||||
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
|
||||
} else if ((event.getCurrentItem().getType() == Material.TRIPWIRE_HOOK) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Weather.Item.Synchronised.Displayname"))))) {
|
||||
if (island.isWeatherSynchronised()) {
|
||||
island.setWeatherSynchronised(false);
|
||||
|
||||
int islandTime = island.getTime();
|
||||
WeatherType islandWeather = island.getWeather();
|
||||
|
||||
for (Player all : islandManager.getPlayersAtIsland(island, Location.World.Normal)) {
|
||||
all.setPlayerTime(islandTime, fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Weather.Time.Cycle"));
|
||||
all.setPlayerWeather(islandWeather);
|
||||
}
|
||||
} else {
|
||||
island.setWeatherSynchronised(true);
|
||||
|
||||
for (Player all : islandManager.getPlayersAtIsland(island, Location.World.Normal)) {
|
||||
all.resetPlayerTime();
|
||||
all.resetPlayerWeather();
|
||||
}
|
||||
}
|
||||
|
||||
open(player);
|
||||
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
});
|
||||
|
||||
Island island = islandManager.getIsland(playerDataManager.getPlayerData(player).getOwner());
|
||||
|
||||
String timeName = "", timeChoice = "", weatherSynchronised, weatherChoice, synchronisedChoice;
|
||||
int islandTime = island.getTime();
|
||||
|
||||
if (island.isWeatherSynchronised()) {
|
||||
weatherSynchronised = configLoad.getString("Menu.Weather.Item.Info.Synchronised.Enabled");
|
||||
} else {
|
||||
weatherSynchronised = configLoad.getString("Menu.Weather.Item.Info.Synchronised.Disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (islandTime == 0) {
|
||||
timeName = configLoad.getString("Menu.Weather.Item.Info.Time.Dawn");
|
||||
timeChoice = configLoad.getString("Menu.Weather.Item.Time.Choice.Day");
|
||||
} else if (islandTime == 1000) {
|
||||
timeName = configLoad.getString("Menu.Weather.Item.Info.Time.Day");
|
||||
timeChoice = configLoad.getString("Menu.Weather.Item.Time.Choice.Noon");
|
||||
} else if (islandTime == 6000) {
|
||||
timeName = configLoad.getString("Menu.Weather.Item.Info.Time.Noon");
|
||||
timeChoice = configLoad.getString("Menu.Weather.Item.Time.Choice.Dusk");
|
||||
} else if (islandTime == 12000) {
|
||||
timeName = configLoad.getString("Menu.Weather.Item.Info.Time.Dusk");
|
||||
timeChoice = configLoad.getString("Menu.Weather.Item.Time.Choice.Night");
|
||||
} else if (islandTime == 13000) {
|
||||
timeName = configLoad.getString("Menu.Weather.Item.Info.Time.Night");
|
||||
timeChoice = configLoad.getString("Menu.Weather.Item.Time.Choice.Midnight");
|
||||
} else if (islandTime == 18000) {
|
||||
timeName = configLoad.getString("Menu.Weather.Item.Info.Time.Midnight");
|
||||
timeChoice = configLoad.getString("Menu.Weather.Item.Time.Choice.Dawn");
|
||||
}
|
||||
|
||||
if (island.getWeather() == WeatherType.CLEAR) {
|
||||
weatherChoice = configLoad.getString("Menu.Weather.Item.Weather.Choice.Downfall");
|
||||
} else {
|
||||
weatherChoice = configLoad.getString("Menu.Weather.Item.Weather.Choice.Clear");
|
||||
}
|
||||
|
||||
if (island.isWeatherSynchronised()) {
|
||||
synchronisedChoice = configLoad.getString("Menu.Weather.Item.Synchronised.Choice.Disable");
|
||||
} else {
|
||||
synchronisedChoice = configLoad.getString("Menu.Weather.Item.Synchronised.Choice.Enable");
|
||||
}
|
||||
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.NAME_TAG), configLoad.getString("Menu.Weather.Item.Info.Displayname"), configLoad.getStringList("Menu.Weather.Item.Info.Lore"), nInv.createItemLoreVariable(new String[] { "%synchronised#" + weatherSynchronised, "%time_name#" + timeName, "%time#" + island.getTime(), "%weather#" + island.getWeatherName() }), null, null), 0);
|
||||
nInv.addItem(nInv.createItem(Materials.BLACK_STAINED_GLASS_PANE.parseItem(), configLoad.getString("Menu.Weather.Item.Barrier.Displayname"), null, null, null, null), 1);
|
||||
nInv.addItem(nInv.createItem(Materials.SUNFLOWER.parseItem(), configLoad.getString("Menu.Weather.Item.Time.Displayname"), configLoad.getStringList("Menu.Weather.Item.Time.Lore"), nInv.createItemLoreVariable(new String[] { "%choice#" + timeChoice }), null, null), 2);
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.GHAST_TEAR), configLoad.getString("Menu.Weather.Item.Weather.Displayname"), configLoad.getStringList("Menu.Weather.Item.Weather.Lore"), nInv.createItemLoreVariable(new String[] { "%choice#" + weatherChoice }), null, null), 3);
|
||||
nInv.addItem(nInv.createItem(new ItemStack(Material.TRIPWIRE_HOOK), configLoad.getString("Menu.Weather.Item.Synchronised.Displayname"), configLoad.getStringList("Menu.Weather.Item.Synchronised.Lore"), nInv.createItemLoreVariable(new String[] { "%choice#" + synchronisedChoice }), null, null), 4);
|
||||
|
||||
nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Weather.Title")));
|
||||
nInv.setType(InventoryType.HOPPER);
|
||||
nInv.open();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,13 +24,13 @@ import me.goodandevil.skyblock.utils.version.NMSUtil;
|
||||
public class AnvilGUI {
|
||||
|
||||
private Player player;
|
||||
@SuppressWarnings("unused")
|
||||
private AnvilClickEventHandler handler;
|
||||
private static Class<?> BlockPosition;
|
||||
private static Class<?> PacketPlayOutOpenWindow;
|
||||
private static Class<?> ContainerAnvil;
|
||||
private static Class<?> ChatMessage;
|
||||
private static Class<?> EntityHuman;
|
||||
|
||||
private Class<?> BlockPosition;
|
||||
private Class<?> PacketPlayOutOpenWindow;
|
||||
private Class<?> ContainerAnvil;
|
||||
private Class<?> ChatMessage;
|
||||
private Class<?> EntityHuman;
|
||||
|
||||
private Map<AnvilSlot, ItemStack> items = new HashMap<>();
|
||||
private Inventory inv;
|
||||
private Listener listener;
|
||||
@ -46,8 +46,7 @@ public class AnvilGUI {
|
||||
public AnvilGUI(final Player player, final AnvilClickEventHandler handler) {
|
||||
loadClasses();
|
||||
this.player = player;
|
||||
this.handler = handler;
|
||||
|
||||
|
||||
this.listener = new Listener() {
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
@ -174,7 +173,6 @@ public class AnvilGUI {
|
||||
|
||||
public void destroy() {
|
||||
player = null;
|
||||
handler = null;
|
||||
items = null;
|
||||
|
||||
HandlerList.unregisterAll(listener);
|
||||
|
@ -1,20 +0,0 @@
|
||||
package me.goodandevil.skyblock.utils.item;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEvent;
|
||||
import me.goodandevil.skyblock.utils.item.nInventoryUtil.ClickEventHandler;
|
||||
|
||||
public class ExampleInventory {
|
||||
|
||||
public void open(Player player) {
|
||||
nInventoryUtil nInventoryUtil = new nInventoryUtil(player, "Test", null, 1*9, new ClickEventHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
nInventoryUtil.open();
|
||||
}
|
||||
}
|
@ -41,6 +41,11 @@ public final class SkullUtil {
|
||||
}
|
||||
|
||||
public static ItemStack create(String signature, String value) {
|
||||
if (signature == null || signature.isEmpty() || value == null || value.isEmpty()) {
|
||||
signature = "K9P4tCIENYbNpDuEuuY0shs1x7iIvwXi4jUUVsATJfwsAIZGS+9OZ5T2HB0tWBoxRvZNi73Vr+syRdvTLUWPusVXIg+2fhXmQoaNEtnQvQVGQpjdQP0TkZtYG8PbvRxE6Z75ddq+DVx/65OSNHLWIB/D+Rg4vINh4ukXNYttn9QvauDHh1aW7/IkIb1Bc0tLcQyqxZQ3mdglxJfgIerqnlA++Lt7TxaLdag4y1NhdZyd3OhklF5B0+B9zw/qP8QCzsZU7VzJIcds1+wDWKiMUO7+60OSrIwgE9FPamxOQDFoDvz5BOULQEeNx7iFMB+eBYsapCXpZx0zf1bduppBUbbVC9wVhto/J4tc0iNyUq06/esHUUB5MHzdJ0Y6IZJAD/xIw15OLCUH2ntvs8V9/cy5/n8u3JqPUM2zhUGeQ2p9FubUGk4Q928L56l3omRpKV+5QYTrvF+AxFkuj2hcfGQG3VE2iYZO6omXe7nRPpbJlHkMKhE8Xvd1HP4PKpgivSkHBoZ92QEUAmRzZydJkp8CNomQrZJf+MtPiNsl/Q5RQM+8CQThg3+4uWptUfP5dDFWOgTnMdA0nIODyrjpp+bvIJnsohraIKJ7ZDnj4tIp4ObTNKDFC/8j8JHz4VCrtr45mbnzvB2DcK8EIB3JYT7ElJTHnc5BKMyLy5SKzuw=";
|
||||
value = "eyJ0aW1lc3RhbXAiOjE1MjkyNTg0MTE4NDksInByb2ZpbGVJZCI6Ijg2NjdiYTcxYjg1YTQwMDRhZjU0NDU3YTk3MzRlZWQ3IiwicHJvZmlsZU5hbWUiOiJTdGV2ZSIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGMxYzc3Y2U4ZTU0OTI1YWI1ODEyNTQ0NmVjNTNiMGNkZDNkMGNhM2RiMjczZWI5MDhkNTQ4Mjc4N2VmNDAxNiJ9LCJDQVBFIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjc2N2Q0ODMyNWVhNTMyNDU2MTQwNmI4YzgyYWJiZDRlMjc1NWYxMTE1M2NkODVhYjA1NDVjYzIifX19";
|
||||
}
|
||||
|
||||
ItemStack is = createItemStack();
|
||||
SkullMeta sm = (SkullMeta) is.getItemMeta();
|
||||
|
||||
|
@ -13,7 +13,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
@ -28,18 +28,18 @@ import me.goodandevil.skyblock.SkyBlock;
|
||||
public class nInventoryUtil {
|
||||
|
||||
private Player player;
|
||||
private Inventory inv;
|
||||
private Listener listener;
|
||||
|
||||
public nInventoryUtil(Player player, String inventoryTitle, InventoryType inventoryType, int inventoryRows, final ClickEventHandler handler) {
|
||||
private Inventory inv;
|
||||
|
||||
private String title;
|
||||
private int size = 9;
|
||||
private InventoryType type;
|
||||
private Map<Integer, ItemStack> items = new HashMap<>();
|
||||
|
||||
public nInventoryUtil(Player player, final ClickEventHandler handler) {
|
||||
this.player = player;
|
||||
|
||||
if (inventoryType == null) {
|
||||
inv = Bukkit.getServer().createInventory(null, inventoryRows * 9, ChatColor.translateAlternateColorCodes('&', inventoryTitle));
|
||||
} else {
|
||||
inv = Bukkit.getServer().createInventory(null, inventoryType, ChatColor.translateAlternateColorCodes('&', inventoryTitle));
|
||||
}
|
||||
|
||||
this.listener = new Listener() {
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
@ -47,14 +47,20 @@ public class nInventoryUtil {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getInventory().equals(inv)) {
|
||||
if (inv != null && event.getInventory().equals(inv)) {
|
||||
if (event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR) {
|
||||
return;
|
||||
}
|
||||
|
||||
ClickEvent clickEvent = new ClickEvent(event.getAction(), event.getSlot(), event.getCurrentItem());
|
||||
event.setCancelled(true);
|
||||
|
||||
ClickEvent clickEvent = new ClickEvent(event.getClick(), event.getSlot(), event.getCurrentItem());
|
||||
handler.onClick(clickEvent);
|
||||
|
||||
if (!clickEvent.getCancelled()) {
|
||||
event.setCancelled(false);
|
||||
}
|
||||
|
||||
if (clickEvent.getWillClose()) {
|
||||
event.getWhoClicked().closeInventory();
|
||||
}
|
||||
@ -73,7 +79,7 @@ public class nInventoryUtil {
|
||||
|
||||
Inventory inv = event.getInventory();
|
||||
|
||||
if (inv.equals(inv)) {
|
||||
if (inv.equals(nInventoryUtil.this.inv)) {
|
||||
inv.clear();
|
||||
destroy();
|
||||
}
|
||||
@ -90,18 +96,22 @@ public class nInventoryUtil {
|
||||
Bukkit.getPluginManager().registerEvents(listener, SkyBlock.getInstance());
|
||||
}
|
||||
|
||||
public void addItem(Item item, int... inventorySlots) {
|
||||
for (int inventorySlot : inventorySlots) {
|
||||
inv.setItem(inventorySlot, item.prepareItem());
|
||||
public void addItem(Item item, int... slots) {
|
||||
for (int slotList : slots) {
|
||||
items.put(slotList, item.prepareItem());
|
||||
}
|
||||
}
|
||||
|
||||
public void addItemStack(ItemStack is, int... inventorySlots) {
|
||||
for (int inventorySlot : inventorySlots) {
|
||||
inv.setItem(inventorySlot, is);
|
||||
public void addItemStack(ItemStack is, int... slots) {
|
||||
for (int slotList : slots) {
|
||||
items.put(slotList, is);
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, ItemStack> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public Item createItem(ItemStack is, String itemDisplayname, List<String> itemLore, Map<String, String> itemLoreVariables, Enchantment[] itemEnchantments, ItemFlag[] itemFlags) {
|
||||
return new Item(is, itemDisplayname, itemLore, itemLoreVariables, itemEnchantments, itemFlags);
|
||||
}
|
||||
@ -126,9 +136,57 @@ public class nInventoryUtil {
|
||||
}
|
||||
|
||||
public void open() {
|
||||
createInventory();
|
||||
player.openInventory(inv);
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public void setType(InventoryType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setRows(int rows) {
|
||||
if (rows > 6 || rows < 0) {
|
||||
size = 9;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.size = rows * 9;
|
||||
}
|
||||
|
||||
public void setSize(int size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public void createInventory() {
|
||||
if (type == null) {
|
||||
if (title == null) {
|
||||
inv = Bukkit.createInventory(null, size);
|
||||
} else {
|
||||
inv = Bukkit.createInventory(null, size, title);
|
||||
}
|
||||
} else {
|
||||
if (title == null) {
|
||||
inv = Bukkit.createInventory(null, type);
|
||||
} else {
|
||||
inv = Bukkit.createInventory(null, type, title);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
int slot = (int) items.keySet().toArray()[i];
|
||||
inv.setItem(slot, items.get(slot));
|
||||
}
|
||||
}
|
||||
|
||||
public void setInventory(Inventory inv) {
|
||||
this.inv = inv;
|
||||
}
|
||||
|
||||
public Inventory getInventory() {
|
||||
return inv;
|
||||
}
|
||||
@ -201,7 +259,11 @@ public class nInventoryUtil {
|
||||
public void destroy() {
|
||||
HandlerList.unregisterAll(listener);
|
||||
|
||||
title = null;
|
||||
type = null;
|
||||
inv = null;
|
||||
items.clear();
|
||||
|
||||
listener = null;
|
||||
}
|
||||
|
||||
@ -211,28 +273,29 @@ public class nInventoryUtil {
|
||||
|
||||
public class ClickEvent {
|
||||
|
||||
private InventoryAction action;
|
||||
private ClickType click;
|
||||
private int slot;
|
||||
private ItemStack is;
|
||||
|
||||
private boolean close = true;
|
||||
private boolean destroy = true;
|
||||
private boolean cancelled = true;
|
||||
|
||||
public ClickEvent(InventoryAction inventoryAction, int slot, ItemStack is) {
|
||||
this.action = inventoryAction;
|
||||
public ClickEvent(ClickType click, int slot, ItemStack is) {
|
||||
this.click = click;
|
||||
this.slot = slot;
|
||||
this.is = is;
|
||||
}
|
||||
|
||||
public InventoryAction getAction() {
|
||||
return action;
|
||||
public ClickType getClick() {
|
||||
return click;
|
||||
}
|
||||
|
||||
public int getSlot() {
|
||||
return slot;
|
||||
}
|
||||
|
||||
public ItemStack getItemStack() {
|
||||
public ItemStack getItem() {
|
||||
return is;
|
||||
}
|
||||
|
||||
@ -251,5 +314,13 @@ public class nInventoryUtil {
|
||||
public void setWillDestroy(boolean destroy) {
|
||||
this.destroy = destroy;
|
||||
}
|
||||
|
||||
public boolean getCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user