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.F;
|
||||
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.UtilEvent;
|
||||
import mineplex.core.common.util.UtilGear;
|
||||
@ -95,7 +97,11 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
private ArrayList<Location> _lavaSource = new ArrayList<Location>();
|
||||
|
||||
//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
|
||||
private ArrayList<Location> _iceBridge = new ArrayList<Location>();
|
||||
@ -234,12 +240,17 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void GameStateChange(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Live)
|
||||
return;
|
||||
|
||||
if (!WorldData.GetCustomLocs("WATER_DAMAGE").isEmpty())
|
||||
{
|
||||
WorldWaterDamage = 4;
|
||||
}
|
||||
|
||||
if (WorldWaterDamage > 0)
|
||||
{
|
||||
if (WorldData.MapName.equals("Volcanic Islands"))
|
||||
@ -259,6 +270,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
ParseWoodBridge();
|
||||
ParseIceBridge();
|
||||
ParseLillyPad();
|
||||
ParseMushrooms();
|
||||
|
||||
ParseChests();
|
||||
|
||||
@ -650,12 +662,29 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
|
||||
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()
|
||||
{
|
||||
_lillyPads = WorldData.GetDataLocs("LIME");
|
||||
for (Location loc : WorldData.GetDataLocs("LIME"))
|
||||
{
|
||||
_lillyPads.put(loc, 0L);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -690,6 +719,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
BuildLava();
|
||||
BuildIce();
|
||||
BuildLillyPad();
|
||||
buildMushroom();
|
||||
}
|
||||
|
||||
private void BuildLava()
|
||||
@ -729,7 +759,10 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
if (_lillyPads != null && !_lillyPads.isEmpty())
|
||||
{
|
||||
// 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())
|
||||
continue;
|
||||
@ -743,9 +776,99 @@ 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()
|
||||
{
|
||||
if (UtilTime.elapsed(this.GetStateTime(), _bridgeTime + 120000))
|
||||
if (_iceBridge == null || _iceBridge.isEmpty() || UtilTime.elapsed(this.GetStateTime(), _bridgeTime + 120000))
|
||||
{
|
||||
WorldData.World.setStorm(false);
|
||||
return;
|
||||
@ -755,7 +878,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
|
||||
int attempts = 0;
|
||||
int done = 0;
|
||||
while (done < 2 && attempts < 500 && _iceBridge != null && !_iceBridge.isEmpty())
|
||||
while (done < 4 && attempts < 500)
|
||||
{
|
||||
attempts++;
|
||||
|
||||
@ -776,9 +899,9 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
_iceBridge.remove(loc);
|
||||
|
||||
if (Math.random() > 0.25)
|
||||
MapUtil.QuickChangeBlockAt(loc, Material.PACKED_ICE);
|
||||
MapUtil.QuickChangeBlockAt(block.getLocation(), Material.PACKED_ICE);
|
||||
else
|
||||
MapUtil.QuickChangeBlockAt(loc, Material.ICE);
|
||||
MapUtil.QuickChangeBlockAt(block.getLocation(), Material.ICE);
|
||||
|
||||
// Sound
|
||||
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())
|
||||
{
|
||||
//Display Individual Players
|
||||
if (this.GetPlayers(true).size() < 10)
|
||||
if (this.GetPlayers(true).size() < 8)
|
||||
{
|
||||
if (!team.IsTeamAlive())
|
||||
continue;
|
||||
@ -1662,9 +1785,12 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void toggleOre(PlayerCommandPreprocessEvent event)
|
||||
public void debug(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (event.getPlayer().isOp() && event.getMessage().contains("/oretoggle"))
|
||||
_ore.ToggleVisibility();
|
||||
|
||||
if (event.getPlayer().isOp() && event.getMessage().contains("/bridge"))
|
||||
_bridgeTime = 30000;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user