mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2025-02-22 14:41:51 +01:00
Fixed from exp source
This commit is contained in:
parent
d8cdd8791b
commit
63fba6dc5e
@ -22,8 +22,9 @@ public class FromExperienceSource extends ExperienceSource {
|
||||
public FromExperienceSource(ExperienceDispenser dispenser, MMOLineConfig config) {
|
||||
super(dispenser);
|
||||
|
||||
config.validateKeys("source");
|
||||
List<String> list = new ConfigFile("exp-sources").getConfig().getStringList(config.getString("source"));
|
||||
Validate.isTrue(list.size() != 0, "There is no source matching " + config.getString("key"));
|
||||
Validate.isTrue(list != null && !list.isEmpty(), "There is no source matching " + config.getString("source"));
|
||||
list.stream()
|
||||
.map(MMOLineConfig::new)
|
||||
.forEach(mmoLineConfig ->
|
||||
|
@ -14,16 +14,25 @@ import org.bukkit.event.HandlerList;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class ExperienceManager implements MMOCoreManager {
|
||||
private final Map<String, ExpCurve> expCurves = new HashMap<>();
|
||||
private final Map<String, ExperienceTable> expTables = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Experience sources from the exp-sources.yml config file where you can
|
||||
* input any exp source which can later be used along with the 'from'
|
||||
* exp source anywhere in the plugin.
|
||||
* <p>
|
||||
* TODO First needs to edit the exp-source current structure. This is going to break a lot of things
|
||||
*
|
||||
* @deprecated See TODO
|
||||
*/
|
||||
@Deprecated
|
||||
private final Map<String, List<ExperienceSource<?>>> publicExpSources = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Saves different experience sources based on experience source type.
|
||||
*/
|
||||
@ -51,6 +60,12 @@ public class ExperienceManager implements MMOCoreManager {
|
||||
return expCurves.get(id);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Nullable
|
||||
public List<ExperienceSource<?>> getExperienceSourceList(String key) {
|
||||
return publicExpSources.get(key);
|
||||
}
|
||||
|
||||
public boolean hasTable(String id) {
|
||||
return expTables.containsKey(id);
|
||||
}
|
||||
@ -88,7 +103,7 @@ public class ExperienceManager implements MMOCoreManager {
|
||||
managers.clear();
|
||||
}
|
||||
|
||||
expCurves.clear();
|
||||
// Exp curves
|
||||
for (File file : new File(MMOCore.plugin.getDataFolder() + "/expcurves").listFiles())
|
||||
try {
|
||||
ExpCurve curve = new ExpCurve(file);
|
||||
@ -97,7 +112,7 @@ public class ExperienceManager implements MMOCoreManager {
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load exp curve '" + file.getName() + "': " + exception.getMessage());
|
||||
}
|
||||
|
||||
expTables.clear();
|
||||
// Exp tables
|
||||
FileConfiguration expTablesConfig = new ConfigFile("exp-tables").getConfig();
|
||||
for (String key : expTablesConfig.getKeys(false))
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user