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

This commit is contained in:
cnr 2017-04-06 00:33:47 -05:00
commit a1fc6bd20f
14 changed files with 159 additions and 127 deletions

View File

@ -26,14 +26,12 @@ 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.PerkBomber;
import nautilus.game.arcade.kit.perks.PerkDestructor;
import nautilus.game.arcade.ore.OreHider;
import nautilus.game.arcade.ore.OreObsfucation;
import nautilus.game.arcade.stats.*;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Chest;
@ -74,11 +72,6 @@ public class Bridge extends TeamGame implements OreObsfucation
*/
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
@ -113,6 +106,8 @@ public class Bridge extends TeamGame implements OreObsfucation
private boolean _tournament;
private HashMap<GameTeam, Integer> _tournamentKills = new HashMap<GameTeam, Integer>();
private long _tournamentKillMessageTimer = 0;
private final Map<GameTeam, Location> _averageSpawns = new HashMap<>();
@SuppressWarnings("unchecked")
public Bridge(ArcadeManager manager)
@ -145,7 +140,6 @@ public class Bridge extends TeamGame implements OreObsfucation
new KitApple(manager),
new KitBerserker(manager),
new KitBrawler(manager),
new KitMammoth(manager),
new KitArcher(manager),
new KitMiner(manager),
new KitBomber(manager),
@ -192,7 +186,7 @@ public class Bridge extends TeamGame implements OreObsfucation
WorldTimeSet = 2000;
WorldWaterDamage = 0;
WorldBoundaryKill = false;
WorldBoundaryKill = true;
DeathDropItems = true;
@ -225,25 +219,18 @@ public class Bridge extends TeamGame implements OreObsfucation
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;
}
((KitDestructor) kit).SetEnabled(false);
break;
}
}
registerDebugCommand(new DebugCommand("bridge", Rank.ADMIN)
registerDebugCommand(new DebugCommand("bridge", getArcadeManager().getGameCommandRank())
{
@Override
@ -279,33 +266,8 @@ public class Bridge extends TeamGame implements OreObsfucation
{
return;
}
//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);
Manager.runSyncLater(() -> _animation.onParse(), 10);
}
@EventHandler(priority = EventPriority.MONITOR)
@ -319,17 +281,13 @@ public class Bridge extends TeamGame implements OreObsfucation
if (!WorldData.GetCustomLocs("WATER_DAMAGE").isEmpty())
{
WorldWaterDamage = 4;
}
if (WorldWaterDamage > 0)
{
String name = WorldData.MapName;
if (name.equals("Volcanic Islands"))
{
UtilTextMiddle.display(C.cRed + "Warning", "Water is Boiling Hot", 10, 60, 20);
}
else if (WorldData.MapName.equals("Icelands"))
else if (name.equals("Icelands"))
{
UtilTextMiddle.display(C.cRed + "Warning", "Water is Freezing Cold", 10, 60, 20);
}
@ -387,9 +345,7 @@ public class Bridge extends TeamGame implements OreObsfucation
}
}
}
_animation.onParse();
ParseChests();
ParseOre(WorldData.GetCustomLocs("73")); // Red
@ -750,12 +706,12 @@ public class Bridge extends TeamGame implements OreObsfucation
{
_bridgesDown = true;
WorldBorderModule borderModule = getModule(WorldBorderModule.class);
for (Player player : GetPlayers(true))
{
borderModule.setSize(player, 10000);
}
// WorldBorderModule borderModule = getModule(WorldBorderModule.class);
//
// for (Player player : GetPlayers(true))
// {
// borderModule.setSize(player, 10000);
// }
Manager.GetExplosion().SetLiquidDamage(true);
Announce(C.cRedB + "ALERT: " + C.Reset + C.Bold + "THE BRIDGES ARE SPAWNING!");
@ -1121,6 +1077,16 @@ public class Bridge extends TeamGame implements OreObsfucation
}
}
@EventHandler
public void diamondOreExplode(PerkBomber.BomberExplodeDiamondBlock event)
{
event.setSpawnDrop(false);
event.getBlock().setType(Material.AIR);
Item item = event.getBlock().getWorld().dropItem(event.getBlock().getLocation().add(.5, .5, .5), new ItemStack(Material.DIAMOND));
item.setMetadata("owner", new FixedMetadataValue(Manager.getPlugin(), event.getPlayer().getUniqueId()));
}
@EventHandler
public void itemPickup(PlayerPickupItemEvent event)
{
@ -1654,10 +1620,10 @@ public class Bridge extends TeamGame implements OreObsfucation
}
}
@EventHandler(priority=EventPriority.LOWEST)
@EventHandler(priority=EventPriority.HIGHEST)
public void revivePlayer(CustomDamageEvent event)
{
if (!IsLive() || _bridgesDown || !(event.GetDamageeEntity() instanceof Player))
if (!IsLive() || event.isCancelled() || _bridgesDown || !(event.GetDamageeEntity() instanceof Player))
{
return;
}
@ -1674,7 +1640,9 @@ public class Bridge extends TeamGame implements OreObsfucation
_usedLife.add(player.getName());
UtilPlayer.message(player, F.main("Game", "You used your " + F.elem(C.cAqua + "Early Game Revive") + "."));
UtilServer.broadcast(F.main("Game", GetTeam(player).GetColor() + player.getName()) + C.cGray + " fell into the void.");
player.setFallDistance(0);
GetTeam(player).SpawnTeleport(player);
player.setHealth(20);
event.SetCancelled("Early Game Revive");
@ -1754,6 +1722,49 @@ public class Bridge extends TeamGame implements OreObsfucation
}
}
@EventHandler
public void updateBorder(UpdateEvent event)
{
if (!IsLive() || event.getType() != UpdateType.FAST || _bridgesDown)
{
return;
}
for (GameTeam team : GetTeamList())
{
List<Location> border = WorldData.GetCustomLocs("BORDER " + team.getDisplayName());
if (border.size() < 2)
{
continue;
}
Location one = border.get(0);
Location two = border.get(1);
Location average = _averageSpawns.computeIfAbsent(team, k -> UtilAlg.getAverageLocation(team.GetSpawns()));
one.setY(0);
two.setY(256);
for (Player player : team.GetPlayers(true))
{
if (player.getGameMode() != GameMode.SURVIVAL)
{
continue;
}
Location location = player.getLocation();
if (!UtilAlg.inBoundingBox(location, one, two))
{
player.setVelocity(UtilAlg.getTrajectory(location, average).multiply(2).add(new Vector(0, 0.5, 0)));
player.sendMessage(C.cRedB + "STAY ON YOUR ISLAND!");
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1, 0.5F);
}
}
}
}
public void setBridgeTime(int time)
{
_bridgeTime = time;

View File

@ -179,6 +179,11 @@ public abstract class CustomBridgeAnimation extends BridgeAnimation
continue;
}
for (Location location : locations)
{
location.getChunk().load();
}
for (Block block : UtilBlock.getInBoundingBox(locations.get(0), locations.get(1)))
{
if (!_blockIds.contains(block.getTypeId()) || _bridgeBlocks.containsKey(block))

View File

@ -29,7 +29,7 @@ public class RadiusCustomBridgeAnimation extends CustomBridgeAnimation
@Override
public void onUpdate(UpdateType type)
{
if (type != UpdateType.FAST)
if (type != UpdateType.SEC)
{
return;
}

View File

@ -21,7 +21,7 @@ public class KitApple extends ProgressingKit
};
private static final Perk[] PERKS = {
new PerkApple(10000)
new PerkApple(10000, 250)
};
private static final ItemStack IN_HAND = new ItemStack(Material.APPLE);

View File

@ -22,12 +22,12 @@ public class KitArcher extends ProgressingKit
"Highly trained with a bow, probably an elf or something...",
" ",
"Begin the game with a Bow",
receiveArrowString(1, 20, 3),
receiveArrowString(1, 20, 4),
"Charge Bow to use " + C.cGreen + "Barrage"
};
private static final Perk[] PERKS = {
new PerkFletcher(20, 3, true),
new PerkFletcher(20, 4, true),
new PerkBarrage(5, 250, true, false),
};

View File

@ -25,7 +25,7 @@ public class KitBerserker extends ProgressingKit
};
private static final Perk[] PERKS = {
new PerkLeap("Beserker Leap", 1.2, 1.2, 8000),
new PerkLeap("Beserker Leap", 1.2, 1.2, 10000),
new PerkAxeman(),
};

View File

@ -17,12 +17,12 @@ public class KitBomber extends ProgressingKit
private static final String[] DESCRIPTION = {
"Crazy bomb throwing guy.",
" ",
receiveItem("TNT", 1, 30, 2),
receiveItem("TNT", 1, 25, 2),
C.cYellow + "Click" + C.cWhite + " to throw TNT"
};
private static final Perk[] PERKS = {
new PerkBomber(30, 2, -1)
new PerkBomber(25, 2, -1)
};
private static final ItemStack IN_HAND = new ItemStack(Material.TNT);

View File

@ -20,8 +20,8 @@ public class KitBrawler extends ProgressingKit
"Giant and muscular, easily smacks others around.",
" ",
"Begin with an Iron Sword",
"Take " + C.cGreen + "75%" + C.cWhite + " knockback",
"Deal " + C.cGreen + "125%" + C.cWhite + " knockback",
"Take " + C.cGreen + "85%" + C.cWhite + " knockback",
"Deal " + C.cGreen + "115%" + C.cWhite + " knockback",
"Take " + C.cGreen + "-1" + C.cWhite + " damage from all attacks"
};

View File

@ -26,7 +26,7 @@ public class KitDestructor extends ProgressingKit
};
private static final Perk[] PERKS = {
new PerkDestructor(40, 2, 400, false)
new PerkDestructor(40, 2, 400, 3, false)
};
private static final Achievement[] ACHIEVEMENTS = {

View File

@ -28,7 +28,7 @@ public class KitBrawlAppler extends ProgressingKit
private static final Perk[] PERKS =
{
new PerkApple(3000)
new PerkApple(3000, 0)
};
private static final ItemStack IN_HAND = new ItemStack(Material.APPLE);

View File

@ -21,14 +21,19 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import java.util.Iterator;
public class PerkApple extends Perk implements IThrown
{
private long _spawnDelay;
public PerkApple(long delay)
private long _throwDelay;
public PerkApple(long delay, long throwDelay)
{
super("Apple Thrower", new String[]
{
@ -37,6 +42,7 @@ public class PerkApple extends Perk implements IThrown
});
_spawnDelay = delay;
_throwDelay = throwDelay;
}
@EventHandler
@ -80,6 +86,11 @@ public class PerkApple extends Perk implements IThrown
if (!Kit.HasKit(player))
return;
if (!Recharge.Instance.use(player, getMessage(player) + " Throw", _throwDelay, false, false))
{
return;
}
event.setCancelled(true);
@ -132,6 +143,23 @@ public class PerkApple extends Perk implements IThrown
}
@EventHandler
public void playerDeath(PlayerDeathEvent event)
{
if (!hasPerk(event.getEntity()))
{
return;
}
for (ItemStack itemStack : event.getDrops())
{
if (itemStack.getType() == Material.APPLE)
{
itemStack.setAmount((int) Math.ceil((double) itemStack.getAmount() / 2D));
}
}
}
private Material getMaterial(Player player)
{
if (Manager.getCosmeticManager().getGadgetManager().isKitModifierActive(KitModifier.Bridges_Apple_Potato, player))

View File

@ -39,18 +39,30 @@ public class PerkBomber extends Perk
}
private final Block _block;
private boolean _spawnDrop;
public BomberExplodeDiamondBlock(Player who, Block block)
{
super(who);
_block = block;
_spawnDrop = true;
}
public Block getBlock()
{
return _block;
}
public void setSpawnDrop(boolean b)
{
_spawnDrop = b;
}
public boolean shouldSpawnDrop()
{
return _spawnDrop;
}
}
private static final String THROWING_TNT_DISPLAY_NAME = F.item("Throwing TNT");
@ -265,8 +277,13 @@ public class PerkBomber extends Perk
if (block.getType() == Material.DIAMOND_ORE)
{
Bukkit.getPluginManager().callEvent(new BomberExplodeDiamondBlock(player, block));
block.breakNaturally();
BomberExplodeDiamondBlock explodeEvent = new BomberExplodeDiamondBlock(player, block);
UtilServer.CallEvent(explodeEvent);
if (explodeEvent.shouldSpawnDrop())
{
block.breakNaturally();
}
it.remove();
}
}

View File

@ -32,6 +32,7 @@ import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent;
@ -49,10 +50,12 @@ public class PerkDestructor extends Perk
private long _fallTime;
private double _damage;
private HashSet<String> _preparing = new HashSet<String>();
private HashMap<Block, Long> _blocks = new HashMap<Block, Long>();
public PerkDestructor(int spawnRate, int max, long fallTime, boolean enabled)
public PerkDestructor(int spawnRate, int max, long fallTime, double damage, boolean enabled)
{
super("Seismic Charge", new String[]
{
@ -64,7 +67,8 @@ public class PerkDestructor extends Perk
_spawnRate = spawnRate;
_max = max;
_fallTime = fallTime;
_damage = damage;
_enabled = enabled;
}
@ -203,7 +207,17 @@ public class PerkDestructor extends Perk
if (!proj.hasMetadata("Destructor"))
return;
for (Player hit : UtilPlayer.getNearby(proj.getLocation(), 3))
{
if (player.equals(hit))
{
continue;
}
Manager.GetDamage().NewDamageEvent(hit, player, proj, EntityDamageEvent.DamageCause.CUSTOM, _damage, true, true, true, proj.getName(), GetName());
}
for (Block block : UtilBlock.getInRadius(proj.getLocation(), 4).keySet())
{
if (block.getType() == Material.AIR || block.getType() == Material.BEDROCK || block.getType() == Material.BARRIER || block.isLiquid())
@ -226,49 +240,6 @@ public class PerkDestructor extends Perk
proj.getWorld().playSound(proj.getLocation(), Sound.EXPLODE, 1f, 0.5f);
proj.getWorld().playSound(proj.getLocation(), Sound.FIREWORK_TWINKLE, 2f, 0.5f);
}
// @EventHandler
// public void collide(PlayerTeleportEvent event)
// {
// if (Manager.GetGame() == null || !Manager.GetGame().IsLive())
// return;
//
// if (event.getCause() != TeleportCause.ENDER_PEARL)
// return;
//
// if (!Manager.IsAlive(event.getPlayer()))
// return;
//
// if (!Kit.HasKit(event.getPlayer()))
// return;
//
//
//
// for (Block block : UtilBlock.getInRadius(event.getTo(), 4).keySet())
// {
// if (block.getType() == Material.AIR || block.getType() == Material.BEDROCK || block.isLiquid())
// continue;
//
// //Event
// PerkDestructorBlockEvent blockEvent = new PerkDestructorBlockEvent(event.getPlayer(), block);
// UtilServer.getServer().getPluginManager().callEvent(blockEvent);
//
// if (!blockEvent.isCancelled())
// {
// _blocks.put(block, System.currentTimeMillis());
//
// block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
// }
// }
//
// UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, event.getTo(), 0f, 0f, 0f, 0f, 1,
// ViewDist.MAX, UtilServer.getPlayers());
//
// event.getTo().getWorld().playSound(event.getTo(), Sound.EXPLODE, 1f, 0.5f);
// event.getTo().getWorld().playSound(event.getTo(), Sound.FIREWORK_TWINKLE, 2f, 0.5f);
//
// event.setCancelled(true);
// }
@SuppressWarnings("deprecation")
@EventHandler

View File

@ -14,7 +14,7 @@ public class PerkMammoth extends Perk
{
super("Mammoth", new String[]
{
C.cGray + "Take 75% knockback and deal 125% knockback",
C.cGray + "Take 85% knockback and deal 115% knockback",
});
}
@ -30,7 +30,7 @@ public class PerkMammoth extends Perk
if (!Kit.HasKit(damager))
return;
event.AddKnockback(GetName(), 1.25d);
event.AddKnockback(GetName(), 1.15d);
}
@EventHandler(priority = EventPriority.HIGH)
@ -45,6 +45,6 @@ public class PerkMammoth extends Perk
if (!Kit.HasKit(damagee))
return;
event.AddKnockback(GetName(), 0.75d);
event.AddKnockback(GetName(), 0.85d);
}
}