Add AnvilInv LeftClick and SchematicSelector AnvilInv returns
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Dieser Commit ist enthalten in:
Ursprung
3e5347dfef
Commit
7ce6668de4
@ -42,6 +42,7 @@ SCHEM_SELECTOR_SORTING_UPDATE=Last update
|
|||||||
SCHEM_SELECTOR_SORTING_DIRECTION=§e{0} §7order
|
SCHEM_SELECTOR_SORTING_DIRECTION=§e{0} §7order
|
||||||
SCHEM_SELECTOR_SORTING_ASC=Ascending
|
SCHEM_SELECTOR_SORTING_ASC=Ascending
|
||||||
SCHEM_SELECTOR_SORTING_DSC=Descending
|
SCHEM_SELECTOR_SORTING_DSC=Descending
|
||||||
|
SCHEM_SELECTOR_CLICK_BACK=§7Click to go back
|
||||||
|
|
||||||
SCHEM_SELECTOR_ITEM_NAME=§e{0}
|
SCHEM_SELECTOR_ITEM_NAME=§e{0}
|
||||||
SCHEM_SELECTOR_ITEM_NAME_FILTER=§7{0}
|
SCHEM_SELECTOR_ITEM_NAME_FILTER=§7{0}
|
||||||
|
@ -42,6 +42,7 @@ SCHEM_SELECTOR_SORTING_UPDATE=Letztes Update
|
|||||||
SCHEM_SELECTOR_SORTING_DIRECTION=§7Richtung: §e{0}
|
SCHEM_SELECTOR_SORTING_DIRECTION=§7Richtung: §e{0}
|
||||||
SCHEM_SELECTOR_SORTING_ASC=Aufsteigend
|
SCHEM_SELECTOR_SORTING_ASC=Aufsteigend
|
||||||
SCHEM_SELECTOR_SORTING_DSC=Absteigend
|
SCHEM_SELECTOR_SORTING_DSC=Absteigend
|
||||||
|
SCHEM_SELECTOR_CLICK_BACK=§7Klicke hier, um zurückzugehen
|
||||||
|
|
||||||
SCHEM_SELECTOR_CREATE_DIR_TITLE=Ordner erstellen
|
SCHEM_SELECTOR_CREATE_DIR_TITLE=Ordner erstellen
|
||||||
|
|
||||||
|
@ -66,6 +66,10 @@ public class SWAnvilInv {
|
|||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addLeftCallback(Runnable callback) {
|
||||||
|
builder.onLeftInputClick(p -> callback.run());
|
||||||
|
}
|
||||||
|
|
||||||
public void addCloseCallback(Runnable callback) {
|
public void addCloseCallback(Runnable callback) {
|
||||||
builder.onClose(p -> callback.run());
|
builder.onClose(p -> callback.run());
|
||||||
}
|
}
|
||||||
|
@ -25,11 +25,13 @@ import de.steamwar.sql.SchematicNode;
|
|||||||
import de.steamwar.sql.SchematicType;
|
import de.steamwar.sql.SchematicType;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class SchematicSelector {
|
public class SchematicSelector {
|
||||||
@ -249,9 +251,23 @@ public class SchematicSelector {
|
|||||||
return new SWListInv.SWListEntry<>(item, node);
|
return new SWListInv.SWListEntry<>(item, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addLeftCloseAction(SWAnvilInv inv, Runnable runnable) {
|
||||||
|
AtomicBoolean wasLeft = new AtomicBoolean(false);
|
||||||
|
inv.addCloseCallback(() -> {
|
||||||
|
if(injectable.onAnvilInvCloseAction(this) == SchematicSelectorInjectable.AnvilInvCloseAction.REOPEN && !wasLeft.get()) {
|
||||||
|
player.closeInventory();
|
||||||
|
Bukkit.getScheduler().runTaskLater(Core.getInstance(), runnable, 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
inv.addLeftCallback(() -> {
|
||||||
|
wasLeft.set(true);
|
||||||
|
runnable.run();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void createFolderIn(SchematicNode parent) {
|
private void createFolderIn(SchematicNode parent) {
|
||||||
SWAnvilInv inv = new SWAnvilInv(player, Core.MESSAGE.parse("SCHEM_SELECTOR_CREATE_DIR_TITLE", player));
|
SWAnvilInv inv = new SWAnvilInv(player, Core.MESSAGE.parse("SCHEM_SELECTOR_CREATE_DIR_TITLE", player));
|
||||||
inv.setItem(Material.CHEST);
|
inv.setItem(Material.CHEST, Collections.singletonList(Core.MESSAGE.parse("SCHEM_SELECTOR_CLICK_BACK", player)), false);
|
||||||
inv.setCallback(s -> {
|
inv.setCallback(s -> {
|
||||||
if(!SchematicNode.invalidSchemName(new String[] {s})) {
|
if(!SchematicNode.invalidSchemName(new String[] {s})) {
|
||||||
if(injectable.onFolderCreate(this, s)) {
|
if(injectable.onFolderCreate(this, s)) {
|
||||||
@ -262,6 +278,7 @@ public class SchematicSelector {
|
|||||||
}
|
}
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
});
|
});
|
||||||
|
addLeftCloseAction(inv, this::reOpen);
|
||||||
inv.open();
|
inv.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,11 +290,12 @@ public class SchematicSelector {
|
|||||||
openFilter();
|
openFilter();
|
||||||
} else {
|
} else {
|
||||||
SWAnvilInv swAnvilInv = new SWAnvilInv(player, Core.MESSAGE.parse("SCHEM_SELECTOR_FILTER_ENTER_NAME", player));
|
SWAnvilInv swAnvilInv = new SWAnvilInv(player, Core.MESSAGE.parse("SCHEM_SELECTOR_FILTER_ENTER_NAME", player));
|
||||||
swAnvilInv.setItem(Material.NAME_TAG);
|
swAnvilInv.setItem(Material.NAME_TAG, Collections.singletonList(Core.MESSAGE.parse("SCHEM_SELECTOR_CLICK_BACK", player)), false);
|
||||||
swAnvilInv.setCallback(s -> {
|
swAnvilInv.setCallback(s -> {
|
||||||
filter.setName(s);
|
filter.setName(s);
|
||||||
openFilter();
|
openFilter();
|
||||||
});
|
});
|
||||||
|
addLeftCloseAction(swAnvilInv, this::openFilter);
|
||||||
swAnvilInv.open();
|
swAnvilInv.open();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -293,13 +311,14 @@ public class SchematicSelector {
|
|||||||
openFilter();
|
openFilter();
|
||||||
} else {
|
} else {
|
||||||
SWAnvilInv swAnvilInv = new SWAnvilInv(player, Core.MESSAGE.parse("SCHEM_SELECTOR_FILTER_ENTER_OWNER", player));
|
SWAnvilInv swAnvilInv = new SWAnvilInv(player, Core.MESSAGE.parse("SCHEM_SELECTOR_FILTER_ENTER_OWNER", player));
|
||||||
swAnvilInv.setItem(SWItem.getMaterial("SKULL_ITEM"), (byte) 3);
|
swAnvilInv.setItem(SWItem.getMaterial("SKULL_ITEM"), (byte) 3, Collections.singletonList(Core.MESSAGE.parse("SCHEM_SELECTOR_CLICK_BACK", player)), false);
|
||||||
swAnvilInv.setCallback(s -> {
|
swAnvilInv.setCallback(s -> {
|
||||||
if(SteamwarUser.get(s) != null) {
|
if(SteamwarUser.get(s) != null) {
|
||||||
filter.setOwner(SteamwarUser.get(s).getId());
|
filter.setOwner(SteamwarUser.get(s).getId());
|
||||||
}
|
}
|
||||||
openFilter();
|
openFilter();
|
||||||
});
|
});
|
||||||
|
addLeftCloseAction(swAnvilInv, this::openFilter);
|
||||||
swAnvilInv.open();
|
swAnvilInv.open();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -45,8 +45,15 @@ public interface SchematicSelectorInjectable {
|
|||||||
|
|
||||||
default void onSelectorOpen(SchematicSelector selector, OpenFrom from) {}
|
default void onSelectorOpen(SchematicSelector selector, OpenFrom from) {}
|
||||||
|
|
||||||
|
default AnvilInvCloseAction onAnvilInvCloseAction(SchematicSelector selector) {return AnvilInvCloseAction.CLOSE;}
|
||||||
|
|
||||||
enum OpenFrom {
|
enum OpenFrom {
|
||||||
FRESH,
|
FRESH,
|
||||||
REOPEN
|
REOPEN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum AnvilInvCloseAction {
|
||||||
|
CLOSE,
|
||||||
|
REOPEN
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren