File tree 5 files changed +45
-6
lines changed
resources/assets/antichatspam
5 files changed +45
-6
lines changed Original file line number Diff line number Diff line change @@ -31,14 +31,18 @@ protected Class<Configuration> configurationClass() {
31
31
32
32
@ Subscribe
33
33
public void onSubServerSwitch (SubServerSwitchEvent event ) {
34
- duplicateMessages .clear ();
35
- duplicateMessageCount .clear ();
34
+ if (configuration ().subServerSwitchReset ().get ()) {
35
+ duplicateMessages .clear ();
36
+ duplicateMessageCount .clear ();
37
+ }
36
38
}
37
39
38
40
@ Subscribe
39
41
public void onServerJoin (ServerJoinEvent event ) {
40
- duplicateMessages .clear ();
41
- duplicateMessageCount .clear ();
42
+ if (configuration ().serverSwitchReset ().get ()) {
43
+ duplicateMessages .clear ();
44
+ duplicateMessageCount .clear ();
45
+ }
42
46
}
43
47
44
48
@ Subscribe
@@ -50,9 +54,15 @@ public void onChatReceive(ChatReceiveEvent event) {
50
54
if (count >= configuration ().amount ().get ()) {
51
55
duplicates .forEach (ChatMessage ::delete );
52
56
duplicates .clear ();
53
- event .chatMessage ().component ().append (Component .text (" [x" + count + "]" ));
57
+ event .chatMessage ().component ().append (Component .text (getDuplicateText ( count ) ));
54
58
}
55
59
56
60
duplicates .add (event .chatMessage ());
57
61
}
62
+
63
+ public String getDuplicateText (int count ) {
64
+ return configuration ().text ().get ()
65
+ .replace ("%amount%" , Integer .toString (count ))
66
+ .replace ("&" , "§" );
67
+ }
58
68
}
Original file line number Diff line number Diff line change 3
3
import net .labymod .api .addon .AddonConfig ;
4
4
import net .labymod .api .client .gui .screen .widget .widgets .input .SliderWidget .SliderSetting ;
5
5
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 ;
6
7
import net .labymod .api .configuration .loader .annotation .ConfigName ;
7
8
import net .labymod .api .configuration .loader .property .ConfigProperty ;
8
9
@@ -15,10 +16,26 @@ public class Configuration extends AddonConfig {
15
16
@ SliderSetting (min = 2 , max = 50 )
16
17
private final ConfigProperty <Integer > amount = new ConfigProperty <>(2 );
17
18
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
+
18
28
@ Override
19
29
public ConfigProperty <Boolean > enabled () {
20
30
return this .enabled ;
21
31
}
22
32
23
33
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
+
24
41
}
Original file line number Diff line number Diff line change 8
8
"amount" : {
9
9
"name" : " Amount" ,
10
10
"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"
11
23
}
12
24
}
13
25
}
Original file line number Diff line number Diff line change 1
1
rootProject.name = " antichatspam"
2
2
3
3
pluginManagement {
4
- val labyGradlePluginVersion = " 0.3.43 "
4
+ val labyGradlePluginVersion = " 0.3.44 "
5
5
plugins {
6
6
id(" net.labymod.gradle" ) version (labyGradlePluginVersion)
7
7
}
You can’t perform that action at this time.
0 commit comments