Преглед изворни кода

Treasures are being rewritten completely

nossr50 пре 5 година
родитељ
комит
2165d1448e

+ 0 - 53
src/main/java/com/gmail/nossr50/config/treasure/ExcavationTreasureConfig.java

@@ -1,53 +0,0 @@
-package com.gmail.nossr50.config.treasure;
-
-import com.gmail.nossr50.config.Config;
-import com.gmail.nossr50.config.ConfigConstants;
-import com.gmail.nossr50.config.UnsafeValueValidation;
-import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
-import com.gmail.nossr50.mcMMO;
-
-import java.util.HashMap;
-import java.util.List;
-
-public class ExcavationTreasureConfig extends Config implements UnsafeValueValidation {
-    public static final String EXCAVATION = "Archaeology";
-    public static final String AMOUNT = "Amount";
-    public static final String XP = "XP";
-    public static final String DROP_CHANCE = "Drop_Chance";
-    public static final String DROP_LEVEL = "Drop_Level";
-    public static final String CUSTOM_NAME = "Custom_Name";
-    public static final String LORE = "Lore";
-    public HashMap<String, List<ExcavationTreasure>> excavationMap = new HashMap<>();
-
-    public ExcavationTreasureConfig() {
-        super("excavation_drops", pluginRef.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, false, true, false);
-    }
-
-    /**
-     * This grabs an instance of this config class from the Config Manager
-     * This method is deprecated and will be removed in the future
-     *
-     * @return the instance of this config
-     * @see mcMMO#getConfigManager()
-     * @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead
-     */
-    @Deprecated
-    public static ExcavationTreasureConfig getInstance() {
-        return pluginRef.getConfigManager().getExcavationTreasureConfig();
-    }
-
-    @Override
-    public List<String> validateKeys() {
-        return null;
-    }
-
-    /**
-     * The version of this config
-     *
-     * @return
-     */
-    @Override
-    public double getConfigVersion() {
-        return 1;
-    }
-}

+ 0 - 62
src/main/java/com/gmail/nossr50/config/treasure/HerbalismTreasureConfig.java

@@ -1,62 +0,0 @@
-package com.gmail.nossr50.config.treasure;
-
-import com.gmail.nossr50.config.Config;
-import com.gmail.nossr50.config.ConfigConstants;
-import com.gmail.nossr50.config.UnsafeValueValidation;
-import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
-import com.gmail.nossr50.mcMMO;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-public class HerbalismTreasureConfig extends Config implements UnsafeValueValidation {
-    public static final String HYLIAN_LUCK = "Hylian_Luck";
-    public static final String AMOUNT = "Amount";
-    public static final String XP = "XP";
-    public static final String DROP_CHANCE = "Drop_Chance";
-    public static final String DROP_LEVEL = "Drop_Level";
-    public static final String CUSTOM_NAME = "Custom_Name";
-    public static final String LORE = "Lore";
-
-    public HashMap<String, List<HylianTreasure>> hylianMap = new HashMap<>();
-
-    public HerbalismTreasureConfig() {
-        super("hylian_luck_drops", pluginRef.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, false, true, false);
-    }
-
-    /**
-     * This grabs an instance of this config class from the Config Manager
-     * This method is deprecated and will be removed in the future
-     *
-     * @return the instance of this config
-     * @see mcMMO#getConfigManager()
-     * @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead
-     */
-    @Deprecated
-    public static HerbalismTreasureConfig getInstance() {
-        return pluginRef.getConfigManager().getHerbalismTreasureConfig();
-    }
-
-    @Override
-    public List<String> validateKeys() {
-        return null;
-    }
-
-    /**
-     * The version of this config
-     *
-     * @return
-     */
-    @Override
-    public double getConfigVersion() {
-        return 1;
-    }
-
-    private void addHylianTreasure(String dropper, HylianTreasure treasure) {
-        if (!hylianMap.containsKey(dropper))
-            hylianMap.put(dropper, new ArrayList<>());
-
-        hylianMap.get(dropper).add(treasure);
-    }
-}

+ 0 - 144
src/main/java/com/gmail/nossr50/config/treasure/TreasureFactory.java

@@ -1,144 +0,0 @@
-package com.gmail.nossr50.config.treasure;
-
-import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
-import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
-import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
-import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
-import com.google.common.reflect.TypeToken;
-import ninja.leaping.configurate.ConfigurationNode;
-import ninja.leaping.configurate.objectmapping.ObjectMappingException;
-import org.bukkit.ChatColor;
-import org.bukkit.Material;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.meta.ItemMeta;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Handles creating treasures for various skill loot tables
- */
-public class TreasureFactory {
-
-    public static final String CHANGE_ME = "ChangeMe";
-
-    /**
-     * Make a new ExcavationTreasure
-     *
-     * @param material
-     * @param dropAmount
-     * @param xpReward
-     * @param dropChance
-     * @param dropLevel
-     * @param customName
-     * @param customLore
-     * @return
-     */
-    public static ExcavationTreasure makeExcavationTreasure(Material material, int dropAmount, int xpReward, double dropChance, int dropLevel, String customName, ConfigurationNode customLore) {
-        ItemStack treasure = makeItemStack(material, dropAmount, customName, customLore);
-
-        return new ExcavationTreasure(treasure, xpReward, dropChance, dropLevel);
-    }
-
-    public static ShakeTreasure makeShakeTreasure(Material material, int dropAmount, int xpReward, double dropChance, int dropLevel, String customName, ConfigurationNode customLore) {
-        ItemStack treasure = makeItemStack(material, dropAmount, customName, customLore);
-
-        return new ShakeTreasure(treasure, xpReward, dropChance, dropLevel);
-    }
-
-    public static FishingTreasure makeFishingTreasure(Material material, int dropAmount, int xpReward, String customName, ConfigurationNode customLore) {
-        ItemStack treasure = makeItemStack(material, dropAmount, customName, customLore);
-
-        return new FishingTreasure(treasure, xpReward);
-    }
-
-    public static HylianTreasure makeHylianTreasure(Material material, int dropAmount, int xpReward, double dropChance, int dropLevel, String customName, ConfigurationNode customLore) {
-        ItemStack treasure = makeItemStack(material, dropAmount, customName, customLore);
-
-        return new HylianTreasure(treasure, xpReward, dropChance, dropLevel);
-    }
-
-    private static ItemStack makeItemStack(Material material, int dropAmount, String customName, ConfigurationNode customLore) {
-        ItemStack treasure = new ItemStack(material, dropAmount);
-
-        /* IF FOR SOME REASON ITS A POTION */
-
-        /*if(isPotion(material))
-            treasure = makePotionItemStack(material, dropAmount, customName, customLore);*/
-
-        /* ADD CUSTOM NAME */
-        if (customName != null) {
-            ItemMeta itemMeta = treasure.getItemMeta();
-            itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', customName));
-            treasure.setItemMeta(itemMeta);
-        }
-
-        /* ADD CUSTOM LORE */
-        if (customLore != null && !customLore.getString().equalsIgnoreCase(CHANGE_ME)) {
-            ItemMeta itemMeta = treasure.getItemMeta();
-            List<String> lore = new ArrayList<>();
-
-            try {
-                //TODO: Not sure how this will be handled by Configurate
-                for (String loreLine : customLore.getList(TypeToken.of(String.class))) {
-                    lore.add(ChatColor.translateAlternateColorCodes('&', loreLine));
-                }
-
-                itemMeta.setLore(lore);
-                treasure.setItemMeta(itemMeta);
-            } catch (ObjectMappingException e) {
-                e.printStackTrace();
-            }
-        }
-
-
-        //TODO: Do this later
-
-        return treasure;
-    }
-
-    private static boolean isPotion(Material material) {
-        switch (material) {
-            case POTION:
-            case SPLASH_POTION:
-            case LINGERING_POTION:
-                return true;
-            default:
-                return false;
-        }
-    }
-
-    /*private static ItemStack makePotionItemStack(ItemStack itemStack, Material material, int dropAmount, String customName, ConfigurationNode customLore)
-    {
-        //TODO: Rewrite this...
-        Material mat = Material.matchMaterial(materialName);
-
-        itemStack = new ItemStack(mat, amount, data);
-        PotionMeta itemMeta = (PotionMeta) itemStack.getItemMeta();
-
-        PotionType potionType = null;
-        try {
-            potionType = PotionType.valueOf(config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
-        } catch (IllegalArgumentException ex) {
-            reason.add("Invalid Potion_Type: " + config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
-        }
-        boolean extended = config.getBoolean(type + "." + treasureName + ".PotionData.Extended", false);
-        boolean upgraded = config.getBoolean(type + "." + treasureName + ".PotionData.Upgraded", false);
-        itemMeta.setBasePotionData(new PotionData(potionType, extended, upgraded));
-
-        if (config.contains(type + "." + treasureName + ".Custom_Name")) {
-            itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(type + "." + treasureName + ".Custom_Name")));
-        }
-
-        if (config.contains(type + "." + treasureName + ".Lore")) {
-            List<String> lore = new ArrayList<String>();
-            for (String s : config.getStringList(type + "." + treasureName + ".Lore")) {
-                lore.add(ChatColor.translateAlternateColorCodes('&', s));
-            }
-            itemMeta.setLore(lore);
-        }
-        itemStack.setItemMeta(itemMeta);
-
-        return itemStack;
-    }*/
-}

+ 0 - 8
src/main/java/com/gmail/nossr50/config/treasure/TreasureType.java

@@ -1,8 +0,0 @@
-package com.gmail.nossr50.config.treasure;
-
-public enum TreasureType {
-    FISHING,
-    EXCAVATION,
-    HYLIAN,
-    SHAKE
-}

+ 53 - 0
src/main/java/com/gmail/nossr50/dumpster/ExcavationTreasureConfig.java

@@ -0,0 +1,53 @@
+//package com.gmail.nossr50.config.treasure;
+//
+//import com.gmail.nossr50.config.Config;
+//import com.gmail.nossr50.config.ConfigConstants;
+//import com.gmail.nossr50.config.UnsafeValueValidation;
+//import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
+//import com.gmail.nossr50.mcMMO;
+//
+//import java.util.HashMap;
+//import java.util.List;
+//
+//public class ExcavationTreasureConfig extends Config implements UnsafeValueValidation {
+//    public static final String EXCAVATION = "Archaeology";
+//    public static final String AMOUNT = "Amount";
+//    public static final String XP = "XP";
+//    public static final String DROP_CHANCE = "Drop_Chance";
+//    public static final String DROP_LEVEL = "Drop_Level";
+//    public static final String CUSTOM_NAME = "Custom_Name";
+//    public static final String LORE = "Lore";
+//    public HashMap<String, List<ExcavationTreasure>> excavationMap = new HashMap<>();
+//
+//    public ExcavationTreasureConfig() {
+//        super("excavation_drops", pluginRef.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, false, true, false);
+//    }
+//
+//    /**
+//     * This grabs an instance of this config class from the Config Manager
+//     * This method is deprecated and will be removed in the future
+//     *
+//     * @return the instance of this config
+//     * @see mcMMO#getConfigManager()
+//     * @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead
+//     */
+//    @Deprecated
+//    public static ExcavationTreasureConfig getInstance() {
+//        return pluginRef.getConfigManager().getExcavationTreasureConfig();
+//    }
+//
+//    @Override
+//    public List<String> validateKeys() {
+//        return null;
+//    }
+//
+//    /**
+//     * The version of this config
+//     *
+//     * @return
+//     */
+//    @Override
+//    public double getConfigVersion() {
+//        return 1;
+//    }
+//}

+ 0 - 0
src/main/java/com/gmail/nossr50/config/treasure/FishingTreasureConfig.java → src/main/java/com/gmail/nossr50/dumpster/FishingTreasureConfig.java


+ 62 - 0
src/main/java/com/gmail/nossr50/dumpster/HerbalismTreasureConfig.java

@@ -0,0 +1,62 @@
+//package com.gmail.nossr50.config.treasure;
+//
+//import com.gmail.nossr50.config.Config;
+//import com.gmail.nossr50.config.ConfigConstants;
+//import com.gmail.nossr50.config.UnsafeValueValidation;
+//import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
+//import com.gmail.nossr50.mcMMO;
+//
+//import java.util.ArrayList;
+//import java.util.HashMap;
+//import java.util.List;
+//
+//public class HerbalismTreasureConfig extends Config implements UnsafeValueValidation {
+//    public static final String HYLIAN_LUCK = "Hylian_Luck";
+//    public static final String AMOUNT = "Amount";
+//    public static final String XP = "XP";
+//    public static final String DROP_CHANCE = "Drop_Chance";
+//    public static final String DROP_LEVEL = "Drop_Level";
+//    public static final String CUSTOM_NAME = "Custom_Name";
+//    public static final String LORE = "Lore";
+//
+//    public HashMap<String, List<HylianTreasure>> hylianMap = new HashMap<>();
+//
+//    public HerbalismTreasureConfig() {
+//        super("hylian_luck_drops", pluginRef.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, false, true, false);
+//    }
+//
+//    /**
+//     * This grabs an instance of this config class from the Config Manager
+//     * This method is deprecated and will be removed in the future
+//     *
+//     * @return the instance of this config
+//     * @see mcMMO#getConfigManager()
+//     * @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead
+//     */
+//    @Deprecated
+//    public static HerbalismTreasureConfig getInstance() {
+//        return pluginRef.getConfigManager().getHerbalismTreasureConfig();
+//    }
+//
+//    @Override
+//    public List<String> validateKeys() {
+//        return null;
+//    }
+//
+//    /**
+//     * The version of this config
+//     *
+//     * @return
+//     */
+//    @Override
+//    public double getConfigVersion() {
+//        return 1;
+//    }
+//
+//    private void addHylianTreasure(String dropper, HylianTreasure treasure) {
+//        if (!hylianMap.containsKey(dropper))
+//            hylianMap.put(dropper, new ArrayList<>());
+//
+//        hylianMap.get(dropper).add(treasure);
+//    }
+//}

+ 144 - 0
src/main/java/com/gmail/nossr50/dumpster/TreasureFactory.java

@@ -0,0 +1,144 @@
+//package com.gmail.nossr50.config.treasure;
+//
+//import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
+//import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
+//import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
+//import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
+//import com.google.common.reflect.TypeToken;
+//import ninja.leaping.configurate.ConfigurationNode;
+//import ninja.leaping.configurate.objectmapping.ObjectMappingException;
+//import org.bukkit.ChatColor;
+//import org.bukkit.Material;
+//import org.bukkit.inventory.ItemStack;
+//import org.bukkit.inventory.meta.ItemMeta;
+//
+//import java.util.ArrayList;
+//import java.util.List;
+//
+///**
+// * Handles creating treasures for various skill loot tables
+// */
+//public class TreasureFactory {
+//
+//    public static final String CHANGE_ME = "ChangeMe";
+//
+//    /**
+//     * Make a new ExcavationTreasure
+//     *
+//     * @param material
+//     * @param dropAmount
+//     * @param xpReward
+//     * @param dropChance
+//     * @param dropLevel
+//     * @param customName
+//     * @param customLore
+//     * @return
+//     */
+//    public static ExcavationTreasure makeExcavationTreasure(Material material, int dropAmount, int xpReward, double dropChance, int dropLevel, String customName, ConfigurationNode customLore) {
+//        ItemStack treasure = makeItemStack(material, dropAmount, customName, customLore);
+//
+//        return new ExcavationTreasure(treasure, xpReward, dropChance, dropLevel);
+//    }
+//
+//    public static ShakeTreasure makeShakeTreasure(Material material, int dropAmount, int xpReward, double dropChance, int dropLevel, String customName, ConfigurationNode customLore) {
+//        ItemStack treasure = makeItemStack(material, dropAmount, customName, customLore);
+//
+//        return new ShakeTreasure(treasure, xpReward, dropChance, dropLevel);
+//    }
+//
+//    public static FishingTreasure makeFishingTreasure(Material material, int dropAmount, int xpReward, String customName, ConfigurationNode customLore) {
+//        ItemStack treasure = makeItemStack(material, dropAmount, customName, customLore);
+//
+//        return new FishingTreasure(treasure, xpReward);
+//    }
+//
+//    public static HylianTreasure makeHylianTreasure(Material material, int dropAmount, int xpReward, double dropChance, int dropLevel, String customName, ConfigurationNode customLore) {
+//        ItemStack treasure = makeItemStack(material, dropAmount, customName, customLore);
+//
+//        return new HylianTreasure(treasure, xpReward, dropChance, dropLevel);
+//    }
+//
+//    private static ItemStack makeItemStack(Material material, int dropAmount, String customName, ConfigurationNode customLore) {
+//        ItemStack treasure = new ItemStack(material, dropAmount);
+//
+//        /* IF FOR SOME REASON ITS A POTION */
+//
+//        /*if(isPotion(material))
+//            treasure = makePotionItemStack(material, dropAmount, customName, customLore);*/
+//
+//        /* ADD CUSTOM NAME */
+//        if (customName != null) {
+//            ItemMeta itemMeta = treasure.getItemMeta();
+//            itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', customName));
+//            treasure.setItemMeta(itemMeta);
+//        }
+//
+//        /* ADD CUSTOM LORE */
+//        if (customLore != null && !customLore.getString().equalsIgnoreCase(CHANGE_ME)) {
+//            ItemMeta itemMeta = treasure.getItemMeta();
+//            List<String> lore = new ArrayList<>();
+//
+//            try {
+//                //TODO: Not sure how this will be handled by Configurate
+//                for (String loreLine : customLore.getList(TypeToken.of(String.class))) {
+//                    lore.add(ChatColor.translateAlternateColorCodes('&', loreLine));
+//                }
+//
+//                itemMeta.setLore(lore);
+//                treasure.setItemMeta(itemMeta);
+//            } catch (ObjectMappingException e) {
+//                e.printStackTrace();
+//            }
+//        }
+//
+//
+//        //TODO: Do this later
+//
+//        return treasure;
+//    }
+//
+//    private static boolean isPotion(Material material) {
+//        switch (material) {
+//            case POTION:
+//            case SPLASH_POTION:
+//            case LINGERING_POTION:
+//                return true;
+//            default:
+//                return false;
+//        }
+//    }
+//
+//    /*private static ItemStack makePotionItemStack(ItemStack itemStack, Material material, int dropAmount, String customName, ConfigurationNode customLore)
+//    {
+//        //TODO: Rewrite this...
+//        Material mat = Material.matchMaterial(materialName);
+//
+//        itemStack = new ItemStack(mat, amount, data);
+//        PotionMeta itemMeta = (PotionMeta) itemStack.getItemMeta();
+//
+//        PotionType potionType = null;
+//        try {
+//            potionType = PotionType.valueOf(config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
+//        } catch (IllegalArgumentException ex) {
+//            reason.add("Invalid Potion_Type: " + config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
+//        }
+//        boolean extended = config.getBoolean(type + "." + treasureName + ".PotionData.Extended", false);
+//        boolean upgraded = config.getBoolean(type + "." + treasureName + ".PotionData.Upgraded", false);
+//        itemMeta.setBasePotionData(new PotionData(potionType, extended, upgraded));
+//
+//        if (config.contains(type + "." + treasureName + ".Custom_Name")) {
+//            itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(type + "." + treasureName + ".Custom_Name")));
+//        }
+//
+//        if (config.contains(type + "." + treasureName + ".Lore")) {
+//            List<String> lore = new ArrayList<String>();
+//            for (String s : config.getStringList(type + "." + treasureName + ".Lore")) {
+//                lore.add(ChatColor.translateAlternateColorCodes('&', s));
+//            }
+//            itemMeta.setLore(lore);
+//        }
+//        itemStack.setItemMeta(itemMeta);
+//
+//        return itemStack;
+//    }*/
+//}

+ 8 - 0
src/main/java/com/gmail/nossr50/dumpster/TreasureType.java

@@ -0,0 +1,8 @@
+//package com.gmail.nossr50.config.treasure;
+//
+//public enum TreasureType {
+//    FISHING,
+//    EXCAVATION,
+//    HYLIAN,
+//    SHAKE
+//}