Fix offcentered regions
This commit is contained in:
parent
a0b6a6f900
commit
b407f4ed8a
@ -10,6 +10,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -800,6 +801,11 @@ public class CakeWars extends TeamGame
|
||||
return _averages.get(team);
|
||||
}
|
||||
|
||||
public boolean isNearSpawn(Block block)
|
||||
{
|
||||
return isNearSpawn(block.getLocation().add(0.5, 0, 0.5));
|
||||
}
|
||||
|
||||
public boolean isNearSpawn(Location location)
|
||||
{
|
||||
for (List<Location> locations : WorldData.SpawnLocs.values())
|
||||
|
@ -143,7 +143,7 @@ public class CakePlayerModule extends CakeModule
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(F.main("Game", "You cannot place a " + F.name(RUNE_OF_HOLDING.getItemMeta().getDisplayName()) + "."));
|
||||
}
|
||||
else if (_game.isNearSpawn(event.getBlock().getLocation()))
|
||||
else if (_game.isNearSpawn(event.getBlock()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(F.main("Game", "You cannot place blocks that near to a player spawn."));
|
||||
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -37,17 +38,10 @@ public class CakeSpawnerModule extends CakeModule
|
||||
super(game);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void blockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Location block = event.getBlock().getLocation();
|
||||
|
||||
if (isNearSpawner(block))
|
||||
if (isNearSpawner(event.getBlock()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(F.main("Game", "You cannot place blocks that close to a generator."));
|
||||
@ -208,6 +202,11 @@ public class CakeSpawnerModule extends CakeModule
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isNearSpawner(Block block)
|
||||
{
|
||||
return isNearSpawner(block.getLocation().add(0.5, 0, 0.5));
|
||||
}
|
||||
|
||||
public boolean isNearSpawner(Location location)
|
||||
{
|
||||
for (CakeTeam team : _game.getCakeTeamModule().getCakeTeams().values())
|
||||
|
@ -44,7 +44,7 @@ public abstract class CakeSpecialItem
|
||||
protected boolean isInvalidBlock(Block block)
|
||||
{
|
||||
Location location = block.getLocation();
|
||||
return !UtilBlock.airFoliage(block) || _game.getCapturePointModule().isOnPoint(location) || _game.getCakeShopModule().isNearShop(location) || _game.getCakeSpawnerModule().isNearSpawner(location) || _game.isNearSpawn(location);
|
||||
return !UtilBlock.airFoliage(block) || _game.getCapturePointModule().isOnPoint(location) || _game.getCakeShopModule().isNearShop(location) || _game.getCakeSpawnerModule().isNearSpawner(block) || _game.isNearSpawn(block);
|
||||
}
|
||||
|
||||
public ItemStack getItemStack()
|
||||
|
Loading…
Reference in New Issue
Block a user