Now all sections types may not have a provider

This commit is contained in:
Jaime Martinez Rincon 2017-01-26 13:44:02 +01:00
parent ba26697920
commit b54ed5c5d5
3 changed files with 10 additions and 19 deletions

View File

@ -50,11 +50,7 @@ public class FallbackCommand extends Command {
String bind = rules.getString(section.getName());
ServerSection target = plugin.getSectionManager().getByName(bind);
if (target == null) {
target = section.getParent();
}
return target;
return target == null ? section.getParent() : target;
}
} else {
if (ConfigEntries.FALLBACK_PRINCIPAL_ENABLED.get()) {

View File

@ -53,14 +53,6 @@ public class ServerKickListener implements Listener {
return null;
}
Configuration rules = plugin.getConfig().getSection("settings.reconnect-kick.rules");
String name = rules.getString(section.getName());
ServerSection target = plugin.getSectionManager().getByName(name);
if (target == null) {
target = section.getParent();
}
AtomicBoolean matches = new AtomicBoolean(false);
String reason = TextComponent.toPlainText(event.getKickReasonComponent());
for (String pattern : ConfigEntries.RECONNECT_KICK_REASONS.get()) {
@ -79,7 +71,11 @@ public class ServerKickListener implements Listener {
}
if (matches.get()) {
return target;
Configuration rules = plugin.getConfig().getSection("settings.reconnect-kick.rules");
String name = rules.getString(section.getName());
ServerSection target = plugin.getSectionManager().getByName(name);
return target == null ? section.getParent() : target;
}
} else {
if (ConfigEntries.FALLBACK_PRINCIPAL_ENABLED.get()) {

View File

@ -56,11 +56,6 @@ public class ServerSection {
if (parent == null) {
throw new IllegalArgumentException(String.format("The section \"%s\" has an invalid parent set", name));
}
} else {
//Principal sections do not necessarily must have a parent section, but might
if (!principal) {
throw new IllegalArgumentException(String.format("The section \"%s\" does not have a parent set", name));
}
}
if (ConfigUtils.isSet(section, "servers")) {
@ -166,6 +161,10 @@ public class ServerSection {
return dummy;
}
public boolean hasParent() {
return parent != null;
}
public ServerSection getParent() {
return parent;
}