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