From 432d4b2d8c12804116b2cbf532ab986f0c636063 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Mon, 13 Jul 2020 18:57:22 +0200 Subject: [PATCH] Added IronGolems settings --- .../permission/PermissionManager.java | 1 + .../listening/IronGolemPermission.java | 36 +++++++++++++++++++ .../listening/MobGriefingPermission.java | 12 ++++--- src/main/resources/language.yml | 4 +++ src/main/resources/settings.yml | 1 + 5 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/songoda/skyblock/permission/permissions/listening/IronGolemPermission.java diff --git a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java index da139af3..8ffc6ca6 100644 --- a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java +++ b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java @@ -83,6 +83,7 @@ public class PermissionManager { new ItemDropPermission(), new FishingPermission(plugin), new CauldronPermission(plugin), + new IronGolemPermission(plugin), // Basic new MemberPermission(), diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/IronGolemPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/IronGolemPermission.java new file mode 100644 index 00000000..36bde502 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/IronGolemPermission.java @@ -0,0 +1,36 @@ +package com.songoda.skyblock.permission.permissions.listening; + +import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.permission.ListeningPermission; +import com.songoda.skyblock.permission.PermissionHandler; +import com.songoda.skyblock.permission.PermissionType; +import org.bukkit.entity.IronGolem; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.entity.minecart.ExplosiveMinecart; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.hanging.HangingBreakByEntityEvent; +import org.bukkit.event.vehicle.VehicleDamageEvent; +import org.bukkit.event.vehicle.VehicleDestroyEvent; + +public class IronGolemPermission extends ListeningPermission { + + private final SkyBlock plugin; + + public IronGolemPermission(SkyBlock plugin) { + super("IronGolems", CompatibleMaterial.IRON_BLOCK, PermissionType.ISLAND); + this.plugin = plugin; + } + + @PermissionHandler + public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { + if (event.getDamager() instanceof IronGolem) { + event.setCancelled(true); + } + } +} + diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java index 55e88cf0..f8497c44 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/MobGriefingPermission.java @@ -5,6 +5,7 @@ import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionType; +import org.bukkit.entity.IronGolem; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; @@ -29,7 +30,7 @@ public class MobGriefingPermission extends ListeningPermission { public void onEntityExplode(EntityExplodeEvent event) { if (!(event.getEntity() instanceof Player) && (!(event.getEntity() instanceof org.bukkit.entity.Projectile) - || !(((org.bukkit.entity.Projectile) event.getEntity()).getShooter() instanceof Player)) + || !(((org.bukkit.entity.Projectile) event.getEntity()).getShooter() instanceof Player)) && !(event.getEntity() instanceof TNTPrimed) && !(event.getEntity() instanceof ExplosiveMinecart)) { event.setCancelled(true); @@ -40,7 +41,7 @@ public class MobGriefingPermission extends ListeningPermission { public void onVehicleDamage(VehicleDamageEvent event) { if (!(event.getAttacker() instanceof Player) && (!(event.getAttacker() instanceof org.bukkit.entity.Projectile) - || !(((org.bukkit.entity.Projectile) event.getAttacker()).getShooter() instanceof Player)) + || !(((org.bukkit.entity.Projectile) event.getAttacker()).getShooter() instanceof Player)) && !(event.getAttacker() instanceof TNTPrimed) && !(event.getAttacker() instanceof ExplosiveMinecart)) { event.setCancelled(true); @@ -51,7 +52,7 @@ public class MobGriefingPermission extends ListeningPermission { public void onVehicleDestroy(VehicleDestroyEvent event) { if (!(event.getAttacker() instanceof Player) && (!(event.getAttacker() instanceof org.bukkit.entity.Projectile) - || !(((org.bukkit.entity.Projectile) event.getAttacker()).getShooter() instanceof Player)) + || !(((org.bukkit.entity.Projectile) event.getAttacker()).getShooter() instanceof Player)) && !(event.getAttacker() instanceof TNTPrimed) && !(event.getAttacker() instanceof ExplosiveMinecart)) { event.setCancelled(true); @@ -62,9 +63,10 @@ public class MobGriefingPermission extends ListeningPermission { public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { if (!(event.getDamager() instanceof Player) && (!(event.getDamager() instanceof org.bukkit.entity.Projectile) - || !(((org.bukkit.entity.Projectile) event.getDamager()).getShooter() instanceof Player)) + || !(((org.bukkit.entity.Projectile) event.getDamager()).getShooter() instanceof Player)) && !(event.getDamager() instanceof TNTPrimed) - && !(event.getDamager() instanceof ExplosiveMinecart)) { + && !(event.getDamager() instanceof ExplosiveMinecart) + && !(event.getDamager() instanceof IronGolem)) { event.setCancelled(true); } } diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index 6cf4d6ff..b98a1332 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -1323,6 +1323,8 @@ Menu: Displayname: '&aLeaf Decay' MobGriefing: Displayname: '&aMob Griefing' + IronGolems: + Displayname: '&aIron Golems' Status: Enabled: Lore: @@ -1793,6 +1795,8 @@ Menu: Displayname: '&aNatural Mob Spawning' MobGriefing: Displayname: '&aMob Griefing' + IronGolems: + Displayname: '&aIron Golems' PvP: Displayname: '&aPvP' Explosions: diff --git a/src/main/resources/settings.yml b/src/main/resources/settings.yml index 0e50ae85..f32380de 100644 --- a/src/main/resources/settings.yml +++ b/src/main/resources/settings.yml @@ -167,6 +167,7 @@ Settings: Owner: NaturalMobSpawning: true MobGriefing: true + IronGolems: true Explosions: true FireSpread: true LeafDecay: true