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

@ -14,6 +14,7 @@ import dev.plex.punishment.PunishmentType;
import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexLog;
import dev.plex.util.PlexUtils;
import dev.plex.util.WebUtils;
import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;
@ -38,7 +39,7 @@ public class BanCMD extends PlexCommand
return usage();
}
UUID targetUUID = PlexUtils.getFromName(args[0]);
UUID targetUUID = WebUtils.getFromName(args[0]);
if (targetUUID == null || !DataUtils.hasPlayedBefore(targetUUID))
{

View File

@ -6,6 +6,7 @@ import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.annotation.System;
import dev.plex.rank.enums.Rank;
import dev.plex.util.GameRuleUtil;
import dev.plex.util.PlexLog;
import dev.plex.util.PlexUtils;
import java.util.Arrays;
@ -47,7 +48,7 @@ public class DebugCMD extends PlexCommand
{
for (World world : Bukkit.getWorlds())
{
PlexUtils.commitGlobalGameRules(world);
GameRuleUtil.commitGlobalGameRules(world);
PlexLog.log("Set global gamerules for world: " + world.getName());
}
for (String world : plugin.config.getConfigurationSection("worlds").getKeys(false))
@ -55,7 +56,7 @@ public class DebugCMD extends PlexCommand
World bukkitWorld = Bukkit.getWorld(world);
if (bukkitWorld != null)
{
PlexUtils.commitSpecificGameRules(bukkitWorld);
GameRuleUtil.commitSpecificGameRules(bukkitWorld);
PlexLog.log("Set specific gamerules for world: " + world.toLowerCase(Locale.ROOT));
}
}

View File

@ -11,6 +11,7 @@ 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.WebUtils;
import java.time.LocalDateTime;
import java.util.UUID;
import net.kyori.adventure.text.Component;
@ -33,7 +34,7 @@ public class KickCMD extends PlexCommand
return usage();
}
UUID targetUUID = PlexUtils.getFromName(args[0]);
UUID targetUUID = WebUtils.getFromName(args[0]);
String reason = "No reason provided";
if (targetUUID == null || !DataUtils.hasPlayedBefore(targetUUID))

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)

View File

@ -11,6 +11,7 @@ import dev.plex.command.source.RequiredCommandSource;
import dev.plex.player.PlexPlayer;
import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexUtils;
import dev.plex.util.WebUtils;
import java.util.List;
import java.util.UUID;
import net.kyori.adventure.text.Component;
@ -34,7 +35,7 @@ public class UnbanCMD extends PlexCommand
if (args.length == 1)
{
UUID targetUUID = PlexUtils.getFromName(args[0]);
UUID targetUUID = WebUtils.getFromName(args[0]);
if (targetUUID == null || !DataUtils.hasPlayedBefore(targetUUID))
{