[MB] Allow Item Frames and Paintings

This commit is contained in:
Shaun Bennett 2015-05-11 12:38:21 -05:00
parent 46c07665e1
commit c0dc531252

View File

@ -2,7 +2,6 @@ package nautilus.game.arcade.game.games.build;
import java.util.AbstractMap; import java.util.AbstractMap;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -13,6 +12,8 @@ import org.bukkit.Sound;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Boat; import org.bukkit.entity.Boat;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Hanging;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.ItemFrame; import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -41,10 +42,15 @@ import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.ItemDespawnEvent; import org.bukkit.event.entity.ItemDespawnEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerDropItemEvent;
@ -766,6 +772,67 @@ public class Build extends SoloGame
} }
} }
@Override
@EventHandler
public void onHangingPlace(HangingPlaceEvent event)
{
Player player = event.getPlayer();
if (_buildGameState == 0 && IsLive() && IsAlive(player))
{
BuildData buildData = _data.get(player);
if (buildData != null)
{
// Allow placing paintings and item frames in your own plot
if (buildData.inBuildArea(event.getBlock())) return;
}
}
event.setCancelled(true);
}
@Override
@EventHandler
public void onHangingBreak(HangingBreakEvent event)
{
if (event instanceof HangingBreakByEntityEvent)
{
HangingBreakByEntityEvent ev = ((HangingBreakByEntityEvent) event);
if (ev.getRemover() instanceof Player)
if (_buildGameState != 0 || !IsAlive(ev.getRemover()))
event.setCancelled(true);
}
}
@Override
@EventHandler
public void onDamageHanging(EntityDamageEvent event)
{
if (!(event.getEntity() instanceof Hanging)) return;
if (event instanceof EntityDamageByEntityEvent)
{
EntityDamageByEntityEvent ev = ((EntityDamageByEntityEvent) event);
if (ev.getDamager() instanceof Player)
{
Player player = ((Player) ev.getDamager());
if (_buildGameState != 0 || !IsAlive(player))
event.setCancelled(true);
}
}
else super.onDamageHanging(event);
}
@EventHandler
public void preventRotateHanging(PlayerInteractEntityEvent event)
{
EntityType type = event.getRightClicked().getType();
if (_buildGameState != 0 && (type == EntityType.PAINTING || type == EntityType.ITEM_FRAME))
event.setCancelled(true);
}
@EventHandler @EventHandler
public void potionThrow(ProjectileLaunchEvent event) public void potionThrow(ProjectileLaunchEvent event)
{ {