mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-11-23 08:50:52 +01:00
ExtensionForm development
This commit is contained in:
parent
4b6ad8fd05
commit
bbbf872b4f
@ -1,3 +1,3 @@
|
|||||||
Manifest-Version: 1.0
|
Manifest-Version: 1.0
|
||||||
Main-Class: main.extensions.examples.AdminOnConnect
|
Main-Class: main.extensions.examples.adminonconnect.AdminOnConnect
|
||||||
|
|
||||||
|
@ -258,11 +258,20 @@ public abstract class Extension {
|
|||||||
|
|
||||||
private boolean isOnClickMethodUsed() {
|
private boolean isOnClickMethodUsed() {
|
||||||
|
|
||||||
try {
|
Class<? extends Extension> c = getClass();
|
||||||
return !getClass().getDeclaredMethod("onClick").getDeclaringClass().equals(Extension.class);
|
|
||||||
} catch (NoSuchMethodException e) {
|
while (c != Extension.class) {
|
||||||
// e.printStackTrace();
|
try {
|
||||||
|
c.getDeclaredMethod("onClick");
|
||||||
|
// if it didnt error, onClick exists
|
||||||
|
return true;
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
c = (Class<? extends Extension>) c.getSuperclass();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
134
src/main/extensions/ExtensionForm.java
Normal file
134
src/main/extensions/ExtensionForm.java
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
package main.extensions;
|
||||||
|
|
||||||
|
import javafx.application.Application;
|
||||||
|
import javafx.application.Platform;
|
||||||
|
import javafx.event.EventHandler;
|
||||||
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.scene.Parent;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
import javafx.stage.WindowEvent;
|
||||||
|
import main.protocol.HMessage;
|
||||||
|
import main.protocol.HPacket;
|
||||||
|
import main.ui.GEarthController;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Jonas on 22/09/18.
|
||||||
|
*/
|
||||||
|
public abstract class ExtensionForm extends Application {
|
||||||
|
|
||||||
|
private Extension extension = null;
|
||||||
|
protected static String[] args;
|
||||||
|
private volatile Stage primaryStage = null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start(Stage primaryStage) throws Exception {
|
||||||
|
Platform.setImplicitExit(false);
|
||||||
|
setStageData(primaryStage);
|
||||||
|
this.primaryStage = primaryStage;
|
||||||
|
primaryStage.setOnCloseRequest(event -> {
|
||||||
|
event.consume();
|
||||||
|
Platform.runLater(primaryStage::hide);
|
||||||
|
});
|
||||||
|
ExtensionForm thiss = this;
|
||||||
|
Thread t = new Thread(() -> {
|
||||||
|
extension = new Extension(args) {
|
||||||
|
@Override
|
||||||
|
protected String getTitle() {
|
||||||
|
return thiss.getTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getDescription() {
|
||||||
|
return thiss.getDescription();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getVersion() {
|
||||||
|
return thiss.getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getAuthor() {
|
||||||
|
return thiss.getAuthor();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
thiss.initExtension();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onClick() {
|
||||||
|
thiss.onClick();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStartConnection() {
|
||||||
|
thiss.onStartConnection();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onEndConnection() {
|
||||||
|
thiss.onEndConnection();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Platform.runLater(primaryStage::close);
|
||||||
|
});
|
||||||
|
t.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void setStageData(Stage primaryStage) throws Exception;
|
||||||
|
|
||||||
|
protected boolean requestFlags(Extension.FlagsCheckListener flagRequestCallback){
|
||||||
|
return extension.requestFlags(flagRequestCallback);
|
||||||
|
}
|
||||||
|
protected void writeToConsole(String s) {
|
||||||
|
extension.writeToConsole(s);
|
||||||
|
}
|
||||||
|
protected void intercept(HMessage.Side side, Extension.MessageListener messageListener) {
|
||||||
|
extension.intercept(side, messageListener);
|
||||||
|
}
|
||||||
|
protected void intercept(HMessage.Side side, int headerId, Extension.MessageListener messageListener){
|
||||||
|
extension.intercept(side, headerId, messageListener);
|
||||||
|
}
|
||||||
|
protected boolean sendToServer(HPacket packet){
|
||||||
|
return extension.sendToServer(packet);
|
||||||
|
}
|
||||||
|
protected boolean sendToClient(HPacket packet){
|
||||||
|
return extension.sendToClient(packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets called when a connection has been established with G-Earth.
|
||||||
|
* This does not imply a connection with Habbo is setup.
|
||||||
|
*/
|
||||||
|
protected void initExtension(){}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The application got doubleclicked from the G-Earth interface. Doing something here is optional
|
||||||
|
*/
|
||||||
|
private void onClick(){
|
||||||
|
Platform.runLater(() -> {
|
||||||
|
primaryStage.show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A connection with Habbo has been started
|
||||||
|
*/
|
||||||
|
protected void onStartConnection(){}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A connection with Habbo has ended
|
||||||
|
*/
|
||||||
|
protected void onEndConnection(){}
|
||||||
|
|
||||||
|
protected abstract String getTitle();
|
||||||
|
protected abstract String getDescription();
|
||||||
|
protected abstract String getVersion();
|
||||||
|
protected abstract String getAuthor();
|
||||||
|
|
||||||
|
}
|
58
src/main/extensions/FXApplication.java
Normal file
58
src/main/extensions/FXApplication.java
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
package main.extensions;
|
||||||
|
|
||||||
|
import javafx.application.Application;
|
||||||
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.scene.Parent;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Jonas on 22/09/18.
|
||||||
|
*/
|
||||||
|
public class FXApplication extends Application {
|
||||||
|
|
||||||
|
public interface InitStage {
|
||||||
|
void callback(Stage primaryStage, Parent root);
|
||||||
|
}
|
||||||
|
private InitStage initStage;
|
||||||
|
private URL layoutLocation;
|
||||||
|
private boolean[] isOpen = {false};
|
||||||
|
|
||||||
|
public FXApplication(URL layoutLocation, InitStage initStage) {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.layoutLocation = layoutLocation;
|
||||||
|
this.initStage = initStage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start(Stage primaryStage) throws Exception {
|
||||||
|
FXMLLoader loader = new FXMLLoader(layoutLocation);
|
||||||
|
Parent root = loader.load();
|
||||||
|
|
||||||
|
initStage.callback(primaryStage, root);
|
||||||
|
primaryStage.show();
|
||||||
|
|
||||||
|
primaryStage.setOnCloseRequest(event -> isOpen[0] = false);
|
||||||
|
isOpen[0] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop() throws Exception {
|
||||||
|
super.stop();
|
||||||
|
|
||||||
|
isOpen[0] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isOpen() {
|
||||||
|
return isOpen[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void open() {
|
||||||
|
if (!isOpen()) {
|
||||||
|
launch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package main.extensions.examples;
|
package main.extensions.examples.adminonconnect;
|
||||||
|
|
||||||
import main.extensions.Extension;
|
import main.extensions.Extension;
|
||||||
import main.protocol.HMessage;
|
import main.protocol.HMessage;
|
@ -0,0 +1,48 @@
|
|||||||
|
package main.extensions.examples.blockreplacepackets;
|
||||||
|
|
||||||
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.scene.Parent;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
import main.extensions.ExtensionForm;
|
||||||
|
import main.ui.GEarthController;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Jonas on 22/09/18.
|
||||||
|
*/
|
||||||
|
public class BlockAndReplacePackets extends ExtensionForm {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
ExtensionForm.args = args;
|
||||||
|
launch(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initExtension() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStageData(Stage primaryStage) throws Exception {
|
||||||
|
FXMLLoader loader = new FXMLLoader(BlockAndReplacePackets.class.getResource("blockreplace.fxml"));
|
||||||
|
Parent root = loader.load();
|
||||||
|
|
||||||
|
primaryStage.setTitle("Packet blocker and replacer");
|
||||||
|
primaryStage.setScene(new Scene(root, 565, 262));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getTitle() {
|
||||||
|
return "iManipulate";
|
||||||
|
}
|
||||||
|
protected String getDescription() {
|
||||||
|
return "Block &/ replace packets";
|
||||||
|
}
|
||||||
|
protected String getVersion() {
|
||||||
|
return "0.1";
|
||||||
|
}
|
||||||
|
protected String getAuthor() {
|
||||||
|
return "sirjonasxx";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?import javafx.scene.control.TextArea?>
|
||||||
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
|
<?import javafx.scene.layout.GridPane?>
|
||||||
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
|
|
||||||
|
<GridPane prefHeight="260.0" prefWidth="179.0" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1" fx:controller="main.extensions.examples.blockreplacepackets.BlockAndReplacePackets">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="367.0" minWidth="10.0" prefWidth="163.0" />
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
</rowConstraints>
|
||||||
|
<children>
|
||||||
|
<GridPane>
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints maxHeight="121.0" minHeight="10.0" prefHeight="28.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints maxHeight="234.0" minHeight="10.0" prefHeight="234.0" vgrow="SOMETIMES" />
|
||||||
|
</rowConstraints>
|
||||||
|
<children>
|
||||||
|
<TextArea fx:id="text" editable="false" prefHeight="200.0" prefWidth="200.0" GridPane.rowIndex="1">
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||||
|
</GridPane.margin>
|
||||||
|
</TextArea>
|
||||||
|
<Label alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" text="Blocks packets:" textAlignment="CENTER" GridPane.halignment="CENTER" GridPane.valignment="CENTER" />
|
||||||
|
</children>
|
||||||
|
</GridPane>
|
||||||
|
</children>
|
||||||
|
</GridPane>
|
@ -1,4 +1,4 @@
|
|||||||
package main.extensions.examples;
|
package main.extensions.examples.speechcolorizer;
|
||||||
|
|
||||||
import main.extensions.Extension;
|
import main.extensions.Extension;
|
||||||
import main.protocol.HMessage;
|
import main.protocol.HMessage;
|
7
src/main/extensions/extra/Inspector.java
Normal file
7
src/main/extensions/extra/Inspector.java
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package main.extensions.extra;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Jonas on 22/09/18.
|
||||||
|
*/
|
||||||
|
public class Inspector {
|
||||||
|
}
|
@ -4,6 +4,7 @@ import javafx.geometry.Insets;
|
|||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.ScrollPane;
|
import javafx.scene.control.ScrollPane;
|
||||||
|
import javafx.scene.control.Tooltip;
|
||||||
import javafx.scene.input.MouseEvent;
|
import javafx.scene.input.MouseEvent;
|
||||||
import javafx.scene.layout.*;
|
import javafx.scene.layout.*;
|
||||||
import javafx.scene.text.Font;
|
import javafx.scene.text.Font;
|
||||||
@ -66,6 +67,8 @@ public class ExtensionItemContainer extends GridPane {
|
|||||||
|
|
||||||
|
|
||||||
DeleteButton deleteButton = new DeleteButton();
|
DeleteButton deleteButton = new DeleteButton();
|
||||||
|
Tooltip delete = new Tooltip("Close connection with this extension");
|
||||||
|
Tooltip.install(deleteButton,delete);
|
||||||
deleteButton.show();
|
deleteButton.show();
|
||||||
deleteButton.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> item.isRemoveClickTrigger());
|
deleteButton.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> item.isRemoveClickTrigger());
|
||||||
SimpleClickButton clickButton = new SimpleClickButton();
|
SimpleClickButton clickButton = new SimpleClickButton();
|
||||||
|
Loading…
Reference in New Issue
Block a user