feat: player management/check
This commit is contained in:
parent
119392320b
commit
6fae824fe2
5 changed files with 130 additions and 1 deletions
|
@ -106,6 +106,7 @@ public class AppearanceManager {
|
||||||
if (!actionResult.isError()) {
|
if (!actionResult.isError()) {
|
||||||
this.profile.setSkin(null);
|
this.profile.setSkin(null);
|
||||||
this.profile.setName(null);
|
this.profile.setName(null);
|
||||||
|
dataStore.getCache().cache(uuid, profile);
|
||||||
}
|
}
|
||||||
return actionResult;
|
return actionResult;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package xyz.atnrch.nicko.gui;
|
package xyz.atnrch.nicko.gui;
|
||||||
|
|
||||||
import xyz.atnrch.nicko.gui.items.admin.ManageCacheItem;
|
import xyz.atnrch.nicko.gui.items.admin.ManageCacheItem;
|
||||||
|
import xyz.atnrch.nicko.gui.items.admin.ManagePlayerItem;
|
||||||
import xyz.atnrch.nicko.gui.items.common.GoBackItem;
|
import xyz.atnrch.nicko.gui.items.common.GoBackItem;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import xyz.xenondevs.invui.gui.Gui;
|
import xyz.xenondevs.invui.gui.Gui;
|
||||||
|
@ -16,10 +17,11 @@ public class AdminGUI {
|
||||||
this.gui = Gui.normal()
|
this.gui = Gui.normal()
|
||||||
.setStructure(
|
.setStructure(
|
||||||
"# # # # # # # # #",
|
"# # # # # # # # #",
|
||||||
"# # # S U U # # #",
|
"# # # S C U # # #",
|
||||||
"B # # # # # # # #"
|
"B # # # # # # # #"
|
||||||
)
|
)
|
||||||
.addIngredient('S', new ManageCacheItem())
|
.addIngredient('S', new ManageCacheItem())
|
||||||
|
.addIngredient('C', new ManagePlayerItem())
|
||||||
.addIngredient('B', new GoBackItem(parent.getGUI(), parent.getTitle()))
|
.addIngredient('B', new GoBackItem(parent.getGUI(), parent.getTitle()))
|
||||||
.build();
|
.build();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
53
src/main/java/xyz/atnrch/nicko/gui/PlayerCheckGUI.java
Normal file
53
src/main/java/xyz/atnrch/nicko/gui/PlayerCheckGUI.java
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
package xyz.atnrch.nicko.gui;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import xyz.atnrch.nicko.gui.items.admin.check.PlayerInformationItem;
|
||||||
|
import xyz.atnrch.nicko.gui.items.common.GoBackItem;
|
||||||
|
import xyz.atnrch.nicko.gui.items.common.ScrollDownItem;
|
||||||
|
import xyz.atnrch.nicko.gui.items.common.ScrollUpItem;
|
||||||
|
import xyz.xenondevs.invui.gui.Gui;
|
||||||
|
import xyz.xenondevs.invui.gui.ScrollGui;
|
||||||
|
import xyz.xenondevs.invui.gui.structure.Markers;
|
||||||
|
import xyz.xenondevs.invui.item.Item;
|
||||||
|
import xyz.xenondevs.invui.window.Window;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class PlayerCheckGUI {
|
||||||
|
public static final String TITLE = "Nicko > Admin... > Check";
|
||||||
|
|
||||||
|
private final Player player;
|
||||||
|
private final Gui gui;
|
||||||
|
|
||||||
|
public PlayerCheckGUI(Player player) {
|
||||||
|
final List<Item> items = Bukkit.getOnlinePlayers().stream()
|
||||||
|
.map(Entity::getUniqueId)
|
||||||
|
.map(PlayerInformationItem::new)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
final AdminGUI parent = new AdminGUI(player);
|
||||||
|
gui = ScrollGui.items(guiItemBuilder -> {
|
||||||
|
guiItemBuilder.setStructure(
|
||||||
|
"x x x x x x x x U",
|
||||||
|
"x x x x x x x x #",
|
||||||
|
"x x x x x x x x #",
|
||||||
|
"x x x x x x x x #",
|
||||||
|
"x x x x x x x x D",
|
||||||
|
"B % % % % % % % %");
|
||||||
|
guiItemBuilder.addIngredient('x', Markers.CONTENT_LIST_SLOT_HORIZONTAL);
|
||||||
|
guiItemBuilder.addIngredient('U', new ScrollUpItem());
|
||||||
|
guiItemBuilder.addIngredient('D', new ScrollDownItem());
|
||||||
|
guiItemBuilder.addIngredient('B', new GoBackItem(parent.getGUI(), parent.getTitle()));
|
||||||
|
guiItemBuilder.setContent(items);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.player = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void open() {
|
||||||
|
Window.single().setGui(gui).setTitle(TITLE).open(player);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package xyz.atnrch.nicko.gui.items.admin;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import xyz.atnrch.nicko.gui.PlayerCheckGUI;
|
||||||
|
import xyz.xenondevs.invui.item.builder.ItemBuilder;
|
||||||
|
import xyz.xenondevs.invui.item.impl.SuppliedItem;
|
||||||
|
|
||||||
|
public class ManagePlayerItem extends SuppliedItem {
|
||||||
|
public ManagePlayerItem() {
|
||||||
|
super(() -> {
|
||||||
|
final ItemBuilder builder = new ItemBuilder(Material.WRITABLE_BOOK);
|
||||||
|
builder.setDisplayName("Check a player...");
|
||||||
|
builder.addLoreLines("§7See players' disguise information.");
|
||||||
|
return builder;
|
||||||
|
},
|
||||||
|
click -> true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent
|
||||||
|
event) {
|
||||||
|
if (clickType.isLeftClick() || clickType.isRightClick()) {
|
||||||
|
event.getView().close();
|
||||||
|
new PlayerCheckGUI(player).open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
package xyz.atnrch.nicko.gui.items.admin.check;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import xyz.atnrch.nicko.NickoBukkit;
|
||||||
|
import xyz.atnrch.nicko.appearance.AppearanceManager;
|
||||||
|
import xyz.atnrch.nicko.mojang.MojangAPI;
|
||||||
|
import xyz.xenondevs.invui.item.builder.ItemBuilder;
|
||||||
|
import xyz.xenondevs.invui.item.builder.SkullBuilder;
|
||||||
|
import xyz.xenondevs.invui.item.impl.AsyncItem;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class PlayerInformationItem extends AsyncItem {
|
||||||
|
private final MojangAPI mojangAPI = NickoBukkit.getInstance().getMojangAPI();
|
||||||
|
|
||||||
|
public PlayerInformationItem(UUID uuid) {
|
||||||
|
super(new ItemBuilder(Material.PAINTING).setDisplayName("§7§oLoading..."), () -> {
|
||||||
|
final Player player = Bukkit.getPlayer(uuid);
|
||||||
|
final SkullBuilder skull = new SkullBuilder(uuid);
|
||||||
|
|
||||||
|
final AppearanceManager appearanceManager = AppearanceManager.get(player);
|
||||||
|
if (appearanceManager.hasData()) {
|
||||||
|
skull.addLoreLines(
|
||||||
|
"§cNicked: §a✔",
|
||||||
|
"§cName: §6" + appearanceManager.getName(),
|
||||||
|
"§cSkin: §6" + appearanceManager.getSkin()
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
skull.addLoreLines(
|
||||||
|
"§cNicked: §c❌",
|
||||||
|
"§cName: §7N/A",
|
||||||
|
"§cSkin: §7N/A"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
skull.setDisplayName("§6" + player.getName());
|
||||||
|
return skull;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue