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);
}
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)));
}
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();
}));
}
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);
}
Aggregations