1
0
mirror of https://github.com/AuthMe/AuthMeReloaded.git synced 2025-04-03 10:35:50 +02:00

1.10 API + cleanup

This commit is contained in:
Gabriele C 2016-06-11 17:46:24 +02:00
parent 2e269b6f5e
commit 01f297919d
9 changed files with 52 additions and 34 deletions

View File

@ -66,7 +66,7 @@
<bukkitplugin.authors>Xephi, sgdc3, DNx5, timvisee, games647, ljacqu</bukkitplugin.authors>
<!-- Change Bukkit Version HERE! -->
<bukkit.version>1.9.4-R0.1-SNAPSHOT</bukkit.version>
<bukkit.version>1.10-R0.1-SNAPSHOT</bukkit.version>
</properties>
<!-- Jenkins profile (add the real buildNumber to the version string) -->

View File

@ -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);
}

View File

@ -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;

View File

@ -50,7 +50,6 @@ public class CommandConsistencyTest {
*
* @return collection of all base command labels
*/
@SuppressWarnings("unchecked")
private static Collection<List<String>> initializeCommands() {
CommandInitializer initializer = new CommandInitializer();
Collection<List<String>> commandLabels = new ArrayList<>();

View File

@ -81,13 +81,13 @@ public class CommandHandlerTest {
* <p>
* 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<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Class<?> clazz = (Class<?>) invocation.getArguments()[0];
if (ExecutableCommand.class.isAssignableFrom(clazz)) {
@SuppressWarnings("unchecked")
Class<? extends ExecutableCommand> commandClass = (Class<? extends ExecutableCommand>) clazz;
ExecutableCommand mock = mock(commandClass);
mockedCommands.put(commandClass, mock);

View File

@ -33,7 +33,6 @@ public class CommandInitializerTest {
private static Set<CommandDescription> commands;
@SuppressWarnings("unchecked")
@BeforeClass
public static void initializeCommandCollection() {
CommandInitializer commandInitializer = new CommandInitializer();

View File

@ -280,6 +280,7 @@ public class CommandMapperTest {
assertThat(result.getArguments(), contains(parts.get(2)));
}
@SuppressWarnings("unchecked")
@Test
public void shouldReturnExecutableCommandClasses() {
// given / when

View File

@ -38,6 +38,7 @@ public class PlayerCommandTest {
// given
Player player = mock(Player.class);
List<String> arguments = Arrays.asList("arg1", "testarg2");
@SuppressWarnings("unused")
CommandService service = mock(CommandService.class);
PlayerCommandImpl command = new PlayerCommandImpl();

View File

@ -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);