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);
|
Player onlinePlayer = bukkitService.getPlayerExact(name);
|
||||||
if (onlinePlayer != null && onlinePlayer.isOnline()) {
|
if (onlinePlayer != null) {
|
||||||
throw new FailedVerificationException(MessageKey.USERNAME_ALREADY_ONLINE_ERROR);
|
throw new FailedVerificationException(MessageKey.USERNAME_ALREADY_ONLINE_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -202,31 +202,6 @@ public class PlayerListener implements Listener {
|
|||||||
management.performJoin(player);
|
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)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
|||||||
@ -31,7 +31,7 @@ import java.lang.reflect.InvocationTargetException;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
class AuthMeInventoryPacketAdapter extends PacketAdapter {
|
class InventoryPacketAdapter extends PacketAdapter {
|
||||||
|
|
||||||
private static final int PLAYER_INVENTORY = 0;
|
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)
|
// 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 MAIN_SIZE = 27;
|
||||||
private static final int HOTBAR_SIZE = 9;
|
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);
|
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 {
|
public class ProtocolLibService implements SettingsDependent {
|
||||||
|
|
||||||
/* Packet Adapters */
|
/* Packet Adapters */
|
||||||
private AuthMeInventoryPacketAdapter inventoryPacketAdapter;
|
private InventoryPacketAdapter inventoryPacketAdapter;
|
||||||
private AuthMeTabCompletePacketAdapter tabCompletePacketAdapter;
|
private TabCompletePacketAdapter tabCompletePacketAdapter;
|
||||||
|
|
||||||
/* Settings */
|
/* Settings */
|
||||||
private boolean protectInvBeforeLogin;
|
private boolean protectInvBeforeLogin;
|
||||||
@ -57,14 +57,14 @@ public class ProtocolLibService implements SettingsDependent {
|
|||||||
|
|
||||||
// Set up packet adapters
|
// Set up packet adapters
|
||||||
if (protectInvBeforeLogin && inventoryPacketAdapter == null) {
|
if (protectInvBeforeLogin && inventoryPacketAdapter == null) {
|
||||||
inventoryPacketAdapter = new AuthMeInventoryPacketAdapter(plugin);
|
inventoryPacketAdapter = new InventoryPacketAdapter(plugin);
|
||||||
inventoryPacketAdapter.register();
|
inventoryPacketAdapter.register();
|
||||||
} else if (inventoryPacketAdapter != null) {
|
} else if (inventoryPacketAdapter != null) {
|
||||||
inventoryPacketAdapter.unregister();
|
inventoryPacketAdapter.unregister();
|
||||||
inventoryPacketAdapter = null;
|
inventoryPacketAdapter = null;
|
||||||
}
|
}
|
||||||
if (denyTabCompleteBeforeLogin && tabCompletePacketAdapter == null) {
|
if (denyTabCompleteBeforeLogin && tabCompletePacketAdapter == null) {
|
||||||
tabCompletePacketAdapter = new AuthMeTabCompletePacketAdapter(plugin);
|
tabCompletePacketAdapter = new TabCompletePacketAdapter(plugin);
|
||||||
tabCompletePacketAdapter.register();
|
tabCompletePacketAdapter.register();
|
||||||
} else if (tabCompletePacketAdapter != null) {
|
} else if (tabCompletePacketAdapter != null) {
|
||||||
tabCompletePacketAdapter.unregister();
|
tabCompletePacketAdapter.unregister();
|
||||||
|
|||||||
@ -10,9 +10,9 @@ 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;
|
||||||
|
|
||||||
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);
|
super(plugin, ListenerPriority.NORMAL, PacketType.Play.Client.TAB_COMPLETE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,11 +32,11 @@ public final class ListenerConsistencyTest {
|
|||||||
PlayerListener.class, PlayerListener16.class, PlayerListener18.class,
|
PlayerListener.class, PlayerListener16.class, PlayerListener18.class,
|
||||||
ServerListener.class };
|
ServerListener.class };
|
||||||
|
|
||||||
private static final Set<String> CANCELED_EXCEPTIONS = Sets.newHashSet("AuthMePlayerListener#onPlayerJoin",
|
private static final Set<String> CANCELED_EXCEPTIONS = Sets.newHashSet(
|
||||||
"AuthMePlayerListener#onPreLogin", "AuthMePlayerListener#onPlayerLogin",
|
"PlayerListener#onPlayerJoin", "PlayerListener#onPlayerLogin",
|
||||||
"AuthMePlayerListener#onPlayerQuit", "AuthMeServerListener#onPluginDisable",
|
"PlayerListener#onPlayerQuit", "ServerListener#onPluginDisable",
|
||||||
"AuthMeServerListener#onServerPing", "AuthMeServerListener#onPluginEnable",
|
"ServerListener#onServerPing", "ServerListener#onPluginEnable",
|
||||||
"AuthMePlayerListener#onJoinMessage", "AuthMePlayerListener#onLoginSingleSession");
|
"PlayerListener#onJoinMessage", "PlayerListener#onLoginSingleSession");
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldSetIgnoreCancelledToTrue() {
|
public void shouldSetIgnoreCancelledToTrue() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user