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/server/EntityCreeper.java b/src/main/java/net/minecraft/server/EntityCreeper.java
index ff80ac7db73b7c7dd6ac62ac128af1cab961d075..36bf307985624a3567eb1196e034470bd7002e1e 100644
--- a/src/main/java/net/minecraft/server/EntityCreeper.java
+++ b/src/main/java/net/minecraft/server/EntityCreeper.java
@@ -216,7 +216,7 @@ public class EntityCreeper extends EntityMonster {
 
     public void explode() {
         if (!this.world.isClientSide) {
-            Explosion.Effect explosion_effect = this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING) ? Explosion.Effect.DESTROY : Explosion.Effect.NONE;
+            Explosion.Effect explosion_effect = this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING) && world.purpurConfig.creeperAllowGriefing ? Explosion.Effect.DESTROY : Explosion.Effect.NONE; // Purpur
             float f = this.isPowered() ? 2.0F : 1.0F;
 
             // CraftBukkit start
diff --git a/src/main/java/net/minecraft/server/EntityEnderman.java b/src/main/java/net/minecraft/server/EntityEnderman.java
index f53525eb32a6096ae24fd23756b2169d5d39e9d4..7b175240e44b0c7eb5044d7bcaf54dac22f50f2a 100644
--- a/src/main/java/net/minecraft/server/EntityEnderman.java
+++ b/src/main/java/net/minecraft/server/EntityEnderman.java
@@ -369,6 +369,7 @@ public class EntityEnderman extends EntityMonster implements IEntityAngerable {
 
         @Override
         public boolean a() {
+            if (!enderman.world.purpurConfig.endermanAllowGriefing) return false; // Purpur
             return this.enderman.getCarried() != null ? false : (!this.enderman.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING) ? false : this.enderman.getRandom().nextInt(20) == 0);
         }
 
@@ -402,7 +403,7 @@ public class EntityEnderman extends EntityMonster implements IEntityAngerable {
 
     static class PathfinderGoalEndermanPlaceBlock extends PathfinderGoal {
 
-        private final EntityEnderman a;
+        private final EntityEnderman a; public EntityEnderman getEnderman() { return a; } // Purpur - OBFHELPER
 
         public PathfinderGoalEndermanPlaceBlock(EntityEnderman entityenderman) {
             this.a = entityenderman;
@@ -410,6 +411,7 @@ public class EntityEnderman extends EntityMonster implements IEntityAngerable {
 
         @Override
         public boolean a() {
+            if (!getEnderman().world.purpurConfig.endermanAllowGriefing) return false; // Purpur
             return this.a.getCarried() == null ? false : (!this.a.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING) ? false : this.a.getRandom().nextInt(2000) == 0);
         }
 
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 4a0bbc0cd41b4a50ebad9b4569e07d727fc3e482..236b4f51ea805c671b905c1b081538b67cee7f57 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -191,8 +191,10 @@ public class PurpurWorldConfig {
         cowFeedMushrooms = getInt("mobs.cow.feed-mushrooms-for-mooshroom", cowFeedMushrooms);
     }
 
+    public boolean creeperAllowGriefing = true;
     public double creeperChargedChance = 0.0D;
     private void creeperSettings() {
+        creeperAllowGriefing = getBoolean("mobs.creeper.allow-griefing", creeperAllowGriefing);
         creeperChargedChance = getDouble("mobs.creeper.naturally-charged-chance", creeperChargedChance);
     }
 
@@ -201,6 +203,11 @@ public class PurpurWorldConfig {
         enderDragonAlwaysDropsFullExp = getBoolean("mobs.ender_dragon.always-drop-full-exp", enderDragonAlwaysDropsFullExp);
     }
 
+    public boolean endermanAllowGriefing = true;
+    private void endermanSettings() {
+        endermanAllowGriefing = getBoolean("mobs.enderman.allow-griefing", endermanAllowGriefing);
+    }
+
     public boolean foxTypeChangesWithTulips = false;
     private void foxSettings() {
         foxTypeChangesWithTulips = getBoolean("mobs.fox.tulips-change-type", foxTypeChangesWithTulips);
