- send blank inventory on logout if protect inventory is enabled.
- added reload support for protect inventory option.
This commit is contained in:
@@ -98,18 +98,15 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
||||
|
||||
protected void restoreInventory() {
|
||||
RestoreInventoryEvent event = new RestoreInventoryEvent(player);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
pm.callEvent(event);
|
||||
if (!event.isCancelled() && plugin.inventoryProtector != null) {
|
||||
plugin.inventoryProtector.sendInventoryPacket(player);
|
||||
}
|
||||
}
|
||||
|
||||
protected void forceCommands() {
|
||||
for (String command : Settings.forceCommands) {
|
||||
try {
|
||||
player.performCommand(command.replace("%p", player.getName()));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
player.performCommand(command.replace("%p", player.getName()));
|
||||
}
|
||||
for (String command : Settings.forceCommandsAsConsole) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), command.replace("%p", player.getName()));
|
||||
@@ -154,7 +151,7 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
||||
|
||||
restoreFlyghtState();
|
||||
|
||||
if (Settings.protectInventoryBeforeLogInEnabled && plugin.inventoryProtector != null) {
|
||||
if (Settings.protectInventoryBeforeLogInEnabled) {
|
||||
restoreInventory();
|
||||
}
|
||||
|
||||
|
||||
@@ -46,8 +46,9 @@ public class AsynchronousLogout {
|
||||
|
||||
public void process() {
|
||||
preLogout();
|
||||
if (!canLogout)
|
||||
if (!canLogout) {
|
||||
return;
|
||||
}
|
||||
final Player p = player;
|
||||
BukkitScheduler scheduler = p.getServer().getScheduler();
|
||||
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
|
||||
@@ -66,11 +67,11 @@ public class AsynchronousLogout {
|
||||
Utils.teleportToSpawn(p);
|
||||
}
|
||||
});
|
||||
if (LimboCache.getInstance().hasLimboPlayer(name))
|
||||
if (LimboCache.getInstance().hasLimboPlayer(name)) {
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
}
|
||||
LimboCache.getInstance().addLimboPlayer(player);
|
||||
Utils.setGroup(player, GroupType.NOTLOGGEDIN);
|
||||
|
||||
scheduler.scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerLogout(p, plugin));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,14 +43,18 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin.sessions.containsKey(name))
|
||||
if (plugin.sessions.containsKey(name)) {
|
||||
plugin.sessions.get(name).cancel();
|
||||
plugin.sessions.remove(name);
|
||||
int delay = Settings.getRegistrationTimeout * 20;
|
||||
plugin.sessions.remove(name);
|
||||
}
|
||||
if (Settings.protectInventoryBeforeLogInEnabled) {
|
||||
plugin.inventoryProtector.sendBlankInventoryPacket(player);
|
||||
}
|
||||
int timeOut = Settings.getRegistrationTimeout * 20;
|
||||
int interval = Settings.getWarnMessageInterval;
|
||||
BukkitScheduler sched = player.getServer().getScheduler();
|
||||
if (delay != 0) {
|
||||
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), delay);
|
||||
if (timeOut != 0) {
|
||||
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), timeOut);
|
||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
||||
}
|
||||
BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("login_msg"), interval));
|
||||
|
||||
Reference in New Issue
Block a user