Merge please

This commit is contained in:
DNx5 2015-12-05 03:45:52 +07:00
parent 93484a3449
commit fda7822644
3 changed files with 24 additions and 30 deletions

View File

@ -14,6 +14,8 @@ import org.bukkit.entity.Player;
import java.util.concurrent.ConcurrentHashMap;
import static com.google.common.base.Preconditions.checkNotNull;
/**
*/
public class LimboCache {
@ -117,9 +119,8 @@ public class LimboCache {
* @param name String
*/
public void deleteLimboPlayer(String name) {
if (name == null)
return;
cache.remove(name);
checkNotNull(name);
cache.remove(name.toLowerCase());
}
/**
@ -130,9 +131,8 @@ public class LimboCache {
* @return LimboPlayer
*/
public LimboPlayer getLimboPlayer(String name) {
if (name == null)
return null;
return cache.get(name);
checkNotNull(name);
return cache.get(name.toLowerCase());
}
/**
@ -143,9 +143,8 @@ public class LimboCache {
* @return boolean
*/
public boolean hasLimboPlayer(String name) {
if (name == null)
return false;
return cache.containsKey(name);
checkNotNull(name);
return cache.containsKey(name.toLowerCase());
}
/**
@ -154,9 +153,8 @@ public class LimboCache {
* @param player Player
*/
public void updateLimboPlayer(Player player) {
if (this.hasLimboPlayer(player.getName().toLowerCase())) {
this.deleteLimboPlayer(player.getName().toLowerCase());
}
checkNotNull(player);
deleteLimboPlayer(player.getName().toLowerCase());
addLimboPlayer(player);
}

View File

@ -9,10 +9,10 @@ import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.cache.limbo.LimboPlayer;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.permission.UserPermission;
import fr.xephi.authme.settings.MessageKey;
import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.permission.PlayerPermission;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.GeoLiteAPI;
import fr.xephi.authme.util.Utils;
@ -32,8 +32,6 @@ import org.bukkit.event.player.*;
import java.util.concurrent.ConcurrentHashMap;
import static fr.xephi.authme.output.MessageKey.USERNAME_ALREADY_ONLINE_ERROR;
/**
*/
public class AuthMePlayerListener implements Listener {
@ -169,20 +167,21 @@ public class AuthMePlayerListener implements Listener {
}
}
@EventHandler(priority = EventPriority.HIGHEST)
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerJoin(PlayerJoinEvent event) {
if (event.getPlayer() == null || Utils.isNPC(event.getPlayer())) {
return;
}
final Player player = event.getPlayer();
final String name = player.getName().toLowerCase();
final String joinMsg = event.getJoinMessage();
final boolean delay = Settings.delayJoinLeaveMessages && joinMsg != null;
String name = player.getName().toLowerCase();
String joinMsg = event.getJoinMessage();
boolean delay = Settings.delayJoinLeaveMessages && joinMsg != null;
// Remove the join message while the player isn't logging in
if (delay) {
event.setJoinMessage(null);
joinMessage.put(name, joinMsg);
}
// Shedule login task so works after the prelogin
@ -190,9 +189,6 @@ public class AuthMePlayerListener implements Listener {
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
if (delay) {
joinMessage.put(name, joinMsg);
}
plugin.getManagement().performJoin(player);
}
});
@ -453,7 +449,7 @@ public class AuthMePlayerListener implements Listener {
String name = player.getName().toLowerCase();
Location spawn = plugin.getSpawnLocation(player);
if (Settings.isSaveQuitLocationEnabled && plugin.database.isAuthAvailable(name)) {
final PlayerAuth auth = new PlayerAuth(name, spawn.getX(), spawn.getY(), spawn.getZ(), spawn.getWorld().getName(), player.getName());
PlayerAuth auth = new PlayerAuth(name, spawn.getX(), spawn.getY(), spawn.getZ(), spawn.getWorld().getName(), player.getName());
plugin.database.updateQuitLoc(auth);
}
if (spawn != null && spawn.getWorld() != null) {
@ -468,7 +464,7 @@ public class AuthMePlayerListener implements Listener {
}
Player player = event.getPlayer();
if (plugin.getPermissionsManager().hasPermission(player, UserPermission.BYPASS_FORCE_SURVIVAL)) {
if (plugin.getPermissionsManager().hasPermission(player, PlayerPermission.BYPASS_FORCE_SURVIVAL)) {
return;
}

View File

@ -5,10 +5,10 @@ import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.permission.PlayerPermission;
import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.permission.PlayerPermission;
import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.settings.Settings;
import org.bukkit.entity.Player;
@ -60,7 +60,7 @@ public class AsyncRegister {
m.send(player, MessageKey.NAME_ALREADY_REGISTERED);
return false;
} else if (Settings.getmaxRegPerIp > 0
&& !plugin.getPermissionsManager().hasPermission(player, UserPermission.ALLOW_MULTIPLE_ACCOUNTS)
&& !plugin.getPermissionsManager().hasPermission(player, PlayerPermission.ALLOW_MULTIPLE_ACCOUNTS)
&& !ip.equalsIgnoreCase("127.0.0.1")
&& !ip.equalsIgnoreCase("localhost")
&& database.getAllAuthsByIp(ip).size() >= Settings.getmaxRegPerIp) {
@ -89,7 +89,7 @@ public class AsyncRegister {
private void emailRegister() throws Exception {
if (Settings.getmaxRegPerEmail > 0
&& !plugin.getPermissionsManager().hasPermission(player, UserPermission.ALLOW_MULTIPLE_ACCOUNTS)
&& !plugin.getPermissionsManager().hasPermission(player, PlayerPermission.ALLOW_MULTIPLE_ACCOUNTS)
&& database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
m.send(player, MessageKey.MAX_REGISTER_EXCEEDED);
return;