Created layout for default config

This commit is contained in:
Jaime Martínez Rincón 2017-09-12 20:46:54 +02:00
parent 6da91c3944
commit e707d82772
20 changed files with 468 additions and 332 deletions

View File

@ -43,4 +43,4 @@ jobs:
path: target/surefire-reports
- store_artifacts:
path: target/PlayerBalancer.jar
path: target/PlayerBalancer.jar

View File

@ -103,6 +103,7 @@
<scope>compile</scope>
<exclusions>
<exclusion>
<!-- Already shaded in bungee -->
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>

View File

@ -4,14 +4,13 @@ import com.google.common.reflect.TypeToken;
import com.jaimemartz.playerbalancer.commands.FallbackCommand;
import com.jaimemartz.playerbalancer.commands.MainCommand;
import com.jaimemartz.playerbalancer.commands.ManageCommand;
import com.jaimemartz.playerbalancer.connection.ServerAssignRegistry;
import com.jaimemartz.playerbalancer.listener.*;
import com.jaimemartz.playerbalancer.manager.NetworkManager;
import com.jaimemartz.playerbalancer.manager.PasteHelper;
import com.jaimemartz.playerbalancer.manager.PlayerLocker;
import com.jaimemartz.playerbalancer.ping.StatusManager;
import com.jaimemartz.playerbalancer.section.SectionManager;
import com.jaimemartz.playerbalancer.settings.MainSettings;
import com.jaimemartz.playerbalancer.settings.SettingsHolder;
import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.api.plugin.Plugin;
@ -31,7 +30,7 @@ import java.util.logging.Level;
public class PlayerBalancer extends Plugin {
private boolean failed = false;
private StatusManager statusManager;
private MainSettings mainSettings;
private SettingsHolder mainSettings;
private ConfigurationLoader<CommentedConfigurationNode> loader;
private SectionManager sectionManager;
private NetworkManager networkManager;
@ -63,11 +62,11 @@ public class PlayerBalancer extends Plugin {
CommentedConfigurationNode node = loader.load();
if (!file.exists()) {
mainSettings = new MainSettings().__defaults();
node.setValue(TypeToken.of(MainSettings.class), mainSettings);
mainSettings = new SettingsHolder(); //.__defaults(); todo load defaults from default config
node.setValue(TypeToken.of(SettingsHolder.class), mainSettings);
loader.save(node);
} else {
mainSettings = node.getValue(TypeToken.of(MainSettings.class));
mainSettings = node.getValue(TypeToken.of(SettingsHolder.class));
}
} catch (Exception e) {
e.printStackTrace();
@ -76,7 +75,7 @@ public class PlayerBalancer extends Plugin {
mainCommand = new MainCommand(this);
getProxy().getPluginManager().registerCommand(this, mainCommand);
if (mainSettings.getGeneralProps().isActive()) {
if (mainSettings.getGeneralProps().isEnabled()) {
if (mainSettings.getGeneralProps().isSilent()) {
getLogger().setLevel(Level.WARNING);
}
@ -99,11 +98,11 @@ public class PlayerBalancer extends Plugin {
sectionManager.load();
statusManager = new StatusManager(this);
if (mainSettings.getServerCheckerProps().isActive()) {
if (mainSettings.getServerCheckerProps().isEnabled()) {
statusManager.start();
}
if (mainSettings.getFallbackCommandProps().isActive()) {
if (mainSettings.getFallbackCommandProps().isEnabled()) {
fallbackCommand = new FallbackCommand(this, mainSettings.getFallbackCommandProps().getCommand());
getProxy().getPluginManager().registerCommand(this, fallbackCommand);
}
@ -123,7 +122,7 @@ public class PlayerBalancer extends Plugin {
PasteHelper.reset();
if (mainSettings.getKickHandlerProps().isActive()) {
if (mainSettings.getKickHandlerProps().isEnabled()) {
kickListener = new ServerKickListener(this);
getProxy().getPluginManager().registerListener(this, kickListener);
}
@ -151,7 +150,7 @@ public class PlayerBalancer extends Plugin {
getProxy().getPluginManager().unregisterCommand(mainCommand);
mainCommand = null;
if (mainSettings.getGeneralProps().isActive()) {
if (mainSettings.getGeneralProps().isEnabled()) {
//Do not try to do anything if the plugin has not loaded correctly
if (failed) return;
@ -160,15 +159,20 @@ public class PlayerBalancer extends Plugin {
reloadListener = null;
}
if (mainSettings.getServerCheckerProps().isActive()) {
if (mainSettings.getServerCheckerProps().isEnabled()) {
statusManager.stop();
}
if (mainSettings.getFallbackCommandProps().isActive()) {
if (mainSettings.getFallbackCommandProps().isEnabled()) {
getProxy().getPluginManager().unregisterCommand(fallbackCommand);
fallbackCommand = null;
}
if (mainSettings.getKickHandlerProps().isEnabled()) {
getProxy().getPluginManager().unregisterListener(kickListener);
kickListener = null;
}
getProxy().getPluginManager().unregisterListener(connectListener);
connectListener = null;
@ -178,16 +182,13 @@ public class PlayerBalancer extends Plugin {
getProxy().getPluginManager().unregisterCommand(manageCommand);
manageCommand = null;
if (mainSettings.getKickHandlerProps().isActive()) {
getProxy().getPluginManager().unregisterListener(kickListener);
kickListener = null;
}
sectionManager.flush();
/*
if (mainSettings.getGeneralProps().isAssignTargets()) {
ServerAssignRegistry.getTable().clear();
}
*/
}
PlayerLocker.flush();
@ -207,7 +208,7 @@ public class PlayerBalancer extends Plugin {
return !failed;
}
public MainSettings getSettings() {
public SettingsHolder getSettings() {
return mainSettings;
}

View File

@ -3,9 +3,9 @@ package com.jaimemartz.playerbalancer.commands;
import com.jaimemartz.playerbalancer.PlayerBalancer;
import com.jaimemartz.playerbalancer.connection.ConnectionIntent;
import com.jaimemartz.playerbalancer.section.ServerSection;
import com.jaimemartz.playerbalancer.settings.props.FallbackCommandProps;
import com.jaimemartz.playerbalancer.settings.props.MessagesProps;
import com.jaimemartz.playerbalancer.settings.shared.CommandProps;
import com.jaimemartz.playerbalancer.settings.props.features.FallbackCommandProps;
import com.jaimemartz.playerbalancer.settings.props.shared.CommandProps;
import com.jaimemartz.playerbalancer.utils.MessageUtils;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;

View File

@ -4,8 +4,8 @@ import com.jaimemartz.playerbalancer.PlayerBalancer;
import com.jaimemartz.playerbalancer.connection.ConnectionIntent;
import com.jaimemartz.playerbalancer.manager.PlayerLocker;
import com.jaimemartz.playerbalancer.section.ServerSection;
import com.jaimemartz.playerbalancer.settings.props.KickHandlerProps;
import com.jaimemartz.playerbalancer.settings.props.MessagesProps;
import com.jaimemartz.playerbalancer.settings.props.features.KickHandlerProps;
import com.jaimemartz.playerbalancer.utils.MessageUtils;
import net.md_5.bungee.api.Callback;
import net.md_5.bungee.api.chat.TextComponent;

View File

@ -2,7 +2,7 @@ package com.jaimemartz.playerbalancer.section;
import com.jaimemartz.playerbalancer.PlayerBalancer;
import com.jaimemartz.playerbalancer.commands.FallbackCommand;
import com.jaimemartz.playerbalancer.settings.shared.CommandProps;
import com.jaimemartz.playerbalancer.settings.props.shared.CommandProps;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;

View File

@ -9,17 +9,13 @@ import net.md_5.bungee.api.scheduler.ScheduledTask;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.TreeMap;
public class SectionManager {
private final PlayerBalancer plugin;
private ScheduledTask updateTask;
private ServerSection principal;
private final Map<String, ServerSection> sections = new TreeMap<>(
String.CASE_INSENSITIVE_ORDER
);
private final Map<String, ServerSection> sections = new HashMap<>();
private final Map<ServerInfo, ServerSection> servers = new HashMap<>();
public SectionManager(PlayerBalancer plugin) {
@ -36,46 +32,15 @@ public class SectionManager {
sections.put(name, object);
});
this.sections.forEach((name, section) -> {
plugin.getLogger().info(String.format("Pre-Initialization of section with name \"%s\"", name));
//section.preInit();
});
//todo validate principal section
//todo validate dummy sections
this.sections.forEach((name, section) -> {
plugin.getLogger().info(String.format("Initialization of section with name \"%s\"", name));
//section.load();
sections.forEach((name, section) -> {
//load section
});
this.sections.forEach((name, section) -> {
plugin.getLogger().info(String.format("Post-Initialization of section with name \"%s\"", name));
//section.postInit();
});
/*
//todo unify loading code with SectionManager
if (ConfigEntries.SERVERS_UPDATE.get()) {
updateTask = plugin.getProxy().getScheduler().schedule(plugin, () -> {
this.sections.forEach((name, section) -> {
section.getConfiguration().getStringList("servers").forEach(entry -> {
Pattern pattern = Pattern.compile(entry);
plugin.getProxy().getServers().forEach((key, value) -> {
Matcher matcher = pattern.matcher(key);
if (matcher.matches()) {
if (!section.getServers().contains(value)) {
plugin.getLogger().info(String.format("Found a new match with \"%s\" for entry \"%s\"", key, entry));
this.register(value, section);
section.getServers().add(value);
}
}
});
});
});
}, 1, 1, TimeUnit.MINUTES);
}
*/
long ending = System.currentTimeMillis() - starting;
plugin.getLogger().info(String.format("A total of %s section(s) have been loaded in %sms", this.sections.size(), ending));
plugin.getLogger().info(String.format("A total of %s section(s) have been loaded in %sms", sections.size(), ending));
}
public void flush() {

View File

@ -1,7 +1,7 @@
package com.jaimemartz.playerbalancer.section;
import com.jaimemartz.playerbalancer.connection.ProviderType;
import com.jaimemartz.playerbalancer.settings.shared.SectionProps;
import com.jaimemartz.playerbalancer.settings.props.shared.SectionProps;
import net.md_5.bungee.api.config.ServerInfo;
import java.util.List;

View File

@ -1,110 +0,0 @@
package com.jaimemartz.playerbalancer.settings;
import com.jaimemartz.playerbalancer.settings.props.*;
import com.jaimemartz.playerbalancer.settings.shared.SectionProps;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import java.util.HashMap;
import java.util.Map;
@ConfigSerializable
public class MainSettings {
@Setting(value = "general")
private GeneralProps generalProps;
@Setting(value = "server-checker")
private ServerCheckerProps serverCheckerProps;
@Setting(value = "kick-handler")
private KickHandlerProps kickHandlerProps;
@Setting(value = "fallback-command")
private FallbackCommandProps fallbackCommandProps;
@Setting(value = "messages", comment = "Effectively remove (i.e comment) a message to disable it")
private MessagesProps messagesProps;
@Setting
private Map<String, SectionProps> sections;
public MainSettings __defaults() {
this.generalProps = new GeneralProps().__defaults();
this.serverCheckerProps = new ServerCheckerProps().__defaults();
this.kickHandlerProps = new KickHandlerProps().__defaults();
this.fallbackCommandProps = new FallbackCommandProps().__defaults();
this.messagesProps = new MessagesProps().__defaults();
this.sections = new HashMap<>();
SectionProps prop1 = new SectionProps();
prop1.setDummy(true);
prop1.setPrincipal(true);
sections.put("test", prop1);
SectionProps prop2 = new SectionProps();
prop2.setDummy(false);
prop2.setPrincipal(false);
sections.put("other", prop2);
return this;
}
public GeneralProps getGeneralProps() {
return generalProps;
}
public void setGeneralProps(GeneralProps generalProps) {
this.generalProps = generalProps;
}
public ServerCheckerProps getServerCheckerProps() {
return serverCheckerProps;
}
public void setServerCheckerProps(ServerCheckerProps serverCheckerProps) {
this.serverCheckerProps = serverCheckerProps;
}
public KickHandlerProps getKickHandlerProps() {
return kickHandlerProps;
}
public void setKickHandlerProps(KickHandlerProps kickHandlerProps) {
this.kickHandlerProps = kickHandlerProps;
}
public FallbackCommandProps getFallbackCommandProps() {
return fallbackCommandProps;
}
public void setFallbackCommandProps(FallbackCommandProps fallbackCommandProps) {
this.fallbackCommandProps = fallbackCommandProps;
}
public MessagesProps getMessagesProps() {
return messagesProps;
}
public void setMessagesProps(MessagesProps messagesProps) {
this.messagesProps = messagesProps;
}
public Map<String, SectionProps> getSections() {
return sections;
}
public void setSections(Map<String, SectionProps> sections) {
this.sections = sections;
}
@Override
public String toString() {
return "MainSettings{" +
"generalProps=" + generalProps +
", serverCheckerProps=" + serverCheckerProps +
", kickHandlerProps=" + kickHandlerProps +
", fallbackCommandProps=" + fallbackCommandProps +
", messagesProps=" + messagesProps +
", sections=" + sections +
'}';
}
}

View File

@ -0,0 +1,88 @@
package com.jaimemartz.playerbalancer.settings;
import com.jaimemartz.playerbalancer.settings.props.FeaturesProps;
import com.jaimemartz.playerbalancer.settings.props.GeneralProps;
import com.jaimemartz.playerbalancer.settings.props.MessagesProps;
import com.jaimemartz.playerbalancer.settings.props.features.BalancerProps;
import com.jaimemartz.playerbalancer.settings.props.features.FallbackCommandProps;
import com.jaimemartz.playerbalancer.settings.props.features.KickHandlerProps;
import com.jaimemartz.playerbalancer.settings.props.features.ServerCheckerProps;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class SettingsHolder {
@Setting(value = "general")
private GeneralProps generalProps;
@Setting(value = "messages")
private MessagesProps messagesProps;
@Setting(value = "features")
private FeaturesProps featuresProps;
public GeneralProps getGeneralProps() {
return generalProps;
}
public void setGeneralProps(GeneralProps generalProps) {
this.generalProps = generalProps;
}
public MessagesProps getMessagesProps() {
return messagesProps;
}
public void setMessagesProps(MessagesProps messagesProps) {
this.messagesProps = messagesProps;
}
public FeaturesProps getFeaturesProps() {
return featuresProps;
}
public void setFeaturesProps(FeaturesProps featuresProps) {
this.featuresProps = featuresProps;
}
public BalancerProps getBalancerProps() {
return featuresProps.getBalancerProps();
}
public void setBalancerProps(BalancerProps balancerProps) {
featuresProps.setBalancerProps(balancerProps);
}
public FallbackCommandProps getFallbackCommandProps() {
return featuresProps.getFallbackCommandProps();
}
public void setFallbackCommandProps(FallbackCommandProps fallbackCommandProps) {
featuresProps.setFallbackCommandProps(fallbackCommandProps);
}
public ServerCheckerProps getServerCheckerProps() {
return featuresProps.getServerCheckerProps();
}
public void setServerCheckerProps(ServerCheckerProps serverCheckerProps) {
featuresProps.setServerCheckerProps(serverCheckerProps);
}
public KickHandlerProps getKickHandlerProps() {
return featuresProps.getKickHandlerProps();
}
public void setKickHandlerProps(KickHandlerProps kickHandlerProps) {
featuresProps.setKickHandlerProps(kickHandlerProps);
}
@Override
public String toString() {
return "SettingsHolder{" +
"generalProps=" + generalProps +
", messagesProps=" + messagesProps +
", featuresProps=" + featuresProps +
'}';
}
}

View File

@ -0,0 +1,65 @@
package com.jaimemartz.playerbalancer.settings.props;
import com.jaimemartz.playerbalancer.settings.props.features.BalancerProps;
import com.jaimemartz.playerbalancer.settings.props.features.FallbackCommandProps;
import com.jaimemartz.playerbalancer.settings.props.features.KickHandlerProps;
import com.jaimemartz.playerbalancer.settings.props.features.ServerCheckerProps;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class FeaturesProps {
@Setting(value = "balancer")
private BalancerProps balancerProps;
@Setting(value = "fallback-command")
private FallbackCommandProps fallbackCommandProps;
@Setting(value = "server-checker")
private ServerCheckerProps serverCheckerProps;
@Setting(value = "kick-handler")
private KickHandlerProps kickHandlerProps;
public BalancerProps getBalancerProps() {
return balancerProps;
}
public void setBalancerProps(BalancerProps balancerProps) {
this.balancerProps = balancerProps;
}
public FallbackCommandProps getFallbackCommandProps() {
return fallbackCommandProps;
}
public void setFallbackCommandProps(FallbackCommandProps fallbackCommandProps) {
this.fallbackCommandProps = fallbackCommandProps;
}
public ServerCheckerProps getServerCheckerProps() {
return serverCheckerProps;
}
public void setServerCheckerProps(ServerCheckerProps serverCheckerProps) {
this.serverCheckerProps = serverCheckerProps;
}
public KickHandlerProps getKickHandlerProps() {
return kickHandlerProps;
}
public void setKickHandlerProps(KickHandlerProps kickHandlerProps) {
this.kickHandlerProps = kickHandlerProps;
}
@Override
public String toString() {
return "FeaturesProps{" +
"balancerProps=" + balancerProps +
", fallbackCommandProps=" + fallbackCommandProps +
", serverCheckerProps=" + serverCheckerProps +
", kickHandlerProps=" + kickHandlerProps +
'}';
}
}

View File

@ -6,7 +6,7 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class GeneralProps {
@Setting
private boolean active;
private boolean enabled;
@Setting
private boolean silent;
@ -17,21 +17,18 @@ public class GeneralProps {
@Setting(value = "redis-bungee")
private boolean redisBungee;
@Setting(value = "assign-targets")
private boolean assignTargets;
@Setting(value = "fallback-principal")
private boolean fallbackPrincipal;
@Setting(value = "auto-refresh")
private boolean autoRefresh;
public boolean isActive() {
return active;
public boolean isEnabled() {
return enabled;
}
public void setActive(boolean active) {
this.active = active;
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public boolean isSilent() {
@ -58,14 +55,6 @@ public class GeneralProps {
this.redisBungee = redisBungee;
}
public boolean isAssignTargets() {
return assignTargets;
}
public void setAssignTargets(boolean assignTargets) {
this.assignTargets = assignTargets;
}
public boolean isFallbackPrincipal() {
return fallbackPrincipal;
}
@ -82,25 +71,13 @@ public class GeneralProps {
this.autoRefresh = autoRefresh;
}
public GeneralProps __defaults() {
this.active = false;
this.silent = false;
this.autoReload = true;
this.redisBungee = false;
this.assignTargets = false;
this.fallbackPrincipal = true;
this.autoRefresh = false;
return this;
}
@Override
public String toString() {
return "GeneralProps{" +
"active=" + active +
"enabled=" + enabled +
", silent=" + silent +
", autoReload=" + autoReload +
", redisBungee=" + redisBungee +
", assignTargets=" + assignTargets +
", fallbackPrincipal=" + fallbackPrincipal +
", autoRefresh=" + autoRefresh +
'}';

View File

@ -5,46 +5,33 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class MessagesProps {
@Setting("connecting-server")
@Setting(value = "connecting-server")
private String connectingMessage;
@Setting("connected-server")
@Setting(value = "connected-server")
private String connectedMessage;
@Setting("misc-failure")
@Setting(value = "misc-failure")
private String failureMessage;
@Setting("unknown-section")
@Setting(value = "unknown-section")
private String unknownSectionMessage;
@Setting("invalid-input")
@Setting(value = "invalid-input")
private String invalidInputMessage;
@Setting("unavailable-server")
@Setting(value = "unavailable-server")
private String unavailableServerMessage;
@Setting("player-kicked")
@Setting(value = "player-kicked")
private String kickMessage;
@Setting("player-bypass")
@Setting(value = "player-bypass")
private String bypassMessage;
@Setting("same-section")
@Setting(value = "same-section")
private String sameSectionMessage;
public MessagesProps __defaults() {
connectingMessage = "&aConnecting to a {section} server";
connectedMessage = "&aConnected to {server}";
failureMessage = "&cCould not find a server to get connected to";
unknownSectionMessage = "&aCould not find a section with that name";
invalidInputMessage = "&cThis is an invalid input type for this command";
unavailableServerMessage = "&cThis command cannot be executed on this server";
kickMessage = "&cYou have been kicked from &a{from} &cand you are being moved to &a{to}, reason: &a{reason}";
bypassMessage = "&cYou have not been moved because you have the playerbalancer.bypass permission";
sameSectionMessage = "&cYou are already connected to a server on this section!";
return this;
}
public String getConnectingMessage() {
return connectingMessage;
}

View File

@ -0,0 +1,65 @@
package com.jaimemartz.playerbalancer.settings.props.features;
import com.jaimemartz.playerbalancer.settings.props.shared.SectionProps;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import java.util.List;
import java.util.Map;
@ConfigSerializable
public class BalancerProps {
@Setting(value = "principal-section")
private String principalSectionName;
@Setting(value = "dummy-sections")
private List<String> dummySectionNames;
@Setting(value = "reiterative-sections")
private List<String> reiterativeSectionNames;
@Setting(value = "sections")
private Map<String, SectionProps> sectionProps;
public String getPrincipalSectionName() {
return principalSectionName;
}
public void setPrincipalSectionName(String principalSectionName) {
this.principalSectionName = principalSectionName;
}
public List<String> getDummySectionNames() {
return dummySectionNames;
}
public void setDummySectionNames(List<String> dummySectionNames) {
this.dummySectionNames = dummySectionNames;
}
public List<String> getReiterativeSectionNames() {
return reiterativeSectionNames;
}
public void setReiterativeSectionNames(List<String> reiterativeSectionNames) {
this.reiterativeSectionNames = reiterativeSectionNames;
}
public Map<String, SectionProps> getSectionProps() {
return sectionProps;
}
public void setSectionProps(Map<String, SectionProps> sectionProps) {
this.sectionProps = sectionProps;
}
@Override
public String toString() {
return "BalancerProps{" +
"principalSectionName='" + principalSectionName + '\'' +
", dummySectionNames=" + dummySectionNames +
", reiterativeSectionNames=" + reiterativeSectionNames +
", sectionProps=" + sectionProps +
'}';
}
}

View File

@ -1,24 +1,21 @@
package com.jaimemartz.playerbalancer.settings.props;
package com.jaimemartz.playerbalancer.settings.props.features;
import com.google.common.collect.ImmutableMap;
import com.jaimemartz.playerbalancer.settings.shared.CommandProps;
import com.jaimemartz.playerbalancer.settings.props.shared.CommandProps;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ConfigSerializable
public class FallbackCommandProps {
@Setting
private boolean active;
private boolean enabled;
@Setting
private CommandProps command;
@Setting("excluded-sections")
@Setting(value = "excluded-sections")
private List<String> excludedSections;
@Setting
@ -27,12 +24,12 @@ public class FallbackCommandProps {
@Setting
private Map<String, String> rules;
public boolean isActive() {
return active;
public boolean isEnabled() {
return enabled;
}
public void setActive(boolean active) {
this.active = active;
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public CommandProps getCommand() {
@ -67,22 +64,10 @@ public class FallbackCommandProps {
this.rules = rules;
}
public FallbackCommandProps __defaults() {
this.active = true;
this.command = new CommandProps();
command.setName("fallback");
command.setPermission("");
command.setAliases(Arrays.asList("lobby", "hub", "back"));
this.excludedSections = Collections.emptyList();
this.restrictive = true;
this.rules = ImmutableMap.of("section-from", "section-to");
return this;
}
@Override
public String toString() {
return "FallbackCommandProps{" +
"active=" + active +
"enabled=" + enabled +
", command=" + command +
", excludedSections=" + excludedSections +
", restrictive=" + restrictive +

View File

@ -1,18 +1,15 @@
package com.jaimemartz.playerbalancer.settings.props;
package com.jaimemartz.playerbalancer.settings.props.features;
import com.google.common.collect.ImmutableMap;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ConfigSerializable
public class KickHandlerProps {
@Setting
private boolean active;
private boolean enabled;
@Setting
private boolean inverted;
@ -35,12 +32,12 @@ public class KickHandlerProps {
@Setting(value = "debug-info")
private boolean debug;
public boolean isActive() {
return active;
public boolean isEnabled() {
return enabled;
}
public void setActive(boolean active) {
this.active = active;
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public boolean isInverted() {
@ -99,22 +96,10 @@ public class KickHandlerProps {
this.debug = debug;
}
public KickHandlerProps __defaults() {
this.active = true;
this.inverted = true;
this.reasons = Arrays.asList("Banned", "Hacks");
this.excludedSections = Collections.emptyList();
this.restricted = true;
this.forcePrincipal = false; //maybe stop using this
this.rules = ImmutableMap.of("section-from", "section-to");
this.debug = false;
return this;
}
@Override
public String toString() {
return "KickHandlerProps{" +
"active=" + active +
"enabled=" + enabled +
", inverted=" + inverted +
", reasons=" + reasons +
", excludedSections=" + excludedSections +

View File

@ -1,16 +1,15 @@
package com.jaimemartz.playerbalancer.settings.props;
package com.jaimemartz.playerbalancer.settings.props.features;
import com.jaimemartz.playerbalancer.ping.PingTactic;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import java.util.Arrays;
import java.util.List;
@ConfigSerializable
public class ServerCheckerProps {
@Setting
private boolean active;
private boolean enabled;
@Setting
private PingTactic tactic;
@ -27,12 +26,12 @@ public class ServerCheckerProps {
@Setting(value = "debug-info")
private boolean debug;
public boolean isActive() {
return active;
public boolean isEnabled() {
return enabled;
}
public void setActive(boolean active) {
this.active = active;
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public PingTactic getTactic() {
@ -74,26 +73,4 @@ public class ServerCheckerProps {
public void setDebug(boolean debug) {
this.debug = debug;
}
public ServerCheckerProps __defaults() {
this.active = true;
this.tactic = PingTactic.CUSTOM;
this.attempts = 5;
this.interval = 10000;
this.markerDescs = Arrays.asList("Server is not accessible", "Gamemode has already started");
this.debug = false;
return this;
}
@Override
public String toString() {
return "ServerCheckerProps{" +
"active=" + active +
", tactic=" + tactic +
", attempts=" + attempts +
", interval=" + interval +
", markerDescs=" + markerDescs +
", debug=" + debug +
'}';
}
}

View File

@ -1,4 +1,4 @@
package com.jaimemartz.playerbalancer.settings.shared;
package com.jaimemartz.playerbalancer.settings.props.shared;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;

View File

@ -1,4 +1,4 @@
package com.jaimemartz.playerbalancer.settings.shared;
package com.jaimemartz.playerbalancer.settings.props.shared;
import com.jaimemartz.playerbalancer.connection.ProviderType;
import ninja.leaping.configurate.objectmapping.Setting;
@ -8,43 +8,21 @@ import java.util.List;
@ConfigSerializable
public class SectionProps {
@Setting
private boolean principal; //TODO move this to other place
@Setting
private boolean dummy; //TODO move this to other place
@Setting
private ProviderType provider;
@Setting("parent")
@Setting(value = "parent")
private String parentName;
@Setting("servers")
@Setting(value = "servers")
private List<String> serverEntries;
@Setting
private CommandProps command;
@Setting("server")
@Setting(value = "server")
private String serverName;
public boolean isPrincipal() {
return principal;
}
public void setPrincipal(boolean principal) {
this.principal = principal;
}
public boolean isDummy() {
return dummy;
}
public void setDummy(boolean dummy) {
this.dummy = dummy;
}
public ProviderType getProvider() {
return provider;
}
@ -88,9 +66,7 @@ public class SectionProps {
@Override
public String toString() {
return "SectionProps{" +
"principal=" + principal +
", dummy=" + dummy +
", provider=" + provider +
"provider=" + provider +
", parentName='" + parentName + '\'' +
", serverEntries=" + serverEntries +
", command=" + command +

View File

@ -0,0 +1,174 @@
# LobbyBalancer Configuration (https://www.spigotmc.org/resources/10788/)
# Read the comments, they are a very important part of the configuration
# To get support send me a private message with a description of the problem and the config file
# To easily paste the config file (and other relevant files) use the command /balancer paste
general {
# IMPORTANT! Set this to true after configuring the plugin!
enabled=false
# When true, the plugin will check for new servers added to bungee
auto-refresh=false
# When true, the plugin will reload when you execute /greload
auto-reload=true
# When true, the plugin will get player counts from RedisBungee
redis-bungee=false
# When true, the plugin will print less messages while loading
silent=false
# Do not modify this
version: "${project.version}"
}
# Effectively remove (i.e comment) a message to disable it
# Supported variables are shown in the default messages
messages {
connected-server="&aConnected to {server}"
connecting-server="&aConnecting to a {section} server"
invalid-input="&cThis is an invalid input type for this command"
misc-failure="&cCould not find a server to get connected to"
player-bypass="&cYou have not been moved because you have the playerbalancer.bypass permission"
player-kicked="&cYou have been kicked from &a{from} &cand you are being moved to &a{to}, reason: &a{reason}"
same-section="&cYou are already connected to a server on this section!"
unavailable-server="&cThis command cannot be executed on this server"
unknown-section="&aCould not find a section with that name"
}
features {
balancer {
# The principal section is very important for other features
# Normally set this to the section that has your main lobbies
principal-section=test
# When a player is not in any section, the player will go to the principal section
# This affects both the fallback command and kick handler features
fallback-principal=true
# Dummy sections can have servers from other non-dummy sections
# When a player connects to a dummy section, nothing will happen
dummy-sections=[]
# Reiterative sections remember the server the player connected to previously
# The plugin will keep connecting the player to that server until changes
reiterative-sections=[]
sections {
auth-lobbies {
provider=RANDOM
servers=[
"Auth1",
"Auth2",
"Auth3"
]
}
general-lobbies {
parent="auth-lobbies"
provider=RANDOM
servers=[
"Lobby1",
"Lobby2",
"Lobby3"
]
}
skywars-lobbies {
parent="general-lobbies"
provider=LOWEST
servers=[
"SWLobby1",
"SWLobby2",
"SWLobby3"
]
}
skywars-games {
parent="skywars-lobbies"
provider=FILLER
servers=[
"SW_A1", "SW_A2", "SW_A3", "SW_A4", "SW_A5",
"SW_B1", "SW_B2", "SW_B3", "SW_B4", "SW_B5"
]
section-server=playskywars
section-command {
name=skywars
permission=""
aliases=[]
}
}
}
}
# Connects a player to the parent of current section the player is connected to
fallback-command {
enabled=true
command {
name=fallback
permission=""
aliases=[
lobby,
hub,
back
]
}
# Add sections here where you do not want this feature to work
excluded-sections=[]
# When true, players will not be able to get to a section
restrictive=true
# You can override the behavior with rules, overriding the parent section
# This will set the section to go when you come from the section specified
rules {
section-from=section-to
}
}
server-checker {
enabled=true
tactic=CUSTOM
attempts=5
debug-info=false
interval=10000
marker-descs=[
"Server is not accessible",
"Gamemode has already started"
]
}
# Connects a player to other section when kicked
kick-handler {
enabled=true
inverted=true
reasons=[]
force-principal=false
# Add sections here where you do not want this feature to work
excluded-sections=[]
restrictive=true
# When true, the plugin will print useful info when a player gets kicked
debug-info=false
# You can override the behavior with rules, overriding the parent section
# This will set the section to go when you come from the section specified
rules {
section-from=section-to
}
}
}