diff --git a/language.yml b/language.yml index 85a905ca..0cbb36af 100644 --- a/language.yml +++ b/language.yml @@ -549,6 +549,11 @@ Command: Message: "&f&oChange Island level materials and points." Permission: Message: "&bSkyBlock &8| &cError&8: &eYou don't have permission to perform that command." + Settings: + Info: + Message: "&f&oChange the default settings for when an Island is created." + Permission: + Message: "&bSkyBlock &8| &cError&8: &eYou don't have permission to perform that command." Structure: Info: Message: "&f&oCreate structures for Islands." @@ -2055,4 +2060,206 @@ Menu: - "&7Points&8: &6%points" - "" - "&eLeft-Click to change points!" - - "&eRight-Click to remove material!" \ No newline at end of file + - "&eRight-Click to remove material!" + Settings: + Categories: + Title: "&8Settings Editor - Categories" + Item: + Exit: + Displayname: "&cClick to Exit" + Visitor: + Displayname: "&aVisitor Settings" + Lore: + - "&7Edit and decide what you want" + - "&7the default Visitor permissions" + - "&7to be when an Island is created." + - "" + - "&eClick to Edit Settings!" + Member: + Displayname: "&aMember Settings" + Lore: + - "&7Edit and decide what you want" + - "&7the default Member permissions" + - "&7to be when an Island is created." + - "" + - "&eClick to Edit Settings!" + Operator: + Displayname: "&aOperator Settings" + Lore: + - "&7Edit and decide what you want" + - "&7the default Operator permissions" + - "&7to be when an Island is created." + - "" + - "&eClick to Edit Settings!" + Owner: + Displayname: "&aIsland Settings" + Lore: + - "&7Edit and decide what you want" + - "&7the default Island permissions" + - "&7to be when an Island is created." + - "" + - "&eClick to Edit Settings!" + Visitor: + Title: "&8Settings Editor - Visitor" + Item: + Return: + Displayname: "&cClick to Return" + Member: + Title: "&8Settings Editor - Member" + Item: + Return: + Displayname: "&cClick to Return" + Operator: + Title: "&8Settings Editor - Operator" + Item: + Return: + Displayname: "&cClick to Return" + Setting: + Status: + Enabled: + Lore: + - "&7Status&8: &atrue" + Disabled: + Lore: + - "&7Status&8: &cfalse" + Invite: + Displayname: "&aSend Invites" + Kick: + Displayname: "&aKick Members & Visitors" + Ban: + Displayname: "&aBan Visitors" + Unban: + Displayname: "&aUnban Visitors" + Visitor: + Displayname: "&aEdit Visitor Settings" + Member: + Displayname: "&aEdit Member Settings" + Island: + Displayname: "&aEdit Island Settings" + MainSpawn: + Displayname: "&aSet Island Main Spawn" + VisitorSpawn: + Displayname: "&aSet Island Visitor Spawn" + Biome: + Displayname: "&aSet Biome" + Weather: + Displayname: "&aSet Weather" + Owner: + Title: "&8Settings Editor - Island" + Item: + Return: + Displayname: "&cClick to Return" + Setting: + Status: + Enabled: + Lore: + - "&7Status&8: &atrue" + Disabled: + Lore: + - "&7Status&8: &cfalse" + NaturalMobSpawning: + Displayname: "&aNatural Mob Spawning" + MobGriefing: + Displayname: "&aMob Griefing" + PvP: + Displayname: "&aPvP" + Explosions: + Displayname: "&aExplosions" + FireSpread: + Displayname: "&aFire Spread" + LeafDecay: + Displayname: "&aLeaf Decay" + KeepItemsOnDeath: + Displayname: "&aKeep Items on Death" + Default: + Item: + Setting: + Status: + Enabled: + Lore: + - "&7Status&8: &atrue" + Disabled: + Lore: + - "&7Status&8: &cfalse" + Destroy: + Displayname: "&aDestroy Blocks" + Place: + Displayname: "&aPlace Blocks" + Anvil: + Displayname: "&aAnvil Use" + ArmorStand: + Displayname: "&aArmorStand Use" + Beacon: + Displayname: "&aBeacon Use" + Bed: + Displayname: "&aBed Use" + AnimalBreeding: + Displayname: "&aAnimal Breeding" + Brewing: + Displayname: "&aBrewing Stand Use" + Bucket: + Displayname: "&aBucket Use" + WaterCollection: + Displayname: "&aWater Collection" + Storage: + Displayname: "&aAccess Storage" + Workbench: + Displayname: "&aWorkbench Use" + Crop: + Displayname: "&aCrop Trampling" + Door: + Displayname: "&aDoor Use" + Gate: + Displayname: "&aGate Use" + Projectile: + Displayname: "&aProjectile Launch" + Enchant: + Displayname: "&aEnchantment Table Use" + Fire: + Displayname: "&aFire Extinguish" + Furnace: + Displayname: "&aFurnace Use" + HorseInventory: + Displayname: "&aAccess Horse Inventory" + MobRiding: + Displayname: "&aMob Riding" + MobHurting: + Displayname: "&aMob Hurting" + MobTaming: + Displayname: "&aMob Taming" + Leash: + Displayname: "&aLeash Use" + LeverButton: + Displayname: "&aLever/Button Use" + Milking: + Displayname: "&aMilking" + Jukebox: + Displayname: "&aJukebox Use" + PressurePlate: + Displayname: "&aPressure Plate Activate" + Redstone: + Displayname: "&aRedstone Use" + Shearing: + Displayname: "&aMob Shearing" + Trading: + Displayname: "&aVillager Trading" + ItemDrop: + Displayname: "&aItem Drop" + ItemPickup: + Displayname: "&aItem Pickup" + Fishing: + Displayname: "&aFishing" + DropperDispenser: + Displayname: "&aDropper/Dispenser Use" + SpawnEgg: + Displayname: "&aSpawn Eggs" + Cake: + Displayname: "&aCake Consumption" + DragonEggUse: + Displayname: "&aDragon Egg Use" + MinecartBoat: + Displayname: "&aMinecart/Boat Use" + Portal: + Displayname: "&aPortal Use" + Hopper: + Displayname: "&aHopper Use" \ No newline at end of file diff --git a/plugin.yml b/plugin.yml index bdf4e4f6..0d345210 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: SkyBlock main: me.goodandevil.skyblock.Main -version: 23 +version: 24 api-version: 1.13 description: A unique SkyBlock plugin author: GoodAndEvil diff --git a/src/me/goodandevil/skyblock/Main.java b/src/me/goodandevil/skyblock/Main.java index 56829310..26a2619c 100644 --- a/src/me/goodandevil/skyblock/Main.java +++ b/src/me/goodandevil/skyblock/Main.java @@ -149,6 +149,7 @@ public class Main extends JavaPlugin { pluginManager.registerEvents(new me.goodandevil.skyblock.menus.admin.Levelling(), this); pluginManager.registerEvents(new me.goodandevil.skyblock.menus.admin.Creator(), this); + pluginManager.registerEvents(new me.goodandevil.skyblock.menus.admin.Settings(), this); pluginManager.registerEvents(new Generator(), this); } diff --git a/src/me/goodandevil/skyblock/command/CommandManager.java b/src/me/goodandevil/skyblock/command/CommandManager.java index f38ebbbd..27b5d689 100644 --- a/src/me/goodandevil/skyblock/command/CommandManager.java +++ b/src/me/goodandevil/skyblock/command/CommandManager.java @@ -119,11 +119,12 @@ public class CommandManager implements CommandExecutor, TabCompleter { this.subCommands.put(CommandManager.Type.Default, subCommands); subCommands = new ArrayList<>(); - subCommands.add(new me.goodandevil.skyblock.command.commands.admin.LevelCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Level.Info.Message")))); subCommands.add(new me.goodandevil.skyblock.command.commands.admin.SetSpawnCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.SetSpawn.Info.Message")))); - subCommands.add(new StructureCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Info.Message")))); subCommands.add(new me.goodandevil.skyblock.command.commands.admin.CreateCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Create.Info.Message")))); subCommands.add(new GeneratorCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Generator.Info.Message")))); + subCommands.add(new me.goodandevil.skyblock.command.commands.admin.LevelCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Level.Info.Message")))); + subCommands.add(new me.goodandevil.skyblock.command.commands.admin.SettingsCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Settings.Info.Message")))); + subCommands.add(new StructureCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Structure.Info.Message")))); subCommands.add(new DeleteCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Delete.Info.Message")))); subCommands.add(new OwnerCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Owner.Info.Message")))); subCommands.add(new ReloadCommand(plugin).setInfo(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Reload.Info.Message")))); diff --git a/src/me/goodandevil/skyblock/command/commands/admin/SettingsCommand.java b/src/me/goodandevil/skyblock/command/commands/admin/SettingsCommand.java new file mode 100644 index 00000000..488404ac --- /dev/null +++ b/src/me/goodandevil/skyblock/command/commands/admin/SettingsCommand.java @@ -0,0 +1,71 @@ +package me.goodandevil.skyblock.command.commands.admin; + +import java.io.File; + +import org.bukkit.ChatColor; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; + +import me.goodandevil.skyblock.Main; +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; +import me.goodandevil.skyblock.config.FileManager.Config; +import me.goodandevil.skyblock.menus.admin.Settings; +import me.goodandevil.skyblock.sound.SoundManager; +import me.goodandevil.skyblock.utils.version.Sounds; + +public class SettingsCommand extends SubCommand { + + private final Main plugin; + private String info; + + public SettingsCommand(Main plugin) { + this.plugin = plugin; + } + + @Override + public void onCommand(Player player, String[] args) { + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); + + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + + if (player.hasPermission("skyblock.admin.settings") || player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*")) { + Settings.getInstance().open(player, Settings.Type.Categories, null); + soundManager.playSound(player, Sounds.CHEST_OPEN.bukkitSound(), 1.0F, 1.0F); + } else { + player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Command.Island.Admin.Settings.Permission.Message"))); + soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); + } + } + + @Override + public String getName() { + return "settings"; + } + + @Override + public String getInfo() { + return info; + } + + @Override + public SubCommand setInfo(String info) { + this.info = info; + + return this; + } + + @Override + public String[] getAliases() { + return new String[] { "permissions", "perms", "p" }; + } + + @Override + public Type getType() { + return CommandManager.Type.Admin; + } +} diff --git a/src/me/goodandevil/skyblock/menus/admin/Settings.java b/src/me/goodandevil/skyblock/menus/admin/Settings.java new file mode 100644 index 00000000..87d344ed --- /dev/null +++ b/src/me/goodandevil/skyblock/menus/admin/Settings.java @@ -0,0 +1,291 @@ +package me.goodandevil.skyblock.menus.admin; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +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.ItemFlag; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import me.goodandevil.skyblock.Main; +import me.goodandevil.skyblock.config.FileManager; +import me.goodandevil.skyblock.config.FileManager.Config; +import me.goodandevil.skyblock.island.Island; +import me.goodandevil.skyblock.sound.SoundManager; +import me.goodandevil.skyblock.utils.item.InventoryUtil; +import me.goodandevil.skyblock.utils.version.Materials; +import me.goodandevil.skyblock.utils.version.Sounds; + +public class Settings implements Listener { + + private static Settings instance; + + public static Settings getInstance(){ + if(instance == null) { + instance = new Settings(); + } + + return instance; + } + + public void open(Player player, Settings.Type menuType, me.goodandevil.skyblock.island.Settings.Role role) { + Main plugin = Main.getInstance(); + + Island island = plugin.getIslandManager().getIsland(plugin.getPlayerDataManager().getPlayerData(player).getOwner()); + InventoryUtil inv = null; + + Config mainConfig = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); + Config languageConfig = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")); + FileConfiguration configLoad = languageConfig.getFileConfiguration(); + + if (menuType == Settings.Type.Categories) { + inv = new InventoryUtil(configLoad.getString("Menu.Admin.Settings.Categories.Title"), null, 1); + inv.addItem(inv.createItem(Materials.OAK_FENCE_GATE.parseItem(), configLoad.getString("Menu.Admin.Settings.Categories.Item.Exit.Displayname"), null, null, null, null), 0, 8); + inv.addItem(inv.createItem(new ItemStack(Material.SIGN), configLoad.getString("Menu.Admin.Settings.Categories.Item.Visitor.Displayname"), configLoad.getStringList("Menu.Admin.Settings.Categories.Item.Visitor.Lore"), null, null, null), 2); + inv.addItem(inv.createItem(new ItemStack(Material.PAINTING), configLoad.getString("Menu.Admin.Settings.Categories.Item.Member.Displayname"), configLoad.getStringList("Menu.Admin.Settings.Categories.Item.Member.Lore"), null, null, null), 3); + inv.addItem(inv.createItem(new ItemStack(Material.ITEM_FRAME), configLoad.getString("Menu.Admin.Settings.Categories.Item.Operator.Displayname"), configLoad.getStringList("Menu.Admin.Settings.Categories.Item.Operator.Lore"), null, null, null), 4); + inv.addItem(inv.createItem(Materials.OAK_SAPLING.parseItem(), configLoad.getString("Menu.Admin.Settings.Categories.Item.Owner.Displayname"), configLoad.getStringList("Menu.Admin.Settings.Categories.Item.Owner.Lore"), null, null, null), 6); + } else if (menuType == Settings.Type.Role) { + if (role == me.goodandevil.skyblock.island.Settings.Role.Visitor || role == me.goodandevil.skyblock.island.Settings.Role.Member) { + inv = new InventoryUtil(configLoad.getString("Menu.Admin.Settings." + role.name() + ".Title"), null, 6); + inv.addItemStack(createItem(island, role, "Destroy", Material.DIAMOND_PICKAXE), 9); + inv.addItemStack(createItem(island, role, "Place", Material.GRASS), 10); + inv.addItemStack(createItem(island, role, "Anvil", Material.ANVIL), 11); + inv.addItemStack(createItem(island, role, "ArmorStand", Material.ARMOR_STAND), 12); + inv.addItemStack(createItem(island, role, "Beacon", Material.BEACON), 13); + inv.addItemStack(createItem(island, role, "Bed", Materials.WHITE_BED.parseMaterial()), 14); + inv.addItemStack(createItem(island, role, "AnimalBreeding", Material.WHEAT), 15); + inv.addItemStack(createItem(island, role, "Brewing", Materials.LEGACY_BREWING_STAND.getPostMaterial()), 16); + inv.addItemStack(createItem(island, role, "Bucket", Material.BUCKET), 17); + inv.addItemStack(createItem(island, role, "WaterCollection", Material.POTION), 18); + inv.addItemStack(createItem(island, role, "Storage", Material.CHEST), 19); + inv.addItemStack(createItem(island, role, "Workbench", Materials.CRAFTING_TABLE.parseMaterial()), 20); + inv.addItemStack(createItem(island, role, "Crop", Materials.WHEAT_SEEDS.parseMaterial()), 21); + inv.addItemStack(createItem(island, role, "Door", Materials.OAK_DOOR.parseMaterial()), 22); + inv.addItemStack(createItem(island, role, "Gate", Materials.OAK_FENCE_GATE.parseMaterial()), 23); + inv.addItemStack(createItem(island, role, "Projectile", Material.ARROW), 24); + inv.addItemStack(createItem(island, role, "Enchant", Materials.ENCHANTING_TABLE.parseMaterial()), 25); + inv.addItemStack(createItem(island, role, "Fire", Material.FLINT_AND_STEEL), 26); + inv.addItemStack(createItem(island, role, "Furnace", Material.FURNACE), 27); + inv.addItemStack(createItem(island, role, "HorseInventory", Materials.CHEST_MINECART.parseMaterial()), 28); + inv.addItemStack(createItem(island, role, "MobRiding", Material.SADDLE), 29); + inv.addItemStack(createItem(island, role, "MobHurting", Materials.WOODEN_SWORD.parseMaterial()), 30); + inv.addItemStack(createItem(island, role, "MobTaming", Materials.POPPY.parseMaterial()), 31); + inv.addItemStack(createItem(island, role, "Leash", Materials.LEAD.parseMaterial()), 32); + inv.addItemStack(createItem(island, role, "LeverButton", Material.LEVER), 33); + inv.addItemStack(createItem(island, role, "Milking", Material.MILK_BUCKET), 34); + inv.addItemStack(createItem(island, role, "Jukebox", Material.JUKEBOX), 35); + inv.addItemStack(createItem(island, role, "PressurePlate", Materials.OAK_PRESSURE_PLATE.parseMaterial()), 37); + inv.addItemStack(createItem(island, role, "Redstone", Material.REDSTONE), 38); + inv.addItemStack(createItem(island, role, "Shearing", Material.SHEARS), 39); + inv.addItemStack(createItem(island, role, "Trading", Material.EMERALD), 40); + inv.addItemStack(createItem(island, role, "ItemDrop", Material.PUMPKIN_SEEDS), 41); + inv.addItemStack(createItem(island, role, "ItemPickup", Material.MELON_SEEDS), 42); + inv.addItemStack(createItem(island, role, "Fishing", Material.FISHING_ROD), 43); + inv.addItemStack(createItem(island, role, "DropperDispenser", Material.DISPENSER), 46); + inv.addItemStack(createItem(island, role, "SpawnEgg", Material.EGG), 47); + inv.addItemStack(createItem(island, role, "Cake", Material.CAKE), 48); + inv.addItemStack(createItem(island, role, "DragonEggUse", Material.DRAGON_EGG), 49); + inv.addItemStack(createItem(island, role, "MinecartBoat", Material.MINECART), 50); + inv.addItemStack(createItem(island, role, "Portal", Material.ENDER_PEARL), 51); + inv.addItemStack(createItem(island, role, "Hopper", Material.HOPPER), 52); + } else if (role == me.goodandevil.skyblock.island.Settings.Role.Operator) { + if (mainConfig.getFileConfiguration().getBoolean("Island.Visitor.Banning")) { + inv = new InventoryUtil(configLoad.getString("Menu.Admin.Settings." + role.name() + ".Title"), null, 3); + inv.addItemStack(createItem(island, role, "Invite", Materials.WRITABLE_BOOK.parseMaterial()), 10); + inv.addItemStack(createItem(island, role, "Kick", Material.IRON_DOOR), 11); + inv.addItemStack(createItem(island, role, "Ban", Material.IRON_AXE), 12); + inv.addItemStack(createItem(island, role, "Unban", Material.NAME_TAG), 13); + inv.addItemStack(createItem(island, role, "Visitor", Material.SIGN), 14); + inv.addItemStack(createItem(island, role, "Member", Material.PAINTING), 15); + inv.addItemStack(createItem(island, role, "Island", Materials.OAK_SAPLING.parseMaterial()), 16); + inv.addItemStack(createItem(island, role, "MainSpawn", Material.EMERALD), 20); + inv.addItemStack(createItem(island, role, "VisitorSpawn", Material.NETHER_STAR), 21); + inv.addItemStack(createItem(island, role, "Biome", Material.MAP), 23); + inv.addItemStack(createItem(island, role, "Weather", Materials.CLOCK.parseMaterial()), 24); + } else { + inv = new InventoryUtil(configLoad.getString("Menu.Admin.Settings." + role.name() + ".Title"), null, 2); + inv.addItemStack(createItem(island, role, "Invite", Materials.WRITABLE_BOOK.parseMaterial()), 9); + inv.addItemStack(createItem(island, role, "Kick", Material.IRON_DOOR), 10); + inv.addItemStack(createItem(island, role, "Visitor", Material.SIGN), 11); + inv.addItemStack(createItem(island, role, "Member", Material.PAINTING), 12); + inv.addItemStack(createItem(island, role, "Island", Materials.OAK_SAPLING.parseMaterial()), 13); + inv.addItemStack(createItem(island, role, "MainSpawn", Material.EMERALD), 14); + inv.addItemStack(createItem(island, role, "VisitorSpawn", Material.NETHER_STAR), 15); + inv.addItemStack(createItem(island, role, "Biome", Material.MAP), 16); + inv.addItemStack(createItem(island, role, "Weather", Materials.CLOCK.parseMaterial()), 17); + } + } else if (role == me.goodandevil.skyblock.island.Settings.Role.Owner) { + inv = new InventoryUtil(configLoad.getString("Menu.Admin.Settings." + role.name() + ".Title"), null, 2); + inv.addItemStack(createItem(island, role, "NaturalMobSpawning", Materials.PIG_SPAWN_EGG.parseMaterial()), 10); + inv.addItemStack(createItem(island, role, "MobGriefing", Materials.IRON_SHOVEL.parseMaterial()), 11); + inv.addItemStack(createItem(island, role, "PvP", Material.DIAMOND_SWORD), 12); + inv.addItemStack(createItem(island, role, "Explosions", Materials.GUNPOWDER.parseMaterial()), 13); + inv.addItemStack(createItem(island, role, "FireSpread", Material.FLINT_AND_STEEL), 14); + inv.addItemStack(createItem(island, role, "LeafDecay", Materials.OAK_LEAVES.parseMaterial()), 15); + inv.addItemStack(createItem(island, role, "KeepItemsOnDeath", Material.ITEM_FRAME), 16); + } + + inv.addItem(inv.createItem(Materials.OAK_FENCE_GATE.parseItem(), configLoad.getString("Menu.Admin.Settings." + role.name() + ".Item.Return.Displayname"), null, null, null, null), 0, 8); + } + + player.openInventory(inv.getInventory()); + } + + private ItemStack createItem(Island island, me.goodandevil.skyblock.island.Settings.Role role, String setting, Material material) { + Main plugin = Main.getInstance(); + + FileManager fileManager = plugin.getFileManager(); + + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + + List itemLore = new ArrayList<>(); + + ItemStack is = new ItemStack(material); + ItemMeta im = is.getItemMeta(); + + String roleName = role.name(); + + if (role == me.goodandevil.skyblock.island.Settings.Role.Visitor || role == me.goodandevil.skyblock.island.Settings.Role.Member) { + roleName = "Default"; + } + + im.setDisplayName(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Settings." + roleName + ".Item.Setting." + setting + ".Displayname"))); + + if (fileManager.getConfig(new File(plugin.getDataFolder(), "settings.yml")).getFileConfiguration().getBoolean(role.name() + "." + setting)) { + for (String itemLoreList : configLoad.getStringList("Menu.Admin.Settings." + roleName + ".Item.Setting.Status.Enabled.Lore")) { + itemLore.add(ChatColor.translateAlternateColorCodes('&', itemLoreList)); + } + } else { + for (String itemLoreList : configLoad.getStringList("Menu.Admin.Settings." + roleName + ".Item.Setting.Status.Disabled.Lore")) { + itemLore.add(ChatColor.translateAlternateColorCodes('&', itemLoreList)); + } + } + + im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); + im.setLore(itemLore); + is.setItemMeta(im); + + return is; + } + + @EventHandler + public void onInventoryClick(InventoryClickEvent event) { + Player player = (Player) event.getWhoClicked(); + ItemStack is = event.getCurrentItem(); + + if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR) { + Main plugin = Main.getInstance(); + + SoundManager soundManager = plugin.getSoundManager(); + FileManager fileManager = plugin.getFileManager(); + + Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + + if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Settings.Categories.Title"))) || event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Settings.Visitor.Title"))) || event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Settings.Member.Title"))) || event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Settings.Operator.Title"))) || event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Settings.Owner.Title")))) { + event.setCancelled(true); + + if (!(player.hasPermission("skyblock.admin.settings") || player.hasPermission("skyblock.admin.*") || player.hasPermission("skyblock.*"))) { + player.sendMessage(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Admin.Settings.Permission.Message"))); + soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F); + + return; + } + + if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Settings.Categories.Title")))) { + if ((event.getCurrentItem().getType() == Materials.OAK_FENCE_GATE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Settings.Categories.Item.Exit.Displayname"))))) { + soundManager.playSound(player, Sounds.CHEST_CLOSE.bukkitSound(), 1.0F, 1.0F); + player.closeInventory(); + } else if ((is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Settings.Categories.Item.Visitor.Displayname"))))) { + open(player, Settings.Type.Role, me.goodandevil.skyblock.island.Settings.Role.Visitor); + soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F); + } else if ((event.getCurrentItem().getType() == Material.PAINTING) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Settings.Categories.Item.Member.Displayname"))))) { + open(player, Settings.Type.Role, me.goodandevil.skyblock.island.Settings.Role.Member); + soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F); + } else if ((event.getCurrentItem().getType() == Material.ITEM_FRAME) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Settings.Categories.Item.Operator.Displayname"))))) { + open(player, Settings.Type.Role, me.goodandevil.skyblock.island.Settings.Role.Operator); + soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F); + } else if ((event.getCurrentItem().getType() == Materials.OAK_SAPLING.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Settings.Categories.Item.Owner.Displayname"))))) { + open(player, Settings.Type.Role, me.goodandevil.skyblock.island.Settings.Role.Owner); + soundManager.playSound(player, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F); + } + } else if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Settings.Visitor.Title"))) || event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Settings.Member.Title"))) || event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Settings.Operator.Title"))) || event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Settings.Owner.Title")))) { + if ((event.getCurrentItem().getType() == Materials.OAK_FENCE_GATE.parseMaterial()) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Settings.Visitor.Item.Return.Displayname"))) || is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Settings.Member.Item.Return.Displayname"))) || is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Settings.Operator.Item.Return.Displayname"))) || is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Settings.Owner.Item.Return.Displayname"))))) { + open(player, Settings.Type.Categories, null); + soundManager.playSound(player, Sounds.ARROW_HIT.bukkitSound(), 1.0F, 1.0F); + } else if (is.hasItemMeta()) { + me.goodandevil.skyblock.island.Settings.Role role = null; + String roleName = null, rolePermissionName = null; + + if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Settings.Visitor.Title")))) { + role = me.goodandevil.skyblock.island.Settings.Role.Visitor; + roleName = "Visitor"; + rolePermissionName = "Default"; + } else if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Settings.Member.Title")))) { + role = me.goodandevil.skyblock.island.Settings.Role.Member; + roleName = "Member"; + rolePermissionName = "Default"; + } else if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Settings.Operator.Title")))) { + role = me.goodandevil.skyblock.island.Settings.Role.Operator; + roleName = role.name(); + rolePermissionName = role.name(); + } else if (event.getInventory().getName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Settings.Owner.Title")))) { + role = me.goodandevil.skyblock.island.Settings.Role.Owner; + roleName = role.name(); + rolePermissionName = role.name(); + } + + FileConfiguration settingsConfigLoad = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "settings.yml")).getFileConfiguration(); + + for (String settingList : settingsConfigLoad.getConfigurationSection(roleName).getKeys(false)) { + if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Admin.Settings." + rolePermissionName + ".Item.Setting." + settingList + ".Displayname")))) { + if (settingsConfigLoad.getBoolean(roleName + "." + settingList)) { + settingsConfigLoad.set(roleName + "." + settingList, false); + } else { + settingsConfigLoad.set(roleName + "." + settingList, true); + } + + Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() { + @Override + public void run() { + try { + Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "settings.yml")); + config.getFileConfiguration().save(config.getFile()); + } catch (IOException e) { + e.printStackTrace(); + } + } + }); + + break; + } + } + + soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F); + open(player, Settings.Type.Role, role); + } + } + } + } + } + + public enum Type { + + Categories, + Panel, + Role; + + } +}