Bridges bug fixes
This commit is contained in:
parent
99ff344679
commit
13806a49d2
@ -13,14 +13,12 @@ import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.entity.Chicken;
|
||||
import org.bukkit.entity.Cow;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Pig;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -31,9 +29,11 @@ import org.bukkit.event.block.BlockFormEvent;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.inventory.CraftItemEvent;
|
||||
import org.bukkit.event.inventory.PrepareItemCraftEvent;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerBucketFillEvent;
|
||||
@ -48,7 +48,6 @@ import org.bukkit.util.Vector;
|
||||
import mineplex.core.common.Rank;
|
||||
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.UtilAction;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
@ -71,7 +70,6 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.events.PlayerDeathOutEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.TeamGame;
|
||||
@ -89,6 +87,8 @@ import nautilus.game.arcade.game.games.bridge.kits.KitMiner;
|
||||
import nautilus.game.arcade.game.modules.WorldBorderModule;
|
||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.kit.Perk;
|
||||
import nautilus.game.arcade.kit.perks.PerkDestructor;
|
||||
import nautilus.game.arcade.ore.OreHider;
|
||||
import nautilus.game.arcade.ore.OreObsfucation;
|
||||
import nautilus.game.arcade.stats.BridgesSniperStatTracker;
|
||||
@ -118,25 +118,6 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
private long _bridgeTime = BRIDGE_TIME;
|
||||
private boolean _bridgesDown = false;
|
||||
private BridgeAnimation _animation;
|
||||
|
||||
//Wood Bridge
|
||||
private ArrayList<Location> _woodBridge = new ArrayList<Location>();
|
||||
private HashMap<Location, Integer> _woodBridgeBlocks = null;
|
||||
|
||||
//Lava Bridge
|
||||
private ArrayList<Location> _lavaBridge = new ArrayList<Location>();
|
||||
private ArrayList<Location> _lavaSource = new ArrayList<Location>();
|
||||
|
||||
//Lilly Pad Bridge
|
||||
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>();
|
||||
private boolean _stemsGrown = false;
|
||||
|
||||
//Ice
|
||||
private ArrayList<Location> _iceBridge = new ArrayList<Location>();
|
||||
|
||||
private HashSet<BridgePart> _bridgeParts = new HashSet<BridgePart>();
|
||||
|
||||
@ -273,26 +254,20 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
.register(this);
|
||||
|
||||
new WorldBorderModule().register(this);
|
||||
}
|
||||
|
||||
//TODO move this lower and use EntityDamage
|
||||
@EventHandler
|
||||
public void PlayerOut(final PlayerDeathOutEvent event)
|
||||
{
|
||||
if (_bridgesDown)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.GetPlayer();
|
||||
|
||||
if (!_usedLife.contains(player.getName()))
|
||||
// So that we can be 110% sure
|
||||
for (Kit kit : GetKits())
|
||||
{
|
||||
_usedLife.add(player.getName());
|
||||
|
||||
UtilPlayer.message(player, F.main("Game", "You used your " + F.elem(C.cAqua + "Early Game Revive") + "."));
|
||||
|
||||
event.setCancelled(true);
|
||||
if (kit instanceof KitDestructor)
|
||||
{
|
||||
for (Perk perk : kit.GetPerks())
|
||||
{
|
||||
((PerkDestructor) perk).setEnabled(false);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -308,54 +283,25 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
Manager.runSyncLater(() -> {
|
||||
|
||||
WorldBorderModule borderModule = getModule(WorldBorderModule.class);
|
||||
boolean oldWay = WorldData.GetCustomLocs("BORDER").isEmpty() || WorldData.GetCustomLocs("BORDER CENTER").isEmpty();
|
||||
|
||||
// if (!oldWay)
|
||||
// {
|
||||
// // Step 1 - Get the vector offset between the spectator location and the center of the border
|
||||
// Location center = WorldData.GetCustomLocs("BORDER").get(0);
|
||||
//
|
||||
// Vector offset = center.subtract(SpectatorSpawn.toVector()).toVector();
|
||||
// }
|
||||
|
||||
// Here we do some calculations for per player world borders
|
||||
for (GameTeam team : GetTeamList())
|
||||
{
|
||||
if (oldWay)
|
||||
// If this is an old map or the builders haven't done it properly we can use this more of an estimate of the border size
|
||||
// Step 1 - Get the average location of the spawns, we will assume this is the centre of the island
|
||||
Location center = UtilAlg.getAverageLocation(team.GetSpawns());
|
||||
center.add(UtilAlg.getTrajectory(SpectatorSpawn, center).multiply(20));
|
||||
|
||||
// Step 2 - Calculate an estimate for the size of the border. We'll go with half but the setSize uses the radius so it works out the same to leave it like this
|
||||
double distToCenter = UtilMath.offset2d(SpectatorSpawn, center);
|
||||
|
||||
// Step 3 - Send the setCenter and setSize packets to the team members
|
||||
for (Player player : team.GetPlayers(true))
|
||||
{
|
||||
// If this is an old map or the builders haven't done it properly we can use this more of an estimate of the border size
|
||||
// Step 1 - Get the average location of the spawns, we will assume this is the centre of the island
|
||||
Location center = UtilAlg.getAverageLocation(team.GetSpawns());
|
||||
|
||||
// Step 2 - Calculate an estimate for the size of the border. We'll go with half but the setSize uses the radius so it works out the same to leave it like this
|
||||
double distToCenter = UtilMath.offset2d(SpectatorSpawn, center);
|
||||
|
||||
// Step 3 - Send the setCenter and setSize packets to the team members
|
||||
for (Player player : team.GetPlayers(true))
|
||||
{
|
||||
borderModule.setCenter(player, center);
|
||||
borderModule.setSize(player, distToCenter);
|
||||
}
|
||||
borderModule.setCenter(player, center);
|
||||
borderModule.setSize(player, distToCenter * 0.6);
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// // Step 1 - Get the vector offset between the spectator location and the center of the border
|
||||
// Location edge = WorldData.GetCustomLocs("BORDER").get(0);
|
||||
// Location center = WorldData.GetCustomLocs("BORDER CENTER").get(0);
|
||||
//
|
||||
// Vector offset = center.subtract(SpectatorSpawn.toVector()).toVector();
|
||||
//
|
||||
// // Step 2 - Calculate the distance between the the two border data points
|
||||
// // Multiple by 2 because it is a radius
|
||||
// double borderSize = UtilMath.offset2d(edge, center) * 2;
|
||||
//
|
||||
// // Step 3 - Send the setCenter and setSize packets to the team members
|
||||
// for (Player player : team.GetPlayers(true))
|
||||
// {
|
||||
// borderModule.setCenter(player, center);
|
||||
// borderModule.setSize(player, borderSize);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
}, WORLD_BORDER_PREPARE_TICKS);
|
||||
@ -417,12 +363,6 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
_animation.onParse();
|
||||
}
|
||||
|
||||
ParseLavaBridge();
|
||||
ParseWoodBridge();
|
||||
ParseIceBridge();
|
||||
ParseLillyPad();
|
||||
ParseMushrooms();
|
||||
|
||||
ParseChests();
|
||||
|
||||
ParseOre(WorldData.GetCustomLocs("73")); // Red
|
||||
@ -761,81 +701,6 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
}
|
||||
}
|
||||
|
||||
protected void ParseWoodBridge() {
|
||||
_woodBridge = new ArrayList<Location>();
|
||||
|
||||
// Load Wood In
|
||||
for (Location loc : WorldData.GetDataLocs("BROWN")) {
|
||||
_woodBridge.add(loc.getBlock().getLocation());
|
||||
}
|
||||
|
||||
for (Location loc : WorldData.GetDataLocs("GRAY")) {
|
||||
_woodBridge.add(loc.getBlock().getLocation());
|
||||
_woodBridge.add(loc.getBlock().getRelative(BlockFace.UP)
|
||||
.getLocation());
|
||||
}
|
||||
|
||||
// Determine Wood Block
|
||||
_woodBridgeBlocks = new HashMap<Location, Integer>();
|
||||
|
||||
for (Location loc : _woodBridge) {
|
||||
if (_woodBridge.contains(loc.getBlock().getRelative(BlockFace.DOWN)
|
||||
.getLocation())) {
|
||||
_woodBridgeBlocks.put(loc, 85);
|
||||
}
|
||||
|
||||
if (_woodBridge.contains(loc.getBlock().getRelative(BlockFace.UP)
|
||||
.getLocation())) {
|
||||
_woodBridgeBlocks.put(loc, 17);
|
||||
}
|
||||
|
||||
if (!_woodBridgeBlocks.containsKey(loc)) {
|
||||
_woodBridgeBlocks.put(loc, 126);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void ParseLavaBridge() {
|
||||
for (Location loc : WorldData.GetDataLocs("RED")) {
|
||||
_lavaBridge.add(loc.getBlock().getLocation());
|
||||
}
|
||||
|
||||
for (Location loc : WorldData.GetDataLocs("ORANGE")) {
|
||||
_lavaBridge.add(loc.getBlock().getLocation());
|
||||
_lavaBridge.add(loc.getBlock().getRelative(BlockFace.UP)
|
||||
.getLocation());
|
||||
}
|
||||
|
||||
_lavaSource = WorldData.GetDataLocs("BLACK");
|
||||
}
|
||||
|
||||
protected void ParseIceBridge()
|
||||
{
|
||||
_iceBridge = WorldData.GetDataLocs("LIGHT_BLUE");
|
||||
}
|
||||
|
||||
protected 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);
|
||||
}
|
||||
}
|
||||
|
||||
protected void ParseLillyPad()
|
||||
{
|
||||
for (Location loc : WorldData.GetDataLocs("LIME"))
|
||||
{
|
||||
_lillyPads.put(loc, 0L);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void BridgeBuild(UpdateEvent event)
|
||||
{
|
||||
@ -866,7 +731,8 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
}
|
||||
|
||||
Manager.GetExplosion().SetLiquidDamage(true);
|
||||
Announce(C.cRed + C.Bold + "ALERT: " + ChatColor.RESET + C.Bold + "THE BRIDGES ARE SPAWNING!");
|
||||
Announce(C.cRedB + "ALERT: " + C.Reset + C.Bold + "THE BRIDGES ARE SPAWNING!");
|
||||
UtilTextMiddle.display(C.cRedB + "ALERT", "The BRIDGES ARE SPAWNING!");
|
||||
|
||||
for (Kit kit : GetKits())
|
||||
{
|
||||
@ -876,269 +742,43 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// BuildWood();
|
||||
// BuildLava();
|
||||
// BuildIce();
|
||||
// BuildLillyPad();
|
||||
// buildMushroom();
|
||||
}
|
||||
|
||||
protected void BuildLava()
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
if (_lavaBridge != null && _lavaSource != null
|
||||
&& !_lavaBridge.isEmpty() && !_lavaSource.isEmpty()) {
|
||||
// Random Block
|
||||
Location bestLoc = _lavaBridge.get(UtilMath.r(_lavaBridge
|
||||
.size()));
|
||||
|
||||
if (bestLoc.getBlock().getRelative(BlockFace.DOWN)
|
||||
.isLiquid())
|
||||
continue;
|
||||
|
||||
_lavaBridge.remove(bestLoc);
|
||||
|
||||
Location source = _lavaSource.get(UtilMath.r(_lavaSource
|
||||
.size()));
|
||||
|
||||
// Create Part
|
||||
FallingBlock block = bestLoc.getWorld().spawnFallingBlock(
|
||||
source, 87, (byte) 0);
|
||||
BridgePart part = new BridgePart(block, bestLoc, true);
|
||||
_bridgeParts.add(part);
|
||||
|
||||
// Sound
|
||||
source.getWorld().playSound(source, Sound.EXPLODE,
|
||||
5f * (float) Math.random(),
|
||||
0.5f + (float) Math.random());
|
||||
}
|
||||
}
|
||||
|
||||
protected void BuildLillyPad()
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
if (_lillyPads != null && !_lillyPads.isEmpty())
|
||||
{
|
||||
// Random Block
|
||||
Location loc = UtilAlg.Random(_lillyPads.keySet());
|
||||
|
||||
if (!UtilTime.elapsed(_lillyPads.get(loc), 8000))
|
||||
continue;
|
||||
|
||||
if (!loc.getBlock().getRelative(BlockFace.DOWN).isLiquid())
|
||||
continue;
|
||||
|
||||
_lillyPads.remove(loc);
|
||||
|
||||
MapUtil.QuickChangeBlockAt(loc, Material.WATER_LILY);
|
||||
|
||||
// Sound
|
||||
loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 111);
|
||||
}
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
// @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));
|
||||
// }
|
||||
|
||||
protected 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
|
||||
{
|
||||
_stemsGrown = true;
|
||||
}
|
||||
|
||||
if (_stemsGrown && _mushroomTop != null && !_mushroomTop.isEmpty())
|
||||
{
|
||||
int attempts = 0;
|
||||
int done = 0;
|
||||
while (done < 6 && 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);
|
||||
|
||||
done++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void breakMushroom(BlockBreakEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
|
||||
if (event.getBlock().getTypeId() == 100 &&
|
||||
WorldData.GetCustomLocs("21").contains(event.getBlock().getLocation().add(0.5, 0, 0.5)))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
event.getBlock().setType(Material.AIR);
|
||||
|
||||
_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)))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
event.getBlock().setType(Material.AIR);
|
||||
|
||||
_mushroomTop.put(event.getBlock().getLocation(), System.currentTimeMillis() + (long)(Math.random() * 12000));
|
||||
}
|
||||
}
|
||||
|
||||
protected void BuildIce()
|
||||
{
|
||||
if (_iceBridge == null || _iceBridge.isEmpty() || UtilTime.elapsed(this.GetStateTime(), _bridgeTime + 120000))
|
||||
{
|
||||
WorldData.World.setStorm(false);
|
||||
return;
|
||||
}
|
||||
|
||||
WorldData.World.setStorm(true);
|
||||
|
||||
int attempts = 0;
|
||||
int done = 0;
|
||||
while (done < 5 && attempts < 400)
|
||||
{
|
||||
attempts++;
|
||||
|
||||
// Random Block
|
||||
Location loc = _iceBridge.get(UtilMath.r(_iceBridge.size()));
|
||||
|
||||
Block block = loc.getBlock().getRelative(BlockFace.DOWN);
|
||||
|
||||
if (!block.isLiquid())
|
||||
continue;
|
||||
|
||||
if (block.getRelative(BlockFace.NORTH).isLiquid() &&
|
||||
block.getRelative(BlockFace.EAST).isLiquid() &&
|
||||
block.getRelative(BlockFace.SOUTH).isLiquid() &&
|
||||
block.getRelative(BlockFace.WEST).isLiquid())
|
||||
continue;
|
||||
|
||||
_iceBridge.remove(loc);
|
||||
|
||||
if (Math.random() > 0.25)
|
||||
MapUtil.QuickChangeBlockAt(block.getLocation(), Material.PACKED_ICE);
|
||||
else
|
||||
MapUtil.QuickChangeBlockAt(block.getLocation(), Material.ICE);
|
||||
|
||||
done++;
|
||||
}
|
||||
}
|
||||
|
||||
protected void BuildWood()
|
||||
{
|
||||
if (_woodBridgeBlocks != null && !_woodBridgeBlocks.isEmpty())
|
||||
{
|
||||
ArrayList<Location> toDo = new ArrayList<Location>();
|
||||
|
||||
BlockFace[] faces = new BlockFace[] { BlockFace.NORTH,
|
||||
BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST };
|
||||
|
||||
for (Location loc : _woodBridgeBlocks.keySet())
|
||||
{
|
||||
if (_woodBridgeBlocks.get(loc) == 17)
|
||||
{
|
||||
int adjacent = 0;
|
||||
|
||||
for (BlockFace face : faces)
|
||||
if (loc.getBlock().getRelative(face).getTypeId() != 0)
|
||||
adjacent++;
|
||||
|
||||
if (adjacent > 0)
|
||||
toDo.add(loc);
|
||||
|
||||
} else if (_woodBridgeBlocks.get(loc) == 85)
|
||||
{
|
||||
if (loc.getBlock().getRelative(BlockFace.DOWN).getTypeId() == 0)
|
||||
continue;
|
||||
|
||||
toDo.add(loc);
|
||||
} else if (_woodBridgeBlocks.get(loc) == 126)
|
||||
{
|
||||
int adjacent = 0;
|
||||
|
||||
for (BlockFace face : faces)
|
||||
if (loc.getBlock().getRelative(face).getTypeId() != 0)
|
||||
adjacent++;
|
||||
|
||||
if (adjacent > 0)
|
||||
toDo.add(loc);
|
||||
}
|
||||
}
|
||||
|
||||
if (toDo.size() == 0)
|
||||
return;
|
||||
|
||||
for (Location loc : toDo)
|
||||
{
|
||||
int id = _woodBridgeBlocks.remove(loc);
|
||||
|
||||
Location source = loc.clone().add(0, 30, 0);
|
||||
|
||||
// Create Part
|
||||
FallingBlock block = loc.getWorld().spawnFallingBlock(source,
|
||||
id, (byte) 0);
|
||||
block.setVelocity(new Vector(0, -1, 0));
|
||||
BridgePart part = new BridgePart(block, loc, false);
|
||||
_bridgeParts.add(part);
|
||||
}
|
||||
}
|
||||
}
|
||||
// @EventHandler
|
||||
// public void breakMushroom(BlockBreakEvent event)
|
||||
// {
|
||||
// if (event.isCancelled())
|
||||
// return;
|
||||
//
|
||||
//
|
||||
// if (event.getBlock().getTypeId() == 100 &&
|
||||
// WorldData.GetCustomLocs("21").contains(event.getBlock().getLocation().add(0.5, 0, 0.5)))
|
||||
// {
|
||||
// event.setCancelled(true);
|
||||
// event.getBlock().setType(Material.AIR);
|
||||
//
|
||||
// _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)))
|
||||
// {
|
||||
// event.setCancelled(true);
|
||||
// event.getBlock().setType(Material.AIR);
|
||||
//
|
||||
// _mushroomTop.put(event.getBlock().getLocation(), System.currentTimeMillis() + (long)(Math.random() * 12000));
|
||||
// }
|
||||
// }
|
||||
|
||||
@EventHandler
|
||||
public void BridgeUpdate(UpdateEvent event)
|
||||
@ -1255,7 +895,7 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
while (!UtilBlock.airFoliage(block))
|
||||
{
|
||||
block = block.getRelative(BlockFace.UP);
|
||||
|
||||
|
||||
if (block.getY() >= 256)
|
||||
break;
|
||||
}
|
||||
@ -1268,15 +908,15 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
break;
|
||||
}
|
||||
|
||||
block = block.getRelative(BlockFace.UP);
|
||||
|
||||
if (block.getTypeId() == 0)
|
||||
if (block.getType() != Material.SNOW)
|
||||
{
|
||||
if (Math.random() > 0.5)
|
||||
block.setTypeId(39);
|
||||
else
|
||||
block.setTypeId(40);
|
||||
block = block.getRelative(BlockFace.UP);
|
||||
}
|
||||
|
||||
if (Math.random() > 0.5)
|
||||
block.setTypeId(39);
|
||||
else
|
||||
block.setTypeId(40);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2023,23 +1663,32 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
}
|
||||
}
|
||||
|
||||
// @EventHandler
|
||||
// public void liquidBlockDeny(BlockBreakEvent event)
|
||||
// {
|
||||
// if (_bridgesDown)
|
||||
// return;
|
||||
//
|
||||
// if (!IsAlive(event.getPlayer()))
|
||||
// return;
|
||||
//
|
||||
// if (event.getBlock().getRelative(BlockFace.UP).isLiquid() || event.getBlock().getRelative(BlockFace.UP).getRelative(BlockFace.UP).isLiquid())
|
||||
// {
|
||||
// UtilPlayer.message(event.getPlayer(), F.main("Game",
|
||||
// "Cannot tunnel under liquids."));
|
||||
//
|
||||
// event.setCancelled(true);
|
||||
// }
|
||||
// }
|
||||
@EventHandler(priority=EventPriority.LOWEST)
|
||||
public void revivePlayer(EntityDamageEvent event)
|
||||
{
|
||||
if (_bridgesDown || !(event.getEntity() instanceof Player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
if (player.getHealth() - event.getDamage() > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_usedLife.contains(player.getName()))
|
||||
{
|
||||
_usedLife.add(player.getName());
|
||||
|
||||
UtilPlayer.message(player, F.main("Game", "You used your " + F.elem(C.cAqua + "Early Game Revive") + "."));
|
||||
|
||||
GetTeam(player).SpawnTeleport(player);
|
||||
player.setHealth(20);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void vehicleDeny(PlayerInteractEvent event)
|
||||
@ -2089,6 +1738,40 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot pickup liquids before the bridges have fallen."));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void disableDoors(CraftItemEvent event)
|
||||
{
|
||||
if (_bridgesDown)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Material type = event.getRecipe().getResult().getType();
|
||||
|
||||
if (type == Material.WOOD_DOOR || type == Material.IRON_DOOR)
|
||||
{
|
||||
event.setResult(null);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void disableDoors(PlayerPickupItemEvent event)
|
||||
{
|
||||
if (_bridgesDown)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Material type = event.getItem().getItemStack().getType();
|
||||
|
||||
if (type == Material.WOOD_DOOR || type == Material.IRON_DOOR)
|
||||
{
|
||||
event.getItem().remove();
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void setBridgeTime(int time)
|
||||
{
|
||||
|
@ -7,7 +7,9 @@ public enum BridgeAnimationType
|
||||
|
||||
WOOD(WoodBridgeAnimation.class, "BROWN", "GRAY"),
|
||||
ICE(IceBridgeAnimation.class, "LIGHT_BLUE"),
|
||||
LAVA(LavaBridgeAnimation.class, "BLACK", "RED", "ORANGE")
|
||||
LAVA(LavaBridgeAnimation.class, "BLACK", "RED", "ORANGE"),
|
||||
LILLY(LillyPadBridgeAnimation.class, "LIME"),
|
||||
MUSHROOM(MushroomBridgeAnimation.class, "PURPLE")
|
||||
|
||||
;
|
||||
|
||||
|
@ -0,0 +1,65 @@
|
||||
package nautilus.game.arcade.game.games.bridge.animation;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
|
||||
import mineplex.core.common.util.MapUtil;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import nautilus.game.arcade.game.games.bridge.Bridge;
|
||||
|
||||
public class LillyPadBridgeAnimation extends BridgeAnimation
|
||||
{
|
||||
|
||||
private Map<Location, Long> _lillyPads = new HashMap<>();
|
||||
|
||||
public LillyPadBridgeAnimation(Bridge bridge)
|
||||
{
|
||||
super(bridge);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onParse()
|
||||
{
|
||||
for (Location loc : _worldData.GetDataLocs("LIME"))
|
||||
{
|
||||
_lillyPads.put(loc, 0L);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(UpdateType type)
|
||||
{
|
||||
if (type != UpdateType.FASTEST)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (_lillyPads != null && !_lillyPads.isEmpty())
|
||||
{
|
||||
// Random Block
|
||||
Location loc = UtilAlg.Random(_lillyPads.keySet());
|
||||
|
||||
if (!UtilTime.elapsed(_lillyPads.get(loc), 8000))
|
||||
continue;
|
||||
|
||||
if (!loc.getBlock().getRelative(BlockFace.DOWN).isLiquid())
|
||||
continue;
|
||||
|
||||
_lillyPads.remove(loc);
|
||||
|
||||
MapUtil.QuickChangeBlockAt(loc, Material.WATER_LILY);
|
||||
|
||||
// Sound
|
||||
loc.getWorld().playEffect(loc, Effect.STEP_SOUND, 111);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
package nautilus.game.arcade.game.games.bridge.animation;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
|
||||
import mineplex.core.common.util.MapUtil;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import nautilus.game.arcade.game.games.bridge.Bridge;
|
||||
|
||||
public class MushroomBridgeAnimation extends BridgeAnimation
|
||||
{
|
||||
|
||||
private Map<Location, Long> _mushroomStem = new HashMap<>();
|
||||
private Map<Location, Long> _mushroomTop = new HashMap<>();
|
||||
private boolean _stemsGrown = false;
|
||||
|
||||
public MushroomBridgeAnimation(Bridge bridge)
|
||||
{
|
||||
super(bridge);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onParse()
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(UpdateType type)
|
||||
{
|
||||
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
|
||||
{
|
||||
_stemsGrown = true;
|
||||
}
|
||||
|
||||
if (_stemsGrown && _mushroomTop != null && !_mushroomTop.isEmpty())
|
||||
{
|
||||
int attempts = 0;
|
||||
int done = 0;
|
||||
while (done < 6 && 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);
|
||||
|
||||
done++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -44,7 +44,7 @@ public class KitDestructor extends ProgressingKit
|
||||
{
|
||||
super(manager, "Destructor", "bridgedesctructor", KitAvailability.Achievement, 99999, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND);
|
||||
|
||||
this.setAchievementRequirements(ACHIEVEMENTS);
|
||||
setAchievementRequirements(ACHIEVEMENTS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,7 +14,6 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
@ -29,7 +28,6 @@ import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.events.PlayerPrepareTeleportEvent;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.games.AbsorptionFix;
|
||||
import nautilus.game.arcade.game.games.bridge.Bridge;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
@ -72,38 +70,8 @@ public class OverpoweredBridge extends Bridge
|
||||
public void ParseData()
|
||||
{
|
||||
_starterChests = new HashMap<>();
|
||||
|
||||
ParseLavaBridge();
|
||||
ParseWoodBridge();
|
||||
ParseIceBridge();
|
||||
ParseLillyPad();
|
||||
ParseMushrooms();
|
||||
|
||||
ParseChests();
|
||||
|
||||
ParseOre(WorldData.GetCustomLocs("73")); // Red
|
||||
ParseOre(WorldData.GetCustomLocs("14")); // Yellow
|
||||
ParseOre(WorldData.GetCustomLocs("129")); // Green
|
||||
ParseOre(WorldData.GetCustomLocs("56")); // Blue
|
||||
|
||||
//Mass Teams
|
||||
if (!WorldData.GetCustomLocs("152").isEmpty())
|
||||
ParseOre(WorldData.GetCustomLocs("152"));
|
||||
if (!WorldData.GetCustomLocs("41").isEmpty())
|
||||
ParseOre(WorldData.GetCustomLocs("41"));
|
||||
if (!WorldData.GetCustomLocs("133").isEmpty())
|
||||
ParseOre(WorldData.GetCustomLocs("133"));
|
||||
if (!WorldData.GetCustomLocs("57").isEmpty())
|
||||
ParseOre(WorldData.GetCustomLocs("57"));
|
||||
|
||||
if (!WorldData.GetCustomLocs("100").isEmpty())
|
||||
ParseOre(WorldData.GetCustomLocs("100"));
|
||||
if (!WorldData.GetCustomLocs("86").isEmpty())
|
||||
ParseOre(WorldData.GetCustomLocs("86"));
|
||||
if (!WorldData.GetCustomLocs("103").isEmpty())
|
||||
ParseOre(WorldData.GetCustomLocs("103"));
|
||||
if (!WorldData.GetCustomLocs("22").isEmpty())
|
||||
ParseOre(WorldData.GetCustomLocs("22"));
|
||||
|
||||
super.ParseData();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -294,7 +294,9 @@ public class PerkDestructor extends Perk
|
||||
|
||||
if (lowest != null)
|
||||
{
|
||||
if (lowest.getType() != Material.AIR && UtilBlock.airFoliage(lowest.getRelative(BlockFace.DOWN)))
|
||||
Block down = lowest.getRelative(BlockFace.DOWN);
|
||||
|
||||
if (lowest.getType() != Material.AIR && (UtilBlock.airFoliage(down) || down.isLiquid()))
|
||||
{
|
||||
lowest.getWorld().playEffect(lowest.getLocation(), Effect.STEP_SOUND, lowest.getType());
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package nautilus.game.arcade.stats;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -40,6 +41,11 @@ public class FoodForTheMassesStatTracker extends StatTracker<Game>
|
||||
Player player = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName());
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
if (killer.getItemInHand().getType() != Material.APPLE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.GetLog().GetKiller().GetReason() != null && event.GetLog().GetKiller().GetReason().contains("Apple Thrower"))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user