Implement the acl listing
Hopefully also implement the ACL untrust system via shift-click
This commit is contained in:
parent
a188657fb2
commit
291be34118
2 changed files with 84 additions and 3 deletions
|
@ -3,6 +3,7 @@ package dev.zontreck.ase.commands.warps;
|
|||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.mojang.brigadier.Command;
|
||||
|
@ -86,6 +87,16 @@ public class EditWarpCommand {
|
|||
AriasServerEssentials.getSelf().SaveConfiguration();
|
||||
}
|
||||
break;
|
||||
case untrust:
|
||||
if (args.length == 0 || args[0].isEmpty()) {
|
||||
// silently fail
|
||||
} else {
|
||||
OfflinePlayer toUntrust = Bukkit.getOfflinePlayer(args[0]);
|
||||
warp.allowedPlayers.remove(toUntrust.getUniqueId());
|
||||
AriasServerEssentials.getSelf().warps.put(warpName, warp);
|
||||
AriasServerEssentials.getSelf().SaveConfiguration();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -106,6 +117,7 @@ public class EditWarpCommand {
|
|||
mksrvwarp,
|
||||
acl,
|
||||
addacl,
|
||||
trust
|
||||
trust,
|
||||
untrust
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package dev.zontreck.ase.guis;
|
|||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import dev.zontreck.ase.warps.Warp;
|
||||
|
@ -48,6 +49,72 @@ public class WarpACLGUI {
|
|||
addButton.addAction(new PrimitiveAction(PrimitiveAction.SEND_COMMAND, "editwarp " + warpName + " addacl"));
|
||||
gui.add(addButton);
|
||||
|
||||
int startPos = page * 28;
|
||||
if (startPos > 0)
|
||||
startPos++;
|
||||
|
||||
int pageNumber = startPos / 28;
|
||||
int totalEntries = warp.allowedPlayers.size();
|
||||
int totalPages = totalEntries / 28;
|
||||
|
||||
gui.seek((9 * 5) + 3);
|
||||
if (pageNumber > 0) {
|
||||
PrimitiveItem btn = new PrimitiveItem(Material.RED_STAINED_GLASS_PANE,
|
||||
Component.text("<- Back", NamedTextColor.YELLOW), true,
|
||||
Component.text("Go back to the previous page", NamedTextColor.AQUA));
|
||||
btn.addAction(new PrimitiveAction(PrimitiveAction.SEND_COMMAND,
|
||||
"editwarp " + warpName + " acl " + (pageNumber - 1)));
|
||||
|
||||
gui.add(btn);
|
||||
}
|
||||
gui.seek((9 * 5) + 4);
|
||||
PrimitiveItem warpInfo = new PrimitiveItem(null,
|
||||
Component.text("Page " + (pageNumber + 1) + " / " + (totalPages + 1), NamedTextColor.YELLOW), true,
|
||||
Component.text("Warp Name: ", NamedTextColor.AQUA)
|
||||
.append(Component.text(warpName, NamedTextColor.DARK_PURPLE)));
|
||||
warpInfo.skull(player.getName());
|
||||
gui.add(warpInfo);
|
||||
|
||||
gui.seek((9 * 5) + 5);
|
||||
if (pageNumber < totalPages) {
|
||||
// Add a next page button
|
||||
PrimitiveItem btn = new PrimitiveItem(Material.GREEN_STAINED_GLASS_PANE,
|
||||
Component.text("Next ->", NamedTextColor.YELLOW), true,
|
||||
Component.text("Go to the next page", NamedTextColor.AQUA));
|
||||
btn.addAction(new PrimitiveAction(PrimitiveAction.SEND_COMMAND,
|
||||
"editwarp " + warpName + " acl " + (pageNumber + 1)));
|
||||
|
||||
gui.add(btn);
|
||||
}
|
||||
|
||||
gui.seek(10);
|
||||
|
||||
int row = 0;
|
||||
|
||||
for (int i = startPos; i < totalEntries; i++) {
|
||||
if (i < totalEntries) {
|
||||
OfflinePlayer authorizedPlayer = Bukkit.getOfflinePlayer(warp.allowedPlayers.get(i));
|
||||
|
||||
PrimitiveItem head = new PrimitiveItem(null,
|
||||
Component.text(authorizedPlayer.getName(), NamedTextColor.YELLOW), true,
|
||||
Component.text("This player is trusted.", NamedTextColor.DARK_GREEN),
|
||||
Component.text("SHIFT CLICK", NamedTextColor.AQUA), Component.text("--> Untrust player"));
|
||||
head.skull(authorizedPlayer.getName());
|
||||
head.shiftClickAction = new PrimitiveAction(PrimitiveAction.SEND_COMMAND,
|
||||
"editwarp " + warpName + " untrust " + authorizedPlayer.getName());
|
||||
head.addAction(new PrimitiveAction(PrimitiveAction.SEND_COMMAND,
|
||||
"editwarp " + warpName + " acl " + pageNumber));
|
||||
|
||||
gui.add(head);
|
||||
row++;
|
||||
|
||||
if (row > 7) {
|
||||
row = 0;
|
||||
gui.seek(gui.getPosition() + 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gui.doPresentation();
|
||||
}
|
||||
|
||||
|
@ -126,6 +193,8 @@ public class WarpACLGUI {
|
|||
|
||||
gui.add(head);
|
||||
|
||||
row++;
|
||||
|
||||
if (row > 7) {
|
||||
row = 0;
|
||||
gui.seek(gui.getPosition() + 2);
|
||||
|
@ -136,7 +205,7 @@ public class WarpACLGUI {
|
|||
// Prev Page button
|
||||
if (startPos > 0) {
|
||||
|
||||
PrimitiveItem prevButton = new PrimitiveItem(Material.GREEN_STAINED_GLASS_PANE,
|
||||
PrimitiveItem prevButton = new PrimitiveItem(Material.RED_STAINED_GLASS_PANE,
|
||||
Component.text("<- Previous Page", NamedTextColor.YELLOW), true,
|
||||
Component.text("Go to the previous page"));
|
||||
prevButton.addAction(new PrimitiveAction(PrimitiveAction.SEND_COMMAND,
|
||||
|
@ -148,7 +217,7 @@ public class WarpACLGUI {
|
|||
gui.seek((9 * 5) + 5);
|
||||
if (pageNumber < totalPages) {
|
||||
|
||||
PrimitiveItem nextButton = new PrimitiveItem(Material.RED_STAINED_GLASS_PANE,
|
||||
PrimitiveItem nextButton = new PrimitiveItem(Material.GREEN_STAINED_GLASS_PANE,
|
||||
Component.text("Next Page ->", NamedTextColor.YELLOW), true,
|
||||
Component.text("Go to the next page"));
|
||||
nextButton.addAction(new PrimitiveAction(PrimitiveAction.SEND_COMMAND,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue