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