diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/effects/LineParticle.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/effects/LineParticle.java new file mode 100644 index 000000000..a19623df1 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/effects/LineParticle.java @@ -0,0 +1,105 @@ +package mineplex.core.common.util.particles.effects; + +import java.util.Set; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; + +/** + * Creates a line of particles with customise able traits. + * + * Most noticeable with Blink skills. + */ +public class LineParticle +{ + + private Location _start; + private Vector _direction; + private Location _lastLocation; + + private double _curRange; + private double _incrementedRange; + private double _maxRange; + + private Set _ignoredTypes; + + private ParticleType _particleType; + private Player[] _toDisplay; + + public LineParticle(Location start, Vector direction, double incrementedRange, double maxRange, Set ignoredTypes, ParticleType particleType, Player... toDisplay) + { + this(start, null, direction, incrementedRange, maxRange, ignoredTypes, particleType, toDisplay); + } + + public LineParticle(Location start, Location end, Vector direction, double incrementedRange, double maxRange, Set ignoredTypes, ParticleType particleType, Player... toDisplay) + { + _start = start; + _direction = direction; + _lastLocation = start; + + _curRange = 0; + _incrementedRange = incrementedRange; + _maxRange = maxRange; + _ignoredTypes = ignoredTypes; + + _particleType = particleType; + _toDisplay = toDisplay; + + if (_direction == null) + { + direction = UtilAlg.getTrajectory(start, end).normalize(); + } + } + + /** + * Advances the line. + * + * @return true when the line has reached its target or has collided with a + * block with a type contained in _ignoredTypes. + */ + public boolean update() + { + boolean done = _curRange > _maxRange; + + Location newTarget = _start.clone().add(new Vector(0, 0.2, 0)).add(_direction.clone().multiply(_curRange)); + _lastLocation = newTarget; + + if (!(UtilBlock.airFoliage(newTarget.getBlock()) || UtilBlock.airFoliage(newTarget.getBlock().getRelative(BlockFace.UP)))) + { + if (_ignoredTypes == null) + { + done = true; + } + + if (!_ignoredTypes.contains(newTarget.getBlock().getType())) + { + done = true; + } + } + + _curRange += _incrementedRange; + + UtilParticle.PlayParticle(_particleType, newTarget, 0, 0, 0, 0.001F, 1, ViewDist.LONG, _toDisplay); + + return done; + } + + public Location getLastLocation() + { + return _lastLocation; + } + + public Location getDestination() + { + return _lastLocation.subtract(_direction); + } +} diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/effects/ObjectiveParticle.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/effects/ObjectiveParticle.java new file mode 100644 index 000000000..009c6b138 --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/particles/effects/ObjectiveParticle.java @@ -0,0 +1,94 @@ +package mineplex.core.common.util.particles.effects; + +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +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; + +/** + * Creates a particle curve that bends towards a location. + * + * Most noticeable in Gladiators and TOITQ. + */ +public class ObjectiveParticle +{ + + private Location _current; + private Location _target; + private Vector _direction; + + private float _turnMultipler; + private float _blocksToAdvance; + private float _particleOffset; + private int _particleCount; + private float _soundVolume; + private float _soundPitch; + private double _stopAtDistance; + + private Sound _sound; + private ParticleType _particleType; + private Player[] _toDisplay; + + public ObjectiveParticle(Location start, Vector startVector, Location target, Player... toDisplay) + { + this(start, startVector, target, 0.15F, 0.5F, 0.03F, 3, ParticleType.HAPPY_VILLAGER, 0.2F, 3F, null, 4, toDisplay); + } + + public ObjectiveParticle(Location start, Vector startVector, Location target, float turnMutlipler, float blocksToAdvance, float particleOffset, int particleCount, ParticleType particleType, + float soundVolume, float soundPitch, Sound sound, double stopAtDistance, Player... toDisplay) + { + _current = start; + _target = target; + _turnMultipler = turnMutlipler; + _blocksToAdvance = blocksToAdvance; + _particleOffset = particleOffset; + _particleCount = particleCount; + _particleType = particleType; + _soundVolume = soundVolume; + _soundPitch = soundPitch; + _sound = sound; + _stopAtDistance = stopAtDistance; + _toDisplay = toDisplay; + _direction = startVector; + + if (_direction.getY() < 0) + { + _direction.setY(0); + } + + _direction.normalize(); + } + + /** + * Advances the curve. + * + * @return true when the curve is within _stopAtDistance blocks of the + * target. + */ + public boolean update() + { + _direction.add(UtilAlg.getTrajectory(_current, _target).multiply(_turnMultipler)); + _direction.normalize(); + + _current.add(_direction.clone().multiply(_blocksToAdvance)); + + UtilParticle.PlayParticle(_particleType, _current, _particleOffset, _particleOffset, _particleOffset, 0, _particleCount, ViewDist.LONG, _toDisplay); + + if (_sound != null) + { + for (Player player : _toDisplay) + { + player.playSound(_current, _sound, _soundVolume, _soundPitch); + } + } + + return UtilMath.offset(_current, _target) < _stopAtDistance; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index 5c6ff235e..cdf29e95c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -83,6 +83,8 @@ public enum GameDisplay Valentines("Valentines Vendetta", Material.LEATHER, (byte)0, GameCategory.EXTRA, 61), Basketball("Hoops", Material.SLIME_BALL, (byte)0, GameCategory.EXTRA, 63), + + QuiverPayload("One in the Quiver Payload", Material.ARROW, (byte)0, GameCategory.ARCADE, 64), Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/KitProgressionManager.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/KitProgressionManager.java index 19b1dff5b..211837758 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/KitProgressionManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/KitProgressionManager.java @@ -2,6 +2,7 @@ package mineplex.core.progression; import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; +import mineplex.core.donation.DonationManager; import mineplex.core.progression.data.PlayerKit; import mineplex.core.progression.data.PlayerKitDataManager; import org.bukkit.plugin.java.JavaPlugin; @@ -16,16 +17,23 @@ public class KitProgressionManager extends MiniClientPlugin private PlayerKitDataManager _dataManager; private KitProgressionRepository _kitProgressionRepository; + private DonationManager _donationManager; private CoreClientManager _coreClientManager; - public KitProgressionManager(JavaPlugin plugin, CoreClientManager clientManager) + public KitProgressionManager(JavaPlugin plugin, DonationManager donationManager, CoreClientManager clientManager) { super("Kit Progression", plugin); _dataManager = new PlayerKitDataManager(); _kitProgressionRepository = new KitProgressionRepository(this); + _donationManager = donationManager; _coreClientManager = clientManager; } - + + public DonationManager getDonationManager() + { + return _donationManager; + } + public CoreClientManager getClientManager() { return _coreClientManager; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/ProgressiveKit.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/ProgressiveKit.java index ec55bfb35..395bd428d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/ProgressiveKit.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/ProgressiveKit.java @@ -285,4 +285,4 @@ public interface ProgressiveKit ViewDist.NORMAL, displayTo); } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/data/KitUpgradeProcessor.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/data/KitUpgradeProcessor.java new file mode 100644 index 000000000..4bb9d3f34 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/data/KitUpgradeProcessor.java @@ -0,0 +1,56 @@ +package mineplex.core.progression.data; + +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; + +import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.common.util.F; +import mineplex.core.progression.KitProgressionManager; +import mineplex.core.progression.ProgressiveKit; +import mineplex.core.progression.math.Calculations; +import mineplex.core.shop.confirmation.ConfirmationCallback; +import mineplex.core.shop.confirmation.ConfirmationProcessor; + +public class KitUpgradeProcessor implements ConfirmationProcessor +{ + private KitProgressionManager _manager; + private Player _player; + private ProgressiveKit _kit; + private int _upgradeLevel; + + public KitUpgradeProcessor(KitProgressionManager manager, Player player, ProgressiveKit kit, int upgradeLevel) + { + _manager = manager; + _player = player; + _kit = kit; + _upgradeLevel = upgradeLevel; + } + + @Override + public void init(Inventory inventory) + { + } + + @Override + public void process(ConfirmationCallback callback) + { + int gems = _manager.getDonationManager().Get(_player).getBalance(GlobalCurrency.GEM); + int cost = Calculations.getGemsCost(_upgradeLevel); + + if (gems >= cost) + { + _kit.upgrade(_upgradeLevel, _player.getUniqueId()); + + _player.playSound(_player.getLocation(), Sound.CAT_MEOW, 5.0f, 1.0f); + _player.sendMessage(F.main("Kit Progression", "Purchased upgrades for " + _kit.getDisplayName() + " level " + _upgradeLevel)); + + _manager.getDonationManager().Get(_player).DeductCost(cost, GlobalCurrency.GEM); + callback.resolve("Success! You now own this upgrade!"); + return; + } + + callback.reject("Insufficient funds!"); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/data/KitUpgradeShop.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/data/KitUpgradeShop.java new file mode 100644 index 000000000..f62bc4d48 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/data/KitUpgradeShop.java @@ -0,0 +1,28 @@ +package mineplex.core.progression.data; + +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.donation.DonationManager; +import mineplex.core.progression.KitProgressionManager; +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.page.ShopPageBase; + +/* + * This is currently just used to open a confirmation menu and no other references should be made to this. + */ +public class KitUpgradeShop extends ShopBase +{ + + public KitUpgradeShop(KitProgressionManager plugin, CoreClientManager clientManager, DonationManager donationManager) + { + super(plugin, clientManager, donationManager, "Kit Upgrade"); + } + + @Override + protected ShopPageBase> buildPagesFor(Player player) + { + return null; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeButton.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeButton.java index e2922a50d..58f73f6a6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeButton.java @@ -1,14 +1,19 @@ package mineplex.core.progression.gui.buttons; -import mineplex.core.common.util.F; -import mineplex.core.menu.Menu; -import mineplex.core.progression.ProgressiveKit; +import java.util.UUID; + import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -import java.util.UUID; +import mineplex.core.common.util.F; +import mineplex.core.menu.Menu; +import mineplex.core.progression.KitProgressionManager; +import mineplex.core.progression.ProgressiveKit; +import mineplex.core.progression.data.KitUpgradeProcessor; +import mineplex.core.progression.data.KitUpgradeShop; +import mineplex.core.shop.confirmation.ConfirmationPage; /** * @author Timothy Andis (TadahTech) on 4/7/2016. @@ -16,11 +21,13 @@ import java.util.UUID; public class KitUpgradeButton extends KitButton { + private KitProgressionManager _plugin; private int _upgradeLevel; - public KitUpgradeButton(ProgressiveKit kit, ItemStack itemStack, int upgradeLevel) + public KitUpgradeButton(KitProgressionManager plugin, ProgressiveKit kit, ItemStack itemStack, int upgradeLevel) { super(kit, itemStack); + _plugin = plugin; _upgradeLevel = upgradeLevel; } @@ -35,15 +42,15 @@ public class KitUpgradeButton extends KitButton player.sendMessage(F.main("Kit Progression", "You cannot purchase this upgrade!")); return; } - - getKit().upgrade(_upgradeLevel, uuid); - - player.playSound(player.getLocation(), Sound.CAT_MEOW, 5.0f, 1.0f); - - player.sendMessage(F.main("Kit Progression", "Purchased upgrades for " + getKit().getDisplayName() + " level " + _upgradeLevel)); + + KitUpgradeShop shop = new KitUpgradeShop(_plugin, _plugin.getClientManager(), _plugin.getDonationManager()); + KitUpgradeProcessor processor = new KitUpgradeProcessor(_plugin, player, getKit(), _upgradeLevel); + ConfirmationPage page = new ConfirmationPage(player, _plugin, shop, _plugin.getClientManager(), _plugin.getDonationManager(), processor, getItemStack()); + + shop.openPageForPlayer(player, page); Menu.remove(uuid); - player.closeInventory(); + //player.closeInventory(); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitXPButton.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitXPButton.java index 11fd5fbba..1331f38bd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitXPButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitXPButton.java @@ -2,6 +2,7 @@ package mineplex.core.progression.gui.buttons; import com.google.common.collect.Lists; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.progression.KitProgressionManager; import mineplex.core.progression.ProgressiveKit; import mineplex.core.progression.gui.guis.KitInformationTrackerMenu; import mineplex.core.progression.gui.guis.KitMenu; @@ -23,9 +24,9 @@ public class KitXPButton extends KitButton private ItemStack _item; - public KitXPButton(ProgressiveKit kit, Player player) + public KitXPButton(ProgressiveKit kit, Player player, KitProgressionManager plugin) { - super(kit, null); + super(kit, null, plugin); ItemBuilder builder = new ItemBuilder(Material.EXP_BOTTLE); builder.setTitle(ChatColor.YELLOW + "XP and Level"); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitDisplayMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitDisplayMenu.java index 8124a5f48..2a9d73b67 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitDisplayMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitDisplayMenu.java @@ -63,7 +63,7 @@ public class KitDisplayMenu extends KitMenu */ private void setUpNextMenuButtons(Button[] buttons, Player player) { - buttons[48] = new KitXPButton(getKit(), player); + buttons[48] = new KitXPButton(getKit(), player, getPlugin()); buttons[50] = new KitUpgradeMenuButton(getKit(), player, getPlugin()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitInformationTrackerMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitInformationTrackerMenu.java index 992490c69..42d1aa723 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitInformationTrackerMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitInformationTrackerMenu.java @@ -1,6 +1,17 @@ package mineplex.core.progression.gui.guis; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.ChatColor; +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import com.google.common.collect.Lists; + import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.menu.Button; @@ -11,15 +22,6 @@ import mineplex.core.progression.gui.buttons.KitUpgradeButton; import mineplex.core.progression.gui.buttons.KitUpgradeDetailsButton; import mineplex.core.progression.gui.buttons.misc.BackButton; import mineplex.core.progression.math.Calculations; -import org.bukkit.ChatColor; -import org.bukkit.DyeColor; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import java.util.List; -import java.util.Map; -import java.util.UUID; /** * This is the secondary menu access by either the Enchantment table or XP Bottle @@ -174,8 +176,8 @@ public class KitInformationTrackerMenu extends KitMenu itemStack.addLore("Costs " + C.cGreen + Calculations.getGemsCost(index) + C.cGray + " gems"); itemStack.addLore(C.cRed + "You cannot purchase this upgrade!"); } - - KitUpgradeButton upgradeButton = new KitUpgradeButton(getKit(), itemStack.build(), index); + + KitUpgradeButton upgradeButton = new KitUpgradeButton(getPlugin(), getKit(), itemStack.build(), index); buttons[i] = upgradeButton; } return; 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 cd12e5e60..c6032fcb7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -376,7 +376,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation _punishmentManager = punish; - _kitProgressionManager = new KitProgressionManager(getPlugin(), clientManager); + _kitProgressionManager = new KitProgressionManager(getPlugin(), donationManager, clientManager); _progressionKitManager = new ProgressingKitManager(this); _serverUptimeManager = new ServerUptimeManager(this); 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 d80d871ec..1df0d4cb7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -59,6 +59,7 @@ import nautilus.game.arcade.game.games.monstermaze.MonsterMaze; import nautilus.game.arcade.game.games.oldmineware.OldMineWare; import nautilus.game.arcade.game.games.paintball.Paintball; import nautilus.game.arcade.game.games.quiver.Quiver; +import nautilus.game.arcade.game.games.quiver.QuiverPayload; import nautilus.game.arcade.game.games.quiver.QuiverTeams; import nautilus.game.arcade.game.games.quiver.modes.BunnyHop; import nautilus.game.arcade.game.games.rings.ElytraRings; @@ -157,6 +158,7 @@ public enum GameType OldMineWare(OldMineWare.class, GameDisplay.OldMineWare), Paintball(Paintball.class, GameDisplay.Paintball), Quiver(Quiver.class, GameDisplay.Quiver), + QuiverPayload(QuiverPayload.class, GameDisplay.QuiverPayload), QuiverTeams(QuiverTeams.class, GameDisplay.QuiverTeams), Runner(Runner.class, GameDisplay.Runner), SearchAndDestroy(SearchAndDestroy.class, GameDisplay.SearchAndDestroy), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java index 7ecd12499..562098414 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java @@ -5,17 +5,29 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.scoreboard.DisplaySlot; +import org.bukkit.scoreboard.Objective; + import mineplex.core.common.Pair; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; -import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.itemstack.ItemBuilder; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; -import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; @@ -31,19 +43,6 @@ import nautilus.game.arcade.stats.SharpShooterStatTracker; import nautilus.game.arcade.stats.WinWithoutBowStatTracker; import nautilus.game.arcade.stats.WinWithoutDyingStatTracker; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.player.PlayerPickupItemEvent; -import org.bukkit.scoreboard.DisplaySlot; -import org.bukkit.scoreboard.Objective; - public class Quiver extends SoloGame { private ArrayList _ranks = new ArrayList(); @@ -52,7 +51,10 @@ public class Quiver extends SoloGame private HashMap _deathTime = new HashMap(); private Objective _scoreObj; + + public static final ItemStack SUPER_ARROW = new ItemBuilder(Material.ARROW).setTitle(C.cYellow + "Super Arrow").build(); + @SuppressWarnings("unchecked") public Quiver(ArcadeManager manager) { this(manager, new Kit[] @@ -62,6 +64,12 @@ public class Quiver extends SoloGame new KitEnchanter(manager), new KitSlamShot(manager), new KitNinja(manager) +// new KitBeserker(manager), +// new KitNewNinja(manager), +// new KitBarrage(manager), +// new KitHeadHunter(manager), +// new KitPyromancer(manager), +// new KitNecromancer(manager), }, GameType.Quiver); registerStatTrackers( @@ -81,6 +89,7 @@ public class Quiver extends SoloGame ); } + @SuppressWarnings("deprecation") public Quiver(ArcadeManager manager, Kit[] kits, GameType type) { super(manager, type, kits, @@ -97,8 +106,6 @@ public class Quiver extends SoloGame this.DamageSelf = false; this.DamageTeamSelf = true; this.PrepareFreeze = false; - this.BlockBreakAllow.add(102); - this.BlockBreakAllow.add(20); this.BlockBreakAllow.add(Material.STAINED_GLASS_PANE.getId()); this.BlockBreakAllow.add(Material.STAINED_GLASS.getId()); @@ -116,7 +123,7 @@ public class Quiver extends SoloGame for (Player player : GetPlayers(true)) { - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(262, (byte)0, 1, F.item("Super Arrow"))); + player.getInventory().addItem(SUPER_ARROW); player.playSound(player.getLocation(), Sound.PISTON_EXTEND, 3f, 2f); } } @@ -150,7 +157,7 @@ public class Quiver extends SoloGame public void run() { if (!player.getInventory().contains(Material.ARROW)) - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(262, (byte)0, 1, F.item("Super Arrow"))); + player.getInventory().addItem(SUPER_ARROW); } }, 10); @@ -173,18 +180,18 @@ public class Quiver extends SoloGame Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); if (player == null) return; - int amount = 1; - - if (GetKit(player) instanceof KitSlamShot) - { - if (Manager.GetCondition().HasCondition(event.GetEvent().getEntity(), ConditionType.FALLING, null)) - { - amount = 2; - } - } +// int amount = 1; +// +// if (GetKit(player) instanceof KitSlamShot) +// { +// if (Manager.GetCondition().HasCondition(event.GetEvent().getEntity(), ConditionType.FALLING, null)) +// { +// amount = 2; +// } +// } //New Arrow - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(262, (byte)0, amount, F.item("Super Arrow"))); + player.getInventory().addItem(SUPER_ARROW); player.playSound(player.getLocation(), Sound.PISTON_EXTEND, 3f, 2f); //Score @@ -280,17 +287,14 @@ public class Quiver extends SoloGame @EventHandler public void ArrowDamage(CustomDamageEvent event) - { - if (!(event.GetDamagerEntity(true) instanceof Arrow) - && !(event.GetDamagerEntity(true) instanceof Player) - && (event.GetDamagerEntity(true) instanceof Entity)) - { - event.setCancelled(true); - return; - } - + { if (event.GetProjectile() == null) return; + + if (!(event.GetProjectile() instanceof Arrow)) + { + return; + } event.AddMod("Projectile", "Instagib", 9001, false); event.SetKnockback(false); @@ -312,6 +316,7 @@ public class Quiver extends SoloGame Scoreboard.writeNewLine(); + //Write New Scoreboard.writeGroup(_ranks, score -> Pair.create(C.cGreen + score.Player.getName(), score.Kills), true); Scoreboard.draw(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverPayload.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverPayload.java new file mode 100644 index 000000000..3cd388492 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverPayload.java @@ -0,0 +1,1541 @@ +package nautilus.game.arcade.game.games.quiver; + +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Set; +import java.util.UUID; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Minecart; +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.event.vehicle.VehicleDamageEvent; +import org.bukkit.event.vehicle.VehicleEnterEvent; +import org.bukkit.event.vehicle.VehicleEntityCollisionEvent; +import org.bukkit.material.MaterialData; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.scoreboard.Team; +import org.bukkit.util.Vector; + +import mineplex.core.common.MinecraftVersion; +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.UtilBlock; +import mineplex.core.common.util.UtilEnt; +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.UtilServer; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTextTop; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.particles.effects.ObjectiveParticle; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.combat.CombatComponent; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.games.quiver.data.PowerupGenerator; +import nautilus.game.arcade.game.games.quiver.data.SpawnBarrier; +import nautilus.game.arcade.game.games.quiver.kits.KitBarrage; +import nautilus.game.arcade.game.games.quiver.kits.KitBeserker; +import nautilus.game.arcade.game.games.quiver.kits.KitNecromancer; +import nautilus.game.arcade.game.games.quiver.kits.KitNewNinja; +import nautilus.game.arcade.game.games.quiver.kits.KitPyromancer; +import nautilus.game.arcade.game.games.quiver.kits.KitSkyWarrior; +import nautilus.game.arcade.game.games.quiver.ultimates.Ultimate; +import nautilus.game.arcade.game.modules.VersionModule; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; +import net.md_5.bungee.api.ChatColor; + +public class QuiverPayload extends TeamGame +{ + + // Define all our constants. + private static final long GAME_TIMEOUT = 600000; + + private static final double PAYLOAD_CAPTURE_RANGE = 4; + private static final double PAYLOAD_VELOCITY = 0.2; + private static final int PAYLOAD_MARKER_MAX_DISTANCE = 2; + private static final int PAYLOAD_RENGERATION_DURATION = 3 * 20; + private static final int PAYLOAD_RENGERATION_AMPLIFIER = 1; + private static final int PAYLOAD_RESPAWN_DELAY_TICKS = 7 * 20; + + private static final String SUPER_ARROW_DAMAGE_REASON = "Instagib"; + private static final double SUPER_ARROW_DAMAGE_MOD = 9001; + + private static final int ULTIMATE_PERCENTAGE_INCREASE_KILL = 5; + private static final int ULTIMATE_PERCENTAGE_INCREASE_ASSIST = 2; + private static final double ULTIMATE_PERCENTAGE_PAYLOAD = 0.2; + + private static final long POWERUP_SPAWN_DELAY = 20000; + + private static final int RESPAWN_INITAL_SECONDS = 2; + private static final int RESPAWN_ARROW_GIVE_DELAY = 20; + + private static final int END_EFFECT_DELAY = 100; + private static final int END_EFFECT_TNT_AMOUNT = 8; + private static final int END_EFFECT_EXPLOSION_RADIUS = 5; + private static final int MAX_SCORE = 5; + + private static final long KILLSTREAK_TIME_PERIOD = 1500; + private static final long TEAM_KILL_MINIMUM_DELAY = 20000; + private static final int TEAM_KILL_MINIMUM_PLAYERS = 6; + + private static final long OBJECTIVE_PARTICLES_TIME = 10000; + + private static final int GEMS_KILL = 2; + private static final int GEMS_ASSIST = 1; + private static final int GEMS_SCORE = 3; + private static final int GEMS_KILLSTREAK = 3; + + private static final String DATA_POINT_MARKER_START = "PINK"; + private static final String DATA_POINT_RED = "RED"; + private static final String DATA_POINT_BLUE = "BLUE"; + private static final String DATA_POINT_PAYLOAD = "BLACK"; + private static final String DATA_POINT_POWERUP = "YELLOW"; + private static final String DATA_POINT_KIT_RED = "ORANGE"; + private static final String DATA_POINT_KIT_BLUE = "LIGHT_BLUE"; + private static final String CUSTOM_LOCATION_BARRIER_RED = "73"; + private static final String CUSTOM_LOCATION_BARRIER_BLUE = "21"; + + private static final int SPAWN_SHIELD_RADIUS = 5; + + private static final String OVERTIME = C.cGold + "!!! " + C.cDRedB + "OVERTIME" + C.cGold + " !!!"; + + private Minecart _minecart; + private GameTeam _teamDirection; + private int _targetIndex; + private boolean _hasMoved; + private boolean _isOvertime; + private boolean _recentlyChanged; + private double _totalDistance; + private Set _lastOvertimeTrack = new HashSet<>(); + private List _pathMarkers = new ArrayList<>(); + + private PayloadState _payloadState; + private boolean _hasAnnouncedGameEnd; + private boolean _isEnding; + private boolean _coloredMessage; + + private Map _teamScore = new HashMap<>(); + + private List _powerupGenerators = new ArrayList<>(); + + private Map _ultimatePercentage = new HashMap<>(); + private Map _kitNPC = new HashMap<>(); + private Map _killstreakAmount = new HashMap<>(); + private Map _killstreamLast = new HashMap<>(); + private long _lastTeamKill; + + private Set _objectiveParticle = new HashSet<>(); + private Set _spawnBarrier = new HashSet<>(); + + private Team _payloadTeam; + + public QuiverPayload(ArcadeManager manager) + { + super(manager, GameType.QuiverPayload, new Kit[] { + + new KitBeserker(manager), new KitNewNinja(manager), new KitBarrage(manager), new KitSkyWarrior(manager), new KitPyromancer(manager), new KitNecromancer(manager), + + }, new String[] { "Arrows one hit kill opponents.", "You recieve one arrow per kill.", "Stand next to the payload to move it towards the enemy base.", + "Lasts 10 minutes or until a team scores " + MAX_SCORE + " points", }); + + this.PlayersPerTeam = 5; + this.DeathOut = false; + this.DeathSpectateSecs = RESPAWN_INITAL_SECONDS; + this.DamageSelf = false; + this.DamageTeamSelf = false; + this.DamageFall = false; + this.TeamArmor = true; + this.TeamArmorHotbar = true; + this.HungerSet = 20; + this._help = new String[] { "Standing near the payload increases your Ultimate charge.", "Arrow powerups respawn every 20 seconds.", + "Killing or assisting on kills increases your Ultimate charge.", "You can change your Kit during the game by clicking the Zombies in your Spawn." }; + + registerModule(new VersionModule(MinecraftVersion.Version1_9, "One in the Quiver Payload requires Minecraft 1.9!")); + + _payloadState = PayloadState.NONE; + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + if (GetTeamList().isEmpty()) + { + return; + } + + Scoreboard.reset(); + Scoreboard.writeNewLine(); + + Scoreboard.write(C.cGoldB + "Payload"); + + if (_payloadState.equals(PayloadState.CONTESTED)) + { + Scoreboard.write(C.cDPurpleB + "Contested"); + } + else if (_payloadState.equals(PayloadState.RESTARTING)) + { + Scoreboard.write("Respawning..."); + } + else if (_payloadState.equals(PayloadState.NONE)) + { + Scoreboard.write("None"); + } + else if (_teamDirection != null) + { + String distance = new DecimalFormat("0.0").format(getTrackDistanceToMarker(getDestination(_teamDirection))); + Scoreboard.write(_teamDirection.GetFormattedName() + ChatColor.RESET + _teamDirection.GetColor() + " (" + _teamDirection.GetColor() + distance + "m)"); + } + else + { + Scoreboard.write("Loading..."); + } + + if (IsLive()) + { + Scoreboard.writeNewLine(); + + if (_isOvertime) + { + for (GameTeam gameTeam : _teamScore.keySet()) + { + Scoreboard.write(gameTeam.GetColor() + C.Bold + "Team " + gameTeam.getDisplayName()); + + int alivePlayers = 0; + + for (Player player : gameTeam.GetPlayers(true)) + { + if (UtilPlayer.isSpectator(player)) + { + continue; + } + + alivePlayers++; + } + + Scoreboard.write(alivePlayers + "/" + gameTeam.GetPlayers(true).size() + " Alive"); + Scoreboard.writeNewLine(); + } + } + else + { + for (GameTeam gameTeam : _teamScore.keySet()) + { + int score = Math.min(_teamScore.get(gameTeam), MAX_SCORE); + + Scoreboard.write(gameTeam.GetColor() + C.Bold + "Team " + gameTeam.getDisplayName()); + Scoreboard.write(score + " Point" + (score == 1 ? "" : "s") + " (" + (MAX_SCORE - score) + ")"); + Scoreboard.writeNewLine(); + } + } + + Scoreboard.write(C.cRedB + "Game End"); + + if (_isOvertime) + { + Scoreboard.write(OVERTIME); + } + else + { + Scoreboard.write(UtilTime.MakeStr(GAME_TIMEOUT - (System.currentTimeMillis() - GetStateTime()))); + } + } + else if (WinnerTeam != null) + { + Scoreboard.writeNewLine(); + Scoreboard.write(WinnerTeam.GetFormattedName() + " Won!"); + } + + Scoreboard.writeNewLine(); + Scoreboard.draw(); + } + + @EventHandler + public void onGameStateChange(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Prepare) + { + _lastTeamKill = System.currentTimeMillis(); + _payloadTeam = GetScoreboard().getHandle().registerNewTeam("payloadTeam"); + + for (GameTeam gameTeam : GetTeamList()) + { + _teamScore.put(gameTeam, 0); + } + + CreatureAllowOverride = true; + + spawnKitNPCs(WorldData.GetDataLocs(DATA_POINT_KIT_RED), GetTeam(org.bukkit.ChatColor.RED)); + spawnKitNPCs(WorldData.GetDataLocs(DATA_POINT_KIT_BLUE), GetTeam(org.bukkit.ChatColor.AQUA)); + + CreatureAllowOverride = false; + + Set redBarriers = new HashSet<>(); + Set blueBarriers = new HashSet<>(); + + redBarriers.addAll(WorldData.GetCustomLocs(CUSTOM_LOCATION_BARRIER_RED)); + blueBarriers.addAll(WorldData.GetCustomLocs(CUSTOM_LOCATION_BARRIER_BLUE)); + + _spawnBarrier.add(new SpawnBarrier(this, GetTeam(org.bukkit.ChatColor.RED), redBarriers)); + _spawnBarrier.add(new SpawnBarrier(this, GetTeam(org.bukkit.ChatColor.AQUA), blueBarriers)); + } + + if (event.GetState() == GameState.Live) + { + /* + * This is the location that the minecart will spawn at the start of + * the game. This is represented as a DATA_POINT_PAYLOAD coloured + * data point. + */ + Location location = WorldData.GetDataLocs(DATA_POINT_PAYLOAD).get(0); + + _minecart = location.getWorld().spawn(location, Minecart.class); + + _minecart.spigot().forceGlowing(true); + _minecart.setDisplayBlock(new MaterialData(Material.TNT)); + _payloadTeam.addEntry(_minecart.getUniqueId().toString()); + + for (Player player : GetPlayers(true)) + { + if (GetKit(player) instanceof KitNewNinja) + { + continue; + } + + // Give all players a Super Arrow item. + player.getInventory().addItem(Quiver.SUPER_ARROW); + } + + for (Location powerup : WorldData.GetDataLocs(DATA_POINT_POWERUP)) + { + _powerupGenerators.add(new PowerupGenerator(this, powerup, POWERUP_SPAWN_DELAY)); + } + + /* + * The payload which is represented as a minecart follows a linear + * path connecting the two gameTeam's bases. The logic used to + * calculate the path that the minecart takes is done below. + * + * Initially we need to get a constant point we will use to start + * our calculations. This is a DATA_POINT_MARKER_START coloured data + * point. This is placed at the red gameTeam's base, at the end of + * the track. + */ + + Location start = WorldData.GetDataLocs(DATA_POINT_MARKER_START).get(0); + Location last = start; + ArrayList dataPoints = new ArrayList<>(); + + /* + * The dataPoints ArrayList is an unordered list of all the data + * points. We add the start location and all red and blue data + * points. + * + * We use red and blue data points so that it is easier for the + * builders to see which direction the minecart would move when a + * certain gameTeam moved the minecart. + * + * Data points are placed above the track, they should be placed at + * intervals along the track where it is ensured that the next data + * point along the track is the closest relative to all other data + * points in the map as well on any point where the track curves. + * + */ + + dataPoints.add(start); + dataPoints.addAll(WorldData.GetDataLocs(DATA_POINT_RED)); + dataPoints.addAll(WorldData.GetDataLocs(DATA_POINT_BLUE)); + + /* + * While there are locations still left in the list, we search for + * the nearest different data point and add it to a new list, this + * list contains all the data points sorted in the correct order of + * the track's path. + */ + + while (!dataPoints.isEmpty()) + { + Location dataPoint = UtilAlg.findClosest(last, dataPoints); + + _pathMarkers.add(dataPoint); + dataPoints.remove(dataPoint); + last = dataPoint; + } + + /* + * We need to calculate the total linear distance between all the + * stored data points. This is used later when displaying the + * Dragon/Wither progression bar. + */ + for (int i = 1; i < _pathMarkers.size(); i++) + { + _totalDistance += UtilMath.offset(_pathMarkers.get(i - 1), _pathMarkers.get(i)); + } + } + + if (event.GetState() == GameState.End) + { + for (UUID uuid : _ultimatePercentage.keySet()) + { + Player player = UtilPlayer.searchExact(uuid); + + for (Perk perk : GetKit(player).GetPerks()) + { + if (!(perk instanceof Ultimate)) + { + continue; + } + + Ultimate ultimate = (Ultimate) perk; + + if (ultimate.getLastUltimate().containsKey(player.getUniqueId())) + { + ultimate.cancel(player); + } + } + + } + } + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (!IsLive()) + { + return; + } + + if (event.getType() == UpdateType.MIN_02) + { + this.DeathSpectateSecs++; + } + + if (event.getType() == UpdateType.SEC) + { + + /* + * If the game lasts longer than GAME_TIMEOUT milliseconds. A winner + * is determined by calculating which gameTeam has the least amount + * of distance left the push the payload. + */ + if (UtilTime.elapsed(GetStateTime(), GAME_TIMEOUT) && !_isOvertime) + { + /* + * If a particular gameTeam has scored the most points they are + * the winners otherwise if all gameTeam's scores are the same, + * the game goes into overtime and after OVERTIME milliseconds + * the distance from the minecart and that gameTeams destination + * is used to determine the winner. + */ + + int lastScore = -1; + boolean same = false; + + for (GameTeam gameTeam : _teamScore.keySet()) + { + int score = _teamScore.get(gameTeam); + + if (lastScore == -1) + { + lastScore = score; + WinnerTeam = gameTeam; + } + else if (score > lastScore) + { + WinnerTeam = gameTeam; + } + else if (score == lastScore) + { + same = true; + } + } + + if (same) + { + String subTitle = C.cRed + "The track will now shrink over time!"; + + UtilTextMiddle.display(OVERTIME, subTitle, 10, 30, 10); + UtilServer.broadcast(OVERTIME + " " + subTitle); + + _isOvertime = true; + return; + + // double shortest = Double.MAX_VALUE; + // + // for (GameTeam gameTeam : _teamScore.keySet()) + // { + // double distance = + // getTrackDistanceToMarker(getDestination(gameTeam), + // gameTeam); + // + // if (distance < shortest) + // { + // shortest = distance; + // WinnerTeam = gameTeam; + // } + // } + } + + AnnounceEnd(WinnerTeam); + SetState(GameState.End); + return; + } + + if (event.getType() == UpdateType.SEC && _isOvertime) + { + if (_lastOvertimeTrack.isEmpty()) + { + _lastOvertimeTrack.add(_pathMarkers.get(0).getBlock().getRelative(BlockFace.DOWN)); + _lastOvertimeTrack.add(_pathMarkers.get(_pathMarkers.size() - 1).getBlock().getRelative(BlockFace.DOWN)); + } + + Set newTracks = new HashSet<>(); + + for (Block block : _lastOvertimeTrack) + { + if (isMinecartNearMarker(block.getLocation())) + { + Location locationA = UtilAlg.findClosest(_minecart.getLocation(), WorldData.GetDataLocs(DATA_POINT_RED)); + Location locationB = UtilAlg.findClosest(_minecart.getLocation(), WorldData.GetDataLocs(DATA_POINT_BLUE)); + + if (UtilMath.offset(_minecart.getLocation(), locationA) < UtilMath.offset(_minecart.getLocation(), locationB)) + { + WinnerTeam = GetTeam(org.bukkit.ChatColor.AQUA); + } + else + { + WinnerTeam = GetTeam(org.bukkit.ChatColor.RED); + } + + _payloadState = PayloadState.RESTARTING; + awardWinGems(); + displayEndEffect(); + return; + } + + for (Block other : UtilBlock.getInRadius(block, 1.5).keySet()) + { + if (other.getType() == Material.RAILS) + { + block.setType(Material.AIR); + newTracks.add(other); + UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.05F, 12, ViewDist.NORMAL); + } + } + } + + _lastOvertimeTrack = newTracks; + } + + /* + * If the game only has 60 seconds left before it times out we sent + * all players a message. + */ + else if (UtilTime.elapsed(GetStateTime(), GAME_TIMEOUT - 60000) && !_hasAnnouncedGameEnd) + { + _hasAnnouncedGameEnd = true; + + String message = C.cRedB + "Only 60 seconds remain!"; + + UtilTextMiddle.display("", message, 10, 20, 10); + UtilServer.broadcast(message); + + for (Player player : UtilServer.getPlayers()) + { + player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 0); + } + } + + for (PowerupGenerator powerupGenerator : _powerupGenerators) + { + powerupGenerator.update(); + } + + for (SpawnBarrier spawnBarrier : _spawnBarrier) + { + spawnBarrier.playParticles(); + } + + _coloredMessage = !_coloredMessage; + + for (Player player : GetPlayers(true)) + { + Kit kit = GetKit(player); + + if (kit == null || UtilPlayer.isSpectator(player)) + { + continue; + } + + if (!_ultimatePercentage.containsKey(player.getUniqueId())) + { + _ultimatePercentage.put(player.getUniqueId(), 0D); + } + + double percentage = _ultimatePercentage.get(player.getUniqueId()); + + if (percentage >= 100) + { + UtilTextBottom.display((_coloredMessage ? C.cWhiteB : C.cAquaB) + "ULTIMATE READY (PRESS SNEAK)", player); + player.setExp(0.999F); + player.setLevel(100); + continue; + } + + String percentageFormatted = new DecimalFormat("0.0").format(percentage); + + UtilTextBottom.displayProgress("Ultimate", percentage / 100, percentageFormatted + "%", player); + player.setExp((float) percentage / 100); + player.setLevel((int) percentage); + + for (Perk perk : kit.GetPerks()) + { + if (perk instanceof Ultimate) + { + Ultimate ultimate = (Ultimate) perk; + + if (ultimate.getLastUltimate().containsKey(player.getUniqueId())) + { + continue; + } + + incrementUltimate(player, ultimate.getChargeIncreasePerSecond()); + } + } + } + } + + if (event.getType() == UpdateType.TICK) + { + Iterator iterator = _objectiveParticle.iterator(); + + while (iterator.hasNext()) + { + ObjectiveParticle objectiveParticle = iterator.next(); + + if (objectiveParticle.update()) + { + iterator.remove(); + } + } + } + + if (event.getType() == UpdateType.SEC_05) + { + if (UtilTime.elapsed(GetStateTime(), OBJECTIVE_PARTICLES_TIME)) + { + return; + } + + for (Player player : GetPlayers(true)) + { + _objectiveParticle.add(new ObjectiveParticle(player.getEyeLocation(), player.getLocation().getDirection(), _minecart.getLocation().add(0, 1, 0), player)); + } + + } + + if (event.getType() == UpdateType.FAST) + { + if (GetPlayers(true).size() >= TEAM_KILL_MINIMUM_PLAYERS) + { + for (GameTeam gameTeam : GetTeamList()) + { + if (!UtilTime.elapsed(_lastTeamKill, TEAM_KILL_MINIMUM_DELAY)) + { + break; + } + + boolean gameTeamKill = true; + + for (Player player : gameTeam.GetPlayers(false)) + { + if (!UtilPlayer.isSpectator(player)) + { + gameTeamKill = false; + } + } + + if (gameTeamKill) + { + String message = gameTeam.GetColor() + C.Bold + "DOMINATION"; + + UtilTextMiddle.display(message, "", 10, 30, 10); + UtilServer.broadcast(message); + + _lastTeamKill = System.currentTimeMillis(); + } + } + } + + for (Player player : UtilServer.getPlayers()) + { + if (_killstreamLast.containsKey(player.getUniqueId()) && _killstreakAmount.containsKey(player.getUniqueId())) + { + long lastKill = _killstreamLast.get(player.getUniqueId()); + int kills = _killstreakAmount.get(player.getUniqueId()); + + if (UtilTime.elapsed(lastKill, KILLSTREAK_TIME_PERIOD)) + { + if (kills > 1) + { + String name = null; + + switch (kills) + { + case 3: + name = "TRIPLE"; + break; + case 4: + name = "QUADRA"; + break; + case 5: + name = "PENTA"; + break; + case 6: + name = "HEXA"; + break; + case 7: + name = "SEPTA"; + break; + case 8: + name = "OCTA"; + break; + case 9: + name = "NONA"; + break; + case 10: + name = "DECA"; + break; + } + + if (name != null) + { + for (Player other : UtilServer.getPlayers()) + { + other.playSound(other.getLocation(), Sound.ENDERDRAGON_GROWL, 1F + kills, 1f + kills); + } + + AddGems(player, GEMS_KILLSTREAK * kills, name + " Killstreak", true, true); + UtilServer.broadcast(C.cGreenB + player.getName() + C.cWhite + " got a " + C.cGreenB + name + " KILL" + C.cWhite + "!"); + } + } + + _killstreakAmount.put(player.getUniqueId(), 0); + } + } + } + + for (SpawnBarrier spawnBarrier : _spawnBarrier) + { + spawnBarrier.update(); + } + } + + if (event.getType() == UpdateType.FAST && _minecart != null && !_payloadState.equals(PayloadState.RESTARTING)) + { + + /* + * In order to determine which direction the payload will move we + * calculate how many players are within PAYLOAD_CAPURE_RANGE blocks + * of the payload. + */ + + int gameTeamACount = 0, gameTeamBCount = 0; + + for (Player player : UtilPlayer.getNearby(_minecart.getLocation(), PAYLOAD_CAPTURE_RANGE)) + { + GameTeam gameTeam = GetTeam(player); + + if (GetTeamList().get(0).equals(gameTeam)) + { + gameTeamACount++; + } + else + { + gameTeamBCount++; + } + + player.removePotionEffect(PotionEffectType.REGENERATION); + player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, PAYLOAD_RENGERATION_DURATION, PAYLOAD_RENGERATION_AMPLIFIER)); + incrementUltimate(player, ULTIMATE_PERCENTAGE_PAYLOAD); + } + + UtilTextTop.display(getTopBar(), UtilServer.getPlayers()); + + /* + * _recentlyChanged is used to show that on the targetIndex needs to + * be updated as the payload's direction has changed. + */ + + if (gameTeamACount > gameTeamBCount && gameTeamBCount == 0) + { + if (_teamDirection != null) + { + if (!_teamDirection.equals(GetTeamList().get(0))) + { + setMinecartTeam(GetTeamList().get(0)); + _recentlyChanged = true; + } + } + + _teamDirection = GetTeamList().get(0); + } + else if (gameTeamACount < gameTeamBCount && gameTeamACount == 0) + { + if (_teamDirection != null) + { + if (!_teamDirection.equals(GetTeamList().get(1))) + { + setMinecartTeam(GetTeamList().get(1)); + _recentlyChanged = true; + } + } + + _teamDirection = GetTeamList().get(1); + } + else + { + if (gameTeamACount > 0 && gameTeamBCount > 0) + { + _payloadState = PayloadState.CONTESTED; + } + else + { + _payloadState = PayloadState.NONE; + } + + setMinecartTeam(_payloadState); + _minecart.setVelocity(new Vector(0, 0, 0)); + return; + } + + setMinecartTeam(_teamDirection); + _payloadState = PayloadState.MOVING; + + if (_teamDirection.equals(GetTeamList().get(0))) + { + // If the minecart has never moved + if (!_hasMoved) + { + _targetIndex = _pathMarkers.size() / 2; + } + else if (isMinecartNearMarker(_pathMarkers.get(_targetIndex)) || _recentlyChanged) + { + _targetIndex++; + _recentlyChanged = false; + } + } + else + { + // If the minecart has never moved + if (!_hasMoved) + { + _targetIndex = _pathMarkers.size() / 2 - 2; + } + else if (isMinecartNearMarker(_pathMarkers.get(_targetIndex)) || _recentlyChanged) + { + _targetIndex--; + _recentlyChanged = false; + } + } + + /* + * The minecart's velocity is set to the vector between the the + * minecart's current location and the next data point it will + * reach. + */ + + _minecart.setVelocity(UtilAlg.getTrajectory(_minecart.getLocation(), _pathMarkers.get(_targetIndex)).normalize().multiply(PAYLOAD_VELOCITY)); + _hasMoved = true; + } + + if (event.getType() == UpdateType.FASTER && _payloadState.equals(PayloadState.RESTARTING)) + { + UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, _minecart.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 1, 10, ViewDist.LONG); + } + } + + @Override + public void EndCheck() + { + if (!IsLive() || _payloadState.equals(PayloadState.RESTARTING)) + { + return; + } + + for (GameTeam gameTeam : _teamScore.keySet()) + { + if (gameTeam.GetPlayers(true).isEmpty()) + { + for (GameTeam otherTeam : _teamScore.keySet()) + { + if (gameTeam.equals(otherTeam)) + { + continue; + } + + WinnerTeam = otherTeam; + awardWinGems(); + displayEndEffect(); + } + } + + if (isMinecartNearMarker(getDestination(gameTeam)) && _teamDirection.equals(gameTeam)) + { + int score = _teamScore.get(gameTeam); + + WinnerTeam = gameTeam; + _teamScore.put(gameTeam, ++score); + + if (score == MAX_SCORE) + { + awardWinGems(); + displayEndEffect(); + } + else + { + resetMinecart(); + } + } + } + } + + private boolean isMinecartNearMarker(Location marker) + { + return isMinecartNearMarker(marker, PAYLOAD_MARKER_MAX_DISTANCE); + } + + private boolean isMinecartNearMarker(Location marker, double distance) + { + return UtilMath.offset(_minecart.getLocation(), marker) < distance; + } + + private double getTrackDistanceToMarker(Location marker) + { + return getTrackDistanceToMarker(marker, _teamDirection); + } + + private double getTrackDistanceToMarker(Location marker, GameTeam gameTeam) + { + double distance = 0; + + if (_minecart == null) + { + return distance; + } + + if (gameTeam == null) + { + return _totalDistance / 2; + } + + if (_targetIndex > _pathMarkers.size() - 1 || _targetIndex < 0) + { + return distance; + } + + if (gameTeam.equals(_teamDirection)) + { + distance += UtilMath.offset(_minecart.getLocation(), _pathMarkers.get(_targetIndex)); + } + + if (GetTeamList().get(0).equals(gameTeam)) + { + if (!gameTeam.equals(_teamDirection)) + { + if (_targetIndex < _pathMarkers.size() - 1) + { + distance += UtilMath.offset(_minecart.getLocation(), _pathMarkers.get(_targetIndex + 1)); + } + else + { + distance += UtilMath.offset(_minecart.getLocation(), _pathMarkers.get(_pathMarkers.size() - 1)); + } + } + + for (int i = _targetIndex + 1; i < _pathMarkers.size(); i++) + { + distance += UtilMath.offset(_pathMarkers.get(i - 1), _pathMarkers.get(i)); + } + } + else + { + if (!gameTeam.equals(_teamDirection)) + { + if (_targetIndex > 0) + { + distance += UtilMath.offset(_minecart.getLocation(), _pathMarkers.get(_targetIndex - 1)); + } + else + { + // distance += UtilMath.offset(_minecart.getLocation(), + // _pathMarkers.get(0)); + } + } + + for (int i = _targetIndex - 1; i >= 0; i--) + { + distance += UtilMath.offset(_pathMarkers.get(i + 1), _pathMarkers.get(i)); + } + } + + return distance; + } + + private Location getDestination(GameTeam gameTeam) + { + if (GetTeamList().get(0).equals(gameTeam)) + { + return _pathMarkers.get(_pathMarkers.size() - 1); + } + + return _pathMarkers.get(0); + } + + private void resetMinecart() + { + _payloadState = PayloadState.RESTARTING; + setMinecartTeam(_payloadState); + _hasMoved = false; + _recentlyChanged = false; + UtilAction.zeroVelocity(_minecart); + + if (_teamScore.get(_teamDirection) < MAX_SCORE) + { + String message = WinnerTeam.GetFormattedName() + " scored a point! Payload respawning..."; + + UtilTextMiddle.display("", message, 10, 20, 10); + UtilServer.broadcast(message); + } + + for (Player player : GetPlayers(true)) + { + if (GetTeam(player).equals(_teamDirection)) + { + AddGems(player, GEMS_SCORE, "Payload Captures", true, true); + } + + player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 0); + } + + displayPointScoreEffect(); + + new BukkitRunnable() + { + + Location toTeleport = WorldData.GetDataLocs(DATA_POINT_PAYLOAD).get(0); + + @Override + public void run() + { + UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _minecart.getLocation().add(0, 1, 0), 0, 0, 0, 1, 1, ViewDist.LONG); + UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, toTeleport, 0, 0, 0, 1, 1, ViewDist.LONG); + _minecart.teleport(toTeleport); + _payloadState = PayloadState.NONE; + setMinecartTeam(_payloadState); + } + }.runTaskLater(Manager.getPlugin(), PAYLOAD_RESPAWN_DELAY_TICKS); + } + + private void displayPointScoreEffect() + { + if (_isEnding) + { + return; + } + + Location location = _minecart.getLocation().add(0, 1, 0); + + UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, location, 0, 0, 0, 1, 1, ViewDist.LONG); + UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, location, 0, 0, 0, 1, 200, ViewDist.LONG); + + for (Player player : UtilPlayer.getNearby(_minecart.getLocation(), 15)) + { + if (!IsAlive(player)) + { + continue; + } + + UtilAction.velocity(player, UtilAlg.getTrajectory(location, player.getLocation()).normalize().multiply(UtilMath.offset(location, player.getLocation())).setY(1.5)); + } + } + + private void displayEndEffect() + { + if (_isEnding) + { + return; + } + + Random random = new Random(); + + _isEnding = true; + _minecart.setDisplayBlock(null); + + for (int i = 0; i < END_EFFECT_TNT_AMOUNT; i++) + { + TNTPrimed tntPrimed = _minecart.getWorld().spawn(_minecart.getLocation().add(0, 1, 0), TNTPrimed.class); + + tntPrimed.setVelocity(new Vector(random.nextDouble() - 0.5, random.nextDouble() / 2, random.nextDouble() - 0.5)); + tntPrimed.setFuseTicks((int) (END_EFFECT_DELAY / 2)); + tntPrimed.setYield(END_EFFECT_EXPLOSION_RADIUS); + } + + new BukkitRunnable() + { + + @Override + public void run() + { + AnnounceEnd(WinnerTeam); + SetState(GameState.End); + } + }.runTaskLater(Manager.getPlugin(), END_EFFECT_DELAY); + } + + @EventHandler + public void onVehicleEntityCollision(VehicleEntityCollisionEvent event) + { + if (event.getVehicle() instanceof Minecart) + { + event.setCollisionCancelled(true); + event.setCancelled(true); + } + } + + @EventHandler + public void onVehicleDamage(VehicleDamageEvent event) + { + if (event.getVehicle() instanceof Minecart) + { + event.setCancelled(true); + } + } + + @EventHandler + public void onVehicleEnter(VehicleEnterEvent event) + { + if (event.getVehicle() instanceof Minecart) + { + event.setCancelled(true); + } + } + + @EventHandler + public void onCombatDeath(CombatDeathEvent event) + { + if (event.GetEvent().getEntity() == null || event.GetLog().GetKiller() == null) + { + return; + } + + if (!(event.GetEvent().getEntity() instanceof Player)) + { + return; + } + + Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); + Player killed = (Player) event.GetEvent().getEntity(); + + if (player == null) + { + return; + } + + player.getInventory().addItem(Quiver.SUPER_ARROW); + killed.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 10, 0)); + + incrementUltimate(player, ULTIMATE_PERCENTAGE_INCREASE_KILL); + + if (_killstreakAmount.containsKey(player.getUniqueId())) + { + _killstreakAmount.put(player.getUniqueId(), _killstreakAmount.get(player.getUniqueId()) + 1); + } + else + { + _killstreakAmount.put(player.getUniqueId(), 1); + } + _killstreamLast.put(player.getUniqueId(), System.currentTimeMillis()); + + for (CombatComponent combatComponent : event.GetLog().GetAttackers()) + { + if (event.GetLog().GetKiller() != null && combatComponent.equals(event.GetLog().GetKiller())) + { + continue; + } + + if (combatComponent.IsPlayer()) + { + Player assitedPlayer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); + + if (assitedPlayer != null) + { + incrementUltimate(assitedPlayer, ULTIMATE_PERCENTAGE_INCREASE_ASSIST); + } + } + } + + if (GetKit(killed) instanceof KitNewNinja) + { + return; + } + + new BukkitRunnable() + { + + @Override + public void run() + { + if (!killed.getInventory().contains(Material.ARROW)) + { + killed.getInventory().addItem(Quiver.SUPER_ARROW); + } + } + }.runTaskLater(Manager.getPlugin(), (long) (this.DeathSpectateSecs * 20 + RESPAWN_ARROW_GIVE_DELAY)); + } + + @EventHandler + public void onPlayerToggleSneak(PlayerToggleSneakEvent event) + { + if (!IsLive()) + { + return; + } + + Player player = event.getPlayer(); + ProgressingKit kit = (ProgressingKit) GetKit(player); + + if (!event.isSneaking()) + { + return; + } + + if (kit == null || UtilPlayer.isSpectator(player)) + { + return; + } + + if (_ultimatePercentage.get(player.getUniqueId()) < 100) + { + return; + } + + for (Perk perk : kit.getPerks()[kit.getUpgradeLevel(player.getUniqueId())]) + { + if (perk instanceof Ultimate) + { + Ultimate ultimate = (Ultimate) perk; + + if (ultimate.isUsable(player)) + { + ultimate.activate(player); + resetUltimate(player, false); + } + } + } + } + + public void incrementUltimate(Player player, double percentage) + { + ProgressingKit kit = (ProgressingKit) GetKit(player); + + for (Perk perk : kit.getPerks()[kit.getUpgradeLevel(player.getUniqueId())]) + { + if (perk instanceof Ultimate) + { + Ultimate ultimate = (Ultimate) perk; + + if (ultimate.getLastUltimate().containsKey(player.getUniqueId())) + { + return; + } + } + } + _ultimatePercentage.put(player.getUniqueId(), _ultimatePercentage.get(player.getUniqueId()) + percentage); + } + + public void resetUltimate(Player player, boolean inform) + { + if (inform) + { + player.sendMessage(F.main("Game", "Your Ultimate charge has been reset!")); + } + _ultimatePercentage.put(player.getUniqueId(), 0D); + } + + @EventHandler + public void onCustomDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity() instanceof Player) + { + Player player = event.GetDamageePlayer(); + + if (event.GetProjectile() != null) + { + if (event.GetProjectile() instanceof Arrow) + { + event.AddMod("Projectile", SUPER_ARROW_DAMAGE_REASON, SUPER_ARROW_DAMAGE_MOD, false); + + event.SetKnockback(false); + } + } + + event.SetDamageToLevel(false); + + if (UtilMath.offset(player.getLocation(), UtilAlg.findClosest(player.getLocation(), GetTeam(player).GetSpawns())) < SPAWN_SHIELD_RADIUS) + { + event.SetCancelled("Spawn Shield"); + } + + if (UtilItem.isLeatherProduct(player.getInventory().getBoots())) + { + event.SetIgnoreArmor(true); + } + } + else if (isKitNPC(event.GetDamageeEntity())) + { + event.SetCancelled("Kit NPC Damage"); + } + } + + @EventHandler + public void onEntityCombust(EntityCombustEvent event) + { + if (isKitNPC(event.getEntity())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void onPlayerInteractEntity(PlayerInteractEntityEvent event) + { + if (isKitNPC(event.getRightClicked()) && IsAlive(event.getPlayer())) + { + ProgressingKit progressingKit = _kitNPC.get(event.getRightClicked()); + + Manager.getProgressionKitManager().entityClick(event.getPlayer(), progressingKit); + } + } + + @EventHandler + public void onProjectileHit(ProjectileHitEvent event) + { + event.getEntity().remove(); + } + + @EventHandler + public void onPlayerPickupItem(PlayerPickupItemEvent event) + { + event.setCancelled(true); + + for (PowerupGenerator powerupGenerator : _powerupGenerators) + { + powerupGenerator.pickup(event.getPlayer(), event.getItem()); + } + } + + @EventHandler + public void onEntityRegainHealthEvent(EntityRegainHealthEvent event) + { + if (event.getEntity().getFireTicks() > 0) + { + event.setCancelled(true); + } + } + + public void setMinecartTeam(GameTeam gameTeam) + { + _payloadTeam.setPrefix(gameTeam.GetColor().toString()); + } + + public void setMinecartTeam(PayloadState payloadState) + { + switch (payloadState) + { + case RESTARTING: + _payloadTeam.setPrefix(C.cGreen); + break; + case CONTESTED: + _payloadTeam.setPrefix(C.cPurple); + break; + case NONE: + _payloadTeam.setPrefix(C.cWhite); + break; + default: + break; + } + } + + public String getTopBar() + { + String progress = C.cAqua; + GameTeam gameTeamA = GetTeamList().get(0); + + int percentage = (int) (((int) getTrackDistanceToMarker(getDestination(gameTeamA), gameTeamA) / _totalDistance) * 100); + boolean switched = false; + + if (_teamDirection == null) + { + percentage = 50; + } + + for (int i = 0; i < 25; i++) + { + if (percentage / 4 == i) + { + switched = true; + progress += C.cWhite + "•" + C.cRed; + } + else if (switched) + { + progress += "<"; + } + else + { + progress += ">"; + } + } + + return C.cAqua + "♚ " + C.cWhite + "[ " + progress + C.cWhite + " ]" + C.cRed + " ♚"; + } + + private void awardWinGems() + { + for (Player player : GetPlayers(true)) + { + if (!GetTeam(player).equals(WinnerTeam)) + { + continue; + } + + AddGems(player, 10, "Winning Team", false, false); + } + } + + private void spawnKitNPCs(List locations, GameTeam gameTeam) + { + int i = 0; + Location spawnsAverage = UtilAlg.getAverageLocation(gameTeam.GetSpawns()).subtract(0, 1, 0); + + for (Location location : locations) + { + if (i >= GetKits().length) + { + break; + } + + Entity entity = GetKits()[i].SpawnEntity(location); + ProgressingKit progressingKit = (ProgressingKit) GetKits()[i++]; + + UtilEnt.CreatureLook(entity, spawnsAverage); + + _kitNPC.put(entity, progressingKit); + } + } + + private boolean isKitNPC(Entity entity) + { + return _kitNPC.containsKey(entity); + } + + @EventHandler //DEBUG COMMANDS + public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) + { + if (!UtilServer.isTestServer()) + { + return; + } + + Player player = event.getPlayer(); + + if (event.getMessage().startsWith("/maxpower")) + { + event.setCancelled(true); + incrementUltimate(player, 100); + } + else if (event.getMessage().startsWith("/ks")) + { + event.setCancelled(true); + // This is edgy + _killstreakAmount.put(player.getUniqueId(), Integer.parseInt(event.getMessage().split(" ")[1])); + _killstreamLast.put(player.getUniqueId(), System.currentTimeMillis()); + } + else if (event.getMessage().startsWith("/point")) + { + event.setCancelled(true); + + for (GameTeam gameTeam : _teamScore.keySet()) + { + _teamScore.put(gameTeam, Integer.parseInt(event.getMessage().split(" ")[1])); + } + } + else if (event.getMessage().startsWith("/overtime")) + { + event.setCancelled(true); + + _isOvertime = true; + } + } + + @Override + public double GetKillsGems(Player killer, Player killed, boolean assist) + { + return assist ? GEMS_ASSIST : GEMS_KILL; + } + + public Set getSpawnBarriers() + { + return _spawnBarrier; + } + + private static enum PayloadState + { + NONE, MOVING, CONTESTED, RESTARTING; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/data/PowerupGenerator.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/data/PowerupGenerator.java new file mode 100644 index 000000000..1be26f0cd --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/data/PowerupGenerator.java @@ -0,0 +1,122 @@ +package nautilus.game.arcade.game.games.quiver.data; + +import org.bukkit.Color; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.quiver.Quiver; +import nautilus.game.arcade.game.games.quiver.QuiverPayload; + +public class PowerupGenerator +{ + + private static final int ARROWS_TO_GIVE = 1; + private static final int FIREWORK_VIEW_DISTANCE = 10; + + private QuiverPayload _game; + + private Location _location; + private Item _item; + private long _lastPickup; + private long _respawnDelay; + + public PowerupGenerator(QuiverPayload game, Location location, long respawnDelay) + { + _game = game; + _location = location; + _lastPickup = System.currentTimeMillis(); + _respawnDelay = respawnDelay; + + _location.getBlock().getRelative(BlockFace.DOWN).setType(Material.IRON_BLOCK); + } + + public void update() + { + if (_item != null) + { + if (!_item.isValid()) + { + _item.remove(); + _item = null; + } + + return; + } + + if (UtilTime.elapsed(_lastPickup, _respawnDelay)) + { + _item = _location.getWorld().dropItem(_location, new ItemStack(Material.ARROW)); + + _item.setVelocity(new Vector(0, 1, 0)); + _item.getLocation().getBlock().getRelative(BlockFace.DOWN).setType(Material.GOLD_BLOCK); + + playFirework(); + } + } + + public void pickup(Player player, Item item) + { + if (_item == null) + { + return; + } + + if (!_item.equals(item)) + { + return; + } + + if (!_game.IsAlive(player)) + { + return; + } + + GameTeam gameTeam = _game.GetTeam(player); + + if (gameTeam == null) + { + return; + } + + _item.remove(); + _item = null; + + _lastPickup = System.currentTimeMillis(); + + _location.getBlock().getRelative(BlockFace.DOWN).setType(Material.IRON_BLOCK); + + player.sendMessage(F.main("Game", "You collected the resupply powerup.")); + + playFirework(); + + ItemStack itemStack = Quiver.SUPER_ARROW.clone(); + + itemStack.setAmount(ARROWS_TO_GIVE); + + player.getInventory().addItem(itemStack); + } + + private void playFirework() + { + for (Player player : UtilServer.getPlayers()) + { + if (UtilMath.offset(_location, player.getLocation()) < FIREWORK_VIEW_DISTANCE) + { + UtilFirework.packetPlayFirework(player, _location, Type.BALL_LARGE, Color.YELLOW, false, true); + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/data/SpawnBarrier.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/data/SpawnBarrier.java new file mode 100644 index 000000000..56b52d2c0 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/data/SpawnBarrier.java @@ -0,0 +1,101 @@ +package nautilus.game.arcade.game.games.quiver.data; + +import java.util.Set; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +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 nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.GameTeam; + +public class SpawnBarrier +{ + + private Game _game; + private GameTeam _gameTeam; + private Set _barriers; + + public SpawnBarrier(Game game, GameTeam gameTeam, Set barriers) + { + _game = game; + _gameTeam = gameTeam; + _barriers = barriers; + + for (Location location : _barriers) + { + location.getBlock().setType(Material.AIR); + } + } + + public void update() + { + for (Player player : _game.GetPlayers(true)) + { + if (UtilPlayer.isSpectator(player)) + { + continue; + } + + if (_game.GetTeam(player).equals(_gameTeam)) + { + continue; + } + + for (Location location : _gameTeam.GetSpawns()) + { + if (UtilMath.offset(player.getLocation(), location) < 5) + { + _game.Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.VOID, 9001, false, true, true, _game.GetName(), "Spawn Shield"); + } + } + + for (Location location : _barriers) + { + if (UtilMath.offset(player.getLocation(), location) < 4) + { + UtilAction.velocity(player, UtilAlg.getTrajectory(location, player.getLocation()).normalize().setY(0.4)); + } + } + } + } + + public void playParticles() + { + for (Player player : _game.GetPlayers(true)) + { + if (UtilPlayer.isSpectator(player)) + { + continue; + } + + if (_game.GetTeam(player).equals(_gameTeam)) + { + continue; + } + + for (Location location : _barriers) + { + UtilParticle.PlayParticle(ParticleType.BARRIER, location.clone().add(0, 0.5, 0), 0, 0, 0, 0.1F, 1, ViewDist.SHORT, player); + } + } + } + + public GameTeam getGameTeam() + { + return _gameTeam; + } + + public Set getBlocks() + { + return _barriers; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitBarrage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitBarrage.java new file mode 100644 index 000000000..82028031c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitBarrage.java @@ -0,0 +1,144 @@ +package nautilus.game.arcade.game.games.quiver.kits; + +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilServer; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.quiver.Quiver; +import nautilus.game.arcade.game.games.quiver.QuiverPayload; +import nautilus.game.arcade.game.games.quiver.ultimates.UltimateBarrage; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; +import nautilus.game.arcade.kit.perks.PerkFletcher; + +public class KitBarrage extends ProgressingKit +{ + private static final String[] DESCRIPTION = { + "Oooo look an arrow... ooo look an arrow...", + "", + "Gain an arrow every " + C.cGreen + "5" + C.cWhite + " seconds.", + "", + C.cGreenB + "ULTIMATE", + "When you fire your next arrow you fire an additional", + C.cGreen + "10" + C.cWhite + " arrows." + }; + + private static final String DOUBLE_JUMP = "Double Jump"; + private static final String ULTIMATE = "Ultimate"; + private static final String SUPER_ARROW = "Super Arrow"; + + private static final Perk[][] PERKS = { + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkFletcher(5, 1, true, -1, true, SUPER_ARROW), + new UltimateBarrage(10) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkFletcher(5, 1, true, -1, true, SUPER_ARROW), + new UltimateBarrage(12) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkFletcher(5, 1, true, -1, true, SUPER_ARROW), + new UltimateBarrage(14) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkFletcher(5, 1, true, -1, true, SUPER_ARROW), + new UltimateBarrage(16) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkFletcher(5, 1, true, -1, true, SUPER_ARROW), + new UltimateBarrage(18) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkFletcher(5, 1, true, -1, true, SUPER_ARROW), + new UltimateBarrage(20) + } + }; + + private static final String[][] UPGRADE_DETAILS = { + { + increaseArrows(2), + }, + { + increaseArrows(2), + }, + { + increaseArrows(2), + }, + { + increaseArrows(2), + }, + { + increaseArrows(2), + }, + }; + + private static final String increaseArrows(int arrows) + { + return C.cWhite + "Increase arrows fired from " + C.cGreen + ULTIMATE + C.cWhite + " by " + C.cGreen + arrows + C.cWhite + "."; + } + + private static final ItemStack IN_HAND = new ItemStack(Material.IRON_AXE); + + private static final ItemStack[] PLAYER_ITEMS = { + new ItemBuilder(Material.IRON_AXE).setUnbreakable(true).build(), + new ItemBuilder(Material.BOW).setUnbreakable(true).build(), + }; + + public KitBarrage(ArcadeManager manager) + { + super(manager, "Barrage", "quiverbarrage", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND); + + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(PLAYER_ITEMS); + + if (Manager.GetGame().GetState() == GameState.Live) + { + player.getInventory().addItem(Quiver.SUPER_ARROW); + + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), () -> UtilInv.Update(player), 10); + } + } + + @Override + public void onSelected(UUID player) + { + super.onSelected(player); + + if (!Manager.GetGame().IsLive()) + { + return; + } + + QuiverPayload quiverPayload = (QuiverPayload) Manager.GetGame(); + + quiverPayload.resetUltimate(Bukkit.getPlayer(player), true); + } + + @Override + public boolean showUpgrades() + { + return true; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitBeserker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitBeserker.java new file mode 100644 index 000000000..1ddc13c74 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitBeserker.java @@ -0,0 +1,139 @@ +package nautilus.game.arcade.game.games.quiver.kits; + +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilServer; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.quiver.Quiver; +import nautilus.game.arcade.game.games.quiver.QuiverPayload; +import nautilus.game.arcade.game.games.quiver.ultimates.UltimateBeserker; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; +import nautilus.game.arcade.kit.perks.PerkStrength; + +public class KitBeserker extends ProgressingKit +{ + private static final String[] DESCRIPTION = { + "Missed your arrow? Not a big deal.", + "", + "Deal " + C.cGreen + "+1" + C.cWhite + " more damage", + "", + C.cGreenB + "ULTIMATE", + "You equip " + C.cGreen + "iron" + C.cWhite + " chestplate, leggings and boots.", + "Arrows do not one hit you.", + "Lasts for " + C.cGreen + "6" + C.cWhite + " seconds." + }; + + private static final String DOUBLE_JUMP = "Double Jump"; + private static final String ULTIMATE = "Ultimate"; + private static final String DURATION = "Duration"; + + private static final Perk[][] PERKS = { + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkStrength(1), + new UltimateBeserker(6000) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkStrength(1), + new UltimateBeserker(6500) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkStrength(1), + new UltimateBeserker(7000) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkStrength(1), + new UltimateBeserker(7500) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkStrength(1), + new UltimateBeserker(8000) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkStrength(1), + new UltimateBeserker(8500) + } + }; + + private static final String[][] UPGRADE_DETAILS = { + { + increase(ULTIMATE, DURATION, 12) + }, + { + increase(ULTIMATE, DURATION, 12) + }, + { + increase(ULTIMATE, DURATION, 12) + }, + { + increase(ULTIMATE, DURATION, 12) + }, + { + increase(ULTIMATE, DURATION, 12) + }, + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.IRON_SWORD); + + private static final ItemStack[] PLAYER_ITEMS = { + new ItemBuilder(Material.IRON_SWORD).setUnbreakable(true).build(), + new ItemBuilder(Material.BOW).setUnbreakable(true).build(), + }; + + public KitBeserker(ArcadeManager manager) + { + super(manager, "Berserker", "quiverbeserker", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(PLAYER_ITEMS); + + if (Manager.GetGame().GetState() == GameState.Live) + { + player.getInventory().addItem(Quiver.SUPER_ARROW); + + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), () -> UtilInv.Update(player), 10); + } + } + + @Override + public void onSelected(UUID player) + { + super.onSelected(player); + + if (!Manager.GetGame().IsLive()) + { + return; + } + + QuiverPayload quiverPayload = (QuiverPayload) Manager.GetGame(); + + quiverPayload.resetUltimate(Bukkit.getPlayer(player), true); + } + + @Override + public boolean showUpgrades() + { + return true; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitEnchanter.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitEnchanter.java index 1b38cfa92..62bc02f18 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitEnchanter.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitEnchanter.java @@ -1,5 +1,10 @@ package nautilus.game.arcade.game.games.quiver.kits; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilInv; @@ -13,22 +18,17 @@ import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.ProgressingKit; import nautilus.game.arcade.kit.perks.PerkArrowRebound; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - public class KitEnchanter extends ProgressingKit { private static final String[] DESCRIPTION = { "3 Kills, 1 Arrow.", "", - "Arrows bounce " + C.cGreen + "2" + C.cWhite + " times upon hitting your target" + "Arrows bounce " + C.cGreen + "once" + C.cWhite + " upon hitting your target" }; private static final Perk[] PERKS = { - new PerkArrowRebound(2, 1.2f) - }; + new PerkArrowRebound(1, 1.2F, 1) + }; private static final ItemStack IN_HAND = new ItemStack(Material.BOW); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitLeaper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitLeaper.java index f12ed6a8d..f3cae0351 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitLeaper.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitLeaper.java @@ -38,7 +38,6 @@ public class KitLeaper extends ProgressingKit public KitLeaper(ArcadeManager manager) { super(manager, "Jumper", "quiverjumper", KitAvailability.Free, DESCRIPTION, PERKS, EntityType.ZOMBIE, IN_HAND); - } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitNecromancer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitNecromancer.java new file mode 100644 index 000000000..01477dda2 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitNecromancer.java @@ -0,0 +1,139 @@ +package nautilus.game.arcade.game.games.quiver.kits; + +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilServer; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.quiver.Quiver; +import nautilus.game.arcade.game.games.quiver.QuiverPayload; +import nautilus.game.arcade.game.games.quiver.ultimates.UltimateNecromancer; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; +import nautilus.game.arcade.kit.perks.PerkLifestealArrows; + +public class KitNecromancer extends ProgressingKit +{ + private static final String[] DESCRIPTION = { + "Spooky scary skeletons", + "", + "Successful arrow hits restore " + C.cGreen + "2" + C.cWhite + " hearts.", + "", + C.cGreenB + "ULTIMATE", + "Summon " + C.cGreen + "4 Undead Minions" + C.cWhite + " that shoot at other players", + "Lasts for " + C.cGreen + "10" + C.cWhite + " seconds." + }; + + private static final String DOUBLE_JUMP = "Double Jump"; + private static final String ULTIMATE = "Ultimate"; + private static final String DURATION = "Duration"; + + private static final Perk[][] PERKS = { + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkLifestealArrows(8), + new UltimateNecromancer(10000, 4) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkLifestealArrows(8), + new UltimateNecromancer(10500, 4) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkLifestealArrows(8), + new UltimateNecromancer(11000, 4) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkLifestealArrows(8), + new UltimateNecromancer(11500, 4) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkLifestealArrows(8), + new UltimateNecromancer(12000, 4) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkLifestealArrows(8), + new UltimateNecromancer(12500, 4) + } + }; + + private static final String[][] UPGRADE_DETAILS = { + { + increase(ULTIMATE, DURATION, 10) + }, + { + increase(ULTIMATE, DURATION, 10) + }, + { + increase(ULTIMATE, DURATION, 10) + }, + { + increase(ULTIMATE, DURATION, 10) + }, + { + increase(ULTIMATE, DURATION, 10) + }, + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.BONE); + + private static final ItemStack[] PLAYER_ITEMS = { + new ItemBuilder(Material.IRON_AXE).setUnbreakable(true).build(), + new ItemBuilder(Material.BOW).setUnbreakable(true).build(), + }; + + public KitNecromancer(ArcadeManager manager) + { + super(manager, "Necromancer", "quivernecromancer", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND); + + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(PLAYER_ITEMS); + + if (Manager.GetGame().GetState() == GameState.Live) + { + player.getInventory().addItem(Quiver.SUPER_ARROW); + + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), () -> UtilInv.Update(player), 10); + } + } + + @Override + public void onSelected(UUID player) + { + super.onSelected(player); + + if (!Manager.GetGame().IsLive()) + { + return; + } + + QuiverPayload quiverPayload = (QuiverPayload) Manager.GetGame(); + + quiverPayload.resetUltimate(Bukkit.getPlayer(player), true); + } + + @Override + public boolean showUpgrades() + { + return true; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitNewNinja.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitNewNinja.java new file mode 100644 index 000000000..beb0db171 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitNewNinja.java @@ -0,0 +1,130 @@ +package nautilus.game.arcade.game.games.quiver.kits; + +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.quiver.QuiverPayload; +import nautilus.game.arcade.game.games.quiver.ultimates.UltimateNinja; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; +import nautilus.game.arcade.kit.perks.PerkDash; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; + +public class KitNewNinja extends ProgressingKit +{ + + private static final String[] DESCRIPTION = { + "Zip zap boing around the map!", + "You do not spawn with an arrow!", + "", + C.cYellow + "Right-click " + C.cGreen + "Sword" + C.cWhite + " to dash.", + "", + C.cGreenB + "ULTIMATE", + "Your " + C.cGreen + "Gold Sword" + C.cWhite + " changes into a " + C.cGreen + "Diamond Sword" + C.cWhite + ".", + "This new sword kills players in " + C.cRedB + "ONE" + C.cWhite + " hit!", + "Lasts for " + C.cGreen + "6" + C.cWhite + " seconds." + }; + + private static final String DOUBLE_JUMP = "Double Jump"; + private static final String ULTIMATE = "Ultimate"; + private static final String DURATION = "Duration"; + + private static final Perk[][] PERKS = { + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkDash(5000, 10, 8), + new UltimateNinja(6000) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkDash(5000, 10, 8), + new UltimateNinja(6500) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkDash(5000, 10, 8), + new UltimateNinja(7000) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkDash(5000, 10, 8), + new UltimateNinja(7500) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkDash(5000, 10, 8), + new UltimateNinja(8000) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkDash(5000, 10, 8), + new UltimateNinja(8500) + } + }; + + private static final String[][] UPGRADE_DETAILS = { + { + increase(ULTIMATE, DURATION, 12) + }, + { + increase(ULTIMATE, DURATION, 12) + }, + { + increase(ULTIMATE, DURATION, 12) + }, + { + increase(ULTIMATE, DURATION, 12) + }, + { + increase(ULTIMATE, DURATION, 12) + }, + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.GOLD_SWORD); + + private static final ItemStack[] PLAYER_ITEMS = { + new ItemBuilder(Material.GOLD_SWORD).setUnbreakable(true).build(), + new ItemBuilder(Material.BOW).setUnbreakable(true).build(), + }; + + public KitNewNinja(ArcadeManager manager) + { + super(manager, "Ninja", "quivernewninja", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(PLAYER_ITEMS); + } + + @Override + public void onSelected(UUID player) + { + super.onSelected(player); + + if (!Manager.GetGame().IsLive()) + { + return; + } + + QuiverPayload quiverPayload = (QuiverPayload) Manager.GetGame(); + + quiverPayload.resetUltimate(Bukkit.getPlayer(player), true); + } + + @Override + public boolean showUpgrades() + { + return true; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitPyromancer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitPyromancer.java new file mode 100644 index 000000000..56d2bfed1 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitPyromancer.java @@ -0,0 +1,142 @@ +package nautilus.game.arcade.game.games.quiver.kits; + +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilServer; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.quiver.Quiver; +import nautilus.game.arcade.game.games.quiver.QuiverPayload; +import nautilus.game.arcade.game.games.quiver.ultimates.UltimatePyromancer; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; +import nautilus.game.arcade.kit.perks.PerkFireArrows; + +public class KitPyromancer extends ProgressingKit +{ + private static final String[] DESCRIPTION = { + "Hot! Hot! Hot!", + "", + "When your arrows land, players within " + C.cGreen + "2" + C.cWhite + " blocks are set on", + "fire for " + C.cGreen + "3" + C.cWhite + " seconds.", + "", + C.cGreenB + "ULTIMATE", + "You begin to fire " + C.cGreen + "20" + C.cWhite + " arrows per second in all directions around you.", + "During this time you have " + C.cGreen + "75%" + C.cWhite + " reduced movement speed and are", + "unable to jump.", + "Lasts for " + C.cGreen + "5" + C.cWhite + " seconds" + }; + + private static final String DOUBLE_JUMP = "Double Jump"; + private static final String ULTIMATE = "Ultimate"; + private static final String DURATION = "Duration"; + + private static final Perk[][] PERKS = { + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkFireArrows(3, 60), + new UltimatePyromancer(5000) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkFireArrows(3, 60), + new UltimatePyromancer(5500) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkFireArrows(3, 60), + new UltimatePyromancer(6000) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkFireArrows(3, 60), + new UltimatePyromancer(6500) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkFireArrows(3, 60), + new UltimatePyromancer(7000) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkFireArrows(2, 60), + new UltimatePyromancer(7500) + } + }; + + private static final String[][] UPGRADE_DETAILS = { + { + increase(ULTIMATE, DURATION, 10) + }, + { + increase(ULTIMATE, DURATION, 10) + }, + { + increase(ULTIMATE, DURATION, 10) + }, + { + increase(ULTIMATE, DURATION, 10) + }, + { + increase(ULTIMATE, DURATION, 10) + }, + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.BLAZE_POWDER); + + private static final ItemStack[] PLAYER_ITEMS = { + new ItemBuilder(Material.IRON_AXE).setUnbreakable(true).build(), + new ItemBuilder(Material.BOW).setUnbreakable(true).build(), + }; + + public KitPyromancer(ArcadeManager manager) + { + super(manager, "Pyromancer", "quiverpyromancer", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND); + + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(PLAYER_ITEMS); + + if (Manager.GetGame().GetState() == GameState.Live) + { + player.getInventory().addItem(Quiver.SUPER_ARROW); + + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), () -> UtilInv.Update(player), 10); + } + } + + @Override + public void onSelected(UUID player) + { + super.onSelected(player); + + if (!Manager.GetGame().IsLive()) + { + return; + } + + QuiverPayload quiverPayload = (QuiverPayload) Manager.GetGame(); + + quiverPayload.resetUltimate(Bukkit.getPlayer(player), true); + } + + @Override + public boolean showUpgrades() + { + return true; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitSkyWarrior.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitSkyWarrior.java new file mode 100644 index 000000000..9486806f3 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitSkyWarrior.java @@ -0,0 +1,154 @@ + package nautilus.game.arcade.game.games.quiver.kits; + +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilServer; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.quiver.Quiver; +import nautilus.game.arcade.game.games.quiver.QuiverPayload; +import nautilus.game.arcade.game.games.quiver.ultimates.UltimateSkyWarrior; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; +import nautilus.game.arcade.kit.perks.PerkSpeed; + +public class KitSkyWarrior extends ProgressingKit +{ + + private static final String[] DESCRIPTION = { + "We\'ll see you in the sky.", + "", + "Gain permanent Speed I", + "", + C.cGreenB + "ULTIMATE", + "You fly up into the air and are given a launcher.", + "Clicking the launcher fires a Astral Arrow.", + "When it hits a block a pulse of energy is fired", + "damaging all players within " + C.cGreen + "5" + C.cWhite + " blocks", + "for " + C.cGreen + "10" + C.cWhite + " damage.", + "", + "Total of " + C.cRed + "3" + C.cWhite + " uses!", + "", + "Once all arrows are fired you teleport to a random", + "teammate dealing damage to all players within", + C.cGreen + "10" + C.cWhite + " blocks for " + C.cGreen + "5" + C.cWhite + " damage." + }; + + private static final String DOUBLE_JUMP = "Double Jump"; + private static final String ULTIMATE = "Ultimate"; + private static final String DAMAGE = "Damage"; + private static final String DAMAGE_TELEPORT = "Teleportation Damage"; + + private static final Perk[][] PERKS = { + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkSpeed(0), + new UltimateSkyWarrior(5, 10, 10, 5, 30) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkSpeed(0), + new UltimateSkyWarrior(5.5, 10, 11, 5, 30) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkSpeed(0), + new UltimateSkyWarrior(6, 10, 12, 5, 30) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkSpeed(0), + new UltimateSkyWarrior(6.5, 10, 13, 5, 30) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkSpeed(0), + new UltimateSkyWarrior(7, 10, 14, 5, 30) + }, + { + new PerkDoubleJump(DOUBLE_JUMP, 0.9, 0.9, true), + new PerkSpeed(0), + new UltimateSkyWarrior(7.5, 10, 15, 5, 30) + } + }; + + private static final String[][] UPGRADE_DETAILS = { + { + increase(ULTIMATE, DAMAGE, 10), + increase(ULTIMATE, DAMAGE_TELEPORT, 10), + }, + { + increase(ULTIMATE, DAMAGE, 10), + increase(ULTIMATE, DAMAGE_TELEPORT, 10), + }, + { + increase(ULTIMATE, DAMAGE, 10), + increase(ULTIMATE, DAMAGE_TELEPORT, 10), + }, + { + increase(ULTIMATE, DAMAGE, 10), + increase(ULTIMATE, DAMAGE_TELEPORT, 10), + }, + { + increase(ULTIMATE, DAMAGE, 10), + increase(ULTIMATE, DAMAGE_TELEPORT, 10), + }, + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.FEATHER); + + private static final ItemStack[] PLAYER_ITEMS = { + new ItemBuilder(Material.IRON_AXE).setUnbreakable(true).build(), + new ItemBuilder(Material.BOW).setUnbreakable(true).build(), + }; + + public KitSkyWarrior(ArcadeManager manager) + { + super(manager, "Sky Warrior", "quiverskywarrior", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADE_DETAILS, EntityType.ZOMBIE, IN_HAND); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(PLAYER_ITEMS); + + if (Manager.GetGame().GetState() == GameState.Live) + { + player.getInventory().addItem(Quiver.SUPER_ARROW); + + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), () -> UtilInv.Update(player), 10); + } + } + + @Override + public void onSelected(UUID player) + { + super.onSelected(player); + + if (!Manager.GetGame().IsLive()) + { + return; + } + + QuiverPayload quiverPayload = (QuiverPayload) Manager.GetGame(); + + quiverPayload.resetUltimate(Bukkit.getPlayer(player), true); + } + + @Override + public boolean showUpgrades() + { + return true; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitSlamShot.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitSlamShot.java index cb74f3079..94adb1832 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitSlamShot.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitSlamShot.java @@ -25,9 +25,9 @@ public class KitSlamShot extends ProgressingKit }; private static final Perk[] PERKS = { - new PerkSeismicSlamOITQ() + new PerkSeismicSlamOITQ() }; - + private static final ItemStack IN_HAND = new ItemStack(Material.DIAMOND_SPADE); private static final ItemStack[] PLAYER_ITEMS = { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/Ultimate.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/Ultimate.java new file mode 100644 index 000000000..557795266 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/Ultimate.java @@ -0,0 +1,126 @@ +package nautilus.game.arcade.game.games.quiver.ultimates; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.ChatColor; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.quiver.Quiver; +import nautilus.game.arcade.game.games.quiver.kits.KitNewNinja; +import nautilus.game.arcade.kit.Perk; + +public abstract class Ultimate extends Perk +{ + + private Map _lastUltimate = new HashMap<>(); + + public Ultimate(String name, String[] perkDesc) + { + super(name, perkDesc); + } + + public void activate(Player player) + { + _lastUltimate.put(player.getUniqueId(), System.currentTimeMillis()); + + if (!(Manager.GetGame().GetKit(player) instanceof KitNewNinja)) + { + player.getInventory().addItem(Quiver.SUPER_ARROW); + } + + ChatColor teamColor = Manager.GetGame().GetTeam(player).GetColor(); + + UtilServer.broadcast(teamColor + C.Bold + player.getName() + C.cWhiteB + " activated their " + teamColor + C.Bold + GetName() + C.cWhiteB + "."); + + for (Player other : UtilServer.getPlayers()) + { + other.playSound(other.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 0); + } + } + + public void cancel(Player player) + { + _lastUltimate.remove(player.getUniqueId()); + + player.playSound(player.getLocation(), Sound.BLAZE_DEATH, 1, 0); + } + + public boolean isUsable(Player player) + { + return true; + } + + public abstract double getChargeIncreasePerSecond(); + + public abstract long getLength(); + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST || getLength() == 0) + { + return; + } + + for (Player player : UtilServer.getPlayers()) + { + if (!_lastUltimate.containsKey(player.getUniqueId())) + { + continue; + } + + if (UtilTime.elapsed(_lastUltimate.get(player.getUniqueId()), getLength())) + { + cancel(player); + } + } + } + + @EventHandler + public void onCombatDeath(CombatDeathEvent event) + { + if (!(event.GetEvent().getEntity() instanceof Player)) + { + return; + } + + Player player = (Player) event.GetEvent().getEntity(); + + if (!_lastUltimate.containsKey(player.getUniqueId())) + { + return; + } + + cancel(player); + } + + @EventHandler + public void onGameStateChange(GameStateChangeEvent event) + { + if (event.GetState() != GameState.End) + { + for (UUID uuid : _lastUltimate.keySet()) + { + cancel(UtilPlayer.searchExact(uuid)); + } + } + } + + public Map getLastUltimate() + { + return _lastUltimate; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateBarrage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateBarrage.java new file mode 100644 index 000000000..6fa5f5e22 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateBarrage.java @@ -0,0 +1,63 @@ +package nautilus.game.arcade.game.games.quiver.ultimates; + +import org.bukkit.Sound; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.util.Vector; + +public class UltimateBarrage extends Ultimate +{ + + private static final double CHARGE_PER_SECOND = 0.8; + private static final float VELOCITY_MULTIPLIER = 3; + + private int _arrows; + + public UltimateBarrage(int arrows) + { + super("Arrow Barrage", new String[] {}); + + _arrows = arrows; + } + + @EventHandler + public void onEntityShootBow(EntityShootBowEvent event) + { + if (event.isCancelled() || !(event.getEntity() instanceof Player)) + { + return; + } + + Player player = (Player) event.getEntity(); + + if (getLastUltimate().containsKey(player.getUniqueId())) + { + for (int i = 0; i < _arrows; i++) + { + Vector random = new Vector((Math.random() - 0.5) / 3, (Math.random() - 0.5) / 3, (Math.random() - 0.5) / 3); + Arrow arrow = player.launchProjectile(Arrow.class); + + arrow.setCritical(true); + arrow.setVelocity(player.getLocation().getDirection().add(random).multiply(VELOCITY_MULTIPLIER)); + player.getWorld().playSound(player.getLocation(), Sound.SHOOT_ARROW, 1F, 1F); + } + + cancel(player); + } + } + + @Override + public double getChargeIncreasePerSecond() + { + return CHARGE_PER_SECOND; + } + + @Override + public long getLength() + { + return 0; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateBeserker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateBeserker.java new file mode 100644 index 000000000..3bf418769 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateBeserker.java @@ -0,0 +1,95 @@ +package nautilus.game.arcade.game.games.quiver.ultimates; + +import java.util.Iterator; + +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.itemstack.ItemBuilder; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import mineplex.minecraft.game.core.damage.DamageChange; + +public class UltimateBeserker extends Ultimate +{ + + private static final double CHARGE_PER_SECOND = 0.4; + + private long _length; + + public UltimateBeserker(long length) + { + super("Berserker Shield", new String[] {}); + + _length = length; + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onCustomDamage(CustomDamageEvent event) + { + if (event.isCancelled()) + { + return; + } + + if (event.GetDamageePlayer() == null) + { + return; + } + + if (!getLastUltimate().containsKey(event.GetDamageePlayer().getUniqueId())) + { + return; + } + + Iterator iterator = event.GetDamageMod().iterator(); + + while (iterator.hasNext()) + { + DamageChange damageChange = iterator.next(); + + if (damageChange.GetReason().equals("Instagib")) + { + iterator.remove(); + } + } + } + + @Override + public void activate(Player player) + { + super.activate(player); + + player.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE)); + player.getInventory().setLeggings(new ItemStack(Material.IRON_LEGGINGS)); + player.getInventory().setBoots(new ItemStack(Material.IRON_BOOTS)); + } + + @Override + public void cancel(Player player) + { + super.cancel(player); + + Color color = Manager.GetGame().GetTeam(player).GetColorBase(); + + player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(color).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(color).build()); + player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(color).build()); + } + + @Override + public double getChargeIncreasePerSecond() + { + return CHARGE_PER_SECOND; + } + + @Override + public long getLength() + { + return _length; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateNecromancer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateNecromancer.java new file mode 100644 index 000000000..8690c588e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateNecromancer.java @@ -0,0 +1,176 @@ +package nautilus.game.arcade.game.games.quiver.ultimates; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.UUID; + +import org.bukkit.Material; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Creature; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.inventory.ItemStack; + +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.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.Game; + +public class UltimateNecromancer extends Ultimate +{ + + private static final double CHARGE_PER_SECOND = 0.4; + + private long _length; + private int _skeletons; + + private Map> _entities = new HashMap<>(); + + public UltimateNecromancer(long length, int skeletons) + { + super("Summon Undead", new String[] {}); + + _length = length; + _skeletons = skeletons; + } + + @EventHandler + public void onEntityDamage(EntityDamageEvent event) + { + for (Set entityList : _entities.values()) + { + for (LivingEntity livingEntity : entityList) + { + if (event.getEntity().equals(livingEntity)) + { + event.setCancelled(true); + event.getEntity().setFireTicks(0); + } + } + } + } + + @EventHandler + public void onEntityTarget(EntityTargetEvent event) + { + for (Set livingEntities : _entities.values()) + { + if (event.getTarget() instanceof Player && livingEntities.contains(event.getEntity())) + { + Game game = Manager.GetGame(); + Player source = getPlayerFromEntity(event.getEntity()); + Player targetPlayer = (Player) event.getTarget(); + + if (game.GetTeam(targetPlayer).equals(game.GetTeam(source))) + { + event.setCancelled(true); + } + } + } + } + + @EventHandler + public void onCustomDamage(CustomDamageEvent event) + { + if (event.GetProjectile() != null) + { + if (event.GetProjectile() instanceof Arrow) + { + LivingEntity livingEntity = event.GetDamagerEntity(true); + + for (UUID uuid : _entities.keySet()) + { + Set entities = _entities.get(uuid); + Player player = UtilPlayer.searchExact(uuid); + + for (LivingEntity livingEntity2 : entities) + { + if (livingEntity.equals(livingEntity2)) + { + event.SetDamager(player); + } + } + } + } + } + } + + @Override + public void activate(Player player) + { + super.activate(player); + + Set entities = new HashSet<>(); + + Manager.GetGame().CreatureAllowOverride = true; + + for (int i = 0; i < _skeletons; i++) + { + LivingEntity livingEntity = player.getWorld().spawn(player.getLocation().add((Math.random() - 0.5) * 3, 0, (Math.random() - 0.5) * 3), Skeleton.class); + + livingEntity.getEquipment().setItemInHand(new ItemStack(Material.BOW)); + entities.add(livingEntity); + UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, livingEntity.getEyeLocation(), 1F, 1F, 1F, 0.1F, 20, ViewDist.NORMAL); + + ((Creature) livingEntity).setTarget(UtilPlayer.getClosest(livingEntity.getLocation(), Manager.GetGame().GetTeam(player).GetPlayers(true))); + } + + Manager.GetGame().CreatureAllowOverride = false; + + _entities.put(player.getUniqueId(), entities); + } + + @Override + public void cancel(Player player) + { + super.cancel(player); + + for (LivingEntity entity : _entities.get(player.getUniqueId())) + { + entity.getEquipment().clear(); + entity.remove(); + } + + _entities.remove(player.getUniqueId()); + } + + public Player getPlayerFromEntity(Entity entity) + { + for (UUID uuid : _entities.keySet()) + { + Set livingEntities = _entities.get(uuid); + + for (LivingEntity livingEntity : livingEntities) + { + if (livingEntity.equals(livingEntity)) + { + return UtilPlayer.searchExact(uuid); + } + } + } + + return null; + } + + @Override + public double getChargeIncreasePerSecond() + { + return CHARGE_PER_SECOND; + } + + @Override + public long getLength() + { + return _length; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateNinja.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateNinja.java new file mode 100644 index 000000000..e4f3d84ce --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateNinja.java @@ -0,0 +1,76 @@ +package nautilus.game.arcade.game.games.quiver.ultimates; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +public class UltimateNinja extends Ultimate +{ + + private static final double CHARGE_PER_SECOND = 0.4; + private static final int SPEED_AMPLIFIER = 1; + + private long _length; + + public UltimateNinja(long length) + { + super("Ancient Blade", new String[] {}); + + _length = length; + } + + @EventHandler + public void onCustomDamage(CustomDamageEvent event) + { + if (event.GetCause() != DamageCause.ENTITY_ATTACK) + { + return; + } + + if (getLastUltimate().containsKey(event.GetDamagerPlayer(false).getUniqueId()) && event.GetDamagerPlayer(false).getItemInHand().getType() == Material.DIAMOND_SWORD) + { + event.AddMod(event.GetDamagerPlayer(false).getName(), GetName(), 9001, true); + } + } + + @Override + public void activate(Player player) + { + super.activate(player); + + player.getInventory().setItem(0, new ItemStack(Material.DIAMOND_SWORD)); + player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, (int) ((_length / 1000) * 20), SPEED_AMPLIFIER)); + + UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, player.getEyeLocation(), 0, 0, 0, 1F, 100, ViewDist.NORMAL); + } + + @Override + public void cancel(Player player) + { + super.cancel(player); + + player.getInventory().setItem(0, new ItemStack(Material.GOLD_SWORD)); + } + + @Override + public double getChargeIncreasePerSecond() + { + return CHARGE_PER_SECOND; + } + + @Override + public long getLength() + { + return _length; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimatePyromancer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimatePyromancer.java new file mode 100644 index 000000000..0a1cb472c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimatePyromancer.java @@ -0,0 +1,80 @@ +package nautilus.game.arcade.game.games.quiver.ultimates; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; + +public class UltimatePyromancer extends Ultimate +{ + + private static final double CHARGE_PER_SECOND = 0.4; + + private long _length; + + private Map _tasks = new HashMap<>(); + + public UltimatePyromancer(long length) + { + super("Fire Blossom", new String[] {}); + + _length = length; + } + + @Override + public void activate(Player player) + { + super.activate(player); + + player.setWalkSpeed(0.05F); + player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, (int) ((getLength() / 1000) * 20), -10)); + + _tasks.put(player.getUniqueId(), (new BukkitRunnable() + { + + @Override + public void run() + { + UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, player.getLocation().add(0, 0.5, 0), 2F, 0, 2F, 0.01F, 5, ViewDist.LONG); + UtilParticle.PlayParticleToAll(ParticleType.FLAME, player.getLocation().add(0, 0.5, 0), 2F, 0, 2F, 0.01F, 5, ViewDist.LONG); + + Arrow arrow = player.launchProjectile(Arrow.class); + arrow.setCritical(true); + arrow.setVelocity(new Vector((Math.random() - 0.5) * 9, 0.1, (Math.random() - 0.5) * 9)); + } + }.runTaskTimer(Manager.getPlugin(), 0, 1)).getTaskId()); + } + + @Override + public void cancel(Player player) + { + super.cancel(player); + + player.setWalkSpeed(0.2F); + Bukkit.getScheduler().cancelTask(_tasks.get(player.getUniqueId())); + } + + @Override + public double getChargeIncreasePerSecond() + { + return CHARGE_PER_SECOND; + } + + @Override + public long getLength() + { + return _length; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateSkyWarrior.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateSkyWarrior.java new file mode 100644 index 000000000..f2832b950 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/ultimates/UltimateSkyWarrior.java @@ -0,0 +1,342 @@ +package nautilus.game.arcade.game.games.quiver.ultimates; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import com.google.common.collect.Sets; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilInv; +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.UtilTime; +import mineplex.core.common.util.particles.effects.LineParticle; +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.game.Game; +import nautilus.game.arcade.game.games.quiver.Quiver; + +public class UltimateSkyWarrior extends Ultimate +{ + + private static final double CHARGE_PER_SECOND = 0.4; + private static final long LAUNCHER_FIRE_DELAY = 500; + private static final long LAUNCHER_MAX_TIME = 15000; + private static final int Y_INCREASE = 10; + + private double _damageTeleport; + private double _radiusTeleport; + private double _damageLauncher; + private double _radiusLauncher; + private int _rangeLauncher; + + private List _data = new ArrayList<>(); + + public UltimateSkyWarrior(double damageTeleport, double radiusTeleport, double damageLauncher, double radiusLauncher, int rangeLauncher) + { + super("Bombardment", new String[] {}); + + _damageTeleport = damageTeleport; + _radiusTeleport = radiusTeleport; + _damageLauncher = damageLauncher; + _radiusLauncher = radiusLauncher; + _rangeLauncher = rangeLauncher; + } + + @Override + public void activate(Player player) + { + super.activate(player); + + Location playerLocation = player.getLocation(); + // This is to stop the players getting killed by the border if they were + // teleported above it. + Location toTeleport = new Location(player.getWorld(), playerLocation.getX(), Math.min(Manager.GetGame().WorldData.MaxY - 3, playerLocation.getY() + Y_INCREASE), playerLocation.getZ()); + + toTeleport.setYaw(playerLocation.getYaw()); + toTeleport.setPitch(playerLocation.getPitch()); + + Block block = toTeleport.getBlock().getRelative(BlockFace.DOWN); + + block.setType(Material.BARRIER); + player.setWalkSpeed(0); + player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, -10)); + player.teleport(toTeleport); + + _data.add(new SkyWarriorData(player, block, 3, UtilInv.getAmount(player, Material.ARROW), System.currentTimeMillis())); + + player.getInventory().clear(); + + ItemStack itemStack = new ItemBuilder(Material.IRON_HOE).setTitle(C.cGreenB + GetName() + C.cDGreenB + " Click To Fire!").build(); + + for (int i = 0; i < 9; i++) + { + player.getInventory().addItem(itemStack); + } + + Game game = Manager.GetGame(); + + UtilFirework.playFirework(playerLocation, Type.BALL, game.GetTeam(player).GetColorBase(), false, false); + UtilFirework.playFirework(toTeleport, Type.BALL, game.GetTeam(player).GetColorBase(), false, false); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() == UpdateType.TICK) + { + for (SkyWarriorData data : _data) + { + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, data.getPlayer().getLocation().subtract(0, 0.5, 0), 0.5F, 0.25F, 0.5F, 0.01F, 6, ViewDist.MAX); + } + } + else if (event.getType() == UpdateType.FAST) + { + for (SkyWarriorData data : _data) + { + if (UtilTime.elapsed(data.getStartTimeStamp(), LAUNCHER_MAX_TIME)) + { + cancel(data.getPlayer()); + } + } + } + } + + @EventHandler + public void onPlayerInteract(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + SkyWarriorData data = getData(player); + + if (data == null) + { + return; + } + + if (player.getItemInHand().getType() != Material.IRON_HOE) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + + if (!Recharge.Instance.use(player, GetName(), LAUNCHER_FIRE_DELAY, true, false)) + { + return; + } + + player.getWorld().playSound(player.getLocation(), Sound.FIREWORK_BLAST, 5, 1); + + LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.5, _rangeLauncher, Sets.newHashSet(Material.BARRIER), ParticleType.FIREWORKS_SPARK, UtilServer.getPlayers()); + + while (!lineParticle.update()) + { + } + + Location location = lineParticle.getDestination(); + + // Damage Players + for (Player other : UtilPlayer.getNearby(location, _radiusLauncher)) + { + Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, _damageLauncher, true, true, false, player.getName(), GetName()); + } + + UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, location, 0, 0, 0, 1F, 1, ViewDist.LONG); + + data.setShotsLeft(data.getShotsLeft() - 1); + + if (data.getShotsLeft() == 0) + { + cancel(player); + } + } + + @EventHandler + public void onPlayerMove(PlayerMoveEvent event) + { + if (!getLastUltimate().containsKey(event.getPlayer().getUniqueId())) + { + return; + } + + Location from = event.getFrom(); + Location to = event.getTo(); + + if (from.getX() == to.getX() && from.getZ() == to.getZ()) + { + return; + } + + event.setTo(from); + } + + @Override + public void cancel(Player player) + { + super.cancel(player); + + player.getInventory().clear(); + Kit.GiveItems(player); + + player.setWalkSpeed(0.2F); + player.removePotionEffect(PotionEffectType.JUMP); + + SkyWarriorData data = getData(player); + Game game = Manager.GetGame(); + + data.getBlock().setType(Material.AIR); + + for (int i = 0; i < data.getPreviousArrows(); i++) + { + player.getInventory().addItem(Quiver.SUPER_ARROW); + } + + boolean found = false; + + for (Player other : game.GetPlayers(true)) + { + if (UtilPlayer.isSpectator(other) || player.equals(other)) + { + continue; + } + + if (game.GetTeam(player).equals(game.GetTeam(other))) + { + player.sendMessage(F.main("Game", "You were teleported to " + F.elem(other.getName()) + ".")); + player.teleport(other); + other.getWorld().strikeLightningEffect(other.getLocation()); + UtilFirework.playFirework(other.getLocation(), Type.STAR, game.GetTeam(player).GetColorBase(), false, false); + + for (Player toDamage : UtilPlayer.getNearby(other.getEyeLocation(), _radiusTeleport)) + { + Manager.GetDamage().NewDamageEvent(toDamage, player, null, DamageCause.CUSTOM, _damageTeleport, false, true, false, player.getName(), GetName() + " Teleportation"); + } + + found = true; + break; + } + } + + if (!found) + { + player.sendMessage(F.main("Game", "A player could not be found!")); + } + + _data.remove(data); + } + + @Override + public boolean isUsable(Player player) + { + for (int i = 2; i <= Y_INCREASE; i++) + { + if (player.getLocation().add(0, i, 0).getBlock().getType() != Material.AIR) + { + player.sendMessage(F.main("Game", "You do not have enough room to use this!"));; + return false; + } + } + + return true; + } + + @Override + public double getChargeIncreasePerSecond() + { + return CHARGE_PER_SECOND; + } + + @Override + public long getLength() + { + return 0; + } + + private SkyWarriorData getData(Player player) + { + for (SkyWarriorData data : _data) + { + if (data.getPlayer().equals(player)) + { + return data; + } + } + + return null; + } + + private final class SkyWarriorData + { + + private Player _player; + private Block _block; + private int _shotsLeft; + private int _previousArrows; + private long _startTimeStamp; + + public SkyWarriorData(Player player, Block block, int shots, int previousArrows, long startTimeStamp) + { + _player = player; + _block = block; + _shotsLeft = shots; + _previousArrows = previousArrows; + _startTimeStamp = startTimeStamp; + } + + public void setShotsLeft(int slotsLeft) + { + _shotsLeft = slotsLeft; + } + + public Player getPlayer() + { + return _player; + } + + public Block getBlock() + { + return _block; + } + + public int getShotsLeft() + { + return _shotsLeft; + } + + public int getPreviousArrows() + { + return _previousArrows; + } + + public long getStartTimeStamp() + { + return _startTimeStamp; + } + + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java index 001e802bb..b3ae96fc7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java @@ -301,16 +301,18 @@ public abstract class Skywars extends Game private void parseCreateConnectorChests() { - for (int i = 0; i < 4 && !WorldData.GetDataLocs("GRAY").isEmpty(); i++) + Iterator iterator = WorldData.GetDataLocs("GRAY").iterator(); + + while (iterator.hasNext()) { - Location loc = UtilAlg.Random(WorldData.GetDataLocs("GRAY")); - - WorldData.GetDataLocs("GRAY").remove(loc); - + Location loc = iterator.next(); + loc.getBlock().setTypeIdAndData(Material.CHEST.getId(), (byte) UtilMath.r(4), true); _connectorChests.add(loc.getBlock()); _worldBlocks.add(loc.getBlock()); + + iterator.remove(); } } @@ -392,15 +394,15 @@ public abstract class Skywars extends Game private void setupBookEnchantments() { - _commonBookEnchantments.put(Enchantment.DAMAGE_ALL, 3); + _commonBookEnchantments.put(Enchantment.DAMAGE_ALL, 1); _commonBookEnchantments.put(Enchantment.FIRE_ASPECT, 1); - _commonBookEnchantments.put(Enchantment.ARROW_DAMAGE, 3); - _commonBookEnchantments.put(Enchantment.PROTECTION_ENVIRONMENTAL, 2); + _commonBookEnchantments.put(Enchantment.ARROW_DAMAGE, 1); + _commonBookEnchantments.put(Enchantment.PROTECTION_ENVIRONMENTAL, 1); - _rareBookEnchantments.put(Enchantment.DAMAGE_ALL, 4); - _rareBookEnchantments.put(Enchantment.PROTECTION_ENVIRONMENTAL, 3); + _rareBookEnchantments.put(Enchantment.DAMAGE_ALL, 2); + _rareBookEnchantments.put(Enchantment.PROTECTION_ENVIRONMENTAL, 2); + _rareBookEnchantments.put(Enchantment.ARROW_DAMAGE, 2); _rareBookEnchantments.put(Enchantment.ARROW_FIRE, 1); - //_rareBookEnchantments.put(Enchantment.FIRE_ASPECT, 2); _rareBookEnchantments.put(Enchantment.ARROW_KNOCKBACK, 1); _rareBookEnchantments.put(Enchantment.KNOCKBACK, 2); _rareBookEnchantments.put(Enchantment.THORNS, 1); @@ -1156,28 +1158,31 @@ public abstract class Skywars extends Game chest.getBlockInventory().setItem(getIndex(used), _middleBlock.getLoot()); // Books - ItemStack itemStack = _middleBooks.getLoot(); - EnchantmentStorageMeta meta = (EnchantmentStorageMeta) itemStack.getItemMeta(); - Enchantment enchantment = null; - - for (Enchantment cur : meta.getStoredEnchants().keySet()) + for (int i = 0; i < UtilMath.r(2); i++) { - meta.removeStoredEnchant(cur); - } + ItemStack itemStack = _middleBooks.getLoot(); + EnchantmentStorageMeta meta = (EnchantmentStorageMeta) itemStack.getItemMeta(); + Enchantment enchantment = null; - if (UtilMath.r(4) == 0) - { - enchantment = UtilAlg.Random(_rareBookEnchantments.keySet()); - meta.addStoredEnchant(enchantment, _rareBookEnchantments.get(enchantment), true); - } - else - { - enchantment = UtilAlg.Random(_commonBookEnchantments.keySet()); - meta.addStoredEnchant(enchantment, _commonBookEnchantments.get(enchantment), true); - } + for (Enchantment cur : meta.getStoredEnchants().keySet()) + { + meta.removeStoredEnchant(cur); + } - itemStack.setItemMeta(meta); - chest.getBlockInventory().setItem(getIndex(used), itemStack); + if (UtilMath.r(4) == 0) + { + enchantment = UtilAlg.Random(_rareBookEnchantments.keySet()); + meta.addStoredEnchant(enchantment, _rareBookEnchantments.get(enchantment), true); + } + else + { + enchantment = UtilAlg.Random(_commonBookEnchantments.keySet()); + meta.addStoredEnchant(enchantment, _commonBookEnchantments.get(enchantment), true); + } + + itemStack.setItemMeta(meta); + chest.getBlockInventory().setItem(getIndex(used), itemStack); + } // Misc chest.getBlockInventory().setItem(getIndex(used), _middleMisc.getLoot()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitFire.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitFire.java index b078a8252..06360a85a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitFire.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitFire.java @@ -22,9 +22,9 @@ public class KitFire extends ProgressingKit "Start with " + C.cGreen + "Wood Sword" + C.cGray + " and " + C.cGreen + "Blaze Rod", "", C.cYellow + "Right Click" + C.cWhite + " with Blaze Rod to use " + C.cGreen + "Fire Burst", - "Sends out a pulse of fire that deals " + C.cGreen + 3 + C.cWhite + " damage to", + "Sends out a pulse of fire that deals " + C.cGreen + 5 + C.cWhite + " damage to", "all players within " + C.cGreen + 4 + C.cWhite + " blocks.", - "Cooldown " + C.cGreen + UtilTime.convertString(45000, 0, TimeUnit.SECONDS) + C.cWhite + "." + "Cooldown " + C.cGreen + UtilTime.convertString(40000, 0, TimeUnit.SECONDS) + C.cWhite + "." }; private static final String FIRE_BURST = "Fire Burst"; @@ -32,22 +32,22 @@ public class KitFire extends ProgressingKit private static final Perk[][] PERKS = { { - new PerkFireBurst(45000, 4, 3) + new PerkFireBurst(40000, 4, 5) }, { - new PerkFireBurst(44000, 4, 3) + new PerkFireBurst(39000, 4, 5) }, { - new PerkFireBurst(43000, 4, 3) + new PerkFireBurst(38000, 4, 5) }, { - new PerkFireBurst(42000, 4, 4) + new PerkFireBurst(37000, 4, 6) }, { - new PerkFireBurst(41000, 4, 4) + new PerkFireBurst(36000, 4, 6) }, { - new PerkFireBurst(40000, 4, 4) + new PerkFireBurst(35000, 4, 6) }, }; @@ -61,7 +61,7 @@ public class KitFire extends ProgressingKit }, { reduceCooldown(FIRE_BURST, 1), - increase(FIRE_BURST, "Range", 20) + increase(FIRE_BURST, "Damage", 25) }, { reduceCooldown(FIRE_BURST, 1) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMetal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMetal.java index 1c6e43125..36fdd74c3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMetal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/kits/KitMetal.java @@ -31,7 +31,7 @@ public class KitMetal extends ProgressingKit "Cooldown " + C.cGreen + UtilTime.convertString(15000, 0, TimeUnit.SECONDS) + C.cWhite + ".", "", "For each piece of metal armor you wear you gain", - "a level of " + C.cGreen + "Damage Resistance" + C.cWhite + ".", + "a " + C.cGreen + 7.5 + C.cWhite + "% damage resistance.", }; private static final String MAGNET = "Magnet"; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/VersionModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/VersionModule.java new file mode 100644 index 000000000..e1969552a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/VersionModule.java @@ -0,0 +1,57 @@ +package nautilus.game.arcade.game.modules; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerJoinEvent; + +import mineplex.core.common.MinecraftVersion; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; + +/** + * This module functions as a checkpoint for any client connecting a game + * server. Making sure they have the minimum client version for your game. + * + * @see MinecraftVersion + */ +public class VersionModule extends Module +{ + + private MinecraftVersion _minecraftVersion; + private String _kickMessage; + + public VersionModule(MinecraftVersion minecraftVersion) + { + this(minecraftVersion, "You have an outdated client for this game!"); + } + + public VersionModule(MinecraftVersion minecraftVersion, String kickMessage) + { + _minecraftVersion = minecraftVersion; + _kickMessage = kickMessage; + + for (Player player : UtilServer.getPlayers()) + { + if (!hasVersion(player)) + { + player.kickPlayer(kickMessage); + } + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onPlayerJoin(PlayerJoinEvent event) + { + if (!hasVersion(event.getPlayer())) + { + event.getPlayer().kickPlayer(_kickMessage); + } + } + + private boolean hasVersion(Player player) + { + return UtilPlayer.getVersion(player) == _minecraftVersion; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Perk.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Perk.java index 9d637c716..51c9f2959 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Perk.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Perk.java @@ -30,6 +30,11 @@ public abstract class Perk implements Listener public boolean hasPerk(Player player) { + if (!Manager.GetGame().IsLive()) + { + return false; + } + if (!(Kit instanceof ProgressingKit)) { return Kit.HasKit(player); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkArrowRebound.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkArrowRebound.java index 6ae4c5f1f..d1716971c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkArrowRebound.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkArrowRebound.java @@ -24,8 +24,9 @@ public class PerkArrowRebound extends Perk private int _max = 0; private float _maxPower = 1f; + private float _maxDistance; - public PerkArrowRebound(int max, float maxPower) + public PerkArrowRebound(int max, float maxPower, float maxDistance) { super("Chain Arrows", new String[] { @@ -35,6 +36,7 @@ public class PerkArrowRebound extends Perk _max = max; _maxPower = maxPower; + _maxDistance = maxDistance; } @EventHandler @@ -65,8 +67,8 @@ public class PerkArrowRebound extends Perk Player hit = UtilPlayer.getClosest(arrowLoc, data.Ignore); if (hit == null) return; - if (UtilMath.offset(hit.getLocation(), arrowLoc) > 1 && - UtilMath.offset(hit.getEyeLocation(), arrowLoc) > 1) + if (UtilMath.offset(hit.getLocation(), arrowLoc) > _maxDistance && + UtilMath.offset(hit.getEyeLocation(), arrowLoc) > _maxDistance) return; data.Ignore.add(hit); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDash.java new file mode 100644 index 000000000..b54c5ab1d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDash.java @@ -0,0 +1,129 @@ +package nautilus.game.arcade.kit.perks; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; + +import com.google.common.collect.Sets; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.particles.effects.LineParticle; +import mineplex.core.recharge.Recharge; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.kit.Perk; + +public class PerkDash extends Perk +{ + + private static final double DAMAGE_RADIUS = 2.5; + + private long _cooldown; + private double _damage; + private double _distance; + + public PerkDash(long cooldown, double damage, double distance) + { + super("Dash", new String[] {}); + + _cooldown = cooldown; + _damage = damage; + _distance = distance; + } + + @EventHandler + public void onPlayerInteract(PlayerInteractEvent event) + { + if (event.isCancelled()) + { + return; + } + + if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + { + return; + } + + Player player = event.getPlayer(); + + if (player.getItemInHand() == null) + { + return; + } + + if (!UtilItem.isSword(player.getItemInHand())) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + + if (!Recharge.Instance.use(player, GetName(), _cooldown, true, true)) + { + return; + } + + LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.8, _distance, Sets.newHashSet(Material.RAILS), ParticleType.FIREWORKS_SPARK, + UtilServer.getPlayers()); + Set hitPlayers = new HashSet<>(); + + while (!lineParticle.update()) + { + for (Player other : UtilPlayer.getNearby(lineParticle.getLastLocation(), DAMAGE_RADIUS)) + { + if (hitPlayers.contains(other.getUniqueId()) || player.equals(other)) + { + continue; + } + + if (Manager.GetGame() instanceof TeamGame) + { + Game game = Manager.GetGame(); + + if (game.GetTeam(player).equals(game.GetTeam(other))) + { + continue; + } + } + + hitPlayers.add(other.getUniqueId()); + Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, _damage, true, true, false, player.getName(), GetName()); + player.sendMessage(F.main("Game", "You hit " + F.elem(other.getName()) + " with " + F.skill(GetName()) + ".")); + } + } + + Game game = Manager.GetGame(); + Location location = lineParticle.getDestination(); + + UtilFirework.playFirework(player.getEyeLocation(), Type.BALL, game.GetTeam(player).GetColorBase(), false, false); + + player.playSound(player.getLocation(), Sound.SHOOT_ARROW, 1, 1); + player.teleport(location.add(0, 0.5, 0)); + player.playSound(player.getLocation(), Sound.SHOOT_ARROW, 1, 1); + + UtilFirework.playFirework(player.getEyeLocation(), Type.BALL, game.GetTeam(player).GetColorBase(), false, false); + + player.setFallDistance(0); + + player.sendMessage(F.main("Game", "You used " + F.skill(GetName()) + ".")); + + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDirtCannon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDirtCannon.java index a010dd5f4..243d29eea 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDirtCannon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDirtCannon.java @@ -25,17 +25,20 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.games.skywars.TeamSkywars; import nautilus.game.arcade.kit.Perk; public class PerkDirtCannon extends Perk implements IThrown { private static final int GIVE_DELAY = 20000; - + private static final int MAX_DIRT = 4; + private static final long COOLDOWN = 500; + private static final ItemStack DIRT_ITEM = new ItemBuilder(Material.DIRT).setTitle(C.cGreen + "Throwable Dirt").setGlow(true).build(); private long _lastDirt; @@ -74,6 +77,11 @@ public class PerkDirtCannon extends Perk implements IThrown return; } + if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true)) + { + return; + } + int amount = player.getInventory().getItemInHand().getAmount() - 1; if (amount == 0) @@ -82,9 +90,9 @@ public class PerkDirtCannon extends Perk implements IThrown } else { - player.getItemInHand().setAmount(amount); + player.getItemInHand().setAmount(Math.min(MAX_DIRT - 1, amount)); } - + @SuppressWarnings("deprecation") FallingBlock fallingBlock = player.getWorld().spawnFallingBlock(player.getEyeLocation().add(player.getLocation().getDirection()), Material.DIRT, (byte) 0); fallingBlock.setDropItem(false); @@ -104,7 +112,7 @@ public class PerkDirtCannon extends Perk implements IThrown { for (Player player : Manager.GetGame().GetPlayers(true)) { - if (!hasPerk(player) || UtilInv.contains(player, "Throwable", Material.DIRT, (byte) 0, 4)) + if (!hasPerk(player) || UtilInv.contains(player, "Throwable", Material.DIRT, (byte) 0, MAX_DIRT)) { continue; } @@ -143,6 +151,11 @@ public class PerkDirtCannon extends Perk implements IThrown @EventHandler public void onPlayerDropItem(PlayerDropItemEvent event) { + if (!hasPerk(event.getPlayer())) + { + return; + } + if (DIRT_ITEM.isSimilar(event.getItemDrop().getItemStack())) { event.getPlayer().sendMessage(F.main("Game", "You cannot drop this item.")); @@ -178,16 +191,11 @@ public class PerkDirtCannon extends Perk implements IThrown return; } - if (Manager.GetGame() instanceof TeamGame && target instanceof Player && data.getThrower() instanceof Player) + if (Manager.GetGame() instanceof TeamSkywars && target instanceof Player && data.getThrower() instanceof Player) { Game game = Manager.GetGame(); - if (!game.IsAlive(target)) - { - return; - } - - if (game.GetTeam((Player) target).equals(game.GetTeam((Player) data.getThrower()))) + if (game.GetTeam((Player) target).equals(game.GetTeam((Player) data.getThrower())) || !game.IsAlive(target)) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFireArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFireArrows.java new file mode 100644 index 000000000..891a6833f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFireArrows.java @@ -0,0 +1,49 @@ +package nautilus.game.arcade.kit.perks; + +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.ProjectileHitEvent; + +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.kit.Perk; + +public class PerkFireArrows extends Perk +{ + + private double _distance; + private int _fireTicks; + + public PerkFireArrows(double distance, int fireTicks) + { + super("Fire Arrows", new String[] {}); + + _distance = distance; + _fireTicks = fireTicks; + } + + @EventHandler + public void onProjectileHit(ProjectileHitEvent event) + { + if (event.getEntity().getShooter() instanceof Player) + { + Player player = (Player) event.getEntity().getShooter(); + Projectile projectile = event.getEntity(); + + if (!hasPerk(player)) + { + return; + } + + for (Player other : UtilPlayer.getNearby(projectile.getLocation(), _distance)) + { + if (!Manager.IsAlive(other) || player.equals(other) || Manager.GetGame().GetTeam(player).equals(Manager.GetGame().GetTeam(other))) + { + continue; + } + + other.setFireTicks(_fireTicks); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFletcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFletcher.java index 0d66a2957..e0bd889de 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFletcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFletcher.java @@ -38,6 +38,7 @@ public class PerkFletcher extends Perk private boolean _remove; private int _slot; private boolean _instant = true; + private String _name; public PerkFletcher(int time, int max, boolean remove) { @@ -55,6 +56,11 @@ public class PerkFletcher extends Perk } public PerkFletcher(int time, int max, boolean remove, int slot, boolean instant) + { + this(time, max, remove, slot, instant, "Fletcted Arrow"); + } + + public PerkFletcher(int time, int max, boolean remove, int slot, boolean instant, String name) { super("Fletcher", new String[] { @@ -66,8 +72,9 @@ public class PerkFletcher extends Perk _remove = remove; _slot = slot; _instant = instant; + _name = name; } - + public boolean isFletchedArrow(ItemStack stack) { if (!UtilGear.isMat(stack, Material.ARROW)) @@ -78,7 +85,7 @@ public class PerkFletcher extends Perk if (meta.getDisplayName() == null) return false; - if (!meta.getDisplayName().contains("Fletched Arrow")) + if (!meta.getDisplayName().contains(_name)) return false; return true; @@ -92,7 +99,7 @@ public class PerkFletcher extends Perk Player player = (Player)event.getEntity(); - if (!Kit.HasKit(player)) + if (!hasPerk(player)) return; for (int i=0 ; i<=8 ; i++) @@ -129,7 +136,7 @@ public class PerkFletcher extends Perk if (Manager.isSpectator(cur)) continue; - if (!Kit.HasKit(cur)) + if (!hasPerk(cur)) continue; if (!Manager.GetGame().IsAlive(cur)) @@ -145,17 +152,17 @@ public class PerkFletcher extends Perk if (!Recharge.Instance.use(cur, GetName(), _time * 1000, false, false)) continue; - if (UtilInv.contains(cur, "Fletched Arrow", Material.ARROW, (byte)0, _max)) + if (UtilInv.contains(cur, _name, Material.ARROW, (byte)0, _max)) continue; //Add if (_slot == -1) { - cur.getInventory().addItem(ItemStackFactory.Instance.CreateStack(262, (byte)0, 1, F.item("Fletched Arrow"))); + cur.getInventory().addItem(ItemStackFactory.Instance.CreateStack(262, (byte)0, 1, F.item(_name))); } else { - cur.getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(262, (byte)0, 1, F.item("Fletched Arrow"))); + cur.getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(262, (byte)0, 1, F.item(_name))); } cur.playSound(cur.getLocation(), Sound.ITEM_PICKUP, 2f, 1f); @@ -175,7 +182,7 @@ public class PerkFletcher extends Perk event.setCancelled(true); //Inform - UtilPlayer.message(event.getPlayer(), F.main(GetName(), "You cannot drop " + F.item("Fletched Arrow") + ".")); + UtilPlayer.message(event.getPlayer(), F.main(GetName(), "You cannot drop " + F.item(_name) + ".")); } @EventHandler @@ -194,7 +201,7 @@ public class PerkFletcher extends Perk @EventHandler public void FletchInvClick(InventoryClickEvent event) { - UtilInv.DisallowMovementOf(event, "Fletched Arrow", Material.ARROW, (byte)0, true); + UtilInv.DisallowMovementOf(event, _name, Material.ARROW, (byte)0, true); } @EventHandler @@ -211,4 +218,4 @@ public class PerkFletcher extends Perk arrowIterator.remove(); } } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLifestealArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLifestealArrows.java new file mode 100644 index 000000000..95152db18 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkLifestealArrows.java @@ -0,0 +1,46 @@ +package nautilus.game.arcade.kit.perks; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.kit.Perk; + +public class PerkLifestealArrows extends Perk +{ + + private double _health; + + public PerkLifestealArrows(double health) + { + super("Lifesteal Arrows", new String[] {}); + + _health = health; + } + + @EventHandler + public void onCustomDamage(CustomDamageEvent event) + { + if (event.GetCause() != DamageCause.PROJECTILE) + { + return; + } + + Player player = event.GetDamagerPlayer(true); + + if (!hasPerk(player)) + { + return; + } + + player.setHealth(Math.min(player.getMaxHealth(), player.getHealth() + _health)); + UtilParticle.PlayParticleToAll(ParticleType.HEART, player.getLocation().add(0, 1, 0), 1, 1, 1, 1, 5, ViewDist.NORMAL); + UtilParticle.PlayParticleToAll(ParticleType.HEART, event.GetDamageeEntity().getLocation().add(0, 1, 0), 1, 1, 1, 1, 5, ViewDist.NORMAL); + + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMagnetism.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMagnetism.java index 915ab6004..dee6a4981 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMagnetism.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkMagnetism.java @@ -16,30 +16,25 @@ import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.ItemStack; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilItem; -import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilMath; 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.particles.effects.LineParticle; import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.games.skywars.TeamSkywars; import nautilus.game.arcade.kit.Perk; public class PerkMagnetism extends Perk { - - private static final int RESISTANCE_DURATION = 40; private long _cooldown; private int _range; @@ -56,30 +51,23 @@ public class PerkMagnetism extends Perk } @EventHandler - public void onUpdate(UpdateEvent event) + public void onCustomDamage(CustomDamageEvent event) { - if (event.getType() != UpdateType.FAST) + if (!(event.GetDamageeEntity() instanceof Player)) { return; } - for (Player player : UtilServer.getPlayers()) + Player player = event.GetDamageePlayer(); + + if (!hasPerk(player)) { - if (!hasPerk(player) || UtilPlayer.isSpectator(player)) - { - continue; - } - - int magnituide = getAmountOfMetalArmor(player); - - if (magnituide == 0) - { - continue; - } - - player.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE); - player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, RESISTANCE_DURATION, magnituide - 1)); + return; } + + int magnitude = getAmountOfMetalArmor(player); + + event.AddMod(GetName(), event.GetDamage() * (magnitude * -0.075)); } @EventHandler @@ -139,8 +127,13 @@ public class PerkMagnetism extends Perk } Manager.GetDamage().NewDamageEvent(target, player, null, DamageCause.CUSTOM, 1, false, true, true, player.getName(), GetName()); - UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, player.getEyeLocation(), 1, 1, 1, 0.01F, 20, ViewDist.NORMAL); + LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.5, UtilMath.offset(player, target), null, ParticleType.FIREWORKS_SPARK, UtilServer.getPlayers()); + + while (!lineParticle.update()) + { + } + Vector vector = UtilAlg.getTrajectory(target, player).multiply((.5 + magnitude / 4) * _magnituideFactor); UtilAction.velocity(target, vector.setY(Math.max(.6, vector.getY()))); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicSlamOITQ.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicSlamOITQ.java index b0a12668a..0844461bd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicSlamOITQ.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSeismicSlamOITQ.java @@ -25,6 +25,7 @@ import nautilus.game.arcade.kit.Perk; public class PerkSeismicSlamOITQ extends Perk { + public PerkSeismicSlamOITQ() { super("Ground Pound", new String[] diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSpeed.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSpeed.java index 8d6e8a8f6..8fd188d13 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSpeed.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSpeed.java @@ -33,7 +33,7 @@ public class PerkSpeed extends Perk for (Player player : Manager.GetGame().GetPlayers(true)) { - if (!Kit.HasKit(player)) + if (!hasPerk(player)) continue; Manager.GetCondition().Factory().Speed(GetName(), player, player, 8, _level, false, false, true); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkStrength.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkStrength.java index 038948a2d..26fc75ed3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkStrength.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkStrength.java @@ -31,7 +31,7 @@ public class PerkStrength extends Perk Player damager = event.GetDamagerPlayer(true); if (damager == null) return; - if (!Kit.HasKit(damager)) + if (!hasPerk(damager)) return; event.AddMod(damager.getName(), GetName(), _power, false); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java index 62e5a3711..bb5b48c7b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java @@ -1012,7 +1012,17 @@ public class GameLobbyManager implements Listener public void AddPlayerToScoreboards(Player player, GameTeam gameTeam) { - Rank rank = Manager.GetClients().Get(player).getRealOrDisguisedRank(); + Rank rank; + + if (player == null) + { + rank = Rank.ALL; + } + else + { + rank = Manager.GetClients().Get(player).getRealOrDisguisedRank(); + } + String teamId = getTeamId(gameTeam, player); for (MineplexScoreboard scoreboard : Manager.getScoreboardManager().getScoreboards().values()) @@ -1040,7 +1050,10 @@ public class GameLobbyManager implements Listener } } } - team.addEntry(player.getName()); + if (player != null) + { + team.addEntry(player.getName()); + } } } @@ -1063,14 +1076,27 @@ public class GameLobbyManager implements Listener public String getTeamId(GameTeam gameTeam, Player player) { - Rank rank = Manager.GetClients().Get(player).getRealOrDisguisedRank(); - String rankName = rank.Name; - boolean rankIsUltra = !rank.has(Rank.ULTRA) && - Manager.GetDonation().Get(player).OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA"); - - if (rankIsUltra) + Rank rank; + + if (player == null) { - rankName = Rank.ULTRA.Name; + rank = Rank.ALL; + } + else + { + rank = Manager.GetClients().Get(player).getRealOrDisguisedRank(); + } + + String rankName = rank.Name; + if (player != null) + { + boolean rankIsUltra = !rank.has(Rank.ULTRA) && + Manager.GetDonation().Get(player).OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA"); + + if (rankIsUltra) + { + rankName = Rank.ULTRA.Name; + } } String teamId;