2018-10-05 06:48:44 +02:00
|
|
|
package bentobox.addon.limits;
|
|
|
|
|
2019-02-07 08:20:45 +01:00
|
|
|
import java.util.ArrayList;
|
2018-10-05 06:48:44 +02:00
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.HashMap;
|
2019-02-07 08:20:45 +01:00
|
|
|
import java.util.List;
|
2018-10-05 06:48:44 +02:00
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import org.bukkit.configuration.ConfigurationSection;
|
|
|
|
import org.bukkit.entity.EntityType;
|
|
|
|
|
|
|
|
public class Settings {
|
|
|
|
|
|
|
|
private Map<EntityType, Integer> limits = new HashMap<>();
|
2019-02-07 08:20:45 +01:00
|
|
|
private List<String> gameModes = new ArrayList<>();
|
2018-10-05 06:48:44 +02:00
|
|
|
|
|
|
|
public Settings(Limits addon) {
|
2019-02-07 08:20:45 +01:00
|
|
|
|
|
|
|
// GameModes
|
2019-02-09 07:35:29 +01:00
|
|
|
gameModes = addon.getConfig().getStringList("gamemodes");
|
2019-02-07 08:20:45 +01:00
|
|
|
|
2018-10-05 06:48:44 +02:00
|
|
|
ConfigurationSection el = addon.getConfig().getConfigurationSection("entitylimits");
|
|
|
|
if (el != null) {
|
|
|
|
for (String key : el.getKeys(false)) {
|
|
|
|
EntityType type = getType(key);
|
|
|
|
if (type != null) {
|
|
|
|
limits.put(type, el.getInt(key, 0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private EntityType getType(String key) {
|
|
|
|
return Arrays.stream(EntityType.values()).filter(v -> v.name().equalsIgnoreCase(key)).findFirst().orElse(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the limits
|
|
|
|
*/
|
|
|
|
public Map<EntityType, Integer> getLimits() {
|
|
|
|
return limits;
|
|
|
|
}
|
|
|
|
|
2019-02-07 08:20:45 +01:00
|
|
|
/**
|
|
|
|
* @return the gameModes
|
|
|
|
*/
|
|
|
|
public List<String> getGameModes() {
|
|
|
|
return gameModes;
|
|
|
|
}
|
|
|
|
|
2018-10-05 06:48:44 +02:00
|
|
|
}
|