mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-23 18:55:30 +01:00
Changed Explosion setting to Island and fixed explosion and mobgrief settings
This commit is contained in:
parent
8514c0233e
commit
a186206d00
@ -27,6 +27,8 @@ import org.bukkit.event.hanging.HangingBreakEvent;
|
||||
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
|
||||
import org.bukkit.event.player.PlayerShearEntityEvent;
|
||||
import org.bukkit.event.vehicle.VehicleDamageEvent;
|
||||
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@ -109,7 +111,7 @@ public class Entity implements Listener {
|
||||
skyblock.getPermissionManager()
|
||||
.processPermission(event, player, islandManager.getIslandAtLocation(player.getLocation()));
|
||||
|
||||
} else if (event.getDamager() instanceof TNTPrimed) {
|
||||
} else { // Make it work with all the entities, not just TNT
|
||||
org.bukkit.entity.Entity entity = event.getEntity();
|
||||
|
||||
// Check permissions.
|
||||
@ -217,6 +219,7 @@ public class Entity implements Listener {
|
||||
@EventHandler
|
||||
public void onHangingBreak(HangingBreakEvent event) {
|
||||
Hanging hanging = event.getEntity();
|
||||
|
||||
if (!skyblock.getWorldManager().isIslandWorld(hanging.getWorld())) return;
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
|
||||
@ -229,14 +232,15 @@ public class Entity implements Listener {
|
||||
public void onHangingBreak(HangingBreakByEntityEvent event) {
|
||||
Hanging hanging = event.getEntity();
|
||||
|
||||
if (!(event.getRemover() instanceof Player))
|
||||
return;
|
||||
|
||||
if (!skyblock.getWorldManager().isIslandWorld(hanging.getWorld())) return;
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
|
||||
Player p = null;
|
||||
if(event.getRemover() instanceof Player){
|
||||
p = (Player) event.getRemover();
|
||||
}
|
||||
// Check permissions.
|
||||
skyblock.getPermissionManager().processPermission(event, (Player) event.getRemover(),
|
||||
skyblock.getPermissionManager().processPermission(event, p,
|
||||
islandManager.getIslandAtLocation(hanging.getLocation()));
|
||||
}
|
||||
|
||||
@ -322,9 +326,11 @@ public class Entity implements Listener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check permissions.
|
||||
skyblock.getPermissionManager().processPermission(event, null, island);
|
||||
|
||||
|
||||
if (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Block.Level.Enable"))
|
||||
return;
|
||||
@ -373,10 +379,10 @@ public class Entity implements Listener {
|
||||
if (skyblock.getWorldManager().isIslandWorld(entity.getWorld())) {
|
||||
// Check permissions.
|
||||
Island island = islandManager.getIslandAtLocation(entity.getLocation());
|
||||
|
||||
skyblock.getPermissionManager().processPermission(event, null, island);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
|
||||
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
|
||||
.getBoolean("Island.Block.Level.Enable")) {
|
||||
for (org.bukkit.block.Block blockList : event.blockList()) {
|
||||
@ -563,6 +569,22 @@ public class Entity implements Listener {
|
||||
event.setCancelled(true); // For other plugin API reasons.
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDamageVehicle(VehicleDamageEvent event) {
|
||||
if (!(event.getAttacker() instanceof Player)) {
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
skyblock.getPermissionManager().processPermission(event, null, islandManager.getIslandAtLocation(event.getVehicle().getLocation()));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDestroyVehicle(VehicleDestroyEvent event) {
|
||||
if (!(event.getAttacker() instanceof Player)) {
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
skyblock.getPermissionManager().processPermission(event, null, islandManager.getIslandAtLocation(event.getVehicle().getLocation()));
|
||||
}
|
||||
}
|
||||
|
||||
private static SpawnReason getSpawnReason(String reason) {
|
||||
try {
|
||||
return SpawnReason.valueOf(reason);
|
||||
|
@ -1,53 +1,89 @@
|
||||
package com.songoda.skyblock.permission.permissions.listening;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.CompatibleSound;
|
||||
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.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
||||
import org.bukkit.event.block.BlockExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.vehicle.VehicleDamageEvent;
|
||||
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
||||
|
||||
public class ExplosionsPermission extends ListeningPermission {
|
||||
|
||||
private SkyBlock plugin;
|
||||
|
||||
public ExplosionsPermission(SkyBlock plugin) {
|
||||
super("Explosions", CompatibleMaterial.GUNPOWDER, PermissionType.GENERIC);
|
||||
super("Explosions", CompatibleMaterial.GUNPOWDER, PermissionType.ISLAND);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
public void onBlockExplode(BlockExplodeEvent event) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (event.getDamager() instanceof TNTPrimed)
|
||||
@PermissionHandler
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onVehicleDamage(VehicleDamageEvent event) {
|
||||
if (event.getAttacker() instanceof TNTPrimed
|
||||
|| event.getAttacker() instanceof ExplosiveMinecart
|
||||
|| event.getAttacker() instanceof Creeper)
|
||||
event.setCancelled(true);
|
||||
if (entity.getType() == EntityType.PLAYER
|
||||
&& event.getDamager() instanceof TNTPrimed)
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onVehicleDestroy(VehicleDestroyEvent event) {
|
||||
if (event.getAttacker() instanceof TNTPrimed
|
||||
|| event.getAttacker() instanceof ExplosiveMinecart
|
||||
|| event.getAttacker() instanceof Creeper)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
if (event.getCause().equals(EntityDamageEvent.DamageCause.ENTITY_EXPLOSION)
|
||||
|| event.getCause().equals(EntityDamageEvent.DamageCause.BLOCK_EXPLOSION)
|
||||
|| event.getDamager() instanceof TNTPrimed
|
||||
|| event.getDamager() instanceof ExplosiveMinecart
|
||||
|| event.getDamager() instanceof Creeper)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onHangingBreak(HangingBreakEvent event) {
|
||||
if (event.getCause() != HangingBreakEvent.RemoveCause.EXPLOSION)
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
if (event.getCause().equals(HangingBreakEvent.RemoveCause.EXPLOSION)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onBlockInteract(PlayerInteractEvent event) {
|
||||
if (CompatibleMaterial.getMaterial(event.getPlayer().getItemInHand()) != CompatibleMaterial.FLINT_AND_STEEL)
|
||||
return;
|
||||
public void onHangingBreak(HangingBreakByEntityEvent event) {
|
||||
if(event.getCause().equals(HangingBreakEvent.RemoveCause.EXPLOSION)){
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
CompatibleMaterial material = CompatibleMaterial.getMaterial(event.getClickedBlock());
|
||||
if (material == CompatibleMaterial.TNT)
|
||||
@PermissionHandler
|
||||
public void onTNTInteract(PlayerInteractEvent event) {
|
||||
if(event.getItem().getType().equals(CompatibleMaterial.FLINT_AND_STEEL.getMaterial())
|
||||
&& event.getClickedBlock().getType().equals(CompatibleMaterial.TNT.getBlockMaterial())){
|
||||
cancelAndMessage(event, event.getPlayer(), plugin, plugin.getMessageManager());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,43 +2,79 @@ package com.songoda.skyblock.permission.permissions.listening;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.skyblock.SkyBlock;
|
||||
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.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
||||
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 MobGriefingPermission extends ListeningPermission {
|
||||
|
||||
private final SkyBlock plugin;
|
||||
private final MessageManager messageManager;
|
||||
|
||||
public MobGriefingPermission(SkyBlock plugin) {
|
||||
super("MobGriefing", CompatibleMaterial.IRON_SHOVEL, PermissionType.ISLAND);
|
||||
this.plugin = plugin;
|
||||
this.messageManager = plugin.getMessageManager();
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
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))
|
||||
&& !(event.getEntity() instanceof TNTPrimed)
|
||||
&& !(event.getEntity() instanceof ExplosiveMinecart)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onVehicleDamage(VehicleDamageEvent event) {
|
||||
|
||||
|
||||
Player player = (Player) event.getAttacker();
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
if (!(event.getAttacker() instanceof Player)
|
||||
&& (!(event.getAttacker() instanceof org.bukkit.entity.Projectile)
|
||||
|| !(((org.bukkit.entity.Projectile) event.getAttacker()).getShooter() instanceof Player))
|
||||
&& !(event.getAttacker() instanceof TNTPrimed)
|
||||
&& !(event.getAttacker() instanceof ExplosiveMinecart)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onVehicleDestroy(VehicleDestroyEvent event) {
|
||||
|
||||
|
||||
Player player = (Player) event.getAttacker();
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
if (!(event.getAttacker() instanceof Player)
|
||||
&& (!(event.getAttacker() instanceof org.bukkit.entity.Projectile)
|
||||
|| !(((org.bukkit.entity.Projectile) event.getAttacker()).getShooter() instanceof Player))
|
||||
&& !(event.getAttacker() instanceof TNTPrimed)
|
||||
&& !(event.getAttacker() instanceof ExplosiveMinecart)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
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))
|
||||
&& !(event.getDamager() instanceof TNTPrimed)
|
||||
&& !(event.getDamager() instanceof ExplosiveMinecart)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@PermissionHandler
|
||||
public void onHangingBreak(HangingBreakByEntityEvent event) {
|
||||
if(!(event.getRemover() instanceof Player)){
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
/*@PermissionHandler // TODO ? - Fabrimat
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
EntityType type = event.getEntityType();
|
||||
@ -53,6 +89,6 @@ public class MobGriefingPermission extends ListeningPermission {
|
||||
else return;
|
||||
|
||||
cancelAndMessage(event, player, plugin, messageManager);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user