Stopped blocks from dropping and stopped people from breaking the other teams blocks with their fist.

Signed-off-by: Aaron Brock <TheMineBench@gmail.com>
This commit is contained in:
Aaron Brock 2015-06-18 19:50:06 -04:00
parent b0ca5ca4aa
commit 76e4dc6056

View File

@ -16,13 +16,16 @@ import org.bukkit.craftbukkit.v1_7_R4.entity.CraftArrow;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockEvent; import org.bukkit.event.block.BlockEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.ProjectileHitEvent;
@ -281,11 +284,12 @@ public class TurfForts extends TeamGame
} }
} }
@EventHandler @EventHandler(ignoreCancelled = true)
public void BlockPlace(BlockPlaceEvent event) public void BlockPlace(BlockPlaceEvent event)
{ {
if (event.isCancelled()) //Remoeved and replaced by ignoreCancelled = true
return; //if (event.isCancelled())
// return;
GameTeam team = GetTeam(event.getPlayer()); GameTeam team = GetTeam(event.getPlayer());
if (team == null) if (team == null)
@ -324,6 +328,7 @@ public class TurfForts extends TeamGame
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} }
@EventHandler @EventHandler
@ -347,6 +352,7 @@ public class TurfForts extends TeamGame
Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
{ {
public void run() public void run()
{ {
try try
@ -369,18 +375,19 @@ public class TurfForts extends TeamGame
if (block.getTypeId() == 35) if (block.getTypeId() == 35)
{ {
if (block.getData() == 14 && team.GetColor() != ChatColor.RED) if (block.getData() == 14 /* && team.GetColor() != ChatColor.RED */)
{ {
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.REDSTONE_BLOCK.getId()); block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.REDSTONE_BLOCK.getId());
} }
else if (block.getData() == 3 && team.GetColor() != ChatColor.AQUA) else if (block.getData() == 3 /* && team.GetColor() != ChatColor.AQUA */)
{ {
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.LAPIS_BLOCK.getId()); block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.LAPIS_BLOCK.getId());
} }
Bukkit.getPluginManager().callEvent(new ShredBlockEvent(block, arrow)); Bukkit.getPluginManager().callEvent(new ShredBlockEvent(block, arrow));
block.breakNaturally();
block.setType(Material.AIR);
} }
arrow.remove(); arrow.remove();
@ -656,6 +663,7 @@ public class TurfForts extends TeamGame
} }
} }
/*
@EventHandler @EventHandler
public void ItemRemoval(UpdateEvent event) public void ItemRemoval(UpdateEvent event)
{ {
@ -674,6 +682,37 @@ public class TurfForts extends TeamGame
ent.remove(); ent.remove();
} }
} }
*/
//Added by TheMineBench.
@EventHandler
public void blockBreak(BlockBreakEvent event) {
Block block = event.getBlock();
GameTeam team = GetTeam(event.getPlayer());
GameTeam otherTeam = GetOtherTeam(team);
if (block.getType().equals(Material.WOOL) && (block.getData() == 14 && team.GetColor() != ChatColor.RED || block.getData() == 3 || team.GetColor() != ChatColor.AQUA))
{
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot break the " + F.elem(otherTeam.GetColor() + otherTeam.GetName()) + " team's blocks!"));
event.setCancelled(true);
return;
}
}
public GameTeam GetOtherTeam(GameTeam team) {
return team.GetColor() == ChatColor.RED ? GetTeam(ChatColor.AQUA) : GetTeam(ChatColor.RED);
}
@EventHandler
public void onItem(ItemSpawnEvent e) {
if (e.getEntityType().equals(EntityType.DROPPED_ITEM)) {
e.setCancelled(true);
}
}
@Override @Override
public void EndCheck() public void EndCheck()