HashMaps need to be Concurrent
This commit is contained in:
parent
108bb5c357
commit
d84cd6549b
@ -1,14 +1,14 @@
|
|||||||
package fr.xephi.authme.cache.auth;
|
package fr.xephi.authme.cache.auth;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class PlayerCache {
|
public class PlayerCache {
|
||||||
|
|
||||||
private static PlayerCache singleton = null;
|
private static PlayerCache singleton = null;
|
||||||
private HashMap<String, PlayerAuth> cache;
|
private ConcurrentHashMap<String, PlayerAuth> cache;
|
||||||
|
|
||||||
private PlayerCache() {
|
private PlayerCache() {
|
||||||
cache = new HashMap<String, PlayerAuth>();
|
cache = new ConcurrentHashMap<String, PlayerAuth>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayer(PlayerAuth auth) {
|
public void addPlayer(PlayerAuth auth) {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
package fr.xephi.authme.cache.limbo;
|
package fr.xephi.authme.cache.limbo;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -18,13 +18,13 @@ import fr.xephi.authme.settings.Settings;
|
|||||||
public class LimboCache {
|
public class LimboCache {
|
||||||
|
|
||||||
private static LimboCache singleton = null;
|
private static LimboCache singleton = null;
|
||||||
public HashMap<String, LimboPlayer> cache;
|
public ConcurrentHashMap<String, LimboPlayer> cache;
|
||||||
private FileCache playerData;
|
private FileCache playerData;
|
||||||
public AuthMe plugin;
|
public AuthMe plugin;
|
||||||
|
|
||||||
private LimboCache(AuthMe plugin) {
|
private LimboCache(AuthMe plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.cache = new HashMap<String, LimboPlayer>();
|
this.cache = new ConcurrentHashMap<String, LimboPlayer>();
|
||||||
this.playerData = new FileCache(plugin);
|
this.playerData = new FileCache(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,9 +52,8 @@ public class LimboCache {
|
|||||||
playerGroup = playerData.readCache(player).getGroup();
|
playerGroup = playerData.readCache(player).getGroup();
|
||||||
operator = playerData.readCache(player).getOperator();
|
operator = playerData.readCache(player).getOperator();
|
||||||
flying = playerData.readCache(player).isFlying();
|
flying = playerData.readCache(player).isFlying();
|
||||||
} catch (Exception e)
|
} catch (Exception e) {
|
||||||
{
|
ConsoleLogger.showError("Some error on reading cache of " + name);
|
||||||
ConsoleLogger.showError("Some error on reading cache of " + name);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
StoreInventoryEvent event = new StoreInventoryEvent(player);
|
StoreInventoryEvent event = new StoreInventoryEvent(player);
|
||||||
|
|||||||
@ -43,7 +43,6 @@ import fr.xephi.authme.Utils;
|
|||||||
import fr.xephi.authme.api.API;
|
import fr.xephi.authme.api.API;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.cache.backup.FileCache;
|
|
||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
@ -60,14 +59,12 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
private Messages m = Messages.getInstance();
|
private Messages m = Messages.getInstance();
|
||||||
public AuthMe plugin;
|
public AuthMe plugin;
|
||||||
private DataSource data;
|
private DataSource data;
|
||||||
private FileCache playerBackup;
|
|
||||||
public static ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<String, Boolean>();
|
public static ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<String, Boolean>();
|
||||||
private List<String> antibot = new ArrayList<String>();
|
private List<String> antibot = new ArrayList<String>();
|
||||||
|
|
||||||
public AuthMePlayerListener(AuthMe plugin, DataSource data) {
|
public AuthMePlayerListener(AuthMe plugin, DataSource data) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.playerBackup = new FileCache(plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user