Search in sources :

Example 1 with PunishmentType

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

the class PunishCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!requirePlayer(sender) || !requirePermission(sender, SystemProfileFlag.HELPER))
        return true;
    if (args.length == 0) {
        sender.sendMessage(ChatColor.RED + "Specify a player and code! /punish <player1 [player2 ...]> <code> [extra info]");
        return true;
    }
    CmdData data = CmdUtil.parse(sender, "/punish <players> <code> ", args);
    if (data == null)
        return true;
    int level = data.code.getStandingLevel();
    boolean canApply = data.code.canApply(user(sender));
    boolean notMod = !hasPermission(sender, SystemProfileFlag.MODERATION);
    List<WrappedUser> wrapped = data.targets.stream().map(u -> WrappedUser.of(u)).collect(Collectors.toList());
    int minEffectiveLevel = -1;
    for (WrappedUser w : wrapped) {
        w.updateStandingLevels();
        if (canApply) {
            // Punish immediately
            PunishmentType type = w.autoPunish(data.code, data.extraInfo, user(sender)).type;
            String punishment = "Punished";
            if (type == PunishmentType.BAN) {
                punishment = "Banned";
            } else if (type == PunishmentType.MUTE) {
                punishment = "Muted";
            } else if (type == PunishmentType.KICK) {
                punishment = "Kicked";
            } else if (type == PunishmentType.WARNING) {
                punishment = "Warned";
            }
            sender.sendMessage(ChatColor.GREEN + "Punishment applied to " + w.getUser().getName() + ": " + punishment + " for " + data.code.getName());
        }
        if (level >= 10 && notMod) {
            Report review = reportLoader.fileStaffReport(data.targets, user(sender), "Post Review: " + data.formatInternalReason(), "");
            sender.sendMessage(ChatColor.GRAY + " A senior staff member will review this punishment. (Escalation Report ID: " + review.getId() + ")");
        }
    }
    if (!canApply) {
        // Generate escalation report
        Report r = reportLoader.fileStaffReport(data.targets, user(sender), data.formatInternalReason(), "punish " + StringUtil.parseList(data.targets.stream().map(u -> u.getUUID().toString()).collect(Collectors.toList()), " ") + " " + data.code.getCode() + (data.extraInfo.isBlank() ? "" : " " + data.extraInfo) + " -uuid");
        boolean held = false;
        if (r != null && minEffectiveLevel > 1) {
            held = true;
            HoldEntry hold = holdLoader.newHold(data.targets, user(sender), data.formatInternalReason(), r, true, data.code.getType() == StandingLevelType.BAN ? HoldType.SUSPEND : HoldType.MUTE);
            r.getData().append("holdId", hold.getId());
            r.save();
        }
        sender.sendMessage(ChatColor.GREEN + (held ? "Placed a " + HoldLoader.HOLD_DURATION_HOURS + "-hour hold and escalated" : "Escalated") + " this issue for review by a senior staff member.");
    }
    return true;
}
Also used : WrappedUser(mc.dragons.tools.moderation.WrappedUser) PunishmentType(mc.dragons.tools.moderation.punishment.PunishmentType) StringUtil(mc.dragons.core.util.StringUtil) ReportLoader(mc.dragons.tools.moderation.report.ReportLoader) CommandSender(org.bukkit.command.CommandSender) HoldType(mc.dragons.tools.moderation.hold.HoldLoader.HoldType) HoldEntry(mc.dragons.tools.moderation.hold.HoldLoader.HoldEntry) SystemProfileFlag(mc.dragons.core.gameobject.user.permission.SystemProfile.SystemProfileFlags.SystemProfileFlag) Collectors(java.util.stream.Collectors) StandingLevelType(mc.dragons.tools.moderation.punishment.StandingLevelType) List(java.util.List) Report(mc.dragons.tools.moderation.report.ReportLoader.Report) DragonsCommandExecutor(mc.dragons.core.commands.DragonsCommandExecutor) CmdUtil(mc.dragons.tools.moderation.util.CmdUtil) HoldLoader(mc.dragons.tools.moderation.hold.HoldLoader) CmdData(mc.dragons.tools.moderation.util.CmdUtil.CmdData) ChatColor(org.bukkit.ChatColor) Command(org.bukkit.command.Command) HoldEntry(mc.dragons.tools.moderation.hold.HoldLoader.HoldEntry) Report(mc.dragons.tools.moderation.report.ReportLoader.Report) CmdData(mc.dragons.tools.moderation.util.CmdUtil.CmdData) WrappedUser(mc.dragons.tools.moderation.WrappedUser) PunishmentType(mc.dragons.tools.moderation.punishment.PunishmentType)

Example 2 with PunishmentType

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

the class UnPunishCommands method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!requirePermission(sender, SystemProfileFlag.HELPER))
        return true;
    if (args.length == 0) {
        sender.sendMessage(ChatColor.RED + "Specify a player and code! /" + label + " <player> <revocation code>");
        // sender.sendMessage(ChatColor.GRAY + "Warning: It is recommended to use /removepunishment to remove a specific punishment. This command revokes only the first applicable punishment.");
        return true;
    }
    if (args.length == 1) {
        sender.sendMessage(ChatColor.RED + "Select a revocation code below:");
        for (RevocationCode code : RevocationCode.values()) {
            sender.spigot().sendMessage(StringUtil.clickableHoverableText(ChatColor.GRAY + "- " + ChatColor.RESET + code.getCode() + ChatColor.GRAY + " - " + code.getDescription(), "/" + label + " " + args[0] + " " + code.getCode(), code.getDescription()));
        }
        return true;
    }
    User targetUser = lookupUser(sender, args[0]);
    RevocationCode code = RevocationCode.parseCode(sender, args[1]);
    if (targetUser == null || code == null)
        return true;
    WrappedUser wrapped = WrappedUser.of(targetUser);
    PunishmentType type = label.equalsIgnoreCase("unban") ? PunishmentType.BAN : PunishmentType.MUTE;
    List<PunishmentData> history = wrapped.getPunishmentHistory();
    PunishmentData record = null;
    int id = -1;
    for (int i = 0; i < history.size(); i++) {
        if (history.get(i).getType() == type && !history.get(i).hasExpired() && !history.get(i).isRevoked()) {
            id = i;
            record = history.get(i);
            break;
        }
    }
    if (record == null) {
        sender.sendMessage(ChatColor.RED + "This player does not have any active punishments matching those criteria!");
        return true;
    }
    if (!record.getIssuedBy().equals(user(sender)) && !hasPermission(sender, SystemProfileFlag.APPEALS_TEAM) || !hasPermission(sender, code.getPermissionToApply())) {
        sender.sendMessage(ChatColor.RED + "You do not have permission to revoke this punishment!");
        return true;
    }
    wrapped.unpunish(id, code, user(sender));
    // Check if we need to tell a different server to immediately revoke the punishment
    if (targetUser.getServerName() != null && !targetUser.getServerName().equals(dragons.getServerName())) {
        handler.forwardUnpunishment(targetUser, id);
    }
    sender.sendMessage(ChatColor.GREEN + "Punishment revoked successfully.");
    return true;
}
Also used : RevocationCode(mc.dragons.tools.moderation.punishment.RevocationCode) WrappedUser(mc.dragons.tools.moderation.WrappedUser) User(mc.dragons.core.gameobject.user.User) PunishmentData(mc.dragons.tools.moderation.punishment.PunishmentData) WrappedUser(mc.dragons.tools.moderation.WrappedUser) PunishmentType(mc.dragons.tools.moderation.punishment.PunishmentType)

Example 3 with PunishmentType

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

the class WrappedUser method autoPunish.

/**
 * Automatically issue the given punishment type, determining parameters,
 * updating standing level and punishment record, and forwarding to the
 * correct server as required.
 *
 * @param code
 * @param extraInfo
 * @param issuer
 * @return
 */
public AppliedPunishmentData autoPunish(PunishmentCode code, String extraInfo, User issuer) {
    user.getStorageAccess().pull("punishmentHistory", List.class);
    int standingLevel = getStandingLevel(code.getType()) + code.getStandingLevel();
    long duration = WrappedUser.getDurationByStandingLevel(standingLevel);
    PunishmentType type = code.getType().getPunishmentType();
    if (duration == 0) {
        type = PunishmentType.WARNING;
    }
    return new AppliedPunishmentData(type, autoPunish(type, code.getType(), code, extraInfo, issuer, duration), duration);
}
Also used : PunishmentType(mc.dragons.tools.moderation.punishment.PunishmentType)

Aggregations

PunishmentType (mc.dragons.tools.moderation.punishment.PunishmentType)3 WrappedUser (mc.dragons.tools.moderation.WrappedUser)2 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 DragonsCommandExecutor (mc.dragons.core.commands.DragonsCommandExecutor)1 User (mc.dragons.core.gameobject.user.User)1 SystemProfileFlag (mc.dragons.core.gameobject.user.permission.SystemProfile.SystemProfileFlags.SystemProfileFlag)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 HoldType (mc.dragons.tools.moderation.hold.HoldLoader.HoldType)1 PunishmentData (mc.dragons.tools.moderation.punishment.PunishmentData)1 RevocationCode (mc.dragons.tools.moderation.punishment.RevocationCode)1 StandingLevelType (mc.dragons.tools.moderation.punishment.StandingLevelType)1 ReportLoader (mc.dragons.tools.moderation.report.ReportLoader)1 Report (mc.dragons.tools.moderation.report.ReportLoader.Report)1 CmdUtil (mc.dragons.tools.moderation.util.CmdUtil)1 CmdData (mc.dragons.tools.moderation.util.CmdUtil.CmdData)1 ChatColor (org.bukkit.ChatColor)1 Command (org.bukkit.command.Command)1