diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml index 8f865a7..dcf5918 100644 --- a/dependency-reduced-pom.xml +++ b/dependency-reduced-pom.xml @@ -4,7 +4,7 @@ com.adzel.velocitybroadcast velocitybroadcast VelocityBroadcast - 0.3-pre + 0.3.5 Broadcast plugin for Minecraft Velocity proxy. @@ -49,6 +49,12 @@ 3.1.1 provided + + net.luckperms + api + 5.4 + provided + 17 diff --git a/pom.xml b/pom.xml index dac361d..07a6210 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.adzel.velocitybroadcast velocitybroadcast - 0.3-pre + 0.3.5 jar VelocityBroadcast Broadcast plugin for Minecraft Velocity proxy. @@ -77,6 +77,14 @@ snakeyaml 2.2 + + + + net.luckperms + api + 5.4 + provided + diff --git a/src/main/java/com/adzel/velocitybroadcast/BroadcastCommand.java b/src/main/java/com/adzel/velocitybroadcast/BroadcastCommand.java index d70d6e2..0855bfd 100644 --- a/src/main/java/com/adzel/velocitybroadcast/BroadcastCommand.java +++ b/src/main/java/com/adzel/velocitybroadcast/BroadcastCommand.java @@ -14,6 +14,7 @@ public class BroadcastCommand implements SimpleCommand { private final VelocityBroadcast plugin; private final DatabaseManager databaseManager; + private final MiniMessage mm = MiniMessage.miniMessage(); public BroadcastCommand(VelocityBroadcast plugin) { this.plugin = plugin; @@ -26,12 +27,12 @@ public class BroadcastCommand implements SimpleCommand { List args = List.of(invocation.arguments()); if (!source.hasPermission("vb.broadcast")) { - source.sendMessage(MiniMessage.miniMessage().deserialize("You don't have permission to use this command.")); + source.sendMessage(mm.deserialize("You don't have permission to use this command.")); return; } if (args.isEmpty()) { - source.sendMessage(MiniMessage.miniMessage().deserialize("Usage: /vb ")); + source.sendMessage(mm.deserialize("Usage: /vb ")); return; } @@ -39,20 +40,19 @@ public class BroadcastCommand implements SimpleCommand { String prefix = plugin.getConfigHandler().getPrefix(); String fullMessage = prefix + messageRaw; - Component broadcast = MiniMessage.miniMessage().deserialize(fullMessage); - + Component broadcast = mm.deserialize(fullMessage); plugin.getServer().getAllPlayers().forEach(player -> player.sendMessage(broadcast)); if (plugin.getConfigHandler().isDebugEnabled()) { plugin.getLogger().info("[Broadcast] Sent: " + fullMessage); } - // ✅ Log to the database - String sender = (source instanceof Player) - ? ((Player) source).getUsername() - : "Console"; - - String sourceServer = plugin.getServer().getBoundAddress().toString(); // optional + // ✅ Log to the database with proper sender + String sender = (source instanceof Player player) ? player.getUsername() : "Console"; + String sourceServer = plugin.getServer().getBoundAddress().toString(); databaseManager.logBroadcast(sender, messageRaw, sourceServer); + + // Optional feedback to source + source.sendMessage(mm.deserialize("Broadcast sent.")); } } diff --git a/src/main/java/com/adzel/velocitybroadcast/VelocityBroadcast.java b/src/main/java/com/adzel/velocitybroadcast/VelocityBroadcast.java index 857df2f..32fefb3 100644 --- a/src/main/java/com/adzel/velocitybroadcast/VelocityBroadcast.java +++ b/src/main/java/com/adzel/velocitybroadcast/VelocityBroadcast.java @@ -16,17 +16,19 @@ import com.velocitypowered.api.plugin.annotation.DataDirectory; import com.velocitypowered.api.proxy.ProxyServer; import net.kyori.adventure.text.minimessage.MiniMessage; +import net.luckperms.api.LuckPerms; +import net.luckperms.api.LuckPermsProvider; @Plugin( id = "velocitybroadcast", name = "VelocityBroadcast", - version = "0.3-pre", + version = "0.3.5", description = "A proxy-wide broadcast plugin for Velocity.", authors = {"Adzel"} ) public class VelocityBroadcast { - public static final String PLUGIN_VERSION = "0.3-pre"; + public static final String PLUGIN_VERSION = "0.3.5"; public static final MiniMessage MINI_MESSAGE = MiniMessage.miniMessage(); private final ProxyServer server; @@ -35,6 +37,7 @@ public class VelocityBroadcast { private ConfigHandler config; private DatabaseManager databaseManager; + private LuckPerms luckPerms; @Inject public VelocityBroadcast(ProxyServer server, Logger logger, @DataDirectory Path dataDirectory) { @@ -53,6 +56,15 @@ public class VelocityBroadcast { logger.info("[VelocityBroadcast] Debug mode is enabled."); } + // Initialize LuckPerms + try { + this.luckPerms = LuckPermsProvider.get(); + logger.info("[VelocityBroadcast] Successfully hooked into LuckPerms."); + } catch (IllegalStateException e) { + logger.error("[VelocityBroadcast] LuckPerms is not loaded! This plugin requires LuckPerms."); + return; // Prevent plugin from loading if LP is not available + } + // Initialize database manager java.util.logging.Logger jdkLogger = java.util.logging.Logger.getLogger("VelocityBroadcast"); this.databaseManager = new DatabaseManager(config, jdkLogger, dataDirectory); @@ -68,10 +80,10 @@ public class VelocityBroadcast { } }); - // ✅ Register login listener with DatabaseManager + // Register login listener server.getEventManager().register(this, new LoginListener(server, PLUGIN_VERSION, updateChecker, databaseManager)); - // Register root command + // Register command server.getCommandManager().register( server.getCommandManager().metaBuilder("vb").plugin(this).build(), new VBCommand(this) @@ -104,4 +116,8 @@ public class VelocityBroadcast { public DatabaseManager getDatabaseManager() { return databaseManager; } + + public LuckPerms getLuckPerms() { + return luckPerms; + } } diff --git a/src/main/resources/plugin.json b/src/main/resources/plugin.json index 484681b..39ee34c 100644 --- a/src/main/resources/plugin.json +++ b/src/main/resources/plugin.json @@ -1,7 +1,7 @@ { "id": "velocitybroadcast", "name": "VelocityBroadcast", - "version": "0.3-pre", + "version": "0.3.5", "authors": ["Adzel"], "main": "com.adzel.velocitybroadcast.VelocityBroadcast", "description": "A proxy-wide broadcast plugin for Velocity.", diff --git a/target/classes/plugin.json b/target/classes/plugin.json index 484681b..39ee34c 100644 --- a/target/classes/plugin.json +++ b/target/classes/plugin.json @@ -1,7 +1,7 @@ { "id": "velocitybroadcast", "name": "VelocityBroadcast", - "version": "0.3-pre", + "version": "0.3.5", "authors": ["Adzel"], "main": "com.adzel.velocitybroadcast.VelocityBroadcast", "description": "A proxy-wide broadcast plugin for Velocity.", diff --git a/target/classes/velocity-plugin.json b/target/classes/velocity-plugin.json index 081c28b..f8cc865 100644 --- a/target/classes/velocity-plugin.json +++ b/target/classes/velocity-plugin.json @@ -1 +1 @@ -{"id":"velocitybroadcast","name":"VelocityBroadcast","version":"0.3-pre","description":"A proxy-wide broadcast plugin for Velocity.","authors":["Adzel"],"dependencies":[],"main":"com.adzel.velocitybroadcast.VelocityBroadcast"} \ No newline at end of file +{"id":"velocitybroadcast","name":"VelocityBroadcast","version":"0.3.5","description":"A proxy-wide broadcast plugin for Velocity.","authors":["Adzel"],"dependencies":[],"main":"com.adzel.velocitybroadcast.VelocityBroadcast"} \ No newline at end of file diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties index 663f2ed..0434b51 100644 --- a/target/maven-archiver/pom.properties +++ b/target/maven-archiver/pom.properties @@ -1,3 +1,3 @@ artifactId=velocitybroadcast groupId=com.adzel.velocitybroadcast -version=0.3-pre +version=0.3.5 diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst index abe6263..a7f5a7d 100644 --- a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -2,6 +2,7 @@ com\adzel\velocitybroadcast\VelocityBroadcast.class com\adzel\velocitybroadcast\VBCommand.class com\adzel\velocitybroadcast\BroadcastCommand.class com\adzel\velocitybroadcast\ConfigHandler.class +com\adzel\velocitybroadcast\UpdateChecker.class com\adzel\velocitybroadcast\ReloadCommand.class velocity-plugin.json com\adzel\velocitybroadcast\util\DatabaseManager.class