From e07de605371d07869df60990a9475da2ac7c8774 Mon Sep 17 00:00:00 2001 From: wtlgo Date: Fri, 3 Mar 2023 02:30:20 +0300 Subject: [PATCH 1/5] Add config value --- .../java/dev/mikchan/mcnp/chat/contract/config/IConfig.kt | 5 +++++ .../chat/implementation/fallback/config/FallbackConfig.kt | 4 ++++ .../chat/implementation/spigot/config/BoostedYamlConfig.kt | 7 +++++++ src/main/resources/config.yml | 5 ++++- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/dev/mikchan/mcnp/chat/contract/config/IConfig.kt b/src/main/java/dev/mikchan/mcnp/chat/contract/config/IConfig.kt index 00daa40..0ebe2d0 100644 --- a/src/main/java/dev/mikchan/mcnp/chat/contract/config/IConfig.kt +++ b/src/main/java/dev/mikchan/mcnp/chat/contract/config/IConfig.kt @@ -11,6 +11,11 @@ interface IConfig { */ fun reload(): Boolean + /** + * Is logging enabled. + */ + var enableLog: Boolean + /** * Is local chat enabled. * diff --git a/src/main/java/dev/mikchan/mcnp/chat/implementation/fallback/config/FallbackConfig.kt b/src/main/java/dev/mikchan/mcnp/chat/implementation/fallback/config/FallbackConfig.kt index 1a5c269..f32d762 100644 --- a/src/main/java/dev/mikchan/mcnp/chat/implementation/fallback/config/FallbackConfig.kt +++ b/src/main/java/dev/mikchan/mcnp/chat/implementation/fallback/config/FallbackConfig.kt @@ -7,6 +7,10 @@ internal class FallbackConfig : IConfig { return true } + override var enableLog: Boolean + get() = false + set(_) {} + override var enableLocal: Boolean get() = false set(_) {} diff --git a/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/config/BoostedYamlConfig.kt b/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/config/BoostedYamlConfig.kt index 3d01fdc..960ba57 100644 --- a/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/config/BoostedYamlConfig.kt +++ b/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/config/BoostedYamlConfig.kt @@ -25,6 +25,13 @@ internal class BoostedYamlConfig(document: File, resource: InputStream) : IConfi return config.reload() } + override var enableLog: Boolean + get() = config.getBoolean("enableLog", false) + set(value) { + config.set("enableLog", value) + config.save() + } + override var enableLocal: Boolean get() = config.getBoolean("enableLocal", false) set(value) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index ff28cbb..14c7935 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,5 +1,8 @@ # This is an automatic property, do not change! -configVersion: 3 +configVersion: 4 + +# Should enable logging messages? +enableLog: false # Local chat settings # If enabled, by default all messages sent by a player From d374e83649f76c50df53662c934e890b77bcbe00 Mon Sep 17 00:00:00 2001 From: wtlgo Date: Fri, 3 Mar 2023 03:26:58 +0300 Subject: [PATCH 2/5] Create logger --- build.gradle | 1 - .../java/dev/mikchan/mcnp/chat/ChatPlugin.kt | 2 + .../mcnp/chat/contract/IChatPluginFactory.kt | 3 + .../mcnp/chat/contract/log/IChatLogger.kt | 10 +++ .../spigot/SpigotChatPluginFactory.kt | 20 +++-- .../spigot/log/FileChatLogger.kt | 78 +++++++++++++++++++ 6 files changed, 106 insertions(+), 8 deletions(-) create mode 100644 src/main/java/dev/mikchan/mcnp/chat/contract/log/IChatLogger.kt create mode 100644 src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/log/FileChatLogger.kt diff --git a/build.gradle b/build.gradle index dc750c8..05cfc1f 100644 --- a/build.gradle +++ b/build.gradle @@ -48,7 +48,6 @@ dependencies { implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.8.10' compileOnly 'dev.dejvokep:boosted-yaml-spigot:1.3' - implementation "org.bstats:bstats-bukkit:3.0.1" shadow "org.bstats:bstats-bukkit:3.0.1" diff --git a/src/main/java/dev/mikchan/mcnp/chat/ChatPlugin.kt b/src/main/java/dev/mikchan/mcnp/chat/ChatPlugin.kt index 97031fd..aed9e73 100644 --- a/src/main/java/dev/mikchan/mcnp/chat/ChatPlugin.kt +++ b/src/main/java/dev/mikchan/mcnp/chat/ChatPlugin.kt @@ -5,6 +5,7 @@ import dev.mikchan.mcnp.chat.contract.config.IConfig import dev.mikchan.mcnp.chat.contract.events.IEventManager import dev.mikchan.mcnp.chat.contract.formatting.IFormatter import dev.mikchan.mcnp.chat.contract.keys.IKeys +import dev.mikchan.mcnp.chat.contract.log.IChatLogger import dev.mikchan.mcnp.chat.contract.users.IUserManager import org.bstats.bukkit.Metrics import org.bukkit.plugin.java.JavaPlugin @@ -26,6 +27,7 @@ class ChatPlugin : JavaPlugin() { val userManager: IUserManager by lazy { factory.createUserManager() } val eventManager: IEventManager by lazy { factory.createEventManager() } val keys: IKeys by lazy { factory.createKeys() } + val chatLogger: IChatLogger by lazy { factory.createChatLogger() } override fun onEnable() { commandManager.enableAll() diff --git a/src/main/java/dev/mikchan/mcnp/chat/contract/IChatPluginFactory.kt b/src/main/java/dev/mikchan/mcnp/chat/contract/IChatPluginFactory.kt index 8721740..bd2ebac 100644 --- a/src/main/java/dev/mikchan/mcnp/chat/contract/IChatPluginFactory.kt +++ b/src/main/java/dev/mikchan/mcnp/chat/contract/IChatPluginFactory.kt @@ -5,6 +5,7 @@ import dev.mikchan.mcnp.chat.contract.config.IConfig import dev.mikchan.mcnp.chat.contract.events.IEventManager import dev.mikchan.mcnp.chat.contract.formatting.IFormatter import dev.mikchan.mcnp.chat.contract.keys.IKeys +import dev.mikchan.mcnp.chat.contract.log.IChatLogger import dev.mikchan.mcnp.chat.contract.users.IUserManager /** @@ -17,4 +18,6 @@ interface IChatPluginFactory { fun createFormatter(): IFormatter fun createKeys(): IKeys fun createUserManager(): IUserManager + + fun createChatLogger(): IChatLogger } diff --git a/src/main/java/dev/mikchan/mcnp/chat/contract/log/IChatLogger.kt b/src/main/java/dev/mikchan/mcnp/chat/contract/log/IChatLogger.kt new file mode 100644 index 0000000..0f2520d --- /dev/null +++ b/src/main/java/dev/mikchan/mcnp/chat/contract/log/IChatLogger.kt @@ -0,0 +1,10 @@ +package dev.mikchan.mcnp.chat.contract.log + +import org.bukkit.entity.Player + +interface IChatLogger { + fun logGlobal(player: Player, message: String) + fun logLocal(player: Player, message: String) + fun logPrivate(from: Player, to: Player, message: String) + fun logConsole(player: Player, fromConsole: Boolean, message: String) +} diff --git a/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/SpigotChatPluginFactory.kt b/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/SpigotChatPluginFactory.kt index 2cffbcc..0e983d0 100644 --- a/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/SpigotChatPluginFactory.kt +++ b/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/SpigotChatPluginFactory.kt @@ -1,6 +1,14 @@ package dev.mikchan.mcnp.chat.implementation.spigot import dev.mikchan.mcnp.chat.ChatPlugin +import dev.mikchan.mcnp.chat.contract.IChatPluginFactory +import dev.mikchan.mcnp.chat.contract.commands.ICommandManager +import dev.mikchan.mcnp.chat.contract.config.IConfig +import dev.mikchan.mcnp.chat.contract.events.IEventManager +import dev.mikchan.mcnp.chat.contract.formatting.IFormatter +import dev.mikchan.mcnp.chat.contract.keys.IKeys +import dev.mikchan.mcnp.chat.contract.log.IChatLogger +import dev.mikchan.mcnp.chat.contract.users.IUserManager import dev.mikchan.mcnp.chat.implementation.fallback.config.FallbackConfig import dev.mikchan.mcnp.chat.implementation.fallback.formatting.FallbackFormatter import dev.mikchan.mcnp.chat.implementation.spigot.commands.SpigotCommandManager @@ -8,14 +16,8 @@ import dev.mikchan.mcnp.chat.implementation.spigot.config.BoostedYamlConfig import dev.mikchan.mcnp.chat.implementation.spigot.events.SpigotEventManager import dev.mikchan.mcnp.chat.implementation.spigot.formatting.PAPIFormatter import dev.mikchan.mcnp.chat.implementation.spigot.keys.SpigotKeys +import dev.mikchan.mcnp.chat.implementation.spigot.log.FileChatLogger import dev.mikchan.mcnp.chat.implementation.spigot.users.SpigotUserManager -import dev.mikchan.mcnp.chat.contract.IChatPluginFactory -import dev.mikchan.mcnp.chat.contract.commands.ICommandManager -import dev.mikchan.mcnp.chat.contract.config.IConfig -import dev.mikchan.mcnp.chat.contract.events.IEventManager -import dev.mikchan.mcnp.chat.contract.formatting.IFormatter -import dev.mikchan.mcnp.chat.contract.keys.IKeys -import dev.mikchan.mcnp.chat.contract.users.IUserManager import me.clip.placeholderapi.PlaceholderAPIPlugin import java.io.File @@ -57,4 +59,8 @@ internal class SpigotChatPluginFactory(private val plugin: ChatPlugin) : IChatPl override fun createUserManager(): IUserManager { return SpigotUserManager(plugin) } + + override fun createChatLogger(): IChatLogger { + return FileChatLogger(plugin) + } } diff --git a/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/log/FileChatLogger.kt b/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/log/FileChatLogger.kt new file mode 100644 index 0000000..fe20c7b --- /dev/null +++ b/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/log/FileChatLogger.kt @@ -0,0 +1,78 @@ +package dev.mikchan.mcnp.chat.implementation.spigot.log + +import dev.mikchan.mcnp.chat.ChatPlugin +import dev.mikchan.mcnp.chat.contract.log.IChatLogger +import org.bukkit.entity.Player +import java.io.BufferedWriter +import java.io.File +import java.io.FileOutputStream +import java.text.SimpleDateFormat +import java.util.* +import java.util.concurrent.locks.ReentrantLock +import kotlin.concurrent.thread +import kotlin.concurrent.withLock + +internal class FileChatLogger(val plugin: ChatPlugin) : IChatLogger { + private val mutex = ReentrantLock() + private val folder = File(plugin.dataFolder, "logs") + private var lastFileName: String? = null + private var writer: BufferedWriter? = FileOutputStream(folder, true).bufferedWriter() + + private fun getWriter(): BufferedWriter { + val now = SimpleDateFormat("yyyy-MM-dd").format(Date()) + + val writer = writer + if (lastFileName == now && writer != null) { + return writer + } + + val newFileName = "${now}.log" + val newFile = File(folder, newFileName) + val newWriter = FileOutputStream(newFile, true).bufferedWriter() + + lastFileName = now + this.writer = newWriter + + return newWriter + } + + private fun getTime(): String { + return SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US).format(Date()) + } + + private fun write(log: String) { + if (!plugin.config.enableLog) return + + thread { + mutex.withLock { + getWriter().use { + it.write("[${getTime()}] ") + it.write(log) + it.newLine() + } + } + } + } + + override fun logGlobal(player: Player, message: String) { + write("[GLOBAL] (${player.uniqueId}) ${player.name}: $message") + } + + override fun logLocal(player: Player, message: String) { + write("[LOCAL] (${player.uniqueId}) ${player.name}: $message") + } + + override fun logPrivate(from: Player, to: Player, message: String) { + write("[PRIVATE] (${from.uniqueId}, ${to.uniqueId}) ${from.name}, ${to.name}: $message") + } + + override fun logConsole(player: Player, fromConsole: Boolean, message: String) { + write( + if (fromConsole) { + "[PRIVATE] (${player.uniqueId}) CONSOLE, ${player.name}: $message" + } else { + "[PRIVATE] (${player.uniqueId}) ${player.name}, CONSOLE: $message" + } + ) + } +} From 4a08b9945bb66d6caae62e443feabf17b63d6531 Mon Sep 17 00:00:00 2001 From: wtlgo Date: Fri, 3 Mar 2023 04:50:16 +0300 Subject: [PATCH 3/5] Integrate logger --- .../spigot/commands/command/MsgCommand.kt | 2 + .../spigot/commands/command/ReplyCommand.kt | 9 ++- .../spigot/events/listeners/MCNCListener.kt | 13 +++++ .../spigot/log/FileChatLogger.kt | 55 ++++++++++--------- 4 files changed, 51 insertions(+), 28 deletions(-) diff --git a/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/commands/command/MsgCommand.kt b/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/commands/command/MsgCommand.kt index 86909e8..2bf7e69 100644 --- a/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/commands/command/MsgCommand.kt +++ b/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/commands/command/MsgCommand.kt @@ -38,8 +38,10 @@ internal class MsgCommand(private val plugin: ChatPlugin, private val history: M if (sender is Player) { user.sendMessage(sender.uniqueId, formattedMessage) + plugin.chatLogger.logPrivate(sender, user, message) } else { sender.sendMessage(formattedMessage) + plugin.chatLogger.logConsole(user, true, message) } if (user != sender) { diff --git a/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/commands/command/ReplyCommand.kt b/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/commands/command/ReplyCommand.kt index 320c0a2..b3d9835 100644 --- a/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/commands/command/ReplyCommand.kt +++ b/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/commands/command/ReplyCommand.kt @@ -44,7 +44,6 @@ internal class ReplyCommand(private val plugin: ChatPlugin, private val history: sender.sendMessage(recipient.uniqueId, formattedMessage) } else { sender.sendMessage(formattedMessage) - } if (recipient != sender) { @@ -55,6 +54,14 @@ internal class ReplyCommand(private val plugin: ChatPlugin, private val history: } } + if (sender is Player && recipient is Player) { + plugin.chatLogger.logPrivate(sender, recipient, msg) + } else if (sender is Player && recipient !is Player) { + plugin.chatLogger.logConsole(sender, false, msg) + } else if (recipient is Player) { + plugin.chatLogger.logConsole(recipient, true, msg) + } + if (recipientUUID != null) { history[recipientUUID] = senderUUID } diff --git a/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/events/listeners/MCNCListener.kt b/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/events/listeners/MCNCListener.kt index eb7744a..4d1fb30 100644 --- a/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/events/listeners/MCNCListener.kt +++ b/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/events/listeners/MCNCListener.kt @@ -38,4 +38,17 @@ internal class MCNCListener(private val plugin: ChatPlugin) : Listener { } } } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + fun onLogEvent(event: MCNChatEvent) { + if(event.isCancelled) return + if(event.isPreview) return + + if(event.isGlobal) { + plugin.chatLogger.logGlobal(event.sender, event.message) + } + else { + plugin.chatLogger.logLocal(event.sender, event.message) + } + } } diff --git a/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/log/FileChatLogger.kt b/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/log/FileChatLogger.kt index fe20c7b..30c4134 100644 --- a/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/log/FileChatLogger.kt +++ b/src/main/java/dev/mikchan/mcnp/chat/implementation/spigot/log/FileChatLogger.kt @@ -3,38 +3,43 @@ package dev.mikchan.mcnp.chat.implementation.spigot.log import dev.mikchan.mcnp.chat.ChatPlugin import dev.mikchan.mcnp.chat.contract.log.IChatLogger import org.bukkit.entity.Player -import java.io.BufferedWriter import java.io.File import java.io.FileOutputStream +import java.io.PrintStream import java.text.SimpleDateFormat import java.util.* import java.util.concurrent.locks.ReentrantLock import kotlin.concurrent.thread import kotlin.concurrent.withLock +import kotlin.random.Random internal class FileChatLogger(val plugin: ChatPlugin) : IChatLogger { private val mutex = ReentrantLock() - private val folder = File(plugin.dataFolder, "logs") + private val folder = File(plugin.dataFolder.path, "logs") private var lastFileName: String? = null - private var writer: BufferedWriter? = FileOutputStream(folder, true).bufferedWriter() + private var stream: PrintStream? = null - private fun getWriter(): BufferedWriter { - val now = SimpleDateFormat("yyyy-MM-dd").format(Date()) + private val printer: PrintStream + get() { + val now = SimpleDateFormat("yyyy-MM-dd").format(Date()) - val writer = writer - if (lastFileName == now && writer != null) { - return writer - } + val stream = stream + if (lastFileName == now && stream != null) { + return stream + } - val newFileName = "${now}.log" - val newFile = File(folder, newFileName) - val newWriter = FileOutputStream(newFile, true).bufferedWriter() + val newFileName = "${now}.log" + lastFileName = now - lastFileName = now - this.writer = newWriter + folder.mkdirs() + val newFile = File(folder, newFileName) + val newStream = PrintStream(FileOutputStream(newFile, true)) - return newWriter - } + this.stream?.close() + this.stream = newStream + + return newStream + } private fun getTime(): String { return SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US).format(Date()) @@ -43,35 +48,31 @@ internal class FileChatLogger(val plugin: ChatPlugin) : IChatLogger { private fun write(log: String) { if (!plugin.config.enableLog) return - thread { + thread(name = "mcn-chat-log-${Random.nextInt()}") { mutex.withLock { - getWriter().use { - it.write("[${getTime()}] ") - it.write(log) - it.newLine() - } + printer.println("[${getTime()}]$log") } } } override fun logGlobal(player: Player, message: String) { - write("[GLOBAL] (${player.uniqueId}) ${player.name}: $message") + write("[GLOBAL] ${player.name}: $message (at ${player.location})") } override fun logLocal(player: Player, message: String) { - write("[LOCAL] (${player.uniqueId}) ${player.name}: $message") + write("[LOCAL] ${player.name}: $message (at ${player.location})") } override fun logPrivate(from: Player, to: Player, message: String) { - write("[PRIVATE] (${from.uniqueId}, ${to.uniqueId}) ${from.name}, ${to.name}: $message") + write("[PRIVATE] ${from.name} to ${to.name}: $message (at ${from.location})") } override fun logConsole(player: Player, fromConsole: Boolean, message: String) { write( if (fromConsole) { - "[PRIVATE] (${player.uniqueId}) CONSOLE, ${player.name}: $message" + "[PRIVATE] CONSOLE, ${player.name}: $message" } else { - "[PRIVATE] (${player.uniqueId}) ${player.name}, CONSOLE: $message" + "[PRIVATE] ${player.name}, CONSOLE: $message (at ${player.location})" } ) } From 46751586a44ef0db714ba4a7df07f43f0f2d1aee Mon Sep 17 00:00:00 2001 From: wtlgo Date: Fri, 3 Mar 2023 10:39:34 +0300 Subject: [PATCH 4/5] Add documentation --- .../mcnp/chat/contract/IChatPluginFactory.kt | 40 +++++++++++++++++++ .../mikchan/mcnp/chat/contract/keys/IKey.kt | 10 +++++ .../mikchan/mcnp/chat/contract/keys/IKeys.kt | 6 +++ .../mcnp/chat/contract/log/IChatLogger.kt | 33 +++++++++++++++ 4 files changed, 89 insertions(+) diff --git a/src/main/java/dev/mikchan/mcnp/chat/contract/IChatPluginFactory.kt b/src/main/java/dev/mikchan/mcnp/chat/contract/IChatPluginFactory.kt index bd2ebac..50ea6da 100644 --- a/src/main/java/dev/mikchan/mcnp/chat/contract/IChatPluginFactory.kt +++ b/src/main/java/dev/mikchan/mcnp/chat/contract/IChatPluginFactory.kt @@ -12,12 +12,52 @@ import dev.mikchan.mcnp.chat.contract.users.IUserManager * An abstract factory */ interface IChatPluginFactory { + /** + * Creates a configuration + * + * @return A new configuration object + */ fun createConfig(): IConfig + + /** + * Creates a command manager + * + * @return A new command manager + */ fun createCommandManager(): ICommandManager + + /** + * Creates an event manager + * + * @return A new event manager + */ fun createEventManager(): IEventManager + + /** + * Creates a formatter + * + * @return A new formatter + */ fun createFormatter(): IFormatter + + /** + * Creates a key store + * + * @return A new key store + */ fun createKeys(): IKeys + + /** + * Creates a user manager + * + * @return A new user manager + */ fun createUserManager(): IUserManager + /** + * Creates a chat logger + * + * @return A new chat logger + */ fun createChatLogger(): IChatLogger } diff --git a/src/main/java/dev/mikchan/mcnp/chat/contract/keys/IKey.kt b/src/main/java/dev/mikchan/mcnp/chat/contract/keys/IKey.kt index 3f40fdb..51ae3ad 100644 --- a/src/main/java/dev/mikchan/mcnp/chat/contract/keys/IKey.kt +++ b/src/main/java/dev/mikchan/mcnp/chat/contract/keys/IKey.kt @@ -3,7 +3,17 @@ package dev.mikchan.mcnp.chat.contract.keys import org.bukkit.NamespacedKey import org.bukkit.persistence.PersistentDataType +/** + * Key representation + */ interface IKey { + /** + * The key name + */ val key: NamespacedKey + + /** + * The key type + */ val type: PersistentDataType } diff --git a/src/main/java/dev/mikchan/mcnp/chat/contract/keys/IKeys.kt b/src/main/java/dev/mikchan/mcnp/chat/contract/keys/IKeys.kt index 6f2af76..bdb6338 100644 --- a/src/main/java/dev/mikchan/mcnp/chat/contract/keys/IKeys.kt +++ b/src/main/java/dev/mikchan/mcnp/chat/contract/keys/IKeys.kt @@ -1,5 +1,11 @@ package dev.mikchan.mcnp.chat.contract.keys +/** + * Namespaced keys collection interface + */ interface IKeys { + /** + * Namespaced key related to spy feature + */ val spy: IKey } diff --git a/src/main/java/dev/mikchan/mcnp/chat/contract/log/IChatLogger.kt b/src/main/java/dev/mikchan/mcnp/chat/contract/log/IChatLogger.kt index 0f2520d..4cf323d 100644 --- a/src/main/java/dev/mikchan/mcnp/chat/contract/log/IChatLogger.kt +++ b/src/main/java/dev/mikchan/mcnp/chat/contract/log/IChatLogger.kt @@ -2,9 +2,42 @@ package dev.mikchan.mcnp.chat.contract.log import org.bukkit.entity.Player +/** + * A chat logger interface + */ interface IChatLogger { + /** + * Logs global message + * + * @param player The player who sent the message + * @param message The message + */ fun logGlobal(player: Player, message: String) + + /** + * Logs local message + * + * @param player The player who sent the message + * @param message The message + */ fun logLocal(player: Player, message: String) + + /** + * Logs private message + * + * @param from The player who sent the message + * @param to The player who receives the message + * @param message The message + */ fun logPrivate(from: Player, to: Player, message: String) + + /** + * Logs console private message + * + * @param player The player which is related to this log + * @param fromConsole If `true` logs a `Console -> Player` type of message, + * and if `false` logs `Player -> Console` + * @param message The message + */ fun logConsole(player: Player, fromConsole: Boolean, message: String) } From dc548aa404e9c307abf4209514bb964543cfe01f Mon Sep 17 00:00:00 2001 From: wtlgo Date: Fri, 3 Mar 2023 10:50:30 +0300 Subject: [PATCH 5/5] Bump version --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 05cfc1f..86d342a 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ static def determineVersion(String defaultVersion) { } group = 'dev.mikchan.mcnp' -version = determineVersion('2.0.0') +version = determineVersion('2.1.0') repositories { mavenCentral()