mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-11-23 08:50:52 +01:00
fix bug in extensionForm 2
This commit is contained in:
parent
4d29895f5f
commit
3636c42245
@ -157,12 +157,7 @@ public class BlockAndReplacePackets extends ExtensionForm {
|
||||
|
||||
@Override
|
||||
protected void initExtension() {
|
||||
intercept(HMessage.Side.TOSERVER, new Extension.MessageListener() {
|
||||
@Override
|
||||
public void act(HMessage message) {
|
||||
System.out.println("just testing");
|
||||
}
|
||||
});
|
||||
intercept(HMessage.Side.TOSERVER, message -> System.out.println("just testing"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -13,46 +13,45 @@ import java.util.concurrent.Semaphore;
|
||||
*/
|
||||
public abstract class ExtensionForm extends Application {
|
||||
|
||||
private Extension extension = null;
|
||||
private volatile Extension extension;
|
||||
protected static String[] args;
|
||||
protected volatile Stage primaryStage;
|
||||
|
||||
private ExtensionForm realForm = null;
|
||||
private volatile ExtensionForm realForm = null;
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
ExtensionInfo extInfo = getClass().getAnnotation(ExtensionInfo.class);
|
||||
Semaphore semaphore = new Semaphore(1);
|
||||
semaphore.acquire();
|
||||
|
||||
realForm = launchForm(primaryStage);
|
||||
realForm.extension = new Extension(args) {
|
||||
@Override
|
||||
protected void init() {
|
||||
realForm.initExtension();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onClick() {
|
||||
realForm.onClick();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStartConnection() {
|
||||
realForm.onStartConnection();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEndConnection() {
|
||||
realForm.onEndConnection();
|
||||
}
|
||||
|
||||
@Override
|
||||
ExtensionInfo getInfoAnnotations() {
|
||||
return extInfo;
|
||||
}
|
||||
};
|
||||
realForm.primaryStage = primaryStage;
|
||||
Thread t = new Thread(() -> {
|
||||
realForm.extension = new Extension(args) {
|
||||
@Override
|
||||
protected void init() {
|
||||
realForm.initExtension();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onClick() {
|
||||
realForm.onClick();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStartConnection() {
|
||||
realForm.onStartConnection();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEndConnection() {
|
||||
realForm.onEndConnection();
|
||||
}
|
||||
|
||||
@Override
|
||||
ExtensionInfo getInfoAnnotations() {
|
||||
return extInfo;
|
||||
}
|
||||
};
|
||||
semaphore.release();
|
||||
realForm.extension.run();
|
||||
// Platform.runLater(primaryStage::close);
|
||||
//when the extension has ended, close this process
|
||||
@ -60,10 +59,7 @@ public abstract class ExtensionForm extends Application {
|
||||
});
|
||||
t.start();
|
||||
|
||||
semaphore.acquire();
|
||||
Platform.setImplicitExit(false);
|
||||
realForm = launchForm(primaryStage);
|
||||
realForm.primaryStage = primaryStage;
|
||||
|
||||
primaryStage.setOnCloseRequest(event -> {
|
||||
event.consume();
|
||||
|
@ -291,7 +291,9 @@ public class Extensions extends SubForm {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
extension.onClick(observable -> extension.sendMessage(new HPacket(OUTGOING_MESSAGES_IDS.ONDOUBLECLICK)));
|
||||
extension.onClick(observable -> {
|
||||
extension.sendMessage(new HPacket(OUTGOING_MESSAGES_IDS.ONDOUBLECLICK));
|
||||
});
|
||||
|
||||
Platform.runLater(() -> producer.extensionConnected(extension));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user