Fixed mob griefing (sheep and enderman)

This commit is contained in:
Fabrizio La Rosa 2020-07-11 14:18:53 +02:00
parent 742cd86f96
commit 4cd9212159

View File

@ -5,9 +5,11 @@ import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.permission.ListeningPermission; import com.songoda.skyblock.permission.ListeningPermission;
import com.songoda.skyblock.permission.PermissionHandler; import com.songoda.skyblock.permission.PermissionHandler;
import com.songoda.skyblock.permission.PermissionType; import com.songoda.skyblock.permission.PermissionType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.TNTPrimed;
import org.bukkit.entity.minecart.ExplosiveMinecart; import org.bukkit.entity.minecart.ExplosiveMinecart;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent;
@ -74,21 +76,11 @@ public class MobGriefingPermission extends ListeningPermission {
} }
} }
/*@PermissionHandler // TODO ? - Fabrimat @PermissionHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { public void onMobChangeBlock(EntityChangeBlockEvent event) {
Entity entity = event.getEntity(); if(event.getEntity() instanceof LivingEntity && !(event.getEntity() instanceof Player)) {
EntityType type = event.getEntityType(); event.setCancelled(true);
}
if (type == EntityType.ARMOR_STAND || type == EntityType.PLAYER || entity instanceof Monster) return; }
Player player;
if (event.getDamager() instanceof Player)
player = (Player)event.getDamager();
else if (event.getDamager() instanceof Projectile && ((Projectile) event.getDamager()).getShooter() instanceof Player)
player = (Player) ((Projectile) event.getDamager()).getShooter();
else return;
cancelAndMessage(event, player, plugin, messageManager);
}*/
} }