From 44332fceb706b568a16be18007090ad12b24f742 Mon Sep 17 00:00:00 2001 From: Unprotesting Date: Sun, 11 Oct 2020 16:53:40 +0100 Subject: [PATCH] 0.10.0 - Added atconfig command + Added atconfig command and atconfig permission to edit config values in-game + Cleaned up pom.xml + Updated to 0.10.0 --- Auto-Tune/.classpath | 11 - Auto-Tune/.factorypath | 3 - Auto-Tune/.project | 13 +- Auto-Tune/dependency-reduced-pom.xml | 81 ++-- Auto-Tune/pom.xml | 35 +- Auto-Tune/src/resources/plugin.yml | 4 + .../AutoTuneAutoTuneConfigCommand.java | 375 ++++++++++++++++++ .../com/github/Commands/AutoTuneCommand.java | 1 + .../github/Commands/AutoTuneLoanCommand.java | 2 +- .../src/unprotesting/com/github/Main.java | 13 +- .../com/github/util/ChatHandler.java | 32 ++ README.md | 5 +- 12 files changed, 500 insertions(+), 75 deletions(-) delete mode 100644 Auto-Tune/.factorypath create mode 100644 Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneAutoTuneConfigCommand.java create mode 100644 Auto-Tune/src/unprotesting/com/github/util/ChatHandler.java diff --git a/Auto-Tune/.classpath b/Auto-Tune/.classpath index fda11a8..50a624d 100644 --- a/Auto-Tune/.classpath +++ b/Auto-Tune/.classpath @@ -19,17 +19,6 @@ - - - - - - - - - - - diff --git a/Auto-Tune/.factorypath b/Auto-Tune/.factorypath deleted file mode 100644 index 7a2c8b0..0000000 --- a/Auto-Tune/.factorypath +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/Auto-Tune/.project b/Auto-Tune/.project index 6755740..01a008e 100644 --- a/Auto-Tune/.project +++ b/Auto-Tune/.project @@ -20,4 +20,15 @@ org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature - \ No newline at end of file + + + 1601053181493 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + diff --git a/Auto-Tune/dependency-reduced-pom.xml b/Auto-Tune/dependency-reduced-pom.xml index 726ad93..55e132f 100644 --- a/Auto-Tune/dependency-reduced-pom.xml +++ b/Auto-Tune/dependency-reduced-pom.xml @@ -4,7 +4,7 @@ unprotesting.com.github Auto-Tune Auto-Tune - 0.9.1 + 0.10.0 The automatic pricing plugin for minecraft https://github.com/Unprotesting/Auto-Tune @@ -32,28 +32,17 @@ - - maven-surefire-plugin - 3.0.0-M5 - maven-compiler-plugin - 3.8.1 + 2.0.2 1.8 1.8 - - - org.projectlombok - lombok - ${lombok.version} - - maven-shade-plugin - 3.2.4 + 2.3 package @@ -96,47 +85,85 @@ jitpack.io https://jitpack.io - - projectlombok.org - https://projectlombok.org/edge-releases - org.spigotmc spigot-api - 1.16.3-R0.1-SNAPSHOT + 1.16.2-R0.1-SNAPSHOT provided + + + commons-lang + commons-lang + + + gson + com.google.code.gson + + + bungeecord-chat + net.md-5 + + + snakeyaml + org.yaml + + com.github.MilkBowl VaultAPI 1.7 provided - - - org.projectlombok - lombok - edge-SNAPSHOT - provided + + + bukkit + org.bukkit + + org.junit.jupiter junit-jupiter-api 5.7.0-RC1 provided + + + apiguardian-api + org.apiguardian + + + opentest4j + org.opentest4j + + + junit-platform-commons + org.junit.platform + + org.junit.jupiter junit-jupiter-engine 5.7.0-RC1 provided + + + junit-platform-engine + org.junit.platform + + + apiguardian-api + org.apiguardian + + - edge-SNAPSHOT - 1.8 ${project.groupId}.${project.artifactId} + 1.6 UTF-8 + diff --git a/Auto-Tune/pom.xml b/Auto-Tune/pom.xml index a8a563c..30f99ab 100644 --- a/Auto-Tune/pom.xml +++ b/Auto-Tune/pom.xml @@ -1,16 +1,15 @@ + 4.0.0 UTF-8 ${project.groupId}.${project.artifactId} - 1.8 - edge-SNAPSHOT + 1.6 unprotesting.com.github Auto-Tune - 0.9.1 - jar + 0.10.0 Auto-Tune https://github.com/Unprotesting/Auto-Tune @@ -39,10 +38,6 @@ jitpack.io https://jitpack.io - - projectlombok.org - https://projectlombok.org/edge-releases - @@ -54,7 +49,7 @@ org.spigotmc spigot-api - 1.16.3-R0.1-SNAPSHOT + 1.16.2-R0.1-SNAPSHOT provided @@ -66,7 +61,7 @@ com.github.stefvanschie.inventoryframework IF - 0.7.2 + 0.7.0 org.apache.httpcomponents @@ -76,8 +71,8 @@ org.projectlombok lombok - ${lombok.version} - provided + 1.18.12 + compile com.googlecode.json-simple @@ -115,31 +110,19 @@ - - org.apache.maven.plugins - maven-surefire-plugin - 3.0.0-M5 - org.apache.maven.plugins maven-compiler-plugin - 3.8.1 + 2.0.2 1.8 1.8 - - - org.projectlombok - lombok - ${lombok.version} - - org.apache.maven.plugins maven-shade-plugin - 3.2.4 + 2.3 diff --git a/Auto-Tune/src/resources/plugin.yml b/Auto-Tune/src/resources/plugin.yml index 63a942b..a596c16 100644 --- a/Auto-Tune/src/resources/plugin.yml +++ b/Auto-Tune/src/resources/plugin.yml @@ -43,6 +43,8 @@ commands: gdp: description: View GDP info usage: + atconfig: + description: View and change plugin config settings permssions: at.help: description: Displays Auto-Tune help information @@ -63,6 +65,8 @@ permssions: description: Decrease price of an item at.gdp: description: View GDP info + at.atconfig: + description: View and change plugin config settings diff --git a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneAutoTuneConfigCommand.java b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneAutoTuneConfigCommand.java new file mode 100644 index 0000000..3b58bf8 --- /dev/null +++ b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneAutoTuneConfigCommand.java @@ -0,0 +1,375 @@ +package unprotesting.com.github.Commands; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.github.stefvanschie.inventoryframework.Gui; +import com.github.stefvanschie.inventoryframework.GuiItem; +import com.github.stefvanschie.inventoryframework.pane.OutlinePane; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.HumanEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.scheduler.BukkitRunnable; + +import unprotesting.com.github.Main; +import unprotesting.com.github.util.ChatHandler; +import unprotesting.com.github.util.Config; +import unprotesting.com.github.util.TextHandler; + +public class AutoTuneAutoTuneConfigCommand implements CommandExecutor { + + public static List pList = new ArrayList(); + + @Override + public boolean onCommand(CommandSender sender, Command command, String atconfig, String[] args) { + if (command.getName().equalsIgnoreCase("atconfig")) { + if (!(sender instanceof Player)) { + Main.sendMessage(sender, "&cPlayers only."); + return true; + } + if (sender instanceof Player) { + Player p = (Player) sender; + if (p.hasPermission("at.atconfig") || p.isOp()) { + Config.loadDefaults(); + openConfigGUI(p, sender); + return true; + } else { + TextHandler.noPermssion(p); + return true; + } + } + } + return false; + } + + public void openConfigGUI(Player player, CommandSender sender) { + OutlinePane configPane = new OutlinePane(0, 0, 5, 1); + Gui configGUI = new Gui(1, "Configuration Panel"); + GuiItem[] guiItemArr = createConfigMenuGuiItems(sender); + for (int i = 0; i < guiItemArr.length; i++) { + configPane.addItem(guiItemArr[i]); + } + configGUI.addPane(configPane); + configGUI.update(); + configGUI.show((HumanEntity) sender); + } + + public GuiItem[] createConfigMenuGuiItems(CommandSender sender) { + GuiItem[] guiItemArr = new GuiItem[5]; + guiItemArr[0] = new GuiItem(createGeneralSetting(), event -> { + event.getWhoClicked().getOpenInventory().close(); + loadGeneralSettings((Player) event.getWhoClicked(), sender); + }); + guiItemArr[1] = new GuiItem(createBasicAdvancedPricingModelSetting(), event -> { + event.getWhoClicked().getOpenInventory().close(); + loadBasicAdvancedPricingModelSettings((Player) event.getWhoClicked(), sender); + }); + guiItemArr[2] = new GuiItem(createExponentialPricingModelSetting(), event -> { + event.getWhoClicked().getOpenInventory().close(); + loadExponentialPricingModelSettings((Player) event.getWhoClicked(), sender); + }); + guiItemArr[3] = new GuiItem(createOtherEcononomySettings(), event -> { + event.getWhoClicked().getOpenInventory().close(); + loadOtherEcononomySettings((Player) event.getWhoClicked(), sender); + }); + guiItemArr[4] = new GuiItem(createOtherSettings(), event -> { + event.getWhoClicked().getOpenInventory().close(); + loadOtherSettings((Player) event.getWhoClicked(), sender); + }); + return guiItemArr; + } + + public void loadGeneralSettings(Player p, CommandSender sender) { + OutlinePane generalConfigPane = new OutlinePane(0, 0, 9, 2); + Gui generalConfigGUI = new Gui(2, "General-Configuration Panel"); + createGeneralConfigMenuGuiItems(generalConfigGUI, generalConfigPane, p, sender); + generalConfigGUI.addPane(generalConfigPane); + generalConfigGUI.update(); + generalConfigGUI.show((HumanEntity) sender); + } + + public void loadBasicAdvancedPricingModelSettings(Player p, CommandSender sender) { + OutlinePane BAConfigPane = new OutlinePane(0, 0, 9, 1); + Gui BAConfigGUI = new Gui(1, "Basic/Advanced Pricing-Model-Configuration Panel"); + createBasicAdvancedPricingModelConfigMenuGuiItems(BAConfigGUI, BAConfigPane, p, sender); + BAConfigGUI.addPane(BAConfigPane); + BAConfigGUI.update(); + BAConfigGUI.show((HumanEntity) sender); + } + + public void loadExponentialPricingModelSettings(Player p, CommandSender sender){ + OutlinePane EPConfigPane = new OutlinePane(0, 0, 9, 1); + Gui EPConfigGUI = new Gui(1, "Exponential Pricing-Model-Configuration Panel"); + createExponentialPricingModelMenuGuiItems(EPConfigGUI, EPConfigPane, p, sender); + EPConfigGUI.addPane(EPConfigPane); + EPConfigGUI.update(); + EPConfigGUI.show((HumanEntity) sender); + } + + public void loadOtherEcononomySettings(Player p, CommandSender sender){ + OutlinePane OEConfigPane = new OutlinePane(0, 0, 9, 1); + Gui OEConfigGUI = new Gui(1, "Other Econonomy Configuration Panel"); + createOtherEcononomyMenuGuiItems(OEConfigGUI, OEConfigPane, p, sender); + OEConfigGUI.addPane(OEConfigPane); + OEConfigGUI.update(); + OEConfigGUI.show((HumanEntity) sender); + } + + public void loadOtherSettings(Player p, CommandSender sender){ + OutlinePane OConfigPane = new OutlinePane(0, 0, 9, 1); + Gui OConfigGUI = new Gui(1, "Other-Configuration Panel"); + createOtherMenuGuiItems(OConfigGUI, OConfigPane, p, sender); + OConfigGUI.addPane(OConfigPane); + OConfigGUI.update(); + OConfigGUI.show((HumanEntity) sender); + } + + public ItemStack createOtherSettings(){ + ItemStack is = new ItemStack(Material.matchMaterial("STONE")); + ItemMeta im = is.getItemMeta(); + im.setDisplayName(ChatColor.GREEN + "Other Settings"); + im.setLore(Arrays.asList(ChatColor.WHITE + "Click to Change Settings")); + is.setItemMeta(im); + return is; + } + + public ItemStack createOtherEcononomySettings(){ + ItemStack is = new ItemStack(Material.matchMaterial("GOLD_INGOT")); + ItemMeta im = is.getItemMeta(); + im.setDisplayName(ChatColor.GREEN + "Other Econonomy Settings"); + im.setLore(Arrays.asList(ChatColor.WHITE + "Click to Change Settings")); + is.setItemMeta(im); + return is; + } + + public ItemStack createExponentialPricingModelSetting(){ + ItemStack is = new ItemStack(Material.matchMaterial("Piston")); + ItemMeta im = is.getItemMeta(); + im.setDisplayName(ChatColor.GREEN + "Exponential Pricing-Model Settings"); + im.setLore(Arrays.asList(ChatColor.WHITE + "Click to Change Settings")); + is.setItemMeta(im); + return is; + } + + public ItemStack createBasicAdvancedPricingModelSetting(){ + ItemStack is = new ItemStack(Material.matchMaterial("REDSTONE")); + ItemMeta im = is.getItemMeta(); + im.setDisplayName(ChatColor.GREEN + "Basic/Advanced Pricing-Model Settings"); + im.setLore(Arrays.asList(ChatColor.WHITE + "Click to Change Settings")); + is.setItemMeta(im); + return is; + } + + public ItemStack createGeneralSetting(){ + ItemStack is = new ItemStack(Material.matchMaterial("GRASS_BLOCK")); + ItemMeta im = is.getItemMeta(); + im.setDisplayName(ChatColor.GREEN + "General Settings"); + im.setLore(Arrays.asList(ChatColor.WHITE + "Click to Change Settings")); + is.setItemMeta(im); + return is; + } + + public void createGeneralConfigMenuGuiItems(Gui configGui, OutlinePane generalConfigPane, Player player, CommandSender sender) { + generalConfigPane.addItem(new GuiItem(createItemStackWithMeta("Web Server", String.valueOf(Config.isWebServer())), event -> { + Player p = (Player) event.getWhoClicked(); + checkForMessage(p, "Web Server", "web-server-enabled", "boolean", sender);})); + generalConfigPane.addItem(new GuiItem(createItemStackWithMeta("Port", Config.getPort()), event -> { + Player p = (Player) event.getWhoClicked(); + checkForMessage(p, "Port", "port", "integer", sender);})); + generalConfigPane.addItem(new GuiItem(createItemStackWithMeta("Server Name", Config.getServerName()), event -> { + Player p = (Player) event.getWhoClicked(); + checkForMessage(p, "Server Name", "server-name", "string", sender);})); + generalConfigPane.addItem(new GuiItem(createItemStackWithMeta("Pricing Model", Config.getPricingModel()), event -> { + Player p = (Player) event.getWhoClicked(); + checkForMessage(p, "Pricing Model", "pricing-model", "string", sender);})); + generalConfigPane.addItem(new GuiItem(createItemStackWithMeta("Time Period", Config.getTimePeriod()), event -> { + Player p = (Player) event.getWhoClicked(); + checkForMessage(p, "Time Period", "time-period", "integer", sender);})); + generalConfigPane.addItem(new GuiItem(createItemStackWithMeta("Menu Rows", Config.getMenuRows()), event -> { + Player p = (Player) event.getWhoClicked(); + checkForMessage(p, "Menu Rows", "menu-rows", "integer", sender);})); + generalConfigPane.addItem(new GuiItem(createItemStackWithMeta("Menu Title", Config.getMenuTitle()), event -> { + Player p = (Player) event.getWhoClicked(); + checkForMessage(p, "Menu Title", "menu-title", "string", sender);})); + generalConfigPane.addItem(new GuiItem(createItemStackWithMeta("No Permission Message", Config.getNoPermission()), event -> { + Player p = (Player) event.getWhoClicked(); + checkForMessage(p, "No Permission Message", "no-permission", "string", sender);})); + generalConfigPane.addItem(new GuiItem(createItemStackWithMeta("Auto Sell Update Period", Config.getAutoSellUpdatePeriod()), event -> { + Player p = (Player) event.getWhoClicked(); + checkForMessage(p, "Auto Sell Update Period", "auto-sell-update-period", "integer", sender);})); + generalConfigPane.addItem(new GuiItem(createItemStackWithMeta("Auto Sell Profit Update Period", Config.getAutoSellProfitUpdatePeriod()), + event -> { + Player p = (Player) event.getWhoClicked(); + checkForMessage(p, "Auto Sell Profit Update Period", "auto-sell-profit-update-period", "integer", sender); + resetPlayerToSettings(player, sender);})); + } + + public void createBasicAdvancedPricingModelConfigMenuGuiItems(Gui configGui, OutlinePane BAConfigPane, Player player, CommandSender sender) { + BAConfigPane.addItem(new GuiItem(createItemStackWithMeta("Volatility Algorithm", String.valueOf(Config.getBasicVolatilityAlgorithim())), event -> { + Player p = (Player) event.getWhoClicked(); + checkForMessage(p, "Volatility Algorithm", "Volatility-Algorithim", "string", sender);})); + BAConfigPane.addItem(new GuiItem(createItemStackWithMeta("Sell Price Difference", Config.getSellPriceDifference()), event -> { + Player p = (Player) event.getWhoClicked(); + checkForMessage(p, "Sell Price Difference", "sell-price-difference", "double", sender);})); + BAConfigPane.addItem(new GuiItem(createItemStackWithMeta("Fixed Max Volatility", Config.getBasicMaxFixedVolatility()), event -> { + Player p = (Player) event.getWhoClicked(); + checkForMessage(p, "Fixed Max Volatility", "Fixed-Max-Volatility", "double", sender);})); + BAConfigPane.addItem(new GuiItem(createItemStackWithMeta("Fixed Min Volatility", Config.getBasicMinFixedVolatility()), event -> { + Player p = (Player) event.getWhoClicked(); + checkForMessage(p, "Fixed Min Volatility", "Fixed-Min-Volatility", "double", sender);})); + BAConfigPane.addItem(new GuiItem(createItemStackWithMeta("Variable Max Volatility", Config.getBasicMaxVariableVolatility()), event -> { + Player p = (Player) event.getWhoClicked(); + checkForMessage(p, "Variable Max Volatility", "Variable-Max-Volatility", "double", sender);})); + BAConfigPane.addItem(new GuiItem(createItemStackWithMeta("Variable Min Volatility", Config.getBasicMinVariableVolatility()), event -> { + Player p = (Player) event.getWhoClicked(); + checkForMessage(p, "Variable Min Volatility", "Variable-Min-Volatility", "double", sender);})); + } + + public void createExponentialPricingModelMenuGuiItems(Gui configGui, OutlinePane BAConfigPane, Player player, CommandSender sender) { + BAConfigPane.addItem(new GuiItem(createItemStackWithMeta("Data Selection M", Config.getDataSelectionM()), event -> { + Player p = (Player) event.getWhoClicked(); + checkForMessage(p, "Data Selection M", "data-selection-m", "double", sender);})); + BAConfigPane.addItem(new GuiItem(createItemStackWithMeta("Data Selection Z", Config.getDataSelectionZ()), event -> { + Player p = (Player) event.getWhoClicked(); + checkForMessage(p, "Data Selection Z", "data-selection-z", "double", sender);})); + BAConfigPane.addItem(new GuiItem(createItemStackWithMeta("Data Selection C", Config.getDataSelectionC()), event -> { + Player p = (Player) event.getWhoClicked(); + checkForMessage(p, "Data Selection C", "data-selection-c", "double", sender);})); + } + + public void createOtherEcononomyMenuGuiItems(Gui configGui, OutlinePane BAConfigPane, Player player, CommandSender sender) { + BAConfigPane.addItem(new GuiItem(createItemStackWithMeta("Sell Price Difference Variation Enabled", String.valueOf(Config.isSellPriceDifferenceVariationEnabled())), event -> { + Player p = (Player) event.getWhoClicked(); + checkForMessage(p, "Sell Price Difference Variation Enabled", "sell-price-difference-variation-enabled", "boolean", sender);})); + BAConfigPane.addItem(new GuiItem(createItemStackWithMeta("Sell Price Difference Variation Start", Config.getSellPriceDifferenceVariationStart()), event -> { + Player p = (Player) event.getWhoClicked(); + checkForMessage(p, "Sell Price Difference Variation Start", "sell-price-differnence-variation-start", "double", sender);})); + BAConfigPane.addItem(new GuiItem(createItemStackWithMeta("Sell Price Variation Time Period", Config.getSellPriceVariationTimePeriod()), event -> { + Player p = (Player) event.getWhoClicked(); + checkForMessage(p, "Sell Price Variation Time Period", "sell-price-variation-time-period", "integer", sender);})); + BAConfigPane.addItem(new GuiItem(createItemStackWithMeta("Sell Price Variation Update Period", Config.getSellPriceVariationUpdatePeriod()), event -> { + Player p = (Player) event.getWhoClicked(); + checkForMessage(p, "Sell Price Variation Update Period", "sell-price-variation-update-period", "integer", sender);})); + } + + public void createOtherMenuGuiItems(Gui configGui, OutlinePane BAConfigPane, Player player, CommandSender sender) { + BAConfigPane.addItem(new GuiItem(createItemStackWithMeta("Debug Enabled", String.valueOf(Config.isDebugEnabled())), event -> { + Player p = (Player) event.getWhoClicked(); + checkForMessage(p, "Debug Enabled", "debug-enabled", "boolean", sender);})); + BAConfigPane.addItem(new GuiItem(createItemStackWithMeta("Checksum Header Bypass", String.valueOf(Config.isChecksumHeaderBypass())), event -> { + Player p = (Player) event.getWhoClicked(); + checkForMessage(p, "Checksum Header Bypass", "checksum-header-bypass", "boolean", sender);})); + } + + public void resetPlayerToSettings(Player p, CommandSender sender){ + Config.loadDefaults(); + p.getOpenInventory().close(); + openConfigGUI(p, sender); + } + + public void checkForMessage(Player p, String type, String configSetting, String setting, CommandSender sender) { + p.getOpenInventory().close(); + if (ChatHandler.message == null){ + p.sendMessage(ChatColor.GOLD + "Enter a new value for " + ChatColor.GREEN + type + ChatColor.GOLD + " in chat: "); + pList.add(p); + messageCheckRunnable(p, type, configSetting, setting, sender); + } + else{ + p.sendMessage(ChatColor.RED + "Please complete the answer for the previous setting first.."); + } + } + + public void messageCheckRunnable(Player p, String type, String configSetting, String setting, CommandSender sender){ + new BukkitRunnable(){ + @Override + public void run() { + if (ChatHandler.message != null) { + if (setting.contains("string")){ + Main.getMainConfig().set(configSetting, ChatHandler.message); + resetPlayerToSettings(p, sender); + this.cancel(); + } + if (setting.contains("boolean")){ + ChatHandler.message.toLowerCase(); + Main.getMainConfig().set(configSetting, Boolean.parseBoolean(ChatHandler.message)); + resetPlayerToSettings(p, sender); + this.cancel(); + } + if (setting.contains("integer")){ + Main.getMainConfig().set(configSetting, Integer.parseInt(ChatHandler.message)); + resetPlayerToSettings(p, sender); + this.cancel(); + } + if (setting.contains("double")){ + Main.getMainConfig().set(configSetting, Double.parseDouble(ChatHandler.message)); + resetPlayerToSettings(p, sender); + this.cancel(); + } + else{ + resetPlayerToSettings(p, sender); + this.cancel(); + } + try { + Main.getMainConfig().save(Main.getConfigf()); + } catch (IOException e) { + e.printStackTrace(); + } + p.sendMessage(ChatColor.GOLD + "Changed " + ChatColor.GREEN + type + ChatColor.GOLD + " to " + ChatColor.GREEN + ChatHandler.message); + pList.remove(p); + ChatHandler.message = null; + } + } + }.runTaskTimer(Main.getINSTANCE(), 0L, 5L); + } + + public ItemStack createItemStackWithMeta(String setting, int configSetting){ + ItemStack is = new ItemStack(Material.matchMaterial("LEVER")); + ItemMeta im = is.getItemMeta(); + im.setDisplayName(ChatColor.GREEN + setting + " : " + configSetting); + List list = new ArrayList(); + list.add(" "); + list.add(ChatColor.WHITE + "Left click to change"); + list.add(ChatColor.GRAY + "Changing a setting will remove all \'##\' config notes!"); + im.setLore(list); + is.setItemMeta(im); + return is; + } + + public ItemStack createItemStackWithMeta(String setting, String configSetting){ + ItemStack is = new ItemStack(Material.matchMaterial("LEVER")); + ItemMeta im = is.getItemMeta(); + im.setDisplayName(ChatColor.GREEN + setting + " : " + configSetting); + List list = new ArrayList(); + list.add(" "); + list.add(ChatColor.WHITE + "Left click to change"); + list.add(ChatColor.GRAY + "Changing a setting will remove all \'##\' config notes!"); + im.setLore(list); + is.setItemMeta(im); + return is; + } + + public ItemStack createItemStackWithMeta(String setting, double configSetting){ + ItemStack is = new ItemStack(Material.matchMaterial("LEVER")); + ItemMeta im = is.getItemMeta(); + im.setDisplayName(ChatColor.GREEN + setting + " : " + configSetting); + List list = new ArrayList(); + list.add(" "); + list.add(ChatColor.WHITE + "Left click to change"); + list.add(ChatColor.GRAY + "Changing a setting will remove all \'##\' config notes!"); + im.setLore(list); + is.setItemMeta(im); + return is; + } + + + +} \ No newline at end of file diff --git a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneCommand.java b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneCommand.java index cc9a306..af58280 100644 --- a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneCommand.java +++ b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneCommand.java @@ -120,6 +120,7 @@ else if (!(player.hasPermission("at.help")) && !(player.isOp())){ return true; } } + return false; } return false; } diff --git a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneLoanCommand.java b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneLoanCommand.java index 5da657a..48ecee2 100644 --- a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneLoanCommand.java +++ b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneLoanCommand.java @@ -26,7 +26,7 @@ public boolean onCommand(CommandSender sender, Command command, String loan, Str if (command.getName().equalsIgnoreCase("loan")){ Player p = (Player) sender; if (p.hasPermission("at.loan") || p.isOp()){ - if (args[0] == null || args[0] == " " || args[0] == "" || args[1]!=null){ + if (args[0] == null){ return false; } else{ diff --git a/Auto-Tune/src/unprotesting/com/github/Main.java b/Auto-Tune/src/unprotesting/com/github/Main.java index c6e4ddc..28af3da 100644 --- a/Auto-Tune/src/unprotesting/com/github/Main.java +++ b/Auto-Tune/src/unprotesting/com/github/Main.java @@ -52,6 +52,7 @@ import net.milkbowl.vault.economy.Economy; import unprotesting.com.github.Commands.AutoTuneGDPCommand; import unprotesting.com.github.Commands.AutoTuneAutoSellCommand; +import unprotesting.com.github.Commands.AutoTuneAutoTuneConfigCommand; import unprotesting.com.github.Commands.AutoTuneCommand; import unprotesting.com.github.Commands.AutoTuneGUIShopUserCommand; import unprotesting.com.github.Commands.AutoTuneLoanCommand; @@ -61,6 +62,7 @@ import unprotesting.com.github.util.AutoSellEventHandler; import unprotesting.com.github.util.AutoTunePlayerAutoSellEventHandler; import unprotesting.com.github.util.CSVHandler; +import unprotesting.com.github.util.ChatHandler; import unprotesting.com.github.util.Config; import unprotesting.com.github.util.HttpPostRequestor; import unprotesting.com.github.util.InflationEventHandler; @@ -79,7 +81,7 @@ public final class Main extends JavaPlugin implements Listener { private static final Logger log = Logger.getLogger("Minecraft"); public static Economy econ; - private static JavaPlugin plugin; + public static JavaPlugin plugin; static File playerdata = new File("plugins/Auto-Tune/", "playerdata.yml"); public static final String BASEDIR = "plugins/Auto-Tune/web"; public static final String BASEDIRMAIN = "plugins/Auto-Tune/data.csv"; @@ -93,7 +95,7 @@ public final class Main extends JavaPlugin implements Listener { public static HTreeMap loanMap; public static ConcurrentHashMap> tempmap; public static ConcurrentMap ItemMap; - BukkitScheduler scheduler; + public static BukkitScheduler scheduler; public File folderfile; public static Double buys = 0.0; public static Double sells = 0.0; @@ -102,7 +104,7 @@ public final class Main extends JavaPlugin implements Listener { public static Boolean locked = null; public static Boolean falseBool = false; - @Getter + static @Getter private File configf, shopf, tradef, tradeShortf; public static String basicVolatilityAlgorithim; @@ -140,6 +142,7 @@ public void onDisable() { @Override public void onEnable() { Bukkit.getServer().getPluginManager().registerEvents(new JoinEventHandler(), this); + Bukkit.getServer().getPluginManager().registerEvents(new ChatHandler(), this); folderfile = new File("plugins/Auto-Tune/web/"); folderfile.mkdirs(); createFiles(); @@ -148,6 +151,7 @@ public void onEnable() { File folderfileJS = new File("plugins/Auto-Tune/Javascript/"); folderfileJS.mkdirs(); INSTANCE = this; + plugin = this; if (!setupEconomy()) { log.severe(String.format("Disabled Auto-Tune due to no Vault dependency found!", getDescription().getName())); getServer().getPluginManager().disablePlugin(this); @@ -173,6 +177,7 @@ public void onEnable() { if (tempdatadata.isEmpty() == true || tempdatadata.get("SellPriceDifferenceDifference") == null) { tempdataresetSPDifference(); } + ChatHandler.message = null; saveplayerdata(); loadShopsFile(); loadShopData(); @@ -192,6 +197,7 @@ public void onEnable() { this.getCommand("sell").setExecutor(new AutoTuneSellCommand()); if (Config.isAutoSellEnabled()){this.getCommand("autosell").setExecutor(new AutoTuneAutoSellCommand());} this.getCommand("loan").setExecutor(new AutoTuneLoanCommand()); + this.getCommand("atconfig").setExecutor(new AutoTuneAutoTuneConfigCommand()); this.getCommand("loans").setExecutor(new AutoTuneLoansCommand()); this.getCommand("payloan").setExecutor(new AutoTunePaybackLoanCommand()); this.getCommand("gdp").setExecutor(new AutoTuneGDPCommand()); @@ -265,7 +271,6 @@ public void SellDifrunnable() { new BukkitRunnable() { @Override public void run() { - Integer sellPriceVariationInt = Config.getSellPriceVariationUpdatePeriod(); Double d = Double.valueOf(sellPriceVariationInt); Double updates = (Config.getSellPriceVariationTimePeriod() / d); diff --git a/Auto-Tune/src/unprotesting/com/github/util/ChatHandler.java b/Auto-Tune/src/unprotesting/com/github/util/ChatHandler.java new file mode 100644 index 0000000..0eb5161 --- /dev/null +++ b/Auto-Tune/src/unprotesting/com/github/util/ChatHandler.java @@ -0,0 +1,32 @@ +package unprotesting.com.github.util; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.AsyncPlayerChatEvent; + +import unprotesting.com.github.Commands.AutoTuneAutoTuneConfigCommand; + +public class ChatHandler implements Listener{ + + public static String message; + + @EventHandler + public void getChatMessage(AsyncPlayerChatEvent e){ + if (AutoTuneAutoTuneConfigCommand.pList.contains(e.getPlayer())){ + Player p = e.getPlayer(); + e.setCancelled(true); + String msg = e.getMessage(); + if (msg.contains("cancel")){ + p.sendMessage(ChatColor.RED + "Cancled"); + AutoTuneAutoTuneConfigCommand.pList.remove(p); + message = null; + } + else { + p.sendMessage(ChatColor.GRAY + "Changing setting to " + msg); + message = msg; + } + } + } +} diff --git a/README.md b/README.md index 7d372b1..3fe6426 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ An example of a shop setup using Auto-Tune: - 2 forced-inflation methods with individual options [Dynamic and Static Inflation, configurable update periods] - 2 integrated web-servers to display prices online in graphs [Server port settings and more] - Configurable GUI with sizing and naming options [80+ supported item-slots] + - Config settings can easily be modified with an in-built GUI editor - Configurable shops with options to lock price and sell-price-differences [For more look at shops.yml configuration below] - Configurable sell-price-difference - Sell price-difference-variation algorithim options [Update period, total time, starting-difference, ending difference] @@ -239,8 +240,8 @@ To get an Auto-Tune API key please open a ticket on our discord: #### Auto-Tune API Pricing -Pricing at the moment will be variable based on how much we think your server having Auto-Tune will benefit its development and growth (free keys are available for some servers) -However, pricing will roughly be at around: +Pricing at the moment will be variable based on how much we think your server having Auto-Tune will benefit its development and growth (free keys are available until 2021!) +When Auto-Tune goes paid, however, pricing will roughly be at around: - Basic: £1.00 per 25,000 - 50,000 API requests - Advanced: £1.00 per 20,000 - 40,000 API requests - Exponential: £1.00 per 8,000 - 25,000 API requests