Search in sources :

Example 96 with Path

use of gg.projecteden.nexus.framework.commands.models.annotations.Path in project Nexus by ProjectEdenGG.

the class WhoIsCommand method run.

@Async
@Path("<player>")
void run(Nerd nerd) {
    line();
    line();
    send("&3Who the fuck is &6&l" + nerd.getNickname() + "&3?");
    HoursService hoursService = new HoursService();
    GeoIPService geoipService = new GeoIPService();
    Punishments punishments = Punishments.of(nerd);
    boolean history = punishments.hasHistory();
    JsonBuilder alts = punishments.getAltsMessage();
    Hours hours = hoursService.get(nerd);
    String rank = nerd.getRank().getColoredName();
    String firstJoin = shortDateTimeFormat(nerd.getFirstJoin());
    String lastJoinQuitLabel = null;
    String lastJoinQuitDate = null;
    String lastJoinQuitDiff = null;
    if (nerd.isOnline()) {
        if (nerd.getLastQuit() != null) {
            lastJoinQuitLabel = "Last Quit";
            lastJoinQuitDate = shortDateTimeFormat(nerd.getLastQuit());
            lastJoinQuitDiff = Timespan.of(nerd.getLastQuit()).format();
        }
    } else {
        lastJoinQuitLabel = "Last Join";
        lastJoinQuitDate = shortDateTimeFormat(nerd.getLastQuit());
        lastJoinQuitDiff = Timespan.of(nerd.getLastJoin()).format();
    }
    Set<String> pastNames = nerd.getPastNames();
    Godmode godmode = new GodmodeService().get(nerd);
    JsonBuilder json = json();
    if (nerd.hasNickname())
        json.newline().next("&3Real Name: &e" + nerd.getName()).group();
    json.newline().next("&3Rank: &e" + rank).group();
    json.newline().next("&3First Join: &e" + firstJoin).group();
    if (lastJoinQuitDate != null)
        json.newline().next("&3" + lastJoinQuitLabel + ": &e" + lastJoinQuitDiff + " ago").hover("&e" + lastJoinQuitDate).group();
    if (hours.getTotal() > 0)
        json.newline().next("&3Hours: &e" + TimespanBuilder.ofSeconds(hours.getTotal()).noneDisplay(true).format()).group();
    if (history)
        json.newline().next("&3History: &e" + punishments.getPunishments().size()).command("/history " + nerd.getName()).hover("&eClick to view history").group();
    if (alts != null)
        json.newline().next("&3Alts: &e").next(alts).group();
    if (!pastNames.isEmpty())
        json.newline().next("&3Past Names: &e" + String.join("&3, &e", pastNames)).group();
    try {
        GeoIP geoip = geoipService.get(nerd);
        if (!isNullOrEmpty(geoip.getIp()))
            json.newline().next("&3GeoIP: &e" + geoip.getFriendlyLocationString()).hover("&e" + geoip.getIp()).suggest(geoip.getIp()).group();
    } catch (InvalidInputException ex) {
        json.newline().next("&3GeoIP: &c" + ex.getMessage()).group();
    }
    try {
        json.newline().next("&3Location: &e" + getLocationString(nerd.getLocation())).hover("&eClick to TP").command("/tp " + nerd.getName()).group();
    } catch (InvalidInputException ex) {
        json.newline().next("&3Location: &c" + ex.getMessage()).group();
    }
    json.newline().next("&3Balances:");
    for (ShopGroup shopGroup : ShopGroup.values()) if (new BankerService().getBalance(nerd, shopGroup) != 500)
        json.newline().next("  &3" + camelCase(shopGroup) + ": &e" + new BankerService().getBalanceFormatted(nerd, shopGroup)).group();
    if (nerd.isOnline()) {
        Player player = nerd.getOnlinePlayer();
        json.newline().next("&3Minecraft Version: &e" + PlayerUtils.getPlayerVersion(player));
        json.newline().next("&3Client Brand Name: &e" + player.getClientBrandName()).group();
        final LocalResourcePackUser packUser = new LocalResourcePackUserService().get(nerd);
        json.newline().next("&3Saturn: &e" + packUser.getSaturnStatus()).group();
        json.newline().next("&3Titan: &e" + packUser.getTitanStatus()).group();
        json.newline().next("&3Gamemode: &e" + camelCase(player.getGameMode())).group();
        json.newline().next("&3God mode: &e" + godmode.isEnabled()).group();
        json.newline().next("&3Fly mode: &e" + player.getAllowFlight() + " &3(" + (player.isFlying() ? "flying" : "not flying") + ")").group();
        final ChatVisibility chatVisibility = player.getClientOption(ClientOption.CHAT_VISIBILITY);
        if (chatVisibility != ChatVisibility.FULL)
            json.newline().next("&3Chat Visibility: &e" + camelCase(chatVisibility));
    }
    json.newline().next("&3OP: &e" + nerd.getOfflinePlayer().isOp()).group();
    send(json);
}
Also used : GeoIP(gg.projecteden.nexus.models.geoip.GeoIP) InvalidInputException(gg.projecteden.nexus.framework.exceptions.postconfigured.InvalidInputException) Player(org.bukkit.entity.Player) Hours(gg.projecteden.nexus.models.hours.Hours) Godmode(gg.projecteden.nexus.models.godmode.Godmode) GeoIPService(gg.projecteden.nexus.models.geoip.GeoIPService) HoursService(gg.projecteden.nexus.models.hours.HoursService) StringUtils.getLocationString(gg.projecteden.nexus.utils.StringUtils.getLocationString) GodmodeService(gg.projecteden.nexus.models.godmode.GodmodeService) JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) ShopGroup(gg.projecteden.nexus.models.shop.Shop.ShopGroup) LocalResourcePackUser(gg.projecteden.nexus.models.resourcepack.LocalResourcePackUser) ChatVisibility(com.destroystokyo.paper.ClientOption.ChatVisibility) BankerService(gg.projecteden.nexus.models.banker.BankerService) LocalResourcePackUserService(gg.projecteden.nexus.models.resourcepack.LocalResourcePackUserService) Punishments(gg.projecteden.nexus.models.punishments.Punishments) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Async(gg.projecteden.annotations.Async)

Example 97 with Path

use of gg.projecteden.nexus.framework.commands.models.annotations.Path in project Nexus by ProjectEdenGG.

the class WorldEditUtilsCommand method clipboard.

@Path("clipboard [--build] [--async] [--entities]")
void clipboard(@Switch @Arg("false") boolean build, @Switch @Arg("false") boolean async, @Switch @Arg("false") boolean entities) {
    final WorldEditUtils utils = new WorldEditUtils(world());
    List<CompletableFuture<Void>> futures = new ArrayList<>();
    Runnable task = () -> {
        final Paster paster = utils.paster("Testing clipboard").clipboard(player()).at(location()).entities(entities);
        if (build) {
            send("Building " + (async ? "async" : "sync"));
            for (int i = 0; i < 5; i++) futures.add(paster.build());
        } else {
            send("Pasting " + (async ? "async" : "sync"));
            for (int i = 0; i < 5; i++) futures.add(paster.pasteAsync());
        }
        CompletableFutures.allOf(futures).thenRun(() -> send("done"));
    };
    if (async)
        Tasks.async(task);
    else
        task.run();
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) WorldEditUtils(gg.projecteden.nexus.utils.WorldEditUtils) ArrayList(java.util.ArrayList) Paster(gg.projecteden.nexus.utils.WorldEditUtils.Paster) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Example 98 with Path

use of gg.projecteden.nexus.framework.commands.models.annotations.Path in project Nexus by ProjectEdenGG.

the class WorldEditUtilsCommand method rotate.

@Path("rotate [y] [x] [z]")
void rotate(int y, int x, int z) {
    final WorldEditUtils worldedit = new WorldEditUtils(player());
    worldedit.paster("Testing rotate").clipboard(worldedit.getPlayerSelection(player())).at(location()).transform(new AffineTransform().rotateY(y).rotateX(x).rotateZ(z)).pasteAsync();
}
Also used : WorldEditUtils(gg.projecteden.nexus.utils.WorldEditUtils) AffineTransform(com.sk89q.worldedit.math.transform.AffineTransform) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Example 99 with Path

use of gg.projecteden.nexus.framework.commands.models.annotations.Path in project Nexus by ProjectEdenGG.

the class SoundMenuCommand method playSound.

@Path("play <sound>")
public void playSound(String string) {
    Location loc = location();
    float pitch = (float) getPitchDouble(player());
    Sound sound = getSound(string);
    if (sound == null)
        error("Couldn't find sound: " + string);
    if (playToOthers.contains(uuid()))
        loc.getWorld().playSound(loc, sound, 1F, pitch);
    else
        player().playSound(loc, sound, 1F, pitch);
    bookMenu(pageMap.get(uuid()));
}
Also used : Sound(org.bukkit.Sound) Location(org.bukkit.Location) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Example 100 with Path

use of gg.projecteden.nexus.framework.commands.models.annotations.Path in project Nexus by ProjectEdenGG.

the class StripMetaCommand method menu.

@Path
void menu() {
    Inventory inv = Bukkit.createInventory(null, 54, TITLE);
    player().openInventory(inv);
}
Also used : Inventory(org.bukkit.inventory.Inventory) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Aggregations

Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)333 Permission (gg.projecteden.nexus.framework.commands.models.annotations.Permission)110 JsonBuilder (gg.projecteden.nexus.utils.JsonBuilder)51 Async (gg.projecteden.annotations.Async)48 ItemStack (org.bukkit.inventory.ItemStack)38 CommandEvent (gg.projecteden.nexus.framework.commands.models.events.CommandEvent)31 ArrayList (java.util.ArrayList)31 CustomCommand (gg.projecteden.nexus.framework.commands.models.CustomCommand)30 Description (gg.projecteden.nexus.framework.commands.models.annotations.Description)29 List (java.util.List)28 Location (org.bukkit.Location)28 Group (gg.projecteden.nexus.framework.commands.models.annotations.Permission.Group)27 UUID (java.util.UUID)26 Arg (gg.projecteden.nexus.framework.commands.models.annotations.Arg)25 Nerd (gg.projecteden.nexus.models.nerd.Nerd)24 HashMap (java.util.HashMap)24 BiFunction (java.util.function.BiFunction)21 Map (java.util.Map)20 Player (org.bukkit.entity.Player)20 NonNull (lombok.NonNull)18