Skip to content

Commit 74337ff

Browse files
authored
Add wind charge explosion protect config (#6183)
Adds new protect config to cancel the knockback effect from windcharges ```yml protect: # General physics/behavior modifications. Set these to true to disable behaviors. prevent: windcharge-explosion: false ``` Closes #6181
1 parent b36d433 commit 74337ff

5 files changed

Lines changed: 37 additions & 5 deletions

File tree

Essentials/src/main/resources/config.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ change-tab-complete-name: false
7878
#add-prefix-in-playerlist: true
7979

8080
# When this option is enabled, player suffixes will be shown in the (tab) player list.
81-
# This feature only works for Minecraft version 1.8 and higher.
81+
# This feature only works for Minecraft version 1.8 and higher.
8282
# The value of 'change-playerlist' above must be true.
8383
#add-suffix-in-playerlist: true
8484

@@ -566,7 +566,7 @@ custom-quit-message: "none"
566566
# Set this to "none" to use the 'custom-join-message' setting for every join.
567567
#
568568
# Available placeholders:
569-
# {PLAYER} - The player's display name.
569+
# {PLAYER} - The player's display name.
570570
# {USERNAME} - The player's username.
571571
# {OLDUSERNAME} - The player's old username.
572572
# {PREFIX} - The player's prefix.
@@ -923,7 +923,7 @@ chat:
923923
# You can add command costs for shout/question by adding 'chat-shout' and 'chat-question' to the 'command-costs' section above.
924924
radius: 0
925925

926-
# Chat formatting can be configured in two ways:
926+
# Chat formatting can be configured in two ways:
927927
# - A standard format for all chat ('format' section)
928928
# - Group-specific chat formats for extra variation ('group-formats' section)
929929
#
@@ -1027,6 +1027,7 @@ protect:
10271027
fireball-fire: false
10281028
fireball-playerdamage: false
10291029
fireball-itemdamage: false
1030+
windcharge-explosion: false
10301031
witherskull-explosion: false
10311032
witherskull-playerdamage: false
10321033
witherskull-itemdamage: false
@@ -1256,7 +1257,7 @@ random-respawn-location: "none"
12561257
spawn-on-join: false
12571258
# The following value of 'guests' states that all players in the 'guests' group will be teleported to spawn when joining.
12581259
#spawn-on-join: guests
1259-
# The following list value states that all players in the 'guests' or 'admin' groups will be teleported to spawn when joining.
1260+
# The following list value states that all players in the 'guests' or 'admin' groups will be teleported to spawn when joining.
12601261
#spawn-on-join:
12611262
# - guests
12621263
# - admin

EssentialsProtect/src/main/java/com/earth2me/essentials/protect/EssentialsProtect.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ private void initialize(final PluginManager pm, final Plugin essPlugin) {
6464
pm.registerEvents(blockListener_1_16_r1, this);
6565
}
6666

67+
if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_21_3_R01)){
68+
final EssentialsProtectEntityListener_1_21_3_R1 entityListener_1_21_3_r1 = new EssentialsProtectEntityListener_1_21_3_R1(this);
69+
pm.registerEvents(entityListener_1_21_3_r1, this);
70+
}
71+
6772
final EssentialsProtectWeatherListener weatherListener = new EssentialsProtectWeatherListener(this);
6873
pm.registerEvents(weatherListener, this);
6974
}

EssentialsProtect/src/main/java/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public void onEntityExplode(final EntityExplodeEvent event) {
180180
} else if (entity instanceof TNTPrimed && prot.getSettingBool(ProtectConfig.prevent_tnt_explosion)) {
181181
event.setCancelled(true);
182182

183-
} else if (entity instanceof Fireball && prot.getSettingBool(ProtectConfig.prevent_fireball_explosion)) {
183+
} else if (entity instanceof Fireball && !entity.getClass().getSimpleName().equals("CraftWindCharge") && prot.getSettingBool(ProtectConfig.prevent_fireball_explosion)) {
184184
event.setCancelled(true);
185185

186186
} else if ((entity instanceof WitherSkull) && prot.getSettingBool(ProtectConfig.prevent_witherskull_explosion)) {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.earth2me.essentials.protect;
2+
3+
import org.bukkit.entity.Entity;
4+
import org.bukkit.entity.WindCharge;
5+
import org.bukkit.event.EventHandler;
6+
import org.bukkit.event.EventPriority;
7+
import org.bukkit.event.Listener;
8+
import org.bukkit.event.entity.EntityExplodeEvent;
9+
10+
public class EssentialsProtectEntityListener_1_21_3_R1 implements Listener {
11+
private final IProtect prot;
12+
13+
EssentialsProtectEntityListener_1_21_3_R1(final IProtect prot) {
14+
this.prot = prot;
15+
}
16+
17+
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
18+
public void onEntityExplode(final EntityExplodeEvent event) {
19+
final Entity entity = event.getEntity();
20+
21+
if (entity instanceof WindCharge && prot.getSettingBool(ProtectConfig.prevent_windcharge_explosion)) {
22+
event.setCancelled(true);
23+
}
24+
}
25+
}

EssentialsProtect/src/main/java/com/earth2me/essentials/protect/ProtectConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public enum ProtectConfig {
3434
prevent_fireball_fire("protect.prevent.fireball-fire", false),
3535
prevent_fireball_playerdmg("protect.prevent.fireball-playerdamage", false),
3636
prevent_fireball_itemdmg("protect.prevent.fireball-itemdamage", false),
37+
prevent_windcharge_explosion("protect.prevent.windcharge-explosion", false),
3738
prevent_witherskull_explosion("protect.prevent.witherskull-explosion", false),
3839
prevent_witherskull_playerdmg("protect.prevent.witherskull-playerdamage", false),
3940
prevent_witherskull_itemdmg("protect.prevent.witherskull-itemdamage", false),

0 commit comments

Comments
 (0)