From 0e512d68fb3f6e71f767acbb0971260d82ca81d0 Mon Sep 17 00:00:00 2001 From: Starky Date: Fri, 20 May 2022 19:15:43 -0400 Subject: [PATCH 1/5] Added VelocityPlugin basics --- pom.xml | 11 ++++++ .../game/core/GrubnestCorePlugin.java | 15 +++++--- .../game/core/velocity/VelocityPlugin.java | 36 +++++++++++++++++++ 3 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/grubnest/game/core/velocity/VelocityPlugin.java diff --git a/pom.xml b/pom.xml index 1fba3a2..504e1ce 100644 --- a/pom.xml +++ b/pom.xml @@ -60,9 +60,20 @@ spigot-repo https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + papermc + https://repo.papermc.io/repository/maven-public/ + + + com.velocitypowered + velocity-api + 3.0.1 + provided + org.spigotmc spigot-api diff --git a/src/main/java/com/grubnest/game/core/GrubnestCorePlugin.java b/src/main/java/com/grubnest/game/core/GrubnestCorePlugin.java index 7acf009..df43218 100644 --- a/src/main/java/com/grubnest/game/core/GrubnestCorePlugin.java +++ b/src/main/java/com/grubnest/game/core/GrubnestCorePlugin.java @@ -3,11 +3,15 @@ import com.grubnest.game.core.DatabaseHandler.MySQL; import com.grubnest.game.core.DatabaseHandler.MySQLData; import com.grubnest.game.core.DatabaseHandler.Utils.Disabler; +import com.velocitypowered.api.proxy.ProxyServer; import org.bukkit.plugin.java.JavaPlugin; +import org.slf4j.Logger; public class GrubnestCorePlugin extends JavaPlugin { + private MySQL sql; private static GrubnestCorePlugin instance; + /** * Runs when plugin is enabled */ @@ -37,9 +41,10 @@ public void onDisable() { /** * Initialize data from config.yml + * * @return MySQLData */ - private MySQLData dataInitializer(){ + private MySQLData dataInitializer() { String host = getConfig().getString("Database.hostname"); String port = getConfig().getString("Database.port"); String database = getConfig().getString("Database.database"); @@ -49,22 +54,24 @@ private MySQLData dataInitializer(){ int minimumConnections = getConfig().getInt("Database.minimumConnections"); int maximumConnections = getConfig().getInt("Database.maximumConnections"); long connectionTimeout = getConfig().getLong("Database.connectionTimeout"); - return new MySQLData(host,username,password,port,database,minimumConnections,maximumConnections,connectionTimeout); + return new MySQLData(host, username, password, port, database, minimumConnections, maximumConnections, connectionTimeout); } /** * Get SQL Object + * * @return SQL object */ - public MySQL getMySQL(){ + public MySQL getMySQL() { return sql; } /** * Get Plugin Instance + * * @return Plugin Instance */ - public static GrubnestCorePlugin getInstance(){ + public static GrubnestCorePlugin getInstance() { return instance; } } diff --git a/src/main/java/com/grubnest/game/core/velocity/VelocityPlugin.java b/src/main/java/com/grubnest/game/core/velocity/VelocityPlugin.java new file mode 100644 index 0000000..6825fbc --- /dev/null +++ b/src/main/java/com/grubnest/game/core/velocity/VelocityPlugin.java @@ -0,0 +1,36 @@ +package com.grubnest.game.core.velocity; + +import com.google.inject.Inject; +import com.velocitypowered.api.plugin.Plugin; +import com.velocitypowered.api.proxy.ProxyServer; +import org.slf4j.Logger; + +/** + * The VelocityPlugin class is an implementation of the Velocity API. + * It provides communication to and from the Velocity Proxy server + * running on the Grubnest network + *

+ * Date: 5/20/2022 + * Authors: Theeef + */ +@Plugin(id = "myfirstplugin", name = "My First Plugin", version = "0.1.0-SNAPSHOT", + url = "https://example.org", description = "I did it!", authors = {"Me"}) +public class VelocityPlugin { + + private final ProxyServer server; + private final Logger logger; + + + /** + * Creates an instance of the Velocity Plugin and injects it + * + * @param server The velocity proxy server + * @param logger The proxy server's logger + */ + @Inject + public VelocityPlugin(ProxyServer server, Logger logger) { + this.server = server; + this.logger = logger; + } + +} From 9f1f0ab4482d6bbf44bd1f91c102f4ab603b482f Mon Sep 17 00:00:00 2001 From: Starky Date: Fri, 20 May 2022 19:19:43 -0400 Subject: [PATCH 2/5] Startup message --- .../com/grubnest/game/core/velocity/VelocityPlugin.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/grubnest/game/core/velocity/VelocityPlugin.java b/src/main/java/com/grubnest/game/core/velocity/VelocityPlugin.java index 6825fbc..246ea65 100644 --- a/src/main/java/com/grubnest/game/core/velocity/VelocityPlugin.java +++ b/src/main/java/com/grubnest/game/core/velocity/VelocityPlugin.java @@ -13,8 +13,8 @@ * Date: 5/20/2022 * Authors: Theeef */ -@Plugin(id = "myfirstplugin", name = "My First Plugin", version = "0.1.0-SNAPSHOT", - url = "https://example.org", description = "I did it!", authors = {"Me"}) +@Plugin(id = "grubnestcore", name = "Grubnest Core Plugin", version = "0.1.0-SNAPSHOT", + url = "htts://grubnest.com", description = "Grubnest Core running on Velocity", authors = {"Theeef"}) public class VelocityPlugin { private final ProxyServer server; @@ -31,6 +31,8 @@ public class VelocityPlugin { public VelocityPlugin(ProxyServer server, Logger logger) { this.server = server; this.logger = logger; + + logger.info("Hello there! Velocity is working!"); } } From 09fd836b1cb1c1902b931c5df28ba7323a89632c Mon Sep 17 00:00:00 2001 From: Starky Date: Fri, 20 May 2022 19:21:49 -0400 Subject: [PATCH 3/5] Startup message --- .../java/com/grubnest/game/core/velocity/VelocityPlugin.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/grubnest/game/core/velocity/VelocityPlugin.java b/src/main/java/com/grubnest/game/core/velocity/VelocityPlugin.java index 246ea65..8a9a42c 100644 --- a/src/main/java/com/grubnest/game/core/velocity/VelocityPlugin.java +++ b/src/main/java/com/grubnest/game/core/velocity/VelocityPlugin.java @@ -3,6 +3,8 @@ import com.google.inject.Inject; import com.velocitypowered.api.plugin.Plugin; import com.velocitypowered.api.proxy.ProxyServer; +import net.kyori.adventure.text.Component; +import net.minecraft.network.chat.TextColor; import org.slf4j.Logger; /** @@ -32,7 +34,7 @@ public VelocityPlugin(ProxyServer server, Logger logger) { this.server = server; this.logger = logger; - logger.info("Hello there! Velocity is working!"); + this.server.sendMessage(Component.text("GrubnestCore is enabled on Velocity!")); } } From 0ad27977ff61b6eac86a1090059648bc40748cb5 Mon Sep 17 00:00:00 2001 From: Starky Date: Fri, 20 May 2022 19:22:11 -0400 Subject: [PATCH 4/5] Cleaned imports and docs --- src/main/java/com/grubnest/game/core/GrubnestCorePlugin.java | 2 -- .../java/com/grubnest/game/core/velocity/VelocityPlugin.java | 1 - 2 files changed, 3 deletions(-) diff --git a/src/main/java/com/grubnest/game/core/GrubnestCorePlugin.java b/src/main/java/com/grubnest/game/core/GrubnestCorePlugin.java index df43218..bfa8b42 100644 --- a/src/main/java/com/grubnest/game/core/GrubnestCorePlugin.java +++ b/src/main/java/com/grubnest/game/core/GrubnestCorePlugin.java @@ -3,9 +3,7 @@ import com.grubnest.game.core.DatabaseHandler.MySQL; import com.grubnest.game.core.DatabaseHandler.MySQLData; import com.grubnest.game.core.DatabaseHandler.Utils.Disabler; -import com.velocitypowered.api.proxy.ProxyServer; import org.bukkit.plugin.java.JavaPlugin; -import org.slf4j.Logger; public class GrubnestCorePlugin extends JavaPlugin { diff --git a/src/main/java/com/grubnest/game/core/velocity/VelocityPlugin.java b/src/main/java/com/grubnest/game/core/velocity/VelocityPlugin.java index 8a9a42c..4b2e28a 100644 --- a/src/main/java/com/grubnest/game/core/velocity/VelocityPlugin.java +++ b/src/main/java/com/grubnest/game/core/velocity/VelocityPlugin.java @@ -4,7 +4,6 @@ import com.velocitypowered.api.plugin.Plugin; import com.velocitypowered.api.proxy.ProxyServer; import net.kyori.adventure.text.Component; -import net.minecraft.network.chat.TextColor; import org.slf4j.Logger; /** From 43340d679414d5987593a8a742f12aa76bb54b33 Mon Sep 17 00:00:00 2001 From: Starky Date: Fri, 20 May 2022 19:23:10 -0400 Subject: [PATCH 5/5] Renamed package --- .../game/core/{velocity => Velocity}/VelocityPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/main/java/com/grubnest/game/core/{velocity => Velocity}/VelocityPlugin.java (96%) diff --git a/src/main/java/com/grubnest/game/core/velocity/VelocityPlugin.java b/src/main/java/com/grubnest/game/core/Velocity/VelocityPlugin.java similarity index 96% rename from src/main/java/com/grubnest/game/core/velocity/VelocityPlugin.java rename to src/main/java/com/grubnest/game/core/Velocity/VelocityPlugin.java index 4b2e28a..026cfc0 100644 --- a/src/main/java/com/grubnest/game/core/velocity/VelocityPlugin.java +++ b/src/main/java/com/grubnest/game/core/Velocity/VelocityPlugin.java @@ -1,4 +1,4 @@ -package com.grubnest.game.core.velocity; +package com.grubnest.game.core.Velocity; import com.google.inject.Inject; import com.velocitypowered.api.plugin.Plugin;