Fix Mini OITQ barriers enclosing players at spawn
This commit is contained in:
parent
09fb1842b6
commit
816abad8de
@ -10,8 +10,10 @@ import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@ -60,7 +62,6 @@ public class ChallengeMiniOneInTheQuiver extends Challenge
|
||||
return spawns;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void createMap()
|
||||
{
|
||||
@ -85,22 +86,16 @@ public class ChallengeMiniOneInTheQuiver extends Challenge
|
||||
{
|
||||
block.setType(Material.FENCE);
|
||||
}
|
||||
else if (absX == getArenaSize() - 2 || absZ == getArenaSize() - 2)
|
||||
else if ((absX <= getArenaSize() - 1 || absZ <= getArenaSize() - 1))
|
||||
{
|
||||
Location location = block.getLocation();
|
||||
|
||||
if (UtilMath.r(8) == 0)
|
||||
if (((absX == getArenaSize() - 2 || absZ == getArenaSize() - 2) || (absX == getArenaSize() - 4 || absZ == getArenaSize() - 4)) && UtilMath.r(7) == 0 && canPlaceBarrier(block.getRelative(BlockFace.UP)) && !Data.isSpawnLocation(block.getLocation()))
|
||||
{
|
||||
block.setType(Material.STAINED_CLAY);
|
||||
block.getRelative(BlockFace.UP).setType(Material.STAINED_CLAY);
|
||||
|
||||
block.setData((byte) 14);
|
||||
block.getRelative(BlockFace.UP).setData((byte) 14);
|
||||
generateBarrier(block);
|
||||
}
|
||||
else
|
||||
{
|
||||
generateGrass(block);
|
||||
}
|
||||
}
|
||||
else if ((absX <= getArenaSize() - 1 || absZ <= getArenaSize() - 1) && block.getType() != Material.STAINED_CLAY)
|
||||
{
|
||||
generateGrass(block);
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,7 +104,38 @@ public class ChallengeMiniOneInTheQuiver extends Challenge
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canPlaceBarrier(Block block)
|
||||
{
|
||||
Block[] relatives = {
|
||||
block.getRelative(BlockFace.NORTH_EAST),
|
||||
block.getRelative(BlockFace.NORTH_WEST),
|
||||
block.getRelative(BlockFace.SOUTH_EAST),
|
||||
block.getRelative(BlockFace.SOUTH_WEST)
|
||||
};
|
||||
|
||||
boolean foundOtherBarrier = false;
|
||||
|
||||
for (Block relative : relatives)
|
||||
{
|
||||
if (relative.getType() == Material.STAINED_CLAY)
|
||||
{
|
||||
foundOtherBarrier = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return !foundOtherBarrier;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void generateBarrier(Block block)
|
||||
{
|
||||
block.setType(Material.STAINED_CLAY);
|
||||
block.getRelative(BlockFace.UP).setType(Material.STAINED_CLAY);
|
||||
block.setData((byte) 14);
|
||||
block.getRelative(BlockFace.UP).setData((byte) 14);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -179,4 +205,18 @@ public class ChallengeMiniOneInTheQuiver extends Challenge
|
||||
damaged.setHealth(1);
|
||||
event.setDamage(event.getDamage());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onProjectileHit(ProjectileHitEvent event)
|
||||
{
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
Projectile entity = event.getEntity();
|
||||
|
||||
if (entity instanceof Arrow)
|
||||
{
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user