mcMMO-Dev / mcMMO

The RPG Lover's Mod!
https://mcmmo.org
GNU General Public License v3.0
1k stars 863 forks source link

Fishing treasures yml does not allow to give multiple amount for same item and different rarity #4812

Open LeChatP opened 2 years ago

LeChatP commented 2 years ago

By example i would like to set COD at 8 amount as common treasure, 16 for uncommon etc. But actual yaml does not allow same material for different amount. To solve this issue, it would be cool to be using yaml list instead of current dictionnary.

LeChatP commented 2 years ago
        List<Map<?,?>> treasures = cs.getMapList("Fishing")
        for (Map<?,?> entry : treasures) {
            for (Map.Entry<?,?> o : entry.entrySet()){
                Material mat = Material.getMaterial((String) o.getKey());
                Map<?,?> map = (Map<?, ?>) o.getValue();
                int amount = (int) map.get("Amount");
                int xp = (int) map.get("XP");
                Rarity rarity = Rarity.getRarity((String) map.get("Rarity"));
                ItemStack itemStack = new ItemStack(mat,amount);
                FishingTreasure ft = new FishingTreasure(itemStack,xp);
                this.instance.fishingRewards.get(rarity).add(ft);
            }
        }

Here is the way to parse a list to solve this issue

Fishing:
  - PUFFERFISH:
      Amount: 8
      XP: 200
      Rarity: COMMON
  - TROPICAL_FISH:
      Amount: 8
      XP: 200
      Rarity: COMMON
  - SALMON:
      Amount: 8
      XP: 200
      Rarity: COMMON
  - COD:
      Amount: 8
      XP: 200
      Rarity: COMMON
  - PUFFERFISH:
      Amount: 16
      XP: 200
      Rarity: UNCOMMON
  - TROPICAL_FISH:
      Amount: 16
      XP: 200
      Rarity: UNCOMMON
  - SALMON:
      Amount: 16
      XP: 200
      Rarity: UNCOMMON
  - COD:
      Amount: 16
      XP: 200
      Rarity: UNCOMMON
  - PUFFERFISH:
      Amount: 32
      XP: 200
      Rarity: RARE
  - TROPICAL_FISH:
      Amount: 32
      XP: 200
      Rarity: RARE
  - SALMON:
      Amount: 32
      XP: 200
      Rarity: RARE
  - COD:
      Amount: 32
      XP: 200
      Rarity: RARE
  - PUFFERFISH:
      Amount: 64
      XP: 200
      Rarity: EPIC
  - TROPICAL_FISH:
      Amount: 64
      XP: 200
      Rarity: EPIC
  - SALMON:
      Amount: 64
      XP: 200
      Rarity: EPIC
  - COD:
      Amount: 64
      XP: 200
      Rarity: EPIC
  - PUFFERFISH:
      Amount: 128
      XP: 200
      Rarity: LEGENDARY
  - TROPICAL_FISH:
      Amount: 128
      XP: 200
      Rarity: LEGENDARY
  - SALMON:
      Amount: 128
      XP: 200
      Rarity: LEGENDARY
  - COD:
      Amount: 128
      XP: 200
      Rarity: LEGENDARY
  - PUFFERFISH:
      Amount: 256
      XP: 200
      Rarity: MYTHIC
  - TROPICAL_FISH:
      Amount: 256
      XP: 200
      Rarity: MYTHIC
  - SALMON:
      Amount: 256
      XP: 200
      Rarity: MYTHIC
  - COD:
      Amount: 256
      XP: 200
      Rarity: MYTHIC