mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-30 10:47:33 +02:00
Moved config value checking
Previously the value for "autoLoginFloodgate" and "autoRegisterFloodgate" was checked every time a player joined. Now they are checked at startup.
This commit is contained in:
@ -59,6 +59,13 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
|
|||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check Floodgate config values
|
||||||
|
if (!isValidFloodgateConfigString("autoLoginFloodgate")
|
||||||
|
|| !isValidFloodgateConfigString("allowFloodgateNameConflict")) {
|
||||||
|
setEnabled(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
bungeeManager = new BungeeManager(this);
|
bungeeManager = new BungeeManager(this);
|
||||||
bungeeManager.initialize();
|
bungeeManager.initialize();
|
||||||
@ -206,4 +213,28 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin<Comman
|
|||||||
public void sendMessage(CommandSender receiver, String message) {
|
public void sendMessage(CommandSender receiver, String message) {
|
||||||
receiver.sendMessage(message);
|
receiver.sendMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a config entry (related to Floodgate) is valid. <br>
|
||||||
|
* Writes to Log if the value is invalid.
|
||||||
|
* <p>
|
||||||
|
* This should be used for:
|
||||||
|
* <ul>
|
||||||
|
* <li>allowFloodgateNameConflict
|
||||||
|
* <li>autoLoginFloodgate
|
||||||
|
* </ul>
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param key the key of the entry in config.yml
|
||||||
|
* @return <b>true</b> if the entry's value is "true", "false", or "linked"
|
||||||
|
*/
|
||||||
|
private boolean isValidFloodgateConfigString(String key) {
|
||||||
|
String value = core.getConfig().getString(key);
|
||||||
|
if (!value.equalsIgnoreCase("true") && !value.equalsIgnoreCase("linked") && !value.equalsIgnoreCase("false")) {
|
||||||
|
logger.error("Invalid value detected for {} in FastLogin/config.yml.", key);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,12 +44,6 @@ public class FloodgateAuthTask implements Runnable {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!isValidConfigValue(allowNameConflict)) {
|
|
||||||
plugin.getLog().error(
|
|
||||||
"Invalid value detected for 'allowFloodgateNameConflict' in FasttLogin/config.yml. Aborting login of Player {}",
|
|
||||||
player.getName());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
AuthPlugin<Player> authPlugin = plugin.getCore().getAuthPluginHook();
|
AuthPlugin<Player> authPlugin = plugin.getCore().getAuthPluginHook();
|
||||||
|
|
||||||
@ -88,17 +82,5 @@ public class FloodgateAuthTask implements Runnable {
|
|||||||
Runnable forceLoginTask = new ForceLoginTask(plugin.getCore(), player, session);
|
Runnable forceLoginTask = new ForceLoginTask(plugin.getCore(), player, session);
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, forceLoginTask);
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, forceLoginTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a string is a valid configuration option for
|
|
||||||
* 'allowFloodgateNameConflict' or 'autoLoginFloodgate'
|
|
||||||
*
|
|
||||||
* @param value The value of 'allowFloodgateNameConflict' or
|
|
||||||
* 'autoLoginFloodgate' from config.yml
|
|
||||||
* @return true if value is "true", "false", or "linked"
|
|
||||||
*/
|
|
||||||
boolean isValidConfigValue(String value) {
|
|
||||||
return value.equalsIgnoreCase("true") || value.equalsIgnoreCase("linked") || value.equalsIgnoreCase("false");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user