mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 14:46:46 +01:00
ExcavationTreasureConfig pt 1
This commit is contained in:
parent
15be278ee1
commit
772ceddf65
@ -8,13 +8,20 @@ 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.Material;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class ExcavationTreasureConfig extends Config implements UnsafeValueValidation, Registers {
|
||||
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<String, List<ExcavationTreasure>>();
|
||||
|
||||
public ExcavationTreasureConfig() {
|
||||
@ -22,6 +29,18 @@ public class ExcavationTreasureConfig extends Config implements UnsafeValueValid
|
||||
register();
|
||||
}
|
||||
|
||||
/**
|
||||
* This grabs an instance of this config class from the Config Manager
|
||||
* This method is deprecated and will be removed in the future
|
||||
* @see mcMMO#getConfigManager()
|
||||
* @return the instance of this config
|
||||
* @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static ExcavationTreasureConfig getInstance() {
|
||||
return mcMMO.getConfigManager().getExcavationTreasureConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register stuff
|
||||
*/
|
||||
@ -37,7 +56,99 @@ public class ExcavationTreasureConfig extends Config implements UnsafeValueValid
|
||||
|
||||
try {
|
||||
for (String treasureName : excavationTreasureNode.getList(TypeToken.of(String.class))) {
|
||||
//Treasure Material Definition
|
||||
Material treasureMaterial = Material.matchMaterial(treasureName.toUpperCase());
|
||||
|
||||
if(treasureMaterial != null)
|
||||
{
|
||||
ConfigurationNode currentTreasure = excavationTreasureNode.getNode(treasureName);
|
||||
|
||||
//TODO: Rewrite the entire treasure system because it sucks
|
||||
|
||||
/*
|
||||
* TREASURE PARAMETERS
|
||||
*/
|
||||
int amount = currentTreasure.getNode(AMOUNT).getInt();
|
||||
int xp = currentTreasure.getNode(XP).getInt();
|
||||
double dropChance = currentTreasure.getNode(DROP_CHANCE).getDouble();
|
||||
int dropLevel = currentTreasure.getNode(DROP_LEVEL).getInt();
|
||||
String customName = null;
|
||||
String lore;
|
||||
|
||||
/*
|
||||
* PARAMETER INIT
|
||||
*/
|
||||
|
||||
ArrayList<String> dropsFrom = new ArrayList(currentTreasure.getNode("Drops_From").getList(TypeToken.of(String.class)));
|
||||
|
||||
if(amount <= 0)
|
||||
{
|
||||
mcMMO.p.getLogger().severe("Excavation Treasure named "+treasureName+" in the config has an amount of 0 or below, is this intentional?");
|
||||
mcMMO.p.getLogger().severe("Skipping "+treasureName+" for being invalid");
|
||||
continue;
|
||||
}
|
||||
|
||||
if(xp <= 0)
|
||||
{
|
||||
mcMMO.p.getLogger().info("Excavation Treasure named "+treasureName+" in the config has xp set to 0 or below, is this intentional?");
|
||||
xp = 0;
|
||||
}
|
||||
|
||||
if(dropChance <= 0)
|
||||
{
|
||||
mcMMO.p.getLogger().severe("Excavation Treasure named "+treasureName+" in the config has a drop chance of 0 or below, is this intentional?");
|
||||
mcMMO.p.getLogger().severe("Skipping "+treasureName+" for being invalid");
|
||||
continue;
|
||||
}
|
||||
|
||||
if(dropLevel < 0)
|
||||
{
|
||||
mcMMO.p.getLogger().info("Excavation Treasure named "+treasureName+" in the config has a drop level below 0, is this intentional?");
|
||||
dropLevel = 0;
|
||||
}
|
||||
|
||||
if(dropsFrom == null || dropsFrom.isEmpty())
|
||||
{
|
||||
mcMMO.p.getLogger().severe("Excavation Treasure named "+treasureName+" in the config has no drop targets, which would make it impossible to obtain, is this intentional?");
|
||||
mcMMO.p.getLogger().severe("Skipping "+treasureName+" for being invalid");
|
||||
continue;
|
||||
}
|
||||
|
||||
/* OPTIONAL PARAMETERS */
|
||||
|
||||
//Custom Name
|
||||
|
||||
if(currentTreasure.getNode(CUSTOM_NAME) != null && !currentTreasure.getNode(CUSTOM_NAME).getString().equalsIgnoreCase("ChangeMe"))
|
||||
{
|
||||
customName = currentTreasure.getNode(CUSTOM_NAME).getString();
|
||||
}
|
||||
|
||||
//Lore
|
||||
if(currentTreasure.getNode(LORE) != null && !currentTreasure.getNode(LORE).getString().equalsIgnoreCase("ChangeMe"))
|
||||
{
|
||||
lore = currentTreasure.getNode(LORE).getString();
|
||||
}
|
||||
|
||||
/*
|
||||
* REGISTER TREASURE
|
||||
*/
|
||||
|
||||
ExcavationTreasure excavationTreasure = TreasureFactory.makeExcavationTreasure(treasureMaterial, amount, xp, dropChance, dropLevel, customName, currentTreasure.getNode(LORE));
|
||||
|
||||
/*
|
||||
* Add to map
|
||||
*/
|
||||
for(String dropBlock : dropsFrom)
|
||||
{
|
||||
if(excavationMap.get(dropBlock) == null)
|
||||
excavationMap.put(dropBlock, new ArrayList<>());
|
||||
|
||||
excavationMap.get(dropBlock).add(excavationTreasure);
|
||||
}
|
||||
|
||||
} else {
|
||||
mcMMO.p.getLogger().severe("Excavation Treasure Config - Material named "+treasureName+" does not match any known material.");
|
||||
}
|
||||
}
|
||||
} catch (ObjectMappingException e) {
|
||||
e.printStackTrace();
|
||||
@ -46,7 +157,7 @@ public class ExcavationTreasureConfig extends Config implements UnsafeValueValid
|
||||
|
||||
@Override
|
||||
public void unload() {
|
||||
|
||||
excavationMap.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -31,6 +31,18 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati
|
||||
public static final String ENCHANTMENT_DROP_RATES = "Enchantment_Drop_Rates";
|
||||
public static final String SHAKE = "Shake";
|
||||
|
||||
/**
|
||||
* This grabs an instance of this config class from the Config Manager
|
||||
* This method is deprecated and will be removed in the future
|
||||
* @see mcMMO#getConfigManager()
|
||||
* @return the instance of this config
|
||||
* @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static FishingTreasureConfig getInstance() {
|
||||
return mcMMO.getConfigManager().getFishingTreasureConfig();
|
||||
}
|
||||
|
||||
public FishingTreasureConfig() {
|
||||
super(mcMMO.p.getDataFolder().getAbsoluteFile(), "fishing_treasures.yml", false, true, false);
|
||||
register();
|
||||
|
@ -23,6 +23,18 @@ public class HerbalismTreasureConfig extends Config implements UnsafeValueValida
|
||||
register();
|
||||
}
|
||||
|
||||
/**
|
||||
* This grabs an instance of this config class from the Config Manager
|
||||
* This method is deprecated and will be removed in the future
|
||||
* @see mcMMO#getConfigManager()
|
||||
* @return the instance of this config
|
||||
* @deprecated Please use mcMMO.getConfigManager() to grab a specific config instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static HerbalismTreasureConfig getInstance() {
|
||||
return mcMMO.getConfigManager().getHerbalismTreasureConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register stuff
|
||||
*/
|
||||
|
@ -0,0 +1,73 @@
|
||||
package com.gmail.nossr50.config.treasure;
|
||||
|
||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
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 {
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
private static ItemStack makeItemStack(Material material, int dropAmount, String customName, ConfigurationNode customLore) {
|
||||
ItemStack treasure = new ItemStack(material, dropAmount);
|
||||
|
||||
/* ADD CUSTOM NAME */
|
||||
if(customName != null)
|
||||
{
|
||||
ItemMeta itemMeta = treasure.getItemMeta();
|
||||
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', customName));
|
||||
treasure.setItemMeta(itemMeta);
|
||||
}
|
||||
|
||||
/* ADD CUSTOM LORE */
|
||||
if(customLore != null)
|
||||
{
|
||||
ItemMeta itemMeta = treasure.getItemMeta();
|
||||
List<String> lore = new ArrayList<String>();
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
/* IF FOR SOME REASON ITS A POTION */
|
||||
|
||||
//TODO: Do this later
|
||||
|
||||
return treasure;
|
||||
}
|
||||
}
|
@ -1,6 +1,9 @@
|
||||
package com.gmail.nossr50.skills.fishing;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.MainConfig;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.config.treasure.FishingTreasureConfig;
|
||||
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
@ -453,7 +456,7 @@ public class FishingManager extends SkillManager {
|
||||
break;
|
||||
}*/
|
||||
|
||||
List<FishingTreasure> fishingTreasures = TreasureConfig.getInstance().fishingRewards.get(rarity);
|
||||
List<FishingTreasure> fishingTreasures = FishingTreasureConfig.getInstance().fishingRewards.get(rarity);
|
||||
|
||||
if (fishingTreasures.isEmpty()) {
|
||||
return null;
|
||||
|
@ -8,123 +8,165 @@ Archaeology:
|
||||
Drop_Chance: 0.05
|
||||
Drop_Level: 75
|
||||
Drops_From: [Dirt, Podzol, Grass_Block, Sand, Red_Sand, Gravel, Clay, Mycelium, Soul_Sand]
|
||||
Custom_Name: ChangeMe
|
||||
Lore: ChangeMe
|
||||
GUNPOWDER:
|
||||
Amount: 1
|
||||
XP: 30
|
||||
Drop_Chance: 10.0
|
||||
Drop_Level: 10
|
||||
Drops_From: [Gravel]
|
||||
Custom_Name: ChangeMe
|
||||
Lore: ChangeMe
|
||||
BONE:
|
||||
Amount: 1
|
||||
XP: 30
|
||||
Drop_Chance: 10.0
|
||||
Drop_Level: 20
|
||||
Drops_From: [Gravel]
|
||||
Custom_Name: ChangeMe
|
||||
Lore: ChangeMe
|
||||
APPLE:
|
||||
Amount: 1
|
||||
XP: 100
|
||||
Drop_Chance: 0.1
|
||||
Drop_Level: 25
|
||||
Drops_From: [Grass_Block, Mycelium]
|
||||
Custom_Name: ChangeMe
|
||||
Lore: ChangeMe
|
||||
SLIME_BALL:
|
||||
Amount: 1
|
||||
XP: 100
|
||||
Drop_Chance: 5.0
|
||||
Drop_Level: 15
|
||||
Drops_From: [Clay]
|
||||
Custom_Name: ChangeMe
|
||||
Lore: ChangeMe
|
||||
BUCKET:
|
||||
Amount: 1
|
||||
XP: 100
|
||||
Drop_Chance: 0.1
|
||||
Drop_Level: 50
|
||||
Drops_From: [Clay]
|
||||
Custom_Name: ChangeMe
|
||||
Lore: ChangeMe
|
||||
NETHERRACK:
|
||||
Amount: 1
|
||||
XP: 30
|
||||
Drop_Chance: 0.5
|
||||
Drop_Level: 85
|
||||
Drops_From: [Gravel]
|
||||
Custom_Name: ChangeMe
|
||||
Lore: ChangeMe
|
||||
RED_MUSHROOM:
|
||||
Amount: 1
|
||||
XP: 80
|
||||
Drop_Chance: 0.5
|
||||
Drop_Level: 50
|
||||
Drops_From: [Dirt, Podzol, Grass_Block, Mycelium]
|
||||
Custom_Name: ChangeMe
|
||||
Lore: ChangeMe
|
||||
BROWN_MUSHROOM:
|
||||
Amount: 1
|
||||
XP: 80
|
||||
Drop_Chance: 0.5
|
||||
Drop_Level: 50
|
||||
Drops_From: [Dirt, Podzol, Grass_Block, Mycelium]
|
||||
Custom_Name: ChangeMe
|
||||
Lore: ChangeMe
|
||||
EGG:
|
||||
Amount: 1
|
||||
XP: 100
|
||||
Drop_Chance: 1.0
|
||||
Drop_Level: 25
|
||||
Drops_From: [Grass_Block]
|
||||
Custom_Name: ChangeMe
|
||||
Lore: ChangeMe
|
||||
SOUL_SAND:
|
||||
Amount: 1
|
||||
XP: 80
|
||||
Drop_Chance: 0.5
|
||||
Drop_Level: 65
|
||||
Drops_From: [Sand, Red_Sand]
|
||||
Custom_Name: ChangeMe
|
||||
Lore: ChangeMe
|
||||
CLOCK:
|
||||
Amount: 1
|
||||
XP: 100
|
||||
Drop_Chance: 0.1
|
||||
Drop_Level: 50
|
||||
Drops_From: [Clay]
|
||||
Custom_Name: ChangeMe
|
||||
Lore: ChangeMe
|
||||
COBWEB:
|
||||
Amount: 1
|
||||
XP: 150
|
||||
Drop_Chance: 5.0
|
||||
Drop_Level: 75
|
||||
Drops_From: [Clay]
|
||||
Custom_Name: ChangeMe
|
||||
Lore: ChangeMe
|
||||
STRING:
|
||||
Amount: 1
|
||||
XP: 200
|
||||
Drop_Chance: 5.0
|
||||
Drop_Level: 25
|
||||
Drops_From: [Clay]
|
||||
Custom_Name: ChangeMe
|
||||
Lore: ChangeMe
|
||||
GLOWSTONE_DUST:
|
||||
Amount: 1
|
||||
XP: 80
|
||||
Drop_Chance: 5.0
|
||||
Drop_Level: 5
|
||||
Drops_From: [Dirt, Podzol, Grass_Block, Sand, Red_Sand, Mycelium]
|
||||
Custom_Name: ChangeMe
|
||||
Lore: ChangeMe
|
||||
MUSIC_DISC_13:
|
||||
Amount: 1
|
||||
XP: 3000
|
||||
Drop_Chance: 0.05
|
||||
Drop_Level: 25
|
||||
Drops_From: [Dirt, Podzol, Grass_Block, Sand, Red_Sand, Gravel, Clay, Mycelium, Soul_Sand]
|
||||
Custom_Name: ChangeMe
|
||||
Lore: ChangeMe
|
||||
MUSIC_DISC_CAT:
|
||||
Amount: 1
|
||||
XP: 3000
|
||||
Drop_Chance: 0.05
|
||||
Drop_Level: 25
|
||||
Drops_From: [Dirt, Podzol, Grass_Block, Sand, Red_Sand, Gravel, Clay, Mycelium, Soul_Sand]
|
||||
Custom_Name: ChangeMe
|
||||
Lore: ChangeMe
|
||||
DIAMOND:
|
||||
Amount: 1
|
||||
XP: 1000
|
||||
Drop_Chance: 0.13
|
||||
Drop_Level: 35
|
||||
Drops_From: [Dirt, Podzol, Grass_Block, Sand, Red_Sand, Gravel, Clay, Mycelium, Soul_Sand]
|
||||
Custom_Name: ChangeMe
|
||||
Lore: ChangeMe
|
||||
COCOA_BEANS:
|
||||
Amount: 1
|
||||
XP: 100
|
||||
Drop_Chance: 1.33
|
||||
Drop_Level: 35
|
||||
Drops_From: [Dirt, Podzol, Grass_Block, Mycelium]
|
||||
Custom_Name: ChangeMe
|
||||
Lore: ChangeMe
|
||||
QUARTZ:
|
||||
Amount: 1
|
||||
XP: 100
|
||||
Drop_Chance: 0.5
|
||||
Drop_Level: 85
|
||||
Drops_From: [Dirt, Podzol, Sand, Red_Sand, Gravel, Mycelium, Soul_Sand]
|
||||
Custom_Name: ChangeMe
|
||||
Lore: ChangeMe
|
||||
NAME_TAG:
|
||||
Amount: 1
|
||||
XP: 3000
|
||||
Drop_Chance: 0.05
|
||||
Drop_Level: 25
|
||||
Drops_From: [Dirt, Podzol, Grass_Block, Sand, Red_Sand, Gravel, Clay, Mycelium, Soul_Sand]
|
||||
Custom_Name: ChangeMe
|
||||
Lore: ChangeMe
|
Loading…
Reference in New Issue
Block a user