forked from Upstream/mmocore
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) {
|
public FromExperienceSource(ExperienceDispenser dispenser, MMOLineConfig config) {
|
||||||
super(dispenser);
|
super(dispenser);
|
||||||
|
|
||||||
|
config.validateKeys("source");
|
||||||
List<String> list = new ConfigFile("exp-sources").getConfig().getStringList(config.getString("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()
|
list.stream()
|
||||||
.map(MMOLineConfig::new)
|
.map(MMOLineConfig::new)
|
||||||
.forEach(mmoLineConfig ->
|
.forEach(mmoLineConfig ->
|
||||||
|
@ -14,16 +14,25 @@ import org.bukkit.event.HandlerList;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class ExperienceManager implements MMOCoreManager {
|
public class ExperienceManager implements MMOCoreManager {
|
||||||
private final Map<String, ExpCurve> expCurves = new HashMap<>();
|
private final Map<String, ExpCurve> expCurves = new HashMap<>();
|
||||||
private final Map<String, ExperienceTable> expTables = 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.
|
* Saves different experience sources based on experience source type.
|
||||||
*/
|
*/
|
||||||
@ -51,6 +60,12 @@ public class ExperienceManager implements MMOCoreManager {
|
|||||||
return expCurves.get(id);
|
return expCurves.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@Nullable
|
||||||
|
public List<ExperienceSource<?>> getExperienceSourceList(String key) {
|
||||||
|
return publicExpSources.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasTable(String id) {
|
public boolean hasTable(String id) {
|
||||||
return expTables.containsKey(id);
|
return expTables.containsKey(id);
|
||||||
}
|
}
|
||||||
@ -88,7 +103,7 @@ public class ExperienceManager implements MMOCoreManager {
|
|||||||
managers.clear();
|
managers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
expCurves.clear();
|
// Exp curves
|
||||||
for (File file : new File(MMOCore.plugin.getDataFolder() + "/expcurves").listFiles())
|
for (File file : new File(MMOCore.plugin.getDataFolder() + "/expcurves").listFiles())
|
||||||
try {
|
try {
|
||||||
ExpCurve curve = new ExpCurve(file);
|
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());
|
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();
|
FileConfiguration expTablesConfig = new ConfigFile("exp-tables").getConfig();
|
||||||
for (String key : expTablesConfig.getKeys(false))
|
for (String key : expTablesConfig.getKeys(false))
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user