diff --git a/Auto-Tune/dependency-reduced-pom.xml b/Auto-Tune/dependency-reduced-pom.xml index e72f264..0a39968 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.10.5 + 0.11.0 The automatic pricing plugin for minecraft https://github.com/Unprotesting/Auto-Tune diff --git a/Auto-Tune/pom.xml b/Auto-Tune/pom.xml index 2abecf1..0e87111 100644 --- a/Auto-Tune/pom.xml +++ b/Auto-Tune/pom.xml @@ -9,7 +9,7 @@ unprotesting.com.github Auto-Tune - 0.10.5 + 0.11.0 Auto-Tune https://github.com/Unprotesting/Auto-Tune diff --git a/Auto-Tune/src/resources/plugin.yml b/Auto-Tune/src/resources/plugin.yml index 7e81a7f..e1bf673 100644 --- a/Auto-Tune/src/resources/plugin.yml +++ b/Auto-Tune/src/resources/plugin.yml @@ -14,10 +14,9 @@ version: ${project.version} author: Unprotesting description: Automatic Economy Plugin depend: [Vault] -api-version: 1.16 +api-version: 1.14 website: https://github.com/Unprotesting/Auto-Tune prefix: '[AUTO-TUNE]' -loadbefore: [Essentials] commands: at: description: Auto-Tune Command. diff --git a/Auto-Tune/src/resources/shops.yml b/Auto-Tune/src/resources/shops.yml index 4332e9a..f638e67 100644 --- a/Auto-Tune/src/resources/shops.yml +++ b/Auto-Tune/src/resources/shops.yml @@ -19,11 +19,12 @@ ## Set the default / starting prices for the items you want available in the shop ## Info: Make sure you put a decimal point and two digits to create a double for the shop algorithim to accept and parse to a price-value ## Info: Most of these values will be almost useless once the economy has started, to use these values again delete the data.db file -## Options: "price: " set the defualt starting price of the item -## Options: "locked: " set the price to be locked or variable (variable by default). -## Options: "sell-difference: " set a custom sell-price-difference (default set in config). -## Options: "max-buy": set a maximum quantity that can be purchased in a time-period -## Options: "max-sell": set a maximum quantity that can be sold in a time-period +## Info: Material names are available here: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html +## Options: 'price: ' set the defualt starting price of the item +## Options: 'locked: ' set the price to be locked or variable (variable by default). +## Options: 'sell-difference: ' set a custom sell-price-difference (default set in config). +## Options: 'max-buy': set a maximum quantity that can be purchased in a time-period +## Options: 'max-sell': set a maximum quantity that can be sold in a time-period ## Example: @@ -39,475 +40,601 @@ shops: price: 15.00 max-buy: 80 max-sell: 115 + section: 'Ores' COAL_ORE: price: 30.00 max-buy: 50 max-sell: 90 + section: 'Ores' IRON_INGOT: price: 13.00 max-buy: 75 max-sell: 100 + section: 'Ores' IRON_ORE: price: 15.00 max-buy: 60 max-sell: 100 + section: 'Ores' GOLD_INGOT: price: 30.00 max-buy: 45 max-sell: 75 + section: 'Ores' GOLD_ORE: price: 32.50 max-buy: 40 max-sell: 90 + section: 'Ores' DIAMOND: price: 300.00 max-buy: 12 max-sell: 32 + section: 'Ores' DIAMOND_ORE: price: 550.00 max-buy: 5 max-sell: 12 + section: 'Ores' LAPIS_LAZULI: price: 18.00 max-buy: 128 max-sell: 256 + section: 'Ores' LAPIS_ORE: price: 35.00 max-buy: 64 max-sell: 80 + section: 'Ores' EMERALD: price: 150.00 max-buy: 12 max-sell: 32 + section: 'Ores' EMERALD_ORE: price: 250.00 max-buy: 6 max-sell: 32 + section: 'Ores' QUARTZ: price: 17.00 max-buy: 40 max-sell: 125 + section: 'Ores' NETHER_QUARTZ_ORE: price: 40.00 max-buy: 75 max-sell: 90 + section: 'Ores' REDSTONE: price: 9.00 max-buy: 80 max-sell: 128 + section: 'Ores' REDSTONE_ORE: price: 25.00 max-buy: 50 max-sell: 80 + section: 'Ores' NETHERITE_INGOT: price: 8000.00 max-buy: 1 max-sell: 2 + section: 'Ores' NETHERITE_SCRAP: price: 3000.00 max-buy: 2 max-sell: 4 + section: 'Ores' GLOWSTONE_DUST: price: 5.00 max-buy: 128 max-sell: 256 + section: 'Ores' DIRT: price: 0.5 max-buy: 512 max-sell: 1024 + section: 'Blocks' GRASS_BLOCK: price: 4.00 max-buy: 128 max-sell: 256 + section: 'Blocks' MYCELIUM: price: 8.00 max-buy: 75 max-sell: 100 + section: 'Blocks' COBBLESTONE: price: 1.00 max-buy: 256 max-sell: 800 + section: 'Blocks' STONE: price: 2.00 max-buy: 128 max-sell: 256 + section: 'Blocks' GRANITE: price: 0.80 max-buy: 128 max-sell: 512 + section: 'Blocks' DIORITE: price: 0.80 max-buy: 128 max-sell: 512 + section: 'Blocks' ANDESITE: price: 1.00 max-buy: 128 max-sell: 512 + section: 'Blocks' GRAVEL: price: 3.00 max-buy: 128 max-sell: 256 + section: 'Blocks' SAND: price: 1.00 max-buy: 128 max-sell: 500 + section: 'Blocks' SANDSTONE: price: 4.00 max-buy: 100 max-sell: 250 + section: 'Blocks' GLASS: price: 3.00 max-buy: 90 max-sell: 200 + section: 'Blocks' SNOWBALL: price: 1.50 max-buy: 128 max-sell: 512 + section: 'Blocks' CLAY_BALL: price: 2.50 max-buy: 64 max-sell: 128 + section: 'Blocks' ICE: price: 5.50 max-buy: 128 max-sell: 256 + section: 'Blocks' PRISMARINE: price: 9.00 max-buy: 64 max-sell: 175 + section: 'Blocks' PRISMARINE_BRICKS: price: 10.00 max-buy: 64 max-sell: 175 + section: 'Blocks' DARK_PRISMARINE: price: 12.50 max-buy: 64 max-sell: 175 + section: 'Blocks' OBSIDIAN: price: 15.00 max-buy: 20 max-sell: 64 + section: 'Blocks' END_STONE: price: 3.50 max-buy: 80 max-sell: 200 + section: 'Blocks' NETHERRACK: price: 1.00 max-buy: 256 max-sell: 1024 + section: 'Blocks' NETHER_BRICKS: price: 8.00 max-buy: 64 max-sell: 128 + section: 'Blocks' BLACKSTONE: price: 2.25 max-buy: 64 max-sell: 100 + section: 'Blocks' SOUL_SAND: price: 4.00 max-buy: 64 max-sell: 175 + section: 'Blocks' WHITE_WOOL: price: 6.50 max-buy: 64 max-sell: 80 + section: 'Blocks' OAK_LOG: price: 8.00 max-buy: 90 max-sell: 256 + section: 'Blocks' SPRUCE_LOG: price: 8.50 max-buy: 90 max-sell: 256 + section: 'Blocks' BIRCH_LOG: price: 8.50 max-buy: 90 max-sell: 256 + section: 'Blocks' DARK_OAK_LOG: price: 8.75 max-buy: 90 max-sell: 256 + section: 'Blocks' ACACIA_LOG: price: 8.25 max-buy: 90 max-sell: 256 + section: 'Blocks' JUNGLE_LOG: price: 8.25 max-buy: 90 max-sell: 256 + section: 'Blocks' CACTUS: price: 3.00 max-buy: 64 max-sell: 200 + section: 'Farming' VINE: price: 2.00 max-buy: 64 max-sell: 256 + section: 'Farming' CARROT: price: 4.00 max-buy: 80 max-sell: 256 + section: 'Farming' EGG: price: 3.50 max-buy: 32 max-sell: 128 + section: 'Farming' MELON_SLICE: price: 1.75 max-buy: 85 max-sell: 175 + section: 'Farming' APPLE: price: 4.00 max-buy: 64 max-sell: 100 + section: 'Farming' WHEAT: price: 2.00 max-buy: 128 max-sell: 256 + section: 'Farming' SUGAR_CANE: price: 1.50 max-buy: 164 max-sell: 256 + section: 'Farming' BEEF: price: 2.50 max-buy: 64 max-sell: 150 + section: 'Farming' PORKCHOP: price: 2.25 max-buy: 64 max-sell: 150 + section: 'Farming' CHICKEN: price: 1.45 max-buy: 64 max-sell: 150 + section: 'Farming' RABBIT: price: 2.50 max-buy: 64 max-sell: 150 + section: 'Farming' MUTTON: price: 2.00 max-buy: 64 max-sell: 150 + section: 'Farming' PUMPKIN: price: 8.00 max-buy: 64 max-sell: 128 + section: 'Farming' RED_MUSHROOM: price: 6.00 max-buy: 64 max-sell: 100 + section: 'Farming' BROWN_MUSHROOM: price: 6.00 max-buy: 64 max-sell: 100 + section: 'Farming' WHEAT_SEEDS: price: 1.25 max-buy: 80 max-sell: 200 + section: 'Farming' NETHER_WART: price: 4.00 max-buy: 64 max-sell: 200 + section: 'Farming' FLINT: price: 4.00 max-buy: 64 max-sell: 128 + section: 'Materials' GUNPOWDER: price: 12.50 max-buy: 64 max-sell: 128 + section: 'Materials' LEATHER: price: 20.00 max-buy: 64 max-sell: 128 + section: 'Materials' INK_SAC: price: 2.50 max-buy: 32 max-sell: 64 + section: 'Materials' FEATHER: price: 4.00 max-buy: 32 max-sell: 64 + section: 'Materials' BONE: price: 6.00 max-buy: 64 max-sell: 100 + section: 'Materials' BONE_MEAL: price: 2.00 max-buy: 64 max-sell: 90 + section: 'Materials' STRING: price: 4.00 max-buy: 64 max-sell: 100 + section: 'Materials' ROTTEN_FLESH: price: 0.50 max-buy: 64 max-sell: 128 + section: 'Materials' SPIDER_EYE: price: 7.00 max-buy: 64 max-sell: 128 + section: 'Materials' SLIME_BALL: price: 25.00 max-buy: 32 max-sell: 64 + section: 'Materials' ENDER_PEARL: price: 35.00 max-buy: 16 max-sell: 40 + section: 'Materials' NETHER_STAR: price: 12000.00 max-buy: 1 max-sell: 1 + section: 'Materials' GHAST_TEAR: price: 125.00 max-buy: 4 max-sell: 8 + section: 'Materials' MAGMA_CREAM: price: 50.00 max-buy: 16 max-sell: 32 + section: 'Materials' BLAZE_ROD: price: 45.00 max-buy: 8 max-sell: 32 + section: 'Materials' ARROW: price: 2.00 max-buy: 64 max-sell: 128 + section: 'Materials' NAME_TAG: price: 50.00 max-buy: 8 max-sell: 16 + section: 'Materials' CHORUS_FRUIT: price: 1.25 max-buy: 64 max-sell: 128 - HONEY_BOTTLE: - price: 5.00 - max-buy: 64 - max-sell: 128 + section: 'Farming' CHEST: price: 20.00 max-buy: 30 max-sell: 64 + section: 'Blocks' TORCH: price: 2.5 max-buy: 64 max-sell: 100 + section: 'Blocks' NOTE_BLOCK: price: 36.0 max-buy: 16 max-sell: 32 + section: 'Blocks' BUCKET: price: 7.50 max-buy: 16 max-sell: 32 + section: 'Other' FURNACE: price: 8.5 max-buy: 32 max-sell: 48 + section: 'Blocks' TNT: price: 125.0 max-buy: 16 max-sell: 32 + section: 'Blocks' SPONGE: price: 60.00 max-buy: 32 max-sell: 128 + section: 'Blocks' PHANTOM_MEMBRANE: price: 45.00 max-buy: 32 max-sell: 64 + section: 'Materials' OAK_LEAVES: price: 1.0 max-buy: 64 max-sell: 128 + section: 'Blocks' BIRCH_LEAVES: price: 1.0 max-buy: 64 max-sell: 128 + section: 'Blocks' SPRUCE_LEAVES: price: 1.0 max-buy: 64 max-sell: 128 + section: 'Blocks' JUNGLE_LEAVES: price: 1.0 max-buy: 64 max-sell: 128 + section: 'Blocks' DARK_OAK_LEAVES: price: 1.0 max-buy: 64 max-sell: 128 + section: 'Blocks' ACACIA_LEAVES: price: 1.0 max-buy: 64 max-sell: 128 + section: 'Blocks' OAK_PLANKS: price: 0.5 max-buy: 128 max-sell: 256 + section: 'Blocks' BIRCH_PLANKS: price: 0.5 max-buy: 128 max-sell: 256 + section: 'Blocks' SPRUCE_PLANKS: price: 0.5 max-buy: 128 max-sell: 256 + section: 'Blocks' JUNGLE_PLANKS: price: 0.5 max-buy: 128 max-sell: 256 + section: 'Blocks' DARK_OAK_PLANKS: price: 0.5 max-buy: 128 max-sell: 256 + section: 'Blocks' ACACIA_PLANKS: price: 0.5 max-buy: 128 max-sell: 256 + section: 'Blocks' OAK_SAPLING: price: 2.5 max-buy: 32 max-sell: 64 + section: 'Materials' BIRCH_SAPLING: price: 2.5 max-buy: 32 max-sell: 64 + section: 'Materials' SPRUCE_SAPLING: price: 2.5 max-buy: 32 max-sell: 64 + section: 'Materials' JUNGLE_SAPLING: price: 2.5 max-buy: 32 max-sell: 64 + section: 'Materials' DARK_OAK_SAPLING: price: 2.5 max-buy: 32 max-sell: 64 + section: 'Materials' ACACIA_SAPLING: price: 2.5 max-buy: 32 max-sell: 64 + section: 'Materials' DISPENSER: price: 58.0 max-buy: 8 max-sell: 16 + section: 'Blocks' CAKE: price: 160.0 max-buy: 8 max-sell: 10 + section: 'Other' MILK_BUCKET: price: 9.00 max-buy: 12 max-sell: 20 + section: 'Other' STICK: price: 0.2 max-buy: 64 max-sell: 128 + section: 'Materials' BOOK: price: 28.0 max-buy: 32 - max-sell: 48 \ No newline at end of file + max-sell: 48 + section: 'Other' +## Shop sections configuration +sections: + 'Ores': + block: 'IRON_ORE' + 'Blocks': + block: 'STONE' + 'Materials': + block: 'STICK' + 'Farming': + block: 'WHEAT_SEEDS' + 'Other': + block: 'COMMAND_BLOCK' diff --git a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneGUIShopUserCommand.java b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneGUIShopUserCommand.java index 56e8587..0c8d75e 100644 --- a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneGUIShopUserCommand.java +++ b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneGUIShopUserCommand.java @@ -2,6 +2,7 @@ import java.text.DecimalFormat; import java.util.Arrays; +import java.util.List; import java.util.concurrent.ConcurrentHashMap; import com.github.stefvanschie.inventoryframework.Gui; @@ -27,6 +28,7 @@ import net.milkbowl.vault.economy.Economy; import unprotesting.com.github.Main; import unprotesting.com.github.util.Config; +import unprotesting.com.github.util.Section; import unprotesting.com.github.util.TextHandler; public class AutoTuneGUIShopUserCommand implements CommandExecutor { @@ -54,7 +56,10 @@ public boolean onCommand(CommandSender sender, Command command, String shop, Str if (Config.getMenuRows() == 6) { SBPanePos = 2; } - if (p.hasPermission("at.shop") || p.isOp()){loadGUIMAIN(p, sender);} + if (p.hasPermission("at.shop") || p.isOp()) + { + loadGUISECTIONS(p, sender); + } else if (!(p.hasPermission("at.shop")) && !(p.isOp())){TextHandler.noPermssion(p);} return true; @@ -64,7 +69,39 @@ public boolean onCommand(CommandSender sender, Command command, String shop, Str } - public void loadGUIMAIN(Player player, CommandSender senderpub) { + public void loadGUISECTIONS(Player player, CommandSender senderpub){ + Gui front = new Gui(3, Config.getMenuTitle()); + OutlinePane pane = new OutlinePane(1, 1, 7, 1); + if (Main.sectionedItems.length > 7){ + front = new Gui(4, Config.getMenuTitle()); + pane = new OutlinePane(1, 1, 7, 2); + } + for (int i = 0; i < Main.sectionedItems.length; i++){ + ItemStack is = new ItemStack((Main.sectionedItems[i].image)); + ItemMeta im = is.getItemMeta(); + im.setDisplayName(ChatColor.GOLD + Main.sectionedItems[i].name); + im.setLore(Arrays.asList(ChatColor.WHITE + "Click to enter the " + (Main.sectionedItems[i].name.toLowerCase()) + " shop!")); + is.setItemMeta(im); + final Section inputSection = Main.sectionedItems[i]; + GuiItem gItem = new GuiItem(is, event ->{ + final Player playernew = player; + if (event.getClick() == ClickType.LEFT) { + player.getOpenInventory().close(); + loadGUIMAIN(player, senderpub, inputSection); + } + else if (event.getClick() != ClickType.LEFT) { + event.setCancelled(true); + playernew.setItemOnCursor(null); + } + }); + pane.addItem(gItem); + front.addPane(pane); + } + front.update(); + front.show((HumanEntity) senderpub); + } + + public void loadGUIMAIN(Player player, CommandSender senderpub, Section sec) { Integer menuRows = Config.getMenuRows(); OutlinePane SBPane = new OutlinePane(1, SBPanePos, 7, 2); ItemStack is; @@ -80,10 +117,11 @@ public void loadGUIMAIN(Player player, CommandSender senderpub) { StaticPane pageFive = new StaticPane(1, 1, 7, menuRows - 2); StaticPane back = new StaticPane(0, menuRows - 1, 1, 1); StaticPane forward = new StaticPane(8, menuRows - 1, 1, 1); + StaticPane reset = new StaticPane(0, 0, 1, 1); player = (Player) senderpub; gui1 = new Gui(menuRows, Config.getMenuTitle()); - Integer size = Main.getMaterialListSize(); + Integer size = sec.items.size(); PaginatedPane pane = new PaginatedPane(0, 0, 9, menuRows); Integer paneSize = (menuRows - 2) * 7; Integer pageAmount = 2; @@ -108,9 +146,9 @@ public void loadGUIMAIN(Player player, CommandSender senderpub) { // page one StaticPane pageOne = new StaticPane(1, 1, 7, menuRows - 2); - for (i = 0; i { if (event.getClick() == ClickType.LEFT) { @@ -121,8 +159,7 @@ public void loadGUIMAIN(Player player, CommandSender senderpub) { ItemStack tempis = event.getCurrentItem(); Material tempmat = tempis.getType(); matClickedString = tempmat.toString(); - ConcurrentHashMap tempmap = Main.map.get(matClickedString); + ConcurrentHashMap tempmap = Main.map.get(matClickedString); Integer tempMapSize = tempmap.size(); Double[] tempDoublearray = tempmap.get(tempMapSize - 1); price = tempDoublearray[0]; @@ -153,14 +190,14 @@ public void loadGUIMAIN(Player player, CommandSender senderpub) { } }); ItemMeta im = is.getItemMeta(); - im.setDisplayName(ChatColor.AQUA + Main.memMap.get(i)); - ConcurrentHashMap tempmap = Main.map.get(Main.memMap.get(i)); + im.setDisplayName(ChatColor.AQUA + sec.items.get(i)); + ConcurrentHashMap tempmap = Main.map.get(sec.items.get(i)); Integer tempMapSize = tempmap.size(); Double[] tempDoublearray = tempmap.get(tempMapSize - 1); price1 = tempDoublearray[0]; String priceString = df2.format(price1); String fullprice = "Price: " + Config.getCurrencySymbol() + priceString; - im.setLore(Arrays.asList((ChatColor.GOLD + fullprice), (ChatColor.WHITE + "Maximum Buys: " + (Integer)Main.getShopConfig().get("shops." + Main.memMap.get(i) + "." + "max-buy") + " per " + Config.getTimePeriod() + "min"), (ChatColor.WHITE + "Maximum Sells: " + (Integer)Main.getShopConfig().get("shops." + Main.memMap.get(i) + "." + "max-sell") + " per " + Config.getTimePeriod() + "min"))); + im.setLore(Arrays.asList((ChatColor.GOLD + fullprice), (ChatColor.WHITE + "Maximum Buys: " + (Integer)Main.getShopConfig().get("shops." + sec.items.get(i) + "." + "max-buy") + " per " + Config.getTimePeriod() + "min"), (ChatColor.WHITE + "Maximum Sells: " + (Integer)Main.getShopConfig().get("shops." + sec.items.get(i) + "." + "max-sell") + " per " + Config.getTimePeriod() + "min"))); is.setItemMeta(im); if (Config.getMenuRows() == 4) { if (i<7) { @@ -349,6 +386,18 @@ else if (finalPageAmount == 6) { imforward.setDisplayName(ChatColor.WHITE + "Next Page"); imforward.setLore(Arrays.asList(ChatColor.BOLD + "Click to go to the next page")); isforward.setItemMeta(imforward); + ItemStack isback2 = new ItemStack(Material.ARROW); + ItemMeta imback2 = isback2.getItemMeta(); + imback2.setDisplayName(ChatColor.WHITE + "Main-Menu"); + imback2.setLore(Arrays.asList(ChatColor.BOLD + "Click to return to Main-Shop Menu")); + isback2.setItemMeta(imback2); + + final Player fPlayer = player; + + reset.addItem(new GuiItem(new ItemStack(isback2), event -> { + fPlayer.getOpenInventory().close(); + loadGUISECTIONS(fPlayer, senderpub); + }), 0, 0); if (pane.getPage() == 0 && finalPageAmount == 6) { back.setVisible(false); @@ -411,9 +460,7 @@ else if (pane.getPage() == 0 && finalPageAmount == 2) { gui1.addPane(back); gui1.addPane(forward); - - gui1.addPane(back); - gui1.addPane(forward); + gui1.addPane(reset); gui1.show((HumanEntity) senderpub); @@ -484,7 +531,7 @@ public void createTradingPanel(Gui gui, String matClickedString, Player player, sellAmount }; tempMap2.put(tempMap2Size - 1, tempDArray); - ConcurrentHashMap cMap = Main.maxBuyMap.get(player); + ConcurrentHashMap cMap = Main.maxBuyMap.get(player.getUniqueId()); boolean notMax = true; Integer max = (Integer)Main.getShopConfig().get("shops." + matClickedString + "." + "max-buy"); if (max == null){ @@ -525,7 +572,7 @@ public void createTradingPanel(Gui gui, String matClickedString, Player player, sellAmount }; tempMap2.put(tempMap2Size - 1, tempDArray); - ConcurrentHashMap cMap = Main.maxBuyMap.get(player); + ConcurrentHashMap cMap = Main.maxBuyMap.get(player.getUniqueId()); boolean notMax = true; Integer max = (Integer)Main.getShopConfig().get("shops." + matClickedString + "." + "max-buy"); if (max == null){ @@ -566,7 +613,7 @@ public void createTradingPanel(Gui gui, String matClickedString, Player player, sellAmount }; tempMap2.put(tempMap2Size - 1, tempDArray); - ConcurrentHashMap cMap = Main.maxBuyMap.get(player); + ConcurrentHashMap cMap = Main.maxBuyMap.get(player.getUniqueId()); boolean notMax = true; Integer max = (Integer)Main.getShopConfig().get("shops." + matClickedString + "." + "max-buy"); if (max == null){ @@ -607,7 +654,7 @@ public void createTradingPanel(Gui gui, String matClickedString, Player player, sellAmount }; tempMap2.put(tempMap2Size - 1, tempDArray); - ConcurrentHashMap cMap = Main.maxBuyMap.get(player); + ConcurrentHashMap cMap = Main.maxBuyMap.get(player.getUniqueId()); boolean notMax = true; Integer max = (Integer)Main.getShopConfig().get("shops." + matClickedString + "." + "max-buy"); if (max == null){ @@ -648,7 +695,7 @@ public void createTradingPanel(Gui gui, String matClickedString, Player player, sellAmount }; tempMap2.put(tempMap2Size - 1, tempDArray); - ConcurrentHashMap cMap = Main.maxBuyMap.get(player); + ConcurrentHashMap cMap = Main.maxBuyMap.get(player.getUniqueId()); boolean notMax = true; Integer max = (Integer)Main.getShopConfig().get("shops." + matClickedString + "." + "max-buy"); if (max == null){ @@ -689,7 +736,7 @@ public void createTradingPanel(Gui gui, String matClickedString, Player player, sellAmount }; tempMap2.put(tempMap2Size - 1, tempDArray); - ConcurrentHashMap cMap = Main.maxBuyMap.get(player); + ConcurrentHashMap cMap = Main.maxBuyMap.get(player.getUniqueId()); boolean notMax = true; Integer max = (Integer)Main.getShopConfig().get("shops." + matClickedString + "." + "max-buy"); if (max == null){ @@ -730,7 +777,7 @@ public void createTradingPanel(Gui gui, String matClickedString, Player player, sellAmount }; tempMap2.put(tempMap2Size - 1, tempDArray); - ConcurrentHashMap cMap = Main.maxBuyMap.get(player); + ConcurrentHashMap cMap = Main.maxBuyMap.get(player.getUniqueId()); boolean notMax = true; Integer max = (Integer)Main.getShopConfig().get("shops." + matClickedString + "." + "max-buy"); if (max == null){ @@ -801,7 +848,7 @@ public void createTradingPanel(Gui gui, String matClickedString, Player player, } catch (IllegalArgumentException e) { player.sendMessage(ChatColor.RED + "No items present of that type in your inventory!"); } - ConcurrentHashMap cMap = Main.maxSellMap.get(player); + ConcurrentHashMap cMap = Main.maxSellMap.get(player.getUniqueId()); boolean notMax = true; Integer max = (Integer)Main.getShopConfig().get("shops." + matClickedString + "." + "max-sell"); if (max == null){ @@ -856,7 +903,7 @@ public void createTradingPanel(Gui gui, String matClickedString, Player player, } catch (IllegalArgumentException e) { player.sendMessage(ChatColor.RED + "No items present of that type in your inventory!"); } - ConcurrentHashMap cMap = Main.maxSellMap.get(player); + ConcurrentHashMap cMap = Main.maxSellMap.get(player.getUniqueId()); boolean notMax = true; Integer max = (Integer)Main.getShopConfig().get("shops." + matClickedString + "." + "max-sell"); if (max == null){ @@ -912,7 +959,7 @@ public void createTradingPanel(Gui gui, String matClickedString, Player player, } catch (IllegalArgumentException e) { player.sendMessage(ChatColor.RED + "No items present of that type in your inventory!"); } - ConcurrentHashMap cMap = Main.maxSellMap.get(player); + ConcurrentHashMap cMap = Main.maxSellMap.get(player.getUniqueId()); boolean notMax = true; Integer max = (Integer)Main.getShopConfig().get("shops." + matClickedString + "." + "max-sell"); if (max == null){ @@ -968,7 +1015,7 @@ public void createTradingPanel(Gui gui, String matClickedString, Player player, } catch (IllegalArgumentException e) { player.sendMessage(ChatColor.RED + "No items present of that type in your inventory!"); } - ConcurrentHashMap cMap = Main.maxSellMap.get(player); + ConcurrentHashMap cMap = Main.maxSellMap.get(player.getUniqueId()); boolean notMax = true; Integer max = (Integer)Main.getShopConfig().get("shops." + matClickedString + "." + "max-sell"); if (max == null){ @@ -1024,7 +1071,7 @@ public void createTradingPanel(Gui gui, String matClickedString, Player player, } catch (IllegalArgumentException e) { player.sendMessage(ChatColor.RED + "No items present of that type in your inventory!"); } - ConcurrentHashMap cMap = Main.maxSellMap.get(player); + ConcurrentHashMap cMap = Main.maxSellMap.get(player.getUniqueId()); boolean notMax = true; Integer max = (Integer)Main.getShopConfig().get("shops." + matClickedString + "." + "max-sell"); if (max == null){ @@ -1080,7 +1127,7 @@ public void createTradingPanel(Gui gui, String matClickedString, Player player, } catch (IllegalArgumentException e) { player.sendMessage(ChatColor.RED + "No items present of that type in your inventory!"); } - ConcurrentHashMap cMap = Main.maxSellMap.get(player); + ConcurrentHashMap cMap = Main.maxSellMap.get(player.getUniqueId()); boolean notMax = true; Integer max = (Integer)Main.getShopConfig().get("shops." + matClickedString + "." + "max-sell"); if (max == null){ @@ -1135,7 +1182,7 @@ public void createTradingPanel(Gui gui, String matClickedString, Player player, } catch (IllegalArgumentException e) { player.sendMessage(ChatColor.RED + "No items present of that type in your inventory!"); } - ConcurrentHashMap cMap = Main.maxSellMap.get(player); + ConcurrentHashMap cMap = Main.maxSellMap.get(player.getUniqueId()); boolean notMax = true; Integer max = (Integer)Main.getShopConfig().get("shops." + matClickedString + "." + "max-sell"); if (max == null){ @@ -1214,17 +1261,17 @@ public boolean hasAvaliableSlot(Player player) { public static void sendPlayerShopMessageAndUpdateGDP(int amount, double price, Player player, String matClickedString, boolean sell){ if (!sell){ - ConcurrentHashMap cMap = Main.maxBuyMap.get(player); + ConcurrentHashMap cMap = Main.maxBuyMap.get(player.getUniqueId()); cMap.put(matClickedString, (cMap.get(matClickedString)+amount)); - Main.maxBuyMap.put(player, cMap); + Main.maxBuyMap.put(player.getUniqueId(), cMap); Main.tempdatadata.put("GDP", (Main.tempdatadata.get("GDP")+(price*amount))); player.sendMessage(ChatColor.GOLD + "Purchased " + amount + "x " + matClickedString + " for " + ChatColor.GREEN + Config.getCurrencySymbol() + df2.format(price*amount)); } else if (sell){ - ConcurrentHashMap cMap = Main.maxSellMap.get(player); + ConcurrentHashMap cMap = Main.maxSellMap.get(player.getUniqueId()); cMap.put(matClickedString, (cMap.get(matClickedString)+amount)); - Main.maxSellMap.put(player, cMap); + Main.maxSellMap.put(player.getUniqueId(), cMap); Main.tempdatadata.put("GDP", (Main.tempdatadata.get("GDP")+(price*amount))); player.sendMessage(ChatColor.GOLD + "Sold " + amount + "x " + matClickedString + " for " + ChatColor.GREEN + Config.getCurrencySymbol() + df2.format(price*amount)); } diff --git a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneSellCommand.java b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneSellCommand.java index bf32eeb..285e053 100644 --- a/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneSellCommand.java +++ b/Auto-Tune/src/unprotesting/com/github/Commands/AutoTuneSellCommand.java @@ -76,7 +76,7 @@ public static void sellItems(Player player, ItemStack[] items, Boolean autoSell) continue; } if (!autoSell){ - ConcurrentHashMap cMap = Main.maxSellMap.get(player); + ConcurrentHashMap cMap = Main.maxSellMap.get(player.getUniqueId()); Integer max = 10000; try{ max = (Integer)Main.getShopConfig().get("shops." + itemString + "." + "max-sell"); @@ -95,9 +95,9 @@ public static void sellItems(Player player, ItemStack[] items, Boolean autoSell) continue; } } - ConcurrentHashMap cMap2 = Main.maxSellMap.get(player); + ConcurrentHashMap cMap2 = Main.maxSellMap.get(player.getUniqueId()); cMap2.put(itemString, (cMap2.get(itemString)+quantity)); - Main.maxSellMap.put(player, cMap2); + Main.maxSellMap.put(player.getUniqueId(), cMap2); Integer tempMapSize = tempMap1.size(); Double[] tempDoublearray = tempMap1.get(tempMapSize-1); Double sellpricedif = Config.getSellPriceDifference(); diff --git a/Auto-Tune/src/unprotesting/com/github/Main.java b/Auto-Tune/src/unprotesting/com/github/Main.java index df69607..f073c51 100644 --- a/Auto-Tune/src/unprotesting/com/github/Main.java +++ b/Auto-Tune/src/unprotesting/com/github/Main.java @@ -13,6 +13,7 @@ import java.util.Calendar; import java.util.Date; import java.util.Set; +import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.logging.Level; @@ -24,6 +25,7 @@ import org.bukkit.Bukkit; import org.bukkit.Material; +import org.bukkit.OfflinePlayer; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.configuration.ConfigurationSection; @@ -70,6 +72,7 @@ import unprotesting.com.github.util.JoinEventHandler; import unprotesting.com.github.util.LoanEventHandler; import unprotesting.com.github.util.MathHandler; +import unprotesting.com.github.util.Section; import unprotesting.com.github.util.StaticFileHandler; import unprotesting.com.github.util.TextHandler; import unprotesting.com.github.util.TutorialHandler; @@ -81,6 +84,7 @@ public final class Main extends JavaPlugin implements Listener { @Getter public static Main INSTANCE; + public static Section[] sectionedItems; private static final Logger log = Logger.getLogger("Minecraft"); public static Economy econ; public static JavaPlugin plugin; @@ -93,8 +97,8 @@ public final class Main extends JavaPlugin implements Listener { public static DB db, memDB, tempDB, loanDB; public static HTreeMap tempdatadata; public static ConcurrentMap> map; - public static ConcurrentMap> maxBuyMap = new ConcurrentHashMap>(); - public static ConcurrentMap> maxSellMap = new ConcurrentHashMap>(); + public static ConcurrentMap> maxBuyMap = new ConcurrentHashMap>(); + public static ConcurrentMap> maxSellMap = new ConcurrentHashMap>(); public static HTreeMap memMap; public static HTreeMap loanMap; public static ConcurrentHashMap> tempmap; @@ -248,6 +252,7 @@ public void onEnable() { Config.getSellPriceDifferenceVariationStart() - tempdatadata.get("SellPriceDifferenceDifference")); SellDifrunnable(); } + loadSections(); } private boolean setupEconomy() { @@ -298,9 +303,9 @@ public static void tempdataresetSPDifference() { } public static void setupMaxBuySell(){ - for (Player p : Bukkit.getOnlinePlayers()){ - maxBuyMap.put(p, loadMaxStrings(map)); - maxSellMap.put(p, loadMaxStrings(map)); + for (OfflinePlayer p : Bukkit.getOnlinePlayers()){ + maxBuyMap.put(p.getUniqueId(), loadMaxStrings(map)); + maxSellMap.put(p.getUniqueId(), loadMaxStrings(map)); } } @@ -594,6 +599,16 @@ public static void loadItemPricesAndCalculate() throws ParseException { } } + public void loadSections(){ + int sectionAmount = getShopConfig().getConfigurationSection("sections").getKeys(false).size(); + sectionedItems = new Section[sectionAmount]; + int i = 0; + for (String section : getShopConfig().getConfigurationSection("sections").getKeys(false)){ + sectionedItems[i] = new Section(section); + i++; + } + } + public void createFiles() { configf = new File(getDataFolder(), "config.yml"); @@ -779,6 +794,8 @@ public void loadShopData() { } } + + @Getter public static Set < String > tempCollection; diff --git a/Auto-Tune/src/unprotesting/com/github/util/AutoSellEventHandler.java b/Auto-Tune/src/unprotesting/com/github/util/AutoSellEventHandler.java index 628a40b..707c4fd 100644 --- a/Auto-Tune/src/unprotesting/com/github/util/AutoSellEventHandler.java +++ b/Auto-Tune/src/unprotesting/com/github/util/AutoSellEventHandler.java @@ -28,7 +28,7 @@ public void run() { ConcurrentHashMap itemstosell = new ConcurrentHashMap(); for (String material : config.getKeys(false)){ if (player.getInventory().contains(Material.matchMaterial(material)) && Main.playerDataConfig.getBoolean(uuid + ".AutoSell" + "." + material)==true){ - ConcurrentHashMap cMap = Main.maxSellMap.get(player); + ConcurrentHashMap cMap = Main.maxSellMap.get(player.getUniqueId()); Integer max = (Integer)Main.getShopConfig().get("shops." + material + "." + "max-sell"); Integer amount = getAmount(player, Material.matchMaterial(material)); if (max == null){ diff --git a/Auto-Tune/src/unprotesting/com/github/util/JoinEventHandler.java b/Auto-Tune/src/unprotesting/com/github/util/JoinEventHandler.java index fe21ec2..8359b83 100644 --- a/Auto-Tune/src/unprotesting/com/github/util/JoinEventHandler.java +++ b/Auto-Tune/src/unprotesting/com/github/util/JoinEventHandler.java @@ -1,9 +1,11 @@ package unprotesting.com.github.util; +import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Logger; +import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -17,28 +19,23 @@ public class JoinEventHandler implements Listener { @EventHandler public void onPlayerJoin(PlayerLoginEvent e) { - Player p = e.getPlayer(); - UUID uuid = p.getUniqueId(); - String name = p.getName(); - Main.playerDataConfig.set(uuid + ".name", name); - Main.saveplayerdata(); - ConcurrentHashMap test = new ConcurrentHashMap<>(); - try{ - test = Main.maxBuyMap.get(p); - } - catch(NullPointerException ex){ - ConcurrentHashMap cMap = Main.loadMaxStrings(Main.map); - ConcurrentHashMap cMap2 = Main.loadMaxStrings(Main.map); - Main.maxBuyMap.put(p, cMap); - Main.maxSellMap.put(p, cMap2); - } - if (test == null){ - ConcurrentHashMap cMap = Main.loadMaxStrings(Main.map); - ConcurrentHashMap cMap2 = Main.loadMaxStrings(Main.map); - Main.maxBuyMap.put(p, cMap); - Main.maxSellMap.put(p, cMap2); - } + Player p = e.getPlayer(); + OfflinePlayer player = (OfflinePlayer) p; + UUID uuid = p.getUniqueId(); + String name = p.getName(); + Main.playerDataConfig.set(uuid + ".name", name); + Main.saveplayerdata(); + if (!Main.maxBuyMap.containsKey(player.getUniqueId())){ + ConcurrentHashMap cMap = Main.loadMaxStrings(Main.map); + Main.maxBuyMap.put(player.getUniqueId(), cMap); + } + if (!Main.maxSellMap.containsKey(player.getUniqueId())){ + ConcurrentHashMap cMap2 = Main.loadMaxStrings(Main.map); + Main.maxSellMap.put(player.getUniqueId(), cMap2); } + } +} + \ No newline at end of file diff --git a/Auto-Tune/src/unprotesting/com/github/util/Section.java b/Auto-Tune/src/unprotesting/com/github/util/Section.java new file mode 100644 index 0000000..128d87f --- /dev/null +++ b/Auto-Tune/src/unprotesting/com/github/util/Section.java @@ -0,0 +1,32 @@ +package unprotesting.com.github.util; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Material; + +import unprotesting.com.github.Main; + +public class Section { + + public List items; + public String name; + public Material image = Material.matchMaterial("GRASS_BLOCK"); + + public Section(String name){ + this.name = name; + items = new ArrayList(); + for (String section : Main.getShopConfig().getConfigurationSection("sections").getKeys(false)){ + if (section.equals(name)){ + image = Material.matchMaterial(Main.getShopConfig().getConfigurationSection("sections." + section).getString("block")); + for (String shop : Main.getShopConfig().getConfigurationSection("shops").getKeys(false)){ + String shopSection = Main.getShopConfig().getConfigurationSection("shops." + shop).getString("section"); + if (shopSection.equals(section)){ + Main.log(shop); + items.add(shop); + } + } + } + } + } +}