Dieser Commit ist enthalten in:
Ursprung
089e45a4fb
Commit
75cd23fd77
@ -35,6 +35,7 @@ public class SWAnvilInv {
|
||||
private final Player player;
|
||||
private final String defaultText;
|
||||
|
||||
private Runnable leftCallback;
|
||||
private Consumer<String> callback;
|
||||
|
||||
public SWAnvilInv(Player p, String t) {
|
||||
@ -42,7 +43,7 @@ public class SWAnvilInv {
|
||||
}
|
||||
|
||||
public SWAnvilInv(Player p, String t, String defaultText) {
|
||||
builder = new AnvilGUI.Builder().plugin(Core.getInstance()).title(t).text("»" + defaultText).onComplete(this::onResult);
|
||||
builder = new AnvilGUI.Builder().plugin(Core.getInstance()).title(t).text("»" + defaultText).onClick(this::onResult);
|
||||
this.defaultText = defaultText;
|
||||
player = p;
|
||||
}
|
||||
@ -68,7 +69,7 @@ public class SWAnvilInv {
|
||||
}
|
||||
|
||||
public void addLeftCallback(Runnable callback) {
|
||||
builder.onLeftInputClick(p -> callback.run());
|
||||
leftCallback = callback;
|
||||
}
|
||||
|
||||
public void addCloseCallback(Runnable callback) {
|
||||
@ -80,7 +81,15 @@ public class SWAnvilInv {
|
||||
builder.open(player);
|
||||
}
|
||||
|
||||
private List<AnvilGUI.ResponseAction> onResult(Player player, String s) {
|
||||
private List<AnvilGUI.ResponseAction> onResult(Integer slot, AnvilGUI.StateSnapshot state) {
|
||||
if(slot != AnvilGUI.Slot.OUTPUT) {
|
||||
if(slot == AnvilGUI.Slot.INPUT_LEFT && leftCallback != null)
|
||||
leftCallback.run();
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
String s = state.getText();
|
||||
if(s.startsWith("»"))
|
||||
s = s.substring(1);
|
||||
callback.accept(s);
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren