PC-1054 PC-1164

GameTeam can't handle spawnpoints which are also solid blocks, and
SurvivalGames has a chance of spawning a chest on a spawn platform. When
this happens, the next closest spawn is always the same spawn because the
two players will be exactly 1 block apart, causing everyone to spawn at
the same podium. This commit prevents SurvivalGames from generating random
chests on spawn podiums
This commit is contained in:
samczsun 2017-01-03 19:46:03 -05:00 committed by cnr
parent cc7150850c
commit 1ce69dfa14

View File

@ -32,6 +32,7 @@ import org.bukkit.block.Furnace;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLargeFireball;
import org.bukkit.craftbukkit.v1_8_R3.scoreboard.CraftScoreboard;
import org.bukkit.craftbukkit.v1_8_R3.util.LongHash;
import org.bukkit.entity.Boat;
import org.bukkit.entity.Egg;
import org.bukkit.entity.Entity;
@ -414,7 +415,7 @@ public abstract class SurvivalGames extends Game
@EventHandler
public void CreateRandomChests(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Recruit)
if (event.GetState() != GameState.Prepare)
return;
HashSet<Material> ignore = new HashSet<Material>();
@ -424,14 +425,28 @@ public abstract class SurvivalGames extends Game
int xDiff = WorldData.MaxX - WorldData.MinX;
int zDiff = WorldData.MaxZ - WorldData.MinZ;
Set<Long> illegalCoordinates = new HashSet<>();
for (GameTeam team : GetTeamList())
{
for (Location l : team.GetSpawns())
{
illegalCoordinates.add(LongHash.toLong(l.getBlockX(), l.getBlockZ()));
}
}
int done = 0;
while (done < 40)
{
int tx = WorldData.MinX + UtilMath.r(xDiff);
int tz = WorldData.MinZ + UtilMath.r(zDiff);
Block block = UtilBlock.getHighest(WorldData.World, WorldData.MinX
+ UtilMath.r(xDiff), WorldData.MinZ + UtilMath.r(zDiff),
ignore);
// Don't spawn chest on spawn platform
if (illegalCoordinates.contains(LongHash.toLong(tx, tz)))
continue;
Block block = UtilBlock.getHighest(WorldData.World, tx, tz, ignore);
if (!UtilBlock.airFoliage(block)
|| !UtilBlock.solid(block.getRelative(BlockFace.DOWN)))