[CHORE] Code Cleanup
This commit is contained in:
@@ -29,7 +29,10 @@ import java.io.IOException;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import static com.hypherionmc.sdlink.core.managers.DatabaseManager.sdlinkDatabase;
|
import static com.hypherionmc.sdlink.core.managers.DatabaseManager.sdlinkDatabase;
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
package com.hypherionmc.sdlink.core.discord.commands.slash.general;
|
package com.hypherionmc.sdlink.core.discord.commands.slash.general;
|
||||||
|
|
||||||
import com.hypherionmc.sdlink.core.accounts.MinecraftAccount;
|
import com.hypherionmc.sdlink.core.accounts.MinecraftAccount;
|
||||||
|
import com.hypherionmc.sdlink.core.config.SDLinkConfig;
|
||||||
import com.hypherionmc.sdlink.core.discord.commands.slash.SDLinkSlashCommand;
|
import com.hypherionmc.sdlink.core.discord.commands.slash.SDLinkSlashCommand;
|
||||||
import com.hypherionmc.sdlink.core.services.SDLinkPlatform;
|
import com.hypherionmc.sdlink.core.services.SDLinkPlatform;
|
||||||
import com.hypherionmc.sdlink.core.util.MessageUtil;
|
import com.hypherionmc.sdlink.core.util.MessageUtil;
|
||||||
@@ -63,7 +64,7 @@ public class PlayerListSlashCommand extends SDLinkSlashCommand {
|
|||||||
p.forEach(account -> {
|
p.forEach(account -> {
|
||||||
sb.append("`").append(account.getUsername()).append("`");
|
sb.append("`").append(account.getUsername()).append("`");
|
||||||
|
|
||||||
if (account.getDiscordUser() != null) {
|
if (SDLinkConfig.INSTANCE.accessControl.enabled && account.getDiscordUser() != null) {
|
||||||
sb.append(" - ").append(account.getDiscordUser().getAsMention());
|
sb.append(" - ").append(account.getDiscordUser().getAsMention());
|
||||||
}
|
}
|
||||||
sb.append("\r\n");
|
sb.append("\r\n");
|
||||||
|
@@ -26,12 +26,10 @@ public class StaffUnverifyCommand extends SDLinkSlashCommand {
|
|||||||
this.name = "staffunverify";
|
this.name = "staffunverify";
|
||||||
this.help = "Unverify another player's Minecraft account";
|
this.help = "Unverify another player's Minecraft account";
|
||||||
|
|
||||||
List<OptionData> options = new ArrayList<>() {{
|
this.options = new ArrayList<>() {{
|
||||||
add(new OptionData(OptionType.USER, "discorduser", "The discord user the minecraft account belongs to").setRequired(true));
|
add(new OptionData(OptionType.USER, "discorduser", "The discord user the minecraft account belongs to").setRequired(true));
|
||||||
add(new OptionData(OptionType.STRING, "mcname", "The minecraft account of the linked user").setRequired(true));
|
add(new OptionData(OptionType.STRING, "mcname", "The minecraft account of the linked user").setRequired(true));
|
||||||
}};
|
}};
|
||||||
|
|
||||||
this.options = options;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -14,7 +14,6 @@ import net.dv8tion.jda.api.interactions.commands.OptionType;
|
|||||||
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class StaffVerifyAccountCommand extends SDLinkSlashCommand {
|
public class StaffVerifyAccountCommand extends SDLinkSlashCommand {
|
||||||
|
|
||||||
@@ -23,12 +22,10 @@ public class StaffVerifyAccountCommand extends SDLinkSlashCommand {
|
|||||||
this.name = "staffverify";
|
this.name = "staffverify";
|
||||||
this.help = "Allow staff members verify minecraft players, without verification";
|
this.help = "Allow staff members verify minecraft players, without verification";
|
||||||
|
|
||||||
List<OptionData> options = new ArrayList<>() {{
|
this.options = new ArrayList<>() {{
|
||||||
add(new OptionData(OptionType.USER, "discorduser", "The discord user the minecraft account belongs to").setRequired(true));
|
add(new OptionData(OptionType.USER, "discorduser", "The discord user the minecraft account belongs to").setRequired(true));
|
||||||
add(new OptionData(OptionType.STRING, "mcname", "The minecraft account to link to the user").setRequired(true));
|
add(new OptionData(OptionType.STRING, "mcname", "The minecraft account to link to the user").setRequired(true));
|
||||||
}};
|
}};
|
||||||
|
|
||||||
this.options = options;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -35,36 +35,6 @@ public class SystemUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Time Conversion
|
// Time Conversion
|
||||||
public static final List<Long> times = Arrays.asList(
|
|
||||||
TimeUnit.DAYS.toMillis(365),
|
|
||||||
TimeUnit.DAYS.toMillis(30),
|
|
||||||
TimeUnit.DAYS.toMillis(1),
|
|
||||||
TimeUnit.HOURS.toMillis(1),
|
|
||||||
TimeUnit.MINUTES.toMillis(1),
|
|
||||||
TimeUnit.SECONDS.toMillis(1));
|
|
||||||
|
|
||||||
public static final List<String> timesString = Arrays.asList("year", "month", "day", "hour", "minute", "second");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unix Timestamp to Duration
|
|
||||||
* @param duration Unix Timestamp
|
|
||||||
* @return Formatted Duration
|
|
||||||
*/
|
|
||||||
public static String toDuration(long duration) {
|
|
||||||
StringBuffer res = new StringBuffer();
|
|
||||||
for (int i = 0; i < times.size(); i++) {
|
|
||||||
Long current = times.get(i);
|
|
||||||
long temp = duration / current;
|
|
||||||
if (temp > 0) {
|
|
||||||
res.append(temp).append(" ").append(timesString.get(i)).append(temp != 1 ? "s" : "");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ("".equals(res.toString()))
|
|
||||||
return "0 seconds ago";
|
|
||||||
else
|
|
||||||
return res.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert Seconds into a Timestamp
|
* Convert Seconds into a Timestamp
|
||||||
@@ -85,13 +55,6 @@ public class SystemUtils {
|
|||||||
return timeString;
|
return timeString;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate random verification code for Whitelisting and Account Linking
|
|
||||||
*/
|
|
||||||
public static int generateRandomJoinCode() {
|
|
||||||
return new Random().ints(1000, 9999).findFirst().getAsInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isLong(String input) {
|
public static boolean isLong(String input) {
|
||||||
try {
|
try {
|
||||||
Long.parseLong(input);
|
Long.parseLong(input);
|
||||||
|
Reference in New Issue
Block a user