forked from unimatrix/web
Route active Home Block deeds through DuneMenus
This commit is contained in:
parent
6985ecb624
commit
97d958609d
2 changed files with 46 additions and 1 deletions
|
|
@ -57,6 +57,11 @@ public final class DuneMenusPlugin extends JavaPlugin implements TabExecutor {
|
|||
|
||||
Backend backend() { return backend; }
|
||||
|
||||
public void warObjective(Player player, com.google.gson.JsonObject target, Runnable capture) {
|
||||
if (!getServer().isPrimaryThread() || !player.isOnline() || !player.hasPermission("dunemenus.use")) return;
|
||||
new WarObjectiveMenu(this, player, target.deepCopy(), capture).open();
|
||||
}
|
||||
|
||||
void requestPackStatus(Player player) {
|
||||
if (player.isOnline()) player.sendPluginMessage(this, PACK_CONTROL,
|
||||
"common-status".getBytes(java.nio.charset.StandardCharsets.US_ASCII));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
package com.dunerealms.menus;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
final class WarObjectiveMenu extends Menu {
|
||||
private final JsonObject target;
|
||||
private final Runnable capture;
|
||||
|
||||
WarObjectiveMenu(DuneMenusPlugin plugin, Player player, JsonObject target, Runnable capture) {
|
||||
super(plugin, player, new HubMenu(plugin, player));
|
||||
this.target = target;
|
||||
this.capture = capture;
|
||||
}
|
||||
|
||||
String id() { return "war-objective"; }
|
||||
Skin skin() { return Skin.CLAN; }
|
||||
String title() { return "Home Block deed"; }
|
||||
int rows() { return 3; }
|
||||
|
||||
void draw() {
|
||||
backdrop(Material.BLACK_STAINED_GLASS_PANE);
|
||||
back(18);
|
||||
var text = MiniMessage.miniMessage();
|
||||
put(4, Ui.item(Material.FILLED_MAP, "<gold>" + text.escapeTags(target.get("name").getAsString()),
|
||||
"<gray>Held by " + text.escapeTags(target.get("owner").getAsString())));
|
||||
if (target.get("canCapture").getAsBoolean()) {
|
||||
put(22, Ui.item(Material.WRITABLE_BOOK, "<gold>Capture deed"), click -> {
|
||||
end();
|
||||
capture.run();
|
||||
});
|
||||
} else {
|
||||
put(22, Ui.item(Material.GRAY_DYE, "<gray>This deed cannot be contested by your roster"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue

Staff