Skip to content

Commit 472603a

Browse files
committed
Add API for logging cancelled chat/commands
1 parent e7fc42f commit 472603a

File tree

1 file changed

+32
-13
lines changed

1 file changed

+32
-13
lines changed

src/main/java/net/coreprotect/CoreProtectAPI.java

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,24 @@ public boolean isEnabled() {
213213

214214
/**
215215
* Logs a chat message for a player.
216-
*
217-
* @param player
218-
* The player who sent the message
219-
* @param message
220-
* The chat message
216+
*
217+
* @param player The player who sent the message
218+
* @param message The chat message
221219
* @return True if the message was logged
222220
*/
223221
public boolean logChat(Player player, String message) {
222+
return logChat(player, message, false);
223+
}
224+
225+
/**
226+
* Logs a chat message for a player.
227+
*
228+
* @param player The player who sent the message
229+
* @param message The chat message
230+
* @param cancelled Whether the chat message was cancelled.
231+
* @return True if the message was logged
232+
*/
233+
public boolean logChat(Player player, String message, boolean cancelled) {
224234
if (!isEnabledForPlayer(player) || !Config.getConfig(player.getWorld()).PLAYER_MESSAGES) {
225235
return false;
226236
}
@@ -230,30 +240,39 @@ public boolean logChat(Player player, String message) {
230240
}
231241

232242
long timestamp = System.currentTimeMillis() / 1000L;
233-
Queue.queuePlayerChat(player, message, timestamp, false);
243+
Queue.queuePlayerChat(player, message, timestamp, cancelled);
234244
return true;
235245
}
236246

237247
/**
238248
* Logs a command executed by a player.
239-
*
240-
* @param player
241-
* The player who executed the command
242-
* @param command
243-
* The command
249+
*
250+
* @param player The player who executed the command
251+
* @param command The command
244252
* @return True if the command was logged
245253
*/
246254
public boolean logCommand(Player player, String command) {
255+
return logCommand(player, command, false);
256+
}
257+
258+
/**
259+
* Logs a command executed by a player.
260+
*
261+
* @param player The player who executed the command
262+
* @param command The command
263+
* @return True if the command was logged
264+
*/
265+
public boolean logCommand(Player player, String command, boolean cancelled) {
247266
if (!isEnabledForPlayer(player) || !Config.getConfig(player.getWorld()).PLAYER_COMMANDS) {
248267
return false;
249268
}
250269

251-
if (command == null || command.isEmpty() || !command.startsWith("/")) {
270+
if (command == null || !command.startsWith("/")) {
252271
return false;
253272
}
254273

255274
long timestamp = System.currentTimeMillis() / 1000L;
256-
Queue.queuePlayerCommand(player, command, timestamp, false);
275+
Queue.queuePlayerCommand(player, command, timestamp, cancelled);
257276
return true;
258277
}
259278

0 commit comments

Comments
 (0)