From ebe65d5b6dc94484d455404d96d053784be2f6bb Mon Sep 17 00:00:00 2001 From: Alessio Gravili Date: Mon, 30 Sep 2024 12:43:11 +0200 Subject: [PATCH] feat!: upgrade to Minecraft 1.21.0, update dependencies, remove unused dependencies --- README.md | 4 +- build.gradle.kts | 12 +- paper/build.gradle.kts | 9 +- .../gravili/notquests/paper/NotQuests.java | 5 - .../paper/commands/AdminCommands.java | 38 ----- .../notquests/paper/managers/DataManager.java | 2 +- .../notquests/paper/managers/WebManager.java | 135 ------------------ .../paper/managers/packets/PacketManager.java | 2 +- plugin/build.gradle.kts | 8 +- 9 files changed, 17 insertions(+), 198 deletions(-) delete mode 100644 paper/src/main/java/rocks/gravili/notquests/paper/managers/WebManager.java diff --git a/README.md b/README.md index e3947073b..16768663f 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Download: https://modrinth.com/plugin/notquests/versions ![Banner](https://user-images.githubusercontent.com/70709113/133943253-af271d49-441b-473e-8b95-6053fe5d09cb.png) -NotQuests is a flexible, Minecraft 1.17-1.20 Quest plugin, featuring a complete GUI for player interactions, open & trusted source code and flexibility. +NotQuests is a flexible, Minecraft 1.17-1.21 Quest plugin, featuring a complete GUI for player interactions, open & trusted source code and flexibility. --- I created NotQuests for my own server, mc.notnot.pro and planned to keep it private. However, I don't have enough time to maintain it myself, so I just made it public. @@ -119,7 +119,7 @@ Admin Commands - Quest Editing: **Requirements to run this:** -- Paper 1.17.1 - 1.20.6 +- Paper 1.17.1 - 1.21.1 - Java 17 diff --git a/build.gradle.kts b/build.gradle.kts index c6ad52f0d..55d73cff2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -21,26 +21,26 @@ import org.gradle.api.JavaVersion.* plugins { `java-library` `maven-publish` - id("io.github.goooler.shadow") version "8.1.7" - id("io.papermc.paperweight.userdev") version "1.7.0" + id("com.gradleup.shadow") version "8.3.1" + id("io.papermc.paperweight.userdev") version "1.7.3" id("xyz.jpenilla.run-paper") version "2.2.4" // Adds runServer and runMojangMappedServer tasks for testing } subprojects { plugins.apply("java-library") plugins.apply("maven-publish") - plugins.apply("io.github.goooler.shadow") + plugins.apply("com.gradleup.shadow") } group = "rocks.gravili.notquests" -version = "5.18.2" +version = "5.19.0" repositories { } dependencies { - paperweight.paperDevBundle("1.20.6-R0.1-SNAPSHOT") + paperweight.paperDevBundle("1.21.1-R0.1-SNAPSHOT") } java { @@ -80,7 +80,7 @@ tasks { // Configure the Minecraft version for our task. // This is the only required configuration besides applying the plugin. // Your plugin's jar (or shadowJar if present) will be used automatically. - minecraftVersion("1.20.6") + minecraftVersion("1.21.1") } } diff --git a/paper/build.gradle.kts b/paper/build.gradle.kts index adf23a136..25e065bbd 100644 --- a/paper/build.gradle.kts +++ b/paper/build.gradle.kts @@ -161,7 +161,7 @@ repositories { dependencies { implementation(project(path= ":common", configuration= "shadow")) - paperweight.paperDevBundle("1.20.6-R0.1-SNAPSHOT") + paperweight.paperDevBundle("1.21.1-R0.1-SNAPSHOT") //compileOnly("io.papermc.paper:paper-api:1.18.1-R0.1-SNAPSHOT!!") //implementation("de.themoep:inventorygui:1.5-SNAPSHOT") @@ -249,11 +249,8 @@ dependencies { implementation("com.github.Redempt:Crunch:2.0.3") - implementation("com.fasterxml.jackson.core:jackson-core:2.17.0") - implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.17.0") - implementation("org.apache.httpcomponents:httpclient:4.5.14") - implementation("com.zaxxer:HikariCP:5.1.0") + implementation("com.zaxxer:HikariCP:6.0.0") compileOnly("com.github.war-systems:UltimateJobs:0.3.6") @@ -376,7 +373,7 @@ tasks { // Configure the Minecraft version for our task. // This is the only required configuration besides applying the plugin. // Your plugin's jar (or shadowJar if present) will be used automatically. - minecraftVersion("1.20.6") + minecraftVersion("1.21.1") } } diff --git a/paper/src/main/java/rocks/gravili/notquests/paper/NotQuests.java b/paper/src/main/java/rocks/gravili/notquests/paper/NotQuests.java index fed5d13de..154684ad5 100644 --- a/paper/src/main/java/rocks/gravili/notquests/paper/NotQuests.java +++ b/paper/src/main/java/rocks/gravili/notquests/paper/NotQuests.java @@ -82,7 +82,6 @@ public class NotQuests extends NotQuestsMainAbstract { private MessageManager messageManager; private TagManager tagManager; private ItemsManager itemsManager; - private WebManager webManager; //Registering Managers private ObjectiveManager objectiveManager; @@ -270,7 +269,6 @@ public void onEnable() { itemsManager = new ItemsManager(this); - webManager = new WebManager(this); NotQuestsFullyLoadedEvent notQuestsFullyLoadedEvent = new NotQuestsFullyLoadedEvent(this); if (Bukkit.isPrimaryThread()) { @@ -534,9 +532,6 @@ public final ItemsManager getItemsManager(){ return itemsManager; } - public final WebManager getWebManager(){ - return webManager; - } public final MiniMessage getMiniMessage(){ return messageManager.getMiniMessage(); diff --git a/paper/src/main/java/rocks/gravili/notquests/paper/commands/AdminCommands.java b/paper/src/main/java/rocks/gravili/notquests/paper/commands/AdminCommands.java index 5f7f16d7d..bfcb57ae5 100644 --- a/paper/src/main/java/rocks/gravili/notquests/paper/commands/AdminCommands.java +++ b/paper/src/main/java/rocks/gravili/notquests/paper/commands/AdminCommands.java @@ -695,44 +695,6 @@ public AdminCommands(final NotQuests main, PaperCommandManager ma context.getSender().sendMessage(main.parse( "
This feature is still in development. The web editor does not work at all yet. Sorry! This command just acts as a placeholder. Consult the NotQuests documentation for a tutorial on how to use NotQuests." )); - if(true){ - return; - } - context.getSender().sendMessage(main.parse( - "
Opening the web editor..." - )); - - String jsonResult = main.getWebManager().openEditor(); - - /*context.getSender().sendMessage(main.parse( - "
Result: " + jsonResult - ));*/ - - String editorURL = ""; - - try { - JSONParser parser = new JSONParser(); - Object resultObject = parser.parse(jsonResult); - - if (resultObject instanceof JSONArray array) { - editorURL = "error"; - }else if (resultObject instanceof JSONObject obj) { - editorURL = ""+(long)(obj.get("editor_id")); - } - - } catch (Exception e) { - e.printStackTrace(); - context.getSender().sendMessage(main.parse( - "Failed to parse json!" - )); - editorURL = "error"; - } - - editorURL = "https://editor.notquests.com/editor/" + editorURL; - - context.getSender().sendMessage(main.parse( - "Click following link to open the editor: \nClick to open the web editor\">" + editorURL - )); })); diff --git a/paper/src/main/java/rocks/gravili/notquests/paper/managers/DataManager.java b/paper/src/main/java/rocks/gravili/notquests/paper/managers/DataManager.java index 84d396127..2083fdf18 100644 --- a/paper/src/main/java/rocks/gravili/notquests/paper/managers/DataManager.java +++ b/paper/src/main/java/rocks/gravili/notquests/paper/managers/DataManager.java @@ -1232,7 +1232,7 @@ public void updateAndReadGeneralConfig() { main.getLogManager().info("Detected version: " + Bukkit.getBukkitVersion() + " (Paper)"); - if (!Bukkit.getBukkitVersion().contains("1.20")) { + if (!Bukkit.getBukkitVersion().contains("1.21")) { if (!configuration.isPacketMagicUnsafeDisregardVersion()) { configuration.setPacketMagic(false); main.getLogManager().info("Packet magic has been disabled, because you are using an unsupported bukkit version..."); diff --git a/paper/src/main/java/rocks/gravili/notquests/paper/managers/WebManager.java b/paper/src/main/java/rocks/gravili/notquests/paper/managers/WebManager.java deleted file mode 100644 index 1abc1e785..000000000 --- a/paper/src/main/java/rocks/gravili/notquests/paper/managers/WebManager.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * NotQuests - A Questing plugin for Minecraft Servers - * Copyright (C) 2022 Alessio Gravili - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package rocks.gravili.notquests.paper.managers; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import java.io.IOException; -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.util.EntityUtils; -import rocks.gravili.notquests.paper.NotQuests; -import rocks.gravili.notquests.paper.managers.data.Category; - -public class WebManager { - private final NotQuests main; - Gson gson = new Gson(); - - public WebManager(final NotQuests main) { - this.main = main; - - /*Assert.assertTrue(jsonObject.isJsonObject()); - Assert.assertTrue(jsonObject.get("name").getAsString().equals("Baeldung")); - Assert.assertTrue(jsonObject.get("java").getAsBoolean() == true);*/ - - } - - String convertYamlToJson(String yaml) throws JsonProcessingException { - ObjectMapper yamlReader = new ObjectMapper(new YAMLFactory()); - Object obj = yamlReader.readValue(yaml, Object.class); - - ObjectMapper jsonWriter = new ObjectMapper(); - return jsonWriter.writeValueAsString(obj); - } - - public String sendRequest(JsonObject jsonObject) throws IOException { - // String postURL = "editor.notquests.com/webeditornew";// put in your url - String postURL = "https://editor.notquests.com/api/webeditors"; - HttpClient httpClient = HttpClientBuilder.create().build(); - HttpPost post = new HttpPost(postURL); - StringEntity postingString = - new StringEntity(gson.toJson(jsonObject)); // gson.tojson() converts your pojo to json - post.setEntity(postingString); - post.setHeader("Content-type", "application/json"); - - HttpResponse result = httpClient.execute(post); - - return EntityUtils.toString(result.getEntity(), "UTF-8"); - - // main.getLogManager().info("Response: " + response.toString()); - } - - public String openEditor() { - JsonObject jsonObject = toJson(); - - try { - String jsonReturnObject = sendRequest(jsonObject); - main.getLogManager().info("JSON returned: \n" + jsonReturnObject); - return jsonReturnObject; - // main.getLogManager().info("Sent web request!"); - } catch (IOException e) { - main.getLogManager().warn("Cannot send web request!"); - e.printStackTrace(); - } - - return "Cannot send web request!"; - } - - public JsonObject toJson() { - /*String jsonDefaultCategoryQuests = "{}"; - - try{ - jsonDefaultCategoryQuests = convertYamlToJson(main.getDataManager().getDefaultCategory().getQuestsConfig().saveToString()); - }catch (JsonProcessingException e){ - main.getLogManager().warn("Cannot convert Quests YAML to web-ready JSON."); - e.printStackTrace(); - } - - main.getLogManager().info("JSON to send: \n" + jsonDefaultCategoryQuests);*/ - - JsonObject categories = new JsonObject(); - - try { - for (Category category : main.getDataManager().getCategories()) { - JsonObject categoryObject = new JsonObject(); - - String ymlQuestsString = category.getQuestsConfig().saveToString(); - String ymlActionsString = category.getActionsConfig().saveToString(); - String ymlConditionsString = category.getConditionsConfig().saveToString(); - - if (!ymlQuestsString.isBlank()) { - String jsonQuestsString = convertYamlToJson(ymlQuestsString); - categoryObject.add("Quests", JsonParser.parseString(jsonQuestsString)); - } - if (!ymlActionsString.isBlank()) { - String jsonActionsString = convertYamlToJson(ymlActionsString); - categoryObject.add("Actions", JsonParser.parseString(jsonActionsString)); - } - if (!ymlConditionsString.isBlank()) { - String jsonConditionsString = convertYamlToJson(ymlConditionsString); - categoryObject.add("Conditions", JsonParser.parseString(jsonConditionsString)); - } - - categories.add(category.getCategoryName(), categoryObject); - } - } catch (Exception e) { - main.getLogManager().warn("Cannot convert Quests YAML to web-ready JSON."); - e.printStackTrace(); - } - - return categories; - } -} diff --git a/paper/src/main/java/rocks/gravili/notquests/paper/managers/packets/PacketManager.java b/paper/src/main/java/rocks/gravili/notquests/paper/managers/packets/PacketManager.java index b1525361b..22936c170 100644 --- a/paper/src/main/java/rocks/gravili/notquests/paper/managers/packets/PacketManager.java +++ b/paper/src/main/java/rocks/gravili/notquests/paper/managers/packets/PacketManager.java @@ -50,7 +50,7 @@ public class PacketManager implements Listener { public PacketManager(final NotQuests main) { this.main = main; usePacketEvents = main.getConfiguration().usePacketEvents; - modern = Bukkit.getVersion().contains("1.20"); + modern = Bukkit.getVersion().contains("1.21"); } public final ReflectionPacketInjector getPacketInjector() { diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index 3af67a341..e2441d2c7 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -126,7 +126,7 @@ repositories { } dependencies { - paperweight.paperDevBundle("1.20.6-R0.1-SNAPSHOT") + paperweight.paperDevBundle("1.21.1-R0.1-SNAPSHOT") implementation(project(path= ":common", configuration= "shadow")) implementation(project(path= ":paper", configuration= "shadow")) @@ -193,7 +193,7 @@ tasks { // Configure the Minecraft version for our task. // This is the only required configuration besides applying the plugin. // Your plugin's jar (or shadowJar if present) will be used automatically. - minecraftVersion("1.20.6") + minecraftVersion("1.21.1") } } @@ -217,9 +217,9 @@ bukkit { name = "NotQuests" version = rootProject.version.toString() main = "rocks.gravili.notquests.Main" - apiVersion = "1.20" + apiVersion = "1.21" authors = listOf("AlessioGr") - description = "Flexible, open, GUI Quest Plugin for Minecraft 1.20.6" + description = "Flexible, open, GUI Quest Plugin for Minecraft 1.21.1" website = "https://www.notquests.com" softDepend = listOf( "ProtocolLib",