bridges update
This commit is contained in:
parent
fcedb4d6ba
commit
190e58c37e
@ -43,6 +43,8 @@ import org.bukkit.util.Vector;
|
|||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.MapUtil;
|
import mineplex.core.common.util.MapUtil;
|
||||||
|
import mineplex.core.common.util.NautHashMap;
|
||||||
|
import mineplex.core.common.util.UtilAlg;
|
||||||
import mineplex.core.common.util.UtilBlock;
|
import mineplex.core.common.util.UtilBlock;
|
||||||
import mineplex.core.common.util.UtilEvent;
|
import mineplex.core.common.util.UtilEvent;
|
||||||
import mineplex.core.common.util.UtilGear;
|
import mineplex.core.common.util.UtilGear;
|
||||||
@ -95,8 +97,12 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||||||
private ArrayList<Location> _lavaSource = new ArrayList<Location>();
|
private ArrayList<Location> _lavaSource = new ArrayList<Location>();
|
||||||
|
|
||||||
//Lilly Pad Bridge
|
//Lilly Pad Bridge
|
||||||
private ArrayList<Location> _lillyPads = new ArrayList<Location>();
|
private NautHashMap<Location, Long> _lillyPads = new NautHashMap<Location, Long>();
|
||||||
|
|
||||||
|
//Mushrooms
|
||||||
|
private NautHashMap<Location, Long> _mushroomStem = new NautHashMap<Location, Long>();
|
||||||
|
private NautHashMap<Location, Long> _mushroomTop = new NautHashMap<Location, Long>();
|
||||||
|
|
||||||
//Ice
|
//Ice
|
||||||
private ArrayList<Location> _iceBridge = new ArrayList<Location>();
|
private ArrayList<Location> _iceBridge = new ArrayList<Location>();
|
||||||
|
|
||||||
@ -234,11 +240,16 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void GameStateChange(GameStateChangeEvent event)
|
public void GameStateChange(GameStateChangeEvent event)
|
||||||
{
|
{
|
||||||
if (event.GetState() != GameState.Live)
|
if (event.GetState() != GameState.Live)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!WorldData.GetCustomLocs("WATER_DAMAGE").isEmpty())
|
||||||
|
{
|
||||||
|
WorldWaterDamage = 4;
|
||||||
|
}
|
||||||
|
|
||||||
if (WorldWaterDamage > 0)
|
if (WorldWaterDamage > 0)
|
||||||
{
|
{
|
||||||
@ -259,7 +270,8 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||||||
ParseWoodBridge();
|
ParseWoodBridge();
|
||||||
ParseIceBridge();
|
ParseIceBridge();
|
||||||
ParseLillyPad();
|
ParseLillyPad();
|
||||||
|
ParseMushrooms();
|
||||||
|
|
||||||
ParseChests();
|
ParseChests();
|
||||||
|
|
||||||
ParseOre(WorldData.GetCustomLocs("73")); // Red
|
ParseOre(WorldData.GetCustomLocs("73")); // Red
|
||||||
@ -650,12 +662,29 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||||||
|
|
||||||
private void ParseIceBridge()
|
private void ParseIceBridge()
|
||||||
{
|
{
|
||||||
_iceBridge = WorldData.GetCustomLocs("LIGHT_BLUE");
|
_iceBridge = WorldData.GetDataLocs("LIGHT_BLUE");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ParseMushrooms()
|
||||||
|
{
|
||||||
|
for (Location loc : WorldData.GetCustomLocs("21"))
|
||||||
|
{
|
||||||
|
_mushroomStem.put(loc, 0L);
|
||||||
|
loc.getBlock().setType(Material.AIR);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Location loc : WorldData.GetDataLocs("PURPLE"))
|
||||||
|
{
|
||||||
|
_mushroomTop.put(loc, 0L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ParseLillyPad()
|
private void ParseLillyPad()
|
||||||
{
|
{
|
||||||
_lillyPads = WorldData.GetDataLocs("LIME");
|
for (Location loc : WorldData.GetDataLocs("LIME"))
|
||||||
|
{
|
||||||
|
_lillyPads.put(loc, 0L);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -690,6 +719,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||||||
BuildLava();
|
BuildLava();
|
||||||
BuildIce();
|
BuildIce();
|
||||||
BuildLillyPad();
|
BuildLillyPad();
|
||||||
|
buildMushroom();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BuildLava()
|
private void BuildLava()
|
||||||
@ -729,7 +759,10 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||||||
if (_lillyPads != null && !_lillyPads.isEmpty())
|
if (_lillyPads != null && !_lillyPads.isEmpty())
|
||||||
{
|
{
|
||||||
// Random Block
|
// Random Block
|
||||||
Location loc = _lillyPads.get(UtilMath.r(_lillyPads.size()));
|
Location loc = UtilAlg.Random(_lillyPads.keySet());
|
||||||
|
|
||||||
|
if (!UtilTime.elapsed(_lillyPads.get(loc), 8000))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (!loc.getBlock().getRelative(BlockFace.DOWN).isLiquid())
|
if (!loc.getBlock().getRelative(BlockFace.DOWN).isLiquid())
|
||||||
continue;
|
continue;
|
||||||
@ -743,19 +776,109 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void breakLillyPad(BlockBreakEvent event)
|
||||||
|
{
|
||||||
|
if (event.getBlock().getType() != Material.WATER_LILY)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_lillyPads.put(event.getBlock().getLocation(), System.currentTimeMillis() + (long)(Math.random() * 12000));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildMushroom()
|
||||||
|
{
|
||||||
|
if (_mushroomStem != null && !_mushroomStem.isEmpty())
|
||||||
|
{
|
||||||
|
for (int i=0 ; i<4 && !_mushroomStem.isEmpty() ; i++)
|
||||||
|
{
|
||||||
|
double lowestY = 0;
|
||||||
|
Location lowestLoc = null;
|
||||||
|
|
||||||
|
for (Location loc : _mushroomStem.keySet())
|
||||||
|
{
|
||||||
|
if (!UtilTime.elapsed(_mushroomStem.get(loc), 6000))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (lowestLoc == null || loc.getY() < lowestY)
|
||||||
|
{
|
||||||
|
lowestY = loc.getY();
|
||||||
|
lowestLoc = loc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lowestLoc == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
_mushroomStem.remove(lowestLoc);
|
||||||
|
|
||||||
|
MapUtil.QuickChangeBlockAt(lowestLoc, 100, (byte)15);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (_mushroomTop != null && !_mushroomTop.isEmpty())
|
||||||
|
{
|
||||||
|
int attempts = 0;
|
||||||
|
int done = 0;
|
||||||
|
while (done < 4 && attempts < 400)
|
||||||
|
{
|
||||||
|
attempts++;
|
||||||
|
|
||||||
|
// Random Block
|
||||||
|
Location loc = UtilAlg.Random(_mushroomTop.keySet());
|
||||||
|
|
||||||
|
if (!UtilTime.elapsed(_mushroomTop.get(loc), 6000))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Block block = loc.getBlock();
|
||||||
|
|
||||||
|
if (block.getRelative(BlockFace.DOWN).getType() == Material.AIR &&
|
||||||
|
block.getRelative(BlockFace.NORTH).getType() == Material.AIR &&
|
||||||
|
block.getRelative(BlockFace.EAST).getType() == Material.AIR &&
|
||||||
|
block.getRelative(BlockFace.SOUTH).getType() == Material.AIR &&
|
||||||
|
block.getRelative(BlockFace.WEST).getType() == Material.AIR)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
_mushroomTop.remove(loc);
|
||||||
|
|
||||||
|
MapUtil.QuickChangeBlockAt(block.getLocation(), 99, (byte)14);
|
||||||
|
|
||||||
|
// Sound
|
||||||
|
loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 99);
|
||||||
|
|
||||||
|
done++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void breakMushroom(BlockBreakEvent event)
|
||||||
|
{
|
||||||
|
if (event.getBlock().getTypeId() == 100 &&
|
||||||
|
WorldData.GetCustomLocs("21").contains(event.getBlock().getLocation().add(0.5, 0, 0.5)))
|
||||||
|
{
|
||||||
|
_mushroomStem.put(event.getBlock().getLocation(), System.currentTimeMillis() + (long)(Math.random() * 12000));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.getBlock().getTypeId() == 99 &&
|
||||||
|
WorldData.GetDataLocs("PURPLE").contains(event.getBlock().getLocation().add(0.5, 0, 0.5)))
|
||||||
|
{
|
||||||
|
_mushroomTop.put(event.getBlock().getLocation(), System.currentTimeMillis() + (long)(Math.random() * 12000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void BuildIce()
|
private void BuildIce()
|
||||||
{
|
{
|
||||||
if (UtilTime.elapsed(this.GetStateTime(), _bridgeTime + 120000))
|
if (_iceBridge == null || _iceBridge.isEmpty() || UtilTime.elapsed(this.GetStateTime(), _bridgeTime + 120000))
|
||||||
{
|
{
|
||||||
WorldData.World.setStorm(false);
|
WorldData.World.setStorm(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldData.World.setStorm(true);
|
WorldData.World.setStorm(true);
|
||||||
|
|
||||||
int attempts = 0;
|
int attempts = 0;
|
||||||
int done = 0;
|
int done = 0;
|
||||||
while (done < 2 && attempts < 500 && _iceBridge != null && !_iceBridge.isEmpty())
|
while (done < 4 && attempts < 500)
|
||||||
{
|
{
|
||||||
attempts++;
|
attempts++;
|
||||||
|
|
||||||
@ -776,9 +899,9 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||||||
_iceBridge.remove(loc);
|
_iceBridge.remove(loc);
|
||||||
|
|
||||||
if (Math.random() > 0.25)
|
if (Math.random() > 0.25)
|
||||||
MapUtil.QuickChangeBlockAt(loc, Material.PACKED_ICE);
|
MapUtil.QuickChangeBlockAt(block.getLocation(), Material.PACKED_ICE);
|
||||||
else
|
else
|
||||||
MapUtil.QuickChangeBlockAt(loc, Material.ICE);
|
MapUtil.QuickChangeBlockAt(block.getLocation(), Material.ICE);
|
||||||
|
|
||||||
// Sound
|
// Sound
|
||||||
loc.getWorld().playEffect(loc, Effect.STEP_SOUND, Material.ICE);
|
loc.getWorld().playEffect(loc, Effect.STEP_SOUND, Material.ICE);
|
||||||
@ -1242,7 +1365,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||||||
for (GameTeam team : this.GetTeamList())
|
for (GameTeam team : this.GetTeamList())
|
||||||
{
|
{
|
||||||
//Display Individual Players
|
//Display Individual Players
|
||||||
if (this.GetPlayers(true).size() < 10)
|
if (this.GetPlayers(true).size() < 8)
|
||||||
{
|
{
|
||||||
if (!team.IsTeamAlive())
|
if (!team.IsTeamAlive())
|
||||||
continue;
|
continue;
|
||||||
@ -1662,9 +1785,12 @@ public class Bridge extends TeamGame implements OreObsfucation
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void toggleOre(PlayerCommandPreprocessEvent event)
|
public void debug(PlayerCommandPreprocessEvent event)
|
||||||
{
|
{
|
||||||
if (event.getPlayer().isOp() && event.getMessage().contains("/oretoggle"))
|
if (event.getPlayer().isOp() && event.getMessage().contains("/oretoggle"))
|
||||||
_ore.ToggleVisibility();
|
_ore.ToggleVisibility();
|
||||||
|
|
||||||
|
if (event.getPlayer().isOp() && event.getMessage().contains("/bridge"))
|
||||||
|
_bridgeTime = 30000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user