File tree Expand file tree Collapse file tree 6 files changed +73
-1
lines changed
src/main/java/com/eternalcode/core
configuration/implementation Expand file tree Collapse file tree 6 files changed +73
-1
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,8 @@ object Versions {
34
34
35
35
const val TRIUMPH_GUI = " 3.1.12"
36
36
37
+ const val XSERIES = " 13.3.3"
38
+
37
39
const val BSTATS = " 3.1.0"
38
40
39
41
const val CAFFEINE = " 3.2.2"
Original file line number Diff line number Diff line change @@ -49,6 +49,12 @@ eternalShadow {
49
49
" com.eternalcode.multification" ,
50
50
)
51
51
52
+ // XSeries
53
+ library(" com.github.cryptomorin:XSeries:${Versions .XSERIES } " )
54
+ libraryRelocate(
55
+ " com.cryptomorin.xseries" ,
56
+ )
57
+
52
58
// EternalCode Commons & GitCheck
53
59
library(" com.eternalcode:eternalcode-commons-bukkit:${Versions .ETERNALCODE_COMMONS } " )
54
60
library(" com.eternalcode:eternalcode-commons-adventure:${Versions .ETERNALCODE_COMMONS } " )
Original file line number Diff line number Diff line change 6
6
import com .eternalcode .core .feature .automessage .AutoMessageSettings ;
7
7
import com .eternalcode .core .feature .catboy .CatBoySettings ;
8
8
import com .eternalcode .core .feature .chat .ChatSettings ;
9
+ import com .eternalcode .core .feature .heal .HealConfiguration ;
9
10
import com .eternalcode .core .feature .helpop .HelpOpSettings ;
10
11
import com .eternalcode .core .feature .jail .JailSettings ;
11
12
import com .eternalcode .core .feature .randomteleport .RandomTeleportSettingsImpl ;
@@ -154,6 +155,10 @@ public static class Homes {
154
155
};
155
156
}
156
157
158
+ @ Bean
159
+ @ Description ({ " " , "# Settings controlling how player healing works and which potion effects get cleared" })
160
+ public HealConfiguration heal = new HealConfiguration ();
161
+
157
162
@ Description ({ " " , "# Awesome sounds" })
158
163
public Sounds sound = new Sounds ();
159
164
Original file line number Diff line number Diff line change 1
1
package com .eternalcode .core .feature .heal ;
2
2
3
3
import com .eternalcode .annotations .scan .command .DescriptionDocs ;
4
+ import com .eternalcode .core .configuration .implementation .PluginConfiguration ;
4
5
import com .eternalcode .core .injector .annotations .Inject ;
5
6
import com .eternalcode .core .notice .NoticeService ;
7
+ import com .eternalcode .core .util .PotionEffectUtil ;
6
8
import com .eternalcode .core .viewer .Viewer ;
7
9
import dev .rollczi .litecommands .annotations .argument .Arg ;
8
10
import dev .rollczi .litecommands .annotations .command .Command ;
16
18
class HealCommand {
17
19
18
20
private final NoticeService noticeService ;
21
+ private final HealConfiguration healConfiguration ;
19
22
20
23
@ Inject
21
- HealCommand (NoticeService noticeService ) {
24
+ HealCommand (NoticeService noticeService , PluginConfiguration pluginConfiguration ) {
22
25
this .noticeService = noticeService ;
26
+ this .healConfiguration = pluginConfiguration .heal ;
23
27
}
24
28
25
29
@ Execute
@@ -65,6 +69,11 @@ private void heal(Player player) {
65
69
player .setRemainingAir (player .getMaximumAir ());
66
70
67
71
for (PotionEffect effect : player .getActivePotionEffects ()) {
72
+ if (healConfiguration .removeOnlyNegativeEffects ) {
73
+ if (!PotionEffectUtil .isNegativeEffect (effect .getType ())) {
74
+ continue ;
75
+ }
76
+ }
68
77
player .removePotionEffect (effect .getType ());
69
78
}
70
79
}
Original file line number Diff line number Diff line change
1
+ package com .eternalcode .core .feature .heal ;
2
+
3
+ import net .dzikoysk .cdn .entity .Contextual ;
4
+ import net .dzikoysk .cdn .entity .Description ;
5
+
6
+ @ Contextual
7
+ public class HealConfiguration {
8
+
9
+ @ Description ({
10
+ "If true, only negative potion effects will be removed on heal" ,
11
+ "If false, all potion effects will be removed on heal"
12
+ })
13
+ public boolean removeOnlyNegativeEffects = true ;
14
+ }
Original file line number Diff line number Diff line change
1
+ package com .eternalcode .core .util ;
2
+
3
+ import com .cryptomorin .xseries .XPotion ;
4
+ import com .cryptomorin .xseries .XTag ;
5
+ import org .bukkit .potion .PotionEffectType ;
6
+
7
+ /**
8
+ * XSeries is controversial, but it provides long-term mappings
9
+ * that support multiple Minecraft versions reliably.
10
+ * <p>
11
+ * This utility uses XPotion from XSeries to detect negative potion effects (debuffs).
12
+ * It helps keep compatibility and simplifies effect management across versions.
13
+ * <p>
14
+ * <u>Important:</u> Because potion effect names have changed between Minecraft versions
15
+ * from 1.17.1 (our support target) up to 1.21.7 (and later),
16
+ * I decided to use XSeries to handle these naming differences consistently.
17
+ * <p>
18
+ * This special utility class was created to avoid overusing XSeries directly
19
+ * throughout the codebase and to isolate its usage in one dedicated place.
20
+ */
21
+ public final class PotionEffectUtil {
22
+
23
+ public PotionEffectUtil () {
24
+ throw new UnsupportedOperationException ("This is a utility class and cannot be instantiated" );
25
+ }
26
+
27
+ public static boolean isNegativeEffect (PotionEffectType effectType ) {
28
+ if (effectType == null ) {
29
+ return false ;
30
+ }
31
+
32
+ XPotion xpotion = XPotion .of (effectType );
33
+
34
+ return XTag .DEBUFFS .isTagged (xpotion );
35
+ }
36
+ }
You can’t perform that action at this time.
0 commit comments