mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-19 15:17:56 +01:00
Pass the ip check into player join event
if AuthMe still cannot get the ip address.
This commit is contained in:
parent
8c88136812
commit
f0cd775d7c
@ -23,6 +23,7 @@ import fr.xephi.authme.settings.properties.HooksSettings;
|
|||||||
import fr.xephi.authme.settings.properties.PluginSettings;
|
import fr.xephi.authme.settings.properties.PluginSettings;
|
||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
|
import fr.xephi.authme.util.PlayerUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
@ -226,6 +227,15 @@ public class PlayerListener implements Listener {
|
|||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (unresolvedPlayerHostname.remove(player.getName())) {
|
||||||
|
try {
|
||||||
|
runOnJoinChecks(JoiningPlayer.fromPlayerObject(player), PlayerUtils.getPlayerIp(player));
|
||||||
|
} catch (FailedVerificationException e) {
|
||||||
|
player.kickPlayer(messages.retrieveSingle(player, e.getReason(), e.getArgs()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!PlayerListener19Spigot.isPlayerSpawnLocationEventCalled()) {
|
if (!PlayerListener19Spigot.isPlayerSpawnLocationEventCalled()) {
|
||||||
teleportationService.teleportOnJoin(player);
|
teleportationService.teleportOnJoin(player);
|
||||||
}
|
}
|
||||||
@ -266,15 +276,6 @@ public class PlayerListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// getAddress() sometimes returning null if not yet resolved
|
|
||||||
// skip it and let PlayerLoginEvent to handle it
|
|
||||||
if (event.getAddress() == null) {
|
|
||||||
unresolvedPlayerHostname.add(event.getName());
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
unresolvedPlayerHostname.remove(event.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
final String name = event.getName();
|
final String name = event.getName();
|
||||||
|
|
||||||
if (validationService.isUnrestricted(name)) {
|
if (validationService.isUnrestricted(name)) {
|
||||||
@ -292,6 +293,15 @@ public class PlayerListener implements Listener {
|
|||||||
ConsoleLogger.logException("Unable to load the permission data of user " + name, e);
|
ConsoleLogger.logException("Unable to load the permission data of user " + name, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getAddress() sometimes returning null if not yet resolved
|
||||||
|
// skip it and let PlayerLoginEvent to handle it
|
||||||
|
if (event.getAddress() == null) {
|
||||||
|
unresolvedPlayerHostname.add(event.getName());
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
unresolvedPlayerHostname.remove(event.getName());
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
runOnJoinChecks(JoiningPlayer.fromName(name), event.getAddress().getHostAddress());
|
runOnJoinChecks(JoiningPlayer.fromName(name), event.getAddress().getHostAddress());
|
||||||
} catch (FailedVerificationException e) {
|
} catch (FailedVerificationException e) {
|
||||||
@ -320,9 +330,16 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!isAsyncPlayerPreLoginEventCalled || !settings.getProperty(PluginSettings.USE_ASYNC_PRE_LOGIN_EVENT)
|
if (event.getAddress() == null) { // Address still null
|
||||||
|| unresolvedPlayerHostname.remove(name)) {
|
unresolvedPlayerHostname.add(name);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
unresolvedPlayerHostname.remove(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isAsyncPlayerPreLoginEventCalled || !settings.getProperty(PluginSettings.USE_ASYNC_PRE_LOGIN_EVENT)) {
|
||||||
try {
|
try {
|
||||||
|
// Player.getAddress() can be null at this event, use event.getAddress()
|
||||||
runOnJoinChecks(JoiningPlayer.fromPlayerObject(player), event.getAddress().getHostAddress());
|
runOnJoinChecks(JoiningPlayer.fromPlayerObject(player), event.getAddress().getHostAddress());
|
||||||
} catch (FailedVerificationException e) {
|
} catch (FailedVerificationException e) {
|
||||||
event.setKickMessage(messages.retrieveSingle(player, e.getReason(), e.getArgs()));
|
event.setKickMessage(messages.retrieveSingle(player, e.getReason(), e.getArgs()));
|
||||||
|
Loading…
Reference in New Issue
Block a user