mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-27 04:35:46 +01:00
Fixed ArmorStand and ItemFrame that can be destroyed
This commit is contained in:
parent
92ea9f4404
commit
fc8a95d1c1
@ -16,6 +16,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -111,6 +112,13 @@ public class Entity implements Listener {
|
||||
skyblock.getPermissionManager()
|
||||
.processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation()), true);
|
||||
|
||||
} else if((event.getDamager() instanceof org.bukkit.entity.Projectile
|
||||
&& ((Projectile) event.getDamager()).getShooter() instanceof Player)
|
||||
&& (event.getEntity().getType().equals(EntityType.ARMOR_STAND)
|
||||
|| event.getEntity().getType().equals(EntityType.ITEM_FRAME))){
|
||||
Player player = (Player) ((Projectile) event.getDamager()).getShooter();
|
||||
skyblock.getPermissionManager()
|
||||
.processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation()));
|
||||
} else { // Make it work with all the entities, not just TNT
|
||||
org.bukkit.entity.Entity entity = event.getEntity();
|
||||
|
||||
|
@ -6,9 +6,8 @@ import com.songoda.skyblock.message.MessageManager;
|
||||
import com.songoda.skyblock.permission.ListeningPermission;
|
||||
import com.songoda.skyblock.permission.PermissionHandler;
|
||||
import com.songoda.skyblock.permission.PermissionType;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
@ -27,8 +26,6 @@ public class DestroyPermission extends ListeningPermission {
|
||||
|
||||
@PermissionHandler
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
|
||||
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
@ -42,13 +39,24 @@ public class DestroyPermission extends ListeningPermission {
|
||||
|
||||
@PermissionHandler
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
if (!(event.getDamager() instanceof Player)) return;
|
||||
Player player = (Player)event.getDamager();
|
||||
Entity entity = event.getEntity();
|
||||
Player player = null;
|
||||
if (event.getDamager() instanceof Player) {
|
||||
player = (Player) event.getDamager();
|
||||
}
|
||||
if(event.getDamager() instanceof Projectile && ((Projectile) event.getDamager()).getShooter() instanceof Player){
|
||||
player = (Player) ((Projectile) event.getDamager()).getShooter();
|
||||
}
|
||||
if(player != null){
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (entity.getType() != EntityType.ARMOR_STAND) return;
|
||||
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
switch (entity.getType()){
|
||||
case ARMOR_STAND:
|
||||
case PAINTING:
|
||||
case ITEM_FRAME:
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
|
Loading…
Reference in New Issue
Block a user