mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-03 01:00:18 +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) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
teleportationService.teleportNewPlayerToFirstSpawn(player);
|
|
||||||
management.performJoin(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
|
// 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.
|
// 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) {
|
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final String name = player.getName();
|
final String name = player.getName();
|
||||||
@ -239,6 +238,7 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
antiBot.handlePlayerJoin(player);
|
antiBot.handlePlayerJoin(player);
|
||||||
|
teleportationService.teleportNewPlayerToFirstSpawn(player);
|
||||||
teleportationService.teleportOnJoin(player);
|
teleportationService.teleportOnJoin(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,11 +261,13 @@ public class PlayerListener implements Listener {
|
|||||||
public void onPlayerKick(PlayerKickEvent event) {
|
public void onPlayerKick(PlayerKickEvent event) {
|
||||||
// Note #831: Especially for offline CraftBukkit, we need to catch players being kicked because of
|
// 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
|
// "logged in from another location" and to cancel their kick
|
||||||
if (settings.getProperty(RestrictionSettings.FORCE_SINGLE_SESSION)
|
if(settings.getProperty(RestrictionSettings.FORCE_SINGLE_SESSION)) {
|
||||||
&& event.getReason().contains("You logged in from another location")) {
|
String reason = event.getReason();
|
||||||
|
if (reason.contains("You logged in from another location")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (!antiBot.wasPlayerKicked(player.getName())) {
|
if (!antiBot.wasPlayerKicked(player.getName())) {
|
||||||
|
@ -72,7 +72,7 @@ public class TeleportationService implements Reloadable {
|
|||||||
return;
|
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()));
|
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
|
* @param event the event to emit and according to which to teleport
|
||||||
*/
|
*/
|
||||||
private void performTeleportation(final Player player, final AbstractTeleportEvent event) {
|
private void performTeleportation(final Player player, final AbstractTeleportEvent event) {
|
||||||
bukkitService.scheduleSyncDelayedTask(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
bukkitService.callEvent(event);
|
bukkitService.callEvent(event);
|
||||||
if (player.isOnline() && isEventValid(event)) {
|
if (player.isOnline() && isEventValid(event)) {
|
||||||
player.teleport(event.getTo());
|
player.teleport(event.getTo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isEventValid(AbstractTeleportEvent event) {
|
private static boolean isEventValid(AbstractTeleportEvent event) {
|
||||||
return !event.isCancelled() && event.getTo() != null && event.getTo().getWorld() != null;
|
return !event.isCancelled() && event.getTo() != null && event.getTo().getWorld() != null;
|
||||||
|
Loading…
Reference in New Issue
Block a user