Rename Services and LogsType enums

This commit is contained in:
zax71 2023-08-30 17:26:15 +01:00
parent 2b7d1412b5
commit 0c79c6577e

View File

@ -59,35 +59,35 @@ public class DumpsCommand extends MultiverseCommand {
this.worldManager = worldManager; this.worldManager = worldManager;
registerFlagGroup(CommandFlagGroup.builder("mvdumps") registerFlagGroup(CommandFlagGroup.builder("mvdumps")
.add(CommandValueFlag.builder("--logs", LogsType.class) .add(CommandValueFlag.builder("--logs", LogsTypeOption.class)
.addAlias("-l") .addAlias("-l")
.context((value) -> { .context((value) -> {
try { try {
return LogsType.valueOf(value.toUpperCase()); return LogsTypeOption.valueOf(value.toUpperCase());
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
throw new InvalidCommandArgument("Invalid logs type " + value + " in --logs"); throw new InvalidCommandArgument("Invalid logs type " + value + " in --logs");
} }
}) })
.completion(() -> { .completion(() -> {
List<String> types = new ArrayList<>(); List<String> types = new ArrayList<>();
for (LogsType type : LogsType.values()) { for (LogsTypeOption type : LogsTypeOption.values()) {
types.add(type.name().toLowerCase()); types.add(type.name().toLowerCase());
} }
return types; return types;
}) })
.build()) .build())
.add(CommandValueFlag.builder("--upload", Services.class) .add(CommandValueFlag.builder("--upload", ServiceTypeOption.class)
.addAlias("-u") .addAlias("-u")
.context((value) -> { .context((value) -> {
try { try {
return Services.valueOf(value.toUpperCase()); return ServiceTypeOption.valueOf(value.toUpperCase());
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
throw new InvalidCommandArgument("Invalid service " + value + " in --upload"); throw new InvalidCommandArgument("Invalid service " + value + " in --upload");
} }
}) })
.completion(() -> { .completion(() -> {
List<String> types = new ArrayList<>(); List<String> types = new ArrayList<>();
for (Services type : Services.values()) { for (ServiceTypeOption type : ServiceTypeOption.values()) {
types.add(type.name().toLowerCase()); types.add(type.name().toLowerCase());
} }
return types; return types;
@ -99,12 +99,12 @@ public class DumpsCommand extends MultiverseCommand {
.build()); .build());
} }
private enum Services { private enum ServiceTypeOption {
PASTEGG, PASTEGG,
PASTESDEV PASTESDEV
} }
private enum LogsType { private enum LogsTypeOption {
APPEND, APPEND,
MCLOGS MCLOGS
} }
@ -133,32 +133,32 @@ public class DumpsCommand extends MultiverseCommand {
} }
// Deal with default case of logs // Deal with default case of logs
LogsType logsType = parsedFlags.flagValue("--logs", LogsType.class); LogsTypeOption logsTypeOption = parsedFlags.flagValue("--logs", LogsTypeOption.class);
if (logsType == null) { if (logsTypeOption == null) {
logsType = LogsType.MCLOGS; logsTypeOption = LogsTypeOption.MCLOGS;
Logging.finer("Logs was null so set to mclogs"); Logging.finer("Logs was null so set to mclogs");
} }
// Deal with default case of upload // Deal with default case of upload
Services services = parsedFlags.flagValue("--upload", Services.class); ServiceTypeOption serviceTypeOption = parsedFlags.flagValue("--upload", ServiceTypeOption.class);
if (services == null) { if (serviceTypeOption == null) {
services = Services.PASTEGG; serviceTypeOption = ServiceTypeOption.PASTEGG;
Logging.finer("Upload was null so set to pastegg"); Logging.finer("Upload was null so set to pastegg");
} }
// Need to be final for some reason... // Need to be final for some reason...
final LogsType finalLogsType = logsType; final LogsTypeOption finalLogsTypeOption = logsTypeOption;
final Services finalServices = services; final ServiceTypeOption finalServiceTypeOption = serviceTypeOption;
BukkitRunnable logPoster = new BukkitRunnable() { BukkitRunnable logPoster = new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
HashMap<String, String> pasteURLs = new HashMap<>(); HashMap<String, String> pasteURLs = new HashMap<>();
Logging.finer("Logs type is: " + finalLogsType); Logging.finer("Logs type is: " + finalLogsTypeOption);
Logging.finer("Services is: " + finalServices); Logging.finer("Services is: " + finalServiceTypeOption);
// Deal with logs flag // Deal with logs flag
if (!parsedFlags.hasFlag("--paranoid")) { if (!parsedFlags.hasFlag("--paranoid")) {
switch (finalLogsType) { switch (finalLogsTypeOption) {
case MCLOGS -> issuer.sendInfo(MVCorei18n.DUMPS_URL_LIST, case MCLOGS -> issuer.sendInfo(MVCorei18n.DUMPS_URL_LIST,
"{service}", "Logs", "{service}", "Logs",
"{link}", postToService(PasteServiceType.MCLOGS, true, getLogs(), null) "{link}", postToService(PasteServiceType.MCLOGS, true, getLogs(), null)
@ -171,7 +171,7 @@ public class DumpsCommand extends MultiverseCommand {
final Map<String, String> files = versionEvent.getDetailedVersionInfo(); final Map<String, String> files = versionEvent.getDetailedVersionInfo();
// Deal with uploading debug info // Deal with uploading debug info
switch (finalServices) { switch (finalServiceTypeOption) {
case PASTEGG -> issuer.sendInfo(MVCorei18n.DUMPS_URL_LIST, case PASTEGG -> issuer.sendInfo(MVCorei18n.DUMPS_URL_LIST,
"{service}", "paste.gg", "{service}", "paste.gg",
"{link}", postToService(PasteServiceType.PASTEGG, true, null, files) "{link}", postToService(PasteServiceType.PASTEGG, true, null, files)