Skip to content

Add wind charge explosion protect config #6183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Essentials/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ change-tab-complete-name: false
#add-prefix-in-playerlist: true

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

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

# Chat formatting can be configured in two ways:
# Chat formatting can be configured in two ways:
# - A standard format for all chat ('format' section)
# - Group-specific chat formats for extra variation ('group-formats' section)
#
Expand Down Expand Up @@ -1027,6 +1027,7 @@ protect:
fireball-fire: false
fireball-playerdamage: false
fireball-itemdamage: false
windcharge-explosion: false
witherskull-explosion: false
witherskull-playerdamage: false
witherskull-itemdamage: false
Expand Down Expand Up @@ -1256,7 +1257,7 @@ random-respawn-location: "none"
spawn-on-join: false
# The following value of 'guests' states that all players in the 'guests' group will be teleported to spawn when joining.
#spawn-on-join: guests
# The following list value states that all players in the 'guests' or 'admin' groups will be teleported to spawn when joining.
# The following list value states that all players in the 'guests' or 'admin' groups will be teleported to spawn when joining.
#spawn-on-join:
# - guests
# - admin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ private void initialize(final PluginManager pm, final Plugin essPlugin) {
pm.registerEvents(blockListener_1_16_r1, this);
}

if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_21_3_R01)){
final EssentialsProtectEntityListener_1_21_3_R1 entityListener_1_21_3_r1 = new EssentialsProtectEntityListener_1_21_3_R1(this);
pm.registerEvents(entityListener_1_21_3_r1, this);
}

final EssentialsProtectWeatherListener weatherListener = new EssentialsProtectWeatherListener(this);
pm.registerEvents(weatherListener, this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void onEntityExplode(final EntityExplodeEvent event) {
} else if (entity instanceof TNTPrimed && prot.getSettingBool(ProtectConfig.prevent_tnt_explosion)) {
event.setCancelled(true);

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

} else if ((entity instanceof WitherSkull) && prot.getSettingBool(ProtectConfig.prevent_witherskull_explosion)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.earth2me.essentials.protect;

import org.bukkit.entity.Entity;
import org.bukkit.entity.WindCharge;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;

public class EssentialsProtectEntityListener_1_21_3_R1 implements Listener {
private final IProtect prot;

EssentialsProtectEntityListener_1_21_3_R1(final IProtect prot) {
this.prot = prot;
}

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityExplode(final EntityExplodeEvent event) {
final Entity entity = event.getEntity();

if (entity instanceof WindCharge && prot.getSettingBool(ProtectConfig.prevent_windcharge_explosion)) {
event.setCancelled(true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public enum ProtectConfig {
prevent_fireball_fire("protect.prevent.fireball-fire", false),
prevent_fireball_playerdmg("protect.prevent.fireball-playerdamage", false),
prevent_fireball_itemdmg("protect.prevent.fireball-itemdamage", false),
prevent_windcharge_explosion("protect.prevent.windcharge-explosion", false),
prevent_witherskull_explosion("protect.prevent.witherskull-explosion", false),
prevent_witherskull_playerdmg("protect.prevent.witherskull-playerdamage", false),
prevent_witherskull_itemdmg("protect.prevent.witherskull-itemdamage", false),
Expand Down
Loading