Skip to content

Commit 7a70706

Browse files
added ability to send command denied message as action bar in bukkit and waterfall
1 parent b4fda1c commit 7a70706

File tree

9 files changed

+41
-7
lines changed

9 files changed

+41
-7
lines changed

CommandWhitelistBukkit/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>eu.endermite.commandwhitelist</groupId>
88
<artifactId>CommandWhitelist</artifactId>
9-
<version>2.10.0</version>
9+
<version>2.11.0</version>
1010
</parent>
1111

1212
<artifactId>Bukkit</artifactId>

CommandWhitelistBukkit/src/main/java/eu/endermite/commandwhitelist/bukkit/listeners/PlayerCommandPreProcessListener.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,14 @@ public void PlayerExecuteCommand(PlayerCommandPreprocessEvent event) {
3434
messageWithoutSlash,
3535
config.prefix + CommandWhitelistBukkit.getCommandDeniedMessage(label)
3636
);
37-
audiences.player(player).sendMessage(message);
37+
switch (config.messageType) {
38+
case CHAT:
39+
audiences.player(player).sendMessage(message);
40+
break;
41+
case ACTIONBAR:
42+
audiences.player(player).sendActionBar(message);
43+
break;
44+
}
3845
return;
3946
}
4047

CommandWhitelistCommon/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>eu.endermite.commandwhitelist</groupId>
88
<artifactId>CommandWhitelist</artifactId>
9-
<version>2.10.0</version>
9+
<version>2.11.0</version>
1010
</parent>
1111

1212
<artifactId>Common</artifactId>

CommandWhitelistCommon/src/main/java/eu/endermite/commandwhitelist/common/ConfigCache.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class ConfigCache {
1717
public String prefix, command_denied, no_permission, no_such_subcommand, config_reloaded, added_to_whitelist,
1818
removed_from_whitelist, group_doesnt_exist, subcommand_denied;
1919
public boolean useProtocolLib = false;
20+
public MessageType messageType = MessageType.CHAT;
2021
public boolean debug = false;
2122

2223
public ConfigCache(File configFile, boolean canDoProtocolLib, Object logger) {
@@ -56,6 +57,8 @@ public boolean reloadConfig() {
5657
if (canDoProtocolLib)
5758
config.addDefault("use_protocollib", false, "Do not enable if you don't have issues with aliased commands.\nThis requires server restart to take effect.");
5859

60+
config.addDefault("message_type", MessageType.CHAT.toString(), "Valid message types are CHAT and ACTIONBAR. Does nothing on velocity.");
61+
5962
if (config.isNew()) {
6063
List<String> exampleCommands = new ArrayList<>();
6164
exampleCommands.add("example");
@@ -102,6 +105,16 @@ public boolean reloadConfig() {
102105
group_doesnt_exist = config.getString("messages.group_doesnt_exist");
103106
useProtocolLib = config.getBoolean("use_protocollib");
104107
debug = config.getBoolean("debug", false);
108+
try {
109+
String chatTypeId = config.getString("message_type");
110+
if (chatTypeId == null) {
111+
warn("Invalid message type. Using CHAT.");
112+
} else {
113+
messageType = MessageType.valueOf(chatTypeId.toUpperCase(Locale.ENGLISH));
114+
}
115+
} catch (IllegalArgumentException e) {
116+
warn("Invalid message type. Using CHAT.");
117+
}
105118

106119
ConfigSection groupSection = config.getConfigSection("groups");
107120
for (String key : groupSection.getKeys(false)) {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package eu.endermite.commandwhitelist.common;
2+
3+
public enum MessageType {
4+
5+
CHAT, ACTIONBAR
6+
7+
}

CommandWhitelistVelocity/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>eu.endermite.commandwhitelist</groupId>
88
<artifactId>CommandWhitelist</artifactId>
9-
<version>2.10.0</version>
9+
<version>2.11.0</version>
1010
</parent>
1111

1212
<artifactId>Velocity</artifactId>

CommandWhitelistWaterfall/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>eu.endermite.commandwhitelist</groupId>
88
<artifactId>CommandWhitelist</artifactId>
9-
<version>2.10.0</version>
9+
<version>2.11.0</version>
1010
</parent>
1111

1212
<artifactId>Waterfall</artifactId>

CommandWhitelistWaterfall/src/main/java/eu/endermite/commandwhitelist/waterfall/listeners/BungeeChatEventListener.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@ public void onChatEvent(ChatEvent event) {
3838
command,
3939
configCache.prefix + CommandWhitelistWaterfall.getCommandDeniedMessage(label)
4040
);
41-
audiences.player(player).sendMessage(message);
41+
switch (configCache.messageType) {
42+
case CHAT:
43+
audiences.player(player).sendMessage(message);
44+
break;
45+
case ACTIONBAR:
46+
audiences.player(player).sendActionBar(message);
47+
break;
48+
}
4249
return;
4350
}
4451

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>eu.endermite.commandwhitelist</groupId>
88
<artifactId>CommandWhitelist</artifactId>
9-
<version>2.10.0</version>
9+
<version>2.11.0</version>
1010
<modules>
1111
<module>CommandWhitelistCommon</module>
1212
<module>CommandWhitelistBukkit</module>

0 commit comments

Comments
 (0)