mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-30 06:03:36 +01:00
Cleanup + fix some teleport behaviour
This commit is contained in:
parent
4b81e3b7dc
commit
5d6f3e1f06
@ -193,10 +193,9 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
teleportationService.teleportNewPlayerToFirstSpawn(player);
|
||||
management.performJoin(player);
|
||||
}
|
||||
|
||||
@ -206,7 +205,7 @@ public class PlayerListener implements Listener {
|
||||
// event caused by "logged in from another location". The nicer way, but only for Spigot, would be
|
||||
// to check in the AsyncPlayerPreLoginEvent. To support all servers, we use the less nice way.
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final String name = player.getName();
|
||||
@ -239,6 +238,7 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
antiBot.handlePlayerJoin(player);
|
||||
teleportationService.teleportNewPlayerToFirstSpawn(player);
|
||||
teleportationService.teleportOnJoin(player);
|
||||
}
|
||||
|
||||
@ -261,11 +261,13 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerKick(PlayerKickEvent event) {
|
||||
// Note #831: Especially for offline CraftBukkit, we need to catch players being kicked because of
|
||||
// "logged in from another location" and to cancel their kick
|
||||
if (settings.getProperty(RestrictionSettings.FORCE_SINGLE_SESSION)
|
||||
&& event.getReason().contains("You logged in from another location")) {
|
||||
if(settings.getProperty(RestrictionSettings.FORCE_SINGLE_SESSION)) {
|
||||
String reason = event.getReason();
|
||||
if (reason.contains("You logged in from another location")) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
if (!antiBot.wasPlayerKicked(player.getName())) {
|
||||
|
@ -72,7 +72,7 @@ public class TeleportationService implements Reloadable {
|
||||
return;
|
||||
}
|
||||
|
||||
if (settings.getProperty(TELEPORT_UNAUTHED_TO_SPAWN) || mustForceSpawnAfterLogin(player.getWorld().getName())) {
|
||||
if (settings.getProperty(TELEPORT_UNAUTHED_TO_SPAWN)) {
|
||||
teleportToSpawn(player, playerCache.isAuthenticated(player.getName()));
|
||||
}
|
||||
}
|
||||
@ -160,16 +160,11 @@ public class TeleportationService implements Reloadable {
|
||||
* @param event the event to emit and according to which to teleport
|
||||
*/
|
||||
private void performTeleportation(final Player player, final AbstractTeleportEvent event) {
|
||||
bukkitService.scheduleSyncDelayedTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
bukkitService.callEvent(event);
|
||||
if (player.isOnline() && isEventValid(event)) {
|
||||
player.teleport(event.getTo());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static boolean isEventValid(AbstractTeleportEvent event) {
|
||||
return !event.isCancelled() && event.getTo() != null && event.getTo().getWorld() != null;
|
||||
|
Loading…
Reference in New Issue
Block a user