From fa2f79239ed3b4db9f18ebd5070add7dc21a27bc Mon Sep 17 00:00:00 2001 From: ZeroHD Date: Wed, 21 Jul 2021 00:20:25 +0000 Subject: [PATCH] Add Config To Disable Enderman Grief (#14) Added default config value Bumped version number Add config for disabling enderman grief Co-authored-by: Joey Hines Reviewed-on: https://git.canopymc.net/Canopy/QoL/pulls/14 Reviewed-by: Etzelia Co-Authored-By: ZeroHD Co-Committed-By: ZeroHD --- pom.xml | 2 +- src/main/java/xyz/etztech/qol/QoL.java | 1 + .../listeners/EntityChangeBlockListener.java | 26 +++++++++++++++++++ src/main/resources/config.yml | 3 +++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/main/java/xyz/etztech/qol/listeners/EntityChangeBlockListener.java diff --git a/pom.xml b/pom.xml index 5e8b769..84a0e37 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ xyz.etztech QoL - 1.12 + 1.13 jar diff --git a/src/main/java/xyz/etztech/qol/QoL.java b/src/main/java/xyz/etztech/qol/QoL.java index e1ee728..e841f54 100644 --- a/src/main/java/xyz/etztech/qol/QoL.java +++ b/src/main/java/xyz/etztech/qol/QoL.java @@ -104,6 +104,7 @@ public class QoL extends JavaPlugin { new BlockIgniteListener(this); new CommandPreprocessListener(this); new DeathListener(this); + new EntityChangeBlockListener(this); // Add commands new MainCommand(this); diff --git a/src/main/java/xyz/etztech/qol/listeners/EntityChangeBlockListener.java b/src/main/java/xyz/etztech/qol/listeners/EntityChangeBlockListener.java new file mode 100644 index 0000000..cd99c11 --- /dev/null +++ b/src/main/java/xyz/etztech/qol/listeners/EntityChangeBlockListener.java @@ -0,0 +1,26 @@ +package xyz.etztech.qol.listeners; + +import org.bukkit.entity.EntityType; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import xyz.etztech.qol.QoL; + +public class EntityChangeBlockListener implements Listener { + QoL plugin; + + public EntityChangeBlockListener(QoL plugin) { + this.plugin = plugin; + plugin.getServer().getPluginManager().registerEvents(this, plugin); + } + + @EventHandler + public void onEntityChangeBlock(EntityChangeBlockEvent e) { + if (e.getEntity().getType() == EntityType.ENDERMAN) { + if(plugin.getConfig().getBoolean("disable-mob-grief.enderman", false)){ + e.setCancelled(true); + } + } + + } +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 102a360..4c297df 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -93,6 +93,9 @@ disable-fire: ender_crystal: false explosion: false +disable-mob-grief: + enderman: false + # A list of commands to confirm before using if the user isn't in spectator mode spec-confirm: - "tp"