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();
}
@Override
protected boolean canDelete() {
return false;
}
}

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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(() -> {