added ability to send command denied message as action bar in bukkit and waterfall

This commit is contained in:
2024-12-17 17:14:50 +01:00
parent b4fda1cb9e
commit 7a707068e2
9 changed files with 41 additions and 7 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId>
<version>2.10.0</version>
<version>2.11.0</version>
</parent>
<artifactId>Bukkit</artifactId>
@@ -34,7 +34,14 @@ public class PlayerCommandPreProcessListener implements Listener {
messageWithoutSlash,
config.prefix + CommandWhitelistBukkit.getCommandDeniedMessage(label)
);
audiences.player(player).sendMessage(message);
switch (config.messageType) {
case CHAT:
audiences.player(player).sendMessage(message);
break;
case ACTIONBAR:
audiences.player(player).sendActionBar(message);
break;
}
return;
}
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId>
<version>2.10.0</version>
<version>2.11.0</version>
</parent>
<artifactId>Common</artifactId>
@@ -17,6 +17,7 @@ public class ConfigCache {
public String prefix, command_denied, no_permission, no_such_subcommand, config_reloaded, added_to_whitelist,
removed_from_whitelist, group_doesnt_exist, subcommand_denied;
public boolean useProtocolLib = false;
public MessageType messageType = MessageType.CHAT;
public boolean debug = false;
public ConfigCache(File configFile, boolean canDoProtocolLib, Object logger) {
@@ -56,6 +57,8 @@ public class ConfigCache {
if (canDoProtocolLib)
config.addDefault("use_protocollib", false, "Do not enable if you don't have issues with aliased commands.\nThis requires server restart to take effect.");
config.addDefault("message_type", MessageType.CHAT.toString(), "Valid message types are CHAT and ACTIONBAR. Does nothing on velocity.");
if (config.isNew()) {
List<String> exampleCommands = new ArrayList<>();
exampleCommands.add("example");
@@ -102,6 +105,16 @@ public class ConfigCache {
group_doesnt_exist = config.getString("messages.group_doesnt_exist");
useProtocolLib = config.getBoolean("use_protocollib");
debug = config.getBoolean("debug", false);
try {
String chatTypeId = config.getString("message_type");
if (chatTypeId == null) {
warn("Invalid message type. Using CHAT.");
} else {
messageType = MessageType.valueOf(chatTypeId.toUpperCase(Locale.ENGLISH));
}
} catch (IllegalArgumentException e) {
warn("Invalid message type. Using CHAT.");
}
ConfigSection groupSection = config.getConfigSection("groups");
for (String key : groupSection.getKeys(false)) {
@@ -0,0 +1,7 @@
package eu.endermite.commandwhitelist.common;
public enum MessageType {
CHAT, ACTIONBAR
}
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId>
<version>2.10.0</version>
<version>2.11.0</version>
</parent>
<artifactId>Velocity</artifactId>
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId>
<version>2.10.0</version>
<version>2.11.0</version>
</parent>
<artifactId>Waterfall</artifactId>
@@ -38,7 +38,14 @@ public class BungeeChatEventListener implements Listener {
command,
configCache.prefix + CommandWhitelistWaterfall.getCommandDeniedMessage(label)
);
audiences.player(player).sendMessage(message);
switch (configCache.messageType) {
case CHAT:
audiences.player(player).sendMessage(message);
break;
case ACTIONBAR:
audiences.player(player).sendActionBar(message);
break;
}
return;
}
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>eu.endermite.commandwhitelist</groupId>
<artifactId>CommandWhitelist</artifactId>
<version>2.10.0</version>
<version>2.11.0</version>
<modules>
<module>CommandWhitelistCommon</module>
<module>CommandWhitelistBukkit</module>