Search in sources :

Example 1 with Rank

use of gg.projecteden.nexus.models.nerd.Rank in project Nexus by ProjectEdenGG.

the class TeleportCommand method checkTeleportDisabled.

private boolean checkTeleportDisabled(Player from, OfflinePlayer to) {
    SettingService settingService = new SettingService();
    Setting setting = settingService.get(to, "tpDisable");
    if (setting.getBoolean()) {
        Rank fromRank = Rank.of(from);
        Rank toRank = Rank.of(to);
        if (fromRank.ordinal() > toRank.ordinal())
            if (!(Arrays.asList(Rank.BUILDER, Rank.ARCHITECT).contains(toRank) && fromRank == Rank.MODERATOR))
                return false;
        PlayerUtils.send(to, PREFIX + "&c" + from.getName() + " tried to teleport to you, but you have teleports disabled");
        send(PREFIX + "&cThat player has teleports disabled. Sending a request instead");
        runCommand(from, "tpa " + argsString());
        return true;
    }
    return false;
}
Also used : SettingService(gg.projecteden.nexus.models.setting.SettingService) Setting(gg.projecteden.nexus.models.setting.Setting) Rank(gg.projecteden.nexus.models.nerd.Rank)

Example 2 with Rank

use of gg.projecteden.nexus.models.nerd.Rank in project Nexus by ProjectEdenGG.

the class ReferralCommand method whoHasRank.

@Path("who has rank <rank> from <site> [page]")
void whoHasRank(Rank rank, @Arg(tabCompleter = ReferralSite.class) String subdomain, @Arg("1") int page) {
    List<Hours> players = getPlayersFrom(subdomain).stream().map(uuid -> new HoursService().get(uuid)).filter(uuid -> Rank.of(uuid).gte(rank)).sorted(Comparator.comparing(Hours::getTotal).reversed()).toList();
    BiFunction<Hours, String, JsonBuilder> formatter = (hours, index) -> json(index + " &e" + Nerd.of(hours).getColoredName());
    paginate(players, formatter, "/referral who has rank " + rank.name().toLowerCase() + " from " + subdomain, page);
}
Also used : Arrays(java.util.Arrays) StringUtils(gg.projecteden.nexus.utils.StringUtils) TabCompleteIgnore(gg.projecteden.nexus.framework.commands.models.annotations.TabCompleteIgnore) BiFunction(java.util.function.BiFunction) RequiredArgsConstructor(lombok.RequiredArgsConstructor) Nullables.isNullOrEmpty(gg.projecteden.nexus.utils.Nullables.isNullOrEmpty) WrittenBookMenu(gg.projecteden.nexus.features.menus.BookBuilder.WrittenBookMenu) EventHandler(org.bukkit.event.EventHandler) Utils.sortByValueReverse(gg.projecteden.nexus.utils.Utils.sortByValueReverse) Punishments(gg.projecteden.nexus.models.punishments.Punishments) Map(java.util.Map) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission) HasReadRules(gg.projecteden.nexus.models.rule.HasReadRules) Timespan(gg.projecteden.utils.TimeUtils.Timespan) Nexus(gg.projecteden.nexus.Nexus) PlayerJoinEvent(org.bukkit.event.player.PlayerJoinEvent) Description(gg.projecteden.nexus.framework.commands.models.annotations.Description) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Nerd(gg.projecteden.nexus.models.nerd.Nerd) PlayerLoginEvent(org.bukkit.event.player.PlayerLoginEvent) Rank(gg.projecteden.nexus.models.nerd.Rank) NonNull(lombok.NonNull) Tasks(gg.projecteden.nexus.utils.Tasks) HideFromHelp(gg.projecteden.nexus.framework.commands.models.annotations.HideFromHelp) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) List(java.util.List) NotNull(org.jetbrains.annotations.NotNull) Getter(lombok.Getter) JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) LocalDateTime(java.time.LocalDateTime) Async(gg.projecteden.annotations.Async) Arg(gg.projecteden.nexus.framework.commands.models.annotations.Arg) HashMap(java.util.HashMap) Group(gg.projecteden.nexus.framework.commands.models.annotations.Permission.Group) Function(java.util.function.Function) ArrayList(java.util.ArrayList) Hours(gg.projecteden.nexus.models.hours.Hours) Strings(com.google.common.base.Strings) HasReadRulesService(gg.projecteden.nexus.models.rule.HasReadRulesService) Referral(gg.projecteden.nexus.models.referral.Referral) Listener(org.bukkit.event.Listener) ReferralService(gg.projecteden.nexus.models.referral.ReferralService) CustomCommand(gg.projecteden.nexus.framework.commands.models.CustomCommand) HasUniqueId(me.lexikiq.HasUniqueId) Origin(gg.projecteden.nexus.models.referral.Referral.Origin) CooldownService(gg.projecteden.nexus.models.cooldown.CooldownService) TickTime(gg.projecteden.utils.TimeUtils.TickTime) CommandEvent(gg.projecteden.nexus.framework.commands.models.events.CommandEvent) HoursService(gg.projecteden.nexus.models.hours.HoursService) Data(lombok.Data) Comparator(java.util.Comparator) NoArgsConstructor(lombok.NoArgsConstructor) JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) Hours(gg.projecteden.nexus.models.hours.Hours) HoursService(gg.projecteden.nexus.models.hours.HoursService) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Example 3 with Rank

use of gg.projecteden.nexus.models.nerd.Rank in project Nexus by ProjectEdenGG.

the class HallOfHistoryCommand method removeRankConfirm.

@Async
@Permission(Group.STAFF)
@Path("removeRank <player> <current|former> <rank> <promotionDate> [resignationDate]")
void removeRankConfirm(OfflinePlayer player, String when, Rank rank, LocalDate promotion, LocalDate resignation) {
    boolean current = "current".equalsIgnoreCase(when);
    HallOfHistory history = service.get(player.getUniqueId());
    ConfirmationMenu.builder().title("Remove rank from " + player.getName() + "?").onConfirm((item) -> {
        for (RankHistory rankHistory : new ArrayList<>(history.getRankHistory())) {
            if (!new RankHistory(rank, current, promotion, resignation).equals(rankHistory))
                continue;
            history.getRankHistory().remove(rankHistory);
            service.save(history);
            send(PREFIX + "Removed the rank from &e" + player.getName());
            send(json(PREFIX + "&eClick here &3to generate a command to re-add rank").suggest("/hoh addrank " + player.getName() + " " + getRankCommandArgs(rankHistory)));
            return;
        }
        send(PREFIX + "Could not find the rank to delete");
    }).open(player());
}
Also used : StringUtils(gg.projecteden.nexus.utils.StringUtils) JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) BiFunction(java.util.function.BiFunction) OptionalDouble(java.util.OptionalDouble) Async(gg.projecteden.annotations.Async) Arg(gg.projecteden.nexus.framework.commands.models.annotations.Arg) HashMap(java.util.HashMap) Group(gg.projecteden.nexus.framework.commands.models.annotations.Permission.Group) RankHistory(gg.projecteden.nexus.models.hallofhistory.HallOfHistory.RankHistory) ArrayList(java.util.ArrayList) Nullables.isNullOrEmpty(gg.projecteden.nexus.utils.Nullables.isNullOrEmpty) ServerAge(gg.projecteden.nexus.features.commands.AgeCommand.ServerAge) Map(java.util.Map) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission) Nickname(gg.projecteden.nexus.models.nickname.Nickname) Timespan(gg.projecteden.utils.TimeUtils.Timespan) ConfirmationMenu(gg.projecteden.nexus.features.menus.MenuUtils.ConfirmationMenu) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Nerd(gg.projecteden.nexus.models.nerd.Nerd) Rank(gg.projecteden.nexus.models.nerd.Rank) CustomCommand(gg.projecteden.nexus.framework.commands.models.CustomCommand) Tasks(gg.projecteden.nexus.utils.Tasks) TimeUtils.shortDateFormat(gg.projecteden.utils.TimeUtils.shortDateFormat) UUID(java.util.UUID) PlayerNotFoundException(gg.projecteden.nexus.framework.exceptions.postconfigured.PlayerNotFoundException) TimeUtils.dateFormat(gg.projecteden.utils.TimeUtils.dateFormat) EdenSocialMediaSite(gg.projecteden.nexus.features.socialmedia.SocialMedia.EdenSocialMediaSite) HallOfHistory(gg.projecteden.nexus.models.hallofhistory.HallOfHistory) Utils(gg.projecteden.nexus.utils.Utils) OfflinePlayer(org.bukkit.OfflinePlayer) StringUtils.stripColor(gg.projecteden.nexus.utils.StringUtils.stripColor) Aliases(gg.projecteden.nexus.framework.commands.models.annotations.Aliases) TickTime(gg.projecteden.utils.TimeUtils.TickTime) List(java.util.List) ChronoUnit(java.time.temporal.ChronoUnit) CommandEvent(gg.projecteden.nexus.framework.commands.models.events.CommandEvent) LocalDate(java.time.LocalDate) NerdService(gg.projecteden.nexus.models.nerd.NerdService) HallOfHistoryService(gg.projecteden.nexus.models.hallofhistory.HallOfHistoryService) Comparator(java.util.Comparator) HallOfHistory(gg.projecteden.nexus.models.hallofhistory.HallOfHistory) RankHistory(gg.projecteden.nexus.models.hallofhistory.HallOfHistory.RankHistory) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Async(gg.projecteden.annotations.Async) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 4 with Rank

use of gg.projecteden.nexus.models.nerd.Rank in project Nexus by ProjectEdenGG.

the class StaffHallCommand method writeHtml.

private static void writeHtml() {
    File folder = Paths.get("plugins/website/meetthestaff/").toFile();
    if (!folder.exists())
        folder.mkdir();
    Rank.getStaffNerds().thenAccept(ranks -> {
        for (Rank rank : ranks.keySet()) {
            for (Nerd staff : ranks.get(rank)) try {
                String html = "";
                if (!Strings.isNullOrEmpty(staff.getPreferredName()))
                    html += "<span style=\"font-weight: bold;\">Preferred name:</span> " + staff.getPreferredName() + "<br/>";
                if (staff.getBirthday() != null)
                    html += "<span style=\"font-weight: bold;\">Birthday:</span> " + shortDateFormat(staff.getBirthday()) + " (" + staff.getBirthday().until(LocalDate.now()).getYears() + " years)<br/>";
                if (staff.getPromotionDate() != null)
                    html += "<span style=\"font-weight: bold;\">Promotion date:</span> " + shortDateFormat(staff.getPromotionDate()) + "<br/>";
                html += "<br/>";
                if (!Strings.isNullOrEmpty(staff.getAbout()))
                    html += "<span style=\"font-weight: bold;\">About me:</span> " + staff.getAbout();
                File file = Paths.get("plugins/website/meetthestaff/" + staff.getUuid() + ".html").toFile();
                if (!file.exists())
                    file.createNewFile();
                Files.write(file.toPath(), html.getBytes(), StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    });
}
Also used : Rank(gg.projecteden.nexus.models.nerd.Rank) File(java.io.File) Nerd(gg.projecteden.nexus.models.nerd.Nerd)

Example 5 with Rank

use of gg.projecteden.nexus.models.nerd.Rank in project Nexus by ProjectEdenGG.

the class MinigamesCommand method updateInvite.

private void updateInvite() {
    final boolean noStaffInMinigames = OnlinePlayers.where().worldGroup(WorldGroup.MINIGAMES).rank(Rank::isStaff).get().isEmpty();
    boolean canUse = false;
    if (!new NextMGN().isNow() || noStaffInMinigames)
        canUse = true;
    if (player().hasPermission("minigames.invite"))
        canUse = true;
    if (!canUse)
        permissionError();
    WorldGuardUtils worldguard = new WorldGuardUtils(player());
    if (!worldguard.isInRegion(location(), "minigamelobby"))
        error("You must be in the Minigame Lobby to use this command");
    if (worldguard.isInRegion(location(), "screenshot")) {
        inviteCommand = "warp screenshot";
        inviteMessage = "take a screenshot";
    } else {
        Sign sign = getTargetSignRequired();
        String line2 = stripColor(sign.getLine(1)).toLowerCase();
        if (line2.contains("screenshot"))
            error("Stand in the screenshot area then run the command (sign not needed)");
        if (!line2.contains("join"))
            error("Cannot parse sign. If you believe this is an error, make a GitHub ticket with information and screenshots.");
        String prefix = "";
        String line1 = stripColor(sign.getLine(0)).toLowerCase();
        if (line1.contains("[minigame]") || line1.contains("< minigames >"))
            prefix = "mgm";
        else
            error("Cannot parse sign. If you believe this is an error, make a GitHub ticket with information and screenshots.");
        String line3 = stripColor(sign.getLine(2)) + stripColor(sign.getLine(3));
        inviteCommand = prefix + " join " + line3;
        String mechanic = ArenaManager.get(line3).getMechanic().getName();
        inviteMessage = mechanic + " &3on &e" + line3;
        if (line3.equalsIgnoreCase(mechanic))
            inviteMessage = line3;
    }
}
Also used : NextMGN(gg.projecteden.nexus.features.minigames.utils.MinigameNight.NextMGN) Rank(gg.projecteden.nexus.models.nerd.Rank) Sign(org.bukkit.block.Sign) WorldGuardUtils(gg.projecteden.nexus.utils.WorldGuardUtils)

Aggregations

Rank (gg.projecteden.nexus.models.nerd.Rank)8 Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)5 Async (gg.projecteden.annotations.Async)3 Nerd (gg.projecteden.nexus.models.nerd.Nerd)3 JsonBuilder (gg.projecteden.nexus.utils.JsonBuilder)3 CustomCommand (gg.projecteden.nexus.framework.commands.models.CustomCommand)2 Arg (gg.projecteden.nexus.framework.commands.models.annotations.Arg)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 Nullables.isNullOrEmpty (gg.projecteden.nexus.utils.Nullables.isNullOrEmpty)2 StringUtils (gg.projecteden.nexus.utils.StringUtils)2 Tasks (gg.projecteden.nexus.utils.Tasks)2 TickTime (gg.projecteden.utils.TimeUtils.TickTime)2 Timespan (gg.projecteden.utils.TimeUtils.Timespan)2 ArrayList (java.util.ArrayList)2 Comparator (java.util.Comparator)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2