From ebfe84cf1496dd078524ccd3a07c06af6d1904e5 Mon Sep 17 00:00:00 2001 From: William Date: Wed, 26 Apr 2023 19:10:53 +0100 Subject: [PATCH] Bump DesertWell to use v2.0.2 (#371) --- bukkit/build.gradle | 3 +- .../william278/huskhomes/BukkitHuskHomes.java | 2 +- common/build.gradle | 2 +- .../net/william278/huskhomes/HuskHomes.java | 22 +++--- .../huskhomes/command/HuskHomesCommand.java | 67 ++++++++++--------- .../william278/huskhomes/FabricHuskHomes.java | 2 +- paper/build.gradle | 3 +- sponge/build.gradle | 1 + .../william278/huskhomes/SpongeHuskHomes.java | 2 +- 9 files changed, 57 insertions(+), 47 deletions(-) diff --git a/bukkit/build.gradle b/bukkit/build.gradle index f103f6ac..27739af0 100644 --- a/bukkit/build.gradle +++ b/bukkit/build.gradle @@ -10,7 +10,7 @@ dependencies { compileOnly 'org.jetbrains:annotations:24.0.1' compileOnly 'de.themoep:minedown-adventure:1.7.2-SNAPSHOT' compileOnly 'net.william278:Annotaml:2.0.1' - compileOnly 'net.william278:DesertWell:1.1.1' + compileOnly 'net.william278:DesertWell:2.0.2' compileOnly 'com.github.MilkBowl:VaultAPI:1.7.1' compileOnly 'com.github.Emibergo02:RedisEconomy:4.0-SNAPSHOT' compileOnly 'me.clip:placeholderapi:2.11.3' @@ -39,6 +39,7 @@ shadowJar { relocate 'net.william278.annotaml', 'net.william278.huskhomes.libraries.annotaml' relocate 'net.william278.paginedown', 'net.william278.huskhomes.libraries.paginedown' relocate 'net.william278.desertwell', 'net.william278.huskhomes.libraries.desertwell' + relocate 'org.json', 'net.william278.huskhomes.libraries.json' relocate 'dev.dejvokep.boostedyaml', 'net.william278.huskhomes.libraries.boostedyaml' relocate 'org.yaml.snakeyaml', 'net.william278.huskhomes.libraries.snakeyaml' relocate 'com.google.gson', 'net.william278.huskhomes.libraries.gson' diff --git a/bukkit/src/main/java/net/william278/huskhomes/BukkitHuskHomes.java b/bukkit/src/main/java/net/william278/huskhomes/BukkitHuskHomes.java index 276d0b15..fb0943a2 100644 --- a/bukkit/src/main/java/net/william278/huskhomes/BukkitHuskHomes.java +++ b/bukkit/src/main/java/net/william278/huskhomes/BukkitHuskHomes.java @@ -21,7 +21,7 @@ package net.william278.huskhomes; import net.kyori.adventure.platform.bukkit.BukkitAudiences; import net.william278.annotaml.Annotaml; -import net.william278.desertwell.Version; +import net.william278.desertwell.util.Version; import net.william278.huskhomes.command.BukkitCommand; import net.william278.huskhomes.command.Command; import net.william278.huskhomes.command.DisabledCommand; diff --git a/common/build.gradle b/common/build.gradle index 9c528abd..5292c650 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -13,7 +13,7 @@ dependencies { api 'com.google.code.gson:gson:2.10.1' api 'net.william278:Annotaml:2.0.1' api 'net.william278:PagineDown:1.1' - api 'net.william278:DesertWell:1.1.1' + api 'net.william278:DesertWell:2.0.2' api 'dev.dejvokep:boosted-yaml:1.3.1' api 'net.kyori:adventure-api:4.13.1' api('com.zaxxer:HikariCP:5.0.1') { diff --git a/common/src/main/java/net/william278/huskhomes/HuskHomes.java b/common/src/main/java/net/william278/huskhomes/HuskHomes.java index 0950a2c2..452cee22 100644 --- a/common/src/main/java/net/william278/huskhomes/HuskHomes.java +++ b/common/src/main/java/net/william278/huskhomes/HuskHomes.java @@ -23,8 +23,8 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import net.kyori.adventure.key.Key; import net.william278.annotaml.Annotaml; -import net.william278.desertwell.UpdateChecker; -import net.william278.desertwell.Version; +import net.william278.desertwell.util.UpdateChecker; +import net.william278.desertwell.util.Version; import net.william278.huskhomes.command.Command; import net.william278.huskhomes.config.Locales; import net.william278.huskhomes.config.Server; @@ -181,7 +181,7 @@ public interface HuskHomes extends TaskRunner, EventDispatcher, SafetyResolver { UnsafeBlocks getUnsafeBlocks(); /** - * The {@link Database} that stores persistent plugin data + * The {@link Database} that store persistent plugin data * * @return the {@link Database} implementation for accessing data */ @@ -189,7 +189,7 @@ public interface HuskHomes extends TaskRunner, EventDispatcher, SafetyResolver { Database getDatabase(); /** - * The {@link Validator} for validating thome names and descriptions + * The {@link Validator} for validating home names and descriptions * * @return the {@link Validator} instance */ @@ -448,15 +448,19 @@ public interface HuskHomes extends TaskRunner, EventDispatcher, SafetyResolver { @NotNull default UpdateChecker getUpdateChecker() { - return UpdateChecker.create(getVersion(), SPIGOT_RESOURCE_ID); + return UpdateChecker.builder() + .currentVersion(getVersion()) + .endpoint(UpdateChecker.Endpoint.SPIGOT) + .resource(Integer.toString(SPIGOT_RESOURCE_ID)) + .build(); } default void checkForUpdates() { if (getSettings().doCheckForUpdates()) { - getUpdateChecker().isUpToDate().thenAccept(updated -> { - if (!updated) { - getUpdateChecker().getLatestVersion().thenAccept(latest -> log(Level.WARNING, - "A new version of HuskTowns is available: v" + latest + " (running v" + getVersion() + ")")); + getUpdateChecker().check().thenAccept(checked -> { + if (!checked.isUpToDate()) { + log(Level.WARNING, "A new version of HuskTowns is available: v" + + checked.getLatestVersion() + " (running v" + getVersion() + ")"); } }); } diff --git a/common/src/main/java/net/william278/huskhomes/command/HuskHomesCommand.java b/common/src/main/java/net/william278/huskhomes/command/HuskHomesCommand.java index 4f30c146..99c200f7 100644 --- a/common/src/main/java/net/william278/huskhomes/command/HuskHomesCommand.java +++ b/common/src/main/java/net/william278/huskhomes/command/HuskHomesCommand.java @@ -20,8 +20,10 @@ package net.william278.huskhomes.command; import de.themoep.minedown.adventure.MineDown; -import net.william278.desertwell.AboutMenu; -import net.william278.desertwell.UpdateChecker; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.TextColor; +import net.william278.desertwell.about.AboutMenu; +import net.william278.desertwell.util.UpdateChecker; import net.william278.huskhomes.HuskHomes; import net.william278.huskhomes.config.Locales; import net.william278.huskhomes.user.CommandUser; @@ -49,30 +51,32 @@ public class HuskHomesCommand extends Command implements TabProvider { addAdditionalPermissions(SUB_COMMANDS); this.updateChecker = plugin.getUpdateChecker(); - this.aboutMenu = AboutMenu.create("HuskHomes") - .withDescription("A powerful, intuitive and flexible teleportation suite") - .withVersion(plugin.getVersion()) - .addAttribution("Author", - AboutMenu.Credit.of("William278").withDescription("Click to visit website").withUrl("https://william278.net")) - .addAttribution("Contributors", - AboutMenu.Credit.of("imDaniX").withDescription("Code, refactoring"), - AboutMenu.Credit.of("Log1x").withDescription("Code")) - .addAttribution("Translators", - AboutMenu.Credit.of("SnivyJ").withDescription("Simplified Chinese (zh-cn)"), - AboutMenu.Credit.of("ApliNi").withDescription("Simplified Chinese (zh-cn)"), - AboutMenu.Credit.of("Wtq_").withDescription("Simplified Chinese (zh-cn)"), - AboutMenu.Credit.of("TonyPak").withDescription("Traditional Chinese (zh-tw)"), - AboutMenu.Credit.of("davgo0103").withDescription("Traditional Chinese (zh-tw)"), - AboutMenu.Credit.of("Villag3r_").withDescription("Italian (it-it)"), - AboutMenu.Credit.of("ReferTV").withDescription("Polish (pl)"), - AboutMenu.Credit.of("anchelthe").withDescription("Spanish (es-es)"), - AboutMenu.Credit.of("Chiquis2005").withDescription("Spanish (es-es)"), - AboutMenu.Credit.of("Ceddix").withDescription("German, (de-de)"), - AboutMenu.Credit.of("Pukejoy_1").withDescription("Bulgarian (bg-bg)")) - .addButtons( - AboutMenu.Link.of("https://william278.net/docs/huskhomes").withText("Documentation").withIcon("⛏"), - AboutMenu.Link.of("https://github.com/WiIIiam278/HuskHomes2/issues").withText("Issues").withIcon("❌").withColor("#ff9f0f"), - AboutMenu.Link.of("https://discord.gg/tVYhJfyDWG").withText("Discord").withIcon("⭐").withColor("#6773f5")); + this.aboutMenu = AboutMenu.builder() + .title(Component.text("HuskHomes")) + .description(Component.text("A powerful, intuitive and flexible teleportation suite")) + .version(plugin.getVersion()) + .credits("Author", + AboutMenu.Credit.of("William278").description("Click to visit website").url("https://william278.net")) + .credits("Contributors", + AboutMenu.Credit.of("imDaniX").description("Code, refactoring"), + AboutMenu.Credit.of("Log1x").description("Code")) + .credits("Translators", + AboutMenu.Credit.of("SnivyJ").description("Simplified Chinese (zh-cn)"), + AboutMenu.Credit.of("ApliNi").description("Simplified Chinese (zh-cn)"), + AboutMenu.Credit.of("Wtq_").description("Simplified Chinese (zh-cn)"), + AboutMenu.Credit.of("TonyPak").description("Traditional Chinese (zh-tw)"), + AboutMenu.Credit.of("davgo0103").description("Traditional Chinese (zh-tw)"), + AboutMenu.Credit.of("Villag3r_").description("Italian (it-it)"), + AboutMenu.Credit.of("ReferTV").description("Polish (pl)"), + AboutMenu.Credit.of("anchelthe").description("Spanish (es-es)"), + AboutMenu.Credit.of("Chiquis2005").description("Spanish (es-es)"), + AboutMenu.Credit.of("Ceddix").description("German, (de-de)"), + AboutMenu.Credit.of("Pukejoy_1").description("Bulgarian (bg-bg)")) + .buttons( + AboutMenu.Link.of("https://william278.net/docs/huskhomes").text("Documentation").icon("⛏"), + AboutMenu.Link.of("https://github.com/WiIIiam278/HuskHomes2/issues").text("Issues").icon("❌").color(TextColor.color(0xff9f0f)), + AboutMenu.Link.of("https://discord.gg/tVYhJfyDWG").text("Discord").icon("⭐").color(TextColor.color(0x6773f5))) + .build(); } @Override @@ -85,7 +89,7 @@ public class HuskHomesCommand extends Command implements TabProvider { } switch (action.toLowerCase()) { - case "about" -> executor.sendMessage(aboutMenu.toMineDown()); + case "about" -> executor.sendMessage(aboutMenu.toComponent()); case "help" -> executor.sendMessage(getCommandList(executor) .getNearestValidPage(parseIntArg(args, 1).orElse(1))); case "reload" -> { @@ -95,15 +99,14 @@ public class HuskHomesCommand extends Command implements TabProvider { } executor.sendMessage(new MineDown("[HuskHomes](#00fb9a bold) �fb9a&| Reloaded config & message files.")); } - case "update" -> updateChecker.isUpToDate().thenAccept(upToDate -> { - if (upToDate) { + case "update" -> updateChecker.check().thenAccept(checked -> { + if (checked.isUpToDate()) { plugin.getLocales().getLocale("up_to_date", plugin.getVersion().toString()) .ifPresent(executor::sendMessage); return; } - updateChecker.getLatestVersion().thenAccept(latest -> plugin.getLocales() - .getLocale("update_available", latest.toString(), plugin.getVersion().toString()) - .ifPresent(executor::sendMessage)); + plugin.getLocales().getLocale("update_available", checked.getLatestVersion().toString(), + plugin.getVersion().toString()).ifPresent(executor::sendMessage); }); default -> plugin.getLocales().getLocale("error_invalid_syntax", getUsage()) .ifPresent(executor::sendMessage); diff --git a/fabric/src/main/java/net/william278/huskhomes/FabricHuskHomes.java b/fabric/src/main/java/net/william278/huskhomes/FabricHuskHomes.java index f0ffaad9..dc89d61a 100644 --- a/fabric/src/main/java/net/william278/huskhomes/FabricHuskHomes.java +++ b/fabric/src/main/java/net/william278/huskhomes/FabricHuskHomes.java @@ -34,7 +34,7 @@ import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; import net.william278.annotaml.Annotaml; -import net.william278.desertwell.Version; +import net.william278.desertwell.util.Version; import net.william278.huskhomes.command.Command; import net.william278.huskhomes.command.FabricCommand; import net.william278.huskhomes.config.Locales; diff --git a/paper/build.gradle b/paper/build.gradle index 8fe2f166..3932cd9b 100644 --- a/paper/build.gradle +++ b/paper/build.gradle @@ -13,7 +13,7 @@ dependencies { compileOnly 'org.jetbrains:annotations:24.0.1' compileOnly 'de.themoep:minedown-adventure:1.7.2-SNAPSHOT' compileOnly 'net.william278:Annotaml:2.0.1' - compileOnly 'net.william278:DesertWell:1.1.1' + compileOnly 'net.william278:DesertWell:2.0.2' compileOnly 'me.lucko:commodore:2.2' compileOnly 'com.github.MilkBowl:VaultAPI:1.7.1' compileOnly 'com.github.Emibergo02:RedisEconomy:9f4f9c86f4' @@ -35,6 +35,7 @@ shadowJar { relocate 'net.william278.annotaml', 'net.william278.huskhomes.libraries.annotaml' relocate 'net.william278.paginedown', 'net.william278.huskhomes.libraries.paginedown' relocate 'net.william278.desertwell', 'net.william278.huskhomes.libraries.desertwell' + relocate 'org.json', 'net.william278.huskhomes.libraries.json' relocate 'dev.dejvokep.boostedyaml', 'net.william278.huskhomes.libraries.boostedyaml' relocate 'org.yaml.snakeyaml', 'net.william278.huskhomes.libraries.snakeyaml' relocate 'com.google.gson', 'net.william278.huskhomes.libraries.gson' diff --git a/sponge/build.gradle b/sponge/build.gradle index 0b131b16..5b624abb 100644 --- a/sponge/build.gradle +++ b/sponge/build.gradle @@ -67,6 +67,7 @@ shadowJar { relocate 'net.william278.annotaml', 'net.william278.huskhomes.libraries.annotaml' relocate 'net.william278.paginedown', 'net.william278.huskhomes.libraries.paginedown' relocate 'net.william278.desertwell', 'net.william278.huskhomes.libraries.desertwell' + relocate 'org.json', 'net.william278.huskhomes.libraries.json' relocate 'dev.dejvokep.boostedyaml', 'net.william278.huskhomes.libraries.boostedyaml' relocate 'org.yaml.snakeyaml', 'net.william278.huskhomes.libraries.snakeyaml' relocate 'com.google.gson', 'net.william278.huskhomes.libraries.gson' diff --git a/sponge/src/main/java/net/william278/huskhomes/SpongeHuskHomes.java b/sponge/src/main/java/net/william278/huskhomes/SpongeHuskHomes.java index 5ce065bb..c95cf3d1 100644 --- a/sponge/src/main/java/net/william278/huskhomes/SpongeHuskHomes.java +++ b/sponge/src/main/java/net/william278/huskhomes/SpongeHuskHomes.java @@ -21,7 +21,7 @@ package net.william278.huskhomes; import com.google.inject.Inject; import net.william278.annotaml.Annotaml; -import net.william278.desertwell.Version; +import net.william278.desertwell.util.Version; import net.william278.huskhomes.command.Command; import net.william278.huskhomes.command.SpongeCommand; import net.william278.huskhomes.config.Locales;