Search in sources :

Example 1 with JsonBuilder

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

the class BoopCommand method run.

public void run(Player booper, Player booped, String message, boolean anonymous) {
    if (message == null)
        message = "";
    if (isSelf(booped))
        error("You cannot boop yourself!");
    if (MuteMenuUser.hasMuted(booper, MuteMenuItem.BOOPS))
        error("You have boops disabled!");
    if (MuteMenuUser.hasMuted(booped, MuteMenuItem.BOOPS))
        error(booped.getName() + " has boops disabled!");
    if (Minigames.isMinigameWorld(booper.getWorld()))
        error("You cannot boop in minigames!");
    String boopedName = Nickname.of(booped);
    if (Minigames.isMinigameWorld(booped.getWorld()))
        error("You cannot boop " + boopedName + ", they are in minigames");
    String toBooper = PREFIX;
    String toBooped = PREFIX;
    if (!message.equalsIgnoreCase(""))
        message = " &3and said &e" + message;
    if (anonymous) {
        toBooper += "&3You anonymously booped &e" + boopedName + message;
        toBooped += "&eSomebody &3booped you" + message;
    } else {
        toBooper += "&3You booped &e" + boopedName + message;
        toBooped += "&e" + nickname() + " &3booped you" + message;
    }
    send(toBooper);
    JsonBuilder json = new JsonBuilder(toBooped);
    if (!anonymous)
        json.next("&3. &eClick to boop back").suggest("/boop " + Nickname.of(booper) + " ");
    booped.sendMessage(booper, json);
    booped.playSound(booped.getLocation(), Sound.BLOCK_NOTE_BLOCK_XYLOPHONE, 10.0F, 0.1F);
}
Also used : JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder)

Example 2 with JsonBuilder

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

the class OnlineCommand method help.

@Path
@Override
public void help() {
    long vanished = OnlinePlayers.getAll().stream().filter(PlayerUtils::isVanished).count();
    long online = OnlinePlayers.getAll().size() - vanished;
    boolean canSeeVanished = !isPlayer() || player().hasPermission("pv.see");
    String counts = online + ((canSeeVanished && vanished > 0) ? " &3+ &e" + vanished : "");
    line();
    send("&3There are &e" + counts + " &3out of maximum &e" + Bukkit.getMaxPlayers() + " &3players online");
    Rank.REVERSED.forEach(rank -> {
        List<Nerd> nerds = rank.getOnlineNerds().stream().filter(this::canSee).collect(Collectors.toList());
        if (nerds.size() == 0)
            return;
        JsonBuilder builder = new JsonBuilder(rank.getColoredName() + "s&f: ");
        nerds.forEach(nerd -> getNameWithPresence(nerd, builder));
        send(builder);
    });
    line();
    send("&e&lClick &3on a player's name to open the &eQuickAction &3menu");
    line();
}
Also used : JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) Nerd(gg.projecteden.nexus.models.nerd.Nerd) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Example 3 with JsonBuilder

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

the class RulesCommand method search.

private List<JsonBuilder> search(RulesType rulesType, String filter) {
    List<JsonBuilder> results = new ArrayList<>();
    for (RulesSection page : rulesType.getPages()) for (JsonBuilder message : page.getRules()) if (message.toString().toLowerCase().contains(filter.toLowerCase()))
        results.add(message);
    if (results.isEmpty())
        return new ArrayList<>();
    return new ArrayList<>() {

        {
            add(json("&3[+] &e" + camelCase(rulesType) + " Rules").command("/rules " + rulesType.name().toLowerCase()));
            add(json(" "));
            addAll(results);
            add(json(" "));
        }
    };
}
Also used : JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) ArrayList(java.util.ArrayList) RulesSection(gg.projecteden.nexus.models.rule.HasReadRules.RulesSection)

Example 4 with JsonBuilder

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

the class Pugmas20Command method treeCounts.

@Permission(Group.ADMIN)
@Path("tree counts")
void treeCounts() {
    int total = 0;
    JsonBuilder json = json(PREFIX + "Pugmas tree counts:");
    for (PugmasTreeType treeType : PugmasTreeType.values()) {
        Set<Integer> ids = treeType.getPasters().keySet();
        if (ids.size() == 0)
            continue;
        String collect = ids.stream().map(String::valueOf).collect(Collectors.joining(", "));
        json.newline().next("&e " + camelCase(treeType) + " &7- " + ids.size() + " &3[" + collect + "]");
        total += ids.size();
    }
    if (total == 0)
        error("No pugmas trees found");
    send(json.newline().next("&3Total: &e" + total));
}
Also used : JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) PugmasTreeType(gg.projecteden.nexus.features.events.y2020.pugmas20.quests.OrnamentVendor.PugmasTreeType) Pugmas20.showWaypoint(gg.projecteden.nexus.features.events.y2020.pugmas20.Pugmas20.showWaypoint) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 5 with JsonBuilder

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

the class AntiXray method checkLogs.

private void checkLogs(Player player, Material ore) {
    UUID uuid = player.getUniqueId();
    List<XRayLog> logs = XRayLogs.get(uuid);
    LocalDateTime now = LocalDateTime.now();
    int count = 0;
    for (XRayLog log : new ArrayList<>(logs)) {
        if (log.getTimestamp().isAfter(now.minusMinutes(minuteThreshold)))
            ++count;
        if (count > countMap.get(ore)) {
            new WarpsService().edit0(warps -> warps.add(new Warp(player.getName(), WarpType.XRAY, player.getLocation())));
            logs.clear();
            String name = player.getName();
            final JsonBuilder message = new JsonBuilder("&7&l[&cRadar&7&l] &a" + name + "&f is possibly xraying. ").next("&e[Click to Teleport]").command("mcmd vanish on ;; xraywarp " + name).hover("This will automatically vanish you");
            Broadcast.staffIngame().message(message).send();
            Broadcast.staffDiscord().prefix("Radar").message(name + " is possibly xraying. `/xraywarp " + name + "`").send();
            break;
        }
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) Warp(gg.projecteden.nexus.models.warps.Warps.Warp) WarpsService(gg.projecteden.nexus.models.warps.WarpsService) ArrayList(java.util.ArrayList) UUID(java.util.UUID)

Aggregations

JsonBuilder (gg.projecteden.nexus.utils.JsonBuilder)86 Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)45 Permission (gg.projecteden.nexus.framework.commands.models.annotations.Permission)21 ArrayList (java.util.ArrayList)21 List (java.util.List)21 CustomCommand (gg.projecteden.nexus.framework.commands.models.CustomCommand)19 CommandEvent (gg.projecteden.nexus.framework.commands.models.events.CommandEvent)19 Player (org.bukkit.entity.Player)18 HashMap (java.util.HashMap)17 EventHandler (org.bukkit.event.EventHandler)17 Arg (gg.projecteden.nexus.framework.commands.models.annotations.Arg)16 Group (gg.projecteden.nexus.framework.commands.models.annotations.Permission.Group)16 Map (java.util.Map)16 BiFunction (java.util.function.BiFunction)16 UUID (java.util.UUID)15 PlayerUtils (gg.projecteden.nexus.utils.PlayerUtils)14 Async (gg.projecteden.annotations.Async)13 Nerd (gg.projecteden.nexus.models.nerd.Nerd)13 Rank (gg.projecteden.nexus.models.nerd.Rank)13 Tasks (gg.projecteden.nexus.utils.Tasks)13