|
|
|
@ -55,38 +55,38 @@ public class HuskSyncCommand extends PluginCommand {
|
|
|
|
|
super("husksync", List.of(), Permission.Default.TRUE, ExecutionScope.ALL, plugin);
|
|
|
|
|
this.updateChecker = plugin.getUpdateChecker();
|
|
|
|
|
this.aboutMenu = AboutMenu.builder()
|
|
|
|
|
.title(Component.text("HuskSync"))
|
|
|
|
|
.description(Component.text("A modern, cross-server player data synchronization system"))
|
|
|
|
|
.version(plugin.getPluginVersion())
|
|
|
|
|
.credits("Author",
|
|
|
|
|
AboutMenu.Credit.of("William278").description("Click to visit website").url("https://william278.net"))
|
|
|
|
|
.credits("Contributors",
|
|
|
|
|
AboutMenu.Credit.of("HarvelsX").description("Code"),
|
|
|
|
|
AboutMenu.Credit.of("HookWoods").description("Code"),
|
|
|
|
|
AboutMenu.Credit.of("Preva1l").description("Code"),
|
|
|
|
|
AboutMenu.Credit.of("hanbings").description("Code (Fabric porting)"),
|
|
|
|
|
AboutMenu.Credit.of("Stampede2011").description("Code (Fabric mixins)"))
|
|
|
|
|
.credits("Translators",
|
|
|
|
|
AboutMenu.Credit.of("Namiu").description("Japanese (ja-jp)"),
|
|
|
|
|
AboutMenu.Credit.of("anchelthe").description("Spanish (es-es)"),
|
|
|
|
|
AboutMenu.Credit.of("Melonzio").description("Spanish (es-es)"),
|
|
|
|
|
AboutMenu.Credit.of("Ceddix").description("German (de-de)"),
|
|
|
|
|
AboutMenu.Credit.of("Pukejoy_1").description("Bulgarian (bg-bg)"),
|
|
|
|
|
AboutMenu.Credit.of("mateusneresrb").description("Brazilian Portuguese (pt-br)"),
|
|
|
|
|
AboutMenu.Credit.of("小蔡").description("Traditional Chinese (zh-tw)"),
|
|
|
|
|
AboutMenu.Credit.of("Ghost-chu").description("Simplified Chinese (zh-cn)"),
|
|
|
|
|
AboutMenu.Credit.of("DJelly4K").description("Simplified Chinese (zh-cn)"),
|
|
|
|
|
AboutMenu.Credit.of("Thourgard").description("Ukrainian (uk-ua)"),
|
|
|
|
|
AboutMenu.Credit.of("xF3d3").description("Italian (it-it)"),
|
|
|
|
|
AboutMenu.Credit.of("cada3141").description("Korean (ko-kr)"),
|
|
|
|
|
AboutMenu.Credit.of("Wirayuda5620").description("Indonesian (id-id)"),
|
|
|
|
|
AboutMenu.Credit.of("WinTone01").description("Turkish (tr-tr)"),
|
|
|
|
|
AboutMenu.Credit.of("IbanEtchep").description("French (fr-fr)"))
|
|
|
|
|
.buttons(
|
|
|
|
|
AboutMenu.Link.of("https://william278.net/docs/husksync").text("Documentation").icon("⛏"),
|
|
|
|
|
AboutMenu.Link.of("https://github.com/WiIIiam278/HuskSync/issues").text("Issues").icon("❌").color(TextColor.color(0xff9f0f)),
|
|
|
|
|
AboutMenu.Link.of("https://discord.gg/tVYhJfyDWG").text("Discord").icon("⭐").color(TextColor.color(0x6773f5)))
|
|
|
|
|
.build();
|
|
|
|
|
.title(Component.text("HuskSync"))
|
|
|
|
|
.description(Component.text("A modern, cross-server player data synchronization system"))
|
|
|
|
|
.version(plugin.getPluginVersion())
|
|
|
|
|
.credits("Author",
|
|
|
|
|
AboutMenu.Credit.of("William278").description("Click to visit website").url("https://william278.net"))
|
|
|
|
|
.credits("Contributors",
|
|
|
|
|
AboutMenu.Credit.of("HarvelsX").description("Code"),
|
|
|
|
|
AboutMenu.Credit.of("HookWoods").description("Code"),
|
|
|
|
|
AboutMenu.Credit.of("Preva1l").description("Code"),
|
|
|
|
|
AboutMenu.Credit.of("hanbings").description("Code (Fabric porting)"),
|
|
|
|
|
AboutMenu.Credit.of("Stampede2011").description("Code (Fabric mixins)"))
|
|
|
|
|
.credits("Translators",
|
|
|
|
|
AboutMenu.Credit.of("Namiu").description("Japanese (ja-jp)"),
|
|
|
|
|
AboutMenu.Credit.of("anchelthe").description("Spanish (es-es)"),
|
|
|
|
|
AboutMenu.Credit.of("Melonzio").description("Spanish (es-es)"),
|
|
|
|
|
AboutMenu.Credit.of("Ceddix").description("German (de-de)"),
|
|
|
|
|
AboutMenu.Credit.of("Pukejoy_1").description("Bulgarian (bg-bg)"),
|
|
|
|
|
AboutMenu.Credit.of("mateusneresrb").description("Brazilian Portuguese (pt-br)"),
|
|
|
|
|
AboutMenu.Credit.of("小蔡").description("Traditional Chinese (zh-tw)"),
|
|
|
|
|
AboutMenu.Credit.of("Ghost-chu").description("Simplified Chinese (zh-cn)"),
|
|
|
|
|
AboutMenu.Credit.of("DJelly4K").description("Simplified Chinese (zh-cn)"),
|
|
|
|
|
AboutMenu.Credit.of("Thourgard").description("Ukrainian (uk-ua)"),
|
|
|
|
|
AboutMenu.Credit.of("xF3d3").description("Italian (it-it)"),
|
|
|
|
|
AboutMenu.Credit.of("cada3141").description("Korean (ko-kr)"),
|
|
|
|
|
AboutMenu.Credit.of("Wirayuda5620").description("Indonesian (id-id)"),
|
|
|
|
|
AboutMenu.Credit.of("WinTone01").description("Turkish (tr-tr)"),
|
|
|
|
|
AboutMenu.Credit.of("IbanEtchep").description("French (fr-fr)"))
|
|
|
|
|
.buttons(
|
|
|
|
|
AboutMenu.Link.of("https://william278.net/docs/husksync").text("Documentation").icon("⛏"),
|
|
|
|
|
AboutMenu.Link.of("https://github.com/WiIIiam278/HuskSync/issues").text("Issues").icon("❌").color(TextColor.color(0xff9f0f)),
|
|
|
|
|
AboutMenu.Link.of("https://discord.gg/tVYhJfyDWG").text("Discord").icon("⭐").color(TextColor.color(0x6773f5)))
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -109,8 +109,8 @@ public class HuskSyncCommand extends PluginCommand {
|
|
|
|
|
final CommandUser user = user(sub, ctx);
|
|
|
|
|
plugin.getLocales().getLocale("system_status_header").ifPresent(user::sendMessage);
|
|
|
|
|
user.sendMessage(Component.join(
|
|
|
|
|
JoinConfiguration.newlines(),
|
|
|
|
|
Arrays.stream(StatusLine.values()).map(s -> s.get(plugin)).toList()
|
|
|
|
|
JoinConfiguration.newlines(),
|
|
|
|
|
Arrays.stream(StatusLine.values()).map(s -> s.get(plugin)).toList()
|
|
|
|
|
));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
@ -126,7 +126,7 @@ public class HuskSyncCommand extends PluginCommand {
|
|
|
|
|
plugin.getLocales().getLocale("reload_complete").ifPresent(user::sendMessage);
|
|
|
|
|
} catch (Throwable e) {
|
|
|
|
|
user.sendMessage(new MineDown(
|
|
|
|
|
"[Error:](#ff3300) [Failed to reload the plugin. Check console for errors.](#ff7e5e)"
|
|
|
|
|
"[Error:](#ff3300) [Failed to reload the plugin. Check console for errors.](#ff7e5e)"
|
|
|
|
|
));
|
|
|
|
|
plugin.log(Level.SEVERE, "Failed to reload the plugin", e);
|
|
|
|
|
}
|
|
|
|
@ -139,11 +139,11 @@ public class HuskSyncCommand extends PluginCommand {
|
|
|
|
|
final CommandUser user = user(sub, ctx);
|
|
|
|
|
if (checked.isUpToDate()) {
|
|
|
|
|
plugin.getLocales().getLocale("up_to_date", plugin.getPluginVersion().toString())
|
|
|
|
|
.ifPresent(user::sendMessage);
|
|
|
|
|
.ifPresent(user::sendMessage);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
plugin.getLocales().getLocale("update_available", checked.getLatestVersion().toString(),
|
|
|
|
|
plugin.getPluginVersion().toString()).ifPresent(user::sendMessage);
|
|
|
|
|
plugin.getPluginVersion().toString()).ifPresent(user::sendMessage);
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -154,10 +154,10 @@ public class HuskSyncCommand extends PluginCommand {
|
|
|
|
|
sub.setDefaultExecutor((ctx) -> {
|
|
|
|
|
plugin.log(Level.INFO, "Please choose a migrator, then run \"husksync migrate start <migrator>\"");
|
|
|
|
|
plugin.log(Level.INFO, String.format(
|
|
|
|
|
"List of available migrators:\nMigrator ID / Migrator Name:\n%s",
|
|
|
|
|
plugin.getAvailableMigrators().stream()
|
|
|
|
|
.map(migrator -> String.format("%s - %s", migrator.getIdentifier(), migrator.getName()))
|
|
|
|
|
.collect(Collectors.joining("\n"))
|
|
|
|
|
"List of available migrators:\nMigrator ID / Migrator Name:\n%s",
|
|
|
|
|
plugin.getAvailableMigrators().stream()
|
|
|
|
|
.map(migrator -> String.format("%s - %s", migrator.getIdentifier(), migrator.getName()))
|
|
|
|
|
.collect(Collectors.joining("\n"))
|
|
|
|
|
));
|
|
|
|
|
});
|
|
|
|
|
sub.addSubCommand("help", (help) -> help.addSyntax((cmd) -> {
|
|
|
|
@ -187,7 +187,7 @@ public class HuskSyncCommand extends PluginCommand {
|
|
|
|
|
return new ArgumentElement<>("migrator", reader -> {
|
|
|
|
|
final String id = reader.readString();
|
|
|
|
|
final Migrator migrator = plugin.getAvailableMigrators().stream()
|
|
|
|
|
.filter(m -> m.getIdentifier().equalsIgnoreCase(id)).findFirst().orElse(null);
|
|
|
|
|
.filter(m -> m.getIdentifier().equalsIgnoreCase(id)).findFirst().orElse(null);
|
|
|
|
|
if (migrator == null) {
|
|
|
|
|
throw CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownArgument().createWithContext(reader);
|
|
|
|
|
}
|
|
|
|
@ -202,54 +202,54 @@ public class HuskSyncCommand extends PluginCommand {
|
|
|
|
|
|
|
|
|
|
private enum StatusLine {
|
|
|
|
|
PLUGIN_VERSION(plugin -> Component.text("v" + plugin.getPluginVersion().toStringWithoutMetadata())
|
|
|
|
|
.appendSpace().append(plugin.getPluginVersion().getMetadata().isBlank() ? Component.empty()
|
|
|
|
|
: Component.text("(build " + plugin.getPluginVersion().getMetadata() + ")"))),
|
|
|
|
|
.appendSpace().append(plugin.getPluginVersion().getMetadata().isBlank() ? Component.empty()
|
|
|
|
|
: Component.text("(build " + plugin.getPluginVersion().getMetadata() + ")"))),
|
|
|
|
|
PLATFORM_TYPE(plugin -> Component.text(WordUtils.capitalizeFully(plugin.getPlatformType()))),
|
|
|
|
|
LANGUAGE(plugin -> Component.text(plugin.getSettings().getLanguage())),
|
|
|
|
|
MINECRAFT_VERSION(plugin -> Component.text(plugin.getMinecraftVersion().toString())),
|
|
|
|
|
JAVA_VERSION(plugin -> Component.text(System.getProperty("java.version"))),
|
|
|
|
|
JAVA_VENDOR(plugin -> Component.text(System.getProperty("java.vendor"))),
|
|
|
|
|
SYNC_MODE(plugin -> Component.text(WordUtils.capitalizeFully(
|
|
|
|
|
plugin.getSettings().getSynchronization().getMode().toString()
|
|
|
|
|
plugin.getSettings().getSynchronization().getMode().toString()
|
|
|
|
|
))),
|
|
|
|
|
DELAY_LATENCY(plugin -> Component.text(
|
|
|
|
|
plugin.getSettings().getSynchronization().getNetworkLatencyMilliseconds() + "ms"
|
|
|
|
|
plugin.getSettings().getSynchronization().getNetworkLatencyMilliseconds() + "ms"
|
|
|
|
|
)),
|
|
|
|
|
SERVER_NAME(plugin -> Component.text(plugin.getServerName())),
|
|
|
|
|
CLUSTER_ID(plugin -> Component.text(plugin.getSettings().getClusterId().isBlank() ? "None" : plugin.getSettings().getClusterId())),
|
|
|
|
|
DATABASE_TYPE(plugin ->
|
|
|
|
|
Component.text(plugin.getSettings().getDatabase().getType().getDisplayName() +
|
|
|
|
|
(plugin.getSettings().getDatabase().getType() == Database.Type.MONGO ?
|
|
|
|
|
(plugin.getSettings().getDatabase().getMongoSettings().isUsingAtlas() ? " Atlas" : "") : ""))
|
|
|
|
|
Component.text(plugin.getSettings().getDatabase().getType().getDisplayName() +
|
|
|
|
|
(plugin.getSettings().getDatabase().getType() == Database.Type.MONGO ?
|
|
|
|
|
(plugin.getSettings().getDatabase().getMongoSettings().isUsingAtlas() ? " Atlas" : "") : ""))
|
|
|
|
|
),
|
|
|
|
|
IS_DATABASE_LOCAL(plugin -> getLocalhostBoolean(plugin.getSettings().getDatabase().getCredentials().getHost())),
|
|
|
|
|
USING_REDIS_SENTINEL(plugin -> getBoolean(
|
|
|
|
|
!plugin.getSettings().getRedis().getSentinel().getMaster().isBlank()
|
|
|
|
|
!plugin.getSettings().getRedis().getSentinel().getMaster().isBlank()
|
|
|
|
|
)),
|
|
|
|
|
USING_REDIS_PASSWORD(plugin -> getBoolean(
|
|
|
|
|
!plugin.getSettings().getRedis().getCredentials().getPassword().isBlank()
|
|
|
|
|
!plugin.getSettings().getRedis().getCredentials().getPassword().isBlank()
|
|
|
|
|
)),
|
|
|
|
|
REDIS_USING_SSL(plugin -> getBoolean(
|
|
|
|
|
plugin.getSettings().getRedis().getCredentials().isUseSsl()
|
|
|
|
|
plugin.getSettings().getRedis().getCredentials().isUseSsl()
|
|
|
|
|
)),
|
|
|
|
|
IS_REDIS_LOCAL(plugin -> getLocalhostBoolean(
|
|
|
|
|
plugin.getSettings().getRedis().getCredentials().getHost()
|
|
|
|
|
plugin.getSettings().getRedis().getCredentials().getHost()
|
|
|
|
|
)),
|
|
|
|
|
DATA_TYPES(plugin -> Component.join(
|
|
|
|
|
JoinConfiguration.commas(true),
|
|
|
|
|
plugin.getRegisteredDataTypes().stream().map(i -> Component.textOfChildren(Component.text(i.toString())
|
|
|
|
|
.appendSpace().append(Component.text(i.isEnabled() ? '✔' : '❌')))
|
|
|
|
|
.color(i.isEnabled() ? NamedTextColor.GREEN : NamedTextColor.RED)
|
|
|
|
|
.hoverEvent(HoverEvent.showText(
|
|
|
|
|
Component.text(i.isEnabled() ? "Enabled" : "Disabled")
|
|
|
|
|
.append(Component.newline())
|
|
|
|
|
.append(Component.text("Dependencies: %s".formatted(i.getDependencies()
|
|
|
|
|
.isEmpty() ? "(None)" : i.getDependencies().stream()
|
|
|
|
|
.map(d -> "%s (%s)".formatted(
|
|
|
|
|
d.getKey().value(), d.isRequired() ? "Required" : "Optional"
|
|
|
|
|
)).collect(Collectors.joining(", ")))
|
|
|
|
|
).color(NamedTextColor.GRAY))
|
|
|
|
|
))).toList()
|
|
|
|
|
JoinConfiguration.commas(true),
|
|
|
|
|
plugin.getRegisteredDataTypes().stream().map(i -> Component.textOfChildren(Component.text(i.toString())
|
|
|
|
|
.appendSpace().append(Component.text(i.isEnabled() ? '✔' : '❌')))
|
|
|
|
|
.color(i.isEnabled() ? NamedTextColor.GREEN : NamedTextColor.RED)
|
|
|
|
|
.hoverEvent(HoverEvent.showText(
|
|
|
|
|
Component.text(i.isEnabled() ? "Enabled" : "Disabled")
|
|
|
|
|
.append(Component.newline())
|
|
|
|
|
.append(Component.text("Dependencies: %s".formatted(i.getDependencies()
|
|
|
|
|
.isEmpty() ? "(None)" : i.getDependencies().stream()
|
|
|
|
|
.map(d -> "%s (%s)".formatted(
|
|
|
|
|
d.getKey().value(), d.isRequired() ? "Required" : "Optional"
|
|
|
|
|
)).collect(Collectors.joining(", ")))
|
|
|
|
|
).color(NamedTextColor.GRAY))
|
|
|
|
|
))).toList()
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
private final Function<HuskSync, Component> supplier;
|
|
|
|
@ -261,13 +261,13 @@ public class HuskSyncCommand extends PluginCommand {
|
|
|
|
|
@NotNull
|
|
|
|
|
private Component get(@NotNull HuskSync plugin) {
|
|
|
|
|
return Component
|
|
|
|
|
.text("•").appendSpace()
|
|
|
|
|
.append(Component.text(
|
|
|
|
|
WordUtils.capitalizeFully(name().replaceAll("_", " ")),
|
|
|
|
|
TextColor.color(0x848484)
|
|
|
|
|
))
|
|
|
|
|
.append(Component.text(':')).append(Component.space().color(NamedTextColor.WHITE))
|
|
|
|
|
.append(supplier.apply(plugin));
|
|
|
|
|
.text("•").appendSpace()
|
|
|
|
|
.append(Component.text(
|
|
|
|
|
WordUtils.capitalizeFully(name().replaceAll("_", " ")),
|
|
|
|
|
TextColor.color(0x848484)
|
|
|
|
|
))
|
|
|
|
|
.append(Component.text(':')).append(Component.space().color(NamedTextColor.WHITE))
|
|
|
|
|
.append(supplier.apply(plugin));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@NotNull
|
|
|
|
@ -278,7 +278,7 @@ public class HuskSyncCommand extends PluginCommand {
|
|
|
|
|
@NotNull
|
|
|
|
|
private static Component getLocalhostBoolean(@NotNull String value) {
|
|
|
|
|
return getBoolean(value.equals("127.0.0.1") || value.equals("0.0.0.0")
|
|
|
|
|
|| value.equals("localhost") || value.equals("::1"));
|
|
|
|
|
|| value.equals("localhost") || value.equals("::1"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|