mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-09-07 04:38:03 +02:00
Change from HashMap to ConcurrentHashMap, need to be available from
other threads !
This commit is contained in:
parent
96925a580a
commit
dc3a8c1f06
@ -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;
|
||||||
|
@ -370,10 +370,10 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
Location spawn = plugin.getSpawnLocation(player);
|
Location spawn = plugin.getSpawnLocation(player);
|
||||||
|
|
||||||
if (spawn != null && spawn.getWorld() != null)
|
if (spawn != null && spawn.getWorld() != null)
|
||||||
if (!event.getPlayer().getWorld().equals(spawn.getWorld())) {
|
if (!event.getPlayer().getWorld().equals(spawn.getWorld())) {
|
||||||
event.getPlayer().teleport(spawn);
|
event.getPlayer().teleport(spawn);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((spawn.distance(player.getLocation()) > radius) && spawn.getWorld() != null) {
|
if ((spawn.distance(player.getLocation()) > radius) && spawn.getWorld() != null) {
|
||||||
event.getPlayer().teleport(spawn);
|
event.getPlayer().teleport(spawn);
|
||||||
return;
|
return;
|
||||||
@ -381,21 +381,19 @@ 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;
|
}
|
||||||
}
|
if (player == null)
|
||||||
}
|
return;
|
||||||
if (player == null)
|
|
||||||
return;
|
|
||||||
final String name = player.getName().toLowerCase();
|
final String name = player.getName().toLowerCase();
|
||||||
|
|
||||||
if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||||
@ -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"))
|
||||||
@ -669,8 +668,8 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||||
if (!tpEvent.isCancelled()) {
|
if (!tpEvent.isCancelled()) {
|
||||||
if (player != null && player.isOnline() && tpEvent.getTo() != null) {
|
if (player != null && player.isOnline() && tpEvent.getTo() != null) {
|
||||||
if (tpEvent.getTo().getWorld() != null)
|
if (tpEvent.getTo().getWorld() != null)
|
||||||
player.teleport(tpEvent.getTo());
|
player.teleport(tpEvent.getTo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -679,9 +678,8 @@ 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 {
|
||||||
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) {
|
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) {
|
||||||
@ -701,8 +699,8 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||||
if (!tpEvent.isCancelled()) {
|
if (!tpEvent.isCancelled()) {
|
||||||
if (player != null && player.isOnline() && tpEvent.getTo() != null) {
|
if (player != null && player.isOnline() && tpEvent.getTo() != null) {
|
||||||
if (tpEvent.getTo().getWorld() != null)
|
if (tpEvent.getTo().getWorld() != null)
|
||||||
player.teleport(tpEvent.getTo());
|
player.teleport(tpEvent.getTo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -773,14 +771,14 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
if (b.getType() == Material.PORTAL || b.getType() == Material.ENDER_PORTAL || b.getType() == Material.LAVA || b.getType() == Material.STATIONARY_LAVA) {
|
if (b.getType() == Material.PORTAL || b.getType() == Material.ENDER_PORTAL || b.getType() == Material.LAVA || b.getType() == Material.STATIONARY_LAVA) {
|
||||||
m.send(player, "unsafe_spawn");
|
m.send(player, "unsafe_spawn");
|
||||||
if (spawnLoc.getWorld() != null)
|
if (spawnLoc.getWorld() != null)
|
||||||
player.teleport(spawnLoc);
|
player.teleport(spawnLoc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Block c = player.getLocation().add(0D, 1D, 0D).getBlock();
|
Block c = player.getLocation().add(0D, 1D, 0D).getBlock();
|
||||||
if (c.getType() == Material.PORTAL || c.getType() == Material.ENDER_PORTAL || c.getType() == Material.LAVA || c.getType() == Material.STATIONARY_LAVA) {
|
if (c.getType() == Material.PORTAL || c.getType() == Material.ENDER_PORTAL || c.getType() == Material.LAVA || c.getType() == Material.STATIONARY_LAVA) {
|
||||||
m.send(player, "unsafe_spawn");
|
m.send(player, "unsafe_spawn");
|
||||||
if (spawnLoc.getWorld() != null)
|
if (spawnLoc.getWorld() != null)
|
||||||
player.teleport(spawnLoc);
|
player.teleport(spawnLoc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -906,8 +904,8 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||||
if (!tpEvent.isCancelled()) {
|
if (!tpEvent.isCancelled()) {
|
||||||
if (player != null && player.isOnline() && tpEvent.getTo() != null) {
|
if (player != null && player.isOnline() && tpEvent.getTo() != null) {
|
||||||
if (tpEvent.getTo().getWorld() != null)
|
if (tpEvent.getTo().getWorld() != null)
|
||||||
player.teleport(tpEvent.getTo());
|
player.teleport(tpEvent.getTo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (NullPointerException npe) {
|
} catch (NullPointerException npe) {
|
||||||
@ -1178,7 +1176,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (spawn != null && spawn.getWorld() != null)
|
if (spawn != null && spawn.getWorld() != null)
|
||||||
event.setRespawnLocation(spawn);
|
event.setRespawnLocation(spawn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
Loading…
Reference in New Issue
Block a user