diff --git a/src/main/java/fr/xephi/authme/listener/ServerListener.java b/src/main/java/fr/xephi/authme/listener/ServerListener.java index f424fc37f..83898bdc6 100644 --- a/src/main/java/fr/xephi/authme/listener/ServerListener.java +++ b/src/main/java/fr/xephi/authme/listener/ServerListener.java @@ -41,7 +41,7 @@ public class ServerListener implements Listener { pluginHookService.unhookEssentials(); ConsoleLogger.info("Essentials has been disabled: unhooking"); } else if ("CMI".equalsIgnoreCase(pluginName)) { - pluginHookService.unhookCMI(); + pluginHookService.unhookCmi(); spawnLoader.unloadCMISpawn(); ConsoleLogger.info("CMI has been disabled: unhooking"); } else if ("Multiverse-Core".equalsIgnoreCase(pluginName)) { @@ -75,7 +75,7 @@ public class ServerListener implements Listener { } else if ("EssentialsSpawn".equalsIgnoreCase(pluginName)) { spawnLoader.loadEssentialsSpawn(); } else if ("CMI".equalsIgnoreCase(pluginName)) { - pluginHookService.tryHookToCMI(); + pluginHookService.tryHookToCmi(); spawnLoader.loadCMISpawn(); } else if ("ProtocolLib".equalsIgnoreCase(pluginName)) { protocolLibService.setup(); diff --git a/src/main/java/fr/xephi/authme/service/PluginHookService.java b/src/main/java/fr/xephi/authme/service/PluginHookService.java index 0ae10a7c1..0a204aa0e 100644 --- a/src/main/java/fr/xephi/authme/service/PluginHookService.java +++ b/src/main/java/fr/xephi/authme/service/PluginHookService.java @@ -34,7 +34,7 @@ public class PluginHookService { public PluginHookService(PluginManager pluginManager) { this.pluginManager = pluginManager; tryHookToEssentials(); - tryHookToCMI(); + tryHookToCmi(); tryHookToMultiverse(); } @@ -67,7 +67,7 @@ public class PluginHookService { * * @return The CMI data folder, or null if unavailable */ - public File getCMIDataFolder() { + public File getCmiDataFolder() { Plugin plugin = pluginManager.getPlugin("CMI"); if(plugin == null) { return null; @@ -105,7 +105,7 @@ public class PluginHookService { /** * @return true if we have a hook to CMI, false otherwise */ - public boolean isCMIAvailable() { + public boolean isCmiAvailable() { return cmi != null; } @@ -134,7 +134,7 @@ public class PluginHookService { /** * Attempts to create a hook into CMI. */ - public void tryHookToCMI() { + public void tryHookToCmi() { try { cmi = getPlugin(pluginManager, "CMI", Plugin.class); } catch (Exception | NoClassDefFoundError ignored) { @@ -167,7 +167,7 @@ public class PluginHookService { /** * Unhooks from CMI. */ - public void unhookCMI() { + public void unhookCmi() { cmi = null; } diff --git a/src/main/java/fr/xephi/authme/settings/SpawnLoader.java b/src/main/java/fr/xephi/authme/settings/SpawnLoader.java index f64c68488..93d1f57f3 100644 --- a/src/main/java/fr/xephi/authme/settings/SpawnLoader.java +++ b/src/main/java/fr/xephi/authme/settings/SpawnLoader.java @@ -135,7 +135,7 @@ public class SpawnLoader implements Reloadable { * Load the spawn point defined in CMI. */ public void loadCMISpawn() { - File cmiFolder = pluginHookService.getCMIDataFolder(); + File cmiFolder = pluginHookService.getCmiDataFolder(); if (cmiFolder == null) { return; } diff --git a/src/test/java/fr/xephi/authme/listener/ServerListenerTest.java b/src/test/java/fr/xephi/authme/listener/ServerListenerTest.java index 29b484ad5..8cfdf03ef 100644 --- a/src/test/java/fr/xephi/authme/listener/ServerListenerTest.java +++ b/src/test/java/fr/xephi/authme/listener/ServerListenerTest.java @@ -60,7 +60,7 @@ public class ServerListenerTest { checkEnableHandling(ESSENTIALS, () -> verify(pluginHookService).tryHookToEssentials()); checkEnableHandling(ESSENTIALS_SPAWN, () -> verify(spawnLoader).loadEssentialsSpawn()); checkEnableHandling(CMI, () -> { - verify(pluginHookService).tryHookToCMI(); + verify(pluginHookService).tryHookToCmi(); verify(spawnLoader).loadCMISpawn(); }); checkEnableHandling(MULTIVERSE, () -> verify(pluginHookService).tryHookToMultiverse()); @@ -73,7 +73,7 @@ public class ServerListenerTest { checkDisableHandling(ESSENTIALS, () -> verify(pluginHookService).unhookEssentials()); checkDisableHandling(ESSENTIALS_SPAWN, () -> verify(spawnLoader).unloadEssentialsSpawn()); checkDisableHandling(CMI, () -> { - verify(pluginHookService).unhookCMI(); + verify(pluginHookService).unhookCmi(); verify(spawnLoader).unloadCMISpawn(); }); checkDisableHandling(MULTIVERSE, () -> verify(pluginHookService).unhookMultiverse()); diff --git a/src/test/java/fr/xephi/authme/service/PluginHookServiceTest.java b/src/test/java/fr/xephi/authme/service/PluginHookServiceTest.java index 763e6b312..d949db7dd 100644 --- a/src/test/java/fr/xephi/authme/service/PluginHookServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/PluginHookServiceTest.java @@ -35,6 +35,8 @@ public class PluginHookServiceTest { /** The plugin name of Essentials. */ private static final String ESSENTIALS = "Essentials"; + /** The plugin name of CMI. */ + private static final String CMI = "CMI"; /** The plugin name of Multiverse-Core. */ private static final String MULTIVERSE = "Multiverse-Core"; @@ -71,6 +73,19 @@ public class PluginHookServiceTest { assertThat(pluginHookService.isEssentialsAvailable(), equalTo(true)); } + @Test + public void shouldHookIntoCmiAtInitialization() { + // given + PluginManager pluginManager = mock(PluginManager.class); + setPluginAvailable(pluginManager, CMI, Plugin.class); + + // when + PluginHookService pluginHookService = new PluginHookService(pluginManager); + + // then + assertThat(pluginHookService.isCmiAvailable(), equalTo(true)); + } + @Test public void shouldHookIntoMultiverseAtInitialization() { // given @@ -175,6 +190,7 @@ public class PluginHookServiceTest { // then assertThat(pluginHookService.isEssentialsAvailable(), equalTo(false)); + assertThat(pluginHookService.isCmiAvailable(), equalTo(false)); assertThat(pluginHookService.isMultiverseAvailable(), equalTo(false)); }