From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Sun, 26 Apr 2020 16:28:38 -0500
Subject: [PATCH] Add enderman and creeper griefing controls


diff --git a/src/main/java/net/minecraft/world/entity/monster/Creeper.java b/src/main/java/net/minecraft/world/entity/monster/Creeper.java
index b2b3630a90c685b0a692efb9bf8bb111e321c9d1..c7554c6c1a1787d976ad1fe0c78d86562464947e 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Creeper.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Creeper.java
@@ -340,7 +340,7 @@ public class Creeper extends Monster implements PowerableMob {
 
     public void explodeCreeper() {
         if (!this.level.isClientSide) {
-            Explosion.BlockInteraction explosion_effect = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE;
+            Explosion.BlockInteraction explosion_effect = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && level.purpurConfig.creeperAllowGriefing ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE; // Purpur
             float f = this.isPowered() ? 2.0F : 1.0F;
 
             // CraftBukkit start
diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
index b92a83cfd15cedf7cd68c26193e65c5f24d9a621..a36313c321f9057350a9edb8b0959fd49a8e21a3 100644
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
@@ -480,6 +480,7 @@ public class EnderMan extends Monster implements NeutralMob {
 
         @Override
         public boolean canUse() {
+            if (!enderman.level.purpurConfig.endermanAllowGriefing) return false; // Purpur
             return this.enderman.getCarriedBlock() == null ? false : (!this.enderman.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? false : this.enderman.getRandom().nextInt(2000) == 0);
         }
 
@@ -527,6 +528,7 @@ public class EnderMan extends Monster implements NeutralMob {
 
         @Override
         public boolean canUse() {
+            if (!enderman.level.purpurConfig.endermanAllowGriefing) return false; // Purpur
             return this.enderman.getCarriedBlock() != null ? false : (!this.enderman.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) ? false : this.enderman.getRandom().nextInt(20) == 0);
         }
 
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 12df67056e742916b9638ee1fce6f8b7dab2b3f2..b94165c34e4c809e3686253beae26c05c7c3a181 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -381,6 +381,7 @@ public class PurpurWorldConfig {
     public boolean creeperRidableInWater = false;
     public double creeperMaxHealth = 20.0D;
     public double creeperChargedChance = 0.0D;
+    public boolean creeperAllowGriefing = true;
     private void creeperSettings() {
         creeperRidable = getBoolean("mobs.creeper.ridable", creeperRidable);
         creeperRidableInWater = getBoolean("mobs.creeper.ridable-in-water", creeperRidableInWater);
@@ -391,6 +392,7 @@ public class PurpurWorldConfig {
         }
         creeperMaxHealth = getDouble("mobs.creeper.attributes.max_health", creeperMaxHealth);
         creeperChargedChance = getDouble("mobs.creeper.naturally-charged-chance", creeperChargedChance);
+        creeperAllowGriefing = getBoolean("mobs.creeper.allow-griefing", creeperAllowGriefing);
     }
 
     public boolean dolphinRidable = false;
@@ -488,6 +490,7 @@ public class PurpurWorldConfig {
     public boolean endermanRidable = false;
     public boolean endermanRidableInWater = false;
     public double endermanMaxHealth = 40.0D;
+    public boolean endermanAllowGriefing = true;
     private void endermanSettings() {
         endermanRidable = getBoolean("mobs.enderman.ridable", endermanRidable);
         endermanRidableInWater = getBoolean("mobs.enderman.ridable-in-water", endermanRidableInWater);
@@ -497,6 +500,7 @@ public class PurpurWorldConfig {
             set("mobs.enderman.attributes.max_health", oldValue);
         }
         endermanMaxHealth = getDouble("mobs.enderman.attributes.max_health", endermanMaxHealth);
+        endermanAllowGriefing = getBoolean("mobs.enderman.allow-griefing", endermanAllowGriefing);
     }
 
     public boolean endermiteRidable = false;
