Updated Source Code for Version 0.3.5
This commit is contained in:
@ -4,7 +4,7 @@
|
||||
<groupId>com.adzel.velocitybroadcast</groupId>
|
||||
<artifactId>velocitybroadcast</artifactId>
|
||||
<name>VelocityBroadcast</name>
|
||||
<version>0.3-pre</version>
|
||||
<version>0.3.5</version>
|
||||
<description>Broadcast plugin for Minecraft Velocity proxy.</description>
|
||||
<build>
|
||||
<plugins>
|
||||
@ -49,6 +49,12 @@
|
||||
<version>3.1.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.luckperms</groupId>
|
||||
<artifactId>api</artifactId>
|
||||
<version>5.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
|
10
pom.xml
10
pom.xml
@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>com.adzel.velocitybroadcast</groupId>
|
||||
<artifactId>velocitybroadcast</artifactId>
|
||||
<version>0.3-pre</version>
|
||||
<version>0.3.5</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>VelocityBroadcast</name>
|
||||
<description>Broadcast plugin for Minecraft Velocity proxy.</description>
|
||||
@ -77,6 +77,14 @@
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- LuckPerms API (Velocity-compatible) -->
|
||||
<dependency>
|
||||
<groupId>net.luckperms</groupId>
|
||||
<artifactId>api</artifactId>
|
||||
<version>5.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -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<String> args = List.of(invocation.arguments());
|
||||
|
||||
if (!source.hasPermission("vb.broadcast")) {
|
||||
source.sendMessage(MiniMessage.miniMessage().deserialize("<red>You don't have permission to use this command.</red>"));
|
||||
source.sendMessage(mm.deserialize("<red>You don't have permission to use this command.</red>"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.isEmpty()) {
|
||||
source.sendMessage(MiniMessage.miniMessage().deserialize("<red>Usage: /vb <message></red>"));
|
||||
source.sendMessage(mm.deserialize("<red>Usage: /vb <message></red>"));
|
||||
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("<green>Broadcast sent.</green>"));
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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.",
|
||||
|
@ -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.",
|
||||
|
@ -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"}
|
||||
{"id":"velocitybroadcast","name":"VelocityBroadcast","version":"0.3.5","description":"A proxy-wide broadcast plugin for Velocity.","authors":["Adzel"],"dependencies":[],"main":"com.adzel.velocitybroadcast.VelocityBroadcast"}
|
@ -1,3 +1,3 @@
|
||||
artifactId=velocitybroadcast
|
||||
groupId=com.adzel.velocitybroadcast
|
||||
version=0.3-pre
|
||||
version=0.3.5
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user