mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-30 22:53:27 +01:00
Close web editor sockets on plugin disable (#3326)
This commit is contained in:
parent
fb56189f0a
commit
eece15d415
@ -58,6 +58,7 @@ import me.lucko.luckperms.common.tasks.ExpireTemporaryTask;
|
|||||||
import me.lucko.luckperms.common.tasks.SyncTask;
|
import me.lucko.luckperms.common.tasks.SyncTask;
|
||||||
import me.lucko.luckperms.common.treeview.PermissionRegistry;
|
import me.lucko.luckperms.common.treeview.PermissionRegistry;
|
||||||
import me.lucko.luckperms.common.verbose.VerboseHandler;
|
import me.lucko.luckperms.common.verbose.VerboseHandler;
|
||||||
|
import me.lucko.luckperms.common.webeditor.socket.WebEditorSocket;
|
||||||
import me.lucko.luckperms.common.webeditor.store.WebEditorStore;
|
import me.lucko.luckperms.common.webeditor.store.WebEditorStore;
|
||||||
|
|
||||||
import net.luckperms.api.LuckPerms;
|
import net.luckperms.api.LuckPerms;
|
||||||
@ -234,6 +235,13 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin {
|
|||||||
// cancel delayed/repeating tasks
|
// cancel delayed/repeating tasks
|
||||||
getBootstrap().getScheduler().shutdownScheduler();
|
getBootstrap().getScheduler().shutdownScheduler();
|
||||||
|
|
||||||
|
// close web editor sockets
|
||||||
|
for (WebEditorSocket socket : this.webEditorStore.sockets().getSockets()) {
|
||||||
|
if (!socket.isClosed()) {
|
||||||
|
socket.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// shutdown permission vault and verbose handler tasks
|
// shutdown permission vault and verbose handler tasks
|
||||||
this.permissionRegistry.close();
|
this.permissionRegistry.close();
|
||||||
this.verboseHandler.close();
|
this.verboseHandler.close();
|
||||||
|
@ -217,6 +217,7 @@ public class WebEditorSocket {
|
|||||||
|
|
||||||
private void closeSocket() {
|
private void closeSocket() {
|
||||||
this.socket.socket().close(1000, "Normal");
|
this.socket.socket().close(1000, "Normal");
|
||||||
|
this.plugin.getWebEditorStore().sockets().removeSocket(this);
|
||||||
this.closed = true;
|
this.closed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,13 +31,12 @@ import me.lucko.luckperms.common.sender.Sender;
|
|||||||
import me.lucko.luckperms.common.util.CaffeineFactory;
|
import me.lucko.luckperms.common.util.CaffeineFactory;
|
||||||
import me.lucko.luckperms.common.webeditor.socket.WebEditorSocket;
|
import me.lucko.luckperms.common.webeditor.socket.WebEditorSocket;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
public final class WebEditorSocketMap {
|
public final class WebEditorSocketMap {
|
||||||
private final Cache<UUID, WebEditorSocket> sockets = CaffeineFactory.newBuilder()
|
private final Cache<UUID, WebEditorSocket> sockets = CaffeineFactory.newBuilder()
|
||||||
.weakValues()
|
.weakValues()
|
||||||
.expireAfterWrite(5, TimeUnit.MINUTES)
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public WebEditorSocket getSocket(Sender sender) {
|
public WebEditorSocket getSocket(Sender sender) {
|
||||||
@ -47,4 +46,12 @@ public final class WebEditorSocketMap {
|
|||||||
public void putSocket(Sender sender, WebEditorSocket socket) {
|
public void putSocket(Sender sender, WebEditorSocket socket) {
|
||||||
this.sockets.put(sender.getUniqueId(), socket);
|
this.sockets.put(sender.getUniqueId(), socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeSocket(WebEditorSocket socket) {
|
||||||
|
this.sockets.asMap().values().remove(socket);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<WebEditorSocket> getSockets() {
|
||||||
|
return this.sockets.asMap().values();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user