diff --git a/.idea/libraries/Maven__com_flowpowered_flow_math_1_0_3.xml b/.idea/libraries/Maven__com_flowpowered_flow_math_1_0_3.xml new file mode 100644 index 0000000..2339b45 --- /dev/null +++ b/.idea/libraries/Maven__com_flowpowered_flow_math_1_0_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__com_google_code_findbugs_jsr305_3_0_2.xml b/.idea/libraries/Maven__com_google_code_findbugs_jsr305_3_0_2.xml new file mode 100644 index 0000000..1c380d0 --- /dev/null +++ b/.idea/libraries/Maven__com_google_code_findbugs_jsr305_3_0_2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__com_sk89q_worldedit_7_0_0.xml b/.idea/libraries/Maven__com_sk89q_worldedit_7_0_0.xml new file mode 100644 index 0000000..abfa991 --- /dev/null +++ b/.idea/libraries/Maven__com_sk89q_worldedit_7_0_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__me_lucko_helper_5_3_0.xml b/.idea/libraries/Maven__me_lucko_helper_5_3_0.xml new file mode 100644 index 0000000..0eb2883 --- /dev/null +++ b/.idea/libraries/Maven__me_lucko_helper_5_3_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_spigotmc_spigot_1_13_2.xml b/.idea/libraries/Maven__org_spigotmc_spigot_1_13_2.xml new file mode 100644 index 0000000..01fd179 --- /dev/null +++ b/.idea/libraries/Maven__org_spigotmc_spigot_1_13_2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index cec1a03..eba3240 100644 --- a/pom.xml +++ b/pom.xml @@ -54,10 +54,16 @@ + + me.lucko + helper + LATEST + provided + org.spigotmc spigot - 1.12.2 + 1.13.2 com.songoda diff --git a/src/main/java/com/songoda/epicbuckets/EpicBuckets.java b/src/main/java/com/songoda/epicbuckets/EpicBuckets.java index 17d3f23..5a9830d 100644 --- a/src/main/java/com/songoda/epicbuckets/EpicBuckets.java +++ b/src/main/java/com/songoda/epicbuckets/EpicBuckets.java @@ -1,182 +1,21 @@ package com.songoda.epicbuckets; -import com.songoda.epicbuckets.commands.GenbucketAdminCommand; -import com.songoda.epicbuckets.commands.GenbucketCommand; -import com.songoda.epicbuckets.filehandler.files.ShopFile; -import com.songoda.epicbuckets.listeners.GenbucketPlaceListener; -import com.songoda.epicbuckets.listeners.InventoryClickListener; -import com.songoda.epicbuckets.util.ChatUtil; -import com.songoda.epicbuckets.util.ServerVersion; -import net.milkbowl.vault.chat.Chat; -import net.milkbowl.vault.economy.Economy; -import net.milkbowl.vault.permission.Permission; -import org.apache.commons.lang.ArrayUtils; -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.java.JavaPlugin; -import java.io.File; - public class EpicBuckets extends JavaPlugin { - private static CommandSender console = Bukkit.getConsoleSender(); - private static EpicBuckets INSTANCE; - private static Permission permission = null; - private static Economy economy = null; - private static Chat chat = null; - public YamlConfiguration shopFile; + private static EpicBuckets instance; - private Locale locale; - - private ServerVersion serverVersion = ServerVersion.fromPackageName(Bukkit.getServer().getClass().getPackage().getName()); - - public static EpicBuckets getInstance() { - return INSTANCE; - } + public static EpicBuckets getInstance() { return instance; } @Override public void onEnable() { - console.sendMessage(ChatUtil.colorString("&a=============================")); - console.sendMessage(ChatUtil.colorString("&7EpicBuckets " + this.getDescription().getVersion() + " by &5Songoda <3!")); - console.sendMessage(ChatUtil.colorString("&7Action: &aEnabling&7...")); - INSTANCE = this; - - if (!isEnabled()) - return; - - // Locales - Locale.init(this); - Locale.saveDefaultLocale("en_US"); - this.locale = Locale.getLocale(getConfig().getString("Locale", "en_US")); - - - this.setUpFiles(); - - this.setupPermissions(); - this.setupEconomy(); - this.setupChat(); - this.setUpCommands(); - this.registerListeners(); - - console.sendMessage(ChatUtil.colorString("&a=============================")); - } - - private void save(String folder, String file) { - File f = null; - if(folder != null && !folder.equals("")) - f = new File(getDataFolder() + File.separator + folder + File.separator, file); - else - f = new File(getDataFolder() + File.separator, file); - if(!f.exists()) { - f.getParentFile().mkdirs(); - saveResource(folder != null && !folder.equals("") ? folder + File.separator + file : file, false); - } - if(file.equals("shops.yml")) { - shopFile = YamlConfiguration.loadConfiguration(f); - } + instance = this; } @Override public void onDisable() { - console.sendMessage(ChatUtil.colorString("&a=============================")); - console.sendMessage(ChatUtil.colorString("&7EpicBuckets " + this.getDescription().getVersion() + " by &5Songoda <3!")); - console.sendMessage(ChatUtil.colorString("&7Action: &cDisabling&7...")); - console.sendMessage(ChatUtil.colorString("&a=============================")); - } - private void setUpFiles() { - - if (!getDataFolder().exists()) { - getDataFolder().mkdirs(); - getLogger().warning("Folder not found, generating files!"); - saveResource("shops.yml", false); - saveDefaultConfig(); - } - saveDefaultConfig(); - save(null, "shops.yml"); - } - - public double getBalance(Player player) { - return economy.getBalance(player); - } - - public void withdrawBalance(Player player, int amount, boolean sendMessage) { - - if (sendMessage) - player.sendMessage(locale.getMessage("interface.withdrawl.success").replace("{amount}", String.valueOf(amount))); - - economy.withdrawPlayer(player, amount); - } - - - private void setUpCommands() { - - getCommand("genbucket").setExecutor(new GenbucketCommand()); - getCommand("genbucketadmin").setExecutor(new GenbucketAdminCommand()); - - } - - private void registerListeners() { - - this.getServer().getPluginManager().registerEvents(new InventoryClickListener(), this); - this.getServer().getPluginManager().registerEvents(new GenbucketPlaceListener(), this); - - } - - - public void reloadFiles() { - this.locale.reloadMessages(); - reloadConfig(); - - } - - private boolean setupPermissions() { - RegisteredServiceProvider permissionProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class); - if (permissionProvider != null) { - permission = permissionProvider.getProvider(); - } - return (permission != null); - } - - private boolean setupChat() { - - RegisteredServiceProvider chatProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.chat.Chat.class); - if (chatProvider != null) { - chat = chatProvider.getProvider(); - } - - return (chat != null); - } - - private boolean setupEconomy() { - RegisteredServiceProvider economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class); - if (economyProvider != null) { - economy = economyProvider.getProvider(); - } - - return (economy != null); - } - - public ServerVersion getServerVersion() { - return serverVersion; - } - - public boolean isServerVersion(ServerVersion version) { - return serverVersion == version; - } - public boolean isServerVersion(ServerVersion... versions) { - return ArrayUtils.contains(versions, serverVersion); - } - - public boolean isServerVersionAtLeast(ServerVersion version) { - return serverVersion.ordinal() >= version.ordinal(); - } - - public Locale getLocale() { - return locale; } } diff --git a/src/main/java/com/songoda/epicbuckets/Locale.java b/src/main/java/com/songoda/epicbuckets/Locale.java deleted file mode 100644 index 866f1d3..0000000 --- a/src/main/java/com/songoda/epicbuckets/Locale.java +++ /dev/null @@ -1,364 +0,0 @@ -package com.songoda.epicbuckets; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; -import org.apache.commons.io.IOUtils; -import org.bukkit.ChatColor; -import org.bukkit.plugin.java.JavaPlugin; - -import java.io.*; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - -/** - * Assists in the creation of multiple localizations and languages, - * as well as the generation of default .lang files - * - * @author Parker Hawke - 2008Choco - */ -public class Locale { - - private static JavaPlugin plugin; - private static final List LOCALES = Lists.newArrayList(); - - private static final Pattern NODE_PATTERN = Pattern.compile("(\\w+(?:\\.{1}\\w+)*)\\s*=\\s*\"(.*)\""); - private static final String FILE_EXTENSION = ".lang"; - private static File localeFolder; - - private static String defaultLocale; - - private final Map nodes = new HashMap<>(); - - private final File file; - private final String name, region; - - private Locale(String name, String region) { - if (plugin == null) - throw new IllegalStateException("Cannot generate locales without first initializing the class (Locale#init(JavaPlugin))"); - - this.name = name.toLowerCase(); - this.region = region.toUpperCase(); - - String fileName = name + "_" + region + FILE_EXTENSION; - this.file = new File(localeFolder, fileName); - - if (this.reloadMessages()) return; - - plugin.getLogger().info("Loaded locale " + fileName); - } - - /** - * Get the name of the language that this locale is based on. - * (i.e. "en" for English, or "fr" for French) - * - * @return the name of the language - */ - public String getName() { - return name; - } - - /** - * Get the name of the region that this locale is from. - * (i.e. "US" for United States or "CA" for Canada) - * - * @return the name of the region - */ - public String getRegion() { - return region; - } - - /** - * Return the entire locale tag (i.e. "en_US") - * - * @return the language tag - */ - public String getLanguageTag() { - return name + "_" + region; - } - - /** - * Get the file that represents this locale - * - * @return the locale file (.lang) - */ - public File getFile() { - return file; - } - - /** - * Get a message set for a specific node - * - * @param node the node to get - * @return the message for the specified node - */ - public String getMessage(String node) { - return ChatColor.translateAlternateColorCodes('&', this.getMessageOrDefault(node, node)); - } - - /** - * Get a message set for a specific node and replace its params with a supplied arguments. - * - * @param node the node to get - * @param args the replacement arguments - * @return the message for the specified node - */ - public String getMessage(String node, Object... args) { - String message = getMessage(node); - for (Object arg : args) { - message = message.replaceFirst("\\%.*?\\%", arg.toString()); - } - return message; - } - - /** - * Get a message set for a specific node - * - * @param node the node to get - * @param defaultValue the default value given that a value for the node was not found - * @return the message for the specified node. Default if none found - */ - public String getMessageOrDefault(String node, String defaultValue) { - return this.nodes.getOrDefault(node, defaultValue); - } - - /** - * Get the key-value map of nodes to messages - * - * @return node-message map - */ - public Map getMessageNodeMap() { - return ImmutableMap.copyOf(nodes); - } - - /** - * Clear the previous message cache and load new messages directly from file - * - * @return reload messages from file - */ - public boolean reloadMessages() { - if (!this.file.exists()) { - plugin.getLogger().warning("Could not find file for locale " + this.name); - return false; - } - - this.nodes.clear(); // Clear previous data (if any) - - try (BufferedReader reader = new BufferedReader(new FileReader(file))) { - String line; - for (int lineNumber = 0; (line = reader.readLine()) != null; lineNumber++) { - if (line.isEmpty() || line.startsWith("#") /* Comment */) continue; - - Matcher matcher = NODE_PATTERN.matcher(line); - if (!matcher.find()) { - System.err.println("Invalid locale syntax at (line=" + lineNumber + ")"); - continue; - } - - nodes.put(matcher.group(1), matcher.group(2)); - } - } catch (IOException e) { - e.printStackTrace(); - return false; - } - return true; - } - - /** - * Initialize the locale class to generate information and search for localizations. - * This must be called before any other methods in the Locale class can be invoked. - * Note that this will also call {@link #searchForLocales()}, so there is no need to - * invoke it for yourself after the initialization - * - * @param plugin the plugin instance - */ - public static void init(JavaPlugin plugin) { - Locale.plugin = plugin; - - if (localeFolder == null) { - localeFolder = new File(plugin.getDataFolder(), "locales/"); - } - - localeFolder.mkdirs(); - Locale.searchForLocales(); - } - - /** - * Find all .lang file locales under the "locales" folder - */ - public static void searchForLocales() { - if (!localeFolder.exists()) localeFolder.mkdirs(); - - for (File file : localeFolder.listFiles()) { - String name = file.getName(); - if (!name.endsWith(".lang")) continue; - - String fileName = name.substring(0, name.lastIndexOf('.')); - String[] localeValues = fileName.split("_"); - - if (localeValues.length != 2) continue; - if (localeExists(localeValues[0] + "_" + localeValues[1])) continue; - - LOCALES.add(new Locale(localeValues[0], localeValues[1])); - plugin.getLogger().info("Found and loaded locale \"" + fileName + "\""); - } - } - - /** - * Get a locale by its entire proper name (i.e. "en_US") - * - * @param name the full name of the locale - * @return locale of the specified name - */ - public static Locale getLocale(String name) { - for (Locale locale : LOCALES) - if (locale.getLanguageTag().equalsIgnoreCase(name)) return locale; - return null; - } - - /** - * Get a locale from the cache by its name (i.e. "en" from "en_US") - * - * @param name the name of the language - * @return locale of the specified language. Null if not cached - */ - public static Locale getLocaleByName(String name) { - for (Locale locale : LOCALES) - if (locale.getName().equalsIgnoreCase(name)) return locale; - return null; - } - - /** - * Get a locale from the cache by its region (i.e. "US" from "en_US") - * - * @param region the name of the region - * @return locale of the specified region. Null if not cached - */ - public static Locale getLocaleByRegion(String region) { - for (Locale locale : LOCALES) - if (locale.getRegion().equalsIgnoreCase(region)) return locale; - return null; - } - - /** - * Check whether a locale exists and is registered or not - * - * @param name the whole language tag (i.e. "en_US") - * @return true if it exists - */ - public static boolean localeExists(String name) { - for (Locale locale : LOCALES) - if (locale.getLanguageTag().equals(name)) return true; - return false; - } - - /** - * Get an immutable list of all currently loaded locales - * - * @return list of all locales - */ - public static List getLocales() { - return ImmutableList.copyOf(LOCALES); - } - - /** - * Save a default locale file from the project source directory, to the locale folder - * - * @param path the path to the file to save - * @param fileName the name of the file to save - * @return true if the operation was successful, false otherwise - */ - public static boolean saveDefaultLocale(String path, String fileName) { - if (!localeFolder.exists()) localeFolder.mkdirs(); - - if (!fileName.endsWith(FILE_EXTENSION)) - fileName = (fileName.lastIndexOf(".") == -1 ? fileName : fileName.substring(0, fileName.lastIndexOf('.'))) + FILE_EXTENSION; - - File destinationFile = new File(localeFolder, fileName); - if (destinationFile.exists()) { - return compareFiles(plugin.getResource(fileName), destinationFile); - } - - try (OutputStream outputStream = new FileOutputStream(destinationFile)) { - IOUtils.copy(plugin.getResource(fileName), outputStream); - - fileName = fileName.substring(0, fileName.lastIndexOf('.')); - String[] localeValues = fileName.split("_"); - - if (localeValues.length != 2) return false; - - LOCALES.add(new Locale(localeValues[0], localeValues[1])); - if (defaultLocale == null) defaultLocale = fileName; - - return true; - } catch (IOException e) { - return false; - } - } - - /** - * Save a default locale file from the project source directory, to the locale folder - * - * @param fileName the name of the file to save - * @return true if the operation was successful, false otherwise - */ - public static boolean saveDefaultLocale(String fileName) { - return saveDefaultLocale("", fileName); - } - - /** - * Clear all current locale data - */ - public static void clearLocaleData() { - for (Locale locale : LOCALES) - locale.nodes.clear(); - LOCALES.clear(); - } - - // Write new changes to existing files, if any at all - private static boolean compareFiles(InputStream defaultFile, File existingFile) { - // Look for default - if (defaultFile == null) { - defaultFile = plugin.getResource(defaultLocale != null ? defaultLocale : "en_US"); - if (defaultFile == null) return false; // No default at all - } - - boolean changed = false; - - List defaultLines, existingLines; - try (BufferedReader defaultReader = new BufferedReader(new InputStreamReader(defaultFile)); - BufferedReader existingReader = new BufferedReader(new FileReader(existingFile)); - BufferedWriter writer = new BufferedWriter(new FileWriter(existingFile, true))) { - defaultLines = defaultReader.lines().collect(Collectors.toList()); - existingLines = existingReader.lines().map(s -> s.split("\\s*=")[0]).collect(Collectors.toList()); - - for (String defaultValue : defaultLines) { - if (defaultValue.isEmpty() || defaultValue.startsWith("#")) continue; - - String key = defaultValue.split("\\s*=")[0]; - - if (!existingLines.contains(key)) { - if (!changed) { - writer.newLine(); - writer.newLine(); - writer.write("# New messages for " + plugin.getName() + " v" + plugin.getDescription().getVersion()); - } - - writer.newLine(); - writer.write(defaultValue); - - changed = true; - } - } - } catch (IOException e) { - return false; - } - - return changed; - } - -} \ No newline at end of file diff --git a/src/main/java/com/songoda/epicbuckets/commands/GenbucketAdminCommand.java b/src/main/java/com/songoda/epicbuckets/commands/GenbucketAdminCommand.java deleted file mode 100644 index 5b7ce1a..0000000 --- a/src/main/java/com/songoda/epicbuckets/commands/GenbucketAdminCommand.java +++ /dev/null @@ -1,359 +0,0 @@ -package com.songoda.epicbuckets.commands; - -import com.songoda.epicbuckets.EpicBuckets; -import com.songoda.epicbuckets.genbuckets.GenbucketItem; -import com.songoda.epicbuckets.genbuckets.GenbucketManager; -import com.songoda.epicbuckets.inventories.InventoryManager; -import com.songoda.epicbuckets.util.ChatUtil; -import com.songoda.epicbuckets.util.Util; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.OfflinePlayer; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -/** - * GenbucketAdminCommand created by: SoFocused - * Date Created: oktober 06 2018 - * Time created: 11:56 - */ -public class GenbucketAdminCommand implements CommandExecutor { - - private EpicBuckets plugin = EpicBuckets.getInstance(); - - @Override - public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { - - if (args.length == 0) { - - if (!sender.hasPermission("genbucketadmin.command.help")) { - sender.sendMessage(plugin.getLocale().getMessage("event.general.nopermission")); - return true; - } - - sender.sendMessage(""); - sender.sendMessage(ChatUtil.colorString(ChatUtil.getPrefix() + "&7Version " + plugin.getDescription().getVersion() + " Created with <3 by &5&l&oBrianna")); - sender.sendMessage(ChatUtil.colorString("&8 - &agenbucketadmin info&7 - Plugin information")); - sender.sendMessage(ChatUtil.colorString("&8 - &agenbucketadmin admin&7 - Toggle admin mode")); - sender.sendMessage(ChatUtil.colorString("&8 - &agenbucketadmin reload&7 - Reload the configs")); - sender.sendMessage(ChatUtil.colorString("&8 - &agenbucketadmin toggleStatus&7 - Enable/Disable genbuckets")); - sender.sendMessage(ChatUtil.colorString("&8 - &agenbucketadmin toggleSponge&7 - Enable/Disable sponges")); - sender.sendMessage(ChatUtil.colorString("&8 - &agenbucketadmin toggleEnchant&7 - Toggle glowing genbuckets")); - sender.sendMessage(ChatUtil.colorString("&8 - &agenbucketadmin toggleInfinity&7 - Toggle infinite genbuckets")); - sender.sendMessage(ChatUtil.colorString("&8 - &agenbucketadmin activepanel&7 - Opens a GUI")); - sender.sendMessage(ChatUtil.colorString("&8 - &agenbucketadmin setHeight &7 - Modify vertical height")); - sender.sendMessage(ChatUtil.colorString("&8 - &agenbucketadmin setLength &7 - Modify horizontal length")); - sender.sendMessage(ChatUtil.colorString("&8 - &agenbucketadmin give ")); - sender.sendMessage(""); - return true; - } - - if (args.length == 1) { - - String permission = "genbucketadmin.command." + args[0]; - - if (args[0].equalsIgnoreCase("admin")) { - - if (!sender.hasPermission(permission)) { - sender.sendMessage(plugin.getLocale().getMessage("event.general.nopermission")); - return true; - } - - if (!(sender instanceof Player)) { - sender.sendMessage(plugin.getLocale().getMessage("event.general.playercommand")); - return true; - } - - Player player = (Player) sender; - - boolean isPlayerInAdminMode = GenbucketManager.adminList.contains(player.getUniqueId()); - - if (isPlayerInAdminMode) { - - // Player is in admin mode - - GenbucketManager.adminList.remove(player.getUniqueId()); - - player.sendMessage(plugin.getLocale().getMessage("command.admin.off")); - - } else { - - // Player is not in admin mode - - GenbucketManager.adminList.add(player.getUniqueId()); - - player.sendMessage(plugin.getLocale().getMessage("command.admin.on")); - - } - - return true; - } - - if (args[0].equalsIgnoreCase("reload")) { - - if (!sender.hasPermission(permission)) { - sender.sendMessage(plugin.getLocale().getMessage("event.general.nopermission")); - return true; - } - - try { - - EpicBuckets.getInstance().reloadFiles(); - - } catch (Exception e) { - sender.sendMessage(plugin.getLocale().getMessage("event.general.error")); - e.printStackTrace(); - } - - sender.sendMessage(plugin.getLocale().getMessage("command.reload.success")); - - return true; - } - - - if (args[0].equalsIgnoreCase("activepanel")) { - - if (!sender.hasPermission(permission)) { - sender.sendMessage(plugin.getLocale().getMessage("event.general.nopermission")); - return true; - } - - if (!(sender instanceof Player)) { - sender.sendMessage(plugin.getLocale().getMessage("event.general.playercommand")); - return true; - } - - Player player = (Player) sender; - - InventoryManager inventoryManager = new InventoryManager(); - - inventoryManager.openActiveGenbuckets(player); - - return true; - } - - if (args[0].equalsIgnoreCase("toggleStatus")) { - - if (!sender.hasPermission(permission)) { - sender.sendMessage(plugin.getLocale().getMessage("event.general.nopermission")); - return true; - } - - boolean oldValue = Util.disableGenbuckets(); - - plugin.getConfig().set("DISABLE-GENBUCKETS", !oldValue); - - toggleSetting(sender, "disable-genbuckets", oldValue); - - return true; - - } - - if (args[0].equalsIgnoreCase("toggleInfinity")) { - - if (!sender.hasPermission(permission)) { - sender.sendMessage(plugin.getLocale().getMessage("event.general.nopermission")); - return true; - } - - boolean oldValue = Util.infiniteGenbuckets(); - - plugin.getConfig().set("INFINITE-USE", !oldValue); - - plugin.saveConfig(); - - toggleSetting(sender, "INFINITE-USE", oldValue); - - return true; - - } - - if (args[0].equalsIgnoreCase("toggleSponge")) { - - if (!sender.hasPermission(permission)) { - sender.sendMessage(plugin.getLocale().getMessage("event.general.nopermission")); - return true; - } - - boolean oldValue = Util.useSpongeSupport(); - - plugin.getConfig().set("USE-SPONGE-SUPPORT", !oldValue); - - plugin.saveConfig(); - - toggleSetting(sender, "use-sponge-support", oldValue); - - return true; - - } - - if (args[0].equalsIgnoreCase("info")) { - - String spigotUserId = "%%__USER__%%"; - String resourceId = "%%__RESOURCE__%%"; - String uniqueDownload = "%%__NONCE__%%"; - sender.sendMessage("§aName: §c" + EpicBuckets.getInstance().getDescription().getName()); - sender.sendMessage("§aVersion: §c" + EpicBuckets.getInstance().getDescription().getVersion()); - sender.sendMessage("§aDeveloper: §c" + EpicBuckets.getInstance().getDescription().getAuthors()); - sender.sendMessage("§aSpigot ID: §c" + spigotUserId); - sender.sendMessage("§aResource ID: §c" + resourceId); - sender.sendMessage("§aUnique download ID: §c" + uniqueDownload); - sender.sendMessage("§aRegistered to: §fhttps://www.spigotmc.org/members/" + spigotUserId); - - return true; - } - - if (args[0].equalsIgnoreCase("toggleEnchant")) { - - if (!sender.hasPermission(permission)) { - sender.sendMessage(plugin.getLocale().getMessage("event.general.nopermission")); - return true; - } - - boolean oldValue = Util.enchantGenbuckets(); - - plugin.getConfig().set("ENCHANT", !oldValue); - - plugin.saveConfig(); - - toggleSetting(sender, "enchant", oldValue); - - return true; - - } - - - } // END of args.length == 1 - - if (args.length == 2) { - - String permission = "genbucketadmin.command." + args[0]; - - if (args[0].equalsIgnoreCase("setheight")) { - - if (!sender.hasPermission(permission)) { - sender.sendMessage(plugin.getLocale().getMessage("event.general.nopermission")); - return true; - } - - int height; - - try { - height = Integer.parseInt(args[1]); - } catch (NumberFormatException e) { - - return true; - } - - - plugin.getConfig().set("MAX-VERTICAL-HEIGHT", height); - - toggleSetting(sender, "MAX-VERTICAL-HEIGHT", String.valueOf(height)); - - plugin.saveConfig(); - - return true; - - } - - if (args[0].equalsIgnoreCase("setlength")) { - - if (!sender.hasPermission(permission)) { - sender.sendMessage(plugin.getLocale().getMessage("event.general.nopermission")); - return true; - } - - int height; - - try { - height = Integer.parseInt(args[1]); - } catch (NumberFormatException e) { - - return true; - } - - - plugin.getConfig().set("MAX-HORIZONTAL-LENGTH", height); - - plugin.saveConfig(); - - toggleSetting(sender, "MAX-HORIZONTAL-LENGTH", String.valueOf(height)); - - return true; - - } - - } - - if (args.length == 5) { - - String permission = "genbucketadmin.command." + args[0]; - - - if (args[0].equalsIgnoreCase("give")) { - - if (!sender.hasPermission(permission)) { - sender.sendMessage(plugin.getLocale().getMessage("event.general.nopermission")); - return true; - } - - // /genbucketadmin give - - OfflinePlayer player = Bukkit.getOfflinePlayer(args[1]); - - if (!player.hasPlayedBefore()) { - - sender.sendMessage("§cPlayer '" + args[1] + "' has never joined"); - - return true; - } else if (!player.isOnline()) { - - sender.sendMessage("§cPlayer '" + player.getName() + "' is not online!"); - - return true; - } - - int amount; - - try { - amount = Integer.parseInt(args[4]); - } catch (NumberFormatException e) { - sender.sendMessage("§cPlease specify a number"); - return true; - } - - String shopName = args[2]; - String key = args[3]; - - try { - GenbucketItem genbucketItem = new GenbucketItem(shopName, key); - - genbucketItem.setAmount(amount); - - player.getPlayer().getInventory().addItem(genbucketItem.getGenbucketItem()); - - sender.sendMessage("§7You sent §e" + genbucketItem.getAmount() + "x " + genbucketItem.getItemName() + "§7 genbucket(s) to §e" + player.getName()); - } catch (NullPointerException e) { - sender.sendMessage("§cError while making the genbucket, are you sure you specified a valid shop name and a valid key (config section)?"); - } - return true; - - } - - return false; - } - - return false; - } - - - private void toggleSetting(CommandSender sender, String setting, boolean oldValue) { - sender.sendMessage(plugin.getLocale().getMessage("command.settings.modify", setting.toUpperCase(), String.valueOf(!oldValue))); - } - - private void toggleSetting(CommandSender sender, String setting, String oldValue) { - sender.sendMessage(plugin.getLocale().getMessage("command.settings.modify", setting.toUpperCase(), String.valueOf(oldValue))); - } -} diff --git a/src/main/java/com/songoda/epicbuckets/commands/GenbucketCommand.java b/src/main/java/com/songoda/epicbuckets/commands/GenbucketCommand.java deleted file mode 100644 index efff56b..0000000 --- a/src/main/java/com/songoda/epicbuckets/commands/GenbucketCommand.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.songoda.epicbuckets.commands; - -import com.songoda.epicbuckets.EpicBuckets; -import com.songoda.epicbuckets.inventories.InventoryManager; -import com.songoda.epicbuckets.util.ChatUtil; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -/** - * GenbucketCommand created by: SoFocused - * Date Created: oktober 02 2018 - * Time created: 23:20 - */ -public class GenbucketCommand implements CommandExecutor { - - @Override - public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { - - if (!(sender instanceof Player)) { - sender.sendMessage(EpicBuckets.getInstance().getLocale().getMessage("event.general.playercommand")); - return true; - } - - if (!sender.hasPermission("genbucket.command")) { - sender.sendMessage(EpicBuckets.getInstance().getLocale().getMessage("event.general.nopermission")); - return true; - } - - Player player = (Player) sender; - - InventoryManager inventoryManager = new InventoryManager(); - - inventoryManager.openMainInventory(player); - - return true; - - } -} diff --git a/src/main/java/com/songoda/epicbuckets/events/GenbucketPlaceEvent.java b/src/main/java/com/songoda/epicbuckets/events/GenbucketPlaceEvent.java deleted file mode 100644 index fc35c73..0000000 --- a/src/main/java/com/songoda/epicbuckets/events/GenbucketPlaceEvent.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.songoda.epicbuckets.events; - -import com.songoda.epicbuckets.genbuckets.GenbucketItem; -import org.bukkit.Location; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; - -import java.util.UUID; - -/** - * GenbucketPlaceEvent created by: SoFocused - * Date Created: oktober 05 2018 - * Time created: 22:15 - */ -public class GenbucketPlaceEvent extends Event implements Cancellable { - - private static final HandlerList HANDLERS = new HandlerList(); - private boolean isCancelled = false; - - private Player player; - private Location location; - private BlockFace blockFace; - private GenbucketItem genbucketItem; - private UUID genbucketUUID; - - public GenbucketPlaceEvent(Player player, Location location, BlockFace blockFace, GenbucketItem genbucketItem, UUID genbucketUUID) { - this.player = player; - this.location = location; - this.blockFace = blockFace; - this.genbucketItem = genbucketItem; - this.genbucketUUID = genbucketUUID; - } - - public static HandlerList getHandlerList() { - return HANDLERS; - } - - public Player getPlayer() { - return player; - } - - public Location getLocation() { - return location; - } - - public BlockFace getBlockFace() { - return blockFace; - } - - public GenbucketItem getGenbucketItem() { - return genbucketItem; - } - - public UUID getGenbucketUUID() { - return genbucketUUID; - } - - public HandlerList getHandlers() { - return HANDLERS; - } - - public boolean isCancelled() { - return this.isCancelled; - } - - public void setCancelled(boolean isCancelled) { - this.isCancelled = isCancelled; - } - -} - diff --git a/src/main/java/com/songoda/epicbuckets/filehandler/FileManager.java b/src/main/java/com/songoda/epicbuckets/filehandler/FileManager.java deleted file mode 100644 index cd242c0..0000000 --- a/src/main/java/com/songoda/epicbuckets/filehandler/FileManager.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.songoda.epicbuckets.filehandler; - -import com.songoda.epicbuckets.EpicBuckets; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; - -import java.io.File; -import java.io.IOException; - -/** - * FileManager created by: SoFocused - * Date Created: oktober 02 2018 - * Time created: 22:56 - */ -public class FileManager { - - public FileConfiguration config; - private File file; - - public FileManager(String filename) { - - EpicBuckets main = EpicBuckets.getInstance(); - - this.file = new File(main.getDataFolder(), filename); - if (!this.file.exists()) { - try { - boolean b = this.file.createNewFile(); - - if (b) - main.getLogger().info(filename + " was successfully created"); - - } catch (IOException e) { - e.printStackTrace(); - } - } - this.config = YamlConfiguration.loadConfiguration(this.file); - } - - public void save() { - try { - this.config.save(this.file); - } catch (IOException e) { - e.printStackTrace(); - } - } - - public void load() { - this.config = YamlConfiguration.loadConfiguration(this.file); - } - -} diff --git a/src/main/java/com/songoda/epicbuckets/filehandler/files/ShopFile.java b/src/main/java/com/songoda/epicbuckets/filehandler/files/ShopFile.java deleted file mode 100644 index d52f237..0000000 --- a/src/main/java/com/songoda/epicbuckets/filehandler/files/ShopFile.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.songoda.epicbuckets.filehandler.files; - -import com.songoda.epicbuckets.filehandler.FileManager; - -/** - * ShopFile created by: SoFocused - * Date Created: oktober 02 2018 - * Time created: 23:58 - */ -public class ShopFile extends FileManager { - - public ShopFile() { - super("shops.yml"); - } - -} diff --git a/src/main/java/com/songoda/epicbuckets/files/Config.java b/src/main/java/com/songoda/epicbuckets/files/Config.java new file mode 100644 index 0000000..843d94a --- /dev/null +++ b/src/main/java/com/songoda/epicbuckets/files/Config.java @@ -0,0 +1,34 @@ +package com.songoda.epicbuckets.files; + +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.io.File; +import java.io.IOException; + +public class Config { + + private FileConfiguration handler; + private File file; + + public Config(File file) { + initializeHandler(file); + } + + private void initializeHandler(File file) { + if (!file.exists()) { + try { + file.createNewFile(); + } catch (IOException e) { + e.printStackTrace(); + } + } + this.file = file; + handler = YamlConfiguration.loadConfiguration(this.file); + } + + public FileConfiguration getConfig() { + return handler; + } + +} diff --git a/src/main/java/com/songoda/epicbuckets/files/ConfigManager.java b/src/main/java/com/songoda/epicbuckets/files/ConfigManager.java new file mode 100644 index 0000000..fad7e87 --- /dev/null +++ b/src/main/java/com/songoda/epicbuckets/files/ConfigManager.java @@ -0,0 +1,38 @@ +package com.songoda.epicbuckets.files; + +import com.songoda.epicbuckets.EpicBuckets; +import org.bukkit.configuration.file.FileConfiguration; + +import java.io.File; +import java.util.HashMap; + +public class ConfigManager { + + private EpicBuckets epicBuckets; + private HashMap configDatabase; + + public ConfigManager() { + this.epicBuckets = EpicBuckets.getInstance(); + setup(); + } + + private void setup() { + epicBuckets.saveDefaultConfig(); + createConfig("shops"); + } + + public void createConfig(String name) { + File f = new File(epicBuckets.getDataFolder(), name + ".yml"); + configDatabase.put(name, new Config(f)); + } + + public FileConfiguration getConfig() { + return epicBuckets.getConfig(); + } + + public FileConfiguration getConfig(String name) { + if (!configDatabase.containsKey(name)) return null; + return configDatabase.get(name).getConfig(); + } + +} diff --git a/src/main/java/com/songoda/epicbuckets/genbuckets/Genbucket.java b/src/main/java/com/songoda/epicbuckets/genbuckets/Genbucket.java deleted file mode 100644 index 516726f..0000000 --- a/src/main/java/com/songoda/epicbuckets/genbuckets/Genbucket.java +++ /dev/null @@ -1,248 +0,0 @@ -package com.songoda.epicbuckets.genbuckets; - -import com.songoda.epicbuckets.EpicBuckets; -import com.songoda.epicbuckets.regionhandlers.*; -import com.songoda.epicbuckets.util.ChatUtil; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import java.util.UUID; - -/** - * Genbucket created by: SoFocused - * Date Created: oktober 02 2018 - * Time created: 21:51 - */ -public abstract class Genbucket { - - protected EpicBuckets plugin = EpicBuckets.getInstance(); - - private GenbucketType genbucketType; - - public Genbucket(GenbucketType genbucketType) { - - this.genbucketType = genbucketType; - - } - - public abstract void run(); - - public EpicBuckets getInstance() { - return plugin; - } - - protected void genbucketFinished(Player player, UUID uuid) { - - int a = GenbucketManager.getActiveGenBuckets(player); - - if (a - 1 < 0) - GenbucketManager.setActiveGenBuckets(player, 0); - else - GenbucketManager.setActiveGenBuckets(player, a - 1); - - if (GenbucketManager.activeGenbucketItems.containsKey(uuid)) - GenbucketManager.activeGenbucketItems.remove(uuid); - - if (GenbucketManager.activeGenbucketLocation.containsKey(uuid)) - GenbucketManager.activeGenbucketLocation.remove(uuid); - - } - - protected boolean canPlace(Player player, Location location) { - - boolean factionsCheck = RegionFactions.canBuild(player, location); - boolean factionsUUIDCheck = RegionFactions.canBuild(player, location); - boolean griefPreventionCheck = RegionGriefPrevention.canBuild(player, location); - boolean worldGuardCheck = RegionWorldGuard.canBuild(player, location); - boolean worldBorderCheck = RegionWBorder.isOutsideOfBorder(location); - - //ChatUtil.debugMSG(player, factionsCheck, factionsUUIDCheck, griefPreventionCheck, worldGuardCheck, worldBorderCheck); - - if (!factionsCheck || !factionsUUIDCheck || !griefPreventionCheck || !worldGuardCheck || worldBorderCheck) { - player.sendMessage(plugin.getLocale().getMessage("event.place.nothere")); - return false; - } - - return true; - } - - protected boolean canPlace(Player player, Location location, boolean sendMessage) { - - boolean factionsCheck = RegionFactions.canBuild(player, location); - boolean factionsUUIDCheck = RegionFactions.canBuild(player, location); - boolean griefPreventionCheck = RegionGriefPrevention.canBuild(player, location); - boolean worldGuardCheck = RegionWorldGuard.canBuild(player, location); - boolean worldBorderCheck = RegionWBorder.isOutsideOfBorder(location); - - - if (!factionsCheck || !factionsUUIDCheck || !griefPreventionCheck || !worldGuardCheck || worldBorderCheck) { - - if (sendMessage) - player.sendMessage(plugin.getLocale().getMessage("event.place.nothere")); - - return false; - - } - - return true; - } - - private void removeBucket(Player player, ItemStack item) { - - int genBuckets = item.getAmount(); - - if (genBuckets > 1) - item.setAmount(genBuckets - 1); - else - player.getInventory().clear(player.getInventory().getHeldItemSlot()); - - - player.updateInventory(); - } - - protected boolean canPlayerPlaceAGenbucket(Player player) { - - if (GenbucketManager.getActiveGenBuckets(player) >= maxActiveGenForPlayer(player) + 1) { - - player.sendMessage(plugin.getLocale().getMessage("event.place.wait")); - return false; - - } - - return true; - - } - - protected void notifyAdmins(Player target) { - - for (UUID uuid : GenbucketManager.adminList) { - - OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uuid); - - if (!offlinePlayer.isOnline()) - continue; - - offlinePlayer.getPlayer().sendMessage(plugin.getLocale().getMessage("event.admin.playerplaced", target.getName(), genbucketType.toString().toLowerCase())); - - } - - } - - protected boolean withdrawMoney(Player player, GenbucketItem item) { - - boolean useInfinityGens = plugin.getConfig().getBoolean("INFINITE-USE"); - - if (!useInfinityGens) { - removeBucket(player, player.getInventory().getItem(player.getInventory().getHeldItemSlot())); - return true; - } - - double playerBalance = plugin.getBalance(player); - - if (playerBalance >= item.getPrice()) { - - plugin.withdrawBalance(player, item.getPrice(), true); - - return true; - - } else { - - player.sendMessage(plugin.getLocale().getMessage("interface.withdrawl.success", String.valueOf((playerBalance - item.getPrice()) * -1))); - - return false; - } - - } - - private int maxActiveGenForPlayer(Player player) { - - int maxActiveGenForPlayer = 0; - - boolean foundValue = false; - - for (String maxAmountString : plugin.getConfig().getConfigurationSection("CUSTOM-ACTIVE-GEN-PER-PLAY").getKeys(false)) { - - String value[] = plugin.getConfig().getString("CUSTOM-ACTIVE-GEN-PER-PLAY." + maxAmountString).split(":"); - - if (!player.hasPermission(value[1])) - continue; - - maxActiveGenForPlayer = Integer.valueOf(value[0]); - foundValue = true; - break; - - } - - if (!foundValue) - maxActiveGenForPlayer = plugin.getConfig().getInt("MAX-ACTIVE-GEN-PER-PLAYER"); - - //ChatUtil.debugMSG(player, maxActiveGenForPlayer, foundValue); - - return maxActiveGenForPlayer; - - } - - protected boolean foundSponge(Location loc) { - - boolean useSponge = plugin.getConfig().getBoolean("USE-SPONGE-SUPPORT"); - - if (!useSponge) - return false; - - int radius = plugin.getConfig().getInt("SPONGE-RADIUS"); - - if (radius < 0) - return false; - - for (double x = loc.getX() - radius; x < loc.getX() + radius; x++) { - for (double y = loc.getY() - radius; y < loc.getY() + radius; y++) { - for (double z = loc.getZ() - radius; z < loc.getZ() + radius; z++) { - - Material materialAt = new Location(loc.getWorld(), x, y, z).getBlock().getType(); - - if (materialAt.equals(Material.SPONGE)) - return true; - } - - } - - } - - return false; - } - - protected Block moveBlock(Block b, BlockFace blockFace, int length) { - - switch (blockFace) { - case NORTH: - return b.getRelative(0, 0, -length); - case SOUTH: - return b.getRelative(0, 0, length); - case EAST: - return b.getRelative(length, 0, 0); - case WEST: - return b.getRelative(-length, 0, 0); - } - return null; - } - - protected Block getLastBlockPlaced(Block b, BlockFace blockFace) { - switch (blockFace) { - case NORTH: - return b.getRelative(0, 0, -1); - case SOUTH: - return b.getRelative(0, 0, 1); - case EAST: - return b.getRelative(1, 0, 0); - case WEST: - return b.getRelative(-1, 0, 0); - } - return null; - } -} diff --git a/src/main/java/com/songoda/epicbuckets/genbuckets/GenbucketItem.java b/src/main/java/com/songoda/epicbuckets/genbuckets/GenbucketItem.java deleted file mode 100644 index ee6bc4d..0000000 --- a/src/main/java/com/songoda/epicbuckets/genbuckets/GenbucketItem.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.songoda.epicbuckets.genbuckets; - -import com.songoda.epicbuckets.EpicBuckets; -import com.songoda.epicbuckets.util.ChatUtil; -import com.songoda.epicbuckets.util.ItemStackUtil; -import org.bukkit.Material; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.inventory.ItemStack; - -import java.util.List; - -/** - * GenbucketItem created by: SoFocused - * Date Created: oktober 05 2018 - * Time created: 12:00 - */ -public class GenbucketItem { - - private EpicBuckets main = EpicBuckets.getInstance(); - - private String itemName; - private List itemLore; - private List itemSecondLore; - - private Material icon; - private int typeDamage; - private Material type; - - private GenbucketType genbucketType; - - private int amount; - private int damage; - private int price; - - - public GenbucketItem(String shopName, String key) { - // - FileConfiguration config = EpicBuckets.getInstance().shopFile; - this.itemName = ChatUtil.colorString(config.getString("shops." + shopName + "." + key + ".name")); - - this.price = config.getInt("shops." + shopName + "." + key + ".price"); - - this.icon = Material.valueOf(config.getString("shops." + shopName + "." + key + ".icon").toUpperCase()); - - this.typeDamage = config.getInt("shops." + shopName + "." + key + ".type-damage"); - this.type = Material.valueOf(config.getString("shops." + shopName + "." + key + ".type").toUpperCase()); - - this.itemLore = ChatUtil.colorList(config.getStringList("shops." + shopName + "." + key + ".item-lore")); - - this.itemSecondLore = ChatUtil.colorList(config.getStringList("shops." + shopName + "." + key + ".description"), type, price); - - this.damage = config.getInt("shops." + shopName + "." + key + ".damage"); - - this.genbucketType = GenbucketType.valueOf(config.getString("shops." + shopName + ".trait").toUpperCase()); - - amount = 1; - } - - public String getItemName() { - return itemName; - } - - public List getItemLore() { - return itemLore; - } - - public void setItemLore(List itemLore) { - this.itemLore = itemLore; - } - - public GenbucketType getGenbucketType() { - return genbucketType; - } - - public List getItemSecondLore() { - return itemSecondLore; - } - - public Material getType() { - return type; - } - - public Material getIcon() { - return icon; - } - - public int getDamage() { - return damage; - } - - public int getPrice() { - return price; - } - - public int getAmount() { - return amount; - } - - public void setAmount(int amount) { - this.amount = amount; - } - - public int getVerticalHeight() { - return main.getConfig().getInt("MAX-VERTICAL-HEIGHT"); - } - - public byte getTypeDamage() { - return (byte) typeDamage; - } - - public int getHorizontalLength() { - return main.getConfig().getInt("MAX-HORIZONTAL-LENGTH"); - } - - public ItemStack getGenbucketItem() { - return ItemStackUtil.createItemStack(getItemName(), getItemLore(), getIcon(), getAmount(), getDamage(), true); - } -} diff --git a/src/main/java/com/songoda/epicbuckets/genbuckets/GenbucketManager.java b/src/main/java/com/songoda/epicbuckets/genbuckets/GenbucketManager.java deleted file mode 100644 index 21b2fc9..0000000 --- a/src/main/java/com/songoda/epicbuckets/genbuckets/GenbucketManager.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.songoda.epicbuckets.genbuckets; - -import com.songoda.epicbuckets.EpicBuckets; -import com.songoda.epicbuckets.util.ChatUtil; -import com.songoda.epicbuckets.util.InventoryUtil; -import com.songoda.epicbuckets.util.ItemStackUtil; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; - -import java.util.*; - -/** - * GenbucketManager created by: SoFocused - * Date Created: oktober 05 2018 - * Time created: 12:41 - */ -public class GenbucketManager { - - public static HashMap playerInteger = new HashMap<>(); - public static HashMap activeGenBuckets = new HashMap<>(); - public static HashMap activeGenbucketItems = new HashMap<>(); - public static HashMap activeGenbucketLocation = new HashMap<>(); - - public static List adminList = new ArrayList<>(); - - public static int getPlayerInteger(Player player) { - return playerInteger.getOrDefault(player.getUniqueId(), 1); - } - - public static void setPlayerInteger(Player player, int amount) { - playerInteger.put(player.getUniqueId(), amount); - } - - public static int getActiveGenBuckets(Player player) { - return activeGenBuckets.getOrDefault(player.getUniqueId(), 1); - } - - public static void setActiveGenBuckets(Player player, int amount) { - activeGenBuckets.put(player.getUniqueId(), amount); - } - - public void openBulkShop(Player player, GenbucketItem genbucketItem) { - - FileConfiguration config = EpicBuckets.getInstance().getConfig(); - - String inventoryName = ChatUtil.colorString(config.getString("BULK-SHOP-INVENTORY.inventory-name").replace("{player}", player.getName())); - - int size = config.getInt("BULK-SHOP-INVENTORY.size"); - - Inventory inventory = Bukkit.createInventory(player, size, inventoryName); - - int mainItemSlot = config.getInt("BULK-SHOP-INVENTORY.plugin-item-slot"); - - int itemAmount = getPlayerInteger(player); - - genbucketItem.setAmount(itemAmount); - - genbucketItem.setItemLore(genbucketItem.getItemSecondLore()); - - int returnBackItemSlot = config.getInt("BULK-SHOP-INVENTORY.return-back-slot"); - - String purchaseItemName = ChatUtil.colorString(config.getString("BULK-SHOP-INVENTORY.purchase-item.name")); - Material purchaseItemMaterial = Material.valueOf(config.getString("BULK-SHOP-INVENTORY.purchase-item.material").toUpperCase()); - int purchaseItemDamage = config.getInt("BULK-SHOP-INVENTORY.purchase-item.damage"); - int purchaseItemSlot = config.getInt("BULK-SHOP-INVENTORY.purchase-item.slot"); - - InventoryUtil.fillInventory(inventory, config.getBoolean("BULK-SHOP-INVENTORY.fill")); - - InventoryUtil.setBackButton(inventory, returnBackItemSlot, true); - - inventory.setItem(purchaseItemSlot, ItemStackUtil.createItemStack(purchaseItemName, Arrays.asList("&f"), purchaseItemMaterial, 1, purchaseItemDamage, false)); - - inventory.setItem(mainItemSlot, genbucketItem.getGenbucketItem()); - - loadAmountModifiers(inventory, "increase"); - loadAmountModifiers(inventory, "decrease"); - - player.getOpenInventory().close(); - player.openInventory(inventory); - - } - - private void loadAmountModifiers(Inventory inventory, String key) { - - FileConfiguration config = EpicBuckets.getInstance().getConfig(); - - int x = 1; - - String operator = key.equalsIgnoreCase("increase") ? "§a§l+ " : "§c§l- "; - - Material material = Material.valueOf(config.getString("BULK-SHOP-INVENTORY.increase-item.material").toUpperCase()); - - int damage = config.getInt("BULK-SHOP-INVENTORY." + key + "-item.damage"); - - for (String str : config.getString("BULK-SHOP-INVENTORY." + key + "-item.slots").split(",")) { - - int slot = Integer.parseInt(str); - - inventory.setItem(slot, ItemStackUtil.createItemStack(operator + x, Arrays.asList("&f"), material, 1, damage, false)); - - if (x == 1) - x = 10; - else - x = 64; - - } - - } - - -} diff --git a/src/main/java/com/songoda/epicbuckets/genbuckets/GenbucketType.java b/src/main/java/com/songoda/epicbuckets/genbuckets/GenbucketType.java deleted file mode 100644 index e8ff93e..0000000 --- a/src/main/java/com/songoda/epicbuckets/genbuckets/GenbucketType.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.songoda.epicbuckets.genbuckets; - -/** - * GenbucketType created by: SoFocused - * Date Created: oktober 02 2018 - * Time created: 21:40 - */ -public enum GenbucketType { - - HORIZONTAL("HORIZONTAL"), - INFUSED("INFUSED"), - PSUEDO("PSUEDO"), - VERTICAL("VERTICAL"); - - public final String name; - - GenbucketType(String name) { - this.name = name; - } - - @Override - public String toString() { - return name; - } - -} diff --git a/src/main/java/com/songoda/epicbuckets/genbuckets/types/Horizontal.java b/src/main/java/com/songoda/epicbuckets/genbuckets/types/Horizontal.java deleted file mode 100644 index afd53b7..0000000 --- a/src/main/java/com/songoda/epicbuckets/genbuckets/types/Horizontal.java +++ /dev/null @@ -1,145 +0,0 @@ -package com.songoda.epicbuckets.genbuckets.types; - - -import com.songoda.epicbuckets.events.GenbucketPlaceEvent; -import com.songoda.epicbuckets.genbuckets.Genbucket; -import com.songoda.epicbuckets.genbuckets.GenbucketItem; -import com.songoda.epicbuckets.genbuckets.GenbucketManager; -import com.songoda.epicbuckets.genbuckets.GenbucketType; -import com.songoda.epicbuckets.regionhandlers.RegionWBorder; -import com.songoda.epicbuckets.util.ChatUtil; -import com.songoda.epicbuckets.util.ServerVersion; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.scheduler.BukkitRunnable; - -import java.util.UUID; - -/** - * Horizontal created by: SoFocused - * Date Created: oktober 02 2018 - * Time created: 21:40 - */ -public class Horizontal extends Genbucket { - - private Location genbucketLocation; - private int movedBlocks = 1; - private Player player; - private BlockFace blockFace; - private GenbucketItem genbucketItem; - private UUID genbucketUUID; - - public Horizontal(Player player, Location genbucketLocation, BlockFace blockFace, GenbucketItem genbucketItem) { - super(GenbucketType.HORIZONTAL); - - this.genbucketLocation = genbucketLocation; - this.player = player; - this.blockFace = blockFace; - this.genbucketItem = genbucketItem; - this.genbucketUUID = UUID.randomUUID(); - - run(); - } - - @Override - public void run() { - - if ("DOWN".equalsIgnoreCase(blockFace.name()) || "UP".equalsIgnoreCase(blockFace.name())) { - player.sendMessage(ChatUtil.colorPrefix(plugin.getLocale().getMessage("event.genbucket.placedwrong", plugin.getLocale().getMessage("event.translate.directionside", ChatUtil.stripColor(genbucketItem.getItemName()))))); - return; - } - - if (!canPlace(player, genbucketLocation)) - return; - - if (!canPlayerPlaceAGenbucket(player)) - return; - - if (!withdrawMoney(player, genbucketItem)) - return; - - long delay = plugin.getConfig().getInt("DELAY"); - - // Now we can start spawning the blocks - - notifyAdmins(player); - - GenbucketPlaceEvent genbucketPlaceEvent = new GenbucketPlaceEvent(player, genbucketLocation, blockFace, genbucketItem, genbucketUUID); - - Bukkit.getPluginManager().callEvent(genbucketPlaceEvent); - - if (genbucketPlaceEvent.isCancelled()) - return; - - new BukkitRunnable() { - - public void run() { - - final Block block = moveBlock(genbucketLocation.getBlock(), blockFace, movedBlocks); - - if (foundSponge(block.getLocation())) { - - genbucketFinished(player, genbucketUUID); - this.cancel(); - return; - } - - if (!GenbucketManager.activeGenbucketItems.containsKey(genbucketUUID)) { - genbucketFinished(player, genbucketUUID); - this.cancel(); - return; - } - - if (movedBlocks > genbucketItem.getHorizontalLength()) { - - genbucketFinished(player, genbucketUUID); - - this.cancel(); - return; - - } - - if (!canPlace(player, block.getLocation())) { - - //ChatUtil.debugMSG(player, "done from canPlace()"); - - if (RegionWBorder.isOutsideOfBorder(block.getLocation())) { - - if (blockFace.name().equalsIgnoreCase("SOUTH") || - blockFace.name().equalsIgnoreCase("EAST")) - moveBlock(genbucketLocation.getBlock(), blockFace, movedBlocks - 1).setType(Material.AIR); - } - - genbucketFinished(player, genbucketUUID); - - this.cancel(); - return; - } - - boolean run = plugin.getConfig().getStringList("IGNORE-MATERIALS").contains(block.getType().name()); - - if (run) { - - //ChatUtil.debugMSG(player, genbucketItem.getType(), genbucketItem.getTypeDamage(), movedBlocks); - - block.setType(genbucketItem.getType()); - if (!plugin.isServerVersionAtLeast(ServerVersion.V1_13)) - block.setData(genbucketItem.getTypeDamage()); - movedBlocks++; - - } else { - genbucketFinished(player, genbucketUUID); - this.cancel(); - } - - } - - }.runTaskTimer(plugin, 0L, delay); - - } - -} diff --git a/src/main/java/com/songoda/epicbuckets/genbuckets/types/Infused.java b/src/main/java/com/songoda/epicbuckets/genbuckets/types/Infused.java deleted file mode 100644 index 416c479..0000000 --- a/src/main/java/com/songoda/epicbuckets/genbuckets/types/Infused.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.songoda.epicbuckets.genbuckets.types; - -import com.songoda.epicbuckets.events.GenbucketPlaceEvent; -import com.songoda.epicbuckets.genbuckets.Genbucket; -import com.songoda.epicbuckets.genbuckets.GenbucketItem; -import com.songoda.epicbuckets.genbuckets.GenbucketManager; -import com.songoda.epicbuckets.genbuckets.GenbucketType; -import com.songoda.epicbuckets.util.ChatUtil; -import com.songoda.epicbuckets.util.ServerVersion; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.scheduler.BukkitRunnable; - -import java.util.UUID; - -/** - * Infused created by: SoFocused - * Date Created: oktober 02 2018 - * Time created: 21:40 - */ -public class Infused extends Genbucket { - - private Location genbucketLocation; - private int movedBlocks = 1; - private Player player; - private BlockFace blockFace; - private GenbucketItem genbucketItem; - private boolean runPillarOne = true; - private boolean runPillarTwo = true; - private UUID genbucketUUID; - - /** - * Creating the class constructor for a Infused genbucket - * - * @param player the player who placed the genbucket - * @param genbucketLocation the location of where the genbucket was placed - * @param blockFace the blockface received from the {GenbucketPlaceListener#onRightClickBlock} - * @param genbucketItem the genbucket that was placed - */ - public Infused(Player player, Location genbucketLocation, BlockFace blockFace, GenbucketItem genbucketItem) { - super(GenbucketType.INFUSED); - - this.blockFace = blockFace; - this.genbucketLocation = genbucketLocation; - this.genbucketItem = genbucketItem; - this.player = player; - this.genbucketUUID = UUID.randomUUID(); - - // Call this to run the genbucket - run(); - } - - @Override - public void run() { - - if (!"UP".equalsIgnoreCase(blockFace.name())) { - player.sendMessage(ChatUtil.colorPrefix(plugin.getLocale().getMessage("event.genbucket.placedwrong", plugin.getLocale().getMessage("event.translate.directionup", "{genbucket}", ChatUtil.stripColor(genbucketItem.getItemName()))))); - return; - } - - final Block[] blocks = getBlocks(genbucketLocation.getBlock(), blockFace, player); - - final Block blockL = blocks[0]; - final Block blockR = blocks[1]; - - if (!canPlace(player, blockL.getLocation()) || !canPlace(player, blockR.getLocation())) - return; - - if (!canPlayerPlaceAGenbucket(player)) - return; - - if (!withdrawMoney(player, genbucketItem)) - return; - - long delay = plugin.getConfig().getInt("DELAY"); - - // Now we can start spawning the blocks - - notifyAdmins(player); - - GenbucketPlaceEvent genbucketPlaceEvent = new GenbucketPlaceEvent(player, genbucketLocation, blockFace, genbucketItem, genbucketUUID); - - Bukkit.getPluginManager().callEvent(genbucketPlaceEvent); - - if (genbucketPlaceEvent.isCancelled()) - return; - - new BukkitRunnable() { - - public void run() { - - Block blockOne = blocks[0].getLocation().subtract(0, movedBlocks - 1, 0).getBlock(); - Block blockTwo = blocks[1].getLocation().subtract(0, movedBlocks - 1, 0).getBlock(); - - if (foundSponge(blockOne.getLocation())) - runPillarOne = false; - - if (foundSponge(blockTwo.getLocation())) - runPillarTwo = false; - - if (!GenbucketManager.activeGenbucketItems.containsKey(genbucketUUID)) { - genbucketFinished(player, genbucketUUID); - this.cancel(); - return; - } - - if (movedBlocks > genbucketItem.getHorizontalLength()) { - - genbucketFinished(player, genbucketUUID); - - this.cancel(); - return; - - } - - boolean runFirst = plugin.getConfig().getStringList("IGNORE-MATERIALS").contains(blockOne.getType().name()); - - if (runPillarOne && runFirst && canPlace(player, blockOne.getLocation(), false)) { - - blockOne.setType(genbucketItem.getType()); - if (!plugin.isServerVersionAtLeast(ServerVersion.V1_13)) - blockOne.setData(genbucketItem.getTypeDamage()); - - } else - runPillarOne = false; - - boolean runSecond = plugin.getConfig().getStringList("IGNORE-MATERIALS").contains(blockTwo.getType().name()); - - if (runPillarTwo && runSecond && canPlace(player, blockTwo.getLocation(), false)) { - - blockTwo.setType(genbucketItem.getType()); - if (!plugin.isServerVersionAtLeast(ServerVersion.V1_13)) - blockTwo.setData(genbucketItem.getTypeDamage()); - - } else - runPillarTwo = false; - - movedBlocks++; - - if (!canPlace(player, blockOne.getLocation(), true) && !canPlace(player, blockTwo.getLocation(), false)) { - - genbucketFinished(player, genbucketUUID); - - this.cancel(); - return; - } - - Block nextBlockOne = blockOne.getLocation().clone().subtract(0, 1, 0).getBlock(); - Block nextBlockTwo = blockTwo.getLocation().clone().subtract(0, 1, 0).getBlock(); - - boolean checkNextBlock = plugin.getConfig().getStringList("IGNORE-MATERIALS").contains(nextBlockOne.getType().name()); - boolean checkNextBlock_ = plugin.getConfig().getStringList("IGNORE-MATERIALS").contains(nextBlockTwo.getType().name()); - - if (!checkNextBlock && !checkNextBlock_ || !runPillarOne && !runPillarTwo) { - - //ChatUtil.debugMSG(player, nextBlockOne.getType().name(), nextBlockTwo.getType().name()); - - genbucketFinished(player, genbucketUUID); - this.cancel(); - - } - - } - - }.runTaskTimer(plugin, 0L, delay); - - } - - private Block[] getBlocks(Block block, BlockFace blockFace, Player player) { - - if ("NORTH".equalsIgnoreCase(blockFace.name()) || "SOUTH".equalsIgnoreCase(blockFace.name())) { - Block b1 = block.getRelative(blockFace, 1); // Left - Block b2 = block.getRelative(blockFace, -1); // Right - - return new Block[]{b1, b2}; - } else if ("EAST".equalsIgnoreCase(blockFace.name()) || "WEST".equalsIgnoreCase(blockFace.name())) { - Location loc1 = block.getLocation(); - Location loc2 = block.getLocation(); - loc1.setX(loc1.getX() + 1); - loc2.setX(loc1.getX() - 2); - - Block b1 = loc1.getBlock(); - Block b2 = loc2.getBlock(); - - return new Block[]{b1, b2}; - } - - if ("e".equalsIgnoreCase(getDirection(player)) || "w".equalsIgnoreCase(getDirection(player))) { - Location getLeftSide = new Location(player.getWorld(), block.getX(), block.getY(), block.getZ() + 1); - Location getRightSide = new Location(player.getWorld(), block.getX(), block.getY(), block.getZ() - 1); - - return new Block[]{getLeftSide.getBlock(), getRightSide.getBlock()}; - } else if (!"e".equalsIgnoreCase(getDirection(player)) || !"w".equalsIgnoreCase(getDirection(player)) && getDirection(player) != null) { - Location getLeftSide = new Location(player.getWorld(), block.getX() + 1, block.getY(), block.getZ()); - Location getRightSide = new Location(player.getWorld(), block.getX() - 1, block.getY(), block.getZ()); - - return new Block[]{getLeftSide.getBlock(), getRightSide.getBlock()}; - } - - return null; - - } - - private String getDirection(Player player) { - double rot = (player.getLocation().getYaw() - 180) % 360; - if (rot < 0) { - rot += 360.0; - } - - if (0 <= rot && rot < 22.5) { - return "N"; - } else if (67.5 <= rot && rot < 112.5) { - return "E"; - } else if (157.5 <= rot && rot < 202.5) { - return "S"; - } else if (247.5 <= rot && rot < 292.5) { - return "W"; - } else if (337.5 <= rot && rot < 360.0) { - return "N"; - } else { - return null; - } - } -} diff --git a/src/main/java/com/songoda/epicbuckets/genbuckets/types/PsuedoVertical.java b/src/main/java/com/songoda/epicbuckets/genbuckets/types/PsuedoVertical.java deleted file mode 100644 index c139e56..0000000 --- a/src/main/java/com/songoda/epicbuckets/genbuckets/types/PsuedoVertical.java +++ /dev/null @@ -1,198 +0,0 @@ -package com.songoda.epicbuckets.genbuckets.types; - -import com.songoda.epicbuckets.events.GenbucketPlaceEvent; -import com.songoda.epicbuckets.genbuckets.Genbucket; -import com.songoda.epicbuckets.genbuckets.GenbucketItem; -import com.songoda.epicbuckets.genbuckets.GenbucketManager; -import com.songoda.epicbuckets.genbuckets.GenbucketType; -import com.songoda.epicbuckets.util.ChatUtil; -import com.songoda.epicbuckets.util.ServerVersion; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.scheduler.BukkitRunnable; - -import java.util.List; -import java.util.UUID; - -/** - * PsuedoVertical created by: SoFocused - * Date Created: oktober 02 2018 - * Time created: 21:40 - */ -public class PsuedoVertical extends Genbucket { - - private Location genbucketLocation; - private int movedBlocks = 1; - private Player player; - private BlockFace blockFace; - private GenbucketItem genbucketItem; - private UUID genbucketUUID; - - /** - * Creating the class constructor for a PsuedoVertical genbucket - * - * @param player the player who placed the genbucket - * @param genbucketLocation the location of where the genbucket was placed - * @param blockFace the blockface received from the {GenbucketPlaceListener#onRightClickBlock} - * @param genbucketItem the genbucket that was placed - */ - public PsuedoVertical(Player player, Location genbucketLocation, BlockFace blockFace, GenbucketItem genbucketItem) { - super(GenbucketType.PSUEDO); - - this.genbucketLocation = genbucketLocation; - this.player = player; - this.blockFace = blockFace; - this.genbucketItem = genbucketItem; - this.genbucketUUID = UUID.randomUUID(); - - // Call this to run the genbucket - run(); - } - - @Override - public void run() { - - // Get the material the player clicked the genbucket on - final Material clickedMaterial = genbucketLocation.getBlock().getType(); - - boolean validMaterial = false; - - // This is a list of allowed material from the config - List materialList = plugin.getConfig().getStringList("PSUEDO-MATERIALS"); - - // In the for loop we simply check if the material is - // valid if it is then validMaterial is set to true - for (String string : materialList) { - - if (string.toUpperCase().equalsIgnoreCase(genbucketItem.getType().name().toUpperCase())) - validMaterial = true; - } - - // If the material isn't valid we tell the player and stop the code - if (!validMaterial || !clickedMaterial.equals(genbucketItem.getType())) { - player.sendMessage(plugin.getLocale().getMessage("event.genbucket.wrongmaterialpsuedo")); - return; - } - - // Region support - if (!canPlace(player, genbucketLocation)) - return; - - // This checks if the player can place more - // genbuckets or if he has placed max - if (!canPlayerPlaceAGenbucket(player)) - return; - - // Tries to withdrawMoney, if successful then it - // returns true - if (!withdrawMoney(player, genbucketItem)) - return; - - // Delay from config - long delay = plugin.getConfig().getInt("DELAY"); - - // Now we can start spawning the blocks - - // If any admins (or players with permission) has enabled the - // admin mode we will notify them - notifyAdmins(player); - - // Call in the {@link GenbucketPlaceEvent} - GenbucketPlaceEvent genbucketPlaceEvent = new GenbucketPlaceEvent(player, genbucketLocation, blockFace, genbucketItem, genbucketUUID); - - Bukkit.getPluginManager().callEvent(genbucketPlaceEvent); - - if (genbucketPlaceEvent.isCancelled()) - return; - - new BukkitRunnable() { - - public void run() { - - final Block block = genbucketLocation.clone().subtract(0, movedBlocks, 0).getBlock(); - - if (foundSponge(block.getLocation())) { - - genbucketFinished(player, genbucketUUID); - this.cancel(); - return; - } - - if (foundSponge(block.getLocation())) { - - genbucketFinished(player, genbucketUUID); - this.cancel(); - return; - } - - if (!GenbucketManager.activeGenbucketItems.containsKey(genbucketUUID)) { - genbucketFinished(player, genbucketUUID); - this.cancel(); - return; - } - - if (movedBlocks > genbucketItem.getVerticalHeight()) { - - //if (block.getType().equals(Material.COBBLESTONE) && genbucketItem.getType().equals(Material.SAND) || block.getType().equals(Material.COBBLESTONE) && genbucketItem.getType().equals(Material.GRAVEL)) - //block.setType(Material.AIR); - - genbucketFinished(player, genbucketUUID); - this.cancel(); - return; - - } - - if (!canPlace(player, block.getLocation())) { - - //ChatUtil.debugMSG(player, "done from canPlace()"); - - genbucketFinished(player, genbucketUUID); - - this.cancel(); - return; - } - - - - if (block.getType().equals(Material.AIR) || block.getType().equals(Material.WATER) || block.getType().equals(Material.STATIONARY_WATER) - || block.getType().equals(Material.LAVA) || block.getType().equals(Material.STATIONARY_LAVA)) { - - block.setType(genbucketItem.getType()); - if (!plugin.isServerVersionAtLeast(ServerVersion.V1_13)) - block.setData(genbucketItem.getTypeDamage()); - - } else { - - List materialList = plugin.getConfig().getStringList("PSUEDO-MATERIALS"); - - boolean validMaterial = false; - - for (String string : materialList) { - - if (string.toUpperCase().equalsIgnoreCase(genbucketItem.getType().name().toUpperCase())) - validMaterial = true; - } - - if (!validMaterial || !block.getType().equals(clickedMaterial)) { - //ChatUtil.debugMSG(player, "Last block: " + block.getType(), "Material:" + genbucketItem.getType()); - genbucketFinished(player, genbucketUUID); - this.cancel(); - } - - //ChatUtil.debugMSG(player, block.getType().name(), validMaterial, movedBlocks); - - } - - movedBlocks++; - - } - - }.runTaskTimer(plugin, 0L, delay); - - - } -} diff --git a/src/main/java/com/songoda/epicbuckets/genbuckets/types/Vertical.java b/src/main/java/com/songoda/epicbuckets/genbuckets/types/Vertical.java deleted file mode 100644 index 31ffa08..0000000 --- a/src/main/java/com/songoda/epicbuckets/genbuckets/types/Vertical.java +++ /dev/null @@ -1,385 +0,0 @@ -package com.songoda.epicbuckets.genbuckets.types; - -import com.songoda.epicbuckets.events.GenbucketPlaceEvent; -import com.songoda.epicbuckets.genbuckets.Genbucket; -import com.songoda.epicbuckets.genbuckets.GenbucketItem; -import com.songoda.epicbuckets.genbuckets.GenbucketManager; -import com.songoda.epicbuckets.genbuckets.GenbucketType; -import com.songoda.epicbuckets.util.ServerVersion; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Player; -import org.bukkit.scheduler.BukkitRunnable; - -import java.util.UUID; - -/** - * Vertical created by: SoFocused - * Date Created: oktober 02 2018 - * Time created: 21:39 - */ -public class Vertical extends Genbucket { - - private Location genbucketLocation; - private int movedBlocks = 1; - private Player player; - private BlockFace blockFace; - private GenbucketItem genbucketItem; - private UUID genbucketUUID; - private long delay = plugin.getConfig().getInt("DELAY"); - - /** - * Creating the class constructor for a Vertical genbucket - * - * @param player the player who placed the genbucket - * @param genbucketLocation the location of where the genbucket was placed - * @param blockFace the blockface received from the {GenbucketPlaceListener#onRightClickBlock} - * @param genbucketItem the genbucket that was placed - */ - public Vertical(Player player, Location genbucketLocation, BlockFace blockFace, GenbucketItem genbucketItem) { - super(GenbucketType.VERTICAL); - - this.genbucketLocation = genbucketLocation; - this.player = player; - this.blockFace = blockFace; - this.genbucketItem = genbucketItem; - this.genbucketUUID = UUID.randomUUID(); - - // Call this to run the genbucket - run(); - } - - @Override - public void run() { - - if (!canPlace(player, genbucketLocation)) - return; - - if (!canPlayerPlaceAGenbucket(player)) - return; - - if (!withdrawMoney(player, genbucketItem)) - return; - - // Now we can start spawning the blocks - - notifyAdmins(player); - - GenbucketPlaceEvent genbucketPlaceEvent = new GenbucketPlaceEvent(player, genbucketLocation, blockFace, genbucketItem, genbucketUUID); - - Bukkit.getPluginManager().callEvent(genbucketPlaceEvent); - - if (genbucketPlaceEvent.isCancelled()) - return; - - /** - * Compared to the other genbuckets the veritcal genbucket - * can be placed in 3 different locations. Therefore, we cannot - * use the same method as we've done with the other genbuckettypes. - */ - - switch (blockFace) { - - case DOWN: - directionDown(); - break; - - case UP: - directionUP(); - break; - - default: - directionSide(); - break; - - } - - } - - private void directionSide() { - - final Block firstBlock = getLastBlockPlaced(genbucketLocation.getBlock(), blockFace); - - // This is needed to stop sand/gravel genbuckets - // to destroy bedrock - if (firstBlock.getLocation().getBlockY() <= 1) - return; - - new BukkitRunnable() { - - public void run() { - - final Block block = firstBlock.getLocation().clone().subtract(0, movedBlocks - 1, 0).getBlock(); - - if (foundSponge(block.getLocation())) { - - genbucketFinished(player, genbucketUUID); - this.cancel(); - return; - } - - if (!GenbucketManager.activeGenbucketItems.containsKey(genbucketUUID)) { - genbucketFinished(player, genbucketUUID); - this.cancel(); - return; - } - - if (movedBlocks > genbucketItem.getVerticalHeight()) { - - if (block.getType().equals(Material.COBBLESTONE) && genbucketItem.getType().equals(Material.SAND) || block.getType().equals(Material.COBBLESTONE) && genbucketItem.getType().equals(Material.GRAVEL)) - block.setType(Material.AIR); - - genbucketFinished(player, genbucketUUID); - this.cancel(); - return; - - } - - if (!canPlace(player, block.getLocation())) { - - //ChatUtil.debugMSG(player, "done from canPlace()"); - - genbucketFinished(player, genbucketUUID); - - this.cancel(); - return; - } - - boolean run = plugin.getConfig().getStringList("IGNORE-MATERIALS").contains(block.getType().name()); - - if (!run && genbucketItem.getType().equals(Material.SAND) || !run && genbucketItem.getType().equals(Material.GRAVEL) || run) { - - //ChatUtil.debugMSG(player, genbucketItem.getType(), genbucketItem.getTypeDamage(), movedBlocks); - - if (genbucketItem.getType().equals(Material.SAND) || genbucketItem.getType().equals(Material.GRAVEL)) { - - block.setType(genbucketItem.getType()); - - Block block_ = block.getLocation().clone().subtract(0, 1, 0).getBlock(); - block_.setType(Material.COBBLESTONE); - - Block blockUnderCobbleStone = block.getLocation().clone().subtract(0, 2, 0).getBlock(); - boolean ignoreBlock = plugin.getConfig().getStringList("IGNORE-MATERIALS").contains(blockUnderCobbleStone.getType().name()); - - if (!ignoreBlock) { - block_.setType(genbucketItem.getType()); - genbucketFinished(player, genbucketUUID); - this.cancel(); - return; - } else { - block.setType(genbucketItem.getType()); - if (!plugin.isServerVersionAtLeast(ServerVersion.V1_13)) - block.setData(genbucketItem.getTypeDamage()); - } - - } else { - block.setType(genbucketItem.getType()); - if (!plugin.isServerVersionAtLeast(ServerVersion.V1_13)) - block.setData(genbucketItem.getTypeDamage()); - } - - movedBlocks++; - - } else { - - //ChatUtil.debugMSG(player, "Last block: " + block.getType(), "Material:" + genbucketItem.getType()); - genbucketFinished(player, genbucketUUID); - this.cancel(); - } - - } - - }.runTaskTimer(plugin, 0L, delay); - - } - - private void directionUP() { - - new BukkitRunnable() { - - public void run() { - - final Block block = genbucketLocation.clone().add(0, movedBlocks, 0).getBlock(); - - if (foundSponge(block.getLocation())) { - - genbucketFinished(player, genbucketUUID); - this.cancel(); - return; - } - - if (!GenbucketManager.activeGenbucketItems.containsKey(genbucketUUID)) { - genbucketFinished(player, genbucketUUID); - this.cancel(); - return; - } - - if (movedBlocks > genbucketItem.getVerticalHeight() || block.getY() >= 257) { - - if (block.getType().equals(Material.COBBLESTONE) && genbucketItem.getType().equals(Material.SAND) || block.getType().equals(Material.COBBLESTONE) && genbucketItem.getType().equals(Material.GRAVEL)) - block.setType(Material.AIR); - - genbucketFinished(player, genbucketUUID); - this.cancel(); - return; - - } - - if (!canPlace(player, block.getLocation())) { - - //ChatUtil.debugMSG(player, "done from canPlace()"); - - genbucketFinished(player, genbucketUUID); - - this.cancel(); - return; - } - - boolean run = plugin.getConfig().getStringList("IGNORE-MATERIALS").contains(block.getType().name()); - - if (!run && genbucketItem.getType().equals(Material.SAND) || !run && genbucketItem.getType().equals(Material.GRAVEL) || run) { - - //ChatUtil.debugMSG(player, genbucketItem.getType(), genbucketItem.getTypeDamage(), movedBlocks); - - if (genbucketItem.getType().equals(Material.SAND) || genbucketItem.getType().equals(Material.GRAVEL)) { - - block.setType(genbucketItem.getType()); - - Block block_ = block.getLocation().clone().add(0, 1, 0).getBlock(); - block_.setType(Material.COBBLESTONE); - - Block blockUnderCobbleStone = block.getLocation().clone().add(0, 2, 0).getBlock(); - boolean ignoreBlock = plugin.getConfig().getStringList("IGNORE-MATERIALS").contains(blockUnderCobbleStone.getType().name()); - - if (!ignoreBlock) { - block_.setType(genbucketItem.getType()); - genbucketFinished(player, genbucketUUID); - this.cancel(); - return; - } else { - block.setType(genbucketItem.getType()); - if (!plugin.isServerVersionAtLeast(ServerVersion.V1_13)) - block.setData(genbucketItem.getTypeDamage()); - } - - } else { - block.setType(genbucketItem.getType()); - if (!plugin.isServerVersionAtLeast(ServerVersion.V1_13)) - block.setData(genbucketItem.getTypeDamage()); - } - - movedBlocks++; - - } else { - - //ChatUtil.debugMSG(player, "Last block: " + block.getType(), "Material:" + genbucketItem.getType()); - genbucketFinished(player, genbucketUUID); - this.cancel(); - } - - } - - }.runTaskTimer(plugin, 0L, delay); - } - - private void directionDown() { - - // This is needed to stop sand/gravel genbuckets - // to destroy bedrock - if (genbucketLocation.getBlockY() <= 3) - return; - - new BukkitRunnable() { - - public void run() { - - final Block block = genbucketLocation.clone().subtract(0, movedBlocks, 0).getBlock(); - - if (foundSponge(block.getLocation())) { - - genbucketFinished(player, genbucketUUID); - this.cancel(); - return; - } - - if (!GenbucketManager.activeGenbucketItems.containsKey(genbucketUUID)) { - genbucketFinished(player, genbucketUUID); - this.cancel(); - return; - } - - if (movedBlocks > genbucketItem.getVerticalHeight()) { - - if (block.getType().equals(Material.COBBLESTONE) && genbucketItem.getType().equals(Material.SAND) || block.getType().equals(Material.COBBLESTONE) && genbucketItem.getType().equals(Material.GRAVEL)) - block.setType(Material.AIR); - - genbucketFinished(player, genbucketUUID); - this.cancel(); - return; - - } - - if (!canPlace(player, block.getLocation())) { - - //ChatUtil.debugMSG(player, "done from canPlace()"); - - genbucketFinished(player, genbucketUUID); - - this.cancel(); - return; - } - - boolean run = plugin.getConfig().getStringList("IGNORE-MATERIALS").contains(block.getType().name()); - - if (!run && genbucketItem.getType().equals(Material.SAND) || !run && genbucketItem.getType().equals(Material.GRAVEL) || run) { - - //ChatUtil.debugMSG(player, genbucketItem.getType(), genbucketItem.getTypeDamage(), movedBlocks); - - if (genbucketItem.getType().equals(Material.SAND) || genbucketItem.getType().equals(Material.GRAVEL)) { - - block.setType(genbucketItem.getType()); - - Block block_ = block.getLocation().clone().subtract(0, 1, 0).getBlock(); - block_.setType(Material.COBBLESTONE); - - Block blockUnderCobbleStone = block.getLocation().clone().subtract(0, 2, 0).getBlock(); - boolean ignoreBlock = plugin.getConfig().getStringList("IGNORE-MATERIALS").contains(blockUnderCobbleStone.getType().name()); - - if (!ignoreBlock) { - block_.setType(genbucketItem.getType()); - genbucketFinished(player, genbucketUUID); - this.cancel(); - return; - } else { - block.setType(genbucketItem.getType()); - if (!plugin.isServerVersionAtLeast(ServerVersion.V1_13)) - block.setData(genbucketItem.getTypeDamage()); - } - - } else { - block.setType(genbucketItem.getType()); - if (!plugin.isServerVersionAtLeast(ServerVersion.V1_13)) - block.setData(genbucketItem.getTypeDamage()); - } - - movedBlocks++; - - } else { - - //ChatUtil.debugMSG(player, "Last block: " + block.getType(), "Material:" + genbucketItem.getType()); - genbucketFinished(player, genbucketUUID); - this.cancel(); - } - - } - - }.runTaskTimer(plugin, 0L, delay); - - - } - - -} diff --git a/src/main/java/com/songoda/epicbuckets/inventories/InventoryManager.java b/src/main/java/com/songoda/epicbuckets/inventories/InventoryManager.java deleted file mode 100644 index 54eeacc..0000000 --- a/src/main/java/com/songoda/epicbuckets/inventories/InventoryManager.java +++ /dev/null @@ -1,192 +0,0 @@ -package com.songoda.epicbuckets.inventories; - -import com.songoda.epicbuckets.EpicBuckets; -import com.songoda.epicbuckets.genbuckets.GenbucketManager; -import com.songoda.epicbuckets.util.ChatUtil; -import com.songoda.epicbuckets.util.InventoryUtil; -import com.songoda.epicbuckets.util.ItemStackUtil; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; - -import java.util.Arrays; -import java.util.List; -import java.util.UUID; - -/** - * InventoryManager created by: SoFocused - * Date Created: oktober 03 2018 - * Time created: 16:24 - */ -public class InventoryManager { - - public void openMainInventory(Player player) { - - FileConfiguration config = EpicBuckets.getInstance().getConfig(); - - boolean fillInventory = config.getBoolean("MENU-ITEMS.fill"); - - int size = config.getInt("MENU-ITEMS.size"); - - String inventoryName = ChatUtil.colorString(config.getString("MENU-ITEMS.inventory-name")); - - Inventory inventory = Bukkit.createInventory(null, size, inventoryName); - - InventoryUtil.fillInventory(inventory, fillInventory); - - for (String key : config.getConfigurationSection("MENU-ITEMS").getKeys(false)) { - - // Check if the key has the item category if not just skip - - if (!config.contains("MENU-ITEMS." + key + ".item")) - continue; - - // Now we know that we might have a possible item! - - setBucketInMainGUI(inventory, "MENU-ITEMS.", key); - - } - - player.getOpenInventory().close(); - player.openInventory(inventory); - - } - - public void loadSubInventory(Player player, String shopName) { - - FileConfiguration config = EpicBuckets.getInstance().shopFile; - - String inventoryName = ChatUtil.colorString(config.getString("shops." + shopName + ".inventory-name")); - - int inventorySize = config.getInt("shops." + shopName + ".size"); - - boolean fillInventory = config.getBoolean("shops." + shopName + ".fill"); - - boolean useBackButton = config.getBoolean("use-back-buttons"); - - int backButtonSlot = config.getInt("shops." + shopName + ".goBackButton"); - - Inventory inventory = Bukkit.createInventory(null, inventorySize, inventoryName); - - InventoryUtil.fillInventory(inventory, fillInventory); - - InventoryUtil.setBackButton(inventory, backButtonSlot, useBackButton); - - // Load in the buckets - - for (String key : config.getConfigurationSection("shops." + shopName).getKeys(false)) { - - // Make sure our key / path has a type in it - - if (!config.contains("shops." + shopName + "." + key + ".type")) - continue; - - // Now we can "safely" load in the genbucket - - setBucketInSubGUI(inventory, shopName, key); - - } - - player.getOpenInventory().close(); - player.openInventory(inventory); - - } - - private void setBucketInSubGUI(Inventory inventory, String shopName, String key) { - - FileConfiguration config = EpicBuckets.getInstance().shopFile; - - String name = ChatUtil.colorString(config.getString("shops." + shopName + "." + key + ".name")); - - int price = config.getInt("shops." + shopName + "." + key + ".price"); - - Material icon = Material.valueOf(config.getString("shops." + shopName + "." + key + ".icon").toUpperCase()); - Material type = Material.valueOf(config.getString("shops." + shopName + "." + key + ".type").toUpperCase()); - - List lore = ChatUtil.colorList(config.getStringList("shops." + shopName + "." + key + ".description"), type, price); - - int damage = config.getInt("shops." + shopName + "." + key + ".damage"); - - int slot = config.getInt("shops." + shopName + "." + key + ".slot"); - - inventory.setItem(slot, ItemStackUtil.createItemStack(name, lore, icon, 1, damage, true)); - - } - - private void setBucketInMainGUI(Inventory inventory, String path, String key) { - - FileConfiguration config = EpicBuckets.getInstance().getConfig(); - - String itemName = config.getString(path + key + ".item.name"); - - List itemLore = config.getStringList(path + key + ".item.lore"); - - Material m = Material.valueOf(config.getString(path + key + ".item.material").toUpperCase()); - - int damage = config.getInt(path + key + ".item.damage"); - - int slot = config.getInt(path + key + ".slot"); - - ItemStack itemStack = ItemStackUtil.createItemStack(itemName, itemLore, m, 1, damage, true); - - inventory.setItem(slot, itemStack); - - } - - public void openActiveGenbuckets(Player player) { - - Inventory inventory = Bukkit.createInventory(null, 54, "Active genbuckets"); - - int i = 0; - - for (UUID uuid : GenbucketManager.activeGenbucketItems.keySet()) { - - inventory.setItem(i, GenbucketManager.activeGenbucketItems.get(uuid)); - i++; - - if (i == 54) - break; - - } - - inventory.setItem(53, ItemStackUtil.createItemStack("§a§lNext page", Arrays.asList("§7Current page 1"), Material.ARROW, 1, 0, true)); - - player.getOpenInventory().close(); - - player.openInventory(inventory); - - } - - public void loadNextInventory(Inventory inventory) { - - int page = Integer.parseInt(ChatUtil.stripColor(inventory.getItem(53).getItemMeta().getLore().get(0).split(" ")[2])) + 1; - - inventory.clear(); - - int i = 0; - int slot = 0; - - for (UUID uuid : GenbucketManager.activeGenbucketItems.keySet()) { - - i++; - - if (i < 53 * page) - continue; - - if (slot > 52) - break; - - inventory.setItem(slot, GenbucketManager.activeGenbucketItems.get(uuid)); - - slot++; - - } - - inventory.setItem(53, ItemStackUtil.createItemStack("§a§lNext page", Arrays.asList("§7Current page " + page), Material.ARROW, 1, 0, true)); - - } - -} diff --git a/src/main/java/com/songoda/epicbuckets/listeners/GenbucketPlaceListener.java b/src/main/java/com/songoda/epicbuckets/listeners/GenbucketPlaceListener.java deleted file mode 100644 index 60ad34e..0000000 --- a/src/main/java/com/songoda/epicbuckets/listeners/GenbucketPlaceListener.java +++ /dev/null @@ -1,201 +0,0 @@ -package com.songoda.epicbuckets.listeners; - -import com.songoda.epicbuckets.EpicBuckets; -import com.songoda.epicbuckets.events.GenbucketPlaceEvent; -import com.songoda.epicbuckets.genbuckets.GenbucketItem; -import com.songoda.epicbuckets.genbuckets.GenbucketManager; -import com.songoda.epicbuckets.genbuckets.types.Horizontal; -import com.songoda.epicbuckets.genbuckets.types.Infused; -import com.songoda.epicbuckets.genbuckets.types.PsuedoVertical; -import com.songoda.epicbuckets.genbuckets.types.Vertical; -import com.songoda.epicbuckets.util.ChatUtil; -import com.songoda.epicbuckets.util.ItemStackUtil; -import com.songoda.epicbuckets.util.ServerVersion; -import com.songoda.epicbuckets.util.Util; -import org.bukkit.Material; -import org.bukkit.block.Block; -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.block.Action; -import org.bukkit.event.player.PlayerBucketEmptyEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.ItemStack; - -import java.util.Arrays; -import java.util.List; - -/** - * GenbucketPlaceListener created by: SoFocused - * Date Created: oktober 05 2018 - * Time created: 16:06 - */ -public class GenbucketPlaceListener implements Listener { - - private EpicBuckets plugin = EpicBuckets.getInstance(); - - // We have to do a double for loop to find the genbucket - // don't think this is going to be a big issue but eehhh - - @EventHandler - public void onPlayerBucketEmptyEvent(PlayerBucketEmptyEvent event) { - - FileConfiguration config = plugin.shopFile; - - final Player player = event.getPlayer(); - - GenbucketItem genbucketItem; - - ItemStack itemStack = player.getInventory().getItem(player.getInventory().getHeldItemSlot()); - - if (!itemStack.hasItemMeta()) - return; - - for (String path : config.getConfigurationSection("shops").getKeys(false)) { - - for (String key : config.getConfigurationSection("shops." + path).getKeys(false)) { - - if (!config.contains("shops." + path + "." + key + ".icon")) - continue; - - genbucketItem = new GenbucketItem(path, key); - - Material itemMaterial = itemStack.getType(); - String itemName = ChatUtil.stripColor(itemStack.getItemMeta().getDisplayName()); - List itemLore = itemStack.getItemMeta().getLore(); - - if (!genbucketItem.getIcon().equals(itemMaterial)) - continue; - - if (!ChatUtil.stripColor(genbucketItem.getItemName()).equalsIgnoreCase(itemName)) - continue; - - if (!itemLore.equals(genbucketItem.getItemLore())) - continue; - - event.setCancelled(true); - - player.updateInventory(); - event.getBlockClicked().getRelative(event.getBlockFace()).getState().update(); - event.getBlockClicked().getState().update(); - - break; - } - } - - } - - @EventHandler - public void onRightClickBlock(PlayerInteractEvent event) { - - if (event.getAction() != Action.RIGHT_CLICK_BLOCK || event.getItem() == null) - return; - - if (!event.getItem().hasItemMeta()) - return; - - final Player player = event.getPlayer(); - - Block clickedBlock = event.getClickedBlock(); - - FileConfiguration config = plugin.shopFile; - - boolean foundGenbucket = false; - - GenbucketItem genbucketItem = null; - - for (String path : config.getConfigurationSection("shops").getKeys(false)) { - - if (foundGenbucket) - break; - - for (String key : config.getConfigurationSection("shops." + path).getKeys(false)) { - - if (!config.contains("shops." + path + "." + key + ".icon")) - continue; - - genbucketItem = new GenbucketItem(path, key); - - Material itemMaterial; - String itemName; - List itemLore; - - try { - itemMaterial = event.getItem().getType(); - itemName = ChatUtil.stripColor(event.getItem().getItemMeta().getDisplayName()); - itemLore = event.getItem().getItemMeta().getLore(); - } catch (NullPointerException e) { - continue; - } - - if (!genbucketItem.getIcon().equals(itemMaterial)) - continue; - - if (!ChatUtil.stripColor(genbucketItem.getItemName()).equalsIgnoreCase(itemName)) - continue; - - if (!itemLore.equals(genbucketItem.getItemLore())) - continue; - - foundGenbucket = true; - - event.setCancelled(true); - - break; - } - } - - if (!foundGenbucket) - return; - - if (!player.hasPermission("genbucket.place")) { - player.sendMessage(plugin.getLocale().getMessage("event.general.nopermission")); - return; - } - - if (Util.disableGenbuckets()) { - player.sendMessage(plugin.getLocale().getMessage("event.genbucket.disabled")); - player.updateInventory(); - return; - } - - switch (genbucketItem.getGenbucketType()) { - - case PSUEDO: - new PsuedoVertical(player, clickedBlock.getLocation(), event.getBlockFace(), genbucketItem); - break; - - case INFUSED: - new Infused(player, clickedBlock.getLocation(), event.getBlockFace(), genbucketItem); - break; - - case VERTICAL: - new Vertical(player, clickedBlock.getLocation(), event.getBlockFace(), genbucketItem); - break; - - case HORIZONTAL: - new Horizontal(player, clickedBlock.getLocation(), event.getBlockFace(), genbucketItem); - break; - - - } - - player.updateInventory(); - - } - - @EventHandler - public void onGenbucketPlace(GenbucketPlaceEvent event) { - - ItemStack item = ItemStackUtil.createItemStack("§7" + event.getGenbucketUUID().toString(), Arrays.asList("", "§7Information:", " §eLeft click: §6Teleport to location", " §eRight click: §6Stop genbucket", " §ePlaced by §6SoFocused", " §eCordinates: §6" + ChatUtil.getCoordinatesFromLocation(event.getLocation()), " §eMaterial: §6" + event.getGenbucketItem().getType(), " §eDamage: §6" + event.getGenbucketItem().getTypeDamage()), Material.valueOf(plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? "GRAY_STAINED_GLASS_PANE" : "STAINED_GLASS_PANE"), 1, 13, true); - - GenbucketManager.activeGenbucketItems.put(event.getGenbucketUUID(), item); - GenbucketManager.activeGenbucketLocation.put(event.getGenbucketUUID(), event.getLocation()); - - if (!plugin.getConfig().getBoolean("PLACE-UNLIMTED-GENS")) - GenbucketManager.setActiveGenBuckets(event.getPlayer(), GenbucketManager.getActiveGenBuckets(event.getPlayer()) + 1); - - } - -} diff --git a/src/main/java/com/songoda/epicbuckets/listeners/InventoryClickListener.java b/src/main/java/com/songoda/epicbuckets/listeners/InventoryClickListener.java deleted file mode 100644 index 0e7c400..0000000 --- a/src/main/java/com/songoda/epicbuckets/listeners/InventoryClickListener.java +++ /dev/null @@ -1,417 +0,0 @@ -package com.songoda.epicbuckets.listeners; - -import com.songoda.epicbuckets.EpicBuckets; -import com.songoda.epicbuckets.genbuckets.GenbucketItem; -import com.songoda.epicbuckets.genbuckets.GenbucketManager; -import com.songoda.epicbuckets.inventories.InventoryManager; -import com.songoda.epicbuckets.util.ChatUtil; -import org.apache.commons.lang.ArrayUtils; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.configuration.ConfigurationSection; -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.Inventory; -import org.bukkit.inventory.ItemStack; - -import java.util.Map; -import java.util.UUID; -import java.util.WeakHashMap; - -/** - * InventoryClickListener created by: SoFocused - * Date Created: oktober 03 2018 - * Time created: 21:15 - */ -public class InventoryClickListener implements Listener { - - private EpicBuckets plugin = EpicBuckets.getInstance(); - - private Map shopMap = new WeakHashMap<>(); - - // Main inventory - - @EventHandler - public void onClick(InventoryClickEvent event) { - - String inventoryTitle = ChatUtil.stripColor(plugin.getConfig().getString("MENU-ITEMS.inventory-name")); - String clickedInventoryTitle = ChatColor.stripColor(event.getInventory().getTitle()); - - if (!clickedInventoryTitle.equalsIgnoreCase(inventoryTitle)) - return; - - if (event.getCurrentItem() == null || event.getCurrentItem().getType().equals(Material.AIR)) - return; - - if (!event.getCurrentItem().hasItemMeta()) - return; - - event.setCancelled(true); - - // I'm guessing the fastest way to find it is to check if the - // slot is in the config.yml itself? - - int slot = event.getSlot(); - - FileConfiguration config = EpicBuckets.getInstance().getConfig(); - - Player player = (Player) event.getWhoClicked(); - - for (String key : config.getConfigurationSection("MENU-ITEMS").getKeys(false)) { - - // Check if the key has the item category if not just skip - - if (!config.contains("MENU-ITEMS." + key + ".slot")) - continue; - - int configSlot = config.getInt("MENU-ITEMS." + key + ".slot"); - - if (slot == configSlot) { - - // Now we know that the slot they clicked - // was found in the config! - - String shopName = config.getString("MENU-ITEMS." + key + ".shop"); - - InventoryManager inventoryManager = new InventoryManager(); - - inventoryManager.loadSubInventory(player, shopName); - - } - - - } - - } - - // Sub inventories - - @EventHandler - public void onClickSubInventory(InventoryClickEvent event) { - - FileConfiguration config = plugin.shopFile; - - String clickedInventory = ChatUtil.stripColor(event.getInventory().getTitle()); - - boolean foundInventory = false; - - String shopName = ""; - - ConfigurationSection cs = config.getConfigurationSection("shops"); - - if (cs != null) { - for (String key : config.getConfigurationSection("shops").getKeys(false)) { - - String inventoryName = ChatUtil.stripColor(config.getString("shops." + key + ".inventory-name")); - - if (!clickedInventory.equalsIgnoreCase(inventoryName)) - continue; - - foundInventory = true; - - shopName = key; - - break; - } - } - - if (!foundInventory || shopName.equalsIgnoreCase("")) - return; - - event.setCancelled(true); - - Player player = (Player) event.getWhoClicked(); - - int slot = event.getSlot(); - - int goBackButton = config.getInt("shops." + shopName + ".goBackButton"); - - boolean useBackButton = config.getBoolean("use-back-buttons"); - - // Player clicked on the back button - if (useBackButton && slot == goBackButton) { - - player.getOpenInventory().close(); - - player.performCommand("genbucket"); - - return; - } - - // They did not click on the back button so we - // have to check if they're trying to purchase - // a genbucket - - // Loop thru all slots in the shops config to see - // if it equals with a genbucket - - // Left click to buy or right click to open stacked shop - - for (String key : config.getConfigurationSection("shops." + shopName).getKeys(false)) { - - if (!config.contains("shops." + shopName + "." + key + ".slot")) - continue; - - int configSlot = config.getInt("shops." + shopName + "." + key + ".slot"); - - if (configSlot != slot) - continue; - - - // I can init & declare because I know I have the - // necessary data - - GenbucketItem genbucketItem = new GenbucketItem(shopName, key); - - // Buy a singular genbucket - if (event.getClick().equals(ClickType.LEFT)) { - - purchaseGenbucket(player, 1, genbucketItem); - - } else { - - // Open the multiple gui shop - - final boolean infinite_gens = plugin.getConfig().getBoolean("INFINITE-USE"); - - if (infinite_gens) { - return; - } - - shopMap.put(player.getUniqueId(), shopName + ":" + key); - - GenbucketManager genbucketManager = new GenbucketManager(); - - genbucketManager.openBulkShop(player, genbucketItem); - - } - - break; - - } - - } - - @EventHandler - public void onClickBulkShop(InventoryClickEvent event) { - - FileConfiguration config = EpicBuckets.getInstance().getConfig(); - - String inventoryName = ChatUtil.stripColor(config.getString("BULK-SHOP-INVENTORY.inventory-name").replace("{player}", event.getWhoClicked().getName())); - String clickedInventoryName = ChatUtil.stripColor(event.getInventory().getTitle()); - - if (!inventoryName.equalsIgnoreCase(clickedInventoryName)) - return; - - if (event.getCurrentItem() == null || event.getCurrentItem().getType().equals(Material.AIR)) - return; - - if (!event.getCurrentItem().hasItemMeta()) - return; - - event.setCancelled(true); - - // Lets first check if they're trying to increase/decrease the amount - - Player player = (Player) event.getWhoClicked(); - - // We have to case this to avoid NPE - - if (!shopMap.containsKey(player.getUniqueId())) { - player.getOpenInventory().close(); - return; - } - - int clickedSlot = event.getSlot(); - - int returnBackItemSlot = config.getInt("BULK-SHOP-INVENTORY.return-back-slot"); - - int purchaseItemSlot = config.getInt("BULK-SHOP-INVENTORY.purchase-item.slot"); - - if (ArrayUtils.contains(modifySlotList(), clickedSlot)) { - - modifyValue(event.getInventory(), player, event.getCurrentItem()); - - } else if (clickedSlot == returnBackItemSlot) { - - player.getOpenInventory().close(); - - String[] genbucketDetails = shopMap.get(player.getUniqueId()).split(":"); - - InventoryManager inventoryManager = new InventoryManager(); - - inventoryManager.loadSubInventory(player, genbucketDetails[0]); - - } else if (clickedSlot == purchaseItemSlot) { - - String[] genbucketDetails = shopMap.get(player.getUniqueId()).split(":"); - - GenbucketItem genbucketItem = new GenbucketItem(genbucketDetails[0], genbucketDetails[1]); - - purchaseGenbucket(player, GenbucketManager.getPlayerInteger(player), genbucketItem); - } - - } - - @EventHandler - public void onClickActGbInventory(InventoryClickEvent event) { - - - if (!event.getInventory().getTitle().equalsIgnoreCase("Active genbuckets")) - return; - - if (event.getCurrentItem() == null || event.getCurrentItem().getType().equals(Material.AIR)) - return; - - if (!event.getCurrentItem().hasItemMeta()) - return; - - event.setCancelled(true); - - if (event.getSlot() == 53) { - - InventoryManager inventoryManager = new InventoryManager(); - - inventoryManager.loadNextInventory(event.getInventory()); - return; - } - - UUID uuid = UUID.fromString(ChatColor.stripColor(event.getCurrentItem().getItemMeta().getDisplayName())); - - Player player = (Player) event.getWhoClicked(); - - ClickType clickType = event.getClick(); - - if (clickType.equals(ClickType.LEFT)) { - - // Teleport - - player.teleport(GenbucketManager.activeGenbucketLocation.get(uuid).clone().add(0, 50, 0)); - player.sendMessage("§a§lTeleporting..."); - - } else { - - GenbucketManager.activeGenbucketItems.remove(uuid); - event.getInventory().clear(event.getSlot()); - player.sendMessage("§c§lStopping..."); - } - - } - - private void modifyValue(Inventory inventory, Player player, ItemStack itemStack) { - - boolean addition = ChatUtil.stripColor(itemStack.getItemMeta().getDisplayName().split(" ")[0]).equalsIgnoreCase("+"); - - int value = Integer.parseInt(itemStack.getItemMeta().getDisplayName().split(" ")[1]); - - int oldAmount = GenbucketManager.getPlayerInteger(player); - - int newAmount; - - if (addition) { - - newAmount = oldAmount + value; - - if (newAmount > 64) - newAmount = newAmount - (newAmount - 64); - - GenbucketManager.setPlayerInteger(player, newAmount); - - } else { - - newAmount = oldAmount - value; - - if (newAmount == 0) - newAmount = 1; - else if (newAmount < 0) - newAmount = oldAmount - (oldAmount - 1); - - GenbucketManager.setPlayerInteger(player, newAmount); - - } - - FileConfiguration config = plugin.getConfig(); - - int mainItemSlot = config.getInt("BULK-SHOP-INVENTORY.plugin-item-slot"); - - inventory.getItem(mainItemSlot).setAmount(GenbucketManager.getPlayerInteger(player)); - - player.updateInventory(); - - } - - private int[] modifySlotList() { - - FileConfiguration config = plugin.getConfig(); - - int[] modifyValueSlots = new int[6]; - - for (int i = 0; i < config.getString("BULK-SHOP-INVENTORY.increase-item.slots").split(",").length; i++) - modifyValueSlots[i] = Integer.parseInt(config.getString("BULK-SHOP-INVENTORY.increase-item.slots").split(",")[i]); - - int x = 3; - - for (int i = 0; i < config.getString("BULK-SHOP-INVENTORY.decrease-item.slots").split(",").length; i++) { - - if (modifyValueSlots[x] == 0) - modifyValueSlots[x] = Integer.parseInt(config.getString("BULK-SHOP-INVENTORY.decrease-item.slots").split(",")[i]); - - x++; - - } - - return modifyValueSlots; - - } - - private void purchaseGenbucket(Player player, int amount, GenbucketItem genbucketItem) { - - if (player.getInventory().firstEmpty() == -1) { - - player.sendMessage(EpicBuckets.getInstance().getLocale().getMessage("event.purchase.inventoryfull")); - - return; - } - - int price = genbucketItem.getPrice() * amount; - - double playerBalance = plugin.getBalance(player); - - final boolean infinite_gens = plugin.getConfig().getBoolean("INFINITE-USE"); - - if (infinite_gens) { - player.getInventory().addItem(genbucketItem.getGenbucketItem()); - return; - } - - if (playerBalance >= price) { - - // they have enough money - - plugin.withdrawBalance(player, price, true); - - genbucketItem.setAmount(amount); - - player.getInventory().addItem(genbucketItem.getGenbucketItem()); - - } else { - - // they have less money - - player.sendMessage(plugin.getLocale().getMessage("interface.withdrawl.success", String.valueOf((playerBalance - price) * -1))); - - } - - boolean closeGUI = plugin.getConfig().getBoolean("CLOSE-GUI-AFTER-PURCHASE"); - - if (closeGUI) - player.getOpenInventory().close(); - - } - - -} diff --git a/src/main/java/com/songoda/epicbuckets/regionhandlers/RegionFactions.java b/src/main/java/com/songoda/epicbuckets/regionhandlers/RegionFactions.java deleted file mode 100644 index 335a0f7..0000000 --- a/src/main/java/com/songoda/epicbuckets/regionhandlers/RegionFactions.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.songoda.epicbuckets.regionhandlers; - -import com.songoda.epicbuckets.EpicBuckets; -import me.markeh.factionsframework.entities.FPlayers; -import me.markeh.factionsframework.entities.Faction; -import org.bukkit.Location; -import org.bukkit.entity.Player; - -/** - * FactionsUUID created by: SoFocused - * Date Created: oktober 05 2018 - * Time created: 18:00 - */ -public class RegionFactions { - - public static boolean canBuild(Player player, Location location) { - - boolean isFactionsUUIDEnabled = EpicBuckets.getInstance().getConfig().getBoolean("FACTIONS-SUPPORT"); - - if (!isFactionsUUIDEnabled) - return true; - - - Faction factionAt = me.markeh.factionsframework.entities.Factions.getFactionAt(location); - - boolean enableGensInWilderness = EpicBuckets.getInstance().getConfig().getBoolean("ENABLE-GENS-IN-WILDERNESS"); - - if (factionAt.isNone()) { - return enableGensInWilderness; - } - - return false; - } - - -} diff --git a/src/main/java/com/songoda/epicbuckets/regionhandlers/RegionGriefPrevention.java b/src/main/java/com/songoda/epicbuckets/regionhandlers/RegionGriefPrevention.java deleted file mode 100644 index 6579707..0000000 --- a/src/main/java/com/songoda/epicbuckets/regionhandlers/RegionGriefPrevention.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.songoda.epicbuckets.regionhandlers; - -import com.songoda.epicbuckets.EpicBuckets; -import org.bukkit.Location; -import org.bukkit.entity.Player; - -/** - * GriefPrevention created by: SoFocused - * Date Created: oktober 05 2018 - * Time created: 18:00 - */ -public class RegionGriefPrevention { - - public static me.ryanhamshire.GriefPrevention.GriefPrevention getGriefPrevention() { - org.bukkit.plugin.Plugin pl = EpicBuckets.getInstance().getServer().getPluginManager().getPlugin("GriefPrevention"); - - if (pl == null) { - EpicBuckets.getInstance().getLogger().warning("GriefPrevention support is enabled but cannot find the plugin"); - return null; - } - - return (me.ryanhamshire.GriefPrevention.GriefPrevention) pl; - - } - - public static boolean canBuild(Player player, Location location) { - - boolean isGriefPreventionEnabled = EpicBuckets.getInstance().getConfig().getBoolean("griefprevention-support"); - - // If we don't check for griefprevention, just let them place - if (!isGriefPreventionEnabled) - return true; - - return getGriefPrevention().allowBreak(player, location.getBlock(), location) != null; - - } - -} diff --git a/src/main/java/com/songoda/epicbuckets/regionhandlers/RegionWBorder.java b/src/main/java/com/songoda/epicbuckets/regionhandlers/RegionWBorder.java deleted file mode 100644 index 3b276d8..0000000 --- a/src/main/java/com/songoda/epicbuckets/regionhandlers/RegionWBorder.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.songoda.epicbuckets.regionhandlers; - -import com.songoda.epicbuckets.EpicBuckets; -import org.bukkit.Location; -import org.bukkit.WorldBorder; - -/** - * WBorder created by: SoFocused - * Date Created: oktober 05 2018 - * Time created: 22:06 - */ -public class RegionWBorder { - - public static boolean isOutsideOfBorder(Location loc) { - - if (EpicBuckets.getInstance().getServer().getVersion().contains("1.7")) - return true; - - WorldBorder border = loc.getWorld().getWorldBorder(); - double size = border.getSize() / 2; - Location center = border.getCenter(); - double x = loc.getX() - center.getX(), z = loc.getZ() - center.getZ(); - return ((x > size || (-x) > size) || (z > size || (-z) > size)); - - } - -} diff --git a/src/main/java/com/songoda/epicbuckets/regionhandlers/RegionWorldGuard.java b/src/main/java/com/songoda/epicbuckets/regionhandlers/RegionWorldGuard.java deleted file mode 100644 index 3a43b85..0000000 --- a/src/main/java/com/songoda/epicbuckets/regionhandlers/RegionWorldGuard.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.songoda.epicbuckets.regionhandlers; - -import com.sk89q.worldguard.bukkit.WorldGuardPlugin; -import com.sk89q.worldguard.protection.ApplicableRegionSet; -import com.sk89q.worldguard.protection.managers.RegionManager; -import com.sk89q.worldguard.protection.regions.ProtectedRegion; -import com.songoda.epicbuckets.EpicBuckets; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; - -/** - * WorldGuard created by: SoFocused - * Date Created: oktober 05 2018 - * Time created: 18:00 - */ -public class RegionWorldGuard { - - public static WorldGuardPlugin getWorldGuard() { - // WorldGuard may not be loaded - Plugin plugin = EpicBuckets.getInstance().getServer().getPluginManager().getPlugin("WorldGuard"); - - if (plugin == null || !(plugin instanceof WorldGuardPlugin)) { - return null; // Maybe you want throw an exception instead - } - return (WorldGuardPlugin) plugin; - } - - public static boolean canBuild(Player player, Location loc) { - - boolean isWorldGuardEnabled = EpicBuckets.getInstance().getConfig().getBoolean("WORLDGUARD-SUPPORT"); - - if (!isWorldGuardEnabled) - return true; - - RegionManager regionManager = getWorldGuard().getRegionManager(player.getLocation().getWorld()); - - ApplicableRegionSet set = regionManager.getApplicableRegions(loc); - - for (ProtectedRegion region : set) { - return false; - } - - return true; - } - -} diff --git a/src/main/java/com/songoda/epicbuckets/util/ChatUtil.java b/src/main/java/com/songoda/epicbuckets/util/ChatUtil.java deleted file mode 100644 index 6c411f9..0000000 --- a/src/main/java/com/songoda/epicbuckets/util/ChatUtil.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.songoda.epicbuckets.util; - -import com.songoda.epicbuckets.EpicBuckets; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.List; -import java.util.StringJoiner; - -/** - * ChatUtil created by: SoFocused - * Date Created: oktober 02 2018 - * Time created: 22:54 - */ -public class ChatUtil { - - public static String colorPrefix(String msg) { - return ChatColor.translateAlternateColorCodes('&', getPrefix() + msg); - } - - public static String colorString(String msg) { - return ChatColor.translateAlternateColorCodes('&', msg); - - } - - public static List colorList(List list) { - - List newList = new ArrayList<>(); - - list.forEach(string -> newList.add(colorString(string))); - - return newList; - - } - - public static List colorList(List list, Material material, int price) { - - List newList = new ArrayList<>(); - - list.forEach(string -> newList.add(colorString(string.replace("{material}", properMaterialName(material).toLowerCase()).replace("{price}", String.valueOf(price))))); - - return newList; - - } - - public static String stripColor(String input) { - return ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', input)); - } - - public static String getPrefix() { - return EpicBuckets.getInstance().getLocale().getMessage("general.nametag.prefix").equals("none") ? "" : EpicBuckets.getInstance().getLocale().getMessage("general.nametag.prefix") + " "; - } - - public static void debugMSG(Player player, Object... args) { - - StringJoiner stringBuilder = new StringJoiner("§8:"); - - for (int i = 0; i < args.length; i++) - stringBuilder.add("§a" + args[i].toString()); - - - player.sendMessage(stringBuilder.toString()); - - } - - public static String getCoordinatesFromLocation(Location l) { - return "X: " + l.getBlockX() + " Y: " + l.getBlockY() + " Z: " + l.getBlockZ(); - } - - public static String properMaterialName(Material material) { - - String materialName; - - if (material.name().split("_").length > 1) { - - StringJoiner stringJoiner = new StringJoiner(" "); - - for (String str : material.name().split("_")) - stringJoiner.add(str); - - materialName = stringJoiner.toString(); - } else - materialName = material.name(); - - return materialName; - - } - - -} diff --git a/src/main/java/com/songoda/epicbuckets/util/InventoryUtil.java b/src/main/java/com/songoda/epicbuckets/util/InventoryUtil.java deleted file mode 100644 index 465684b..0000000 --- a/src/main/java/com/songoda/epicbuckets/util/InventoryUtil.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.songoda.epicbuckets.util; - -import com.songoda.epicbuckets.EpicBuckets; -import org.bukkit.Material; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; - -import java.util.Arrays; - -/** - * InventoryUtil created by: SoFocused - * Date Created: oktober 03 2018 - * Time created: 16:25 - */ -public class InventoryUtil { - - public static EpicBuckets plugin = EpicBuckets.getInstance(); - - - public static ItemStack getFillItemStack() { - - FileConfiguration config = plugin.getConfig(); - - Material m = Material.valueOf(config.getString("FILL-ITEM.material").toUpperCase()); - - int damage = config.getInt("FILL-ITEM.damage"); - - return ItemStackUtil.createItemStack(config.getString("FILL-ITEM.name"), Arrays.asList("&f"), m, 1, damage, false); - - } - - private static ItemStack getBackItemStack() { - - FileConfiguration config = plugin.getConfig(); - - Material m = Material.valueOf(config.getString("BACK-BUTTON.material").toUpperCase()); - - int damage = config.getInt("BACK-BUTTON.damage"); - - return ItemStackUtil.createItemStack(config.getString("BACK-BUTTON.name"), Arrays.asList("&f"), m, 1, damage, false); - - } - - public static void fillInventory(Inventory inventory, boolean fillInventory) { - - if (!fillInventory) - return; - - for (int i = 0; i < inventory.getSize(); i++) - inventory.setItem(i, getFillItemStack()); - - } - - public static void setBackButton(Inventory inventory, int slot, boolean setItem) { - - if (setItem) - inventory.setItem(slot, getBackItemStack()); - - } - - -} diff --git a/src/main/java/com/songoda/epicbuckets/util/ItemStackUtil.java b/src/main/java/com/songoda/epicbuckets/util/ItemStackUtil.java deleted file mode 100644 index 73a890c..0000000 --- a/src/main/java/com/songoda/epicbuckets/util/ItemStackUtil.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.songoda.epicbuckets.util; - -import com.songoda.epicbuckets.EpicBuckets; -import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.inventory.ItemFlag; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -import java.util.List; - -/** - * ItemStackUtil created by: SoFocused - * Date Created: oktober 03 2018 - * Time created: 16:26 - */ -public class ItemStackUtil { - - public static ItemStack createItemStack(String name, List lore, Material m, int amount, int i, boolean enchantItem) { - ItemStack itemStack = new ItemStack(m, amount, (short) i); - ItemMeta itemMeta = itemStack.getItemMeta(); - - if (name != null) - itemMeta.setDisplayName(ChatUtil.colorString(name)); - if (lore != null) - itemMeta.setLore(ChatUtil.colorList(lore)); - - if (enchantItem) { - - itemMeta.addEnchant(Enchantment.DURABILITY, 1, false); - - if (!EpicBuckets.getInstance().getServer().getVersion().contains("1.7")) - itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS); - - } - - itemStack.setItemMeta(itemMeta); - - return itemStack; - } - - -} diff --git a/src/main/java/com/songoda/epicbuckets/util/ServerVersion.java b/src/main/java/com/songoda/epicbuckets/util/ServerVersion.java deleted file mode 100644 index 388586e..0000000 --- a/src/main/java/com/songoda/epicbuckets/util/ServerVersion.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.songoda.epicbuckets.util; - -public enum ServerVersion { - - UNKNOWN("unknown_server_version"), - V1_7("org.bukkit.craftbukkit.v1_7"), - V1_8("org.bukkit.craftbukkit.v1_8"), - V1_9("org.bukkit.craftbukkit.v1_9"), - V1_10("org.bukkit.craftbukkit.v1_10"), - V1_11("org.bukkit.craftbukkit.v1_11"), - V1_12("org.bukkit.craftbukkit.v1_12"), - V1_13("org.bukkit.craftbukkit.v1_13"); - - - private final String packagePrefix; - - private ServerVersion(String packagePrefix) { - this.packagePrefix = packagePrefix; - } - - public static ServerVersion fromPackageName(String packageName) { - for (ServerVersion version : values()) - if (packageName.startsWith(version.packagePrefix)) return version; - return ServerVersion.UNKNOWN; - } -} \ No newline at end of file diff --git a/src/main/java/com/songoda/epicbuckets/util/Util.java b/src/main/java/com/songoda/epicbuckets/util/Util.java deleted file mode 100644 index 4e7aea1..0000000 --- a/src/main/java/com/songoda/epicbuckets/util/Util.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.songoda.epicbuckets.util; - -import com.songoda.epicbuckets.EpicBuckets; - -/** - * Util created by: SoFocused - * Date Created: oktober 06 2018 - * Time created: 12:24 - */ -public class Util { - - public static boolean disableGenbuckets() { - return EpicBuckets.getInstance().getConfig().getBoolean("DISABLE-GENBUCKETS"); - } - - public static boolean useSpongeSupport() { - return EpicBuckets.getInstance().getConfig().getBoolean("USE-SPONGE-SUPPORT"); - } - - public static boolean enchantGenbuckets() { - return EpicBuckets.getInstance().getConfig().getBoolean("ENCHANT"); - } - - public static boolean infiniteGenbuckets() { - return EpicBuckets.getInstance().getConfig().getBoolean("INFINITE-USE"); - } - -} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index c1aa3bd..679c46f 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -4,7 +4,7 @@ ############################################### -# All config files can be found on +# All files files can be found on # https://www.spigotmc.org/resources/ezbucket-1-7-1-12-region-support-gui-horizontal-vertical-and-infused-gens-genbucket.50944/ FACTIONS-SUPPORT: false # MassiveCore and Factions/FactionsUUID/SavageFactions is needed diff --git a/src/main/resources/shops.yml b/src/main/resources/shops.yml index 28c370b..4f273c5 100644 --- a/src/main/resources/shops.yml +++ b/src/main/resources/shops.yml @@ -4,7 +4,7 @@ shops: vertical: - goBackButton: 31 # back button will display if enabled in config.yml + goBackButton: 31 # back button will display if enabled in files.yml trait: "VERTICAL" # Which genbucket type does this shop have?