Advertisement
Guest User

Untitled

a guest
Mar 17th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. package kayarsell.managers;
  2.  
  3. import java.util.HashMap;
  4. import java.util.List;
  5. import java.util.Map;
  6.  
  7. import org.bukkit.configuration.ConfigurationSection;
  8. import org.bukkit.configuration.file.YamlConfiguration;
  9.  
  10. import kayarsell.KayarSell;
  11. import kayarsell.workspace.SellMoney;
  12.  
  13. public class ItemManager {
  14.  
  15. private Map<String, SellMoney> items;
  16.  
  17. public ItemManager() {
  18. items = new HashMap<>();
  19. YamlConfiguration config = KayarSell.configManager.getConfig("config").getYaml();
  20. ConfigurationSection section = config.getConfigurationSection("items");
  21. if (section != null) {
  22. for (String string : section.getKeys(false)) {
  23. String path = "items." + string + ".";
  24. String id = config.getString(path.concat("id"));
  25. if (!id.contains(":")) {
  26. id += ":0";
  27. }
  28. double defaultValue = config.getDouble(path.concat("default"));
  29. ConfigurationSection permissions = config.getConfigurationSection(path.concat("permission"));
  30. boolean checkName = config.getBoolean(path.concat("checkName"));
  31. boolean checkLore = config.getBoolean(path.concat("checkLore"));
  32. List<String> lore_item = config.getStringList(path.concat("lore_item"));
  33. String name = config.getString(path.concat("nome_item"));
  34. int quantia = config.getInt(path.concat("quantidade"));
  35. SellMoney sellMoney = new SellMoney(defaultValue, checkName, checkLore, lore_item, name, quantia);
  36. if (permissions != null) {
  37. for (String key : permissions.getKeys(false)) {
  38. sellMoney.getMoneys().put("vender." + key,
  39. config.getDouble(path.concat("permission." + key)));
  40. }
  41. }
  42. this.items.put(id, sellMoney);
  43. }
  44. }
  45.  
  46. }
  47.  
  48. public Map<String, SellMoney> getItems() {
  49. return items;
  50. }
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement