Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
CommandWarn: add support for actions with different numbers of warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFaser committed Oct 7, 2023
1 parent 3c42817 commit c38fb89
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/main/java/net/flectone/misc/entity/FPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,11 @@ public void warn(int time, @NotNull String reason, @Nullable String moderatorUUI
PlayerWarn playerWarn = new PlayerWarn(this.uuid.toString(), finalTime, reason, moderatorUUID);
warnList.add(playerWarn);

if (!isBanned() && getRealWarnsCount() >= config.getInt("command.warn.count-for-ban")) {
String configString = locale.getString("command.warn.ban-too-many");
tempban(-1, configString, null);
int countWarns = getRealWarnsCount();
String warnAction = config.getString("command.warn.action." + countWarns);
if (!warnAction.isEmpty()) {
Bukkit.getScheduler().runTask(Main.getInstance(), () ->
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), warnAction.replace("<player>", this.name)));
}

Main.getDataThreadPool().execute(() ->
Expand Down
8 changes: 7 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,13 @@ command:
warn:
enable: true
announce: true
count-for-ban: 3

# number: "command"
# These actions will be executed when the number of warnings EQUALS the number config
# There can be as many as you want
action:
3: "ban <player> 7d"
5: "ban <player>"

# Command tab-complete mode: offline/online
tab-complete-mode: "offline"
Expand Down

0 comments on commit c38fb89

Please sign in to comment.