extension settings

This commit is contained in:
sirjonasxx 2018-11-06 23:13:34 +01:00
parent 982b3c3fe6
commit 3a2178337a
4 changed files with 38 additions and 4 deletions

View File

@ -211,4 +211,9 @@ public class BlockAndReplacePackets extends ExtensionForm {
clearInput(); clearInput();
} }
@Override
protected boolean canDelete() {
return false;
}
} }

View File

@ -23,8 +23,8 @@ public abstract class Extension {
void act(String[] args); void act(String[] args);
} }
protected static final boolean CANLEAVE = true; // can you disconnect the ext protected boolean canLeave; // 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 canDelete; // can you delete the ext (will be false for some built-in extensions)
private String[] args; private String[] args;
private boolean isCorrupted = false; private boolean isCorrupted = false;
@ -53,6 +53,9 @@ public abstract class Extension {
* @param args arguments * @param args arguments
*/ */
public Extension(String[] args) { public Extension(String[] args) {
canLeave = canLeave();
canDelete = canDelete();
//obtain port //obtain port
this.args = args; this.args = args;
@ -126,8 +129,8 @@ public abstract class Extension {
.appendBoolean(file != null) .appendBoolean(file != null)
.appendString(file == null ? "": file) .appendString(file == null ? "": file)
.appendString(cookie == null ? "" : cookie) .appendString(cookie == null ? "" : cookie)
.appendBoolean(CANLEAVE) .appendBoolean(canLeave)
.appendBoolean(CANDELETE); .appendBoolean(canDelete);
writeToStream(response.toBytes()); writeToStream(response.toBytes());
} }
else if (packet.headerId() == Extensions.OUTGOING_MESSAGES_IDS.CONNECTIONSTART) { else if (packet.headerId() == Extensions.OUTGOING_MESSAGES_IDS.CONNECTIONSTART) {
@ -348,6 +351,14 @@ public abstract class Extension {
*/ */
protected void onEndConnection(){} protected void onEndConnection(){}
protected boolean canLeave() {
return true;
}
protected boolean canDelete() {
return true;
}
ExtensionInfo getInfoAnnotations() { ExtensionInfo getInfoAnnotations() {
return getClass().getAnnotation(ExtensionInfo.class); return getClass().getAnnotation(ExtensionInfo.class);

View File

@ -74,4 +74,12 @@ public abstract class ExtensionForm {
* A connection with Habbo has ended * A connection with Habbo has ended
*/ */
protected void onEndConnection(){} protected void onEndConnection(){}
protected boolean canLeave() {
return true;
}
protected boolean canDelete() {
return true;
}
} }

View File

@ -44,6 +44,16 @@ public class ExtensionFormLauncher extends Application{
ExtensionInfo getInfoAnnotations() { ExtensionInfo getInfoAnnotations() {
return extInfo; return extInfo;
} }
@Override
protected boolean canLeave() {
return extensionForm.canLeave();
}
@Override
protected boolean canDelete() {
return extensionForm.canDelete();
}
}; };
extensionForm.primaryStage = primaryStage; extensionForm.primaryStage = primaryStage;
Thread t = new Thread(() -> { Thread t = new Thread(() -> {