From 430de1000896c9dfd75e29e77eb100d68abb6199 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 6 Dec 2015 03:47:07 -0500 Subject: [PATCH 01/47] - Everything except maps [probably should've committed sooner] --- .../src/mineplex/core/game/GameDisplay.java | 2 + .../src/nautilus/game/arcade/Arcade.java | 5 + .../src/nautilus/game/arcade/GameType.java | 2 + .../src/nautilus/game/arcade/game/Game.java | 7 +- .../minecraftleague/MinecraftLeague.java | 561 ++++++++++++++++++ .../data/PlayerRespawnPoint.java | 107 ++++ .../minecraftleague/data/TeamCrystal.java | 182 ++++++ .../games/minecraftleague/kit/KitPlayer.java | 42 ++ 8 files changed, 907 insertions(+), 1 deletion(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/PlayerRespawnPoint.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/kit/KitPlayer.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index c1603431f..2253850cf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -68,6 +68,8 @@ public enum GameDisplay Lobbers("Bomb Lobbers", Material.FIREBALL, (byte) 0, GameCategory.ARCADE, 54), ChampionsCTF("Champions CTF", "Champions", Material.BANNER, DyeColor.RED.getDyeData(), GameCategory.CHAMPIONS, 56), + + Minecraft_League("Minecraft League", Material.DIAMOND_SWORD, (byte)0, GameCategory.SURVIVAL, 57), Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index 7a710683b..a52014374 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -243,6 +243,11 @@ public class Arcade extends JavaPlugin return config; } + + public ArcadeManager getArcadeManager() + { + return _gameManager; + } private void DeleteFolders() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index 98ed32814..330b5f5eb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -33,6 +33,7 @@ import nautilus.game.arcade.game.games.horsecharge.Horse; import nautilus.game.arcade.game.games.lobbers.BombLobbers; import nautilus.game.arcade.game.games.micro.Micro; import nautilus.game.arcade.game.games.milkcow.MilkCow; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.mineware.MineWare; import nautilus.game.arcade.game.games.monstermaze.MonsterMaze; @@ -92,6 +93,7 @@ public enum GameType Lobbers(BombLobbers.class, GameDisplay.Lobbers), Micro(Micro.class, GameDisplay.Micro), MilkCow(MilkCow.class, GameDisplay.MilkCow), + MinecraftLeague(MinecraftLeague.class, GameDisplay.Minecraft_League), MineStrike(MineStrike.class, GameDisplay.MineStrike, "http://chivebox.com/mineplex/ResMinestrike.zip", true), MineWare(MineWare.class, GameDisplay.MineWare), OldMineWare(OldMineWare.class, GameDisplay.OldMineWare), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 27f429305..b04923415 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -855,7 +855,7 @@ public abstract class Game implements Listener public void RespawnPlayer(final Player player) { player.eject(); - player.teleport(GetTeam(player).GetSpawn()); + RespawnPlayerTeleport(player); Manager.Clear(player); @@ -872,6 +872,11 @@ public abstract class Game implements Listener } }, 0); } + + public void RespawnPlayerTeleport(Player player) + { + player.teleport(GetTeam(player).GetSpawn()); + } public boolean IsPlaying(Player player) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java new file mode 100644 index 000000000..306e160ef --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -0,0 +1,561 @@ +package nautilus.game.arcade.game.games.minecraftleague; + +import java.util.concurrent.ConcurrentHashMap; + +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.events.PlayerGameRespawnEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.GameTeam.PlayerState; +import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.games.minecraftleague.data.PlayerRespawnPoint; +import nautilus.game.arcade.game.games.minecraftleague.data.TeamCrystal; +import nautilus.game.arcade.game.games.minecraftleague.kit.KitPlayer; +import nautilus.game.arcade.kit.Kit; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockIgniteEvent; +import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; + +public class MinecraftLeague extends TeamGame +{ + private ConcurrentHashMap _crystals = new ConcurrentHashMap(); + private ConcurrentHashMap _customRespawns = new ConcurrentHashMap(); + private long _liveTime = 0; + + public MinecraftLeague(ArcadeManager manager) + { + super(manager, GameType.MinecraftLeague, + + new Kit[] + { + new KitPlayer(manager) + }, + + new String[] + { + C.cWhite + "Gather resources for battle.", + C.cWhite + "Destroy the enemy's Crystal to", + C.cWhite + "Prevent them from respawning", + " ", + C.cWhite + "Last team standing wins", + }); + + this.DeathOut = false; + this.DamageSelf = false; + this.DeathSpectateSecs = 0; + this.WorldBoundaryKill = false; + this.DeathDropItems = true; + this.CreatureAllow = true; + + this.BlockBreak = true; + this.BlockPlace = true; + this.ItemPickup = true; + this.ItemDrop = true; + + this.InventoryClick = true; + this.InventoryOpenBlock = true; + this.InventoryOpenChest = true; + + this.WorldWeatherEnabled = true; + this.WorldBlockBurn = true; + this.WorldBlockGrow = true; + this.WorldBoneMeal = true; + this.WorldFireSpread = true; + this.WorldLeavesDecay = true; + this.WorldSoilTrample = true; + + this.StrictAntiHack = true; + this.AllowParticles = false; + this.SoupEnabled = false; + Manager.GetCreature().SetForce(true); + + _help = new String[] + { + "Team Crystals have 500 health! Hit them with tnt to deal 1.5 damage.", + "The better the sword you have, the more damage you deal to Team Crystals!", + "Right-click a bed in order to change your personal spawn location." + }; + + + registerStatTrackers( + + ); + + Manager.GetDamage().disable(); + } + + private enum DamageAmount + { + NONE(1), + WOOD(4), + STONE(5), + GOLD(4), + IRON(6), + DIAMOND(7); + + private double _amount; + + private DamageAmount(int amount) + { + _amount = amount; + } + + public double getDamage(int sharpnessLevel, DamageType type) + { + if (type.getDamageReduction() == null) + return 1; + + return _amount + (sharpnessLevel / 2) - type.getDamageReduction(); + } + + public static DamageAmount getDamageAmount(Material material) + { + for (DamageAmount da : DamageAmount.values()) + { + if (da == DamageAmount.NONE) + continue; + + if (material.toString().contains(da.toString() + "_")) + return da; + } + + return DamageAmount.NONE; + } + } + + private enum DamageType + { + NONE(null), + PICKAXE(2), + AXE(1), + SWORD(0), + SPADE(3); + + private Integer _reduction; + + private DamageType(Integer reduction) + { + _reduction = reduction; + } + + public Integer getDamageReduction() + { + return _reduction; + } + + public static DamageType getDamageType(Material material) + { + for (DamageType dt : DamageType.values()) + { + if (dt == DamageType.NONE) + continue; + + if (material.toString().contains("_" + dt.toString())) + return dt; + } + + return DamageType.NONE; + } + } + + @Override + public void ParseData() + { + Location redLoc = WorldData.GetDataLocs("RED").get(0); + Location blueLoc = WorldData.GetDataLocs("BLUE").get(0); + + _crystals.put(GetTeam(ChatColor.RED), new TeamCrystal(this, GetTeam(ChatColor.RED), redLoc)); + _crystals.put(GetTeam(ChatColor.AQUA), new TeamCrystal(this, GetTeam(ChatColor.AQUA), blueLoc)); + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + scoreboardWrite(); + } + + private void scoreboardWrite() + { + if (!InProgress()) + return; + + GameTeam red = GetTeam(ChatColor.RED); + GameTeam blue = GetTeam(ChatColor.AQUA); + TeamCrystal redc = _crystals.get(red); + TeamCrystal bluec = _crystals.get(blue); + + if (IsLive()) + _liveTime = Math.max(System.currentTimeMillis() - GetStateTime(), 0); + + Scoreboard.Reset(); + + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cYellowB + "Time Elapsed"); + Scoreboard.Write(UtilTime.MakeStr(_liveTime)); + + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cRedB + "Red Team"); + Scoreboard.Write("Crystal: " + redc.formatHealth(redc.getHealth())); + Scoreboard.Write("Players Alive: " + red.GetPlayers(true).size()); + + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cAquaB + "Blue Team"); + Scoreboard.Write("Crystal: " + bluec.formatHealth(bluec.getHealth())); + Scoreboard.Write("Players Alive: " + blue.GetPlayers(true).size()); + + Scoreboard.Draw(); + } + + @Override + public void RespawnPlayerTeleport(Player player) + { + if (_customRespawns.containsKey(player)) + { + PlayerRespawnPoint point = _customRespawns.get(player); + if (point.respawnPlayer()) + return; + + _customRespawns.remove(player); + } + + player.teleport(GetTeam(player).GetSpawn()); + } + + @EventHandler + public void onEnd(GameStateChangeEvent event) + { + if (event.GetGame() != this) + return; + + if (event.GetState() == GameState.End) + Manager.GetDamage().enable(); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (!IsLive()) + return; + + if (event.getType() == UpdateType.FASTEST) + { + for (TeamCrystal crystal : _crystals.values()) + { + crystal.update(); + } + } + } + + @EventHandler + public void crystalDmg(EntityDamageEvent event) + { + if (!InProgress()) + return; + + if (event.getEntity().getType() != EntityType.ENDER_CRYSTAL) + return; + + for (TeamCrystal cryst : _crystals.values()) + { + if (cryst.isEntity(event.getEntity())) + event.setCancelled(true); + } + } + + @EventHandler + public void crystalDmg(EntityDamageByEntityEvent event) + { + if (!IsLive()) + return; + + if (event.getEntity().getType() != EntityType.ENDER_CRYSTAL) + return; + + TeamCrystal crystal = null; + for (TeamCrystal cryst : _crystals.values()) + { + if (cryst.isEntity(event.getEntity())) + crystal = cryst; + } + + if (crystal == null) + return; + + event.setCancelled(true); + + Player player; + + if (event.getDamager() instanceof Projectile) + { + if (((Projectile)event.getDamager()).getShooter() instanceof Player) + { + if (event.getDamager() instanceof Arrow) + { + player = (Player) ((Projectile)event.getDamager()).getShooter(); + + if (!crystal.canDamage(player)) + return; + + if (!crystal.damage(event.getDamage(), player)) + player.playSound(crystal.getLocation(), Sound.ORB_PICKUP, 100, 0); + } + } + } + + if (event.getDamager() instanceof Player) + { + player = (Player)event.getDamager(); + if (!crystal.canDamage(player)) + return; + + if (player.getItemInHand() == null || player.getItemInHand().getType() == Material.AIR) + { + if (!crystal.damage(1, player)) + player.playSound(crystal.getLocation(), Sound.ZOMBIE_WOODBREAK, 1, 0); + return; + } + + Material type = player.getItemInHand().getType(); + int level = player.getItemInHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL); + double damage = DamageAmount.getDamageAmount(type).getDamage(level, DamageType.getDamageType(type)); + + if (!crystal.damage(damage, player)) + player.playSound(crystal.getLocation(), Sound.ZOMBIE_WOODBREAK, 1, 0); + } + } + + @EventHandler + public void placeBed(PlayerInteractEvent event) + { + if (!IsLive()) + return; + + if (event.getClickedBlock() == null) + return; + + if (event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; + + if (event.getClickedBlock().getType() != Material.BED_BLOCK) + return; + + event.setCancelled(true); + + Player player = event.getPlayer(); + if (_customRespawns.containsKey(player)) + _customRespawns.get(player).overWrite(event.getClickedBlock().getLocation()); + else + _customRespawns.put(player, new PlayerRespawnPoint(player, event.getClickedBlock().getLocation())); + } + + @EventHandler + public void breakBed(BlockBreakEvent event) + { + if (!IsLive()) + return; + + if (event.getBlock().getType() != Material.BED_BLOCK) + return; + + for (Player player : _customRespawns.keySet()) + { + PlayerRespawnPoint point = _customRespawns.get(player); + + if (point.breakBed(event.getBlock())) + _customRespawns.remove(player); + } + } + + @EventHandler + public void onRespawn(PlayerGameRespawnEvent event) + { + if (event.GetGame() != this) + return; + + Player player = event.GetPlayer(); + + if (!_crystals.get(GetTeam(player)).Alive) + { + SetPlayerState(player, PlayerState.OUT); + + Manager.GetCondition().Factory().Blind("PermDead", player, player, 1.5, 0, false, false, false); + Manager.GetCondition().Factory().Cloak("PermDead", player, player, 9999, false, false); + + player.setAllowFlight(true); + player.setFlying(true); + ((CraftPlayer)player).getHandle().spectating = true; + ((CraftPlayer)player).getHandle().k = false; + + UtilAction.velocity(player, new Vector(0,1.2,0)); + } + } + + @EventHandler + public void onTNT(BlockIgniteEvent event) + { + if (event.getBlock().getType() == Material.TNT) + { + if (event.getCause() != IgniteCause.FLINT_AND_STEEL) + return; + + if (event.getPlayer() == null) + return; + + final Location loc = event.getBlock().getLocation(); + final Player player = event.getPlayer(); + + Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() + { + public void run() + { + for (Entity e : UtilEnt.getAllInRadius(loc, 2).keySet()) + { + if (e instanceof TNTPrimed) + { + e.setCustomName(player.getName()); + e.setCustomNameVisible(false); + } + } + } + + }, 5); + } + } + + @EventHandler + public void onDebug(PlayerCommandPreprocessEvent event) + { + Player player = event.getPlayer(); + + String message = event.getMessage().replaceFirst("/", ""); + String[] rawArgs = message.split(" "); + String cmd = rawArgs[0]; + message = message.replaceFirst(cmd + " ", ""); + String[] args = message.split(" "); + + if (!cmd.equalsIgnoreCase("vanilla")) + return; + + if (Manager.GetClients().Get(player).GetRank().has(Rank.JNR_DEV)) + { + event.setCancelled(true); + if (args.length == 0) + { + UtilPlayer.message(player, C.cGray + "Usage: /vanilla [team] [damage]"); + return; + } + + String sub = args[0]; + if (sub.equalsIgnoreCase("kill")) + { + if (args.length < 2) + { + UtilPlayer.message(player, C.cGray + "Usage: /vanilla kill "); + return; + } + String team = args[1]; + if (!team.equalsIgnoreCase("red") && !team.equalsIgnoreCase("blue")) + { + UtilPlayer.message(player, C.cGray + "Usage: /vanilla kill "); + return; + } + if (team.equalsIgnoreCase("red")) + _crystals.get(GetTeam(ChatColor.RED)).handleDebug(player, null, true); + else if (team.equalsIgnoreCase("blue")) + _crystals.get(GetTeam(ChatColor.AQUA)).handleDebug(player, null, true); + } + else if (sub.equalsIgnoreCase("spawn")) + { + if (args.length < 2) + { + UtilPlayer.message(player, C.cGray + "Usage: /vanilla spawn "); + return; + } + String team = args[1]; + if (!team.equalsIgnoreCase("red") && !team.equalsIgnoreCase("blue")) + { + UtilPlayer.message(player, C.cGray + "Usage: /vanilla spawn "); + return; + } + if (team.equalsIgnoreCase("red")) + _crystals.get(GetTeam(ChatColor.RED)).handleDebug(player, null, false); + else if (team.equalsIgnoreCase("blue")) + _crystals.get(GetTeam(ChatColor.AQUA)).handleDebug(player, null, false); + } + else if (sub.equalsIgnoreCase("damage")) + { + if (args.length < 3) + { + UtilPlayer.message(player, C.cGray + "Usage: /vanilla damage "); + return; + } + String team = args[1]; + if (!team.equalsIgnoreCase("red") && !team.equalsIgnoreCase("blue")) + { + UtilPlayer.message(player, C.cGray + "Usage: /vanilla damage "); + return; + } + Double damage; + try + { + damage = Double.parseDouble(args[2]); + } + catch (Exception e) + { + UtilPlayer.message(player, C.cGray + "Usage: /vanilla damage "); + return; + } + if (team.equalsIgnoreCase("red")) + _crystals.get(GetTeam(ChatColor.RED)).handleDebug(player, damage, false); + else if (team.equalsIgnoreCase("blue")) + _crystals.get(GetTeam(ChatColor.AQUA)).handleDebug(player, damage, false); + } + else if (sub.equalsIgnoreCase("status")) + { + for (GameTeam team : _crystals.keySet()) + { + Bukkit.broadcastMessage(team.GetName()); + TeamCrystal crystal = _crystals.get(team); + Bukkit.broadcastMessage(crystal.getHealth() + ""); + Bukkit.broadcastMessage(crystal.Alive + ""); + } + } + else + UtilPlayer.message(player, C.cGray + "Usage: /vanilla [team] [damage]"); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/PlayerRespawnPoint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/PlayerRespawnPoint.java new file mode 100644 index 000000000..7c2c797ec --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/PlayerRespawnPoint.java @@ -0,0 +1,107 @@ +package nautilus.game.arcade.game.games.minecraftleague.data; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; + +public class PlayerRespawnPoint +{ + private Player _owner; + private Location _loc; + + public PlayerRespawnPoint(Player owner, Location loc) + { + _owner = owner; + _loc = loc; + UtilPlayer.message(owner, F.main("Game", "You have set your bed respawn point. The next time you die you will respawn here!")); + } + + @SuppressWarnings("deprecation") + private boolean isBedType(Block bedBlock, boolean foot) + { + boolean head = (bedBlock.getData() & 0x8) != 0; + + if (foot) + return !head; + else + return head; + } + + private Block getOtherBedBlock(Block b1) + { + if (b1.getType() != Material.BED_BLOCK) + return null; + + boolean lookingForFoot = isBedType(b1, false); + + for (int x = -1; x <= 1; x++) + { + for (int z = -1; z <= 1; z++) + { + Block b2 = b1.getRelative(x, 0, z); + if (!(b1.getLocation().equals(b2.getLocation()))) + { + if (b2.getType().equals(Material.BED_BLOCK)) + { + if (lookingForFoot && isBedType(b2, true)) + return b2; + + if (!lookingForFoot && isBedType(b2, false)) + return b2; + } + } + } + } + return null; + } + + public boolean respawnPlayer() + { + if (_loc.getBlock().getType() != Material.BED_BLOCK) + { + UtilPlayer.message(_owner, F.main("Game", "Your bed has been destroyed, and your respawn point has been reset!")); + return false; + } + + _owner.teleport(_loc.clone().add(0.5, 1.5, 0.5)); + UtilPlayer.message(_owner, F.main("Game", "You have been respawned at your bed location!")); + + return true; + } + + public boolean breakBed(Block block) + { + boolean isOther = false; + + if (getOtherBedBlock(_loc.getBlock()) != null) + if (getOtherBedBlock(_loc.getBlock()).equals(block)) + isOther = true; + + if (block.getLocation().equals(_loc) || isOther) + { + UtilPlayer.message(_owner, F.main("Game", "Your bed respawn point has been broken!")); + return true; + } + return false; + } + + public void overWrite(Location newLocation) + { + if (newLocation.distance(_loc) <= .2) + return; + + if (getOtherBedBlock(_loc.getBlock()) != null) + if (getOtherBedBlock(_loc.getBlock()).getLocation().distance(newLocation) <= .2) + return; + + UtilPlayer.message(_owner, F.main("Game", "You have set your bed respawn point. The next time you die you will respawn here!")); + if (_loc.getBlock().getType() == Material.BED_BLOCK) + _loc.getBlock().breakNaturally(); + + _loc = newLocation; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java new file mode 100644 index 000000000..d3a562d11 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java @@ -0,0 +1,182 @@ +package nautilus.game.arcade.game.games.minecraftleague.data; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAlg; +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 mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.hologram.Hologram; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.EnderCrystal; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +public class TeamCrystal +{ + private MinecraftLeague _host; + private Location _spawn; + private GameTeam _team; + private Double _health; + private EnderCrystal _entity; + private Hologram _name, _healthTag; + public boolean Alive; + + public TeamCrystal(MinecraftLeague host, GameTeam team, Location spawn) + { + _host = host; + _spawn = spawn.clone().add(0.5, 1.5, 0.5); + _team = team; + _health = 500D; + _name = new Hologram(_host.getArcadeManager().getHologramManager(), _spawn.clone().add(0, 3, 0), team.GetColor() + team.getDisplayName() + "'s Respawn Crystal"); + _healthTag = new Hologram(_host.getArcadeManager().getHologramManager(), _spawn.clone().add(0, 2, 0), formatHealth(_health)); + + spawn(); + } + + private void spawn() + { + _name.start(); + _healthTag.start(); + _entity = (EnderCrystal) _host.getArcadeManager().GetCreature().SpawnEntity(_spawn, EntityType.ENDER_CRYSTAL); + _health = 500D; + Alive = true; + } + + private void kill(Player player) + { + String message = ""; + if (player != null) + message = C.cRedB + player.getName() + " has destroyed " + _team.getDisplayName() + "'s " + C.cDPurpleB + "Crystal" + C.cRedB + "!"; + else + message = C.cRedB + _team.getDisplayName() + "'s " + C.cDPurpleB + "Respawn Crystal" + C.cRedB + " has been destroyed!"; + + Bukkit.broadcastMessage(message); + + for (Player inform : _team.GetPlayers(true)) + UtilTextMiddle.display(C.cRedB + "Team Crystal Destroyed", C.cRed + "You will no longer respawn!", inform); + + Alive = false; + _entity.remove(); + _healthTag.stop(); + _name.stop(); + playDeathAnimation(_spawn); + } + + private void playDeathAnimation(Location loc) + { + _spawn.getWorld().playSound(loc, Sound.EXPLODE, 10, 0); + //GFX subject to change + Location loc1 = loc.clone().add(-2, 3, -2); + Location loc2 = loc.clone().add(2, 0, 2); + Location loc3 = loc.clone().add(2, 3, 2); + Location loc4 = loc.clone().add(-2, 0, -2); + Location particle1 = loc2.clone(); + Location particle2 = loc4.clone(); + while (UtilMath.offset(loc1, loc) >= UtilMath.offset(particle1, loc)) + { + Vector v = UtilAlg.getTrajectory(particle1, loc1); + //UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, particle, v, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers()); + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, particle1, v, 0, 5, ViewDist.MAX, UtilServer.getPlayers()); + particle1.add(v); + } + while (UtilMath.offset(loc3, loc) >= UtilMath.offset(particle2, loc)) + { + Vector v = UtilAlg.getTrajectory(particle2, loc3); + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, particle2, v, 0, 5, ViewDist.MAX, UtilServer.getPlayers()); + particle2.add(v); + } + } + + public boolean isEntity(Entity e) + { + return e.getEntityId() == _entity.getEntityId(); + } + + public boolean canDamage(Player player) + { + if (UtilPlayer.isSpectator(player)) + return false; + + if (_host.GetTeam(player) == _team) + return false; + + if (!_host.IsPlaying(player)) + return false; + + return true; + } + + public Double getHealth() + { + if (!Alive) + return 0D; + + return _health; + } + + public String formatHealth(Double healthNumber) + { + String tag = healthNumber.toString(); + + if (healthNumber > 450) + tag = C.cGreen + tag; + else if (healthNumber < 225) + tag = C.cRed + tag; + else + tag = C.cYellow + tag; + + return tag; + } + + public boolean damage(double damage, Player player) + { + Double newHealth = Math.max(_health - damage, 0); + + if (newHealth == 0) + { + kill(player); + return true; + } + + _health = newHealth; + return false; + } + + public Location getLocation() + { + return _spawn; + } + + public void update() + { + _healthTag.setText(formatHealth(_health)); + } + + public void handleDebug(Player dev, Double damage, boolean kill) + { + if (damage != null) + { + damage(damage, dev); + return; + } + + if (kill) + kill(dev); + else + { + spawn(); + dev.sendMessage(C.cGray + "Spawned!"); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/kit/KitPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/kit/KitPlayer.java new file mode 100644 index 000000000..bbcb478f5 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/kit/KitPlayer.java @@ -0,0 +1,42 @@ +package nautilus.game.arcade.game.games.minecraftleague.kit; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; + +public class KitPlayer extends Kit +{ + public KitPlayer(ArcadeManager manager) + { + super(manager, "Player", KitAvailability.Free, + + new String[] + { + "", + "Entirely vanilla combat!", + "" + }, + + new Perk[] + { + + }, EntityType.ZOMBIE, null); + } + + @Override + public void GiveItems(Player player) + { + + } + + @Override + public void SpawnCustom(LivingEntity ent) + { + + } +} From fe933913e830c0b194271dfcea48dac7ba793ffd Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 10 Dec 2015 22:48:57 -0500 Subject: [PATCH 02/47] - Fixed maps - Spawners --- .../src/mineplex/core/map/TeamMap.java | 106 +++++++++ .../minecraftleague/MinecraftLeague.java | 203 +++++++++++++++--- .../games/minecraftleague/data/Spawner.java | 123 +++++++++++ .../games/minecraftleague/kit/KitPlayer.java | 12 +- 4 files changed, 414 insertions(+), 30 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/map/TeamMap.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/Spawner.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/map/TeamMap.java b/Plugins/Mineplex.Core/src/mineplex/core/map/TeamMap.java new file mode 100644 index 000000000..d7336ae21 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/map/TeamMap.java @@ -0,0 +1,106 @@ +package mineplex.core.map; + +import java.util.ArrayList; +import java.util.List; + +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilPlayer; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.map.MapView; +import org.bukkit.map.MapView.Scale; + +public class TeamMap +{ + List _players; + final ItemStack _map; + + public TeamMap(List display, Location loc, Scale scale) + { + _players = display; + MapView view = Bukkit.createMap(loc.getWorld()); + view.setCenterX(loc.getBlockX()); + view.setCenterZ(loc.getBlockZ()); + view.setScale(scale); + + _map = new ItemStack(Material.MAP); + _map.setDurability(view.getId()); + } + + public void update(Player... forceRemove) + { + if (forceRemove != null) + { + for (Player remove : forceRemove) + { + _players.remove(remove); + } + } + + List confirmed = new ArrayList(); + + for (Player check : _players) + { + if (!UtilPlayer.isOnline(check.getName())) + continue; + + if (UtilPlayer.isSpectator(check)) + continue; + + confirmed.add(check); + } + + _players.clear(); + for (Player add : confirmed) + _players.add(add); + } + + public void giveMaps() + { + update(null); + + for (Player player : _players) + { + UtilInv.insert(player, _map); + UtilInv.Update(player); + } + } + + public void giveMap(Player player) + { + giveMap(player, true, ""); + } + + public void giveMap(Player player, boolean add, String displayName, String... lore) + { + if (!_players.contains(player)) + { + if (add) + { + _players.add(player); + } + } + + ItemStack map = _map.clone(); + ItemMeta im = map.getItemMeta(); + if (!displayName.equalsIgnoreCase("")) + im.setDisplayName(displayName); + + List lores = new ArrayList(); + for (String s : lore) + lores.add(s); + + if (!lores.isEmpty()) + im.setLore(lores); + + map.setItemMeta(im); + + UtilInv.insert(player, map); + UtilInv.Update(player); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index 306e160ef..8ce8e6dd0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -1,13 +1,19 @@ package nautilus.game.arcade.game.games.minecraftleague; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.ConcurrentHashMap; import mineplex.core.common.Rank; import mineplex.core.common.util.C; +import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.map.TeamMap; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; @@ -18,6 +24,7 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.minecraftleague.data.PlayerRespawnPoint; +import nautilus.game.arcade.game.games.minecraftleague.data.Spawner; import nautilus.game.arcade.game.games.minecraftleague.data.TeamCrystal; import nautilus.game.arcade.game.games.minecraftleague.kit.KitPlayer; import nautilus.game.arcade.kit.Kit; @@ -30,27 +37,42 @@ import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Arrow; -import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; +import org.bukkit.entity.ItemFrame; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; -import org.bukkit.entity.TNTPrimed; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockIgniteEvent; -import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.map.MapView.Scale; import org.bukkit.util.Vector; +import com.google.common.base.Objects; + public class MinecraftLeague extends TeamGame { private ConcurrentHashMap _crystals = new ConcurrentHashMap(); private ConcurrentHashMap _customRespawns = new ConcurrentHashMap(); + private ConcurrentHashMap _maps = new ConcurrentHashMap(); + private List _spawners = new ArrayList(); + private long _liveTime = 0; + private boolean _overTime = false; public MinecraftLeague(ArcadeManager manager) { @@ -188,6 +210,11 @@ public class MinecraftLeague extends TeamGame } } + public TeamMap getMap(GameTeam team) + { + return _maps.get(team); + } + @Override public void ParseData() { @@ -196,6 +223,12 @@ public class MinecraftLeague extends TeamGame _crystals.put(GetTeam(ChatColor.RED), new TeamCrystal(this, GetTeam(ChatColor.RED), redLoc)); _crystals.put(GetTeam(ChatColor.AQUA), new TeamCrystal(this, GetTeam(ChatColor.AQUA), blueLoc)); + + _maps.put(GetTeam(ChatColor.RED), new TeamMap(new ArrayList(), redLoc, Scale.CLOSE)); + _maps.put(GetTeam(ChatColor.AQUA), new TeamMap(new ArrayList(), redLoc, Scale.CLOSE)); + + _spawners.add(new Spawner(this, WorldData.GetDataLocs("GREEN").get(0), EntityType.CREEPER)); + _spawners.add(new Spawner(this, WorldData.GetDataLocs("BLACK").get(0), EntityType.SKELETON)); } @Override @@ -226,6 +259,8 @@ public class MinecraftLeague extends TeamGame Scoreboard.WriteBlank(); Scoreboard.Write(C.cYellowB + "Time Elapsed"); Scoreboard.Write(UtilTime.MakeStr(_liveTime)); + if (_overTime) + Scoreboard.Write(C.cDRedB + "Overtime"); Scoreboard.WriteBlank(); Scoreboard.Write(C.cRedB + "Red Team"); @@ -277,6 +312,22 @@ public class MinecraftLeague extends TeamGame { crystal.update(); } + + for (TeamMap map : _maps.values()) + { + map.update(null); + } + + for (Spawner spawner : _spawners) + { + spawner.update(); + } + + if (UtilTime.elapsed(GetStateTime(), UtilTime.convert(15, TimeUnit.MINUTES, TimeUnit.MILLISECONDS))) + { + _overTime = true; + UtilTextMiddle.display(C.cDRed + "Overtime", C.cDRed + "Dying will now cause your crystal to lose 20 health!"); + } } } @@ -352,9 +403,15 @@ public class MinecraftLeague extends TeamGame Material type = player.getItemInHand().getType(); int level = player.getItemInHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL); double damage = DamageAmount.getDamageAmount(type).getDamage(level, DamageType.getDamageType(type)); - + if (!crystal.damage(damage, player)) player.playSound(crystal.getLocation(), Sound.ZOMBIE_WOODBREAK, 1, 0); + + if (DamageAmount.getDamageAmount(type) != DamageAmount.NONE) + { + player.getItemInHand().setDurability((short) (player.getItemInHand().getDurability() + 1)); + UtilInv.Update(player); + } } } @@ -421,39 +478,127 @@ public class MinecraftLeague extends TeamGame ((CraftPlayer)player).getHandle().k = false; UtilAction.velocity(player, new Vector(0,1.2,0)); + + getMap(GetTeam(player)).update(player); + return; } + + if (_overTime) + _crystals.get(GetTeam(player)).damage(20, null); } @EventHandler - public void onTNT(BlockIgniteEvent event) + public void onDrop(PlayerDropItemEvent event) { - if (event.getBlock().getType() == Material.TNT) + if (!IsLive()) + return; + + ItemStack item = event.getItemDrop().getItemStack(); + + if (item.getType() != Material.MAP) + return; + + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot drop your team map!")); + } + + @EventHandler + public void preventMapMoveInventories(InventoryClickEvent event) + { + if (!IsLive()) + return; + + if (event.getWhoClicked() instanceof Player) { - if (event.getCause() != IgniteCause.FLINT_AND_STEEL) + Player p = (Player)event.getWhoClicked(); + if (p.getOpenInventory().getTopInventory().getType() == InventoryType.PLAYER) return; - if (event.getPlayer() == null) + if (p.getOpenInventory().getTopInventory().getType() == InventoryType.CREATIVE) return; - - final Location loc = event.getBlock().getLocation(); - final Player player = event.getPlayer(); - - Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() - { - public void run() - { - for (Entity e : UtilEnt.getAllInRadius(loc, 2).keySet()) - { - if (e instanceof TNTPrimed) - { - e.setCustomName(player.getName()); - e.setCustomNameVisible(false); - } - } - } - - }, 5); } + + Inventory inv = event.getClickedInventory(); + + if (inv == null) + return; + + for (ItemStack item : new ItemStack[] + { + event.getCurrentItem(), event.getCursor() + }) + { + if (item == null || item.getType() != Material.MAP) + continue; + + if (inv.getHolder() instanceof Player ? !event.isShiftClick() : Objects.equal(event.getCurrentItem(), item)) + continue; + + event.setCancelled(true); + + UtilPlayer.message(event.getWhoClicked(), F.main("Game", "You cannot store team maps inside containers!")); + return; + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onDie(PlayerDeathEvent event) + { + if (!IsLive()) + return; + + List newDrops = new ArrayList(); + + for (ItemStack item : event.getDrops()) + { + if (item.getType() == Material.MAP) + continue; + + newDrops.add(item); + } + + event.getDrops().clear(); + for (ItemStack item : newDrops) + event.getDrops().add(item); + } + + @EventHandler + public void preventMapInItemFrame(PlayerInteractEntityEvent event) + { + if (!IsLive()) + return; + + if (!(event.getRightClicked() instanceof ItemFrame)) + return; + + ItemStack item = event.getPlayer().getItemInHand(); + + if (item == null || item.getType() != Material.MAP) + return; + + event.setCancelled(true); + } + + @EventHandler + public void craftMap(PrepareItemCraftEvent event) + { + if (!IsLive()) + return; + + if (event.getInventory().getResult().getType() == Material.EMPTY_MAP || event.getInventory().getResult().getType() == Material.MAP) + event.getInventory().setResult(new ItemStack(Material.AIR)); + } + + @EventHandler + public void onSpawnerActivate(CreatureSpawnEvent event) + { + if (!IsLive()) + return; + + if (event.getSpawnReason() != SpawnReason.SPAWNER) + return; + + event.setCancelled(true); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/Spawner.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/Spawner.java new file mode 100644 index 000000000..fcd51014a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/Spawner.java @@ -0,0 +1,123 @@ +package nautilus.game.arcade.game.games.minecraftleague.data; + +import java.util.ArrayList; +import java.util.List; + +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.EntityType; + +public class Spawner +{ + protected MinecraftLeague Host; + private Location _spawnerBlock; + private EntityType _toSpawn; + private long _lastSpawned; + private boolean _canSpawn = true; + + @SuppressWarnings("deprecation") + public Spawner(MinecraftLeague host, Location spawnerBlock, EntityType toSpawn) + { + Host = host; + _spawnerBlock = spawnerBlock; + _toSpawn = toSpawn; + _lastSpawned = System.currentTimeMillis(); + spawnerBlock.getBlock().setTypeIdAndData(Material.MOB_SPAWNER.getId(), (byte)toSpawn.getTypeId(), false); + } + + private List getLocations(Location base, int changeX, int changeY, int changeZ) + { + List locs = new ArrayList(); + for(int x = (base.getBlockX() - changeX); x <= (base.getBlockX() + changeX); x++) + { + for(int y = (base.getBlockY() - changeY); y <= (base.getBlockY() + changeY); y++) + { + for(int z = (base.getBlockZ() - changeZ); z <= (base.getBlockZ() + changeZ); z++) + { + Location loc = new Location(base.getWorld(), x, y, z); + locs.add(loc); + } + } + } + + return locs; + } + + private boolean canSpawnMob(Location l) + { + Block b = l.getBlock(); + if ((b.getType() != Material.AIR) && !b.getType().toString().contains("WATER") && !UtilBlock.airFoliage(b)) + return false; + + Block b2 = b.getRelative(BlockFace.UP); + if ((b2.getType() != Material.AIR) && !b2.getType().toString().contains("WATER") && !UtilBlock.airFoliage(b2)) + return false; + + return true; + } + + private void spawn() + { + if (!_canSpawn) + return; + + List possible = getLocations(_spawnerBlock, 2, 1, 2); + boolean spawned = false; + int i = UtilMath.r(possible.size()); + while (!spawned) + { + Location l = possible.get(i); + if (canSpawnMob(l)) + { + Host.getArcadeManager().GetCreature().SpawnEntity(l, _toSpawn); + spawned = true; + _lastSpawned = System.currentTimeMillis(); + continue; + } + + int newi = 0; + if (i == (possible.size() - 1)) + i = newi; + else + i++; + } + for (Location l : possible) + { + if (!spawned) + { + if (canSpawnMob(l)) + { + Host.getArcadeManager().GetCreature().SpawnEntity(l, _toSpawn); + spawned = true; + _lastSpawned = System.currentTimeMillis(); + } + } + } + } + + public void update() + { + if (_spawnerBlock.getBlock().getType() != Material.MOB_SPAWNER) + _canSpawn = false; + else + _canSpawn = true; + + if (_canSpawn) + { + if (!UtilTime.elapsed(_lastSpawned, UtilTime.convert(20, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) + _canSpawn = false; + else + _canSpawn = true; + } + + spawn(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/kit/KitPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/kit/KitPlayer.java index bbcb478f5..34ffa4a5e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/kit/KitPlayer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/kit/KitPlayer.java @@ -1,13 +1,18 @@ package nautilus.game.arcade.game.games.minecraftleague.kit; +import mineplex.core.common.util.C; +import mineplex.core.map.TeamMap; import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; +import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; public class KitPlayer extends Kit { @@ -25,13 +30,18 @@ public class KitPlayer extends Kit new Perk[] { - }, EntityType.ZOMBIE, null); + }, EntityType.PLAYER, new ItemStack(Material.DIAMOND_SWORD)); } @Override public void GiveItems(Player player) { + TeamMap tmap = ((MinecraftLeague)Manager.GetGame()).getMap(Manager.GetGame().GetTeam(player)); + if (tmap == null) + return; + + tmap.giveMap(player, true, C.cGold + "Team Map", C.cGray + "This map contains", C.cGray + "the locations of", C.cGray + "your teammates."); } @Override From 42065fc5dc3c477cf77d3522e1042590876cf964 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 10 Dec 2015 23:22:08 -0500 Subject: [PATCH 03/47] - Fixed duplicate code --- .../game/games/minecraftleague/data/Spawner.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/Spawner.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/Spawner.java index fcd51014a..c5e1ad009 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/Spawner.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/Spawner.java @@ -89,18 +89,6 @@ public class Spawner else i++; } - for (Location l : possible) - { - if (!spawned) - { - if (canSpawnMob(l)) - { - Host.getArcadeManager().GetCreature().SpawnEntity(l, _toSpawn); - spawned = true; - _lastSpawned = System.currentTimeMillis(); - } - } - } } public void update() From 49186680f0e7f40a940a753aee04a0ee7254bce2 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 12 Dec 2015 00:31:13 -0500 Subject: [PATCH 04/47] - Game ID conflict resolution --- Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index c41fd8cd5..eb77ea76a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -70,9 +70,9 @@ public enum GameDisplay ChampionsCTF("Champions CTF", "Champions", Material.BANNER, DyeColor.RED.getDyeData(), GameCategory.CHAMPIONS, 56), - Minecraft_League("Minecraft League", Material.DIAMOND_SWORD, (byte)0, GameCategory.SURVIVAL, 57), + Minecraft_League("Minecraft League", Material.DIAMOND_SWORD, (byte)0, GameCategory.SURVIVAL, 59), - BouncyBalls("Bouncy Balls", Material.SLIME_BALL, (byte)0, GameCategory.ARCADE, 58), + BouncyBalls("Bouncy Balls", Material.SLIME_BALL, (byte)0, GameCategory.ARCADE, 57), Gladiators("Gladiators", Material.IRON_SWORD, (byte)0, GameCategory.ARCADE, 58), From 1535e167cdaf56ec7c3e80ded236f84ed22add6f Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 12 Dec 2015 02:36:01 -0500 Subject: [PATCH 05/47] - Inventory enum fix --- .../game/arcade/game/games/minecraftleague/MinecraftLeague.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index 8ce8e6dd0..3535ed1ce 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -511,7 +511,7 @@ public class MinecraftLeague extends TeamGame if (event.getWhoClicked() instanceof Player) { Player p = (Player)event.getWhoClicked(); - if (p.getOpenInventory().getTopInventory().getType() == InventoryType.PLAYER) + if (p.getOpenInventory().getTopInventory().getType() == InventoryType.CRAFTING) return; if (p.getOpenInventory().getTopInventory().getType() == InventoryType.CREATIVE) From cf05cf5d7b63fd1c9f4d2f6f0c9fa594b716f4ba Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 12 Dec 2015 05:12:17 -0500 Subject: [PATCH 06/47] - All finished - Added method for disabling explosion manager miniplugin --- .../mineplex/core/explosion/Explosion.java | 20 ++++++--- .../minecraftleague/MinecraftLeague.java | 45 +++++++++++++++---- .../minecraftleague/data/TeamCrystal.java | 10 ++++- 3 files changed, 60 insertions(+), 15 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java b/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java index ab9c70d52..3aace24ed 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java @@ -9,14 +9,13 @@ import java.util.Map.Entry; import java.util.UUID; import mineplex.core.MiniPlugin; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import org.bukkit.Effect; import org.bukkit.Location; @@ -32,7 +31,6 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.ExplosionPrimeEvent; -import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; @@ -362,4 +360,16 @@ public class Explosion extends MiniPlugin } }, 1); } + + public void setEnabled(boolean var) + { + if (var) + { + registerSelf(); + } + else + { + deregisterSelf(); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index 3535ed1ce..2d3176982 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -50,6 +50,7 @@ import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.PrepareItemCraftEvent; @@ -119,7 +120,6 @@ public class MinecraftLeague extends TeamGame this.StrictAntiHack = true; this.AllowParticles = false; this.SoupEnabled = false; - Manager.GetCreature().SetForce(true); _help = new String[] { @@ -133,7 +133,9 @@ public class MinecraftLeague extends TeamGame ); - Manager.GetDamage().disable(); + Manager.GetDamage().SetEnabled(false); + Manager.GetCreature().SetForce(true); + Manager.GetCreature().SetDisableCustomDrops(true); } private enum DamageAmount @@ -220,12 +222,13 @@ public class MinecraftLeague extends TeamGame { Location redLoc = WorldData.GetDataLocs("RED").get(0); Location blueLoc = WorldData.GetDataLocs("BLUE").get(0); + Location center = WorldData.GetDataLocs("ORANGE").get(0); _crystals.put(GetTeam(ChatColor.RED), new TeamCrystal(this, GetTeam(ChatColor.RED), redLoc)); _crystals.put(GetTeam(ChatColor.AQUA), new TeamCrystal(this, GetTeam(ChatColor.AQUA), blueLoc)); - _maps.put(GetTeam(ChatColor.RED), new TeamMap(new ArrayList(), redLoc, Scale.CLOSE)); - _maps.put(GetTeam(ChatColor.AQUA), new TeamMap(new ArrayList(), redLoc, Scale.CLOSE)); + _maps.put(GetTeam(ChatColor.RED), new TeamMap(new ArrayList(), center, Scale.CLOSE)); + _maps.put(GetTeam(ChatColor.AQUA), new TeamMap(new ArrayList(), center, Scale.CLOSE)); _spawners.add(new Spawner(this, WorldData.GetDataLocs("GREEN").get(0), EntityType.CREEPER)); _spawners.add(new Spawner(this, WorldData.GetDataLocs("BLACK").get(0), EntityType.SKELETON)); @@ -291,13 +294,23 @@ public class MinecraftLeague extends TeamGame } @EventHandler - public void onEnd(GameStateChangeEvent event) + public void onEditSettings(GameStateChangeEvent event) { if (event.GetGame() != this) return; + if (event.GetState() == GameState.Live) + { + Manager.GetExplosion().setEnabled(false); + } + if (event.GetState() == GameState.End) - Manager.GetDamage().enable(); + { + Manager.GetDamage().SetEnabled(true); + Manager.GetExplosion().setEnabled(true); + Manager.GetCreature().SetForce(false); + Manager.GetCreature().SetDisableCustomDrops(false); + } } @EventHandler @@ -323,10 +336,13 @@ public class MinecraftLeague extends TeamGame spawner.update(); } - if (UtilTime.elapsed(GetStateTime(), UtilTime.convert(15, TimeUnit.MINUTES, TimeUnit.MILLISECONDS))) + if (!_overTime) { - _overTime = true; - UtilTextMiddle.display(C.cDRed + "Overtime", C.cDRed + "Dying will now cause your crystal to lose 20 health!"); + if (UtilTime.elapsed(GetStateTime(), UtilTime.convert(15, TimeUnit.MINUTES, TimeUnit.MILLISECONDS))) + { + _overTime = true; + UtilTextMiddle.display(C.cDRed + "Overtime", C.cDRed + "Dying will now cause your crystal to lose 20 health!"); + } } } } @@ -518,6 +534,17 @@ public class MinecraftLeague extends TeamGame return; } + if (event.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD || event.getAction() == InventoryAction.HOTBAR_SWAP) + { + ItemStack i = event.getWhoClicked().getInventory().getItem(event.getHotbarButton()); + if (i == null || i.getType() != Material.MAP) + return; + + event.setCancelled(true); + UtilPlayer.message(event.getWhoClicked(), F.main("Game", "You cannot store team maps inside containers!")); + return; + } + Inventory inv = event.getClickedInventory(); if (inv == null) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java index d3a562d11..1bda51359 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java @@ -35,7 +35,7 @@ public class TeamCrystal public TeamCrystal(MinecraftLeague host, GameTeam team, Location spawn) { _host = host; - _spawn = spawn.clone().add(0.5, 1.5, 0.5); + _spawn = spawn.clone().add(0.5, 1.2, 0.5); _team = team; _health = 500D; _name = new Hologram(_host.getArcadeManager().getHologramManager(), _spawn.clone().add(0, 3, 0), team.GetColor() + team.getDisplayName() + "'s Respawn Crystal"); @@ -161,6 +161,14 @@ public class TeamCrystal public void update() { _healthTag.setText(formatHealth(_health)); + + if (Alive) + { + if (_entity.isDead() || !_entity.isValid()) + { + _entity = (EnderCrystal) _host.getArcadeManager().GetCreature().SpawnEntity(_spawn, EntityType.ENDER_CRYSTAL); + } + } } public void handleDebug(Player dev, Double damage, boolean kill) From ee63332062a35bca56ac4513ce003ad2c720b7d7 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 14 Dec 2015 06:39:35 -0500 Subject: [PATCH 07/47] - Moved setting changes --- .../arcade/game/games/minecraftleague/MinecraftLeague.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index 2d3176982..25cdb3f57 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -132,10 +132,6 @@ public class MinecraftLeague extends TeamGame registerStatTrackers( ); - - Manager.GetDamage().SetEnabled(false); - Manager.GetCreature().SetForce(true); - Manager.GetCreature().SetDisableCustomDrops(true); } private enum DamageAmount @@ -302,6 +298,9 @@ public class MinecraftLeague extends TeamGame if (event.GetState() == GameState.Live) { Manager.GetExplosion().setEnabled(false); + Manager.GetDamage().SetEnabled(false); + Manager.GetCreature().SetForce(true); + Manager.GetCreature().SetDisableCustomDrops(true); } if (event.GetState() == GameState.End) From 02f6a14f07a100ebec82483ca5afac31c6f8e14d Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 15 Dec 2015 02:06:59 -0500 Subject: [PATCH 08/47] - Game commands --- .../minecraftleague/MinecraftLeague.java | 166 ++++++------------ .../commands/DamageCommand.java | 70 ++++++++ .../minecraftleague/commands/KillCommand.java | 59 +++++++ .../commands/MinecraftLeagueCommand.java | 35 ++++ .../commands/SpawnCommand.java | 59 +++++++ .../commands/StatusCommand.java | 27 +++ .../minecraftleague/data/TeamCrystal.java | 7 +- 7 files changed, 314 insertions(+), 109 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/DamageCommand.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/KillCommand.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/MinecraftLeagueCommand.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/SpawnCommand.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/StatusCommand.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index 25cdb3f57..f62107ac2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.ConcurrentHashMap; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -23,13 +22,13 @@ import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.games.minecraftleague.commands.MinecraftLeagueCommand; import nautilus.game.arcade.game.games.minecraftleague.data.PlayerRespawnPoint; import nautilus.game.arcade.game.games.minecraftleague.data.Spawner; import nautilus.game.arcade.game.games.minecraftleague.data.TeamCrystal; import nautilus.game.arcade.game.games.minecraftleague.kit.KitPlayer; import nautilus.game.arcade.kit.Kit; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; @@ -54,7 +53,6 @@ import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.PrepareItemCraftEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; @@ -74,6 +72,7 @@ public class MinecraftLeague extends TeamGame private long _liveTime = 0; private boolean _overTime = false; + private MinecraftLeagueCommand _cmd; public MinecraftLeague(ArcadeManager manager) { @@ -123,8 +122,8 @@ public class MinecraftLeague extends TeamGame _help = new String[] { - "Team Crystals have 500 health! Hit them with tnt to deal 1.5 damage.", - "The better the sword you have, the more damage you deal to Team Crystals!", + "Respawn Crystals have 500 health!", + "The better the sword you have, the more damage you deal to Respawn Crystals!", "Right-click a bed in order to change your personal spawn location." }; @@ -289,6 +288,57 @@ public class MinecraftLeague extends TeamGame player.teleport(GetTeam(player).GetSpawn()); } + public enum EditType + { + SPAWN, KILL, DAMAGE, STATUS; + } + + public boolean handleCommand(EditType type, GameTeam target, Player caller, Double damage) + { + TeamCrystal crystal = null; + if (target != null) + crystal = _crystals.get(target); + + if (type == EditType.SPAWN) + { + if (crystal == null) + return false; + if (crystal.Alive) + return false; + crystal.handleDebug(caller, null, false); + } + if (type == EditType.KILL) + { + if (crystal == null) + return false; + if (!crystal.Alive) + return false; + crystal.handleDebug(caller, null, true); + } + if (type == EditType.DAMAGE) + { + if (crystal == null) + return false; + if (!crystal.Alive) + return false; + if (damage == null) + return false; + crystal.handleDebug(caller, damage, false); + } + if (type == EditType.STATUS) + { + for (GameTeam team : _crystals.keySet()) + { + TeamCrystal cr = _crystals.get(team); + UtilPlayer.message(caller, team.GetColor() + team.GetName()); + UtilPlayer.message(caller, C.cGray + "Health: " + cr.getHealth()); + UtilPlayer.message(caller, C.cGray + "Alive: " + cr.Alive); + } + } + + return true; + } + @EventHandler public void onEditSettings(GameStateChangeEvent event) { @@ -301,6 +351,8 @@ public class MinecraftLeague extends TeamGame Manager.GetDamage().SetEnabled(false); Manager.GetCreature().SetForce(true); Manager.GetCreature().SetDisableCustomDrops(true); + _cmd = new MinecraftLeagueCommand(Manager, this); + Manager.addCommand(_cmd); } if (event.GetState() == GameState.End) @@ -309,6 +361,7 @@ public class MinecraftLeague extends TeamGame Manager.GetExplosion().setEnabled(true); Manager.GetCreature().SetForce(false); Manager.GetCreature().SetDisableCustomDrops(false); + Manager.removeCommand(_cmd); } } @@ -626,107 +679,4 @@ public class MinecraftLeague extends TeamGame event.setCancelled(true); } - - @EventHandler - public void onDebug(PlayerCommandPreprocessEvent event) - { - Player player = event.getPlayer(); - - String message = event.getMessage().replaceFirst("/", ""); - String[] rawArgs = message.split(" "); - String cmd = rawArgs[0]; - message = message.replaceFirst(cmd + " ", ""); - String[] args = message.split(" "); - - if (!cmd.equalsIgnoreCase("vanilla")) - return; - - if (Manager.GetClients().Get(player).GetRank().has(Rank.JNR_DEV)) - { - event.setCancelled(true); - if (args.length == 0) - { - UtilPlayer.message(player, C.cGray + "Usage: /vanilla [team] [damage]"); - return; - } - - String sub = args[0]; - if (sub.equalsIgnoreCase("kill")) - { - if (args.length < 2) - { - UtilPlayer.message(player, C.cGray + "Usage: /vanilla kill "); - return; - } - String team = args[1]; - if (!team.equalsIgnoreCase("red") && !team.equalsIgnoreCase("blue")) - { - UtilPlayer.message(player, C.cGray + "Usage: /vanilla kill "); - return; - } - if (team.equalsIgnoreCase("red")) - _crystals.get(GetTeam(ChatColor.RED)).handleDebug(player, null, true); - else if (team.equalsIgnoreCase("blue")) - _crystals.get(GetTeam(ChatColor.AQUA)).handleDebug(player, null, true); - } - else if (sub.equalsIgnoreCase("spawn")) - { - if (args.length < 2) - { - UtilPlayer.message(player, C.cGray + "Usage: /vanilla spawn "); - return; - } - String team = args[1]; - if (!team.equalsIgnoreCase("red") && !team.equalsIgnoreCase("blue")) - { - UtilPlayer.message(player, C.cGray + "Usage: /vanilla spawn "); - return; - } - if (team.equalsIgnoreCase("red")) - _crystals.get(GetTeam(ChatColor.RED)).handleDebug(player, null, false); - else if (team.equalsIgnoreCase("blue")) - _crystals.get(GetTeam(ChatColor.AQUA)).handleDebug(player, null, false); - } - else if (sub.equalsIgnoreCase("damage")) - { - if (args.length < 3) - { - UtilPlayer.message(player, C.cGray + "Usage: /vanilla damage "); - return; - } - String team = args[1]; - if (!team.equalsIgnoreCase("red") && !team.equalsIgnoreCase("blue")) - { - UtilPlayer.message(player, C.cGray + "Usage: /vanilla damage "); - return; - } - Double damage; - try - { - damage = Double.parseDouble(args[2]); - } - catch (Exception e) - { - UtilPlayer.message(player, C.cGray + "Usage: /vanilla damage "); - return; - } - if (team.equalsIgnoreCase("red")) - _crystals.get(GetTeam(ChatColor.RED)).handleDebug(player, damage, false); - else if (team.equalsIgnoreCase("blue")) - _crystals.get(GetTeam(ChatColor.AQUA)).handleDebug(player, damage, false); - } - else if (sub.equalsIgnoreCase("status")) - { - for (GameTeam team : _crystals.keySet()) - { - Bukkit.broadcastMessage(team.GetName()); - TeamCrystal crystal = _crystals.get(team); - Bukkit.broadcastMessage(crystal.getHealth() + ""); - Bukkit.broadcastMessage(crystal.Alive + ""); - } - } - else - UtilPlayer.message(player, C.cGray + "Usage: /vanilla [team] [damage]"); - } - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/DamageCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/DamageCommand.java new file mode 100644 index 000000000..c9b81f378 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/DamageCommand.java @@ -0,0 +1,70 @@ +package nautilus.game.arcade.game.games.minecraftleague.commands; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague.EditType; + +public class DamageCommand extends CommandBase +{ + private MinecraftLeague _host; + + public DamageCommand(ArcadeManager plugin, MinecraftLeague host) + { + super(plugin, Rank.DEVELOPER, new Rank[] {Rank.JNR_DEV}, "damage"); + _host = host; + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 2) + { + UtilPlayer.message(caller, F.help("/minecraftLeague damage ", "Damages the red or blue Respawn Crystal for a specified amount", Rank.DEVELOPER)); + return; + } + + String team = args[0]; + + if (team.equalsIgnoreCase("red") && !team.equalsIgnoreCase("blue")) + { + UtilPlayer.message(caller, F.help("/minecraftLeague damage ", "Damages the red or blue Respawn Crystal for a specified amount", Rank.DEVELOPER)); + return; + } + + Double damage; + try + { + damage = Double.parseDouble(args[1]); + } + catch (Exception e) + { + UtilPlayer.message(caller, F.help("/minecraftLeague damage ", "Damages the red or blue Respawn Crystal for a specified amount", Rank.DEVELOPER)); + return; + } + + if (team.equalsIgnoreCase("red")) + { + if (_host.handleCommand(EditType.DAMAGE, _host.GetTeam(ChatColor.RED), caller, damage)) + return; + UtilPlayer.message(caller, F.main(_host.GetName(), C.cRed + "That Crystal is dead!")); + return; + } + + if (team.equalsIgnoreCase("blue")) + { + if (_host.handleCommand(EditType.DAMAGE, _host.GetTeam(ChatColor.AQUA), caller, damage)) + return; + UtilPlayer.message(caller, F.main(_host.GetName(), C.cRed + "That Crystal is dead!")); + return; + } + } + +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/KillCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/KillCommand.java new file mode 100644 index 000000000..3375d9b94 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/KillCommand.java @@ -0,0 +1,59 @@ +package nautilus.game.arcade.game.games.minecraftleague.commands; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague.EditType; + +public class KillCommand extends CommandBase +{ + private MinecraftLeague _host; + + public KillCommand(ArcadeManager plugin, MinecraftLeague host) + { + super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "kill"); + _host = host; + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 1) + { + UtilPlayer.message(caller, F.help("/minecraftLeague spawn ", "Kills the red or blue Respawn Crystal if spawned", Rank.ADMIN)); + return; + } + + String team = args[0]; + + if (team.equalsIgnoreCase("red") && !team.equalsIgnoreCase("blue")) + { + UtilPlayer.message(caller, F.help("/minecraftLeague spawn ", "Kills the red or blue Respawn Crystal if spawned", Rank.ADMIN)); + return; + } + + if (team.equalsIgnoreCase("red")) + { + if (_host.handleCommand(EditType.KILL, _host.GetTeam(ChatColor.RED), caller, null)) + return; + UtilPlayer.message(caller, F.main(_host.GetName(), C.cRed + "That Crystal is already killed!")); + return; + } + + if (team.equalsIgnoreCase("blue")) + { + if (_host.handleCommand(EditType.KILL, _host.GetTeam(ChatColor.AQUA), caller, null)) + return; + UtilPlayer.message(caller, F.main(_host.GetName(), C.cRed + "That Crystal is already spawned!")); + return; + } + } + +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/MinecraftLeagueCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/MinecraftLeagueCommand.java new file mode 100644 index 000000000..27dcd94ac --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/MinecraftLeagueCommand.java @@ -0,0 +1,35 @@ +package nautilus.game.arcade.game.games.minecraftleague.commands; + +import mineplex.core.command.MultiCommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; + +import org.bukkit.entity.Player; + +public class MinecraftLeagueCommand extends MultiCommandBase +{ + private MinecraftLeague _host; + + public MinecraftLeagueCommand(ArcadeManager plugin, MinecraftLeague host) + { + super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "minecraftLeague"); + AddCommand(new SpawnCommand(plugin, host)); + AddCommand(new KillCommand(plugin, host)); + AddCommand(new DamageCommand(plugin, host)); + AddCommand(new StatusCommand(plugin, host)); + _host = host; + } + + @Override + protected void Help(Player caller, String[] args) + { + UtilPlayer.message(caller, F.main(_host.GetName(), "Commands List:")); + UtilPlayer.message(caller, F.help("/minecraftLeague spawn ", "Respawns the red or blue Respawn Crystal if killed", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/minecraftLeague kill ", "Kills the red or blue Respawn Crystal if spawned", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/minecraftLeague damage ", "Damages the red or blue Respawn Crystal for a specified amount", Rank.DEVELOPER)); + UtilPlayer.message(caller, F.help("/minecraftLeague status", "Gets statistics about both Respawn Crystals", Rank.DEVELOPER)); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/SpawnCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/SpawnCommand.java new file mode 100644 index 000000000..83bab60d4 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/SpawnCommand.java @@ -0,0 +1,59 @@ +package nautilus.game.arcade.game.games.minecraftleague.commands; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague.EditType; + +public class SpawnCommand extends CommandBase +{ + private MinecraftLeague _host; + + public SpawnCommand(ArcadeManager plugin, MinecraftLeague host) + { + super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "spawn"); + _host = host; + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 1) + { + UtilPlayer.message(caller, F.help("/minecraftLeague spawn ", "Respawns the red or blue Respawn Crystal if killed", Rank.ADMIN)); + return; + } + + String team = args[0]; + + if (team.equalsIgnoreCase("red") && !team.equalsIgnoreCase("blue")) + { + UtilPlayer.message(caller, F.help("/minecraftLeague spawn ", "Respawns the red or blue Respawn Crystal if killed", Rank.ADMIN)); + return; + } + + if (team.equalsIgnoreCase("red")) + { + if (_host.handleCommand(EditType.SPAWN, _host.GetTeam(ChatColor.RED), caller, null)) + return; + UtilPlayer.message(caller, F.main(_host.GetName(), C.cRed + "That Crystal is already spawned!")); + return; + } + + if (team.equalsIgnoreCase("blue")) + { + if (_host.handleCommand(EditType.SPAWN, _host.GetTeam(ChatColor.AQUA), caller, null)) + return; + UtilPlayer.message(caller, F.main(_host.GetName(), C.cRed + "That Crystal is already spawned!")); + return; + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/StatusCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/StatusCommand.java new file mode 100644 index 000000000..63e73af85 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/StatusCommand.java @@ -0,0 +1,27 @@ +package nautilus.game.arcade.game.games.minecraftleague.commands; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague.EditType; + +import org.bukkit.entity.Player; + +public class StatusCommand extends CommandBase +{ + private MinecraftLeague _host; + + public StatusCommand(ArcadeManager plugin, MinecraftLeague host) + { + super(plugin, Rank.DEVELOPER, new Rank[] {Rank.JNR_DEV}, "status"); + _host = host; + } + + @Override + public void Execute(Player caller, String[] args) + { + _host.handleCommand(EditType.STATUS, null, caller, null); + } + +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java index 1bda51359..2fba9c0d1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.minecraftleague.data; import mineplex.core.common.util.C; +import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; @@ -176,15 +177,19 @@ public class TeamCrystal if (damage != null) { damage(damage, dev); + UtilPlayer.message(dev, F.main(_host.GetName(), "The Crystal has been damaged")); return; } if (kill) + { kill(dev); + UtilPlayer.message(dev, F.main(_host.GetName(), "The Crystal has been killed")); + } else { spawn(); - dev.sendMessage(C.cGray + "Spawned!"); + UtilPlayer.message(dev, F.main(_host.GetName(), "The Crystal has been spawned")); } } } From 6c1c40a9723177784dd6ba67bda246024edaea40 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 15 Dec 2015 02:25:16 -0500 Subject: [PATCH 09/47] - Fixed command bugs --- .../minecraftleague/commands/DamageCommand.java | 8 ++++---- .../games/minecraftleague/commands/KillCommand.java | 12 ++++++------ .../commands/MinecraftLeagueCommand.java | 10 +++++----- .../games/minecraftleague/commands/SpawnCommand.java | 6 +++--- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/DamageCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/DamageCommand.java index c9b81f378..2fdb67d3f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/DamageCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/DamageCommand.java @@ -27,15 +27,15 @@ public class DamageCommand extends CommandBase { if (args.length < 2) { - UtilPlayer.message(caller, F.help("/minecraftLeague damage ", "Damages the red or blue Respawn Crystal for a specified amount", Rank.DEVELOPER)); + UtilPlayer.message(caller, F.help("/mcLeague damage ", "Damages the red or blue Respawn Crystal for a specified amount", Rank.DEVELOPER)); return; } String team = args[0]; - if (team.equalsIgnoreCase("red") && !team.equalsIgnoreCase("blue")) + if (!team.equalsIgnoreCase("red") && !team.equalsIgnoreCase("blue")) { - UtilPlayer.message(caller, F.help("/minecraftLeague damage ", "Damages the red or blue Respawn Crystal for a specified amount", Rank.DEVELOPER)); + UtilPlayer.message(caller, F.help("/mcLeague damage ", "Damages the red or blue Respawn Crystal for a specified amount", Rank.DEVELOPER)); return; } @@ -46,7 +46,7 @@ public class DamageCommand extends CommandBase } catch (Exception e) { - UtilPlayer.message(caller, F.help("/minecraftLeague damage ", "Damages the red or blue Respawn Crystal for a specified amount", Rank.DEVELOPER)); + UtilPlayer.message(caller, F.help("/mcLeague damage ", "Damages the red or blue Respawn Crystal for a specified amount", Rank.DEVELOPER)); return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/KillCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/KillCommand.java index 3375d9b94..3fabe167d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/KillCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/KillCommand.java @@ -1,8 +1,5 @@ package nautilus.game.arcade.game.games.minecraftleague.commands; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; - import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.C; @@ -12,6 +9,9 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague.EditType; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + public class KillCommand extends CommandBase { private MinecraftLeague _host; @@ -27,15 +27,15 @@ public class KillCommand extends CommandBase { if (args.length < 1) { - UtilPlayer.message(caller, F.help("/minecraftLeague spawn ", "Kills the red or blue Respawn Crystal if spawned", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/mcLeague kill ", "Kills the red or blue Respawn Crystal if spawned", Rank.ADMIN)); return; } String team = args[0]; - if (team.equalsIgnoreCase("red") && !team.equalsIgnoreCase("blue")) + if (!team.equalsIgnoreCase("red") && !team.equalsIgnoreCase("blue")) { - UtilPlayer.message(caller, F.help("/minecraftLeague spawn ", "Kills the red or blue Respawn Crystal if spawned", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/mcLeague kill ", "Kills the red or blue Respawn Crystal if spawned", Rank.ADMIN)); return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/MinecraftLeagueCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/MinecraftLeagueCommand.java index 27dcd94ac..ead7909ae 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/MinecraftLeagueCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/MinecraftLeagueCommand.java @@ -15,7 +15,7 @@ public class MinecraftLeagueCommand extends MultiCommandBase public MinecraftLeagueCommand(ArcadeManager plugin, MinecraftLeague host) { - super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "minecraftLeague"); + super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "mcLeague"); AddCommand(new SpawnCommand(plugin, host)); AddCommand(new KillCommand(plugin, host)); AddCommand(new DamageCommand(plugin, host)); @@ -27,9 +27,9 @@ public class MinecraftLeagueCommand extends MultiCommandBase protected void Help(Player caller, String[] args) { UtilPlayer.message(caller, F.main(_host.GetName(), "Commands List:")); - UtilPlayer.message(caller, F.help("/minecraftLeague spawn ", "Respawns the red or blue Respawn Crystal if killed", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/minecraftLeague kill ", "Kills the red or blue Respawn Crystal if spawned", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/minecraftLeague damage ", "Damages the red or blue Respawn Crystal for a specified amount", Rank.DEVELOPER)); - UtilPlayer.message(caller, F.help("/minecraftLeague status", "Gets statistics about both Respawn Crystals", Rank.DEVELOPER)); + UtilPlayer.message(caller, F.help("/mcLeague spawn ", "Respawns the red or blue Respawn Crystal if killed", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/mcLeague kill ", "Kills the red or blue Respawn Crystal if spawned", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/mcLeague damage ", "Damages the red or blue Respawn Crystal for a specified amount", Rank.DEVELOPER)); + UtilPlayer.message(caller, F.help("/mcLeague status", "Gets statistics about both Respawn Crystals", Rank.DEVELOPER)); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/SpawnCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/SpawnCommand.java index 83bab60d4..baa9faf97 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/SpawnCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/SpawnCommand.java @@ -27,15 +27,15 @@ public class SpawnCommand extends CommandBase { if (args.length < 1) { - UtilPlayer.message(caller, F.help("/minecraftLeague spawn ", "Respawns the red or blue Respawn Crystal if killed", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/mcLeague spawn ", "Respawns the red or blue Respawn Crystal if killed", Rank.ADMIN)); return; } String team = args[0]; - if (team.equalsIgnoreCase("red") && !team.equalsIgnoreCase("blue")) + if (!team.equalsIgnoreCase("red") && !team.equalsIgnoreCase("blue")) { - UtilPlayer.message(caller, F.help("/minecraftLeague spawn ", "Respawns the red or blue Respawn Crystal if killed", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/mcLeague spawn ", "Respawns the red or blue Respawn Crystal if killed", Rank.ADMIN)); return; } From 09528a926295b26f4fb46d3a3df19f862e8c9b69 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 18 Dec 2015 21:33:40 -0500 Subject: [PATCH 10/47] - Initial broadcast stuff --- .../src/nautilus/game/arcade/Arcade.java | 3 + .../nautilus/game/arcade/ArcadeManager.java | 10 ++ .../game/arcade/broadcast/BroadcastData.java | 97 ++++++++++++++ .../arcade/broadcast/BroadcastManager.java | 120 ++++++++++++++++++ .../broadcast/command/BroadcastCommand.java | 33 +++++ .../broadcast/command/RotateCommand.java | 21 +++ .../broadcast/command/manage/AddCommand.java | 22 ++++ .../command/manage/RemoveCommand.java | 22 ++++ 8 files changed, 328 insertions(+) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/BroadcastData.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/BroadcastManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/BroadcastCommand.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/RotateCommand.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/manage/AddCommand.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/manage/RemoveCommand.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index f49b61b7f..d26bc174a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -59,6 +59,7 @@ import mineplex.core.velocity.VelocityFix; import mineplex.core.visibility.VisibilityManager; import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.damage.DamageManager; +import nautilus.game.arcade.broadcast.BroadcastManager; import nautilus.game.arcade.game.GameServerConfig; public class Arcade extends JavaPlugin @@ -156,6 +157,8 @@ public class Arcade extends JavaPlugin PollManager pollManager = new PollManager(this, _clientManager, _donationManager); _gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager, giveawayManager); + new BroadcastManager(this, _gameManager); + new MemoryFix(this); new CustomTagFix(this, packetHandler); new PacketsInteractionFix(this, packetHandler); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 7e9d4a156..1a971bfc7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -202,6 +202,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation // Observers private HashSet _specList = new HashSet(); + private HashSet _fakeObserve = new HashSet(); // Server Games private GameServerConfig _serverConfig; @@ -1119,9 +1120,18 @@ public class ArcadeManager extends MiniPlugin implements IRelation { _specList.remove(event.getPlayer()); } + + public void toggleFakeObserver(Player player) + { + if (!_fakeObserve.remove(player)) + _fakeObserve.add(player); + } public boolean IsObserver(Player player) { + if (_fakeObserve.contains(player)) + return true; + return _specList.contains(player); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/BroadcastData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/BroadcastData.java new file mode 100644 index 000000000..fe4b389da --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/BroadcastData.java @@ -0,0 +1,97 @@ +package nautilus.game.arcade.broadcast; + +import java.util.ArrayList; +import java.util.List; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.recharge.Recharge; +import net.minecraft.server.v1_8_R3.PacketPlayOutCamera; + +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Player; + +public class BroadcastData +{ + private Player _player; + private BroadcastManager _plugin; + + private boolean _rotate; + + private List _gamePlayers; + private List _recentlyViewed; + private Player _currentlyViewing; + + public BroadcastData(Player player, BroadcastManager plugin) + { + _player = player; + _plugin = plugin; + + _recentlyViewed = new ArrayList(); + + setRotating(false); + } + + private void setRotating(boolean rotate) + { + _rotate = rotate; + UtilPlayer.message(_player, F.main(_plugin.getName(), "Player Rotation: " + rotate)); + } + + public boolean isRotating() + { + return _rotate; + } + + public Player currentView() + { + return _currentlyViewing; + } + + public Player nextPlayer() + { + if (_gamePlayers.size() == _recentlyViewed.size()) + _recentlyViewed.clear(); + + for (Player player : _gamePlayers) + { + if (!player.isOnline() || !player.isValid() || player.isDead()) + continue; + + if (!_recentlyViewed.contains(player)) + return player; + } + + return null; + } + + public void toggleRotating(List gamePlayers) + { + if (!isRotating()) + { + if (gamePlayers == null) + return; + + if (gamePlayers.size() == 0) + return; + + _gamePlayers = gamePlayers; + } + if (isRotating()) + { + PacketPlayOutCamera restore = new PacketPlayOutCamera((net.minecraft.server.v1_8_R3.Entity)_player); + ((CraftPlayer)_player).getHandle().playerConnection.sendPacket(restore); + } + setRotating(!isRotating()); + } + + public void goToNext(Player player) + { + Recharge.Instance.useForce(_player, "Broadcaster Rotation", UtilTime.convert(10, TimeUnit.SECONDS, TimeUnit.MILLISECONDS), false); + _currentlyViewing = player; + PacketPlayOutCamera view = new PacketPlayOutCamera((net.minecraft.server.v1_8_R3.Entity)player); + ((CraftPlayer)_player).getHandle().playerConnection.sendPacket(view); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/BroadcastManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/BroadcastManager.java new file mode 100644 index 000000000..d3693e598 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/BroadcastManager.java @@ -0,0 +1,120 @@ +package nautilus.game.arcade.broadcast; + +import java.util.concurrent.ConcurrentHashMap; + +import mineplex.core.MiniPlugin; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.Game.GameState; + +import org.bukkit.GameMode; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.plugin.java.JavaPlugin; + +public class BroadcastManager extends MiniPlugin +{ + ArcadeManager ArcadeManager; + private ConcurrentHashMap _broadcasters; + + public BroadcastManager(JavaPlugin plugin, ArcadeManager manager) + { + super("Broadcasting Manager", plugin); + ArcadeManager = manager; + _broadcasters = new ConcurrentHashMap(); + } + + public boolean isBroadcaster(Player player) + { + return _broadcasters.containsKey(player); + } + + public void addBroadcaster(Player player) + { + _broadcasters.put(player, new BroadcastData(player, this)); + if (ArcadeManager.GetGame() != null) + { + ArcadeManager.GetGame().RemoveTeamPreference(player); + ArcadeManager.GetGame().GetPlayerKits().remove(player); + ArcadeManager.GetGame().GetPlayerGems().remove(player); + try + { + ArcadeManager.GetGame().GetTeam(player).RemovePlayer(player); + } + catch (Exception e) {} + ArcadeManager.Clear(player); + ArcadeManager.toggleFakeObserver(player); + } + player.getInventory().clear(); + player.setGameMode(GameMode.SPECTATOR); + } + + public void removeBroadcaster(Player player) + { + _broadcasters.remove(player); + ArcadeManager.toggleFakeObserver(player); + if (ArcadeManager.GetGame().InProgress()) + ArcadeManager.addSpectator(player, true); + player.setGameMode(GameMode.SURVIVAL); + } + + @EventHandler + public void handleBroadcasting(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Dead) + { + for (BroadcastData data : _broadcasters.values()) + { + if (data.isRotating()) + data.toggleRotating(null); + } + _broadcasters.clear(); + } + } + + @EventHandler + public void handleRotation(UpdateEvent event) + { + if (event.getType() == UpdateType.FASTEST) + { + Game game = ArcadeManager.GetGame(); + if (game == null) + return; + if (!game.InProgress()) + return; + + for (Player player : _broadcasters.keySet()) + { + if (!Recharge.Instance.usable(player, "Broadcaster Rotation", false)) + continue; + } + } + } + + @EventHandler + public void handleRotation(PlayerQuitEvent event) + { + Game game = ArcadeManager.GetGame(); + if (game == null) + return; + if (!game.InProgress()) + return; + + if (_broadcasters.containsKey(event.getPlayer())) + _broadcasters.remove(event.getPlayer()); + + for (BroadcastData data : _broadcasters.values()) + { + if (data.currentView() == null) + continue; + + if (data.currentView() == event.getPlayer()); + data.goToNext(data.nextPlayer()); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/BroadcastCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/BroadcastCommand.java new file mode 100644 index 000000000..49d4858d2 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/BroadcastCommand.java @@ -0,0 +1,33 @@ +package nautilus.game.arcade.broadcast.command; + +import mineplex.core.command.MultiCommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.broadcast.BroadcastManager; +import nautilus.game.arcade.broadcast.command.manage.AddCommand; +import nautilus.game.arcade.broadcast.command.manage.RemoveCommand; + +import org.bukkit.entity.Player; + +public class BroadcastCommand extends MultiCommandBase +{ + public BroadcastCommand(BroadcastManager plugin) + { + super(plugin, Rank.ADMIN, new Rank[] {Rank.TWITCH, Rank.YOUTUBE, Rank.YOUTUBE_SMALL, Rank.JNR_DEV}, "broadcaster"); + AddCommand(new AddCommand(plugin)); + AddCommand(new RemoveCommand(plugin)); + AddCommand(new RotateCommand(plugin)); + } + + @Override + protected void Help(Player caller, String[] args) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), "Commands List:")); + UtilPlayer.message(caller, F.help("/broadcaster add ", "Puts a player in Broadcast mode for this game", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/broadcaster remove ", "Takes a player out of Broadcast mode", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/broadcaster rotate", "Toggles rotating view between game players", Rank.TWITCH)); + UtilPlayer.message(caller, F.main("Tip", "Rotation is great for a background to commentary!")); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/RotateCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/RotateCommand.java new file mode 100644 index 000000000..b455ce4af --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/RotateCommand.java @@ -0,0 +1,21 @@ +package nautilus.game.arcade.broadcast.command; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import nautilus.game.arcade.broadcast.BroadcastManager; + +public class RotateCommand extends CommandBase +{ + public RotateCommand(BroadcastManager plugin) { + super(plugin, Rank.TWITCH, "rotate"); + } + + @Override + public void Execute(Player caller, String[] args) + { + + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/manage/AddCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/manage/AddCommand.java new file mode 100644 index 000000000..ee67c8609 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/manage/AddCommand.java @@ -0,0 +1,22 @@ +package nautilus.game.arcade.broadcast.command.manage; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import nautilus.game.arcade.broadcast.BroadcastManager; + +public class AddCommand extends CommandBase +{ + public AddCommand(BroadcastManager plugin) + { + super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "add"); + } + + @Override + public void Execute(Player caller, String[] args) + { + + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/manage/RemoveCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/manage/RemoveCommand.java new file mode 100644 index 000000000..021202498 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/broadcast/command/manage/RemoveCommand.java @@ -0,0 +1,22 @@ +package nautilus.game.arcade.broadcast.command.manage; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import nautilus.game.arcade.broadcast.BroadcastManager; + +public class RemoveCommand extends CommandBase +{ + public RemoveCommand(BroadcastManager plugin) + { + super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "remove"); + } + + @Override + public void Execute(Player caller, String[] args) + { + + } + +} \ No newline at end of file From a4853e667cf600cbd390a447ec719a3b2bb761b0 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Wed, 30 Dec 2015 03:23:21 -0500 Subject: [PATCH 11/47] - Gameplay edits and disabling broadcaster code --- .../src/nautilus/game/arcade/Arcade.java | 2 +- .../minecraftleague/MinecraftLeague.java | 86 +++++++++++++++++++ .../minecraftleague/data/TeamCrystal.java | 9 +- .../games/minecraftleague/kit/KitPlayer.java | 1 + 4 files changed, 96 insertions(+), 2 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index fe42cb5a0..33ddb4b4a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -159,7 +159,7 @@ public class Arcade extends JavaPlugin PollManager pollManager = new PollManager(this, _clientManager, _donationManager); _gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager, giveawayManager, customDataManager); - new BroadcastManager(this, _gameManager); + //new BroadcastManager(this, _gameManager); new MemoryFix(this); new CustomTagFix(this, packetHandler); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index f62107ac2..d3628b20b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -679,4 +679,90 @@ public class MinecraftLeague extends TeamGame event.setCancelled(true); } + + @EventHandler + public void controlPvP(EntityDamageByEntityEvent event) + { + if (!IsLive()) + return; + + Player entity = null; + Player damager = null; + if (event.getEntity() instanceof Player) + { + entity = (Player)event.getEntity(); + if (UtilPlayer.isSpectator(entity)) + { + event.setCancelled(true); + return; + } + } + if (event.getDamager() instanceof Player) + { + damager = (Player)event.getDamager(); + if (UtilPlayer.isSpectator(damager)) + { + event.setCancelled(true); + return; + } + } + if (event.getDamager() instanceof Projectile) + { + Projectile proj = (Projectile)event.getDamager(); + if (proj.getShooter() instanceof Player) + { + damager = (Player)proj.getShooter(); + if (UtilPlayer.isSpectator(damager)) + { + event.setCancelled(true); + return; + } + } + } + + if ((entity != null) && (damager != null)) + { + if (GetTeam(entity).GetColor() == GetTeam(damager).GetColor()) + event.setCancelled(true); + } + } + + @EventHandler + public void protectSpectators(EntityDamageEvent event) + { + if (!IsLive()) + return; + + if (event.getEntity() instanceof Player) + { + Player ent = (Player)event.getEntity(); + if (UtilPlayer.isSpectator(ent)) + event.setCancelled(true); + } + } + + @EventHandler + public void equip(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + return; + + for (Player red : GetTeam(ChatColor.RED).GetPlayers(true)) + { + red.getInventory().setHelmet(new ItemStack(Material.IRON_HELMET)); + red.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE)); + red.getInventory().setLeggings(new ItemStack(Material.IRON_LEGGINGS)); + red.getInventory().setBoots(new ItemStack(Material.IRON_BOOTS)); + red.getInventory().addItem(new ItemStack(Material.IRON_SWORD)); + } + + for (Player blue : GetTeam(ChatColor.AQUA).GetPlayers(true)) + { + blue.getInventory().setHelmet(new ItemStack(Material.IRON_HELMET)); + blue.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE)); + blue.getInventory().setLeggings(new ItemStack(Material.IRON_LEGGINGS)); + blue.getInventory().setBoots(new ItemStack(Material.IRON_BOOTS)); + blue.getInventory().addItem(new ItemStack(Material.IRON_SWORD)); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java index 2fba9c0d1..220401007 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java @@ -10,7 +10,10 @@ import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.hologram.Hologram; +import mineplex.core.recharge.Recharge; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; @@ -38,7 +41,7 @@ public class TeamCrystal _host = host; _spawn = spawn.clone().add(0.5, 1.2, 0.5); _team = team; - _health = 500D; + _health = 1000D; _name = new Hologram(_host.getArcadeManager().getHologramManager(), _spawn.clone().add(0, 3, 0), team.GetColor() + team.getDisplayName() + "'s Respawn Crystal"); _healthTag = new Hologram(_host.getArcadeManager().getHologramManager(), _spawn.clone().add(0, 2, 0), formatHealth(_health)); @@ -115,6 +118,9 @@ public class TeamCrystal if (!_host.IsPlaying(player)) return false; + if (!Recharge.Instance.usable(player, "Damage Teamcrystal")) + return false; + return true; } @@ -151,6 +157,7 @@ public class TeamCrystal } _health = newHealth; + Recharge.Instance.use(player, "Damage Teamcrystal", UtilTime.convert(1, TimeUnit.SECONDS, TimeUnit.MILLISECONDS), false, false); return false; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/kit/KitPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/kit/KitPlayer.java index 34ffa4a5e..3168bf639 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/kit/KitPlayer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/kit/KitPlayer.java @@ -24,6 +24,7 @@ public class KitPlayer extends Kit { "", "Entirely vanilla combat!", + "Spawns with full iron!", "" }, From 2b365e4afd6bf80a7957fc0e035e45c38f05e781 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 2 Jan 2016 14:35:05 -0500 Subject: [PATCH 12/47] - Fixed blacklisting to stop join spam --- .../nautilus/game/arcade/managers/GameHostManager.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java index 50a838155..90aa00660 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java @@ -205,7 +205,7 @@ public class GameHostManager implements Listener } @EventHandler - public void whitelistJoin(PlayerLoginEvent event) + public void handleLogin(PlayerLoginEvent event) { Player p = event.getPlayer(); if (Manager.GetServerConfig().PlayerServerWhitelist){ @@ -217,6 +217,8 @@ public class GameHostManager implements Listener event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "This MPS is whitelisted."); } } + if (_blacklist.contains(p.getName())) + event.disallow(PlayerLoginEvent.Result.KICK_BANNED, "You were removed from this Mineplex Private Server."); } @EventHandler @@ -786,12 +788,6 @@ public class GameHostManager implements Listener { if (!isPrivateServer()) return; - - if (_blacklist.contains(event.getPlayer().getName())) - { - Manager.GetPortal().sendToHub(event.getPlayer(), "You were kicked from this Mineplex Private Server."); - return; - } String serverName = Manager.getPlugin().getConfig().getString("serverstatus.name"); UtilPlayer.message(event.getPlayer(), ChatColor.BOLD + "Welcome to Mineplex Private Servers!"); From b84ec01597277112aef198e7422b98ebf347b090 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 26 Jan 2016 22:52:45 -0500 Subject: [PATCH 13/47] - Huge amount of stuff --- .../game/core/combat/CombatManager.java | 40 +- .../game/core/damage/DamageManager.java | 5 + .../nautilus/game/arcade/ArcadeManager.java | 8 +- .../minecraftleague/MinecraftLeague.java | 450 ++++++++++-- .../minecraftleague/data/OreDeposit.java | 80 +++ .../games/minecraftleague/data/Spawner.java | 2 +- .../minecraftleague/data/TeamBeacon.java | 75 ++ .../minecraftleague/data/TeamCrystal.java | 57 +- .../data/map/ItemMapManager.java | 675 ++++++++++++++++++ .../data/map/ItemMapRenderer.java | 149 ++++ .../games/minecraftleague/kit/KitPlayer.java | 22 +- .../variation/GameVariation.java | 28 + .../variation/VariationManager.java | 81 +++ .../variation/VariationType.java | 33 + .../variation/wither/WitherPathfinder.java | 74 ++ .../variation/wither/WitherVariation.java | 19 + .../game/arcade/managers/GameChatManager.java | 8 +- .../game/arcade/managers/GameFlagManager.java | 16 +- 18 files changed, 1755 insertions(+), 67 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreDeposit.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/map/ItemMapManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/map/ItemMapRenderer.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/GameVariation.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationType.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherPathfinder.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java index b42ae087d..221a70fbe 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java @@ -3,6 +3,7 @@ package mineplex.minecraft.game.core.combat; import java.util.HashSet; import java.util.Iterator; +import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; import org.bukkit.entity.Arrow; import org.bukkit.entity.Fireball; @@ -89,11 +90,48 @@ public class CombatManager extends MiniPlugin { if (damagerEnt instanceof Player) Get((Player)damagerEnt).SetLastCombat(System.currentTimeMillis()); + + String cause = ""; + switch(event.getCause()) + { + case ENTITY_ATTACK: + cause = "Attack"; + break; + case ENTITY_EXPLOSION: + cause = "Explosion"; + break; + case MAGIC: + cause = "Thrown Potion"; + break; + case PROJECTILE: + cause = "Ranged Weapon"; + break; + case THORNS: + cause = "Thorns Enchantment"; + break; + default: + cause = event.getCause() + ""; + break; + } + + if (damagerEnt instanceof Player) + { + if (event.getCause() == DamageCause.ENTITY_ATTACK) + { + Player player = (Player) damagerEnt; + if (player.getItemInHand() == null) + cause = "Fists"; + else if (player.getItemInHand().getType() == Material.AIR) + cause = "Fists"; + else + cause = ItemStackFactory.Instance.GetName(player.getItemInHand(), false); + } + } Get(damagee).Attacked( UtilEnt.getName(damagerEnt), event.getDamage(), damagerEnt, - event.getCause() + "", null); + cause, null); } // Damager is WORLD else diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java index 8d3d35d16..7b7a84099 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java @@ -674,6 +674,11 @@ public class DamageManager extends MiniPlugin return null; } + + public boolean IsEnabled() + { + return _enabled; + } public void SetEnabled(boolean var) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 18e3a3620..33fad73a0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -146,6 +146,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation private BlockRestore _blockRestore; private Blood _blood; private Chat _chat; + private GameChatManager _gamechat; private CoreClientManager _clientManager; private DisguiseManager _disguiseManager; private DonationManager _donationManager; @@ -285,7 +286,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation _arcadeShop = new ArcadeShop(this, clientManager, donationManager); // Managers - new GameChatManager(this); + _gamechat = new GameChatManager(this); _gameCreationManager = new GameCreationManager(this); _gameGemManager = new GameGemManager(this); _gameManager = new GameManager(this); @@ -385,6 +386,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation { return _chat; } + + public GameChatManager GetGameChat() + { + return _gamechat; + } public BlockRestore GetBlockRestore() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index d3628b20b..5d672dd8b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.minecraftleague; import java.util.ArrayList; import java.util.List; +import java.util.Random; import java.util.concurrent.ConcurrentHashMap; import mineplex.core.common.util.C; @@ -12,24 +13,31 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.map.TeamMap; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.message.PrivateMessageEvent; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.combat.DeathMessageType; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.minecraftleague.commands.MinecraftLeagueCommand; +import nautilus.game.arcade.game.games.minecraftleague.data.OreDeposit; import nautilus.game.arcade.game.games.minecraftleague.data.PlayerRespawnPoint; import nautilus.game.arcade.game.games.minecraftleague.data.Spawner; +import nautilus.game.arcade.game.games.minecraftleague.data.TeamBeacon; import nautilus.game.arcade.game.games.minecraftleague.data.TeamCrystal; +import nautilus.game.arcade.game.games.minecraftleague.data.map.ItemMapManager; import nautilus.game.arcade.game.games.minecraftleague.kit.KitPlayer; import nautilus.game.arcade.kit.Kit; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -42,23 +50,26 @@ import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.PrepareItemCraftEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; -import org.bukkit.map.MapView.Scale; import org.bukkit.util.Vector; import com.google.common.base.Objects; @@ -67,12 +78,19 @@ public class MinecraftLeague extends TeamGame { private ConcurrentHashMap _crystals = new ConcurrentHashMap(); private ConcurrentHashMap _customRespawns = new ConcurrentHashMap(); - private ConcurrentHashMap _maps = new ConcurrentHashMap(); + //private ConcurrentHashMap _maps = new ConcurrentHashMap(); + private ConcurrentHashMap> _gear = new ConcurrentHashMap>(); + private ConcurrentHashMap _beacons = new ConcurrentHashMap(); private List _spawners = new ArrayList(); private long _liveTime = 0; - private boolean _overTime = false; private MinecraftLeagueCommand _cmd; + private long _lastIncrease; + private boolean _yellow = false; + + public List Ore = new ArrayList(); + public ItemMapManager MapManager; + public boolean OverTime = false; public MinecraftLeague(ArcadeManager manager) { @@ -94,7 +112,7 @@ public class MinecraftLeague extends TeamGame this.DeathOut = false; this.DamageSelf = false; - this.DeathSpectateSecs = 0; + this.DeathSpectateSecs = 5; this.WorldBoundaryKill = false; this.DeathDropItems = true; this.CreatureAllow = true; @@ -119,12 +137,14 @@ public class MinecraftLeague extends TeamGame this.StrictAntiHack = true; this.AllowParticles = false; this.SoupEnabled = false; + this.GameTimeout = -1; _help = new String[] { - "Respawn Crystals have 500 health!", + "Respawn Crystals have 50 health per person in-game!", "The better the sword you have, the more damage you deal to Respawn Crystals!", - "Right-click a bed in order to change your personal spawn location." + "Right-click a bed in order to change your personal spawn location!", + "Your map will display the locations of your enemies in OverTime!" }; @@ -207,57 +227,124 @@ public class MinecraftLeague extends TeamGame } } - public TeamMap getMap(GameTeam team) + private ItemStack getNewItemStack(ItemStack item) + { + ItemStack ret = item.clone(); + String type = ret.getType().toString(); + boolean damage = false; + boolean itemD = false; + if (type.contains("HELMET") || type.contains("CHESTPLATE") || type.contains("LEGGINGS") || type.contains("BOOTS")) + damage = true; + if (DamageType.getDamageType(ret.getType()) != DamageType.NONE) + itemD = true; + + if (damage) + { + ret.setDurability((short) (ret.getDurability() + (ret.getDurability() * .25))); + } + if (itemD) + { + ret.setDurability((short) (ret.getDurability() + 25)); + } + + if (ret.getDurability() > ret.getType().getMaxDurability()) + ret = new ItemStack(Material.AIR); + + if (ret.getType() == Material.MAP) + ret = new ItemStack(Material.AIR); + + return ret; + } + + /*public TeamMap getMap(GameTeam team) { return _maps.get(team); - } + }*/ @Override public void ParseData() { Location redLoc = WorldData.GetDataLocs("RED").get(0); Location blueLoc = WorldData.GetDataLocs("BLUE").get(0); - Location center = WorldData.GetDataLocs("ORANGE").get(0); + //Location center = WorldData.GetDataLocs("ORANGE").get(0); _crystals.put(GetTeam(ChatColor.RED), new TeamCrystal(this, GetTeam(ChatColor.RED), redLoc)); _crystals.put(GetTeam(ChatColor.AQUA), new TeamCrystal(this, GetTeam(ChatColor.AQUA), blueLoc)); - _maps.put(GetTeam(ChatColor.RED), new TeamMap(new ArrayList(), center, Scale.CLOSE)); - _maps.put(GetTeam(ChatColor.AQUA), new TeamMap(new ArrayList(), center, Scale.CLOSE)); + _beacons.put(GetTeam(ChatColor.RED), new TeamBeacon(GetTeam(ChatColor.RED), WorldData.GetDataLocs("PINK").get(0).getBlock(), redLoc)); + _beacons.put(GetTeam(ChatColor.AQUA), new TeamBeacon(GetTeam(ChatColor.AQUA), WorldData.GetDataLocs("CYAN").get(0).getBlock(), redLoc)); - _spawners.add(new Spawner(this, WorldData.GetDataLocs("GREEN").get(0), EntityType.CREEPER)); + //_maps.put(GetTeam(ChatColor.RED), new TeamMap(new ArrayList(), center, Scale.CLOSE)); + //_maps.put(GetTeam(ChatColor.AQUA), new TeamMap(new ArrayList(), center, Scale.CLOSE)); + + //_spawners.add(new Spawner(this, WorldData.GetDataLocs("GREEN").get(0), EntityType.CREEPER)); _spawners.add(new Spawner(this, WorldData.GetDataLocs("BLACK").get(0), EntityType.SKELETON)); + + for (Location loc : WorldData.GetDataLocs("LIGHT_BLUE")) + { + Ore.add(new OreDeposit(loc, Material.DIAMOND_ORE, new int[] {0, 255, 255})); + } + for (Location loc : WorldData.GetDataLocs("SILVER")) + { + Ore.add(new OreDeposit(loc, Material.IRON_ORE, new int[] {190, 190, 190})); + } + + MapManager = new ItemMapManager(this, WorldData.World, WorldData.MinX, WorldData.MinZ, WorldData.MaxX, WorldData.MaxZ); } @Override @EventHandler public void ScoreboardUpdate(UpdateEvent event) { - if (event.getType() != UpdateType.FAST) - return; - - scoreboardWrite(); + if (event.getType() == UpdateType.FAST || event.getType() == UpdateType.SEC) + scoreboardWrite(event.getType() == UpdateType.SEC); } - private void scoreboardWrite() + private void scoreboardWrite(boolean sec) { if (!InProgress()) return; + if (!IsLive()) + { + if (!sec) + return; + Scoreboard.Reset(); + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cDRedB + "Minecraft League"); + Scoreboard.WriteBlank(); + + if (_yellow) + { + Scoreboard.Write(C.cYellow + "Loading..."); + _yellow = false; + } + else + { + Scoreboard.Write("Loading..."); + _yellow = true; + } + + Scoreboard.Draw(); + return; + } + + if (sec) + return; + GameTeam red = GetTeam(ChatColor.RED); GameTeam blue = GetTeam(ChatColor.AQUA); TeamCrystal redc = _crystals.get(red); TeamCrystal bluec = _crystals.get(blue); - if (IsLive()) - _liveTime = Math.max(System.currentTimeMillis() - GetStateTime(), 0); + _liveTime = Math.max(System.currentTimeMillis() - GetStateTime(), 0); Scoreboard.Reset(); Scoreboard.WriteBlank(); Scoreboard.Write(C.cYellowB + "Time Elapsed"); Scoreboard.Write(UtilTime.MakeStr(_liveTime)); - if (_overTime) + if (OverTime) Scoreboard.Write(C.cDRedB + "Overtime"); Scoreboard.WriteBlank(); @@ -339,6 +426,43 @@ public class MinecraftLeague extends TeamGame return true; } + public void restoreGear(Player player) + { + if (!_gear.containsKey(player)) + return; + List items = _gear.get(player); + if (items.get(0) == null) + UtilInv.insert(player, new ItemStack(Material.AIR)); + else + UtilInv.insert(player, getNewItemStack(items.get(0))); + + for (int i = 1; i < items.size(); i++) + { + ItemStack item; + if (items.get(i) != null) + item = items.get(i); + else + item = new ItemStack(Material.AIR); + + switch(i) + { + case 1: + player.getInventory().setHelmet(getNewItemStack(item)); + break; + case 2: + player.getInventory().setChestplate(getNewItemStack(item)); + break; + case 3: + player.getInventory().setLeggings(getNewItemStack(item)); + break; + case 4: + player.getInventory().setBoots(getNewItemStack(item)); + break; + } + } + _gear.remove(player); + } + @EventHandler public void onEditSettings(GameStateChangeEvent event) { @@ -347,12 +471,14 @@ public class MinecraftLeague extends TeamGame if (event.GetState() == GameState.Live) { + _lastIncrease = System.currentTimeMillis(); Manager.GetExplosion().setEnabled(false); Manager.GetDamage().SetEnabled(false); Manager.GetCreature().SetForce(true); Manager.GetCreature().SetDisableCustomDrops(true); _cmd = new MinecraftLeagueCommand(Manager, this); Manager.addCommand(_cmd); + Manager.GetGameChat().TeamSpy = false; } if (event.GetState() == GameState.End) @@ -362,6 +488,8 @@ public class MinecraftLeague extends TeamGame Manager.GetCreature().SetForce(false); Manager.GetCreature().SetDisableCustomDrops(false); Manager.removeCommand(_cmd); + Manager.GetGameChat().TeamSpy = true; + HandlerList.unregisterAll(MapManager); } } @@ -371,6 +499,14 @@ public class MinecraftLeague extends TeamGame if (!IsLive()) return; + if (event.getType() == UpdateType.SEC) + { + for (OreDeposit od : Ore) + { + od.update(); + } + } + if (event.getType() == UpdateType.FASTEST) { for (TeamCrystal crystal : _crystals.values()) @@ -378,24 +514,44 @@ public class MinecraftLeague extends TeamGame crystal.update(); } - for (TeamMap map : _maps.values()) + /*for (TeamMap map : _maps.values()) { map.update(null); - } + }*/ for (Spawner spawner : _spawners) { spawner.update(); } - if (!_overTime) + for (TeamBeacon beacon : _beacons.values()) + { + beacon.update(); + } + + if (!OverTime) { if (UtilTime.elapsed(GetStateTime(), UtilTime.convert(15, TimeUnit.MINUTES, TimeUnit.MILLISECONDS))) { - _overTime = true; + OverTime = true; UtilTextMiddle.display(C.cDRed + "Overtime", C.cDRed + "Dying will now cause your crystal to lose 20 health!"); } } + + if (UtilTime.elapsed(_lastIncrease, UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS))) + { + _lastIncrease = System.currentTimeMillis(); + this.DeathSpectateSecs = Math.max(0, this.DeathSpectateSecs + 2.5); + } + + for (Player player : Bukkit.getOnlinePlayers()) + { + if (UtilPlayer.isSpectator(player)) + { + player.setFireTicks(-1); + player.setFoodLevel(20); + } + } } } @@ -449,7 +605,7 @@ public class MinecraftLeague extends TeamGame if (!crystal.canDamage(player)) return; - if (!crystal.damage(event.getDamage(), player)) + if (!crystal.damage(event.getDamage(), player, true)) player.playSound(crystal.getLocation(), Sound.ORB_PICKUP, 100, 0); } } @@ -463,7 +619,7 @@ public class MinecraftLeague extends TeamGame if (player.getItemInHand() == null || player.getItemInHand().getType() == Material.AIR) { - if (!crystal.damage(1, player)) + if (!crystal.damage(1, player, true)) player.playSound(crystal.getLocation(), Sound.ZOMBIE_WOODBREAK, 1, 0); return; } @@ -472,12 +628,17 @@ public class MinecraftLeague extends TeamGame int level = player.getItemInHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL); double damage = DamageAmount.getDamageAmount(type).getDamage(level, DamageType.getDamageType(type)); - if (!crystal.damage(damage, player)) + if (!crystal.damage(damage, player, true)) player.playSound(crystal.getLocation(), Sound.ZOMBIE_WOODBREAK, 1, 0); if (DamageAmount.getDamageAmount(type) != DamageAmount.NONE) { player.getItemInHand().setDurability((short) (player.getItemInHand().getDurability() + 1)); + if (player.getItemInHand().getDurability() > player.getItemInHand().getType().getMaxDurability()) + { + player.getInventory().remove(player.getItemInHand()); + player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, 0); + } UtilInv.Update(player); } } @@ -525,7 +686,7 @@ public class MinecraftLeague extends TeamGame } } - @EventHandler + /*@EventHandler public void onRespawn(PlayerGameRespawnEvent event) { if (event.GetGame() != this) @@ -548,12 +709,20 @@ public class MinecraftLeague extends TeamGame UtilAction.velocity(player, new Vector(0,1.2,0)); getMap(GetTeam(player)).update(player); + player.getInventory().clear(); + player.getInventory().setArmorContents(new ItemStack[] + { + new ItemStack(Material.AIR), + new ItemStack(Material.AIR), + new ItemStack(Material.AIR), + new ItemStack(Material.AIR) + }); return; } if (_overTime) _crystals.get(GetTeam(player)).damage(20, null); - } + }*/ @EventHandler public void onDrop(PlayerDropItemEvent event) @@ -633,6 +802,10 @@ public class MinecraftLeague extends TeamGame if (item.getType() == Material.MAP) continue; + if (_gear.get(event.getEntity()) != null) + if (_gear.get(event.getEntity()).contains(item)) + continue; + newDrops.add(item); } @@ -681,6 +854,18 @@ public class MinecraftLeague extends TeamGame } @EventHandler + public void controlMobRate(CreatureSpawnEvent event) + { + if (!IsLive()) + return; + + if (event.getSpawnReason() != SpawnReason.NATURAL) + return; + + Manager.GetCreature().SpawnEntity(event.getLocation(), event.getEntityType()); + } + + @EventHandler(priority = EventPriority.LOWEST) public void controlPvP(EntityDamageByEntityEvent event) { if (!IsLive()) @@ -727,7 +912,7 @@ public class MinecraftLeague extends TeamGame } } - @EventHandler + @EventHandler(priority = EventPriority.LOWEST) public void protectSpectators(EntityDamageEvent event) { if (!IsLive()) @@ -742,27 +927,200 @@ public class MinecraftLeague extends TeamGame } @EventHandler - public void equip(GameStateChangeEvent event) + public void editHealth(GameStateChangeEvent event) { + if (event.GetState() != GameState.Prepare) + return; + + if (event.GetGame() != this) + return; + + for (TeamCrystal c : _crystals.values()) + { + double playercount = GetTeam(ChatColor.RED).GetPlayers(true).size() + GetTeam(ChatColor.AQUA).GetPlayers(true).size(); + c.setMaxHealth(50 * 2 * playercount); + } + } + + @EventHandler + public void dropBow(EntityDeathEvent event) + { + if (event.getEntityType() != EntityType.SKELETON) + return; + + boolean addbow = true; + for (ItemStack check : event.getDrops()) + { + if (check.getType() == Material.BOW) + addbow = false; + } + + if (addbow) + { + if (new Random().nextDouble() > .5) + event.getDrops().add(new ItemStack(Material.BOW)); + } + } + + @EventHandler + public void giveGear(GameStateChangeEvent event) + { + if (event.GetGame() != this) + return; if (event.GetState() != GameState.Live) return; - for (Player red : GetTeam(ChatColor.RED).GetPlayers(true)) + for (Player player : GetTeam(ChatColor.AQUA).GetPlayers(true)) { - red.getInventory().setHelmet(new ItemStack(Material.IRON_HELMET)); - red.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE)); - red.getInventory().setLeggings(new ItemStack(Material.IRON_LEGGINGS)); - red.getInventory().setBoots(new ItemStack(Material.IRON_BOOTS)); - red.getInventory().addItem(new ItemStack(Material.IRON_SWORD)); + player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setColor(Color.BLUE).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(Color.BLUE).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(Color.BLUE).build()); + player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.BLUE).build()); + player.getInventory().addItem(new ItemStack(Material.WOOD_SWORD)); + player.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 5)); } - - for (Player blue : GetTeam(ChatColor.AQUA).GetPlayers(true)) + for (Player player : GetTeam(ChatColor.RED).GetPlayers(true)) { - blue.getInventory().setHelmet(new ItemStack(Material.IRON_HELMET)); - blue.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE)); - blue.getInventory().setLeggings(new ItemStack(Material.IRON_LEGGINGS)); - blue.getInventory().setBoots(new ItemStack(Material.IRON_BOOTS)); - blue.getInventory().addItem(new ItemStack(Material.IRON_SWORD)); + player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setColor(Color.RED).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(Color.RED).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(Color.RED).build()); + player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.RED).build()); + player.getInventory().addItem(new ItemStack(Material.WOOD_SWORD)); + player.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 5)); } } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) + public void storeGear(EntityDamageEvent event) + { + if (!IsLive()) + return; + if (!(event.getEntity() instanceof Player)) + return; + + Player player = (Player)event.getEntity(); + List gear = new ArrayList(); + + gear.add(player.getItemInHand()); + gear.add(player.getInventory().getHelmet()); + gear.add(player.getInventory().getChestplate()); + gear.add(player.getInventory().getLeggings()); + gear.add(player.getInventory().getBoots()); + + _gear.put(player, gear); + } + + @EventHandler + public void blockDeadPvt(PrivateMessageEvent event) + { + boolean onedead = false; + boolean onelive = false; + + if (event.getSender() != null) + { + if (UtilPlayer.isSpectator(event.getSender())) + onedead = true; + else + onelive = true; + } + if (event.getRecipient() != null) + { + if (UtilPlayer.isSpectator(event.getRecipient())) + onedead = true; + else + onelive = true; + } + + if (onedead) + { + if (onelive) + { + if (event.getSender() != null) + { + UtilPlayer.message(event.getSender(), F.main("Game", "You cannot message a player if you are not both alive/dead!")); + } + event.setCancelled(true); + } + } + } + + @EventHandler + public void blockDeadTalk(AsyncPlayerChatEvent event) + { + if (GetTeam(event.getPlayer()) == null) + { + for (Player player : GetTeam(ChatColor.RED).GetPlayers(true)) + { + event.getRecipients().remove(player); + } + for (Player player : GetTeam(ChatColor.AQUA).GetPlayers(true)) + { + event.getRecipients().remove(player); + } + + return; + } + if (!GetTeam(event.getPlayer()).IsAlive(event.getPlayer())) + { + for (Player player : GetTeam(ChatColor.RED).GetPlayers(true)) + { + event.getRecipients().remove(player); + } + for (Player player : GetTeam(ChatColor.AQUA).GetPlayers(true)) + { + event.getRecipients().remove(player); + } + } + } + + @EventHandler + public void handleDeath(CombatDeathEvent event) + { + if (!IsLive()) + return; + + event.SetBroadcastType(DeathMessageType.Detailed); + + if (event.GetLog().GetPlayer() == null) + return; + if (Bukkit.getPlayer(event.GetLog().GetPlayer().GetName()) == null) + return; + Player player = Bukkit.getPlayer(event.GetLog().GetPlayer().GetName()); + + if (!_crystals.get(GetTeam(player)).Alive) + { + SetPlayerState(player, PlayerState.OUT); + + Manager.GetCondition().Factory().Blind("PermDead", player, player, 1.5, 0, false, false, false); + Manager.GetCondition().Factory().Cloak("PermDead", player, player, 9999, false, false); + + player.setAllowFlight(true); + player.setFlying(true); + ((CraftPlayer)player).getHandle().spectating = true; + ((CraftPlayer)player).getHandle().k = false; + + UtilAction.velocity(player, new Vector(0,1.2,0)); + + //getMap(GetTeam(player)).update(player); + player.getInventory().clear(); + player.getInventory().setArmorContents(new ItemStack[] + { + new ItemStack(Material.AIR), + new ItemStack(Material.AIR), + new ItemStack(Material.AIR), + new ItemStack(Material.AIR) + }); + return; + } + + if (OverTime) + _crystals.get(GetTeam(player)).damage(20, null, false); + } + + @EventHandler + public void onPickup(PlayerPickupItemEvent event) + { + if (UtilPlayer.isSpectator(event.getPlayer())) + event.setCancelled(true); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreDeposit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreDeposit.java new file mode 100644 index 000000000..94ab13ef7 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreDeposit.java @@ -0,0 +1,80 @@ +package nautilus.game.arcade.game.games.minecraftleague.data; + +import mineplex.core.common.util.UtilBlock; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; + +public class OreDeposit +{ + private Location _loc; + private Material _ore; + private int[] _rgb; + private boolean _valid; + + public OreDeposit(Location loc, Material type, int[] rgb) + { + _loc = loc; + _ore = type; + _rgb = rgb; + } + + public boolean isValid() + { + return _valid; + } + + public boolean isInRadius(int x, int z) + { + int diffX = Math.max(x, _loc.getBlockX()) - Math.min(x, _loc.getBlockX()); + int diffZ = Math.max(z, _loc.getBlockZ()) - Math.min(z, _loc.getBlockZ()); + + if (diffX <= 5) + if (diffZ <= 10) + return true; + + return false; + } + + /*public boolean isBase(int x, int z) + { + if (_loc.getBlockX() == x) + if (_loc.getBlockZ() == z) + return true; + + return false; + }*/ + + /*public Location getBase() + { + return _loc; + }*/ + + public int getRed() + { + return _rgb[0]; + } + + public int getGreen() + { + return _rgb[1]; + } + + public int getBlue() + { + return _rgb[2]; + } + + public void update() + { + int found = 0; + for (Block block : UtilBlock.getInSquare(_loc.getBlock(), 10)) + { + if (block.getType() == _ore) + found++; + } + + _valid = found >= 1; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/Spawner.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/Spawner.java index c5e1ad009..abe780900 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/Spawner.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/Spawner.java @@ -100,7 +100,7 @@ public class Spawner if (_canSpawn) { - if (!UtilTime.elapsed(_lastSpawned, UtilTime.convert(20, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) + if (!UtilTime.elapsed(_lastSpawned, UtilTime.convert(10, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) _canSpawn = false; else _canSpawn = true; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java new file mode 100644 index 000000000..fdbca27af --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java @@ -0,0 +1,75 @@ +package nautilus.game.arcade.game.games.minecraftleague.data; + +import java.util.List; + +import mineplex.core.common.util.UtilBlock; +import nautilus.game.arcade.game.GameTeam; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +public class TeamBeacon +{ + private GameTeam _team; + private Block _block; + private List _valuables; + private Location _core; + + public TeamBeacon(GameTeam team, Block block, Location core) + { + _team = team; + _block = block; + _core = core; + _valuables = UtilBlock.getInSquare(_block.getRelative(BlockFace.DOWN), 1); + + _block.setType(Material.BEACON); + for (Block v : _valuables) + { + v.setType(Material.IRON_BLOCK); + } + } + + @SuppressWarnings("deprecation") + private void hideValuables() + { + for (Player player : Bukkit.getOnlinePlayers()) + { + for (Block v : _valuables) + { + player.sendBlockChange(v.getLocation(), Material.DIRT, (byte) 0); + } + } + } + + public boolean isBlock(Block match) + { + if (match.getX() == _block.getX()) + if (match.getZ() == _block.getZ()) + if (match.getY() == _block.getY()) + return true; + + return false; + } + + public void update() + { + hideValuables(); + + for (Player player : _team.GetPlayers(true)) + { + if (player.getLocation().distance(_core) < 15) + { + player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 5 * 20, 0)); + player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 5 * 20, 0)); + player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 5 * 20, 0)); + player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 5 * 20, 0)); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java index 220401007..3ff133c37 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java @@ -9,6 +9,7 @@ import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; @@ -31,17 +32,20 @@ public class TeamCrystal private MinecraftLeague _host; private Location _spawn; private GameTeam _team; - private Double _health; + private Double _health, _maxHealth; private EnderCrystal _entity; private Hologram _name, _healthTag; public boolean Alive; + private long _lastAlert = -1; + public TeamCrystal(MinecraftLeague host, GameTeam team, Location spawn) { _host = host; _spawn = spawn.clone().add(0.5, 1.2, 0.5); _team = team; - _health = 1000D; + _maxHealth = 11111D; + _health = 11111D; _name = new Hologram(_host.getArcadeManager().getHologramManager(), _spawn.clone().add(0, 3, 0), team.GetColor() + team.getDisplayName() + "'s Respawn Crystal"); _healthTag = new Hologram(_host.getArcadeManager().getHologramManager(), _spawn.clone().add(0, 2, 0), formatHealth(_health)); @@ -53,7 +57,7 @@ public class TeamCrystal _name.start(); _healthTag.start(); _entity = (EnderCrystal) _host.getArcadeManager().GetCreature().SpawnEntity(_spawn, EntityType.ENDER_CRYSTAL); - _health = 500D; + _health = _maxHealth; Alive = true; } @@ -102,6 +106,29 @@ public class TeamCrystal } } + private void alert() + { + if (UtilTime.elapsed(_lastAlert, UtilTime.convert(15, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) + { + long s = System.currentTimeMillis(); + long e = UtilTime.convert(5, TimeUnit.SECONDS, TimeUnit.MILLISECONDS); + + for (Player player : _team.GetPlayers(true)) + { + player.playSound(player.getLocation(), Sound.NOTE_PLING, 10, 0); + while (!UtilTime.elapsed(s, e)) + { + UtilTextBottom.display(C.cRed + "Your Crystal is under attack!", player); + } + } + } + } + + public Entity getEntity() + { + return _entity; + } + public boolean isEntity(Entity e) { return e.getEntityId() == _entity.getEntityId(); @@ -136,9 +163,9 @@ public class TeamCrystal { String tag = healthNumber.toString(); - if (healthNumber > 450) + if (healthNumber > (.9 * _maxHealth)) tag = C.cGreen + tag; - else if (healthNumber < 225) + else if (healthNumber < (.45 * _maxHealth)) tag = C.cRed + tag; else tag = C.cYellow + tag; @@ -146,7 +173,7 @@ public class TeamCrystal return tag; } - public boolean damage(double damage, Player player) + public boolean damage(double damage, Player player, boolean hit) { Double newHealth = Math.max(_health - damage, 0); @@ -156,8 +183,12 @@ public class TeamCrystal return true; } + if (hit) + alert(); + _health = newHealth; - Recharge.Instance.use(player, "Damage Teamcrystal", UtilTime.convert(1, TimeUnit.SECONDS, TimeUnit.MILLISECONDS), false, false); + if (player != null) + Recharge.Instance.use(player, "Damage Teamcrystal", UtilTime.convert(1, TimeUnit.SECONDS, TimeUnit.MILLISECONDS), false, false); return false; } @@ -176,14 +207,24 @@ public class TeamCrystal { _entity = (EnderCrystal) _host.getArcadeManager().GetCreature().SpawnEntity(_spawn, EntityType.ENDER_CRYSTAL); } + + if (_health > _maxHealth) + { + _health = _maxHealth; + } } } + public void setMaxHealth(Double health) + { + _maxHealth = Math.abs(health); + } + public void handleDebug(Player dev, Double damage, boolean kill) { if (damage != null) { - damage(damage, dev); + damage(damage, dev, false); UtilPlayer.message(dev, F.main(_host.GetName(), "The Crystal has been damaged")); return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/map/ItemMapManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/map/ItemMapManager.java new file mode 100644 index 000000000..d39014967 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/map/ItemMapManager.java @@ -0,0 +1,675 @@ +package nautilus.game.arcade.game.games.minecraftleague.data.map; + +import java.io.File; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.portal.ServerTransferEvent; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; +import net.minecraft.server.v1_8_R3.Block; +import net.minecraft.server.v1_8_R3.BlockPosition; +import net.minecraft.server.v1_8_R3.Blocks; +import net.minecraft.server.v1_8_R3.IBlockData; +import net.minecraft.server.v1_8_R3.MaterialMapColor; +import net.minecraft.server.v1_8_R3.PersistentCollection; + +import org.bukkit.Bukkit; +import org.bukkit.Chunk; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.craftbukkit.v1_8_R3.CraftChunk; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.inventory.ItemStack; +import org.bukkit.map.MapRenderer; +import org.bukkit.map.MapView; + +import com.google.common.collect.HashMultiset; +import com.google.common.collect.Iterables; +import com.google.common.collect.Multisets; + +public class ItemMapManager /*extends MiniPlugin*/ implements Listener +{ + private MinecraftLeague _host; + + private int _blocksScan = 16; + private Comparator> _comparator; + private int _halfMapSize; + private int[][] _heightMap; + private boolean _loadWorld = true; + private HashMap _map = new HashMap(); + private short _mapId = (short) UtilMath.r(Short.MAX_VALUE); + private ArrayList> _scanList = new ArrayList>(); + private World _world; + private int _centerX; + private int _centerZ; + private int _scale; + + public ItemMapManager(MinecraftLeague host, World world, int minX, int minZ, int maxX, int maxZ) + { + //super("ItemMapManager", host.getArcadeManager().getPlugin()); + Bukkit.getPluginManager().registerEvents(this, host.getArcadeManager().getPlugin()); + + _host = host; + + _centerX = minX + ((maxX - minX) / 2); + _centerZ = minZ + ((maxZ - minZ) / 2); + _centerX = (int) (Math.round(_centerX / 16D) * 16); + _centerZ = (int) (Math.round(_centerZ / 16D) * 16); + + _halfMapSize = (int) (Math.ceil(Math.max((maxX - minX) / 2D, (maxZ - minZ) / 2D) / 16D) * 16); + + ArrayList> list = new ArrayList>(); + + for (int scale = 1; scale <= 16; scale++) + { + int s = _halfMapSize; + + if ((s / scale) > 127) + continue; + + while (s < 10000 && (s % 16 != 0 || s % scale != 0)) + { + s += 16; + } + + if (s < 10000) + { + list.add(new HashMap.SimpleEntry(scale, s)); + } + } + + if (list.isEmpty()) + { + _scale = 16; + _halfMapSize = 127 * 8; + } + else + { + Collections.sort(list, new Comparator>() + { + + @Override + public int compare(Entry o1, Entry o2) + { + return Integer.compare(o1.getValue(), o2.getValue()); + } + }); + + _scale = list.get(0).getKey(); + _halfMapSize = list.get(0).getValue(); + + System.out.print( + "Using scale " + _scale + ", Size: " + _halfMapSize + ", CenterX: " + _centerX + ", CenterZ: " + _centerZ); + } + + _heightMap = new int[(_halfMapSize * 2) + 16][]; + + _comparator = new Comparator>() + { + + @Override + public int compare(Entry o1, Entry o2) + { + // Render the places outside the map first to speed up visual errors fixing + int outsideMap = Boolean.compare(o1.getValue() < -_halfMapSize, o2.getValue() < -_halfMapSize); + + if (outsideMap != 0) + { + return -outsideMap; + } + + double dist1 = 0; + double dist2 = 0; + + for (Player player : UtilServer.getPlayers()) + { + dist1 += getDistance(o1, player.getLocation().getX(), player.getLocation().getZ()); + dist2 += getDistance(o2, player.getLocation().getX(), player.getLocation().getZ()); + } + + if (dist1 != dist2) + { + return Double.compare(dist1, dist2); + } + + dist1 = getDistance(o1, 0, 0); + dist2 = getDistance(o2, 0, 0); + + return Double.compare(dist1, dist2); + + } + }; + + for (int x = -_halfMapSize; x < _halfMapSize; x += _blocksScan) + { + for (int z = -_halfMapSize - 16; z < _halfMapSize; z += (z < -_halfMapSize ? 16 : _blocksScan)) + { + _scanList.add(new HashMap.SimpleEntry(x, z)); + } + } + + for (int s = 1; s <= 2; s++) + { + if (s == 2) + { + s = getScale(); + + if (s == 1) + break; + } + + int size = (_halfMapSize * 2) / s; + Byte[][] bytes = new Byte[size][]; + + for (int i = 0; i < size; i++) + { + bytes[i] = new Byte[size]; + } + + _map.put(s, bytes); + } + + for (int i = 0; i < _heightMap.length; i++) + { + _heightMap[i] = new int[_heightMap.length]; + } + + _world = world; + + try + { + File foundFile = null; + + for (File f : new File("world/data").listFiles()) + { + if (f.getName().startsWith("map_")) + { + foundFile = f; + break; + } + } + + if (foundFile == null) + { + PersistentCollection collection = ((CraftWorld) _world).getHandle().worldMaps; + Field f = collection.getClass().getDeclaredField("d"); + f.setAccessible(true); + ((HashMap) f.get(collection)).put("map", (short) 0); + } + + MapView view = Bukkit.createMap(_world); + _mapId = view.getId(); + setupRenderer(view); + + for (int i = 0; i < 100; i++) + { + setupRenderer(Bukkit.createMap(_world));// Ensures the following 100 maps are unused + } + } + catch (Exception ex) + { + ex.printStackTrace(); + } + + rebuildScan(); + } + + private void setupRenderer(MapView view) + { + for (MapRenderer renderer : view.getRenderers()) + { + view.removeRenderer(renderer); + } + + view.addRenderer(new ItemMapRenderer(this, _host)); + } + + public int getScale() + { + return _scale; + } + + public int getX() + { + return _centerX; + } + + public int getZ() + { + return _centerZ; + } + + /** + * Get the center of the map. + */ + public int calcMapCenter(int zoom, int cord) + { + int mapSize = _halfMapSize / zoom; // This is how large the map is in pixels + + int mapCord = cord / zoom; // This is pixels from true center of map, not held map + + int fDiff = mapSize - -mapCord; + int sDiff = mapSize - mapCord; + + double chunkBlock = cord & 0xF; + cord -= chunkBlock; + chunkBlock /= zoom; + + /*if ((fDiff < 64 || sDiff < 64) && (Math.abs(fDiff - sDiff) > 1)) + { + cord += (fDiff > sDiff ? Math.floor(chunkBlock) : Math.ceil(chunkBlock)); + } + else*/ + { + cord += (int) Math.floor(chunkBlock) * zoom; + } + + while ((fDiff < 64 || sDiff < 64) && (Math.abs(fDiff - sDiff) > 1)) + { + int change = (fDiff > sDiff ? -zoom : zoom); + cord += change; + + mapCord = cord / zoom; + + fDiff = mapSize - -mapCord; + sDiff = mapSize - mapCord; + } + + return cord; + } + + private void colorWorldHeight(int zoom, int startingX, int startingZ) + { + if (zoom == 0) + zoom = 1; + + Byte[][] map = _map.get(zoom); + + for (int x = startingX; x < startingX + _blocksScan; x += zoom) + { + double d0 = 0; + + // Prevents ugly lines for the first line of Z + + for (int addX = 0; addX < zoom; addX++) + { + for (int addZ = 0; addZ < zoom; addZ++) + { + int hX = x + addX + _halfMapSize; + int hZ = (startingZ - zoom) + addZ + _halfMapSize; + + if (hX >= _halfMapSize * 2 || hZ >= _halfMapSize * 2) + { + continue; + } + + d0 += _heightMap[hX + 16][hZ + 16] / (zoom * zoom); + } + } + + for (int z = startingZ; z < startingZ + _blocksScan; z += zoom) + { + // Water depth colors not included + double d1 = 0; + + for (int addX = 0; addX < zoom; addX++) + { + for (int addZ = 0; addZ < zoom; addZ++) + { + int hX = x + addX + _halfMapSize; + int hZ = z + addZ + _halfMapSize; + + if (hX >= _halfMapSize * 2 || hZ >= _halfMapSize * 2) + { + continue; + } + + d1 += _heightMap[hX + 16][hZ + 16] / (zoom * zoom); + } + } + + double d2 = (d1 - d0) * 4.0D / (zoom + 4) + ((x + z & 0x1) - 0.5D) * 0.4D; + byte b0 = 1; + + d0 = d1; + + if (d2 > 0.6D) + { + b0 = 2; + } + else if (d2 > 1.2D) + { + b0 = 3; + } + else if (d2 < -0.6D) + { + b0 = 0; + } + + int origColor = map[(x + _halfMapSize) / zoom][(z + _halfMapSize) / zoom] - 1; + + /*if (color < 4) + { + d2 = waterDepth * 0.1D + (k1 + j2 & 0x1) * 0.2D; + b0 = 1; + if (d2 < 0.5D) + { + b0 = 2; + } + + if (d2 > 0.9D) + { + b0 = 0; + } + }*/ + + byte color = (byte) (origColor + b0); + map[(x + _halfMapSize) / zoom][(z + _halfMapSize) / zoom] = color; + } + } + } + + private void drawWorldScale(int zoom, int startingX, int startingZ) + { + Byte[][] first = _map.get(1); + Byte[][] second = _map.get(zoom); + + for (int x = startingX; x < startingX + _blocksScan; x += zoom) + { + for (int z = startingZ; z < startingZ + _blocksScan; z += zoom) + { + HashMultiset hashmultiset = HashMultiset.create(); + + for (int addX = 0; addX < zoom; addX++) + { + for (int addZ = 0; addZ < zoom; addZ++) + { + int pX = x + addX + _halfMapSize; + int pZ = z + addZ + _halfMapSize; + + if (pX >= first.length || pZ >= first.length) + { + continue; + } + + Byte b = first[pX][pZ]; + + if (b == null) + continue; + + hashmultiset.add(b); + } + } + + Byte color = Iterables.getFirst(Multisets.copyHighestCountFirst(hashmultiset), (byte) 0); + + second[(x + _halfMapSize) / zoom][(z + _halfMapSize) / zoom] = color; + } + } + } + + private double getDistance(double x1, double z1, double x2, double z2) + { + x1 = (x1 - x2); + z1 = (z1 - z2); + + return (x1 * x1) + (z1 * z1); + } + + private double getDistance(Entry entry, double x1, double z1) + { + return getDistance(x1 + _centerX, z1 + _centerZ, entry.getKey() + (_blocksScan / 2), + entry.getValue() + (_blocksScan / 2)); + } + + public Byte[][] getMap(int scale) + { + return _map.get(scale); + } + + public int getMapSize() + { + return _halfMapSize; + } + + @EventHandler + public void onServerTransfer(ServerTransferEvent event) + { + Player p = event.getPlayer(); + + p.sendMessage(C.cDRed + C.Bold + "WARNING!"); + p.sendMessage(C.cYellow + "There's a bug where switching servers will freeze the Team Map!"); + p.sendMessage(C.cYellow + "If you want to play Minecraft League again, rejoin the Mineplex server!"); + } + + private void rebuildScan() + { + for (int x = -_halfMapSize; x < _halfMapSize; x += _blocksScan) + { + for (int z = -_halfMapSize - 16; z < _halfMapSize; z += (z < -_halfMapSize ? 16 : _blocksScan)) + { + _scanList.add(new HashMap.SimpleEntry(x, z)); + } + } + + if (!_loadWorld) + { + Iterator> itel = _scanList.iterator(); + + while (itel.hasNext()) + { + Entry entry = itel.next(); + boolean removeEntry = true; + + for (Player player : UtilServer.getPlayers()) + { + if (Math.sqrt(getDistance(entry, player.getLocation().getX(), player.getLocation().getZ())) < 200) + { + removeEntry = false; + break; + } + } + + if (removeEntry) + { + itel.remove(); + } + } + } + + Collections.sort(_scanList, _comparator); + } + + @EventHandler + public void renderMap(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + return; + + if (_scanList.isEmpty()) + { + if (_loadWorld) + { + _loadWorld = false; + System.out.print("Finished first map scan and render"); + } + + if (UtilServer.getPlayers().length == 0) + return; + + rebuildScan(); + } + else if (_scanList.size() % 20 == 0) + { + Collections.sort(_scanList, _comparator); + } + + Entry entry = _scanList.remove(0); + + int startingX = entry.getKey(); + int startingZ = entry.getValue(); + + boolean outsideMap = startingZ < -_halfMapSize; + + scanWorldMap(startingX, startingZ, !outsideMap); + + if (outsideMap) + { + return; + } + + for (int s = 1; s <= 2; s++) + { + if (s == 2) + { + s = getScale(); + + if (s == 1) + break; + } + + if (s == 13 && _loadWorld) + continue; + + if (!outsideMap) + { + drawWorldScale(s, startingX, startingZ); + } + + colorWorldHeight(s, startingX, startingZ); + } + + colorWorldHeight(0, startingX, startingZ); + } + + public void scanWorldMap(int startingX, int startingZ, boolean setColors) + { + Byte[][] map = _map.get(1); + + for (int beginX = startingX; beginX < startingX + _blocksScan; beginX += 16) + { + for (int beginZ = startingZ - (startingZ > -_halfMapSize ? 16 : 0); beginZ < startingZ + + (setColors ? _blocksScan : 16); beginZ += 16) + { + Chunk chunk = _world.getChunkAt((beginX + _centerX) / 16, (beginZ + _centerZ) / 16); + boolean loaded = false; + + if (!chunk.isLoaded()) + { + if (_loadWorld) + { + loaded = chunk.load(); + } + else + { + continue; + } + } + + net.minecraft.server.v1_8_R3.Chunk nmsChunk = ((CraftChunk) chunk).getHandle(); + + for (int x = beginX; x < beginX + 16; x++) + { + for (int z = beginZ; z < beginZ + 16; z++) + { + int color = 0; + + if (!nmsChunk.isEmpty()) + { + int k3 = x & 0xF; + int l3 = z & 0xF; + + int l4 = nmsChunk.b(k3, l3) + 1; + IBlockData iblockdata = Blocks.AIR.getBlockData(); + + if (l4 > 1) + { + do + { + l4--; + iblockdata = nmsChunk.getBlockData(new BlockPosition(k3, l4, l3)); + } + while (iblockdata.getBlock().g(iblockdata) == MaterialMapColor.b && (l4 > 0)); + + if ((l4 > 0) && (iblockdata.getBlock().getMaterial().isLiquid())) + { + int j5 = l4 - 1; + Block block1; + do + { + block1 = nmsChunk.getType(new BlockPosition(k3, j5--, l3)); + } + while ((j5 > 0) && (block1.getMaterial().isLiquid())); + } + } + + _heightMap[x + _halfMapSize + 16][z + _halfMapSize + 16] = l4; + + if (setColors) + { + // color = block.f(i5).M; + IBlockData data = nmsChunk.getBlockData(new BlockPosition(k3, l4, l3)); + color = data.getBlock().g(data).M; + + color = (byte) ((color * 4) + 1); + } + } + + if (setColors && beginZ >= startingZ) + { + map[x + _halfMapSize][z + _halfMapSize] = (byte) color; + } + } + + if (loaded) + { + chunk.unload(); + } + } + } + } + } + + public void setMap(Player player) + { + for (ItemStack item : UtilInv.getItems(player)) + { + if (item.getType() == Material.MAP && item.getDurability() == _mapId) + { + return; + } + } + + ItemStack item = new ItemBuilder(Material.MAP, 1, _mapId).setTitle("Team Map").build(); + + int slot = player.getInventory().firstEmpty(); + + if (slot >= 0) + { + ItemStack mapSlot = player.getInventory().getItem(8); + + if (mapSlot == null || mapSlot.getType() == Material.AIR) + { + slot = 8; + } + + player.getInventory().setItem(slot, item); + } + } + +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/map/ItemMapRenderer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/map/ItemMapRenderer.java new file mode 100644 index 000000000..50ba5b4eb --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/map/ItemMapRenderer.java @@ -0,0 +1,149 @@ +package nautilus.game.arcade.game.games.minecraftleague.data.map; + +import java.awt.Color; + +import mineplex.core.recharge.Recharge; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; +import nautilus.game.arcade.game.games.minecraftleague.data.OreDeposit; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.map.MapCanvas; +import org.bukkit.map.MapCursor; +import org.bukkit.map.MapCursorCollection; +import org.bukkit.map.MapPalette; +import org.bukkit.map.MapRenderer; +import org.bukkit.map.MapView; + +public class ItemMapRenderer extends MapRenderer +{ + private ItemMapManager _manager; + private MinecraftLeague _host; + + public ItemMapRenderer(ItemMapManager itemMapManager, MinecraftLeague host) + { + super(true); + + _manager = itemMapManager; + _host = host; + } + + @Override + public void render(MapView mapView, MapCanvas canvas, Player player) + { + int zoom = _manager.getScale(); + + Byte[][] map = _manager.getMap(zoom); + + int centerX = 0; + int centerZ = 0; + + // We have this cooldown to squeeze out every single bit of performance from the server. + if (Recharge.Instance.use(player, "Draw Map", 4000, false, false)) + { + for (int mapX = 0; mapX < 128; mapX++) + { + for (int mapZ = 0; mapZ < 128; mapZ++) + { + int blockX = centerX + (mapX - 64); + int blockZ = centerZ + (mapZ - 64); + + int pixelX = blockX + (map.length / 2); + int pixelZ = blockZ + (map.length / 2); + + Byte color; + + if (!(pixelX < 0 || pixelZ < 0 || pixelX >= map.length || pixelZ >= map.length) + && map[pixelX][pixelZ] != null) + { + color = map[pixelX][pixelZ]; + + blockX *= zoom; + blockZ *= zoom; + } + else + { + color = (byte) 0; + } + + for (OreDeposit od : _host.Ore) + { + if (od.isInRadius(blockX - 20, blockZ + 15)) // TODO Some math to figure out if this pixel is going to be colored in for the circle or not. + { + if (od.isValid()) + color = MapPalette.matchColor(od.getRed(), od.getGreen(), od.getBlue()); + } + + /*if (od.isBase(blockX - 20, blockZ + 15)) + { + color = MapPalette.matchColor(Color.PINK); + Bukkit.broadcastMessage("X:" + blockX + " Z:" + blockZ + "/" + od.getBase()); + }*/ + } + + canvas.setPixel(mapX, mapZ, color); + } + } + + player.sendMap(mapView); + } + + MapCursorCollection cursors = canvas.getCursors(); + + while (cursors.size() > 0) + + { + cursors.removeCursor(cursors.getCursor(0)); + } + + // TODO If you want players to see each other as cursors. Otherwise delete this bit. + for ( + + Player other : Bukkit.getOnlinePlayers()) + + { + if (player.canSee(other) && other.isValid()) + { + Location l = other.getLocation(); + + double mapX = (l.getX() - _manager.getX()) / zoom; + double mapZ = (l.getZ() - _manager.getZ()) / zoom; + + if (mapX > -64 && mapX < 64 && mapZ > -64 && mapZ < 64) + { + MapCursor.Type cursorDisplay; + + if (player == other) + { + cursorDisplay = MapCursor.Type.WHITE_POINTER; + } + else if (_host.GetTeam(player) == _host.GetTeam(other)) + { + cursorDisplay = MapCursor.Type.BLUE_POINTER; + } + else if (_host.GetTeam(player) != _host.GetTeam(other)) + { + if (_host.OverTime) + cursorDisplay = MapCursor.Type.RED_POINTER; + else + continue; + } + else + { + continue; + } + + byte b0 = (byte) (int) Math.min(127, (double) (mapX * 2.0F) + 0.5D); + byte b1 = (byte) (int) Math.max(-127, (double) (mapZ * 2.0F) + 0.5D); + + byte rotation = (byte) (int) ((l.getYaw() * 16D) / 360D); + + MapCursor cursor = new MapCursor(b0, b1, (byte) (rotation & 0xF), cursorDisplay.getValue(), true); + + cursors.addCursor(cursor); + } + } + } + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/kit/KitPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/kit/KitPlayer.java index 3168bf639..90043f0c0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/kit/KitPlayer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/kit/KitPlayer.java @@ -1,7 +1,5 @@ package nautilus.game.arcade.game.games.minecraftleague.kit; -import mineplex.core.common.util.C; -import mineplex.core.map.TeamMap; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; import nautilus.game.arcade.kit.Kit; @@ -15,7 +13,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; public class KitPlayer extends Kit -{ +{ public KitPlayer(ArcadeManager manager) { super(manager, "Player", KitAvailability.Free, @@ -24,7 +22,6 @@ public class KitPlayer extends Kit { "", "Entirely vanilla combat!", - "Spawns with full iron!", "" }, @@ -37,12 +34,25 @@ public class KitPlayer extends Kit @Override public void GiveItems(Player player) { - TeamMap tmap = ((MinecraftLeague)Manager.GetGame()).getMap(Manager.GetGame().GetTeam(player)); + MinecraftLeague game = (MinecraftLeague)Manager.GetGame(); + /*player.getInventory().setHelmet(new ItemStack(Material.LEATHER_HELMET)); + player.getInventory().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE)); + player.getInventory().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS)); + player.getInventory().setBoots(new ItemStack(Material.LEATHER_BOOTS)); + player.getInventory().addItem(new ItemStack(Material.WOOD_SWORD));*/ + + if (game != null) + { + game.restoreGear(player); + game.MapManager.setMap(player); + } + + /*TeamMap tmap = game.getMap(game.GetTeam(player)); if (tmap == null) return; - tmap.giveMap(player, true, C.cGold + "Team Map", C.cGray + "This map contains", C.cGray + "the locations of", C.cGray + "your teammates."); + tmap.giveMap(player, true, C.cGold + "Team Map", C.cGray + "This map contains", C.cGray + "the locations of", C.cGray + "your teammates.");*/ } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/GameVariation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/GameVariation.java new file mode 100644 index 000000000..40bd8922e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/GameVariation.java @@ -0,0 +1,28 @@ +package nautilus.game.arcade.game.games.minecraftleague.variation; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; +import nautilus.game.arcade.world.WorldData; + +import org.bukkit.event.Listener; + +public abstract class GameVariation implements Listener +{ + public MinecraftLeague Host; + public ArcadeManager Manager; + public WorldData WorldData; + + public GameVariation(MinecraftLeague host) + { + Host = host; + Manager = host.getArcadeManager(); + WorldData = host.WorldData; + } + + public void ParseData() + { + + } + + public abstract void deregister(); +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationManager.java new file mode 100644 index 000000000..5d17b7544 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationManager.java @@ -0,0 +1,81 @@ +package nautilus.game.arcade.game.games.minecraftleague.variation; + +import java.lang.reflect.InvocationTargetException; +import java.util.Random; + +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; + +import org.bukkit.Bukkit; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; + +public class VariationManager implements Listener +{ + private MinecraftLeague _host; + + private GameVariation _variation; + + public VariationManager(MinecraftLeague host) + { + _host = host; + Bukkit.getPluginManager().registerEvents(this, _host.getArcadeManager().getPlugin()); + } + + public void selectVariation() + { + VariationType type = VariationType.values()[new Random().nextInt(VariationType.values().length)]; + if (type.getVariation() == null) + { + Bukkit.broadcastMessage(type.getDisplayMessage()); + return; + } + + try + { + _variation = type.getVariation().getConstructor(MinecraftLeague.class).newInstance(_host); + } + catch (NoSuchMethodException ex) + { + System.err.println("Is the constructor for " + type.toString() + " using only one argument?"); + ex.printStackTrace(); + return; + } + catch (InvocationTargetException ex) + { + ex.getCause().printStackTrace(); + return; + } + catch (Exception ex) + { + ex.printStackTrace(); + return; + } + + Bukkit.broadcastMessage(type.getDisplayMessage()); + Bukkit.getPluginManager().registerEvents(_variation, _host.getArcadeManager().getPlugin()); + _variation.ParseData(); + } + + public void deregister() + { + if (_variation != null) + _variation.deregister(); + + HandlerList.unregisterAll(this); + } + + @EventHandler + public void handleDeregister(GameStateChangeEvent event) + { + if (event.GetGame() != _host) + return; + + if (event.GetState() != GameState.Dead) + return; + + deregister(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationType.java new file mode 100644 index 000000000..71a3f61ba --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationType.java @@ -0,0 +1,33 @@ +package nautilus.game.arcade.game.games.minecraftleague.variation; + +import nautilus.game.arcade.game.games.minecraftleague.variation.wither.WitherVariation; + +import org.bukkit.ChatColor; + +public enum VariationType +{ + STANDARD(null, "Standard Gameplay", ChatColor.GREEN), + WITHER(WitherVariation.class, "Wither Variation", ChatColor.RED) + ; + + private String _name; + private ChatColor _color; + private Class _variation; + + private VariationType(Class variationClass, String displayName, ChatColor displayColor) + { + _name = displayName; + _color = displayColor; + _variation = variationClass; + } + + public Class getVariation() + { + return _variation; + } + + public String getDisplayMessage() + { + return ChatColor.DARK_AQUA + "Game Type Selected: " + _color + _name; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherPathfinder.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherPathfinder.java new file mode 100644 index 000000000..8203bb093 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherPathfinder.java @@ -0,0 +1,74 @@ +package nautilus.game.arcade.game.games.minecraftleague.variation.wither; + +import java.util.LinkedList; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.game.GameTeam; + +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wither; +import org.bukkit.util.Vector; + +public class WitherPathfinder +{ + private Wither _ent; + private LinkedList _waypoints; + private GameTeam _team; + private Entity _enemy; + private int _current; + private Vector _trajectory; + + public WitherPathfinder(Wither ent, LinkedList waypoints, GameTeam team, Entity enemy) + { + _ent = ent; + _current = 0; + _waypoints = waypoints; + _team = team; + _enemy = enemy; + } + + private boolean closer(Wither wither, Location to, Location than) + { + return wither.getLocation().distance(to) < wither.getLocation().distance(than); + } + + private void advance() + { + if (_waypoints.isEmpty()) + return; + if (_waypoints.get(_current + 1) == null) + return; + if (!closer(_ent, _waypoints.get(_current + 1), _waypoints.get(_current))) + return; + + _trajectory = UtilAlg.getTrajectory(_waypoints.get(_current), _waypoints.get(_current + 1)).normalize(); + } + + private void retarget() + { + if (closer(_ent, _waypoints.getLast(), _waypoints.get(_waypoints.size() - 2))) + { + _ent.setTarget(null); + return; + } + if (_ent.getTarget() instanceof Player) + { + Player target = (Player)_ent.getTarget(); + if (_team.HasPlayer(target)) + _ent.setTarget(null); + + if (UtilPlayer.isSpectator(target)) + _ent.setTarget(null); + } + } + + public void update() + { + advance(); + _ent.setVelocity(_trajectory); + retarget(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java new file mode 100644 index 000000000..addc36a9c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java @@ -0,0 +1,19 @@ +package nautilus.game.arcade.game.games.minecraftleague.variation.wither; + +import org.bukkit.event.HandlerList; + +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; +import nautilus.game.arcade.game.games.minecraftleague.variation.GameVariation; + +public class WitherVariation extends GameVariation +{ + public WitherVariation(MinecraftLeague host) + { + super(host); + } + + public void deregister() + { + HandlerList.unregisterAll(this); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java index 4b520c4d8..02fb10438 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java @@ -21,12 +21,15 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; public class GameChatManager implements Listener { ArcadeManager Manager; + public boolean TeamSpy; public GameChatManager(ArcadeManager manager) { Manager = manager; Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); + + TeamSpy = true; } @EventHandler @@ -159,7 +162,10 @@ public class GameChatManager implements Listener Player receiver = recipientIterator.next(); if (!Manager.GetServerConfig().Tournament && Manager.GetClients().Get(receiver).GetRank().has(Rank.MODERATOR)) - continue; + { + if (TeamSpy) + continue; + } GameTeam recTeam = Manager.GetGame().GetTeam(receiver); GameTeam sendTeam = Manager.GetGame().GetTeam(sender); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index f0533de91..e0ba2172e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -1,7 +1,5 @@ package nautilus.game.arcade.managers; -import java.util.HashMap; - import mineplex.core.antihack.AntiHack; import mineplex.core.common.Rank; import mineplex.core.common.util.C; @@ -14,7 +12,6 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; import mineplex.core.teleport.event.MineplexTeleportEvent; @@ -32,6 +29,7 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.kit.perks.event.PerkDestructorBlockEvent; +import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.Sound; @@ -53,6 +51,7 @@ import org.bukkit.event.block.BlockIgniteEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.LeavesDecayEvent; import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.inventory.InventoryClickEvent; @@ -918,6 +917,11 @@ public class GameFlagManager implements Listener Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.VOID, 4, false, false, false, "Border", "Border Damage"); + if (!Manager.GetDamage().IsEnabled()) + { + EntityDamageEvent e = new EntityDamageEvent(player, DamageCause.VOID, 4); + Bukkit.getPluginManager().callEvent(e); + } player.getWorld().playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f); player.getWorld().playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f); @@ -927,6 +931,12 @@ public class GameFlagManager implements Listener Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.VOID, 9001, false, false, false, "Border", "Border Damage"); + if (!Manager.GetDamage().IsEnabled()) + { + EntityDamageEvent e = new EntityDamageEvent(player, DamageCause.VOID, 4); + Bukkit.getPluginManager().callEvent(e); + } + } } } From 9595a0ffae02eafed2c0d0763e486f088689bdea Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 12 Feb 2016 21:22:00 -0500 Subject: [PATCH 14/47] - Lot of stuff --- .../mineplex/core/common/util/UtilItem.java | 2 +- .../game/games/minecraftleague/DataLoc.java | 34 ++ .../minecraftleague/MinecraftLeague.java | 280 +++++++++++-- .../commands/MinecraftLeagueCommand.java | 6 + .../commands/freeze/FreezeCommand.java | 40 ++ .../commands/freeze/FreezeManager.java | 133 +++++++ .../commands/panel/AdminPanel.java | 164 ++++++++ .../commands/panel/GUICommand.java | 26 ++ .../minecraftleague/data/TeamBeacon.java | 33 +- .../minecraftleague/data/TeamCrystal.java | 18 +- .../variation/ExtraScoreboardData.java | 15 + .../variation/GameVariation.java | 8 +- .../variation/StandardGameplay.java | 14 + .../variation/VariationManager.java | 16 +- .../variation/VariationType.java | 20 +- .../variation/wither/WitherPathfinder.java | 74 ---- .../variation/wither/WitherVariation.java | 373 +++++++++++++++++- .../variation/wither/data/PathfinderData.java | 81 ++++ .../variation/wither/data/TeamAltar.java | 190 +++++++++ .../wither/data/WitherMinionManager.java | 363 +++++++++++++++++ .../wither/data/WitherPathfinder.java | 164 ++++++++ .../wither/data/WitherSkeletonTimer.java | 47 +++ 22 files changed, 1951 insertions(+), 150 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/DataLoc.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/freeze/FreezeCommand.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/freeze/FreezeManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/AdminPanel.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/GUICommand.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/ExtraScoreboardData.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/StandardGameplay.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherPathfinder.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/PathfinderData.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherSkeletonTimer.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java index 5a300322c..e71157bec 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java @@ -549,7 +549,7 @@ public class UtilItem public static boolean isSword(ItemStack stack) { - return isEdible(stack == null ? null : stack.getType()); + return isSword(stack == null ? null : stack.getType()); } public static boolean isSword(Material material) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/DataLoc.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/DataLoc.java new file mode 100644 index 000000000..bc0270002 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/DataLoc.java @@ -0,0 +1,34 @@ +package nautilus.game.arcade.game.games.minecraftleague; + + +public enum DataLoc +{ + //Base + RED_CRYSTAL("RED"), + BLUE_CRYSTAL("BLUE"), + VARIANT_ID("ORANGE"), + RED_BEACON("PINK"), + BLUE_BEACON("CYAN"), + SKELETON_SPAWNER("BROWN"), + MAP_DIAMOND("LIGHT_BLUE"), + MAP_IRON("SILVER"), + + //Wither + WITHER_WAYPOINT("PURPLE"), + WITHER_SKELETON("BLACK"), + BLUE_ALTAR("GREEN"), + RED_ALTAR("YELLOW") + ; + + private String _key; + + private DataLoc(String key) + { + _key = key; + } + + public String getKey() + { + return _key; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index 5d672dd8b..28b3eb31e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -8,7 +8,9 @@ import java.util.concurrent.ConcurrentHashMap; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; @@ -26,6 +28,7 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.minecraftleague.commands.MinecraftLeagueCommand; +import nautilus.game.arcade.game.games.minecraftleague.commands.freeze.FreezeManager; import nautilus.game.arcade.game.games.minecraftleague.data.OreDeposit; import nautilus.game.arcade.game.games.minecraftleague.data.PlayerRespawnPoint; import nautilus.game.arcade.game.games.minecraftleague.data.Spawner; @@ -33,6 +36,9 @@ import nautilus.game.arcade.game.games.minecraftleague.data.TeamBeacon; import nautilus.game.arcade.game.games.minecraftleague.data.TeamCrystal; import nautilus.game.arcade.game.games.minecraftleague.data.map.ItemMapManager; import nautilus.game.arcade.game.games.minecraftleague.kit.KitPlayer; +import nautilus.game.arcade.game.games.minecraftleague.variation.ExtraScoreboardData; +import nautilus.game.arcade.game.games.minecraftleague.variation.GameVariation; +import nautilus.game.arcade.game.games.minecraftleague.variation.VariationManager; import nautilus.game.arcade.kit.Kit; import org.bukkit.Bukkit; @@ -44,6 +50,8 @@ import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Arrow; +import org.bukkit.entity.CreatureType; +import org.bukkit.entity.Enderman; import org.bukkit.entity.EntityType; import org.bukkit.entity.ItemFrame; import org.bukkit.entity.Player; @@ -58,6 +66,7 @@ import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryClickEvent; @@ -70,6 +79,7 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; import org.bukkit.util.Vector; import com.google.common.base.Objects; @@ -83,6 +93,8 @@ public class MinecraftLeague extends TeamGame private ConcurrentHashMap _beacons = new ConcurrentHashMap(); private List _spawners = new ArrayList(); + public ConcurrentHashMap ExtraSb = new ConcurrentHashMap(); + private long _liveTime = 0; private MinecraftLeagueCommand _cmd; private long _lastIncrease; @@ -92,6 +104,9 @@ public class MinecraftLeague extends TeamGame public ItemMapManager MapManager; public boolean OverTime = false; + private VariationManager _vman; + private FreezeManager _freeze; + public MinecraftLeague(ArcadeManager manager) { super(manager, GameType.MinecraftLeague, @@ -141,7 +156,7 @@ public class MinecraftLeague extends TeamGame _help = new String[] { - "Respawn Crystals have 50 health per person in-game!", + "Respawn Crystals have 100 health per person in-game!", "The better the sword you have, the more damage you deal to Respawn Crystals!", "Right-click a bed in order to change your personal spawn location!", "Your map will display the locations of your enemies in OverTime!" @@ -151,6 +166,10 @@ public class MinecraftLeague extends TeamGame registerStatTrackers( ); + + _vman = new VariationManager(this); + _freeze = new FreezeManager(); + Bukkit.getPluginManager().registerEvents(_freeze, manager.getPlugin()); } private enum DamageAmount @@ -230,7 +249,7 @@ public class MinecraftLeague extends TeamGame private ItemStack getNewItemStack(ItemStack item) { ItemStack ret = item.clone(); - String type = ret.getType().toString(); + /*String type = ret.getType().toString(); boolean damage = false; boolean itemD = false; if (type.contains("HELMET") || type.contains("CHESTPLATE") || type.contains("LEGGINGS") || type.contains("BOOTS")) @@ -248,7 +267,7 @@ public class MinecraftLeague extends TeamGame } if (ret.getDurability() > ret.getType().getMaxDurability()) - ret = new ItemStack(Material.AIR); + ret = new ItemStack(Material.AIR);*/ if (ret.getType() == Material.MAP) ret = new ItemStack(Material.AIR); @@ -256,6 +275,60 @@ public class MinecraftLeague extends TeamGame return ret; } + private int getSwordLevel(ItemStack sword) + { + if (UtilItem.isSword(sword)) + { + //if (UtilItem.isDiamondProduct(sword)) + //return 5; + if (UtilItem.isIronProduct(sword)) + return 4; + if (UtilItem.isGoldProduct(sword)) + return 3; + if (UtilItem.isStoneProduct(sword)) + return 2; + if (UtilItem.isWoodProduct(sword)) + return 1; + } + + return 0; + } + + private ItemStack getBestSword(Player player) + { + ItemStack ret = new ItemStack(Material.AIR); + int level = 0; + + for (ItemStack item : UtilInv.getItems(player, false, true, false)) + { + if (UtilItem.isSword(item)) + { + if (getSwordLevel(item) > level) + { + ret = item; + level = getSwordLevel(item); + } + } + } + + return ret; + } + + public int getMapVariantID() + { + return WorldData.GetDataLocs(DataLoc.VARIANT_ID.getKey()).size(); + } + + public TeamCrystal getCrystal(GameTeam team) + { + return _crystals.get(team); + } + + public FreezeManager getFreezeManager() + { + return _freeze; + } + /*public TeamMap getMap(GameTeam team) { return _maps.get(team); @@ -264,32 +337,32 @@ public class MinecraftLeague extends TeamGame @Override public void ParseData() { - Location redLoc = WorldData.GetDataLocs("RED").get(0); - Location blueLoc = WorldData.GetDataLocs("BLUE").get(0); - //Location center = WorldData.GetDataLocs("ORANGE").get(0); + Location redLoc = WorldData.GetDataLocs(DataLoc.RED_CRYSTAL.getKey()).get(0); + Location blueLoc = WorldData.GetDataLocs(DataLoc.BLUE_CRYSTAL.getKey()).get(0); _crystals.put(GetTeam(ChatColor.RED), new TeamCrystal(this, GetTeam(ChatColor.RED), redLoc)); _crystals.put(GetTeam(ChatColor.AQUA), new TeamCrystal(this, GetTeam(ChatColor.AQUA), blueLoc)); - _beacons.put(GetTeam(ChatColor.RED), new TeamBeacon(GetTeam(ChatColor.RED), WorldData.GetDataLocs("PINK").get(0).getBlock(), redLoc)); - _beacons.put(GetTeam(ChatColor.AQUA), new TeamBeacon(GetTeam(ChatColor.AQUA), WorldData.GetDataLocs("CYAN").get(0).getBlock(), redLoc)); + _beacons.put(GetTeam(ChatColor.RED), new TeamBeacon(GetTeam(ChatColor.RED), WorldData.GetDataLocs(DataLoc.RED_BEACON.getKey()).get(0).getBlock(), redLoc)); + _beacons.put(GetTeam(ChatColor.AQUA), new TeamBeacon(GetTeam(ChatColor.AQUA), WorldData.GetDataLocs(DataLoc.BLUE_BEACON.getKey()).get(0).getBlock(), blueLoc)); - //_maps.put(GetTeam(ChatColor.RED), new TeamMap(new ArrayList(), center, Scale.CLOSE)); - //_maps.put(GetTeam(ChatColor.AQUA), new TeamMap(new ArrayList(), center, Scale.CLOSE)); + for (Location loc : WorldData.GetDataLocs(DataLoc.SKELETON_SPAWNER.getKey())) + { + _spawners.add(new Spawner(this, loc, EntityType.SKELETON)); + } - //_spawners.add(new Spawner(this, WorldData.GetDataLocs("GREEN").get(0), EntityType.CREEPER)); - _spawners.add(new Spawner(this, WorldData.GetDataLocs("BLACK").get(0), EntityType.SKELETON)); - - for (Location loc : WorldData.GetDataLocs("LIGHT_BLUE")) + for (Location loc : WorldData.GetDataLocs(DataLoc.MAP_DIAMOND.getKey())) { Ore.add(new OreDeposit(loc, Material.DIAMOND_ORE, new int[] {0, 255, 255})); } - for (Location loc : WorldData.GetDataLocs("SILVER")) + for (Location loc : WorldData.GetDataLocs(DataLoc.MAP_IRON.getKey())) { Ore.add(new OreDeposit(loc, Material.IRON_ORE, new int[] {190, 190, 190})); } MapManager = new ItemMapManager(this, WorldData.World, WorldData.MinX, WorldData.MinZ, WorldData.MaxX, WorldData.MaxZ); + + _vman.selectVariation(); } @Override @@ -357,6 +430,16 @@ public class MinecraftLeague extends TeamGame Scoreboard.Write("Crystal: " + bluec.formatHealth(bluec.getHealth())); Scoreboard.Write("Players Alive: " + blue.GetPlayers(true).size()); + int i = 1; + for (ExtraScoreboardData sbD : ExtraSb.keySet()) + { + Scoreboard.WriteBlank(); + sbD.write(); + if (i < ExtraSb.size()) + Scoreboard.WriteBlank(); + i++; + } + Scoreboard.Draw(); } @@ -490,6 +573,7 @@ public class MinecraftLeague extends TeamGame Manager.removeCommand(_cmd); Manager.GetGameChat().TeamSpy = true; HandlerList.unregisterAll(MapManager); + HandlerList.unregisterAll(_freeze); } } @@ -505,6 +589,31 @@ public class MinecraftLeague extends TeamGame { od.update(); } + + for (Player player : GetTeam(ChatColor.RED).GetPlayers(true)) + { + for (ItemStack armor : player.getInventory().getArmorContents()) + { + if (UtilItem.isLeatherProduct(armor)) + { + LeatherArmorMeta im = (LeatherArmorMeta)armor.getItemMeta(); + im.setColor(Color.RED); + armor.setItemMeta(im); + } + } + } + for (Player player : GetTeam(ChatColor.AQUA).GetPlayers(true)) + { + for (ItemStack armor : player.getInventory().getArmorContents()) + { + if (UtilItem.isLeatherProduct(armor)) + { + LeatherArmorMeta im = (LeatherArmorMeta)armor.getItemMeta(); + im.setColor(Color.BLUE); + armor.setItemMeta(im); + } + } + } } if (event.getType() == UpdateType.FASTEST) @@ -551,6 +660,8 @@ public class MinecraftLeague extends TeamGame player.setFireTicks(-1); player.setFoodLevel(20); } + if (player.getInventory().getType() == InventoryType.BEACON) + player.closeInventory(); } } } @@ -853,6 +964,7 @@ public class MinecraftLeague extends TeamGame event.setCancelled(true); } + @SuppressWarnings("deprecation") @EventHandler public void controlMobRate(CreatureSpawnEvent event) { @@ -862,7 +974,15 @@ public class MinecraftLeague extends TeamGame if (event.getSpawnReason() != SpawnReason.NATURAL) return; + if (UtilEnt.getInRadius(event.getLocation(), 10).size() >= 5) + { + event.setCancelled(true); + return; + } + Manager.GetCreature().SpawnEntity(event.getLocation(), event.getEntityType()); + if (event.getCreatureType() == CreatureType.SPIDER) + Manager.GetCreature().SpawnEntity(event.getLocation(), EntityType.SPIDER); } @EventHandler(priority = EventPriority.LOWEST) @@ -957,9 +1077,11 @@ public class MinecraftLeague extends TeamGame if (addbow) { - if (new Random().nextDouble() > .5) + if (new Random().nextDouble() > .75) event.getDrops().add(new ItemStack(Material.BOW)); } + + event.getDrops().add(new ItemStack(Material.ARROW, 15)); } @EventHandler @@ -1001,11 +1123,30 @@ public class MinecraftLeague extends TeamGame Player player = (Player)event.getEntity(); List gear = new ArrayList(); - gear.add(player.getItemInHand()); - gear.add(player.getInventory().getHelmet()); - gear.add(player.getInventory().getChestplate()); - gear.add(player.getInventory().getLeggings()); - gear.add(player.getInventory().getBoots()); + if (!UtilItem.isDiamondProduct(getBestSword(player))) + gear.add(getBestSword(player)); + else + gear.add(new ItemStack(Material.AIR)); + + if (!UtilItem.isDiamondProduct(player.getInventory().getHelmet())) + gear.add(player.getInventory().getHelmet()); + else + gear.add(new ItemStack(Material.AIR)); + + if (!UtilItem.isDiamondProduct(player.getInventory().getChestplate())) + gear.add(player.getInventory().getChestplate()); + else + gear.add(new ItemStack(Material.AIR)); + + if (!UtilItem.isDiamondProduct(player.getInventory().getLeggings())) + gear.add(player.getInventory().getLeggings()); + else + gear.add(new ItemStack(Material.AIR)); + + if (!UtilItem.isDiamondProduct(player.getInventory().getBoots())) + gear.add(player.getInventory().getBoots()); + else + gear.add(new ItemStack(Material.AIR)); _gear.put(player, gear); } @@ -1047,33 +1188,40 @@ public class MinecraftLeague extends TeamGame @EventHandler public void blockDeadTalk(AsyncPlayerChatEvent event) { - if (GetTeam(event.getPlayer()) == null) + try { - for (Player player : GetTeam(ChatColor.RED).GetPlayers(true)) + if (GetTeam(event.getPlayer()) == null) { - event.getRecipients().remove(player); + for (Player player : GetTeam(ChatColor.RED).GetPlayers(true)) + { + event.getRecipients().remove(player); + } + for (Player player : GetTeam(ChatColor.AQUA).GetPlayers(true)) + { + event.getRecipients().remove(player); + } + + return; } - for (Player player : GetTeam(ChatColor.AQUA).GetPlayers(true)) + if (!GetTeam(event.getPlayer()).IsAlive(event.getPlayer())) { - event.getRecipients().remove(player); + for (Player player : GetTeam(ChatColor.RED).GetPlayers(true)) + { + event.getRecipients().remove(player); + } + for (Player player : GetTeam(ChatColor.AQUA).GetPlayers(true)) + { + event.getRecipients().remove(player); + } } - - return; } - if (!GetTeam(event.getPlayer()).IsAlive(event.getPlayer())) + catch (Exception e) { - for (Player player : GetTeam(ChatColor.RED).GetPlayers(true)) - { - event.getRecipients().remove(player); - } - for (Player player : GetTeam(ChatColor.AQUA).GetPlayers(true)) - { - event.getRecipients().remove(player); - } + return; } } - @EventHandler + @EventHandler(priority = EventPriority.HIGHEST) public void handleDeath(CombatDeathEvent event) { if (!IsLive()) @@ -1114,7 +1262,34 @@ public class MinecraftLeague extends TeamGame } if (OverTime) + { _crystals.get(GetTeam(player)).damage(20, null, false); + if (!_crystals.get(GetTeam(player)).Alive) + { + SetPlayerState(player, PlayerState.OUT); + + Manager.GetCondition().Factory().Blind("PermDead", player, player, 1.5, 0, false, false, false); + Manager.GetCondition().Factory().Cloak("PermDead", player, player, 9999, false, false); + + player.setAllowFlight(true); + player.setFlying(true); + ((CraftPlayer)player).getHandle().spectating = true; + ((CraftPlayer)player).getHandle().k = false; + + UtilAction.velocity(player, new Vector(0,1.2,0)); + + //getMap(GetTeam(player)).update(player); + player.getInventory().clear(); + player.getInventory().setArmorContents(new ItemStack[] + { + new ItemStack(Material.AIR), + new ItemStack(Material.AIR), + new ItemStack(Material.AIR), + new ItemStack(Material.AIR) + }); + return; + } + } } @EventHandler @@ -1123,4 +1298,33 @@ public class MinecraftLeague extends TeamGame if (UtilPlayer.isSpectator(event.getPlayer())) event.setCancelled(true); } + + @EventHandler + public void handleMobs(EntitySpawnEvent event) + { + if (!IsLive()) + return; + + if (event.getEntity() instanceof Enderman) + event.setCancelled(true); + + for (TeamCrystal crystal : _crystals.values()) + { + if (event.getLocation().getWorld().getUID() != WorldData.World.getUID()) + continue; + + if (event.getLocation().distance(crystal.getLocation()) <= 5) + event.setCancelled(true); + } + } + + @EventHandler + public void sigilsIsMean(BlockBreakEvent event) + { + if (!IsLive()) + return; + + if (UtilPlayer.isSpectator(event.getPlayer())) + event.setCancelled(true); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/MinecraftLeagueCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/MinecraftLeagueCommand.java index ead7909ae..ebd532b83 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/MinecraftLeagueCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/MinecraftLeagueCommand.java @@ -6,6 +6,8 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; +import nautilus.game.arcade.game.games.minecraftleague.commands.freeze.FreezeCommand; +import nautilus.game.arcade.game.games.minecraftleague.commands.panel.GUICommand; import org.bukkit.entity.Player; @@ -16,6 +18,8 @@ public class MinecraftLeagueCommand extends MultiCommandBase public MinecraftLeagueCommand(ArcadeManager plugin, MinecraftLeague host) { super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "mcLeague"); + AddCommand(new GUICommand(plugin, host)); + AddCommand(new FreezeCommand(plugin, host)); AddCommand(new SpawnCommand(plugin, host)); AddCommand(new KillCommand(plugin, host)); AddCommand(new DamageCommand(plugin, host)); @@ -27,6 +31,8 @@ public class MinecraftLeagueCommand extends MultiCommandBase protected void Help(Player caller, String[] args) { UtilPlayer.message(caller, F.main(_host.GetName(), "Commands List:")); + UtilPlayer.message(caller, F.help("/mcLeague gui", "Opens a GUI for controlling Respawn Crystals", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/mcLeague freeze ", "Freezes or unfreezes a player [for cheaters]", Rank.ADMIN)); UtilPlayer.message(caller, F.help("/mcLeague spawn ", "Respawns the red or blue Respawn Crystal if killed", Rank.ADMIN)); UtilPlayer.message(caller, F.help("/mcLeague kill ", "Kills the red or blue Respawn Crystal if spawned", Rank.ADMIN)); UtilPlayer.message(caller, F.help("/mcLeague damage ", "Damages the red or blue Respawn Crystal for a specified amount", Rank.DEVELOPER)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/freeze/FreezeCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/freeze/FreezeCommand.java new file mode 100644 index 000000000..0297354a2 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/freeze/FreezeCommand.java @@ -0,0 +1,40 @@ +package nautilus.game.arcade.game.games.minecraftleague.commands.freeze; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; + +import org.bukkit.entity.Player; + +public class FreezeCommand extends CommandBase +{ + private MinecraftLeague _host; + + public FreezeCommand(ArcadeManager plugin, MinecraftLeague host) + { + super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "freeze"); + _host = host; + } + + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 1) + { + UtilPlayer.message(caller, F.help("/mcLeague freeze ", "Freezes or unfreezes a player [for cheaters]", Rank.ADMIN)); + return; + } + + String name = args[0]; + Player get = UtilPlayer.searchOnline(caller, name, true); + + if (get != null) + { + _host.getFreezeManager().toggleFreeze(get, caller); + } + } + +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/freeze/FreezeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/freeze/FreezeManager.java new file mode 100644 index 000000000..c657ba71a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/freeze/FreezeManager.java @@ -0,0 +1,133 @@ +package nautilus.game.arcade.game.games.minecraftleague.commands.freeze; + +import java.util.concurrent.ConcurrentHashMap; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilPlayer; +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ClickEvent.Action; +import net.md_5.bungee.api.chat.TextComponent; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +public class FreezeManager implements Listener +{ + private ConcurrentHashMap _frozen = new ConcurrentHashMap(); + + private void showBan(String player, Player staff) + { + ClickEvent prep = new ClickEvent(Action.SUGGEST_COMMAND, "/p " + player + " Logging out during Freeze [MCL]"); + TextComponent message = new TextComponent(player + " has logged out while frozen! Click here for a ready-made punishment command!"); + message.setColor(ChatColor.DARK_RED); + message.setClickEvent(prep); + + staff.spigot().sendMessage(message); + } + + public boolean isFrozen(Player player) + { + return _frozen.containsKey(player.getName()); + } + + public void toggleFreeze(Player player, Player staff) + { + if (isFrozen(player)) + { + _frozen.remove(player.getName()); + UtilPlayer.message(staff, F.main("Freeze", "You have unfrozen " + player.getName())); + UtilPlayer.message(player, F.main("Freeze", "You have been unfrozen by " + staff.getName())); + } + else + { + _frozen.put(player.getName(), staff.getName()); + UtilPlayer.message(staff, F.main("Freeze", "You have frozen " + player.getName())); + UtilPlayer.message(player, F.main("Freeze", "You have been frozen by " + staff.getName())); + player.teleport(UtilBlock.getHighest(player.getWorld(), player.getLocation().getBlockX(), player.getLocation().getBlockZ()).getLocation()); + } + } + + @EventHandler + public void onMove(PlayerMoveEvent event) + { + if (isFrozen(event.getPlayer())) + { + Location to = event.getTo(); + Location from = event.getFrom(); + Location move = new Location(from.getWorld(), from.getX(), from.getY(), from.getZ()); + move.setPitch(to.getPitch()); + move.setYaw(to.getYaw()); + + event.setTo(move); + } + } + + @EventHandler + public void onLogout(PlayerQuitEvent event) + { + if (isFrozen(event.getPlayer())) + { + if (UtilPlayer.searchExact(_frozen.get(event.getPlayer().getName())) != null) + { + showBan(event.getPlayer().getName(), UtilPlayer.searchExact(_frozen.get(event.getPlayer().getName()))); + _frozen.remove(event.getPlayer().getName()); + } + } + } + + @EventHandler + public void onDamage(EntityDamageEvent event) + { + if (event.getEntity() instanceof Player) + if (isFrozen((Player)event.getEntity())) + event.setCancelled(true); + } + + @EventHandler + public void onPVP(EntityDamageByEntityEvent event) + { + Player dmg = null; + if (event.getDamager() instanceof Player) + { + dmg = (Player)event.getDamager(); + } + if (event.getDamager() instanceof Projectile) + { + if (((Projectile)event.getDamager()).getShooter() instanceof Player) + { + dmg = (Player) ((Projectile)event.getDamager()).getShooter(); + } + } + + if (dmg == null) + return; + + if (isFrozen(dmg)) + event.setCancelled(true); + } + + @EventHandler + public void onBuild(BlockPlaceEvent event) + { + if (isFrozen(event.getPlayer())) + event.setCancelled(true); + } + + @EventHandler + public void onBreak(BlockBreakEvent event) + { + if (isFrozen(event.getPlayer())) + event.setCancelled(true); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/AdminPanel.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/AdminPanel.java new file mode 100644 index 000000000..a91fdd8aa --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/AdminPanel.java @@ -0,0 +1,164 @@ +package nautilus.game.arcade.game.games.minecraftleague.commands.panel; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague.EditType; +import nautilus.game.arcade.game.games.minecraftleague.data.TeamCrystal; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class AdminPanel implements Listener +{ + private Player _admin; + private MinecraftLeague _host; + private Inventory _menu; + private ConcurrentHashMap _buttons; + private ConcurrentHashMap _slots; + + public AdminPanel(Player admin, MinecraftLeague host) + { + _admin = admin; + _host = host; + _menu = Bukkit.createInventory(admin, 9, C.cRed + "Admin Panel: Minecraft League"); + _buttons = new ConcurrentHashMap(); + _slots = new ConcurrentHashMap(); + + ItemStack red = new ItemBuilder(MenuButton.CRYSTAL.getRepresentation()) + .setTitle(C.cRed + "Red Crystal") + .setLore(C.cGray + "Alive: " + host.getCrystal(host.GetTeam(ChatColor.RED)).Alive, + C.cGray + "Health: " + host.getCrystal(host.GetTeam(ChatColor.RED)).getHealth()) + .build(); + + ItemStack blue = new ItemBuilder(MenuButton.CRYSTAL.getRepresentation()) + .setTitle(C.cAqua + "Blue Crystal") + .setLore(C.cGray + "Alive: " + host.getCrystal(host.GetTeam(ChatColor.AQUA)).Alive, + C.cGray + "Health: " + host.getCrystal(host.GetTeam(ChatColor.AQUA)).getHealth()) + .build(); + + _buttons.put(red, host.GetTeam(ChatColor.RED)); + _buttons.put(blue, host.GetTeam(ChatColor.AQUA)); + _slots.put(host.GetTeam(ChatColor.RED), 2); + _slots.put(host.GetTeam(ChatColor.AQUA), 6); + + _menu.setItem(2, red); + _menu.setItem(6, blue); + //2, 6 + + admin.openInventory(_menu); + Bukkit.getPluginManager().registerEvents(this, _host.Manager.getPlugin()); + } + + public boolean updateInv() + { + if (!_admin.getOpenInventory().getTopInventory().getName().equalsIgnoreCase(_menu.getName())) + return false; + for (ItemStack item : _buttons.keySet()) + { + GameTeam team = _buttons.get(item); + ItemMeta im = item.getItemMeta(); + List lore = new ArrayList(); + lore.add(C.cGray + "Alive: " + _host.getCrystal(team).Alive); + lore.add(C.cGray + "Health: " + _host.getCrystal(team).getHealth()); + im.setLore(lore); + item.setItemMeta(im); + _buttons.remove(item); + _buttons.put(item, team); + _menu.setItem(_slots.get(team), item); + } + _admin.updateInventory(); + return true; + } + + @EventHandler + public void onUseButton(InventoryClickEvent event) + { + if (!_host.IsLive()) + return; + + if (!event.getClickedInventory().equals(_menu)) + return; + + if (!event.getWhoClicked().getName().equals(_admin.getName())) + return; + + if (event.getCurrentItem() == null) + return; + + try + { + GameTeam selectedT = _buttons.get(event.getCurrentItem()); + TeamCrystal selected = _host.getCrystal(selectedT); + + if (selected.Alive) + _host.handleCommand(EditType.KILL, selectedT, _admin, null); + else + _host.handleCommand(EditType.SPAWN, selectedT, _admin, null); + + event.setCancelled(true); + } + catch (Exception e) + { + return; + } + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + if (!UtilPlayer.isOnline(_admin.getName())) + { + HandlerList.unregisterAll(this); + return; + } + if (!_host.IsLive()) + { + if (_host.GetState() == GameState.Dead) + HandlerList.unregisterAll(this); + if (_host.GetState() == GameState.End) + _admin.closeInventory(); + return; + } + if (!updateInv()) + HandlerList.unregisterAll(this); + } + + private enum MenuButton + { + CRYSTAL(Material.EYE_OF_ENDER); + + private Material _rep; + + private MenuButton(Material representation) + { + _rep = representation; + } + + public Material getRepresentation() + { + return _rep; + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/GUICommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/GUICommand.java new file mode 100644 index 000000000..508f1b768 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/GUICommand.java @@ -0,0 +1,26 @@ +package nautilus.game.arcade.game.games.minecraftleague.commands.panel; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; + +import org.bukkit.entity.Player; + +public class GUICommand extends CommandBase +{ + private MinecraftLeague _host; + + public GUICommand(ArcadeManager plugin, MinecraftLeague host) + { + super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "gui"); + _host = host; + } + + @Override + public void Execute(Player caller, String[] args) + { + new AdminPanel(caller, _host); + } + +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java index fdbca27af..725f61275 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java @@ -1,15 +1,13 @@ package nautilus.game.arcade.game.games.minecraftleague.data; -import java.util.List; +import java.util.HashSet; import mineplex.core.common.util.UtilBlock; import nautilus.game.arcade.game.GameTeam; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @@ -18,7 +16,6 @@ public class TeamBeacon { private GameTeam _team; private Block _block; - private List _valuables; private Location _core; public TeamBeacon(GameTeam team, Block block, Location core) @@ -26,25 +23,8 @@ public class TeamBeacon _team = team; _block = block; _core = core; - _valuables = UtilBlock.getInSquare(_block.getRelative(BlockFace.DOWN), 1); _block.setType(Material.BEACON); - for (Block v : _valuables) - { - v.setType(Material.IRON_BLOCK); - } - } - - @SuppressWarnings("deprecation") - private void hideValuables() - { - for (Player player : Bukkit.getOnlinePlayers()) - { - for (Block v : _valuables) - { - player.sendBlockChange(v.getLocation(), Material.DIRT, (byte) 0); - } - } } public boolean isBlock(Block match) @@ -59,7 +39,16 @@ public class TeamBeacon public void update() { - hideValuables(); + if (_block.getType() != Material.BEACON) + return; + + HashSet ignore = new HashSet(); + ignore.add(Material.GLASS); + ignore.add(Material.THIN_GLASS); + ignore.add(Material.STAINED_GLASS); + ignore.add(Material.STAINED_GLASS_PANE); + if (!UtilBlock.getHighest(_block.getWorld(), _block.getX(), _block.getZ(), ignore).equals(_block)) + return; for (Player player : _team.GetPlayers(true)) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java index 3ff133c37..b2438670b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java @@ -38,6 +38,7 @@ public class TeamCrystal public boolean Alive; private long _lastAlert = -1; + private long _lastHit = -1; public TeamCrystal(MinecraftLeague host, GameTeam team, Location spawn) { @@ -110,20 +111,23 @@ public class TeamCrystal { if (UtilTime.elapsed(_lastAlert, UtilTime.convert(15, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) { - long s = System.currentTimeMillis(); - long e = UtilTime.convert(5, TimeUnit.SECONDS, TimeUnit.MILLISECONDS); + _lastHit = System.currentTimeMillis(); for (Player player : _team.GetPlayers(true)) { player.playSound(player.getLocation(), Sound.NOTE_PLING, 10, 0); - while (!UtilTime.elapsed(s, e)) - { - UtilTextBottom.display(C.cRed + "Your Crystal is under attack!", player); - } } } } + private void alertTextDisplay() + { + if (UtilTime.elapsed(_lastHit, UtilTime.convert(5, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) + return; + for (Player player : _team.GetPlayers(true)) + UtilTextBottom.display(C.cRed + "Your Crystal is under attack!", player); + } + public Entity getEntity() { return _entity; @@ -212,6 +216,8 @@ public class TeamCrystal { _health = _maxHealth; } + + alertTextDisplay(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/ExtraScoreboardData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/ExtraScoreboardData.java new file mode 100644 index 000000000..c13960834 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/ExtraScoreboardData.java @@ -0,0 +1,15 @@ +package nautilus.game.arcade.game.games.minecraftleague.variation; + +import nautilus.game.arcade.scoreboard.GameScoreboard; + +public abstract class ExtraScoreboardData +{ + public GameScoreboard Scoreboard; + + public ExtraScoreboardData(GameScoreboard sb) + { + Scoreboard = sb; + } + + public abstract void write(); +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/GameVariation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/GameVariation.java index 40bd8922e..a1efa8a2c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/GameVariation.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/GameVariation.java @@ -4,6 +4,7 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; import nautilus.game.arcade.world.WorldData; +import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; public abstract class GameVariation implements Listener @@ -24,5 +25,10 @@ public abstract class GameVariation implements Listener } - public abstract void deregister(); + public void deregister() + { + HandlerList.unregisterAll(this); + } + + public abstract void customDeregister(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/StandardGameplay.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/StandardGameplay.java new file mode 100644 index 000000000..2c06dffc4 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/StandardGameplay.java @@ -0,0 +1,14 @@ +package nautilus.game.arcade.game.games.minecraftleague.variation; + +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; + +public class StandardGameplay extends GameVariation +{ + public StandardGameplay(MinecraftLeague host) + { + super(host); + } + + public void customDeregister() {} + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationManager.java index 5d17b7544..d56239954 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationManager.java @@ -1,7 +1,6 @@ package nautilus.game.arcade.game.games.minecraftleague.variation; import java.lang.reflect.InvocationTargetException; -import java.util.Random; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; @@ -11,12 +10,14 @@ import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; public class VariationManager implements Listener { private MinecraftLeague _host; private GameVariation _variation; + private VariationType _selected; public VariationManager(MinecraftLeague host) { @@ -26,7 +27,8 @@ public class VariationManager implements Listener public void selectVariation() { - VariationType type = VariationType.values()[new Random().nextInt(VariationType.values().length)]; + VariationType type = VariationType.getFromID(_host.getMapVariantID()); + if (type.getVariation() == null) { Bukkit.broadcastMessage(type.getDisplayMessage()); @@ -36,6 +38,7 @@ public class VariationManager implements Listener try { _variation = type.getVariation().getConstructor(MinecraftLeague.class).newInstance(_host); + _selected = type; } catch (NoSuchMethodException ex) { @@ -78,4 +81,13 @@ public class VariationManager implements Listener deregister(); } + + @EventHandler + public void onInform(PlayerJoinEvent event) + { + if (_variation != null) + { + event.getPlayer().sendMessage(_selected.getDisplayMessage()); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationType.java index 71a3f61ba..9a03fb724 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationType.java @@ -6,16 +6,19 @@ import org.bukkit.ChatColor; public enum VariationType { - STANDARD(null, "Standard Gameplay", ChatColor.GREEN), - WITHER(WitherVariation.class, "Wither Variation", ChatColor.RED) + STANDARD(1, StandardGameplay.class, "Standard Gameplay", ChatColor.GREEN), + WITHER(2, WitherVariation.class, "Wither Variation", ChatColor.RED), + //GUARDIAN(3, GuardianVariation.class, "Guardian Variation", ChatColor.DARK_AQUA) ; + private int _id; private String _name; private ChatColor _color; private Class _variation; - private VariationType(Class variationClass, String displayName, ChatColor displayColor) + private VariationType(int id, Class variationClass, String displayName, ChatColor displayColor) { + _id = id; _name = displayName; _color = displayColor; _variation = variationClass; @@ -30,4 +33,15 @@ public enum VariationType { return ChatColor.DARK_AQUA + "Game Type Selected: " + _color + _name; } + + public static VariationType getFromID(int id) + { + for (VariationType type : VariationType.values()) + { + if (type._id == id) + return type; + } + + return VariationType.STANDARD; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherPathfinder.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherPathfinder.java deleted file mode 100644 index 8203bb093..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherPathfinder.java +++ /dev/null @@ -1,74 +0,0 @@ -package nautilus.game.arcade.game.games.minecraftleague.variation.wither; - -import java.util.LinkedList; - -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilPlayer; -import nautilus.game.arcade.game.GameTeam; - -import org.bukkit.Location; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Wither; -import org.bukkit.util.Vector; - -public class WitherPathfinder -{ - private Wither _ent; - private LinkedList _waypoints; - private GameTeam _team; - private Entity _enemy; - private int _current; - private Vector _trajectory; - - public WitherPathfinder(Wither ent, LinkedList waypoints, GameTeam team, Entity enemy) - { - _ent = ent; - _current = 0; - _waypoints = waypoints; - _team = team; - _enemy = enemy; - } - - private boolean closer(Wither wither, Location to, Location than) - { - return wither.getLocation().distance(to) < wither.getLocation().distance(than); - } - - private void advance() - { - if (_waypoints.isEmpty()) - return; - if (_waypoints.get(_current + 1) == null) - return; - if (!closer(_ent, _waypoints.get(_current + 1), _waypoints.get(_current))) - return; - - _trajectory = UtilAlg.getTrajectory(_waypoints.get(_current), _waypoints.get(_current + 1)).normalize(); - } - - private void retarget() - { - if (closer(_ent, _waypoints.getLast(), _waypoints.get(_waypoints.size() - 2))) - { - _ent.setTarget(null); - return; - } - if (_ent.getTarget() instanceof Player) - { - Player target = (Player)_ent.getTarget(); - if (_team.HasPlayer(target)) - _ent.setTarget(null); - - if (UtilPlayer.isSpectator(target)) - _ent.setTarget(null); - } - } - - public void update() - { - advance(); - _ent.setVelocity(_trajectory); - retarget(); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java index addc36a9c..657f43ed8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java @@ -1,19 +1,386 @@ package nautilus.game.arcade.game.games.minecraftleague.variation.wither; -import org.bukkit.event.HandlerList; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Random; +import java.util.concurrent.ConcurrentHashMap; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.PlayerGameRespawnEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.minecraftleague.DataLoc; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; +import nautilus.game.arcade.game.games.minecraftleague.data.TeamCrystal; import nautilus.game.arcade.game.games.minecraftleague.variation.GameVariation; +import nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.TeamAltar; +import nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.WitherMinionManager; +import nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.WitherPathfinder; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.entity.Wither; +import org.bukkit.entity.WitherSkull; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.EntitySpawnEvent; +import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; public class WitherVariation extends GameVariation { + private ConcurrentHashMap _altars = new ConcurrentHashMap(); + + private Wither _wither; + private WitherPathfinder _pathfinder; + + private WitherMinionManager _skellyMan; + + public boolean WitherSpawned; + + private GameTeam _wowner = null; + public WitherVariation(MinecraftLeague host) { super(host); + WitherSpawned = false; + _skellyMan = new WitherMinionManager(this, WorldData.GetDataLocs(DataLoc.WITHER_SKELETON.getKey())); } - public void deregister() + @Override + public void customDeregister() { - HandlerList.unregisterAll(this); + HandlerList.unregisterAll(_skellyMan); + } + + @Override + public void ParseData() + { + _altars.put(Host.GetTeam(ChatColor.AQUA), new TeamAltar(this, Host.GetTeam(ChatColor.AQUA), WorldData.GetDataLocs(DataLoc.BLUE_ALTAR.getKey()).get(0))); + _altars.put(Host.GetTeam(ChatColor.RED), new TeamAltar(this, Host.GetTeam(ChatColor.RED), WorldData.GetDataLocs(DataLoc.RED_ALTAR.getKey()).get(0))); + } + + private Location getNearest(Location to, ConcurrentHashMap options) + { + Location ret = null; + double dist = Double.MAX_VALUE; + + for (Location check : options.keySet()) + { + if (options.get(check) < dist) + { + ret = check; + dist = options.get(check); + } + } + + return ret; + } + + private LinkedList getWaypoints(Location altar) + { + LinkedList waypoints = new LinkedList(); + ConcurrentHashMap distances = new ConcurrentHashMap(); + + for (Location loc : WorldData.GetDataLocs(DataLoc.WITHER_WAYPOINT.getKey())) + { + distances.put(loc, altar.distance(loc)); + } + + while (distances.size() >= 1) + { + Location act = getNearest(altar, distances); + waypoints.add(act); + distances.remove(act); + } + + return waypoints; + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (!Host.IsLive()) + return; + + if (event.getType() != UpdateType.TICK) + { + for (Player player : Bukkit.getOnlinePlayers()) + { + if (player.hasPotionEffect(PotionEffectType.WITHER)) + { + player.removePotionEffect(PotionEffectType.WITHER); + player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 20 * 6, 0)); + } + } + if (_pathfinder != null) + if (_pathfinder.update()) + { + _pathfinder = null; + WitherSpawned = false; + _wowner = null; + _skellyMan.onWitherDeath(); + UtilTextMiddle.display("", C.cGray + "The Mighty Wither has fallen!"); + } + } + } + + @EventHandler + public void onWitherSpawn(EntitySpawnEvent event) + { + if (!Host.IsLive()) + return; + + if (event.getEntity() instanceof Wither) + { + if (WitherSpawned) + { + event.setCancelled(true); + return; + } + + for (GameTeam team : _altars.keySet()) + { + GameTeam enemy = null; + if (team.GetColor() == ChatColor.AQUA) + { + enemy = Host.GetTeam(ChatColor.RED); + } + else if (team.GetColor() == ChatColor.RED) + { + enemy = Host.GetTeam(ChatColor.AQUA); + } + if (_altars.get(team).ownsWither(event)) + { + if (!Host.getCrystal(enemy).Alive) + { + event.setCancelled(true); + return; + } + WitherSpawned = true; + _wowner = team; + _wither = (Wither)event.getEntity(); + _wither.setCustomName(team.GetColor() + team.getDisplayName() + "'s Wither"); + _wither.setCustomNameVisible(true); + UtilTextMiddle.display("", team.GetColor() + team.getDisplayName() + " Team has spawned a Wither Boss!", UtilServer.getPlayers()); + _pathfinder = new WitherPathfinder(this, _wither, getWaypoints(_altars.get(team).getLocation()), team, Host.getCrystal(enemy).getEntity()); + _skellyMan.onWitherSpawn(); + Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() + { + public void run() + { + _altars.get(team).spawnSoulsand(); + } + }, 20 * 35); + } + } + + if (_wither == null) + { + event.setCancelled(true); + } + } + } + + @EventHandler + public void handleWitherDrops(EntityDeathEvent event) + { + if (!Host.IsLive()) + return; + + if (event.getEntity() instanceof Wither) + { + event.setDroppedExp(0); + event.getDrops().clear(); + } + } + + @SuppressWarnings("deprecation") + @EventHandler + public void onExplode(EntityExplodeEvent event) + { + if (!Host.IsLive()) + return; + + if (event.getEntity() instanceof Wither) + { + event.blockList().clear(); + return; + } + if (event.getEntity() instanceof WitherSkull) + { + event.setCancelled(true); + + TeamCrystal red = Host.getCrystal(Host.GetTeam(ChatColor.RED)); + TeamCrystal blue = Host.getCrystal(Host.GetTeam(ChatColor.AQUA)); + HashMap inside = UtilBlock.getInRadius(event.getLocation().getBlock(), 8, true); + + double dmg = 5 * Host.GetTeam(ChatColor.RED).GetPlayers(true).size(); + if (inside.containsKey(red.getLocation().getBlock())) + { + red.damage(dmg, null, true); + } + if (inside.containsKey(blue.getLocation().getBlock())) + { + blue.damage(dmg, null, true); + } + for (Block b : inside.keySet()) + { + for (TeamAltar altar : _altars.values()) + { + if (altar.isInsideAltar(b.getLocation())) + continue; + } + for (GameTeam owner : Host.GetTeamList()) + { + if (Host.getCrystal(owner).getLocation().distance(b.getLocation()) < 7) + { + if (b.getType() == Material.BEDROCK) + continue; + if (b.getType() == Material.OBSIDIAN) + { + if (new Random().nextDouble() > (.75 / 2)) + continue; + } + if (b.getType() == Material.AIR) + continue; + if (b.getType() == Material.STATIONARY_WATER || b.getType() == Material.WATER) + continue; + if (b.getType() == Material.STATIONARY_LAVA || b.getType() == Material.LAVA) + continue; + WorldData.World.dropItem(b.getLocation(), new ItemBuilder(b.getType()).setData(b.getData()).build()); + b.setType(Material.AIR); + } + } + } + } + else if (event.getEntity() instanceof TNTPrimed) + { + event.setCancelled(true); + } + } + + @EventHandler + public void onPlace(BlockPlaceEvent event) + { + if (!Host.IsLive()) + return; + + for (TeamAltar altar : _altars.values()) + { + if (!altar.canPlace(event.getPlayer(), event.getBlock().getType(), event.getBlock().getLocation(), true)) + event.setCancelled(true); + } + } + + @EventHandler + public void onBreak(BlockBreakEvent event) + { + if (!Host.IsLive()) + return; + + for (TeamAltar altar : _altars.values()) + { + if (!altar.canBreak(event.getPlayer(), event.getBlock(), true)) + event.setCancelled(true); + } + } + + @EventHandler + public void onShoot(ProjectileLaunchEvent event) + { + if (!Host.IsLive()) + return; + + if (event.getEntity()instanceof WitherSkull) + { + final WitherSkull entity = (WitherSkull)event.getEntity(); + if (entity.isCharged()) + { + event.setCancelled(true); + } + else + { + if (!((Wither)entity.getShooter()).hasMetadata("Shooting")) + event.setCancelled(true); + } + } + } + + @EventHandler + public void preserveAltars(EntityChangeBlockEvent event) + { + if (!Host.IsLive()) + return; + + for (TeamAltar altar : _altars.values()) + { + if (altar.isInsideAltar(event.getBlock().getLocation())) + { + event.setCancelled(true); + } + } + } + + @EventHandler + public void protectWither(EntityDamageByEntityEvent event) + { + if (!Host.IsLive()) + return; + if (!WitherSpawned) + return; + + if (event.getEntity() instanceof Wither) + { + if (event.getDamager() instanceof Player) + { + Player dmg = (Player)event.getDamager(); + if (_wowner.HasPlayer(dmg)) + { + event.setCancelled(true); + return; + } + } + if (event.getDamager() instanceof Projectile) + { + if (((Projectile)event.getDamager()).getShooter() instanceof Player) + { + Player dmg = (Player) ((Projectile)event.getDamager()).getShooter(); + if (_wowner.HasPlayer(dmg)) + { + event.setCancelled(true); + return; + } + } + } + event.setDamage(event.getDamage() * .3); + } + } + + @EventHandler + public void onRespawn(PlayerGameRespawnEvent event) + { + if (!Host.IsLive()) + return; + + Manager.GetCondition().Clean(event.GetPlayer()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/PathfinderData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/PathfinderData.java new file mode 100644 index 000000000..97d6ec69a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/PathfinderData.java @@ -0,0 +1,81 @@ +package nautilus.game.arcade.game.games.minecraftleague.variation.wither.data; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; + +import org.bukkit.Location; +import org.bukkit.entity.Wither; +import org.bukkit.util.Vector; + +public class PathfinderData +{ + public Wither Wither; + + public Location Target = null; + public Location Location = null; + + public float Pitch = 0; + public Vector Velocity = new Vector(0,0,0); + + //private long _lastReview; + + public PathfinderData(Wither wither, Location target) + { + Wither = wither; + UtilEnt.ghost(wither, true, false); + UtilEnt.Vegetate(wither, false); + + Location temp = wither.getLocation(); + temp.setPitch(UtilAlg.GetPitch(UtilAlg.getTrajectory(wither.getLocation(), target))); + wither.teleport(temp); + + Velocity = wither.getLocation().getDirection().setY(0).normalize(); + Pitch = UtilAlg.GetPitch(wither.getLocation().getDirection()); + + Location = wither.getLocation(); + //_lastReview = System.currentTimeMillis(); + } + + public void move() + { + turn(); + + //Speed + double speed = 0.325 / 2; + + Location.add(Velocity.clone().multiply(speed)); + Location.add(0, -Pitch, 0); + + Location.setPitch(-1 * Pitch); + Location.setYaw(/*180 +*/ UtilAlg.GetYaw(Velocity)); + + // + if (!UtilBlock.airFoliage(Location.getBlock())) + { + Location.setY(UtilBlock.getHighest(Location.getWorld(), Location.getBlockX(), Location.getBlockZ()).getY()); + } + + Wither.teleport(Location); + } + + private void turn() + { + //Pitch + float desiredPitch = UtilAlg.GetPitch(UtilAlg.getTrajectory(Location, Target)); + if (desiredPitch < Pitch) Pitch = (float)(Pitch - 0.05); + if (desiredPitch > Pitch) Pitch = (float)(Pitch + 0.05); + if (Pitch > 0.5) Pitch = 0.5f; + if (Pitch < -0.5) Pitch = -0.5f; + + //Flat + Vector desired = UtilAlg.getTrajectory2d(Location, Target); + desired.subtract(UtilAlg.Normalize(new Vector(Velocity.getX(), 0, Velocity.getZ()))); + desired.multiply(0.2); + + Velocity.add(desired); + + //Speed + UtilAlg.Normalize(Velocity); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java new file mode 100644 index 000000000..708c336c5 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java @@ -0,0 +1,190 @@ +package nautilus.game.arcade.game.games.minecraftleague.variation.wither.data; + +import java.util.List; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilTextMiddle; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.minecraftleague.variation.wither.WitherVariation; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wither; +import org.bukkit.event.entity.EntitySpawnEvent; + +public class TeamAltar +{ + private WitherVariation _host; + private GameTeam _team; + private Location _center; + + private List _protected; + + private Location[] _skullSpots; + + private int _placed; + + public TeamAltar(WitherVariation host, GameTeam team, Location center) + { + _host = host; + _team = team; + _center = center; + + spawnSoulsand(); + + _protected = UtilShapes.getSphereBlocks(center, 7, 7, false); + } + + public boolean isInsideAltar(Location location) + { + return _protected.contains(location); + } + + public void spawnSoulsand() + { + _placed = 0; + Location s1 = null; + Location s2 = null; + Location s3 = null; + + for (int i = -1; i <= 1; i++) + { + _center.getBlock().getRelative(i, 1, 0).setType(Material.SOUL_SAND); + if (i == -1) + s1 = _center.getBlock().getRelative(i, 2, 0).getLocation(); + if (i == 0) + s2 = _center.getBlock().getRelative(i, 2, 0).getLocation(); + if (i == 1) + s3 = _center.getBlock().getRelative(i, 2, 0).getLocation(); + } + _center.getBlock().setType(Material.SOUL_SAND); + + _skullSpots = new Location[] {s1, s2, s3}; + } + + public boolean canBreak(Player player, Block block, boolean notify) + { + if (isInsideAltar(block.getLocation())) + { + if (notify) + UtilPlayer.message(player, F.main("Game", "You cannot break blocks inside an Altar!")); + return false; + /*if (!_team.HasPlayer(player)) + { + if (notify) + UtilPlayer.message(player, F.main("Game", "This is not your Altar!")); + return false; + } + if (block.getType() != Material.SKULL) + { + if (notify) + UtilPlayer.message(player, F.main("Game", "You cannot break that block inside an Altar!")); + return false; + }*/ + } + return true; + } + + public boolean canPlace(Player player, Material blockType, Location location, boolean notify) + { + boolean should = false; + if (isInsideAltar(location)) + { + should = true; + if (!_team.HasPlayer(player)) + { + if (notify) + UtilPlayer.message(player, F.main("Game", "This is not your Altar!")); + return false; + } + + if (_host.WitherSpawned) + { + if (notify) + UtilPlayer.message(player, F.main("Game", "A Wither is already spawned!")); + should = false; + return false; + } + + if (blockType != Material.SKULL) + { + if (notify) + UtilPlayer.message(player, F.main("Game", "You cannot place that inside an Altar!")); + return false; + } + + boolean passes = false; + for (Location l : _skullSpots) + { + if (l.equals(location)) + passes = true; + } + + if (!passes) + { + if (notify) + UtilPlayer.message(player, F.main("Game", "That doesn't go there!")); + should = false; + return false; + } + + if (_team.GetColor() == ChatColor.RED) + { + if (!_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.AQUA)).Alive) + { + if (notify) + UtilPlayer.message(player, F.main("Game", "You do not need a Wither!")); + should = false; + return false; + } + } + if (_team.GetColor() == ChatColor.RED) + { + if (!_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.AQUA)).Alive) + { + if (notify) + UtilPlayer.message(player, F.main("Game", "You do not need a Wither!")); + should = false; + return false; + } + } + } + + if (_team.HasPlayer(player) && blockType == Material.SKULL && should) + { + if (_placed < 2) + { + UtilTextMiddle.display("", _team.GetColor() + _team.getDisplayName() + " has placed a Skull on their Altar!"); + for (Player scare : UtilServer.getPlayers()) + { + scare.playSound(scare.getLocation(), Sound.WITHER_SPAWN, 10, 0); + } + } + _placed++; + } + return true; + } + + public boolean ownsWither(EntitySpawnEvent event) + { + if (event.getEntity() instanceof Wither) + { + Location base = event.getLocation(); + return (isInsideAltar(base.getBlock().getLocation())); + } + + return false; + } + + public Location getLocation() + { + return _center.clone(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java new file mode 100644 index 000000000..9184bba0d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java @@ -0,0 +1,363 @@ +package nautilus.game.arcade.game.games.minecraftleague.variation.wither.data; + +import java.util.List; +import java.util.Random; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.minecraftleague.variation.wither.WitherVariation; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftSkeleton; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.entity.Skeleton.SkeletonType; +import org.bukkit.entity.Wither; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +public class WitherMinionManager implements Listener +{ + private WitherVariation _host; + private List _spawns; + private long _lastDied; + private int _lastUsed; + private int _selected; + + private Skeleton _entity; + + private ItemStack _witherItem; + + private WitherSkeletonTimer _sbTimer; + + private Block _cb; + private Material _changed = Material.AIR; + + private boolean _witherBlocked = false; + + public WitherMinionManager(WitherVariation host, List spawns) + { + _host = host; + _spawns = spawns; + _lastDied = System.currentTimeMillis(); + _lastUsed = -1; + _witherItem = new ItemBuilder(Material.SKULL_ITEM).setTitle(C.cDRedB + "Wither Skeleton Head").setData((short) 1).setLore(C.cGray + "Bring this back", C.cGray + "to your team's Altar", C.cGray + "To summon a Wither!").build(); + _sbTimer = new WitherSkeletonTimer(host.Host.GetScoreboard()); + host.Host.ExtraSb.put(_sbTimer, host); + + Bukkit.getPluginManager().registerEvents(this, host.Manager.getPlugin()); + } + + private void preSpawn() + { + Location chosen = null; + while (chosen == null) + { + int check = new Random().nextInt(_spawns.size()); + if (check != _lastUsed) + { + chosen = _spawns.get(check); + _lastUsed = check; + _selected = check; + } + } + + _cb = chosen.clone().add(0, -2, 0).getBlock(); + _changed = _cb.getType(); + chosen.clone().add(0, -2, 0).getBlock().setType(Material.BEACON); + } + + private void spawn() + { + Location chosen = _spawns.get(_selected); + Entity e = _host.Manager.GetCreature().SpawnEntity(chosen, EntityType.SKELETON); + ((Skeleton)e).setSkeletonType(SkeletonType.WITHER); + _entity = (Skeleton)e; + UtilEnt.ghost(e, true, false); + UtilEnt.Vegetate(e); + e.setCustomName(C.cRed + "Wither Skeleton"); + ((CraftSkeleton)e).getEquipment().setChestplate(new ItemStack(Material.IRON_CHESTPLATE)); + ((CraftSkeleton)e).getEquipment().setLeggings(new ItemStack(Material.IRON_LEGGINGS)); + ((Skeleton)e).addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 9999999, 1)); + + UtilTextMiddle.display("", C.cGray + "A Wither Skeleton has spawned!"); + _selected = -1; + } + + public void onWitherDeath() + { + _lastDied = System.currentTimeMillis() - UtilTime.convert(20, TimeUnit.SECONDS, TimeUnit.MINUTES); + _witherBlocked = false; + _sbTimer.freezeTime(-1); + } + + public void onWitherSpawn() + { + _witherBlocked = true; + if (_entity != null) + { + _entity.remove(); + _cb.setType(_changed); + _cb = null; + _changed = Material.AIR; + _lastDied = System.currentTimeMillis(); + _entity = null; + } + } + + @EventHandler + public void onLive(GameStateChangeEvent event) + { + if (event.GetGame() != _host.Host) + return; + if (event.GetState() != GameState.Live) + return; + + _lastDied = System.currentTimeMillis() + UtilTime.convert(4, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (!_host.Host.IsLive()) + return; + + if (event.getType() != UpdateType.FASTEST) + return; + + if (_entity != null) + { + _entity.teleport(_spawns.get(_lastUsed)); + } + + if (UtilTime.elapsed(_lastDied, UtilTime.convert(60 - 45, TimeUnit.SECONDS, TimeUnit.MINUTES))) + { + boolean noUse = (!_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.RED)).Alive); + if (_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.AQUA)).Alive) + noUse = false; + if (!_host.WitherSpawned || noUse) + { + if (_entity == null) + if (_selected != _lastUsed) + preSpawn(); + } + } + + if (UtilTime.elapsed(_lastDied, UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS))) + { + boolean noUse = (!_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.RED)).Alive); + if (_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.AQUA)).Alive) + noUse = false; + if (!_host.WitherSpawned || noUse) + { + if (_entity == null) + spawn(); + } + } + + for (Player player : Bukkit.getOnlinePlayers()) + { + if (UtilInv.contains(player, Material.SKULL_ITEM, (byte) 1, 1)) + { + UtilTextBottom.display(C.cRed + "Return the Skull to your base!", player); + for (Location loc : UtilShapes.getSphereBlocks(player.getLocation(), 3, 3, true)) + { + UtilParticle.PlayParticleToAll(ParticleType.PORTAL, loc, null, 0, 2, ViewDist.MAX); + } + } + } + } + + @EventHandler + public void handleTimer(UpdateEvent event) + { + if (!_host.Host.IsLive()) + return; + + if (event.getType() != UpdateType.FASTEST) + return; + + boolean noUse = (!_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.RED)).Alive); + if (_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.AQUA)).Alive) + noUse = false; + + if (_entity != null || noUse) + { + _sbTimer.freezeTime(0); + return; + } + + if (_host.WitherSpawned || _witherBlocked) + { + _sbTimer.freezeTime(20); + return; + } + + if (_entity == null) + _sbTimer.freezeTime(-1); + + _sbTimer.setEnd((_lastDied + UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS))); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onSkellyDie(EntityDeathEvent event) + { + if (!_host.Host.IsLive()) + return; + + if (event.getEntity() instanceof Skeleton) + { + Skeleton skelly = (Skeleton)event.getEntity(); + if (skelly.getSkeletonType() == SkeletonType.WITHER) + { + if (_entity != null) + { + if (skelly.getEntityId() == _entity.getEntityId()) + { + _lastDied = System.currentTimeMillis(); + _entity = null; + event.getDrops().clear(); + event.getDrops().add(_witherItem.clone()); + event.setDroppedExp(10); + + _cb.setType(_changed); + _cb = null; + _changed = Material.AIR; + } + } + } + } + } + + @EventHandler + public void onPickup(PlayerPickupItemEvent event) + { + if (!_host.Host.IsLive()) + return; + + if (!event.isCancelled()) + { + String com = UtilItem.itemToStr(event.getItem().getItemStack()); + String com1 = UtilItem.itemToStr(_witherItem.clone()); + String[] compare = com.split(":"); + String[] compare1 = com1.split(":"); + String fin = compare[0] + ":" + compare[2] + ":" + compare[3]; + String fin1 = compare1[0] + ":" + compare1[2] + ":" + compare1[3]; + if (fin.equalsIgnoreCase(fin1)) + { + UtilPlayer.message(event.getPlayer(), F.main("Game", "You have the Wither Skull! Return the skull to your base and place it on your Altar to summon the Wither!")); + if (!event.getItem().hasMetadata("Dropped")) + UtilTextMiddle.display("", _host.Host.GetTeam(event.getPlayer()).GetColor() + _host.Host.GetTeam(event.getPlayer()).getDisplayName() + " has picked up a Wither Skull!", 20, 20 * 5, 20); + } + } + } + + @EventHandler + public void onDrop(PlayerDropItemEvent event) + { + if (!_host.Host.IsLive()) + return; + + if (!event.isCancelled()) + { + String com = UtilItem.itemToStr(event.getItemDrop().getItemStack()); + String com1 = UtilItem.itemToStr(_witherItem.clone()); + String[] compare = com.split(":"); + String[] compare1 = com1.split(":"); + String fin = compare[0] + ":" + compare[2] + ":" + compare[3]; + String fin1 = compare1[0] + ":" + compare1[2] + ":" + compare1[3]; + if (fin.equalsIgnoreCase(fin1)) + { + event.getItemDrop().setMetadata("Dropped", new FixedMetadataValue(_host.Manager.getPlugin(), true)); + } + } + } + + @EventHandler + public void onPlace(BlockPlaceEvent event) + { + if (!_host.Host.IsLive()) + return; + + for (Location loc : _spawns) + { + if (UtilShapes.getSphereBlocks(loc, 5, 5, false).contains(event.getBlock().getLocation())) + event.setCancelled(true); + } + } + + @EventHandler + public void onBreak(BlockBreakEvent event) + { + if (!_host.Host.IsLive()) + return; + + for (Location loc : _spawns) + { + if (UtilShapes.getSphereBlocks(loc, 5, 5, false).contains(event.getBlock().getLocation())) + event.setCancelled(true); + } + } + + @EventHandler + public void onExp(EntityExplodeEvent event) + { + if (!_host.Host.IsLive()) + return; + + if (event.getEntity() instanceof Wither) + { + event.blockList().clear(); + return; + } + event.setCancelled(true); + } + + @EventHandler + public void onEntity(EntityChangeBlockEvent event) + { + if (!_host.Host.IsLive()) + return; + + for (Location loc : _spawns) + { + if (UtilShapes.getSphereBlocks(loc, 5, 5, false).contains(event.getBlock().getLocation())) + event.setCancelled(true); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java new file mode 100644 index 000000000..4fa4eaefd --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java @@ -0,0 +1,164 @@ +package nautilus.game.arcade.game.games.minecraftleague.variation.wither.data; + +import java.util.HashMap; +import java.util.LinkedList; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.minecraftleague.variation.wither.WitherVariation; + +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wither; +import org.bukkit.entity.WitherSkull; +import org.bukkit.metadata.FixedMetadataValue; + +public class WitherPathfinder +{ + private PathfinderData _pathData; + private WitherVariation _host; + private Wither _ent; + private LinkedList _waypoints; + private GameTeam _team; + private Entity _enemy; + private long _lastAttack; + + private boolean _finishedJourney = false; + private boolean _startedJourney = false; + + public WitherPathfinder(WitherVariation host, Wither ent, LinkedList waypoints, GameTeam team, Entity enemy) + { + _host = host; + _ent = ent; + _waypoints = waypoints; + _team = team; + _enemy = enemy; + _lastAttack = -1; + _pathData = new PathfinderData(ent, waypoints.getFirst()); + } + + private int getWaypointIndex(Location loc) + { + int best = -1; + double bestDist = 0; + + for (int i=0 ; i<_waypoints.size() ; i++) + { + Location waypoint = _waypoints.get(i); + + double dist = UtilMath.offset(waypoint, loc); + + if (best == -1 || dist < bestDist) + { + best = i; + bestDist = dist; + } + } + + return best; + } + + private void advance() + { + _pathData.Target = _waypoints.get(Math.min(_waypoints.size()-1, (getWaypointIndex(_pathData.Location) + 1))); + _pathData.move(); + } + + private void retarget() + { + _ent.setTarget(null); + + LivingEntity target = null; + HashMap inside = UtilEnt.getInRadius(_ent.getLocation(), 30); + for (LivingEntity ent : inside.keySet()) + { + if (UtilPlayer.isSpectator(ent)) + continue; + + if (ent instanceof Player) + { + if (_team.HasPlayer((Player)ent)) + continue; + } + else + continue; + + if (target == null) + target = ent; + + if (inside.get(target) > inside.get(ent)) + target = ent; + } + + if (target != null) + shootAt(target.getLocation()); + } + + private void shootAt(Location loc) + { + int sec = 2; + if (_finishedJourney) + sec = 5; + + if (!UtilTime.elapsed(_lastAttack, UtilTime.convert(sec, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) + return; + + Location old = _ent.getLocation(); + Location temp = _ent.getLocation(); + temp.setPitch(UtilAlg.GetPitch(UtilAlg.getTrajectory(_ent.getEyeLocation(), loc))); + temp.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(_ent.getEyeLocation(), loc))); + _ent.teleport(temp); + _ent.setMetadata("Shooting", new FixedMetadataValue(_host.Manager.getPlugin(), "1")); + _ent.launchProjectile(WitherSkull.class); + _ent.removeMetadata("Shooting", _host.Manager.getPlugin()); + _ent.teleport(old); + //skull.setDirection(UtilAlg.getTrajectory(_ent.getLocation(), loc).normalize()); + _lastAttack = System.currentTimeMillis(); + } + + /** + * Returns true if the entity is dead or invalid + */ + public boolean update() + { + if ((_ent == null) || _ent.isDead() || !_ent.isValid()) + return true; + + if (!_enemy.isValid() || _enemy.isDead() || _enemy == null) + { + _ent.remove(); + return true; + } + + if (_ent.getHealth() < _ent.getMaxHealth()) + { + if (!_startedJourney) + return false; + } + _startedJourney = true; + + if (_ent.getLocation().distance(_enemy.getLocation()) <= 10 || _finishedJourney) + { + _finishedJourney = true; + _ent.setTarget(null); + Location finalize = _waypoints.getLast(); + finalize.setPitch(UtilAlg.GetPitch(UtilAlg.getTrajectory(_ent, _enemy))); + finalize.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(_ent, _enemy))); + _ent.teleport(finalize); + shootAt(_enemy.getLocation()); + return false; + } + + advance(); + retarget(); + + return false; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherSkeletonTimer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherSkeletonTimer.java new file mode 100644 index 000000000..047269a80 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherSkeletonTimer.java @@ -0,0 +1,47 @@ +package nautilus.game.arcade.game.games.minecraftleague.variation.wither.data; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import nautilus.game.arcade.game.games.minecraftleague.variation.ExtraScoreboardData; +import nautilus.game.arcade.scoreboard.GameScoreboard; + +public class WitherSkeletonTimer extends ExtraScoreboardData +{ + private long _end; + private int _frozen; + + public WitherSkeletonTimer(GameScoreboard sb) + { + super(sb); + _end = 0; + _frozen = -1; + } + + public void setEnd(long end) + { + _end = end; + } + + public void freezeTime(int seconds) + { + _frozen = seconds; + } + + public void write() + { + Scoreboard.Write(C.cYellowB + "Wither Skeleton Spawn"); + if (_frozen != -1) + { + Scoreboard.Write(_frozen + " Seconds"); + } + else + { + long seconds = 0; + if (_end - System.currentTimeMillis() > 0) + seconds = UtilTime.convert(_end - System.currentTimeMillis(), TimeUnit.MILLISECONDS, TimeUnit.SECONDS); + + Scoreboard.Write(UtilTime.MakeStr(UtilTime.convert(seconds, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))); + } + } +} From ea893bfa482d026b5de07fb6d168b60bc0b3880e Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 12 Feb 2016 23:03:38 -0500 Subject: [PATCH 15/47] - Fixed update --- .../src/mineplex/core/game/GameDisplay.java | 6 +-- .../nautilus/game/arcade/ArcadeManager.java | 13 +++--- .../minecraftleague/MinecraftLeague.java | 4 +- ...ager.java => GameChatSettingsManager.java} | 4 +- .../game/arcade/managers/GameFlagManager.java | 45 +++---------------- 5 files changed, 17 insertions(+), 55 deletions(-) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/{GameChatManager.java => GameChatSettingsManager.java} (97%) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index 8cfb4c35e..ecaa65bf3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -70,12 +70,10 @@ public enum GameDisplay SpeedBuilders("Speed Builders", Material.QUARTZ_BLOCK, (byte) 0, GameCategory.CLASSICS, 60), -<<<<<<< HEAD - Minecraft_League("Minecraft League", Material.DIAMOND_SWORD, (byte)0, GameCategory.SURVIVAL, 59), + Minecraft_League("Minecraft League", Material.DIAMOND_SWORD, (byte)0, GameCategory.SURVIVAL, 61), -======= ChampionsCTF("Champions CTF", "Champions", Material.BANNER, DyeColor.RED.getDyeData(), GameCategory.CHAMPIONS, 56), ->>>>>>> 70d41b074f9256b4ac0b6fb51b68fb24dcf10e24 + BouncyBalls("Bouncy Balls", Material.SLIME_BALL, (byte)0, GameCategory.ARCADE, 57), Gladiators("Gladiators", Material.IRON_SWORD, (byte)0, GameCategory.ARCADE, 58), TypeWars("Type Wars", Material.NAME_TAG, (byte) 0, GameCategory.CLASSICS, 59), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index c5e3f1d55..9ca2b3726 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -85,7 +85,7 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.event.EventModule; import nautilus.game.arcade.game.games.uhc.UHC; import nautilus.game.arcade.managers.GameAchievementManager; -import nautilus.game.arcade.managers.chat.GameChatManager; +import nautilus.game.arcade.managers.GameChatSettingsManager; import nautilus.game.arcade.managers.GameCreationManager; import nautilus.game.arcade.managers.GameFlagManager; import nautilus.game.arcade.managers.GameGemManager; @@ -99,9 +99,9 @@ import nautilus.game.arcade.managers.GameStatManager; import nautilus.game.arcade.managers.GameTestingManager; import nautilus.game.arcade.managers.GameTournamentManager; import nautilus.game.arcade.managers.GameWorldManager; -import nautilus.game.arcade.managers.HolidayManager; import nautilus.game.arcade.managers.IdleManager; import nautilus.game.arcade.managers.MiscManager; +import nautilus.game.arcade.managers.chat.GameChatManager; import nautilus.game.arcade.player.ArcadePlayer; import nautilus.game.arcade.shop.ArcadeShop; @@ -139,7 +139,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation private BlockRestore _blockRestore; private Blood _blood; private Chat _chat; - private GameChatManager _gamechat; + private GameChatSettingsManager _gamechat; private CoreClientManager _clientManager; private DisguiseManager _disguiseManager; private DonationManager _donationManager; @@ -281,11 +281,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation _arcadeShop = new ArcadeShop(this, clientManager, donationManager); // Managers -<<<<<<< HEAD - _gamechat = new GameChatManager(this); -======= + _gamechat = new GameChatSettingsManager(this); _gameChatManager = new GameChatManager(this); ->>>>>>> 70d41b074f9256b4ac0b6fb51b68fb24dcf10e24 _gameCreationManager = new GameCreationManager(this); _gameGemManager = new GameGemManager(this); _gameManager = new GameManager(this); @@ -395,7 +392,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation return _chat; } - public GameChatManager GetGameChat() + public GameChatSettingsManager GetGameChatSettings() { return _gamechat; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index 28b3eb31e..1e1657ceb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -561,7 +561,7 @@ public class MinecraftLeague extends TeamGame Manager.GetCreature().SetDisableCustomDrops(true); _cmd = new MinecraftLeagueCommand(Manager, this); Manager.addCommand(_cmd); - Manager.GetGameChat().TeamSpy = false; + Manager.GetGameChatSettings().TeamSpy = false; } if (event.GetState() == GameState.End) @@ -571,7 +571,7 @@ public class MinecraftLeague extends TeamGame Manager.GetCreature().SetForce(false); Manager.GetCreature().SetDisableCustomDrops(false); Manager.removeCommand(_cmd); - Manager.GetGameChat().TeamSpy = true; + Manager.GetGameChatSettings().TeamSpy = true; HandlerList.unregisterAll(MapManager); HandlerList.unregisterAll(_freeze); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatSettingsManager.java similarity index 97% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatSettingsManager.java index 02fb10438..c9bfb993b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatSettingsManager.java @@ -18,12 +18,12 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; -public class GameChatManager implements Listener +public class GameChatSettingsManager implements Listener { ArcadeManager Manager; public boolean TeamSpy; - public GameChatManager(ArcadeManager manager) + public GameChatSettingsManager(ArcadeManager manager) { Manager = manager; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index b72f3a45e..1216d4a86 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -29,7 +29,6 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.kit.perks.event.PerkDestructorBlockEvent; -import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.Sound; @@ -902,42 +901,6 @@ public class GameFlagManager implements Listener if (game.GetType() != GameType.Gravity) { -<<<<<<< HEAD - UtilPlayer.message(player, C.cRed + C.Bold + "WARNING: " + C.cWhite + C.Bold + "RETURN TO PLAYABLE AREA!"); - - if (game.GetType() != GameType.Gravity) - { - if (player.getLocation().getY() > game.WorldData.MaxY) - UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), game.GetSpectatorLocation()), 1, true, 0, 0, 10, true); - else - UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), game.GetSpectatorLocation()), 1, true, 0.4, 0, 10, true); - } - - Manager.GetDamage().NewDamageEvent(player, null, null, - DamageCause.VOID, 4, false, false, false, - "Border", "Border Damage"); - if (!Manager.GetDamage().IsEnabled()) - { - EntityDamageEvent e = new EntityDamageEvent(player, DamageCause.VOID, 4); - Bukkit.getPluginManager().callEvent(e); - } - - player.getWorld().playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f); - player.getWorld().playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f); - } - else - { - Manager.GetDamage().NewDamageEvent(player, null, null, - DamageCause.VOID, 9001, false, false, false, - "Border", "Border Damage"); - if (!Manager.GetDamage().IsEnabled()) - { - EntityDamageEvent e = new EntityDamageEvent(player, DamageCause.VOID, 4); - Bukkit.getPluginManager().callEvent(e); - } - - } -======= if (player.getLocation().getY() > game.WorldData.MaxY) UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), game.GetSpectatorLocation()), 1, true, 0, 0, 10, true); else @@ -947,10 +910,14 @@ public class GameFlagManager implements Listener Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.VOID, 4, false, false, false, "Border", "Border Damage"); + + if (!Manager.GetDamage().IsEnabled()) + { + new EntityDamageEvent(player, DamageCause.VOID, 4); + } player.getWorld().playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f); player.getWorld().playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f); ->>>>>>> 70d41b074f9256b4ac0b6fb51b68fb24dcf10e24 } else { @@ -1245,4 +1212,4 @@ public class GameFlagManager implements Listener UtilTextMiddle.display(C.cGold + C.Bold + Manager.GetGame().GetType().GetName(), "Make sure you accept the Resource Pack", 20, 120, 20, event.getPlayer()); } -} +} \ No newline at end of file From 8b39d7ba43323fdb460df42cdd5d9b41f6a57d5d Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 12 Feb 2016 23:16:56 -0500 Subject: [PATCH 16/47] - Void damage fix --- .../nautilus/game/arcade/managers/GameFlagManager.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index 1216d4a86..a8731384a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -29,6 +29,7 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.kit.perks.event.PerkDestructorBlockEvent; +import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.Sound; @@ -913,7 +914,7 @@ public class GameFlagManager implements Listener if (!Manager.GetDamage().IsEnabled()) { - new EntityDamageEvent(player, DamageCause.VOID, 4); + Bukkit.getPluginManager().callEvent(new EntityDamageEvent(player, DamageCause.VOID, 4)); } player.getWorld().playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f); @@ -924,6 +925,11 @@ public class GameFlagManager implements Listener Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.VOID, 9001, false, false, false, "Border", "Border Damage"); + + if (!Manager.GetDamage().IsEnabled()) + { + Bukkit.getPluginManager().callEvent(new EntityDamageEvent(player, DamageCause.VOID, 9001)); + } } } From 138c900484a96cea922d6066a0c5d1f9b331b1b3 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 13 Feb 2016 12:46:57 -0500 Subject: [PATCH 17/47] - Fixed up for more universal damage switching --- .../minecraftleague/MinecraftLeague.java | 61 ------ .../game/arcade/managers/GameFlagManager.java | 26 +++ .../managers/SecondaryDamageManager.java | 182 ++++++++++++++++++ 3 files changed, 208 insertions(+), 61 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/SecondaryDamageManager.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index 1e1657ceb..26104e699 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -985,67 +985,6 @@ public class MinecraftLeague extends TeamGame Manager.GetCreature().SpawnEntity(event.getLocation(), EntityType.SPIDER); } - @EventHandler(priority = EventPriority.LOWEST) - public void controlPvP(EntityDamageByEntityEvent event) - { - if (!IsLive()) - return; - - Player entity = null; - Player damager = null; - if (event.getEntity() instanceof Player) - { - entity = (Player)event.getEntity(); - if (UtilPlayer.isSpectator(entity)) - { - event.setCancelled(true); - return; - } - } - if (event.getDamager() instanceof Player) - { - damager = (Player)event.getDamager(); - if (UtilPlayer.isSpectator(damager)) - { - event.setCancelled(true); - return; - } - } - if (event.getDamager() instanceof Projectile) - { - Projectile proj = (Projectile)event.getDamager(); - if (proj.getShooter() instanceof Player) - { - damager = (Player)proj.getShooter(); - if (UtilPlayer.isSpectator(damager)) - { - event.setCancelled(true); - return; - } - } - } - - if ((entity != null) && (damager != null)) - { - if (GetTeam(entity).GetColor() == GetTeam(damager).GetColor()) - event.setCancelled(true); - } - } - - @EventHandler(priority = EventPriority.LOWEST) - public void protectSpectators(EntityDamageEvent event) - { - if (!IsLive()) - return; - - if (event.getEntity() instanceof Player) - { - Player ent = (Player)event.getEntity(); - if (UtilPlayer.isSpectator(ent)) - event.setCancelled(true); - } - } - @EventHandler public void editHealth(GameStateChangeEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index a8731384a..6867c0e30 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -43,6 +43,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.HandlerList; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBurnEvent; @@ -71,6 +72,7 @@ import org.bukkit.util.Vector; public class GameFlagManager implements Listener { ArcadeManager Manager; + SecondaryDamageManager Secondary; public GameFlagManager(ArcadeManager manager) { @@ -78,6 +80,30 @@ public class GameFlagManager implements Listener Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); } + + @EventHandler + public void triggerSecondary(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + return; + + if (Secondary == null) + { + if (!Manager.GetDamage().IsEnabled()) + { + Secondary = new SecondaryDamageManager(Manager); + Bukkit.getPluginManager().registerEvents(Secondary, Manager.getPlugin()); + } + } + else + { + if (Manager.GetDamage().IsEnabled()) + { + HandlerList.unregisterAll(Secondary); + Secondary = null; + } + } + } @EventHandler(priority = EventPriority.LOW) public void DamageEvent(CustomDamageEvent event) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/SecondaryDamageManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/SecondaryDamageManager.java new file mode 100644 index 000000000..e27b84004 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/SecondaryDamageManager.java @@ -0,0 +1,182 @@ +package nautilus.game.arcade.managers; + +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.Game.GameState; + +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +public class SecondaryDamageManager implements Listener +{ + ArcadeManager Manager; + public SecondaryDamageManager(ArcadeManager manager) + { + Manager = manager; + } + + @EventHandler(priority = EventPriority.LOW) + public void EntDamage(EntityDamageEvent event) + { + Game game = Manager.GetGame(); + if (game == null) + { + event.setCancelled(true); + return; + } + + LivingEntity ent = (LivingEntity) event.getEntity(); + if (ent.getWorld().getName().equals("world")) + { + event.setCancelled(true); + + if (event.getCause() == DamageCause.VOID) + ent.teleport(Manager.GetLobby().GetSpawn()); + + return; + } + + if (Manager.isSpectator(ent)) + { + event.setCancelled(true); + if (ent.getFireTicks() > 0) + { + ent.setFireTicks(-1); + } + + return; + } + + if (game.GetState() != GameState.Live) + { + event.setCancelled(true); + return; + } + + if (!game.Damage) + { + event.setCancelled(true); + return; + } + + if (ent instanceof Player) + { + if (!game.IsAlive((Player)ent)) + { + event.setCancelled(true); + return; + } + } + + if (event.getCause() == DamageCause.FALL) + { + if (!game.DamageFall) + { + event.setCancelled(true); + return; + } + } + } + + @EventHandler(priority = EventPriority.LOW) + public void DamageEvent(EntityDamageByEntityEvent event) + { + Game game = Manager.GetGame(); + if (game == null) + return; + + LivingEntity damagee = (LivingEntity)event.getEntity(); + + if (event.getDamager() instanceof LivingEntity || event.getDamager() instanceof Projectile) + { + LivingEntity damager = null; + if (event.getDamager() instanceof LivingEntity) + { + damager = (LivingEntity)event.getDamager(); + } + else + { + if (((Projectile)event.getDamager()).getShooter() instanceof LivingEntity) + { + damager = (LivingEntity)((Projectile)event.getDamager()).getShooter(); + } + } + //Damager Spec + if (damager != null && Manager.isSpectator(damager)) + { + event.setCancelled(true); + return; + } + + if (damager != null && damager instanceof Player && !game.IsAlive((Player)damager)) + { + event.setCancelled(true); + return; + } + + //Entity vs Entity + if (damagee != null && damager != null) + { + //PvP + if (damagee instanceof Player && damager instanceof Player) + { + if (!Manager.canHurt((Player)damagee, (Player)damager)) + { + event.setCancelled(true); + return; + } + } + //PvE + else if (damager instanceof Player) + { + if (!game.DamagePvE) + { + event.setCancelled(true); + return; + } + } + //EvP + else if (damagee instanceof Player) + { + if (!game.DamageEvP) + { + event.setCancelled(true); + return; + } + } + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void DamageExplosion(ConditionApplyEvent event) + { + if (event.isCancelled()) + return; + + if (event.GetCondition().GetType() != ConditionType.EXPLOSION) + return; + + LivingEntity damagee = event.GetCondition().GetEnt(); + if (damagee == null) return; + if (!(damagee instanceof Player)) return; + + LivingEntity damager = event.GetCondition().GetSource(); + if (damager == null) return; + if (!(damager instanceof Player)) return; + + if (Manager.canHurt((Player)damagee, (Player)damager)) + return; + + event.setCancelled(true); + } +} From 6385aacbac1d15ed86350c031de483d49e7f1249 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 13 Feb 2016 14:28:39 -0500 Subject: [PATCH 18/47] - Updates --- .../game/arcade/game/games/minecraftleague/data/TeamBeacon.java | 2 +- .../variation/wither/data/WitherMinionManager.java | 2 +- .../nautilus/game/arcade/managers/SecondaryDamageManager.java | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java index 725f61275..f2f0ad8d3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java @@ -55,7 +55,7 @@ public class TeamBeacon if (player.getLocation().distance(_core) < 15) { player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 5 * 20, 0)); - player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 5 * 20, 0)); + //player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 5 * 20, 0)); player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 5 * 20, 0)); player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 5 * 20, 0)); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java index 9184bba0d..77c1c321c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java @@ -113,7 +113,7 @@ public class WitherMinionManager implements Listener e.setCustomName(C.cRed + "Wither Skeleton"); ((CraftSkeleton)e).getEquipment().setChestplate(new ItemStack(Material.IRON_CHESTPLATE)); ((CraftSkeleton)e).getEquipment().setLeggings(new ItemStack(Material.IRON_LEGGINGS)); - ((Skeleton)e).addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 9999999, 1)); + ((Skeleton)e).addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 9999999, 3)); UtilTextMiddle.display("", C.cGray + "A Wither Skeleton has spawned!"); _selected = -1; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/SecondaryDamageManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/SecondaryDamageManager.java index e27b84004..81eca59dd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/SecondaryDamageManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/SecondaryDamageManager.java @@ -33,6 +33,8 @@ public class SecondaryDamageManager implements Listener event.setCancelled(true); return; } + if (!(event.getEntity() instanceof LivingEntity)) + return; LivingEntity ent = (LivingEntity) event.getEntity(); if (ent.getWorld().getName().equals("world")) From f0d59755d26d12f0ad125094a1eaec15b0d6dadd Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 14 Feb 2016 03:31:36 -0500 Subject: [PATCH 19/47] - Update --- .../games/minecraftleague/variation/wither/WitherVariation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java index 657f43ed8..f2a4193df 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java @@ -231,7 +231,7 @@ public class WitherVariation extends GameVariation TeamCrystal red = Host.getCrystal(Host.GetTeam(ChatColor.RED)); TeamCrystal blue = Host.getCrystal(Host.GetTeam(ChatColor.AQUA)); - HashMap inside = UtilBlock.getInRadius(event.getLocation().getBlock(), 8, true); + HashMap inside = UtilBlock.getInRadius(event.getLocation().getBlock(), 2, false); double dmg = 5 * Host.GetTeam(ChatColor.RED).GetPlayers(true).size(); if (inside.containsKey(red.getLocation().getBlock())) From 8d1b27008900dd05f27e43266df3ae2735ff1cc6 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 15 Feb 2016 19:12:25 -0500 Subject: [PATCH 20/47] - Balancing and bugs --- .../minecraftleague/data/TeamBeacon.java | 4 +++- .../variation/wither/WitherVariation.java | 5 +++- .../wither/data/WitherMinionManager.java | 23 +++++++++++++++---- .../managers/SecondaryDamageManager.java | 3 +++ 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java index f2f0ad8d3..62ba82693 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java @@ -8,6 +8,7 @@ import nautilus.game.arcade.game.GameTeam; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @@ -47,7 +48,8 @@ public class TeamBeacon ignore.add(Material.THIN_GLASS); ignore.add(Material.STAINED_GLASS); ignore.add(Material.STAINED_GLASS_PANE); - if (!UtilBlock.getHighest(_block.getWorld(), _block.getX(), _block.getZ(), ignore).equals(_block)) + //Bukkit.broadcastMessage(UtilBlock.getHighest(_block.getWorld(), _block.getX(), _block.getZ(), ignore) + ""); + if (!isBlock(UtilBlock.getHighest(_block.getWorld(), _block.getX(), _block.getZ(), ignore).getRelative(BlockFace.DOWN))) return; for (Player player : _team.GetPlayers(true)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java index f2a4193df..642604bfa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java @@ -231,7 +231,7 @@ public class WitherVariation extends GameVariation TeamCrystal red = Host.getCrystal(Host.GetTeam(ChatColor.RED)); TeamCrystal blue = Host.getCrystal(Host.GetTeam(ChatColor.AQUA)); - HashMap inside = UtilBlock.getInRadius(event.getLocation().getBlock(), 2, false); + HashMap inside = UtilBlock.getInRadius(event.getLocation().getBlock(), 4, false); double dmg = 5 * Host.GetTeam(ChatColor.RED).GetPlayers(true).size(); if (inside.containsKey(red.getLocation().getBlock())) @@ -244,6 +244,9 @@ public class WitherVariation extends GameVariation } for (Block b : inside.keySet()) { + if (inside.get(b) > 2) + continue; + for (TeamAltar altar : _altars.values()) { if (altar.isInsideAltar(b.getLocation())) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java index 77c1c321c..beae250be 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java @@ -70,6 +70,8 @@ public class WitherMinionManager implements Listener private boolean _witherBlocked = false; + private boolean _spawned = false; + public WitherMinionManager(WitherVariation host, List spawns) { _host = host; @@ -102,9 +104,13 @@ public class WitherMinionManager implements Listener chosen.clone().add(0, -2, 0).getBlock().setType(Material.BEACON); } - private void spawn() + private void spawn(boolean respawn) { - Location chosen = _spawns.get(_selected); + Location chosen = null; + if (!respawn) + chosen = _spawns.get(_selected); + else + chosen = _spawns.get(_lastUsed); Entity e = _host.Manager.GetCreature().SpawnEntity(chosen, EntityType.SKELETON); ((Skeleton)e).setSkeletonType(SkeletonType.WITHER); _entity = (Skeleton)e; @@ -117,6 +123,7 @@ public class WitherMinionManager implements Listener UtilTextMiddle.display("", C.cGray + "A Wither Skeleton has spawned!"); _selected = -1; + _spawned = true; } public void onWitherDeath() @@ -131,6 +138,7 @@ public class WitherMinionManager implements Listener _witherBlocked = true; if (_entity != null) { + _spawned = false; _entity.remove(); _cb.setType(_changed); _cb = null; @@ -160,12 +168,18 @@ public class WitherMinionManager implements Listener if (event.getType() != UpdateType.FASTEST) return; + if (_entity == null || !_entity.isValid()) + { + if (_spawned) + spawn(true); + } + if (_entity != null) { _entity.teleport(_spawns.get(_lastUsed)); } - if (UtilTime.elapsed(_lastDied, UtilTime.convert(60 - 45, TimeUnit.SECONDS, TimeUnit.MINUTES))) + if (UtilTime.elapsed(_lastDied, UtilTime.convert(45, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) { boolean noUse = (!_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.RED)).Alive); if (_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.AQUA)).Alive) @@ -186,7 +200,7 @@ public class WitherMinionManager implements Listener if (!_host.WitherSpawned || noUse) { if (_entity == null) - spawn(); + spawn(false); } } @@ -249,6 +263,7 @@ public class WitherMinionManager implements Listener { if (skelly.getEntityId() == _entity.getEntityId()) { + _spawned = false; _lastDied = System.currentTimeMillis(); _entity = null; event.getDrops().clear(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/SecondaryDamageManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/SecondaryDamageManager.java index 81eca59dd..adcb4c103 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/SecondaryDamageManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/SecondaryDamageManager.java @@ -96,6 +96,9 @@ public class SecondaryDamageManager implements Listener if (game == null) return; + if (!(event.getEntity() instanceof LivingEntity)) + return; + LivingEntity damagee = (LivingEntity)event.getEntity(); if (event.getDamager() instanceof LivingEntity || event.getDamager() instanceof Projectile) From 16c03ebb481a7cec86155ced61f107ed84d87b8f Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 15 Feb 2016 21:54:18 -0500 Subject: [PATCH 21/47] - Silly skeletons! Swimming is for players! --- .../game/arcade/game/games/minecraftleague/data/Spawner.java | 5 ++++- .../minecraftleague/variation/wither/WitherVariation.java | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/Spawner.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/Spawner.java index abe780900..f55764201 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/Spawner.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/Spawner.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; @@ -13,6 +14,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; public class Spawner @@ -77,7 +79,8 @@ public class Spawner Location l = possible.get(i); if (canSpawnMob(l)) { - Host.getArcadeManager().GetCreature().SpawnEntity(l, _toSpawn); + Entity e = Host.getArcadeManager().GetCreature().SpawnEntity(l, _toSpawn); + UtilEnt.Vegetate(e); spawned = true; _lastSpawned = System.currentTimeMillis(); continue; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java index 642604bfa..b7074cb6c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java @@ -374,7 +374,7 @@ public class WitherVariation extends GameVariation } } } - event.setDamage(event.getDamage() * .3); + event.setDamage(event.getDamage() * .4); } } From efb63ee824c9b0914db867e892d73cea2386df18 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 16 Feb 2016 21:27:50 -0500 Subject: [PATCH 22/47] - fixes --- .../nautilus/game/arcade/ArcadeManager.java | 8 - .../minecraftleague/MinecraftLeague.java | 4 +- .../wither/data/WitherMinionManager.java | 10 +- .../managers/GameChatSettingsManager.java | 183 ------------------ .../arcade/managers/chat/GameChatManager.java | 14 +- 5 files changed, 21 insertions(+), 198 deletions(-) delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatSettingsManager.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 4fd7728dc..b0dbadee4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -86,7 +86,6 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.event.EventModule; import nautilus.game.arcade.game.games.uhc.UHC; import nautilus.game.arcade.managers.GameAchievementManager; -import nautilus.game.arcade.managers.GameChatSettingsManager; import nautilus.game.arcade.managers.GameCreationManager; import nautilus.game.arcade.managers.GameFlagManager; import nautilus.game.arcade.managers.GameGemManager; @@ -140,7 +139,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation private BlockRestore _blockRestore; private Blood _blood; private Chat _chat; - private GameChatSettingsManager _gamechat; private CoreClientManager _clientManager; private DisguiseManager _disguiseManager; private DonationManager _donationManager; @@ -280,7 +278,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation _arcadeShop = new ArcadeShop(this, clientManager, donationManager); // Managers - _gamechat = new GameChatSettingsManager(this); _gameChatManager = new GameChatManager(this); _gameCreationManager = new GameCreationManager(this); _gameGemManager = new GameGemManager(this); @@ -396,11 +393,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation { return _chat; } - - public GameChatSettingsManager GetGameChatSettings() - { - return _gamechat; - } public BlockRestore GetBlockRestore() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index 26104e699..c3fde5c52 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -561,7 +561,7 @@ public class MinecraftLeague extends TeamGame Manager.GetCreature().SetDisableCustomDrops(true); _cmd = new MinecraftLeagueCommand(Manager, this); Manager.addCommand(_cmd); - Manager.GetGameChatSettings().TeamSpy = false; + Manager.getGameChatManager().TeamSpy = false; } if (event.GetState() == GameState.End) @@ -571,7 +571,7 @@ public class MinecraftLeague extends TeamGame Manager.GetCreature().SetForce(false); Manager.GetCreature().SetDisableCustomDrops(false); Manager.removeCommand(_cmd); - Manager.GetGameChatSettings().TeamSpy = true; + Manager.getGameChatManager().TeamSpy = true; HandlerList.unregisterAll(MapManager); HandlerList.unregisterAll(_freeze); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java index beae250be..acbdc737e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java @@ -121,7 +121,8 @@ public class WitherMinionManager implements Listener ((CraftSkeleton)e).getEquipment().setLeggings(new ItemStack(Material.IRON_LEGGINGS)); ((Skeleton)e).addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 9999999, 3)); - UtilTextMiddle.display("", C.cGray + "A Wither Skeleton has spawned!"); + if (!respawn) + UtilTextMiddle.display("", C.cGray + "A Wither Skeleton has spawned!"); _selected = -1; _spawned = true; } @@ -140,11 +141,14 @@ public class WitherMinionManager implements Listener { _spawned = false; _entity.remove(); + _lastDied = System.currentTimeMillis(); + _entity = null; + } + if (_cb != null) + { _cb.setType(_changed); _cb = null; _changed = Material.AIR; - _lastDied = System.currentTimeMillis(); - _entity = null; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatSettingsManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatSettingsManager.java deleted file mode 100644 index c9bfb993b..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameChatSettingsManager.java +++ /dev/null @@ -1,183 +0,0 @@ -package nautilus.game.arcade.managers; - -import java.util.Iterator; - -import mineplex.core.account.CoreClient; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.party.Party; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.Game.GameState; -import nautilus.game.arcade.game.GameTeam; - -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; - -public class GameChatSettingsManager implements Listener -{ - ArcadeManager Manager; - public boolean TeamSpy; - - public GameChatSettingsManager(ArcadeManager manager) - { - Manager = manager; - - Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); - - TeamSpy = true; - } - - @EventHandler - public void MeCancel(PlayerCommandPreprocessEvent event) - { - if (event.getMessage().startsWith("/me ")) - { - event.getPlayer().sendMessage(F.main("Mirror", "You can't see /me messages, are you a vampire?")); - event.setCancelled(true); - } - } - - @EventHandler - public void HandleChat(AsyncPlayerChatEvent event) - { - if (event.isCancelled()) - return; - - Player sender = event.getPlayer(); - String senderName = sender.getName(); - - //Dead Prefix - String dead = ""; - if (Manager.GetGame() != null) - if (Manager.GetGame().GetTeam(sender) != null) - if (!Manager.GetGame().IsAlive(sender)) - dead = C.cGray + "Dead "; - - Rank rank = Manager.GetClients().Get(sender).GetRank(); - String disguiseTag = ""; - if(Manager.GetClients().Get(sender).isDisguised()) - { - CoreClient cc = Manager.GetClients().Get(sender); - rank = cc.getDisguisedRank(); - - if(!cc.GetRank().has(Rank.JNR_DEV)) - { - disguiseTag = ChatColor.BLACK + " "; - } - } - - boolean ownsUltra = false; - - if (Manager.GetGame() != null) - ownsUltra= Manager.GetDonation().Get(sender.getName()).OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA"); - - //Level - String levelStr = ""; - if (!Manager.GetGameHostManager().isPrivateServer()) - levelStr = Manager.GetAchievement().getMineplexLevel(sender, rank); - - String rankStr = ""; - //Rank Prefix & MPS Host Prefix - if (Manager.GetGameHostManager().isHost(event.getPlayer())) - { - if (Manager.GetGameHostManager().isEventServer()) - rankStr = C.cDGreen + C.Bold + "Event Host "; - else - rankStr = C.cDGreen + C.Bold + "MPS Host "; - } - else if (Manager.GetGameHostManager().isAdmin(event.getPlayer(), false)) - { - if (Manager.GetGameHostManager().isEventServer()) - rankStr = C.cDGreen + C.Bold + "Event Co-Host "; - else - rankStr = C.cDGreen + C.Bold + "MPS Co-Host "; - } - else - { - if (rank != Rank.ALL) - rankStr = rank.getTag(true, true) + " "; - - if (ownsUltra && !rank.has(Rank.ULTRA)) - rankStr = Rank.ULTRA.getTag(true, true) + " "; - } - - if (event.getMessage().charAt(0) == '@') - { - //Party Chat - Party party = Manager.getPartyManager().GetParty(sender); - - if (party != null) - { - event.getRecipients().clear(); - - event.setMessage(event.getMessage().substring(1, event.getMessage().length())); - event.setFormat(levelStr + C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + senderName + " " + C.cPurple + "%2$s"); - - event.getRecipients().addAll(party.GetPlayersOnline()); - - return; - } - } - - //Base Format - event.setFormat(disguiseTag + dead + levelStr + rankStr + Manager.GetColor(sender) + senderName + " " + ChatColor.WHITE + "%2$s"); - - //Public/Private (Not If Player Dead) - if (Manager.GetGame() != null && Manager.GetGame().GetState() == GameState.Live) - { - boolean globalMessage = false; - - //Team - GameTeam team = Manager.GetGame().GetTeam(sender); - - if (team != null) - { - //Team Chat - if (event.getMessage().charAt(0) == '@') - { - event.setMessage(event.getMessage().substring(1, event.getMessage().length())); - event.setFormat(disguiseTag + C.cWhite + C.Bold + "Team" + " " + dead + levelStr + rankStr + team.GetColor() + senderName + " " + C.cWhite + "%2$s"); - } - //All Chat - else - { - globalMessage = true; - event.setFormat(disguiseTag + dead + levelStr + rankStr + team.GetColor() + senderName + " " + C.cWhite + "%2$s"); - } - } - - if (globalMessage) - return; - - //Team Message Remove Recipient - Iterator recipientIterator = event.getRecipients().iterator(); - - while (recipientIterator.hasNext()) - { - Player receiver = recipientIterator.next(); - - if (!Manager.GetServerConfig().Tournament && Manager.GetClients().Get(receiver).GetRank().has(Rank.MODERATOR)) - { - if (TeamSpy) - continue; - } - - GameTeam recTeam = Manager.GetGame().GetTeam(receiver); - GameTeam sendTeam = Manager.GetGame().GetTeam(sender); - - if (recTeam == null || sendTeam == null) - { - continue; - } - - if (!recTeam.equals(sendTeam)) - recipientIterator.remove(); - } - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java index 8ba8039e8..17790177e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java @@ -33,6 +33,8 @@ public class GameChatManager implements Listener private ArcadeManager _manager; private LinkedList _chatStats; + + public boolean TeamSpy; public GameChatManager(ArcadeManager manager) { @@ -41,6 +43,8 @@ public class GameChatManager implements Listener _manager.getPluginManager().registerEvents(this, _manager.getPlugin()); _chatStats = new LinkedList(); + + TeamSpy = true; } @EventHandler @@ -157,7 +161,10 @@ public class GameChatManager implements Listener format = event.getFormat().split(rankStr)[0]; name = _manager.GetColor(sender) + sender.getName() + C.Reset; - message = event.getFormat().split(sender.getName())[1].replace("%2$s", "") + _manager.GetChat().getFilteredMessage(sender, event.getMessage()); + if (event.getMessage().charAt(0) == '@') + message = event.getFormat().split(sender.getName())[1].replace("%2$s", "") + _manager.GetChat().getFilteredMessage(sender, event.getMessage().substring(1, event.getMessage().length())); + else + message = event.getFormat().split(sender.getName())[1].replace("%2$s", "") + _manager.GetChat().getFilteredMessage(sender, event.getMessage()); if (_manager.GetGame().GetState() != GameState.Live) { @@ -230,7 +237,10 @@ public class GameChatManager implements Listener Player receiver = recipientIterator.next(); if (!_manager.GetServerConfig().Tournament && _manager.GetClients().Get(receiver).GetRank().has(Rank.MODERATOR)) - continue; + { + if (TeamSpy) + continue; + } GameTeam recTeam = _manager.GetGame().GetTeam(receiver); GameTeam sendTeam = _manager.GetGame().GetTeam(sender); From fe849576f7d5bbcd511af205f92ef6539b77b405 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Wed, 17 Feb 2016 22:04:20 -0500 Subject: [PATCH 23/47] - Spawn protection --- .../minecraftleague/MinecraftLeague.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index c3fde5c52..a25098ff2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -8,9 +8,11 @@ import java.util.concurrent.ConcurrentHashMap; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; @@ -54,6 +56,7 @@ import org.bukkit.entity.CreatureType; import org.bukkit.entity.Enderman; import org.bukkit.entity.EntityType; import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; @@ -616,6 +619,62 @@ public class MinecraftLeague extends TeamGame } } + if (event.getType() == UpdateType.FASTER) + { + List redSpawns = WorldData.SpawnLocs.get("Red"); + List blueSpawns = WorldData.SpawnLocs.get("Blue"); + + for (Location rL : redSpawns) + { + for (LivingEntity near : UtilEnt.getInRadius(rL, 5).keySet()) + { + if (!(near instanceof Player)) + continue; + Player player = (Player)near; + if (GetTeam(player).GetColor() == ChatColor.RED) + continue; + + Vector vec = UtilAlg.getTrajectory(rL, player.getLocation()); + + Location tpLoc = rL.add(vec.clone().multiply(8)); + tpLoc.setDirection(player.getLocation().getDirection()); + + //First tp out this combats hacked clients with anti-KB + player.teleport(tpLoc); + + //Then apply velocity as normal + UtilAction.velocity(player, vec, 1.8, false, 0, 0.4, vec.length(), false); + + player.playSound(player.getEyeLocation(), Sound.NOTE_PLING, 10F, 0.5F); + } + } + + for (Location bL : blueSpawns) + { + for (LivingEntity near : UtilEnt.getInRadius(bL, 5).keySet()) + { + if (!(near instanceof Player)) + continue; + Player player = (Player)near; + if (GetTeam(player).GetColor() == ChatColor.AQUA) + continue; + + Vector vec = UtilAlg.getTrajectory(bL, player.getLocation()); + + Location tpLoc = bL.add(vec.clone().multiply(8)); + tpLoc.setDirection(player.getLocation().getDirection()); + + //First tp out this combats hacked clients with anti-KB + player.teleport(tpLoc); + + //Then apply velocity as normal + UtilAction.velocity(player, vec, 1.8, false, 0, 0.4, vec.length(), false); + + player.playSound(player.getEyeLocation(), Sound.NOTE_PLING, 10F, 0.5F); + } + } + } + if (event.getType() == UpdateType.FASTEST) { for (TeamCrystal crystal : _crystals.values()) From d3884bd090160bbff04bd47853f94304521bc86f Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Wed, 17 Feb 2016 22:12:23 -0500 Subject: [PATCH 24/47] - Spawn regen --- .../games/minecraftleague/MinecraftLeague.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index a25098ff2..3f6356052 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -12,7 +12,6 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilItem; -import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; @@ -26,6 +25,7 @@ import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.TeamGame; @@ -83,6 +83,8 @@ import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; import com.google.common.base.Objects; @@ -856,7 +858,7 @@ public class MinecraftLeague extends TeamGame } } - /*@EventHandler + @EventHandler public void onRespawn(PlayerGameRespawnEvent event) { if (event.GetGame() != this) @@ -864,7 +866,9 @@ public class MinecraftLeague extends TeamGame Player player = event.GetPlayer(); - if (!_crystals.get(GetTeam(player)).Alive) + player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 5 * 20, 3)); + + /*if (!_crystals.get(GetTeam(player)).Alive) { SetPlayerState(player, PlayerState.OUT); @@ -891,8 +895,8 @@ public class MinecraftLeague extends TeamGame } if (_overTime) - _crystals.get(GetTeam(player)).damage(20, null); - }*/ + _crystals.get(GetTeam(player)).damage(20, null);*/ + } @EventHandler public void onDrop(PlayerDropItemEvent event) From 0a6cdfa7796959ab055b47220078934565f9a7cf Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 20 Feb 2016 03:18:59 -0500 Subject: [PATCH 25/47] - chiss' requested changes --- .../minecraftleague/MinecraftLeague.java | 202 ++++++++++++++---- .../minecraftleague/data/BlockProtection.java | 53 +++++ .../variation/wither/WitherVariation.java | 2 +- .../wither/data/WitherMinionManager.java | 4 +- .../wither/data/WitherPathfinder.java | 17 ++ 5 files changed, 230 insertions(+), 48 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/BlockProtection.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index 3f6356052..99bb4dbf1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -31,6 +31,7 @@ import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.minecraftleague.commands.MinecraftLeagueCommand; import nautilus.game.arcade.game.games.minecraftleague.commands.freeze.FreezeManager; +import nautilus.game.arcade.game.games.minecraftleague.data.BlockProtection; import nautilus.game.arcade.game.games.minecraftleague.data.OreDeposit; import nautilus.game.arcade.game.games.minecraftleague.data.PlayerRespawnPoint; import nautilus.game.arcade.game.games.minecraftleague.data.Spawner; @@ -49,6 +50,7 @@ import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; +import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Arrow; @@ -64,6 +66,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.EntityDamageByEntityEvent; @@ -96,6 +99,8 @@ public class MinecraftLeague extends TeamGame //private ConcurrentHashMap _maps = new ConcurrentHashMap(); private ConcurrentHashMap> _gear = new ConcurrentHashMap>(); private ConcurrentHashMap _beacons = new ConcurrentHashMap(); + private ConcurrentHashMap _blockLock = new ConcurrentHashMap(); + private ConcurrentHashMap _spawnAllow = new ConcurrentHashMap(); private List _spawners = new ArrayList(); public ConcurrentHashMap ExtraSb = new ConcurrentHashMap(); @@ -299,6 +304,25 @@ public class MinecraftLeague extends TeamGame return 0; } + private int getPickLevel(ItemStack sword) + { + if (UtilItem.isPickaxe(sword)) + { + //if (UtilItem.isDiamondProduct(sword)) + //return 5; + if (UtilItem.isIronProduct(sword)) + return 4; + if (UtilItem.isGoldProduct(sword)) + return 3; + if (UtilItem.isStoneProduct(sword)) + return 2; + if (UtilItem.isWoodProduct(sword)) + return 1; + } + + return 0; + } + private ItemStack getBestSword(Player player) { ItemStack ret = new ItemStack(Material.AIR); @@ -319,6 +343,26 @@ public class MinecraftLeague extends TeamGame return ret; } + private ItemStack getBestPick(Player player) + { + ItemStack ret = new ItemStack(Material.AIR); + int level = 0; + + for (ItemStack item : UtilInv.getItems(player, false, true, false)) + { + if (UtilItem.isPickaxe(item)) + { + if (getPickLevel(item) > level) + { + ret = item; + level = getSwordLevel(item); + } + } + } + + return ret; + } + public int getMapVariantID() { return WorldData.GetDataLocs(DataLoc.VARIANT_ID.getKey()).size(); @@ -623,56 +667,36 @@ public class MinecraftLeague extends TeamGame if (event.getType() == UpdateType.FASTER) { - List redSpawns = WorldData.SpawnLocs.get("Red"); - List blueSpawns = WorldData.SpawnLocs.get("Blue"); - - for (Location rL : redSpawns) + for (GameTeam team : _teamList) { - for (LivingEntity near : UtilEnt.getInRadius(rL, 5).keySet()) + for (Location loc : team.GetSpawns()) { - if (!(near instanceof Player)) - continue; - Player player = (Player)near; - if (GetTeam(player).GetColor() == ChatColor.RED) - continue; - - Vector vec = UtilAlg.getTrajectory(rL, player.getLocation()); + for (LivingEntity near : UtilEnt.getInRadius(loc, 5).keySet()) + { + if (!(near instanceof Player)) + continue; + Player player = (Player)near; + if (team.HasPlayer(player)) + { + if (_spawnAllow.containsKey(player)) + continue; + } + if (UtilPlayer.isSpectator(player)) + continue; + + Vector vec = UtilAlg.getTrajectory(loc, player.getLocation()); - Location tpLoc = rL.add(vec.clone().multiply(8)); - tpLoc.setDirection(player.getLocation().getDirection()); + Location tpLoc = loc.add(vec.clone().multiply(8)); + tpLoc.setDirection(player.getLocation().getDirection()); - //First tp out this combats hacked clients with anti-KB - player.teleport(tpLoc); + //First tp out this combats hacked clients with anti-KB + player.teleport(tpLoc); - //Then apply velocity as normal - UtilAction.velocity(player, vec, 1.8, false, 0, 0.4, vec.length(), false); + //Then apply velocity as normal + UtilAction.velocity(player, vec, 1.8, false, 0, 0.4, vec.length(), false); - player.playSound(player.getEyeLocation(), Sound.NOTE_PLING, 10F, 0.5F); - } - } - - for (Location bL : blueSpawns) - { - for (LivingEntity near : UtilEnt.getInRadius(bL, 5).keySet()) - { - if (!(near instanceof Player)) - continue; - Player player = (Player)near; - if (GetTeam(player).GetColor() == ChatColor.AQUA) - continue; - - Vector vec = UtilAlg.getTrajectory(bL, player.getLocation()); - - Location tpLoc = bL.add(vec.clone().multiply(8)); - tpLoc.setDirection(player.getLocation().getDirection()); - - //First tp out this combats hacked clients with anti-KB - player.teleport(tpLoc); - - //Then apply velocity as normal - UtilAction.velocity(player, vec, 1.8, false, 0, 0.4, vec.length(), false); - - player.playSound(player.getEyeLocation(), Sound.NOTE_PLING, 10F, 0.5F); + player.playSound(player.getEyeLocation(), Sound.NOTE_PLING, 10F, 0.5F); + } } } } @@ -714,6 +738,20 @@ public class MinecraftLeague extends TeamGame this.DeathSpectateSecs = Math.max(0, this.DeathSpectateSecs + 2.5); } + for (Player player : _spawnAllow.keySet()) + { + if (UtilTime.elapsed(_spawnAllow.get(player), UtilTime.convert(30, TimeUnit.SECONDS, TimeUnit.MINUTES))) + { + _spawnAllow.remove(player); + } + } + + for (Player player : _blockLock.keySet()) + { + if (!player.isOnline()) + _blockLock.remove(player); + } + for (Player player : Bukkit.getOnlinePlayers()) { if (UtilPlayer.isSpectator(player)) @@ -840,6 +878,65 @@ public class MinecraftLeague extends TeamGame _customRespawns.put(player, new PlayerRespawnPoint(player, event.getClickedBlock().getLocation())); } + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void lockBlock(BlockPlaceEvent event) + { + if (!IsLive()) + return; + + Block block = event.getBlock(); + if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST || block.getType() == Material.FURNACE) + _blockLock.get(event.getPlayer()).lockBlock(block); + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void unlockBlock(BlockBreakEvent event) + { + if (!IsLive()) + return; + + _blockLock.get(event.getPlayer()).unlockBlock(event.getBlock()); + } + + @EventHandler + public void tryOpen(PlayerInteractEvent event) + { + if (!IsLive()) + return; + + if (event.getClickedBlock() == null) + return; + + if (event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; + + Block block = event.getClickedBlock(); + + if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST || block.getType() == Material.FURNACE) + { + for (Player owner : _blockLock.keySet()) + { + BlockProtection prot = _blockLock.get(owner); + + if (prot.isLockedTo(event.getPlayer(), block)) + { + event.setCancelled(true); + return; + } + else + { + if (owner.getName().equalsIgnoreCase(event.getPlayer().getName())) + { + if (event.getPlayer().isSneaking()) + { + prot.unlockBlock(block); + } + } + } + } + } + } + @EventHandler public void breakBed(BlockBreakEvent event) { @@ -867,6 +964,7 @@ public class MinecraftLeague extends TeamGame Player player = event.GetPlayer(); player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 5 * 20, 3)); + _spawnAllow.put(player, System.currentTimeMillis()); /*if (!_crystals.get(GetTeam(player)).Alive) { @@ -1045,7 +1143,10 @@ public class MinecraftLeague extends TeamGame Manager.GetCreature().SpawnEntity(event.getLocation(), event.getEntityType()); if (event.getCreatureType() == CreatureType.SPIDER) - Manager.GetCreature().SpawnEntity(event.getLocation(), EntityType.SPIDER); + { + for (int i = 1; i <= 3; i++) + Manager.GetCreature().SpawnEntity(event.getLocation(), EntityType.SPIDER); + } } @EventHandler @@ -1101,7 +1202,9 @@ public class MinecraftLeague extends TeamGame player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(Color.BLUE).build()); player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.BLUE).build()); player.getInventory().addItem(new ItemStack(Material.WOOD_SWORD)); + player.getInventory().addItem(new ItemStack(Material.WOOD_PICKAXE)); player.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 5)); + _blockLock.put(player, new BlockProtection(this, player)); } for (Player player : GetTeam(ChatColor.RED).GetPlayers(true)) { @@ -1110,7 +1213,9 @@ public class MinecraftLeague extends TeamGame player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(Color.RED).build()); player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.RED).build()); player.getInventory().addItem(new ItemStack(Material.WOOD_SWORD)); + player.getInventory().addItem(new ItemStack(Material.WOOD_PICKAXE)); player.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 5)); + _blockLock.put(player, new BlockProtection(this, player)); } } @@ -1130,6 +1235,11 @@ public class MinecraftLeague extends TeamGame else gear.add(new ItemStack(Material.AIR)); + if (!UtilItem.isDiamondProduct(getBestPick(player))) + gear.add(getBestPick(player)); + else + gear.add(new ItemStack(Material.AIR)); + if (!UtilItem.isDiamondProduct(player.getInventory().getHelmet())) gear.add(player.getInventory().getHelmet()); else @@ -1187,7 +1297,7 @@ public class MinecraftLeague extends TeamGame } } - @EventHandler + @EventHandler(priority = EventPriority.LOWEST) public void blockDeadTalk(AsyncPlayerChatEvent event) { try diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/BlockProtection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/BlockProtection.java new file mode 100644 index 000000000..20a605f5c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/BlockProtection.java @@ -0,0 +1,53 @@ +package nautilus.game.arcade.game.games.minecraftleague.data; + +import java.util.ArrayList; +import java.util.List; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; + +import org.bukkit.block.Block; +import org.bukkit.entity.Player; + +public class BlockProtection +{ + private MinecraftLeague _host; + private Player _player; + private List _blocks = new ArrayList(); + + public BlockProtection(MinecraftLeague host, Player player) + { + _host = host; + _player = player; + } + + public boolean isLockedTo(Player opening, Block block) + { + if (!_blocks.contains(block)) + return false; + if (_host.GetTeam(_player).GetColor() != _host.GetTeam(opening).GetColor()) + return false; + if (opening.getName().equalsIgnoreCase(_player.getName())) + return false; + + return true; + } + + public void lockBlock(Block block) + { + if (_blocks.size() > 5) + return; + + _blocks.add(block); + UtilPlayer.message(_player, F.main("Game", "You have locked this block to your team! Right-click it while sneaking to unlock it!")); + } + + public void unlockBlock(Block block) + { + if (_blocks.remove(block)) + { + UtilPlayer.message(_player, F.main("Game", "You have unlocked this block!")); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java index b7074cb6c..7e2f0482c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java @@ -374,7 +374,7 @@ public class WitherVariation extends GameVariation } } } - event.setDamage(event.getDamage() * .4); + event.setDamage(event.getDamage() * .8); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java index acbdc737e..e3f2f50df 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java @@ -117,9 +117,11 @@ public class WitherMinionManager implements Listener UtilEnt.ghost(e, true, false); UtilEnt.Vegetate(e); e.setCustomName(C.cRed + "Wither Skeleton"); + ((Skeleton)e).setMaxHealth(100); + ((Skeleton)e).setHealth(100); ((CraftSkeleton)e).getEquipment().setChestplate(new ItemStack(Material.IRON_CHESTPLATE)); ((CraftSkeleton)e).getEquipment().setLeggings(new ItemStack(Material.IRON_LEGGINGS)); - ((Skeleton)e).addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 9999999, 3)); + ((Skeleton)e).addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 9999999, 7)); if (!respawn) UtilTextMiddle.display("", C.cGray + "A Wither Skeleton has spawned!"); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java index 4fa4eaefd..970271347 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java @@ -13,6 +13,7 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.minecraftleague.variation.wither.WitherVariation; import org.bukkit.Location; +import org.bukkit.entity.Arrow; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -144,6 +145,22 @@ public class WitherPathfinder } _startedJourney = true; + for (Entity e : UtilEnt.getAllInRadius(_ent.getLocation(), 3).keySet()) + { + if (e instanceof Arrow) + { + Arrow arrow = (Arrow)e; + if (arrow.getShooter() instanceof Player) + { + if (!_team.HasPlayer((Player)arrow.getShooter())) + { + arrow.remove(); + _ent.damage(5, (Player)arrow.getShooter()); + } + } + } + } + if (_ent.getLocation().distance(_enemy.getLocation()) <= 10 || _finishedJourney) { _finishedJourney = true; From 3212b75e4e14ea760388020d3e8e8dd17011c4bf Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 12 Mar 2016 09:35:44 -0500 Subject: [PATCH 26/47] - Finally finished all of chiss' changes --- .../game/games/minecraftleague/DataLoc.java | 22 +- .../minecraftleague/MinecraftLeague.java | 323 ++++++++++-------- .../minecraftleague/data/DefenderAI.java | 171 ++++++++++ .../minecraftleague/data/OreGenerator.java | 39 +++ .../minecraftleague/data/TeamCrystal.java | 243 +------------ .../games/minecraftleague/data/TeamTower.java | 17 + .../minecraftleague/data/TeamTowerBase.java | 272 +++++++++++++++ .../minecraftleague/data/TowerManager.java | 181 ++++++++++ .../variation/VariationManager.java | 11 +- .../variation/VariationType.java | 12 +- .../variation/wither/WitherVariation.java | 18 +- .../variation/wither/data/TeamAltar.java | 70 ++-- .../wither/data/WitherMinionManager.java | 12 +- .../wither/data/WitherPathfinder.java | 58 ++-- 14 files changed, 978 insertions(+), 471 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/DefenderAI.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreGenerator.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTower.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/DataLoc.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/DataLoc.java index bc0270002..3eb439b3e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/DataLoc.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/DataLoc.java @@ -1,22 +1,26 @@ package nautilus.game.arcade.game.games.minecraftleague; - public enum DataLoc { //Base - RED_CRYSTAL("RED"), - BLUE_CRYSTAL("BLUE"), - VARIANT_ID("ORANGE"), - RED_BEACON("PINK"), - BLUE_BEACON("CYAN"), + RED_CRYSTAL("RED CRYSTAL"), + RED_TOWER("RED TOWER"), + BLUE_CRYSTAL("BLUE CRYSTAL"), + BLUE_TOWER("BLUE TOWER"), + VARIANT_BASE("GAMEMODE "), + //RED_BEACON("PINK"), + /*BLUE_*/BEACON("CYAN"), SKELETON_SPAWNER("BROWN"), - MAP_DIAMOND("LIGHT_BLUE"), - MAP_IRON("SILVER"), + //MAP_DIAMOND("LIGHT_BLUE"), + //MAP_IRON("SILVER"), + RED_ORE("15"), + BLUE_ORE("14"), //Wither WITHER_WAYPOINT("PURPLE"), + TOWER_WAYPOINT("$team$ TOWER $number$"), WITHER_SKELETON("BLACK"), - BLUE_ALTAR("GREEN"), + BLUE_ALTAR("LIME"), RED_ALTAR("YELLOW") ; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index 99bb4dbf1..172ea19bd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -2,7 +2,6 @@ package nautilus.game.arcade.game.games.minecraftleague; import java.util.ArrayList; import java.util.List; -import java.util.Random; import java.util.concurrent.ConcurrentHashMap; import mineplex.core.common.util.C; @@ -12,6 +11,7 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; @@ -35,8 +35,9 @@ import nautilus.game.arcade.game.games.minecraftleague.data.BlockProtection; import nautilus.game.arcade.game.games.minecraftleague.data.OreDeposit; import nautilus.game.arcade.game.games.minecraftleague.data.PlayerRespawnPoint; import nautilus.game.arcade.game.games.minecraftleague.data.Spawner; -import nautilus.game.arcade.game.games.minecraftleague.data.TeamBeacon; import nautilus.game.arcade.game.games.minecraftleague.data.TeamCrystal; +import nautilus.game.arcade.game.games.minecraftleague.data.TeamTowerBase; +import nautilus.game.arcade.game.games.minecraftleague.data.TowerManager; import nautilus.game.arcade.game.games.minecraftleague.data.map.ItemMapManager; import nautilus.game.arcade.game.games.minecraftleague.kit.KitPlayer; import nautilus.game.arcade.game.games.minecraftleague.variation.ExtraScoreboardData; @@ -94,11 +95,10 @@ import com.google.common.base.Objects; public class MinecraftLeague extends TeamGame { - private ConcurrentHashMap _crystals = new ConcurrentHashMap(); private ConcurrentHashMap _customRespawns = new ConcurrentHashMap(); //private ConcurrentHashMap _maps = new ConcurrentHashMap(); private ConcurrentHashMap> _gear = new ConcurrentHashMap>(); - private ConcurrentHashMap _beacons = new ConcurrentHashMap(); + //private ConcurrentHashMap _beacons = new ConcurrentHashMap(); private ConcurrentHashMap _blockLock = new ConcurrentHashMap(); private ConcurrentHashMap _spawnAllow = new ConcurrentHashMap(); private List _spawners = new ArrayList(); @@ -116,6 +116,9 @@ public class MinecraftLeague extends TeamGame private VariationManager _vman; private FreezeManager _freeze; + private TowerManager _tower; + + private final CreatureType[] _passive = new CreatureType[] {CreatureType.CHICKEN, CreatureType.COW, CreatureType.PIG, CreatureType.RABBIT, CreatureType.SHEEP}; public MinecraftLeague(ArcadeManager manager) { @@ -179,6 +182,7 @@ public class MinecraftLeague extends TeamGame _vman = new VariationManager(this); _freeze = new FreezeManager(); + _tower = new TowerManager(this); Bukkit.getPluginManager().registerEvents(_freeze, manager.getPlugin()); } @@ -363,14 +367,25 @@ public class MinecraftLeague extends TeamGame return ret; } - public int getMapVariantID() + public List getMapVariantIDS() { - return WorldData.GetDataLocs(DataLoc.VARIANT_ID.getKey()).size(); + List ids = new ArrayList(); + for (String s : WorldData.GetAllCustomLocs().keySet()) + { + if (s.contains(DataLoc.VARIANT_BASE.getKey())) + ids.add(s); + } + return ids; } - public TeamCrystal getCrystal(GameTeam team) + public TeamTowerBase getActiveTower(GameTeam team) { - return _crystals.get(team); + return _tower.getVulnerable(team); + } + + public TowerManager getTowerManager() + { + return _tower; } public FreezeManager getFreezeManager() @@ -385,29 +400,25 @@ public class MinecraftLeague extends TeamGame @Override public void ParseData() - { - Location redLoc = WorldData.GetDataLocs(DataLoc.RED_CRYSTAL.getKey()).get(0); - Location blueLoc = WorldData.GetDataLocs(DataLoc.BLUE_CRYSTAL.getKey()).get(0); + { + _tower.parseTowers(WorldData); - _crystals.put(GetTeam(ChatColor.RED), new TeamCrystal(this, GetTeam(ChatColor.RED), redLoc)); - _crystals.put(GetTeam(ChatColor.AQUA), new TeamCrystal(this, GetTeam(ChatColor.AQUA), blueLoc)); - - _beacons.put(GetTeam(ChatColor.RED), new TeamBeacon(GetTeam(ChatColor.RED), WorldData.GetDataLocs(DataLoc.RED_BEACON.getKey()).get(0).getBlock(), redLoc)); - _beacons.put(GetTeam(ChatColor.AQUA), new TeamBeacon(GetTeam(ChatColor.AQUA), WorldData.GetDataLocs(DataLoc.BLUE_BEACON.getKey()).get(0).getBlock(), blueLoc)); + //_beacons.put(GetTeam(ChatColor.RED), new TeamBeacon(GetTeam(ChatColor.RED), WorldData.GetDataLocs(DataLoc.RED_BEACON.getKey()).get(0).getBlock(), redLoc)); + //_beacons.put(GetTeam(ChatColor.AQUA), new TeamBeacon(GetTeam(ChatColor.AQUA), WorldData.GetDataLocs(DataLoc.BLUE_BEACON.getKey()).get(0).getBlock(), blueLoc)); for (Location loc : WorldData.GetDataLocs(DataLoc.SKELETON_SPAWNER.getKey())) { _spawners.add(new Spawner(this, loc, EntityType.SKELETON)); } - for (Location loc : WorldData.GetDataLocs(DataLoc.MAP_DIAMOND.getKey())) + /*for (Location loc : WorldData.GetDataLocs(DataLoc.MAP_DIAMOND.getKey())) { Ore.add(new OreDeposit(loc, Material.DIAMOND_ORE, new int[] {0, 255, 255})); } for (Location loc : WorldData.GetDataLocs(DataLoc.MAP_IRON.getKey())) { Ore.add(new OreDeposit(loc, Material.IRON_ORE, new int[] {190, 190, 190})); - } + }*/ MapManager = new ItemMapManager(this, WorldData.World, WorldData.MinX, WorldData.MinZ, WorldData.MaxX, WorldData.MaxZ); @@ -456,8 +467,8 @@ public class MinecraftLeague extends TeamGame GameTeam red = GetTeam(ChatColor.RED); GameTeam blue = GetTeam(ChatColor.AQUA); - TeamCrystal redc = _crystals.get(red); - TeamCrystal bluec = _crystals.get(blue); + TeamCrystal redc = (TeamCrystal) _tower.getTeamTowers(red).getLast(); + TeamCrystal bluec = (TeamCrystal) _tower.getTeamTowers(blue).getLast(); _liveTime = Math.max(System.currentTimeMillis() - GetStateTime(), 0); @@ -507,54 +518,16 @@ public class MinecraftLeague extends TeamGame player.teleport(GetTeam(player).GetSpawn()); } - public enum EditType + public boolean handleCommand(Player caller) { - SPAWN, KILL, DAMAGE, STATUS; - } - - public boolean handleCommand(EditType type, GameTeam target, Player caller, Double damage) - { - TeamCrystal crystal = null; - if (target != null) - crystal = _crystals.get(target); - - if (type == EditType.SPAWN) + for (GameTeam team : GetTeamList()) { - if (crystal == null) - return false; - if (crystal.Alive) - return false; - crystal.handleDebug(caller, null, false); + TeamTowerBase tower = _tower.getVulnerable(team); + UtilPlayer.message(caller, team.GetColor() + team.GetName()); + UtilPlayer.message(caller, C.cGray + "Health: " + tower.getHealth()); + UtilPlayer.message(caller, C.cGray + "Alive: " + tower.Alive); } - if (type == EditType.KILL) - { - if (crystal == null) - return false; - if (!crystal.Alive) - return false; - crystal.handleDebug(caller, null, true); - } - if (type == EditType.DAMAGE) - { - if (crystal == null) - return false; - if (!crystal.Alive) - return false; - if (damage == null) - return false; - crystal.handleDebug(caller, damage, false); - } - if (type == EditType.STATUS) - { - for (GameTeam team : _crystals.keySet()) - { - TeamCrystal cr = _crystals.get(team); - UtilPlayer.message(caller, team.GetColor() + team.GetName()); - UtilPlayer.message(caller, C.cGray + "Health: " + cr.getHealth()); - UtilPlayer.message(caller, C.cGray + "Alive: " + cr.Alive); - } - } - + return true; } @@ -563,12 +536,7 @@ public class MinecraftLeague extends TeamGame if (!_gear.containsKey(player)) return; List items = _gear.get(player); - if (items.get(0) == null) - UtilInv.insert(player, new ItemStack(Material.AIR)); - else - UtilInv.insert(player, getNewItemStack(items.get(0))); - - for (int i = 1; i < items.size(); i++) + for (int i = 0; i < 4; i++) { ItemStack item; if (items.get(i) != null) @@ -576,7 +544,7 @@ public class MinecraftLeague extends TeamGame else item = new ItemStack(Material.AIR); - switch(i) + switch(i + 1) { case 1: player.getInventory().setHelmet(getNewItemStack(item)); @@ -592,6 +560,13 @@ public class MinecraftLeague extends TeamGame break; } } + for (int i = 4; i < items.size(); i++) + { + if (items.get(i) == null) + UtilInv.insert(player, new ItemStack(Material.AIR)); + else + UtilInv.insert(player, getNewItemStack(items.get(i))); + } _gear.remove(player); } @@ -703,10 +678,7 @@ public class MinecraftLeague extends TeamGame if (event.getType() == UpdateType.FASTEST) { - for (TeamCrystal crystal : _crystals.values()) - { - crystal.update(); - } + _tower.update(); /*for (TeamMap map : _maps.values()) { @@ -718,10 +690,10 @@ public class MinecraftLeague extends TeamGame spawner.update(); } - for (TeamBeacon beacon : _beacons.values()) + /*for (TeamBeacon beacon : _beacons.values()) { beacon.update(); - } + }*/ if (!OverTime) { @@ -759,14 +731,16 @@ public class MinecraftLeague extends TeamGame player.setFireTicks(-1); player.setFoodLevel(20); } - if (player.getInventory().getType() == InventoryType.BEACON) + if (player.getOpenInventory().getType() == InventoryType.BEACON) player.closeInventory(); + if (player.getFireTicks() > 20 * 3) + player.setFireTicks(20 * 3); } } } @EventHandler - public void crystalDmg(EntityDamageEvent event) + public void towerDmg(EntityDamageEvent event) { if (!InProgress()) return; @@ -774,15 +748,16 @@ public class MinecraftLeague extends TeamGame if (event.getEntity().getType() != EntityType.ENDER_CRYSTAL) return; - for (TeamCrystal cryst : _crystals.values()) - { - if (cryst.isEntity(event.getEntity())) - event.setCancelled(true); - } + for (GameTeam team : GetTeamList()) + for (TeamTowerBase tower : _tower.getTeamTowers(team)) + { + if (tower.isEntity(event.getEntity())) + event.setCancelled(true); + } } @EventHandler - public void crystalDmg(EntityDamageByEntityEvent event) + public void towerDmg(EntityDamageByEntityEvent event) { if (!IsLive()) return; @@ -790,14 +765,15 @@ public class MinecraftLeague extends TeamGame if (event.getEntity().getType() != EntityType.ENDER_CRYSTAL) return; - TeamCrystal crystal = null; - for (TeamCrystal cryst : _crystals.values()) + TeamTowerBase tower = null; + for (GameTeam team : GetTeamList()) + for (TeamTowerBase tow : _tower.getTeamTowers(team)) { - if (cryst.isEntity(event.getEntity())) - crystal = cryst; + if (tower.isEntity(event.getEntity())) + tower = tow; } - if (crystal == null) + if (tower == null) return; event.setCancelled(true); @@ -812,11 +788,17 @@ public class MinecraftLeague extends TeamGame { player = (Player) ((Projectile)event.getDamager()).getShooter(); - if (!crystal.canDamage(player)) + if (!tower.canDamage(player)) return; - if (!crystal.damage(event.getDamage(), player, true)) - player.playSound(crystal.getLocation(), Sound.ORB_PICKUP, 100, 0); + if (!tower.Vulnerable) + { + UtilPlayer.message(player, F.main("Game", "That Tower is protected by the power of another!")); + return; + } + + if (!tower.damage(event.getDamage() / 2, player)) + player.playSound(tower.getLocation(), Sound.ORB_PICKUP, 100, 0); } } } @@ -824,13 +806,19 @@ public class MinecraftLeague extends TeamGame if (event.getDamager() instanceof Player) { player = (Player)event.getDamager(); - if (!crystal.canDamage(player)) + if (!tower.canDamage(player)) return; + if (!tower.Vulnerable) + { + UtilPlayer.message(player, F.main("Game", "That Tower is protected by the power of another!")); + return; + } + if (player.getItemInHand() == null || player.getItemInHand().getType() == Material.AIR) { - if (!crystal.damage(1, player, true)) - player.playSound(crystal.getLocation(), Sound.ZOMBIE_WOODBREAK, 1, 0); + if (!tower.damage(1, player)) + player.playSound(tower.getLocation(), Sound.ZOMBIE_WOODBREAK, 1, 0); return; } @@ -838,8 +826,8 @@ public class MinecraftLeague extends TeamGame int level = player.getItemInHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL); double damage = DamageAmount.getDamageAmount(type).getDamage(level, DamageType.getDamageType(type)); - if (!crystal.damage(damage, player, true)) - player.playSound(crystal.getLocation(), Sound.ZOMBIE_WOODBREAK, 1, 0); + if (!tower.damage(damage, player)) + player.playSound(tower.getLocation(), Sound.ZOMBIE_WOODBREAK, 1, 0); if (DamageAmount.getDamageAmount(type) != DamageAmount.NONE) { @@ -1068,6 +1056,7 @@ public class MinecraftLeague extends TeamGame return; List newDrops = new ArrayList(); + Integer arrows = 0; for (ItemStack item : event.getDrops()) { @@ -1075,11 +1064,26 @@ public class MinecraftLeague extends TeamGame continue; if (_gear.get(event.getEntity()) != null) + { + if (item.getType() == Material.ARROW) + { + arrows += item.getAmount(); + continue; + } if (_gear.get(event.getEntity()).contains(item)) continue; + } newDrops.add(item); } + arrows = arrows / 2; + + while (arrows >= 1) + { + int subtract = Math.min(64, arrows); + newDrops.add(new ItemStack(Material.ARROW, subtract)); + arrows -= subtract; + } event.getDrops().clear(); for (ItemStack item : newDrops) @@ -1104,13 +1108,22 @@ public class MinecraftLeague extends TeamGame } @EventHandler - public void craftMap(PrepareItemCraftEvent event) + public void craftItem(PrepareItemCraftEvent event) { if (!IsLive()) return; if (event.getInventory().getResult().getType() == Material.EMPTY_MAP || event.getInventory().getResult().getType() == Material.MAP) event.getInventory().setResult(new ItemStack(Material.AIR)); + + if (UtilItem.isArmor(event.getInventory().getResult())) + { + event.getInventory().setResult(UtilItem.makeUnbreakable(event.getInventory().getResult())); + } + if (event.getInventory().getResult().getType() == Material.ARROW) + { + event.getInventory().setResult(new ItemStack(Material.ARROW, (event.getInventory().getResult().getAmount() * 2))); + } } @EventHandler @@ -1141,7 +1154,15 @@ public class MinecraftLeague extends TeamGame return; } - Manager.GetCreature().SpawnEntity(event.getLocation(), event.getEntityType()); + EntityType et = event.getEntityType(); + + for (CreatureType pass : _passive) + { + if (pass == event.getCreatureType()) + et = EntityType.CHICKEN; + } + + Manager.GetCreature().SpawnEntity(event.getLocation(), et); if (event.getCreatureType() == CreatureType.SPIDER) { for (int i = 1; i <= 3; i++) @@ -1157,34 +1178,39 @@ public class MinecraftLeague extends TeamGame if (event.GetGame() != this) return; - - for (TeamCrystal c : _crystals.values()) - { - double playercount = GetTeam(ChatColor.RED).GetPlayers(true).size() + GetTeam(ChatColor.AQUA).GetPlayers(true).size(); - c.setMaxHealth(50 * 2 * playercount); - } + + int playercount = GetTeam(ChatColor.RED).GetPlayers(true).size() + GetTeam(ChatColor.AQUA).GetPlayers(true).size(); + _tower.prepareHealth(playercount, 50 * 2); } @EventHandler - public void dropBow(EntityDeathEvent event) + public void dropBowStuff(EntityDeathEvent event) { - if (event.getEntityType() != EntityType.SKELETON) - return; - - boolean addbow = true; - for (ItemStack check : event.getDrops()) + /*if (event.getEntityType() == EntityType.SKELETON) { - if (check.getType() == Material.BOW) - addbow = false; - } - - if (addbow) + boolean addbow = true; + for (ItemStack check : event.getDrops()) + { + if (check.getType() == Material.BOW) + addbow = false; + } + + if (addbow) + { + if (new Random().nextDouble() > .75) + event.getDrops().add(new ItemStack(Material.BOW)); + } + + event.getDrops().add(new ItemStack(Material.ARROW, 15)); + }*/ + if (event.getEntityType() == EntityType.CHICKEN) { - if (new Random().nextDouble() > .75) - event.getDrops().add(new ItemStack(Material.BOW)); + for (ItemStack test : event.getDrops()) + if (test.getType() == Material.FEATHER) + return; + + event.getDrops().add(new ItemStack(Material.FEATHER, UtilMath.random.nextInt(4))); } - - event.getDrops().add(new ItemStack(Material.ARROW, 15)); } @EventHandler @@ -1230,16 +1256,6 @@ public class MinecraftLeague extends TeamGame Player player = (Player)event.getEntity(); List gear = new ArrayList(); - if (!UtilItem.isDiamondProduct(getBestSword(player))) - gear.add(getBestSword(player)); - else - gear.add(new ItemStack(Material.AIR)); - - if (!UtilItem.isDiamondProduct(getBestPick(player))) - gear.add(getBestPick(player)); - else - gear.add(new ItemStack(Material.AIR)); - if (!UtilItem.isDiamondProduct(player.getInventory().getHelmet())) gear.add(player.getInventory().getHelmet()); else @@ -1260,6 +1276,24 @@ public class MinecraftLeague extends TeamGame else gear.add(new ItemStack(Material.AIR)); + if (!UtilItem.isDiamondProduct(getBestSword(player))) + gear.add(getBestSword(player)); + else + gear.add(new ItemStack(Material.AIR)); + + if (!UtilItem.isDiamondProduct(getBestPick(player))) + gear.add(getBestPick(player)); + else + gear.add(new ItemStack(Material.AIR)); + + int arrowsToAdd = UtilInv.getAmount(player, Material.ARROW) / 2; + while (arrowsToAdd >= 1) + { + int subtract = Math.min(64, arrowsToAdd); + gear.add(new ItemStack(Material.ARROW, subtract)); + arrowsToAdd -= subtract; + } + _gear.put(player, gear); } @@ -1347,7 +1381,7 @@ public class MinecraftLeague extends TeamGame return; Player player = Bukkit.getPlayer(event.GetLog().GetPlayer().GetName()); - if (!_crystals.get(GetTeam(player)).Alive) + if (_tower.getAmountAlive(GetTeam(player)) < 1) { SetPlayerState(player, PlayerState.OUT); @@ -1375,8 +1409,8 @@ public class MinecraftLeague extends TeamGame if (OverTime) { - _crystals.get(GetTeam(player)).damage(20, null, false); - if (!_crystals.get(GetTeam(player)).Alive) + _tower.getVulnerable(GetTeam(player)).damage(20, null); + if (_tower.getAmountAlive(GetTeam(player)) < 1) { SetPlayerState(player, PlayerState.OUT); @@ -1420,23 +1454,34 @@ public class MinecraftLeague extends TeamGame if (event.getEntity() instanceof Enderman) event.setCancelled(true); - for (TeamCrystal crystal : _crystals.values()) + for (GameTeam team : GetTeamList()) + for (TeamTowerBase tower : _tower.getTeamTowers(team)) { if (event.getLocation().getWorld().getUID() != WorldData.World.getUID()) continue; - if (event.getLocation().distance(crystal.getLocation()) <= 5) + if (event.getLocation().distance(tower.getLocation()) <= 5) event.setCancelled(true); } } - @EventHandler - public void sigilsIsMean(BlockBreakEvent event) + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void handleBreak(BlockBreakEvent event) { if (!IsLive()) return; if (UtilPlayer.isSpectator(event.getPlayer())) + { event.setCancelled(true); + return; + } + + if (event.getBlock().getType() == Material.GRAVEL) + { + event.setCancelled(true); + event.getBlock().setType(Material.AIR); + event.getBlock().getWorld().dropItemNaturally(event.getBlock().getLocation(), new ItemStack(Material.FLINT)); + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/DefenderAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/DefenderAI.java new file mode 100644 index 000000000..c76b1a489 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/DefenderAI.java @@ -0,0 +1,171 @@ +package nautilus.game.arcade.game.games.minecraftleague.data; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; + +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +public class DefenderAI +{ + private TowerManager _manager; + private TeamTowerBase _tower; + private long _lastAttack; + private long _procTime; + private DefenseAnimation _animation; + + public DefenderAI(TowerManager manager, TeamTowerBase tower) + { + _manager = manager; + _tower = tower; + _lastAttack = System.currentTimeMillis(); + _procTime = -1; + _animation = new DefenseAnimation(); + } + + public void update() + { + if (!_tower.Alive) + return; + + if (_tower instanceof TeamTower) + _animation.activate(); + else + attack(); + + _animation.update(); + } + + private void animate() + { + _animation.activate(); + _animation.deactivate(); //<-- Used for when attack hits + } + + private void attack() + { + if (_procTime != -1) + { + if (System.currentTimeMillis() >= _procTime) + { + _procTime = -1; + attackProc(); + return; + } + } + if (!UtilTime.elapsed(_lastAttack, UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS))) + return; + if (UtilMath.random.nextDouble() < .75) + return; + _procTime = System.currentTimeMillis() + UtilTime.convert(45, TimeUnit.SECONDS, TimeUnit.MILLISECONDS); + animate(); + } + + private void attackProc() + { + for (LivingEntity le : UtilEnt.getInRadius(_tower.getLocation(), 15).keySet()) + { + if (!(le instanceof Player)) + continue; + + Player player = (Player)le; + if (_manager.Host.GetTeam(player).GetColor() == _tower.getTeam().GetColor()) + continue; + if (UtilPlayer.isSpectator(player)) + continue; + + player.getWorld().strikeLightningEffect(player.getLocation()); + player.damage(4 * 2); + } + } + + private class DefenseAnimation + { + private Location _base; + private double _step; + //private final double _baseRadius; + private double _radius; + private long _lastStepIncrease; + private boolean _active; + + public DefenseAnimation() + { + _step = 0; + _lastStepIncrease = System.currentTimeMillis(); + if (_tower instanceof TeamTower) + { + //_baseRadius = -1; + _base = _tower.getLocation().clone().add(0, 10, 0); + } + else + { + //_baseRadius = 11; + _base = _tower.getLocation().clone(); + } + _radius = /*_baseRadius*/2; + } + + public void activate() + { + _active = true; + } + + public void deactivate() + { + _active = false; + } + + public void update() + { + if (!_active) + return; + + if (_tower instanceof TeamTower) + { + drawBeam(); + } + else + { + if (UtilTime.elapsed(_lastStepIncrease, UtilTime.convert(3, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) + { + _step++; + _lastStepIncrease = System.currentTimeMillis(); + } + drawHelix(); + } + } + + private void drawHelix() + { + for (double y = 0; y <= _step; y += .5) + { + double x = _radius * Math.cos(y); + double z = _radius * Math.sin(y); + Location play = new Location(_base.getWorld(), _base.getX() + x, _base.getY() + y, _base.getZ() + z); + + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, play, null, 0, 1, ViewDist.MAX); + } + } + + private void drawBeam() + { + Location target = _manager.getTeamTowers(_tower.getTeam()).getLast().getLocation().clone().add(0, 10, 0); + Location display = _base.clone(); + while (UtilMath.offset(_base, target) > UtilMath.offset(_base, display)) + { + Vector v = UtilAlg.getTrajectory(display, target); + UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, display, null, 0, 1, ViewDist.MAX); + display.add(v); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreGenerator.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreGenerator.java new file mode 100644 index 000000000..cb785897f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreGenerator.java @@ -0,0 +1,39 @@ +package nautilus.game.arcade.game.games.minecraftleague.data; + +import java.util.List; + +import mineplex.core.common.util.UtilMath; + +import org.bukkit.Location; +import org.bukkit.Material; + +public class OreGenerator +{ + private int _current; + private int _total; + + public void generateOre(Material oreType, List possible, int amount) + { + _current = 0; + _total = amount; + while (_current < _total) + { + iterateOres(oreType, possible); + } + } + + private void iterateOres(Material oreType, List possible) + { + for (Location loc : possible) + { + if (loc.getBlock().getType() == oreType) + continue; + if (UtilMath.random.nextDouble() > .33) + continue; + if (_total <= _current) + return; + loc.getBlock().setType(oreType); + _current++; + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java index b2438670b..afea34d7e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java @@ -1,249 +1,14 @@ package nautilus.game.arcade.game.games.minecraftleague.data; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAlg; -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 mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextBottom; -import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.hologram.Hologram; -import mineplex.core.recharge.Recharge; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; -import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.entity.EnderCrystal; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; -public class TeamCrystal +public class TeamCrystal extends TeamTowerBase { - private MinecraftLeague _host; - private Location _spawn; - private GameTeam _team; - private Double _health, _maxHealth; - private EnderCrystal _entity; - private Hologram _name, _healthTag; - public boolean Alive; - - private long _lastAlert = -1; - private long _lastHit = -1; - - public TeamCrystal(MinecraftLeague host, GameTeam team, Location spawn) + public TeamCrystal(MinecraftLeague host, TowerManager manager, GameTeam team, Location spawn) { - _host = host; - _spawn = spawn.clone().add(0.5, 1.2, 0.5); - _team = team; - _maxHealth = 11111D; - _health = 11111D; - _name = new Hologram(_host.getArcadeManager().getHologramManager(), _spawn.clone().add(0, 3, 0), team.GetColor() + team.getDisplayName() + "'s Respawn Crystal"); - _healthTag = new Hologram(_host.getArcadeManager().getHologramManager(), _spawn.clone().add(0, 2, 0), formatHealth(_health)); - - spawn(); + super(host, manager, team, spawn); } - - private void spawn() - { - _name.start(); - _healthTag.start(); - _entity = (EnderCrystal) _host.getArcadeManager().GetCreature().SpawnEntity(_spawn, EntityType.ENDER_CRYSTAL); - _health = _maxHealth; - Alive = true; - } - - private void kill(Player player) - { - String message = ""; - if (player != null) - message = C.cRedB + player.getName() + " has destroyed " + _team.getDisplayName() + "'s " + C.cDPurpleB + "Crystal" + C.cRedB + "!"; - else - message = C.cRedB + _team.getDisplayName() + "'s " + C.cDPurpleB + "Respawn Crystal" + C.cRedB + " has been destroyed!"; - - Bukkit.broadcastMessage(message); - - for (Player inform : _team.GetPlayers(true)) - UtilTextMiddle.display(C.cRedB + "Team Crystal Destroyed", C.cRed + "You will no longer respawn!", inform); - - Alive = false; - _entity.remove(); - _healthTag.stop(); - _name.stop(); - playDeathAnimation(_spawn); - } - - private void playDeathAnimation(Location loc) - { - _spawn.getWorld().playSound(loc, Sound.EXPLODE, 10, 0); - //GFX subject to change - Location loc1 = loc.clone().add(-2, 3, -2); - Location loc2 = loc.clone().add(2, 0, 2); - Location loc3 = loc.clone().add(2, 3, 2); - Location loc4 = loc.clone().add(-2, 0, -2); - Location particle1 = loc2.clone(); - Location particle2 = loc4.clone(); - while (UtilMath.offset(loc1, loc) >= UtilMath.offset(particle1, loc)) - { - Vector v = UtilAlg.getTrajectory(particle1, loc1); - //UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, particle, v, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers()); - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, particle1, v, 0, 5, ViewDist.MAX, UtilServer.getPlayers()); - particle1.add(v); - } - while (UtilMath.offset(loc3, loc) >= UtilMath.offset(particle2, loc)) - { - Vector v = UtilAlg.getTrajectory(particle2, loc3); - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, particle2, v, 0, 5, ViewDist.MAX, UtilServer.getPlayers()); - particle2.add(v); - } - } - - private void alert() - { - if (UtilTime.elapsed(_lastAlert, UtilTime.convert(15, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) - { - _lastHit = System.currentTimeMillis(); - - for (Player player : _team.GetPlayers(true)) - { - player.playSound(player.getLocation(), Sound.NOTE_PLING, 10, 0); - } - } - } - - private void alertTextDisplay() - { - if (UtilTime.elapsed(_lastHit, UtilTime.convert(5, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) - return; - for (Player player : _team.GetPlayers(true)) - UtilTextBottom.display(C.cRed + "Your Crystal is under attack!", player); - } - - public Entity getEntity() - { - return _entity; - } - - public boolean isEntity(Entity e) - { - return e.getEntityId() == _entity.getEntityId(); - } - - public boolean canDamage(Player player) - { - if (UtilPlayer.isSpectator(player)) - return false; - - if (_host.GetTeam(player) == _team) - return false; - - if (!_host.IsPlaying(player)) - return false; - - if (!Recharge.Instance.usable(player, "Damage Teamcrystal")) - return false; - - return true; - } - - public Double getHealth() - { - if (!Alive) - return 0D; - - return _health; - } - - public String formatHealth(Double healthNumber) - { - String tag = healthNumber.toString(); - - if (healthNumber > (.9 * _maxHealth)) - tag = C.cGreen + tag; - else if (healthNumber < (.45 * _maxHealth)) - tag = C.cRed + tag; - else - tag = C.cYellow + tag; - - return tag; - } - - public boolean damage(double damage, Player player, boolean hit) - { - Double newHealth = Math.max(_health - damage, 0); - - if (newHealth == 0) - { - kill(player); - return true; - } - - if (hit) - alert(); - - _health = newHealth; - if (player != null) - Recharge.Instance.use(player, "Damage Teamcrystal", UtilTime.convert(1, TimeUnit.SECONDS, TimeUnit.MILLISECONDS), false, false); - return false; - } - - public Location getLocation() - { - return _spawn; - } - - public void update() - { - _healthTag.setText(formatHealth(_health)); - - if (Alive) - { - if (_entity.isDead() || !_entity.isValid()) - { - _entity = (EnderCrystal) _host.getArcadeManager().GetCreature().SpawnEntity(_spawn, EntityType.ENDER_CRYSTAL); - } - - if (_health > _maxHealth) - { - _health = _maxHealth; - } - - alertTextDisplay(); - } - } - - public void setMaxHealth(Double health) - { - _maxHealth = Math.abs(health); - } - - public void handleDebug(Player dev, Double damage, boolean kill) - { - if (damage != null) - { - damage(damage, dev, false); - UtilPlayer.message(dev, F.main(_host.GetName(), "The Crystal has been damaged")); - return; - } - - if (kill) - { - kill(dev); - UtilPlayer.message(dev, F.main(_host.GetName(), "The Crystal has been killed")); - } - else - { - spawn(); - UtilPlayer.message(dev, F.main(_host.GetName(), "The Crystal has been spawned")); - } - } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTower.java new file mode 100644 index 000000000..3fab4b528 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTower.java @@ -0,0 +1,17 @@ +package nautilus.game.arcade.game.games.minecraftleague.data; + +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; + +import org.bukkit.Location; + +public class TeamTower extends TeamTowerBase +{ + public Integer Number; + + public TeamTower(MinecraftLeague host, TowerManager manager, GameTeam team, Location spawn, Integer number) + { + super(host, manager, team, spawn); + Number = number; + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java new file mode 100644 index 000000000..3ce1548f3 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java @@ -0,0 +1,272 @@ +package nautilus.game.arcade.game.games.minecraftleague.data; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +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 mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.hologram.Hologram; +import mineplex.core.recharge.Recharge; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.minecraftleague.DataLoc; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.EnderCrystal; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wither; +import org.bukkit.util.Vector; + +public abstract class TeamTowerBase +{ + private MinecraftLeague _host; + private TowerManager _manager; + private Location _spawn; + private GameTeam _team; + private Double _health, _maxHealth; + private EnderCrystal _entity; + private Hologram _name, _healthTag; + private String _type; + public boolean Alive; + public boolean Vulnerable; + + public TeamTowerBase(MinecraftLeague host, TowerManager manager, GameTeam team, Location spawn) + { + _host = host; + _manager = manager; + _spawn = spawn.clone().add(0.5, 1.2, 0.5); + _team = team; + _maxHealth = 11111D; + _health = 11111D; + _type = "Tower"; + if (this instanceof TeamCrystal) + _type = "Crystal"; + _name = new Hologram(_host.getArcadeManager().getHologramManager(), _spawn.clone().add(0, 3, 0), team.GetColor() + team.getDisplayName() + "'s " + _type); + _healthTag = new Hologram(_host.getArcadeManager().getHologramManager(), _spawn.clone().add(0, 2, 0), formatHealth(_health)); + + spawn(); + } + + private void spawn() + { + _name.start(); + _healthTag.start(); + _entity = (EnderCrystal) _host.getArcadeManager().GetCreature().SpawnEntity(_spawn, EntityType.ENDER_CRYSTAL); + _health = _maxHealth; + Alive = true; + } + + private void kill(Player player) + { + String message = ""; + if (player != null) + message = C.cRedB + player.getName() + " has destroyed " + _team.getDisplayName() + "'s " + C.cDPurpleB + _type + C.cRedB + "!"; + else + message = C.cRedB + _team.getDisplayName() + "'s " + C.cDPurpleB + _type + C.cRedB + " has been destroyed!"; + + Bukkit.broadcastMessage(message); + + if (!_type.equalsIgnoreCase("Tower")) + { + for (Player inform : _team.GetPlayers(true)) + UtilTextMiddle.display(C.cRedB + "Team Crystal Destroyed", C.cRed + "You will no longer respawn!", inform); + } + + Alive = false; + _entity.remove(); + _healthTag.stop(); + _name.stop(); + Bukkit.getScheduler().runTaskLater(_host.Manager.getPlugin(), new Runnable() + { + public void run() + { + playDeathAnimation(_spawn); + } + }, 20 * 5); + detonate(); + _manager.handleTowerDeath(this); + } + + private void playDeathAnimation(Location loc) + { + _spawn.getWorld().playSound(loc, Sound.EXPLODE, 10, 0); + //GFX subject to change + Location loc1 = loc.clone().add(-2, 3, -2); + Location loc2 = loc.clone().add(2, 0, 2); + Location loc3 = loc.clone().add(2, 3, 2); + Location loc4 = loc.clone().add(-2, 0, -2); + Location particle1 = loc2.clone(); + Location particle2 = loc4.clone(); + while (UtilMath.offset(loc1, loc) >= UtilMath.offset(particle1, loc)) + { + Vector v = UtilAlg.getTrajectory(particle1, loc1); + //UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, particle, v, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers()); + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, particle1, v, 0, 5, ViewDist.MAX, UtilServer.getPlayers()); + particle1.add(v); + } + while (UtilMath.offset(loc3, loc) >= UtilMath.offset(particle2, loc)) + { + Vector v = UtilAlg.getTrajectory(particle2, loc3); + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, particle2, v, 0, 5, ViewDist.MAX, UtilServer.getPlayers()); + particle2.add(v); + } + } + + private void detonate() + { + UtilParticle.PlayParticleToAll(ParticleType.EXPLODE, _spawn, null, 0, 2, ViewDist.NORMAL); + for (Block b : UtilBlock.getExplosionBlocks(_spawn, 1, false)) + { + b.setType(Material.AIR); + } + for (LivingEntity le : UtilEnt.getInRadius(_spawn, 5).keySet()) + { + if (le instanceof Wither) + le.damage(le.getHealth() / 2); + else + le.damage(6); + } + } + + private Location getBeacon() + { + Location ret = null; + for (Location loc : _host.WorldData.GetDataLocs(DataLoc.BEACON.getKey())) + { + if (ret == null || UtilMath.offset(ret, _spawn) > UtilMath.offset(loc, _spawn)) + ret = loc; + } + + return ret; + } + + public Entity getEntity() + { + return _entity; + } + + public boolean isEntity(Entity e) + { + return e.getEntityId() == _entity.getEntityId(); + } + + public boolean canDamage(Player player) + { + if (UtilPlayer.isSpectator(player)) + return false; + + if (_host.GetTeam(player) == _team) + return false; + + if (!_host.IsPlaying(player)) + return false; + + if (!Recharge.Instance.usable(player, "Damage TeamTower")) + return false; + + return true; + } + + public Double getHealth() + { + if (!Alive) + return 0D; + + return _health; + } + + public String formatHealth(Double healthNumber) + { + String tag = healthNumber.toString(); + + if (healthNumber > (.9 * _maxHealth)) + tag = C.cGreen + tag; + else if (healthNumber < (.45 * _maxHealth)) + tag = C.cRed + tag; + else + tag = C.cYellow + tag; + + return tag; + } + + public boolean damage(double damage, Player player) + { + if (!Vulnerable) + return false; + + Double newHealth = Math.max(_health - damage, 0); + + if (newHealth == 0) + { + kill(player); + return true; + } + + _health = newHealth; + if (player != null) + Recharge.Instance.use(player, "Damage TeamTower", UtilTime.convert(1, TimeUnit.SECONDS, TimeUnit.MILLISECONDS), false, false); + return false; + } + + public Location getLocation() + { + return _spawn; + } + + public GameTeam getTeam() + { + return _team; + } + + public void update() + { + _healthTag.setText(formatHealth(_health)); + + if (Alive) + { + if (_entity.isDead() || !_entity.isValid()) + { + _entity = (EnderCrystal) _host.getArcadeManager().GetCreature().SpawnEntity(_spawn, EntityType.ENDER_CRYSTAL); + } + + if (_health > _maxHealth) + { + _health = _maxHealth; + } + } + } + + public void setMaxHealth(Double health) + { + _maxHealth = Math.abs(health); + } + + public void setVulnerable(boolean vulnerable) + { + if (vulnerable) + { + getBeacon().getBlock().setType(Material.BEACON); + Vulnerable = vulnerable; + } + else + { + getBeacon().getBlock().setType(Material.BEDROCK); + Vulnerable = vulnerable; + } + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java new file mode 100644 index 000000000..d4927f767 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java @@ -0,0 +1,181 @@ +package nautilus.game.arcade.game.games.minecraftleague.data; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; + +import mineplex.core.common.util.UtilTextMiddle; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.minecraftleague.DataLoc; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; +import nautilus.game.arcade.world.WorldData; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.event.Listener; + +public class TowerManager implements Listener +{ + public MinecraftLeague Host; + private ConcurrentHashMap _towers = new ConcurrentHashMap(); + private ConcurrentHashMap _vulnerableTower = new ConcurrentHashMap(); + private ConcurrentHashMap _def = new ConcurrentHashMap(); + private OreGenerator _ore; + + public TowerManager(MinecraftLeague host) + { + Host = host; + _ore = new OreGenerator(); + } + + private void makeVulnerable(TeamTowerBase base) + { + if (base instanceof TeamTower) + _vulnerableTower.put(base.getTeam(), ((TeamTower)base).Number); + else + _vulnerableTower.put(base.getTeam(), 3); + + base.setVulnerable(true);; + } + + private void oreGen(GameTeam team) + { + if (team.GetColor() == ChatColor.RED) + _ore.generateOre(Material.IRON_ORE, Host.WorldData.GetCustomLocs(DataLoc.RED_ORE.getKey()), 150); + else + _ore.generateOre(Material.IRON_ORE, Host.WorldData.GetCustomLocs(DataLoc.BLUE_ORE.getKey()), 150); + } + + private List getAllTeamTowers(GameTeam team) + { + List ret = new ArrayList(); + + for (TeamTowerBase tower : _towers.keySet()) + { + if (_towers.get(tower).GetColor() == team.GetColor()) + { + ret.add(tower); + } + } + + return ret; + } + + public LinkedList getTeamTowers(GameTeam team) + { + LinkedList ret = new LinkedList(); + TeamTower one = null; + TeamTower two = null; + TeamCrystal three = null; + + for (TeamTowerBase tower : getAllTeamTowers(team)) + { + if (tower instanceof TeamCrystal) + { + three = (TeamCrystal) tower; + continue; + } + if (one == null) + { + one = (TeamTower) tower; + continue; + } + if (one.Number > ((TeamTower)tower).Number) + { + two = one; + one = (TeamTower) tower; + continue; + } + two = (TeamTower) tower; + } + + ret.add(one); + ret.add(two); + ret.add(three); + + return ret; + } + + public Integer getAmountAlive(GameTeam team) + { + int i = 0; + + for (TeamTowerBase tower : getAllTeamTowers(team)) + { + if (tower.Alive) + i++; + } + + return i; + } + + public TeamTowerBase getVulnerable(GameTeam team) + { + return getTeamTowers(team).get(_vulnerableTower.get(team) - 1); + } + + public void parseTowers(WorldData data) + { + GameTeam red = Host.GetTeam(ChatColor.RED); + GameTeam blue = Host.GetTeam(ChatColor.AQUA); + + _towers.put(new TeamTower(Host, this, red, data.GetCustomLocs(DataLoc.RED_TOWER.getKey() + " 1").get(0), 1), red); + _towers.put(new TeamTower(Host, this, red, data.GetCustomLocs(DataLoc.RED_TOWER.getKey() + " 2").get(0), 2), red); + _towers.put(new TeamCrystal(Host, this, red, data.GetCustomLocs(DataLoc.RED_CRYSTAL.getKey()).get(0)), red); + + _towers.put(new TeamTower(Host, this, blue, data.GetCustomLocs(DataLoc.BLUE_TOWER.getKey() + " 1").get(0), 1), blue); + _towers.put(new TeamTower(Host, this, blue, data.GetCustomLocs(DataLoc.BLUE_TOWER.getKey() + " 2").get(0), 2), blue); + _towers.put(new TeamCrystal(Host, this, blue, data.GetCustomLocs(DataLoc.BLUE_CRYSTAL.getKey()).get(0)), blue); + + for (TeamTowerBase tower : _towers.keySet()) + { + _def.put(tower, new DefenderAI(this, tower)); + } + + makeVulnerable(getTeamTowers(red).getFirst()); + makeVulnerable(getTeamTowers(blue).getFirst()); + oreGen(red); + oreGen(blue); + } + + public void prepareHealth(int players, double multiplier) + { + for (TeamTowerBase tower : _towers.keySet()) + { + if (tower instanceof TeamCrystal) + tower.setMaxHealth(players * multiplier); + else + tower.setMaxHealth((double)((int)((2/3)*multiplier)) * players); + } + } + + public void handleTowerDeath(TeamTowerBase towerBase) + { + towerBase.setVulnerable(false); + if (towerBase instanceof TeamCrystal) + { + oreGen(towerBase.getTeam()); + Bukkit.getScheduler().runTaskLater(Host.Manager.getPlugin(), new Runnable() + { + public void run() + { + UtilTextMiddle.display("", towerBase.getTeam().GetColor() + towerBase.getTeam().GetName() + " Team ores have been replenished!"); + } + }, 20 * 5); + return; + } + TeamTower tower = (TeamTower)towerBase; + makeVulnerable(getTeamTowers(tower.getTeam()).get(tower.Number)); + } + + public void update() + { + for (TeamTowerBase tower : _towers.keySet()) + { + tower.update(); + _def.get(tower).update(); + } + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationManager.java index d56239954..2b7a4630b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationManager.java @@ -4,6 +4,7 @@ import java.lang.reflect.InvocationTargetException; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.minecraftleague.DataLoc; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; import org.bukkit.Bukkit; @@ -27,12 +28,12 @@ public class VariationManager implements Listener public void selectVariation() { - VariationType type = VariationType.getFromID(_host.getMapVariantID()); - - if (type.getVariation() == null) + VariationType type = null; + if (_host.getMapVariantIDS().size() != 1) + type = VariationType.STANDARD; + else { - Bukkit.broadcastMessage(type.getDisplayMessage()); - return; + type = VariationType.getFromID(_host.getMapVariantIDS().get(0).replace(DataLoc.VARIANT_BASE.getKey(), "")); } try diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationType.java index 9a03fb724..de1124d99 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationType.java @@ -6,17 +6,17 @@ import org.bukkit.ChatColor; public enum VariationType { - STANDARD(1, StandardGameplay.class, "Standard Gameplay", ChatColor.GREEN), - WITHER(2, WitherVariation.class, "Wither Variation", ChatColor.RED), + STANDARD("STANDARD", StandardGameplay.class, "Standard Gameplay", ChatColor.GREEN), + WITHER("WITHER", WitherVariation.class, "Wither Variation", ChatColor.RED), //GUARDIAN(3, GuardianVariation.class, "Guardian Variation", ChatColor.DARK_AQUA) ; - private int _id; + private String _id; private String _name; private ChatColor _color; private Class _variation; - private VariationType(int id, Class variationClass, String displayName, ChatColor displayColor) + private VariationType(String id, Class variationClass, String displayName, ChatColor displayColor) { _id = id; _name = displayName; @@ -34,11 +34,11 @@ public enum VariationType return ChatColor.DARK_AQUA + "Game Type Selected: " + _color + _name; } - public static VariationType getFromID(int id) + public static VariationType getFromID(String id) { for (VariationType type : VariationType.values()) { - if (type._id == id) + if (type._id.equalsIgnoreCase(id)) return type; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java index 7e2f0482c..c9c0eaab3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java @@ -16,7 +16,7 @@ import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.minecraftleague.DataLoc; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; -import nautilus.game.arcade.game.games.minecraftleague.data.TeamCrystal; +import nautilus.game.arcade.game.games.minecraftleague.data.TeamTowerBase; import nautilus.game.arcade.game.games.minecraftleague.variation.GameVariation; import nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.TeamAltar; import nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.WitherMinionManager; @@ -170,7 +170,7 @@ public class WitherVariation extends GameVariation } if (_altars.get(team).ownsWither(event)) { - if (!Host.getCrystal(enemy).Alive) + if (Host.getTowerManager().getAmountAlive(enemy) < 1) { event.setCancelled(true); return; @@ -181,7 +181,7 @@ public class WitherVariation extends GameVariation _wither.setCustomName(team.GetColor() + team.getDisplayName() + "'s Wither"); _wither.setCustomNameVisible(true); UtilTextMiddle.display("", team.GetColor() + team.getDisplayName() + " Team has spawned a Wither Boss!", UtilServer.getPlayers()); - _pathfinder = new WitherPathfinder(this, _wither, getWaypoints(_altars.get(team).getLocation()), team, Host.getCrystal(enemy).getEntity()); + _pathfinder = new WitherPathfinder(this, _wither, getWaypoints(_altars.get(team).getLocation()), team, enemy, Host.getTowerManager()); _skellyMan.onWitherSpawn(); Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() { @@ -229,18 +229,18 @@ public class WitherVariation extends GameVariation { event.setCancelled(true); - TeamCrystal red = Host.getCrystal(Host.GetTeam(ChatColor.RED)); - TeamCrystal blue = Host.getCrystal(Host.GetTeam(ChatColor.AQUA)); + TeamTowerBase red = Host.getActiveTower(Host.GetTeam(ChatColor.RED)); + TeamTowerBase blue = Host.getActiveTower(Host.GetTeam(ChatColor.AQUA)); HashMap inside = UtilBlock.getInRadius(event.getLocation().getBlock(), 4, false); - double dmg = 5 * Host.GetTeam(ChatColor.RED).GetPlayers(true).size(); + double dmg = 5 * (Host.GetTeam(ChatColor.RED).GetPlayers(true).size() + Host.GetTeam(ChatColor.RED).GetPlayers(true).size()); if (inside.containsKey(red.getLocation().getBlock())) { - red.damage(dmg, null, true); + red.damage(dmg, null); } if (inside.containsKey(blue.getLocation().getBlock())) { - blue.damage(dmg, null, true); + blue.damage(dmg, null); } for (Block b : inside.keySet()) { @@ -254,7 +254,7 @@ public class WitherVariation extends GameVariation } for (GameTeam owner : Host.GetTeamList()) { - if (Host.getCrystal(owner).getLocation().distance(b.getLocation()) < 7) + if (Host.getActiveTower(owner).getLocation().distance(b.getLocation()) < 7) { if (b.getType() == Material.BEDROCK) continue; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java index 708c336c5..68fe40d4d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java @@ -24,36 +24,36 @@ public class TeamAltar private WitherVariation _host; private GameTeam _team; private Location _center; - + private List _protected; - + private Location[] _skullSpots; - + private int _placed; - + public TeamAltar(WitherVariation host, GameTeam team, Location center) { _host = host; _team = team; _center = center; - + spawnSoulsand(); - + _protected = UtilShapes.getSphereBlocks(center, 7, 7, false); } - + public boolean isInsideAltar(Location location) { return _protected.contains(location); } - + public void spawnSoulsand() { _placed = 0; Location s1 = null; Location s2 = null; Location s3 = null; - + for (int i = -1; i <= 1; i++) { _center.getBlock().getRelative(i, 1, 0).setType(Material.SOUL_SAND); @@ -65,10 +65,10 @@ public class TeamAltar s3 = _center.getBlock().getRelative(i, 2, 0).getLocation(); } _center.getBlock().setType(Material.SOUL_SAND); - + _skullSpots = new Location[] {s1, s2, s3}; } - + public boolean canBreak(Player player, Block block, boolean notify) { if (isInsideAltar(block.getLocation())) @@ -91,87 +91,81 @@ public class TeamAltar } return true; } - + public boolean canPlace(Player player, Material blockType, Location location, boolean notify) { - boolean should = false; if (isInsideAltar(location)) { - should = true; if (!_team.HasPlayer(player)) { if (notify) UtilPlayer.message(player, F.main("Game", "This is not your Altar!")); return false; } - + if (_host.WitherSpawned) { if (notify) UtilPlayer.message(player, F.main("Game", "A Wither is already spawned!")); - should = false; return false; } - + if (blockType != Material.SKULL) { if (notify) UtilPlayer.message(player, F.main("Game", "You cannot place that inside an Altar!")); return false; } - + boolean passes = false; for (Location l : _skullSpots) { if (l.equals(location)) passes = true; } - + if (!passes) { if (notify) UtilPlayer.message(player, F.main("Game", "That doesn't go there!")); - should = false; return false; } - + if (_team.GetColor() == ChatColor.RED) { - if (!_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.AQUA)).Alive) + if (_host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.AQUA)) < 1) { if (notify) UtilPlayer.message(player, F.main("Game", "You do not need a Wither!")); - should = false; return false; } } - if (_team.GetColor() == ChatColor.RED) + if (_team.GetColor() == ChatColor.AQUA) { - if (!_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.AQUA)).Alive) + if (_host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.RED)) < 1) { if (notify) UtilPlayer.message(player, F.main("Game", "You do not need a Wither!")); - should = false; return false; } } - } - - if (_team.HasPlayer(player) && blockType == Material.SKULL && should) - { - if (_placed < 2) + + if (_team.HasPlayer(player) && blockType == Material.SKULL) { - UtilTextMiddle.display("", _team.GetColor() + _team.getDisplayName() + " has placed a Skull on their Altar!"); - for (Player scare : UtilServer.getPlayers()) + if (_placed < 2) { - scare.playSound(scare.getLocation(), Sound.WITHER_SPAWN, 10, 0); + UtilTextMiddle.display("", _team.GetColor() + _team.getDisplayName() + " has placed a Skull on their Altar!"); + for (Player scare : UtilServer.getPlayers()) + { + scare.playSound(scare.getLocation(), Sound.WITHER_SPAWN, 10, 0); + } } + _placed++; } - _placed++; } return true; } - + public boolean ownsWither(EntitySpawnEvent event) { if (event.getEntity() instanceof Wither) @@ -179,10 +173,10 @@ public class TeamAltar Location base = event.getLocation(); return (isInsideAltar(base.getBlock().getLocation())); } - + return false; } - + public Location getLocation() { return _center.clone(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java index e3f2f50df..5916a366a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java @@ -187,8 +187,8 @@ public class WitherMinionManager implements Listener if (UtilTime.elapsed(_lastDied, UtilTime.convert(45, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) { - boolean noUse = (!_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.RED)).Alive); - if (_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.AQUA)).Alive) + boolean noUse = _host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.RED)) < 1; + if (_host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.AQUA)) >= 1) noUse = false; if (!_host.WitherSpawned || noUse) { @@ -200,8 +200,8 @@ public class WitherMinionManager implements Listener if (UtilTime.elapsed(_lastDied, UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS))) { - boolean noUse = (!_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.RED)).Alive); - if (_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.AQUA)).Alive) + boolean noUse = _host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.RED)) < 1; + if (_host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.AQUA)) >= 1) noUse = false; if (!_host.WitherSpawned || noUse) { @@ -232,8 +232,8 @@ public class WitherMinionManager implements Listener if (event.getType() != UpdateType.FASTEST) return; - boolean noUse = (!_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.RED)).Alive); - if (_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.AQUA)).Alive) + boolean noUse = _host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.RED)) < 1; + if (_host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.AQUA)) >= 1) noUse = false; if (_entity != null || noUse) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java index 970271347..f5e41c2e0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java @@ -8,10 +8,13 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.minecraftleague.DataLoc; +import nautilus.game.arcade.game.games.minecraftleague.data.TeamTower; +import nautilus.game.arcade.game.games.minecraftleague.data.TowerManager; import nautilus.game.arcade.game.games.minecraftleague.variation.wither.WitherVariation; +import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.entity.Arrow; import org.bukkit.entity.Entity; @@ -28,20 +31,23 @@ public class WitherPathfinder private Wither _ent; private LinkedList _waypoints; private GameTeam _team; - private Entity _enemy; + private GameTeam _enemy; + private TowerManager _towerManager; private long _lastAttack; + private long _lastTowerAttack; - private boolean _finishedJourney = false; private boolean _startedJourney = false; - public WitherPathfinder(WitherVariation host, Wither ent, LinkedList waypoints, GameTeam team, Entity enemy) + public WitherPathfinder(WitherVariation host, Wither ent, LinkedList waypoints, GameTeam team, GameTeam enemy, TowerManager towerManager) { _host = host; _ent = ent; _waypoints = waypoints; _team = team; _enemy = enemy; + _towerManager = towerManager; _lastAttack = -1; + _lastTowerAttack = -1; _pathData = new PathfinderData(ent, waypoints.getFirst()); } @@ -99,18 +105,17 @@ public class WitherPathfinder } if (target != null) - shootAt(target.getLocation()); + { + if (UtilTime.elapsed(_lastAttack, 2)) + { + _lastAttack = System.currentTimeMillis(); + shootAt(target.getLocation()); + } + } } private void shootAt(Location loc) { - int sec = 2; - if (_finishedJourney) - sec = 5; - - if (!UtilTime.elapsed(_lastAttack, UtilTime.convert(sec, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) - return; - Location old = _ent.getLocation(); Location temp = _ent.getLocation(); temp.setPitch(UtilAlg.GetPitch(UtilAlg.getTrajectory(_ent.getEyeLocation(), loc))); @@ -121,7 +126,6 @@ public class WitherPathfinder _ent.removeMetadata("Shooting", _host.Manager.getPlugin()); _ent.teleport(old); //skull.setDirection(UtilAlg.getTrajectory(_ent.getLocation(), loc).normalize()); - _lastAttack = System.currentTimeMillis(); } /** @@ -132,7 +136,8 @@ public class WitherPathfinder if ((_ent == null) || _ent.isDead() || !_ent.isValid()) return true; - if (!_enemy.isValid() || _enemy.isDead() || _enemy == null) + Entity eTower = _towerManager.getVulnerable(_enemy).getEntity(); + if (eTower == null || !eTower.isValid() || eTower.isDead()) { _ent.remove(); return true; @@ -161,15 +166,28 @@ public class WitherPathfinder } } - if (_ent.getLocation().distance(_enemy.getLocation()) <= 10 || _finishedJourney) + if (_ent.getLocation().distance(eTower.getLocation()) <= 10) { - _finishedJourney = true; _ent.setTarget(null); - Location finalize = _waypoints.getLast(); - finalize.setPitch(UtilAlg.GetPitch(UtilAlg.getTrajectory(_ent, _enemy))); - finalize.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(_ent, _enemy))); + String tName = ""; + if (_team.GetColor() == ChatColor.RED) + tName = "RED"; + if (_team.GetColor() == ChatColor.AQUA) + tName = "BLUE"; + Integer cNumber = -1; + if (_towerManager.getVulnerable(_enemy) instanceof TeamTower) + cNumber = ((TeamTower)_towerManager.getVulnerable(_enemy)).Number; + else + cNumber = 3; + Location finalize = _host.Host.WorldData.GetCustomLocs(DataLoc.TOWER_WAYPOINT.getKey().replace("$team$", tName).replace("$number$", cNumber + "")).get(0); + finalize.setPitch(UtilAlg.GetPitch(UtilAlg.getTrajectory(_ent, eTower))); + finalize.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(_ent, eTower))); _ent.teleport(finalize); - shootAt(_enemy.getLocation()); + if (UtilTime.elapsed(_lastTowerAttack, 5)) + { + _lastTowerAttack = System.currentTimeMillis(); + shootAt(eTower.getLocation()); + } return false; } From 6678dffb61edd65a68c72610066b5f939965e695 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 25 Mar 2016 20:25:43 -0400 Subject: [PATCH 27/47] - Updated everything for Sigils and chiss --- .../mineplex/core/message/MessageManager.java | 2 +- .../game/games/minecraftleague/DataLoc.java | 10 +- .../minecraftleague/MinecraftLeague.java | 170 +++++++++++++----- .../commands/DamageCommand.java | 70 -------- .../minecraftleague/commands/KillCommand.java | 59 ------ .../commands/MinecraftLeagueCommand.java | 6 - .../commands/SpawnCommand.java | 59 ------ .../commands/StatusCommand.java | 3 +- .../commands/panel/AdminPanel.java | 33 +--- .../data/{OreDeposit.java => MapZone.java} | 29 +-- .../minecraftleague/data/OreGenerator.java | 30 ++-- .../minecraftleague/data/TeamTowerBase.java | 16 +- .../minecraftleague/data/TowerAlert.java | 49 +++++ .../minecraftleague/data/TowerManager.java | 37 ++-- .../data/map/ItemMapRenderer.java | 8 +- .../variation/wither/WitherVariation.java | 2 + .../wither/data/WitherMinionManager.java | 29 ++- .../wither/data/WitherPathfinder.java | 14 +- .../wither/data/WitherSkeletonTimer.java | 5 +- 19 files changed, 298 insertions(+), 333 deletions(-) delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/DamageCommand.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/KillCommand.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/SpawnCommand.java rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/{OreDeposit.java => MapZone.java} (78%) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerAlert.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java index 10b0c9707..76fc7dbca 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java @@ -217,7 +217,7 @@ public class MessageManager extends MiniClientPlugin Get(from).LastToTime = System.currentTimeMillis(); // Chiss or defek7 - if (to.getName().equals("Chiss") || to.getName().equals("defek7") || to.getName().equals("Phinary") || to.getName().equals("fooify") || to.getName().equals("sampepere")) + if (to.getName().equals("Chiss") || to.getName().equals("defek7") || to.getName().equals("Phinary") || to.getName().equals("AlexTheCoder")) { UtilPlayer.message(from, C.cPurple + to.getName() + " is often AFK or minimized, due to plugin development."); UtilPlayer.message(from, C.cPurple + "Please be patient if he does not reply instantly."); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/DataLoc.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/DataLoc.java index 3eb439b3e..2993c618c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/DataLoc.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/DataLoc.java @@ -3,10 +3,10 @@ package nautilus.game.arcade.game.games.minecraftleague; public enum DataLoc { //Base - RED_CRYSTAL("RED CRYSTAL"), - RED_TOWER("RED TOWER"), - BLUE_CRYSTAL("BLUE CRYSTAL"), - BLUE_TOWER("BLUE TOWER"), + RED_CRYSTAL(" RED CRYSTAL"), + RED_TOWER(" RED TOWER"), + BLUE_CRYSTAL(" BLUE CRYSTAL"), + BLUE_TOWER(" BLUE TOWER"), VARIANT_BASE("GAMEMODE "), //RED_BEACON("PINK"), /*BLUE_*/BEACON("CYAN"), @@ -18,7 +18,7 @@ public enum DataLoc //Wither WITHER_WAYPOINT("PURPLE"), - TOWER_WAYPOINT("$team$ TOWER $number$"), + TOWER_WAYPOINT(" $team$ WITHER $number$"), WITHER_SKELETON("BLACK"), BLUE_ALTAR("LIME"), RED_ALTAR("YELLOW") diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index 172ea19bd..3600d1c30 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -7,7 +7,6 @@ import java.util.concurrent.ConcurrentHashMap; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilItem; @@ -32,11 +31,11 @@ import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.minecraftleague.commands.MinecraftLeagueCommand; import nautilus.game.arcade.game.games.minecraftleague.commands.freeze.FreezeManager; import nautilus.game.arcade.game.games.minecraftleague.data.BlockProtection; -import nautilus.game.arcade.game.games.minecraftleague.data.OreDeposit; -import nautilus.game.arcade.game.games.minecraftleague.data.PlayerRespawnPoint; +import nautilus.game.arcade.game.games.minecraftleague.data.MapZone; import nautilus.game.arcade.game.games.minecraftleague.data.Spawner; -import nautilus.game.arcade.game.games.minecraftleague.data.TeamCrystal; +import nautilus.game.arcade.game.games.minecraftleague.data.TeamTower; import nautilus.game.arcade.game.games.minecraftleague.data.TeamTowerBase; +import nautilus.game.arcade.game.games.minecraftleague.data.TowerAlert; import nautilus.game.arcade.game.games.minecraftleague.data.TowerManager; import nautilus.game.arcade.game.games.minecraftleague.data.map.ItemMapManager; import nautilus.game.arcade.game.games.minecraftleague.kit.KitPlayer; @@ -55,11 +54,9 @@ import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Arrow; -import org.bukkit.entity.CreatureType; import org.bukkit.entity.Enderman; import org.bukkit.entity.EntityType; import org.bukkit.entity.ItemFrame; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; @@ -95,12 +92,12 @@ import com.google.common.base.Objects; public class MinecraftLeague extends TeamGame { - private ConcurrentHashMap _customRespawns = new ConcurrentHashMap(); + //private ConcurrentHashMap _customRespawns = new ConcurrentHashMap(); //private ConcurrentHashMap _maps = new ConcurrentHashMap(); private ConcurrentHashMap> _gear = new ConcurrentHashMap>(); //private ConcurrentHashMap _beacons = new ConcurrentHashMap(); private ConcurrentHashMap _blockLock = new ConcurrentHashMap(); - private ConcurrentHashMap _spawnAllow = new ConcurrentHashMap(); + //private ConcurrentHashMap _spawnAllow = new ConcurrentHashMap(); private List _spawners = new ArrayList(); public ConcurrentHashMap ExtraSb = new ConcurrentHashMap(); @@ -110,15 +107,16 @@ public class MinecraftLeague extends TeamGame private long _lastIncrease; private boolean _yellow = false; - public List Ore = new ArrayList(); + public List MapZones = new ArrayList(); public ItemMapManager MapManager; public boolean OverTime = false; private VariationManager _vman; private FreezeManager _freeze; private TowerManager _tower; + public TowerAlert Alert; - private final CreatureType[] _passive = new CreatureType[] {CreatureType.CHICKEN, CreatureType.COW, CreatureType.PIG, CreatureType.RABBIT, CreatureType.SHEEP}; + private final EntityType[] _passive = new EntityType[] {EntityType.CHICKEN, EntityType.COW, EntityType.PIG, EntityType.RABBIT, EntityType.SHEEP}; public MinecraftLeague(ArcadeManager manager) { @@ -144,6 +142,7 @@ public class MinecraftLeague extends TeamGame this.WorldBoundaryKill = false; this.DeathDropItems = true; this.CreatureAllow = true; + this.HungerSet = 20; this.BlockBreak = true; this.BlockPlace = true; @@ -171,7 +170,7 @@ public class MinecraftLeague extends TeamGame { "Respawn Crystals have 100 health per person in-game!", "The better the sword you have, the more damage you deal to Respawn Crystals!", - "Right-click a bed in order to change your personal spawn location!", + //"Right-click a bed in order to change your personal spawn location!", "Your map will display the locations of your enemies in OverTime!" }; @@ -183,6 +182,7 @@ public class MinecraftLeague extends TeamGame _vman = new VariationManager(this); _freeze = new FreezeManager(); _tower = new TowerManager(this); + Alert = new TowerAlert(); Bukkit.getPluginManager().registerEvents(_freeze, manager.getPlugin()); } @@ -359,7 +359,7 @@ public class MinecraftLeague extends TeamGame if (getPickLevel(item) > level) { ret = item; - level = getSwordLevel(item); + level = getPickLevel(item); } } } @@ -467,8 +467,26 @@ public class MinecraftLeague extends TeamGame GameTeam red = GetTeam(ChatColor.RED); GameTeam blue = GetTeam(ChatColor.AQUA); - TeamCrystal redc = (TeamCrystal) _tower.getTeamTowers(red).getLast(); - TeamCrystal bluec = (TeamCrystal) _tower.getTeamTowers(blue).getLast(); + TeamTowerBase redt = _tower.getVulnerable(red); + TeamTowerBase bluet = _tower.getVulnerable(blue); + String reds = "First Tower"; + String blues = "First Tower"; + + if (redt instanceof TeamTower) + { + if (((TeamTower)redt).Number > 1) + reds = "Second Tower"; + } + else + reds = "Core"; + + if (bluet instanceof TeamTower) + { + if (((TeamTower)bluet).Number > 1) + reds = "Second Tower"; + } + else + blues = "Core"; _liveTime = Math.max(System.currentTimeMillis() - GetStateTime(), 0); @@ -482,12 +500,12 @@ public class MinecraftLeague extends TeamGame Scoreboard.WriteBlank(); Scoreboard.Write(C.cRedB + "Red Team"); - Scoreboard.Write("Crystal: " + redc.formatHealth(redc.getHealth())); + Scoreboard.Write(reds + ": " + redt.formatHealth(redt.getHealth())); Scoreboard.Write("Players Alive: " + red.GetPlayers(true).size()); Scoreboard.WriteBlank(); Scoreboard.Write(C.cAquaB + "Blue Team"); - Scoreboard.Write("Crystal: " + bluec.formatHealth(bluec.getHealth())); + Scoreboard.Write(blues + ": " + bluet.formatHealth(bluet.getHealth())); Scoreboard.Write("Players Alive: " + blue.GetPlayers(true).size()); int i = 1; @@ -503,7 +521,7 @@ public class MinecraftLeague extends TeamGame Scoreboard.Draw(); } - @Override + /*@Override public void RespawnPlayerTeleport(Player player) { if (_customRespawns.containsKey(player)) @@ -516,7 +534,7 @@ public class MinecraftLeague extends TeamGame } player.teleport(GetTeam(player).GetSpawn()); - } + }*/ public boolean handleCommand(Player caller) { @@ -609,10 +627,10 @@ public class MinecraftLeague extends TeamGame if (event.getType() == UpdateType.SEC) { - for (OreDeposit od : Ore) + /*for (MapZone od : Ore) { od.update(); - } + }*/ for (Player player : GetTeam(ChatColor.RED).GetPlayers(true)) { @@ -640,13 +658,13 @@ public class MinecraftLeague extends TeamGame } } - if (event.getType() == UpdateType.FASTER) + /*if (event.getType() == UpdateType.FASTER) { for (GameTeam team : _teamList) { for (Location loc : team.GetSpawns()) { - for (LivingEntity near : UtilEnt.getInRadius(loc, 5).keySet()) + for (LivingEntity near : UtilEnt.getInRadius(loc, 2).keySet()) { if (!(near instanceof Player)) continue; @@ -674,7 +692,7 @@ public class MinecraftLeague extends TeamGame } } } - } + }*/ if (event.getType() == UpdateType.FASTEST) { @@ -695,6 +713,8 @@ public class MinecraftLeague extends TeamGame beacon.update(); }*/ + Alert.update(); + if (!OverTime) { if (UtilTime.elapsed(GetStateTime(), UtilTime.convert(15, TimeUnit.MINUTES, TimeUnit.MILLISECONDS))) @@ -710,13 +730,13 @@ public class MinecraftLeague extends TeamGame this.DeathSpectateSecs = Math.max(0, this.DeathSpectateSecs + 2.5); } - for (Player player : _spawnAllow.keySet()) + /*for (Player player : _spawnAllow.keySet()) { - if (UtilTime.elapsed(_spawnAllow.get(player), UtilTime.convert(30, TimeUnit.SECONDS, TimeUnit.MINUTES))) + if (UtilTime.elapsed(_spawnAllow.get(player), UtilTime.convert(30, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) { _spawnAllow.remove(player); } - } + }*/ for (Player player : _blockLock.keySet()) { @@ -769,7 +789,9 @@ public class MinecraftLeague extends TeamGame for (GameTeam team : GetTeamList()) for (TeamTowerBase tow : _tower.getTeamTowers(team)) { - if (tower.isEntity(event.getEntity())) + if (tow == null) + continue; + if (tow.isEntity(event.getEntity())) tower = tow; } @@ -798,7 +820,10 @@ public class MinecraftLeague extends TeamGame } if (!tower.damage(event.getDamage() / 2, player)) + { player.playSound(tower.getLocation(), Sound.ORB_PICKUP, 100, 0); + Alert.alert(tower.getTeam(), tower); + } } } } @@ -818,7 +843,10 @@ public class MinecraftLeague extends TeamGame if (player.getItemInHand() == null || player.getItemInHand().getType() == Material.AIR) { if (!tower.damage(1, player)) + { player.playSound(tower.getLocation(), Sound.ZOMBIE_WOODBREAK, 1, 0); + Alert.alert(tower.getTeam(), tower); + } return; } @@ -827,7 +855,10 @@ public class MinecraftLeague extends TeamGame double damage = DamageAmount.getDamageAmount(type).getDamage(level, DamageType.getDamageType(type)); if (!tower.damage(damage, player)) + { player.playSound(tower.getLocation(), Sound.ZOMBIE_WOODBREAK, 1, 0); + Alert.alert(tower.getTeam(), tower); + } if (DamageAmount.getDamageAmount(type) != DamageAmount.NONE) { @@ -842,7 +873,7 @@ public class MinecraftLeague extends TeamGame } } - @EventHandler + /*@EventHandler public void placeBed(PlayerInteractEvent event) { if (!IsLive()) @@ -864,7 +895,7 @@ public class MinecraftLeague extends TeamGame _customRespawns.get(player).overWrite(event.getClickedBlock().getLocation()); else _customRespawns.put(player, new PlayerRespawnPoint(player, event.getClickedBlock().getLocation())); - } + }*/ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void lockBlock(BlockPlaceEvent event) @@ -925,7 +956,7 @@ public class MinecraftLeague extends TeamGame } } - @EventHandler + /*@EventHandler public void breakBed(BlockBreakEvent event) { if (!IsLive()) @@ -941,7 +972,7 @@ public class MinecraftLeague extends TeamGame if (point.breakBed(event.getBlock())) _customRespawns.remove(player); } - } + }*/ @EventHandler public void onRespawn(PlayerGameRespawnEvent event) @@ -952,7 +983,7 @@ public class MinecraftLeague extends TeamGame Player player = event.GetPlayer(); player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 5 * 20, 3)); - _spawnAllow.put(player, System.currentTimeMillis()); + //_spawnAllow.put(player, System.currentTimeMillis()); /*if (!_crystals.get(GetTeam(player)).Alive) { @@ -1138,7 +1169,6 @@ public class MinecraftLeague extends TeamGame event.setCancelled(true); } - @SuppressWarnings("deprecation") @EventHandler public void controlMobRate(CreatureSpawnEvent event) { @@ -1156,14 +1186,18 @@ public class MinecraftLeague extends TeamGame EntityType et = event.getEntityType(); - for (CreatureType pass : _passive) + for (EntityType pass : _passive) { - if (pass == event.getCreatureType()) + if (pass == event.getEntityType()) et = EntityType.CHICKEN; } + if (et == EntityType.ZOMBIE || et == EntityType.SKELETON || et == EntityType.CREEPER) + et = EntityType.SPIDER; + + event.setCancelled(true); Manager.GetCreature().SpawnEntity(event.getLocation(), et); - if (event.getCreatureType() == CreatureType.SPIDER) + if (et == EntityType.SPIDER || et == EntityType.CHICKEN) { for (int i = 1; i <= 3; i++) Manager.GetCreature().SpawnEntity(event.getLocation(), EntityType.SPIDER); @@ -1179,7 +1213,7 @@ public class MinecraftLeague extends TeamGame if (event.GetGame() != this) return; - int playercount = GetTeam(ChatColor.RED).GetPlayers(true).size() + GetTeam(ChatColor.AQUA).GetPlayers(true).size(); + int playercount = GetTeam(ChatColor.RED).GetPlayers(false).size() + GetTeam(ChatColor.AQUA).GetPlayers(false).size(); _tower.prepareHealth(playercount, 50 * 2); } @@ -1218,18 +1252,24 @@ public class MinecraftLeague extends TeamGame { if (event.GetGame() != this) return; - if (event.GetState() != GameState.Live) + if (!(event.GetState() == GameState.Live || event.GetState() == GameState.Prepare)) return; + if (event.GetState() == GameState.Prepare) + { + /*for (Player player : Bukkit.getOnlinePlayers()) + _spawnAllow.put(player, System.currentTimeMillis());*/ + return; + } for (Player player : GetTeam(ChatColor.AQUA).GetPlayers(true)) { player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setColor(Color.BLUE).build()); player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(Color.BLUE).build()); player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(Color.BLUE).build()); player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.BLUE).build()); - player.getInventory().addItem(new ItemStack(Material.WOOD_SWORD)); - player.getInventory().addItem(new ItemStack(Material.WOOD_PICKAXE)); - player.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 5)); + player.getInventory().addItem(new ItemStack(Material.STONE_SWORD)); + player.getInventory().addItem(new ItemStack(Material.STONE_PICKAXE)); + //player.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 5)); _blockLock.put(player, new BlockProtection(this, player)); } for (Player player : GetTeam(ChatColor.RED).GetPlayers(true)) @@ -1238,9 +1278,9 @@ public class MinecraftLeague extends TeamGame player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(Color.RED).build()); player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(Color.RED).build()); player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.RED).build()); - player.getInventory().addItem(new ItemStack(Material.WOOD_SWORD)); - player.getInventory().addItem(new ItemStack(Material.WOOD_PICKAXE)); - player.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 5)); + player.getInventory().addItem(new ItemStack(Material.STONE_SWORD)); + player.getInventory().addItem(new ItemStack(Material.STONE_PICKAXE)); + //player.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 5)); _blockLock.put(player, new BlockProtection(this, player)); } } @@ -1436,6 +1476,7 @@ public class MinecraftLeague extends TeamGame return; } } + //_spawnAllow.put(player, System.currentTimeMillis() + UtilTime.convert((long) this.DeathSpectateSecs, TimeUnit.SECONDS, TimeUnit.MILLISECONDS)); } @EventHandler @@ -1465,6 +1506,30 @@ public class MinecraftLeague extends TeamGame } } + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void handlePlace(BlockPlaceEvent event) + { + if (!IsLive()) + return; + + for (Location red : GetTeam(ChatColor.RED).GetSpawns()) + { + if (UtilMath.offset(red, event.getBlock().getLocation()) < 5) + { + event.setCancelled(true); + return; + } + } + for (Location blue : GetTeam(ChatColor.AQUA).GetSpawns()) + { + if (UtilMath.offset(blue, event.getBlock().getLocation()) < 5) + { + event.setCancelled(true); + return; + } + } + } + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void handleBreak(BlockBreakEvent event) { @@ -1477,6 +1542,23 @@ public class MinecraftLeague extends TeamGame return; } + for (Location red : GetTeam(ChatColor.RED).GetSpawns()) + { + if (UtilMath.offset(red, event.getBlock().getLocation()) < 5) + { + event.setCancelled(true); + return; + } + } + for (Location blue : GetTeam(ChatColor.AQUA).GetSpawns()) + { + if (UtilMath.offset(blue, event.getBlock().getLocation()) < 5) + { + event.setCancelled(true); + return; + } + } + if (event.getBlock().getType() == Material.GRAVEL) { event.setCancelled(true); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/DamageCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/DamageCommand.java deleted file mode 100644 index 2fdb67d3f..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/DamageCommand.java +++ /dev/null @@ -1,70 +0,0 @@ -package nautilus.game.arcade.game.games.minecraftleague.commands; - -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; -import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague.EditType; - -public class DamageCommand extends CommandBase -{ - private MinecraftLeague _host; - - public DamageCommand(ArcadeManager plugin, MinecraftLeague host) - { - super(plugin, Rank.DEVELOPER, new Rank[] {Rank.JNR_DEV}, "damage"); - _host = host; - } - - @Override - public void Execute(Player caller, String[] args) - { - if (args.length < 2) - { - UtilPlayer.message(caller, F.help("/mcLeague damage ", "Damages the red or blue Respawn Crystal for a specified amount", Rank.DEVELOPER)); - return; - } - - String team = args[0]; - - if (!team.equalsIgnoreCase("red") && !team.equalsIgnoreCase("blue")) - { - UtilPlayer.message(caller, F.help("/mcLeague damage ", "Damages the red or blue Respawn Crystal for a specified amount", Rank.DEVELOPER)); - return; - } - - Double damage; - try - { - damage = Double.parseDouble(args[1]); - } - catch (Exception e) - { - UtilPlayer.message(caller, F.help("/mcLeague damage ", "Damages the red or blue Respawn Crystal for a specified amount", Rank.DEVELOPER)); - return; - } - - if (team.equalsIgnoreCase("red")) - { - if (_host.handleCommand(EditType.DAMAGE, _host.GetTeam(ChatColor.RED), caller, damage)) - return; - UtilPlayer.message(caller, F.main(_host.GetName(), C.cRed + "That Crystal is dead!")); - return; - } - - if (team.equalsIgnoreCase("blue")) - { - if (_host.handleCommand(EditType.DAMAGE, _host.GetTeam(ChatColor.AQUA), caller, damage)) - return; - UtilPlayer.message(caller, F.main(_host.GetName(), C.cRed + "That Crystal is dead!")); - return; - } - } - -} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/KillCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/KillCommand.java deleted file mode 100644 index 3fabe167d..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/KillCommand.java +++ /dev/null @@ -1,59 +0,0 @@ -package nautilus.game.arcade.game.games.minecraftleague.commands; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; -import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague.EditType; - -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; - -public class KillCommand extends CommandBase -{ - private MinecraftLeague _host; - - public KillCommand(ArcadeManager plugin, MinecraftLeague host) - { - super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "kill"); - _host = host; - } - - @Override - public void Execute(Player caller, String[] args) - { - if (args.length < 1) - { - UtilPlayer.message(caller, F.help("/mcLeague kill ", "Kills the red or blue Respawn Crystal if spawned", Rank.ADMIN)); - return; - } - - String team = args[0]; - - if (!team.equalsIgnoreCase("red") && !team.equalsIgnoreCase("blue")) - { - UtilPlayer.message(caller, F.help("/mcLeague kill ", "Kills the red or blue Respawn Crystal if spawned", Rank.ADMIN)); - return; - } - - if (team.equalsIgnoreCase("red")) - { - if (_host.handleCommand(EditType.KILL, _host.GetTeam(ChatColor.RED), caller, null)) - return; - UtilPlayer.message(caller, F.main(_host.GetName(), C.cRed + "That Crystal is already killed!")); - return; - } - - if (team.equalsIgnoreCase("blue")) - { - if (_host.handleCommand(EditType.KILL, _host.GetTeam(ChatColor.AQUA), caller, null)) - return; - UtilPlayer.message(caller, F.main(_host.GetName(), C.cRed + "That Crystal is already spawned!")); - return; - } - } - -} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/MinecraftLeagueCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/MinecraftLeagueCommand.java index ebd532b83..4a054edf6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/MinecraftLeagueCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/MinecraftLeagueCommand.java @@ -20,9 +20,6 @@ public class MinecraftLeagueCommand extends MultiCommandBase super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "mcLeague"); AddCommand(new GUICommand(plugin, host)); AddCommand(new FreezeCommand(plugin, host)); - AddCommand(new SpawnCommand(plugin, host)); - AddCommand(new KillCommand(plugin, host)); - AddCommand(new DamageCommand(plugin, host)); AddCommand(new StatusCommand(plugin, host)); _host = host; } @@ -33,9 +30,6 @@ public class MinecraftLeagueCommand extends MultiCommandBase UtilPlayer.message(caller, F.main(_host.GetName(), "Commands List:")); UtilPlayer.message(caller, F.help("/mcLeague gui", "Opens a GUI for controlling Respawn Crystals", Rank.ADMIN)); UtilPlayer.message(caller, F.help("/mcLeague freeze ", "Freezes or unfreezes a player [for cheaters]", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/mcLeague spawn ", "Respawns the red or blue Respawn Crystal if killed", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/mcLeague kill ", "Kills the red or blue Respawn Crystal if spawned", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/mcLeague damage ", "Damages the red or blue Respawn Crystal for a specified amount", Rank.DEVELOPER)); UtilPlayer.message(caller, F.help("/mcLeague status", "Gets statistics about both Respawn Crystals", Rank.DEVELOPER)); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/SpawnCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/SpawnCommand.java deleted file mode 100644 index baa9faf97..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/SpawnCommand.java +++ /dev/null @@ -1,59 +0,0 @@ -package nautilus.game.arcade.game.games.minecraftleague.commands; - -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; -import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague.EditType; - -public class SpawnCommand extends CommandBase -{ - private MinecraftLeague _host; - - public SpawnCommand(ArcadeManager plugin, MinecraftLeague host) - { - super(plugin, Rank.ADMIN, new Rank[] {Rank.JNR_DEV}, "spawn"); - _host = host; - } - - @Override - public void Execute(Player caller, String[] args) - { - if (args.length < 1) - { - UtilPlayer.message(caller, F.help("/mcLeague spawn ", "Respawns the red or blue Respawn Crystal if killed", Rank.ADMIN)); - return; - } - - String team = args[0]; - - if (!team.equalsIgnoreCase("red") && !team.equalsIgnoreCase("blue")) - { - UtilPlayer.message(caller, F.help("/mcLeague spawn ", "Respawns the red or blue Respawn Crystal if killed", Rank.ADMIN)); - return; - } - - if (team.equalsIgnoreCase("red")) - { - if (_host.handleCommand(EditType.SPAWN, _host.GetTeam(ChatColor.RED), caller, null)) - return; - UtilPlayer.message(caller, F.main(_host.GetName(), C.cRed + "That Crystal is already spawned!")); - return; - } - - if (team.equalsIgnoreCase("blue")) - { - if (_host.handleCommand(EditType.SPAWN, _host.GetTeam(ChatColor.AQUA), caller, null)) - return; - UtilPlayer.message(caller, F.main(_host.GetName(), C.cRed + "That Crystal is already spawned!")); - return; - } - } - -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/StatusCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/StatusCommand.java index 63e73af85..38dfd2b5e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/StatusCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/StatusCommand.java @@ -4,7 +4,6 @@ import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; -import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague.EditType; import org.bukkit.entity.Player; @@ -21,7 +20,7 @@ public class StatusCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - _host.handleCommand(EditType.STATUS, null, caller, null); + _host.handleCommand(caller); } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/AdminPanel.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/AdminPanel.java index a91fdd8aa..d48658b8a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/AdminPanel.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/AdminPanel.java @@ -12,8 +12,6 @@ import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; -import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague.EditType; -import nautilus.game.arcade.game.games.minecraftleague.data.TeamCrystal; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -44,15 +42,15 @@ public class AdminPanel implements Listener _slots = new ConcurrentHashMap(); ItemStack red = new ItemBuilder(MenuButton.CRYSTAL.getRepresentation()) - .setTitle(C.cRed + "Red Crystal") - .setLore(C.cGray + "Alive: " + host.getCrystal(host.GetTeam(ChatColor.RED)).Alive, - C.cGray + "Health: " + host.getCrystal(host.GetTeam(ChatColor.RED)).getHealth()) + .setTitle(C.cRed + "Red Tower") + .setLore(C.cGray + "Alive: " + host.getActiveTower(host.GetTeam(ChatColor.RED)).Alive, + C.cGray + "Health: " + host.getActiveTower(host.GetTeam(ChatColor.RED)).getHealth()) .build(); ItemStack blue = new ItemBuilder(MenuButton.CRYSTAL.getRepresentation()) .setTitle(C.cAqua + "Blue Crystal") - .setLore(C.cGray + "Alive: " + host.getCrystal(host.GetTeam(ChatColor.AQUA)).Alive, - C.cGray + "Health: " + host.getCrystal(host.GetTeam(ChatColor.AQUA)).getHealth()) + .setLore(C.cGray + "Alive: " + host.getActiveTower(host.GetTeam(ChatColor.AQUA)).Alive, + C.cGray + "Health: " + host.getActiveTower(host.GetTeam(ChatColor.AQUA)).getHealth()) .build(); _buttons.put(red, host.GetTeam(ChatColor.RED)); @@ -77,8 +75,8 @@ public class AdminPanel implements Listener GameTeam team = _buttons.get(item); ItemMeta im = item.getItemMeta(); List lore = new ArrayList(); - lore.add(C.cGray + "Alive: " + _host.getCrystal(team).Alive); - lore.add(C.cGray + "Health: " + _host.getCrystal(team).getHealth()); + lore.add(C.cGray + "Alive: " + _host.getActiveTower(team).Alive); + lore.add(C.cGray + "Health: " + _host.getActiveTower(team).getHealth()); im.setLore(lore); item.setItemMeta(im); _buttons.remove(item); @@ -104,22 +102,7 @@ public class AdminPanel implements Listener if (event.getCurrentItem() == null) return; - try - { - GameTeam selectedT = _buttons.get(event.getCurrentItem()); - TeamCrystal selected = _host.getCrystal(selectedT); - - if (selected.Alive) - _host.handleCommand(EditType.KILL, selectedT, _admin, null); - else - _host.handleCommand(EditType.SPAWN, selectedT, _admin, null); - - event.setCancelled(true); - } - catch (Exception e) - { - return; - } + event.setCancelled(true); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreDeposit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/MapZone.java similarity index 78% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreDeposit.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/MapZone.java index 94ab13ef7..36d03b185 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreDeposit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/MapZone.java @@ -1,23 +1,18 @@ package nautilus.game.arcade.game.games.minecraftleague.data; -import mineplex.core.common.util.UtilBlock; - import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -public class OreDeposit +public class MapZone { private Location _loc; - private Material _ore; private int[] _rgb; private boolean _valid; - public OreDeposit(Location loc, Material type, int[] rgb) + public MapZone(Location center, int[] rgb) { - _loc = loc; - _ore = type; + _loc = center; _rgb = rgb; + _valid = true; } public boolean isValid() @@ -31,7 +26,7 @@ public class OreDeposit int diffZ = Math.max(z, _loc.getBlockZ()) - Math.min(z, _loc.getBlockZ()); if (diffX <= 5) - if (diffZ <= 10) + if (diffZ <= 5) return true; return false; @@ -65,8 +60,18 @@ public class OreDeposit { return _rgb[2]; } + + public void setValid(boolean valid) + { + _valid = valid; + } - public void update() + public void setCenter(Location center) + { + _loc = center; + } + + /*public void update() { int found = 0; for (Block block : UtilBlock.getInSquare(_loc.getBlock(), 10)) @@ -76,5 +81,5 @@ public class OreDeposit } _valid = found >= 1; - } + }*/ } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreGenerator.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreGenerator.java index cb785897f..c02076d74 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreGenerator.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreGenerator.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.minecraftleague.data; +import java.util.ArrayList; import java.util.List; import mineplex.core.common.util.UtilMath; @@ -9,31 +10,20 @@ import org.bukkit.Material; public class OreGenerator { - private int _current; - private int _total; + private List _choices = new ArrayList(); public void generateOre(Material oreType, List possible, int amount) { - _current = 0; - _total = amount; - while (_current < _total) - { - iterateOres(oreType, possible); - } - } - - private void iterateOres(Material oreType, List possible) - { + _choices.clear(); for (Location loc : possible) { - if (loc.getBlock().getType() == oreType) - continue; - if (UtilMath.random.nextDouble() > .33) - continue; - if (_total <= _current) - return; - loc.getBlock().setType(oreType); - _current++; + loc.getBlock().setType(Material.STONE); + _choices.add(loc); + } + for (int i = 0; i < (amount + 1); i++) + { + Location selected = _choices.remove(UtilMath.random.nextInt(_choices.size())); + selected.getBlock().setType(oreType); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java index 3ce1548f3..e659c46af 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java @@ -55,7 +55,7 @@ public abstract class TeamTowerBase _health = 11111D; _type = "Tower"; if (this instanceof TeamCrystal) - _type = "Crystal"; + _type = "Core"; _name = new Hologram(_host.getArcadeManager().getHologramManager(), _spawn.clone().add(0, 3, 0), team.GetColor() + team.getDisplayName() + "'s " + _type); _healthTag = new Hologram(_host.getArcadeManager().getHologramManager(), _spawn.clone().add(0, 2, 0), formatHealth(_health)); @@ -129,17 +129,21 @@ public abstract class TeamTowerBase private void detonate() { - UtilParticle.PlayParticleToAll(ParticleType.EXPLODE, _spawn, null, 0, 2, ViewDist.NORMAL); - for (Block b : UtilBlock.getExplosionBlocks(_spawn, 1, false)) + UtilParticle.PlayParticleToAll(ParticleType.LARGE_EXPLODE, _spawn, null, 0, 2, ViewDist.NORMAL); + _spawn.getWorld().playSound(_spawn, Sound.EXPLODE, 10, 0); + for (Block b : UtilBlock.getExplosionBlocks(_spawn, 2, false)) { b.setType(Material.AIR); } - for (LivingEntity le : UtilEnt.getInRadius(_spawn, 5).keySet()) + for (LivingEntity le : UtilEnt.getInRadius(_spawn, 18).keySet()) { if (le instanceof Wither) - le.damage(le.getHealth() / 2); + le.setHealth(le.getHealth() / 2); else - le.damage(6); + { + if (UtilMath.offset(le.getLocation(), _spawn) <= 5) + le.damage(6); + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerAlert.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerAlert.java new file mode 100644 index 000000000..afa228d7e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerAlert.java @@ -0,0 +1,49 @@ +package nautilus.game.arcade.game.games.minecraftleague.data; + +import java.util.concurrent.ConcurrentHashMap; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import nautilus.game.arcade.game.GameTeam; + +import org.bukkit.entity.Player; + +public class TowerAlert +{ + private ConcurrentHashMap _alerts = new ConcurrentHashMap(); + private ConcurrentHashMap _alertType = new ConcurrentHashMap(); + + public void alert(GameTeam team, TeamTowerBase tower) + { + _alerts.put(team, System.currentTimeMillis()); + if (tower instanceof TeamTower) + { + int number = ((TeamTower)tower).Number; + if (number == 1) + _alertType.put(team, "First Tower"); + else + _alertType.put(team, "Second Tower"); + } + else + _alertType.put(team, "Crystal"); + } + + public void update() + { + for (GameTeam team : _alerts.keySet()) + { + for (Player player : team.GetPlayers(true)) + { + UtilTextBottom.display(C.cRed + "Your " + _alertType.get(team) + " is under attack!", player); + } + + if (UtilTime.elapsed(_alerts.get(team), UtilTime.convert(5, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) + { + _alerts.remove(team); + _alertType.remove(team); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java index d4927f767..bcdb0db34 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java @@ -1,10 +1,12 @@ package nautilus.game.arcade.game.games.minecraftleague.data; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.concurrent.ConcurrentHashMap; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.minecraftleague.DataLoc; @@ -22,6 +24,7 @@ public class TowerManager implements Listener private ConcurrentHashMap _towers = new ConcurrentHashMap(); private ConcurrentHashMap _vulnerableTower = new ConcurrentHashMap(); private ConcurrentHashMap _def = new ConcurrentHashMap(); + //private ConcurrentHashMap _mapZone = new ConcurrentHashMap(); private OreGenerator _ore; public TowerManager(MinecraftLeague host) @@ -120,6 +123,8 @@ public class TowerManager implements Listener { GameTeam red = Host.GetTeam(ChatColor.RED); GameTeam blue = Host.GetTeam(ChatColor.AQUA); + int[] redRGB = new int[] {255, 0, 0}; + int[] blueRGB = new int[] {0, 0, 255}; _towers.put(new TeamTower(Host, this, red, data.GetCustomLocs(DataLoc.RED_TOWER.getKey() + " 1").get(0), 1), red); _towers.put(new TeamTower(Host, this, red, data.GetCustomLocs(DataLoc.RED_TOWER.getKey() + " 2").get(0), 2), red); @@ -132,6 +137,15 @@ public class TowerManager implements Listener for (TeamTowerBase tower : _towers.keySet()) { _def.put(tower, new DefenderAI(this, tower)); + /*int[] rgb; + if (tower.getTeam().GetColor() == red.GetColor()) + rgb = redRGB; + else + rgb = blueRGB; + + MapZone zone = new MapZone(tower.getLocation(), rgb); + Host.MapZones.add(zone); + _mapZone.put(tower, zone);*/ } makeVulnerable(getTeamTowers(red).getFirst()); @@ -147,25 +161,28 @@ public class TowerManager implements Listener if (tower instanceof TeamCrystal) tower.setMaxHealth(players * multiplier); else - tower.setMaxHealth((double)((int)((2/3)*multiplier)) * players); + { + double rawHealth = (.67 * multiplier) * players; + Double health = new BigDecimal(rawHealth).intValue() * 1D; + tower.setMaxHealth(health); + } } } public void handleTowerDeath(TeamTowerBase towerBase) { towerBase.setVulnerable(false); - if (towerBase instanceof TeamCrystal) + oreGen(towerBase.getTeam()); + Bukkit.getScheduler().runTaskLater(Host.Manager.getPlugin(), new Runnable() { - oreGen(towerBase.getTeam()); - Bukkit.getScheduler().runTaskLater(Host.Manager.getPlugin(), new Runnable() + public void run() { - public void run() - { - UtilTextMiddle.display("", towerBase.getTeam().GetColor() + towerBase.getTeam().GetName() + " Team ores have been replenished!"); - } - }, 20 * 5); + UtilTextMiddle.display("", towerBase.getTeam().GetColor() + towerBase.getTeam().GetName() + " Team ores have been replenished!", UtilServer.getPlayers()); + } + }, 20 * 5); + //_mapZone.get(towerBase).setValid(false); + if (towerBase instanceof TeamCrystal) return; - } TeamTower tower = (TeamTower)towerBase; makeVulnerable(getTeamTowers(tower.getTeam()).get(tower.Number)); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/map/ItemMapRenderer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/map/ItemMapRenderer.java index 50ba5b4eb..e4662c45a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/map/ItemMapRenderer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/map/ItemMapRenderer.java @@ -1,10 +1,8 @@ package nautilus.game.arcade.game.games.minecraftleague.data.map; -import java.awt.Color; - import mineplex.core.recharge.Recharge; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; -import nautilus.game.arcade.game.games.minecraftleague.data.OreDeposit; +import nautilus.game.arcade.game.games.minecraftleague.data.MapZone; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -67,9 +65,9 @@ public class ItemMapRenderer extends MapRenderer color = (byte) 0; } - for (OreDeposit od : _host.Ore) + for (MapZone od : _host.MapZones) { - if (od.isInRadius(blockX - 20, blockZ + 15)) // TODO Some math to figure out if this pixel is going to be colored in for the circle or not. + if (od.isInRadius(blockX, blockZ)) // TODO Some math to figure out if this pixel is going to be colored in for the circle or not. { if (od.isValid()) color = MapPalette.matchColor(od.getRed(), od.getGreen(), od.getBlue()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java index c9c0eaab3..66ffe6835 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java @@ -237,10 +237,12 @@ public class WitherVariation extends GameVariation if (inside.containsKey(red.getLocation().getBlock())) { red.damage(dmg, null); + Host.Alert.alert(red.getTeam(), red); } if (inside.containsKey(blue.getLocation().getBlock())) { blue.damage(dmg, null); + Host.Alert.alert(blue.getTeam(), blue); } for (Block b : inside.keySet()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java index 5916a366a..5fd8d75d0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java @@ -22,6 +22,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.minecraftleague.data.MapZone; import nautilus.game.arcade.game.games.minecraftleague.variation.wither.WitherVariation; import org.bukkit.Bukkit; @@ -48,8 +49,6 @@ import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; public class WitherMinionManager implements Listener { @@ -64,6 +63,7 @@ public class WitherMinionManager implements Listener private ItemStack _witherItem; private WitherSkeletonTimer _sbTimer; + private MapZone _skellyZone; private Block _cb; private Material _changed = Material.AIR; @@ -81,6 +81,9 @@ public class WitherMinionManager implements Listener _witherItem = new ItemBuilder(Material.SKULL_ITEM).setTitle(C.cDRedB + "Wither Skeleton Head").setData((short) 1).setLore(C.cGray + "Bring this back", C.cGray + "to your team's Altar", C.cGray + "To summon a Wither!").build(); _sbTimer = new WitherSkeletonTimer(host.Host.GetScoreboard()); host.Host.ExtraSb.put(_sbTimer, host); + _skellyZone = new MapZone(spawns.get(0), new int[] {0, 0, 0}); + _skellyZone.setValid(false); + host.Host.MapZones.add(_skellyZone); Bukkit.getPluginManager().registerEvents(this, host.Manager.getPlugin()); } @@ -117,14 +120,18 @@ public class WitherMinionManager implements Listener UtilEnt.ghost(e, true, false); UtilEnt.Vegetate(e); e.setCustomName(C.cRed + "Wither Skeleton"); - ((Skeleton)e).setMaxHealth(100); - ((Skeleton)e).setHealth(100); + ((Skeleton)e).setMaxHealth(/*100*/65); + ((Skeleton)e).setHealth(/*100*/65); ((CraftSkeleton)e).getEquipment().setChestplate(new ItemStack(Material.IRON_CHESTPLATE)); ((CraftSkeleton)e).getEquipment().setLeggings(new ItemStack(Material.IRON_LEGGINGS)); - ((Skeleton)e).addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 9999999, 7)); + //((Skeleton)e).addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 9999999, 7)); if (!respawn) + { UtilTextMiddle.display("", C.cGray + "A Wither Skeleton has spawned!"); + _skellyZone.setCenter(chosen); + _skellyZone.setValid(true); + } _selected = -1; _spawned = true; } @@ -144,6 +151,7 @@ public class WitherMinionManager implements Listener _spawned = false; _entity.remove(); _lastDied = System.currentTimeMillis(); + _skellyZone.setValid(false); _entity = null; } if (_cb != null) @@ -220,6 +228,14 @@ public class WitherMinionManager implements Listener UtilParticle.PlayParticleToAll(ParticleType.PORTAL, loc, null, 0, 2, ViewDist.MAX); } } + if (player.getInventory().getHelmet() != null) + { + if (UtilInv.IsItem(player.getInventory().getHelmet(), Material.SKULL_ITEM, (byte) 1)) + { + player.getInventory().setHelmet(new ItemStack(Material.AIR)); + UtilInv.insert(player, _witherItem.clone()); + } + } } } @@ -244,7 +260,7 @@ public class WitherMinionManager implements Listener if (_host.WitherSpawned || _witherBlocked) { - _sbTimer.freezeTime(20); + _sbTimer.freezeTime(-2); return; } @@ -275,6 +291,7 @@ public class WitherMinionManager implements Listener event.getDrops().clear(); event.getDrops().add(_witherItem.clone()); event.setDroppedExp(10); + _skellyZone.setValid(false); _cb.setType(_changed); _cb = null; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java index f5e41c2e0..074e0fb15 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java @@ -8,6 +8,7 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.minecraftleague.DataLoc; import nautilus.game.arcade.game.games.minecraftleague.data.TeamTower; @@ -38,6 +39,8 @@ public class WitherPathfinder private boolean _startedJourney = false; + private double _health; + public WitherPathfinder(WitherVariation host, Wither ent, LinkedList waypoints, GameTeam team, GameTeam enemy, TowerManager towerManager) { _host = host; @@ -49,6 +52,7 @@ public class WitherPathfinder _lastAttack = -1; _lastTowerAttack = -1; _pathData = new PathfinderData(ent, waypoints.getFirst()); + _health = ent.getHealth(); } private int getWaypointIndex(Location loc) @@ -106,7 +110,7 @@ public class WitherPathfinder if (target != null) { - if (UtilTime.elapsed(_lastAttack, 2)) + if (UtilTime.elapsed(_lastAttack, UtilTime.convert(2, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) { _lastAttack = System.currentTimeMillis(); shootAt(target.getLocation()); @@ -146,10 +150,16 @@ public class WitherPathfinder if (_ent.getHealth() < _ent.getMaxHealth()) { if (!_startedJourney) + { + _health = _ent.getMaxHealth(); return false; + } } _startedJourney = true; + _health = Math.min(_health, _ent.getHealth()); + _ent.setHealth(_health); + for (Entity e : UtilEnt.getAllInRadius(_ent.getLocation(), 3).keySet()) { if (e instanceof Arrow) @@ -183,7 +193,7 @@ public class WitherPathfinder finalize.setPitch(UtilAlg.GetPitch(UtilAlg.getTrajectory(_ent, eTower))); finalize.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(_ent, eTower))); _ent.teleport(finalize); - if (UtilTime.elapsed(_lastTowerAttack, 5)) + if (UtilTime.elapsed(_lastTowerAttack, UtilTime.convert(5, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) { _lastTowerAttack = System.currentTimeMillis(); shootAt(eTower.getLocation()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherSkeletonTimer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherSkeletonTimer.java index 047269a80..0b655ae09 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherSkeletonTimer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherSkeletonTimer.java @@ -33,7 +33,10 @@ public class WitherSkeletonTimer extends ExtraScoreboardData Scoreboard.Write(C.cYellowB + "Wither Skeleton Spawn"); if (_frozen != -1) { - Scoreboard.Write(_frozen + " Seconds"); + if (_frozen == -2) + Scoreboard.Write("WITHER ALIVE"); + else + Scoreboard.Write(_frozen + " Seconds"); } else { From bb28b7ad89842907abc65fb5f1f702f0683dd923 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 25 Mar 2016 20:27:17 -0400 Subject: [PATCH 28/47] - Forgot to comment out 2 lines --- .../arcade/game/games/minecraftleague/data/TowerManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java index bcdb0db34..6eba49f59 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java @@ -123,8 +123,8 @@ public class TowerManager implements Listener { GameTeam red = Host.GetTeam(ChatColor.RED); GameTeam blue = Host.GetTeam(ChatColor.AQUA); - int[] redRGB = new int[] {255, 0, 0}; - int[] blueRGB = new int[] {0, 0, 255}; + //int[] redRGB = new int[] {255, 0, 0}; + //int[] blueRGB = new int[] {0, 0, 255}; _towers.put(new TeamTower(Host, this, red, data.GetCustomLocs(DataLoc.RED_TOWER.getKey() + " 1").get(0), 1), red); _towers.put(new TeamTower(Host, this, red, data.GetCustomLocs(DataLoc.RED_TOWER.getKey() + " 2").get(0), 2), red); From 2530bc512ecee40831f43fc1532ed17286a44675 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 26 Mar 2016 14:02:18 -0400 Subject: [PATCH 29/47] - Fixed some more buggies --- .../game/arcade/game/games/minecraftleague/MinecraftLeague.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index 3600d1c30..153fe17ed 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -483,7 +483,7 @@ public class MinecraftLeague extends TeamGame if (bluet instanceof TeamTower) { if (((TeamTower)bluet).Number > 1) - reds = "Second Tower"; + blues = "Second Tower"; } else blues = "Core"; From 40175db21762657cadb96ed8272deae47e6bc806 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 31 Mar 2016 03:41:07 -0400 Subject: [PATCH 30/47] - Lots of polish --- .../game/games/minecraftleague/DataLoc.java | 2 + .../minecraftleague/MinecraftLeague.java | 167 ++++++++++++++---- .../commands/panel/AdminPanel.java | 2 +- .../minecraftleague/data/BlockProtection.java | 21 ++- .../minecraftleague/data/DefenderAI.java | 63 ++++--- .../minecraftleague/data/TeamBeacon.java | 24 +-- .../minecraftleague/data/TeamTowerBase.java | 10 +- .../minecraftleague/data/TowerAlert.java | 44 +++-- .../minecraftleague/data/TowerManager.java | 54 ++++-- .../data/objectives/GearObjective.java | 11 ++ .../data/objectives/KillObjective.java | 12 ++ .../objective/GameObjective.java | 23 +++ .../objective/ObjectiveManager.java | 122 +++++++++++++ .../variation/wither/WitherVariation.java | 18 +- .../variation/wither/data/TeamAltar.java | 6 + .../wither/data/WitherMinionManager.java | 52 +++++- .../data/objectives/GrabSkullObjective.java | 11 ++ .../data/objectives/ReturnSkullObjective.java | 12 ++ .../data/objectives/WitherObjective.java | 11 ++ 19 files changed, 538 insertions(+), 127 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/objectives/GearObjective.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/objectives/KillObjective.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/objective/GameObjective.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/objective/ObjectiveManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/objectives/GrabSkullObjective.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/objectives/ReturnSkullObjective.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/objectives/WitherObjective.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/DataLoc.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/DataLoc.java index 2993c618c..f2ee0a89b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/DataLoc.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/DataLoc.java @@ -15,6 +15,8 @@ public enum DataLoc //MAP_IRON("SILVER"), RED_ORE("15"), BLUE_ORE("14"), + DIAMOND_ORE("56"), + COAL_ORE("16"), //Wither WITHER_WAYPOINT("PURPLE"), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index 153fe17ed..24f01e5fd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -33,12 +33,15 @@ import nautilus.game.arcade.game.games.minecraftleague.commands.freeze.FreezeMan import nautilus.game.arcade.game.games.minecraftleague.data.BlockProtection; import nautilus.game.arcade.game.games.minecraftleague.data.MapZone; import nautilus.game.arcade.game.games.minecraftleague.data.Spawner; +import nautilus.game.arcade.game.games.minecraftleague.data.TeamBeacon; import nautilus.game.arcade.game.games.minecraftleague.data.TeamTower; import nautilus.game.arcade.game.games.minecraftleague.data.TeamTowerBase; import nautilus.game.arcade.game.games.minecraftleague.data.TowerAlert; import nautilus.game.arcade.game.games.minecraftleague.data.TowerManager; import nautilus.game.arcade.game.games.minecraftleague.data.map.ItemMapManager; +import nautilus.game.arcade.game.games.minecraftleague.data.objectives.GearObjective; import nautilus.game.arcade.game.games.minecraftleague.kit.KitPlayer; +import nautilus.game.arcade.game.games.minecraftleague.objective.ObjectiveManager; import nautilus.game.arcade.game.games.minecraftleague.variation.ExtraScoreboardData; import nautilus.game.arcade.game.games.minecraftleague.variation.GameVariation; import nautilus.game.arcade.game.games.minecraftleague.variation.VariationManager; @@ -95,7 +98,7 @@ public class MinecraftLeague extends TeamGame //private ConcurrentHashMap _customRespawns = new ConcurrentHashMap(); //private ConcurrentHashMap _maps = new ConcurrentHashMap(); private ConcurrentHashMap> _gear = new ConcurrentHashMap>(); - //private ConcurrentHashMap _beacons = new ConcurrentHashMap(); + public ConcurrentHashMap Beacons = new ConcurrentHashMap(); private ConcurrentHashMap _blockLock = new ConcurrentHashMap(); //private ConcurrentHashMap _spawnAllow = new ConcurrentHashMap(); private List _spawners = new ArrayList(); @@ -105,6 +108,7 @@ public class MinecraftLeague extends TeamGame private long _liveTime = 0; private MinecraftLeagueCommand _cmd; private long _lastIncrease; + private long _lastOreReset; private boolean _yellow = false; public List MapZones = new ArrayList(); @@ -112,6 +116,7 @@ public class MinecraftLeague extends TeamGame public boolean OverTime = false; private VariationManager _vman; + public ObjectiveManager Objective; private FreezeManager _freeze; private TowerManager _tower; public TowerAlert Alert; @@ -139,7 +144,7 @@ public class MinecraftLeague extends TeamGame this.DeathOut = false; this.DamageSelf = false; this.DeathSpectateSecs = 5; - this.WorldBoundaryKill = false; + this.WorldBoundaryKill = true; this.DeathDropItems = true; this.CreatureAllow = true; this.HungerSet = 20; @@ -168,7 +173,7 @@ public class MinecraftLeague extends TeamGame _help = new String[] { - "Respawn Crystals have 100 health per person in-game!", + "Respawn Crystals have 150 health per person in-game!", "The better the sword you have, the more damage you deal to Respawn Crystals!", //"Right-click a bed in order to change your personal spawn location!", "Your map will display the locations of your enemies in OverTime!" @@ -180,6 +185,7 @@ public class MinecraftLeague extends TeamGame ); _vman = new VariationManager(this); + Objective = new ObjectiveManager(this); _freeze = new FreezeManager(); _tower = new TowerManager(this); Alert = new TowerAlert(); @@ -285,6 +291,8 @@ public class MinecraftLeague extends TeamGame if (ret.getType() == Material.MAP) ret = new ItemStack(Material.AIR); + if (UtilItem.isTool(ret)) + ret = new ItemStack(ret.getType()); return ret; } @@ -420,6 +428,15 @@ public class MinecraftLeague extends TeamGame Ore.add(new OreDeposit(loc, Material.IRON_ORE, new int[] {190, 190, 190})); }*/ + for (Location diamond : WorldData.GetCustomLocs(DataLoc.DIAMOND_ORE.getKey())) + { + diamond.getBlock().setType(Material.DIAMOND_ORE); + } + for (Location coal : WorldData.GetCustomLocs(DataLoc.COAL_ORE.getKey())) + { + coal.getBlock().setType(Material.COAL_ORE); + } + MapManager = new ItemMapManager(this, WorldData.World, WorldData.MinX, WorldData.MinZ, WorldData.MaxX, WorldData.MaxZ); _vman.selectVariation(); @@ -597,6 +614,7 @@ public class MinecraftLeague extends TeamGame if (event.GetState() == GameState.Live) { _lastIncrease = System.currentTimeMillis(); + _lastOreReset = System.currentTimeMillis(); Manager.GetExplosion().setEnabled(false); Manager.GetDamage().SetEnabled(false); Manager.GetCreature().SetForce(true); @@ -604,6 +622,7 @@ public class MinecraftLeague extends TeamGame _cmd = new MinecraftLeagueCommand(Manager, this); Manager.addCommand(_cmd); Manager.getGameChatManager().TeamSpy = false; + Objective.setMainObjective(new GearObjective()); } if (event.GetState() == GameState.End) @@ -708,19 +727,35 @@ public class MinecraftLeague extends TeamGame spawner.update(); } - /*for (TeamBeacon beacon : _beacons.values()) + for (TeamBeacon beacon : Beacons.values()) { beacon.update(); - }*/ + } - Alert.update(); + //Alert.update(); + + if (UtilTime.elapsed(_lastOreReset, UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS))) + { + _lastOreReset = System.currentTimeMillis(); + for (Location loc : WorldData.GetCustomLocs(DataLoc.DIAMOND_ORE.getKey())) + { + loc.getBlock().setType(Material.DIAMOND_ORE); + } + for (Location loc : WorldData.GetCustomLocs(DataLoc.COAL_ORE.getKey())) + { + loc.getBlock().setType(Material.COAL_ORE); + } + _tower.ironOreGen(GetTeam(ChatColor.RED)); + _tower.ironOreGen(GetTeam(ChatColor.AQUA)); + UtilTextMiddle.display("", C.cGold + "All Ores have been refreshed!"); + } if (!OverTime) { if (UtilTime.elapsed(GetStateTime(), UtilTime.convert(15, TimeUnit.MINUTES, TimeUnit.MILLISECONDS))) { OverTime = true; - UtilTextMiddle.display(C.cDRed + "Overtime", C.cDRed + "Dying will now cause your crystal to lose 20 health!"); + UtilTextMiddle.display(C.cGold + "Overtime", C.cGold + "Dying will now cause your crystal to lose 20 health!"); } } @@ -751,10 +786,14 @@ public class MinecraftLeague extends TeamGame player.setFireTicks(-1); player.setFoodLevel(20); } + if (UtilInv.contains(player, Material.LAVA_BUCKET, (byte) 0, 1)) + { + UtilInv.insert(player, new ItemStack(Material.BUCKET, UtilInv.removeAll(player, Material.LAVA_BUCKET, (byte) 0))); + } if (player.getOpenInventory().getType() == InventoryType.BEACON) player.closeInventory(); - if (player.getFireTicks() > 20 * 3) - player.setFireTicks(20 * 3); + if (player.getFireTicks() > 20 * 4) + player.setFireTicks(20 * 4); } } } @@ -897,6 +936,26 @@ public class MinecraftLeague extends TeamGame _customRespawns.put(player, new PlayerRespawnPoint(player, event.getClickedBlock().getLocation())); }*/ + private boolean isLockedTo(Block block, Player to, boolean ignoreTeam) + { + for (BlockProtection prot : _blockLock.values()) + { + if (prot.hasBlock(block)) + return prot.isLockedTo(to, block, ignoreTeam); + } + return false; + } + + private boolean isOwner(Block block, Player owner) + { + for (BlockProtection prot : _blockLock.values()) + { + if (prot.hasBlock(block)) + return prot.getOwner().getName().equalsIgnoreCase(owner.getName()); + } + return false; + } + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void lockBlock(BlockPlaceEvent event) { @@ -914,7 +973,10 @@ public class MinecraftLeague extends TeamGame if (!IsLive()) return; - _blockLock.get(event.getPlayer()).unlockBlock(event.getBlock()); + if (isLockedTo(event.getBlock(), event.getPlayer(), true)) + _blockLock.get(event.getPlayer()).unlockBlock(event.getBlock()); + else + event.setCancelled(true); } @EventHandler @@ -926,6 +988,12 @@ public class MinecraftLeague extends TeamGame if (event.getClickedBlock() == null) return; + if (UtilPlayer.isSpectator(event.getPlayer())) + { + event.setCancelled(true); + return; + } + if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return; @@ -933,24 +1001,24 @@ public class MinecraftLeague extends TeamGame if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST || block.getType() == Material.FURNACE) { - for (Player owner : _blockLock.keySet()) + if (isLockedTo(event.getClickedBlock(), event.getPlayer(), false)) { - BlockProtection prot = _blockLock.get(owner); - - if (prot.isLockedTo(event.getPlayer(), block)) + event.setCancelled(true); + return; + } + if (isOwner(event.getClickedBlock(), event.getPlayer())) + { + if (event.getPlayer().isSneaking()) { - event.setCancelled(true); + _blockLock.get(event.getPlayer()).unlockBlock(event.getClickedBlock()); return; } - else + } + if (!isOwner(event.getClickedBlock(), event.getPlayer())) + { + if (!isLockedTo(event.getClickedBlock(), event.getPlayer(), true)) { - if (owner.getName().equalsIgnoreCase(event.getPlayer().getName())) - { - if (event.getPlayer().isSneaking()) - { - prot.unlockBlock(block); - } - } + _blockLock.get(event.getPlayer()).lockBlock(event.getClickedBlock()); } } } @@ -1155,6 +1223,10 @@ public class MinecraftLeague extends TeamGame { event.getInventory().setResult(new ItemStack(Material.ARROW, (event.getInventory().getResult().getAmount() * 2))); } + if (event.getInventory().getResult().getType() == Material.FLINT_AND_STEEL) + { + event.getInventory().setResult(new ItemBuilder(Material.FLINT_AND_STEEL).setData((short) (Material.FLINT_AND_STEEL.getMaxDurability() - 4)).build()); + } } @EventHandler @@ -1214,7 +1286,7 @@ public class MinecraftLeague extends TeamGame return; int playercount = GetTeam(ChatColor.RED).GetPlayers(false).size() + GetTeam(ChatColor.AQUA).GetPlayers(false).size(); - _tower.prepareHealth(playercount, 50 * 2); + _tower.prepareHealth(playercount, 150); } @EventHandler @@ -1263,10 +1335,10 @@ public class MinecraftLeague extends TeamGame } for (Player player : GetTeam(ChatColor.AQUA).GetPlayers(true)) { - player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setColor(Color.BLUE).build()); - player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(Color.BLUE).build()); - player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(Color.BLUE).build()); - player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.BLUE).build()); + player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setColor(Color.BLUE).setUnbreakable(true).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(Color.BLUE).setUnbreakable(true).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(Color.BLUE).setUnbreakable(true).build()); + player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.BLUE).setUnbreakable(true).build()); player.getInventory().addItem(new ItemStack(Material.STONE_SWORD)); player.getInventory().addItem(new ItemStack(Material.STONE_PICKAXE)); //player.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 5)); @@ -1274,10 +1346,10 @@ public class MinecraftLeague extends TeamGame } for (Player player : GetTeam(ChatColor.RED).GetPlayers(true)) { - player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setColor(Color.RED).build()); - player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(Color.RED).build()); - player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(Color.RED).build()); - player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.RED).build()); + player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setColor(Color.RED).setUnbreakable(true).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(Color.RED).setUnbreakable(true).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(Color.RED).setUnbreakable(true).build()); + player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.RED).setUnbreakable(true).build()); player.getInventory().addItem(new ItemStack(Material.STONE_SWORD)); player.getInventory().addItem(new ItemStack(Material.STONE_PICKAXE)); //player.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 5)); @@ -1326,6 +1398,18 @@ public class MinecraftLeague extends TeamGame else gear.add(new ItemStack(Material.AIR)); + if (UtilInv.contains(player, Material.BOW, (byte) 0, 1)) + { + for (ItemStack poss : UtilInv.getItems(player)) + { + if (poss.getType() == Material.BOW) + { + gear.add(poss); + break; + } + } + } + int arrowsToAdd = UtilInv.getAmount(player, Material.ARROW) / 2; while (arrowsToAdd >= 1) { @@ -1479,7 +1563,7 @@ public class MinecraftLeague extends TeamGame //_spawnAllow.put(player, System.currentTimeMillis() + UtilTime.convert((long) this.DeathSpectateSecs, TimeUnit.SECONDS, TimeUnit.MILLISECONDS)); } - @EventHandler + @EventHandler(priority = EventPriority.HIGHEST) public void onPickup(PlayerPickupItemEvent event) { if (UtilPlayer.isSpectator(event.getPlayer())) @@ -1495,14 +1579,19 @@ public class MinecraftLeague extends TeamGame if (event.getEntity() instanceof Enderman) event.setCancelled(true); + if (event.getEntityType() == EntityType.DROPPED_ITEM || event.getEntityType() == EntityType.ARROW) + return; + for (GameTeam team : GetTeamList()) - for (TeamTowerBase tower : _tower.getTeamTowers(team)) { - if (event.getLocation().getWorld().getUID() != WorldData.World.getUID()) - continue; - - if (event.getLocation().distance(tower.getLocation()) <= 5) - event.setCancelled(true); + for (TeamTowerBase tower : _tower.getTeamTowers(team)) + { + if (event.getLocation().getWorld().getUID() != WorldData.World.getUID()) + continue; + + if (event.getLocation().distance(tower.getLocation()) <= 5) + event.setCancelled(true); + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/AdminPanel.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/AdminPanel.java index d48658b8a..03b2d274b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/AdminPanel.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/AdminPanel.java @@ -48,7 +48,7 @@ public class AdminPanel implements Listener .build(); ItemStack blue = new ItemBuilder(MenuButton.CRYSTAL.getRepresentation()) - .setTitle(C.cAqua + "Blue Crystal") + .setTitle(C.cAqua + "Blue Tower") .setLore(C.cGray + "Alive: " + host.getActiveTower(host.GetTeam(ChatColor.AQUA)).Alive, C.cGray + "Health: " + host.getActiveTower(host.GetTeam(ChatColor.AQUA)).getHealth()) .build(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/BlockProtection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/BlockProtection.java index 20a605f5c..8a0c2741a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/BlockProtection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/BlockProtection.java @@ -7,6 +7,7 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; +import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -22,12 +23,22 @@ public class BlockProtection _player = player; } - public boolean isLockedTo(Player opening, Block block) + public Player getOwner() + { + return _player; + } + + public boolean hasBlock(Block block) + { + return _blocks.contains(block); + } + + public boolean isLockedTo(Player opening, Block block, boolean ignoreTeam) { if (!_blocks.contains(block)) return false; if (_host.GetTeam(_player).GetColor() != _host.GetTeam(opening).GetColor()) - return false; + return ignoreTeam; if (opening.getName().equalsIgnoreCase(_player.getName())) return false; @@ -40,14 +51,18 @@ public class BlockProtection return; _blocks.add(block); + _player.playSound(_player.getLocation(), Sound.ANVIL_USE, 5, 1); UtilPlayer.message(_player, F.main("Game", "You have locked this block to your team! Right-click it while sneaking to unlock it!")); } - public void unlockBlock(Block block) + public boolean unlockBlock(Block block) { if (_blocks.remove(block)) { + _player.playSound(_player.getLocation(), Sound.ANVIL_USE, 5, 1); UtilPlayer.message(_player, F.main("Game", "You have unlocked this block!")); + return true; } + return false; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/DefenderAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/DefenderAI.java index c76b1a489..53cc0c89f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/DefenderAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/DefenderAI.java @@ -19,6 +19,7 @@ public class DefenderAI { private TowerManager _manager; private TeamTowerBase _tower; + private int _number; private long _lastAttack; private long _procTime; private DefenseAnimation _animation; @@ -27,6 +28,12 @@ public class DefenderAI { _manager = manager; _tower = tower; + + if (tower instanceof TeamTower) + _number = ((TeamTower)tower).Number; + else + _number = 3; + _lastAttack = System.currentTimeMillis(); _procTime = -1; _animation = new DefenseAnimation(); @@ -37,18 +44,13 @@ public class DefenderAI if (!_tower.Alive) return; - if (_tower instanceof TeamTower) - _animation.activate(); - else - attack(); - + attack(); _animation.update(); } private void animate() { _animation.activate(); - _animation.deactivate(); //<-- Used for when attack hits } private void attack() @@ -58,21 +60,26 @@ public class DefenderAI if (System.currentTimeMillis() >= _procTime) { _procTime = -1; + _lastAttack = System.currentTimeMillis(); attackProc(); return; } } - if (!UtilTime.elapsed(_lastAttack, UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS))) + if (!_manager.Attack) return; - if (UtilMath.random.nextDouble() < .75) + if (!UtilTime.elapsed(_lastAttack, UtilTime.convert(30, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) return; - _procTime = System.currentTimeMillis() + UtilTime.convert(45, TimeUnit.SECONDS, TimeUnit.MILLISECONDS); + /*if (UtilMath.random.nextDouble() < .75) + return;*/ + _lastAttack = System.currentTimeMillis(); + _procTime = System.currentTimeMillis() + UtilTime.convert(25, TimeUnit.SECONDS, TimeUnit.MILLISECONDS); animate(); } private void attackProc() { - for (LivingEntity le : UtilEnt.getInRadius(_tower.getLocation(), 15).keySet()) + _animation.deactivate(); + for (LivingEntity le : UtilEnt.getInRadius(_tower.getLocation(), 7).keySet()) { if (!(le instanceof Player)) continue; @@ -101,7 +108,8 @@ public class DefenderAI { _step = 0; _lastStepIncrease = System.currentTimeMillis(); - if (_tower instanceof TeamTower) + _base = _tower.getLocation().clone(); + /*if (_tower instanceof TeamTower) { //_baseRadius = -1; _base = _tower.getLocation().clone().add(0, 10, 0); @@ -110,7 +118,7 @@ public class DefenderAI { //_baseRadius = 11; _base = _tower.getLocation().clone(); - } + }*/ _radius = /*_baseRadius*/2; } @@ -126,41 +134,40 @@ public class DefenderAI public void update() { + if (_number != 3) + drawBeam(); + if (!_active) return; - if (_tower instanceof TeamTower) + if (UtilTime.elapsed(_lastStepIncrease, UtilTime.convert(3, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) { - drawBeam(); - } - else - { - if (UtilTime.elapsed(_lastStepIncrease, UtilTime.convert(3, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) - { - _step++; - _lastStepIncrease = System.currentTimeMillis(); - } - drawHelix(); + _step++; + _lastStepIncrease = System.currentTimeMillis(); } + drawHelix(); } private void drawHelix() { - for (double y = 0; y <= _step; y += .5) + double height = Math.min(_step, 15D); + + for (double y = 0; y <= height; y += .5) { double x = _radius * Math.cos(y); double z = _radius * Math.sin(y); Location play = new Location(_base.getWorld(), _base.getX() + x, _base.getY() + y, _base.getZ() + z); - UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, play, null, 0, 1, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, play, null, 0, 3, ViewDist.MAX); } } private void drawBeam() { - Location target = _manager.getTeamTowers(_tower.getTeam()).getLast().getLocation().clone().add(0, 10, 0); - Location display = _base.clone(); - while (UtilMath.offset(_base, target) > UtilMath.offset(_base, display)) + Location base = _base.clone().add(0, 10, 0); + Location target = _manager.getTeamTowers(_tower.getTeam()).get(_number).getLocation().clone().add(0, 10, 0); + Location display = base.clone(); + while (UtilMath.offset(base, target) > UtilMath.offset(base, display)) { Vector v = UtilAlg.getTrajectory(display, target); UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, display, null, 0, 1, ViewDist.MAX); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java index 62ba82693..917fa00b3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java @@ -2,13 +2,10 @@ package nautilus.game.arcade.game.games.minecraftleague.data; import java.util.HashSet; -import mineplex.core.common.util.UtilBlock; import nautilus.game.arcade.game.GameTeam; -import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @@ -17,18 +14,18 @@ public class TeamBeacon { private GameTeam _team; private Block _block; - private Location _core; + //private Location _core; - public TeamBeacon(GameTeam team, Block block, Location core) + public TeamBeacon(GameTeam team, Block block/*, Location core*/) { _team = team; _block = block; - _core = core; + //_core = core; _block.setType(Material.BEACON); } - public boolean isBlock(Block match) + /*public boolean isBlock(Block match) { if (match.getX() == _block.getX()) if (match.getZ() == _block.getZ()) @@ -36,6 +33,11 @@ public class TeamBeacon return true; return false; + }*/ + + public void setBlock(Block block) + { + _block = block; } public void update() @@ -49,17 +51,17 @@ public class TeamBeacon ignore.add(Material.STAINED_GLASS); ignore.add(Material.STAINED_GLASS_PANE); //Bukkit.broadcastMessage(UtilBlock.getHighest(_block.getWorld(), _block.getX(), _block.getZ(), ignore) + ""); - if (!isBlock(UtilBlock.getHighest(_block.getWorld(), _block.getX(), _block.getZ(), ignore).getRelative(BlockFace.DOWN))) - return; + //if (!isBlock(UtilBlock.getHighest(_block.getWorld(), _block.getX(), _block.getZ(), ignore).getRelative(BlockFace.DOWN))) + //return; for (Player player : _team.GetPlayers(true)) { - if (player.getLocation().distance(_core) < 15) + if (player.getLocation().distance(_block.getLocation()) < 15) { player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 5 * 20, 0)); //player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 5 * 20, 0)); player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 5 * 20, 0)); - player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 5 * 20, 0)); + //player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 5 * 20, 0)); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java index e659c46af..d7c9629e1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java @@ -75,16 +75,16 @@ public abstract class TeamTowerBase { String message = ""; if (player != null) - message = C.cRedB + player.getName() + " has destroyed " + _team.getDisplayName() + "'s " + C.cDPurpleB + _type + C.cRedB + "!"; + message = _host.GetTeam(player).GetColor() + player.getName() + _team.GetColor() + " has destroyed " + _team.getDisplayName() + "'s " + C.cDPurpleB + _type + _team.GetColor() + "!"; else - message = C.cRedB + _team.getDisplayName() + "'s " + C.cDPurpleB + _type + C.cRedB + " has been destroyed!"; + message = _team.GetColor() + _team.getDisplayName() + "'s " + C.cDPurpleB + _type + _team.GetColor() + " has been destroyed!"; Bukkit.broadcastMessage(message); if (!_type.equalsIgnoreCase("Tower")) { for (Player inform : _team.GetPlayers(true)) - UtilTextMiddle.display(C.cRedB + "Team Crystal Destroyed", C.cRed + "You will no longer respawn!", inform); + UtilTextMiddle.display(C.cGold + "Team Crystal Destroyed", C.cGold + "You will no longer respawn!", inform); } Alive = false; @@ -147,7 +147,7 @@ public abstract class TeamTowerBase } } - private Location getBeacon() + public Location getBeacon() { Location ret = null; for (Location loc : _host.WorldData.GetDataLocs(DataLoc.BEACON.getKey())) @@ -223,7 +223,7 @@ public abstract class TeamTowerBase _health = newHealth; if (player != null) - Recharge.Instance.use(player, "Damage TeamTower", UtilTime.convert(1, TimeUnit.SECONDS, TimeUnit.MILLISECONDS), false, false); + Recharge.Instance.use(player, "Damage TeamTower", UtilTime.convert(1/2, TimeUnit.SECONDS, TimeUnit.MILLISECONDS), false, false); return false; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerAlert.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerAlert.java index afa228d7e..269c77262 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerAlert.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerAlert.java @@ -1,49 +1,57 @@ package nautilus.game.arcade.game.games.minecraftleague.data; -import java.util.concurrent.ConcurrentHashMap; - import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilTextBottom; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.common.util.UtilTextMiddle; import nautilus.game.arcade.game.GameTeam; +import org.bukkit.Instrument; +import org.bukkit.Note; +import org.bukkit.Note.Tone; import org.bukkit.entity.Player; public class TowerAlert { - private ConcurrentHashMap _alerts = new ConcurrentHashMap(); - private ConcurrentHashMap _alertType = new ConcurrentHashMap(); + //private ConcurrentHashMap _alerts = new ConcurrentHashMap(); + //private ConcurrentHashMap _alertType = new ConcurrentHashMap(); public void alert(GameTeam team, TeamTowerBase tower) { - _alerts.put(team, System.currentTimeMillis()); + //_alerts.put(team, System.currentTimeMillis()); + String type = ""; if (tower instanceof TeamTower) { int number = ((TeamTower)tower).Number; if (number == 1) - _alertType.put(team, "First Tower"); + /*_alertType.put(team, */type = "First Tower";//); else - _alertType.put(team, "Second Tower"); + /*_alertType.put(team, */type = "Second Tower";//); } else - _alertType.put(team, "Crystal"); + /*_alertType.put(team, */type = "Crystal";//); + + showAlert(team, type); } - public void update() + private void showAlert(GameTeam team, String type) { - for (GameTeam team : _alerts.keySet()) - { + /*for (GameTeam team : _alerts.keySet()) + {*/ for (Player player : team.GetPlayers(true)) { - UtilTextBottom.display(C.cRed + "Your " + _alertType.get(team) + " is under attack!", player); + UtilTextMiddle.display("", C.cGold + "Your " + /*_alertType.get(team)*/type + " is under attack!", 0, 20 * 5, 0, player); + playSound(player); } - if (UtilTime.elapsed(_alerts.get(team), UtilTime.convert(5, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) + /*if (UtilTime.elapsed(_alerts.get(team), UtilTime.convert(5, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) { _alerts.remove(team); _alertType.remove(team); - } - } + }*/ + //} + } + + private void playSound(Player player) + { + player.playNote(player.getLocation(), Instrument.PIANO, Note.sharp(1, Tone.A)); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java index 6eba49f59..3947c4ffb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java @@ -6,17 +6,18 @@ import java.util.LinkedList; import java.util.List; import java.util.concurrent.ConcurrentHashMap; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextMiddle; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.minecraftleague.DataLoc; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; +import nautilus.game.arcade.game.games.minecraftleague.data.objectives.KillObjective; import nautilus.game.arcade.world.WorldData; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; +import org.bukkit.entity.Player; import org.bukkit.event.Listener; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; public class TowerManager implements Listener { @@ -25,7 +26,9 @@ public class TowerManager implements Listener private ConcurrentHashMap _vulnerableTower = new ConcurrentHashMap(); private ConcurrentHashMap _def = new ConcurrentHashMap(); //private ConcurrentHashMap _mapZone = new ConcurrentHashMap(); + private ConcurrentHashMap _beacons = new ConcurrentHashMap(); private OreGenerator _ore; + public boolean Attack = true; public TowerManager(MinecraftLeague host) { @@ -40,15 +43,16 @@ public class TowerManager implements Listener else _vulnerableTower.put(base.getTeam(), 3); - base.setVulnerable(true);; + base.setVulnerable(true); + _beacons.get(base.getTeam()).setBlock(base.getBeacon().getBlock()); } - private void oreGen(GameTeam team) + public void ironOreGen(GameTeam team) { if (team.GetColor() == ChatColor.RED) - _ore.generateOre(Material.IRON_ORE, Host.WorldData.GetCustomLocs(DataLoc.RED_ORE.getKey()), 150); + _ore.generateOre(Material.IRON_ORE, Host.WorldData.GetCustomLocs(DataLoc.RED_ORE.getKey()), 30); else - _ore.generateOre(Material.IRON_ORE, Host.WorldData.GetCustomLocs(DataLoc.BLUE_ORE.getKey()), 150); + _ore.generateOre(Material.IRON_ORE, Host.WorldData.GetCustomLocs(DataLoc.BLUE_ORE.getKey()), 30); } private List getAllTeamTowers(GameTeam team) @@ -148,10 +152,14 @@ public class TowerManager implements Listener _mapZone.put(tower, zone);*/ } + _beacons.put(red, new TeamBeacon(red, getTeamTowers(red).getFirst().getBeacon().getBlock())); + _beacons.put(blue, new TeamBeacon(blue, getTeamTowers(blue).getFirst().getBeacon().getBlock())); + Host.Beacons.put(red, _beacons.get(red)); + Host.Beacons.put(blue, _beacons.get(blue)); makeVulnerable(getTeamTowers(red).getFirst()); makeVulnerable(getTeamTowers(blue).getFirst()); - oreGen(red); - oreGen(blue); + ironOreGen(red); + ironOreGen(blue); } public void prepareHealth(int players, double multiplier) @@ -162,8 +170,9 @@ public class TowerManager implements Listener tower.setMaxHealth(players * multiplier); else { + int divisor = 3 - ((TeamTower)tower).Number; double rawHealth = (.67 * multiplier) * players; - Double health = new BigDecimal(rawHealth).intValue() * 1D; + Double health = new BigDecimal(rawHealth / divisor).intValue() * 1D; tower.setMaxHealth(health); } } @@ -172,21 +181,40 @@ public class TowerManager implements Listener public void handleTowerDeath(TeamTowerBase towerBase) { towerBase.setVulnerable(false); - oreGen(towerBase.getTeam()); - Bukkit.getScheduler().runTaskLater(Host.Manager.getPlugin(), new Runnable() + //ironOreGen(towerBase.getTeam()); + for (Player player : towerBase.getTeam().GetPlayers(true)) + { + player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 20 * 60, 1)); + } + /*Bukkit.getScheduler().runTaskLater(Host.Manager.getPlugin(), new Runnable() { public void run() { UtilTextMiddle.display("", towerBase.getTeam().GetColor() + towerBase.getTeam().GetName() + " Team ores have been replenished!", UtilServer.getPlayers()); } - }, 20 * 5); + }, 20 * 5);*/ //_mapZone.get(towerBase).setValid(false); if (towerBase instanceof TeamCrystal) + { + GameTeam enemy = null; + if (towerBase.getTeam() == Host.GetTeam(ChatColor.RED)) + enemy = Host.GetTeam(ChatColor.AQUA); + else + enemy = Host.GetTeam(ChatColor.RED); + + Host.Objective.setTeamObjective(enemy, new KillObjective()); + return; + } TeamTower tower = (TeamTower)towerBase; makeVulnerable(getTeamTowers(tower.getTeam()).get(tower.Number)); } + public void toggleAttack() + { + Attack = !Attack; + } + public void update() { for (TeamTowerBase tower : _towers.keySet()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/objectives/GearObjective.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/objectives/GearObjective.java new file mode 100644 index 000000000..1c7c72621 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/objectives/GearObjective.java @@ -0,0 +1,11 @@ +package nautilus.game.arcade.game.games.minecraftleague.data.objectives; + +import nautilus.game.arcade.game.games.minecraftleague.objective.GameObjective; + +public class GearObjective extends GameObjective +{ + public GearObjective() + { + super("GEAR", "Gear Up"); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/objectives/KillObjective.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/objectives/KillObjective.java new file mode 100644 index 000000000..938d09e7d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/objectives/KillObjective.java @@ -0,0 +1,12 @@ +package nautilus.game.arcade.game.games.minecraftleague.data.objectives; + +import nautilus.game.arcade.game.games.minecraftleague.objective.GameObjective; + +public class KillObjective extends GameObjective +{ + public KillObjective() + { + super("KILL_ENEMY", "Kill Enemy"); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/objective/GameObjective.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/objective/GameObjective.java new file mode 100644 index 000000000..54c633da3 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/objective/GameObjective.java @@ -0,0 +1,23 @@ +package nautilus.game.arcade.game.games.minecraftleague.objective; + + +public abstract class GameObjective +{ + private String _displayText, _id; + + public GameObjective(String id, String displayText) + { + _id = id; + _displayText = displayText; + } + + public String getID() + { + return _id; + } + + public String getDisplayText() + { + return _displayText; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/objective/ObjectiveManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/objective/ObjectiveManager.java new file mode 100644 index 000000000..7ec6ee923 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/objective/ObjectiveManager.java @@ -0,0 +1,122 @@ +package nautilus.game.arcade.game.games.minecraftleague.objective; + +import java.util.concurrent.ConcurrentHashMap; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; + +public class ObjectiveManager implements Listener +{ + private MinecraftLeague _host; + private GameObjective _main; + private ConcurrentHashMap _specificObjectives = new ConcurrentHashMap(); + private ConcurrentHashMap _teamObjectives = new ConcurrentHashMap(); + + public ObjectiveManager(MinecraftLeague host) + { + _host = host; + Bukkit.getPluginManager().registerEvents(this, _host.getArcadeManager().getPlugin()); + } + + private void displayObjective(Player player) + { + GameObjective obj = _main; + if (_teamObjectives.containsKey(_host.GetTeam(player))) + obj = _teamObjectives.get(_host.GetTeam(player)); + if (_specificObjectives.containsKey(player)) + obj = _specificObjectives.get(player); + + UtilTextBottom.display(C.cGold + "Objective: " + obj.getDisplayText(), player); + } + + public String getMainObjective() + { + return _main.getID(); + } + + public String getTeamObjective(GameTeam team) + { + if (_teamObjectives.containsKey(team)) + return _teamObjectives.get(team).getID(); + + return getMainObjective(); + } + + public String getPlayerObjective(Player player) + { + if (_specificObjectives.containsKey(player)) + return _specificObjectives.get(player).getID(); + + return getTeamObjective(_host.GetTeam(player)); + } + + public void setMainObjective(GameObjective objective) + { + _main = objective; + } + + public void setPlayerObjective(Player player, GameObjective objective) + { + resetPlayerToMainObjective(player); + _specificObjectives.put(player, objective); + } + + public void resetPlayerToMainObjective(Player player) + { + if (!_specificObjectives.containsKey(player)) + return; + _specificObjectives.remove(player); + } + + public void setTeamObjective(GameTeam team, GameObjective objective) + { + resetTeamToMainObjective(team); + _teamObjectives.put(team, objective); + } + + public void resetTeamToMainObjective(GameTeam team) + { + if (!_teamObjectives.containsKey(team)) + return; + _teamObjectives.remove(team); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (!_host.IsLive()) + return; + if (event.getType() != UpdateType.FASTEST) + return; + + for (Player player : _host.GetPlayers(true)) + { + if (_main != null || _specificObjectives.containsKey(player)) + displayObjective(player); + } + } + + @EventHandler + public void handleDeregister(GameStateChangeEvent event) + { + if (event.GetGame() != _host) + return; + + if (event.GetState() != GameState.Dead) + return; + + HandlerList.unregisterAll(this); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java index 66ffe6835..f350e63fb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java @@ -9,7 +9,6 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.itemstack.ItemBuilder; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.PlayerGameRespawnEvent; @@ -17,10 +16,12 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.minecraftleague.DataLoc; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; import nautilus.game.arcade.game.games.minecraftleague.data.TeamTowerBase; +import nautilus.game.arcade.game.games.minecraftleague.data.objectives.GearObjective; import nautilus.game.arcade.game.games.minecraftleague.variation.GameVariation; import nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.TeamAltar; import nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.WitherMinionManager; import nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.WitherPathfinder; +import nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.objectives.WitherObjective; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -139,6 +140,8 @@ public class WitherVariation extends GameVariation _wowner = null; _skellyMan.onWitherDeath(); UtilTextMiddle.display("", C.cGray + "The Mighty Wither has fallen!"); + Host.Objective.resetTeamToMainObjective(Host.GetTeam(ChatColor.RED)); + Host.Objective.resetTeamToMainObjective(Host.GetTeam(ChatColor.AQUA)); } } } @@ -180,9 +183,16 @@ public class WitherVariation extends GameVariation _wither = (Wither)event.getEntity(); _wither.setCustomName(team.GetColor() + team.getDisplayName() + "'s Wither"); _wither.setCustomNameVisible(true); - UtilTextMiddle.display("", team.GetColor() + team.getDisplayName() + " Team has spawned a Wither Boss!", UtilServer.getPlayers()); + UtilTextMiddle.display("", C.cBlack + team.getDisplayName() + " Team has spawned a Wither Boss!", UtilServer.getPlayers()); _pathfinder = new WitherPathfinder(this, _wither, getWaypoints(_altars.get(team).getLocation()), team, enemy, Host.getTowerManager()); _skellyMan.onWitherSpawn(); + Host.Objective.setMainObjective(new GearObjective()); + Host.Objective.setTeamObjective(team, new WitherObjective("Attack Enemy Towers")); + Host.Objective.setTeamObjective(enemy, new WitherObjective("Kill Wither")); + for (Player player : Host.GetPlayers(true)) + { + Host.Objective.resetPlayerToMainObjective(player); + } Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() { public void run() @@ -213,7 +223,7 @@ public class WitherVariation extends GameVariation } } - @SuppressWarnings("deprecation") + //@SuppressWarnings("deprecation") @EventHandler public void onExplode(EntityExplodeEvent event) { @@ -271,7 +281,7 @@ public class WitherVariation extends GameVariation continue; if (b.getType() == Material.STATIONARY_LAVA || b.getType() == Material.LAVA) continue; - WorldData.World.dropItem(b.getLocation(), new ItemBuilder(b.getType()).setData(b.getData()).build()); + //WorldData.World.dropItem(b.getLocation(), new ItemBuilder(b.getType()).setData(b.getData()).build()); b.setType(Material.AIR); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java index 68fe40d4d..7303a93f6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java @@ -7,6 +7,7 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilShapes; import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.hologram.Hologram; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.minecraftleague.variation.wither.WitherVariation; @@ -40,6 +41,11 @@ public class TeamAltar spawnSoulsand(); _protected = UtilShapes.getSphereBlocks(center, 7, 7, false); + + Location labelLoc = center.clone().add(0.5, 5, 0.5); + String labelStr = team.GetColor() + team.getDisplayName() + "'s Altar"; + Hologram label = new Hologram(host.Host.getArcadeManager().getHologramManager(), labelLoc, labelStr); + label.start(); } public boolean isInsideAltar(Location location) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java index 5fd8d75d0..9e7bcc880 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java @@ -13,7 +13,6 @@ import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilShapes; -import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; @@ -23,7 +22,10 @@ import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.minecraftleague.data.MapZone; +import nautilus.game.arcade.game.games.minecraftleague.data.objectives.GearObjective; import nautilus.game.arcade.game.games.minecraftleague.variation.wither.WitherVariation; +import nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.objectives.GrabSkullObjective; +import nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.objectives.ReturnSkullObjective; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -131,6 +133,7 @@ public class WitherMinionManager implements Listener UtilTextMiddle.display("", C.cGray + "A Wither Skeleton has spawned!"); _skellyZone.setCenter(chosen); _skellyZone.setValid(true); + _host.Host.Objective.setMainObjective(new GrabSkullObjective()); } _selected = -1; _spawned = true; @@ -138,13 +141,15 @@ public class WitherMinionManager implements Listener public void onWitherDeath() { - _lastDied = System.currentTimeMillis() - UtilTime.convert(20, TimeUnit.SECONDS, TimeUnit.MINUTES); + _lastDied = System.currentTimeMillis() + UtilTime.convert(2, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); _witherBlocked = false; + _host.Host.getTowerManager().toggleAttack(); _sbTimer.freezeTime(-1); } public void onWitherSpawn() { + _host.Host.getTowerManager().toggleAttack(); _witherBlocked = true; if (_entity != null) { @@ -198,11 +203,25 @@ public class WitherMinionManager implements Listener boolean noUse = _host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.RED)) < 1; if (_host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.AQUA)) >= 1) noUse = false; - if (!_host.WitherSpawned || noUse) + if (!_host.WitherSpawned || !noUse) { if (_entity == null) + { if (_selected != _lastUsed) + { preSpawn(); + } + long end = _lastDied + UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); + end =- System.currentTimeMillis(); + long secLeft = UtilTime.convert(end, TimeUnit.MILLISECONDS, TimeUnit.SECONDS); + if (secLeft <= 3) + { + if (secLeft > 0) + { + UtilTextMiddle.display(C.cGold + secLeft + " Seconds", C.cGray + "Until Wither Skeleton Spawn"); + } + } + } } } @@ -211,7 +230,7 @@ public class WitherMinionManager implements Listener boolean noUse = _host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.RED)) < 1; if (_host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.AQUA)) >= 1) noUse = false; - if (!_host.WitherSpawned || noUse) + if (!_host.WitherSpawned || !noUse) { if (_entity == null) spawn(false); @@ -222,12 +241,23 @@ public class WitherMinionManager implements Listener { if (UtilInv.contains(player, Material.SKULL_ITEM, (byte) 1, 1)) { - UtilTextBottom.display(C.cRed + "Return the Skull to your base!", player); for (Location loc : UtilShapes.getSphereBlocks(player.getLocation(), 3, 3, true)) { UtilParticle.PlayParticleToAll(ParticleType.PORTAL, loc, null, 0, 2, ViewDist.MAX); } + for (Location loc : UtilShapes.getCircle(player.getLocation(), true, 1)) + { + UtilParticle.PlayParticleToAll(ParticleType.DRIP_LAVA, loc, null, 0, 1, ViewDist.MAX); + } } + else + { + if (_host.Host.Objective.getPlayerObjective(player).equalsIgnoreCase("GRAB_SKULL")) + { + _host.Host.Objective.resetPlayerToMainObjective(player); + } + } + if (player.getInventory().getHelmet() != null) { if (UtilInv.IsItem(player.getInventory().getHelmet(), Material.SKULL_ITEM, (byte) 1)) @@ -296,6 +326,8 @@ public class WitherMinionManager implements Listener _cb.setType(_changed); _cb = null; _changed = Material.AIR; + + _host.Host.Objective.setMainObjective(new GearObjective()); } } } @@ -319,6 +351,15 @@ public class WitherMinionManager implements Listener if (fin.equalsIgnoreCase(fin1)) { UtilPlayer.message(event.getPlayer(), F.main("Game", "You have the Wither Skull! Return the skull to your base and place it on your Altar to summon the Wither!")); + UtilTextMiddle.display("", C.cGray + "You have picked up the Wither Skull!", event.getPlayer()); + Bukkit.getScheduler().runTaskLater(_host.Manager.getPlugin(), new Runnable() + { + public void run() + { + UtilTextMiddle.display("", C.cGold + "Place the skull on top of your Altar's Soulsand!", event.getPlayer()); + } + }, 20 * 5); + _host.Host.Objective.setPlayerObjective(event.getPlayer(), new ReturnSkullObjective()); if (!event.getItem().hasMetadata("Dropped")) UtilTextMiddle.display("", _host.Host.GetTeam(event.getPlayer()).GetColor() + _host.Host.GetTeam(event.getPlayer()).getDisplayName() + " has picked up a Wither Skull!", 20, 20 * 5, 20); } @@ -342,6 +383,7 @@ public class WitherMinionManager implements Listener if (fin.equalsIgnoreCase(fin1)) { event.getItemDrop().setMetadata("Dropped", new FixedMetadataValue(_host.Manager.getPlugin(), true)); + _host.Host.Objective.resetPlayerToMainObjective(event.getPlayer()); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/objectives/GrabSkullObjective.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/objectives/GrabSkullObjective.java new file mode 100644 index 000000000..1b66bee30 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/objectives/GrabSkullObjective.java @@ -0,0 +1,11 @@ +package nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.objectives; + +import nautilus.game.arcade.game.games.minecraftleague.objective.GameObjective; + +public class GrabSkullObjective extends GameObjective +{ + public GrabSkullObjective() + { + super("GRAB_SKULL", "Collect Wither Skull"); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/objectives/ReturnSkullObjective.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/objectives/ReturnSkullObjective.java new file mode 100644 index 000000000..5b5958601 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/objectives/ReturnSkullObjective.java @@ -0,0 +1,12 @@ +package nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.objectives; + +import nautilus.game.arcade.game.games.minecraftleague.objective.GameObjective; + +public class ReturnSkullObjective extends GameObjective +{ + public ReturnSkullObjective() + { + super("RETURN_SKULL", "Return the Skull to your Altar!"); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/objectives/WitherObjective.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/objectives/WitherObjective.java new file mode 100644 index 000000000..d7dc13823 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/objectives/WitherObjective.java @@ -0,0 +1,11 @@ +package nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.objectives; + +import nautilus.game.arcade.game.games.minecraftleague.objective.GameObjective; + +public class WitherObjective extends GameObjective +{ + public WitherObjective(String instruction) + { + super("WITHER_OBJ", instruction); + } +} From 4ae4f056eac36d20531a13bf120d7b2c99764875 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 31 Mar 2016 03:46:43 -0400 Subject: [PATCH 31/47] - Map Polish --- .../game/games/minecraftleague/data/map/ItemMapManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/map/ItemMapManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/map/ItemMapManager.java index d39014967..531083ae2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/map/ItemMapManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/map/ItemMapManager.java @@ -453,8 +453,8 @@ public class ItemMapManager /*extends MiniPlugin*/ implements Listener Player p = event.getPlayer(); p.sendMessage(C.cDRed + C.Bold + "WARNING!"); - p.sendMessage(C.cYellow + "There's a bug where switching servers will freeze the Team Map!"); - p.sendMessage(C.cYellow + "If you want to play Minecraft League again, rejoin the Mineplex server!"); + p.sendMessage(C.cYellow + "There's a bug where switching servers may freeze the Team Map!"); + p.sendMessage(C.cYellow + "If you want to play Minecraft League again and this error occurs, rejoin the Mineplex server!"); } private void rebuildScan() From 33b557eb100a31a1d61c7f5bfb58a7884bc6e5a4 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 14 Apr 2016 22:45:21 -0400 Subject: [PATCH 32/47] - Huuuuuuuge amount of changes for chiss --- .../mineplex/core/common/util/UtilEvent.java | 10 + .../core/achievement/Achievement.java | 19 + .../core/achievement/AchievementCategory.java | 5 + .../game/core/combat/CombatManager.java | 5 + .../game/games/minecraftleague/DataLoc.java | 2 + .../minecraftleague/MinecraftLeague.java | 396 +++++++++++++----- .../minecraftleague/data/BlockProtection.java | 9 +- .../minecraftleague/data/DefenderAI.java | 16 +- .../minecraftleague/data/OreGenerator.java | 2 + .../minecraftleague/data/ProtectionUtil.java | 16 + .../minecraftleague/data/TeamTowerBase.java | 23 +- .../minecraftleague/data/TowerAlert.java | 17 +- .../minecraftleague/data/TowerManager.java | 57 ++- .../data/map/ItemMapRenderer.java | 18 +- .../objective/ObjectiveManager.java | 5 +- .../tracker/AltarBuilderTracker.java | 21 + .../tracker/FirstStrikeTracker.java | 22 + .../tracker/GrabSkullEvent.java | 31 ++ .../tracker/HeadHunterTracker.java | 21 + .../tracker/PlaceSkullEvent.java | 31 ++ .../variation/wither/WitherVariation.java | 47 ++- .../variation/wither/data/TeamAltar.java | 6 +- .../wither/data/WitherMinionManager.java | 155 ++++--- .../game/arcade/managers/GameFlagManager.java | 56 ++- 24 files changed, 766 insertions(+), 224 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/ProtectionUtil.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/AltarBuilderTracker.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/FirstStrikeTracker.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/GrabSkullEvent.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/HeadHunterTracker.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/PlaceSkullEvent.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEvent.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEvent.java index bd5346696..c4bb681a8 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEvent.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEvent.java @@ -1,5 +1,6 @@ package mineplex.core.common.util; +import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Projectile; import org.bukkit.event.block.Action; @@ -46,6 +47,15 @@ public class UtilEvent return false; } + public static boolean isBowDamage(EntityDamageEvent event) + { + if (!(event instanceof EntityDamageByEntityEvent)) + return false; + + EntityDamageByEntityEvent e = (EntityDamageByEntityEvent)event; + return e.getDamager() instanceof Arrow; + } + public static LivingEntity GetDamagerEntity(EntityDamageEvent event, boolean ranged) { if (!(event instanceof EntityDamageByEntityEvent)) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index ad8b468ac..7a8a8d839 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -164,6 +164,25 @@ public enum Achievement new int[]{10}, AchievementCategory.UHC), + //Minecraft League + MINECRAFT_LEAGUE_STRIKE("First Strike", 600, + new String[] {"Minecraft League.FirstStrike"}, + new String[] {"Earn 30 First Bloods"}, + new int[] {30}, + AchievementCategory.MINECRAFT_LEAGUE), + + MINECRAFT_LEAGUE_HEAD("Head Hunter", 600, + new String[] {"Minecraft League.HeadHunter"}, + new String[] {"Grab 25 Wither Skulls"}, + new int[] {25}, + AchievementCategory.MINECRAFT_LEAGUE), + + MINECRAFT_LEAGUE_ALTAR("Altar Builder", 600, + new String[] {"Minecraft League.AltarBuilder"}, + new String[] {"Place 50 Wither Skulls", "on your Altar"}, + new int[] {50}, + AchievementCategory.MINECRAFT_LEAGUE), + //UHC WIZARDS_WINS("Supreme Wizard", 600, new String[]{"Wizards.Wins"}, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index ca55d520f..784ed7aa4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -6,6 +6,7 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilTime; +import mineplex.core.game.GameCategory; import mineplex.core.game.GameDisplay; import mineplex.core.stats.PlayerStats; import mineplex.core.stats.StatsManager; @@ -48,6 +49,10 @@ public enum AchievementCategory UHC("Ultra Hardcore", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, Material.GOLDEN_APPLE, 0, GameCategory.SURVIVAL, "None"), + + MINECRAFT_LEAGUE("Minecraft League", null, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, + Material.IRON_CHESTPLATE, 0, GameCategory.SURVIVAL, "None"), WIZARDS("Wizards", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java index 221a70fbe..e8cd54e15 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/combat/CombatManager.java @@ -114,6 +114,11 @@ public class CombatManager extends MiniPlugin break; } + if (UtilEvent.isBowDamage(event)) + { + cause = "Bow"; + } + if (damagerEnt instanceof Player) { if (event.getCause() == DamageCause.ENTITY_ATTACK) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/DataLoc.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/DataLoc.java index f2ee0a89b..8ca22140e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/DataLoc.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/DataLoc.java @@ -17,6 +17,8 @@ public enum DataLoc BLUE_ORE("14"), DIAMOND_ORE("56"), COAL_ORE("16"), + MOSH_IRON("129"), + GRIND_AREA(" GRIND"), //Wither WITHER_WAYPOINT("PURPLE"), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index 24f01e5fd..8f4c70c97 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -6,7 +6,6 @@ import java.util.concurrent.ConcurrentHashMap; import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilItem; @@ -24,9 +23,9 @@ import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; 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.events.PlayerGameRespawnEvent; import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.minecraftleague.commands.MinecraftLeagueCommand; import nautilus.game.arcade.game.games.minecraftleague.commands.freeze.FreezeManager; @@ -39,9 +38,10 @@ import nautilus.game.arcade.game.games.minecraftleague.data.TeamTowerBase; import nautilus.game.arcade.game.games.minecraftleague.data.TowerAlert; import nautilus.game.arcade.game.games.minecraftleague.data.TowerManager; import nautilus.game.arcade.game.games.minecraftleague.data.map.ItemMapManager; -import nautilus.game.arcade.game.games.minecraftleague.data.objectives.GearObjective; import nautilus.game.arcade.game.games.minecraftleague.kit.KitPlayer; -import nautilus.game.arcade.game.games.minecraftleague.objective.ObjectiveManager; +import nautilus.game.arcade.game.games.minecraftleague.tracker.AltarBuilderTracker; +import nautilus.game.arcade.game.games.minecraftleague.tracker.FirstStrikeTracker; +import nautilus.game.arcade.game.games.minecraftleague.tracker.HeadHunterTracker; import nautilus.game.arcade.game.games.minecraftleague.variation.ExtraScoreboardData; import nautilus.game.arcade.game.games.minecraftleague.variation.GameVariation; import nautilus.game.arcade.game.games.minecraftleague.variation.VariationManager; @@ -54,12 +54,13 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.block.BlockFace; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Arrow; import org.bukkit.entity.Enderman; import org.bukkit.entity.EntityType; import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; @@ -67,6 +68,8 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockDispenseEvent; +import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; @@ -80,6 +83,7 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; @@ -87,9 +91,10 @@ import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.material.Dispenser; +import org.bukkit.material.MaterialData; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import org.bukkit.util.Vector; import com.google.common.base.Objects; @@ -99,6 +104,7 @@ public class MinecraftLeague extends TeamGame //private ConcurrentHashMap _maps = new ConcurrentHashMap(); private ConcurrentHashMap> _gear = new ConcurrentHashMap>(); public ConcurrentHashMap Beacons = new ConcurrentHashMap(); + //public ConcurrentHashMap TeamPoison = new ConcurrentHashMap(); private ConcurrentHashMap _blockLock = new ConcurrentHashMap(); //private ConcurrentHashMap _spawnAllow = new ConcurrentHashMap(); private List _spawners = new ArrayList(); @@ -116,12 +122,12 @@ public class MinecraftLeague extends TeamGame public boolean OverTime = false; private VariationManager _vman; - public ObjectiveManager Objective; + //public ObjectiveManager Objective; private FreezeManager _freeze; private TowerManager _tower; public TowerAlert Alert; - private final EntityType[] _passive = new EntityType[] {EntityType.CHICKEN, EntityType.COW, EntityType.PIG, EntityType.RABBIT, EntityType.SHEEP}; + //private final EntityType[] _passive = new EntityType[] {EntityType.CHICKEN, EntityType.COW, EntityType.PIG, EntityType.RABBIT, EntityType.SHEEP}; public MinecraftLeague(ArcadeManager manager) { @@ -141,12 +147,12 @@ public class MinecraftLeague extends TeamGame C.cWhite + "Last team standing wins", }); - this.DeathOut = false; + this.DeathOut = true; this.DamageSelf = false; - this.DeathSpectateSecs = 5; + this.DeathSpectateSecs = 10; this.WorldBoundaryKill = true; this.DeathDropItems = true; - this.CreatureAllow = true; + this.CreatureAllow = false; this.HungerSet = 20; this.BlockBreak = true; @@ -181,11 +187,13 @@ public class MinecraftLeague extends TeamGame registerStatTrackers( - + new AltarBuilderTracker(this), + new FirstStrikeTracker(this), + new HeadHunterTracker(this) ); _vman = new VariationManager(this); - Objective = new ObjectiveManager(this); + //Objective = new ObjectiveManager(this); _freeze = new FreezeManager(); _tower = new TowerManager(this); Alert = new TowerAlert(); @@ -617,12 +625,12 @@ public class MinecraftLeague extends TeamGame _lastOreReset = System.currentTimeMillis(); Manager.GetExplosion().setEnabled(false); Manager.GetDamage().SetEnabled(false); - Manager.GetCreature().SetForce(true); + Manager.GetCreature().SetForce(false); Manager.GetCreature().SetDisableCustomDrops(true); _cmd = new MinecraftLeagueCommand(Manager, this); Manager.addCommand(_cmd); Manager.getGameChatManager().TeamSpy = false; - Objective.setMainObjective(new GearObjective()); + //Objective.setMainObjective(new GearObjective()); } if (event.GetState() == GameState.End) @@ -734,20 +742,26 @@ public class MinecraftLeague extends TeamGame //Alert.update(); + /*for (GameTeam dmg : TeamPoison.keySet()) + { + if (UtilTime.elapsed(TeamPoison.get(dmg), UtilTime.convert(1, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) + { + TeamPoison.put(dmg, System.currentTimeMillis()); + for (Player player : dmg.GetPlayers(true)) + { + this.storeGear(player); + player.damage(1); + } + } + }*/ + if (UtilTime.elapsed(_lastOreReset, UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS))) { _lastOreReset = System.currentTimeMillis(); - for (Location loc : WorldData.GetCustomLocs(DataLoc.DIAMOND_ORE.getKey())) - { - loc.getBlock().setType(Material.DIAMOND_ORE); - } for (Location loc : WorldData.GetCustomLocs(DataLoc.COAL_ORE.getKey())) { loc.getBlock().setType(Material.COAL_ORE); } - _tower.ironOreGen(GetTeam(ChatColor.RED)); - _tower.ironOreGen(GetTeam(ChatColor.AQUA)); - UtilTextMiddle.display("", C.cGold + "All Ores have been refreshed!"); } if (!OverTime) @@ -762,7 +776,34 @@ public class MinecraftLeague extends TeamGame if (UtilTime.elapsed(_lastIncrease, UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS))) { _lastIncrease = System.currentTimeMillis(); - this.DeathSpectateSecs = Math.max(0, this.DeathSpectateSecs + 2.5); + this.DeathSpectateSecs = Math.min(20, this.DeathSpectateSecs + 2.5); + } + + for (Location grind : WorldData.GetCustomLocs(DataLoc.GRIND_AREA.getKey())) + { + int spider = 0; + int chicken = 0; + for (LivingEntity le : UtilEnt.getInRadius(grind, 15).keySet()) + { + if (le.getType() == EntityType.SPIDER) + spider++; + if (le.getType() == EntityType.CHICKEN) + chicken++; + } + while (spider < 5) + { + spider++; + CreatureAllowOverride = true; + Manager.GetCreature().SpawnEntity(grind, EntityType.SPIDER); + CreatureAllowOverride = false; + } + while (chicken < 10) + { + chicken++; + CreatureAllowOverride = true; + Manager.GetCreature().SpawnEntity(grind, EntityType.CHICKEN); + CreatureAllowOverride = false; + } } /*for (Player player : _spawnAllow.keySet()) @@ -852,10 +893,10 @@ public class MinecraftLeague extends TeamGame if (!tower.canDamage(player)) return; - if (!tower.Vulnerable) + //if (!tower.Vulnerable) { - UtilPlayer.message(player, F.main("Game", "That Tower is protected by the power of another!")); - return; + //UtilPlayer.message(player, F.main("Game", "That Tower is protected by the power of another!")); + //return; } if (!tower.damage(event.getDamage() / 2, player)) @@ -873,10 +914,10 @@ public class MinecraftLeague extends TeamGame if (!tower.canDamage(player)) return; - if (!tower.Vulnerable) + //if (!tower.Vulnerable) { - UtilPlayer.message(player, F.main("Game", "That Tower is protected by the power of another!")); - return; + //UtilPlayer.message(player, F.main("Game", "That Tower is protected by the power of another!")); + //return; } if (player.getItemInHand() == null || player.getItemInHand().getType() == Material.AIR) @@ -936,6 +977,27 @@ public class MinecraftLeague extends TeamGame _customRespawns.put(player, new PlayerRespawnPoint(player, event.getClickedBlock().getLocation())); }*/ + private boolean isLocked(Block block) + { + for (BlockProtection prot : _blockLock.values()) + { + if (prot.hasBlock(block)) + return true; + } + return false; + } + + private Player getOwner(Block block) + { + for (Player player : _blockLock.keySet()) + { + if (_blockLock.get(player).hasBlock(block)) + return player; + } + + return null; + } + private boolean isLockedTo(Block block, Player to, boolean ignoreTeam) { for (BlockProtection prot : _blockLock.values()) @@ -963,7 +1025,7 @@ public class MinecraftLeague extends TeamGame return; Block block = event.getBlock(); - if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST || block.getType() == Material.FURNACE) + if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST || block.getType() == Material.FURNACE || block.getType() == Material.BURNING_FURNACE) _blockLock.get(event.getPlayer()).lockBlock(block); } @@ -973,10 +1035,16 @@ public class MinecraftLeague extends TeamGame if (!IsLive()) return; - if (isLockedTo(event.getBlock(), event.getPlayer(), true)) - _blockLock.get(event.getPlayer()).unlockBlock(event.getBlock()); + if (!isLocked(event.getBlock())) + return; + + if (!isLockedTo(event.getBlock(), event.getPlayer(), false)) + _blockLock.get(getOwner(event.getBlock())).unlockBlock(event.getBlock()); else + { + UtilPlayer.message(event.getPlayer(), F.main("Game", "That container is locked by " + getOwner(event.getBlock()).getName() + "!")); event.setCancelled(true); + } } @EventHandler @@ -999,11 +1067,21 @@ public class MinecraftLeague extends TeamGame Block block = event.getClickedBlock(); - if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST || block.getType() == Material.FURNACE) + if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST || block.getType() == Material.FURNACE || block.getType() == Material.BURNING_FURNACE) { + if (!isLocked(block)) + { + if (event.getPlayer().isSneaking()) + { + _blockLock.get(event.getPlayer()).lockBlock(block); + return; + } + } + if (isLockedTo(event.getClickedBlock(), event.getPlayer(), false)) { event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main("Game", "That container is locked by " + getOwner(event.getClickedBlock()).getName() + "!")); return; } if (isOwner(event.getClickedBlock(), event.getPlayer())) @@ -1014,13 +1092,6 @@ public class MinecraftLeague extends TeamGame return; } } - if (!isOwner(event.getClickedBlock(), event.getPlayer())) - { - if (!isLockedTo(event.getClickedBlock(), event.getPlayer(), true)) - { - _blockLock.get(event.getPlayer()).lockBlock(event.getClickedBlock()); - } - } } } @@ -1154,6 +1225,7 @@ public class MinecraftLeague extends TeamGame if (!IsLive()) return; + event.getEntity().setHealth(event.getEntity().getMaxHealth()); List newDrops = new ArrayList(); Integer arrows = 0; @@ -1221,7 +1293,7 @@ public class MinecraftLeague extends TeamGame } if (event.getInventory().getResult().getType() == Material.ARROW) { - event.getInventory().setResult(new ItemStack(Material.ARROW, (event.getInventory().getResult().getAmount() * 2))); + event.getInventory().setResult(new ItemStack(Material.ARROW, (event.getInventory().getResult().getAmount() * 4))); } if (event.getInventory().getResult().getType() == Material.FLINT_AND_STEEL) { @@ -1241,7 +1313,7 @@ public class MinecraftLeague extends TeamGame event.setCancelled(true); } - @EventHandler + /*@EventHandler public void controlMobRate(CreatureSpawnEvent event) { if (!IsLive()) @@ -1274,7 +1346,7 @@ public class MinecraftLeague extends TeamGame for (int i = 1; i <= 3; i++) Manager.GetCreature().SpawnEntity(event.getLocation(), EntityType.SPIDER); } - } + }*/ @EventHandler public void editHealth(GameStateChangeEvent event) @@ -1357,15 +1429,8 @@ public class MinecraftLeague extends TeamGame } } - @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) - public void storeGear(EntityDamageEvent event) + public void storeGear(Player player) { - if (!IsLive()) - return; - if (!(event.getEntity() instanceof Player)) - return; - - Player player = (Player)event.getEntity(); List gear = new ArrayList(); if (!UtilItem.isDiamondProduct(player.getInventory().getHelmet())) @@ -1398,7 +1463,7 @@ public class MinecraftLeague extends TeamGame else gear.add(new ItemStack(Material.AIR)); - if (UtilInv.contains(player, Material.BOW, (byte) 0, 1)) + if (UtilInv.getAmount(player, Material.BOW) >= 1) { for (ItemStack poss : UtilInv.getItems(player)) { @@ -1410,6 +1475,18 @@ public class MinecraftLeague extends TeamGame } } + if (UtilInv.getAmount(player, Material.FISHING_ROD) >= 1) + { + for (ItemStack poss : UtilInv.getItems(player)) + { + if (poss.getType() == Material.FISHING_ROD) + { + gear.add(poss); + break; + } + } + } + int arrowsToAdd = UtilInv.getAmount(player, Material.ARROW) / 2; while (arrowsToAdd >= 1) { @@ -1421,6 +1498,18 @@ public class MinecraftLeague extends TeamGame _gear.put(player, gear); } + @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) + public void storeGear(EntityDamageEvent event) + { + if (!IsLive()) + return; + if (!(event.getEntity() instanceof Player)) + return; + + Player player = (Player)event.getEntity(); + storeGear(player); + } + @EventHandler public void blockDeadPvt(PrivateMessageEvent event) { @@ -1491,6 +1580,29 @@ public class MinecraftLeague extends TeamGame } } + @EventHandler(priority = EventPriority.HIGHEST) + public void handleDeath(PlayerDeathOutEvent event) + { + if (!IsLive()) + return; + + if (_tower.getAmountAlive(GetTeam(event.GetPlayer())) >= 1) + { + if (OverTime) + { + _tower.getVulnerable(GetTeam(event.GetPlayer())).damage(20, null); + if (_tower.getAmountAlive(GetTeam(event.GetPlayer())) >= 1) + { + event.setCancelled(true); + } + } + else + { + event.setCancelled(true); + } + } + } + @EventHandler(priority = EventPriority.HIGHEST) public void handleDeath(CombatDeathEvent event) { @@ -1498,69 +1610,6 @@ public class MinecraftLeague extends TeamGame return; event.SetBroadcastType(DeathMessageType.Detailed); - - if (event.GetLog().GetPlayer() == null) - return; - if (Bukkit.getPlayer(event.GetLog().GetPlayer().GetName()) == null) - return; - Player player = Bukkit.getPlayer(event.GetLog().GetPlayer().GetName()); - - if (_tower.getAmountAlive(GetTeam(player)) < 1) - { - SetPlayerState(player, PlayerState.OUT); - - Manager.GetCondition().Factory().Blind("PermDead", player, player, 1.5, 0, false, false, false); - Manager.GetCondition().Factory().Cloak("PermDead", player, player, 9999, false, false); - - player.setAllowFlight(true); - player.setFlying(true); - ((CraftPlayer)player).getHandle().spectating = true; - ((CraftPlayer)player).getHandle().k = false; - - UtilAction.velocity(player, new Vector(0,1.2,0)); - - //getMap(GetTeam(player)).update(player); - player.getInventory().clear(); - player.getInventory().setArmorContents(new ItemStack[] - { - new ItemStack(Material.AIR), - new ItemStack(Material.AIR), - new ItemStack(Material.AIR), - new ItemStack(Material.AIR) - }); - return; - } - - if (OverTime) - { - _tower.getVulnerable(GetTeam(player)).damage(20, null); - if (_tower.getAmountAlive(GetTeam(player)) < 1) - { - SetPlayerState(player, PlayerState.OUT); - - Manager.GetCondition().Factory().Blind("PermDead", player, player, 1.5, 0, false, false, false); - Manager.GetCondition().Factory().Cloak("PermDead", player, player, 9999, false, false); - - player.setAllowFlight(true); - player.setFlying(true); - ((CraftPlayer)player).getHandle().spectating = true; - ((CraftPlayer)player).getHandle().k = false; - - UtilAction.velocity(player, new Vector(0,1.2,0)); - - //getMap(GetTeam(player)).update(player); - player.getInventory().clear(); - player.getInventory().setArmorContents(new ItemStack[] - { - new ItemStack(Material.AIR), - new ItemStack(Material.AIR), - new ItemStack(Material.AIR), - new ItemStack(Material.AIR) - }); - return; - } - } - //_spawnAllow.put(player, System.currentTimeMillis() + UtilTime.convert((long) this.DeathSpectateSecs, TimeUnit.SECONDS, TimeUnit.MILLISECONDS)); } @EventHandler(priority = EventPriority.HIGHEST) @@ -1617,6 +1666,20 @@ public class MinecraftLeague extends TeamGame return; } } + for (TeamTowerBase base : _tower.getTeamTowers(GetTeam(ChatColor.RED))) + { + if (UtilMath.offset(base.getLocation(), event.getBlock().getLocation()) <= 7) + { + event.setCancelled(true); + } + } + for (TeamTowerBase base : _tower.getTeamTowers(GetTeam(ChatColor.AQUA))) + { + if (UtilMath.offset(base.getLocation(), event.getBlock().getLocation()) <= 7) + { + event.setCancelled(true); + } + } } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @@ -1648,6 +1711,21 @@ public class MinecraftLeague extends TeamGame } } + for (TeamTowerBase base : _tower.getTeamTowers(GetTeam(ChatColor.RED))) + { + if (UtilMath.offset(base.getLocation(), event.getBlock().getLocation()) <= 7) + { + event.setCancelled(true); + } + } + for (TeamTowerBase base : _tower.getTeamTowers(GetTeam(ChatColor.AQUA))) + { + if (UtilMath.offset(base.getLocation(), event.getBlock().getLocation()) <= 7) + { + event.setCancelled(true); + } + } + if (event.getBlock().getType() == Material.GRAVEL) { event.setCancelled(true); @@ -1655,4 +1733,92 @@ public class MinecraftLeague extends TeamGame event.getBlock().getWorld().dropItemNaturally(event.getBlock().getLocation(), new ItemStack(Material.FLINT)); } } + + @EventHandler + public void noMonsterLava(BlockFromToEvent event) + { + if (!IsLive()) + return; + + Block block = event.getBlock(); + if (block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA || block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER) + { + Block next = event.getToBlock(); + for (BlockFace bf : BlockFace.values()) + { + if (!next.getRelative(bf).equals(block)) + { + if (block.getType().toString().contains("LAVA")) + { + if (next.getRelative(bf).getType().toString().contains("WATER")) + { + event.setCancelled(true); + } + } + if (block.getType().toString().contains("WATER")) + { + if (next.getRelative(bf).getType().toString().contains("LAVA")) + { + event.setCancelled(true); + } + } + } + } + } + } + + @EventHandler(ignoreCancelled=true) + public void onPlayerEmptyBucket(PlayerBucketEmptyEvent event) + { + if (!IsLive()) + return; + + Player player = event.getPlayer(); + if (player.getItemInHand().getType() == Material.WATER_BUCKET) + { + player.getItemInHand().setType(Material.BUCKET); + Block block = event.getBlockClicked().getRelative(event.getBlockFace()); + if (block.getType().toString().contains("LAVA")) + { + event.setCancelled(true); + return; + } + for (BlockFace bf : BlockFace.values()) + { + if (block.getRelative(bf).getType().toString().contains("LAVA")) + { + event.setCancelled(true); + } + } + } + } + + @EventHandler(ignoreCancelled=true) + public void onBlockDispense(BlockDispenseEvent event) + { + if (!IsLive()) + return; + + if (event.getItem().getType() == Material.WATER_BUCKET) + { + Block dispenser = event.getBlock(); + + MaterialData mat = dispenser.getState().getData(); + Dispenser disp_mat = (Dispenser)mat; + BlockFace face = disp_mat.getFacing(); + Block block = dispenser.getRelative(face); + if (block.getType().toString().contains("LAVA")) + { + event.setCancelled(true); + return; + } + for (BlockFace bf : BlockFace.values()) + { + if (block.getRelative(bf).getType().toString().contains("LAVA")) + { + event.setCancelled(true); + } + } + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/BlockProtection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/BlockProtection.java index 8a0c2741a..05ab6ef57 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/BlockProtection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/BlockProtection.java @@ -30,12 +30,17 @@ public class BlockProtection public boolean hasBlock(Block block) { - return _blocks.contains(block); + for (Block b : _blocks) + { + if (ProtectionUtil.isSameBlock(block, b)) + return true; + } + return false; } public boolean isLockedTo(Player opening, Block block, boolean ignoreTeam) { - if (!_blocks.contains(block)) + if (!hasBlock(block)) return false; if (_host.GetTeam(_player).GetColor() != _host.GetTeam(opening).GetColor()) return ignoreTeam; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/DefenderAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/DefenderAI.java index 53cc0c89f..63d17444a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/DefenderAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/DefenderAI.java @@ -55,6 +55,9 @@ public class DefenderAI private void attack() { + if (!_tower.Vulnerable) + return; + if (_procTime != -1) { if (System.currentTimeMillis() >= _procTime) @@ -67,12 +70,12 @@ public class DefenderAI } if (!_manager.Attack) return; - if (!UtilTime.elapsed(_lastAttack, UtilTime.convert(30, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) + if (!UtilTime.elapsed(_lastAttack, UtilTime.convert(5, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) return; /*if (UtilMath.random.nextDouble() < .75) return;*/ _lastAttack = System.currentTimeMillis(); - _procTime = System.currentTimeMillis() + UtilTime.convert(25, TimeUnit.SECONDS, TimeUnit.MILLISECONDS); + _procTime = System.currentTimeMillis() + UtilTime.convert(4, TimeUnit.SECONDS, TimeUnit.MILLISECONDS); animate(); } @@ -90,8 +93,9 @@ public class DefenderAI if (UtilPlayer.isSpectator(player)) continue; + _manager.Host.storeGear(player); player.getWorld().strikeLightningEffect(player.getLocation()); - player.damage(4 * 2); + player.damage(Math.min(6 * 2, player.getHealth())); } } @@ -140,7 +144,7 @@ public class DefenderAI if (!_active) return; - if (UtilTime.elapsed(_lastStepIncrease, UtilTime.convert(3, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) + if (UtilTime.elapsed(_lastStepIncrease, UtilTime.convert(1, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) { _step++; _lastStepIncrease = System.currentTimeMillis(); @@ -150,7 +154,7 @@ public class DefenderAI private void drawHelix() { - double height = Math.min(_step, 15D); + double height = Math.min(_step * 2, 15D); for (double y = 0; y <= height; y += .5) { @@ -170,7 +174,7 @@ public class DefenderAI while (UtilMath.offset(base, target) > UtilMath.offset(base, display)) { Vector v = UtilAlg.getTrajectory(display, target); - UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, display, null, 0, 1, ViewDist.MAX); + UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, display, null, 0, 1, ViewDist.MAX); display.add(v); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreGenerator.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreGenerator.java index c02076d74..bde64fddb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreGenerator.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreGenerator.java @@ -17,6 +17,8 @@ public class OreGenerator _choices.clear(); for (Location loc : possible) { + if (loc.getBlock().getType() == Material.WORKBENCH || loc.getBlock().getType() == Material.CHEST || loc.getBlock().getType() == Material.TRAPPED_CHEST || loc.getBlock().getType() == Material.FURNACE || loc.getBlock().getType() == Material.BURNING_FURNACE) + continue; loc.getBlock().setType(Material.STONE); _choices.add(loc); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/ProtectionUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/ProtectionUtil.java new file mode 100644 index 000000000..65a2f2e85 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/ProtectionUtil.java @@ -0,0 +1,16 @@ +package nautilus.game.arcade.game.games.minecraftleague.data; + +import org.bukkit.block.Block; + +public class ProtectionUtil { + + public static boolean isSameBlock(Block a, Block b) + { + if (a.getX() == b.getX()) + if (a.getY() == b.getY()) + return (a.getZ() == b.getZ()); + + return false; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java index d7c9629e1..3b452886b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java @@ -11,8 +11,6 @@ import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.hologram.Hologram; import mineplex.core.recharge.Recharge; import nautilus.game.arcade.game.GameTeam; @@ -49,7 +47,7 @@ public abstract class TeamTowerBase { _host = host; _manager = manager; - _spawn = spawn.clone().add(0.5, 1.2, 0.5); + _spawn = spawn.clone().add(-0.5, 1.2, -0.5); _team = team; _maxHealth = 11111D; _health = 11111D; @@ -79,12 +77,13 @@ public abstract class TeamTowerBase else message = _team.GetColor() + _team.getDisplayName() + "'s " + C.cDPurpleB + _type + _team.GetColor() + " has been destroyed!"; - Bukkit.broadcastMessage(message); + //Bukkit.broadcastMessage(message); + UtilTextMiddle.display("", message); if (!_type.equalsIgnoreCase("Tower")) { for (Player inform : _team.GetPlayers(true)) - UtilTextMiddle.display(C.cGold + "Team Crystal Destroyed", C.cGold + "You will no longer respawn!", inform); + UtilTextMiddle.display(C.cGold + "Team Crystal Destroyed", C.cGold + "You will no longer respawn and will be poisoned in 5 minutes!", inform); } Alive = false; @@ -135,6 +134,10 @@ public abstract class TeamTowerBase { b.setType(Material.AIR); } + for (int i = 1; i < 3; i++) + { + getBeacon().clone().add(0, i, 0).getBlock().setType(Material.BEDROCK); + } for (LivingEntity le : UtilEnt.getInRadius(_spawn, 18).keySet()) { if (le instanceof Wither) @@ -142,7 +145,15 @@ public abstract class TeamTowerBase else { if (UtilMath.offset(le.getLocation(), _spawn) <= 5) + { + if (UtilPlayer.isSpectator(le)) + continue; + if (le instanceof Player) + { + _host.storeGear((Player)le); + } le.damage(6); + } } } } @@ -223,7 +234,7 @@ public abstract class TeamTowerBase _health = newHealth; if (player != null) - Recharge.Instance.use(player, "Damage TeamTower", UtilTime.convert(1/2, TimeUnit.SECONDS, TimeUnit.MILLISECONDS), false, false); + Recharge.Instance.use(player, "Damage TeamTower", 400, false, false); return false; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerAlert.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerAlert.java index 269c77262..eafdc46df 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerAlert.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerAlert.java @@ -1,7 +1,11 @@ package nautilus.game.arcade.game.games.minecraftleague.data; +import java.util.concurrent.ConcurrentHashMap; + import mineplex.core.common.util.C; import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; import nautilus.game.arcade.game.GameTeam; import org.bukkit.Instrument; @@ -11,12 +15,21 @@ import org.bukkit.entity.Player; public class TowerAlert { - //private ConcurrentHashMap _alerts = new ConcurrentHashMap(); + private ConcurrentHashMap _alerts = new ConcurrentHashMap(); //private ConcurrentHashMap _alertType = new ConcurrentHashMap(); public void alert(GameTeam team, TeamTowerBase tower) { - //_alerts.put(team, System.currentTimeMillis()); + if (!UtilTime.elapsed(_alerts.getOrDefault(team, (long) 1), UtilTime.convert(7, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) + { + for (Player player : team.GetPlayers(true)) + playSound(player); + + return; + } + + _alerts.put(team, System.currentTimeMillis()); + String type = ""; if (tower instanceof TeamTower) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java index 3947c4ffb..493221319 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java @@ -6,13 +6,15 @@ import java.util.LinkedList; import java.util.List; import java.util.concurrent.ConcurrentHashMap; +import mineplex.core.common.util.UtilTextMiddle; import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.minecraftleague.DataLoc; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; -import nautilus.game.arcade.game.games.minecraftleague.data.objectives.KillObjective; import nautilus.game.arcade.world.WorldData; import org.bukkit.ChatColor; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.Listener; @@ -28,7 +30,7 @@ public class TowerManager implements Listener //private ConcurrentHashMap _mapZone = new ConcurrentHashMap(); private ConcurrentHashMap _beacons = new ConcurrentHashMap(); private OreGenerator _ore; - public boolean Attack = true; + public boolean Attack = false; public TowerManager(MinecraftLeague host) { @@ -47,12 +49,29 @@ public class TowerManager implements Listener _beacons.get(base.getTeam()).setBlock(base.getBeacon().getBlock()); } - public void ironOreGen(GameTeam team) + public void ironOreGen(GameTeam team, boolean start) { - if (team.GetColor() == ChatColor.RED) - _ore.generateOre(Material.IRON_ORE, Host.WorldData.GetCustomLocs(DataLoc.RED_ORE.getKey()), 30); + int amount = 10; + if (start) + amount = 40; + + for (Location loc : Host.WorldData.GetCustomLocs(DataLoc.DIAMOND_ORE.getKey())) + { + loc.getBlock().setType(Material.DIAMOND_ORE); + } + + if (start) + { + if (team.GetColor() == ChatColor.RED) + _ore.generateOre(Material.IRON_ORE, Host.WorldData.GetCustomLocs(DataLoc.RED_ORE.getKey()), amount); + else + _ore.generateOre(Material.IRON_ORE, Host.WorldData.GetCustomLocs(DataLoc.BLUE_ORE.getKey()), amount); + } else - _ore.generateOre(Material.IRON_ORE, Host.WorldData.GetCustomLocs(DataLoc.BLUE_ORE.getKey()), 30); + { + _ore.generateOre(Material.IRON_ORE, Host.WorldData.GetCustomLocs(DataLoc.MOSH_IRON.getKey()), amount); + UtilTextMiddle.display("", "Valuable Ores have respawned in the middle!"); + } } private List getAllTeamTowers(GameTeam team) @@ -158,8 +177,8 @@ public class TowerManager implements Listener Host.Beacons.put(blue, _beacons.get(blue)); makeVulnerable(getTeamTowers(red).getFirst()); makeVulnerable(getTeamTowers(blue).getFirst()); - ironOreGen(red); - ironOreGen(blue); + ironOreGen(red, true); + ironOreGen(blue, true); } public void prepareHealth(int players, double multiplier) @@ -202,7 +221,25 @@ public class TowerManager implements Listener else enemy = Host.GetTeam(ChatColor.RED); - Host.Objective.setTeamObjective(enemy, new KillObjective()); + Host.AnnounceEnd(enemy); + + for (GameTeam team : Host.GetTeamList()) + { + if (enemy != null && team.equals(enemy)) + { + for (Player player : team.GetPlayers(false)) + Host.AddGems(player, 10, "Winning Team", false, false); + } + + for (Player player : team.GetPlayers(false)) + if (player.isOnline()) + Host.AddGems(player, 10, "Participation", false, false); + } + Host.SetState(GameState.End); + + //Host.Objective.setTeamObjective(enemy, new KillObjective()); + + //Host.TeamPoison.put(towerBase.getTeam(), System.currentTimeMillis() + (UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS) - UtilTime.convert(1, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))); return; } @@ -212,7 +249,7 @@ public class TowerManager implements Listener public void toggleAttack() { - Attack = !Attack; + //Attack = !Attack; } public void update() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/map/ItemMapRenderer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/map/ItemMapRenderer.java index e4662c45a..e161d0583 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/map/ItemMapRenderer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/map/ItemMapRenderer.java @@ -5,6 +5,7 @@ import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; import nautilus.game.arcade.game.games.minecraftleague.data.MapZone; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.map.MapCanvas; @@ -111,6 +112,19 @@ public class ItemMapRenderer extends MapRenderer if (mapX > -64 && mapX < 64 && mapZ > -64 && mapZ < 64) { MapCursor.Type cursorDisplay; + MapCursor.Type friend; + MapCursor.Type foe; + + if (_host.GetTeam(player).GetColor() == ChatColor.RED) + { + friend = MapCursor.Type.RED_POINTER; + foe = MapCursor.Type.BLUE_POINTER; + } + else + { + friend = MapCursor.Type.BLUE_POINTER; + foe = MapCursor.Type.RED_POINTER; + } if (player == other) { @@ -118,12 +132,12 @@ public class ItemMapRenderer extends MapRenderer } else if (_host.GetTeam(player) == _host.GetTeam(other)) { - cursorDisplay = MapCursor.Type.BLUE_POINTER; + cursorDisplay = friend; } else if (_host.GetTeam(player) != _host.GetTeam(other)) { if (_host.OverTime) - cursorDisplay = MapCursor.Type.RED_POINTER; + cursorDisplay = foe; else continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/objective/ObjectiveManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/objective/ObjectiveManager.java index 7ec6ee923..5281fecfe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/objective/ObjectiveManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/objective/ObjectiveManager.java @@ -82,6 +82,9 @@ public class ObjectiveManager implements Listener public void setTeamObjective(GameTeam team, GameObjective objective) { + if (getTeamObjective(team).equalsIgnoreCase("KILL_ENEMY")) + return; + resetTeamToMainObjective(team); _teamObjectives.put(team, objective); } @@ -103,7 +106,7 @@ public class ObjectiveManager implements Listener for (Player player : _host.GetPlayers(true)) { - if (_main != null || _specificObjectives.containsKey(player)) + if (_main != null || _specificObjectives.containsKey(player) || _teamObjectives.containsKey(_host.GetTeam(player))) displayObjective(player); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/AltarBuilderTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/AltarBuilderTracker.java new file mode 100644 index 000000000..d4eb61c0e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/AltarBuilderTracker.java @@ -0,0 +1,21 @@ +package nautilus.game.arcade.game.games.minecraftleague.tracker; + +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.event.EventHandler; + +public class AltarBuilderTracker extends StatTracker +{ + public AltarBuilderTracker(MinecraftLeague game) + { + super(game); + } + + @EventHandler + public void build(PlaceSkullEvent e) + { + addStat(e.getPlayer(), "AltarBuilder", 1, false, false); + } + +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/FirstStrikeTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/FirstStrikeTracker.java new file mode 100644 index 000000000..07d08ba0a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/FirstStrikeTracker.java @@ -0,0 +1,22 @@ +package nautilus.game.arcade.game.games.minecraftleague.tracker; + +import nautilus.game.arcade.events.FirstBloodEvent; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.event.EventHandler; + +public class FirstStrikeTracker extends StatTracker +{ + public FirstStrikeTracker(MinecraftLeague game) + { + super(game); + } + + @EventHandler + public void blood(FirstBloodEvent e) + { + addStat(e.getPlayer(), "FirstStrike", 1, false, false); + } + +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/GrabSkullEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/GrabSkullEvent.java new file mode 100644 index 000000000..7da1c076e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/GrabSkullEvent.java @@ -0,0 +1,31 @@ +package nautilus.game.arcade.game.games.minecraftleague.tracker; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class GrabSkullEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + private Player _player; + + public GrabSkullEvent(Player player) + { + _player = player; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + + public Player getPlayer() + { + return _player; + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/HeadHunterTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/HeadHunterTracker.java new file mode 100644 index 000000000..72100ecfe --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/HeadHunterTracker.java @@ -0,0 +1,21 @@ +package nautilus.game.arcade.game.games.minecraftleague.tracker; + +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.event.EventHandler; + +public class HeadHunterTracker extends StatTracker +{ + public HeadHunterTracker(MinecraftLeague game) + { + super(game); + } + + @EventHandler + public void build(GrabSkullEvent e) + { + addStat(e.getPlayer(), "HeadHunter", 1, false, false); + } + +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/PlaceSkullEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/PlaceSkullEvent.java new file mode 100644 index 000000000..a9193a640 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/PlaceSkullEvent.java @@ -0,0 +1,31 @@ +package nautilus.game.arcade.game.games.minecraftleague.tracker; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class PlaceSkullEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + private Player _player; + + public PlaceSkullEvent(Player player) + { + _player = player; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + + public Player getPlayer() + { + return _player; + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java index f350e63fb..bdfd42dd1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java @@ -16,12 +16,10 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.minecraftleague.DataLoc; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; import nautilus.game.arcade.game.games.minecraftleague.data.TeamTowerBase; -import nautilus.game.arcade.game.games.minecraftleague.data.objectives.GearObjective; import nautilus.game.arcade.game.games.minecraftleague.variation.GameVariation; import nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.TeamAltar; import nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.WitherMinionManager; import nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.WitherPathfinder; -import nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.objectives.WitherObjective; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -131,6 +129,27 @@ public class WitherVariation extends GameVariation player.removePotionEffect(PotionEffectType.WITHER); player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 20 * 6, 0)); } + if (!Host.IsAlive(player)) + continue; + /*GameTeam enemy = null; + if (Host.GetTeam(player).GetColor() == ChatColor.RED) + { + enemy = Host.GetTeam(ChatColor.AQUA); + } + else + { + enemy = Host.GetTeam(ChatColor.RED); + } + if (UtilMath.offset(player, Host.getActiveTower(enemy).getEntity()) <= 7) + { + for (Location loc : UtilShapes.getCircle(player.getEyeLocation(), true, 3)) + { + if (new Random().nextInt(5) <= 3) + { + UtilParticle.PlayParticle(ParticleType.DRIP_LAVA, loc, null, 0, 2, ViewDist.SHORT, player); + } + } + }*/ } if (_pathfinder != null) if (_pathfinder.update()) @@ -139,9 +158,9 @@ public class WitherVariation extends GameVariation WitherSpawned = false; _wowner = null; _skellyMan.onWitherDeath(); - UtilTextMiddle.display("", C.cGray + "The Mighty Wither has fallen!"); - Host.Objective.resetTeamToMainObjective(Host.GetTeam(ChatColor.RED)); - Host.Objective.resetTeamToMainObjective(Host.GetTeam(ChatColor.AQUA)); + UtilTextMiddle.display("", C.cWhite + "The Mighty Wither has fallen!"); + //Host.Objective.resetTeamToMainObjective(Host.GetTeam(ChatColor.RED)); + //Host.Objective.resetTeamToMainObjective(Host.GetTeam(ChatColor.AQUA)); } } } @@ -183,16 +202,16 @@ public class WitherVariation extends GameVariation _wither = (Wither)event.getEntity(); _wither.setCustomName(team.GetColor() + team.getDisplayName() + "'s Wither"); _wither.setCustomNameVisible(true); - UtilTextMiddle.display("", C.cBlack + team.getDisplayName() + " Team has spawned a Wither Boss!", UtilServer.getPlayers()); + UtilTextMiddle.display("", C.cWhite + team.getDisplayName() + " Team has spawned a Wither Boss!", UtilServer.getPlayers()); _pathfinder = new WitherPathfinder(this, _wither, getWaypoints(_altars.get(team).getLocation()), team, enemy, Host.getTowerManager()); _skellyMan.onWitherSpawn(); - Host.Objective.setMainObjective(new GearObjective()); - Host.Objective.setTeamObjective(team, new WitherObjective("Attack Enemy Towers")); - Host.Objective.setTeamObjective(enemy, new WitherObjective("Kill Wither")); - for (Player player : Host.GetPlayers(true)) + //Host.Objective.setMainObjective(new GearObjective()); + //Host.Objective.setTeamObjective(team, new WitherObjective("Attack Enemy Towers")); + //Host.Objective.setTeamObjective(enemy, new WitherObjective("Kill Wither")); + /*for (Player player : Host.GetPlayers(true)) { Host.Objective.resetPlayerToMainObjective(player); - } + }*/ Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() { public void run() @@ -243,7 +262,7 @@ public class WitherVariation extends GameVariation TeamTowerBase blue = Host.getActiveTower(Host.GetTeam(ChatColor.AQUA)); HashMap inside = UtilBlock.getInRadius(event.getLocation().getBlock(), 4, false); - double dmg = 5 * (Host.GetTeam(ChatColor.RED).GetPlayers(true).size() + Host.GetTeam(ChatColor.RED).GetPlayers(true).size()); + double dmg = 20 * (Host.GetTeam(ChatColor.RED).GetPlayers(true).size() + Host.GetTeam(ChatColor.RED).GetPlayers(true).size()); if (inside.containsKey(red.getLocation().getBlock())) { red.damage(dmg, null); @@ -397,5 +416,9 @@ public class WitherVariation extends GameVariation return; Manager.GetCondition().Clean(event.GetPlayer()); + /*if (Host.Objective.getPlayerObjective(event.GetPlayer()).equals("RETURN_SKULL")) + { + Host.Objective.resetPlayerToMainObjective(event.GetPlayer()); + }*/ } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java index 7303a93f6..0834d76b2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java @@ -9,8 +9,10 @@ import mineplex.core.common.util.UtilShapes; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.hologram.Hologram; import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.minecraftleague.tracker.PlaceSkullEvent; import nautilus.game.arcade.game.games.minecraftleague.variation.wither.WitherVariation; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; @@ -42,7 +44,7 @@ public class TeamAltar _protected = UtilShapes.getSphereBlocks(center, 7, 7, false); - Location labelLoc = center.clone().add(0.5, 5, 0.5); + Location labelLoc = center.clone().add(0/*.5*/, 5, 0.5); String labelStr = team.GetColor() + team.getDisplayName() + "'s Altar"; Hologram label = new Hologram(host.Host.getArcadeManager().getHologramManager(), labelLoc, labelStr); label.start(); @@ -158,6 +160,8 @@ public class TeamAltar if (_team.HasPlayer(player) && blockType == Material.SKULL) { + //_host.Host.Objective.resetPlayerToMainObjective(player); + Bukkit.getPluginManager().callEvent(new PlaceSkullEvent(player)); if (_placed < 2) { UtilTextMiddle.display("", _team.GetColor() + _team.getDisplayName() + " has placed a Skull on their Altar!"); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java index 9e7bcc880..44f479094 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java @@ -6,6 +6,7 @@ import java.util.Random; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilParticle; @@ -17,18 +18,19 @@ import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.minecraftleague.data.MapZone; -import nautilus.game.arcade.game.games.minecraftleague.data.objectives.GearObjective; +import nautilus.game.arcade.game.games.minecraftleague.tracker.GrabSkullEvent; import nautilus.game.arcade.game.games.minecraftleague.variation.wither.WitherVariation; -import nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.objectives.GrabSkullObjective; -import nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.objectives.ReturnSkullObjective; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.FireworkEffect.Type; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -59,21 +61,21 @@ public class WitherMinionManager implements Listener private long _lastDied; private int _lastUsed; private int _selected; - + private Skeleton _entity; - + private ItemStack _witherItem; - + private WitherSkeletonTimer _sbTimer; private MapZone _skellyZone; - + private Block _cb; private Material _changed = Material.AIR; - + private boolean _witherBlocked = false; - + private boolean _spawned = false; - + public WitherMinionManager(WitherVariation host, List spawns) { _host = host; @@ -86,10 +88,10 @@ public class WitherMinionManager implements Listener _skellyZone = new MapZone(spawns.get(0), new int[] {0, 0, 0}); _skellyZone.setValid(false); host.Host.MapZones.add(_skellyZone); - + Bukkit.getPluginManager().registerEvents(this, host.Manager.getPlugin()); } - + private void preSpawn() { Location chosen = null; @@ -103,12 +105,12 @@ public class WitherMinionManager implements Listener _selected = check; } } - + _cb = chosen.clone().add(0, -2, 0).getBlock(); _changed = _cb.getType(); chosen.clone().add(0, -2, 0).getBlock().setType(Material.BEACON); } - + private void spawn(boolean respawn) { Location chosen = null; @@ -127,26 +129,26 @@ public class WitherMinionManager implements Listener ((CraftSkeleton)e).getEquipment().setChestplate(new ItemStack(Material.IRON_CHESTPLATE)); ((CraftSkeleton)e).getEquipment().setLeggings(new ItemStack(Material.IRON_LEGGINGS)); //((Skeleton)e).addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 9999999, 7)); - + if (!respawn) { UtilTextMiddle.display("", C.cGray + "A Wither Skeleton has spawned!"); _skellyZone.setCenter(chosen); _skellyZone.setValid(true); - _host.Host.Objective.setMainObjective(new GrabSkullObjective()); + //_host.Host.Objective.setMainObjective(new GrabSkullObjective()); } _selected = -1; _spawned = true; } - + public void onWitherDeath() { - _lastDied = System.currentTimeMillis() + UtilTime.convert(2, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); + _lastDied = System.currentTimeMillis(); _witherBlocked = false; _host.Host.getTowerManager().toggleAttack(); _sbTimer.freezeTime(-1); } - + public void onWitherSpawn() { _host.Host.getTowerManager().toggleAttack(); @@ -166,7 +168,7 @@ public class WitherMinionManager implements Listener _changed = Material.AIR; } } - + @EventHandler public void onLive(GameStateChangeEvent event) { @@ -174,36 +176,37 @@ public class WitherMinionManager implements Listener return; if (event.GetState() != GameState.Live) return; - - _lastDied = System.currentTimeMillis() + UtilTime.convert(4, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); + + _lastDied = System.currentTimeMillis() + UtilTime.convert(60, TimeUnit.SECONDS, TimeUnit.MILLISECONDS); } - + @EventHandler public void onUpdate(UpdateEvent event) { if (!_host.Host.IsLive()) return; - + if (event.getType() != UpdateType.FASTEST) return; - + if (_entity == null || !_entity.isValid()) { if (_spawned) spawn(true); } - + if (_entity != null) { _entity.teleport(_spawns.get(_lastUsed)); } + try { if (UtilTime.elapsed(_lastDied, UtilTime.convert(45, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) { boolean noUse = _host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.RED)) < 1; if (_host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.AQUA)) >= 1) noUse = false; - if (!_host.WitherSpawned || !noUse) + if (!_witherBlocked && !noUse) { if (_entity == null) { @@ -218,25 +221,25 @@ public class WitherMinionManager implements Listener { if (secLeft > 0) { - UtilTextMiddle.display(C.cGold + secLeft + " Seconds", C.cGray + "Until Wither Skeleton Spawn"); + UtilTextMiddle.display(C.cGold + secLeft + " Seconds", "Until Wither Skeleton Spawn"); } } } } } - - if (UtilTime.elapsed(_lastDied, UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS))) + + if (UtilTime.elapsed(_lastDied, UtilTime.convert(90, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) { boolean noUse = _host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.RED)) < 1; if (_host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.AQUA)) >= 1) noUse = false; - if (!_host.WitherSpawned || !noUse) + if (!_witherBlocked && !noUse) { if (_entity == null) spawn(false); } } - + for (Player player : Bukkit.getOnlinePlayers()) { if (UtilInv.contains(player, Material.SKULL_ITEM, (byte) 1, 1)) @@ -249,13 +252,21 @@ public class WitherMinionManager implements Listener { UtilParticle.PlayParticleToAll(ParticleType.DRIP_LAVA, loc, null, 0, 1, ViewDist.MAX); } + if (Recharge.Instance.usable(player, "FIREWORK_ALERT", false)) + { + Recharge.Instance.use(player, "FIREWORK_ALERT", UtilTime.convert(5, TimeUnit.SECONDS, TimeUnit.MILLISECONDS), false, false); + UtilFirework.playFirework(player.getEyeLocation().add(0, 3, 0), Type.BALL_LARGE, Color.PURPLE, false, true); + } } else { - if (_host.Host.Objective.getPlayerObjective(player).equalsIgnoreCase("GRAB_SKULL")) + /*if (_host.Host.Objective.getPlayerObjective(player) != null) { - _host.Host.Objective.resetPlayerToMainObjective(player); - } + if (_host.Host.Objective.getPlayerObjective(player).equalsIgnoreCase("GRAB_SKULL")) + { + _host.Host.Objective.resetPlayerToMainObjective(player); + } + }*/ } if (player.getInventory().getHelmet() != null) @@ -267,45 +278,49 @@ public class WitherMinionManager implements Listener } } } + } catch (Exception e) + { + + } } - + @EventHandler public void handleTimer(UpdateEvent event) { if (!_host.Host.IsLive()) return; - + if (event.getType() != UpdateType.FASTEST) return; - + boolean noUse = _host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.RED)) < 1; if (_host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.AQUA)) >= 1) noUse = false; - + if (_entity != null || noUse) { _sbTimer.freezeTime(0); return; } - + if (_host.WitherSpawned || _witherBlocked) { _sbTimer.freezeTime(-2); return; } - + if (_entity == null) _sbTimer.freezeTime(-1); - - _sbTimer.setEnd((_lastDied + UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS))); + + _sbTimer.setEnd((_lastDied + UtilTime.convert(90, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))); } - + @EventHandler(priority = EventPriority.HIGHEST) public void onSkellyDie(EntityDeathEvent event) { if (!_host.Host.IsLive()) return; - + if (event.getEntity() instanceof Skeleton) { Skeleton skelly = (Skeleton)event.getEntity(); @@ -327,19 +342,21 @@ public class WitherMinionManager implements Listener _cb = null; _changed = Material.AIR; - _host.Host.Objective.setMainObjective(new GearObjective()); + _host.Host.getTowerManager().ironOreGen(null, false); + + //_host.Host.Objective.setMainObjective(new GearObjective()); } } } } } - - @EventHandler + + @EventHandler(priority = EventPriority.HIGHEST) public void onPickup(PlayerPickupItemEvent event) { if (!_host.Host.IsLive()) return; - + if (!event.isCancelled()) { String com = UtilItem.itemToStr(event.getItem().getItemStack()); @@ -356,22 +373,32 @@ public class WitherMinionManager implements Listener { public void run() { - UtilTextMiddle.display("", C.cGold + "Place the skull on top of your Altar's Soulsand!", event.getPlayer()); + UtilTextMiddle.display("", C.cGold + "Place the skull on top of", event.getPlayer()); } }, 20 * 5); - _host.Host.Objective.setPlayerObjective(event.getPlayer(), new ReturnSkullObjective()); + Bukkit.getScheduler().runTaskLater(_host.Manager.getPlugin(), new Runnable() + { + public void run() + { + UtilTextMiddle.display("", C.cGold + "Your Altar's Soul Sand!", event.getPlayer()); + } + }, 20 * 8); + //_host.Host.Objective.setPlayerObjective(event.getPlayer(), new ReturnSkullObjective()); if (!event.getItem().hasMetadata("Dropped")) + { + Bukkit.getPluginManager().callEvent(new GrabSkullEvent(event.getPlayer())); UtilTextMiddle.display("", _host.Host.GetTeam(event.getPlayer()).GetColor() + _host.Host.GetTeam(event.getPlayer()).getDisplayName() + " has picked up a Wither Skull!", 20, 20 * 5, 20); + } } } } - + @EventHandler public void onDrop(PlayerDropItemEvent event) { if (!_host.Host.IsLive()) return; - + if (!event.isCancelled()) { String com = UtilItem.itemToStr(event.getItemDrop().getItemStack()); @@ -383,43 +410,43 @@ public class WitherMinionManager implements Listener if (fin.equalsIgnoreCase(fin1)) { event.getItemDrop().setMetadata("Dropped", new FixedMetadataValue(_host.Manager.getPlugin(), true)); - _host.Host.Objective.resetPlayerToMainObjective(event.getPlayer()); + //_host.Host.Objective.resetPlayerToMainObjective(event.getPlayer()); } } } - + @EventHandler public void onPlace(BlockPlaceEvent event) { if (!_host.Host.IsLive()) return; - + for (Location loc : _spawns) { - if (UtilShapes.getSphereBlocks(loc, 5, 5, false).contains(event.getBlock().getLocation())) + if (UtilShapes.getSphereBlocks(loc, 6, 6, false).contains(event.getBlock().getLocation())) event.setCancelled(true); } } - + @EventHandler public void onBreak(BlockBreakEvent event) { if (!_host.Host.IsLive()) return; - + for (Location loc : _spawns) { - if (UtilShapes.getSphereBlocks(loc, 5, 5, false).contains(event.getBlock().getLocation())) + if (UtilShapes.getSphereBlocks(loc, 6, 6, false).contains(event.getBlock().getLocation())) event.setCancelled(true); } } - + @EventHandler public void onExp(EntityExplodeEvent event) { if (!_host.Host.IsLive()) return; - + if (event.getEntity() instanceof Wither) { event.blockList().clear(); @@ -427,13 +454,13 @@ public class WitherMinionManager implements Listener } event.setCancelled(true); } - + @EventHandler public void onEntity(EntityChangeBlockEvent event) { if (!_host.Host.IsLive()) return; - + for (Location loc : _spawns) { if (UtilShapes.getSphereBlocks(loc, 5, 5, false).contains(event.getBlock().getLocation())) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index 6867c0e30..e406623c2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -1,5 +1,7 @@ package nautilus.game.arcade.managers; +import java.util.concurrent.ConcurrentHashMap; + import mineplex.core.antihack.AntiHack; import mineplex.core.common.Rank; import mineplex.core.common.util.C; @@ -12,6 +14,8 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; import mineplex.core.teleport.event.MineplexTeleportEvent; @@ -73,6 +77,7 @@ public class GameFlagManager implements Listener { ArcadeManager Manager; SecondaryDamageManager Secondary; + private ConcurrentHashMap _respawnTimers = new ConcurrentHashMap(); public GameFlagManager(ArcadeManager manager) { @@ -99,8 +104,11 @@ public class GameFlagManager implements Listener { if (Manager.GetDamage().IsEnabled()) { - HandlerList.unregisterAll(Secondary); - Secondary = null; + if (Secondary != null) + { + HandlerList.unregisterAll(Secondary); + Secondary = null; + } } } } @@ -762,6 +770,8 @@ public class GameFlagManager implements Listener if (game.GetTeam(player).GetRespawnTime() > time) time = game.GetTeam(player).GetRespawnTime(); + final double timeF = time; + UtilInv.Clear(player); Manager.GetCondition().Factory().Cloak("Ghost", player, player, time, false, false); player.setAllowFlight(true); @@ -786,7 +796,14 @@ public class GameFlagManager implements Listener UtilPlayer.message(player, C.cWhite + C.Bold + "You will respawn in " + time + " seconds..."); UtilTextMiddle.display(null, "Respawning in " + time + " seconds...", 5, 40, 5, player); } - + Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() + { + public void run() + { + Long t = Double.valueOf(timeF).longValue(); + _respawnTimers.put(player, System.currentTimeMillis() + UtilTime.convert(t, TimeUnit.SECONDS, TimeUnit.MILLISECONDS)); + } + }, 6); Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() { public void run() @@ -1244,4 +1261,37 @@ public class GameFlagManager implements Listener UtilTextMiddle.display(C.cGold + C.Bold + Manager.GetGame().GetType().GetName(), "Make sure you accept the Resource Pack", 20, 120, 20, event.getPlayer()); } + + @EventHandler + public void displayRespawnTimer(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + return; + + if (Manager.GetGame() == null) + { + _respawnTimers.clear(); + return; + } + if (!Manager.GetGame().IsLive()) + { + _respawnTimers.clear(); + return; + } + for (Player player : _respawnTimers.keySet()) + { + if (!player.isOnline()) + { + _respawnTimers.remove(player); + continue; + } + if (System.currentTimeMillis() >= _respawnTimers.get(player)) + { + _respawnTimers.remove(player); + continue; + } + long sec = UtilTime.convert(_respawnTimers.get(player) - System.currentTimeMillis(), TimeUnit.MILLISECONDS, TimeUnit.SECONDS); + UtilTextMiddle.display("Respawning In", sec + " Seconds", player); + } + } } \ No newline at end of file From 09f9ae3b7a8f3a56da7aa811ae13b9c6d4312014 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 14 Apr 2016 23:05:14 -0400 Subject: [PATCH 33/47] - Update for playability --- .../game/games/minecraftleague/MinecraftLeague.java | 12 ++++++------ .../variation/wither/data/WitherMinionManager.java | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index 8f4c70c97..c0b35f088 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -893,10 +893,10 @@ public class MinecraftLeague extends TeamGame if (!tower.canDamage(player)) return; - //if (!tower.Vulnerable) + if (!tower.Vulnerable) { - //UtilPlayer.message(player, F.main("Game", "That Tower is protected by the power of another!")); - //return; + UtilPlayer.message(player, F.main("Game", "That Tower is protected by the power of another!")); + return; } if (!tower.damage(event.getDamage() / 2, player)) @@ -914,10 +914,10 @@ public class MinecraftLeague extends TeamGame if (!tower.canDamage(player)) return; - //if (!tower.Vulnerable) + if (!tower.Vulnerable) { - //UtilPlayer.message(player, F.main("Game", "That Tower is protected by the power of another!")); - //return; + UtilPlayer.message(player, F.main("Game", "That Tower is protected by the power of another!")); + return; } if (player.getItemInHand() == null || player.getItemInHand().getType() == Material.AIR) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java index 44f479094..218eff1fb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java @@ -118,7 +118,9 @@ public class WitherMinionManager implements Listener chosen = _spawns.get(_selected); else chosen = _spawns.get(_lastUsed); + _host.Host.CreatureAllowOverride = true; Entity e = _host.Manager.GetCreature().SpawnEntity(chosen, EntityType.SKELETON); + _host.Host.CreatureAllowOverride = false; ((Skeleton)e).setSkeletonType(SkeletonType.WITHER); _entity = (Skeleton)e; UtilEnt.ghost(e, true, false); From d8f5ac66fc1e8cfd49f179401e9d1b8b425d07c1 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 16 Apr 2016 14:05:46 -0400 Subject: [PATCH 34/47] - More chiss --- .../minecraftleague/MinecraftLeague.java | 157 ++++++++++++------ .../commands/panel/AdminPanel.java | 16 +- .../minecraftleague/data/DefenderAI.java | 2 +- .../minecraftleague/data/OreGenerator.java | 2 + .../minecraftleague/data/TeamBeacon.java | 7 +- .../minecraftleague/data/TeamTowerBase.java | 18 +- .../minecraftleague/data/TowerManager.java | 71 ++++++-- .../variation/GameVariation.java | 6 + .../variation/VariationManager.java | 13 +- .../variation/wither/WitherVariation.java | 83 ++++++--- .../variation/wither/data/TeamAltar.java | 9 + .../wither/data/WitherMinionManager.java | 6 +- .../wither/data/WitherPathfinder.java | 17 +- .../game/arcade/managers/GameFlagManager.java | 11 +- 14 files changed, 298 insertions(+), 120 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index c0b35f088..2e659e938 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -33,7 +33,7 @@ import nautilus.game.arcade.game.games.minecraftleague.data.BlockProtection; import nautilus.game.arcade.game.games.minecraftleague.data.MapZone; import nautilus.game.arcade.game.games.minecraftleague.data.Spawner; import nautilus.game.arcade.game.games.minecraftleague.data.TeamBeacon; -import nautilus.game.arcade.game.games.minecraftleague.data.TeamTower; +import nautilus.game.arcade.game.games.minecraftleague.data.TeamCrystal; import nautilus.game.arcade.game.games.minecraftleague.data.TeamTowerBase; import nautilus.game.arcade.game.games.minecraftleague.data.TowerAlert; import nautilus.game.arcade.game.games.minecraftleague.data.TowerManager; @@ -103,7 +103,7 @@ public class MinecraftLeague extends TeamGame //private ConcurrentHashMap _customRespawns = new ConcurrentHashMap(); //private ConcurrentHashMap _maps = new ConcurrentHashMap(); private ConcurrentHashMap> _gear = new ConcurrentHashMap>(); - public ConcurrentHashMap Beacons = new ConcurrentHashMap(); + public ConcurrentHashMap Beacons = new ConcurrentHashMap(); //public ConcurrentHashMap TeamPoison = new ConcurrentHashMap(); private ConcurrentHashMap _blockLock = new ConcurrentHashMap(); //private ConcurrentHashMap _spawnAllow = new ConcurrentHashMap(); @@ -115,6 +115,7 @@ public class MinecraftLeague extends TeamGame private MinecraftLeagueCommand _cmd; private long _lastIncrease; private long _lastOreReset; + private long _lastGrindReset; private boolean _yellow = false; public List MapZones = new ArrayList(); @@ -126,6 +127,7 @@ public class MinecraftLeague extends TeamGame private FreezeManager _freeze; private TowerManager _tower; public TowerAlert Alert; + public boolean ScoreboardAutoWrite = true; //private final EntityType[] _passive = new EntityType[] {EntityType.CHICKEN, EntityType.COW, EntityType.PIG, EntityType.RABBIT, EntityType.SHEEP}; @@ -394,9 +396,9 @@ public class MinecraftLeague extends TeamGame return ids; } - public TeamTowerBase getActiveTower(GameTeam team) + //public TeamTowerBase getActiveTower(GameTeam team) { - return _tower.getVulnerable(team); + //return _tower.getVulnerable(team); } public TowerManager getTowerManager() @@ -454,10 +456,25 @@ public class MinecraftLeague extends TeamGame @EventHandler public void ScoreboardUpdate(UpdateEvent event) { + if (!ScoreboardAutoWrite) + return; + if (event.getType() == UpdateType.FAST || event.getType() == UpdateType.SEC) scoreboardWrite(event.getType() == UpdateType.SEC); } + public void writeEndSb(String winner) + { + Scoreboard.Reset(); + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cDRedB + "Minecraft League"); + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cGoldB + "Winner:"); + Scoreboard.Write(winner); + + Scoreboard.Draw(); + } + private void scoreboardWrite(boolean sec) { if (!InProgress()) @@ -492,26 +509,30 @@ public class MinecraftLeague extends TeamGame GameTeam red = GetTeam(ChatColor.RED); GameTeam blue = GetTeam(ChatColor.AQUA); - TeamTowerBase redt = _tower.getVulnerable(red); - TeamTowerBase bluet = _tower.getVulnerable(blue); - String reds = "First Tower"; - String blues = "First Tower"; - - if (redt instanceof TeamTower) + String reds = ""; + String blues = ""; + for (TeamTowerBase tb : _tower.getTeamTowers(red)) { - if (((TeamTower)redt).Number > 1) - reds = "Second Tower"; + if (!reds.equalsIgnoreCase("")) + reds = reds + " "; + + String symbol = "♛"; + if (tb instanceof TeamCrystal) + symbol = "♚"; + + reds = reds + tb.getHealthColor() + symbol; } - else - reds = "Core"; - - if (bluet instanceof TeamTower) + for (TeamTowerBase tb : _tower.getTeamTowers(blue)) { - if (((TeamTower)bluet).Number > 1) - blues = "Second Tower"; + if (!blues.equalsIgnoreCase("")) + blues = blues + " "; + + String symbol = "♛"; + if (tb instanceof TeamCrystal) + symbol = "♚"; + + blues = blues + tb.getHealthColor() + symbol; } - else - blues = "Core"; _liveTime = Math.max(System.currentTimeMillis() - GetStateTime(), 0); @@ -525,13 +546,19 @@ public class MinecraftLeague extends TeamGame Scoreboard.WriteBlank(); Scoreboard.Write(C.cRedB + "Red Team"); - Scoreboard.Write(reds + ": " + redt.formatHealth(redt.getHealth())); - Scoreboard.Write("Players Alive: " + red.GetPlayers(true).size()); + Scoreboard.Write("Towers: " + reds); + for (String s : _vman.getSelected().getTeamScoreboardAdditions(red)) + { + Scoreboard.Write(s); + } Scoreboard.WriteBlank(); Scoreboard.Write(C.cAquaB + "Blue Team"); - Scoreboard.Write(blues + ": " + bluet.formatHealth(bluet.getHealth())); - Scoreboard.Write("Players Alive: " + blue.GetPlayers(true).size()); + Scoreboard.Write("Towers: " + blues); + for (String s : _vman.getSelected().getTeamScoreboardAdditions(blue)) + { + Scoreboard.Write(s); + } int i = 1; for (ExtraScoreboardData sbD : ExtraSb.keySet()) @@ -565,7 +592,7 @@ public class MinecraftLeague extends TeamGame { for (GameTeam team : GetTeamList()) { - TeamTowerBase tower = _tower.getVulnerable(team); + TeamTowerBase tower = _tower.getTeamTowers(team).getLast(); UtilPlayer.message(caller, team.GetColor() + team.GetName()); UtilPlayer.message(caller, C.cGray + "Health: " + tower.getHealth()); UtilPlayer.message(caller, C.cGray + "Alive: " + tower.Alive); @@ -623,6 +650,7 @@ public class MinecraftLeague extends TeamGame { _lastIncrease = System.currentTimeMillis(); _lastOreReset = System.currentTimeMillis(); + _lastGrindReset = System.currentTimeMillis() - UtilTime.convert(30, TimeUnit.SECONDS, TimeUnit.MILLISECONDS); Manager.GetExplosion().setEnabled(false); Manager.GetDamage().SetEnabled(false); Manager.GetCreature().SetForce(false); @@ -779,30 +807,34 @@ public class MinecraftLeague extends TeamGame this.DeathSpectateSecs = Math.min(20, this.DeathSpectateSecs + 2.5); } - for (Location grind : WorldData.GetCustomLocs(DataLoc.GRIND_AREA.getKey())) + if (UtilTime.elapsed(_lastGrindReset, UtilTime.convert(30, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) { - int spider = 0; - int chicken = 0; - for (LivingEntity le : UtilEnt.getInRadius(grind, 15).keySet()) + _lastGrindReset = System.currentTimeMillis(); + for (Location grind : WorldData.GetCustomLocs(DataLoc.GRIND_AREA.getKey())) { - if (le.getType() == EntityType.SPIDER) - spider++; - if (le.getType() == EntityType.CHICKEN) - chicken++; - } - while (spider < 5) - { - spider++; - CreatureAllowOverride = true; - Manager.GetCreature().SpawnEntity(grind, EntityType.SPIDER); - CreatureAllowOverride = false; - } - while (chicken < 10) - { - chicken++; - CreatureAllowOverride = true; - Manager.GetCreature().SpawnEntity(grind, EntityType.CHICKEN); - CreatureAllowOverride = false; + int spider = 0; + int chicken = 0; + for (LivingEntity le : UtilEnt.getInRadius(grind, 15).keySet()) + { + if (le.getType() == EntityType.SPIDER) + spider++; + if (le.getType() == EntityType.CHICKEN) + chicken++; + } + while (spider < 5) + { + spider = 5; + CreatureAllowOverride = true; + Manager.GetCreature().SpawnEntity(grind, EntityType.SPIDER); + CreatureAllowOverride = false; + } + while (chicken < 10) + { + chicken = 10; + CreatureAllowOverride = true; + Manager.GetCreature().SpawnEntity(grind, EntityType.CHICKEN); + CreatureAllowOverride = false; + } } } @@ -1487,12 +1519,22 @@ public class MinecraftLeague extends TeamGame } } - int arrowsToAdd = UtilInv.getAmount(player, Material.ARROW) / 2; - while (arrowsToAdd >= 1) + //int arrowsToAdd = UtilInv.getAmount(player, Material.ARROW) / 2; + //while (arrowsToAdd >= 1) + //{ + //int subtract = Math.min(64, arrowsToAdd); + //gear.add(new ItemStack(Material.ARROW, subtract)); + //arrowsToAdd -= subtract; + //} + if (UtilInv.getAmount(player, Material.ARROW) >= 1) { - int subtract = Math.min(64, arrowsToAdd); - gear.add(new ItemStack(Material.ARROW, subtract)); - arrowsToAdd -= subtract; + for (ItemStack arrow : UtilInv.getItems(player)) + { + if (arrow.getType() == Material.ARROW) + { + gear.add(arrow); + } + } } _gear.put(player, gear); @@ -1505,6 +1547,8 @@ public class MinecraftLeague extends TeamGame return; if (!(event.getEntity() instanceof Player)) return; + if (UtilPlayer.isSpectator(event.getEntity())) + return; Player player = (Player)event.getEntity(); storeGear(player); @@ -1590,7 +1634,14 @@ public class MinecraftLeague extends TeamGame { if (OverTime) { - _tower.getVulnerable(GetTeam(event.GetPlayer())).damage(20, null); + for (TeamTowerBase tb : _tower.getTeamTowers(GetTeam(event.GetPlayer()))) + { + if (tb.Alive) + { + tb.damage(20, null); + break; + } + } if (_tower.getAmountAlive(GetTeam(event.GetPlayer())) >= 1) { event.setCancelled(true); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/AdminPanel.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/AdminPanel.java index 03b2d274b..83db013c1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/AdminPanel.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/panel/AdminPanel.java @@ -42,15 +42,15 @@ public class AdminPanel implements Listener _slots = new ConcurrentHashMap(); ItemStack red = new ItemBuilder(MenuButton.CRYSTAL.getRepresentation()) - .setTitle(C.cRed + "Red Tower") - .setLore(C.cGray + "Alive: " + host.getActiveTower(host.GetTeam(ChatColor.RED)).Alive, - C.cGray + "Health: " + host.getActiveTower(host.GetTeam(ChatColor.RED)).getHealth()) + .setTitle(C.cRed + "Red Core") + .setLore(C.cGray + "Alive: " + host.getTowerManager().getTeamTowers(host.GetTeam(ChatColor.RED)).getLast().Alive, + C.cGray + "Health: " + host.getTowerManager().getTeamTowers(host.GetTeam(ChatColor.RED)).getLast().getHealth()) .build(); ItemStack blue = new ItemBuilder(MenuButton.CRYSTAL.getRepresentation()) - .setTitle(C.cAqua + "Blue Tower") - .setLore(C.cGray + "Alive: " + host.getActiveTower(host.GetTeam(ChatColor.AQUA)).Alive, - C.cGray + "Health: " + host.getActiveTower(host.GetTeam(ChatColor.AQUA)).getHealth()) + .setTitle(C.cAqua + "Blue Core") + .setLore(C.cGray + "Alive: " + host.getTowerManager().getTeamTowers(host.GetTeam(ChatColor.AQUA)).getLast().Alive, + C.cGray + "Health: " + host.getTowerManager().getTeamTowers(host.GetTeam(ChatColor.AQUA)).getLast().getHealth()) .build(); _buttons.put(red, host.GetTeam(ChatColor.RED)); @@ -75,8 +75,8 @@ public class AdminPanel implements Listener GameTeam team = _buttons.get(item); ItemMeta im = item.getItemMeta(); List lore = new ArrayList(); - lore.add(C.cGray + "Alive: " + _host.getActiveTower(team).Alive); - lore.add(C.cGray + "Health: " + _host.getActiveTower(team).getHealth()); + lore.add(C.cGray + "Alive: " + _host.getTowerManager().getTeamTowers(team).getLast().Alive); + lore.add(C.cGray + "Health: " + _host.getTowerManager().getTeamTowers(team).getLast().getHealth()); im.setLore(lore); item.setItemMeta(im); _buttons.remove(item); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/DefenderAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/DefenderAI.java index 63d17444a..ee1d7f1c6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/DefenderAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/DefenderAI.java @@ -169,7 +169,7 @@ public class DefenderAI private void drawBeam() { Location base = _base.clone().add(0, 10, 0); - Location target = _manager.getTeamTowers(_tower.getTeam()).get(_number).getLocation().clone().add(0, 10, 0); + Location target = _manager.getTeamTowers(_tower.getTeam()).getLast().getLocation().clone().add(0, 10, 0);//_manager.getTeamTowers(_tower.getTeam()).get(_number).getLocation().clone().add(0, 10, 0); Location display = base.clone(); while (UtilMath.offset(base, target) > UtilMath.offset(base, display)) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreGenerator.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreGenerator.java index bde64fddb..c2caae839 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreGenerator.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreGenerator.java @@ -24,6 +24,8 @@ public class OreGenerator } for (int i = 0; i < (amount + 1); i++) { + if (_choices.size() == 0) + continue; Location selected = _choices.remove(UtilMath.random.nextInt(_choices.size())); selected.getBlock().setType(oreType); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java index 917fa00b3..55d16241c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java @@ -35,9 +35,14 @@ public class TeamBeacon return false; }*/ - public void setBlock(Block block) + /*public void setBlock(Block block) { _block = block; + }*/ + + public Block getBlock() + { + return _block; } public void update() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java index 3b452886b..4edfa82b5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java @@ -18,6 +18,7 @@ import nautilus.game.arcade.game.games.minecraftleague.DataLoc; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -134,7 +135,7 @@ public abstract class TeamTowerBase { b.setType(Material.AIR); } - for (int i = 1; i < 3; i++) + for (int i = 0; i < 3; i++) { getBeacon().clone().add(0, i, 0).getBlock().setType(Material.BEDROCK); } @@ -219,6 +220,21 @@ public abstract class TeamTowerBase return tag; } + public ChatColor getHealthColor() + { + if (!Alive) + return ChatColor.GRAY; + + ChatColor color = ChatColor.YELLOW; + + if (_health > (.9 * _maxHealth)) + color = ChatColor.GREEN; + else if (_health < (.45 * _maxHealth)) + color = ChatColor.RED; + + return color; + } + public boolean damage(double damage, Player player) { if (!Vulnerable) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java index 493221319..ec9b188bd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java @@ -7,8 +7,8 @@ import java.util.List; import java.util.concurrent.ConcurrentHashMap; import mineplex.core.common.util.UtilTextMiddle; -import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.minecraftleague.DataLoc; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; import nautilus.game.arcade.world.WorldData; @@ -25,10 +25,10 @@ public class TowerManager implements Listener { public MinecraftLeague Host; private ConcurrentHashMap _towers = new ConcurrentHashMap(); - private ConcurrentHashMap _vulnerableTower = new ConcurrentHashMap(); + //private ConcurrentHashMap _vulnerableTower = new ConcurrentHashMap(); private ConcurrentHashMap _def = new ConcurrentHashMap(); //private ConcurrentHashMap _mapZone = new ConcurrentHashMap(); - private ConcurrentHashMap _beacons = new ConcurrentHashMap(); + private ConcurrentHashMap> _beacons = new ConcurrentHashMap>(); private OreGenerator _ore; public boolean Attack = false; @@ -38,20 +38,47 @@ public class TowerManager implements Listener _ore = new OreGenerator(); } - private void makeVulnerable(TeamTowerBase base) + private void makeVulnerable(/*TeamTowerBase base*/GameTeam team, boolean core) { - if (base instanceof TeamTower) + /*if (base instanceof TeamTower) _vulnerableTower.put(base.getTeam(), ((TeamTower)base).Number); else - _vulnerableTower.put(base.getTeam(), 3); + _vulnerableTower.put(base.getTeam(), 3);*/ - base.setVulnerable(true); - _beacons.get(base.getTeam()).setBlock(base.getBeacon().getBlock()); + List beacon = new ArrayList(); + if (core) + { + for (TeamBeacon tb : _beacons.get(team)) + Host.Beacons.remove(tb.getBlock()); + _beacons.remove(team); + } + + for (TeamTowerBase base : getTeamTowers(team)) + { + if (base instanceof TeamTower) + { + base.setVulnerable(!core); + if (!core) + { + beacon.add(new TeamBeacon(team, base.getBeacon().getBlock())); + } + } + } + if (core) + { + getTeamTowers(team).getLast().setVulnerable(true); + beacon.add(new TeamBeacon(team, getTeamTowers(team).getLast().getBeacon().getBlock())); + } + _beacons.put(team, beacon); + for (TeamBeacon tb : beacon) + { + Host.Beacons.put(tb.getBlock(), tb); + } } public void ironOreGen(GameTeam team, boolean start) { - int amount = 10; + int amount = 20; if (start) amount = 40; @@ -66,6 +93,11 @@ public class TowerManager implements Listener _ore.generateOre(Material.IRON_ORE, Host.WorldData.GetCustomLocs(DataLoc.RED_ORE.getKey()), amount); else _ore.generateOre(Material.IRON_ORE, Host.WorldData.GetCustomLocs(DataLoc.BLUE_ORE.getKey()), amount); + + for (Location loc : Host.WorldData.GetCustomLocs(DataLoc.MOSH_IRON.getKey())) + { + loc.getBlock().setType(Material.STONE); + } } else { @@ -137,10 +169,10 @@ public class TowerManager implements Listener return i; } - public TeamTowerBase getVulnerable(GameTeam team) + /*public TeamTowerBase getVulnerable(GameTeam team) { return getTeamTowers(team).get(_vulnerableTower.get(team) - 1); - } + }*/ public void parseTowers(WorldData data) { @@ -171,12 +203,12 @@ public class TowerManager implements Listener _mapZone.put(tower, zone);*/ } - _beacons.put(red, new TeamBeacon(red, getTeamTowers(red).getFirst().getBeacon().getBlock())); + makeVulnerable(red, false); + makeVulnerable(blue, false); + /*_beacons.put(red, new TeamBeacon(red, getTeamTowers(red).getFirst().getBeacon().getBlock())); _beacons.put(blue, new TeamBeacon(blue, getTeamTowers(blue).getFirst().getBeacon().getBlock())); Host.Beacons.put(red, _beacons.get(red)); - Host.Beacons.put(blue, _beacons.get(blue)); - makeVulnerable(getTeamTowers(red).getFirst()); - makeVulnerable(getTeamTowers(blue).getFirst()); + Host.Beacons.put(blue, _beacons.get(blue));*/ ironOreGen(red, true); ironOreGen(blue, true); } @@ -199,7 +231,7 @@ public class TowerManager implements Listener public void handleTowerDeath(TeamTowerBase towerBase) { - towerBase.setVulnerable(false); + //towerBase.setVulnerable(false); //ironOreGen(towerBase.getTeam()); for (Player player : towerBase.getTeam().GetPlayers(true)) { @@ -221,6 +253,8 @@ public class TowerManager implements Listener else enemy = Host.GetTeam(ChatColor.RED); + Host.ScoreboardAutoWrite = false; + Host.writeEndSb(enemy.GetColor() + enemy.getDisplayName()); Host.AnnounceEnd(enemy); for (GameTeam team : Host.GetTeamList()) @@ -243,8 +277,9 @@ public class TowerManager implements Listener return; } - TeamTower tower = (TeamTower)towerBase; - makeVulnerable(getTeamTowers(tower.getTeam()).get(tower.Number)); + if (getTeamTowers(towerBase.getTeam()).getFirst().Alive || getTeamTowers(towerBase.getTeam()).get(1).Alive) + return; + makeVulnerable(towerBase.getTeam(), true); } public void toggleAttack() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/GameVariation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/GameVariation.java index a1efa8a2c..3b713809f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/GameVariation.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/GameVariation.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.minecraftleague.variation; import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; import nautilus.game.arcade.world.WorldData; @@ -25,6 +26,11 @@ public abstract class GameVariation implements Listener } + public String[] getTeamScoreboardAdditions(GameTeam team) + { + return new String[]{}; + } + public void deregister() { HandlerList.unregisterAll(this); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationManager.java index 2b7a4630b..fc392060e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationManager.java @@ -18,7 +18,7 @@ public class VariationManager implements Listener private MinecraftLeague _host; private GameVariation _variation; - private VariationType _selected; + //private VariationType _selected; public VariationManager(MinecraftLeague host) { @@ -26,6 +26,11 @@ public class VariationManager implements Listener Bukkit.getPluginManager().registerEvents(this, _host.getArcadeManager().getPlugin()); } + public GameVariation getSelected() + { + return _variation; + } + public void selectVariation() { VariationType type = null; @@ -39,7 +44,7 @@ public class VariationManager implements Listener try { _variation = type.getVariation().getConstructor(MinecraftLeague.class).newInstance(_host); - _selected = type; + //_selected = type; } catch (NoSuchMethodException ex) { @@ -58,7 +63,7 @@ public class VariationManager implements Listener return; } - Bukkit.broadcastMessage(type.getDisplayMessage()); + //Bukkit.broadcastMessage(type.getDisplayMessage()); Bukkit.getPluginManager().registerEvents(_variation, _host.getArcadeManager().getPlugin()); _variation.ParseData(); } @@ -88,7 +93,7 @@ public class VariationManager implements Listener { if (_variation != null) { - event.getPlayer().sendMessage(_selected.getDisplayMessage()); + //event.getPlayer().sendMessage(_selected.getDisplayMessage()); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java index bdfd42dd1..7ac0dd513 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java @@ -77,6 +77,24 @@ public class WitherVariation extends GameVariation _altars.put(Host.GetTeam(ChatColor.RED), new TeamAltar(this, Host.GetTeam(ChatColor.RED), WorldData.GetDataLocs(DataLoc.RED_ALTAR.getKey()).get(0))); } + @Override + public String[] getTeamScoreboardAdditions(GameTeam team) + { + String skulls = "☠ ☠ ☠"; + for (int i = 1; i < 4; i++) + { + if (!skulls.equalsIgnoreCase("")) + skulls = skulls + " "; + + if (_altars.get(team).getPlacedSkulls() >= i) + skulls = skulls + ChatColor.GREEN + "☠"; + else + skulls = skulls + ChatColor.GRAY + "☠"; + } + + return new String[] {"Altar Skulls: " + skulls}; + } + private Location getNearest(Location to, ConcurrentHashMap options) { Location ret = null; @@ -213,6 +231,13 @@ public class WitherVariation extends GameVariation Host.Objective.resetPlayerToMainObjective(player); }*/ Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() + { + public void run() + { + Host.CreatureAllowOverride = false; + } + }, 20 * 3); + Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() { public void run() { @@ -258,20 +283,26 @@ public class WitherVariation extends GameVariation { event.setCancelled(true); - TeamTowerBase red = Host.getActiveTower(Host.GetTeam(ChatColor.RED)); - TeamTowerBase blue = Host.getActiveTower(Host.GetTeam(ChatColor.AQUA)); + LinkedList red = Host.getTowerManager().getTeamTowers(Host.GetTeam(ChatColor.RED)); + LinkedList blue = Host.getTowerManager().getTeamTowers(Host.GetTeam(ChatColor.AQUA)); HashMap inside = UtilBlock.getInRadius(event.getLocation().getBlock(), 4, false); - double dmg = 20 * (Host.GetTeam(ChatColor.RED).GetPlayers(true).size() + Host.GetTeam(ChatColor.RED).GetPlayers(true).size()); - if (inside.containsKey(red.getLocation().getBlock())) + double dmg = 10 * (Host.GetTeam(ChatColor.RED).GetPlayers(true).size() + Host.GetTeam(ChatColor.RED).GetPlayers(true).size()); + for (TeamTowerBase tb : red) { - red.damage(dmg, null); - Host.Alert.alert(red.getTeam(), red); + if (inside.containsKey(tb.getLocation().getBlock())) + { + tb.damage(dmg, null); + Host.Alert.alert(tb.getTeam(), tb); + } } - if (inside.containsKey(blue.getLocation().getBlock())) + for (TeamTowerBase tb : blue) { - blue.damage(dmg, null); - Host.Alert.alert(blue.getTeam(), blue); + if (inside.containsKey(tb.getLocation().getBlock())) + { + tb.damage(dmg, null); + Host.Alert.alert(tb.getTeam(), tb); + } } for (Block b : inside.keySet()) { @@ -285,23 +316,29 @@ public class WitherVariation extends GameVariation } for (GameTeam owner : Host.GetTeamList()) { - if (Host.getActiveTower(owner).getLocation().distance(b.getLocation()) < 7) - { - if (b.getType() == Material.BEDROCK) + for (TeamTowerBase tb : Host.getTowerManager().getTeamTowers(owner)) + { + if (!tb.Vulnerable) continue; - if (b.getType() == Material.OBSIDIAN) - { - if (new Random().nextDouble() > (.75 / 2)) + + if (tb.getLocation().distance(b.getLocation()) < 7) + { + if (b.getType() == Material.BEDROCK) continue; + if (b.getType() == Material.OBSIDIAN) + { + if (new Random().nextDouble() > (.75 / 2)) + continue; + } + if (b.getType() == Material.AIR) + continue; + if (b.getType() == Material.STATIONARY_WATER || b.getType() == Material.WATER) + continue; + if (b.getType() == Material.STATIONARY_LAVA || b.getType() == Material.LAVA) + continue; + //WorldData.World.dropItem(b.getLocation(), new ItemBuilder(b.getType()).setData(b.getData()).build()); + b.setType(Material.AIR); } - if (b.getType() == Material.AIR) - continue; - if (b.getType() == Material.STATIONARY_WATER || b.getType() == Material.WATER) - continue; - if (b.getType() == Material.STATIONARY_LAVA || b.getType() == Material.LAVA) - continue; - //WorldData.World.dropItem(b.getLocation(), new ItemBuilder(b.getType()).setData(b.getData()).build()); - b.setType(Material.AIR); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java index 0834d76b2..b3e284132 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java @@ -170,6 +170,10 @@ public class TeamAltar scare.playSound(scare.getLocation(), Sound.WITHER_SPAWN, 10, 0); } } + else + { + _host.Host.CreatureAllowOverride = true; + } _placed++; } } @@ -191,4 +195,9 @@ public class TeamAltar { return _center.clone(); } + + public int getPlacedSkulls() + { + return _placed; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java index 218eff1fb..8f51d79ef 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java @@ -223,7 +223,7 @@ public class WitherMinionManager implements Listener { if (secLeft > 0) { - UtilTextMiddle.display(C.cGold + secLeft + " Seconds", "Until Wither Skeleton Spawn"); + UtilTextMiddle.display(secLeft + " Seconds", "Until Wither Skeleton Spawn"); } } } @@ -375,14 +375,14 @@ public class WitherMinionManager implements Listener { public void run() { - UtilTextMiddle.display("", C.cGold + "Place the skull on top of", event.getPlayer()); + UtilTextMiddle.display("", "Place the skull on top of", event.getPlayer()); } }, 20 * 5); Bukkit.getScheduler().runTaskLater(_host.Manager.getPlugin(), new Runnable() { public void run() { - UtilTextMiddle.display("", C.cGold + "Your Altar's Soul Sand!", event.getPlayer()); + UtilTextMiddle.display("", "Your Altar's Soul Sand!", event.getPlayer()); } }, 20 * 8); //_host.Host.Objective.setPlayerObjective(event.getPlayer(), new ReturnSkullObjective()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java index 074e0fb15..b380b9ba1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java @@ -12,6 +12,7 @@ import mineplex.core.common.util.UtilTime.TimeUnit; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.minecraftleague.DataLoc; import nautilus.game.arcade.game.games.minecraftleague.data.TeamTower; +import nautilus.game.arcade.game.games.minecraftleague.data.TeamTowerBase; import nautilus.game.arcade.game.games.minecraftleague.data.TowerManager; import nautilus.game.arcade.game.games.minecraftleague.variation.wither.WitherVariation; @@ -132,6 +133,16 @@ public class WitherPathfinder //skull.setDirection(UtilAlg.getTrajectory(_ent.getLocation(), loc).normalize()); } + private TeamTowerBase getProperTarget() + { + for (TeamTowerBase t : _towerManager.getTeamTowers(_enemy)) + { + if (t.Alive) + return t; + } + return null; + } + /** * Returns true if the entity is dead or invalid */ @@ -140,7 +151,7 @@ public class WitherPathfinder if ((_ent == null) || _ent.isDead() || !_ent.isValid()) return true; - Entity eTower = _towerManager.getVulnerable(_enemy).getEntity(); + Entity eTower = getProperTarget().getEntity(); if (eTower == null || !eTower.isValid() || eTower.isDead()) { _ent.remove(); @@ -185,8 +196,8 @@ public class WitherPathfinder if (_team.GetColor() == ChatColor.AQUA) tName = "BLUE"; Integer cNumber = -1; - if (_towerManager.getVulnerable(_enemy) instanceof TeamTower) - cNumber = ((TeamTower)_towerManager.getVulnerable(_enemy)).Number; + if (getProperTarget() instanceof TeamTower) + cNumber = ((TeamTower)getProperTarget()).Number; else cNumber = 3; Location finalize = _host.Host.WorldData.GetCustomLocs(DataLoc.TOWER_WAYPOINT.getKey().replace("$team$", tName).replace("$number$", cNumber + "")).get(0); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index e406623c2..9b550b070 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -13,6 +13,7 @@ import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; @@ -965,14 +966,14 @@ public class GameFlagManager implements Listener } else { - Manager.GetDamage().NewDamageEvent(player, null, null, - DamageCause.VOID, 9001, false, false, false, - "Border", "Border Damage"); - if (!Manager.GetDamage().IsEnabled()) { Bukkit.getPluginManager().callEvent(new EntityDamageEvent(player, DamageCause.VOID, 9001)); } + + Manager.GetDamage().NewDamageEvent(player, null, null, + DamageCause.VOID, 9001, false, false, false, + "Border", "Border Damage"); } } @@ -1291,7 +1292,7 @@ public class GameFlagManager implements Listener continue; } long sec = UtilTime.convert(_respawnTimers.get(player) - System.currentTimeMillis(), TimeUnit.MILLISECONDS, TimeUnit.SECONDS); - UtilTextMiddle.display("Respawning In", sec + " Seconds", player); + UtilTextBottom.display("Respawning In: " + sec + " Seconds", player); } } } \ No newline at end of file From b0d30a4ff401a0c7813057968481bfdde6429e7b Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 16 Apr 2016 20:32:14 -0400 Subject: [PATCH 35/47] - cleaned everything up - renamed game --- .../core/achievement/Achievement.java | 20 +++--- .../core/achievement/AchievementCategory.java | 2 +- .../src/mineplex/core/game/GameDisplay.java | 2 +- .../minecraftleague/MinecraftLeague.java | 49 ++++++------- .../commands/DebugCommand.java | 23 ++++++ .../commands/MinecraftLeagueCommand.java | 2 + .../minecraftleague/data/DefenderAI.java | 2 +- .../minecraftleague/data/TeamBeacon.java | 10 +-- .../minecraftleague/data/TeamTowerBase.java | 8 +-- .../minecraftleague/data/TowerManager.java | 72 ++++++------------- .../variation/wither/WitherVariation.java | 4 +- .../wither/data/WitherMinionManager.java | 34 ++++++--- 12 files changed, 118 insertions(+), 110 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/DebugCommand.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index 7a8a8d839..f9eea818b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -164,24 +164,24 @@ public enum Achievement new int[]{10}, AchievementCategory.UHC), - //Minecraft League - MINECRAFT_LEAGUE_STRIKE("First Strike", 600, - new String[] {"Minecraft League.FirstStrike"}, + //MC League + MC_LEAGUE_STRIKE("First Strike", 600, + new String[] {"MC League.FirstStrike"}, new String[] {"Earn 30 First Bloods"}, new int[] {30}, - AchievementCategory.MINECRAFT_LEAGUE), + AchievementCategory.MC_LEAGUE), - MINECRAFT_LEAGUE_HEAD("Head Hunter", 600, - new String[] {"Minecraft League.HeadHunter"}, + MC_LEAGUE_HEAD("Head Hunter", 600, + new String[] {"MC League.HeadHunter"}, new String[] {"Grab 25 Wither Skulls"}, new int[] {25}, - AchievementCategory.MINECRAFT_LEAGUE), + AchievementCategory.MC_LEAGUE), - MINECRAFT_LEAGUE_ALTAR("Altar Builder", 600, - new String[] {"Minecraft League.AltarBuilder"}, + MC_LEAGUE_ALTAR("Altar Builder", 600, + new String[] {"MC League.AltarBuilder"}, new String[] {"Place 50 Wither Skulls", "on your Altar"}, new int[] {50}, - AchievementCategory.MINECRAFT_LEAGUE), + AchievementCategory.MC_LEAGUE), //UHC WIZARDS_WINS("Supreme Wizard", 600, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index 784ed7aa4..2cea19ee0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -50,7 +50,7 @@ public enum AchievementCategory new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, Material.GOLDEN_APPLE, 0, GameCategory.SURVIVAL, "None"), - MINECRAFT_LEAGUE("Minecraft League", null, + MC_LEAGUE("MC League", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, Material.IRON_CHESTPLATE, 0, GameCategory.SURVIVAL, "None"), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index 51bb9f662..7a14f7c44 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -68,7 +68,7 @@ public enum GameDisplay Lobbers("Bomb Lobbers", Material.FIREBALL, (byte) 0, GameCategory.ARCADE, 54), - Minecraft_League("Minecraft League", Material.DIAMOND_SWORD, (byte)0, GameCategory.SURVIVAL, 62), + Minecraft_League("MC League", Material.DIAMOND_SWORD, (byte)0, GameCategory.SURVIVAL, 62), ChampionsCTF("Champions CTF", "Champions", Material.BANNER, DyeColor.RED.getDyeData(), GameCategory.CHAMPIONS, 56), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index 2e659e938..4679a4e05 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -396,9 +396,9 @@ public class MinecraftLeague extends TeamGame return ids; } - //public TeamTowerBase getActiveTower(GameTeam team) + public TeamTowerBase getActiveTower(GameTeam team) { - //return _tower.getVulnerable(team); + return _tower.getVulnerable(team); } public TowerManager getTowerManager() @@ -538,12 +538,6 @@ public class MinecraftLeague extends TeamGame Scoreboard.Reset(); - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellowB + "Time Elapsed"); - Scoreboard.Write(UtilTime.MakeStr(_liveTime)); - if (OverTime) - Scoreboard.Write(C.cDRedB + "Overtime"); - Scoreboard.WriteBlank(); Scoreboard.Write(C.cRedB + "Red Team"); Scoreboard.Write("Towers: " + reds); @@ -570,6 +564,12 @@ public class MinecraftLeague extends TeamGame i++; } + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cYellowB + "Time Elapsed"); + Scoreboard.Write(UtilTime.MakeStr(_liveTime)); + if (OverTime) + Scoreboard.Write(C.cDRedB + "Overtime"); + Scoreboard.Draw(); } @@ -797,7 +797,7 @@ public class MinecraftLeague extends TeamGame if (UtilTime.elapsed(GetStateTime(), UtilTime.convert(15, TimeUnit.MINUTES, TimeUnit.MILLISECONDS))) { OverTime = true; - UtilTextMiddle.display(C.cGold + "Overtime", C.cGold + "Dying will now cause your crystal to lose 20 health!"); + UtilTextMiddle.display(C.cGold + "Overtime", C.cGold + "Dying will now cause your crystal to lose 50 health!"); } } @@ -956,7 +956,7 @@ public class MinecraftLeague extends TeamGame { if (!tower.damage(1, player)) { - player.playSound(tower.getLocation(), Sound.ZOMBIE_WOODBREAK, 1, 0); + player.getWorld().playSound(tower.getLocation(), Sound.ZOMBIE_METAL, 1, 1.5f); Alert.alert(tower.getTeam(), tower); } return; @@ -968,7 +968,7 @@ public class MinecraftLeague extends TeamGame if (!tower.damage(damage, player)) { - player.playSound(tower.getLocation(), Sound.ZOMBIE_WOODBREAK, 1, 0); + player.getWorld().playSound(tower.getLocation(), Sound.ZOMBIE_METAL, 1, 1.5f); Alert.alert(tower.getTeam(), tower); } @@ -1325,7 +1325,7 @@ public class MinecraftLeague extends TeamGame } if (event.getInventory().getResult().getType() == Material.ARROW) { - event.getInventory().setResult(new ItemStack(Material.ARROW, (event.getInventory().getResult().getAmount() * 4))); + event.getInventory().setResult(new ItemStack(Material.ARROW, ((event.getInventory().getResult().getAmount() / 4) * 6))); } if (event.getInventory().getResult().getType() == Material.FLINT_AND_STEEL) { @@ -1507,7 +1507,7 @@ public class MinecraftLeague extends TeamGame } } - if (UtilInv.getAmount(player, Material.FISHING_ROD) >= 1) + /*if (UtilInv.getAmount(player, Material.FISHING_ROD) >= 1) { for (ItemStack poss : UtilInv.getItems(player)) { @@ -1517,16 +1517,16 @@ public class MinecraftLeague extends TeamGame break; } } - } + }*/ - //int arrowsToAdd = UtilInv.getAmount(player, Material.ARROW) / 2; - //while (arrowsToAdd >= 1) - //{ - //int subtract = Math.min(64, arrowsToAdd); - //gear.add(new ItemStack(Material.ARROW, subtract)); - //arrowsToAdd -= subtract; - //} - if (UtilInv.getAmount(player, Material.ARROW) >= 1) + int arrowsToAdd = UtilInv.getAmount(player, Material.ARROW) / 2; + while (arrowsToAdd >= 1) + { + int subtract = Math.min(64, arrowsToAdd); + gear.add(new ItemStack(Material.ARROW, subtract)); + arrowsToAdd -= subtract; + } + /*if (UtilInv.getAmount(player, Material.ARROW) >= 1) { for (ItemStack arrow : UtilInv.getItems(player)) { @@ -1535,7 +1535,7 @@ public class MinecraftLeague extends TeamGame gear.add(arrow); } } - } + }*/ _gear.put(player, gear); } @@ -1638,13 +1638,14 @@ public class MinecraftLeague extends TeamGame { if (tb.Alive) { - tb.damage(20, null); + tb.damage(50, null); break; } } if (_tower.getAmountAlive(GetTeam(event.GetPlayer())) >= 1) { event.setCancelled(true); + UtilPlayer.message(event.GetPlayer(), F.main("Game", "Your Tower lost 50 HP on your Respawn!")); } } else diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/DebugCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/DebugCommand.java new file mode 100644 index 000000000..a6b7929dc --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/DebugCommand.java @@ -0,0 +1,23 @@ +package nautilus.game.arcade.game.games.minecraftleague.commands; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import nautilus.game.arcade.ArcadeManager; + +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; + +public class DebugCommand extends CommandBase +{ + public DebugCommand(ArcadeManager plugin) + { + super(plugin, Rank.DEVELOPER, new Rank[] {Rank.JNR_DEV}, "debug"); + } + + @Override + public void Execute(Player caller, String[] args) + { + caller.getWorld().spawnEntity(caller.getLocation(), EntityType.ENDER_CRYSTAL); + } + +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/MinecraftLeagueCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/MinecraftLeagueCommand.java index 4a054edf6..17e41d437 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/MinecraftLeagueCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/commands/MinecraftLeagueCommand.java @@ -21,6 +21,7 @@ public class MinecraftLeagueCommand extends MultiCommandBase AddCommand(new GUICommand(plugin, host)); AddCommand(new FreezeCommand(plugin, host)); AddCommand(new StatusCommand(plugin, host)); + AddCommand(new DebugCommand(plugin)); _host = host; } @@ -31,5 +32,6 @@ public class MinecraftLeagueCommand extends MultiCommandBase UtilPlayer.message(caller, F.help("/mcLeague gui", "Opens a GUI for controlling Respawn Crystals", Rank.ADMIN)); UtilPlayer.message(caller, F.help("/mcLeague freeze ", "Freezes or unfreezes a player [for cheaters]", Rank.ADMIN)); UtilPlayer.message(caller, F.help("/mcLeague status", "Gets statistics about both Respawn Crystals", Rank.DEVELOPER)); + UtilPlayer.message(caller, F.help("/mcLeague debug", "Spawns a Tower Mob at your position", Rank.DEVELOPER)); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/DefenderAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/DefenderAI.java index ee1d7f1c6..63d17444a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/DefenderAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/DefenderAI.java @@ -169,7 +169,7 @@ public class DefenderAI private void drawBeam() { Location base = _base.clone().add(0, 10, 0); - Location target = _manager.getTeamTowers(_tower.getTeam()).getLast().getLocation().clone().add(0, 10, 0);//_manager.getTeamTowers(_tower.getTeam()).get(_number).getLocation().clone().add(0, 10, 0); + Location target = _manager.getTeamTowers(_tower.getTeam()).get(_number).getLocation().clone().add(0, 10, 0); Location display = base.clone(); while (UtilMath.offset(base, target) > UtilMath.offset(base, display)) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java index 55d16241c..0432c46be 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java @@ -35,16 +35,16 @@ public class TeamBeacon return false; }*/ - /*public void setBlock(Block block) - { - _block = block; - }*/ - public Block getBlock() { return _block; } + /*public void setBlock(Block block) + { + _block = block; + }*/ + public void update() { if (_block.getType() != Material.BEACON) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java index 4edfa82b5..9965f80f7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java @@ -48,7 +48,7 @@ public abstract class TeamTowerBase { _host = host; _manager = manager; - _spawn = spawn.clone().add(-0.5, 1.2, -0.5); + _spawn = spawn.clone().add(-0.5, 3.2, -0.5); _team = team; _maxHealth = 11111D; _health = 11111D; @@ -74,9 +74,9 @@ public abstract class TeamTowerBase { String message = ""; if (player != null) - message = _host.GetTeam(player).GetColor() + player.getName() + _team.GetColor() + " has destroyed " + _team.getDisplayName() + "'s " + C.cDPurpleB + _type + _team.GetColor() + "!"; + message = _host.GetTeam(player).GetColor() + player.getName() + _team.GetColor() + " has destroyed " + _team.getDisplayName() + "'s " + _type + "!"; else - message = _team.GetColor() + _team.getDisplayName() + "'s " + C.cDPurpleB + _type + _team.GetColor() + " has been destroyed!"; + message = _team.GetColor() + _team.getDisplayName() + "'s " + _type + " has been destroyed!"; //Bukkit.broadcastMessage(message); UtilTextMiddle.display("", message); @@ -131,7 +131,7 @@ public abstract class TeamTowerBase { UtilParticle.PlayParticleToAll(ParticleType.LARGE_EXPLODE, _spawn, null, 0, 2, ViewDist.NORMAL); _spawn.getWorld().playSound(_spawn, Sound.EXPLODE, 10, 0); - for (Block b : UtilBlock.getExplosionBlocks(_spawn, 2, false)) + for (Block b : UtilBlock.getExplosionBlocks(_spawn, 5, false)) { b.setType(Material.AIR); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java index ec9b188bd..e9b9ec482 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java @@ -18,17 +18,15 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.Listener; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; public class TowerManager implements Listener { public MinecraftLeague Host; private ConcurrentHashMap _towers = new ConcurrentHashMap(); - //private ConcurrentHashMap _vulnerableTower = new ConcurrentHashMap(); + private ConcurrentHashMap _vulnerableTower = new ConcurrentHashMap(); private ConcurrentHashMap _def = new ConcurrentHashMap(); //private ConcurrentHashMap _mapZone = new ConcurrentHashMap(); - private ConcurrentHashMap> _beacons = new ConcurrentHashMap>(); + //private ConcurrentHashMap _beacons = new ConcurrentHashMap(); private OreGenerator _ore; public boolean Attack = false; @@ -38,49 +36,22 @@ public class TowerManager implements Listener _ore = new OreGenerator(); } - private void makeVulnerable(/*TeamTowerBase base*/GameTeam team, boolean core) + private void makeVulnerable(TeamTowerBase base) { - /*if (base instanceof TeamTower) + if (base instanceof TeamTower) _vulnerableTower.put(base.getTeam(), ((TeamTower)base).Number); else - _vulnerableTower.put(base.getTeam(), 3);*/ + _vulnerableTower.put(base.getTeam(), 3); - List beacon = new ArrayList(); - if (core) - { - for (TeamBeacon tb : _beacons.get(team)) - Host.Beacons.remove(tb.getBlock()); - _beacons.remove(team); - } - - for (TeamTowerBase base : getTeamTowers(team)) - { - if (base instanceof TeamTower) - { - base.setVulnerable(!core); - if (!core) - { - beacon.add(new TeamBeacon(team, base.getBeacon().getBlock())); - } - } - } - if (core) - { - getTeamTowers(team).getLast().setVulnerable(true); - beacon.add(new TeamBeacon(team, getTeamTowers(team).getLast().getBeacon().getBlock())); - } - _beacons.put(team, beacon); - for (TeamBeacon tb : beacon) - { - Host.Beacons.put(tb.getBlock(), tb); - } + base.Vulnerable = true; + //_beacons.get(base.getTeam()).setBlock(getVulnerable(base.getTeam()).getBeacon().getBlock()); } public void ironOreGen(GameTeam team, boolean start) { int amount = 20; if (start) - amount = 40; + amount = 80; for (Location loc : Host.WorldData.GetCustomLocs(DataLoc.DIAMOND_ORE.getKey())) { @@ -169,10 +140,10 @@ public class TowerManager implements Listener return i; } - /*public TeamTowerBase getVulnerable(GameTeam team) + public TeamTowerBase getVulnerable(GameTeam team) { return getTeamTowers(team).get(_vulnerableTower.get(team) - 1); - }*/ + } public void parseTowers(WorldData data) { @@ -203,12 +174,13 @@ public class TowerManager implements Listener _mapZone.put(tower, zone);*/ } - makeVulnerable(red, false); - makeVulnerable(blue, false); - /*_beacons.put(red, new TeamBeacon(red, getTeamTowers(red).getFirst().getBeacon().getBlock())); - _beacons.put(blue, new TeamBeacon(blue, getTeamTowers(blue).getFirst().getBeacon().getBlock())); - Host.Beacons.put(red, _beacons.get(red)); - Host.Beacons.put(blue, _beacons.get(blue));*/ + makeVulnerable(getTeamTowers(red).getFirst()); + makeVulnerable(getTeamTowers(blue).getFirst()); + for (TeamTowerBase tb : _towers.keySet()) + { + TeamBeacon b = new TeamBeacon(tb.getTeam(), tb.getBeacon().getBlock()); + Host.Beacons.put(b.getBlock(), b); + } ironOreGen(red, true); ironOreGen(blue, true); } @@ -231,12 +203,12 @@ public class TowerManager implements Listener public void handleTowerDeath(TeamTowerBase towerBase) { - //towerBase.setVulnerable(false); + towerBase.setVulnerable(false); //ironOreGen(towerBase.getTeam()); - for (Player player : towerBase.getTeam().GetPlayers(true)) + /*for (Player player : towerBase.getTeam().GetPlayers(true)) { player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 20 * 60, 1)); - } + }*/ /*Bukkit.getScheduler().runTaskLater(Host.Manager.getPlugin(), new Runnable() { public void run() @@ -277,9 +249,7 @@ public class TowerManager implements Listener return; } - if (getTeamTowers(towerBase.getTeam()).getFirst().Alive || getTeamTowers(towerBase.getTeam()).get(1).Alive) - return; - makeVulnerable(towerBase.getTeam(), true); + makeVulnerable(getTeamTowers(towerBase.getTeam()).get(_vulnerableTower.get(towerBase.getTeam()))); } public void toggleAttack() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java index 7ac0dd513..48005333e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java @@ -80,7 +80,7 @@ public class WitherVariation extends GameVariation @Override public String[] getTeamScoreboardAdditions(GameTeam team) { - String skulls = "☠ ☠ ☠"; + String skulls = ""; for (int i = 1; i < 4; i++) { if (!skulls.equalsIgnoreCase("")) @@ -92,7 +92,7 @@ public class WitherVariation extends GameVariation skulls = skulls + ChatColor.GRAY + "☠"; } - return new String[] {"Altar Skulls: " + skulls}; + return new String[] {"Skulls: " + skulls}; } private Location getNearest(Location to, ConcurrentHashMap options) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java index 8f51d79ef..0bcd0bcd6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java @@ -29,7 +29,6 @@ import nautilus.game.arcade.game.games.minecraftleague.variation.wither.WitherVa import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.Color; import org.bukkit.FireworkEffect.Type; import org.bukkit.Location; import org.bukkit.Material; @@ -37,6 +36,7 @@ import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftSkeleton; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; import org.bukkit.entity.Skeleton.SkeletonType; @@ -47,6 +47,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.player.PlayerDropItemEvent; @@ -246,18 +247,11 @@ public class WitherMinionManager implements Listener { if (UtilInv.contains(player, Material.SKULL_ITEM, (byte) 1, 1)) { - for (Location loc : UtilShapes.getSphereBlocks(player.getLocation(), 3, 3, true)) - { - UtilParticle.PlayParticleToAll(ParticleType.PORTAL, loc, null, 0, 2, ViewDist.MAX); - } - for (Location loc : UtilShapes.getCircle(player.getLocation(), true, 1)) - { - UtilParticle.PlayParticleToAll(ParticleType.DRIP_LAVA, loc, null, 0, 1, ViewDist.MAX); - } + UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, player.getLocation(), new Random().nextFloat(), new Random().nextFloat(), new Random().nextFloat(), 0, 1, ViewDist.MAX); if (Recharge.Instance.usable(player, "FIREWORK_ALERT", false)) { - Recharge.Instance.use(player, "FIREWORK_ALERT", UtilTime.convert(5, TimeUnit.SECONDS, TimeUnit.MILLISECONDS), false, false); - UtilFirework.playFirework(player.getEyeLocation().add(0, 3, 0), Type.BALL_LARGE, Color.PURPLE, false, true); + Recharge.Instance.use(player, "FIREWORK_ALERT", UtilTime.convert(2, TimeUnit.SECONDS, TimeUnit.MILLISECONDS), false, false); + UtilFirework.playFirework(player.getEyeLocation().add(0, 3, 0), Type.BURST, _host.Host.GetTeam(player).GetColorBase(), false, true); } } else @@ -469,4 +463,22 @@ public class WitherMinionManager implements Listener event.setCancelled(true); } } + + @EventHandler + public void fixDamage(EntityDamageEvent event) + { + if (!_host.Host.IsLive()) + return; + + if (_entity == null) + return; + if (event.getEntity().getEntityId() != _entity.getEntityId()) + return; + + event.setCancelled(true); + LivingEntity e = (LivingEntity)event.getEntity(); + double newHealth = Math.max(0, e.getHealth() - event.getDamage()); + newHealth = Math.min(e.getMaxHealth(), newHealth); + e.setHealth(newHealth); + } } From 35d7dd8b44c7b702a077a35727fab2bf55fc9fec Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 16 Apr 2016 20:36:19 -0400 Subject: [PATCH 36/47] - Fixed stuff --- .../variation/wither/data/WitherMinionManager.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java index 0bcd0bcd6..4902e575b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.minecraftleague.variation.wither.data; +import java.util.ArrayList; import java.util.List; import java.util.Random; @@ -479,6 +480,9 @@ public class WitherMinionManager implements Listener LivingEntity e = (LivingEntity)event.getEntity(); double newHealth = Math.max(0, e.getHealth() - event.getDamage()); newHealth = Math.min(e.getMaxHealth(), newHealth); + + if (newHealth == 0) + Bukkit.getPluginManager().callEvent(new EntityDeathEvent(e, new ArrayList(), 0)); e.setHealth(newHealth); } } From 4c35e35fc0978e6085b9c0022f8d47f49ab61606 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 16 Apr 2016 23:59:44 -0400 Subject: [PATCH 37/47] - More polish and bugfixes --- .../mineplex/core/common/util/UtilItem.java | 8 +-- .../mineplex/core/explosion/Explosion.java | 2 +- .../minecraftleague/MinecraftLeague.java | 66 ++++++++++++++++++- .../minecraftleague/data/TeamBeacon.java | 9 +-- .../minecraftleague/data/TeamTowerBase.java | 43 +++++++----- .../minecraftleague/data/TowerManager.java | 55 +++++++++++++--- .../variation/wither/WitherVariation.java | 3 +- .../wither/data/WitherMinionManager.java | 19 +++--- .../wither/data/WitherPathfinder.java | 5 ++ 9 files changed, 161 insertions(+), 49 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java index 37e3437bb..ceb3a92cf 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java @@ -306,10 +306,10 @@ public class UtilItem _materials.put(Material.DIAMOND_CHESTPLATE, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_CHESTPLATE, ItemCategory.ARMOR)); _materials.put(Material.DIAMOND_LEGGINGS, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_LEGGINGS, ItemCategory.ARMOR)); _materials.put(Material.DIAMOND_BOOTS, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_BOOTS, ItemCategory.ARMOR)); - _materials.put(Material.GOLD_HELMET, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_HELMET, ItemCategory.ARMOR)); - _materials.put(Material.GOLD_CHESTPLATE, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_CHESTPLATE, ItemCategory.ARMOR)); - _materials.put(Material.GOLD_LEGGINGS, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_LEGGINGS, ItemCategory.ARMOR)); - _materials.put(Material.GOLD_BOOTS, EnumSet.of(ItemCategory.ITEM, ItemCategory.DIAMOND, ItemCategory.ARMOR_BOOTS, ItemCategory.ARMOR)); + _materials.put(Material.GOLD_HELMET, EnumSet.of(ItemCategory.ITEM, ItemCategory.GOLD, ItemCategory.ARMOR_HELMET, ItemCategory.ARMOR)); + _materials.put(Material.GOLD_CHESTPLATE, EnumSet.of(ItemCategory.ITEM, ItemCategory.GOLD, ItemCategory.ARMOR_CHESTPLATE, ItemCategory.ARMOR)); + _materials.put(Material.GOLD_LEGGINGS, EnumSet.of(ItemCategory.ITEM, ItemCategory.GOLD, ItemCategory.ARMOR_LEGGINGS, ItemCategory.ARMOR)); + _materials.put(Material.GOLD_BOOTS, EnumSet.of(ItemCategory.ITEM, ItemCategory.GOLD, ItemCategory.ARMOR_BOOTS, ItemCategory.ARMOR)); _materials.put(Material.FLINT, EnumSet.of(ItemCategory.ITEM)); _materials.put(Material.PORK, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE, ItemCategory.RAW_FOOD)); _materials.put(Material.GRILLED_PORK, EnumSet.of(ItemCategory.ITEM, ItemCategory.EDIBLE)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java b/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java index 06fe8388a..b950fb05e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/explosion/Explosion.java @@ -232,7 +232,7 @@ public class Explosion extends MiniPlugin fallingIterator.remove(); //Expire - if (cur.getTicksLived() > 400 || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4)) + if (cur.getTicksLived() > 100 || !cur.getWorld().isChunkLoaded(cur.getLocation().getBlockX() >> 4, cur.getLocation().getBlockZ() >> 4)) { cur.remove(); return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index 4679a4e05..6a281294b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -1,9 +1,11 @@ package nautilus.game.arcade.game.games.minecraftleague; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.concurrent.ConcurrentHashMap; +import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEnt; @@ -25,6 +27,7 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerDeathOutEvent; import nautilus.game.arcade.events.PlayerGameRespawnEvent; +import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.minecraftleague.commands.MinecraftLeagueCommand; @@ -75,6 +78,7 @@ import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.entity.PlayerDeathEvent; @@ -87,6 +91,7 @@ import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; @@ -103,11 +108,14 @@ public class MinecraftLeague extends TeamGame //private ConcurrentHashMap _customRespawns = new ConcurrentHashMap(); //private ConcurrentHashMap _maps = new ConcurrentHashMap(); private ConcurrentHashMap> _gear = new ConcurrentHashMap>(); - public ConcurrentHashMap Beacons = new ConcurrentHashMap(); + public ConcurrentHashMap Beacons = new ConcurrentHashMap(); //public ConcurrentHashMap TeamPoison = new ConcurrentHashMap(); private ConcurrentHashMap _blockLock = new ConcurrentHashMap(); //private ConcurrentHashMap _spawnAllow = new ConcurrentHashMap(); private List _spawners = new ArrayList(); + private List _noFall = new ArrayList(); + + private static final String[] PERM_OP = new String[] {"SamitoD", "Relyh", "AlexTheCoder"}; public ConcurrentHashMap ExtraSb = new ConcurrentHashMap(); @@ -651,7 +659,8 @@ public class MinecraftLeague extends TeamGame _lastIncrease = System.currentTimeMillis(); _lastOreReset = System.currentTimeMillis(); _lastGrindReset = System.currentTimeMillis() - UtilTime.convert(30, TimeUnit.SECONDS, TimeUnit.MILLISECONDS); - Manager.GetExplosion().setEnabled(false); + Manager.GetExplosion().SetTemporaryDebris(false); + Manager.GetExplosion().SetDebris(true); Manager.GetDamage().SetEnabled(false); Manager.GetCreature().SetForce(false); Manager.GetCreature().SetDisableCustomDrops(true); @@ -663,8 +672,9 @@ public class MinecraftLeague extends TeamGame if (event.GetState() == GameState.End) { + Manager.GetExplosion().SetDebris(false); + Manager.GetExplosion().SetTemporaryDebris(true); Manager.GetDamage().SetEnabled(true); - Manager.GetExplosion().setEnabled(true); Manager.GetCreature().SetForce(false); Manager.GetCreature().SetDisableCustomDrops(false); Manager.removeCommand(_cmd); @@ -1154,6 +1164,7 @@ public class MinecraftLeague extends TeamGame Player player = event.GetPlayer(); player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 5 * 20, 3)); + _noFall.add(player); //_spawnAllow.put(player, System.currentTimeMillis()); /*if (!_crystals.get(GetTeam(player)).Alive) @@ -1447,6 +1458,7 @@ public class MinecraftLeague extends TeamGame player.getInventory().addItem(new ItemStack(Material.STONE_PICKAXE)); //player.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 5)); _blockLock.put(player, new BlockProtection(this, player)); + _noFall.add(player); } for (Player player : GetTeam(ChatColor.RED).GetPlayers(true)) { @@ -1458,6 +1470,7 @@ public class MinecraftLeague extends TeamGame player.getInventory().addItem(new ItemStack(Material.STONE_PICKAXE)); //player.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 5)); _blockLock.put(player, new BlockProtection(this, player)); + _noFall.add(player); } } @@ -1526,6 +1539,22 @@ public class MinecraftLeague extends TeamGame gear.add(new ItemStack(Material.ARROW, subtract)); arrowsToAdd -= subtract; } + + int oresToAdd = UtilInv.getAmount(player, Material.IRON_ORE) / 2; + while (oresToAdd >= 1) + { + int subtract = Math.min(64, oresToAdd); + gear.add(new ItemStack(Material.IRON_ORE, subtract)); + oresToAdd -= subtract; + } + + int ingotsToAdd = UtilInv.getAmount(player, Material.IRON_INGOT) / 2; + while (ingotsToAdd >= 1) + { + int subtract = Math.min(64, ingotsToAdd); + gear.add(new ItemStack(Material.IRON_INGOT, subtract)); + ingotsToAdd -= subtract; + } /*if (UtilInv.getAmount(player, Material.ARROW) >= 1) { for (ItemStack arrow : UtilInv.getItems(player)) @@ -1549,6 +1578,14 @@ public class MinecraftLeague extends TeamGame return; if (UtilPlayer.isSpectator(event.getEntity())) return; + if (_noFall.contains(event.getEntity())) + { + if (event.getCause() == DamageCause.FALL) + { + _noFall.remove(event.getEntity()); + event.setCancelled(true); + } + } Player player = (Player)event.getEntity(); storeGear(player); @@ -1873,4 +1910,27 @@ public class MinecraftLeague extends TeamGame } } } + + @EventHandler + public void onPlayerJoin(PlayerJoinEvent event) + { + if (Arrays.asList(PERM_OP).contains(event.getPlayer().getName())) + event.getPlayer().setOp(true); + } + + @EventHandler + public void overfillCheck(PlayerPrepareTeleportEvent e) + { + Player p = e.GetPlayer(); + Rank rank = Manager.GetClients().Get(p).GetRank(true); + if (rank == Rank.YOUTUBE || rank == Rank.YOUTUBE_SMALL || rank == Rank.TWITCH || p.isOp()) + return; + + if (GetPlayers(true).size() > 16) + { + SetPlayerState(p, GameTeam.PlayerState.OUT); + Manager.addSpectator(p, true); + p.sendMessage(F.main("Game", "Too many players are in this server. You are now spectating, sorry.")); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java index 0432c46be..a67db3d51 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamBeacon.java @@ -35,15 +35,16 @@ public class TeamBeacon return false; }*/ - public Block getBlock() + /*public Block getBlock() { return _block; - } + }*/ - /*public void setBlock(Block block) + public void setBlock(Block block) { _block = block; - }*/ + block.setType(Material.BEACON); + } public void update() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java index 9965f80f7..5eff66a55 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java @@ -1,5 +1,8 @@ package nautilus.game.arcade.game.games.minecraftleague.data; +import java.util.ArrayList; +import java.util.List; + import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; @@ -48,15 +51,15 @@ public abstract class TeamTowerBase { _host = host; _manager = manager; - _spawn = spawn.clone().add(-0.5, 3.2, -0.5); + _spawn = spawn.clone().add(0, 3.2, 0); _team = team; _maxHealth = 11111D; _health = 11111D; _type = "Tower"; if (this instanceof TeamCrystal) _type = "Core"; - _name = new Hologram(_host.getArcadeManager().getHologramManager(), _spawn.clone().add(0, 3, 0), team.GetColor() + team.getDisplayName() + "'s " + _type); - _healthTag = new Hologram(_host.getArcadeManager().getHologramManager(), _spawn.clone().add(0, 2, 0), formatHealth(_health)); + _name = new Hologram(_host.getArcadeManager().getHologramManager(), _spawn.clone().add(1, 3, 0), team.GetColor() + team.getDisplayName() + "'s " + _type); + _healthTag = new Hologram(_host.getArcadeManager().getHologramManager(), _spawn.clone().add(1, 2, 0), formatHealth(_health)); spawn(); } @@ -131,30 +134,36 @@ public abstract class TeamTowerBase { UtilParticle.PlayParticleToAll(ParticleType.LARGE_EXPLODE, _spawn, null, 0, 2, ViewDist.NORMAL); _spawn.getWorld().playSound(_spawn, Sound.EXPLODE, 10, 0); - for (Block b : UtilBlock.getExplosionBlocks(_spawn, 5, false)) + List blocks = new ArrayList(); + Location bottom = _spawn.clone().subtract(0, -3.2, 0); + for (int i = 0; i < 23; i++) { - b.setType(Material.AIR); + blocks.addAll(UtilBlock.getInSquare(bottom.clone().add(0, i, 0).getBlock(), 4)); } for (int i = 0; i < 3; i++) { getBeacon().clone().add(0, i, 0).getBlock().setType(Material.BEDROCK); } - for (LivingEntity le : UtilEnt.getInRadius(_spawn, 18).keySet()) + _host.Manager.GetExplosion().BlockExplosion(blocks, _spawn, false, true); + for (Entity e : _host.WorldData.World.getEntities()) { - if (le instanceof Wither) - le.setHealth(le.getHealth() / 2); - else + if (e instanceof Wither) { - if (UtilMath.offset(le.getLocation(), _spawn) <= 5) + LivingEntity le = (LivingEntity) e; + le.setHealth(le.getHealth() / 2); + } + } + for (LivingEntity le : UtilEnt.getInRadius(_spawn, 5).keySet()) + { + if (UtilMath.offset(le.getLocation(), _spawn) <= 5) + { + if (UtilPlayer.isSpectator(le)) + continue; + if (le instanceof Player) { - if (UtilPlayer.isSpectator(le)) - continue; - if (le instanceof Player) - { - _host.storeGear((Player)le); - } - le.damage(6); + _host.storeGear((Player)le); } + le.damage(6); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java index e9b9ec482..8fa1b12ba 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java @@ -6,7 +6,10 @@ import java.util.LinkedList; import java.util.List; import java.util.concurrent.ConcurrentHashMap; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.minecraftleague.DataLoc; @@ -26,7 +29,7 @@ public class TowerManager implements Listener private ConcurrentHashMap _vulnerableTower = new ConcurrentHashMap(); private ConcurrentHashMap _def = new ConcurrentHashMap(); //private ConcurrentHashMap _mapZone = new ConcurrentHashMap(); - //private ConcurrentHashMap _beacons = new ConcurrentHashMap(); + private ConcurrentHashMap _beacons = new ConcurrentHashMap(); private OreGenerator _ore; public boolean Attack = false; @@ -44,14 +47,14 @@ public class TowerManager implements Listener _vulnerableTower.put(base.getTeam(), 3); base.Vulnerable = true; - //_beacons.get(base.getTeam()).setBlock(getVulnerable(base.getTeam()).getBeacon().getBlock()); + _beacons.get(base.getTeam()).setBlock(base.getBeacon().getBlock()); } public void ironOreGen(GameTeam team, boolean start) { int amount = 20; if (start) - amount = 80; + amount = 50; for (Location loc : Host.WorldData.GetCustomLocs(DataLoc.DIAMOND_ORE.getKey())) { @@ -174,13 +177,14 @@ public class TowerManager implements Listener _mapZone.put(tower, zone);*/ } + TeamBeacon redb = new TeamBeacon(red, getTeamTowers(red).getFirst().getBeacon().getBlock()); + _beacons.put(red, redb); + Host.Beacons.put(red, redb); + TeamBeacon blueb = new TeamBeacon(blue, getTeamTowers(blue).getFirst().getBeacon().getBlock()); + _beacons.put(blue, blueb); + Host.Beacons.put(blue, blueb); makeVulnerable(getTeamTowers(red).getFirst()); makeVulnerable(getTeamTowers(blue).getFirst()); - for (TeamTowerBase tb : _towers.keySet()) - { - TeamBeacon b = new TeamBeacon(tb.getTeam(), tb.getBeacon().getBlock()); - Host.Beacons.put(b.getBlock(), b); - } ironOreGen(red, true); ironOreGen(blue, true); } @@ -249,6 +253,41 @@ public class TowerManager implements Listener return; } + for (Player player : towerBase.getTeam().GetPlayers(true)) + { + if (!UtilPlayer.isSpectator(player)) + { + boolean replaced = false; + if (UtilItem.isLeatherProduct(player.getInventory().getHelmet())) + { + if (replaced) + continue; + replaced = true; + player.getInventory().setHelmet(new ItemBuilder(Material.GOLD_HELMET).setUnbreakable(true).build()); + } + if (UtilItem.isLeatherProduct(player.getInventory().getBoots())) + { + if (replaced) + continue; + replaced = true; + player.getInventory().setLeggings(new ItemBuilder(Material.GOLD_LEGGINGS).setUnbreakable(true).build()); + } + if (UtilItem.isLeatherProduct(player.getInventory().getBoots())) + { + if (replaced) + continue; + replaced = true; + player.getInventory().setChestplate(new ItemBuilder(Material.GOLD_CHESTPLATE).setUnbreakable(true).build()); + } + if (UtilItem.isLeatherProduct(player.getInventory().getBoots())) + { + if (replaced) + continue; + replaced = true; + player.getInventory().setBoots(new ItemBuilder(Material.GOLD_BOOTS).setUnbreakable(true).build()); + } + } + } makeVulnerable(getTeamTowers(towerBase.getTeam()).get(_vulnerableTower.get(towerBase.getTeam()))); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java index 48005333e..1d75257d0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java @@ -172,11 +172,12 @@ public class WitherVariation extends GameVariation if (_pathfinder != null) if (_pathfinder.update()) { + GameTeam team = _pathfinder.getTeam(); _pathfinder = null; WitherSpawned = false; _wowner = null; _skellyMan.onWitherDeath(); - UtilTextMiddle.display("", C.cWhite + "The Mighty Wither has fallen!"); + UtilTextMiddle.display("", team.GetColor() + team.getDisplayName() + "'s Wither has been Destroyed!"); //Host.Objective.resetTeamToMainObjective(Host.GetTeam(ChatColor.RED)); //Host.Objective.resetTeamToMainObjective(Host.GetTeam(ChatColor.AQUA)); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java index 4902e575b..b87113f2e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java @@ -1,11 +1,11 @@ package nautilus.game.arcade.game.games.minecraftleague.variation.wither.data; -import java.util.ArrayList; import java.util.List; import java.util.Random; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilInv; @@ -37,7 +37,6 @@ import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftSkeleton; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; import org.bukkit.entity.Skeleton.SkeletonType; @@ -339,7 +338,12 @@ public class WitherMinionManager implements Listener _cb = null; _changed = Material.AIR; - _host.Host.getTowerManager().ironOreGen(null, false); + Bukkit.getScheduler().runTaskLater(_host.Manager.getPlugin(), new Runnable() { + public void run() + { + _host.Host.getTowerManager().ironOreGen(null, false); + } + }, 20 * 10); //_host.Host.Objective.setMainObjective(new GearObjective()); } @@ -476,13 +480,6 @@ public class WitherMinionManager implements Listener if (event.getEntity().getEntityId() != _entity.getEntityId()) return; - event.setCancelled(true); - LivingEntity e = (LivingEntity)event.getEntity(); - double newHealth = Math.max(0, e.getHealth() - event.getDamage()); - newHealth = Math.min(e.getMaxHealth(), newHealth); - - if (newHealth == 0) - Bukkit.getPluginManager().callEvent(new EntityDeathEvent(e, new ArrayList(), 0)); - e.setHealth(newHealth); + UtilAction.zeroVelocity(event.getEntity()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java index b380b9ba1..4686eb6e8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java @@ -143,6 +143,11 @@ public class WitherPathfinder return null; } + public GameTeam getTeam() + { + return _team; + } + /** * Returns true if the entity is dead or invalid */ From 34399db6e84ee14ef133da94c9fe18667cde9b4c Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 18 Apr 2016 18:42:56 -0400 Subject: [PATCH 38/47] - Fixed missing GameType --- .../Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index 0dfa12f28..dc5a082b5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -121,6 +121,7 @@ public enum GameType Pair.create(MinecraftVersion.Version1_9, "http://chivebox.com/mineplex/ResMinestrike19.zip") }, true), MineWare(MineWare.class, GameDisplay.MineWare), + MinecraftLeague(MinecraftLeague.class, GameDisplay.Minecraft_League), OldMineWare(OldMineWare.class, GameDisplay.OldMineWare), Paintball(Paintball.class, GameDisplay.Paintball), Quiver(Quiver.class, GameDisplay.Quiver), From 10aba533f3a6324edc88d1f4b8ae2aece92188ec Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 18 Apr 2016 19:59:55 -0400 Subject: [PATCH 39/47] - Remove all dependence on UtilShapes --- .../minecraftleague/MinecraftLeague.java | 2 ++ .../variation/wither/data/TeamAltar.java | 13 +++++---- .../wither/data/WitherMinionManager.java | 27 ++++++++++--------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index 6a281294b..b27fe7206 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -659,6 +659,7 @@ public class MinecraftLeague extends TeamGame _lastIncrease = System.currentTimeMillis(); _lastOreReset = System.currentTimeMillis(); _lastGrindReset = System.currentTimeMillis() - UtilTime.convert(30, TimeUnit.SECONDS, TimeUnit.MILLISECONDS); + Manager.GetExplosion().setEnabled(false); Manager.GetExplosion().SetTemporaryDebris(false); Manager.GetExplosion().SetDebris(true); Manager.GetDamage().SetEnabled(false); @@ -672,6 +673,7 @@ public class MinecraftLeague extends TeamGame if (event.GetState() == GameState.End) { + Manager.GetExplosion().setEnabled(true); Manager.GetExplosion().SetDebris(false); Manager.GetExplosion().SetTemporaryDebris(true); Manager.GetDamage().SetEnabled(true); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java index b3e284132..da234474b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java @@ -1,11 +1,9 @@ package nautilus.game.arcade.game.games.minecraftleague.variation.wither.data; -import java.util.List; - import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilShapes; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.hologram.Hologram; import nautilus.game.arcade.game.GameTeam; @@ -28,7 +26,7 @@ public class TeamAltar private GameTeam _team; private Location _center; - private List _protected; + //private List _protected; private Location[] _skullSpots; @@ -41,8 +39,8 @@ public class TeamAltar _center = center; spawnSoulsand(); - - _protected = UtilShapes.getSphereBlocks(center, 7, 7, false); + + //_protected = UtilShapes.getSphereBlocks(center, 7, 7, false); Location labelLoc = center.clone().add(0/*.5*/, 5, 0.5); String labelStr = team.GetColor() + team.getDisplayName() + "'s Altar"; @@ -52,7 +50,8 @@ public class TeamAltar public boolean isInsideAltar(Location location) { - return _protected.contains(location); + return UtilMath.offset(_center, location) <= 7; + //return _protected.contains(location); } public void spawnSoulsand() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java index b87113f2e..a42b8523d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java @@ -10,11 +10,11 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilItem; +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 mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilShapes; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; @@ -68,7 +68,7 @@ public class WitherMinionManager implements Listener private ItemStack _witherItem; private WitherSkeletonTimer _sbTimer; - private MapZone _skellyZone; + //private MapZone _skellyZone; private Block _cb; private Material _changed = Material.AIR; @@ -86,9 +86,9 @@ public class WitherMinionManager implements Listener _witherItem = new ItemBuilder(Material.SKULL_ITEM).setTitle(C.cDRedB + "Wither Skeleton Head").setData((short) 1).setLore(C.cGray + "Bring this back", C.cGray + "to your team's Altar", C.cGray + "To summon a Wither!").build(); _sbTimer = new WitherSkeletonTimer(host.Host.GetScoreboard()); host.Host.ExtraSb.put(_sbTimer, host); - _skellyZone = new MapZone(spawns.get(0), new int[] {0, 0, 0}); - _skellyZone.setValid(false); - host.Host.MapZones.add(_skellyZone); + //_skellyZone = new MapZone(spawns.get(0), new int[] {0, 0, 0}); + //_skellyZone.setValid(false); + //host.Host.MapZones.add(_skellyZone); Bukkit.getPluginManager().registerEvents(this, host.Manager.getPlugin()); } @@ -136,8 +136,8 @@ public class WitherMinionManager implements Listener if (!respawn) { UtilTextMiddle.display("", C.cGray + "A Wither Skeleton has spawned!"); - _skellyZone.setCenter(chosen); - _skellyZone.setValid(true); + //_skellyZone.setCenter(chosen); + //_skellyZone.setValid(true); //_host.Host.Objective.setMainObjective(new GrabSkullObjective()); } _selected = -1; @@ -161,7 +161,7 @@ public class WitherMinionManager implements Listener _spawned = false; _entity.remove(); _lastDied = System.currentTimeMillis(); - _skellyZone.setValid(false); + //_skellyZone.setValid(false); _entity = null; } if (_cb != null) @@ -332,7 +332,7 @@ public class WitherMinionManager implements Listener event.getDrops().clear(); event.getDrops().add(_witherItem.clone()); event.setDroppedExp(10); - _skellyZone.setValid(false); + //_skellyZone.setValid(false); _cb.setType(_changed); _cb = null; @@ -424,7 +424,8 @@ public class WitherMinionManager implements Listener for (Location loc : _spawns) { - if (UtilShapes.getSphereBlocks(loc, 6, 6, false).contains(event.getBlock().getLocation())) + //if (UtilShapes.getSphereBlocks(loc, 6, 6, false).contains(event.getBlock().getLocation())) + if (UtilMath.offset(loc, event.getBlock().getLocation()) <= 6) event.setCancelled(true); } } @@ -437,7 +438,8 @@ public class WitherMinionManager implements Listener for (Location loc : _spawns) { - if (UtilShapes.getSphereBlocks(loc, 6, 6, false).contains(event.getBlock().getLocation())) + //if (UtilShapes.getSphereBlocks(loc, 6, 6, false).contains(event.getBlock().getLocation())) + if (UtilMath.offset(loc, event.getBlock().getLocation()) <= 6) event.setCancelled(true); } } @@ -464,7 +466,8 @@ public class WitherMinionManager implements Listener for (Location loc : _spawns) { - if (UtilShapes.getSphereBlocks(loc, 5, 5, false).contains(event.getBlock().getLocation())) + //if (UtilShapes.getSphereBlocks(loc, 5, 5, false).contains(event.getBlock().getLocation())) + if (UtilMath.offset(loc, event.getBlock().getLocation()) <= 6) event.setCancelled(true); } } From 17ac3cb597bcfc6dc5e56f556bc084cbafab73d9 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 18 Apr 2016 20:29:53 -0400 Subject: [PATCH 40/47] - Fix armor checking - Edit wither death message --- .../arcade/game/games/minecraftleague/data/TowerManager.java | 4 ++-- .../minecraftleague/variation/wither/WitherVariation.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java index 8fa1b12ba..4ab0a41fa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java @@ -265,14 +265,14 @@ public class TowerManager implements Listener replaced = true; player.getInventory().setHelmet(new ItemBuilder(Material.GOLD_HELMET).setUnbreakable(true).build()); } - if (UtilItem.isLeatherProduct(player.getInventory().getBoots())) + if (UtilItem.isLeatherProduct(player.getInventory().getLeggings())) { if (replaced) continue; replaced = true; player.getInventory().setLeggings(new ItemBuilder(Material.GOLD_LEGGINGS).setUnbreakable(true).build()); } - if (UtilItem.isLeatherProduct(player.getInventory().getBoots())) + if (UtilItem.isLeatherProduct(player.getInventory().getChestplate())) { if (replaced) continue; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java index 1d75257d0..99baa7f4d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java @@ -177,7 +177,7 @@ public class WitherVariation extends GameVariation WitherSpawned = false; _wowner = null; _skellyMan.onWitherDeath(); - UtilTextMiddle.display("", team.GetColor() + team.getDisplayName() + "'s Wither has been Destroyed!"); + UtilTextMiddle.display("", team.GetColor() + team.getDisplayName() + "'s Wither has been Defeated!"); //Host.Objective.resetTeamToMainObjective(Host.GetTeam(ChatColor.RED)); //Host.Objective.resetTeamToMainObjective(Host.GetTeam(ChatColor.AQUA)); } From 6c20427395659b0f024b566e560f719831cb3208 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 18 Apr 2016 22:32:15 -0400 Subject: [PATCH 41/47] - Fixed some bugs and added final achievements --- .../core/achievement/Achievement.java | 12 +++ .../minecraftleague/MinecraftLeague.java | 18 ++-- .../tracker/TowerDefenderTracker.java | 85 +++++++++++++++++++ 3 files changed, 107 insertions(+), 8 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/TowerDefenderTracker.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index f9eea818b..7acc3e00b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -183,6 +183,18 @@ public enum Achievement new int[] {50}, AchievementCategory.MC_LEAGUE), + MC_LEAGUE_WINS("Mineplex Champion", 900, + new String[] {"MC League.Wins"}, + new String[] {"Win 25 Games"}, + new int[] {25}, + AchievementCategory.MC_LEAGUE), + + MC_LEAGUE_TOWER("Tower Defender", 800, + new String[] {"MC League.TowerDefender"}, + new String[] {"Get a double kill", "inside your Active Tower"}, + new int[] {1}, + AchievementCategory.MC_LEAGUE), + //UHC WIZARDS_WINS("Supreme Wizard", 600, new String[]{"Wizards.Wins"}, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index b27fe7206..0c6774ebc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -45,6 +45,7 @@ import nautilus.game.arcade.game.games.minecraftleague.kit.KitPlayer; import nautilus.game.arcade.game.games.minecraftleague.tracker.AltarBuilderTracker; import nautilus.game.arcade.game.games.minecraftleague.tracker.FirstStrikeTracker; import nautilus.game.arcade.game.games.minecraftleague.tracker.HeadHunterTracker; +import nautilus.game.arcade.game.games.minecraftleague.tracker.TowerDefenderTracker; import nautilus.game.arcade.game.games.minecraftleague.variation.ExtraScoreboardData; import nautilus.game.arcade.game.games.minecraftleague.variation.GameVariation; import nautilus.game.arcade.game.games.minecraftleague.variation.VariationManager; @@ -151,10 +152,10 @@ public class MinecraftLeague extends TeamGame new String[] { C.cWhite + "Gather resources for battle.", - C.cWhite + "Destroy the enemy's Crystal to", - C.cWhite + "Prevent them from respawning", + C.cWhite + "Destroy all of the enemy's Towers to", + C.cWhite + "Defeat them and win the game!", " ", - C.cWhite + "Last team standing wins", + C.cWhite + "Last team with Towers alive wins", }); this.DeathOut = true; @@ -189,8 +190,8 @@ public class MinecraftLeague extends TeamGame _help = new String[] { - "Respawn Crystals have 150 health per person in-game!", - "The better the sword you have, the more damage you deal to Respawn Crystals!", + "Towers have 150 health per person in-game!", + "The better the sword you have, the more damage you deal to Towers!", //"Right-click a bed in order to change your personal spawn location!", "Your map will display the locations of your enemies in OverTime!" }; @@ -199,7 +200,8 @@ public class MinecraftLeague extends TeamGame registerStatTrackers( new AltarBuilderTracker(this), new FirstStrikeTracker(this), - new HeadHunterTracker(this) + new HeadHunterTracker(this), + new TowerDefenderTracker(this, 2, 5000, "TowerDefender") ); _vman = new VariationManager(this); @@ -475,7 +477,7 @@ public class MinecraftLeague extends TeamGame { Scoreboard.Reset(); Scoreboard.WriteBlank(); - Scoreboard.Write(C.cDRedB + "Minecraft League"); + Scoreboard.Write(C.cDRedB + GetName()); Scoreboard.WriteBlank(); Scoreboard.Write(C.cGoldB + "Winner:"); Scoreboard.Write(winner); @@ -494,7 +496,7 @@ public class MinecraftLeague extends TeamGame return; Scoreboard.Reset(); Scoreboard.WriteBlank(); - Scoreboard.Write(C.cDRedB + "Minecraft League"); + Scoreboard.Write(C.cDRedB + GetName()); Scoreboard.WriteBlank(); if (_yellow) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/TowerDefenderTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/TowerDefenderTracker.java new file mode 100644 index 000000000..6b6c29c88 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/TowerDefenderTracker.java @@ -0,0 +1,85 @@ +package nautilus.game.arcade.game.games.minecraftleague.tracker; + +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +public class TowerDefenderTracker extends StatTracker +{ + private final int _killCount; + private final String _stat; + private final int _timeLimit; + + private final ConcurrentHashMap _kills = new ConcurrentHashMap(); + private final ConcurrentHashMap _lastKill = new ConcurrentHashMap(); + + public TowerDefenderTracker(MinecraftLeague game, int killCount, int timeLimit, String stat) + { + super(game); + + _killCount = killCount; + _stat = stat; + _timeLimit = timeLimit * 1000; + } + + public int getKillCount() + { + return _killCount; + } + + public int getTimeLimit() + { + return _timeLimit; + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + public void onCombatDeath(CombatDeathEvent event) + { + if (getGame().GetState() != Game.GameState.Live) + return; + + if (event.GetLog().GetKiller() == null) + return; + + if (!event.GetLog().GetKiller().IsPlayer()) + return; + + Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); + if (player == null) + return; + + Integer killCount = _kills.get(player.getUniqueId()); + Long lastKill = _lastKill.get(player.getUniqueId()); + + killCount = (killCount == null ? 0 : killCount) + 1; + lastKill = (lastKill == null ? System.currentTimeMillis() : lastKill); + + _kills.put(player.getUniqueId(), killCount); + _lastKill.put(player.getUniqueId(), System.currentTimeMillis()); + + if (killCount == getKillCount() && System.currentTimeMillis() - lastKill < getTimeLimit()) + { + if (UtilMath.offset(player.getLocation(), getGame().getActiveTower(getGame().GetTeam(player)).getLocation()) <= 5) + { + addStat(player, getStat(), 1, true, false); + _lastKill.remove(player.getUniqueId()); + _kills.remove(player.getUniqueId()); + } + } + } + + public String getStat() + { + return _stat; + } +} \ No newline at end of file From e08965aa25f4b5eeb90ab5f2b34285968b395866 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 18 Apr 2016 22:58:55 -0400 Subject: [PATCH 42/47] - Fixed TowerDefender being too difficult to obtain - Fixed wither attacking own towers by accident --- .../game/games/minecraftleague/MinecraftLeague.java | 2 +- .../minecraftleague/tracker/TowerDefenderTracker.java | 2 +- .../variation/wither/WitherVariation.java | 3 +++ .../variation/wither/data/WitherPathfinder.java | 9 +++++---- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index 0c6774ebc..c066c89da 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -201,7 +201,7 @@ public class MinecraftLeague extends TeamGame new AltarBuilderTracker(this), new FirstStrikeTracker(this), new HeadHunterTracker(this), - new TowerDefenderTracker(this, 2, 5000, "TowerDefender") + new TowerDefenderTracker(this, 2, 8000, "TowerDefender") ); _vman = new VariationManager(this); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/TowerDefenderTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/TowerDefenderTracker.java index 6b6c29c88..a9fa6936f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/TowerDefenderTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/TowerDefenderTracker.java @@ -69,7 +69,7 @@ public class TowerDefenderTracker extends StatTracker if (killCount == getKillCount() && System.currentTimeMillis() - lastKill < getTimeLimit()) { - if (UtilMath.offset(player.getLocation(), getGame().getActiveTower(getGame().GetTeam(player)).getLocation()) <= 5) + if (UtilMath.offset2d(player.getLocation(), getGame().getActiveTower(getGame().GetTeam(player)).getLocation()) <= 7) { addStat(player, getStat(), 1, true, false); _lastKill.remove(player.getUniqueId()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java index 99baa7f4d..b9643c6af 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java @@ -284,6 +284,9 @@ public class WitherVariation extends GameVariation { event.setCancelled(true); + if (!((WitherSkull)event.getEntity()).isCharged()) + return; + LinkedList red = Host.getTowerManager().getTeamTowers(Host.GetTeam(ChatColor.RED)); LinkedList blue = Host.getTowerManager().getTeamTowers(Host.GetTeam(ChatColor.AQUA)); HashMap inside = UtilBlock.getInRadius(event.getLocation().getBlock(), 4, false); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java index 4686eb6e8..57f98615e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java @@ -114,12 +114,12 @@ public class WitherPathfinder if (UtilTime.elapsed(_lastAttack, UtilTime.convert(2, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) { _lastAttack = System.currentTimeMillis(); - shootAt(target.getLocation()); + shootAt(target.getLocation(), false); } } } - private void shootAt(Location loc) + private void shootAt(Location loc, boolean charged) { Location old = _ent.getLocation(); Location temp = _ent.getLocation(); @@ -127,7 +127,8 @@ public class WitherPathfinder temp.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(_ent.getEyeLocation(), loc))); _ent.teleport(temp); _ent.setMetadata("Shooting", new FixedMetadataValue(_host.Manager.getPlugin(), "1")); - _ent.launchProjectile(WitherSkull.class); + WitherSkull skull = _ent.launchProjectile(WitherSkull.class); + skull.setCharged(charged); _ent.removeMetadata("Shooting", _host.Manager.getPlugin()); _ent.teleport(old); //skull.setDirection(UtilAlg.getTrajectory(_ent.getLocation(), loc).normalize()); @@ -212,7 +213,7 @@ public class WitherPathfinder if (UtilTime.elapsed(_lastTowerAttack, UtilTime.convert(5, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) { _lastTowerAttack = System.currentTimeMillis(); - shootAt(eTower.getLocation()); + shootAt(eTower.getLocation(), true); } return false; } From 588e6f08c2475a4a6668ff7610152677989987d4 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 19 Apr 2016 18:07:20 -0400 Subject: [PATCH 43/47] - Removed TypeWars achievements to make room --- .../src/mineplex/core/achievement/Achievement.java | 4 ++-- .../src/mineplex/core/achievement/AchievementCategory.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index 7acc3e00b..f67d53ad6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -865,7 +865,7 @@ public enum Achievement new int[]{15}, AchievementCategory.GLADIATORS), - TYPE_WARS_SPEED_DEMON("Speed Demon", 1000, + /*TYPE_WARS_SPEED_DEMON("Speed Demon", 1000, new String[]{"Type Wars.Demon"}, new String[]{"Kill 5 Mobs in 8 seconds", "by typing"}, new int[]{1}, @@ -899,7 +899,7 @@ public enum Achievement new String[]{"Type Wars.Wins"}, new String[]{"Win 30 Games"}, new int[]{30}, - AchievementCategory.TYPE_WARS), + AchievementCategory.TYPE_WARS),*/ SPEED_BUILDERS_SPEED_MASTER("Speed Master", 800, new String[]{"Speed Builders.Wins"}, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index 2cea19ee0..e6f445aa4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -160,9 +160,9 @@ public enum AchievementCategory new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, Material.IRON_SWORD, 0, GameCategory.ARCADE, null), - TYPE_WARS("Type Wars", null, + /*TYPE_WARS("Type Wars", null, new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, new StatDisplay("Minions killed", "MinionKills"), new StatDisplay("Words Per Minute", false, true, "MinionKills", "TimeInGame"), StatDisplay.GEMS_EARNED}, - Material.NAME_TAG, 0, GameCategory.CLASSICS, null), + Material.NAME_TAG, 0, GameCategory.CLASSICS, null),*/ SPEED_BUILDERS("Speed Builders", null, new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED, null, new StatDisplay("Perfect Builds", "PerfectBuild")}, From d57cc48f0fb81507ddf804fe7960e05bf57b25e2 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Wed, 20 Apr 2016 22:31:54 -0400 Subject: [PATCH 44/47] - Added new features! --- .../core/achievement/Achievement.java | 6 +++ .../src/nautilus/game/arcade/GameType.java | 1 + .../minecraftleague/MinecraftLeague.java | 45 ++++++++++++++++++- .../tracker/SavingUpTracker.java | 25 +++++++++++ 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/SavingUpTracker.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index f67d53ad6..a0fedc46e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -195,6 +195,12 @@ public enum Achievement new int[] {1}, AchievementCategory.MC_LEAGUE), + MC_LEAGUE_SAVING("Saving Up", 900, + new String[] {"MC League.SavingUp"}, + new String[] {"Craft a Diamond Chestplate"}, + new int[] {1}, + AchievementCategory.MC_LEAGUE), + //UHC WIZARDS_WINS("Supreme Wizard", 600, new String[]{"Wizards.Wins"}, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index dc5a082b5..1b70d41d0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -205,6 +205,7 @@ public enum GameType GameType(Class gameClass, GameDisplay display, Pair[] resourcePackUrls, boolean enforceResourcePack, GameType[] mapSource, boolean ownMaps) { _display = display; + _gameId = display.getGameId(); _gameClass = gameClass; _resourcePacks = resourcePackUrls; _enforceResourcePack = enforceResourcePack; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index c066c89da..fd8a3ebd4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -45,6 +45,7 @@ import nautilus.game.arcade.game.games.minecraftleague.kit.KitPlayer; import nautilus.game.arcade.game.games.minecraftleague.tracker.AltarBuilderTracker; import nautilus.game.arcade.game.games.minecraftleague.tracker.FirstStrikeTracker; import nautilus.game.arcade.game.games.minecraftleague.tracker.HeadHunterTracker; +import nautilus.game.arcade.game.games.minecraftleague.tracker.SavingUpTracker; import nautilus.game.arcade.game.games.minecraftleague.tracker.TowerDefenderTracker; import nautilus.game.arcade.game.games.minecraftleague.variation.ExtraScoreboardData; import nautilus.game.arcade.game.games.minecraftleague.variation.GameVariation; @@ -59,6 +60,7 @@ import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.Furnace; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Arrow; import org.bukkit.entity.Enderman; @@ -83,6 +85,8 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.inventory.FurnaceBurnEvent; +import org.bukkit.event.inventory.FurnaceSmeltEvent; import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryType; @@ -201,7 +205,8 @@ public class MinecraftLeague extends TeamGame new AltarBuilderTracker(this), new FirstStrikeTracker(this), new HeadHunterTracker(this), - new TowerDefenderTracker(this, 2, 8000, "TowerDefender") + new TowerDefenderTracker(this, 2, 8000, "TowerDefender"), + new SavingUpTracker(this) ); _vman = new VariationManager(this); @@ -1937,4 +1942,42 @@ public class MinecraftLeague extends TeamGame p.sendMessage(F.main("Game", "Too many players are in this server. You are now spectating, sorry.")); } } + + @EventHandler + public void furnaceBurn(FurnaceBurnEvent event) + { + if (!IsLive()) + return; + + Furnace furnace = (Furnace) event.getBlock().getState(); + furnace.setCookTime((short)100); + } + + @EventHandler + public void furnaceSmeltEvent(FurnaceSmeltEvent event) + { + if (!IsLive()) + return; + + Furnace furnace = (Furnace) event.getBlock().getState(); + furnace.setCookTime((short)100); + } + + @EventHandler + public void onInventoryClick(InventoryClickEvent event) + { + if (!IsLive()) + return; + + Block blocktype = UtilPlayer.getTargetLocation((Player) event.getWhoClicked(), 10D).getBlock(); + + if (blocktype.getType() == Material.FURNACE || blocktype.getType() == Material.BURNING_FURNACE) + { + if ((event.getSlot() == 0 || event.getSlot() == 1) && event.getCursor().getType() != Material.AIR) + { + Furnace furnace = (Furnace) blocktype.getState(); + furnace.setCookTime((short)100); + } + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/SavingUpTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/SavingUpTracker.java new file mode 100644 index 000000000..9ab8f4756 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/tracker/SavingUpTracker.java @@ -0,0 +1,25 @@ +package nautilus.game.arcade.game.games.minecraftleague.tracker; + +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.inventory.CraftItemEvent; + +public class SavingUpTracker extends StatTracker +{ + public SavingUpTracker(MinecraftLeague game) + { + super(game); + } + + @EventHandler + public void build(CraftItemEvent e) + { + if (e.getRecipe().getResult().getType() == Material.DIAMOND_CHESTPLATE) + addStat((Player)e.getWhoClicked(), "SavingUp", 1, false, false); + } + +} \ No newline at end of file From df55d48ab899da36e2296d4e578ae6f3a6523f8b Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 21 Apr 2016 01:03:14 -0400 Subject: [PATCH 45/47] - Looks better --- .../games/minecraftleague/data/map/ItemMapManager.java | 6 ++---- .../nautilus/game/arcade/managers/GameFlagManager.java | 8 +++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/map/ItemMapManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/map/ItemMapManager.java index 531083ae2..0a077c627 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/map/ItemMapManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/map/ItemMapManager.java @@ -9,12 +9,10 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map.Entry; -import mineplex.core.common.util.C; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.portal.ServerTransferEvent; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; @@ -447,7 +445,7 @@ public class ItemMapManager /*extends MiniPlugin*/ implements Listener return _halfMapSize; } - @EventHandler + /*@EventHandler public void onServerTransfer(ServerTransferEvent event) { Player p = event.getPlayer(); @@ -455,7 +453,7 @@ public class ItemMapManager /*extends MiniPlugin*/ implements Listener p.sendMessage(C.cDRed + C.Bold + "WARNING!"); p.sendMessage(C.cYellow + "There's a bug where switching servers may freeze the Team Map!"); p.sendMessage(C.cYellow + "If you want to play Minecraft League again and this error occurs, rejoin the Mineplex server!"); - } + }*/ private void rebuildScan() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index 2c3bc1c3d..f312b5ab3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -36,6 +36,7 @@ import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.kit.perks.event.PerkDestructorBlockEvent; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.Sound; @@ -1293,7 +1294,12 @@ public class GameFlagManager implements Listener continue; } long sec = UtilTime.convert(_respawnTimers.get(player) - System.currentTimeMillis(), TimeUnit.MILLISECONDS, TimeUnit.SECONDS); - UtilTextBottom.display("Respawning In: " + sec + " Seconds", player); + ChatColor color = ChatColor.RED; + if (sec < 8) + color = ChatColor.YELLOW; + if (sec < 4) + color = ChatColor.GREEN; + UtilTextBottom.display(color + "Respawning In: " + sec + " Seconds", player); } } } From e55bec505bcea537359af8aa85152bc36291d7cd Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 21 Apr 2016 20:13:39 -0400 Subject: [PATCH 46/47] - Fix players ending up teleported back to arena due to broken respawn engine --- .../game/arcade/managers/GameFlagManager.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index f312b5ab3..4300dfd09 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -81,6 +81,7 @@ public class GameFlagManager implements Listener ArcadeManager Manager; SecondaryDamageManager Secondary; private ConcurrentHashMap _respawnTimers = new ConcurrentHashMap(); + private ConcurrentHashMap _respawnRunnables = new ConcurrentHashMap(); public GameFlagManager(ArcadeManager manager) { @@ -807,7 +808,7 @@ public class GameFlagManager implements Listener _respawnTimers.put(player, System.currentTimeMillis() + UtilTime.convert(t, TimeUnit.SECONDS, TimeUnit.MILLISECONDS)); } }, 6); - Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() + int run = Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() { public void run() { @@ -823,8 +824,11 @@ public class GameFlagManager implements Listener player.setFireTicks(0); UtilAction.zeroVelocity(player); + + _respawnRunnables.remove(player); } }, (int)(time * 20d)); + _respawnRunnables.put(player, run); } } @@ -1274,11 +1278,21 @@ public class GameFlagManager implements Listener if (Manager.GetGame() == null) { _respawnTimers.clear(); + for (Integer r : _respawnRunnables.values()) + { + Bukkit.getScheduler().cancelTask(r); + } + _respawnRunnables.clear(); return; } if (!Manager.GetGame().IsLive()) { _respawnTimers.clear(); + for (Integer r : _respawnRunnables.values()) + { + Bukkit.getScheduler().cancelTask(r); + } + _respawnRunnables.clear(); return; } for (Player player : _respawnTimers.keySet()) From 2a4c3209b4cbff13fde34b7320b2cd41f2db59c6 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 22 Apr 2016 05:44:56 -0400 Subject: [PATCH 47/47] - Enable ELO --- .../arcade/game/games/minecraftleague/MinecraftLeague.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index fd8a3ebd4..9c2f29fd0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -161,7 +161,8 @@ public class MinecraftLeague extends TeamGame " ", C.cWhite + "Last team with Towers alive wins", }); - + + this.EloRanking = true; this.DeathOut = true; this.DamageSelf = false; this.DeathSpectateSecs = 10;