fix SessionExpireOnIpChange

Note for myself : Refresh Code T.T
This commit is contained in:
Xephi 2013-03-13 23:11:00 +01:00
parent 5462508357
commit cedafe52a8
3 changed files with 16 additions and 30 deletions

View File

@ -28,7 +28,7 @@
</plugin>
</plugins>
</build>
<version>2.7.11b2</version>
<version>2.7.11b3</version>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>

View File

@ -29,7 +29,6 @@ import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.PlayerBedEnterEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
@ -78,7 +77,6 @@ public class AuthMePlayerListener implements Listener {
public static int gm = 0;
public static HashMap<String, Integer> gameMode = new HashMap<String, Integer>();
public HashMap<String, Boolean> sessions = new HashMap<String, Boolean>();
private Utils utils = Utils.getInstance();
private Messages m = Messages.getInstance();
public AuthMe plugin;
@ -566,22 +564,6 @@ public class AuthMePlayerListener implements Listener {
}
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerPreLogin(AsyncPlayerPreLoginEvent event) {
if (event == null || event.getName() == null || event.getName().isEmpty()) return;
if (!Settings.isSessionsEnabled && !Settings.sessionExpireOnIpChange) return;
PlayerAuth auth = data.getAuth(event.getName().toLowerCase());
if (event.getAddress().getHostAddress() == auth.getIp()) {
return;
} else {
if (!plugin.getServer().getPlayer(event.getName()).isOnline()) {
this.sessions.put(event.getName().toLowerCase(), true);
}
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerLogin(PlayerLoginEvent event) {
@ -602,7 +584,8 @@ public class AuthMePlayerListener implements Listener {
if(!Settings.isSessionsEnabled) {
LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player));
} else if(PlayerCache.getInstance().isAuthenticated(name)) {
if(LimboCache.getInstance().hasLimboPlayer(player.getName().toLowerCase())) {
if(!Settings.sessionExpireOnIpChange)
if(LimboCache.getInstance().hasLimboPlayer(player.getName().toLowerCase())) {
LimboCache.getInstance().deleteLimboPlayer(name);
}
LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player));
@ -617,6 +600,7 @@ public class AuthMePlayerListener implements Listener {
if(!Settings.isSessionsEnabled) {
LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player));
} else if(PlayerCache.getInstance().isAuthenticated(name)) {
if(!Settings.sessionExpireOnIpChange)
if(LimboCache.getInstance().hasLimboPlayer(player.getName().toLowerCase())) {
LimboCache.getInstance().deleteLimboPlayer(name);
}
@ -717,7 +701,6 @@ public class AuthMePlayerListener implements Listener {
if((cur - lastLogin < timeout || timeout == 0) && !auth.getIp().equals("198.18.0.1") ) {
if (!this.sessions.containsKey(name)) {
if (auth.getNickname().equalsIgnoreCase(name) && auth.getIp().equals(ip) ) {
plugin.getServer().getPluginManager().callEvent(new SessionEvent(auth, true));
if(PlayerCache.getInstance().getAuth(name) != null) {
@ -727,18 +710,21 @@ public class AuthMePlayerListener implements Listener {
}
player.sendMessage(m._("valid_session"));
return;
} else {
} else if (!Settings.sessionExpireOnIpChange){
int gM = gameMode.get(name);
player.setGameMode(GameMode.getByValue(gM));
player.kickPlayer(m._("unvalid_session"));
return;
}
} else {
//Player change his IP between 2 relog-in
PlayerCache.getInstance().removePlayer(name);
LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player));
this.sessions.remove(name);
}
} else if (auth.getNickname().equalsIgnoreCase(name)){
//Player change his IP between 2 relog-in
PlayerCache.getInstance().removePlayer(name);
LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player));
} else {
int gM = gameMode.get(name);
player.setGameMode(GameMode.getByValue(gM));
player.kickPlayer(m._("unvalid_session"));
return;
}
} else {
//Session is ended correctly
PlayerCache.getInstance().removePlayer(name);

View File

@ -3,7 +3,7 @@ author: darkwarriros,Xephi
website: http://www.multiplayer-italia.com/
description: AuthMe prevents people, which aren't logged in, from doing stuff like placing blocks, moving, typing commands or seeing the inventory of the current player.
main: uk.org.whoami.authme.AuthMe
version: 2.7.11b2
version: 2.7.11b3
softdepend: [Vault, ChestShop, Spout, Multiverse-Core, Notifications, Citizens, CombatTag]
commands:
register: