Organize the util classes

This commit is contained in:
2022-04-19 15:19:55 -05:00
parent 98c487c639
commit 7d2a25668a
16 changed files with 329 additions and 336 deletions

View File

@ -12,19 +12,18 @@ import dev.plex.punishment.Punishment;
import dev.plex.punishment.PunishmentType;
import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexUtils;
import dev.plex.util.TimeUtils;
import dev.plex.util.WebUtils;
import java.util.List;
import java.util.UUID;
import net.kyori.adventure.text.Component;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;
@CommandParameters(name = "tempban", usage = "/<command> <player> <time> [reason]", description = "Temporarily ban a player")
@CommandPermissions(level = Rank.ADMIN, permission = "plex.tempban", source = RequiredCommandSource.ANY)
@ -38,7 +37,7 @@ public class TempbanCMD extends PlexCommand
return usage();
}
UUID targetUUID = PlexUtils.getFromName(args[0]);
UUID targetUUID = WebUtils.getFromName(args[0]);
String reason;
if (targetUUID == null || !DataUtils.hasPlayedBefore(targetUUID))
@ -67,17 +66,18 @@ public class TempbanCMD extends PlexCommand
return messageComponent("playerBanned");
}
Punishment punishment = new Punishment(targetUUID, getUUID(sender));
punishment.setType(PunishmentType.TEMPBAN);
punishment.setType(PunishmentType.BAN);
if (args.length > 2)
{
reason = StringUtils.join(args, " ", 2, args.length);
punishment.setReason(reason);
} else
}
else
{
punishment.setReason("No reason provided.");
}
punishment.setPunishedUsername(plexPlayer.getName());
punishment.setEndDate(PlexUtils.createDate(args[1]));
punishment.setEndDate(TimeUtils.createDate(args[1]));
punishment.setCustomTime(false);
punishment.setActive(!isAdmin(plexPlayer));
if (player != null)