diff --git a/pom.xml b/pom.xml index ac79d331..a11bc97e 100644 --- a/pom.xml +++ b/pom.xml @@ -66,7 +66,7 @@ Xephi, sgdc3, DNx5, timvisee, games647, ljacqu - 1.9.4-R0.1-SNAPSHOT + 1.10-R0.1-SNAPSHOT diff --git a/src/main/java/fr/xephi/authme/permission/PermissionsManager.java b/src/main/java/fr/xephi/authme/permission/PermissionsManager.java index 4e1c4253..c4efc757 100644 --- a/src/main/java/fr/xephi/authme/permission/PermissionsManager.java +++ b/src/main/java/fr/xephi/authme/permission/PermissionsManager.java @@ -313,9 +313,14 @@ public class PermissionsManager { * False is also returned if this feature isn't supported for the current permissions system. */ public boolean addGroup(Player player, String groupName) { - // If no permissions system is used, return false - if (!isEnabled()) + if(groupName.isEmpty()) { return false; + } + + // If no permissions system is used, return false + if (!isEnabled()) { + return false; + } return handler.addToGroup(player, groupName); } diff --git a/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java b/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java index 59892c58..ee19a02d 100644 --- a/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java +++ b/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java @@ -83,7 +83,7 @@ public class AsynchronousJoin implements AsynchronousProcess { // Prevent player collisions in 1.9 if (DISABLE_COLLISIONS) { - ((LivingEntity) player).setCollidable(false); + player.setCollidable(false); } if (service.getProperty(RestrictionSettings.FORCE_SURVIVAL_MODE) @@ -133,6 +133,12 @@ public class AsynchronousJoin implements AsynchronousProcess { // TODO: continue cleanup from this -sgdc3 if (isAuthAvailable) { + // Registered + + // Groups logic + Utils.setGroup(player, GroupType.NOTLOGGEDIN); + + // Spawn logic if (!service.getProperty(RestrictionSettings.NO_TELEPORT)) { if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) { bukkitService.scheduleSyncDelayedTask(new Runnable() { @@ -149,9 +155,11 @@ public class AsynchronousJoin implements AsynchronousProcess { } } placePlayerSafely(player, spawnLoc); + + // Limbo cache limboCache.updateLimboPlayer(player); - // protect inventory + // Protect inventory if (service.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN) && plugin.inventoryProtector != null) { ProtectInventoryEvent ev = new ProtectInventoryEvent(player); plugin.getServer().getPluginManager().callEvent(ev); @@ -163,6 +171,7 @@ public class AsynchronousJoin implements AsynchronousProcess { } } + // Session logic if (service.getProperty(PluginSettings.SESSIONS_ENABLED) && (playerCache.isAuthenticated(name) || database.isLogged(name))) { if (plugin.sessions.containsKey(name)) { plugin.sessions.get(name).cancel(); @@ -180,13 +189,17 @@ public class AsynchronousJoin implements AsynchronousProcess { } } } else { - if (!Settings.unRegisteredGroup.isEmpty()) { - Utils.setGroup(player, Utils.GroupType.UNREGISTERED); - } + // Not Registered + + // Groups logic + Utils.setGroup(player, GroupType.UNREGISTERED); + + // Skip if registration is optional if (!service.getProperty(RegistrationSettings.FORCE)) { return; } + // Spawn logic if (!Settings.noTeleport && !needFirstSpawn(player) && Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) { bukkitService.scheduleSyncDelayedTask(new Runnable() { @@ -202,37 +215,33 @@ public class AsynchronousJoin implements AsynchronousProcess { }); } } + // The user is not logged in if (!limboCache.hasLimboPlayer(name)) { limboCache.addLimboPlayer(player); } - Utils.setGroup(player, isAuthAvailable ? GroupType.NOTLOGGEDIN : GroupType.UNREGISTERED); final int registrationTimeout = service.getProperty(RestrictionSettings.TIMEOUT) * 20; - bukkitService.scheduleSyncDelayedTask(new Runnable() { - @Override - public void run() { - player.setOp(false); - if (!service.getProperty(RestrictionSettings.ALLOW_UNAUTHED_MOVEMENT) - && service.getProperty(RestrictionSettings.REMOVE_SPEED)) { - player.setFlySpeed(0.0f); - player.setWalkSpeed(0.0f); - } - player.setNoDamageTicks(registrationTimeout); - if (pluginHooks.isEssentialsAvailable() && service.getProperty(HooksSettings.USE_ESSENTIALS_MOTD)) { - player.performCommand("motd"); - } - if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) { - // Allow infinite blindness effect - int blindTimeOut = (registrationTimeout <= 0) ? 99999 : registrationTimeout; - player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, blindTimeOut, 2)); - } - } + // Apply effects + // TODO: clenup! + player.setOp(false); + if (!service.getProperty(RestrictionSettings.ALLOW_UNAUTHED_MOVEMENT) + && service.getProperty(RestrictionSettings.REMOVE_SPEED)) { + player.setFlySpeed(0.0f); + player.setWalkSpeed(0.0f); + } + player.setNoDamageTicks(registrationTimeout); + if (pluginHooks.isEssentialsAvailable() && service.getProperty(HooksSettings.USE_ESSENTIALS_MOTD)) { + player.performCommand("motd"); + } + if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) { + // Allow infinite blindness effect + int blindTimeOut = (registrationTimeout <= 0) ? 99999 : registrationTimeout; + player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, blindTimeOut, 2)); + } - }); - - int msgInterval = service.getProperty(RegistrationSettings.MESSAGE_INTERVAL); + // Timeout task if (registrationTimeout > 0) { BukkitTask id = bukkitService.runTaskLater(new TimeoutTask(plugin, name, player), registrationTimeout); LimboPlayer limboPlayer = limboCache.getLimboPlayer(name); @@ -241,6 +250,8 @@ public class AsynchronousJoin implements AsynchronousProcess { } } + // Message task + int msgInterval = service.getProperty(RegistrationSettings.MESSAGE_INTERVAL); MessageKey msg; if (isAuthAvailable) { msg = MessageKey.LOGIN_MESSAGE; diff --git a/src/test/java/fr/xephi/authme/command/CommandConsistencyTest.java b/src/test/java/fr/xephi/authme/command/CommandConsistencyTest.java index 287b398a..d2033d1b 100644 --- a/src/test/java/fr/xephi/authme/command/CommandConsistencyTest.java +++ b/src/test/java/fr/xephi/authme/command/CommandConsistencyTest.java @@ -50,7 +50,6 @@ public class CommandConsistencyTest { * * @return collection of all base command labels */ - @SuppressWarnings("unchecked") private static Collection> initializeCommands() { CommandInitializer initializer = new CommandInitializer(); Collection> commandLabels = new ArrayList<>(); diff --git a/src/test/java/fr/xephi/authme/command/CommandHandlerTest.java b/src/test/java/fr/xephi/authme/command/CommandHandlerTest.java index ff3fd5a7..d831c85a 100644 --- a/src/test/java/fr/xephi/authme/command/CommandHandlerTest.java +++ b/src/test/java/fr/xephi/authme/command/CommandHandlerTest.java @@ -81,13 +81,13 @@ public class CommandHandlerTest { *

* The {@link CommandMapper} is mocked in {@link #initializeCommandMapper()} to return certain test classes. */ + @SuppressWarnings("unchecked") private void setInjectorToMockExecutableCommandClasses() { given(initializer.newInstance(any(Class.class))).willAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { Class clazz = (Class) invocation.getArguments()[0]; if (ExecutableCommand.class.isAssignableFrom(clazz)) { - @SuppressWarnings("unchecked") Class commandClass = (Class) clazz; ExecutableCommand mock = mock(commandClass); mockedCommands.put(commandClass, mock); diff --git a/src/test/java/fr/xephi/authme/command/CommandInitializerTest.java b/src/test/java/fr/xephi/authme/command/CommandInitializerTest.java index 97268e49..669f71d8 100644 --- a/src/test/java/fr/xephi/authme/command/CommandInitializerTest.java +++ b/src/test/java/fr/xephi/authme/command/CommandInitializerTest.java @@ -33,7 +33,6 @@ public class CommandInitializerTest { private static Set commands; - @SuppressWarnings("unchecked") @BeforeClass public static void initializeCommandCollection() { CommandInitializer commandInitializer = new CommandInitializer(); diff --git a/src/test/java/fr/xephi/authme/command/CommandMapperTest.java b/src/test/java/fr/xephi/authme/command/CommandMapperTest.java index 26e43ab0..28ee861f 100644 --- a/src/test/java/fr/xephi/authme/command/CommandMapperTest.java +++ b/src/test/java/fr/xephi/authme/command/CommandMapperTest.java @@ -280,6 +280,7 @@ public class CommandMapperTest { assertThat(result.getArguments(), contains(parts.get(2))); } + @SuppressWarnings("unchecked") @Test public void shouldReturnExecutableCommandClasses() { // given / when diff --git a/src/test/java/fr/xephi/authme/command/PlayerCommandTest.java b/src/test/java/fr/xephi/authme/command/PlayerCommandTest.java index f7641215..bc9e1929 100644 --- a/src/test/java/fr/xephi/authme/command/PlayerCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/PlayerCommandTest.java @@ -38,6 +38,7 @@ public class PlayerCommandTest { // given Player player = mock(Player.class); List arguments = Arrays.asList("arg1", "testarg2"); + @SuppressWarnings("unused") CommandService service = mock(CommandService.class); PlayerCommandImpl command = new PlayerCommandImpl(); diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/ReloadCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/ReloadCommandTest.java index 2371a500..48ed3f6f 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/ReloadCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/ReloadCommandTest.java @@ -85,6 +85,7 @@ public class ReloadCommandTest { public void shouldHandleReloadError() { // given CommandSender sender = mock(CommandSender.class); + @SuppressWarnings("unused") CommandService service = mock(CommandService.class); doThrow(IllegalStateException.class).when(initializer).performReloadOnServices(); given(settings.getProperty(DatabaseSettings.BACKEND)).willReturn(DataSourceType.MYSQL); @@ -104,6 +105,7 @@ public class ReloadCommandTest { public void shouldIssueWarningForChangedDatasourceSetting() { // given CommandSender sender = mock(CommandSender.class); + @SuppressWarnings("unused") CommandService service = mock(CommandService.class); given(settings.getProperty(DatabaseSettings.BACKEND)).willReturn(DataSourceType.MYSQL); given(dataSource.getType()).willReturn(DataSourceType.SQLITE);