mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-11-23 08:50:52 +01:00
changes in extensions
This commit is contained in:
parent
bb608102a7
commit
072bf1d273
@ -23,7 +23,11 @@ public abstract class Extension {
|
|||||||
void act(String[] args);
|
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)
|
||||||
|
|
||||||
|
private String[] args;
|
||||||
|
private boolean isCorrupted = false;
|
||||||
private static final String[] PORT_FLAG = {"--port", "-p"};
|
private static final String[] PORT_FLAG = {"--port", "-p"};
|
||||||
private static final String[] FILE_FLAG = {"--filename", "-f"};
|
private static final String[] FILE_FLAG = {"--filename", "-f"};
|
||||||
|
|
||||||
@ -49,6 +53,8 @@ public abstract class Extension {
|
|||||||
*/
|
*/
|
||||||
public Extension(String[] args) {
|
public Extension(String[] args) {
|
||||||
//obtain port
|
//obtain port
|
||||||
|
this.args = args;
|
||||||
|
|
||||||
|
|
||||||
if (getInfoAnnotations() == null) {
|
if (getInfoAnnotations() == null) {
|
||||||
System.err.println("Extension info not found\n\n" +
|
System.err.println("Extension info not found\n\n" +
|
||||||
@ -59,6 +65,17 @@ public abstract class Extension {
|
|||||||
" Version = \"...\",\n" +
|
" Version = \"...\",\n" +
|
||||||
" Author = \"...\"" +
|
" Author = \"...\"" +
|
||||||
"\n)");
|
"\n)");
|
||||||
|
isCorrupted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getArgument(args, PORT_FLAG) == null) {
|
||||||
|
System.err.println("Don't forget to include G-Earth's port as program parameters (-p {port})");
|
||||||
|
isCorrupted = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
if (isCorrupted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +84,7 @@ public abstract class Extension {
|
|||||||
|
|
||||||
Socket gEarthExtensionServer = null;
|
Socket gEarthExtensionServer = null;
|
||||||
try {
|
try {
|
||||||
gEarthExtensionServer = new Socket("127.0.0.2", port);
|
gEarthExtensionServer = new Socket("127.0.0.1", port);
|
||||||
InputStream in = gEarthExtensionServer.getInputStream();
|
InputStream in = gEarthExtensionServer.getInputStream();
|
||||||
DataInputStream dIn = new DataInputStream(in);
|
DataInputStream dIn = new DataInputStream(in);
|
||||||
out = gEarthExtensionServer.getOutputStream();
|
out = gEarthExtensionServer.getOutputStream();
|
||||||
@ -105,7 +122,9 @@ public abstract class Extension {
|
|||||||
.appendString(info.Description())
|
.appendString(info.Description())
|
||||||
.appendBoolean(isOnClickMethodUsed())
|
.appendBoolean(isOnClickMethodUsed())
|
||||||
.appendBoolean(file == null)
|
.appendBoolean(file == null)
|
||||||
.appendString(file == null ? "": file);
|
.appendString(file == null ? "": file)
|
||||||
|
.appendBoolean(CANLEAVE)
|
||||||
|
.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) {
|
||||||
|
@ -55,6 +55,7 @@ public abstract class ExtensionForm extends Application {
|
|||||||
return extInfo;
|
return extInfo;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
extension.run();
|
||||||
// Platform.runLater(primaryStage::close);
|
// Platform.runLater(primaryStage::close);
|
||||||
//when the extension has ended, close this process
|
//when the extension has ended, close this process
|
||||||
Platform.exit();
|
Platform.exit();
|
||||||
|
@ -20,7 +20,7 @@ import main.protocol.HPacket;
|
|||||||
public class AdminOnConnect extends Extension {
|
public class AdminOnConnect extends Extension {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
new AdminOnConnect(args);
|
new AdminOnConnect(args).run();
|
||||||
}
|
}
|
||||||
public AdminOnConnect(String[] args) {
|
public AdminOnConnect(String[] args) {
|
||||||
super(args);
|
super(args);
|
||||||
|
@ -25,7 +25,7 @@ import java.util.Random;
|
|||||||
public class SpeechColorizer extends Extension {
|
public class SpeechColorizer extends Extension {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
new SpeechColorizer(args);
|
new SpeechColorizer(args).run();
|
||||||
}
|
}
|
||||||
private SpeechColorizer(String[] args) {
|
private SpeechColorizer(String[] args) {
|
||||||
super(args);
|
super(args);
|
||||||
|
@ -70,16 +70,14 @@ public class ExtensionItemContainer extends GridPane {
|
|||||||
exitButton.show();
|
exitButton.show();
|
||||||
exitButton.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> item.isRemoveClickTrigger());
|
exitButton.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> item.isRemoveClickTrigger());
|
||||||
SimpleClickButton clickButton = new SimpleClickButton();
|
SimpleClickButton clickButton = new SimpleClickButton();
|
||||||
|
clickButton.show();
|
||||||
clickButton.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> item.isClickTrigger());
|
clickButton.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> item.isClickTrigger());
|
||||||
|
|
||||||
HBox buttonsBox = new HBox(clickButton, exitButton);
|
HBox buttonsBox = new HBox(clickButton, exitButton);
|
||||||
if (item.isFireButtonUsed()) {
|
|
||||||
clickButton.show();
|
clickButton.setVisible(item.isFireButtonUsed());
|
||||||
}
|
exitButton.setVisible(item.isLeaveButtonVisible());
|
||||||
else {
|
buttonsBox.setSpacing(8);
|
||||||
HBox.setMargin(exitButton, new Insets(0,0,0,24));
|
|
||||||
}
|
|
||||||
buttonsBox.setSpacing(item.isFireButtonUsed() ? 8 : 0);
|
|
||||||
buttonsBox.setAlignment(Pos.CENTER);
|
buttonsBox.setAlignment(Pos.CENTER);
|
||||||
GridPane.setMargin(buttonsBox, new Insets(0, 5, 0, 5));
|
GridPane.setMargin(buttonsBox, new Insets(0, 5, 0, 5));
|
||||||
add(buttonsBox, 4, 0);
|
add(buttonsBox, 4, 0);
|
||||||
|
@ -19,7 +19,10 @@ public class GEarthExtension {
|
|||||||
private String author;
|
private String author;
|
||||||
private String version;
|
private String version;
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
private boolean fireEventButtonVisible;
|
private boolean fireEventButtonVisible;
|
||||||
|
private boolean leaveButtonVisible;
|
||||||
|
private boolean deleteButtonVisible;
|
||||||
|
|
||||||
private boolean isInstalledExtension; // <- extension is in the extensions directory
|
private boolean isInstalledExtension; // <- extension is in the extensions directory
|
||||||
private String fileName;
|
private String fileName;
|
||||||
@ -53,13 +56,7 @@ public class GEarthExtension {
|
|||||||
|
|
||||||
if (packet.headerId() == Extensions.INCOMING_MESSAGES_IDS.EXTENSIONINFO) {
|
if (packet.headerId() == Extensions.INCOMING_MESSAGES_IDS.EXTENSIONINFO) {
|
||||||
GEarthExtension gEarthExtension = new GEarthExtension(
|
GEarthExtension gEarthExtension = new GEarthExtension(
|
||||||
packet.readString(),
|
packet,
|
||||||
packet.readString(),
|
|
||||||
packet.readString(),
|
|
||||||
packet.readString(),
|
|
||||||
packet.readBoolean(),
|
|
||||||
packet.readBoolean(),
|
|
||||||
packet.readString(),
|
|
||||||
connection,
|
connection,
|
||||||
onDisconnectedCallback
|
onDisconnectedCallback
|
||||||
);
|
);
|
||||||
@ -73,15 +70,21 @@ public class GEarthExtension {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private GEarthExtension(String title, String author, String version, String description, boolean fireEventButtonVisible, boolean isInstalledExtension, String fileName, Socket connection, OnDisconnectedCallback onDisconnectedCallback) {
|
private GEarthExtension(HPacket extensionInfo, Socket connection, OnDisconnectedCallback onDisconnectedCallback) {
|
||||||
this.title = title;
|
|
||||||
this.author = author;
|
|
||||||
this.version = version;
|
|
||||||
this.description = description;
|
|
||||||
this.fireEventButtonVisible = fireEventButtonVisible;
|
|
||||||
|
|
||||||
this.isInstalledExtension = isInstalledExtension;
|
|
||||||
this.fileName = fileName;
|
|
||||||
|
this.title = extensionInfo.readString();
|
||||||
|
this.author = extensionInfo.readString();
|
||||||
|
this.version = extensionInfo.readString();
|
||||||
|
this.description = extensionInfo.readString();
|
||||||
|
this.fireEventButtonVisible = extensionInfo.readBoolean();
|
||||||
|
|
||||||
|
this.isInstalledExtension = extensionInfo.readBoolean();
|
||||||
|
this.fileName = extensionInfo.readString();
|
||||||
|
|
||||||
|
this.leaveButtonVisible = extensionInfo.readBoolean();
|
||||||
|
this.deleteButtonVisible = extensionInfo.readBoolean();
|
||||||
|
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
|
|
||||||
@ -134,26 +137,27 @@ public class GEarthExtension {
|
|||||||
public String getAuthor() {
|
public String getAuthor() {
|
||||||
return author;
|
return author;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFireButtonUsed() {
|
public boolean isFireButtonUsed() {
|
||||||
return fireEventButtonVisible;
|
return fireEventButtonVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFileName() {
|
public String getFileName() {
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
public boolean isDeleteButtonVisible() {
|
||||||
|
return deleteButtonVisible;
|
||||||
|
}
|
||||||
|
public boolean isLeaveButtonVisible() {
|
||||||
|
return leaveButtonVisible;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isInstalledExtension() {
|
public boolean isInstalledExtension() {
|
||||||
return isInstalledExtension;
|
return isInstalledExtension;
|
||||||
|
Loading…
Reference in New Issue
Block a user