Search in sources :

Example 1 with PlayerUtils

use of gg.projecteden.nexus.utils.PlayerUtils in project Nexus by ProjectEdenGG.

the class TrustProvider method init.

@Override
public void init(Player player, InventoryContents contents) {
    if (back == null)
        addCloseItem(contents);
    else
        addBackItem(contents, e -> back.run());
    List<ClickableItem> items = new ArrayList<>();
    trust.getAll().stream().map(PlayerUtils::getPlayer).sorted(Comparator.comparing(Nickname::of)).collect(Collectors.toList()).forEach(_player -> {
        if (filterType.get() != null)
            if (!trust.trusts(filterType.get(), _player))
                return;
        ItemBuilder builder = new ItemBuilder(Material.PLAYER_HEAD).skullOwner(_player).name("&e" + Nickname.of(_player));
        for (Trust.Type type : Trust.Type.values()) {
            // TODO Decorations
            if (type.equals(Type.DECORATIONS) && !Rank.of(player).isStaff())
                continue;
            if (trust.trusts(type, _player))
                builder.lore("&a" + type.camelCase());
            else
                builder.lore("&c" + type.camelCase());
        }
        builder.lore("").lore("&fClick to edit");
        items.add(ClickableItem.from(builder.build(), e -> TrustPlayerProvider.open(player, _player)));
    });
    paginator(player, contents, items);
    ItemBuilder add = new ItemBuilder(Material.LIME_CONCRETE_POWDER).name("&aAdd Trust");
    contents.set(0, 8, ClickableItem.from(add.build(), e -> Nexus.getSignMenuFactory().lines("", ARROWS, "Enter a", "player's name").prefix(Features.get(TrustFeature.class).getPrefix()).response(lines -> {
        if (lines[0].length() > 0) {
            OfflinePlayer trusted = PlayerUtils.getPlayer(lines[0]);
            TrustPlayerProvider.open(player, trusted);
        } else
            openMenu(player);
    }).open(player)));
    Trust.Type previous = filterType.get() == null ? Type.values()[0].previousWithLoop() : filterType.get().previous();
    Trust.Type current = filterType.get();
    Trust.Type next = filterType.get() == null ? Type.values()[0] : filterType.get().next();
    if (current == previous)
        previous = null;
    if (current == next)
        next = null;
    ItemBuilder item = new ItemBuilder(Material.HOPPER).name("&6Filter by:").lore("&7⬇ " + (previous == null ? "All" : previous.camelCase())).lore("&e⬇ " + (current == null ? "All" : current.camelCase())).lore("&7⬇ " + (next == null ? "All" : next.camelCase()));
    Trust.Type finalNext = next;
    contents.set(contents.inventory().getRows() - 1, 4, ClickableItem.from(item.build(), e -> {
        filterType.set(finalNext);
        refresh();
    }));
}
Also used : Nexus(gg.projecteden.nexus.Nexus) ItemBuilder(gg.projecteden.nexus.utils.ItemBuilder) Trust(gg.projecteden.nexus.models.trust.Trust) Rank(gg.projecteden.nexus.models.nerd.Rank) SmartInventory(fr.minuskube.inv.SmartInventory) Player(org.bukkit.entity.Player) ARROWS(gg.projecteden.nexus.features.menus.SignMenuFactory.ARROWS) AtomicReference(java.util.concurrent.atomic.AtomicReference) Collectors(java.util.stream.Collectors) OfflinePlayer(org.bukkit.OfflinePlayer) ArrayList(java.util.ArrayList) Features(gg.projecteden.nexus.framework.features.Features) PlayerUtils(gg.projecteden.nexus.utils.PlayerUtils) List(java.util.List) Type(gg.projecteden.nexus.models.trust.Trust.Type) InventoryProvider(fr.minuskube.inv.content.InventoryProvider) InventoryContents(fr.minuskube.inv.content.InventoryContents) MenuUtils(gg.projecteden.nexus.features.menus.MenuUtils) TrustFeature(gg.projecteden.nexus.features.trust.TrustFeature) TrustService(gg.projecteden.nexus.models.trust.TrustService) Nickname(gg.projecteden.nexus.models.nickname.Nickname) Comparator(java.util.Comparator) Material(org.bukkit.Material) ClickableItem(fr.minuskube.inv.ClickableItem) ItemBuilder(gg.projecteden.nexus.utils.ItemBuilder) ClickableItem(fr.minuskube.inv.ClickableItem) ArrayList(java.util.ArrayList) OfflinePlayer(org.bukkit.OfflinePlayer) Type(gg.projecteden.nexus.models.trust.Trust.Type) Trust(gg.projecteden.nexus.models.trust.Trust)

Example 2 with PlayerUtils

use of gg.projecteden.nexus.utils.PlayerUtils in project Nexus by ProjectEdenGG.

the class EndermanFarmCommand method list.

@Path("list [owner]")
void list(@Arg(value = "self", permission = Group.MODERATOR) OfflinePlayer owner) {
    final ProtectedRegion region = getRegion(world(), owner.getUniqueId());
    final DefaultDomain members = region.getMembers();
    final Set<UUID> uuids = members.getUniqueIds();
    if (uuids.isEmpty())
        error("No one has access to your enderman farm");
    final String names = uuids.stream().map(PlayerUtils::getPlayer).map(OfflinePlayer::getName).collect(Collectors.joining(", "));
    send(PREFIX + "Access list: &7" + names);
}
Also used : PlayerUtils(gg.projecteden.nexus.utils.PlayerUtils) ProtectedRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion) UUID(java.util.UUID) DefaultDomain(com.sk89q.worldguard.domains.DefaultDomain) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Aggregations

PlayerUtils (gg.projecteden.nexus.utils.PlayerUtils)2 DefaultDomain (com.sk89q.worldguard.domains.DefaultDomain)1 ProtectedRegion (com.sk89q.worldguard.protection.regions.ProtectedRegion)1 ClickableItem (fr.minuskube.inv.ClickableItem)1 SmartInventory (fr.minuskube.inv.SmartInventory)1 InventoryContents (fr.minuskube.inv.content.InventoryContents)1 InventoryProvider (fr.minuskube.inv.content.InventoryProvider)1 Nexus (gg.projecteden.nexus.Nexus)1 MenuUtils (gg.projecteden.nexus.features.menus.MenuUtils)1 ARROWS (gg.projecteden.nexus.features.menus.SignMenuFactory.ARROWS)1 TrustFeature (gg.projecteden.nexus.features.trust.TrustFeature)1 Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)1 Features (gg.projecteden.nexus.framework.features.Features)1 Rank (gg.projecteden.nexus.models.nerd.Rank)1 Nickname (gg.projecteden.nexus.models.nickname.Nickname)1 Trust (gg.projecteden.nexus.models.trust.Trust)1 Type (gg.projecteden.nexus.models.trust.Trust.Type)1 TrustService (gg.projecteden.nexus.models.trust.TrustService)1 ItemBuilder (gg.projecteden.nexus.utils.ItemBuilder)1 ArrayList (java.util.ArrayList)1