Treasures are being rewritten completely

This commit is contained in:
nossr50 2019-09-20 15:56:25 -07:00
parent 396926d970
commit 2165d1448e
9 changed files with 267 additions and 267 deletions

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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;
}*/
}

View File

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

View File

@ -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;
// }
//}

View File

@ -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);
// }
//}

View File

@ -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;
// }*/
//}

View File

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