mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-10-18 12:03:45 +02:00
Treasure Config Split pt 2, Configs now register to be backed up with the config manager
This commit is contained in:
@@ -1,4 +1,66 @@
|
||||
package com.gmail.nossr50.config.treasure;
|
||||
|
||||
public class ExcavationTreasureConfig {
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.Registers;
|
||||
import com.gmail.nossr50.config.UnsafeValueValidation;
|
||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class ExcavationTreasureConfig extends Config implements UnsafeValueValidation, Registers {
|
||||
public static final String EXCAVATION = "Archaeology";
|
||||
public HashMap<String, List<ExcavationTreasure>> excavationMap = new HashMap<String, List<ExcavationTreasure>>();
|
||||
|
||||
public ExcavationTreasureConfig() {
|
||||
super(mcMMO.p.getDataFolder().getAbsoluteFile(), "excavation_treasures.yml", false, true, false);
|
||||
register();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register stuff
|
||||
*/
|
||||
@Override
|
||||
public void register() {
|
||||
ConfigurationNode excavationTreasureNode = getUserRootNode().getNode(EXCAVATION);
|
||||
|
||||
if(excavationTreasureNode == null)
|
||||
{
|
||||
mcMMO.p.getLogger().info("Excavation treasures in treasures config not defined");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
for (String treasureName : excavationTreasureNode.getList(TypeToken.of(String.class))) {
|
||||
|
||||
}
|
||||
} catch (ObjectMappingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unload() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> validateKeys() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The version of this config
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public double getConfigVersion() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,115 @@
|
||||
package com.gmail.nossr50.config.treasure;
|
||||
|
||||
public class FishingTreasureConfig {
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.Registers;
|
||||
import com.gmail.nossr50.config.UnsafeValueValidation;
|
||||
import com.gmail.nossr50.datatypes.treasure.EnchantmentTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.Rarity;
|
||||
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class FishingTreasureConfig extends Config implements UnsafeValueValidation, Registers {
|
||||
public HashMap<EntityType, List<ShakeTreasure>> shakeMap = new HashMap<EntityType, List<ShakeTreasure>>();
|
||||
public HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<Rarity, List<FishingTreasure>>();
|
||||
public HashMap<Rarity, List<EnchantmentTreasure>> fishingEnchantments = new HashMap<Rarity, List<EnchantmentTreasure>>();
|
||||
|
||||
public static final String ITEM_DROP_RATES = "Item_Drop_Rates";
|
||||
public static final String FISHING = "Fishing";
|
||||
public static final String ENCHANTMENT_DROP_RATES = "Enchantment_Drop_Rates";
|
||||
public static final String SHAKE = "Shake";
|
||||
|
||||
public FishingTreasureConfig() {
|
||||
super(mcMMO.p.getDataFolder().getAbsoluteFile(), "fishing_treasures.yml", false, true, false);
|
||||
register();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register stuff
|
||||
*/
|
||||
@Override
|
||||
public void register() {
|
||||
|
||||
|
||||
/* FISHING TREASURES */
|
||||
|
||||
ConfigurationNode fishingTreasureNode = getUserRootNode().getNode(FISHING);
|
||||
|
||||
if(fishingTreasureNode == null)
|
||||
{
|
||||
mcMMO.p.getLogger().info("Fishing treasures in treasures config not defined");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Initialize fishing HashMap
|
||||
for (Rarity rarity : Rarity.values()) {
|
||||
if (!fishingRewards.containsKey(rarity)) {
|
||||
fishingRewards.put(rarity, (new ArrayList<FishingTreasure>()));
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
for (String treasureName : fishingTreasureNode.getList(TypeToken.of(String.class))) {
|
||||
|
||||
}
|
||||
} catch (ObjectMappingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//Shake
|
||||
for (EntityType entity : EntityType.values()) {
|
||||
if (entity.isAlive()) {
|
||||
loadShake(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadShake(EntityType entityType)
|
||||
{
|
||||
ConfigurationNode shakeTreasureNode = getUserRootNode().getNode(SHAKE, entityType.toString());
|
||||
|
||||
if(shakeTreasureNode != null)
|
||||
return;
|
||||
|
||||
try {
|
||||
for (String treasureName : shakeTreasureNode.getList(TypeToken.of(String.class))) {
|
||||
|
||||
}
|
||||
} catch (ObjectMappingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unload() {
|
||||
shakeMap.clear();
|
||||
fishingRewards.clear();
|
||||
fishingEnchantments.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> validateKeys() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The version of this config
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public double getConfigVersion() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,66 @@
|
||||
package com.gmail.nossr50.config.treasure;
|
||||
|
||||
public class HerbalismTreasureConfig {
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.Registers;
|
||||
import com.gmail.nossr50.config.UnsafeValueValidation;
|
||||
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class HerbalismTreasureConfig extends Config implements UnsafeValueValidation, Registers {
|
||||
public static final String HYLIAN_LUCK = "Hylian_Luck";
|
||||
public HashMap<String, List<HylianTreasure>> hylianMap = new HashMap<String, List<HylianTreasure>>();
|
||||
|
||||
public HerbalismTreasureConfig() {
|
||||
super(mcMMO.p.getDataFolder().getAbsoluteFile(), "herbalism_treasures.yml", false, true, false);
|
||||
register();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register stuff
|
||||
*/
|
||||
@Override
|
||||
public void register() {
|
||||
ConfigurationNode herbalismTreasureNode = getUserRootNode().getNode(HYLIAN_LUCK);
|
||||
|
||||
if(herbalismTreasureNode == null)
|
||||
{
|
||||
mcMMO.p.getLogger().info("Hylian_Luck in treasures config not defined");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
for (String treasureName : herbalismTreasureNode.getList(TypeToken.of(String.class))) {
|
||||
|
||||
}
|
||||
} catch (ObjectMappingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unload() {
|
||||
hylianMap.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> validateKeys() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The version of this config
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public double getConfigVersion() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@@ -29,20 +29,15 @@ import java.util.List;
|
||||
//TODO: Need to rewrite this too
|
||||
public class TreasureConfig extends Config implements UnsafeValueValidation, Registers {
|
||||
|
||||
public static final String ENCHANTMENT_DROP_RATES = "Enchantment_Drop_Rates";
|
||||
public static final String ITEM_DROP_RATES = "Item_Drop_Rates";
|
||||
public static final String FISHING = "Fishing";
|
||||
public static final String EXCAVATION = "Excavation";
|
||||
public static final String SHAKE = "Shake";
|
||||
public static final String HYLIAN_LUCK = "Hylian_Luck";
|
||||
|
||||
public HashMap<String, List<ExcavationTreasure>> excavationMap = new HashMap<String, List<ExcavationTreasure>>();
|
||||
|
||||
public HashMap<EntityType, List<ShakeTreasure>> shakeMap = new HashMap<EntityType, List<ShakeTreasure>>();
|
||||
public HashMap<String, List<HylianTreasure>> hylianMap = new HashMap<String, List<HylianTreasure>>();
|
||||
|
||||
public HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<Rarity, List<FishingTreasure>>();
|
||||
public HashMap<Rarity, List<EnchantmentTreasure>> fishingEnchantments = new HashMap<Rarity, List<EnchantmentTreasure>>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public TreasureConfig() {
|
||||
//super(McmmoCore.getDataFolderPath().getAbsoluteFile(),"treasures.yml");
|
||||
@@ -158,11 +153,7 @@ public class TreasureConfig extends Config implements UnsafeValueValidation, Reg
|
||||
|
||||
loadEnchantments();
|
||||
|
||||
for (EntityType entity : EntityType.values()) {
|
||||
if (entity.isAlive()) {
|
||||
loadShake(entity);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void initRegisters()
|
||||
@@ -185,84 +176,23 @@ public class TreasureConfig extends Config implements UnsafeValueValidation, Reg
|
||||
|
||||
private void loadFishing()
|
||||
{
|
||||
ConfigurationNode fishingTreasureNode = getUserRootNode().getNode(FISHING);
|
||||
|
||||
if(fishingTreasureNode == null)
|
||||
{
|
||||
mcMMO.p.getLogger().info("Fishing treasures in treasures config not defined");
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize fishing HashMap
|
||||
for (Rarity rarity : Rarity.values()) {
|
||||
if (!fishingRewards.containsKey(rarity)) {
|
||||
fishingRewards.put(rarity, (new ArrayList<FishingTreasure>()));
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
for (String treasureName : fishingTreasureNode.getList(TypeToken.of(String.class))) {
|
||||
|
||||
}
|
||||
} catch (ObjectMappingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void loadExcavation()
|
||||
{
|
||||
ConfigurationNode excavationTreasureNode = getUserRootNode().getNode(EXCAVATION);
|
||||
|
||||
if(excavationTreasureNode == null)
|
||||
{
|
||||
mcMMO.p.getLogger().info("Excavation treasures in treasures config not defined");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
for (String treasureName : excavationTreasureNode.getList(TypeToken.of(String.class))) {
|
||||
|
||||
}
|
||||
} catch (ObjectMappingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadHerbalism()
|
||||
{
|
||||
ConfigurationNode herbalismTreasureNode = getUserRootNode().getNode(HYLIAN_LUCK);
|
||||
|
||||
if(herbalismTreasureNode == null)
|
||||
{
|
||||
mcMMO.p.getLogger().info("Hylian_Luck in treasures config not defined");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
for (String treasureName : herbalismTreasureNode.getList(TypeToken.of(String.class))) {
|
||||
|
||||
}
|
||||
} catch (ObjectMappingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadShake(EntityType entityType)
|
||||
{
|
||||
ConfigurationNode shakeTreasureNode = getUserRootNode().getNode(SHAKE, entityType.toString());
|
||||
|
||||
if(shakeTreasureNode != null)
|
||||
return;
|
||||
|
||||
try {
|
||||
for (String treasureName : shakeTreasureNode.getList(TypeToken.of(String.class))) {
|
||||
|
||||
}
|
||||
} catch (ObjectMappingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadTreasures(ConfigurationNode treasureChildNode) {
|
||||
if (treasureChildNode == null) {
|
||||
|
Reference in New Issue
Block a user