Skip to content

Commit

Permalink
Merge pull request #213 from beanbeanjuice/development
Browse files Browse the repository at this point in the history
  • Loading branch information
beanbeanjuice authored Aug 16, 2024
2 parents 0d26c95 + f904345 commit c85a22c
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 25 deletions.
2 changes: 1 addition & 1 deletion projects/main-app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

version = "0.5.5"
version = "0.5.6"

java {
sourceCompatibility = JavaVersion.VERSION_17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,16 @@ private void registerListeners() {
}

private void registerCommands() {
this.getProxy().getPluginManager().registerCommand(this, new BungeeReloadCommand(this));
this.getProxy().getPluginManager().registerCommand(this, new BungeeChatToggleCommand(this));
this.getProxy().getPluginManager().registerCommand(this, new BungeeReloadCommand(this, config.getAsArrayList(ConfigDataKey.RELOAD_ALIASES).toArray(new String[0])));
this.getProxy().getPluginManager().registerCommand(this, new BungeeChatToggleCommand(this, config.getAsArrayList(ConfigDataKey.CHAT_TOGGLE_ALIASES).toArray(new String[0])));
this.getProxy().getPluginManager().registerCommand(this, new BungeeWhisperCommand(this, config.getAsArrayList(ConfigDataKey.WHISPER_ALIASES).toArray(new String[0])));
this.getProxy().getPluginManager().registerCommand(this, new BungeeReplyCommand(this, config.getAsArrayList(ConfigDataKey.REPLY_ALIASES).toArray(new String[0])));
this.getProxy().getPluginManager().registerCommand(this, new BungeeBroadcastCommand(this));
this.getProxy().getPluginManager().registerCommand(this, new BungeeBroadcastCommand(this, config.getAsArrayList(ConfigDataKey.BROADCAST_ALIASES).toArray(new String[0])));

// Only enable when needed.
if (config.getAsBoolean(ConfigDataKey.USE_SIMPLE_PROXY_CHAT_BANNING_SYSTEM)) {
this.getProxy().getPluginManager().registerCommand(this, new BungeeBanCommand(this));
this.getProxy().getPluginManager().registerCommand(this, new BungeeUnbanCommand(this));
this.getProxy().getPluginManager().registerCommand(this, new BungeeBanCommand(this, config.getAsArrayList(ConfigDataKey.BAN_ALIASES).toArray(new String[0])));
this.getProxy().getPluginManager().registerCommand(this, new BungeeUnbanCommand(this, config.getAsArrayList(ConfigDataKey.UNBAN_ALIASES).toArray(new String[0])));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,12 @@ private void registerCommands() {
CommandManager commandManager = proxyServer.getCommandManager();

CommandMeta reloadCommand = commandManager.metaBuilder("spc-reload")
.aliases("spcreload")
.aliases(config.getAsArrayList(ConfigDataKey.RELOAD_ALIASES).toArray(new String[0]))
.plugin(this)
.build();

CommandMeta chatToggleCommand = commandManager.metaBuilder("spc-chat")
.aliases("spcchat")
.aliases(config.getAsArrayList(ConfigDataKey.CHAT_TOGGLE_ALIASES).toArray(new String[0]))
.plugin(this)
.build();

Expand All @@ -231,17 +231,17 @@ private void registerCommands() {
.build();

CommandMeta banCommand = commandManager.metaBuilder("spc-ban")
.aliases("spcban")
.aliases(config.getAsArrayList(ConfigDataKey.BAN_ALIASES).toArray(new String[0]))
.plugin(this)
.build();

CommandMeta unbanCommand = commandManager.metaBuilder("spc-unban")
.aliases("spcunban")
.aliases(config.getAsArrayList(ConfigDataKey.UNBAN_ALIASES).toArray(new String[0]))
.plugin(this)
.build();

CommandMeta broadcastCommand = commandManager.metaBuilder("spc-broadcast")
.aliases("spcbroadcast", "spc-bc", "spcbc")
.aliases(config.getAsArrayList(ConfigDataKey.BROADCAST_ALIASES).toArray(new String[0]))
.plugin(this)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public class BungeeBroadcastCommand extends Command {
private final SimpleProxyChatBungee plugin;
private final Config config;

public BungeeBroadcastCommand(final SimpleProxyChatBungee plugin) {
super("Spc-broadcast", Permission.COMMAND_BROADCAST.getPermissionNode(), "Spc-bc");
public BungeeBroadcastCommand(final SimpleProxyChatBungee plugin, final String... aliases) {
super("Spc-broadcast", Permission.COMMAND_BROADCAST.getPermissionNode(), aliases);

this.plugin = plugin;
this.config = plugin.getConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public class BungeeChatToggleCommand extends Command implements TabExecutor {
private final SimpleProxyChatBungee plugin;
private final Config config;

public BungeeChatToggleCommand(final SimpleProxyChatBungee plugin) {
super("Spc-chat");
public BungeeChatToggleCommand(final SimpleProxyChatBungee plugin, final String... aliases) {
super("Spc-chat", null, aliases);
this.plugin = plugin;
this.config = plugin.getConfig();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public class BungeeReloadCommand extends Command {
private final SimpleProxyChatBungee plugin;
private final Config config;

public BungeeReloadCommand(final SimpleProxyChatBungee plugin) {
super("Spc-reload");
public BungeeReloadCommand(final SimpleProxyChatBungee plugin, final String... aliases) {
super("Spc-reload", null, aliases);
this.plugin = plugin;
this.config = plugin.getConfig();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public class BungeeBanCommand extends Command implements TabExecutor {
private final SimpleProxyChatBungee plugin;
private final Config config;

public BungeeBanCommand(final SimpleProxyChatBungee plugin) {
super("Spc-ban", Permission.COMMAND_BAN.getPermissionNode());
public BungeeBanCommand(final SimpleProxyChatBungee plugin, final String... aliases) {
super("Spc-ban", Permission.COMMAND_BAN.getPermissionNode(), aliases);
this.plugin = plugin;
this.config = plugin.getConfig();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public class BungeeUnbanCommand extends Command implements TabExecutor {
private final SimpleProxyChatBungee plugin;
private final Config config;

public BungeeUnbanCommand(final SimpleProxyChatBungee plugin) {
super("Spc-unban", Permission.COMMAND_UNBAN.getPermissionNode());
public BungeeUnbanCommand(final SimpleProxyChatBungee plugin, final String... aliases) {
super("Spc-unban", Permission.COMMAND_UNBAN.getPermissionNode(), aliases);
this.plugin = plugin;
this.config = plugin.getConfig();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class BungeeReplyCommand extends Command {
private final SimpleProxyChatBungee plugin;
private final Config config;

public BungeeReplyCommand(final SimpleProxyChatBungee plugin, String... aliases) {
public BungeeReplyCommand(final SimpleProxyChatBungee plugin, final String... aliases) {
super("Spc-reply", Permission.COMMAND_WHISPER.getPermissionNode(), aliases);
this.plugin = plugin;;
this.config = plugin.getConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class BungeeWhisperCommand extends Command implements TabExecutor {
private final SimpleProxyChatBungee plugin;
private final Config config;

public BungeeWhisperCommand(final SimpleProxyChatBungee plugin, String... aliases) {
public BungeeWhisperCommand(final SimpleProxyChatBungee plugin, final String... aliases) {
super("Spc-whisper", Permission.COMMAND_WHISPER.getPermissionNode(), aliases);
this.plugin = plugin;
this.config = plugin.getConfig();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.beanbeanjuice.simpleproxychat.utility.config;

import com.beanbeanjuice.simpleproxychat.utility.Tuple;
import com.beanbeanjuice.simpleproxychat.utility.helper.Helper;
import com.beanbeanjuice.simpleproxychat.utility.helper.ServerChatLockHelper;
import dev.dejvokep.boostedyaml.YamlDocument;
Expand Down Expand Up @@ -110,7 +111,8 @@ private void readConfig() throws IOException {
Section aliasSection = yamlConfig.getSection("aliases");
aliasSection.getKeys().stream()
.map((key) -> (String) key)
.forEach((key) -> aliases.put(key, aliasSection.getString(key)));
.map((key) -> Tuple.of(key, aliasSection.getString(key)))
.forEach((pair) -> aliases.put(pair.getKey(), Helper.translateLegacyCodes(pair.getValue())));
config.put(ConfigDataKey.ALIASES, aliases);
config.put(ConfigDataKey.USE_PERMISSIONS, yamlConfig.getBoolean("use-permissions"));
config.put(ConfigDataKey.PROXY_MESSAGE_PREFIX, yamlConfig.getString("proxy-message-prefix"));
Expand All @@ -125,10 +127,20 @@ private void readConfig() throws IOException {
config.put(ConfigDataKey.SEND_PREVIOUS_MESSAGES_ON_SWITCH_ENABLED, yamlConfig.getBoolean("send-previous-messages-on-switch.enabled"));
config.put(ConfigDataKey.SEND_PREVIOUS_MESSAGES_ON_SWITCH_AMOUNT, yamlConfig.getInt("send-previous-messages-on-switch.amount"));

ArrayList<String> reloadAliases = (ArrayList<String>) yamlConfig.getStringList("commands.reload-aliases");
config.put(ConfigDataKey.RELOAD_ALIASES, reloadAliases);
ArrayList<String> chatToggleAliases = (ArrayList<String>) yamlConfig.getStringList("commands.chat-toggle-aliases");
config.put(ConfigDataKey.CHAT_TOGGLE_ALIASES, chatToggleAliases);
ArrayList<String> BanAliases = (ArrayList<String>) yamlConfig.getStringList("commands.ban-aliases");
config.put(ConfigDataKey.BAN_ALIASES, BanAliases);
ArrayList<String> UnbanAliases = (ArrayList<String>) yamlConfig.getStringList("commands.unban-aliases");
config.put(ConfigDataKey.UNBAN_ALIASES, UnbanAliases);
ArrayList<String> whisperAliases = (ArrayList<String>) yamlConfig.getStringList("commands.whisper-aliases");
config.put(ConfigDataKey.WHISPER_ALIASES, whisperAliases);
ArrayList<String> replyAliases = (ArrayList<String>) yamlConfig.getStringList("commands.reply-aliases");
config.put(ConfigDataKey.REPLY_ALIASES, replyAliases);
ArrayList<String> broadcastAliases = (ArrayList<String>) yamlConfig.getStringList("commands.broadcast-aliases");
config.put(ConfigDataKey.BROADCAST_ALIASES, broadcastAliases);

// Checking timezone.
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ public enum ConfigDataKey {
USE_SIMPLE_PROXY_CHAT_BANNING_SYSTEM,
SEND_PREVIOUS_MESSAGES_ON_SWITCH_ENABLED,
SEND_PREVIOUS_MESSAGES_ON_SWITCH_AMOUNT,
RELOAD_ALIASES,
CHAT_TOGGLE_ALIASES,
BAN_ALIASES,
UNBAN_ALIASES,
WHISPER_ALIASES,
REPLY_ALIASES,
BROADCAST_ALIASES,

// MESSAGES
PLUGIN_PREFIX,
Expand Down
13 changes: 12 additions & 1 deletion projects/main-app/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,21 @@ send-previous-messages-on-switch:

# These require a restart in order to take place.
commands:
reload-aliases:
- "spcreload"
chat-toggle-aliases:
- "chattoggle"
ban-aliases:
- "spcban"
unban-aliases:
- "spcunban"
whisper-aliases:
- "spc-msg"
reply-aliases:
- "spc-r"
broadcast-aliases:
- "spc-bc"
- "broadcast"

# DO NOT TOUCH THIS
file-version: 13
file-version: 14

0 comments on commit c85a22c

Please sign in to comment.