Skip to content

Commit 2056a22

Browse files
committed
added option to deactivate server switch reset
added option to deactivate sub server switch reset added option to define the text that appears after the chatmessage added icon.png
1 parent df8b25e commit 2056a22

File tree

5 files changed

+45
-6
lines changed

5 files changed

+45
-6
lines changed

core/src/main/java/de/lebaasti/core/AntiChatSpam.java

+15-5
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,18 @@ protected Class<Configuration> configurationClass() {
3131

3232
@Subscribe
3333
public void onSubServerSwitch(SubServerSwitchEvent event) {
34-
duplicateMessages.clear();
35-
duplicateMessageCount.clear();
34+
if(configuration().subServerSwitchReset().get()) {
35+
duplicateMessages.clear();
36+
duplicateMessageCount.clear();
37+
}
3638
}
3739

3840
@Subscribe
3941
public void onServerJoin(ServerJoinEvent event) {
40-
duplicateMessages.clear();
41-
duplicateMessageCount.clear();
42+
if(configuration().serverSwitchReset().get()) {
43+
duplicateMessages.clear();
44+
duplicateMessageCount.clear();
45+
}
4246
}
4347

4448
@Subscribe
@@ -50,9 +54,15 @@ public void onChatReceive(ChatReceiveEvent event) {
5054
if (count >= configuration().amount().get()) {
5155
duplicates.forEach(ChatMessage::delete);
5256
duplicates.clear();
53-
event.chatMessage().component().append(Component.text(" [x" + count + "]"));
57+
event.chatMessage().component().append(Component.text(getDuplicateText(count)));
5458
}
5559

5660
duplicates.add(event.chatMessage());
5761
}
62+
63+
public String getDuplicateText(int count) {
64+
return configuration().text().get()
65+
.replace("%amount%", Integer.toString(count))
66+
.replace("&", "§");
67+
}
5868
}

core/src/main/java/de/lebaasti/core/Configuration.java

+17
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import net.labymod.api.addon.AddonConfig;
44
import net.labymod.api.client.gui.screen.widget.widgets.input.SliderWidget.SliderSetting;
55
import net.labymod.api.client.gui.screen.widget.widgets.input.SwitchWidget.SwitchSetting;
6+
import net.labymod.api.client.gui.screen.widget.widgets.input.TextFieldWidget.TextFieldSetting;
67
import net.labymod.api.configuration.loader.annotation.ConfigName;
78
import net.labymod.api.configuration.loader.property.ConfigProperty;
89

@@ -15,10 +16,26 @@ public class Configuration extends AddonConfig {
1516
@SliderSetting(min = 2, max = 50)
1617
private final ConfigProperty<Integer> amount = new ConfigProperty<>(2);
1718

19+
@TextFieldSetting
20+
private final ConfigProperty<String> text = new ConfigProperty<>(" &r[x%amount%]");
21+
22+
@SwitchSetting
23+
private final ConfigProperty<Boolean> serverSwitchReset = new ConfigProperty<>(true);
24+
25+
@SwitchSetting
26+
private final ConfigProperty<Boolean> subServerSwitchReset = new ConfigProperty<>(true);
27+
1828
@Override
1929
public ConfigProperty<Boolean> enabled() {
2030
return this.enabled;
2131
}
2232

2333
public ConfigProperty<Integer> amount() { return this.amount; }
34+
35+
public ConfigProperty<String> text() { return this.text; }
36+
37+
public ConfigProperty<Boolean> serverSwitchReset() { return this.serverSwitchReset; }
38+
39+
public ConfigProperty<Boolean> subServerSwitchReset() { return this.subServerSwitchReset; }
40+
2441
}

core/src/main/resources/assets/antichatspam/i18n/en_us.json

+12
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
"amount": {
99
"name": "Amount",
1010
"description": "Amount when duplicate messages should be stacked"
11+
},
12+
"text": {
13+
"name": "Text",
14+
"description": "Text that appears after the message"
15+
},
16+
"serverSwitchReset": {
17+
"name": "Server Switch Reset",
18+
"description": "Whether the duplicate list should be reseted on server switch"
19+
},
20+
"subServerSwitchReset": {
21+
"name": "Sub Server Switch Reset",
22+
"description": "Whether the duplicate list should be reseted on sub server switch"
1123
}
1224
}
1325
}
Loading

settings.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
rootProject.name = "antichatspam"
22

33
pluginManagement {
4-
val labyGradlePluginVersion = "0.3.43"
4+
val labyGradlePluginVersion = "0.3.44"
55
plugins {
66
id("net.labymod.gradle") version (labyGradlePluginVersion)
77
}

0 commit comments

Comments
 (0)