From 710159f13d0558073b80754ec52cad68c8eb20f6 Mon Sep 17 00:00:00 2001 From: SageSphinx63920 Date: Fri, 26 Jan 2024 16:16:20 +0100 Subject: [PATCH] Dependency updates and Improvements --- .github/workflows/api-publish.yml | 4 +-- .github/workflows/javadocs.yml | 5 ++-- pom.xml | 8 +++--- src/main/java/de/hdg/keklist/Keklist.java | 6 +++++ .../java/de/hdg/keklist/KeklistLoader.java | 4 +-- .../hdg/keklist/commands/KeklistCommand.java | 2 +- src/main/java/de/hdg/keklist/database/DB.java | 3 ++- .../gui/events/blacklist/BlacklistEvent.java | 15 ++++++----- .../gui/events/whitelist/WhitelistEvent.java | 27 ++++++++++--------- src/main/resources/assets/lang/en-us.json | 1 + start.sh | 10 +++---- 11 files changed, 50 insertions(+), 35 deletions(-) diff --git a/.github/workflows/api-publish.yml b/.github/workflows/api-publish.yml index 267af8f..99c722a 100644 --- a/.github/workflows/api-publish.yml +++ b/.github/workflows/api-publish.yml @@ -16,10 +16,10 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: - java-version: '17' + java-version: '21' distribution: 'corretto' server-id: github cache: maven diff --git a/.github/workflows/javadocs.yml b/.github/workflows/javadocs.yml index c38f78a..8ae5663 100644 --- a/.github/workflows/javadocs.yml +++ b/.github/workflows/javadocs.yml @@ -6,6 +6,7 @@ on: #branches: [ main ] workflow_dispatch: + jobs: javadoc: runs-on: ubuntu-latest @@ -13,10 +14,10 @@ jobs: - name: Checkout ๐Ÿ™ƒ uses: actions/checkout@v4 - - name: Set up JDK 17 ๐Ÿ›  + - name: Set up JDK 21 ๐Ÿ›  uses: actions/setup-java@v3 with: - java-version: 17 + java-version: 21 distribution: 'corretto' cache: 'maven' diff --git a/pom.xml b/pom.xml index ea16718..4a0d5f4 100644 --- a/pom.xml +++ b/pom.xml @@ -184,7 +184,7 @@ io.papermc.paper paper-api - 1.20.1-R0.1-SNAPSHOT + 1.20.4-R0.1-SNAPSHOT provided @@ -228,7 +228,7 @@ me.clip placeholderapi - 2.11.4 + 2.11.5 provided @@ -236,13 +236,13 @@ org.xerial sqlite-jdbc - 3.43.2.1 + 3.45.0.0 provided org.mariadb.jdbc mariadb-java-client - 3.2.0 + 3.3.2 provided diff --git a/src/main/java/de/hdg/keklist/Keklist.java b/src/main/java/de/hdg/keklist/Keklist.java index cd2b876..395f9e6 100644 --- a/src/main/java/de/hdg/keklist/Keklist.java +++ b/src/main/java/de/hdg/keklist/Keklist.java @@ -83,6 +83,12 @@ public void onLoad() { return; } + if(Bukkit.getServer().getMinecraftVersion().equals("1.20")) { + getLogger().severe(translations.get("paper.version.unsupported")); + Bukkit.getPluginManager().disablePlugin(this); + return; + } + //Init utilities after paper checkร configUtil = new KeklistConfigUtil(this); diff --git a/src/main/java/de/hdg/keklist/KeklistLoader.java b/src/main/java/de/hdg/keklist/KeklistLoader.java index 2e1636a..841c09c 100644 --- a/src/main/java/de/hdg/keklist/KeklistLoader.java +++ b/src/main/java/de/hdg/keklist/KeklistLoader.java @@ -16,8 +16,8 @@ public void classloader(@NotNull PluginClasspathBuilder pluginClasspathBuilder) resolver.addRepository(new RemoteRepository.Builder("maven", "default", "https://repo.maven.apache.org/maven2").build()); resolver.addDependency(new Dependency(new DefaultArtifact("com.squareup.okhttp3:okhttp:5.0.0-alpha.11"), "compile")); - resolver.addDependency(new Dependency(new DefaultArtifact("org.xerial:sqlite-jdbc:3.43.0.0"), "compile")); - resolver.addDependency(new Dependency(new DefaultArtifact("org.mariadb.jdbc:mariadb-java-client:3.2.0"), "compile")); + resolver.addDependency(new Dependency(new DefaultArtifact("org.xerial:sqlite-jdbc:3.45.0.0"), "compile")); + resolver.addDependency(new Dependency(new DefaultArtifact("org.mariadb.jdbc:mariadb-java-client:3.3.2"), "compile")); resolver.addDependency(new Dependency(new DefaultArtifact("club.minnced:discord-webhooks:0.8.4"), "compile")); pluginClasspathBuilder.addLibrary(resolver); diff --git a/src/main/java/de/hdg/keklist/commands/KeklistCommand.java b/src/main/java/de/hdg/keklist/commands/KeklistCommand.java index 85a3303..7a73bee 100644 --- a/src/main/java/de/hdg/keklist/commands/KeklistCommand.java +++ b/src/main/java/de/hdg/keklist/commands/KeklistCommand.java @@ -135,7 +135,7 @@ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLab if (args.length == 3) { if (args[2].equalsIgnoreCase("vanilla")) { for (OfflinePlayer player : Bukkit.getWhitelistedPlayers()) { - Bukkit.dispatchCommand(sender, "keklist whitelist add " + player.getName()); + Bukkit.dispatchCommand(sender, "keklist whitelist add: " + player.getName()); } sender.sendMessage(Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("whitelist.imported"))); diff --git a/src/main/java/de/hdg/keklist/database/DB.java b/src/main/java/de/hdg/keklist/database/DB.java index b88926c..d9e55c4 100644 --- a/src/main/java/de/hdg/keklist/database/DB.java +++ b/src/main/java/de/hdg/keklist/database/DB.java @@ -64,6 +64,7 @@ public void connect() { count.incrementAndGet(); } catch (SQLException | java.io.IOException ex) { ex.printStackTrace(); + Bukkit.getPluginManager().disablePlugin(plugin); } catch (ClassNotFoundException e) { plugin.getLogger().severe(Keklist.getTranslations().get("database.driver-missing")); Bukkit.getPluginManager().disablePlugin(plugin); @@ -114,7 +115,7 @@ public void run() { public ResultSet onQuery(@NotNull @Language("SQL") final String query, Object... preparedArgs) { if (isConnected()) { try { - FutureTask task = new FutureTask<>(new Callable() { + FutureTask task = new FutureTask<>(new Callable<>() { PreparedStatement ps; public ResultSet call() throws Exception { diff --git a/src/main/java/de/hdg/keklist/gui/events/blacklist/BlacklistEvent.java b/src/main/java/de/hdg/keklist/gui/events/blacklist/BlacklistEvent.java index 92646e9..ff6466a 100644 --- a/src/main/java/de/hdg/keklist/gui/events/blacklist/BlacklistEvent.java +++ b/src/main/java/de/hdg/keklist/gui/events/blacklist/BlacklistEvent.java @@ -10,6 +10,7 @@ import org.bukkit.NamespacedKey; import org.bukkit.block.Block; import org.bukkit.block.Sign; +import org.bukkit.block.sign.Side; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -50,12 +51,13 @@ public void onBlacklistClick(InventoryClickEvent event) throws SQLException { player.getWorld().setBlockData(location, Material.DARK_OAK_SIGN.createBlockData()); Sign sign = (Sign) player.getWorld().getBlockState(location); + sign.setWaxed(false); sign.getPersistentDataContainer().set(new NamespacedKey(Keklist.getInstance(), "blacklistMode"), PersistentDataType.STRING, "add"); - sign.line(0, Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("gui.blacklist.sign.line"))); - sign.line(1, Component.empty()); + sign.getSide(Side.FRONT).line(0, Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("gui.blacklist.sign.line"))); + sign.getSide(Side.FRONT).line(1, Component.empty()); sign.update(); - Bukkit.getScheduler().runTaskLater(Keklist.getInstance(), () -> player.openSign(sign), 5); + Bukkit.getScheduler().runTaskLater(Keklist.getInstance(), () -> player.openSign(sign, Side.FRONT), 5); } case DARK_PRISMARINE -> { Location location = player.getLocation(); @@ -65,12 +67,13 @@ public void onBlacklistClick(InventoryClickEvent event) throws SQLException { player.getWorld().setBlockData(location, Material.DARK_OAK_SIGN.createBlockData()); Sign sign = (Sign) player.getWorld().getBlockState(location); + sign.setWaxed(false); sign.getPersistentDataContainer().set(new NamespacedKey(Keklist.getInstance(), "blacklistMode"), PersistentDataType.STRING, "remove"); - sign.line(0, Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("gui.blacklist.sign.line"))); - sign.line(1, Component.empty()); + sign.getSide(Side.FRONT).line(0, Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("gui.blacklist.sign.line"))); + sign.getSide(Side.FRONT).line(1, Component.empty()); sign.update(); - Bukkit.getScheduler().runTaskLater(Keklist.getInstance(), () -> player.openSign(sign), 5); + Bukkit.getScheduler().runTaskLater(Keklist.getInstance(), () -> player.openSign(sign, Side.FRONT), 5); } case PLAYER_HEAD -> player.openInventory(getPage(0, 0, false, false, false)); diff --git a/src/main/java/de/hdg/keklist/gui/events/whitelist/WhitelistEvent.java b/src/main/java/de/hdg/keklist/gui/events/whitelist/WhitelistEvent.java index 36ed4fd..197454e 100644 --- a/src/main/java/de/hdg/keklist/gui/events/whitelist/WhitelistEvent.java +++ b/src/main/java/de/hdg/keklist/gui/events/whitelist/WhitelistEvent.java @@ -10,6 +10,7 @@ import org.bukkit.NamespacedKey; import org.bukkit.block.Block; import org.bukkit.block.Sign; +import org.bukkit.block.sign.Side; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -50,12 +51,13 @@ public void onWhitelistClick(InventoryClickEvent event) throws SQLException { player.getWorld().setBlockData(location, Material.SPRUCE_SIGN.createBlockData()); Sign sign = (Sign) player.getWorld().getBlockState(location); + sign.setWaxed(false); sign.getPersistentDataContainer().set(new NamespacedKey(Keklist.getInstance(), "whitelistMode"), PersistentDataType.STRING, "add"); - sign.line(0, Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("gui.whitelist.sign.line"))); - sign.line(1, Component.empty()); + sign.getSide(Side.FRONT).line(0, Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("gui.whitelist.sign.line"))); + sign.getSide(Side.FRONT).line(1, Component.empty()); sign.update(); - Bukkit.getScheduler().runTaskLater(Keklist.getInstance(), () -> player.openSign(sign), 5); + Bukkit.getScheduler().runTaskLater(Keklist.getInstance(), () -> player.openSign(sign, Side.FRONT), 5); } case PRISMARINE_SHARD -> { Location location = player.getLocation(); @@ -65,12 +67,13 @@ public void onWhitelistClick(InventoryClickEvent event) throws SQLException { player.getWorld().setBlockData(location, Material.SPRUCE_SIGN.createBlockData()); Sign sign = (Sign) player.getWorld().getBlockState(location); + sign.setWaxed(false); sign.getPersistentDataContainer().set(new NamespacedKey(Keklist.getInstance(), "whitelistMode"), PersistentDataType.STRING, "remove"); - sign.line(0, Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("gui.whitelist.sign.line"))); - sign.line(1, Component.empty()); + sign.getSide(Side.FRONT).line(0, Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("gui.whitelist.sign.line"))); + sign.getSide(Side.FRONT).line(1, Component.empty()); sign.update(); - Bukkit.getScheduler().runTaskLater(Keklist.getInstance(), () -> player.openSign(sign), 5); + Bukkit.getScheduler().runTaskLater(Keklist.getInstance(), () -> player.openSign(sign, Side.FRONT), 5); } case PLAYER_HEAD -> player.openInventory(getPage(0, 0, false, false)); case ARROW -> GuiManager.openMainGUI(player); @@ -242,7 +245,7 @@ public static Inventory getPage(int pageIndex, int skipIndex, boolean onlyPlayer // Next Page if (onlyIP) { ResultSet ips = Keklist.getDatabase().onQuery("SELECT * FROM whitelistIp"); - List skippedIPs = new ArrayList<>(); + List skippedIPs; while (ips.next()) { ItemStack ip = new ItemStack(Material.BOOK); @@ -281,18 +284,18 @@ public static Inventory getPage(int pageIndex, int skipIndex, boolean onlyPlayer } - // Last page must be only IPs + // The Last page must be only IPs if (skipIndex > 18) { previousPageMeta.getPersistentDataContainer().set(new NamespacedKey(Keklist.getInstance(), "onlyIP"), PersistentDataType.INTEGER, 1); // Workaround for missing boolean previousPageMeta.getPersistentDataContainer().set(new NamespacedKey(Keklist.getInstance(), "skipIndex"), PersistentDataType.INTEGER, skipIndex - 18); // We must start at skipIndex - 18 for the page before } else previousPageMeta.getPersistentDataContainer().set(new NamespacedKey(Keklist.getInstance(), "skipIndex"), PersistentDataType.INTEGER, -1); // We must start at 0 for the page before - // NOTE : pageIndex*18 = player heads to skip if not onlyIP mode is active + // NOTE: pageIndex*18 = player heads to skip if not onlyIP mode is active } else { ResultSet players = Keklist.getDatabase().onQuery("SELECT * FROM whitelist"); ResultSet isIPThere = Keklist.getDatabase().onQuery("SELECT ip FROM whitelistIp LIMIT 1"); - List skippedHeads = new ArrayList<>(); + List skippedHeads; while (players.next()) { ItemStack skull = new ItemStack(Material.PLAYER_HEAD); @@ -372,14 +375,14 @@ public static Inventory getPage(int pageIndex, int skipIndex, boolean onlyPlayer } } - // Last page must be only Players + // The Last page must be only Players if (skipIndex > 18 && onlyPlayer) { previousPageMeta.getPersistentDataContainer().set(new NamespacedKey(Keklist.getInstance(), "onlyPlayer"), PersistentDataType.INTEGER, 1); // Workaround for missing boolean previousPageMeta.getPersistentDataContainer().set(new NamespacedKey(Keklist.getInstance(), "skipIndex"), PersistentDataType.INTEGER, skipIndex - 18); // We must start at skipIndex - 18 for the page before } else previousPageMeta.getPersistentDataContainer().set(new NamespacedKey(Keklist.getInstance(), "skipIndex"), PersistentDataType.INTEGER, -1); // We must start at 0 for the page before - // NOTE : pageIndex shows if it's the first page + // NOTE: pageIndex shows if it's the first page } diff --git a/src/main/resources/assets/lang/en-us.json b/src/main/resources/assets/lang/en-us.json index e1dc0d2..7fa45cf 100644 --- a/src/main/resources/assets/lang/en-us.json +++ b/src/main/resources/assets/lang/en-us.json @@ -1,6 +1,7 @@ { "limbo.error": "No Player online to limbo player! Waiting for next event...", "paper.required": "This plugin requires a modern version of Paper to run!", + "paper.version.unsupported": "1.20 is not supported! Please use a version newer than 1.20 and come on... 1.20 is not even supported by Paper!", "invalid-syntax": "Invalid syntax!", "config-reloaded": "Config reloaded!", "bstats.done": "Successfully enabled bStats!", diff --git a/start.sh b/start.sh index 9c5d5ce..3c0c754 100644 --- a/start.sh +++ b/start.sh @@ -6,16 +6,16 @@ cp ./target/keklist-1.0-SNAPSHOT.jar ./testserver/plugins cd ./testserver || exit -build=$(curl -s -L "https://api.purpurmc.org/v2/purpur/1.20.1/latest/" | jq -r '.build') +build=$(curl -s -L "https://api.purpurmc.org/v2/purpur/1.20.2/latest/" | jq -r '.build') currentVersion=$(jq -r '.currentVersion' version_history.json) -echo "Latest build: git-Purpur-$build (MC: 1.20.1)" +echo "Latest build: git-Purpur-$build (MC: 1.20.2)" echo "Current version: $currentVersion" # Compare the two values and output the result -if [[ "git-Purpur-$build (MC: 1.20.1)" == "$currentVersion" ]]; then - echo "The server build is up-to-date." +if [[ "git-Purpur-$build (MC: 1.20.2)" == "$currentVersion" ]]; then + echo "The server build is up to date." else echo "The build is out-of-date. Downloading the latest one..." - curl -L https://api.purpurmc.org/v2/purpur/1.20.1/latest/download -o server.jar + curl -L https://api.purpurmc.org/v2/purpur/1.20.2/latest/download -o server.jar fi java -Xms4096M -Xmx4096M --add-modules=jdk.incubator.vector -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -jar server.jar \ No newline at end of file