From 3a2178337a566351b8e74cc822a2af29f352643d Mon Sep 17 00:00:00 2001 From: sirjonasxx <36828922+sirjonasxx@users.noreply.github.com> Date: Tue, 6 Nov 2018 23:13:34 +0100 Subject: [PATCH] extension settings --- .../BlockAndReplacePackets.java | 5 +++++ .../java/gearth/extensions/Extension.java | 19 +++++++++++++++---- .../java/gearth/extensions/ExtensionForm.java | 8 ++++++++ .../extensions/ExtensionFormLauncher.java | 10 ++++++++++ 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/Extensions/BlockReplacePackets/src/main/java/extensions/blockreplacepackets/BlockAndReplacePackets.java b/Extensions/BlockReplacePackets/src/main/java/extensions/blockreplacepackets/BlockAndReplacePackets.java index 0e7337c..1eda9b0 100644 --- a/Extensions/BlockReplacePackets/src/main/java/extensions/blockreplacepackets/BlockAndReplacePackets.java +++ b/Extensions/BlockReplacePackets/src/main/java/extensions/blockreplacepackets/BlockAndReplacePackets.java @@ -211,4 +211,9 @@ public class BlockAndReplacePackets extends ExtensionForm { clearInput(); } + + @Override + protected boolean canDelete() { + return false; + } } diff --git a/G-Earth/src/main/java/gearth/extensions/Extension.java b/G-Earth/src/main/java/gearth/extensions/Extension.java index aa88f63..f720a01 100644 --- a/G-Earth/src/main/java/gearth/extensions/Extension.java +++ b/G-Earth/src/main/java/gearth/extensions/Extension.java @@ -23,8 +23,8 @@ public abstract class Extension { void act(String[] args); } - protected static final boolean CANLEAVE = true; // can you disconnect the ext - protected static final boolean CANDELETE = true; // can you delete the ext (will be false for some built-in extensions) + protected boolean canLeave; // can you disconnect the ext + protected boolean canDelete; // can you delete the ext (will be false for some built-in extensions) private String[] args; private boolean isCorrupted = false; @@ -53,6 +53,9 @@ public abstract class Extension { * @param args arguments */ public Extension(String[] args) { + canLeave = canLeave(); + canDelete = canDelete(); + //obtain port this.args = args; @@ -126,8 +129,8 @@ public abstract class Extension { .appendBoolean(file != null) .appendString(file == null ? "": file) .appendString(cookie == null ? "" : cookie) - .appendBoolean(CANLEAVE) - .appendBoolean(CANDELETE); + .appendBoolean(canLeave) + .appendBoolean(canDelete); writeToStream(response.toBytes()); } else if (packet.headerId() == Extensions.OUTGOING_MESSAGES_IDS.CONNECTIONSTART) { @@ -348,6 +351,14 @@ public abstract class Extension { */ protected void onEndConnection(){} + protected boolean canLeave() { + return true; + } + + protected boolean canDelete() { + return true; + } + ExtensionInfo getInfoAnnotations() { return getClass().getAnnotation(ExtensionInfo.class); diff --git a/G-Earth/src/main/java/gearth/extensions/ExtensionForm.java b/G-Earth/src/main/java/gearth/extensions/ExtensionForm.java index 4815416..e24a816 100644 --- a/G-Earth/src/main/java/gearth/extensions/ExtensionForm.java +++ b/G-Earth/src/main/java/gearth/extensions/ExtensionForm.java @@ -74,4 +74,12 @@ public abstract class ExtensionForm { * A connection with Habbo has ended */ protected void onEndConnection(){} + + protected boolean canLeave() { + return true; + } + + protected boolean canDelete() { + return true; + } } diff --git a/G-Earth/src/main/java/gearth/extensions/ExtensionFormLauncher.java b/G-Earth/src/main/java/gearth/extensions/ExtensionFormLauncher.java index e380415..b0c7253 100644 --- a/G-Earth/src/main/java/gearth/extensions/ExtensionFormLauncher.java +++ b/G-Earth/src/main/java/gearth/extensions/ExtensionFormLauncher.java @@ -44,6 +44,16 @@ public class ExtensionFormLauncher extends Application{ ExtensionInfo getInfoAnnotations() { return extInfo; } + + @Override + protected boolean canLeave() { + return extensionForm.canLeave(); + } + + @Override + protected boolean canDelete() { + return extensionForm.canDelete(); + } }; extensionForm.primaryStage = primaryStage; Thread t = new Thread(() -> {