Search in sources :

Example 1 with StandingLevelType

use of mc.dragons.tools.moderation.punishment.StandingLevelType in project DragonsOnline by UniverseCraft.

the class InfoCommand method onCommand.

public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!requirePermission(sender, PermissionLevel.HELPER))
        return true;
    if (args.length == 0) {
        sender.sendMessage(ChatColor.RED + "Specify a player! /userinfo <player>");
        return true;
    }
    Player targetPlayer = Bukkit.getPlayerExact(args[0]);
    User targetUser = lookupUser(sender, args[0]);
    if (targetUser == null)
        return true;
    boolean helper = hasPermission(sender, SystemProfileFlag.HELPER);
    boolean mod = hasPermission(sender, SystemProfileFlag.MODERATION);
    targetUser.safeResyncData();
    WrappedUser wrapped = WrappedUser.of(targetUser);
    boolean goodStanding = true;
    String skills = Arrays.stream(SkillType.values()).map(s -> s.toString() + " (" + targetUser.getSkillLevel(s) + ")").reduce((a, b) -> a + ", " + b).get();
    PunishmentData banData = wrapped.getActivePunishmentData(PunishmentType.BAN);
    PunishmentData muteData = wrapped.getActivePunishmentData(PunishmentType.MUTE);
    TextComponent report = StringUtil.clickableHoverableText(ChatColor.GRAY + "[Report] ", "/report " + targetUser.getName() + " ", true, "Click to report this user");
    TextComponent hold = !helper ? StringUtil.plainText("") : StringUtil.clickableHoverableText(ChatColor.GRAY + "[Place Hold] ", "/hold " + targetUser.getName() + " ", true, "Click to suspend this account for " + HoldLoader.HOLD_DURATION_HOURS + " hours pending review");
    TextComponent punish = !helper ? StringUtil.plainText("") : StringUtil.clickableHoverableText(ChatColor.GRAY + "[Punish] ", "/punish " + targetUser.getName(), "Click to punish this user");
    TextComponent escalate = StringUtil.clickableHoverableText(ChatColor.GRAY + "[Escalate] ", "/escalate " + targetUser.getName() + " ", "Click to escalate an issue with this user", "for review by a senior staff member");
    TextComponent watchlist = !mod ? StringUtil.plainText("") : StringUtil.clickableHoverableText(ChatColor.GRAY + "[Watchlist] ", "/watchlist add " + targetUser.getName() + " ", true, "Click to add this user to the watch list.", "You will be prompted to enter a reason.");
    TextComponent reports = !mod ? StringUtil.plainText("") : StringUtil.clickableHoverableText(ChatColor.GRAY + "[View Reports] ", "/reports on " + targetUser.getName(), "Click to view reports filed against this user");
    TextComponent phistory = !helper ? StringUtil.plainText("") : StringUtil.clickableHoverableText(ChatColor.GRAY + "[View Punishments]", "/viewpunishments " + targetUser.getName(), "Click to view this user's full punishment history");
    sender.sendMessage(ChatColor.GOLD + "Report for User " + targetUser.getName());
    if (targetPlayer == null) {
        sender.sendMessage(ChatColor.YELLOW + "" + ChatColor.ITALIC + "This player is offline. Showing cached data.");
    }
    sender.spigot().sendMessage(report, hold, punish, escalate, watchlist, reports, phistory);
    sender.sendMessage(ChatColor.YELLOW + "UUID: " + ChatColor.RESET + targetUser.getIdentifier().getUUID().toString());
    if (targetUser.getServerName() != null) {
        sender.sendMessage(ChatColor.YELLOW + "Current Server: " + ChatColor.RESET + targetUser.getServerName());
    }
    if (mod) {
        sender.sendMessage(ChatColor.YELLOW + "Active Punishments:");
        if (banData == null) {
            sender.sendMessage(ChatColor.WHITE + "- Not banned");
        } else {
            sender.sendMessage(ChatColor.WHITE + "- Banned: " + banData.getReason() + " (" + (banData.isPermanent() ? "Permanent" : "Until " + StringUtil.DATE_FORMAT.format(banData.getExpiry())) + ")");
            goodStanding = false;
        }
        if (muteData == null) {
            sender.sendMessage(ChatColor.WHITE + "- Not muted");
        } else {
            sender.sendMessage(ChatColor.WHITE + "- Muted: " + muteData.getReason() + " (" + (muteData.isPermanent() ? "Permanent" : "Until " + StringUtil.DATE_FORMAT.format(muteData.getExpiry())) + ")");
            goodStanding = false;
        }
        List<HoldEntry> holds = holdLoader.getActiveHoldsByUser(targetUser);
        if (holds.size() > 0) {
            sender.spigot().sendMessage(StringUtil.plainText(ChatColor.WHITE + "- " + holds.size() + " holds have been placed on this account. "), StringUtil.clickableHoverableText(ChatColor.GRAY + "[View Holds]", "/viewholds " + targetUser.getName(), "Click to view active holds on this user"));
            goodStanding = false;
        }
        wrapped.updateStandingLevels();
        sender.sendMessage(ChatColor.YELLOW + "Standing Levels: " + ChatColor.RESET + Arrays.stream(StandingLevelType.values()).map(t -> t.toString() + " (" + wrapped.getStandingLevel(t) + ")").reduce((a, b) -> a + ", " + b).get());
        for (StandingLevelType level : StandingLevelType.values()) {
            if (wrapped.getStandingLevel(level) > 1) {
                goodStanding = false;
            }
        }
    }
    sender.sendMessage(ChatColor.YELLOW + "XP: " + ChatColor.RESET + targetUser.getXP() + " [Level " + targetUser.getLevel() + "] (" + MathUtil.round(targetUser.getLevelProgress() * 100) + "%)");
    sender.sendMessage(ChatColor.YELLOW + "Rank: " + ChatColor.RESET + targetUser.getRank().getRankName());
    sender.sendMessage(ChatColor.YELLOW + "Gold Balance: " + ChatColor.RESET + targetUser.getGold());
    sender.sendMessage(ChatColor.YELLOW + "Total Time Online: " + ChatColor.RESET + StringUtil.parseSecondsToTimespan(targetUser.getTotalOnlineTime()));
    sender.sendMessage(ChatColor.YELLOW + "Speaking Channel: " + ChatColor.RESET + targetUser.getSpeakingChannel());
    sender.sendMessage(ChatColor.YELLOW + "Listening Channels: " + ChatColor.RESET + StringUtil.parseList(targetUser.getActiveChatChannels()));
    if (targetPlayer == null) {
        sender.sendMessage(ChatColor.YELLOW + "Cached Location: " + ChatColor.RESET + StringUtil.locToString(targetUser.getSavedLocation()) + " in " + targetUser.getSavedLocation().getWorld().getName());
        sender.sendMessage(ChatColor.YELLOW + "Cached Floor: " + ChatColor.RESET + FloorLoader.fromLocation(targetUser.getSavedLocation()).getDisplayName());
        sender.sendMessage(ChatColor.YELLOW + "Cached Regions: " + ChatColor.RESET + regionLoader.getRegionsByLocation(targetUser.getSavedLocation()).stream().map(r -> r.getFlags().getString("fullname")).collect(Collectors.joining(", ")));
        sender.sendMessage(ChatColor.YELLOW + "Health: " + ChatColor.RESET + targetUser.getSavedHealth() + " / " + targetUser.getSavedMaxHealth());
    } else if (mod) {
        if (targetUser.getSystemProfile() != null) {
            sender.sendMessage(ChatColor.YELLOW + "System Profile: " + ChatColor.RESET + targetUser.getSystemProfile().getProfileName());
        }
        sender.sendMessage(ChatColor.YELLOW + "Active Permission Level: " + ChatColor.RESET + targetUser.getActivePermissionLevel().toString());
        sender.sendMessage(ChatColor.YELLOW + "Location: " + ChatColor.RESET + StringUtil.locToString(targetPlayer.getLocation()) + " in " + targetPlayer.getWorld().getName());
        sender.sendMessage(ChatColor.YELLOW + "Floor: " + ChatColor.RESET + FloorLoader.fromLocation(targetPlayer.getLocation()).getDisplayName());
        sender.sendMessage(ChatColor.YELLOW + "Regions: " + ChatColor.RESET + targetUser.getRegions().stream().map(r -> r.getFlags().getString("fullname")).collect(Collectors.joining(", ")));
        sender.sendMessage(ChatColor.YELLOW + "Health: " + ChatColor.RESET + targetPlayer.getHealth() + " / " + targetPlayer.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
    }
    sender.sendMessage(ChatColor.YELLOW + "Skills: " + ChatColor.RESET + skills);
    sender.sendMessage(ChatColor.YELLOW + "First Join: " + ChatColor.RESET + StringUtil.formatDate(targetUser.getFirstJoined()));
    sender.sendMessage(ChatColor.YELLOW + "Last Join: " + ChatColor.RESET + StringUtil.formatDate(targetUser.getLastJoined()));
    sender.sendMessage(ChatColor.YELLOW + "Last Seen: " + ChatColor.RESET + StringUtil.formatDate(targetUser.getLastSeen()));
    if (mod) {
        if (goodStanding) {
            sender.sendMessage(ChatColor.GREEN + "User is in good standing");
        } else {
            sender.sendMessage(ChatColor.RED + "User is not in good standing");
        }
    }
    if (targetPlayer == null) {
        // User was only constructed for querying purposes. Since they're not really online, remove them from local registry
        userLoader.unregister(targetUser);
    }
    return true;
}
Also used : WrappedUser(mc.dragons.tools.moderation.WrappedUser) PunishmentType(mc.dragons.tools.moderation.punishment.PunishmentType) Attribute(org.bukkit.attribute.Attribute) StringUtil(mc.dragons.core.util.StringUtil) Arrays(java.util.Arrays) CommandSender(org.bukkit.command.CommandSender) SkillType(mc.dragons.core.gameobject.user.SkillType) FloorLoader(mc.dragons.core.gameobject.floor.FloorLoader) HoldEntry(mc.dragons.tools.moderation.hold.HoldLoader.HoldEntry) User(mc.dragons.core.gameobject.user.User) Player(org.bukkit.entity.Player) SystemProfileFlag(mc.dragons.core.gameobject.user.permission.SystemProfile.SystemProfileFlags.SystemProfileFlag) Collectors(java.util.stream.Collectors) StandingLevelType(mc.dragons.tools.moderation.punishment.StandingLevelType) TextComponent(net.md_5.bungee.api.chat.TextComponent) List(java.util.List) DragonsCommandExecutor(mc.dragons.core.commands.DragonsCommandExecutor) PermissionLevel(mc.dragons.core.gameobject.user.permission.PermissionLevel) HoldLoader(mc.dragons.tools.moderation.hold.HoldLoader) PunishmentData(mc.dragons.tools.moderation.punishment.PunishmentData) ChatColor(org.bukkit.ChatColor) Command(org.bukkit.command.Command) MathUtil(mc.dragons.core.util.MathUtil) Bukkit(org.bukkit.Bukkit) TextComponent(net.md_5.bungee.api.chat.TextComponent) StandingLevelType(mc.dragons.tools.moderation.punishment.StandingLevelType) Player(org.bukkit.entity.Player) WrappedUser(mc.dragons.tools.moderation.WrappedUser) User(mc.dragons.core.gameobject.user.User) HoldEntry(mc.dragons.tools.moderation.hold.HoldLoader.HoldEntry) PunishmentData(mc.dragons.tools.moderation.punishment.PunishmentData) WrappedUser(mc.dragons.tools.moderation.WrappedUser)

Example 2 with StandingLevelType

use of mc.dragons.tools.moderation.punishment.StandingLevelType in project DragonsOnline by UniverseCraft.

the class PurgePunishmentsCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!requirePermission(sender, PermissionLevel.ADMIN) || !requirePermission(sender, SystemProfileFlag.MODERATION))
        return true;
    if (args.length == 0) {
        sender.sendMessage(ChatColor.RED + "/purgepunishments <player>");
        return true;
    }
    User target = lookupUser(sender, args[0]);
    if (target == null)
        return true;
    Document standingLevelsEmpty = new Document();
    for (StandingLevelType level : StandingLevelType.values()) {
        standingLevelsEmpty.append(level.toString(), new Document("level", 0).append("on", 0L));
    }
    target.getStorageAccess().set("punishmentHistory", new ArrayList<>());
    target.getStorageAccess().set("standingLevel", standingLevelsEmpty);
    holdLoader.getActiveHoldsByUser(target).forEach(hold -> {
        hold.setStatus(HoldStatus.CLOSED_NOACTION);
        reportLoader.getReportById(hold.getReportId()).setStatus(ReportStatus.NO_ACTION);
    });
    reportLoader.closeReports(new Document("target", List.of(target.getUUID().toString())).append("status", new Document("$in", List.of(ReportStatus.OPEN.toString(), ReportStatus.SUSPENDED.toString()))));
    sender.sendMessage(ChatColor.GREEN + "Purged punishment history of " + target.getName() + " and released all pending holds and watchlist entries");
    return true;
}
Also used : StandingLevelType(mc.dragons.tools.moderation.punishment.StandingLevelType) User(mc.dragons.core.gameobject.user.User) Document(org.bson.Document)

Example 3 with StandingLevelType

use of mc.dragons.tools.moderation.punishment.StandingLevelType in project DragonsOnline by UniverseCraft.

the class StandingLevelCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!requirePermission(sender, PermissionLevel.ADMIN) || !requirePermission(sender, SystemProfileFlag.MODERATION))
        return true;
    if (args.length < 3) {
        sender.sendMessage(ChatColor.RED + "/setsl <player> <type> <level>");
        return true;
    }
    User target = lookupUser(sender, args[0]);
    StandingLevelType type = StringUtil.parseEnum(sender, StandingLevelType.class, args[1].toUpperCase());
    Integer level = parseInt(sender, args[2]);
    if (target == null || type == null || level == null)
        return true;
    WrappedUser wrapped = WrappedUser.of(target);
    wrapped.setStandingLevel(type, level);
    sender.sendMessage(ChatColor.GREEN + "Updated " + target.getName() + "'s standing level successfully.");
    return true;
}
Also used : StandingLevelType(mc.dragons.tools.moderation.punishment.StandingLevelType) WrappedUser(mc.dragons.tools.moderation.WrappedUser) User(mc.dragons.core.gameobject.user.User) WrappedUser(mc.dragons.tools.moderation.WrappedUser)

Example 4 with StandingLevelType

use of mc.dragons.tools.moderation.punishment.StandingLevelType in project DragonsOnline by UniverseCraft.

the class NSPunishCommands method manual.

// Complicated logic for bans and mutes
private void manual(CommandSender sender, String[] args, PunishmentType type) {
    if (!requirePermission(sender, SystemProfileFlag.MODERATION))
        return;
    String cmd = type == PunishmentType.BAN ? "ban" : "mute";
    if (args.length < 2) {
        sender.sendMessage(ChatColor.RED + "/" + cmd + " <player> <code> [extra info] [-d <#y#w#d#h#m#s|permanent>]");
        return;
    }
    String action = type == PunishmentType.BAN ? "Banned" : "Muted";
    StandingLevelType slType = type == PunishmentType.BAN ? StandingLevelType.BAN : StandingLevelType.MUTE;
    User target = lookupUser(sender, args[0]);
    PunishmentCode code = PunishmentCode.parseCode(sender, args[1]);
    if (target == null || code == null)
        return;
    int durationIndex = StringUtil.getFlagIndex(args, "-d", 2);
    String extraInfo = StringUtil.concatArgs(args, 2, durationIndex);
    WrappedUser wtarget = WrappedUser.of(target);
    long duration;
    if (durationIndex == -1) {
        duration = WrappedUser.getDurationByStandingLevel(wtarget.getStandingLevel(slType) + code.getStandingLevel());
        if (duration == 0) {
            sender.sendMessage(ChatColor.RED + "Insufficient standing level to apply mute automatically, please specify duration");
            sender.sendMessage(ChatColor.RED + "/" + cmd + " <player> <code> [extra info] -d <#y#w#d#h#m#s|permanent>");
            return;
        }
    } else if (args[durationIndex + 1].equalsIgnoreCase("permanent")) {
        duration = -1;
    } else {
        duration = StringUtil.parseTimespanToSeconds(args[durationIndex + 1]);
    }
    wtarget.autoPunish(type, slType, code, extraInfo, user(sender), duration);
    sender.sendMessage(ChatColor.GREEN + action + " " + target.getName() + ": " + code.getName() + " (" + StringUtil.parseSecondsToTimespan(duration) + ")");
}
Also used : StandingLevelType(mc.dragons.tools.moderation.punishment.StandingLevelType) WrappedUser(mc.dragons.tools.moderation.WrappedUser) User(mc.dragons.core.gameobject.user.User) PunishmentCode(mc.dragons.tools.moderation.punishment.PunishmentCode) WrappedUser(mc.dragons.tools.moderation.WrappedUser)

Example 5 with StandingLevelType

use of mc.dragons.tools.moderation.punishment.StandingLevelType in project DragonsOnline by UniverseCraft.

the class ModUserHook method onCreateStorageAccess.

@Override
public void onCreateStorageAccess(Document data) {
    Document blankStandingLevel = new Document();
    for (StandingLevelType type : StandingLevelType.values()) {
        blankStandingLevel.append(type.toString(), new Document("level", 0).append("on", 0L));
    }
    data.append("standingLevel", blankStandingLevel);
}
Also used : StandingLevelType(mc.dragons.tools.moderation.punishment.StandingLevelType) Document(org.bson.Document)

Aggregations

StandingLevelType (mc.dragons.tools.moderation.punishment.StandingLevelType)5 User (mc.dragons.core.gameobject.user.User)4 WrappedUser (mc.dragons.tools.moderation.WrappedUser)3 Document (org.bson.Document)2 Arrays (java.util.Arrays)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 DragonsCommandExecutor (mc.dragons.core.commands.DragonsCommandExecutor)1 FloorLoader (mc.dragons.core.gameobject.floor.FloorLoader)1 SkillType (mc.dragons.core.gameobject.user.SkillType)1 PermissionLevel (mc.dragons.core.gameobject.user.permission.PermissionLevel)1 SystemProfileFlag (mc.dragons.core.gameobject.user.permission.SystemProfile.SystemProfileFlags.SystemProfileFlag)1 MathUtil (mc.dragons.core.util.MathUtil)1 StringUtil (mc.dragons.core.util.StringUtil)1 HoldLoader (mc.dragons.tools.moderation.hold.HoldLoader)1 HoldEntry (mc.dragons.tools.moderation.hold.HoldLoader.HoldEntry)1 PunishmentCode (mc.dragons.tools.moderation.punishment.PunishmentCode)1 PunishmentData (mc.dragons.tools.moderation.punishment.PunishmentData)1 PunishmentType (mc.dragons.tools.moderation.punishment.PunishmentType)1 TextComponent (net.md_5.bungee.api.chat.TextComponent)1