Added ProtectorDamage setting

This commit is contained in:
Fabrizio La Rosa 2020-07-28 23:47:14 +02:00
parent 959d52a431
commit 93ae6fd494
5 changed files with 45 additions and 8 deletions

View File

@ -83,6 +83,7 @@ public class PermissionManager {
new ItemDropPermission(),
new FishingPermission(plugin),
new CauldronPermission(plugin),
new ProtectorDamagePermission(plugin),
// Basic
new MemberPermission(),

View File

@ -5,9 +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.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.entity.*;
import org.bukkit.entity.minecart.ExplosiveMinecart;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -29,7 +27,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 +38,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 +49,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 +60,13 @@ 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.getDamager() instanceof Snowman)
&& !(event.getDamager() instanceof Wolf &&
((Wolf) event.getDamager()).isTamed())) {
event.setCancelled(true);
}
}

View File

@ -0,0 +1,29 @@
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.*;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
public class ProtectorDamagePermission extends ListeningPermission {
private final SkyBlock plugin;
public ProtectorDamagePermission(SkyBlock plugin) {
super("ProtectorDamagePermission", CompatibleMaterial.CARVED_PUMPKIN, PermissionType.ISLAND);
this.plugin = plugin;
}
@PermissionHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
if(event.getDamager() instanceof IronGolem ||
event.getDamager() instanceof Snowman ||
(event.getDamager() instanceof Wolf &&
((Wolf) event.getDamager()).isTamed())) {
event.setCancelled(true);
}
}
}

View File

@ -1323,6 +1323,8 @@ Menu:
Displayname: '&aLeaf Decay'
MobGriefing:
Displayname: '&aMob Griefing'
ProtectorDamage:
Displayname: '&aProtector damage'
Status:
Enabled:
Lore:
@ -1793,6 +1795,8 @@ Menu:
Displayname: '&aNatural Mob Spawning'
MobGriefing:
Displayname: '&aMob Griefing'
ProtectorDamage:
Displayname: '&aProtector Damage'
PvP:
Displayname: '&aPvP'
Explosions:

View File

@ -168,6 +168,7 @@ Settings:
NaturalMobSpawning: true
MobGriefing: true
Explosions: true
ProtectorDamage: true
FireSpread: true
LeafDecay: true
KeepItemsOnDeath: false