Move kits to kits.yml (#1774)

* Move kits to kits.yml
We will now use a separate kits.yml file.
Any kits that were defined in the config.yml will be migrated over to the kits.yml file automatically on startup.
This commit is contained in:
Trent Hensler 2018-01-18 00:25:00 -08:00 committed by GitHub
parent 1f0f77ff72
commit cd43355d4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 286 additions and 135 deletions

View file

@ -325,46 +325,24 @@ public class Settings implements net.ess3.api.ISettings {
return config.getDouble("heal-cooldown", 0);
}
private ConfigurationSection kits;
private ConfigurationSection _getKits() {
if (config.isConfigurationSection("kits")) {
final ConfigurationSection section = config.getConfigurationSection("kits");
final ConfigurationSection newSection = new MemoryConfiguration();
for (String kitItem : section.getKeys(false)) {
if (section.isConfigurationSection(kitItem)) {
newSection.set(kitItem.toLowerCase(Locale.ENGLISH), section.getConfigurationSection(kitItem));
}
}
return newSection;
}
return null;
}
@Override
public ConfigurationSection getKits() {
return kits;
return ess.getKits().getKits();
}
@Override
public Map<String, Object> getKit(String name) {
name = name.replace('.', '_').replace('/', '_');
if (getKits() != null) {
final ConfigurationSection kits = getKits();
if (kits.isConfigurationSection(name)) {
return kits.getConfigurationSection(name).getValues(true);
}
}
return null;
return ess.getKits().getKit(name);
}
@Override
public void addKit(String name, List<String> lines, long delay) {
// Will overwrite but w/e
config.set("kits." + name + ".delay", delay);
config.set("kits." + name + ".items", lines);
kits = _getKits();
config.save();
ess.getKits().addKit(name, lines, delay);
}
@Override
public ConfigurationSection getKitSection() {
return config.getConfigurationSection("kits");
}
@Override
@ -516,7 +494,6 @@ public class Settings implements net.ess3.api.ISettings {
itemSpawnBl = _getItemSpawnBlacklist();
loginAttackDelay = _getLoginAttackDelay();
signUsePerSecond = _getSignUsePerSecond();
kits = _getKits();
chatFormats.clear();
changeDisplayName = _changeDisplayName();
disabledCommands = getDisabledCommands();
@ -1202,7 +1179,7 @@ public class Settings implements net.ess3.api.ISettings {
public boolean isSpawnOnJoin() {
return !this.spawnOnJoinGroups.isEmpty();
}
private List<String> spawnOnJoinGroups;
public List<String> _getSpawnOnJoinGroups() {
@ -1241,7 +1218,7 @@ public class Settings implements net.ess3.api.ISettings {
public boolean isTeleportToCenterLocation() {
return config.getBoolean("teleport-to-center", true);
}
private Map<Pattern, Long> commandCooldowns;
private Map<Pattern, Long> _getCommandCooldowns() {
@ -1268,10 +1245,10 @@ public class Settings implements net.ess3.api.ISettings {
cmdEntry = cmdEntry.substring(1);
}
String cmd = cmdEntry
.replaceAll("\\*", ".*"); // Wildcards are accepted as asterisk * as known universally.
.replaceAll("\\*", ".*"); // Wildcards are accepted as asterisk * as known universally.
pattern = Pattern.compile(cmd + "( .*)?"); // This matches arguments, if present, to "ignore" them from the feature.
}
/* ================================
* >> Process cooldown value
* ================================ */
@ -1439,4 +1416,4 @@ public class Settings implements net.ess3.api.ISettings {
public boolean isDirectHatAllowed() {
return config.getBoolean("allow-direct-hat", true);
}
}
}