Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void loadConfig() {
- shopNames = new ArrayList<>();
- buyItems = new ArrayList<>();
- sellItems = new ArrayList<>();
- infoItem = new ArrayList<>();
- currency = new HashMap<>();
- itemInfo = new HashMap<>();
- buyactualItems = new HashMap<>();
- sellactualItems = new HashMap<>();
- config = getPlugin(ShopMain.class).getConfig();
- ConfigurationSection configSection = config.getConfigurationSection("Shops");
- if (configSection != null){
- for (String path: configSection.getKeys(false)){
- String shop = configSection.getString(path + ".Name");
- String currency = configSection.getString(path + ".Currency");
- boolean fluctuation = configSection.getBoolean(path + ".Fluctuation");
- shopNames.add(shop);
- ShopMain.currency.put(shop, currency);
- console.sendMessage(ChatColor.GREEN + "[AtlasSimpleShops] Shop:" + shop);
- console.sendMessage(ChatColor.GREEN + "[AtlasSimpleShops] Currency:" + currency);
- fluctuationEnabled.put(shop, fluctuation);
- console.sendMessage(ChatColor.GREEN + "[AtlasSimpleShops] S/D:" + fluctuation);
- ConfigurationSection configurationSection = config.getConfigurationSection("Shops." + path);
- if (configurationSection != null){
- buyItems = new ArrayList<>();
- sellItems = new ArrayList<>();
- for (String tehPath: configurationSection.getKeys(false)){
- infoItem = new ArrayList<>();
- if (!(tehPath.equals("Name") || tehPath.equals("Currency") || tehPath.equals("Fluctuation"))){
- String material = configurationSection.getString(tehPath + ".Material");
- int damageValue = configurationSection.getInt(tehPath + ".DamageValue");
- String name = configurationSection.getString(tehPath + ".ItemName").substring(1);
- String lore = configurationSection.getString(tehPath + ".ItemLore").substring(1);
- int sellPrice = configurationSection.getInt(tehPath + ".SellPrice");
- int sellNumba = configurationSection.getInt(tehPath + ".SellNumba");
- int buyPrice = configurationSection.getInt(tehPath + ".BuyPrice");
- int buyNumba = configurationSection.getInt(tehPath + ".BuyNumba");
- int amount = configurationSection.getInt(tehPath + ".Amount");
- if (amount < 100){
- amount+=5;
- }
- if (amount > 100){
- amount-=5;
- }
- ArrayList<String> itemLore = new ArrayList<>();
- console.sendMessage(ChatColor.GREEN + "[AtlasSimpleShops] Item: " + tehPath);
- console.sendMessage(ChatColor.GREEN + "[AtlasSimpleShops] Material: " + material);
- console.sendMessage(ChatColor.GREEN + "[AtlasSimpleShops] Variant: " + damageValue);
- console.sendMessage(ChatColor.GREEN + "[AtlasSimpleShops] Name: " + name);
- console.sendMessage(ChatColor.GREEN + "[AtlasSimpleShops] Lore: " + lore);
- console.sendMessage(ChatColor.GREEN + "[AtlasSimpleShops] Sell Price: " + sellPrice);
- console.sendMessage(ChatColor.GREEN + "[AtlasSimpleShops] Number to Sell: " + sellNumba);
- console.sendMessage(ChatColor.GREEN + "[AtlasSimpleShops] Buy Price: " + buyPrice);
- console.sendMessage(ChatColor.GREEN + "[AtlasSimpleShops] Number to Buy: " + buyNumba);
- console.sendMessage(ChatColor.GREEN + "[AtlasSimpleShops] Amount: " + amount);
- if (!lore.equals("--")){
- if (lore.substring(0,1).equals("&")){
- String temp = lore.substring(0,2);
- lore = lore.substring(2);
- while (lore.indexOf("/") != -1){
- itemLore.add(ChatColor.translateAlternateColorCodes('&', temp + lore.substring(0, lore.indexOf("/"))));
- lore = lore.substring(lore.indexOf("/") + 1);
- }
- itemLore.add(ChatColor.translateAlternateColorCodes('&', temp + lore));
- }
- else {
- while (lore.indexOf("/") != -1){
- itemLore.add(ChatColor.translateAlternateColorCodes('&', lore.substring(0, lore.indexOf("/"))));
- lore = lore.substring(lore.indexOf("/") + 1);
- }
- itemLore.add(ChatColor.translateAlternateColorCodes('&', lore));
- }
- }
- ItemStack actualItem = new ItemStack(Material.getMaterial(material));
- ItemMeta actualItemMeta = actualItem.getItemMeta();
- if (!name.equals("--")){
- actualItemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
- }
- actualItemMeta.setLore(itemLore);
- actualItem.setItemMeta(actualItemMeta);
- itemLore.add(ChatColor.translateAlternateColorCodes('&', "&4In Stock:&f " + amount));
- itemLore.add(ChatColor.translateAlternateColorCodes('&', "&f>>&eBuy Price:&f " + buyPrice));
- ItemStack buyItem = new ItemStack(Material.getMaterial(material), buyNumba, (byte) damageValue);
- ItemMeta buyItemMeta = buyItem.getItemMeta();
- if (!name.equals("--")){
- buyItemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
- }
- buyItemMeta.setLore(itemLore);
- buyItem.setItemMeta(buyItemMeta);
- buyItems.add(buyItem);
- itemLore.remove(itemLore.size() - 1);
- itemLore.add(ChatColor.translateAlternateColorCodes('&',"&f>>&aSell Price:&f " + sellPrice));
- ItemStack sellItem = new ItemStack(Material.getMaterial(material), sellNumba, (byte) damageValue);
- ItemMeta sellItemMeta = sellItem.getItemMeta();
- if (!name.equals("--")){
- sellItemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
- }
- sellItemMeta.setLore(itemLore);
- sellItem.setItemMeta(sellItemMeta);
- sellItems.add(sellItem);
- //
- infoItem.add(sellPrice);
- infoItem.add(sellNumba);
- infoItem.add(buyPrice);
- infoItem.add(buyNumba);
- infoItem.add(damageValue);
- infoItem.add(amount);
- //
- itemInfo.put(actualItem, infoItem);
- buyactualItems.put(buyItem, actualItem);
- sellactualItems.put(sellItem, actualItem);
- }
- }
- }
- buyshops.put(shop, buyItems);
- sellshops.put(shop,sellItems);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement