mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-03 09:10:01 +01:00
Fix issues aka "I should go to sleep" + fix unit tests
This commit is contained in:
parent
e2d20caf16
commit
b892b8e3a8
@ -184,7 +184,7 @@ class OnJoinVerifier implements Reloadable {
|
||||
}
|
||||
|
||||
Player onlinePlayer = bukkitService.getPlayerExact(name);
|
||||
if (onlinePlayer != null && onlinePlayer.isOnline()) {
|
||||
if (onlinePlayer != null) {
|
||||
throw new FailedVerificationException(MessageKey.USERNAME_ALREADY_ONLINE_ERROR);
|
||||
}
|
||||
}
|
||||
|
@ -202,31 +202,6 @@ public class PlayerListener implements Listener {
|
||||
management.performJoin(player);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onAsyncPreLogin(AsyncPlayerPreLoginEvent event) {
|
||||
|
||||
// Spigot only
|
||||
try {
|
||||
Class.forName("org.spigotmc.CustomTimingsHandler");
|
||||
} catch(Exception e) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(event.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String name = event.getName();
|
||||
|
||||
try {
|
||||
onJoinVerifier.checkSingleSession(name);
|
||||
} catch (FailedVerificationException e) {
|
||||
event.setKickMessage(m.retrieveSingle(e.getReason(), e.getArgs()));
|
||||
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
|
@ -31,7 +31,7 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Arrays;
|
||||
import java.util.logging.Level;
|
||||
|
||||
class AuthMeInventoryPacketAdapter extends PacketAdapter {
|
||||
class InventoryPacketAdapter extends PacketAdapter {
|
||||
|
||||
private static final int PLAYER_INVENTORY = 0;
|
||||
// http://wiki.vg/Inventory#Inventory (0-4 crafting, 5-8 armor, 9-35 main inventory, 36-44 hotbar, 45 off hand)
|
||||
@ -41,7 +41,7 @@ class AuthMeInventoryPacketAdapter extends PacketAdapter {
|
||||
private static final int MAIN_SIZE = 27;
|
||||
private static final int HOTBAR_SIZE = 9;
|
||||
|
||||
public AuthMeInventoryPacketAdapter(AuthMe plugin) {
|
||||
public InventoryPacketAdapter(AuthMe plugin) {
|
||||
super(plugin, PacketType.Play.Server.SET_SLOT, PacketType.Play.Server.WINDOW_ITEMS);
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ import javax.inject.Inject;
|
||||
public class ProtocolLibService implements SettingsDependent {
|
||||
|
||||
/* Packet Adapters */
|
||||
private AuthMeInventoryPacketAdapter inventoryPacketAdapter;
|
||||
private AuthMeTabCompletePacketAdapter tabCompletePacketAdapter;
|
||||
private InventoryPacketAdapter inventoryPacketAdapter;
|
||||
private TabCompletePacketAdapter tabCompletePacketAdapter;
|
||||
|
||||
/* Settings */
|
||||
private boolean protectInvBeforeLogin;
|
||||
@ -57,14 +57,14 @@ public class ProtocolLibService implements SettingsDependent {
|
||||
|
||||
// Set up packet adapters
|
||||
if (protectInvBeforeLogin && inventoryPacketAdapter == null) {
|
||||
inventoryPacketAdapter = new AuthMeInventoryPacketAdapter(plugin);
|
||||
inventoryPacketAdapter = new InventoryPacketAdapter(plugin);
|
||||
inventoryPacketAdapter.register();
|
||||
} else if (inventoryPacketAdapter != null) {
|
||||
inventoryPacketAdapter.unregister();
|
||||
inventoryPacketAdapter = null;
|
||||
}
|
||||
if (denyTabCompleteBeforeLogin && tabCompletePacketAdapter == null) {
|
||||
tabCompletePacketAdapter = new AuthMeTabCompletePacketAdapter(plugin);
|
||||
tabCompletePacketAdapter = new TabCompletePacketAdapter(plugin);
|
||||
tabCompletePacketAdapter.register();
|
||||
} else if (tabCompletePacketAdapter != null) {
|
||||
tabCompletePacketAdapter.unregister();
|
||||
|
@ -10,9 +10,9 @@ import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
|
||||
class AuthMeTabCompletePacketAdapter extends PacketAdapter {
|
||||
class TabCompletePacketAdapter extends PacketAdapter {
|
||||
|
||||
public AuthMeTabCompletePacketAdapter(AuthMe plugin) {
|
||||
public TabCompletePacketAdapter(AuthMe plugin) {
|
||||
super(plugin, ListenerPriority.NORMAL, PacketType.Play.Client.TAB_COMPLETE);
|
||||
}
|
||||
|
@ -32,11 +32,11 @@ public final class ListenerConsistencyTest {
|
||||
PlayerListener.class, PlayerListener16.class, PlayerListener18.class,
|
||||
ServerListener.class };
|
||||
|
||||
private static final Set<String> CANCELED_EXCEPTIONS = Sets.newHashSet("AuthMePlayerListener#onPlayerJoin",
|
||||
"AuthMePlayerListener#onPreLogin", "AuthMePlayerListener#onPlayerLogin",
|
||||
"AuthMePlayerListener#onPlayerQuit", "AuthMeServerListener#onPluginDisable",
|
||||
"AuthMeServerListener#onServerPing", "AuthMeServerListener#onPluginEnable",
|
||||
"AuthMePlayerListener#onJoinMessage", "AuthMePlayerListener#onLoginSingleSession");
|
||||
private static final Set<String> CANCELED_EXCEPTIONS = Sets.newHashSet(
|
||||
"PlayerListener#onPlayerJoin", "PlayerListener#onPlayerLogin",
|
||||
"PlayerListener#onPlayerQuit", "ServerListener#onPluginDisable",
|
||||
"ServerListener#onServerPing", "ServerListener#onPluginEnable",
|
||||
"PlayerListener#onJoinMessage", "PlayerListener#onLoginSingleSession");
|
||||
|
||||
@Test
|
||||
public void shouldSetIgnoreCancelledToTrue() {
|
||||
|
Loading…
Reference in New Issue
Block a user