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

Signed-off-by: Aaron Brock <TheMineBench@gmail.com>
(cherry picked from commit 76e4dc6)
This commit is contained in:
Aaron Brock 2015-06-18 19:50:06 -04:00 committed by Shaun Bennett
parent 556d5adcd9
commit 9df297fc11

View File

@ -4,6 +4,30 @@ import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftArrow;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.block.BlockEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import net.minecraft.server.v1_7_R4.EntityArrow;
import net.minecraft.server.v1_7_R4.Item;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
@ -30,31 +54,6 @@ import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.stats.BehindEnemyLinesStatTracker;
import nautilus.game.arcade.stats.BlockShreadStatTracker;
import nautilus.game.arcade.stats.TheComebackStatTracker;
import net.minecraft.server.v1_7_R4.EntityArrow;
import net.minecraft.server.v1_7_R4.Item;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftArrow;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
public class TurfForts extends TeamGame
{
@ -301,11 +300,12 @@ public class TurfForts extends TeamGame
}
}
@EventHandler
@EventHandler(ignoreCancelled = true)
public void BlockPlace(BlockPlaceEvent event)
{
if (event.isCancelled())
return;
//Remoeved and replaced by ignoreCancelled = true
//if (event.isCancelled())
// return;
GameTeam team = GetTeam(event.getPlayer());
if (team == null)
@ -397,21 +397,22 @@ public class TurfForts extends TeamGame
int z = fieldZ.getInt(entityArrow);
Block block = arrow.getWorld().getBlockAt(x, y, z);
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());
}
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());
}
Bukkit.getPluginManager().callEvent(new ShredBlockEvent(block, arrow));
block.breakNaturally();
block.setType(Material.AIR);
}
arrow.remove();
@ -686,7 +687,8 @@ public class TurfForts extends TeamGame
}
}
}
/*
@EventHandler
public void ItemRemoval(UpdateEvent event)
{
@ -705,7 +707,38 @@ public class TurfForts extends TeamGame
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
public void EndCheck()
{
@ -735,7 +768,7 @@ public class TurfForts extends TeamGame
if (player.isOnline())
AddGems(player, 10, "Participation", false, false);
}
//End
SetState(GameState.End);
}
@ -744,4 +777,4 @@ public class TurfForts extends TeamGame
{
return _enemyTurf.get(player);
}
}
}