Use JsonCache correctly, couldn't list all changes.

This commit is contained in:
DNx5
2016-06-28 21:36:58 +07:00
parent 874869cef8
commit 145747505f
17 changed files with 185 additions and 152 deletions
@@ -71,11 +71,11 @@ public class SyncProcessManager {
});
}
public void processSyncPlayerQuit(final Player player, final boolean isOp, final boolean needToChange) {
public void processSyncPlayerQuit(final Player player) {
runTask(new Runnable() {
@Override
public void run() {
processSyncronousPlayerQuit.processSyncQuit(player, isOp, needToChange);
processSyncronousPlayerQuit.processSyncQuit(player);
}
});
}
@@ -134,7 +134,7 @@ public class AsynchronousJoin implements AsynchronousProcess {
ProtectInventoryEvent ev = new ProtectInventoryEvent(player);
bukkitService.callEvent(ev);
if (ev.isCancelled()) {
protocolLibService.sendInventoryPacket(player);
player.updateInventory();
if (!service.getProperty(SecuritySettings.REMOVE_SPAM_FROM_CONSOLE)) {
ConsoleLogger.info("ProtectInventoryEvent has been cancelled for " + player.getName() + "...");
}
@@ -199,12 +199,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
// processed in other order.
LimboPlayer limboPlayer = limboCache.getLimboPlayer(name);
if (limboPlayer != null) {
if (limboPlayer.getTimeoutTask() != null) {
limboPlayer.getTimeoutTask().cancel();
}
if (limboPlayer.getMessageTask() != null) {
limboPlayer.getMessageTask().cancel();
}
limboPlayer.clearTasks();
}
syncProcessManager.processSyncPlayerLogin(player);
} else if (player.isOnline()) {
@@ -2,7 +2,6 @@ package fr.xephi.authme.process.login;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.limbo.LimboCache;
@@ -20,7 +19,6 @@ import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.TeleportationService;
import org.apache.commons.lang.reflect.MethodUtils;
import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity;
@@ -77,7 +75,7 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
RestoreInventoryEvent event = new RestoreInventoryEvent(player);
pluginManager.callEvent(event);
if (!event.isCancelled()) {
protocolLibService.sendInventoryPacket(player);
player.updateInventory();
}
}
@@ -99,8 +97,13 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
if (limbo != null) {
// Restore Op state and Permission Group
restoreOpState(player, limbo);
player.setOp(limbo.isOperator());
// Restore primary group
service.setGroup(player, AuthGroupType.LOGGED_IN);
// Restore can-fly state
player.setAllowFlight(limbo.isCanFly());
// Restore walk speed
player.setWalkSpeed(limbo.getWalkSpeed());
teleportationService.teleportOnLogin(player, auth, limbo);
@@ -117,7 +120,7 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
}
// Clean up no longer used temporary data
limboCache.deleteLimboPlayer(name);
limboCache.deleteLimboPlayer(player);
}
// We can now display the join message (if delayed)
@@ -142,6 +145,7 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
bukkitService.callEvent(new LoginEvent(player));
player.saveData();
sendBungeeMessage(player);
// Login is done, display welcome message
if (service.getProperty(RegistrationSettings.USE_WELCOME_MESSAGE)) {
if (service.getProperty(RegistrationSettings.BROADCAST_WELCOME_MESSAGE)) {
@@ -161,10 +165,6 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
sendTo(player);
}
private void restoreOpState(Player player, LimboPlayer limboPlayer) {
player.setOp(limboPlayer.isOperator());
}
private void sendTo(Player player) {
if(!service.getProperty(HooksSettings.BUNGEECORD)) {
return;
@@ -60,7 +60,7 @@ public class AsynchronousLogout implements AsynchronousProcess {
}
});
if (limboCache.hasLimboPlayer(name)) {
limboCache.deleteLimboPlayer(name);
limboCache.deleteLimboPlayer(player);
}
limboCache.addLimboPlayer(player);
service.setGroup(player, AuthGroupType.NOT_LOGGED_IN);
@@ -5,7 +5,6 @@ import fr.xephi.authme.cache.SessionManager;
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.datasource.CacheDataSource;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.process.AsynchronousProcess;
@@ -13,7 +12,6 @@ import fr.xephi.authme.process.ProcessService;
import fr.xephi.authme.process.SyncProcessManager;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.util.StringUtils;
import fr.xephi.authme.util.Utils;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@@ -74,18 +72,6 @@ public class AsynchronousQuit implements AsynchronousProcess {
database.updateSession(auth);
}
boolean needToChange = false;
boolean isOp = false;
LimboPlayer limbo = limboCache.getLimboPlayer(name);
if (limbo != null) {
if (!StringUtils.isEmpty(limbo.getGroup())) {
Utils.addNormal(player, limbo.getGroup());
}
needToChange = true;
isOp = limbo.isOperator();
limboCache.deleteLimboPlayer(name);
}
if (!isKick) {
if (plugin.isEnabled()) {
BukkitTask task = plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
@@ -108,7 +94,7 @@ public class AsynchronousQuit implements AsynchronousProcess {
}
if (plugin.isEnabled()) {
syncProcessManager.processSyncPlayerQuit(player, isOp, needToChange);
syncProcessManager.processSyncPlayerQuit(player);
}
// remove player from cache
if (database instanceof CacheDataSource) {
@@ -1,14 +1,30 @@
package fr.xephi.authme.process.quit;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.cache.limbo.LimboPlayer;
import fr.xephi.authme.process.SynchronousProcess;
import fr.xephi.authme.util.StringUtils;
import fr.xephi.authme.util.Utils;
import org.bukkit.entity.Player;
import javax.inject.Inject;
public class ProcessSyncronousPlayerQuit implements SynchronousProcess {
public void processSyncQuit(Player player, boolean isOp, boolean needToChange) {
if (needToChange) {
player.setOp(isOp);
@Inject
private LimboCache limboCache;
public void processSyncQuit(Player player) {
LimboPlayer limbo = limboCache.getLimboPlayer(player.getName().toLowerCase());
if (limbo != null) {
if (!StringUtils.isEmpty(limbo.getGroup())) {
Utils.addNormal(player, limbo.getGroup());
}
player.setOp(limbo.isOperator());
player.setAllowFlight(limbo.isCanFly());
player.setWalkSpeed(limbo.getWalkSpeed());
limboCache.deleteLimboPlayer(player);
}
player.leaveVehicle();
}
@@ -106,11 +106,11 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess {
RestoreInventoryEvent event = new RestoreInventoryEvent(player);
bukkitService.callEvent(event);
if (!event.isCancelled()) {
protocolLibService.sendInventoryPacket(player);
player.updateInventory();
}
}
limboCache.deleteLimboPlayer(name);
limboCache.deleteLimboPlayer(player);
}
if (!Settings.getRegisteredGroup.isEmpty()) {