diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java index 9867fc99b..0c299bc62 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java @@ -15,6 +15,7 @@ import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.treasure.TreasureConfig; import com.gmail.nossr50.datatypes.treasure.ShakeTreasure; import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.adapter.BiomeAdapter; public final class Fishing { // The order of the values is extremely important, a few methods depend on it to work properly @@ -57,12 +58,8 @@ public final class Fishing { public static int fishermansDietRankLevel2 = fishermansDietRankLevel1 * 2; public static int fishermansDietMaxLevel = fishermansDietRankLevel1 * 5; - public static Set masterAnglerBiomes = EnumSet.of(Biome.RIVER, Biome.OCEAN, Biome.DEEP_OCEAN); - public static Set iceFishingBiomes = EnumSet.of( - Biome.FROZEN_OCEAN, Biome.FROZEN_RIVER, - Biome.TAIGA, Biome.TAIGA_HILLS, Biome.TAIGA_COLD_HILLS, - Biome.ICE_FLATS, Biome.ICE_MOUNTAINS, Biome.MUTATED_ICE_FLATS, - Biome.TAIGA_COLD, Biome.MUTATED_TAIGA_COLD); + public static Set masterAnglerBiomes = BiomeAdapter.WATER_BIOMES; + public static Set iceFishingBiomes = BiomeAdapter.ICE_BIOMES; private Fishing() {} diff --git a/src/main/java/com/gmail/nossr50/util/adapter/BiomeAdapter.java b/src/main/java/com/gmail/nossr50/util/adapter/BiomeAdapter.java new file mode 100644 index 000000000..adeeabfe2 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/util/adapter/BiomeAdapter.java @@ -0,0 +1,73 @@ +package com.gmail.nossr50.util.adapter; + +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.List; +import java.util.Set; + +import org.bukkit.block.Biome; + +import com.gmail.nossr50.mcMMO; + +public class BiomeAdapter { + public static final Set WATER_BIOMES; + public static final Set ICE_BIOMES; + + static { + List temp = new ArrayList(); + EnumSet set = null; + try { + temp.add(Biome.valueOf("RIVER")); + temp.add(Biome.valueOf("OCEAN")); + temp.add(Biome.valueOf("DEEP_OCEAN")); + } catch (Exception e) { + temp.clear(); + } finally { + try { + set = EnumSet.copyOf(temp); + } catch (IllegalArgumentException e) { + mcMMO.p.getLogger().severe("Biome enum mismatch");; + } + temp.clear(); + } + WATER_BIOMES = set; + set = null; + try { + temp.add(Biome.valueOf("FROZEN_OCEAN")); + temp.add(Biome.valueOf("FROZEN_RIVER")); + temp.add(Biome.valueOf("TAIGA")); + temp.add(Biome.valueOf("TAIGA_HILLS")); + temp.add(Biome.valueOf("TAIGA_COLD_HILLS")); + temp.add(Biome.valueOf("TAIGA_COLD")); + temp.add(Biome.valueOf("MUTATED_TAIGA_COLD")); + temp.add(Biome.valueOf("ICE_MOUNTAINS")); + temp.add(Biome.valueOf("ICE_FLATS")); + temp.add(Biome.valueOf("MUTATED_ICE_FLATS")); + } catch (Exception e) { + temp.clear(); + try { + temp.add(Biome.valueOf("FROZEN_OCEAN")); + temp.add(Biome.valueOf("FROZEN_RIVER")); + temp.add(Biome.valueOf("TAIGA")); + temp.add(Biome.valueOf("TAIGA_HILLS")); + temp.add(Biome.valueOf("TAIGA_MOUNTAINS")); + temp.add(Biome.valueOf("COLD_TAIGA")); + temp.add(Biome.valueOf("COLD_TAIGA_HILLS")); + temp.add(Biome.valueOf("COLD_TAIGA_MOUNTAINS")); + temp.add(Biome.valueOf("ICE_MOUNTAINS")); + temp.add(Biome.valueOf("ICE_PLAINS")); + temp.add(Biome.valueOf("ICE_PLAINS_SPIKES")); + } catch (Exception e1) { + temp.clear(); + } + } finally { + try { + set = EnumSet.copyOf(temp); + } catch (IllegalArgumentException e) { + mcMMO.p.getLogger().severe("Biome enum mismatch");; + } + temp.clear(); + } + ICE_BIOMES = set; + } +}