Change from HashMap to ConcurrentHashMap, need to be available from

other threads !
This commit is contained in:
Xephi 2015-05-28 18:56:57 +02:00
parent 96925a580a
commit dc3a8c1f06
2 changed files with 32 additions and 35 deletions

View File

@ -1,8 +1,7 @@
package fr.xephi.authme.datasource; package fr.xephi.authme.datasource;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
@ -13,7 +12,7 @@ public class CacheDataSource extends Thread implements DataSource {
private DataSource source; private DataSource source;
public AuthMe plugin; public AuthMe plugin;
private HashMap<String, PlayerAuth> cache = new HashMap<String, PlayerAuth>(); private ConcurrentHashMap<String, PlayerAuth> cache = new ConcurrentHashMap<String, PlayerAuth>();
public CacheDataSource(AuthMe plugin, DataSource source) { public CacheDataSource(AuthMe plugin, DataSource source) {
this.plugin = plugin; this.plugin = plugin;

View File

@ -381,16 +381,14 @@ public class AuthMePlayerListener implements Listener {
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onAsyncLogin(AsyncPlayerPreLoginEvent event) public void onAsyncLogin(AsyncPlayerPreLoginEvent event) {
{
Player player = null; Player player = null;
try { try {
player = Bukkit.getPlayer(event.getUniqueId()); player = Bukkit.getPlayer(event.getUniqueId());
} catch (Exception e) { } catch (Exception e) {
try { try {
player = Bukkit.getOfflinePlayer(event.getUniqueId()).getPlayer(); player = Bukkit.getOfflinePlayer(event.getUniqueId()).getPlayer();
} catch (Exception ex) } catch (Exception ex) {
{
return; return;
} }
} }
@ -534,7 +532,8 @@ public class AuthMePlayerListener implements Listener {
} }
} }
private void checkAntiBotMod(final AsyncPlayerPreLoginEvent event, final Player player) { private void checkAntiBotMod(final AsyncPlayerPreLoginEvent event,
final Player player) {
if (plugin.delayedAntiBot || plugin.antibotMod) if (plugin.delayedAntiBot || plugin.antibotMod)
return; return;
if (plugin.authmePermissible(player, "authme.bypassantibot")) if (plugin.authmePermissible(player, "authme.bypassantibot"))
@ -679,8 +678,7 @@ public class AuthMePlayerListener implements Listener {
try { try {
DataFileCache dataFile = new DataFileCache(LimboCache.getInstance().getLimboPlayer(name).getInventory(), LimboCache.getInstance().getLimboPlayer(name).getArmour()); DataFileCache dataFile = new DataFileCache(LimboCache.getInstance().getLimboPlayer(name).getInventory(), LimboCache.getInstance().getLimboPlayer(name).getArmour());
playerBackup.createCache(player, dataFile, LimboCache.getInstance().getLimboPlayer(name).getGroup(), LimboCache.getInstance().getLimboPlayer(name).getOperator(), LimboCache.getInstance().getLimboPlayer(name).isFlying()); playerBackup.createCache(player, dataFile, LimboCache.getInstance().getLimboPlayer(name).getGroup(), LimboCache.getInstance().getLimboPlayer(name).getOperator(), LimboCache.getInstance().getLimboPlayer(name).isFlying());
} catch (Exception e) } catch (Exception e) {
{
ConsoleLogger.showError("Error on creating an inventory cache for " + name + ", maybe inventory wipe in preparation..."); ConsoleLogger.showError("Error on creating an inventory cache for " + name + ", maybe inventory wipe in preparation...");
} }
} else { } else {