only display 'play'-button in extensions view if its used

This commit is contained in:
sirjonasxx 2018-09-22 14:04:17 +02:00
parent 86c546adc6
commit 4b6ad8fd05
4 changed files with 28 additions and 8 deletions

View File

@ -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.

View File

@ -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!";

View File

@ -69,11 +69,13 @@ public class ExtensionItemContainer extends GridPane {
deleteButton.show();
deleteButton.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> item.isRemoveClickTrigger());
SimpleClickButton clickButton = new SimpleClickButton();
clickButton.show();
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);

View File

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