Search in sources :

Example 1 with Type

use of gg.projecteden.nexus.models.trust.Trust.Type in project Nexus by ProjectEdenGG.

the class TrustCommand method process.

private void process(Trust trust, List<OfflinePlayer> players, Trust.Type... types) {
    for (Type type : types) players.forEach(player -> trust.get(type).add(player.getUniqueId()));
    service.save(trust);
    String typeNames = Arrays.stream(types).map(Type::camelCase).collect(Collectors.joining("&3, &e"));
    send(PREFIX + "Trusted &e" + nicknames(players, "&3, &e") + " &3to &e" + typeNames);
}
Also used : Home(gg.projecteden.nexus.models.home.Home) Description(gg.projecteden.nexus.framework.commands.models.annotations.Description) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Arrays(java.util.Arrays) Trust(gg.projecteden.nexus.models.trust.Trust) NonNull(lombok.NonNull) TabCompleteIgnore(gg.projecteden.nexus.framework.commands.models.annotations.TabCompleteIgnore) CustomCommand(gg.projecteden.nexus.framework.commands.models.CustomCommand) Arg(gg.projecteden.nexus.framework.commands.models.annotations.Arg) HideFromHelp(gg.projecteden.nexus.framework.commands.models.annotations.HideFromHelp) Group(gg.projecteden.nexus.framework.commands.models.annotations.Permission.Group) Collectors(java.util.stream.Collectors) TrustPlayerProvider(gg.projecteden.nexus.features.trust.providers.TrustPlayerProvider) TrustProvider(gg.projecteden.nexus.features.trust.providers.TrustProvider) OfflinePlayer(org.bukkit.OfflinePlayer) Aliases(gg.projecteden.nexus.framework.commands.models.annotations.Aliases) List(java.util.List) Type(gg.projecteden.nexus.models.trust.Trust.Type) CommandEvent(gg.projecteden.nexus.framework.commands.models.events.CommandEvent) TrustService(gg.projecteden.nexus.models.trust.TrustService) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission) Nickname(gg.projecteden.nexus.models.nickname.Nickname) NotNull(org.jetbrains.annotations.NotNull) HomeService(gg.projecteden.nexus.models.home.HomeService) Type(gg.projecteden.nexus.models.trust.Trust.Type)

Example 2 with Type

use of gg.projecteden.nexus.models.trust.Trust.Type in project Nexus by ProjectEdenGG.

the class TrustPlayerProvider method init.

@Override
public void init(Player player, InventoryContents contents) {
    addBackItem(contents, e -> TrustProvider.openMenu(player));
    contents.set(0, 4, ClickableItem.empty(new ItemBuilder(Material.PLAYER_HEAD).skullOwner(trusted).name("&f" + Nickname.of(trusted)).build()));
    for (Trust.Type type : Trust.Type.values()) {
        List<UUID> list = trust.get(type);
        ItemBuilder builder = new ItemBuilder(type.getMaterial()).name("&e" + type.camelCase());
        if (list.contains(trusted.getUniqueId()))
            builder.lore("&aTrusted");
        else
            builder.lore("&cNot trusted");
        builder.lore("").lore("&fClick to toggle");
        // TODO Decorations
        int column = type.getColumn();
        if (!Rank.of(player).isStaff()) {
            ++column;
            if (type == Type.DECORATIONS)
                continue;
        }
        // 
        contents.set(2, column, ClickableItem.from(builder.build(), e -> {
            if (list.contains(trusted.getUniqueId()))
                list.remove(trusted.getUniqueId());
            else
                list.add(trusted.getUniqueId());
            service.save(trust);
            refresh();
        }));
    }
    contents.set(0, 8, ClickableItem.from(new ItemBuilder(Material.TNT).name("&cUntrust from all").build(), e -> ConfirmationMenu.builder().onConfirm(e2 -> {
        for (Type type : Type.values()) {
            trust.get(type).remove(trusted.getUniqueId());
            service.save(trust);
            TrustProvider.openMenu(player);
        }
    }).onCancel(e2 -> refresh()).open(player)));
}
Also used : 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) UUID(java.util.UUID) OfflinePlayer(org.bukkit.OfflinePlayer) 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) TrustService(gg.projecteden.nexus.models.trust.TrustService) Nickname(gg.projecteden.nexus.models.nickname.Nickname) Material(org.bukkit.Material) ClickableItem(fr.minuskube.inv.ClickableItem) ItemBuilder(gg.projecteden.nexus.utils.ItemBuilder) Type(gg.projecteden.nexus.models.trust.Trust.Type) Type(gg.projecteden.nexus.models.trust.Trust.Type) UUID(java.util.UUID) Trust(gg.projecteden.nexus.models.trust.Trust)

Example 3 with Type

use of gg.projecteden.nexus.models.trust.Trust.Type 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 4 with Type

use of gg.projecteden.nexus.models.trust.Trust.Type in project Nexus by ProjectEdenGG.

the class UntrustCommand method process.

private void process(List<OfflinePlayer> players, Trust.Type... types) {
    for (Type type : types) players.forEach(player -> trust.get(type).remove(player.getUniqueId()));
    service.save(trust);
    String typeNames = Arrays.stream(types).map(Type::camelCase).collect(Collectors.joining("&3, &e"));
    send(PREFIX + "Untrusted &e" + names(players, "&3, &e") + " &3from &e" + typeNames);
}
Also used : Home(gg.projecteden.nexus.models.home.Home) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Arrays(java.util.Arrays) Trust(gg.projecteden.nexus.models.trust.Trust) NonNull(lombok.NonNull) CustomCommand(gg.projecteden.nexus.framework.commands.models.CustomCommand) Arg(gg.projecteden.nexus.framework.commands.models.annotations.Arg) Group(gg.projecteden.nexus.framework.commands.models.annotations.Permission.Group) Collectors(java.util.stream.Collectors) TrustProvider(gg.projecteden.nexus.features.trust.providers.TrustProvider) OfflinePlayer(org.bukkit.OfflinePlayer) List(java.util.List) Type(gg.projecteden.nexus.models.trust.Trust.Type) CommandEvent(gg.projecteden.nexus.framework.commands.models.events.CommandEvent) TrustService(gg.projecteden.nexus.models.trust.TrustService) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission) Nickname(gg.projecteden.nexus.models.nickname.Nickname) NotNull(org.jetbrains.annotations.NotNull) HomeService(gg.projecteden.nexus.models.home.HomeService) Type(gg.projecteden.nexus.models.trust.Trust.Type)

Aggregations

Nickname (gg.projecteden.nexus.models.nickname.Nickname)4 Trust (gg.projecteden.nexus.models.trust.Trust)4 Type (gg.projecteden.nexus.models.trust.Trust.Type)4 TrustService (gg.projecteden.nexus.models.trust.TrustService)4 List (java.util.List)4 OfflinePlayer (org.bukkit.OfflinePlayer)4 Collectors (java.util.stream.Collectors)3 ClickableItem (fr.minuskube.inv.ClickableItem)2 SmartInventory (fr.minuskube.inv.SmartInventory)2 InventoryContents (fr.minuskube.inv.content.InventoryContents)2 InventoryProvider (fr.minuskube.inv.content.InventoryProvider)2 MenuUtils (gg.projecteden.nexus.features.menus.MenuUtils)2 TrustProvider (gg.projecteden.nexus.features.trust.providers.TrustProvider)2 CustomCommand (gg.projecteden.nexus.framework.commands.models.CustomCommand)2 Arg (gg.projecteden.nexus.framework.commands.models.annotations.Arg)2 Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)2 Permission (gg.projecteden.nexus.framework.commands.models.annotations.Permission)2 Group (gg.projecteden.nexus.framework.commands.models.annotations.Permission.Group)2 CommandEvent (gg.projecteden.nexus.framework.commands.models.events.CommandEvent)2 Home (gg.projecteden.nexus.models.home.Home)2