Added more comments to the configuration and command rename (Didn't like it)

This commit is contained in:
Jaime Martinez Rincon 2017-01-14 02:19:06 +01:00
parent 1e4f0df968
commit 355bbcf180
5 changed files with 46 additions and 26 deletions

View File

@ -6,7 +6,7 @@
<groupId>me.jaimemartz</groupId>
<artifactId>lobbybalancer</artifactId>
<version>2.0.2</version>
<version>2.0.3</version>
<name>LobbyBalancer</name>
<repositories>

View File

@ -3,8 +3,8 @@ package me.jaimemartz.lobbybalancer;
import com.google.gson.Gson;
import com.imaginarycode.minecraft.redisbungee.RedisBungee;
import me.jaimemartz.faucet.ConfigFactory;
import me.jaimemartz.lobbybalancer.commands.FallbackCommand;
import me.jaimemartz.lobbybalancer.commands.MainCommand;
import me.jaimemartz.lobbybalancer.commands.RegressCommand;
import me.jaimemartz.lobbybalancer.configuration.ConfigEntries;
import me.jaimemartz.lobbybalancer.connection.ServerAssignRegistry;
import me.jaimemartz.lobbybalancer.listener.*;
@ -29,7 +29,7 @@ public class LobbyBalancer extends Plugin {
public static final String USER_ID = "%%__USER__%%";
public static final String RESOURCE_ID = "%%__RESOURCE__%%";
public static final String NONCE_ID = "%%__NONCE__%%";
private static final int LAST_VER_CONFIG_UPDATE = 20200;
private static final int LAST_VER_CONFIG_UPDATE = 20300;
private final Gson gson = new Gson();
private boolean failed = false;
@ -37,7 +37,7 @@ public class LobbyBalancer extends Plugin {
private ConfigFactory factory;
private PingManager pingManager;
private SectionManager sectionManager;
private Command regressCommand, mainCommand;
private Command fallbackCommand, mainCommand;
private GeolocationManager geolocationManager;
private Listener connectListener, kickListener, messageListener, reloadListener;
@ -91,9 +91,9 @@ public class LobbyBalancer extends Plugin {
pingManager.start();
}
if (ConfigEntries.REGRESS_COMMAND_ENABLED.get()) {
regressCommand = new RegressCommand(this);
getProxy().getPluginManager().registerCommand(this, regressCommand);
if (ConfigEntries.FALLBACK_COMMAND_ENABLED.get()) {
fallbackCommand = new FallbackCommand(this);
getProxy().getPluginManager().registerCommand(this, fallbackCommand);
}
connectListener = new ServerConnectListener(this);
@ -153,9 +153,9 @@ public class LobbyBalancer extends Plugin {
pingManager.stop();
}
if (ConfigEntries.REGRESS_COMMAND_ENABLED.get()) {
getProxy().getPluginManager().unregisterCommand(regressCommand);
regressCommand = null;
if (ConfigEntries.FALLBACK_COMMAND_ENABLED.get()) {
getProxy().getPluginManager().unregisterCommand(fallbackCommand);
fallbackCommand = null;
}
getProxy().getPluginManager().unregisterListener(connectListener);

View File

@ -15,11 +15,11 @@ import net.md_5.bungee.config.Configuration;
import java.util.concurrent.Callable;
public class RegressCommand extends Command {
public class FallbackCommand extends Command {
private final LobbyBalancer plugin;
public RegressCommand(LobbyBalancer plugin) {
super(ConfigEntries.REGRESS_COMMAND_NAME.get(), ConfigEntries.REGRESS_COMMAND_PERMISSION.get(), (ConfigEntries.REGRESS_COMMAND_ALIASES.get().stream()).toArray(String[]::new));
public FallbackCommand(LobbyBalancer plugin) {
super(ConfigEntries.FALLBACK_COMMAND_NAME.get(), ConfigEntries.FALLBACK_COMMAND_PERMISSION.get(), (ConfigEntries.FALLBACK_COMMAND_ALIASES.get().stream()).toArray(String[]::new));
this.plugin = plugin;
}
@ -32,13 +32,13 @@ public class RegressCommand extends Command {
Callable<ServerSection> task = () -> {
if (section != null) {
if ((ConfigEntries.REGRESS_COMMAND_IGNORED_SECTIONS.get()).contains(section.getName())) {
if ((ConfigEntries.FALLBACK_COMMAND_IGNORED_SECTIONS.get()).contains(section.getName())) {
msgr.send(ConfigEntries.UNAVAILABLE_MESSAGE.get());
}
PlayerLocker.lock(player);
if (ConfigEntries.REGRESS_COMMAND_ARGUMENTS.get() && args.length == 1) {
if (ConfigEntries.FALLBACK_COMMAND_ARGUMENTS.get() && args.length == 1) {
ServerSection target = plugin.getSectionManager().getByName(args[0]);
if (target == null) {

View File

@ -29,12 +29,12 @@ public class ConfigEntries implements ConfigEntryHolder {
public static final ConfigEntry<List<String>> RECONNECT_KICK_IGNORED_SECTIONS = new ConfigEntry<>(0, "settings.reconnect-kick.ignored", Collections.emptyList());
public static final ConfigEntry<String> RECONNECT_KICK_MESSAGE = new ConfigEntry<>(0, "settings.reconnect-kick.message", "&cYou have been kicked from &a{from} &cand you are being moved to &a{to}&c, reason: &a{reason}");
public static final ConfigEntry<Boolean> REGRESS_COMMAND_ENABLED = new ConfigEntry<>(0, "settings.regress-command.enabled", true);
public static final ConfigEntry<String> REGRESS_COMMAND_NAME = new ConfigEntry<>(0, "settings.regress-command.name", "backward");
public static final ConfigEntry<List<String>> REGRESS_COMMAND_ALIASES = new ConfigEntry<>(0, "settings.regress-command.aliases", Arrays.asList("lobby", "hub", "back"));
public static final ConfigEntry<String> REGRESS_COMMAND_PERMISSION = new ConfigEntry<>(0, "settings.regress-command.permission", "");
public static final ConfigEntry<List<String>> REGRESS_COMMAND_IGNORED_SECTIONS = new ConfigEntry<>(0, "settings.regress-command.ignored", Collections.emptyList());
public static final ConfigEntry<Boolean> REGRESS_COMMAND_ARGUMENTS = new ConfigEntry<>(0, "settings.regress-command.arguments", true);
public static final ConfigEntry<Boolean> FALLBACK_COMMAND_ENABLED = new ConfigEntry<>(0, "settings.fallback-command.enabled", true);
public static final ConfigEntry<String> FALLBACK_COMMAND_NAME = new ConfigEntry<>(0, "settings.fallback-command.name", "fallback");
public static final ConfigEntry<List<String>> FALLBACK_COMMAND_ALIASES = new ConfigEntry<>(0, "settings.fallback-command.aliases", Arrays.asList("lobby", "hub", "back"));
public static final ConfigEntry<String> FALLBACK_COMMAND_PERMISSION = new ConfigEntry<>(0, "settings.fallback-command.permission", "");
public static final ConfigEntry<List<String>> FALLBACK_COMMAND_IGNORED_SECTIONS = new ConfigEntry<>(0, "settings.fallback-command.ignored", Collections.emptyList());
public static final ConfigEntry<Boolean> FALLBACK_COMMAND_ARGUMENTS = new ConfigEntry<>(0, "settings.fallback-command.arguments", true);
public static final ConfigEntry<Boolean> AUTO_RELOAD_ENABLED = new ConfigEntry<>(0, "settings.auto-reload", true);
public static final ConfigEntry<Boolean> REDIS_BUNGEE_ENABLED = new ConfigEntry<>(0, "settings.redis-bungee", false);

View File

@ -1,3 +1,9 @@
# 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
# Remember to set enabled under settings to true
# Providers of this plugin
# NONE: Returns no server
# DIRECT: Returns the only server in the list
@ -39,6 +45,7 @@ settings:
# This will connect the player to a server of the parent of the section the player is kicked from
reconnect-kick:
# If this is enabled the kick reasons must still match for this to work
enabled: true
# If enabled, the reasons will work as a blacklist instead of a whitelist
@ -60,11 +67,17 @@ settings:
rules: {}
# This will connect the player to a server of the parent of the section the player is currently on
regress-command:
fallback-command:
# If this is disabled the command will not be registered
enabled: true
name: 'backward'
# The name of the command, make sure it does not interfere with other commands
name: 'fallback'
# The aliases of the command, make sure it does not interfere with other commands
aliases: ['lobby', 'hub', 'back']
# Leave this empty for no permission
permission: ''
# Sections where this command is ignored
@ -77,14 +90,17 @@ settings:
rules: {}
# This gets the country of a player and decides to which server the player should go
# Country codes: http://dev.maxmind.com/geoip/legacy/codes/iso3166/
# WARNING: In testing stage
geolocation:
# If disabled the localized provider will choose a random server
enabled: false
# This prints info every time the plugin checks the country of a player (while being used)
print-info: true
# The rules for the LOCALIZED provider, every section using it has to have a rule
# The rules for the localized provider, every section using it has to have a rule
# The country must be the code as specified in the link above
rules:
practice:
'EUPractice': ["Country1", "Country2"]
@ -93,13 +109,15 @@ settings:
# This will reload the plugin every time you execute /greload
auto-reload: true
# Support for getting the players on a server with RedisBungee
# Support for getting the players connected to a server with RedisBungee
redis-bungee: false
# Assign a target to a player instead of looking every time for one
# This is reset every time the player disconnects
assign-targets: false
# When a player is not in any section, the player will go to the principal section
# This affects both the fallback command and reconnect kick features
fallback-principal: true
messages:
@ -151,4 +169,6 @@ sections:
name: 'practice'
permission: ''
aliases: ["rektnoobs"]
# Do not modify this
version: '${project.version}'