Skip to content

Commit a6b10df

Browse files
committed
Allow AutoKiller to be disabled
Signed-off-by: applenick <[email protected]>
1 parent 067eaae commit a6b10df

File tree

5 files changed

+22
-11
lines changed

5 files changed

+22
-11
lines changed

src/main/java/tc/oc/occ/cheaty/BotConfig.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class BotConfig {
1616

1717
private boolean reportsEnabled;
1818
private boolean relayCommandEnabled;
19+
private boolean autoKillerEnabled;
1920

2021
private String reportFormat;
2122
private String relayFormat;
@@ -56,6 +57,7 @@ public void reload(Configuration config) {
5657

5758
this.reportsEnabled = config.getBoolean("types.reports");
5859
this.relayCommandEnabled = config.getBoolean("types.relay-command");
60+
this.autoKillerEnabled = config.getBoolean("types.auto-killer");
5961

6062
this.reportFormat = config.getString("report-format");
6163
this.relayFormat = config.getString("relay-format");
@@ -107,6 +109,10 @@ public boolean isRelayCommandEnabled() {
107109
return relayCommandEnabled;
108110
}
109111

112+
public boolean isAutoKillerEnabled() {
113+
return autoKillerEnabled;
114+
}
115+
110116
public String getReportFormat() {
111117
return replaceServerName(reportFormat);
112118
}

src/main/java/tc/oc/occ/cheaty/BotListener.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@
44
import net.climaxmc.autokiller.events.AutoKillCheatEvent;
55
import org.bukkit.event.EventHandler;
66
import org.bukkit.event.Listener;
7-
import tc.oc.occ.cheaty.DiscordBot.RelayType;
87

98
public class BotListener implements Listener {
109

1110
private final DiscordBot bot;
12-
private final BotConfig config;
1311

14-
public BotListener(DiscordBot bot, BotConfig config) {
12+
public BotListener(DiscordBot bot) {
1513
this.bot = bot;
16-
this.config = config;
1714
}
1815

1916
@EventHandler
@@ -23,6 +20,6 @@ public void onPlayerReport(PlayerReportEvent event) {
2320

2421
@EventHandler
2522
public void onAutoKillerViolation(AutoKillCheatEvent event) {
26-
bot.sendRelay(event.getAlert(), RelayType.AUTOKILL);
23+
bot.sendAutoKiller(event);
2724
}
2825
}

src/main/java/tc/oc/occ/cheaty/Cheaty.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void setupCommands() {
3939
}
4040

4141
private void registerListeners() {
42-
this.getServer().getPluginManager().registerEvents(new BotListener(bot, config), this);
42+
this.getServer().getPluginManager().registerEvents(new BotListener(bot), this);
4343
}
4444

4545
public void reloadBotConfig() {

src/main/java/tc/oc/occ/cheaty/DiscordBot.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.util.UUID;
99
import java.util.logging.Logger;
1010
import java.util.stream.Collectors;
11+
import net.climaxmc.autokiller.events.AutoKillCheatEvent;
1112
import org.bukkit.Bukkit;
1213
import org.bukkit.ChatColor;
1314
import org.bukkit.entity.Player;
@@ -89,6 +90,11 @@ private Optional<ServerChannel> getChannel(String id) {
8990
return Optional.empty();
9091
}
9192

93+
private String getUsername(UUID playerId) {
94+
Player player = Bukkit.getPlayer(playerId);
95+
return player != null ? player.getName() : null;
96+
}
97+
9298
private void sendMessage(String message, boolean report) {
9399
if (api != null) {
94100
api.getServerById(config.getDiscordServerId())
@@ -129,17 +135,18 @@ public void sendReport(PlayerReportEvent event) {
129135
}
130136
}
131137

132-
private String getUsername(UUID playerId) {
133-
Player player = Bukkit.getPlayer(playerId);
134-
return player != null ? player.getName() : null;
135-
}
136-
137138
public void sendRelay(String message, RelayType type) {
138139
if (!config.isRelayCommandEnabled()) return;
139140
String formatted = config.getRelayFormat().replace("%message%", message);
140141
sendMessage(getPrefix(type) + formatted, false);
141142
}
142143

144+
public void sendAutoKiller(AutoKillCheatEvent event) {
145+
if (!config.isAutoKillerEnabled()) return;
146+
String formatted = config.getRelayFormat().replace("%message%", event.getAlert());
147+
sendMessage(getPrefix(RelayType.AUTOKILL) + formatted, false);
148+
}
149+
143150
public void sendReportPing(Report report, int numReports) {
144151
List<String> pingRoles = config.getDiscordPingRoles();
145152

src/main/resources/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ channels:
2020
types:
2121
reports: true
2222
relay-command: true
23+
auto-killer: true
2324

2425
# Reports (Sent from PGM)
2526
#

0 commit comments

Comments
 (0)