mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-11-27 02:40:51 +01:00
only display 'play'-button in extensions view if its used
This commit is contained in:
parent
86c546adc6
commit
4b6ad8fd05
@ -86,7 +86,8 @@ public abstract class Extension {
|
||||
response.appendString(getTitle())
|
||||
.appendString(getAuthor())
|
||||
.appendString(getVersion())
|
||||
.appendString(getDescription());
|
||||
.appendString(getDescription())
|
||||
.appendBoolean(isOnClickMethodUsed());
|
||||
writeToStream(response.toBytes());
|
||||
}
|
||||
else if (packet.headerId() == Extensions.OUTGOING_MESSAGES_IDS.CONNECTIONSTART) {
|
||||
@ -255,6 +256,16 @@ public abstract class Extension {
|
||||
}
|
||||
|
||||
|
||||
private boolean isOnClickMethodUsed() {
|
||||
|
||||
try {
|
||||
return !getClass().getDeclaredMethod("onClick").getDeclaringClass().equals(Extension.class);
|
||||
} catch (NoSuchMethodException e) {
|
||||
// e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets called when a connection has been established with G-Earth.
|
||||
* This does not imply a connection with Habbo is setup.
|
||||
|
@ -40,10 +40,10 @@ public class AdminOnConnect extends Extension {
|
||||
done = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onClick() {
|
||||
System.out.println("clicked");
|
||||
}
|
||||
// @Override
|
||||
// protected void onClick() {
|
||||
// System.out.println("clicked");
|
||||
// }
|
||||
|
||||
protected String getTitle() {
|
||||
return "Always admin!";
|
||||
|
@ -69,11 +69,13 @@ public class ExtensionItemContainer extends GridPane {
|
||||
deleteButton.show();
|
||||
deleteButton.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> item.isRemoveClickTrigger());
|
||||
SimpleClickButton clickButton = new SimpleClickButton();
|
||||
if (item.isFireButtonUsed()) {
|
||||
clickButton.show();
|
||||
}
|
||||
clickButton.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> item.isClickTrigger());
|
||||
|
||||
HBox buttonsBox = new HBox(clickButton, deleteButton);
|
||||
buttonsBox.setSpacing(10);
|
||||
buttonsBox.setSpacing(item.isFireButtonUsed() ? 10 : 0);
|
||||
buttonsBox.setAlignment(Pos.CENTER);
|
||||
GridPane.setMargin(buttonsBox, new Insets(0, 5, 0, 5));
|
||||
add(buttonsBox, 4, 0);
|
||||
|
@ -23,6 +23,7 @@ public class GEarthExtension {
|
||||
private String author;
|
||||
private String version;
|
||||
private String description;
|
||||
private boolean fireEventButtonVisible;
|
||||
|
||||
private Socket connection;
|
||||
|
||||
@ -57,6 +58,7 @@ public class GEarthExtension {
|
||||
packet.readString(),
|
||||
packet.readString(),
|
||||
packet.readString(),
|
||||
packet.readBoolean(),
|
||||
connection,
|
||||
onDisconnectedCallback
|
||||
);
|
||||
@ -70,11 +72,12 @@ public class GEarthExtension {
|
||||
|
||||
}
|
||||
|
||||
private GEarthExtension(String title, String author, String version, String description, Socket connection, OnDisconnectedCallback onDisconnectedCallback) {
|
||||
private GEarthExtension(String title, String author, String version, String description, boolean fireEventButtonVisible, Socket connection, OnDisconnectedCallback onDisconnectedCallback) {
|
||||
this.title = title;
|
||||
this.author = author;
|
||||
this.version = version;
|
||||
this.description = description;
|
||||
this.fireEventButtonVisible = fireEventButtonVisible;
|
||||
this.connection = connection;
|
||||
|
||||
GEarthExtension selff = this;
|
||||
@ -139,6 +142,10 @@ public class GEarthExtension {
|
||||
return version;
|
||||
}
|
||||
|
||||
public boolean isFireButtonUsed() {
|
||||
return fireEventButtonVisible;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean closeConnection() {
|
||||
|
Loading…
Reference in New Issue
Block a user