From c27f9435b1ca07b347ccc16bc1d4503247b05fe9 Mon Sep 17 00:00:00 2001 From: GitHub Date: Thu, 17 Jun 2021 14:54:16 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=97=20Added=20Javadoc=20to=20the=20Com?= =?UTF-8?q?mandLister=20and=20associated=20methods/fields/enums.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mafelp/discord/DiscordMessageBroadcast.java | 15 +++++++++++++++ .../mafelp/discord/commands/WhisperListener.java | 3 +++ .../github/mafelp/minecraft/CommandListener.java | 15 +++++++++++++-- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/github/mafelp/discord/DiscordMessageBroadcast.java b/src/main/java/com/github/mafelp/discord/DiscordMessageBroadcast.java index ff7ad3f..45dbbe5 100644 --- a/src/main/java/com/github/mafelp/discord/DiscordMessageBroadcast.java +++ b/src/main/java/com/github/mafelp/discord/DiscordMessageBroadcast.java @@ -31,6 +31,9 @@ public class DiscordMessageBroadcast extends Thread { */ private final String message; + /** + * The type of the broadcast. + */ private final BroadcastType broadcastType; /** @@ -171,8 +174,20 @@ private void playerCommandBroadcast() { } } +/** + * The type of the broadcast. + */ enum BroadcastType { + /** + * A player executed a command. + */ playerCommandBroadcast, + /** + * The server executed a command. + */ serverCommandBroadcast, + /** + * A player sent a normal message. + */ chatMessageBroadcast } \ No newline at end of file diff --git a/src/main/java/com/github/mafelp/discord/commands/WhisperListener.java b/src/main/java/com/github/mafelp/discord/commands/WhisperListener.java index 0a50ec2..d9cf989 100644 --- a/src/main/java/com/github/mafelp/discord/commands/WhisperListener.java +++ b/src/main/java/com/github/mafelp/discord/commands/WhisperListener.java @@ -221,6 +221,9 @@ public void onMessageCreate(MessageCreateEvent messageCreateEvent) { * The method that creates a prefix for whispered messages, according to the settings.
* This prefix can either be a one-liner or a two-liner. * @param messageCreateEvent The event that stores all the information about the whisper message sender. + * @param playerIsReceiver Receiver is a player; if not, it will be the console so don't display line + * breaks and emoji if this is set to false. + * @param receiver The "name" of the receiver. * @return The prefix to add to the message. */ private static String whisperPrefix(MessageCreateEvent messageCreateEvent, boolean playerIsReceiver, String receiver) { diff --git a/src/main/java/com/github/mafelp/minecraft/CommandListener.java b/src/main/java/com/github/mafelp/minecraft/CommandListener.java index 1e95977..db05770 100644 --- a/src/main/java/com/github/mafelp/minecraft/CommandListener.java +++ b/src/main/java/com/github/mafelp/minecraft/CommandListener.java @@ -9,10 +9,17 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.server.ServerCommandEvent; +/** + * The class that handles the command sending events. + */ public class CommandListener implements Listener { + /** + * The method that handles commands executed by a player. + * @param playerCommandPreprocessEvent The event passed in by the plugin framework with information about the event. + */ @EventHandler public void onCommand(PlayerCommandPreprocessEvent playerCommandPreprocessEvent) { - if (!Settings.getConfiguration().getBoolean("sendCommandToDiscord.player")) { + if (!Settings.getConfiguration().getBoolean("sendCommandToDiscord.player", false)) { Logging.debug("Sending user commands to the discord server is disabled. Not sending command."); return; } @@ -24,9 +31,13 @@ public void onCommand(PlayerCommandPreprocessEvent playerCommandPreprocessEvent) discordMessageBroadcast.start(); } + /** + * The method that handles commands executed in the server's console. + * @param serverCommandEvent The event passed in by the plugin framework with information about the event. + */ @EventHandler public void onServerCommand(ServerCommandEvent serverCommandEvent) { - if (!Settings.getConfiguration().getBoolean("sendCommandToDiscord.server")) { + if (!Settings.getConfiguration().getBoolean("sendCommandToDiscord.server", false)) { Logging.debug("Sending server commands to the discord server is disabled. Not sending command."); return; }