mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-27 12:45:57 +01:00
Rename method on SettingsDependent
- Rename loadSettings to reload - Make ProtocolLibService only implement SettingsDependent, not Relaodable alongside
This commit is contained in:
parent
dff09935e6
commit
aa6fe3e874
@ -24,7 +24,7 @@ public class CaptchaManager implements SettingsDependent {
|
|||||||
CaptchaManager(NewSetting settings) {
|
CaptchaManager(NewSetting settings) {
|
||||||
this.playerCounts = new ConcurrentHashMap<>();
|
this.playerCounts = new ConcurrentHashMap<>();
|
||||||
this.captchaCodes = new ConcurrentHashMap<>();
|
this.captchaCodes = new ConcurrentHashMap<>();
|
||||||
loadSettings(settings);
|
reload(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -123,7 +123,7 @@ public class CaptchaManager implements SettingsDependent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadSettings(NewSetting settings) {
|
public void reload(NewSetting settings) {
|
||||||
this.isEnabled = settings.getProperty(SecuritySettings.USE_CAPTCHA);
|
this.isEnabled = settings.getProperty(SecuritySettings.USE_CAPTCHA);
|
||||||
this.threshold = settings.getProperty(SecuritySettings.MAX_LOGIN_TRIES_BEFORE_CAPTCHA);
|
this.threshold = settings.getProperty(SecuritySettings.MAX_LOGIN_TRIES_BEFORE_CAPTCHA);
|
||||||
this.captchaLength = settings.getProperty(SecuritySettings.CAPTCHA_LENGTH);
|
this.captchaLength = settings.getProperty(SecuritySettings.CAPTCHA_LENGTH);
|
||||||
|
@ -17,7 +17,7 @@ public class SessionManager implements SettingsDependent {
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
SessionManager(NewSetting settings) {
|
SessionManager(NewSetting settings) {
|
||||||
loadSettings(settings);
|
reload(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,7 +67,7 @@ public class SessionManager implements SettingsDependent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadSettings(NewSetting settings) {
|
public void reload(NewSetting settings) {
|
||||||
this.enabled = settings.getProperty(PluginSettings.SESSIONS_ENABLED);
|
this.enabled = settings.getProperty(PluginSettings.SESSIONS_ENABLED);
|
||||||
this.sessionTimeout = settings.getProperty(PluginSettings.SESSIONS_TIMEOUT);
|
this.sessionTimeout = settings.getProperty(PluginSettings.SESSIONS_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ public class TempbanManager implements SettingsDependent {
|
|||||||
this.ipLoginFailureCounts = new ConcurrentHashMap<>();
|
this.ipLoginFailureCounts = new ConcurrentHashMap<>();
|
||||||
this.bukkitService = bukkitService;
|
this.bukkitService = bukkitService;
|
||||||
this.messages = messages;
|
this.messages = messages;
|
||||||
loadSettings(settings);
|
reload(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,7 +108,7 @@ public class TempbanManager implements SettingsDependent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadSettings(NewSetting settings) {
|
public void reload(NewSetting settings) {
|
||||||
this.isEnabled = settings.getProperty(SecuritySettings.TEMPBAN_ON_MAX_LOGINS);
|
this.isEnabled = settings.getProperty(SecuritySettings.TEMPBAN_ON_MAX_LOGINS);
|
||||||
this.threshold = settings.getProperty(SecuritySettings.MAX_LOGIN_TEMPBAN);
|
this.threshold = settings.getProperty(SecuritySettings.MAX_LOGIN_TEMPBAN);
|
||||||
this.length = settings.getProperty(SecuritySettings.TEMPBAN_LENGTH);
|
this.length = settings.getProperty(SecuritySettings.TEMPBAN_LENGTH);
|
||||||
|
@ -50,7 +50,7 @@ public class HelpProvider implements SettingsDependent {
|
|||||||
@Inject
|
@Inject
|
||||||
HelpProvider(PermissionsManager permissionsManager, NewSetting settings) {
|
HelpProvider(PermissionsManager permissionsManager, NewSetting settings) {
|
||||||
this.permissionsManager = permissionsManager;
|
this.permissionsManager = permissionsManager;
|
||||||
loadSettings(settings);
|
reload(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> printHelp(CommandSender sender, FoundCommandResult result, int options) {
|
private List<String> printHelp(CommandSender sender, FoundCommandResult result, int options) {
|
||||||
@ -102,7 +102,7 @@ public class HelpProvider implements SettingsDependent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadSettings(NewSetting settings) {
|
public void reload(NewSetting settings) {
|
||||||
helpHeader = settings.getProperty(PluginSettings.HELP_HEADER);
|
helpHeader = settings.getProperty(PluginSettings.HELP_HEADER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ public class AuthMeServiceInitializer {
|
|||||||
}
|
}
|
||||||
for (Object object : objects.values()) {
|
for (Object object : objects.values()) {
|
||||||
if (object instanceof SettingsDependent) {
|
if (object instanceof SettingsDependent) {
|
||||||
((SettingsDependent) object).loadSettings(settings);
|
((SettingsDependent) object).reload(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (object instanceof Reloadable) {
|
if (object instanceof Reloadable) {
|
||||||
|
@ -8,9 +8,9 @@ import fr.xephi.authme.settings.NewSetting;
|
|||||||
public interface SettingsDependent {
|
public interface SettingsDependent {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the needed settings.
|
* Performs a reload with the provided settings instance.
|
||||||
*
|
*
|
||||||
* @param settings the settings instance
|
* @param settings the settings instance
|
||||||
*/
|
*/
|
||||||
void loadSettings(NewSetting settings);
|
void reload(NewSetting settings);
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ class ListenerService implements SettingsDependent {
|
|||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
this.pluginHooks = pluginHooks;
|
this.pluginHooks = pluginHooks;
|
||||||
this.playerCache = playerCache;
|
this.playerCache = playerCache;
|
||||||
loadSettings(settings);
|
reload(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,7 +74,7 @@ class ListenerService implements SettingsDependent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadSettings(NewSetting settings) {
|
public void reload(NewSetting settings) {
|
||||||
isRegistrationForced = settings.getProperty(RegistrationSettings.FORCE);
|
isRegistrationForced = settings.getProperty(RegistrationSettings.FORCE);
|
||||||
// Keep unrestricted names as Set for more efficient contains()
|
// Keep unrestricted names as Set for more efficient contains()
|
||||||
unrestrictedNames = new HashSet<>(settings.getProperty(RestrictionSettings.UNRESTRICTED_NAMES));
|
unrestrictedNames = new HashSet<>(settings.getProperty(RestrictionSettings.UNRESTRICTED_NAMES));
|
||||||
|
@ -3,7 +3,6 @@ package fr.xephi.authme.listener.protocollib;
|
|||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.initialization.Reloadable;
|
|
||||||
import fr.xephi.authme.initialization.SettingsDependent;
|
import fr.xephi.authme.initialization.SettingsDependent;
|
||||||
import fr.xephi.authme.settings.NewSetting;
|
import fr.xephi.authme.settings.NewSetting;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
@ -12,7 +11,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
public class ProtocolLibService implements SettingsDependent, Reloadable {
|
public class ProtocolLibService implements SettingsDependent {
|
||||||
|
|
||||||
/* Packet Adapters */
|
/* Packet Adapters */
|
||||||
private AuthMeInventoryPacketAdapter inventoryPacketAdapter;
|
private AuthMeInventoryPacketAdapter inventoryPacketAdapter;
|
||||||
@ -33,7 +32,7 @@ public class ProtocolLibService implements SettingsDependent, Reloadable {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.bukkitService = bukkitService;
|
this.bukkitService = bukkitService;
|
||||||
this.playerCache = playerCache;
|
this.playerCache = playerCache;
|
||||||
loadSettings(settings);
|
reload(settings);
|
||||||
setup();
|
setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +98,7 @@ public class ProtocolLibService implements SettingsDependent, Reloadable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadSettings(NewSetting settings) {
|
public void reload(NewSetting settings) {
|
||||||
boolean oldProtectInventory = this.protectInvBeforeLogin;
|
boolean oldProtectInventory = this.protectInvBeforeLogin;
|
||||||
|
|
||||||
this.protectInvBeforeLogin = settings.getProperty(RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN);
|
this.protectInvBeforeLogin = settings.getProperty(RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN);
|
||||||
@ -114,10 +113,7 @@ public class ProtocolLibService implements SettingsDependent, Reloadable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reload() {
|
|
||||||
setup();
|
setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public class Messages implements SettingsDependent {
|
|||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
Messages(NewSetting settings) {
|
Messages(NewSetting settings) {
|
||||||
loadSettings(settings);
|
reload(settings);
|
||||||
this.defaultFile = settings.getDefaultMessagesFile();
|
this.defaultFile = settings.getDefaultMessagesFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ public class Messages implements SettingsDependent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadSettings(NewSetting settings) {
|
public void reload(NewSetting settings) {
|
||||||
File messageFile = settings.getMessagesFile();
|
File messageFile = settings.getMessagesFile();
|
||||||
this.configuration = YamlConfiguration.loadConfiguration(messageFile);
|
this.configuration = YamlConfiguration.loadConfiguration(messageFile);
|
||||||
this.fileName = messageFile.getName();
|
this.fileName = messageFile.getName();
|
||||||
|
@ -137,7 +137,7 @@ public class CaptchaManagerTest {
|
|||||||
assertThat(manager.isCaptchaRequired(player), equalTo(true));
|
assertThat(manager.isCaptchaRequired(player), equalTo(true));
|
||||||
assertHasCount(manager, player, 1);
|
assertHasCount(manager, player, 1);
|
||||||
// end assumptions
|
// end assumptions
|
||||||
manager.loadSettings(settings);
|
manager.reload(settings);
|
||||||
boolean result = manager.isCaptchaRequired(player);
|
boolean result = manager.isCaptchaRequired(player);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
|
@ -114,7 +114,7 @@ public class TempbanManagerTest {
|
|||||||
assertThat(manager.shouldTempban(address), equalTo(true));
|
assertThat(manager.shouldTempban(address), equalTo(true));
|
||||||
assertHasCount(manager, address, 1);
|
assertHasCount(manager, address, 1);
|
||||||
// end assumptions
|
// end assumptions
|
||||||
manager.loadSettings(settings);
|
manager.reload(settings);
|
||||||
boolean result = manager.shouldTempban(address);
|
boolean result = manager.shouldTempban(address);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
|
@ -33,7 +33,7 @@ public class PostConstructTestClass implements SettingsDependent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadSettings(NewSetting settings) {
|
public void reload(NewSetting settings) {
|
||||||
if (settings != null) {
|
if (settings != null) {
|
||||||
wasReloaded = true;
|
wasReloaded = true;
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ public class ListenerServiceTest {
|
|||||||
given(settings.getProperty(RegistrationSettings.FORCE)).willReturn(false);
|
given(settings.getProperty(RegistrationSettings.FORCE)).willReturn(false);
|
||||||
EntityEvent event = mock(EntityEvent.class);
|
EntityEvent event = mock(EntityEvent.class);
|
||||||
given(event.getEntity()).willReturn(player);
|
given(event.getEntity()).willReturn(player);
|
||||||
listenerService.loadSettings(settings);
|
listenerService.reload(settings);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
boolean result = listenerService.shouldCancelEvent(event);
|
boolean result = listenerService.shouldCancelEvent(event);
|
||||||
|
@ -259,7 +259,7 @@ public class MessagesIntegrationTest {
|
|||||||
TestHelper.PROJECT_ROOT + "output/messages_test2.yml"));
|
TestHelper.PROJECT_ROOT + "output/messages_test2.yml"));
|
||||||
|
|
||||||
// when
|
// when
|
||||||
messages.loadSettings(settings);
|
messages.reload(settings);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(messages.retrieveSingle(key), equalTo("test2 - wrong password"));
|
assertThat(messages.retrieveSingle(key), equalTo("test2 - wrong password"));
|
||||||
|
Loading…
Reference in New Issue
Block a user