@@ -49,51 +49,10 @@ object Utils {
4949 return command.startsWith(" /" )
5050 }
5151
52- fun getSplitCommandArgs (command : String ): String {
53- val splitCommand = command.split(" " .toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
54- if (splitCommand.size <= 1 ) return " "
55- return java.lang.String .join(" " , * Arrays .copyOfRange(splitCommand, 1 , splitCommand.size))
56- }
57-
58- fun getSplitCommandHeaders (command : String ): String {
59- val splitCommand = command.split(" " .toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
60- if (splitCommand.isEmpty()) return " "
61- return splitCommand[0 ]
62- }
63-
6452 val preProcessRegex: String
6553 get() = AdvancedSensitiveWords .setting(PluginSettings .PRE_PROCESS_REGEX )
6654
67-
68- fun isCommandAndWhiteListed (command : String ): Boolean {
69- if (! command.startsWith(" /" )) return false
70- val whitelist = AdvancedSensitiveWords .setting(PluginSettings .CHAT_COMMAND_WHITE_LIST )
71- val splitCommand = command.split(" " .toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
72- for (s in whitelist) {
73- if (splitCommand[0 ].equals(s, ignoreCase = true )) {
74- return ! AdvancedSensitiveWords .setting(PluginSettings .CHAT_INVERT_WHITELIST )
75- }
76- }
77- return AdvancedSensitiveWords .setting(PluginSettings .CHAT_INVERT_WHITELIST )
78- }
79-
8055 @JvmStatic
8156 val minecraftVersion: String
8257 get() = Bukkit .getMinecraftVersion()
83-
84- fun isNotCommand (command : String ): Boolean {
85- return ! command.startsWith(" /" )
86- }
87-
88- /* *
89- * Checks if the given object is null, and returns the fallback value if it is.
90- * @param obj The object to check
91- * @param fallback The fallback value to return if the object is null
92- */
93- fun <T > checkNotNullWithFallback (obj : T ? , fallback : T ): T {
94- if (obj == null ) {
95- return fallback
96- }
97- return obj
98- }
9958}
0 commit comments