Merge remote-tracking branch 'update/bridges' into develop

This commit is contained in:
cnr 2017-03-22 22:37:43 -05:00
commit 7e8f5b4939
24 changed files with 1339 additions and 524 deletions

View File

@ -372,11 +372,12 @@ public class UtilParticle
int count, ViewDist dist, Player... players) int count, ViewDist dist, Player... players)
{ {
PacketPlayOutWorldParticles packet = getPacket(particle, location, offsetX, offsetY, offsetZ, speed, count, true); PacketPlayOutWorldParticles packet = getPacket(particle, location, offsetX, offsetY, offsetZ, speed, count, true);
int distValue = dist.getDist() * dist.getDist();
for (Player player : players) for (Player player : players)
{ {
// Out of range for player // Out of range for player
if (UtilMath.offset(player.getLocation(), location) > dist.getDist()) if (UtilMath.offsetSquared(player.getLocation(), location) > distValue)
continue; continue;
UtilPlayer.sendPacket(player, packet); UtilPlayer.sendPacket(player, packet);

View File

@ -1,6 +0,0 @@
package nautilus.game.arcade.game.games.bridge;
public class BattleCryManager
{
}

View File

@ -1,6 +1,5 @@
package nautilus.game.arcade.game.games.bridge; package nautilus.game.arcade.game.games.bridge;
import com.google.common.collect.Lists;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.*; import mineplex.core.common.util.*;
import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilEvent.ActionType;
@ -13,17 +12,28 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerDeathOutEvent; import nautilus.game.arcade.game.DebugCommand;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.bridge.animation.BridgeAnimation;
import nautilus.game.arcade.game.games.bridge.animation.BridgeAnimationType;
import nautilus.game.arcade.game.games.bridge.animation.custom.CustomBridgeAnimation;
import nautilus.game.arcade.game.games.bridge.animation.custom.RadiusCustomBridgeAnimation;
import nautilus.game.arcade.game.games.bridge.animation.custom.RandomCustomBridgeAnimation;
import nautilus.game.arcade.game.games.bridge.kits.*; import nautilus.game.arcade.game.games.bridge.kits.*;
import nautilus.game.arcade.game.modules.WorldBorderModule;
import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit; 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.OreHider;
import nautilus.game.arcade.ore.OreObsfucation; import nautilus.game.arcade.ore.OreObsfucation;
import nautilus.game.arcade.stats.*; import nautilus.game.arcade.stats.*;
import org.bukkit.*; import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.Chest; import org.bukkit.block.Chest;
@ -38,14 +48,19 @@ import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.event.player.*; import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerBucketFillEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.CraftingInventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit;
public class Bridge extends TeamGame implements OreObsfucation public class Bridge extends TeamGame implements OreObsfucation
{ {
@ -54,29 +69,24 @@ public class Bridge extends TeamGame implements OreObsfucation
*/ */
private static final Material[] PLAYER_DROP_DELAY_MATERIALS = new Material[] { Material.LOG, Material.LOG_2, Material.IRON_ORE, Material.DIAMOND_ORE, Material.COAL_ORE, Material.GOLD_ORE, Material.WORKBENCH, Material.FURNACE }; private static final Material[] PLAYER_DROP_DELAY_MATERIALS = new Material[] { Material.LOG, Material.LOG_2, Material.IRON_ORE, Material.DIAMOND_ORE, Material.COAL_ORE, Material.GOLD_ORE, Material.WORKBENCH, Material.FURNACE };
//Bridge Timer /**
private int _bridgeTime = 600000; * The number of milliseconds from the game start time til the bridges should be built.
*/
private static final long BRIDGE_TIME = TimeUnit.MINUTES.toMillis(10);
/**
* The number of ticks after the prepare state that we wait before setting the world border for the players. Just to make sure they are in the correct world.
*/
private static final int WORLD_BORDER_PREPARE_TICKS = 20;
private static final String CUSTOM_BRIDGE_KEY = "TYPE";
//Bridge
private long _bridgeTime = BRIDGE_TIME;
private boolean _bridgesDown = false; private boolean _bridgesDown = false;
private BridgeAnimation _animation;
//Wood Bridge private CustomBridgeAnimation[] _customAnimations;
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>(); private HashSet<BridgePart> _bridgeParts = new HashSet<BridgePart>();
//Animals //Animals
@ -97,14 +107,14 @@ public class Bridge extends TeamGame implements OreObsfucation
private int _buildHeight = -1; private int _buildHeight = -1;
//Player Respawn //Player Respawn
private HashSet<String> _usedLife = new HashSet<String>(); private Set<String> _usedLife = new HashSet<>();
//Tourney Mode //Tourney Mode
private boolean _tournament; private boolean _tournament;
private HashMap<GameTeam, Integer> _tournamentKills = new HashMap<GameTeam, Integer>(); private HashMap<GameTeam, Integer> _tournamentKills = new HashMap<GameTeam, Integer>();
private long _tournamentKillMessageTimer = 0; private long _tournamentKillMessageTimer = 0;
@SuppressWarnings("unchecked")
public Bridge(ArcadeManager manager) public Bridge(ArcadeManager manager)
{ {
this(manager, GameType.Bridge); this(manager, GameType.Bridge);
@ -154,36 +164,14 @@ public class Bridge extends TeamGame implements OreObsfucation
"The last team alive wins!" "The last team alive wins!"
}); });
List<Kit> kits = Lists.newArrayList(GetKits());
List<Kit> finalKits = Lists.newArrayList(kits);
boolean foundBrawler = false;
for(int i = 0; i < kits.size(); i++)
{
Kit kit = kits.get(i);
if(kit.GetName().equalsIgnoreCase("Brawler"))
{
if(!foundBrawler)
{
foundBrawler = true;
}
else
{
finalKits.remove(i);
}
}
}
setKits(finalKits.toArray(new Kit[finalKits.size()]));
_ore = new OreHider(); _ore = new OreHider();
// Flags // Flags
GameTimeout = Manager.IsTournamentServer() ? 5400000 : 3600000; GameTimeout = Manager.IsTournamentServer() ? TimeUnit.MINUTES.toMillis(90) : TimeUnit.MINUTES.toMillis(60);
Manager.GetExplosion().SetLiquidDamage(false); Manager.GetExplosion().SetLiquidDamage(false);
this.StrictAntiHack = true; StrictAntiHack = true;
DamageSelf = true; DamageSelf = true;
@ -206,10 +194,6 @@ public class Bridge extends TeamGame implements OreObsfucation
WorldWaterDamage = 0; WorldWaterDamage = 0;
WorldBoundaryKill = false; WorldBoundaryKill = false;
new CompassModule()
.setGiveCompassToAlive(true)
.register(this);
DeathDropItems = true; DeathDropItems = true;
GemMultiplier = 2.5; GemMultiplier = 2.5;
@ -229,35 +213,108 @@ public class Bridge extends TeamGame implements OreObsfucation
"Killing yourself counts as -1 team kill.", "Killing yourself counts as -1 team kill.",
"Team with the most kills wins!" "Team with the most kills wins!"
}; };
_tournament = true;
} }
_customAnimations = new CustomBridgeAnimation[] {
_tournament = Manager.IsTournamentServer(); new RandomCustomBridgeAnimation(this),
new RadiusCustomBridgeAnimation(this)
};
new CompassModule()
.setGiveCompassToAlive(true)
.register(this);
new WorldBorderModule().register(this);
// So that we can be 110% sure
for (Kit kit : GetKits())
{
if (kit instanceof KitDestructor)
{
for (Perk perk : kit.GetPerks())
{
((PerkDestructor) perk).setEnabled(false);
break;
}
break;
}
}
registerDebugCommand(new DebugCommand("bridge", Rank.ADMIN)
{
@Override
public void Execute(Player caller, String[] args)
{
caller.sendMessage(F.main("Debug", "Spawning the bridges."));
_bridgeTime = 3000;
}
});
registerDebugCommand(new DebugCommand("bridgeinfo", getArcadeManager().getGameCommandRank())
{
@Override
public void Execute(Player caller, String[] args)
{
if (_animation == null || !(_animation instanceof CustomBridgeAnimation))
{
caller.sendMessage(F.main("Debug", "The bridge animation for this map isn't a custom one."));
return;
}
caller.sendMessage(F.main("Debug", "Bridge Info:"));
caller.sendMessage(_animation.toString());
}
});
} }
@EventHandler @EventHandler
public void PlayerOut(final PlayerDeathOutEvent event) public void prepare(GameStateChangeEvent event)
{ {
if (_bridgesDown) if (event.GetState() != GameState.Prepare)
return;
Player player = event.GetPlayer();
if (!_usedLife.contains(player.getName()))
{ {
_usedLife.add(player.getName()); return;
UtilPlayer.message(player, F.main("Game", "You used your " + F.elem(C.cAqua + "Early Game Revive") + "."));
event.setCancelled(true);
} }
}
//Delay this so that we are 100% sure people are in the world.
Manager.runSyncLater(() -> {
WorldBorderModule borderModule = getModule(WorldBorderModule.class);
// Here we do some calculations for per player world borders
for (GameTeam team : GetTeamList())
{
// Step 1 - Get the average location of the spawns, we assume this is generally in an OK position.
Location center = UtilAlg.getAverageLocation(team.GetSpawns());
// Step 1.5 - Move the location back a bit from the centre, this is usually because spawns are on the inside edge of the islands.
center.add(UtilAlg.getTrajectory(SpectatorSpawn, center).multiply(15));
// 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) * 0.9;
// 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);
}
}
}, WORLD_BORDER_PREPARE_TICKS);
}
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void GameStateChange(GameStateChangeEvent event) public void live(GameStateChangeEvent event)
{ {
if (event.GetState() != GameState.Live) if (event.GetState() != GameState.Live)
{
return; return;
}
if (!WorldData.GetCustomLocs("WATER_DAMAGE").isEmpty()) if (!WorldData.GetCustomLocs("WATER_DAMAGE").isEmpty())
{ {
@ -266,24 +323,72 @@ public class Bridge extends TeamGame implements OreObsfucation
if (WorldWaterDamage > 0) if (WorldWaterDamage > 0)
{ {
if (WorldData.MapName.equals("Volcanic Islands")) String name = WorldData.MapName;
if (name.equals("Volcanic Islands"))
{
UtilTextMiddle.display(C.cRed + "Warning", "Water is Boiling Hot", 10, 60, 20); UtilTextMiddle.display(C.cRed + "Warning", "Water is Boiling Hot", 10, 60, 20);
}
else if (WorldData.MapName.equals("Icelands")) else if (WorldData.MapName.equals("Icelands"))
{
UtilTextMiddle.display(C.cRed + "Warning", "Water is Freezing Cold", 10, 60, 20); UtilTextMiddle.display(C.cRed + "Warning", "Water is Freezing Cold", 10, 60, 20);
}
else else
{
UtilTextMiddle.display(C.cRed + "Warning", "Water is Deadly", 10, 60, 20); UtilTextMiddle.display(C.cRed + "Warning", "Water is Deadly", 10, 60, 20);
}
} }
} }
//parse
@Override @Override
public void ParseData() public void ParseData()
{ {
ParseLavaBridge(); // Now we need to decide on what bridge animation.
ParseWoodBridge(); typeLoop : for (BridgeAnimationType type : BridgeAnimationType.values())
ParseIceBridge(); {
ParseLillyPad(); for (String colours : type.getColoursUsed())
ParseMushrooms(); {
if (WorldData.GetDataLocs(colours).isEmpty())
{
continue typeLoop;
}
}
_animation = type.createInstance(this);
break;
}
// If none of the premade ones are usable then we need a custom one!
if (_animation == null)
{
locationLoop : for (String key : WorldData.GetAllCustomLocs().keySet())
{
if (!key.startsWith(CUSTOM_BRIDGE_KEY))
{
continue;
}
String[] split = key.split(" ");
if (split.length < 2)
{
continue;
}
String subKey = split[1];
for (CustomBridgeAnimation animation : _customAnimations)
{
if (animation.getTypeKey().equalsIgnoreCase(subKey))
{
_animation = animation;
break locationLoop;
}
}
}
}
_animation.onParse();
ParseChests(); ParseChests();
@ -403,8 +508,6 @@ public class Bridge extends TeamGame implements OreObsfucation
} }
} }
public void ParseOre(ArrayList<Location> teamOre) public void ParseOre(ArrayList<Location> teamOre)
{ {
int coal = (int) ((teamOre.size() / 32d) * _oreDensity); int coal = (int) ((teamOre.size() / 32d) * _oreDensity);
@ -625,368 +728,45 @@ 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 @EventHandler
public void BridgeBuild(UpdateEvent event) public void BridgeBuild(UpdateEvent event)
{ {
if (!IsLive()) if (!IsLive() || !UtilTime.elapsed(GetStateTime(), _bridgeTime))
{
return; return;
}
if (event.getType() != UpdateType.FASTEST) if (_animation != null)
return; {
_animation.onUpdate(event.getType());
}
if (!UtilTime.elapsed(this.GetStateTime(), _bridgeTime)) if (event.getType() != UpdateType.FAST)
{
return; return;
}
if (!_bridgesDown) if (!_bridgesDown)
{ {
_bridgesDown = true;
WorldBorderModule borderModule = getModule(WorldBorderModule.class);
for (Player player : GetPlayers(true))
{
borderModule.setSize(player, 10000);
}
Manager.GetExplosion().SetLiquidDamage(true); Manager.GetExplosion().SetLiquidDamage(true);
this.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!");
_bridgesDown = true; for (Kit kit : GetKits())
for (Kit kit : this.GetKits())
{
if (kit instanceof KitDestructor)
{ {
((KitDestructor)kit).SetEnabled(true); if (kit instanceof KitDestructor)
}
}
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));
}
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)) ((KitDestructor) kit).SetEnabled(true);
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);
} }
} }
} }
@ -1106,7 +886,7 @@ public class Bridge extends TeamGame implements OreObsfucation
while (!UtilBlock.airFoliage(block)) while (!UtilBlock.airFoliage(block))
{ {
block = block.getRelative(BlockFace.UP); block = block.getRelative(BlockFace.UP);
if (block.getY() >= 256) if (block.getY() >= 256)
break; break;
} }
@ -1119,15 +899,15 @@ public class Bridge extends TeamGame implements OreObsfucation
break; break;
} }
block = block.getRelative(BlockFace.UP); if (block.getType() != Material.SNOW)
if (block.getTypeId() == 0)
{ {
if (Math.random() > 0.5) block = block.getRelative(BlockFace.UP);
block.setTypeId(39);
else
block.setTypeId(40);
} }
if (Math.random() > 0.5)
block.setTypeId(39);
else
block.setTypeId(40);
} }
} }
@ -1515,7 +1295,7 @@ public class Bridge extends TeamGame implements OreObsfucation
else else
{ {
Scoreboard.write(C.cYellow + C.Bold + "Time Left"); Scoreboard.write(C.cYellow + C.Bold + "Time Left");
Scoreboard.write(UtilTime.MakeStr(5400000 - (System.currentTimeMillis() - this.GetStateTime()), 0)); Scoreboard.write(UtilTime.MakeStr(GameTimeout - (System.currentTimeMillis() - GetStateTime()), 0));
} }
Scoreboard.draw(); Scoreboard.draw();
@ -1681,7 +1461,7 @@ public class Bridge extends TeamGame implements OreObsfucation
{ {
_tournamentKillMessageTimer = System.currentTimeMillis(); _tournamentKillMessageTimer = System.currentTimeMillis();
this.Announce(C.cRed + C.Bold + "ALERT: " + ChatColor.RESET + C.Bold + "FIRST TEAM TO HAVE MOST KILLS WINS!"); Announce(C.cRed + C.Bold + "ALERT: " + C.Reset + C.Bold + "FIRST TEAM TO HAVE MOST KILLS WINS!");
} }
} }
@ -1874,23 +1654,32 @@ public class Bridge extends TeamGame implements OreObsfucation
} }
} }
// @EventHandler @EventHandler(priority=EventPriority.LOWEST)
// public void liquidBlockDeny(BlockBreakEvent event) public void revivePlayer(CustomDamageEvent event)
// { {
// if (_bridgesDown) if (!IsLive() || _bridgesDown || !(event.GetDamageeEntity() instanceof Player))
// return; {
// return;
// if (!IsAlive(event.getPlayer())) }
// return;
// Player player = event.GetDamageePlayer();
// if (event.getBlock().getRelative(BlockFace.UP).isLiquid() || event.getBlock().getRelative(BlockFace.UP).getRelative(BlockFace.UP).isLiquid())
// { if (player.getHealth() - event.GetDamage() > 0)
// UtilPlayer.message(event.getPlayer(), F.main("Game", {
// "Cannot tunnel under liquids.")); return;
// }
// event.setCancelled(true);
// } 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("Early Game Revive");
}
}
@EventHandler @EventHandler
public void vehicleDeny(PlayerInteractEvent event) public void vehicleDeny(PlayerInteractEvent event)
@ -1915,16 +1704,6 @@ public class Bridge extends TeamGame implements OreObsfucation
else else
return 12; return 12;
} }
@EventHandler
public void debug(PlayerCommandPreprocessEvent event)
{
if (Manager.GetClients().hasRank(event.getPlayer(), Rank.ADMIN) && event.getMessage().contains("/oretoggle"))
_ore.ToggleVisibility();
if (Manager.GetClients().hasRank(event.getPlayer(), Rank.ADMIN) && event.getMessage().contains("/bridge"))
_bridgeTime = 30000;
}
@EventHandler @EventHandler
public void disableIceForm(BlockFormEvent event) public void disableIceForm(BlockFormEvent event)
@ -1940,6 +1719,40 @@ public class Bridge extends TeamGame implements OreObsfucation
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot pickup liquids before the bridges have fallen.")); UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot pickup liquids before the bridges have fallen."));
event.setCancelled(true); 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) public void setBridgeTime(int time)
{ {
@ -1961,6 +1774,11 @@ public class Bridge extends TeamGame implements OreObsfucation
return _chestLoot; return _chestLoot;
} }
public HashSet<BridgePart> getBridgeParts()
{
return _bridgeParts;
}
public boolean bridgesDown() public boolean bridgesDown()
{ {
return _bridgesDown; return _bridgesDown;

View File

@ -0,0 +1,45 @@
package nautilus.game.arcade.game.games.bridge.animation;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import mineplex.core.updater.UpdateType;
import nautilus.game.arcade.game.games.bridge.Bridge;
import nautilus.game.arcade.game.games.bridge.BridgePart;
import nautilus.game.arcade.world.WorldData;
public abstract class BridgeAnimation
{
public static final int AVERAGE_BRIDGE_BLOCKS = 3000;
protected final Bridge _bridge;
protected final WorldData _worldData;
public BridgeAnimation(Bridge bridge)
{
_bridge = bridge;
_worldData = bridge.WorldData;
}
public abstract void onParse();
public abstract void onUpdate(UpdateType type);
public void registerBridgePart(BridgePart part)
{
_bridge.getBridgeParts().add(part);
}
public boolean isAir(Location location)
{
return isAir(location.getBlock());
}
public boolean isAir(Block block)
{
return block.getType() == Material.AIR;
}
}

View File

@ -0,0 +1,44 @@
package nautilus.game.arcade.game.games.bridge.animation;
import nautilus.game.arcade.game.games.bridge.Bridge;
public enum BridgeAnimationType
{
WOOD(WoodBridgeAnimation.class, "BROWN", "GRAY"),
ICE(IceBridgeAnimation.class, "LIGHT_BLUE"),
LAVA(LavaBridgeAnimation.class, "BLACK", "RED", "ORANGE"),
LILLY(LillyPadBridgeAnimation.class, "LIME"),
MUSHROOM(MushroomBridgeAnimation.class, "PURPLE")
;
private final Class<? extends BridgeAnimation> _clazz;
private final String[] _coloursUsed;
private BridgeAnimationType(Class<? extends BridgeAnimation> clazz, String... coloursUsed)
{
_clazz = clazz;
_coloursUsed = coloursUsed;
}
public BridgeAnimation createInstance(Bridge bridge)
{
try
{
return _clazz.cast(_clazz.getConstructor(Bridge.class).newInstance(bridge));
}
catch (Exception e)
{
e.printStackTrace();
}
return null;
}
public String[] getColoursUsed()
{
return _coloursUsed;
}
}

View File

@ -0,0 +1,79 @@
package nautilus.game.arcade.game.games.bridge.animation;
import java.util.ArrayList;
import java.util.List;
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.updater.UpdateType;
import nautilus.game.arcade.game.games.bridge.Bridge;
public class IceBridgeAnimation extends BridgeAnimation
{
private List<Location> _iceBridge;
public IceBridgeAnimation(Bridge bridge)
{
super(bridge);
_iceBridge = new ArrayList<>(AVERAGE_BRIDGE_BLOCKS);
}
@Override
public void onParse()
{
_iceBridge = _worldData.GetDataLocs("LIGHT_BLUE");
}
@Override
public void onUpdate(UpdateType type)
{
if (type != UpdateType.FASTEST || _iceBridge.isEmpty())
{
return;
}
int attempts = 0;
int done = 0;
while (done < 5 && attempts < 400)
{
attempts++;
// Random Block
Location loc = UtilAlg.Random(_iceBridge);
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++;
}
}
}

View File

@ -0,0 +1,84 @@
package nautilus.game.arcade.game.games.bridge.animation;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.FallingBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.updater.UpdateType;
import nautilus.game.arcade.game.games.bridge.Bridge;
import nautilus.game.arcade.game.games.bridge.BridgePart;
public class LavaBridgeAnimation extends BridgeAnimation
{
private List<Location> _lavaSource;
private List<Location> _lavaBridge;
public LavaBridgeAnimation(Bridge bridge)
{
super(bridge);
_lavaSource = new ArrayList<>();
_lavaBridge = new ArrayList<>(AVERAGE_BRIDGE_BLOCKS);
}
@Override
public void onParse()
{
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");
}
@Override
public void onUpdate(UpdateType type)
{
if (type != UpdateType.FASTEST)
{
return;
}
for (int i = 0; i < 3; i++)
{
if (!_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, Material.NETHERRACK, (byte) 0);
BridgePart part = new BridgePart(block, bestLoc, true);
registerBridgePart(part);
// Sound
source.getWorld().playSound(source, Sound.EXPLODE, 5f * (float) Math.random(), 0.5f + (float) Math.random());
}
}
}
}

View File

@ -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);
}
}
}
}

View File

@ -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++;
}
}
}
}

View File

@ -0,0 +1,129 @@
package nautilus.game.arcade.game.games.bridge.animation;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.FallingBlock;
import org.bukkit.util.Vector;
import mineplex.core.updater.UpdateType;
import nautilus.game.arcade.game.games.bridge.Bridge;
import nautilus.game.arcade.game.games.bridge.BridgePart;
public class WoodBridgeAnimation extends BridgeAnimation
{
private static final BlockFace[] FACES = new BlockFace[] { BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST };
private static final int Y_MOD = 30;
private final Map<Location, Material> _woodBridge;
public WoodBridgeAnimation(Bridge bridge)
{
super(bridge);
_woodBridge = new HashMap<>(AVERAGE_BRIDGE_BLOCKS);
}
@Override
public void onParse()
{
onParse(_worldData.GetDataLocs("BROWN"), false);
onParse(_worldData.GetDataLocs("GRAY"), true);
}
public void onParse(List<Location> locations, boolean aboveBelow)
{
for (Location location : locations)
{
if (aboveBelow)
{
_woodBridge.put(location.getBlock().getRelative(BlockFace.UP).getLocation(), Material.FENCE);
_woodBridge.put(location, Material.LOG);
}
else
{
_woodBridge.put(location, Material.WOOD_STEP);
}
}
}
@Override
public void onUpdate(UpdateType type)
{
if (type != UpdateType.FASTEST)
{
return;
}
List<Location> toDo = new ArrayList<>();
for (Location location : _woodBridge.keySet())
{
Material material = _woodBridge.get(location);
if (material == Material.LOG)
{
int adjacent = 0;
for (BlockFace face : FACES)
{
if (!isAir(location.getBlock().getRelative(face)))
{
adjacent++;
}
}
if (adjacent > 0)
{
toDo.add(location);
}
}
else if (material == Material.FENCE)
{
if (!isAir(location.getBlock().getRelative(BlockFace.DOWN)))
{
toDo.add(location);
}
}
else if (material == Material.WOOD_STEP)
{
int adjacent = 0;
for (BlockFace face : FACES)
{
if (!isAir(location.getBlock().getRelative(face)))
{
adjacent++;
}
}
if (adjacent > 0)
{
toDo.add(location);
}
}
}
if (toDo.isEmpty())
{
return;
}
for (Location location : toDo)
{
Material material = _woodBridge.remove(location);
Location source = location.clone().add(0, Y_MOD, 0);
// Create Part
FallingBlock block = location.getWorld().spawnFallingBlock(source, material, (byte) 0);
block.setVelocity(new Vector(0, -1, 0));
BridgePart part = new BridgePart(block, location, false);
registerBridgePart(part);
}
}
}

View File

@ -0,0 +1,246 @@
package nautilus.game.arcade.game.games.bridge.animation.custom;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.block.Block;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import nautilus.game.arcade.game.games.bridge.Bridge;
import nautilus.game.arcade.game.games.bridge.animation.BridgeAnimation;
public abstract class CustomBridgeAnimation extends BridgeAnimation
{
private static final String BLOCK_IDS_KEY = "BLOCK_IDS";
private static final String RATE_KEY = "RATE";
private static final String PARTICLE_KEY = "PARTICLE";
private static final String SOUND_KEY = "SOUND";
private static final String REGION_KEY = "BRIDGE";
protected final BlockRestore _restore;
private final String _typeKey;
protected final Map<Location, Double> _bridgeBlocks;
// Configuration
protected List<Integer> _blockIds;
protected int _rate;
protected ParticleType _particle;
// Sound
protected Sound _sound;
protected float _pitch;
protected double _maxDistance;
public CustomBridgeAnimation(Bridge bridge, String typeKey)
{
super(bridge);
_restore = bridge.getArcadeManager().GetBlockRestore();
_typeKey = typeKey;
_bridgeBlocks = new HashMap<>(AVERAGE_BRIDGE_BLOCKS);
// Defaults
// Wood, Logs, Fences
_blockIds = Arrays.asList(5, 17, 85);
_rate = 1;
_particle = ParticleType.BLOCK_DUST;
}
@Override
public void onParse()
{
List<Integer> blockIds = new ArrayList<>();
for (String key : _worldData.GetAllCustomLocs().keySet())
{
String[] split = key.split(" ");
String subKey = split[0];
if (split.length < 2)
{
continue;
}
switch (subKey)
{
case BLOCK_IDS_KEY:
// Set the block ids that the animation will use
for (int i = 1; i < split.length; i++)
{
try
{
blockIds.add(Integer.parseInt(split[i]));
}
catch (NumberFormatException e)
{
continue;
}
}
break;
case RATE_KEY:
// Set the rate at which the animation will run at
try
{
_rate = Integer.parseInt(split[1]);
}
catch (NumberFormatException e)
{
continue;
}
break;
case PARTICLE_KEY:
// Set which type of particle will be displayed when a block
// spawns
try
{
_particle = ParticleType.valueOf(split[1]);
}
catch (IllegalArgumentException e)
{
continue;
}
break;
case SOUND_KEY:
// Set the sound and pitch that will be played when a block
// spawns
if (split.length < 3)
{
continue;
}
try
{
_sound = Sound.valueOf(split[1]);
}
catch (IllegalArgumentException e)
{
continue;
}
try
{
_pitch = Float.parseFloat(split[2]);
}
catch (NumberFormatException e)
{
continue;
}
break;
default:
break;
}
}
// Set configuration values
_blockIds = blockIds;
// Save all blocks in a big map.
for (String key : _worldData.GetAllCustomLocs().keySet())
{
if (!key.startsWith(REGION_KEY))
{
continue;
}
List<Location> locations = _worldData.GetCustomLocs(key);
if (locations.size() < 2)
{
continue;
}
for (Block block : UtilBlock.getInBoundingBox(locations.get(0), locations.get(1)))
{
if (!_blockIds.contains(block.getTypeId()) || _bridgeBlocks.containsKey(block))
{
continue;
}
double dist = UtilMath.offset2d(block.getLocation(), _bridge.GetSpectatorLocation());
if (dist > _maxDistance)
{
_maxDistance = dist;
}
_restore.add(block, Material.AIR.getId(), (byte) 0, Integer.MAX_VALUE);
_bridgeBlocks.put(block.getLocation(), dist);
}
}
}
public void onBlockSet(Block block)
{
World world = _worldData.World;
Location location = block.getLocation().add(0.5, 0.5, 0.5);
if (_particle != null)
{
if (_particle == ParticleType.BLOCK_DUST)
{
world.playEffect(location, Effect.STEP_SOUND, block.getType(), block.getData());
}
else
{
UtilParticle.PlayParticleToAll(_particle, block.getLocation(), 0.5F, 0.5F, 0.5F, 0.5F, 5, ViewDist.NORMAL);
}
}
if (_sound != null)
{
world.playSound(location, _sound, 1, _pitch);
}
}
public final String getTypeKey()
{
return _typeKey;
}
@Override
public String toString()
{
StringBuilder builder = new StringBuilder();
builder.append("Type: " + _typeKey).append("\n");
builder.append("Bridge Blocks: " + _bridgeBlocks.size()).append("\n");
builder.append("Block Ids: " + _blockIds).append("\n");
builder.append("Rate: " + _rate).append("\n");
builder.append("Particle: " + (_particle == null ? "Null" : _particle.getFriendlyName())).append("\n");
builder.append("Sound: " + (_sound == null ? "Null" : _sound.toString() + " Pitch: " + _pitch)).append("\n");
builder.append("Max Distance: " + _maxDistance).append("\n");
return builder.toString();
}
}

View File

@ -0,0 +1,58 @@
package nautilus.game.arcade.game.games.bridge.animation.custom;
import java.util.Iterator;
import org.bukkit.Location;
import org.bukkit.block.Block;
import mineplex.core.updater.UpdateType;
import nautilus.game.arcade.game.games.bridge.Bridge;
public class RadiusCustomBridgeAnimation extends CustomBridgeAnimation
{
private double _minDistance;
public RadiusCustomBridgeAnimation(Bridge bridge)
{
super(bridge, "RADIUS");
}
@Override
public void onParse()
{
super.onParse();
_minDistance = _maxDistance;
}
@Override
public void onUpdate(UpdateType type)
{
if (type != UpdateType.FAST)
{
return;
}
_minDistance -= _rate;
Iterator<Location> iterator = _bridgeBlocks.keySet().iterator();
while (iterator.hasNext())
{
Location location = iterator.next();
double dist = _bridgeBlocks.get(location);
if (dist > _minDistance)
{
Block block = location.getBlock();
_restore.restore(block);
onBlockSet(block);
iterator.remove();
}
}
}
}

View File

@ -0,0 +1,44 @@
package nautilus.game.arcade.game.games.bridge.animation.custom;
import java.util.Iterator;
import org.bukkit.Location;
import org.bukkit.block.Block;
import mineplex.core.updater.UpdateType;
import nautilus.game.arcade.game.games.bridge.Bridge;
public class RandomCustomBridgeAnimation extends CustomBridgeAnimation
{
public RandomCustomBridgeAnimation(Bridge bridge)
{
super(bridge, "RANDOM");
}
@Override
public void onUpdate(UpdateType type)
{
if (type != UpdateType.TICK)
{
return;
}
Iterator<Location> iterator = _bridgeBlocks.keySet().iterator();
int i = 0;
while (iterator.hasNext() && i < _rate)
{
i++;
Location location = iterator.next();
Block block = location.getBlock();
_restore.restore(block);
onBlockSet(block);
iterator.remove();
}
}
}

View File

@ -36,4 +36,4 @@ public class KitApple extends ProgressingKit
{ {
} }
} }

View File

@ -53,6 +53,6 @@ public class KitArcher extends ProgressingKit
Bridge bridge = (Bridge) Manager.GetGame(); Bridge bridge = (Bridge) Manager.GetGame();
if(!bridge.hasUsedRevive(player)) if(!bridge.hasUsedRevive(player))
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW)); player.getInventory().addItem(PLAYER_ITEMS);
} }
} }

View File

@ -46,4 +46,4 @@ public class KitBerserker extends ProgressingKit
{ {
player.getInventory().addItem(PLAYER_ITEMS); player.getInventory().addItem(PLAYER_ITEMS);
} }
} }

View File

@ -44,7 +44,7 @@ public class KitDestructor extends ProgressingKit
{ {
super(manager, "Destructor", "bridgedesctructor", KitAvailability.Achievement, 99999, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND); super(manager, "Destructor", "bridgedesctructor", KitAvailability.Achievement, 99999, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND);
this.setAchievementRequirements(ACHIEVEMENTS); setAchievementRequirements(ACHIEVEMENTS);
} }
@Override @Override

View File

@ -14,7 +14,6 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.bukkit.inventory.meta.EnchantmentStorageMeta;
@ -29,7 +28,6 @@ import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; 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.AbsorptionFix;
import nautilus.game.arcade.game.games.bridge.Bridge; import nautilus.game.arcade.game.games.bridge.Bridge;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
@ -72,38 +70,8 @@ public class OverpoweredBridge extends Bridge
public void ParseData() public void ParseData()
{ {
_starterChests = new HashMap<>(); _starterChests = new HashMap<>();
ParseLavaBridge(); super.ParseData();
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"));
} }
@EventHandler @EventHandler

View File

@ -1,10 +1,7 @@
package nautilus.game.arcade.game.modules; package nautilus.game.arcade.game.modules;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import mineplex.core.Managers;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.TeamGame;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
/** /**

View File

@ -0,0 +1,116 @@
package nautilus.game.arcade.game.modules;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import mineplex.core.common.Pair;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketInfo;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game.GameState;
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder;
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder.EnumWorldBorderAction;
import net.minecraft.server.v1_8_R3.WorldBorder;
public class WorldBorderModule extends Module implements IPacketHandler
{
private PacketHandler _packetHandler;
private Map<UUID, Double> _sizeToSet;
private Map<UUID, Pair<Double, Double>> _centerToSet;
@Override
protected void setup()
{
_packetHandler = getGame().getArcadeManager().getPacketHandler();
_sizeToSet = new HashMap<>();
_centerToSet = new HashMap<>();
}
@EventHandler(priority = EventPriority.LOWEST)
public void live(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Prepare)
{
return;
}
_packetHandler.addPacketHandler(this, PacketPlayOutWorldBorder.class);
}
@Override
public void handle(PacketInfo packetInfo)
{
UUID player = packetInfo.getPlayer().getUniqueId();
PacketPlayOutWorldBorder packet = (PacketPlayOutWorldBorder) packetInfo.getPacket();
try
{
Field actionField = packet.getClass().getDeclaredField("a");
actionField.setAccessible(true);
EnumWorldBorderAction action = (EnumWorldBorderAction) actionField.get(packet);
if (action == EnumWorldBorderAction.SET_SIZE)
{
Field sizeField = packet.getClass().getDeclaredField("e");
sizeField.setAccessible(true);
double newSize = _sizeToSet.get(player);
sizeField.set(packet, newSize);
}
else if (action == EnumWorldBorderAction.SET_CENTER)
{
Field xField = packet.getClass().getDeclaredField("c");
Field zField = packet.getClass().getDeclaredField("d");
xField.setAccessible(true);
zField.setAccessible(true);
Pair<Double, Double> pair = _centerToSet.get(player);
xField.set(packet, pair.getLeft());
zField.set(packet, pair.getRight());
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
@Override
public void cleanup()
{
_packetHandler.removePacketHandler(this);
}
public void setSize(Player player, double size)
{
_sizeToSet.put(player.getUniqueId(), size);
sendPacket(player, EnumWorldBorderAction.SET_SIZE);
}
public void setCenter(Player player, Location location)
{
_centerToSet.put(player.getUniqueId(), Pair.create(location.getX(), location.getZ()));
sendPacket(player, EnumWorldBorderAction.SET_CENTER);
}
private void sendPacket(Player player, EnumWorldBorderAction action)
{
WorldBorder border = ((CraftWorld) player.getWorld()).getHandle().getWorldBorder();
UtilPlayer.sendPacket(player, new PacketPlayOutWorldBorder(border, action));
}
}

View File

@ -30,6 +30,7 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.donation.Donor; import mineplex.core.donation.Donor;
import mineplex.core.menu.Menu; import mineplex.core.menu.Menu;
import mineplex.core.progression.ProgressiveKit; import mineplex.core.progression.ProgressiveKit;
@ -53,6 +54,8 @@ import net.minecraft.server.v1_8_R3.World;
public abstract class ProgressingKit extends Kit implements ProgressiveKit public abstract class ProgressingKit extends Kit implements ProgressiveKit
{ {
public static final String COOLDOWN = "Cooldown";
private static final FireworkEffect EFFECT = FireworkEffect.builder() private static final FireworkEffect EFFECT = FireworkEffect.builder()
.withColor(Color.AQUA) .withColor(Color.AQUA)
.with(Type.BALL) .with(Type.BALL)
@ -420,6 +423,11 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit
return "Receive " + C.cGreen + amount + C.cWhite + " " + item + " every " + C.cGreen + time + C.cWhite + " second" + (time == 1 ? "" : "s") + return "Receive " + C.cGreen + amount + C.cWhite + " " + item + " every " + C.cGreen + time + C.cWhite + " second" + (time == 1 ? "" : "s") +
(max > 0 ? ". Max " + C.cGreen + max : ""); (max > 0 ? ". Max " + C.cGreen + max : "");
} }
public static String receiveItem(String item, int amount)
{
return "Receive " + (amount == 1 ? (UtilText.startsWithVowel(item) ? "an" :" a") : C.cGreen + amount) + " " + item;
}
public static String click(boolean left, String comp) public static String click(boolean left, String comp)
{ {

View File

@ -294,7 +294,9 @@ public class PerkDestructor extends Perk
if (lowest != null) 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()); lowest.getWorld().playEffect(lowest.getLocation(), Effect.STEP_SOUND, lowest.getType());

View File

@ -1,17 +1,16 @@
package nautilus.game.arcade.stats; package nautilus.game.arcade.stats;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class DeathBomberStatTracker extends StatTracker<Game> public class DeathBomberStatTracker extends StatTracker<Game>
{ {
@ -52,6 +51,11 @@ public class DeathBomberStatTracker extends StatTracker<Game>
if(killer.equals(killed)) if(killer.equals(killed))
return; return;
if (killer.getItemInHand().getType() != Material.TNT)
{
return;
}
if (event.GetLog().GetKiller() != null && event.GetLog().GetKiller().GetReason().contains("Throwing TNT")) if (event.GetLog().GetKiller() != null && event.GetLog().GetKiller().GetReason().contains("Throwing TNT"))
{ {
Integer count = _killCount.get(killer.getUniqueId()); Integer count = _killCount.get(killer.getUniqueId());

View File

@ -1,5 +1,6 @@
package nautilus.game.arcade.stats; package nautilus.game.arcade.stats;
import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -40,6 +41,11 @@ public class FoodForTheMassesStatTracker extends StatTracker<Game>
Player player = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName()); Player player = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName());
if (player == null) if (player == null)
return; return;
if (killer.getItemInHand().getType() != Material.APPLE)
{
return;
}
if (event.GetLog().GetKiller().GetReason() != null && event.GetLog().GetKiller().GetReason().contains("Apple Thrower")) if (event.GetLog().GetKiller().GetReason() != null && event.GetLog().GetKiller().GetReason().contains("Apple Thrower"))
{ {