From 47c816087ec777135feeb13c9d251a26359c3969 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 4 May 2017 15:45:04 +0100 Subject: [PATCH 01/57] MOBA base --- .../src/mineplex/core/game/GameDisplay.java | 2 + .../src/nautilus/game/arcade/GameType.java | 5 +- .../game/arcade/game/games/moba/Moba.java | 34 +-- .../game/arcade/game/games/moba/MobaRole.java | 32 +++ .../arcade/game/games/moba/kit/KitPlayer.java | 27 +++ .../moba/structure/point/CapturePoint.java | 225 ++++++++++++++++++ .../point/CapturePointCaptureEvent.java | 37 +++ 7 files changed, 337 insertions(+), 25 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/KitPlayer.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointCaptureEvent.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index cc5ba27d4..430a198b7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -99,6 +99,8 @@ public enum GameDisplay StrikeGames("Strike Games", Material.DIAMOND_LEGGINGS, (byte) 0, GameCategory.SURVIVAL, 66, false), + MOBA("Heroes of the Craft", Material.SKULL_ITEM, (byte)1, GameCategory.CLASSICS, 70, true), + Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999, false), Brawl("Brawl", Material.DIAMOND, (byte) 0, GameCategory.EVENT, 998, false); 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 66bef53c0..f7bac3e5e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -1,5 +1,6 @@ package nautilus.game.arcade; +import nautilus.game.arcade.game.games.moba.Moba; import org.bukkit.Material; import mineplex.core.common.MinecraftVersion; @@ -223,7 +224,9 @@ public enum GameType BouncyBalls(BouncyBalls.class, GameDisplay.BouncyBalls), Valentines(Valentines.class, GameDisplay.Valentines), - + + MOBA(Moba.class, GameDisplay.MOBA), + Event(EventGame.class, GameDisplay.Event, new GameType[]{ GameType.BaconBrawl, GameType.Barbarians, GameType.Bridge, GameType.Build, GameType.Build, GameType.Cards, GameType.CastleSiege, GameType.ChampionsDominate, GameType.ChampionsTDM, GameType.Christmas, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 17f393dd6..081417c5b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -1,39 +1,25 @@ package nautilus.game.arcade.game.games.moba; -import java.util.ArrayList; - import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.game.games.sheep.kits.*; +import nautilus.game.arcade.game.games.moba.kit.KitPlayer; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.NullKit; public class Moba extends TeamGame { - private ArrayList _lastScoreboard = new ArrayList(); - public Moba(ArcadeManager manager) + private static final String[] DESCRIPTION = { + "MORE CAPTURE POINTS" + }; + + public Moba(ArcadeManager manager) { - super(manager, GameType.Sheep, + super(manager, GameType.MOBA, new Kit[] { new KitPlayer(manager) }, DESCRIPTION); - new Kit[] - { - new NullKit(manager) - }, - - new String[] - { - "..." - }); - - this.DeathOut = false; - this.DeathSpectateSecs = 8; - - this.HungerSet = 20; - - registerChatStats(); + DeathSpectateSecs = 8; + HungerSet = 20; new CompassModule() .setGiveCompass(true) @@ -43,7 +29,7 @@ public class Moba extends TeamGame } @Override - public void ParseData() + public void ParseData() { } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java new file mode 100644 index 000000000..91f0fa6e5 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java @@ -0,0 +1,32 @@ +package nautilus.game.arcade.game.games.moba; + +import nautilus.game.arcade.kit.Kit; + +public enum MobaRole +{ + + ASSASSIN("Assassin", null), + HUNTER("Hunter", null), + MAGE("Mage", null), + WARRIOR("Warrior", null), + ; + + private String _name; + private Kit[] _kits; + + MobaRole(String name, Kit[] kits) + { + _name = name; + _kits = kits; + } + + public String getName() + { + return _name; + } + + public Kit[] getKits() + { + return _kits; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/KitPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/KitPlayer.java new file mode 100644 index 000000000..41d6428c2 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/KitPlayer.java @@ -0,0 +1,27 @@ +package nautilus.game.arcade.game.games.moba.kit; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; + +public class KitPlayer extends Kit +{ + + private static final String[] DESCRIPTION = { + + }; + + public KitPlayer(ArcadeManager manager) + { + super(manager, "Player", KitAvailability.Free, DESCRIPTION, new Perk[0], EntityType.PIG, null); + } + + @Override + public void GiveItems(Player player) + { + + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java new file mode 100644 index 000000000..6d8c7f08d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java @@ -0,0 +1,225 @@ +package nautilus.game.arcade.game.games.moba.structure.point; + +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; + +import java.util.*; +import java.util.Map.Entry; + +public class CapturePoint +{ + + private static final int MAX_RADIUS = 5; + private static final int MAX_PROGRESS = 10; + + private final Moba _host; + + private final Location _center; + private final List _wool; + private final List _changed; + + private final double _captureDist; + + private GameTeam _owner; + private GameTeam _side; + private int _progress; + + public CapturePoint(Moba host, Location center) + { + _host = host; + _center = center; + _wool = new ArrayList<>(36); + _changed = new ArrayList<>(_wool.size()); + + double highestDist = 0; + + for (Entry entry : UtilBlock.getInRadius(center, MAX_RADIUS).entrySet()) + { + Block block = entry.getKey(); + double offset = entry.getValue(); + + if (block.getType() != Material.WOOL) + { + continue; + } + + if (offset > highestDist) + { + highestDist = offset; + } + + _wool.add(block); + } + Collections.shuffle(_wool); + + _captureDist = highestDist * (double) MAX_RADIUS; + } + + public boolean update() + { + // Store the number of players in a team in this map + Map playersOnPoint = new HashMap<>(); + + for (GameTeam team : _host.GetTeamList()) + { + // Populate + playersOnPoint.put(team, 0); + int players = 0; + + for (Player player : team.GetPlayers(true)) + { + // Ignore for spectators + // If they are not in the range + if (UtilPlayer.isSpectator(player) || UtilMath.offset(player.getLocation(), _center) > _captureDist) + { + continue; + } + + // Increment + players++; + } + + // Put in map + playersOnPoint.put(team, players); + } + + // For each team get the team with the non-zero players + GameTeam highest = null; + for (Entry entry : playersOnPoint.entrySet()) + { + GameTeam team = entry.getKey(); + int players = entry.getValue(); + + // Only care if people are on it + if (players > 0) + { + // If this is the first team on the point + if (highest == null) + { + highest = team; + } + // This means there are 2 teams on the point + else + { + return false; + } + } + } + + // No one at all is on the point + if (highest == null) + { + return false; + } + + // If it has just reached the maximum progress, set the owner. + if (_owner != null && _owner.equals(highest) && _progress == MAX_PROGRESS) + { + return false; + } + + capture(highest); + return true; + } + + private void capture(GameTeam team) + { + // No player has ever stood on the point + if (_side == null) + { + _side = team; + } + + // If it is the same team + if (_side.equals(team)) + { + // Captured + if (_progress == MAX_PROGRESS) + { + setOwner(team); + } + + // Increase progress + _progress++; + display(team, true); + } + // Other team + else + { + // Point back to a neutral state + if (_progress == 0) + { + _side = team; + // Recursively call this method now that the first (same team) condition will be true + capture(team); + return; + } + + _progress--; + display(team, false); + } + } + + private void setOwner(GameTeam team) + { + _owner = team; + + UtilServer.CallEvent(new CapturePointCaptureEvent(this)); + } + + private void display(GameTeam team, boolean forward) + { + Bukkit.broadcastMessage("progress=" + _progress + " forward=" + forward); + + double toChange = Math.ceil(_wool.size() / MAX_PROGRESS); + int changed = 0; + for (Block block : _wool) + { + if (changed >= toChange) + { + return; + } + + Block glass = block.getRelative(BlockFace.UP); + + if (forward) + { + if (_changed.contains(block)) + { + continue; + } + + block.setData(team.GetColorData()); + glass.setData(team.GetColorData()); + changed++; + } + else + { + if (!_changed.contains(block)) + { + continue; + } + + block.setData((byte) 0); + glass.setData((byte) 0); + changed++; + } + } + } + + public GameTeam getOwner() + { + return _owner; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointCaptureEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointCaptureEvent.java new file mode 100644 index 000000000..4383350aa --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointCaptureEvent.java @@ -0,0 +1,37 @@ +package nautilus.game.arcade.game.games.moba.structure.point; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import java.util.List; + +public class CapturePointCaptureEvent extends Event +{ + + private static final HandlerList _handlers = new HandlerList(); + + private CapturePoint _point; + + public CapturePointCaptureEvent(CapturePoint point) + { + _point = point; + } + + public CapturePoint getPoint() + { + return _point; + } + + public static HandlerList getHandlerList() + { + return _handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + +} From 321084339542a20c8c43c4bd40781909ef956cd1 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 4 May 2017 20:20:48 +0100 Subject: [PATCH 02/57] Capture point fix --- .../game/arcade/game/games/moba/Moba.java | 89 ++++++++++++++++++- .../game/games/moba/kit/KitSelection.java | 30 +++++++ .../moba/structure/point/CapturePoint.java | 51 ++++++----- 3 files changed, 148 insertions(+), 22 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/KitSelection.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 081417c5b..ce6d35041 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -1,11 +1,18 @@ package nautilus.game.arcade.game.games.moba; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.moba.kit.KitPlayer; +import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; +import org.bukkit.Location; +import org.bukkit.event.EventHandler; + +import java.util.*; public class Moba extends TeamGame { @@ -14,12 +21,16 @@ public class Moba extends TeamGame "MORE CAPTURE POINTS" }; + private final List _capturePoints = new ArrayList<>(3); + public Moba(ArcadeManager manager) { super(manager, GameType.MOBA, new Kit[] { new KitPlayer(manager) }, DESCRIPTION); + DeathOut = false; DeathSpectateSecs = 8; HungerSet = 20; + DontAllowOverfill = false; new CompassModule() .setGiveCompass(true) @@ -31,6 +42,82 @@ public class Moba extends TeamGame @Override public void ParseData() { - + Collection capturePoints = getLocationStartsWith("POINT").values(); + + for (Location location : capturePoints) + { + _capturePoints.add(new CapturePoint(this, location)); + } + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + GameState state = GetState(); + + switch (state) + { + case Prepare: + writePrepare(); + break; + case Live: + writeLive(); + break; + case End: + writeEnd(); + break; + } + + Scoreboard.draw(); + } + + private void writePrepare() + { + + } + + private void writeLive() + { + + } + + private void writeEnd() + { + + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + for (CapturePoint point : _capturePoints) + { + point.update(); + } + } + + private Map getLocationStartsWith(String s) + { + Map map = new HashMap<>(); + + for (String key : WorldData.GetAllCustomLocs().keySet()) + { + if (key.startsWith(s)) + { + map.put(key, WorldData.GetCustomLocs(key).get(0)); + } + } + + return map; } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/KitSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/KitSelection.java new file mode 100644 index 000000000..1fcea1335 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/KitSelection.java @@ -0,0 +1,30 @@ +package nautilus.game.arcade.game.games.moba.kit; + +import mineplex.core.common.util.UtilServer; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +public class KitSelection implements Listener +{ + + private final + + public KitSelection(Moba moba) + { + UtilServer.RegisterEvents(this); + } + + @EventHandler + public void live(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + + UtilServer.Unregister(this); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java index 6d8c7f08d..95cbc8edc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java @@ -1,15 +1,10 @@ package nautilus.game.arcade.game.games.moba.structure.point; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.*; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; +import org.bukkit.*; +import org.bukkit.FireworkEffect.Type; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; @@ -66,7 +61,7 @@ public class CapturePoint _captureDist = highestDist * (double) MAX_RADIUS; } - public boolean update() + public void update() { // Store the number of players in a team in this map Map playersOnPoint = new HashMap<>(); @@ -112,7 +107,7 @@ public class CapturePoint // This means there are 2 teams on the point else { - return false; + return; } } } @@ -120,17 +115,16 @@ public class CapturePoint // No one at all is on the point if (highest == null) { - return false; + return; } // If it has just reached the maximum progress, set the owner. - if (_owner != null && _owner.equals(highest) && _progress == MAX_PROGRESS) + if (_owner != null && _owner.equals(highest) && _progress >= MAX_PROGRESS) { - return false; + return; } capture(highest); - return true; } private void capture(GameTeam team) @@ -144,15 +138,15 @@ public class CapturePoint // If it is the same team if (_side.equals(team)) { - // Captured - if (_progress == MAX_PROGRESS) - { - setOwner(team); - } - // Increase progress _progress++; display(team, true); + + // Captured + if (_progress >= MAX_PROGRESS) + { + setOwner(team); + } } // Other team else @@ -160,6 +154,7 @@ public class CapturePoint // Point back to a neutral state if (_progress == 0) { + setBeaconColour(null); _side = team; // Recursively call this method now that the first (same team) condition will be true capture(team); @@ -175,6 +170,9 @@ public class CapturePoint { _owner = team; + setBeaconColour(team); + UtilFirework.playFirework(_center, Type.BURST, team.GetColorBase(), false, false); + UtilServer.CallEvent(new CapturePointCaptureEvent(this)); } @@ -182,7 +180,7 @@ public class CapturePoint { Bukkit.broadcastMessage("progress=" + _progress + " forward=" + forward); - double toChange = Math.ceil(_wool.size() / MAX_PROGRESS); + double toChange = Math.ceil(_wool.size() / MAX_PROGRESS) + 1; int changed = 0; for (Block block : _wool) { @@ -203,6 +201,7 @@ public class CapturePoint block.setData(team.GetColorData()); glass.setData(team.GetColorData()); changed++; + _changed.add(block); } else { @@ -214,10 +213,20 @@ public class CapturePoint block.setData((byte) 0); glass.setData((byte) 0); changed++; + _changed.remove(block); } + + glass.getWorld().playEffect(glass.getLocation().add(0.5, 0.5, 0.5), Effect.STEP_SOUND, block.getType(), team.GetColorData()); } } + private void setBeaconColour(GameTeam team) + { + byte colour = team == null ? 0 : team.GetColorData(); + + _center.getBlock().getRelative(BlockFace.DOWN).setData(colour); + } + public GameTeam getOwner() { return _owner; From a32ae91996d49168283736d1da0f668da32a63a2 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 5 May 2017 22:30:37 +0100 Subject: [PATCH 03/57] Gotta go fast! --- .../core/common/entity/ClientArmorStand.java | 1038 +++++++++++++++++ .../src/nautilus/game/arcade/game/Game.java | 3 +- .../game/arcade/game/games/moba/Moba.java | 124 +- .../game/arcade/game/games/moba/MobaRole.java | 18 +- .../arcade/game/games/moba/kit/HeroKit.java | 124 ++ .../game/games/moba/kit/KitSelection.java | 30 - .../game/games/moba/kit/PregameSelection.java | 164 +++ .../game/games/moba/kit/RoleSelectEvent.java | 61 + .../games/moba/kit/heroes/HeroHattori.java | 32 + .../arcade/game/games/moba/recall/Recall.java | 136 +++ .../game/games/moba/recall/RecallSession.java | 19 + .../arcade/game/games/moba/shop/MobaShop.java | 16 + .../moba/structure/point/CapturePoint.java | 2 - .../games/moba/structure/tower/Tower.java | 95 ++ .../structure/tower/TowerDestroyEvent.java | 34 + .../game/arcade/game/games/uhc/UHC.java | 2 + .../game/arcade/managers/GameHostManager.java | 2 +- .../game/arcade/managers/GameManager.java | 2 +- .../serverreset/ServerResetCommand.java | 2 +- 19 files changed, 1862 insertions(+), 42 deletions(-) create mode 100644 Plugins/Mineplex.Core.Common/src/mineplex/core/common/entity/ClientArmorStand.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/KitSelection.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/RoleSelectEvent.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/heroes/HeroHattori.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/RecallSession.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerDestroyEvent.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/entity/ClientArmorStand.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/entity/ClientArmorStand.java new file mode 100644 index 000000000..239f0af5c --- /dev/null +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/entity/ClientArmorStand.java @@ -0,0 +1,1038 @@ +package mineplex.core.common.entity; + +import mineplex.core.common.util.UtilPlayer; +import net.minecraft.server.v1_8_R3.*; +import org.bukkit.EntityEffect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Server; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; +import org.bukkit.entity.*; +import org.bukkit.entity.Entity; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.MetadataValue; +import org.bukkit.permissions.Permission; +import org.bukkit.permissions.PermissionAttachment; +import org.bukkit.permissions.PermissionAttachmentInfo; +import org.bukkit.plugin.Plugin; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.EulerAngle; +import org.bukkit.util.Vector; + +import java.util.*; + +public class ClientArmorStand implements ArmorStand +{ + + private static final int HAND = 0; + private static final int HELMET = 4; + private static final int CHESTPLATE = 3; + private static final int LEGGINGS = 2; + private static final int BOOTS = 1; + + public static ClientArmorStand spawn(Location location) + { + EntityArmorStand entityArmorStand = new EntityArmorStand(((CraftWorld) location.getWorld()).getHandle()); + entityArmorStand.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + ClientArmorStand clientArmorStand = new ClientArmorStand(entityArmorStand); + + for (Player other : clientArmorStand.getObservers()) + { + UtilPlayer.sendPacket(other, new PacketPlayOutSpawnEntityLiving(entityArmorStand)); + } + + return clientArmorStand; + } + + public static ClientArmorStand spawn(Location loc, Player... players) + { + EntityArmorStand entityArmorStand = new EntityArmorStand(((CraftWorld) loc.getWorld()).getHandle()); + entityArmorStand.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()); + ClientArmorStand clientArmorStand = new ClientArmorStand(entityArmorStand, players); + Packet packet = new PacketPlayOutSpawnEntityLiving(entityArmorStand); + + for (Player observer : players) + { + UtilPlayer.sendPacket(observer, packet); + } + + return clientArmorStand; + } + + private final EntityArmorStand _armorStand; + private ItemStack _itemInHand, _helmet, _chestplate, _leggings, _boots; + private boolean _visible; + private final DataWatcher _dataWatcher; + + private Player[] _observers; + + private ClientArmorStand(EntityArmorStand armorStand, Player... players) + { + _armorStand = armorStand; + _dataWatcher = armorStand.getDataWatcher(); + _observers = players; + } + + public EntityArmorStand getHandle() + { + return _armorStand; + } + + @Override + public ItemStack getItemInHand() + { + return _itemInHand; + } + + @Override + public void setItemInHand(ItemStack itemStack) + { + _itemInHand = itemStack; + sendPacket(new PacketPlayOutEntityEquipment(getEntityId(), HAND, CraftItemStack.asNMSCopy(itemStack))); + } + + @Override + public ItemStack getHelmet() + { + return _helmet; + } + + @Override + public void setHelmet(ItemStack itemStack) + { + _helmet = itemStack; + sendPacket(new PacketPlayOutEntityEquipment(getEntityId(), HELMET, CraftItemStack.asNMSCopy(itemStack))); + } + + @Override + public ItemStack getChestplate() + { + return _chestplate; + } + + @Override + public void setChestplate(ItemStack itemStack) + { + _chestplate = itemStack; + sendPacket(new PacketPlayOutEntityEquipment(getEntityId(), CHESTPLATE, CraftItemStack.asNMSCopy(itemStack))); + } + + @Override + public ItemStack getLeggings() + { + return _leggings; + } + + @Override + public void setLeggings(ItemStack itemStack) + { + _leggings = itemStack; + sendPacket(new PacketPlayOutEntityEquipment(getEntityId(), LEGGINGS, CraftItemStack.asNMSCopy(itemStack))); + } + + @Override + public ItemStack getBoots() + { + return _boots; + } + + @Override + public void setBoots(ItemStack itemStack) + { + _boots = itemStack; + sendPacket(new PacketPlayOutEntityEquipment(getEntityId(), BOOTS, CraftItemStack.asNMSCopy(itemStack))); + } + + @Override + public Location getEyeLocation() + { + return getLocation().add(0, getEyeHeight(), 0); + } + + @Override + public double getEyeHeight() + { + return 1.62; + } + + @Override + public double getEyeHeight(boolean sneaking) + { + return getEyeHeight(); + } + + @Override + public String getCustomName() + { + return _armorStand.getCustomName(); + } + + @Override + public Location getLocation() + { + return new Location(getWorld(), _armorStand.locX, _armorStand.locY, _armorStand.locZ); + } + + @Override + public boolean isVisible() + { + return _visible; + } + + @Override + public void setVisible(boolean visible) + { + _visible = visible; + _armorStand.setInvisible(!visible); + sendMetaPacket(); + } + + private void sendMetaPacket() + { + sendPacket(new PacketPlayOutEntityMetadata(getEntityId(), _dataWatcher, true), _observers); + } + + @Override + public Entity getPassenger() + { + return null; + } + + @Override + public Entity getVehicle() + { + return null; + } + + @Override + public org.bukkit.World getWorld() + { + return _armorStand.getWorld().getWorld(); + } + + @Override + public void remove() + { + sendPacket(new PacketPlayOutEntityDestroy(new int[]{_armorStand.getId()})); + } + + public void remove(Player... player) + { + sendPacket(new PacketPlayOutEntityDestroy(new int[]{_armorStand.getId()}), player); + } + + @Override + public void setCustomName(String arg0) + { + _armorStand.setCustomName(arg0); + sendMetaPacket(); + } + + @Override + public boolean setPassenger(Entity arg0) + { + return false; + } + + @Override + public boolean teleport(Location loc) + { + _armorStand.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()); + sendPacket(new PacketPlayOutEntityTeleport(_armorStand)); + return false; + } + + @Override + public EulerAngle getBodyPose() + { + return null; + } + + @Override + public EulerAngle getHeadPose() + { + return fromNMS(_armorStand.headPose); + } + + @Override + public void setHeadPose(EulerAngle pose) + { + _armorStand.setHeadPose(toNMS(pose)); + sendMetaPacket(); + } + + @Override + public EulerAngle getLeftArmPose() + { + return null; + } + + @Override + public EulerAngle getLeftLegPose() + { + return null; + } + + @Override + public EulerAngle getRightArmPose() + { + return null; + } + + @Override + public EulerAngle getRightLegPose() + { + return null; + } + + @Override + public boolean hasArms() + { + return false; + } + + @Override + public boolean hasBasePlate() + { + return false; + } + + @Override + public boolean hasGravity() + { + return false; + } + + @Override + public boolean isMarker() + { + return false; + } + + @Override + public boolean isSmall() + { + return false; + } + + @Override + public void setArms(boolean arg0) + { + _armorStand.setArms(arg0); + sendMetaPacket(); + } + + @Override + public void setBasePlate(boolean arg0) + { + _armorStand.setBasePlate(arg0); + sendMetaPacket(); + } + + @Override + public void setBodyPose(EulerAngle arg0) + { + } + + @Override + public void setLeftArmPose(EulerAngle arg0) + { + } + + @Override + public void setLeftLegPose(EulerAngle arg0) + { + } + + @Override + public void setRightArmPose(EulerAngle arg0) + { + } + + @Override + public void setRightLegPose(EulerAngle arg0) + { + } + + @Override + public void setSmall(boolean arg0) + { + _armorStand.setSmall(arg0); + sendMetaPacket(); + } + + @Override + public int getEntityId() + { + return _armorStand.getId(); + } + + public Player[] getObservers() + { + return _observers; + } + + public void sendPacket(Packet packet) + { + sendPacket(packet, getObservers()); + } + + public void sendPacket(Packet packet, Collection observers) + { + for (Player player : observers) + { + UtilPlayer.sendPacket(player, packet); + } + } + + public void sendPacket(Packet packet, Player... observers) + { + for (Player player : observers) + { + UtilPlayer.sendPacket(player, packet); + } + } + + // Not needed + + @Override + public void setGravity(boolean b) + { + + } + + @Override + public void setMarker(boolean b) + { + + } + + @Override + public List getLineOfSight(HashSet hashSet, int i) + { + return null; + } + + @Override + public List getLineOfSight(Set set, int i) + { + return null; + } + + @Override + public Block getTargetBlock(HashSet hashSet, int i) + { + return null; + } + + @Override + public Block getTargetBlock(Set set, int i) + { + return null; + } + + @Override + public List getLastTwoTargetBlocks(HashSet hashSet, int i) + { + return null; + } + + @Override + public List getLastTwoTargetBlocks(Set set, int i) + { + return null; + } + + @Override + public Egg throwEgg() + { + return null; + } + + @Override + public Snowball throwSnowball() + { + return null; + } + + @Override + public Arrow shootArrow() + { + return null; + } + + @Override + public int getRemainingAir() + { + return 0; + } + + @Override + public void setRemainingAir(int i) + { + + } + + @Override + public int getMaximumAir() + { + return 0; + } + + @Override + public void setMaximumAir(int i) + { + + } + + @Override + public int getMaximumNoDamageTicks() + { + return 0; + } + + @Override + public void setMaximumNoDamageTicks(int i) + { + + } + + @Override + public double getLastDamage() + { + return 0; + } + + @Override + public void setLastDamage(double v) + { + + } + + @Override + public int getNoDamageTicks() + { + return 0; + } + + @Override + public void setNoDamageTicks(int i) + { + + } + + @Override + public Player getKiller() + { + return null; + } + + @Override + public boolean addPotionEffect(PotionEffect potionEffect) + { + return false; + } + + @Override + public boolean addPotionEffect(PotionEffect potionEffect, boolean b) + { + return false; + } + + @Override + public boolean addPotionEffects(Collection collection) + { + return false; + } + + @Override + public boolean hasPotionEffect(PotionEffectType potionEffectType) + { + return false; + } + + @Override + public void removePotionEffect(PotionEffectType potionEffectType) + { + + } + + @Override + public Collection getActivePotionEffects() + { + return null; + } + + @Override + public boolean hasLineOfSight(org.bukkit.entity.Entity entity) + { + return false; + } + + @Override + public boolean getRemoveWhenFarAway() + { + return false; + } + + @Override + public void setRemoveWhenFarAway(boolean b) + { + + } + + @Override + public EntityEquipment getEquipment() + { + return null; + } + + @Override + public void setCanPickupItems(boolean b) + { + + } + + @Override + public boolean getCanPickupItems() + { + return false; + } + + @Override + public boolean isLeashed() + { + return false; + } + + @Override + public org.bukkit.entity.Entity getLeashHolder() throws IllegalStateException + { + return null; + } + + @Override + public boolean setLeashHolder(org.bukkit.entity.Entity entity) + { + return false; + } + + @Override + public boolean shouldBreakLeash() + { + return false; + } + + @Override + public void setShouldBreakLeash(boolean b) + { + + } + + @Override + public boolean shouldPullWhileLeashed() + { + return false; + } + + @Override + public void setPullWhileLeashed(boolean b) + { + + } + + @Override + public boolean isVegetated() + { + return false; + } + + @Override + public void setVegetated(boolean b) + { + + } + + @Override + public boolean isGhost() + { + return false; + } + + @Override + public void setGhost(boolean b) + { + + } + + @Override + public void damage(double v) + { + + } + + @Override + public void damage(double v, org.bukkit.entity.Entity entity) + { + + } + + @Override + public double getHealth() + { + return 0; + } + + @Override + public void setHealth(double v) + { + + } + + @Override + public double getMaxHealth() + { + return 0; + } + + @Override + public void setMaxHealth(double v) + { + + } + + @Override + public void resetMaxHealth() + { + + } + + @Override + public Location getLocation(Location location) + { + return null; + } + + @Override + public void setVelocity(Vector vector) + { + + } + + @Override + public Vector getVelocity() + { + return null; + } + + @Override + public boolean isOnGround() + { + return false; + } + + @Override + public boolean teleport(Location location, TeleportCause teleportCause) + { + return false; + } + + @Override + public boolean teleport(org.bukkit.entity.Entity entity) + { + return false; + } + + @Override + public boolean teleport(org.bukkit.entity.Entity entity, TeleportCause teleportCause) + { + return false; + } + + @Override + public List getNearbyEntities(double v, double v1, double v2) + { + return null; + } + + @Override + public int getFireTicks() + { + return 0; + } + + @Override + public int getMaxFireTicks() + { + return 0; + } + + @Override + public void setFireTicks(int i) + { + + } + + @Override + public boolean isDead() + { + return false; + } + + @Override + public boolean isValid() + { + return false; + } + + @Override + public Server getServer() + { + return null; + } + + @Override + public boolean isEmpty() + { + return false; + } + + @Override + public boolean eject() + { + return false; + } + + @Override + public float getFallDistance() + { + return 0; + } + + @Override + public void setFallDistance(float v) + { + + } + + @Override + public void setLastDamageCause(EntityDamageEvent entityDamageEvent) + { + + } + + @Override + public EntityDamageEvent getLastDamageCause() + { + return null; + } + + @Override + public UUID getUniqueId() + { + return null; + } + + @Override + public int getTicksLived() + { + return 0; + } + + @Override + public void setTicksLived(int i) + { + + } + + @Override + public void playEffect(EntityEffect entityEffect) + { + + } + + @Override + public EntityType getType() + { + return null; + } + + @Override + public boolean isInsideVehicle() + { + return false; + } + + @Override + public boolean leaveVehicle() + { + return false; + } + + @Override + public void setCustomNameVisible(boolean b) + { + _armorStand.setCustomNameVisible(b); + } + + @Override + public boolean isCustomNameVisible() + { + return false; + } + + @Override + public Spigot spigot() + { + return null; + } + + @Override + public void sendMessage(String s) + { + + } + + @Override + public void sendMessage(String[] strings) + { + + } + + @Override + public String getName() + { + return null; + } + + @Override + public void setMetadata(String s, MetadataValue metadataValue) + { + + } + + @Override + public List getMetadata(String s) + { + return null; + } + + @Override + public boolean hasMetadata(String s) + { + return false; + } + + @Override + public void removeMetadata(String s, Plugin plugin) + { + + } + + @Override + public boolean isPermissionSet(String s) + { + return false; + } + + @Override + public boolean isPermissionSet(Permission permission) + { + return false; + } + + @Override + public boolean hasPermission(String s) + { + return false; + } + + @Override + public boolean hasPermission(Permission permission) + { + return false; + } + + @Override + public PermissionAttachment addAttachment(Plugin plugin, String s, boolean b) + { + return null; + } + + @Override + public PermissionAttachment addAttachment(Plugin plugin) + { + return null; + } + + @Override + public PermissionAttachment addAttachment(Plugin plugin, String s, boolean b, int i) + { + return null; + } + + @Override + public PermissionAttachment addAttachment(Plugin plugin, int i) + { + return null; + } + + @Override + public void removeAttachment(PermissionAttachment permissionAttachment) + { + + } + + @Override + public void recalculatePermissions() + { + + } + + @Override + public Set getEffectivePermissions() + { + return null; + } + + @Override + public boolean isOp() + { + return false; + } + + @Override + public void setOp(boolean b) + { + + } + + @Override + public T launchProjectile(Class aClass) + { + return null; + } + + @Override + public T launchProjectile(Class aClass, Vector vector) + { + return null; + } + + private static EulerAngle fromNMS(Vector3f old) + { + return new EulerAngle(Math.toRadians(old.getX()), Math.toRadians(old.getY()), Math.toRadians(old.getZ())); + } + + private static Vector3f toNMS(EulerAngle old) + { + return new Vector3f((float) Math.toDegrees(old.getX()), (float) Math.toDegrees(old.getY()), (float) Math.toDegrees(old.getZ())); + } + +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 89fe831d5..9a1006b42 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -257,7 +257,6 @@ public abstract class Game extends ListenerComponent implements Lifetimed public int HealthSet = -1; public boolean SpawnTeleport = true; - public boolean PrepareFreeze = true; private double _itemMergeRadius = 0; @@ -293,7 +292,9 @@ public abstract class Game extends ListenerComponent implements Lifetimed public boolean AllowParticles = true; + public boolean Prepare = true; public long PrepareTime = 9000; + public boolean PrepareFreeze = true; public boolean PlaySoundGameStart = true; public double XpMult = 1; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index ce6d35041..c7c79dd48 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -1,18 +1,27 @@ package nautilus.game.arcade.game.games.moba; +import mineplex.core.common.util.UtilServer; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.moba.kit.KitPlayer; +import nautilus.game.arcade.game.games.moba.kit.PregameSelection; +import nautilus.game.arcade.game.games.moba.recall.Recall; import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; +import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import org.bukkit.Location; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; import java.util.*; +import java.util.Map.Entry; public class Moba extends TeamGame { @@ -22,13 +31,20 @@ public class Moba extends TeamGame }; private final List _capturePoints = new ArrayList<>(3); + private final List _towers = new ArrayList<>(12); + + private final Map _roles = new HashMap<>(); + + private final Set _listeners = new HashSet<>(); public Moba(ArcadeManager manager) { super(manager, GameType.MOBA, new Kit[] { new KitPlayer(manager) }, DESCRIPTION); + //Prepare = false; + PrepareFreeze = false; DeathOut = false; - DeathSpectateSecs = 8; + DeathSpectateSecs = 10; HungerSet = 20; DontAllowOverfill = false; @@ -37,6 +53,12 @@ public class Moba extends TeamGame .setGiveCompassToSpecs(true) .setGiveCompassToAlive(false) .register(this); + + Listener preGameSelection = new PregameSelection(this, null); + _listeners.add(preGameSelection); + + Listener recall = new Recall(this); + _listeners.add(recall); } @Override @@ -48,6 +70,60 @@ public class Moba extends TeamGame { _capturePoints.add(new CapturePoint(this, location)); } + + Map towers = getLocationStartsWith("TOWER"); + + for (Entry entry : towers.entrySet()) + { + String key = entry.getKey(); + Location location = entry.getValue(); + String[] components = key.split(" "); + + if (components.length < 4) + { + continue; + } + + String team = components[1]; + String lane = components[2]; + int laneInt = 0; + + switch (lane) + { + case "A": + laneInt = 0; + break; + case "B": + laneInt = 1; + break; + case "C": + laneInt = 2; + break; + } + + boolean firstTower; + + try + { + firstTower = Integer.parseInt(components[3]) == 1; + } + catch (NumberFormatException e) + { + continue; + } + + int health = 1000; + GameTeam gameTeam = getTeam(team); + + if (gameTeam == null) + { + continue; + } + + _towers.add(new Tower(this, location, gameTeam, laneInt, health, firstTower)); + } + + _listeners.forEach(UtilServer::RegisterEvents); } @Override @@ -72,6 +148,8 @@ public class Moba extends TeamGame case End: writeEnd(); break; + default: + return; } Scoreboard.draw(); @@ -92,6 +170,37 @@ public class Moba extends TeamGame } + @EventHandler + public void prepare(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + for (Tower tower : _towers) + { + tower.setup(); + } + } + + @EventHandler + public void live(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + } + + @Override + public void disable() + { + super.disable(); + _listeners.forEach(UtilServer::Unregister); + _listeners.clear(); + } + @EventHandler public void update(UpdateEvent event) { @@ -120,4 +229,17 @@ public class Moba extends TeamGame return map; } + + private GameTeam getTeam(String name) + { + for (GameTeam team : GetTeamList()) + { + if (team.GetName().equals(name)) + { + return team; + } + } + + return null; + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java index 91f0fa6e5..8bcb73016 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java @@ -1,22 +1,25 @@ package nautilus.game.arcade.game.games.moba; import nautilus.game.arcade.kit.Kit; +import org.bukkit.Color; public enum MobaRole { - ASSASSIN("Assassin", null), - HUNTER("Hunter", null), - MAGE("Mage", null), - WARRIOR("Warrior", null), + ASSASSIN("Assassin", Color.BLUE, null), + HUNTER("Hunter", Color.LIME, null), + MAGE("Mage", Color.RED, null), + WARRIOR("Warrior", Color.YELLOW, null), ; private String _name; + private Color _color; private Kit[] _kits; - MobaRole(String name, Kit[] kits) + MobaRole(String name, Color color, Kit[] kits) { _name = name; + _color = color; _kits = kits; } @@ -25,6 +28,11 @@ public enum MobaRole return _name; } + public Color getColor() + { + return _color; + } + public Kit[] getKits() { return _kits; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java new file mode 100644 index 000000000..a29eaf563 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -0,0 +1,124 @@ +package nautilus.game.arcade.game.games.moba.kit; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +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.ArcadeManager; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; + +public class HeroKit extends Kit +{ + + private final MobaRole _role; + + private static final int AMMO_SLOT = 7; + private ItemStack _ammo; + private long _giveTime; + private int _maxAmmo; + + private static final int RECALL_SLOT = 8; + private static final ItemStack RECALL_ITEM = new ItemBuilder(Material.BED) + .setTitle(C.cGreenB + "Recall to you Base") + .addLore("Clicking this item will teleport you back to your", "base after " + F.time("5") + " seconds.", "Taking damage or moving will cancel your teleport.") + .build(); + + public HeroKit(ArcadeManager manager, String name, String[] kitDesc, Perk[] kitPerks, ItemStack itemInHand, MobaRole role) + { + super(manager, name, KitAvailability.Free, kitDesc, kitPerks, null, itemInHand); + + _role = role; + } + + public MobaRole getRole() + { + return _role; + } + + public void setAmmo(ItemStack ammo, long giveTime) + { + _ammo = ammo; + _giveTime = giveTime; + } + + public void setMaxAmmo(int max) + { + _maxAmmo = max; + } + + protected boolean useAmmo(Player player, int amount) + { + ItemStack itemStack = player.getInventory().getItem(AMMO_SLOT); + + if (itemStack == null || itemStack.getAmount() < amount) + { + return false; + } + + itemStack.setAmount(itemStack.getAmount() - amount); + player.updateInventory(); + return true; + } + + @EventHandler + public void giveAmmo(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK || Manager.GetGame() == null || !Manager.GetGame().IsLive()) + { + return; + } + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!HasKit(player)) + { + continue; + } + + ItemStack itemStack = player.getInventory().getItem(AMMO_SLOT); + long giveTime = _giveTime; + + //TODO shop cooldown reduction + + if (!Recharge.Instance.use(player, "Ammo", giveTime, false, false)) + { + continue; + } + + if (itemStack == null) + { + itemStack = _ammo; + player.getInventory().setItem(AMMO_SLOT, itemStack); + player.updateInventory(); + continue; + } + + if (itemStack.getAmount() >= _maxAmmo) + { + continue; + } + + itemStack.setAmount(itemStack.getAmount() + 1); + player.updateInventory(); + } + } + + @Override + public void GiveItems(Player player) + { + PlayerInventory inventory = player.getInventory(); + + inventory.setItem(AMMO_SLOT, _ammo); + inventory.setItem(RECALL_SLOT, RECALL_ITEM); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/KitSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/KitSelection.java deleted file mode 100644 index 1fcea1335..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/KitSelection.java +++ /dev/null @@ -1,30 +0,0 @@ -package nautilus.game.arcade.game.games.moba.kit; - -import mineplex.core.common.util.UtilServer; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.Game.GameState; -import nautilus.game.arcade.game.games.moba.Moba; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; - -public class KitSelection implements Listener -{ - - private final - - public KitSelection(Moba moba) - { - UtilServer.RegisterEvents(this); - } - - @EventHandler - public void live(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Live) - { - return; - } - - UtilServer.Unregister(this); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java new file mode 100644 index 000000000..ae14c6523 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java @@ -0,0 +1,164 @@ +package nautilus.game.arcade.game.games.moba.kit; + +import mineplex.core.common.entity.ClientArmorStand; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilSkull; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.packethandler.IPacketHandler; +import mineplex.core.packethandler.PacketHandler.ListenerPriority; +import mineplex.core.packethandler.PacketInfo; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.kit.Kit; +import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.inventory.ItemStack; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; + +public class PregameSelection implements Listener, IPacketHandler +{ + + private final Moba _host; + private final Kit[] _kits; + private final Map _roleStands = new HashMap<>(); + + public PregameSelection(Moba host, Kit[] kits) + { + _host = host; + _kits = kits; + + _host.getArcadeManager().getPacketHandler().addPacketHandler(this, ListenerPriority.NORMAL, true, PacketPlayInUseEntity.class); + } + + // Setup + @EventHandler(priority = EventPriority.HIGHEST) + public void prepare(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + for (GameTeam team : _host.GetTeamList()) + { + if (team.GetColor() == ChatColor.RED) + { + spawnRoleUI(team, "PINK"); + } + else + { + spawnRoleUI(team, "PURPLE"); + } + } + } + + private void spawnRoleUI(GameTeam team, String dataKey) + { + AtomicInteger i = new AtomicInteger(); + List spawns = _host.WorldData.GetDataLocs(dataKey); + Location average = UtilAlg.getAverageLocation(team.GetSpawns()); + Player[] players = team.GetPlayers(true).toArray(new Player[0]); + + ItemStack head = new ItemBuilder(Material.SKULL_ITEM, (byte) 3).build(); + + UtilServer.runSyncLater(() -> + { + for (Location location : spawns) + { + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, average))); + + MobaRole role = MobaRole.values()[i.getAndIncrement()]; + ClientArmorStand stand = ClientArmorStand.spawn(prepareLocation(location), players); + + stand.setCustomNameVisible(true); + stand.setCustomName(C.cGreenB + role.getName() + C.cGray + " - " + C.cGreenB + "AVAILABLE"); + stand.setArms(true); + stand.setHelmet(head); + stand.setChestplate(buildColouredStack(Material.LEATHER_CHESTPLATE, role)); + stand.setLeggings(buildColouredStack(Material.LEATHER_LEGGINGS, role)); + stand.setBoots(buildColouredStack(Material.LEATHER_BOOTS, role)); + + _roleStands.put(stand, role); + } + }, 5); + } + + private Location prepareLocation(Location location) + { + Block block = location.getBlock(); + + block.setType(Material.SMOOTH_BRICK); + block.setData((byte) 3); + + return location.clone().add(0, 1, 0); + } + + private ItemStack buildColouredStack(Material material, MobaRole role) + { + return new ItemBuilder(material).setColor(role.getColor()).build(); + } + + // Listen for those packety clicks + @Override + public void handle(PacketInfo packetInfo) + { + PacketPlayInUseEntity packet = (PacketPlayInUseEntity) packetInfo.getPacket(); + Player player = packetInfo.getPlayer(); + int entityId = packet.a; + + for (ClientArmorStand stand : _roleStands.keySet()) + { + if (stand.getEntityId() != entityId) + { + continue; + } + + Bukkit.broadcastMessage("Beep beep I'm an amourstand, I said beep beep I have an id of " + entityId); + + packetInfo.setCancelled(true); + + MobaRole role = _roleStands.get(stand); + RoleSelectEvent event = new RoleSelectEvent(player, stand, role); + UtilServer.CallEvent(event); + + if (event.isCancelled()) + { + return; + } + + for (ClientArmorStand stand2 : _roleStands.keySet()) + { + stand2.remove(player); + } + } + } + + // Unregister + @EventHandler + public void live(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + + _host.getArcadeManager().getPacketHandler().removePacketHandler(this); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/RoleSelectEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/RoleSelectEvent.java new file mode 100644 index 000000000..d4c170c40 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/RoleSelectEvent.java @@ -0,0 +1,61 @@ +package nautilus.game.arcade.game.games.moba.kit; + +import mineplex.core.common.entity.ClientArmorStand; +import nautilus.game.arcade.game.games.moba.MobaRole; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +public class RoleSelectEvent extends PlayerEvent implements Cancellable +{ + + private static final HandlerList _handlers = new HandlerList(); + + private final ClientArmorStand _stand; + private final MobaRole _role; + + private boolean _cancel; + + public RoleSelectEvent(Player who, ClientArmorStand stand, MobaRole role) + { + super(who); + + _stand = stand; + _role = role; + } + + public ClientArmorStand getStand() + { + return _stand; + } + + public MobaRole getRole() + { + return _role; + } + + @Override + public boolean isCancelled() + { + return _cancel; + } + + @Override + public void setCancelled(boolean b) + { + _cancel = b; + } + + public static HandlerList getHandlerList() + { + return _handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/heroes/HeroHattori.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/heroes/HeroHattori.java new file mode 100644 index 000000000..ffda5fba2 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/heroes/HeroHattori.java @@ -0,0 +1,32 @@ +package nautilus.game.arcade.game.games.moba.kit.heroes; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +public class HeroHattori extends HeroKit +{ + + private static final String[] DESCRIPTION = { + "Something something" + }; + + private static final Perk[] PERKS = { + new PerkDoubleJump("Double Jump", 1, 1, true) + }; + + private static final ItemStack[] PLAYER_ITEMS = { + new ItemStack(Material.WOOD_SWORD), + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.NETHER_STAR); + + public HeroHattori(ArcadeManager manager) + { + super(manager, "Hattori", DESCRIPTION, PERKS, IN_HAND, MobaRole.ASSASSIN); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java new file mode 100644 index 000000000..136dd7d1f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java @@ -0,0 +1,136 @@ +package nautilus.game.arcade.game.games.moba.recall; + +import com.sun.org.apache.regexp.internal.RE; +import mineplex.core.common.util.*; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +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.games.moba.Moba; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.jooq.util.derby.sys.Sys; + +import java.util.*; + +public class Recall implements Listener +{ + + private static final int RECALL_TIME = 5000; + private static final double PARTICLE_HEIGHT = 2.5; + private static final double PARTICLE_RADIUS = 2.5; + + private final Moba _host; + + private final Set _sessions; + + public Recall(Moba host) + { + _host = host; + + _sessions = new HashSet<>(); + } + + @EventHandler + public void interactBed(PlayerInteractEvent event) + { + if (event.isCancelled()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + Player player = event.getPlayer(); + ItemStack itemStack = player.getItemInHand(); + + if (itemStack == null || itemStack.getType() != Material.BED) + { + return; + } + + _sessions.add(new RecallSession(player)); + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + { + return; + } + + long now = System.currentTimeMillis(); + + for (Player player : _host.GetPlayers(true)) + { + if (!_lastRecallStart.containsKey(player.getUniqueId())) + { + continue; + } + + long start = _lastRecallStart.get(player.getUniqueId()); + + if (UtilTime.elapsed(start, RECALL_TIME)) + { + _host.GetTeam(player).SpawnTeleport(player); + _lastRecallStart.remove(player.getUniqueId()); + } + else + { + Location location = player.getLocation().add(0, 0.25, 0); + double height = (now - start) / RECALL_TIME; + + for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 10) + { + double x = PARTICLE_RADIUS * Math.sin(theta); + double z = PARTICLE_RADIUS * Math.cos(theta); + + for (int y = 0; y < height * PARTICLE_HEIGHT; y += 0.5) + { + location.add(x, y, z); + + UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, location, 0, 0, 0, 0.1F, 1, ViewDist.LONG); + + location.subtract(x, y, z); + } + } + } + } + } + + @EventHandler + public void damage(CustomDamageEvent event) + { + if (event.GetDamageePlayer() == null) + { + return; + } + + RecallSession session = + } + + public RecallSession getSession(Player player) + { + for (RecallSession session : _sessions) + { + if (session.Player.equals(player)) + { + return session; + } + } + + return null; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/RecallSession.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/RecallSession.java new file mode 100644 index 000000000..0abca7401 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/RecallSession.java @@ -0,0 +1,19 @@ +package nautilus.game.arcade.game.games.moba.recall; + +import org.bukkit.Location; +import org.bukkit.entity.Player; + +class RecallSession +{ + + public Player Player; + public long Start; + public Location Location; + + public RecallSession(Player player) + { + Player = player; + Start = System.currentTimeMillis(); + Location = player.getLocation(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java new file mode 100644 index 000000000..95da9011c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -0,0 +1,16 @@ +package nautilus.game.arcade.game.games.moba.shop; + +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +public class MobaShop implements Listener +{ + + private final Moba _host; + + public MobaShop(Moba host) + { + _host = host; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java index 95cbc8edc..3c5167baa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java @@ -178,8 +178,6 @@ public class CapturePoint private void display(GameTeam team, boolean forward) { - Bukkit.broadcastMessage("progress=" + _progress + " forward=" + forward); - double toChange = Math.ceil(_wool.size() / MAX_PROGRESS) + 1; int changed = 0; for (Block block : _wool) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java new file mode 100644 index 000000000..c5d448938 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -0,0 +1,95 @@ +package nautilus.game.arcade.game.games.moba.structure.tower; + +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; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.utils.UtilVariant; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.Guardian; + +public class Tower +{ + + private final Moba _host; + private final Location _location; + private final GameTeam _team; + private int _lane; + private double _health; + private int _maxHealth; + private boolean _firstTower; + private Guardian _guardian; + private boolean _dead; + + public Tower(Moba host, Location location, GameTeam team, int lane, int health, boolean firstTower) + { + _host = host; + _location = location; + _team = team; + _lane = lane; + _health = health; + _maxHealth = health; + _firstTower = firstTower; + } + + public void setup() + { + if (_firstTower) + { + _guardian = _location.getWorld().spawn(_location, Guardian.class); + } + else + { + _guardian = UtilVariant.spawnElderGuardian(_location); + } + + _guardian.setCustomNameVisible(true); + updateDisplay(); + } + + public void updateTarget() + { + + } + + public void damage(double damage) + { + _health -= damage; + + if (_health <= 0) + { + UtilServer.CallEvent(new TowerDestroyEvent(this)); + _dead = true; + _guardian.remove(); + explode(); + } + else + { + updateDisplay(); + } + } + + private void updateDisplay() + { + float percentage = (float) _health / (float) _maxHealth; + + _guardian.setCustomName(UtilTextMiddle.progress(percentage)); + } + + private void explode() + { + _host.getArcadeManager().GetExplosion().BlockExplosion(UtilBlock.getBlocksInRadius(_location.clone().subtract(0, 4, 0), 4), _location, false); + _location.getWorld().playSound(_location, Sound.EXPLODE, 2, 0.6F); + UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _location, 0, 0, 0, 0.1F, 1, ViewDist.LONG); + } + + public boolean isDead() + { + return _dead; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerDestroyEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerDestroyEvent.java new file mode 100644 index 000000000..a7107a423 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerDestroyEvent.java @@ -0,0 +1,34 @@ +package nautilus.game.arcade.game.games.moba.structure.tower; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class TowerDestroyEvent extends Event +{ + + private static final HandlerList _handlers = new HandlerList(); + + private Tower _tower; + + public TowerDestroyEvent(Tower tower) + { + _tower = tower; + } + + public Tower getTower() + { + return _tower; + } + + public static HandlerList getHandlerList() + { + return _handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java index ce027ddac..1af689550 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java @@ -211,6 +211,8 @@ public abstract class UHC extends Game _state = UHCState.SAFE; + Prepare = false; + HideTeamSheep = true; StrictAntiHack = true; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java index 126bb399b..f046626b4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java @@ -104,7 +104,7 @@ public class GameHostManager implements Listener ultraGames.add(GameType.MonsterMaze); ultraGames.add(GameType.Gladiators); - //Hero Games + //HeroKit Games heroGames.add(GameType.ChampionsDominate); heroGames.add(GameType.ChampionsTDM); heroGames.add(GameType.ChampionsCTF); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java index 6d3c8e18b..fd1dc5e82 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java @@ -636,7 +636,7 @@ public class GameManager implements Listener return; // Sir, I'll handle this. - if (game instanceof UHC) + if (!game.Prepare) return; final ArrayList players = game.GetPlayers(true); diff --git a/Plugins/Nautilus.Game.PvP/src/nautilus/game/pvp/modules/serverreset/ServerResetCommand.java b/Plugins/Nautilus.Game.PvP/src/nautilus/game/pvp/modules/serverreset/ServerResetCommand.java index 8356e8fd6..d716ee669 100644 --- a/Plugins/Nautilus.Game.PvP/src/nautilus/game/pvp/modules/serverreset/ServerResetCommand.java +++ b/Plugins/Nautilus.Game.PvP/src/nautilus/game/pvp/modules/serverreset/ServerResetCommand.java @@ -44,7 +44,7 @@ public class ServerResetCommand extends CommandBase clientEvent.GetClient().Game().SetEconomyBalance(0); } - File economyDir = new File("economy/"); + File economyDir = new File("shop/"); FilenameFilter statsFilter = new FilenameFilter() { From 23d924f1371e7790524ce13cf3026fdd477f9a40 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 6 May 2017 20:51:49 +0100 Subject: [PATCH 04/57] Kit system --- .../gadgets/particle/ParticleCoalFumes.java | 2 +- .../src/mineplex/clanshub/HubManager.java | 2 +- .../src/nautilus/game/arcade/game/Game.java | 1 + .../game/arcade/game/games/moba/Moba.java | 295 +++++++++++++++++- .../arcade/game/games/moba/MobaPlayer.java | 17 + .../game/arcade/game/games/moba/MobaRole.java | 20 +- .../arcade/game/games/moba/kit/HeroKit.java | 32 +- .../arcade/game/games/moba/kit/HeroSkill.java | 227 ++++++++++++++ .../game/games/moba/kit/PregameSelection.java | 131 +++++++- .../game/games/moba/kit/devon/HeroDevon.java | 59 ++++ .../game/games/moba/kit/devon/SkillBoost.java | 63 ++++ .../games/moba/kit/devon/SkillInfinity.java | 114 +++++++ .../games/moba/kit/devon/SkillTNTArrows.java | 104 ++++++ .../games/moba/kit/hattori/HeroHattori.java | 54 ++++ .../games/moba/kit/hattori/SkillDash.java | 105 +++++++ .../moba/kit/hattori/SkillNinjaBlade.java | 94 ++++++ .../games/moba/kit/hattori/SkillSnowball.java | 91 ++++++ .../games/moba/kit/heroes/HeroHattori.java | 32 -- .../arcade/game/games/moba/recall/Recall.java | 47 ++- .../games/moba/structure/tower/Tower.java | 25 +- .../game/arcade/managers/GameManager.java | 29 +- 21 files changed, 1432 insertions(+), 112 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillBoost.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillDash.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/heroes/HeroHattori.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java index 467db55d2..236bc1e8a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/ParticleCoalFumes.java @@ -20,7 +20,7 @@ public class ParticleCoalFumes extends ParticleGadget public ParticleCoalFumes(GadgetManager manager) { super(manager, "Coal Fumes", - UtilText.splitLineToArray(C.cGray + "Being on the Naughty List does have some perks... if you love coal, that is...", LineFormat.LORE), + UtilText.splitLineToArray(C.cGray + "Being on the Naughty List does have some hattori... if you love coal, that is...", LineFormat.LORE), -1, Material.COAL, (byte) 0); } diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java index bc74ec6f1..29e6ab472 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java @@ -674,7 +674,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter _lastPlayerCount = playerCount; Bukkit.getOnlinePlayers().stream().filter(player -> _clientManager.Get(player).GetRank() == Rank.ALL).forEach(player -> { - UtilTextBottom.display(C.cGray + "Visit " + F.elem("http://www.mineplex.com/shop") + " for exclusive perks!", player); + UtilTextBottom.display(C.cGray + "Visit " + F.elem("http://www.mineplex.com/shop") + " for exclusive hattori!", player); }); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 9a1006b42..74f2baf73 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -295,6 +295,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed public boolean Prepare = true; public long PrepareTime = 9000; public boolean PrepareFreeze = true; + public boolean PrepareAutoAnnounce = true; public boolean PlaySoundGameStart = true; public double XpMult = 1; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index c7c79dd48..fe6591cc4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -1,27 +1,39 @@ package nautilus.game.arcade.game.games.moba; -import mineplex.core.common.util.UtilServer; +import mineplex.core.common.entity.ClientArmorStand; +import mineplex.core.common.util.*; +import mineplex.core.explosion.ExplosionEvent; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.combat.DeathMessageType; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GamePrepareCountdownCommence; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.game.games.moba.kit.KitPlayer; -import nautilus.game.arcade.game.games.moba.kit.PregameSelection; +import nautilus.game.arcade.game.games.moba.kit.*; +import nautilus.game.arcade.game.games.moba.kit.devon.HeroDevon; +import nautilus.game.arcade.game.games.moba.kit.hattori.HeroHattori; import nautilus.game.arcade.game.games.moba.recall.Recall; import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.Perk; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.metadata.FixedMetadataValue; import java.util.*; import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; public class Moba extends TeamGame { @@ -29,11 +41,14 @@ public class Moba extends TeamGame private static final String[] DESCRIPTION = { "MORE CAPTURE POINTS" }; + private static final long PREPARE_TIME = TimeUnit.MINUTES.toMillis(1); + + private final HeroKit[] _kits; private final List _capturePoints = new ArrayList<>(3); private final List _towers = new ArrayList<>(12); - private final Map _roles = new HashMap<>(); + private final Set _playerData = new HashSet<>(); private final Set _listeners = new HashSet<>(); @@ -41,20 +56,28 @@ public class Moba extends TeamGame { super(manager, GameType.MOBA, new Kit[] { new KitPlayer(manager) }, DESCRIPTION); - //Prepare = false; + _kits = new HeroKit[] { + new HeroHattori(Manager), + new HeroDevon(Manager) + }; + + PrepareAutoAnnounce = false; PrepareFreeze = false; + PrepareTime = PREPARE_TIME; DeathOut = false; DeathSpectateSecs = 10; HungerSet = 20; DontAllowOverfill = false; + DamageFall = false; + new CompassModule() .setGiveCompass(true) .setGiveCompassToSpecs(true) .setGiveCompassToAlive(false) .register(this); - Listener preGameSelection = new PregameSelection(this, null); + Listener preGameSelection = new PregameSelection(this); _listeners.add(preGameSelection); Listener recall = new Recall(this); @@ -105,14 +128,14 @@ public class Moba extends TeamGame try { - firstTower = Integer.parseInt(components[3]) == 1; + firstTower = components[3].equalsIgnoreCase("1"); } catch (NumberFormatException e) { continue; } - int health = 1000; + int health = firstTower ? 250 : 500; GameTeam gameTeam = getTeam(team); if (gameTeam == null) @@ -157,7 +180,27 @@ public class Moba extends TeamGame private void writePrepare() { + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellowB + "Hero Selection"); + Scoreboard.write(UtilTime.MakeStr(GetStateTime() + PREPARE_TIME - System.currentTimeMillis())); + + Scoreboard.writeNewLine(); + + Scoreboard.write(C.cYellowB + "Players"); + int kits = 0; + + for (MobaPlayer player : _playerData) + { + if (player.Kit != null) + { + kits++; + } + } + + Scoreboard.write(kits + "/" + GetPlayers(true).size()); + + Scoreboard.writeNewLine(); } private void writeLive() @@ -178,10 +221,21 @@ public class Moba extends TeamGame return; } + // Override those kits! + setKits(_kits); + + // Store player data + for (Player player : GetPlayers(true)) + { + _playerData.add(new MobaPlayer(player)); + } + + CreatureAllowOverride = true; for (Tower tower : _towers) { tower.setup(); } + CreatureAllowOverride = false; } @EventHandler @@ -191,6 +245,19 @@ public class Moba extends TeamGame { return; } + + UtilTextBottom.display(C.cRedB + "!!! Battle !!!", UtilServer.getPlayers()); + + for (MobaPlayer mobaPlayer : _playerData) + { + HeroKit kit = mobaPlayer.Kit; + Perk perk = kit.GetPerks()[kit.GetPerks().length - 1]; + + if (perk instanceof HeroSkill) + { + ((HeroSkill) perk).useSkill(mobaPlayer.Player); + } + } } @Override @@ -215,6 +282,118 @@ public class Moba extends TeamGame } } + @EventHandler + public void updatePrepare(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC || GetState() != GameState.Prepare) + { + return; + } + + if (!UtilTime.elapsed(GetStateTime(), PREPARE_TIME)) + { + for (Player player : GetPlayers(true)) + { + Kit kit = GetKit(player); + + if (!(kit instanceof HeroKit)) + { + return; + } + } + } + + AnnounceGame(); + StartPrepareCountdown(); + + //Event + GamePrepareCountdownCommence countdownEvent = new GamePrepareCountdownCommence(this); + UtilServer.CallEvent(countdownEvent); + + // If players took too long, just give them a random free role and kit. + for (Player player : GetPlayers(true)) + { + Kit kit = GetKit(player); + + if (kit instanceof HeroKit) + { + continue; + } + + HeroKit heroKit = getRandomKit(player); + MobaPlayer mobaPlayer = getData(player); + + mobaPlayer.Role = heroKit.getRole(); + mobaPlayer.Kit = heroKit; + + SetKit(player, heroKit, true); + } + + PrepareTime = 0; + Manager.GetChat().Silence(0, false); + } + + @EventHandler + public void roleSelect(RoleSelectEvent event) + { + Player player = event.getPlayer(); + MobaRole role = event.getRole(); + ClientArmorStand stand = event.getStand(); + + if (stand.hasMetadata("owned")) + { + player.sendMessage(F.main("Game", "Another player has already chosen this role.")); + event.setCancelled(true); + return; + } + + // Store inside the stand that it is claimed by a player + stand.setMetadata("owned", new FixedMetadataValue(Manager.getPlugin(), true)); + + // Show that the kit is claimed. + stand.setCustomName(C.cGreenB + role.getName() + C.cGray + " - " + player.getName()); + + // Store the role of the player + getData(player).Role = role; + } + + @Override + public void SetKit(Player player, Kit kit, boolean announce) + { + super.SetKit(player, kit, announce); + + if (kit instanceof HeroKit) + { + getData(player).Kit = (HeroKit) kit; + } + } + + @Override + public void RespawnPlayer(Player player) + { + MobaPlayer mobaPlayer = getData(player); + + player.eject(); + Manager.Clear(player); + GetTeam(player).SpawnTeleport(player); + SetKit(player, mobaPlayer.Kit, false); + } + + @EventHandler + public void combatDeath(CombatDeathEvent event) + { + event.SetBroadcastType(DeathMessageType.Detailed); + } + + // Clear up memory + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + Player player = event.getPlayer(); + + _playerData.removeIf(mobaPlayer -> mobaPlayer.Player.equals(player)); + } + private Map getLocationStartsWith(String s) { Map map = new HashMap<>(); @@ -234,7 +413,7 @@ public class Moba extends TeamGame { for (GameTeam team : GetTeamList()) { - if (team.GetName().equals(name)) + if (team.GetName().equalsIgnoreCase(name)) { return team; } @@ -242,4 +421,102 @@ public class Moba extends TeamGame return null; } + + public HeroKit[] getKits() + { + return _kits; + } + + public List getKits(MobaRole role) + { + List kits = new ArrayList<>(); + + for (HeroKit kit : _kits) + { + if (kit.getRole() == role) + { + kits.add(kit); + } + } + + return kits; + } + + public MobaPlayer getData(Player player) + { + for (MobaPlayer mobaPlayer : _playerData) + { + if (mobaPlayer.Player.equals(player)) + { + return mobaPlayer; + } + } + + return null; + } + + private HeroKit getRandomKit(Player player) + { + MobaPlayer mobaPlayer = getData(player); + + if (mobaPlayer.Role == null) + { + MobaRole role = getRandomRole(player); + + return getRandomKit(role); + } + else if (mobaPlayer.Kit == null) + { + return getRandomKit(mobaPlayer.Role); + } + + return null; + } + + private HeroKit getRandomKit(MobaRole role) + { + for (HeroKit kit : _kits) + { + if (kit.getRole() == role) + { + return kit; + } + } + + return null; + } + + private MobaRole getRandomRole(Player player) + { + List roles = new ArrayList<>(); + + for (MobaPlayer mobaPlayer : getTeamData(GetTeam(player))) + { + MobaRole role = mobaPlayer.Role; + + if (role != null) + { + roles.add(role); + } + } + + return UtilAlg.Random(Arrays.asList(MobaRole.values()), roles); + } + + public List getTeamData(GameTeam team) + { + List players = new ArrayList<>(); + + for (MobaPlayer mobaPlayer : _playerData) + { + GameTeam otherTeam = GetTeam(mobaPlayer.Player); + + if (team.equals(otherTeam)) + { + players.add(mobaPlayer); + } + } + + return players; + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java new file mode 100644 index 000000000..82c06bf33 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java @@ -0,0 +1,17 @@ +package nautilus.game.arcade.game.games.moba; + +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import org.bukkit.entity.Player; + +public class MobaPlayer +{ + + public final Player Player; + public MobaRole Role; + public HeroKit Kit; + + public MobaPlayer(Player player) + { + Player = player; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java index 8bcb73016..ee648883c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java @@ -1,26 +1,26 @@ package nautilus.game.arcade.game.games.moba; -import nautilus.game.arcade.kit.Kit; +import org.bukkit.ChatColor; import org.bukkit.Color; public enum MobaRole { - ASSASSIN("Assassin", Color.BLUE, null), - HUNTER("Hunter", Color.LIME, null), - MAGE("Mage", Color.RED, null), - WARRIOR("Warrior", Color.YELLOW, null), + ASSASSIN("Assassin", Color.BLUE, ChatColor.AQUA), + HUNTER("Hunter", Color.LIME, ChatColor.GREEN), + MAGE("Mage", Color.RED, ChatColor.RED), + WARRIOR("Warrior", Color.YELLOW, ChatColor.GOLD), ; private String _name; private Color _color; - private Kit[] _kits; + private ChatColor _chatColor; - MobaRole(String name, Color color, Kit[] kits) + MobaRole(String name, Color color, ChatColor chatColor) { _name = name; _color = color; - _kits = kits; + _chatColor = chatColor; } public String getName() @@ -33,8 +33,8 @@ public enum MobaRole return _color; } - public Kit[] getKits() + public ChatColor getChatColor() { - return _kits; + return _chatColor; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index a29eaf563..705581001 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.moba.kit; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -11,6 +12,7 @@ import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -29,8 +31,8 @@ public class HeroKit extends Kit private static final int RECALL_SLOT = 8; private static final ItemStack RECALL_ITEM = new ItemBuilder(Material.BED) - .setTitle(C.cGreenB + "Recall to you Base") - .addLore("Clicking this item will teleport you back to your", "base after " + F.time("5") + " seconds.", "Taking damage or moving will cancel your teleport.") + .setTitle(C.cGreenB + "Recall to your Base") + .addLore("Clicking this item will teleport you back to your", "base after " + F.time("5") + " seconds.", "Taking damage or moving will cancel", "your teleport.") .build(); public HeroKit(ArcadeManager manager, String name, String[] kitDesc, Perk[] kitPerks, ItemStack itemInHand, MobaRole role) @@ -38,6 +40,7 @@ public class HeroKit extends Kit super(manager, name, KitAvailability.Free, kitDesc, kitPerks, null, itemInHand); _role = role; + _maxAmmo = 64; } public MobaRole getRole() @@ -73,14 +76,14 @@ public class HeroKit extends Kit @EventHandler public void giveAmmo(UpdateEvent event) { - if (event.getType() != UpdateType.TICK || Manager.GetGame() == null || !Manager.GetGame().IsLive()) + if (event.getType() != UpdateType.FASTEST || Manager.GetGame() == null || !Manager.GetGame().IsLive() || _ammo == null) { return; } for (Player player : Manager.GetGame().GetPlayers(true)) { - if (!HasKit(player)) + if (!HasKit(player) || UtilPlayer.isSpectator(player)) { continue; } @@ -99,7 +102,6 @@ public class HeroKit extends Kit { itemStack = _ammo; player.getInventory().setItem(AMMO_SLOT, itemStack); - player.updateInventory(); continue; } @@ -109,7 +111,6 @@ public class HeroKit extends Kit } itemStack.setAmount(itemStack.getAmount() + 1); - player.updateInventory(); } } @@ -120,5 +121,24 @@ public class HeroKit extends Kit inventory.setItem(AMMO_SLOT, _ammo); inventory.setItem(RECALL_SLOT, RECALL_ITEM); + + Bukkit.broadcastMessage(""); + Bukkit.broadcastMessage(player.getName()); + + for (Perk perk : GetPerks()) + { + if (!(perk instanceof HeroSkill)) + { + continue; + } + + HeroSkill skill = (HeroSkill) perk; + + if (skill.getItemStack() != null) + { + Bukkit.broadcastMessage("Giving kit " + GetName() + ", perk " + skill.GetName() + ", item " + skill.getItemStack().getItemMeta().getDisplayName()); + inventory.setItem(skill.getSlot(), skill.isOnCooldown(player) ? skill.getCooldownItemStack() : skill.getItemStack()); + } + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java new file mode 100644 index 000000000..252a69089 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -0,0 +1,227 @@ +package nautilus.game.arcade.game.games.moba.kit; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.PlayerKitGiveEvent; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +public class HeroSkill extends Perk +{ + + private ItemStack _item; + private ItemStack _cooldownItem; + private final int _slot; + private final ActionType _actionType; + private final boolean _sneakActivate; + + private long _cooldown; + + private final Map _lastSkill = new HashMap<>(); + + public HeroSkill(String name, String[] perkDesc) + { + this(name, perkDesc, null, -1, null); + } + + public HeroSkill(String name, String[] perkDesc, ItemStack itemStack, int slot, ActionType actionType) + { + this(name, perkDesc, itemStack, slot, actionType, false); + } + + public HeroSkill(String name, String[] perkDesc, ItemStack itemStack, int slot, ActionType actionType, boolean sneakActivate) + { + super(name, perkDesc); + + _item = itemStack; + _slot = slot; + _actionType = actionType; + _sneakActivate = sneakActivate; + + prettifyItem(); + } + + protected void setCooldown(long cooldown) + { + _cooldown = cooldown; + } + + private void prettifyItem() + { + String action = "Click"; + + if (_actionType == ActionType.L) + { + action = "Left Click"; + } + else if (_actionType == ActionType.R) + { + action = "Right Click"; + } + + if (_sneakActivate) + { + action += "/Sneak"; + } + + _item = new ItemBuilder(_item) + .setTitle(C.cYellowB + action + C.cGray + " - " + C.cGreenB + GetName()) + .addLore(GetDesc()) + .build(); + _cooldownItem = new ItemBuilder(Material.INK_SACK, (byte) 8) + .setTitle(C.cRed + GetName()) + .addLore(GetDesc()) + .build(); + } + +// @Override +// public void SetHost(Kit kit) +// { +// super.SetHost(kit); +// +// _kit = (HeroKit) kit; +// } + + @EventHandler + public void giveItem(PlayerKitGiveEvent event) + { + event.getPlayer().getInventory().setItem(_slot, isOnCooldown(event.getPlayer()) ? _cooldownItem : _item); + } + + @EventHandler + public void clearCooldowns(PlayerQuitEvent event) + { + UUID key = event.getPlayer().getUniqueId(); + + _lastSkill.remove(key); + } + + protected boolean isSkillItem(PlayerInteractEvent event) + { + if (event.isCancelled()) + { + return false; + } + + if (!UtilEvent.isAction(event, _actionType)) + { + if (_actionType != null || event.getAction() == Action.PHYSICAL) + { + return false; + } + } + + Player player = event.getPlayer(); + ItemStack itemStack = event.getItem(); + + if (!hasPerk(player) || UtilPlayer.isSpectator(player) || itemStack == null || !itemStack.isSimilar(_item)) + { + return false; + } + + return true; + } + + protected boolean isSkillSneak(PlayerToggleSneakEvent event) + { + if (event.isCancelled() || !event.isSneaking()) + { + return false; + } + + Player player = event.getPlayer(); + + if (!hasPerk(player) || UtilPlayer.isSpectator(player) || !player.getInventory().getItem(_slot).isSimilar(_item)) + { + return false; + } + + return true; + } + + public void useSkill(Player player) + { + _lastSkill.put(player.getUniqueId(), System.currentTimeMillis()); + if (_cooldown > 0 && !UtilPlayer.isSpectator(player)) + { + player.getInventory().setItem(_slot, _cooldownItem); + } + } + + @EventHandler + public void updateCooldowns(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST || _item == null) + { + return; + } + + long current = System.currentTimeMillis(); + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!hasPerk(player) || UtilPlayer.isSpectator(player) || !_lastSkill.containsKey(player.getUniqueId())) + { + continue; + } + + ItemStack itemStack = player.getInventory().getItem(_slot); + long start = _lastSkill.get(player.getUniqueId()); + long cooldown = _cooldown; + + //TODO Shop cooldown reduction + + boolean done = UtilTime.elapsed(start, cooldown); + + if (done) + { + _lastSkill.remove(player.getUniqueId()); + player.getInventory().setItem(_slot, _item); + } + else + { + long timeDiff = current - start; + double amount = (int) (cooldown / 1000) - Math.ceil((double) timeDiff / 1000); + + itemStack.setAmount((int) amount); + } + } + } + + public ItemStack getItemStack() + { + return _item; + } + + public ItemStack getCooldownItemStack() + { + return _cooldownItem; + } + + public int getSlot() + { + return _slot; + } + + public boolean isOnCooldown(Player player) + { + return _lastSkill.containsKey(player.getUniqueId()); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java index ae14c6523..4d56b39ee 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java @@ -1,25 +1,22 @@ package nautilus.game.arcade.game.games.moba.kit; import mineplex.core.common.entity.ClientArmorStand; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilSkull; +import mineplex.core.common.util.*; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketHandler.ListenerPriority; import mineplex.core.packethandler.PacketInfo; import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.events.PlayerKitApplyEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaPlayer; import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.kit.Kit; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; +import org.bukkit.*; +import org.bukkit.FireworkEffect.Type; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -36,13 +33,12 @@ public class PregameSelection implements Listener, IPacketHandler { private final Moba _host; - private final Kit[] _kits; private final Map _roleStands = new HashMap<>(); + private final Map _kitStands = new HashMap<>(); - public PregameSelection(Moba host, Kit[] kits) + public PregameSelection(Moba host) { _host = host; - _kits = kits; _host.getArcadeManager().getPacketHandler().addPacketHandler(this, ListenerPriority.NORMAL, true, PacketPlayInUseEntity.class); } @@ -80,6 +76,11 @@ public class PregameSelection implements Listener, IPacketHandler UtilServer.runSyncLater(() -> { + for (Player player : _host.GetPlayers(true)) + { + displayRoleInformation(player); + } + for (Location location : spawns) { location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, average))); @@ -100,6 +101,48 @@ public class PregameSelection implements Listener, IPacketHandler }, 5); } + private void spawnKitUI(Player player, String dataKey) + { + AtomicInteger i = new AtomicInteger(); + GameTeam team = _host.GetTeam(player); + List spawns = _host.WorldData.GetDataLocs(dataKey); + Location average = UtilAlg.getAverageLocation(team.GetSpawns()); + + MobaPlayer mobaPlayer = _host.getData(player); + + List heroKits = _host.getKits(mobaPlayer.Role); + + ItemStack head = new ItemBuilder(Material.SKULL_ITEM, (byte) 2).build(); + + UtilServer.runSyncLater(() -> + { + for (Location location : spawns) + { + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, average))); + + HeroKit kit = heroKits.get(i.getAndIncrement()); + ClientArmorStand stand = ClientArmorStand.spawn(location.clone().add(0, 1, 0), player); + + stand.setCustomNameVisible(true); + stand.setCustomName(C.cGreenB + kit.GetName()); + stand.setArms(true); + stand.setHelmet(head); +// stand.setChestplate(buildColouredStack(Material.LEATHER_CHESTPLATE, role)); +// stand.setLeggings(buildColouredStack(Material.LEATHER_LEGGINGS, role)); +// stand.setBoots(buildColouredStack(Material.LEATHER_BOOTS, role)); + FireworkEffect effect = FireworkEffect.builder().with(Type.BURST).withColor(Color.LIME).withFade(Color.WHITE).withFlicker().build(); + UtilFirework.playFirework(stand.getLocation(), effect); + + _kitStands.put(stand, kit); + + if (i.get() == heroKits.size()) + { + break; + } + } + }, 20); + } + private Location prepareLocation(Location location) { Block block = location.getBlock(); @@ -115,6 +158,12 @@ public class PregameSelection implements Listener, IPacketHandler return new ItemBuilder(material).setColor(role.getColor()).build(); } + private void removePodiums() + { + _host.WorldData.GetDataLocs("PINK").forEach(location -> location.getBlock().setType(Material.AIR)); + _host.WorldData.GetDataLocs("PURPLE").forEach(location -> location.getBlock().setType(Material.AIR)); + } + // Listen for those packety clicks @Override public void handle(PacketInfo packetInfo) @@ -130,8 +179,6 @@ public class PregameSelection implements Listener, IPacketHandler continue; } - Bukkit.broadcastMessage("Beep beep I'm an amourstand, I said beep beep I have an id of " + entityId); - packetInfo.setCancelled(true); MobaRole role = _roleStands.get(stand); @@ -147,7 +194,54 @@ public class PregameSelection implements Listener, IPacketHandler { stand2.remove(player); } + + GameTeam team = _host.GetTeam(player); + + if (team == null) + { + return; + } + + if (team.GetColor() == ChatColor.RED) + { + spawnKitUI(player, "PINK"); + } + else + { + spawnKitUI(player, "PURPLE"); + } + + displayKitInformation(player, role); } + + for (ClientArmorStand stand : _kitStands.keySet()) + { + if (stand.getEntityId() != entityId) + { + continue; + } + + packetInfo.setCancelled(true); + + HeroKit kit = _kitStands.get(stand); + + for (ClientArmorStand stand2 : _kitStands.keySet()) + { + stand2.remove(player); + } + + _host.SetKit(player, kit, true); + } + } + + private void displayRoleInformation(Player player) + { + UtilTextMiddle.display(C.cYellowB + "Role", "Select the role you would like to play", 10, 40, 10, player); + } + + private void displayKitInformation(Player player, MobaRole role) + { + UtilTextMiddle.display(role.getChatColor() + role.getName(), "Select your " + role.getChatColor() + "Hero", 10, 40, 10, player); } // Unregister @@ -159,6 +253,17 @@ public class PregameSelection implements Listener, IPacketHandler return; } + for (ClientArmorStand stand : _roleStands.keySet()) + { + stand.remove(); + } + + for (ClientArmorStand stand : _kitStands.keySet()) + { + stand.remove(); + } + + removePodiums(); _host.getArcadeManager().getPacketHandler().removePacketHandler(this); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java new file mode 100644 index 000000000..a60d08800 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java @@ -0,0 +1,59 @@ +package nautilus.game.arcade.game.games.moba.kit.devon; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.game.games.moba.kit.hattori.SkillDash; +import nautilus.game.arcade.game.games.moba.kit.hattori.SkillNinjaBlade; +import nautilus.game.arcade.game.games.moba.kit.hattori.SkillSnowball; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkFletcher; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; + +public class HeroDevon extends HeroKit +{ + + private static final String[] DESCRIPTION = { + "Something something" + }; + + private static final Perk[] PERKS = { + new SkillTNTArrows(1), + new SkillBoost(2), + new SkillInfinity(3) + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.BOW); + + private static final ItemStack BOW = new ItemBuilder(Material.BOW) + .setTitle(C.cGreenB + "Bow") + .setUnbreakable(true) + .build(); + + private static final ItemStack AMMO = new ItemBuilder(Material.ARROW) + .setTitle(C.cYellowB + "Hunting Arrow") + .build(); + + public HeroDevon(ArcadeManager manager) + { + super(manager, "Devon", DESCRIPTION, PERKS, IN_HAND, MobaRole.HUNTER); + + setAmmo(AMMO, 3000); + setMaxAmmo(3); + } + + @Override + public void GiveItems(Player player) + { + // TODO remove this when shop is implemented + PlayerInventory inventory = player.getInventory(); + inventory.setItem(0, BOW); + + super.GiveItems(player); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillBoost.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillBoost.java new file mode 100644 index 000000000..6de9c1330 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillBoost.java @@ -0,0 +1,63 @@ +package nautilus.game.arcade.game.games.moba.kit.devon; + +import mineplex.minecraft.game.core.condition.ConditionFactory; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.inventory.ItemStack; + +public class SkillBoost extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Gain Speed II and Jump Boost I for 3 seconds.", + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); + + public SkillBoost(int slot) + { + super("Hunters Boost", DESCRIPTION, SKILL_ITEM, slot, null, true); + + setCooldown(10000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + useSkill(player); + } + + @EventHandler + public void toggleSneak(PlayerToggleSneakEvent event) + { + if (!isSkillSneak(event)) + { + return; + } + + Player player = event.getPlayer(); + useSkill(player); + } + + @Override + public void useSkill(Player player) + { + super.useSkill(player); + + ConditionFactory factory = Manager.GetCondition().Factory(); + int time = 3; + + factory.Speed(GetName(), player, null, time, 1, true, true, false); + factory.Jump(GetName(), player, null, time, 0, true, true, false); + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java new file mode 100644 index 000000000..85f4852f0 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java @@ -0,0 +1,114 @@ +package nautilus.game.arcade.game.games.moba.kit.devon; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +public class SkillInfinity extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "For 7 seconds, your arrow shots don't consume arrows.", + "They also become heat-seeking and inflict wither onto players." + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); + + private final Map _arrows = new HashMap<>(); + + public SkillInfinity(int slot) + { + super("Infinity", DESCRIPTION, SKILL_ITEM, slot, null); + + setCooldown(60000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + ItemStack bow = player.getInventory().getItem(0); + + if (bow == null || bow.getType() != Material.BOW) + { + return; + } + + bow.addEnchantment(Enchantment.ARROW_INFINITE, 0); + Recharge.Instance.useForce(player, GetName(), 7000, false); + + Manager.runSyncLater(() -> bow.removeEnchantment(Enchantment.ARROW_INFINITE), 7 * 20); + } + + @EventHandler + public void shootArrow(EntityShootBowEvent event) + { + if (!(event.getEntity() instanceof Player)) + { + return; + } + + Player player = (Player) event.getEntity(); + + _arrows.put(event.getProjectile(), player); + } + + @EventHandler + public void updateArrowTarget(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST || !Manager.isGameInProgress()) + { + return; + } + + for (Entry entry : _arrows.entrySet()) + { + Entity entity = entry.getKey(); + Player player = entry.getValue(); + GameTeam team = Manager.GetGame().GetTeam(player); + + for (LivingEntity nearby : UtilEnt.getInRadius(entity.getLocation(), 3).keySet()) + { + if (nearby instanceof Player) + { + // If the target is on the same team + if (team.equals(Manager.GetGame().GetTeam((Player) nearby))) + { + continue; + } + } + + entity.setVelocity(UtilAlg.getTrajectory(entity.getLocation(), nearby.getLocation())); + } + } + } + + @EventHandler + public void projectileHit(ProjectileHitEvent event) + { + _arrows.remove(event.getEntity()); + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java new file mode 100644 index 000000000..999cd5c69 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java @@ -0,0 +1,104 @@ +package nautilus.game.arcade.game.games.moba.kit.devon; + +import mineplex.core.common.util.UtilInv; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.kit.hattori.SkillSnowball; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +public class SkillTNTArrows extends HeroSkill implements IThrown +{ + + private static final String[] DESCRIPTION = { + "Your next 3 arrows are infused with TNT.", + "They explode on contact dealing damage and knockback." + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.TNT); + + private final Map _arrows = new HashMap<>(); + + public SkillTNTArrows(int slot) + { + super("TNT Infusion", DESCRIPTION, SKILL_ITEM, slot, null); + + setCooldown(17000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + _arrows.put(player.getUniqueId(), 3); + player.getItemInHand().addEnchantment(UtilInv.getDullEnchantment(), 1); + } + + @EventHandler + public void shootArrow(EntityShootBowEvent event) + { + if (!(event.getEntity() instanceof Player)) + { + return; + } + + Player player = (Player) event.getEntity(); + + if (!hasPerk(player) || !_arrows.containsKey(player.getUniqueId())) + { + return; + } + + int arrows = _arrows.get(player.getUniqueId()); + + if (arrows == 1) + { + _arrows.remove(player.getUniqueId()); + useSkill(player); + } + else + { + _arrows.put(player.getUniqueId(), arrows - 1); + } + + Manager.GetProjectile().AddThrow(event.getProjectile(), player, this, -1, true, true, true, false, 0.5F); + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + Location location = data.getThrown().getLocation(); + location.getWorld().createExplosion(location.getX(), location.getY(), location.getZ(), 4, false, false); + data.getThrown().remove(); + } + + @Override + public void Idle(ProjectileUser data) + { + + } + + @Override + public void Expire(ProjectileUser data) + { + + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java new file mode 100644 index 000000000..0234ed154 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java @@ -0,0 +1,54 @@ +package nautilus.game.arcade.game.games.moba.kit.hattori; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; + +public class HeroHattori extends HeroKit +{ + + private static final String[] DESCRIPTION = { + "Something something" + }; + + private static final Perk[] PERKS = { + new PerkDoubleJump("Double Jump", 1, 1, true), + new SkillSnowball(0), + new SkillDash(2), + new SkillNinjaBlade(3) + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.NETHER_STAR); + + private static final ItemStack SWORD = new ItemBuilder(Material.WOOD_SWORD) + .setTitle(C.cGreenB + "Sword") + .setUnbreakable(true) + .build(); + + public HeroHattori(ArcadeManager manager) + { + super(manager, "Hattori", DESCRIPTION, PERKS, IN_HAND, MobaRole.ASSASSIN); + } + + @Override + public void GiveItems(Player player) + { + Bukkit.broadcastMessage("Hello " + player.getName()); + + // TODO remove this when shop is implemented + PlayerInventory inventory = player.getInventory(); + inventory.setItem(1, SWORD); + + Bukkit.broadcastMessage("Now call the super for " + player.getName()); + super.GiveItems(player); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillDash.java new file mode 100644 index 000000000..8d73dc8ac --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillDash.java @@ -0,0 +1,105 @@ +package nautilus.game.arcade.game.games.moba.kit.hattori; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilFirework; +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 nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.FireworkEffect; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +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.PlayerToggleSneakEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +public class SkillDash extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Dash forward dealing damage to any enemy", + "you collide with." + }; + + private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); + + public SkillDash(int slot) + { + super("Dash", DESCRIPTION, SKILL_ITEM, slot, null, true); + + setCooldown(7000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + useSkill(player); + } + + @EventHandler + public void toggleSneak(PlayerToggleSneakEvent event) + { + if (!isSkillSneak(event)) + { + return; + } + + Player player = event.getPlayer(); + + useSkill(player); + } + + @Override + public void useSkill(Player player) + { + super.useSkill(player); + + LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.8, 10, null, ParticleType.FIREWORKS_SPARK, + UtilServer.getPlayers()); + Set hitPlayers = new HashSet<>(); + Game game = Manager.GetGame(); + GameTeam team = game.GetTeam(player); + + while (!lineParticle.update()) + { + for (Player other : UtilPlayer.getNearby(lineParticle.getLastLocation(), 2)) + { + if (hitPlayers.contains(other.getUniqueId()) || player.equals(other) || team.equals(game.GetTeam(other))) + { + continue; + } + + hitPlayers.add(other.getUniqueId()); + Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, 8, true, true, false, player.getName(), GetName()); + player.sendMessage(F.main("Game", "You hit " + F.elem(other.getName()) + " with " + F.skill(GetName()) + ".")); + } + } + + Location location = lineParticle.getDestination(); + FireworkEffect effect = FireworkEffect.builder().with(Type.BALL).withColor(team.GetColorBase()).withFlicker().build(); + + UtilFirework.playFirework(player.getLocation(), effect); + player.teleport(location.add(0, 0.5, 0)); + UtilFirework.playFirework(player.getLocation(), effect); + + player.sendMessage(F.main("Game", "You used " + F.skill(GetName()) + ".")); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java new file mode 100644 index 000000000..e4562334a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java @@ -0,0 +1,94 @@ +package nautilus.game.arcade.game.games.moba.kit.hattori; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +public class SkillNinjaBlade extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Turns into a Diamond Sword that deals extreme", + "damage to any player hit by it." + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); + private static final ItemStack ACTIVE_ITEM = new ItemBuilder(Material.DIAMOND_SWORD) + .setTitle(C.cGreenB + "NINJA BLADE") + .build(); + + private Set _active = new HashSet<>(); + + public SkillNinjaBlade(int slot) + { + super("Ninja Blade", DESCRIPTION, SKILL_ITEM, slot, null); + + setCooldown(60000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + player.getInventory().setItem(getSlot(), ACTIVE_ITEM); + _active.add(player.getUniqueId()); + Recharge.Instance.useForce(player, GetName(), 7000, true); + + Manager.runSyncLater(() -> + { + + _active.remove(player.getUniqueId()); + useSkill(player); + + }, 7 * 20); + } + + @EventHandler + public void damage(CustomDamageEvent event) + { + Entity entity = event.GetDamageeEntity(); + Player player = event.GetDamagerPlayer(false); + Player damageePlayer = event.GetDamageePlayer(); + + if (player != null && damageePlayer != null) + { + Game game = Manager.GetGame(); + if (game.GetTeam(player).equals(game.GetTeam(damageePlayer))) + { + return; + } + } + + if (player == null || !_active.contains(player.getUniqueId())) + { + return; + } + + UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, entity.getLocation().add(0, 1, 0), 1F, 1F, 1F, 0.1F, 50, ViewDist.LONG); + entity.getWorld().playSound(entity.getLocation(), Sound.EXPLODE, 2, 0.5F); + event.AddMod(GetName(), 4); + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java new file mode 100644 index 000000000..3d4db31d9 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java @@ -0,0 +1,91 @@ +package nautilus.game.arcade.game.games.moba.kit.hattori; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.Snowball; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitRunnable; + +public class SkillSnowball extends HeroSkill implements IThrown +{ + + private static final String[] DESCRIPTION = { + "Fires 3 snowballs, one after another.", + "Each snowball deals 3 damage to any enemy it hits." + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.SNOW_BALL); + + public SkillSnowball(int slot) + { + super("Snowball", DESCRIPTION, SKILL_ITEM, slot, null); + + setCooldown(1000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + useSkill(player); + + Manager.runSyncTimer(new BukkitRunnable() + { + int balls = 0; + + @Override + public void run() + { + Snowball snowball = player.launchProjectile(Snowball.class); + + Manager.GetProjectile().AddThrow(snowball, player, SkillSnowball.this, -1, true, true, true, false, 0.5F); + + if (++balls == 3) + { + cancel(); + } + } + }, 0, 4); + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + Player thrower = (Player) data.getThrower(); + + if (target != null) + { + thrower.playSound(thrower.getLocation(), Sound.LAVA_POP, 1, 1.3F); + Manager.GetDamage().NewDamageEvent(target, thrower, (Projectile) data.getThrown(), DamageCause.PROJECTILE, 3, true, true, false, UtilEnt.getName(thrower), GetName()); + } + } + + @Override + public void Idle(ProjectileUser data) + { + data.getThrown().remove(); + } + + @Override + public void Expire(ProjectileUser data) + { + data.getThrown().remove(); + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/heroes/HeroHattori.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/heroes/HeroHattori.java deleted file mode 100644 index ffda5fba2..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/heroes/HeroHattori.java +++ /dev/null @@ -1,32 +0,0 @@ -package nautilus.game.arcade.game.games.moba.kit.heroes; - -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.games.moba.MobaRole; -import nautilus.game.arcade.game.games.moba.kit.HeroKit; -import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.PerkDoubleJump; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -public class HeroHattori extends HeroKit -{ - - private static final String[] DESCRIPTION = { - "Something something" - }; - - private static final Perk[] PERKS = { - new PerkDoubleJump("Double Jump", 1, 1, true) - }; - - private static final ItemStack[] PLAYER_ITEMS = { - new ItemStack(Material.WOOD_SWORD), - }; - - private static final ItemStack IN_HAND = new ItemStack(Material.NETHER_STAR); - - public HeroHattori(ArcadeManager manager) - { - super(manager, "Hattori", DESCRIPTION, PERKS, IN_HAND, MobaRole.ASSASSIN); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java index 136dd7d1f..ebf2a3a83 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java @@ -1,6 +1,5 @@ package nautilus.game.arcade.game.games.moba.recall; -import com.sun.org.apache.regexp.internal.RE; import mineplex.core.common.util.*; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle.ParticleType; @@ -10,6 +9,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -17,16 +17,16 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; -import org.jooq.util.derby.sys.Sys; -import java.util.*; +import java.util.HashSet; +import java.util.Set; public class Recall implements Listener { private static final int RECALL_TIME = 5000; private static final double PARTICLE_HEIGHT = 2.5; - private static final double PARTICLE_RADIUS = 2.5; + private static final double PARTICLE_RADIUS = 1.5; private final Moba _host; @@ -55,12 +55,15 @@ public class Recall implements Listener Player player = event.getPlayer(); ItemStack itemStack = player.getItemInHand(); - if (itemStack == null || itemStack.getType() != Material.BED) + if (itemStack == null || itemStack.getType() != Material.BED || getSession(player) != null) { return; } - _sessions.add(new RecallSession(player)); + if (Recharge.Instance.use(player, "Recall", RECALL_TIME, false, true)) + { + _sessions.add(new RecallSession(player)); + } } @EventHandler @@ -75,29 +78,33 @@ public class Recall implements Listener for (Player player : _host.GetPlayers(true)) { - if (!_lastRecallStart.containsKey(player.getUniqueId())) + RecallSession session = getSession(player); + + if (session == null) { continue; } - long start = _lastRecallStart.get(player.getUniqueId()); - - if (UtilTime.elapsed(start, RECALL_TIME)) + if (UtilTime.elapsed(session.Start, RECALL_TIME)) { _host.GetTeam(player).SpawnTeleport(player); - _lastRecallStart.remove(player.getUniqueId()); + removeSession(player, null); + } + else if (UtilMath.offsetSquared(player.getLocation(), session.Location) > 4) + { + removeSession(player, "You moved!"); } else { Location location = player.getLocation().add(0, 0.25, 0); - double height = (now - start) / RECALL_TIME; + double height = (double) (now - session.Start) / (double) RECALL_TIME; for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 10) { double x = PARTICLE_RADIUS * Math.sin(theta); double z = PARTICLE_RADIUS * Math.cos(theta); - for (int y = 0; y < height * PARTICLE_HEIGHT; y += 0.5) + for (double y = 0; y < height * PARTICLE_HEIGHT; y += 0.5) { location.add(x, y, z); @@ -118,10 +125,20 @@ public class Recall implements Listener return; } - RecallSession session = + removeSession(event.GetDamageePlayer(), "You took damage!"); } - public RecallSession getSession(Player player) + private void removeSession(Player player, String reason) + { + boolean had = _sessions.removeIf(session -> session.Player.equals(player)); + + if (had && reason != null) + { + player.sendMessage(F.main("Game", reason + " You recall has been cancelled")); + } + } + + private RecallSession getSession(Player player) { for (RecallSession session : _sessions) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index c5d448938..48156e3e3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -1,11 +1,8 @@ package nautilus.game.arcade.game.games.moba.structure.tower; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.*; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.utils.UtilVariant; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; @@ -39,15 +36,19 @@ public class Tower public void setup() { - if (_firstTower) - { - _guardian = _location.getWorld().spawn(_location, Guardian.class); - } - else - { - _guardian = UtilVariant.spawnElderGuardian(_location); - } +// if (_firstTower) +// { + _guardian = _location.getWorld().spawn(_location, Guardian.class); +// } +// else +// { +// _guardian = UtilVariant.spawnElderGuardian(_location); +// } + UtilEnt.vegetate(_guardian); + UtilEnt.setFakeHead(_guardian, true); + UtilEnt.silence(_guardian, true); + _guardian.setRemoveWhenFarAway(false); _guardian.setCustomNameVisible(true); updateDisplay(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java index fd1dc5e82..2b94686d0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java @@ -672,21 +672,24 @@ public class GameManager implements Listener } }, i * game.TickPerTeleport); } - - //Announce Game after every player is TP'd in - UtilServer.getServer().getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() + + if (game.PrepareAutoAnnounce) { - public void run() + //Announce Game after every player is TP'd in + UtilServer.getServer().getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() { - game.AnnounceGame(); - game.StartPrepareCountdown(); - - //Event - GamePrepareCountdownCommence event = new GamePrepareCountdownCommence(game); - UtilServer.getServer().getPluginManager().callEvent(event); - } - }, players.size() * game.TickPerTeleport); - + public void run() + { + game.AnnounceGame(); + game.StartPrepareCountdown(); + + //Event + GamePrepareCountdownCommence event = new GamePrepareCountdownCommence(game); + UtilServer.getServer().getPluginManager().callEvent(event); + } + }, players.size() * game.TickPerTeleport); + } + //Spectators Move for (Player player : UtilServer.getPlayers()) { From 5398bf5e81216da85ddfb9b2d8f117faddad2252 Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 7 May 2017 22:35:15 +0100 Subject: [PATCH 05/57] More progress --- .../util/particles/effects/LineParticle.java | 17 +- .../games/evolution/mobs/KitEnderman.java | 2 +- .../games/evolution/mobs/KitSkeleton.java | 2 +- .../game/games/gravity/kits/KitJetpack.java | 6 +- .../minecraftleague/MinecraftLeague.java | 4 +- .../game/arcade/game/games/moba/Moba.java | 120 ++++++++-- .../arcade/game/games/moba/kit/HeroKit.java | 35 ++- .../arcade/game/games/moba/kit/HeroSkill.java | 186 +++++++++++--- .../game/games/moba/kit/PregameSelection.java | 5 +- .../game/games/moba/kit/anath/HeroAnath.java | 39 +++ .../games/moba/kit/anath/SkillBurnBeam.java | 95 ++++++++ .../moba/kit/anath/SkillFireProjectile.java | 49 ++++ .../games/moba/kit/anath/SkillFlameDash.java | 51 ++++ .../games/moba/kit/anath/SkillMeteor.java | 164 +++++++++++++ .../game/games/moba/kit/common/DashSkill.java | 226 ++++++++++++++++++ .../game/games/moba/kit/common/SkillBow.java | 20 ++ .../games/moba/kit/common/SkillSword.java | 25 ++ .../game/games/moba/kit/dana/HeroDana.java | 31 +++ .../games/moba/kit/dana/SkillDanaDash.java | 82 +++++++ .../games/moba/kit/dana/SkillPulseHeal.java | 164 +++++++++++++ .../game/games/moba/kit/dana/SkillRally.java | 205 ++++++++++++++++ .../game/games/moba/kit/devon/HeroDevon.java | 23 +- .../game/games/moba/kit/devon/SkillBoost.java | 3 +- .../games/moba/kit/devon/SkillInfinity.java | 49 +++- .../games/moba/kit/devon/SkillTNTArrows.java | 75 +++++- .../games/moba/kit/hattori/HeroHattori.java | 26 +- .../games/moba/kit/hattori/SkillDash.java | 105 -------- .../moba/kit/hattori/SkillNinjaBlade.java | 14 +- .../moba/kit/hattori/SkillNinjaDash.java | 72 ++++++ .../games/moba/kit/hattori/SkillSnowball.java | 5 +- .../game/games/moba/shop/MobaMainMenu.java | 89 +++++++ .../arcade/game/games/moba/shop/MobaShop.java | 88 +++++++ .../game/games/moba/shop/MobaUpgrade.java | 19 ++ .../game/games/moba/shop/MobaUpgradeType.java | 13 + .../moba/shop/common/CooldownUpgrade.java | 22 ++ .../src/nautilus/game/arcade/kit/Kit.java | 1 + 36 files changed, 1878 insertions(+), 254 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFlameDash.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillBow.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/HeroDana.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillDash.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaDash.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaMainMenu.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgrade.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgradeType.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/common/CooldownUpgrade.java 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 index 5eb91a337..2842cdd75 100644 --- 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 @@ -31,10 +31,16 @@ public class LineParticle private double _maxRange; private Set _ignoredTypes; + private boolean _ignoreAllBlocks; private ParticleType _particleType; private Player[] _toDisplay; + public LineParticle(Location start, Vector direction, double incrementedRange, double maxRange, ParticleType particleType, Player... toDisplay) + { + this(start, null, direction, incrementedRange, maxRange, null, particleType, 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); @@ -56,7 +62,7 @@ public class LineParticle if (_direction == null) { - direction = UtilAlg.getTrajectory(start, end).normalize(); + _direction = UtilAlg.getTrajectory(start, end).normalize(); } } @@ -73,7 +79,7 @@ public class LineParticle 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 (!_ignoreAllBlocks && (!(UtilBlock.airFoliage(newTarget.getBlock()) || UtilBlock.airFoliage(newTarget.getBlock().getRelative(BlockFace.UP))))) { if (_ignoredTypes == null || !_ignoredTypes.contains(newTarget.getBlock().getType())) { @@ -87,7 +93,12 @@ public class LineParticle return done; } - + + public void setIgnoreAllBlocks(boolean b) + { + _ignoreAllBlocks = b; + } + public Location getLastLocation() { return _lastLocation; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitEnderman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitEnderman.java index 60fb991dd..34196d101 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitEnderman.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitEnderman.java @@ -19,7 +19,7 @@ public class KitEnderman // @Override // protected void giveItems(Player player) // { -// player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD)); +// player.getInventory().addSkillItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD)); // // player.getWorld().playSound(player.getLocation(), Sound.ENDERMAN_IDLE, 4f, 1f); // diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitSkeleton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitSkeleton.java index d4831cbbb..ffe96719e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitSkeleton.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/mobs/KitSkeleton.java @@ -34,7 +34,7 @@ public class KitSkeleton // player.getInventory().setLeggings(new ItemBuilder(Material.CHAINMAIL_LEGGINGS).build()); // player.getInventory().setBoots(new ItemBuilder(Material.IRON_BOOTS).build()); // -// player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW)); +// player.getInventory().addSkillItem(ItemStackFactory.Instance.CreateStack(Material.BOW)); // // player.getWorld().playSound(player.getLocation(), Sound.SKELETON_IDLE, 4f, 1f); // diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/kits/KitJetpack.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/kits/KitJetpack.java index f1797298f..ab3ffbf3b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/kits/KitJetpack.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gravity/kits/KitJetpack.java @@ -42,9 +42,9 @@ public class KitJetpack extends ProgressingKit @Override public void GiveItems(Player player) { - //player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SHEARS, (byte)0, 1, "Block Cannon")); - //player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW, (byte)0, 1, "Space Shooter")); - //player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.ARROW, (byte)0, 64, "Space Arrows")); + //player.getInventory().addSkillItem(ItemStackFactory.Instance.CreateStack(Material.SHEARS, (byte)0, 1, "Block Cannon")); + //player.getInventory().addSkillItem(ItemStackFactory.Instance.CreateStack(Material.BOW, (byte)0, 1, "Space Shooter")); + //player.getInventory().addSkillItem(ItemStackFactory.Instance.CreateStack(Material.ARROW, (byte)0, 64, "Space Arrows")); player.getInventory().addItem(PLAYER_ITEMS); player.getInventory().setArmorContents(PLAYER_ARMOR); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index 1590dc86f..d0d92f862 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -1470,7 +1470,7 @@ public class MinecraftLeague extends RankedTeamGame player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.BLUE).setUnbreakable(true).build()); player.getInventory().addItem(new ItemStack(Material.STONE_SWORD)); player.getInventory().addItem(new ItemStack(Material.STONE_PICKAXE)); - //player.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 5)); + //player.getInventory().addSkillItem(new ItemStack(Material.COOKED_BEEF, 5)); _blockLock.put(player, new BlockProtection(this, player)); _noFall.add(player); } @@ -1482,7 +1482,7 @@ public class MinecraftLeague extends RankedTeamGame player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.RED).setUnbreakable(true).build()); player.getInventory().addItem(new ItemStack(Material.STONE_SWORD)); player.getInventory().addItem(new ItemStack(Material.STONE_PICKAXE)); - //player.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 5)); + //player.getInventory().addSkillItem(new ItemStack(Material.COOKED_BEEF, 5)); _blockLock.put(player, new BlockProtection(this, player)); _noFall.add(player); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index fe6591cc4..36e6b1158 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -1,19 +1,25 @@ package nautilus.game.arcade.game.games.moba; +import mineplex.core.common.Rank; import mineplex.core.common.entity.ClientArmorStand; import mineplex.core.common.util.*; -import mineplex.core.explosion.ExplosionEvent; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.DeathMessageType; -import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.condition.Condition; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GamePrepareCountdownCommence; import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.moba.kit.*; +import nautilus.game.arcade.game.games.moba.kit.anath.HeroAnath; +import nautilus.game.arcade.game.games.moba.kit.dana.HeroDana; import nautilus.game.arcade.game.games.moba.kit.devon.HeroDevon; import nautilus.game.arcade.game.games.moba.kit.hattori.HeroHattori; import nautilus.game.arcade.game.games.moba.recall.Recall; @@ -23,11 +29,12 @@ import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Perk; import org.bukkit.Location; +import org.bukkit.entity.Arrow; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.metadata.FixedMetadataValue; @@ -58,7 +65,9 @@ public class Moba extends TeamGame _kits = new HeroKit[] { new HeroHattori(Manager), - new HeroDevon(Manager) + new HeroDevon(Manager), + new HeroAnath(Manager), + new HeroDana(Manager), }; PrepareAutoAnnounce = false; @@ -67,7 +76,7 @@ public class Moba extends TeamGame DeathOut = false; DeathSpectateSecs = 10; HungerSet = 20; - DontAllowOverfill = false; + DontAllowOverfill = true; DamageFall = false; @@ -82,6 +91,33 @@ public class Moba extends TeamGame Listener recall = new Recall(this); _listeners.add(recall); + + registerDebugCommand(new DebugCommand("kit", Rank.ADMIN) + { + @Override + public void Execute(Player caller, String[] args) + { + String kit = ""; + + for (int i = 0; i < args.length; i++) + { + kit += args[i] + " "; + } + + kit = kit.trim(); + + for (Kit kits : _kits) + { + if (kit.equalsIgnoreCase(kits.GetName())) + { + SetKit(caller, kits, true); + return; + } + } + + caller.sendMessage(F.main("Kit", "Sorry that is not a kit!")); + } + }); } @Override @@ -213,7 +249,7 @@ public class Moba extends TeamGame } - @EventHandler + @EventHandler(priority = EventPriority.LOWEST) public void prepare(GameStateChangeEvent event) { if (event.GetState() != GameState.Prepare) @@ -368,21 +404,64 @@ public class Moba extends TeamGame } } + //TODO announce to all @Override - public void RespawnPlayer(Player player) + public DeathMessageType GetDeathMessageType() { - MobaPlayer mobaPlayer = getData(player); - - player.eject(); - Manager.Clear(player); - GetTeam(player).SpawnTeleport(player); - SetKit(player, mobaPlayer.Kit, false); + return DeathMessageType.Detailed; } @EventHandler - public void combatDeath(CombatDeathEvent event) + public void preventTeamDamage(CustomDamageEvent event) { - event.SetBroadcastType(DeathMessageType.Detailed); + Player damagee = event.GetDamageePlayer(); + Player damager = event.GetDamagerPlayer(true); + + if (damagee == null || damager == null) + { + return; + } + + GameTeam damageeTeam = GetTeam(damagee); + GameTeam damagerTeam = GetTeam(damager); + + if (damageeTeam == null || damagerTeam == null) + { + return; + } + + if (damageeTeam.equals(damagerTeam)) + { + event.SetCancelled("Team Damage"); + } + } + + @EventHandler + public void preventTeamFire(ConditionApplyEvent event) + { + Condition condition = event.GetCondition(); + + if (condition.GetType() != ConditionType.BURNING) + { + return; + } + + if (condition.GetEnt() == null || condition.GetSource() == null) + { + return; + } + + if (!(condition.GetEnt() instanceof Player && condition.GetSource() instanceof Player)) + { + return; + } + + if (!GetTeam((Player) condition.GetEnt()).equals(GetTeam((Player) condition.GetSource()))) + { + return; + } + + event.setCancelled(true); } // Clear up memory @@ -394,7 +473,16 @@ public class Moba extends TeamGame _playerData.removeIf(mobaPlayer -> mobaPlayer.Player.equals(player)); } - private Map getLocationStartsWith(String s) + @EventHandler + public void projectileHit(ProjectileHitEvent event) + { + if (event.getEntity() instanceof Arrow) + { + event.getEntity().remove(); + } + } + + public Map getLocationStartsWith(String s) { Map map = new HashMap<>(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index 705581001..bdb8dc67d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -48,6 +48,11 @@ public class HeroKit extends Kit return _role; } + public ItemStack getAmmo() + { + return _ammo; + } + public void setAmmo(ItemStack ammo, long giveTime) { _ammo = ammo; @@ -59,17 +64,30 @@ public class HeroKit extends Kit _maxAmmo = max; } - protected boolean useAmmo(Player player, int amount) + public boolean useAmmo(Player player, int amount) { ItemStack itemStack = player.getInventory().getItem(AMMO_SLOT); - if (itemStack == null || itemStack.getAmount() < amount) + if (itemStack == null) { return false; } - itemStack.setAmount(itemStack.getAmount() - amount); - player.updateInventory(); + int newAmount = itemStack.getAmount() - amount; + + if (itemStack.getAmount() < amount) + { + return false; + } + + if (newAmount == 0) + { + player.getInventory().remove(itemStack); + } + else + { + itemStack.setAmount(newAmount); + } return true; } @@ -122,9 +140,6 @@ public class HeroKit extends Kit inventory.setItem(AMMO_SLOT, _ammo); inventory.setItem(RECALL_SLOT, RECALL_ITEM); - Bukkit.broadcastMessage(""); - Bukkit.broadcastMessage(player.getName()); - for (Perk perk : GetPerks()) { if (!(perk instanceof HeroSkill)) @@ -134,11 +149,7 @@ public class HeroKit extends Kit HeroSkill skill = (HeroSkill) perk; - if (skill.getItemStack() != null) - { - Bukkit.broadcastMessage("Giving kit " + GetName() + ", perk " + skill.GetName() + ", item " + skill.getItemStack().getItemMeta().getDisplayName()); - inventory.setItem(skill.getSlot(), skill.isOnCooldown(player) ? skill.getCooldownItemStack() : skill.getItemStack()); - } + skill.giveItem(player); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 252a69089..6a63a8db3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -1,16 +1,18 @@ package nautilus.game.arcade.game.games.moba.kit; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.*; import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.PlayerKitGiveEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Perk; import org.bukkit.Material; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.Action; @@ -18,20 +20,21 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitRunnable; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; +import java.util.*; +import java.util.function.Consumer; public class HeroSkill extends Perk { - private ItemStack _item; + protected List _items; private ItemStack _cooldownItem; private final int _slot; private final ActionType _actionType; private final boolean _sneakActivate; + protected HeroKit _kit; private long _cooldown; private final Map _lastSkill = new HashMap<>(); @@ -50,12 +53,13 @@ public class HeroSkill extends Perk { super(name, perkDesc); - _item = itemStack; + _items = new ArrayList<>(2); + _items.add(itemStack); _slot = slot; _actionType = actionType; _sneakActivate = sneakActivate; - prettifyItem(); + prettifyItems(); } protected void setCooldown(long cooldown) @@ -63,10 +67,14 @@ public class HeroSkill extends Perk _cooldown = cooldown; } - private void prettifyItem() + private void prettifyItems() { - String action = "Click"; + String action = null; + if (_actionType == ActionType.ANY) + { + action = "Click"; + } if (_actionType == ActionType.L) { action = "Left Click"; @@ -81,28 +89,57 @@ public class HeroSkill extends Perk action += "/Sneak"; } - _item = new ItemBuilder(_item) - .setTitle(C.cYellowB + action + C.cGray + " - " + C.cGreenB + GetName()) - .addLore(GetDesc()) - .build(); + List items = new ArrayList<>(2); + + for (ItemStack itemStack : _items) + { + items.add(new ItemBuilder(itemStack) + .setTitle((action != null ? C.cYellowB + action + C.cGray + " - " : "") + C.cGreenB + GetName()) + .addLore(GetDesc()) + .setUnbreakable(true) + .build()); + } + + _items = items; _cooldownItem = new ItemBuilder(Material.INK_SACK, (byte) 8) .setTitle(C.cRed + GetName()) .addLore(GetDesc()) + .setUnbreakable(true) .build(); } -// @Override -// public void SetHost(Kit kit) -// { -// super.SetHost(kit); -// -// _kit = (HeroKit) kit; -// } + protected void addSkillItem(ItemStack itemStack) + { + _items.add(itemStack); + prettifyItems(); + } + + @Override + public void SetHost(Kit kit) + { + super.SetHost(kit); + + _kit = (HeroKit) kit; + } @EventHandler public void giveItem(PlayerKitGiveEvent event) { - event.getPlayer().getInventory().setItem(_slot, isOnCooldown(event.getPlayer()) ? _cooldownItem : _item); + Player player = event.getPlayer(); + + if (!hasPerk(player)) + { + return; + } + + if (isOnCooldown(player)) + { + player.getInventory().setItem(_slot, _cooldownItem); + } + else + { + giveItem(player); + } } @EventHandler @@ -131,12 +168,20 @@ public class HeroSkill extends Perk Player player = event.getPlayer(); ItemStack itemStack = event.getItem(); - if (!hasPerk(player) || UtilPlayer.isSpectator(player) || itemStack == null || !itemStack.isSimilar(_item)) + if (!hasPerk(player) || UtilPlayer.isSpectator(player) || itemStack == null) { return false; } - return true; + for (ItemStack correctItem : _items) + { + if (itemStack.isSimilar(correctItem)) + { + return true; + } + } + + return false; } protected boolean isSkillSneak(PlayerToggleSneakEvent event) @@ -147,13 +192,22 @@ public class HeroSkill extends Perk } Player player = event.getPlayer(); + ItemStack itemStack = player.getInventory().getItem(_slot); - if (!hasPerk(player) || UtilPlayer.isSpectator(player) || !player.getInventory().getItem(_slot).isSimilar(_item)) + if (!hasPerk(player) || UtilPlayer.isSpectator(player) || itemStack == null) { return false; } - return true; + for (ItemStack correctItem : _items) + { + if (itemStack.isSimilar(correctItem)) + { + return true; + } + } + + return false; } public void useSkill(Player player) @@ -168,7 +222,7 @@ public class HeroSkill extends Perk @EventHandler public void updateCooldowns(UpdateEvent event) { - if (event.getType() != UpdateType.FASTEST || _item == null) + if (event.getType() != UpdateType.FASTEST || _items == null) { return; } @@ -193,26 +247,90 @@ public class HeroSkill extends Perk if (done) { _lastSkill.remove(player.getUniqueId()); - player.getInventory().setItem(_slot, _item); + giveItem(player); } else { long timeDiff = current - start; double amount = (int) (cooldown / 1000) - Math.ceil((double) timeDiff / 1000); + if (itemStack == null) + { + itemStack = _cooldownItem; + } + itemStack.setAmount((int) amount); } } } - public ItemStack getItemStack() + public void giveItem(Player player) { - return _item; + if (_items.isEmpty()) + { + return; + } + + player.getInventory().setItem(_slot, _items.get(0)); } - public ItemStack getCooldownItemStack() + public void useActiveSkill(Player player, long time) { - return _cooldownItem; + useActiveSkill(null, player, time); + } + + public void useActiveSkill(Runnable complete, Player player, long time) + { + long ticks = (long) (time / 1000D); + ItemStack itemStack = player.getInventory().getItem(getSlot()); + itemStack.setAmount((int) (ticks / 20D)); + UtilInv.addDullEnchantment(itemStack); + Recharge.Instance.useForce(player, GetName(), ticks, true); + Recharge.Instance.setDisplayForce(player, GetName(), true); + + Manager.runSyncTimer(new BukkitRunnable() + { + int iterations = 0; + + @Override + public void run() + { + if (iterations++ > ticks) + { + if (complete != null) + { + complete.run(); + } + useSkill(player); + cancel(); + return; + } + + itemStack.setAmount(itemStack.getAmount() - 1); + } + }, 0, 20); + } + + protected boolean isTeamDamage(LivingEntity damagee, LivingEntity damager) + { + if (!(damagee instanceof Player || damager instanceof Player)) + { + return false; + } + + Player damageePlayer = (Player) damagee; + Player damagerPlayer = (Player) damager; + + Game game = Manager.GetGame(); + GameTeam damageeTeam = game.GetTeam(damageePlayer); + GameTeam damagerTeam = game.GetTeam(damagerPlayer); + + if (damageeTeam == null || damagerTeam == null) + { + return false; + } + + return damageeTeam.equals(damagerTeam); } public int getSlot() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java index 4d56b39ee..cc620307f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java @@ -2,6 +2,8 @@ package nautilus.game.arcade.game.games.moba.kit; import mineplex.core.common.entity.ClientArmorStand; import mineplex.core.common.util.*; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketHandler.ListenerPriority; @@ -130,8 +132,7 @@ public class PregameSelection implements Listener, IPacketHandler // stand.setChestplate(buildColouredStack(Material.LEATHER_CHESTPLATE, role)); // stand.setLeggings(buildColouredStack(Material.LEATHER_LEGGINGS, role)); // stand.setBoots(buildColouredStack(Material.LEATHER_BOOTS, role)); - FireworkEffect effect = FireworkEffect.builder().with(Type.BURST).withColor(Color.LIME).withFade(Color.WHITE).withFlicker().build(); - UtilFirework.playFirework(stand.getLocation(), effect); + UtilParticle.PlayParticle(ParticleType.CLOUD, location.clone().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.01F, 1, ViewDist.LONG, player); _kitStands.put(stand, kit); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java new file mode 100644 index 000000000..d4ef4a78f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java @@ -0,0 +1,39 @@ +package nautilus.game.arcade.game.games.moba.kit.anath; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +public class HeroAnath extends HeroKit +{ + + private static final String[] DESCRIPTION = { + "Something something" + }; + + private static final Perk[] PERKS = { + new SkillFireProjectile(0), + new SkillBurnBeam(1), + new SkillFlameDash(2), + new SkillMeteor(3) + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.BLAZE_ROD); + + private static final ItemStack AMMO = new ItemBuilder(Material.BLAZE_POWDER) + .setTitle(C.cYellowB + "Embers") + .build(); + + public HeroAnath(ArcadeManager manager) + { + super(manager, "Anath the Unsworn", DESCRIPTION, PERKS, IN_HAND, MobaRole.MAGE); + + setAmmo(AMMO, 1000); + setMaxAmmo(4); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java new file mode 100644 index 000000000..2a2f1f23d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java @@ -0,0 +1,95 @@ +package nautilus.game.arcade.game.games.moba.kit.anath; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +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.UtilServer; +import mineplex.core.common.util.particles.effects.LineParticle; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +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.inventory.ItemStack; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.Vector; + +public class SkillBurnBeam extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Fires an Ember at high speed in front of you.", + "Any enemies it collides with take damage and are set on fire." + }; + + private static final ItemStack SKILL_ITEM = new ItemStack(Material.FIREBALL); + + public SkillBurnBeam(int slot) + { + super("Burn Beam", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + + setCooldown(10000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + Vector direction = player.getLocation().getDirection().setY(0); + + player.getWorld().playSound(player.getLocation(), Sound.BLAZE_BREATH, 2, 0.5F); + + useSkill(player); + + LineParticle particle = new LineParticle(player.getLocation().add(direction), direction, 0.2, 9, null, ParticleType.LAVA, UtilServer.getPlayers()); + + particle.setIgnoreAllBlocks(true); + + Manager.runSyncTimer(new BukkitRunnable() + { + @Override + public void run() + { + for (int i = 0; i < 3; i++) + { + if (particle.update()) + { + cancel(); + return; + } + else + { + UtilParticle.PlayParticleToAll(ParticleType.FLAME, particle.getLastLocation().clone().add(0, 5, 0), 0.4F, 5, 0.4F, 0.05F, 30, ViewDist.LONG); + } + } + + if (Math.random() < 0.1) + { + particle.getLastLocation().getWorld().playSound(particle.getLastLocation(), Sound.GHAST_FIREBALL, 2, 0.5F); + } + + for (LivingEntity entity : UtilEnt.getInRadius(particle.getLastLocation(), 2).keySet()) + { + if (entity.equals(player)) + { + continue; + } + + entity.getLocation().getWorld().playSound(entity.getLocation(), Sound.EXPLODE, 2, 0.5F); + Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, 20, true, true, false, UtilEnt.getName(player), GetName()); + } + } + }, 0, 1); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java new file mode 100644 index 000000000..895064ae7 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java @@ -0,0 +1,49 @@ +package nautilus.game.arcade.game.games.moba.kit.anath; + +import mineplex.core.common.util.UtilEvent.ActionType; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Material; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +public class SkillFireProjectile extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Fires an Ember at high speed in front of you.", + "Any enemies it collides with take damage and are set on fire." + }; + + private static final ItemStack SKILL_ITEM = new ItemStack(Material.BLAZE_ROD); + + public SkillFireProjectile(int slot) + { + super("Fire Item", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + if (!_kit.useAmmo(player, 1)) + { + return; + } + + Vector direction = player.getLocation().getDirection().multiply(1.25); + Item item = player.getWorld().dropItem(player.getEyeLocation().add(direction), _kit.getAmmo()); + item.setVelocity(direction); + + Manager.GetFire().Add(item, player, 3, 0, 1, 5, GetName(), false); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFlameDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFlameDash.java new file mode 100644 index 000000000..5c65b976a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFlameDash.java @@ -0,0 +1,51 @@ +package nautilus.game.arcade.game.games.moba.kit.anath; + +import mineplex.core.common.util.UtilBlock; +import nautilus.game.arcade.game.games.moba.kit.common.DashSkill; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class SkillFlameDash extends DashSkill +{ + + private static final String[] DESCRIPTION = { + "Dash along the ground, leaving fire behind you.", + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); + + public SkillFlameDash(int slot) + { + super("Flame Dash", DESCRIPTION, SKILL_ITEM, slot); + + setCooldown(12000); + + _collide = false; + _velocityTime = 600; + _velocityStopOnEnd = true; + _horizontial = true; + } + + @Override + public void dashTick(Player player) + { + Block block = player.getLocation().getBlock(); + + while (!UtilBlock.solid(block)) + { + block = block.getRelative(BlockFace.DOWN); + } + + Block fBlock = block; + Manager.runSyncLater(() -> Manager.GetBlockRestore().add(fBlock.getRelative(BlockFace.UP), Material.FIRE.getId(), (byte) 0, 5000), 10); + } + + @Override + public void postDash(Player player) + { + Manager.GetBlockRestore().restore(player.getLocation().getBlock()); + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java new file mode 100644 index 000000000..3fa7a24b7 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java @@ -0,0 +1,164 @@ +package nautilus.game.arcade.game.games.moba.kit.anath; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +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.games.moba.kit.HeroSkill; +import nautilus.game.arcade.kit.perks.data.MeteorShowerData; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.*; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.HashSet; +import java.util.Set; + +public class SkillMeteor extends HeroSkill implements IThrown +{ + + private static final String[] DESCRIPTION = { + "It doesn't blow up the map :)", + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); + + private final Set _data = new HashSet<>(); + + public SkillMeteor(int slot) + { + super("Meteor Shower", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + + setCooldown(60000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + if (!Recharge.Instance.use(player, GetName() + " Trigger", 10000, false, false)) + { + return; + } + + FallingBlock block = player.getWorld().spawnFallingBlock(player.getEyeLocation().add(player.getLocation().getDirection()), Material.NETHERRACK, (byte) 0); + block.setVelocity(player.getLocation().getDirection()); + + Manager.GetProjectile().AddThrow(block, player, this, 2000, true, true, true, false, 0.5F); + + useActiveSkill(player, 7000); + } + + @EventHandler + public void entityChangeBlock(EntityChangeBlockEvent event) + { + if (event.getEntity() instanceof FallingBlock) + { + event.getEntity().remove(); + event.setCancelled(true); + } + } + + @EventHandler + public void updateShower(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + _data.removeIf(MeteorShowerData::update); + + for (MeteorShowerData data : _data) + { + Location location = data.Target; + + for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 100) + { + double x = 10 * Math.sin(theta); + double z = 10 * Math.cos(theta); + + location.add(x, 0.25, z); + + UtilParticle.PlayParticleToAll(ParticleType.FLAME, location, 0, 0, 0, 0.001F, 1, ViewDist.LONG); + + location.subtract(x, 0.25, z); + } + + for (LivingEntity nearby : UtilEnt.getInRadius(location, 10).keySet()) + { + if (isTeamDamage(data.Shooter, nearby)) + { + continue; + } + + nearby.setFireTicks(20); + Manager.GetDamage().NewDamageEvent(nearby, data.Shooter, null, DamageCause.CUSTOM, 2, true, true, false, UtilEnt.getName(data.Shooter), GetName()); + } + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void projectileHit(EntityExplodeEvent event) + { + if (event.getEntity() instanceof LargeFireball) + { + event.blockList().clear(); + } + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + Entity thrown = data.getThrown(); + + startShower(data); + + thrown.remove(); + } + + @Override + public void Idle(ProjectileUser data) + { + + } + + @Override + public void Expire(ProjectileUser data) + { + for (MeteorShowerData showerData : _data) + { + if (showerData.Shooter.equals(data.getThrower())) + { + return; + } + } + + startShower(data); + } + + private void startShower(ProjectileUser data) + { + Manager.GetBlockRestore().add(data.getThrown().getLocation().getBlock(), Material.NETHERRACK.getId(), (byte) 0, 6000); + _data.add(new MeteorShowerData((Player) data.getThrower(), data.getThrown().getLocation(), 6000)); + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java new file mode 100644 index 000000000..85952a767 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java @@ -0,0 +1,226 @@ +package nautilus.game.arcade.game.games.moba.kit.common; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +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 nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import java.util.*; +import java.util.Map.Entry; + +public class DashSkill extends HeroSkill +{ + + // Teleport Only + protected boolean _teleport = false; + protected boolean _horizontial = false; + protected double _range = 10; + protected ParticleType _particleType = ParticleType.FIREWORKS_SPARK; + + // Velocity + protected long _velocityTime; + protected double _velocityMagnitude = 1; + protected boolean _velocityStopOnEnd = false; + + // Collisions + protected boolean _collide = true; + protected double _collideRange = 2; + protected boolean _collideTeammates = false; + protected boolean _collidePlayers = true; + protected boolean _collideEntities = true; + protected boolean _collideOnce = true; + + private final Map _startTime; + + public DashSkill(String name, String[] perkDesc, ItemStack itemStack, int slot) + { + super(name, perkDesc, itemStack, slot, ActionType.ANY, true); + + _startTime = new HashMap<>(); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + useSkill(player); + } + + @EventHandler + public void toggleSneak(PlayerToggleSneakEvent event) + { + if (!isSkillSneak(event)) + { + return; + } + + Player player = event.getPlayer(); + + useSkill(player); + } + + @Override + public void useSkill(Player player) + { + super.useSkill(player); + + preDash(player); + + if (_teleport) + { + Vector direction = player.getLocation().getDirection(); + + if (_horizontial) + { + direction.setY(0); + } + + LineParticle particle = new LineParticle(player.getEyeLocation(), direction, 0.8, _range, null, _particleType, UtilServer.getPlayers()); + + while (!particle.update()) + { + dashTick(player); + checkCollisions(player, particle.getLastLocation()); + } + + player.teleport(particle.getDestination()); + postDash(player); + } + // Otherwise we set their velocity. + else if (_velocityTime > 0) + { + _startTime.put(player, System.currentTimeMillis()); + } + else + { + setVelocity(player); + } + } + + @EventHandler + public void updateVelocity(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (Entry entry : _startTime.entrySet()) + { + Player player = entry.getKey(); + long start = entry.getValue(); + + if (UtilTime.elapsed(start, _velocityTime)) + { + if (_velocityStopOnEnd) + { + UtilAction.zeroVelocity(player); + } + _startTime.remove(player); + postDash(player); + } + else + { + checkCollisions(player, player.getLocation()); + setVelocity(player); + } + } + } + + private void setVelocity(Player player) + { + Vector direction = player.getLocation().getDirection().multiply(_velocityMagnitude); + + if (_horizontial) + { + direction.setY(0); + } + + dashTick(player); + UtilAction.velocity(player, direction); + } + + private void checkCollisions(Player player, Location location) + { + // No colliding + if (!_collide || !_collideEntities && !_collidePlayers) + { + return; + } + + // All Living entities within the range + for (Entry entry : UtilEnt.getInRadius(location, _collideRange).entrySet()) + { + LivingEntity entity = entry.getKey(); + double scale = entry.getValue(); + + // If player hit themselves or the entity has already been hit + if (player.equals(entity) || !Recharge.Instance.use(player, GetName() + " by " + player.getName(), 500, false, false) && _collideOnce) + { + continue; + } + + // If allowing collisions with players + if (entity instanceof Player) + { + if (!_collidePlayers) + { + continue; + } + + boolean sameTeam = isTeamDamage(entity, player); + + // If their teams are the same and we don't allow collisions with teammates, ignore + if (sameTeam && !_collideTeammates) + { + continue; + } + + collideEntity(entity, player, scale, sameTeam); + } + // Any other entities and if we allow collisions with them + else if (_collideEntities) + { + collideEntity(entity, player, scale, false); + } + } + } + + public void preDash(Player player) + { + } + + public void dashTick(Player player) + { + } + + public void collideEntity(LivingEntity entity, Player damager, double scale, boolean sameTeam) + { + } + + public void postDash(Player player) + { + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillBow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillBow.java new file mode 100644 index 000000000..3ce67db5e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillBow.java @@ -0,0 +1,20 @@ +package nautilus.game.arcade.game.games.moba.kit.common; + +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +public class SkillBow extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Please work" + }; + + private static final ItemStack SKILL_ITEM = new ItemStack(Material.BOW); + + public SkillBow(int slot) + { + super("Bow", DESCRIPTION, SKILL_ITEM, slot, null); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java new file mode 100644 index 000000000..7aa94f22a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java @@ -0,0 +1,25 @@ +package nautilus.game.arcade.game.games.moba.kit.common; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +public class SkillSword extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Please work" + }; + + private static final ItemStack SKILL_ITEM = new ItemBuilder(Material.WOOD_SWORD) + .setTitle(C.cGreenB + "Sword") + .setUnbreakable(true) + .build(); + + public SkillSword(int slot) + { + super("Sword", DESCRIPTION, SKILL_ITEM, slot, null); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/HeroDana.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/HeroDana.java new file mode 100644 index 000000000..ce24c96b5 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/HeroDana.java @@ -0,0 +1,31 @@ +package nautilus.game.arcade.game.games.moba.kit.dana; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.game.games.moba.kit.common.SkillSword; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +public class HeroDana extends HeroKit +{ + + private static final String[] DESCRIPTION = { + "Something something" + }; + + private static final Perk[] PERKS = { + new SkillSword(0), + new SkillPulseHeal(1), + new SkillDanaDash(2), + new SkillRally(3), + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.IRON_SWORD); + + public HeroDana(ArcadeManager manager) + { + super(manager, "Dana", DESCRIPTION, PERKS, IN_HAND, MobaRole.WARRIOR); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java new file mode 100644 index 000000000..f4efd724e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java @@ -0,0 +1,82 @@ +package nautilus.game.arcade.game.games.moba.kit.dana; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import nautilus.game.arcade.game.games.moba.kit.common.DashSkill; +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import java.util.Random; + +public class SkillDanaDash extends DashSkill +{ + + private static final String[] DESCRIPTION = { + "Dash along the ground, leaving fire behind you.", + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); + + public SkillDanaDash(int slot) + { + super("Knock up", DESCRIPTION, SKILL_ITEM, slot); + + setCooldown(10000); + + _velocityTime = 600; + _horizontial = true; + _velocityStopOnEnd = true; + } + + @Override + public void preDash(Player player) + { + player.getWorld().playSound(player.getLocation(), Sound.BLAZE_HIT, 2, 0.4F); + } + + @Override + public void dashTick(Player player) + { + Random random = UtilMath.random; + Location location = player.getLocation().add(random.nextInt(5) - 2.5, random.nextInt(3), random.nextInt(5) - 2.5); + UtilParticle.PlayParticle(ParticleType.CLOUD, location.add(0, 1, 0), 0.5F, 0.5F, 0.5f, 0.1F, 10, ViewDist.LONG); + } + + @Override + public void collideEntity(LivingEntity entity, Player damager, double scale, boolean sameTeam) + { + double damage; + + if (entity instanceof Player) + { + damage = 10; + UtilAction.velocity(entity, new Vector(Math.random() / 2 - 0.25, 2, Math.random() / 2 - 0.25)); + } + else + { + damage = 6; + UtilAction.velocity(entity, new Vector(Math.random() - 0.5, 1, Math.random() - 0.5)); + } + + entity.getWorld().playSound(entity.getLocation(), Sound.IRONGOLEM_HIT, 1, 0.5F); + Manager.GetDamage().NewDamageEvent(entity, damager, null, DamageCause.CUSTOM, damage, false, false, false, UtilEnt.getName(damager), GetName()); + } + + @Override + public void postDash(Player player) + { + player.getWorld().playSound(player.getLocation(), Sound.EXPLODE, 2, 0.4F); + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, player.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5f, 0.1F, 3, ViewDist.LONG); + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java new file mode 100644 index 000000000..dd815d1df --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java @@ -0,0 +1,164 @@ +package nautilus.game.arcade.game.games.moba.kit.dana; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +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.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitRunnable; + +import java.util.HashSet; +import java.util.Set; + +public class SkillPulseHeal extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Fires an Ember at high speed in front of you.", + "Any enemies it collides with take damage and are set on fire." + }; + + private static final ItemStack SKILL_ITEM = new ItemBuilder(Material.INK_SACK, (byte) 10).build(); + private static final ItemStack SKILL_ITEM_TOGGLED = new ItemBuilder(Material.INK_SACK, (byte) 12).build(); + + private Set _toggled = new HashSet<>(); + + public SkillPulseHeal(int slot) + { + super("Pulse Heal", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + addSkillItem(SKILL_ITEM_TOGGLED); + setCooldown(2000); + } + + @Override + public void giveItem(Player player) + { + if (_toggled.contains(player)) + { + player.getInventory().setItem(getSlot(), _items.get(1)); + } + else + { + player.getInventory().setItem(getSlot(), _items.get(0)); + } + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + if (_toggled.contains(player)) + { + _toggled.remove(player); + } + else + { + _toggled.add(player); + } + + useSkill(player); + } + + @EventHandler + public void updatePulse(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (!hasPerk(player) || UtilPlayer.isSpectator(player) || !Recharge.Instance.use(player, GetName(), 10000, false, false)) + { + continue; + } + + Location location = player.getLocation(); + + if (_toggled.contains(player)) + { + for (LivingEntity entity : UtilEnt.getInRadius(player.getLocation(), 5).keySet()) + { + // Don't heal self or enemies + if (entity.equals(player) || !isTeamDamage(entity, player)) + { + continue; + } + + entity.setHealth(Math.min(entity.getHealth() + 2, entity.getMaxHealth())); + } + + displayPulse(location, false); + } + else + { + player.setHealth(Math.min(player.getHealth() + 2, player.getMaxHealth())); + + displayPulse(location, true); + } + } + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + _toggled.remove(event.getPlayer()); + } + + private void displayPulse(Location location, boolean inwards) + { + Manager.runSyncTimer(new BukkitRunnable() + { + + double theta = 0; + double radius = inwards ? 5 : 0; + + @Override + public void run() + { + if (inwards && radius < 0 || !inwards && radius > 5) + { + cancel(); + return; + } + + double increment = inwards ? -0.2 : 0.2; + for (double theta2 = 0; theta2 < 2 * Math.PI; theta2 += Math.PI / 3) + { + double x = radius * Math.sin(theta + theta2); + double z = radius * Math.cos(theta + theta2); + + location.add(x, 0.5, z); + + UtilParticle.PlayParticleToAll(inwards ? ParticleType.HAPPY_VILLAGER : ParticleType.DRIP_WATER, location, 0, 0, 0, 0.1F, 1, ViewDist.LONG); + + location.subtract(x, 0.5, z); + } + + theta += Math.PI / 100; + radius += increment; + } + }, 0, 1); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java new file mode 100644 index 000000000..cd5c004db --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java @@ -0,0 +1,205 @@ +package nautilus.game.arcade.game.games.moba.kit.dana; + +import mineplex.core.common.util.*; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.*; +import org.bukkit.block.Banner; +import org.bukkit.block.Block; +import org.bukkit.block.banner.Pattern; +import org.bukkit.block.banner.PatternType; +import org.bukkit.entity.LivingEntity; +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.inventory.ItemStack; +import org.bukkit.util.Vector; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +public class SkillRally extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Fires an Ember at high speed in front of you.", + "Any enemies it collides with take damage and are set on fire." + }; + + private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); + + private Set _data = new HashSet<>(); + + public SkillRally(int slot) + { + super("Rally", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + + setCooldown(40000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + Vector vector = player.getLocation().getDirection(); + + for (RallyData data : _data) + { + if (data.Owner.equals(player)) + { + return; + } + } + + vector.setY(Math.min(vector.getY(), 1)); + vector.setY(Math.max(vector.getY(), 1.5)); + + UtilAction.velocity(player, vector); + _data.add(new RallyData(player)); + } + + @EventHandler + public void updateLand(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + { + return; + } + + Iterator iterator = _data.iterator(); + + while (iterator.hasNext()) + { + RallyData data = iterator.next(); + Player player = data.Owner; + + if (data.Landed) + { + if (UtilTime.elapsed(data.LandTime, 7000)) + { + iterator.remove(); + } + else + { + for (Player nearby : UtilPlayer.getNearby(data.Banner, 5)) + { + // Only heal allies + if (!isTeamDamage(nearby, player)) + { + continue; + } + + UtilParticle.PlayParticleToAll(ParticleType.HEART, nearby.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.01F, 1, ViewDist.LONG); + Manager.GetCondition().Factory().Regen(GetName(), nearby, data.Owner, 3, 1, false, true, false); + } + } + } + else if (UtilTime.elapsed(data.LaunchTime, 1000) && UtilEnt.isGrounded(data.Owner)) + { + data.LandTime = System.currentTimeMillis(); + data.Landed = true; + Location location = data.Owner.getLocation(); + data.Banner = location; + + useActiveSkill(player, 7000); + + GameTeam team = Manager.GetGame().GetTeam(player); + Block block = location.getBlock(); + + Manager.GetBlockRestore().add(block, Material.STANDING_BANNER.getId(), (byte) 0, 7500); + + Banner banner = (Banner) block.getState(); + banner.setBaseColor(team.GetColor() == ChatColor.RED ? DyeColor.RED : DyeColor.BLUE); + banner.addPattern(getPattern(team)); + banner.update(); + + for (Block nearby : UtilBlock.getBlocksInRadius(banner.getLocation(), 5)) + { + if (UtilBlock.airFoliage(nearby)) + { + continue; + } + + Manager.GetBlockRestore().add(nearby, Material.STAINED_CLAY.getId(), team.GetColorData(), (long) (7000 + (Math.random() * 500))); + if (Math.random() > 0.9) + { + nearby.getWorld().playEffect(nearby.getLocation(), Effect.STEP_SOUND, Material.STAINED_CLAY, team.GetColorData()); + } + } + + for (LivingEntity nearby : UtilEnt.getInRadius(player.getLocation(), 3).keySet()) + { + Manager.GetDamage().NewDamageEvent(nearby, player, null, DamageCause.CUSTOM, 5, true, true, false, UtilEnt.getName(player), GetName()); + } + } + } + } + + @EventHandler + public void updateParticles(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (RallyData data : _data) + { + if (!data.Landed) + { + continue; + } + + Location banner = data.Banner; + + for (int i = 0; i < 5; i++) + { + double x = 5 * Math.sin(data.ParticleTheta); + double z = 5 * Math.cos(data.ParticleTheta); + + banner.add(x, 0.25, z); + + UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, banner, 0, 0, 0, 0.1F, 1, ViewDist.LONG); + + banner.subtract(x, 0.25, z); + + data.ParticleTheta += Math.PI / 100; + } + } + } + + private Pattern getPattern(GameTeam team) + { + return team.GetColor() == ChatColor.RED ? new Pattern(DyeColor.WHITE, PatternType.CROSS) : new Pattern(DyeColor.WHITE, PatternType.CIRCLE_MIDDLE); + } + + private class RallyData + { + + Player Owner; + Location Banner; + boolean Landed; + long LaunchTime; + long LandTime; + double ParticleTheta; + + RallyData(Player owner) + { + Owner = owner; + LaunchTime = System.currentTimeMillis(); + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java index a60d08800..b7bd131c5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java @@ -5,15 +5,10 @@ import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.HeroKit; -import nautilus.game.arcade.game.games.moba.kit.hattori.SkillDash; -import nautilus.game.arcade.game.games.moba.kit.hattori.SkillNinjaBlade; -import nautilus.game.arcade.game.games.moba.kit.hattori.SkillSnowball; +import nautilus.game.arcade.game.games.moba.kit.common.SkillBow; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.PerkFletcher; import org.bukkit.Material; -import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; public class HeroDevon extends HeroKit { @@ -23,6 +18,7 @@ public class HeroDevon extends HeroKit }; private static final Perk[] PERKS = { + new SkillBow(0), new SkillTNTArrows(1), new SkillBoost(2), new SkillInfinity(3) @@ -30,11 +26,6 @@ public class HeroDevon extends HeroKit private static final ItemStack IN_HAND = new ItemStack(Material.BOW); - private static final ItemStack BOW = new ItemBuilder(Material.BOW) - .setTitle(C.cGreenB + "Bow") - .setUnbreakable(true) - .build(); - private static final ItemStack AMMO = new ItemBuilder(Material.ARROW) .setTitle(C.cYellowB + "Hunting Arrow") .build(); @@ -46,14 +37,4 @@ public class HeroDevon extends HeroKit setAmmo(AMMO, 3000); setMaxAmmo(3); } - - @Override - public void GiveItems(Player player) - { - // TODO remove this when shop is implemented - PlayerInventory inventory = player.getInventory(); - inventory.setItem(0, BOW); - - super.GiveItems(player); - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillBoost.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillBoost.java index 6de9c1330..edfb3e95f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillBoost.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillBoost.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.devon; +import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.minecraft.game.core.condition.ConditionFactory; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Material; @@ -19,7 +20,7 @@ public class SkillBoost extends HeroSkill public SkillBoost(int slot) { - super("Hunters Boost", DESCRIPTION, SKILL_ITEM, slot, null, true); + super("Hunters Boost", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY, true); setCooldown(10000); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java index 85f4852f0..279dd195f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java @@ -1,12 +1,17 @@ package nautilus.game.arcade.game.games.moba.kit.devon; +import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilPlayer; 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.GameTeam; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Entity; @@ -17,10 +22,13 @@ import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitRunnable; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; public class SkillInfinity extends HeroSkill { @@ -32,10 +40,11 @@ public class SkillInfinity extends HeroSkill private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); private final Map _arrows = new HashMap<>(); + private final Set _active = new HashSet<>(); public SkillInfinity(int slot) { - super("Infinity", DESCRIPTION, SKILL_ITEM, slot, null); + super("Infinity", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); setCooldown(60000); } @@ -56,10 +65,14 @@ public class SkillInfinity extends HeroSkill return; } - bow.addEnchantment(Enchantment.ARROW_INFINITE, 0); - Recharge.Instance.useForce(player, GetName(), 7000, false); + bow.addEnchantment(Enchantment.ARROW_INFINITE, 1); + _active.add(player); - Manager.runSyncLater(() -> bow.removeEnchantment(Enchantment.ARROW_INFINITE), 7 * 20); + useActiveSkill(() -> + { + bow.removeEnchantment(Enchantment.ARROW_INFINITE); + _active.remove(player); + }, player, 7000); } @EventHandler @@ -72,13 +85,18 @@ public class SkillInfinity extends HeroSkill Player player = (Player) event.getEntity(); + if (!hasPerk(player) || !_active.contains(player)) + { + return; + } + _arrows.put(event.getProjectile(), player); } @EventHandler public void updateArrowTarget(UpdateEvent event) { - if (event.getType() != UpdateType.FASTEST || !Manager.isGameInProgress()) + if (event.getType() != UpdateType.FASTEST) { return; } @@ -89,22 +107,37 @@ public class SkillInfinity extends HeroSkill Player player = entry.getValue(); GameTeam team = Manager.GetGame().GetTeam(player); - for (LivingEntity nearby : UtilEnt.getInRadius(entity.getLocation(), 3).keySet()) + for (LivingEntity nearby : UtilEnt.getInRadius(entity.getLocation(), 6).keySet()) { if (nearby instanceof Player) { // If the target is on the same team - if (team.equals(Manager.GetGame().GetTeam((Player) nearby))) + if (UtilPlayer.isSpectator(player) || team.equals(Manager.GetGame().GetTeam((Player) nearby))) { continue; } } - entity.setVelocity(UtilAlg.getTrajectory(entity.getLocation(), nearby.getLocation())); + UtilAction.velocity(nearby, UtilAlg.getTrajectory(entity.getLocation(), nearby.getLocation().add(0, 1.5, 0))); } } } + @EventHandler + public void arrowDamage(CustomDamageEvent event) + { + if (event.GetProjectile() == null) + { + return; + } + + if (_arrows.containsKey(event.GetProjectile())) + { + Bukkit.broadcastMessage("Wither"); + Manager.GetCondition().Factory().Wither(GetName(), event.GetDamageeEntity(), event.GetDamagerEntity(true), 3, 0, false, true, false); + } + } + @EventHandler public void projectileHit(ProjectileHitEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java index 999cd5c69..9dcd7895c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java @@ -1,23 +1,32 @@ package nautilus.game.arcade.game.games.moba.kit.devon; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; 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.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; -import nautilus.game.arcade.game.games.moba.kit.hattori.SkillSnowball; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.block.Block; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; import java.util.HashMap; import java.util.Map; -import java.util.UUID; +import java.util.Map.Entry; public class SkillTNTArrows extends HeroSkill implements IThrown { @@ -28,11 +37,11 @@ public class SkillTNTArrows extends HeroSkill implements IThrown }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.TNT); - private final Map _arrows = new HashMap<>(); + private final Map _arrows = new HashMap<>(); public SkillTNTArrows(int slot) { - super("TNT Infusion", DESCRIPTION, SKILL_ITEM, slot, null); + super("TNT Infusion", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); setCooldown(17000); } @@ -47,8 +56,9 @@ public class SkillTNTArrows extends HeroSkill implements IThrown Player player = event.getPlayer(); - _arrows.put(player.getUniqueId(), 3); + _arrows.put(player, 3); player.getItemInHand().addEnchantment(UtilInv.getDullEnchantment(), 1); + player.getItemInHand().setAmount(3); } @EventHandler @@ -61,31 +71,74 @@ public class SkillTNTArrows extends HeroSkill implements IThrown Player player = (Player) event.getEntity(); - if (!hasPerk(player) || !_arrows.containsKey(player.getUniqueId())) + if (!hasPerk(player) || !_arrows.containsKey(player)) { return; } - int arrows = _arrows.get(player.getUniqueId()); + ItemStack itemStack = player.getInventory().getItem(getSlot()); + int arrows = _arrows.get(player); if (arrows == 1) { - _arrows.remove(player.getUniqueId()); + _arrows.remove(player); useSkill(player); } else { - _arrows.put(player.getUniqueId(), arrows - 1); + arrows--; + _arrows.put(player, arrows); + itemStack.setAmount(arrows); } - Manager.GetProjectile().AddThrow(event.getProjectile(), player, this, -1, true, true, true, false, 0.5F); + Manager.GetProjectile().AddThrow(event.getProjectile(), player, this, -1, true, true, true, false, 0); + } + + @EventHandler + public void playerDeath(CombatDeathEvent event) + { + _arrows.remove(event.GetEvent().getEntity()); + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + _arrows.remove(event.getPlayer()); } @Override public void Collide(LivingEntity target, Block block, ProjectileUser data) { + LivingEntity thrower = data.getThrower(); Location location = data.getThrown().getLocation(); - location.getWorld().createExplosion(location.getX(), location.getY(), location.getZ(), 4, false, false); + + location.getWorld().playSound(location, Sound.EXPLODE, 1, 0.9F); + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, location, 0, 0, 0, 0.1F, 1, ViewDist.LONG); + double damage = 10; + + // Scale damage with the damage on the player's bow + if (thrower instanceof Player) + { + Player throwerPlayer = (Player) thrower; + ItemStack itemStack = throwerPlayer.getInventory().getItem(0); + + // Player has a bow + if (itemStack != null && itemStack.getType() == Material.BOW) + { + damage += damage * itemStack.getEnchantmentLevel(Enchantment.ARROW_DAMAGE) * 0.25; + } + } + + for (Entry entry : UtilEnt.getInRadius(location, 5).entrySet()) + { + if (entry.getKey().equals(thrower)) + { + continue; + } + + Manager.GetDamage().NewDamageEvent(entry.getKey(), thrower, null, DamageCause.BLOCK_EXPLOSION, (entry.getValue() + 0.5) * damage, true, true, false, UtilEnt.getName(data.getThrower()), GetName()); + } + data.getThrown().remove(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java index 0234ed154..539768e27 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java @@ -1,17 +1,13 @@ package nautilus.game.arcade.game.games.moba.kit.hattori; -import mineplex.core.common.util.C; -import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.game.games.moba.kit.common.SkillSword; import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.perks.PerkDoubleJump; -import org.bukkit.Bukkit; import org.bukkit.Material; -import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; public class HeroHattori extends HeroKit { @@ -23,32 +19,16 @@ public class HeroHattori extends HeroKit private static final Perk[] PERKS = { new PerkDoubleJump("Double Jump", 1, 1, true), new SkillSnowball(0), - new SkillDash(2), + new SkillSword(1), + new SkillNinjaDash(2), new SkillNinjaBlade(3) }; private static final ItemStack IN_HAND = new ItemStack(Material.NETHER_STAR); - private static final ItemStack SWORD = new ItemBuilder(Material.WOOD_SWORD) - .setTitle(C.cGreenB + "Sword") - .setUnbreakable(true) - .build(); public HeroHattori(ArcadeManager manager) { super(manager, "Hattori", DESCRIPTION, PERKS, IN_HAND, MobaRole.ASSASSIN); } - - @Override - public void GiveItems(Player player) - { - Bukkit.broadcastMessage("Hello " + player.getName()); - - // TODO remove this when shop is implemented - PlayerInventory inventory = player.getInventory(); - inventory.setItem(1, SWORD); - - Bukkit.broadcastMessage("Now call the super for " + player.getName()); - super.GiveItems(player); - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillDash.java deleted file mode 100644 index 8d73dc8ac..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillDash.java +++ /dev/null @@ -1,105 +0,0 @@ -package nautilus.game.arcade.game.games.moba.kit.hattori; - -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilFirework; -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 nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.games.moba.kit.HeroSkill; -import org.bukkit.FireworkEffect; -import org.bukkit.FireworkEffect.Type; -import org.bukkit.Location; -import org.bukkit.Material; -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.PlayerToggleSneakEvent; -import org.bukkit.inventory.ItemStack; - -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; - -public class SkillDash extends HeroSkill -{ - - private static final String[] DESCRIPTION = { - "Dash forward dealing damage to any enemy", - "you collide with." - }; - - private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); - - public SkillDash(int slot) - { - super("Dash", DESCRIPTION, SKILL_ITEM, slot, null, true); - - setCooldown(7000); - } - - @EventHandler - public void interact(PlayerInteractEvent event) - { - if (!isSkillItem(event)) - { - return; - } - - Player player = event.getPlayer(); - - useSkill(player); - } - - @EventHandler - public void toggleSneak(PlayerToggleSneakEvent event) - { - if (!isSkillSneak(event)) - { - return; - } - - Player player = event.getPlayer(); - - useSkill(player); - } - - @Override - public void useSkill(Player player) - { - super.useSkill(player); - - LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.8, 10, null, ParticleType.FIREWORKS_SPARK, - UtilServer.getPlayers()); - Set hitPlayers = new HashSet<>(); - Game game = Manager.GetGame(); - GameTeam team = game.GetTeam(player); - - while (!lineParticle.update()) - { - for (Player other : UtilPlayer.getNearby(lineParticle.getLastLocation(), 2)) - { - if (hitPlayers.contains(other.getUniqueId()) || player.equals(other) || team.equals(game.GetTeam(other))) - { - continue; - } - - hitPlayers.add(other.getUniqueId()); - Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, 8, true, true, false, player.getName(), GetName()); - player.sendMessage(F.main("Game", "You hit " + F.elem(other.getName()) + " with " + F.skill(GetName()) + ".")); - } - } - - Location location = lineParticle.getDestination(); - FireworkEffect effect = FireworkEffect.builder().with(Type.BALL).withColor(team.GetColorBase()).withFlicker().build(); - - UtilFirework.playFirework(player.getLocation(), effect); - player.teleport(location.add(0, 0.5, 0)); - UtilFirework.playFirework(player.getLocation(), effect); - - player.sendMessage(F.main("Game", "You used " + F.skill(GetName()) + ".")); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java index e4562334a..9f4fe1071 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.moba.kit.hattori; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; @@ -37,7 +38,7 @@ public class SkillNinjaBlade extends HeroSkill public SkillNinjaBlade(int slot) { - super("Ninja Blade", DESCRIPTION, SKILL_ITEM, slot, null); + super("Ninja Blade", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); setCooldown(60000); } @@ -54,15 +55,8 @@ public class SkillNinjaBlade extends HeroSkill player.getInventory().setItem(getSlot(), ACTIVE_ITEM); _active.add(player.getUniqueId()); - Recharge.Instance.useForce(player, GetName(), 7000, true); - Manager.runSyncLater(() -> - { - - _active.remove(player.getUniqueId()); - useSkill(player); - - }, 7 * 20); + useActiveSkill(() -> _active.remove(player.getUniqueId()), player, 7000); } @EventHandler @@ -81,7 +75,7 @@ public class SkillNinjaBlade extends HeroSkill } } - if (player == null || !_active.contains(player.getUniqueId())) + if (player == null || !_active.contains(player.getUniqueId()) || player.getItemInHand() == null || player.getItemInHand().getType() != Material.DIAMOND_SWORD) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaDash.java new file mode 100644 index 000000000..93439e6ca --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaDash.java @@ -0,0 +1,72 @@ +package nautilus.game.arcade.game.games.moba.kit.hattori; + +import mineplex.core.common.util.*; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.particles.effects.LineParticle; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.kit.common.DashSkill; +import org.bukkit.Bukkit; +import org.bukkit.FireworkEffect; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.LivingEntity; +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.PlayerToggleSneakEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +public class SkillNinjaDash extends DashSkill +{ + + private static final String[] DESCRIPTION = { + "Dash forward dealing damage to any enemy", + "you collide with." + }; + + private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); + + public SkillNinjaDash(int slot) + { + super("Dash", DESCRIPTION, SKILL_ITEM, slot); + + setCooldown(7000); + + _teleport = true; + _range = 10; + } + + @Override + public void preDash(Player player) + { + playFirework(player); + } + + @Override + public void collideEntity(LivingEntity entity, Player player, double scale, boolean sameTeam) + { + Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, 8, true, true, false, UtilEnt.getName(player), GetName()); + } + + @Override + public void postDash(Player player) + { + playFirework(player); + } + + private void playFirework(Player player) + { + GameTeam team = Manager.GetGame().GetTeam(player); + FireworkEffect effect = FireworkEffect.builder().with(Type.BALL).withColor(team.GetColorBase()).withFlicker().build(); + UtilFirework.playFirework(player.getLocation(), effect); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java index 3d4db31d9..5ad950ee0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.moba.kit.hattori; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; @@ -28,7 +29,7 @@ public class SkillSnowball extends HeroSkill implements IThrown public SkillSnowball(int slot) { - super("Snowball", DESCRIPTION, SKILL_ITEM, slot, null); + super("Snowball", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); setCooldown(1000); } @@ -41,6 +42,8 @@ public class SkillSnowball extends HeroSkill implements IThrown return; } + event.setCancelled(true); + Player player = event.getPlayer(); useSkill(player); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaMainMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaMainMenu.java new file mode 100644 index 000000000..b080347bb --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaMainMenu.java @@ -0,0 +1,89 @@ +package nautilus.game.arcade.game.games.moba.shop; + +import mineplex.core.common.util.UtilUI; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; +import mineplex.core.menu.Menu; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.MobaPlayer; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.kit.common.SkillSword; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +import java.util.ArrayList; +import java.util.List; + +public class MobaMainMenu extends Menu +{ + + private static final int SLOTS = 27; + + private final MobaPlayer _player; + + public MobaMainMenu(MobaPlayer player, ArcadeManager plugin) + { + super(player.Kit.GetName() + " Shop", plugin); + + _player = player; + } + + @Override + protected Button[] setUp(Player player) + { + Button[] buttons = new Button[SLOTS]; + HeroKit kit = _player.Kit; + List skills = new ArrayList<>(3); + + for (Perk perk : kit.GetPerks()) + { + if (!(perk instanceof HeroSkill)) + { + continue; + } + + skills.add((HeroSkill) perk); + } + + int slots[] = UtilUI.getIndicesFor(skills.size(), 1, 3); + + for (HeroSkill skill : skills) + { + + } + + return buttons; + } + + private ItemStack getMainMenuItem(HeroSkill skill) + { + ItemBuilder builder; + + if (skill instanceof SkillSword) + { + builder = + } + } + + class MobaMainButton extends Button + { + + private MobaPlayer _player; + + public MobaMainButton(MobaPlayer player, ArcadeManager plugin) + { + super(item, plugin); + + _player = player; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index 95da9011c..d40d78dd1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -1,16 +1,104 @@ package nautilus.game.arcade.game.games.moba.shop; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaPlayer; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Villager; +import org.bukkit.entity.Villager.Profession; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; + +import java.util.*; public class MobaShop implements Listener { private final Moba _host; + private final List _entities; + private final Map> _upgrades; public MobaShop(Moba host) { _host = host; + _entities = new ArrayList<>(2); + _upgrades = new HashMap<>(); + } + + @EventHandler + public void spawnNpc(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + List locations = _host.WorldData.GetDataLocs("CYAN"); + + for (Location location : locations) + { + Villager villager = location.getWorld().spawn(location, Villager.class); + + villager.setProfession(Profession.LIBRARIAN); + villager.setAgeLock(true); + villager.setRemoveWhenFarAway(false); + + _entities.add(villager); + } + } + + public void purchaseUpgrade(Player player, MobaUpgrade upgrade) + { + _upgrades.putIfAbsent(player, new HashSet<>(3)); + _upgrades.get(player).add(upgrade); + } + + private void openShop(MobaPlayer player) + { + + } + + @EventHandler + public void entityDamage(EntityDamageByEntityEvent event) + { + npcInteract(event.getEntity(), event.getDamager()); + } + + @EventHandler + public void entityInteract(PlayerInteractAtEntityEvent event) + { + npcInteract(event.getRightClicked(), event.getPlayer()); + } + + private void npcInteract(Entity clicked, Entity clicker) + { + if (!(clicker instanceof Player)) + { + return; + } + + Player player = (Player) clicked; + + for (LivingEntity shop : _entities) + { + if (clicked.equals(shop)) + { + MobaPlayer data = _host.getData(player); + + if (data == null) + { + return; + } + + openShop(data); + return; + } + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgrade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgrade.java new file mode 100644 index 000000000..55312fdc6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgrade.java @@ -0,0 +1,19 @@ +package nautilus.game.arcade.game.games.moba.shop; + +import org.bukkit.inventory.ItemStack; + +public class MobaUpgrade +{ + + private ItemStack _item; + + public MobaUpgrade(ItemStack item) + { + _item = item; + } + + public ItemStack getItem() + { + return _item; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgradeType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgradeType.java new file mode 100644 index 000000000..432e868a8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgradeType.java @@ -0,0 +1,13 @@ +package nautilus.game.arcade.game.games.moba.shop; + +public enum MobaUpgradeType +{ + + SWORD, + BOW, + HELMET, + CHEST, + LEGS, + BOOTS + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/common/CooldownUpgrade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/common/CooldownUpgrade.java new file mode 100644 index 000000000..0c7d0c84c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/common/CooldownUpgrade.java @@ -0,0 +1,22 @@ +package nautilus.game.arcade.game.games.moba.shop.common; + +import nautilus.game.arcade.game.games.moba.shop.MobaUpgrade; +import org.bukkit.inventory.ItemStack; + +public class CooldownUpgrade extends MobaUpgrade +{ + + private double _reductionFactor; + + public CooldownUpgrade(ItemStack item, double reductionFactor) + { + super(item); + + _reductionFactor = reductionFactor; + } + + public double getReductionFactor() + { + return _reductionFactor; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java index bc6d41347..dbfe01cf6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java @@ -6,6 +6,7 @@ import nautilus.game.arcade.ArcadeFormat; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.events.PlayerKitGiveEvent; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.*; From d107c8d6f4c850ea1c85154e48d9d334b95e9bb3 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 8 May 2017 21:09:09 +0100 Subject: [PATCH 06/57] Bob Ross --- .../game/arcade/game/games/moba/Moba.java | 40 +++- .../game/games/moba/gold/GoldManager.java | 135 ++++++++++++ .../moba/kit/CooldownCalculateEvent.java | 49 +++++ .../arcade/game/games/moba/kit/HeroKit.java | 46 +++- .../arcade/game/games/moba/kit/HeroSkill.java | 11 +- .../games/moba/kit/anath/SkillFlameDash.java | 6 - .../game/games/moba/kit/bob/HeroBob.java | 40 ++++ .../games/moba/kit/bob/SkillBeatTheDevil.java | 47 ++++ .../moba/kit/bob/SkillBuildPainting.java | 206 ++++++++++++++++++ .../games/moba/kit/bob/SkillHappyTrees.java | 174 +++++++++++++++ .../game/games/moba/kit/bob/SkillPaint.java | 100 +++++++++ .../game/games/moba/kit/common/DashSkill.java | 9 +- .../games/moba/kit/common/SkillSword.java | 1 + .../games/moba/kit/dana/SkillDanaDash.java | 4 +- .../game/games/moba/kit/dana/SkillRally.java | 2 +- .../moba/kit/hattori/SkillNinjaBlade.java | 10 +- .../games/moba/kit/hattori/SkillSnowball.java | 2 - .../arcade/game/games/moba/shop/MobaItem.java | 50 +++++ .../game/games/moba/shop/MobaItemEffect.java | 17 ++ .../game/games/moba/shop/MobaMainMenu.java | 89 -------- .../arcade/game/games/moba/shop/MobaShop.java | 174 ++++++++++++++- .../games/moba/shop/MobaShopCategory.java | 47 ++++ .../games/moba/shop/MobaShopCategoryMenu.java | 96 ++++++++ .../game/games/moba/shop/MobaShopMenu.java | 124 +++++++++++ .../game/games/moba/shop/MobaUpgrade.java | 19 -- .../game/games/moba/shop/MobaUpgradeType.java | 13 -- .../moba/shop/assassin/MobaAssassinShop.java | 43 ++++ .../moba/shop/common/CooldownUpgrade.java | 22 -- .../moba/shop/effects/MobaCDREffect.java | 22 ++ .../moba/shop/effects/MobaKillHealEffect.java | 21 ++ .../moba/structure/point/CapturePoint.java | 6 + .../point/CapturePointCaptureEvent.java | 3 - 32 files changed, 1442 insertions(+), 186 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/CooldownCalculateEvent.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBeatTheDevil.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillPaint.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaMainMenu.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategory.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgrade.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgradeType.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/common/CooldownUpgrade.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 36e6b1158..98f5a29a7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -17,12 +17,15 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.games.moba.gold.GoldManager; import nautilus.game.arcade.game.games.moba.kit.*; import nautilus.game.arcade.game.games.moba.kit.anath.HeroAnath; +import nautilus.game.arcade.game.games.moba.kit.bob.HeroBob; import nautilus.game.arcade.game.games.moba.kit.dana.HeroDana; import nautilus.game.arcade.game.games.moba.kit.devon.HeroDevon; import nautilus.game.arcade.game.games.moba.kit.hattori.HeroHattori; import nautilus.game.arcade.game.games.moba.recall.Recall; +import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.modules.compass.CompassModule; @@ -59,6 +62,9 @@ public class Moba extends TeamGame private final Set _listeners = new HashSet<>(); + private final MobaShop _shop; + private final GoldManager _goldManager; + public Moba(ArcadeManager manager) { super(manager, GameType.MOBA, new Kit[] { new KitPlayer(manager) }, DESCRIPTION); @@ -68,6 +74,7 @@ public class Moba extends TeamGame new HeroDevon(Manager), new HeroAnath(Manager), new HeroDana(Manager), + new HeroBob(Manager) }; PrepareAutoAnnounce = false; @@ -92,6 +99,14 @@ public class Moba extends TeamGame Listener recall = new Recall(this); _listeners.add(recall); + MobaShop shop = new MobaShop(this); + _shop = shop; + _listeners.add(shop); + + GoldManager goldManager = new GoldManager(this); + _goldManager = goldManager; + _listeners.add(goldManager); + registerDebugCommand(new DebugCommand("kit", Rank.ADMIN) { @Override @@ -356,7 +371,7 @@ public class Moba extends TeamGame continue; } - HeroKit heroKit = getRandomKit(player); + HeroKit heroKit = getFirstKit(player); MobaPlayer mobaPlayer = getData(player); mobaPlayer.Role = heroKit.getRole(); @@ -543,7 +558,7 @@ public class Moba extends TeamGame return null; } - private HeroKit getRandomKit(Player player) + private HeroKit getFirstKit(Player player) { MobaPlayer mobaPlayer = getData(player); @@ -551,17 +566,17 @@ public class Moba extends TeamGame { MobaRole role = getRandomRole(player); - return getRandomKit(role); + return getFirstKit(role); } else if (mobaPlayer.Kit == null) { - return getRandomKit(mobaPlayer.Role); + return getFirstKit(mobaPlayer.Role); } return null; } - private HeroKit getRandomKit(MobaRole role) + private HeroKit getFirstKit(MobaRole role) { for (HeroKit kit : _kits) { @@ -607,4 +622,19 @@ public class Moba extends TeamGame return players; } + + public List getCapturePoints() + { + return _capturePoints; + } + + public MobaShop getShop() + { + return _shop; + } + + public GoldManager getGoldManager() + { + return _goldManager; + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java new file mode 100644 index 000000000..cfd386e62 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java @@ -0,0 +1,135 @@ +package nautilus.game.arcade.game.games.moba.gold; + +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.DebugCommand; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +public class GoldManager implements Listener +{ + + private static final int GOLD_PER_5 = 20; + private static final int GOLD_PER_CAPTURE_5 = 5; + + private final Moba _host; + + private final Map _playerGold; + + public GoldManager(Moba host) + { + _host = host; + + _playerGold = new HashMap<>(); + + host.registerDebugCommand(new DebugCommand("gold", Rank.ADMIN) + { + @Override + public void Execute(Player caller, String[] args) + { + if (args.length < 1) + { + caller.sendMessage(F.main("Debug", "/gold ")); + return; + } + + try + { + int amount = Integer.parseInt(args[0]); + + addGold(caller, amount); + caller.sendMessage(F.main("Debug", "Gave yourself " + F.elem(args[0]) + " gold.")); + } + catch (NumberFormatException e) + { + caller.sendMessage(F.main("Debug", F.elem(args[0]) + " is not a number.")); + } + } + }); + } + + @EventHandler + public void prepare(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + for (Player player : _host.GetPlayers(true)) + { + _playerGold.put(player, 0); + } + } + + @EventHandler + public void passiveGain(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC_05 || !_host.IsLive()) + { + return; + } + + // Every player passive + for (Player player : _host.GetPlayers(true)) + { + addGold(player, GOLD_PER_5); + } + + // Capture points + for (CapturePoint point : _host.getCapturePoints()) + { + GameTeam owner = point.getOwner(); + + if (owner == null) + { + continue; + } + + for (Player player : owner.GetPlayers(true)) + { + addGold(player, GOLD_PER_CAPTURE_5); + } + } + } + + public void addGold(Player player, int amount) + { + _playerGold.put(player, _playerGold.get(player) + amount); + } + + public void removeGold(Player player, int amount) + { + _playerGold.put(player, _playerGold.get(player) - amount); + } + + public boolean hasGold(Player player, int amount) + { + return _playerGold.get(player) >= amount; + } + + /** + * Returns a map binding the player to the amount of gold they currently have. + * + * @return An unmodifiable version of the internal map used. If you want to edit the player's gold consider using the other methods within this class. + */ + public Map getPlayerGoldMap() + { + return Collections.unmodifiableMap(_playerGold); + } + + + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/CooldownCalculateEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/CooldownCalculateEvent.java new file mode 100644 index 000000000..93c0cee45 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/CooldownCalculateEvent.java @@ -0,0 +1,49 @@ +package nautilus.game.arcade.game.games.moba.kit; + +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +public class CooldownCalculateEvent extends PlayerEvent +{ + + private static final HandlerList _handlers = new HandlerList(); + + private final long _initialCooldown; + private long _cooldown; + + public CooldownCalculateEvent(Player who, long cooldown) + { + super(who); + + _initialCooldown = cooldown; + _cooldown = cooldown; + } + + public void setCooldown(long cooldown) + { + _cooldown = cooldown; + } + + public void decreaseCooldown(double factor) + { + _cooldown = (long) ((double) _initialCooldown * factor); + } + + public long getCooldown() + { + return _cooldown; + } + + public static HandlerList getHandlerList() + { + return _handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index bdb8dc67d..cf31fe78e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -2,13 +2,18 @@ package nautilus.game.arcade.game.games.moba.kit; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilPlayer; 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.ArcadeManager; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.common.SkillBow; +import nautilus.game.arcade.game.games.moba.kit.common.SkillSword; +import nautilus.game.arcade.game.games.moba.shop.MobaItem; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; @@ -19,6 +24,8 @@ import org.bukkit.event.EventHandler; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; +import java.util.List; + public class HeroKit extends Kit { @@ -140,7 +147,10 @@ public class HeroKit extends Kit inventory.setItem(AMMO_SLOT, _ammo); inventory.setItem(RECALL_SLOT, RECALL_ITEM); - for (Perk perk : GetPerks()) + Moba host = (Moba) Manager.GetGame(); + List ownedItems = host.getShop().getOwnedItems(player); + + perkLoop: for (Perk perk : GetPerks()) { if (!(perk instanceof HeroSkill)) { @@ -149,7 +159,39 @@ public class HeroKit extends Kit HeroSkill skill = (HeroSkill) perk; - skill.giveItem(player); + // Sword upgrades + if (skill instanceof SkillSword) + { + for (MobaItem item : ownedItems) + { + if (UtilItem.isSword(item.getItem())) + { + player.getInventory().setItem(skill.getSlot(), item.getItem()); + continue perkLoop; + } + } + } + // Bow upgrades + else if (skill instanceof SkillBow) + { + for (MobaItem item : ownedItems) + { + if (item.getItem().getType() == Material.BOW) + { + player.getInventory().setItem(skill.getSlot(), item.getItem()); + continue perkLoop; + } + } + } + + if (skill.isOnCooldown(player)) + { + player.getInventory().setItem(skill.getSlot(), skill.getCooldownItem()); + } + else + { + skill.giveItem(player); + } } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 6a63a8db3..991e2afe5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -240,7 +240,11 @@ public class HeroSkill extends Perk long start = _lastSkill.get(player.getUniqueId()); long cooldown = _cooldown; - //TODO Shop cooldown reduction + // Modify the cooldown with respect to the upgrade items purchased from the shop + CooldownCalculateEvent cooldownEvent = new CooldownCalculateEvent(player, cooldown); + UtilServer.CallEvent(cooldownEvent); + + cooldown = cooldownEvent.getCooldown(); boolean done = UtilTime.elapsed(start, cooldown); @@ -338,6 +342,11 @@ public class HeroSkill extends Perk return _slot; } + public ItemStack getCooldownItem() + { + return _cooldownItem; + } + public boolean isOnCooldown(Player player) { return _lastSkill.containsKey(player.getUniqueId()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFlameDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFlameDash.java index 5c65b976a..e51aa1004 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFlameDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFlameDash.java @@ -41,11 +41,5 @@ public class SkillFlameDash extends DashSkill Block fBlock = block; Manager.runSyncLater(() -> Manager.GetBlockRestore().add(fBlock.getRelative(BlockFace.UP), Material.FIRE.getId(), (byte) 0, 5000), 10); } - - @Override - public void postDash(Player player) - { - Manager.GetBlockRestore().restore(player.getLocation().getBlock()); - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java new file mode 100644 index 000000000..82ad6b064 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java @@ -0,0 +1,40 @@ +package nautilus.game.arcade.game.games.moba.kit.bob; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +public class HeroBob extends HeroKit +{ + + private static final String[] DESCRIPTION = { + "Something something" + }; + + private static final Perk[] PERKS = { + new SkillPaint(0), + new SkillHappyTrees(1), + new SkillBeatTheDevil(2), + new SkillBuildPainting(3) + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.PAINTING); + + private static final ItemStack AMMO = new ItemBuilder(Material.SNOW_BALL) + .setTitle(C.cYellowB + "Paint") + .build(); + + public HeroBob(ArcadeManager manager) + { + super(manager, "Robert Ross", DESCRIPTION, PERKS, IN_HAND, MobaRole.MAGE); + + setAmmo(AMMO, 500); + setMaxAmmo(8); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBeatTheDevil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBeatTheDevil.java new file mode 100644 index 000000000..596b43a76 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBeatTheDevil.java @@ -0,0 +1,47 @@ +package nautilus.game.arcade.game.games.moba.kit.bob; + +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; +import nautilus.game.arcade.game.games.moba.kit.common.DashSkill; +import org.bukkit.Color; +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.inventory.ItemStack; + +public class SkillBeatTheDevil extends DashSkill +{ + + private static final String[] DESCRIPTION = { + "Dash along the ground, leaving fire behind you.", + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); + + public SkillBeatTheDevil(int slot) + { + super("Beat The Devil Out Of It", DESCRIPTION, SKILL_ITEM, slot); + + setCooldown(12000); + + _collide = false; + _velocityTime = 800; + _velocityStopOnEnd = true; + } + + @Override + public void dashTick(Player player) + { + player.getWorld().playSound(player.getLocation(), player.getTicksLived() % 2 == 0 ? Sound.DOOR_OPEN : Sound.DOOR_CLOSE, 1, 0.5F); + + for (int i = 0; i < 10; i++) + { + UtilParticle.playColoredParticleToAll(Color.RED, ParticleType.RED_DUST, UtilAlg.getRandomLocation(player.getLocation().add(0, 1, 0), 2), 1, ViewDist.LONG); + } + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java new file mode 100644 index 000000000..63a42f160 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java @@ -0,0 +1,206 @@ +package nautilus.game.arcade.game.games.moba.kit.bob; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilMath; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.recharge.Recharge; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Entity; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import java.util.HashSet; +import java.util.Map.Entry; +import java.util.Set; + +public class SkillBuildPainting extends HeroSkill implements IThrown +{ + + private static final String[] DESCRIPTION = { + "Bob Ross" + }; + private static final BlockFace[] AXIS = { BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST }; + private static final byte[][] PAINTING = { + { + 3, 3, 3, 3, 0, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3 + }, + { + 3, 3, 0, 0, 0, 0, 3, 3, 0, 0, 0, 3, 3, 3, 3 + }, + { + 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 3, 3, 3 + }, + { + 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 13, 3 + }, + { + 3, 3, 0, 0, 0, 3, 3, 3, 5, 3, 3, 13, 3, 13, 3 + }, + { + 3, 3, 8, 8, 8, 8, 3, 5, 5, 5, 3, 13, 13, 13, 13 + }, + { + 3, 3, 8, 8, 8, 8, 3, 3, 12, 3, 13, 13, 13, 13, 13 + }, + { + 3, 3, 7, 7, 7, 7, 7, 3, 12, 3, 3, 12, 3, 12, 3 + }, + { + 5, 7, 7, 7, 7, 7, 7, 5, 12, 5, 5, 12, 5, 12, 5 + } + }; + + private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); + + public SkillBuildPainting(int slot) + { + super("The Joy Of Painting", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + + setCooldown(60000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + if (!Recharge.Instance.use(player, GetName() + " Trigger", 5000, false, false)) + { + return; + } + + useActiveSkill(player, 4000); + + Set blocks = new HashSet<>(); + + Vector direction = player.getLocation().getDirection().normalize().setY(0); + Location start = player.getLocation().add(direction); + BlockFace facing = getFace(start.getYaw() + 180F); + Block center = start.getBlock().getRelative(facing).getRelative(BlockFace.UP); + + float leftYaw = start.getYaw() - 90; + BlockFace leftSide = getFace(leftYaw); + + for (int i = 0; i < 7; i++) + { + center = center.getRelative(leftSide); + } + + BlockFace rightSide = leftSide.getOppositeFace(); + + // Rows + for (int y = 0; y < PAINTING.length; y++) + { + byte[] row = PAINTING[y]; + + // Column in row + for (int x = 0; x < row.length; x++) + { + Block result = center; + + for (int i = 0; i < x; i++) + { + result = result.getRelative(rightSide); + } + + result = result.getRelative(0, 8, 0); + + for (int i = 0; i < y; i++) + { + result = result.getRelative(BlockFace.DOWN); + } + + Block fResult = result; + byte blockData = row[x]; + + Manager.runSyncLater(() -> + { + blocks.add(fResult); + Manager.GetBlockRestore().add(fResult, Material.WOOL.getId(), blockData, Long.MAX_VALUE); + + }, UtilMath.r(40)); + } + } + + Manager.runSyncLater(() -> + { + for (Block block : blocks) + { + if (Math.random() < 0.2) + { + FallingBlock fallingBlock = block.getWorld().spawnFallingBlock(block.getLocation().add(0.5, 0.5, 0.5), block.getType(), block.getData()); + + fallingBlock.setVelocity(direction.clone().multiply(1 + (Math.random() * 0.4))); + Manager.GetProjectile().AddThrow(fallingBlock, player, this, 2000, true, true, true, false, 0.5F); + } + + Manager.GetBlockRestore().restore(block); + } + }, 80); + } + + @EventHandler + public void itemSpawn(ItemSpawnEvent event) + { + if (event.getEntity().getItemStack().getType() == Material.WOOL) + { + event.setCancelled(true); + } + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + damage(data); + } + + @Override + public void Idle(ProjectileUser data) + { + + } + + @Override + public void Expire(ProjectileUser data) + { + damage(data); + } + + private void damage(ProjectileUser data) + { + Entity entity = data.getThrown(); + data.getThrown().getWorld().playEffect(entity.getLocation(), Effect.STEP_SOUND, Material.WOOL, (byte) 0); + + for (Entry entry : UtilEnt.getInRadius(entity.getLocation(), 3).entrySet()) + { + Manager.GetDamage().NewDamageEvent(entry.getKey(), data.getThrower(), null, DamageCause.BLOCK_EXPLOSION, 5, true, true, false, UtilEnt.getName(data.getThrower()), GetName()); + } + + data.getThrown().remove(); + } + + private BlockFace getFace(float yaw) + { + return AXIS[Math.round(yaw / 90F) & 0x3]; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java new file mode 100644 index 000000000..3b429be01 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java @@ -0,0 +1,174 @@ +package nautilus.game.arcade.game.games.moba.kit.bob; + +import mineplex.core.common.util.*; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.*; +import java.util.Map.Entry; + +public class SkillHappyTrees extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Bob Ross" + }; + + private static final ItemStack SKILL_ITEM = new ItemStack(Material.SAPLING); + + private final Set _data = new HashSet<>(); + + public SkillHappyTrees(int slot) + { + super("Happy Little Trees", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + + setCooldown(15000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + useSkill(player); + _data.add(new HappyTreeData(player)); + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + { + return; + } + + Iterator iterator = _data.iterator(); + + while (iterator.hasNext()) + { + HappyTreeData data = iterator.next(); + + if (UtilTime.elapsed(data.Start, 9000)) + { + iterator.remove(); + } + else if (data.Tree1 == null) + { + data.Tree1 = buildTree(data.Center); + } + else if (data.Tree2 == null) + { + data.Tree2 = buildTree(data.Center); + } + + if (UtilTime.elapsed(data.Start, 2000)) + { + healPlayers(data.Owner, data.Tree1); + healPlayers(data.Owner, data.Tree2); + } + } + } + + private Block buildTree(Location center) + { + Location start = UtilAlg.getRandomLocation(center, 5, 0, 5); + Map blocks = getTree(start); + + for (Entry entry : blocks.entrySet()) + { + Manager.runSyncLater(() -> Manager.GetBlockRestore().add(entry.getKey(), entry.getValue().getId(), (byte) 0, (long) (6000 + (Math.random() * 1000))), UtilMath.r(60)); + } + + return start.getBlock(); + } + + private Map getTree(Location start) + { + Block last = start.getBlock().getRelative(BlockFace.DOWN); + Map blocks = new HashMap<>(); + + // Trunk + for (int i = 0; i < 5; i++) + { + Block next = last.getRelative(BlockFace.UP); + last = next; + blocks.put(next, Material.LOG); + } + + last = last.getRelative(BlockFace.DOWN).getRelative(BlockFace.DOWN); + + // Bottom Leaves + for (Block block : UtilBlock.getInBoundingBox(last.getLocation().add(2, 1, 2), last.getLocation().subtract(2, 0, 2), false)) + { + blocks.put(block, Material.LEAVES); + } + + last = last.getRelative(BlockFace.UP).getRelative(BlockFace.UP); + + // Middle Leaves + for (Block block : UtilBlock.getInBoundingBox(last.getLocation().add(1, 0, 1), last.getLocation().subtract(1, 0, 1), false)) + { + blocks.put(block, Material.LEAVES); + } + + last = last.getRelative(BlockFace.UP); + + // Top Leaves + blocks.put(last.getRelative(BlockFace.NORTH), Material.LEAVES); + blocks.put(last.getRelative(BlockFace.WEST), Material.LEAVES); + blocks.put(last.getRelative(BlockFace.EAST), Material.LEAVES); + blocks.put(last.getRelative(BlockFace.SOUTH), Material.LEAVES); + blocks.put(last.getRelative(BlockFace.UP), Material.LEAVES); + + return blocks; + } + + private void healPlayers(Player owner, Block block) + { + for (LivingEntity entity : UtilEnt.getInRadius(block.getLocation(), 5).keySet()) + { + // Don't heal enemies + if (!isTeamDamage(entity, owner)) + { + continue; + } + + entity.setHealth(Math.min(entity.getHealth() + 2, entity.getMaxHealth())); + UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, entity.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 4, ViewDist.LONG); + } + } + + private class HappyTreeData + { + public Player Owner; + public long Start; + public Location Center; + public Block Tree1; + public Block Tree2; + + public HappyTreeData(Player owner) + { + Owner = owner; + Start = System.currentTimeMillis(); + Center = owner.getLocation(); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillPaint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillPaint.java new file mode 100644 index 000000000..df990d0dd --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillPaint.java @@ -0,0 +1,100 @@ +package nautilus.game.arcade.game.games.moba.kit.bob; + +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilMath; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.Snowball; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.Random; + +public class SkillPaint extends HeroSkill implements IThrown +{ + + private static final String[] DESCRIPTION = { + "Bob Ross" + }; + private static final byte[] COLOURS = { 14, 1, 4, 5, 3, 11, 0}; + + private static final ItemStack SKILL_ITEM = new ItemStack(Material.DIAMOND_BARDING); + + public SkillPaint(int slot) + { + super("1-Inch Brush", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + if (!_kit.useAmmo(player, 1)) + { + return; + } + + useSkill(player); + + Snowball snowball = player.launchProjectile(Snowball.class); + + Manager.GetProjectile().AddThrow(snowball, player, this, -1, true, true, true, false, 0.5F); + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + Player thrower = (Player) data.getThrower(); + Random random = UtilMath.random; + + if (target != null) + { + thrower.playSound(thrower.getLocation(), Sound.LAVA_POP, 1, 1.3F); + Manager.GetDamage().NewDamageEvent(target, thrower, (Projectile) data.getThrown(), DamageCause.PROJECTILE, 2, true, true, false, UtilEnt.getName(thrower), GetName()); + } + + for (Block nearby : UtilBlock.getBlocksInRadius(data.getThrown().getLocation(), 2)) + { + if (UtilBlock.airFoliage(nearby)) + { + continue; + } + + Manager.GetBlockRestore().add(nearby, Material.STAINED_CLAY.getId(), COLOURS[random.nextInt(COLOURS.length)], (long) (3000 + (Math.random() * 500))); + } + + for (LivingEntity entity : UtilEnt.getInRadius(data.getThrown().getLocation(), 2).keySet()) + { + Manager.GetDamage().NewDamageEvent(entity, thrower, (Projectile) data.getThrown(), DamageCause.PROJECTILE, 2, true, true, false, UtilEnt.getName(thrower), GetName()); + } + } + + @Override + public void Idle(ProjectileUser data) + { + + } + + @Override + public void Expire(ProjectileUser data) + { + + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java index 85952a767..b9e51c378 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java @@ -175,8 +175,13 @@ public class DashSkill extends HeroSkill LivingEntity entity = entry.getKey(); double scale = entry.getValue(); - // If player hit themselves or the entity has already been hit - if (player.equals(entity) || !Recharge.Instance.use(player, GetName() + " by " + player.getName(), 500, false, false) && _collideOnce) + // If player hit themselves + if (player.equals(entity)) + { + continue; + } + + if (!(entity instanceof Player) || !Recharge.Instance.use((Player) entity, GetName() + " by " + player.getName(), 500, false, false) && _collideOnce) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java index 7aa94f22a..864c35188 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java @@ -4,6 +4,7 @@ import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Material; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; public class SkillSword extends HeroSkill diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java index f4efd724e..f6ca20836 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java @@ -60,12 +60,12 @@ public class SkillDanaDash extends DashSkill if (entity instanceof Player) { damage = 10; - UtilAction.velocity(entity, new Vector(Math.random() / 2 - 0.25, 2, Math.random() / 2 - 0.25)); + UtilAction.velocity(entity, new Vector(Math.random() / 2 - 0.25, 1, Math.random() / 2 - 0.25)); } else { damage = 6; - UtilAction.velocity(entity, new Vector(Math.random() - 0.5, 1, Math.random() - 0.5)); + UtilAction.velocity(entity, new Vector(Math.random() - 0.5, 0.5, Math.random() - 0.5)); } entity.getWorld().playSound(entity.getLocation(), Sound.IRONGOLEM_HIT, 1, 0.5F); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java index cd5c004db..c0ac9b8a2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java @@ -73,7 +73,7 @@ public class SkillRally extends HeroSkill @EventHandler public void updateLand(UpdateEvent event) { - if (event.getType() != UpdateType.FASTEST) + if (event.getType() != UpdateType.TICK) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java index 9f4fe1071..9e8546707 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java @@ -66,16 +66,12 @@ public class SkillNinjaBlade extends HeroSkill Player player = event.GetDamagerPlayer(false); Player damageePlayer = event.GetDamageePlayer(); - if (player != null && damageePlayer != null) + if (player == null || damageePlayer == null || isTeamDamage(damageePlayer, player)) { - Game game = Manager.GetGame(); - if (game.GetTeam(player).equals(game.GetTeam(damageePlayer))) - { - return; - } + return; } - if (player == null || !_active.contains(player.getUniqueId()) || player.getItemInHand() == null || player.getItemInHand().getType() != Material.DIAMOND_SWORD) + if (!_active.contains(player.getUniqueId()) || player.getItemInHand() == null || player.getItemInHand().getType() != Material.DIAMOND_SWORD) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java index 5ad950ee0..2d353db1c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java @@ -82,13 +82,11 @@ public class SkillSnowball extends HeroSkill implements IThrown @Override public void Idle(ProjectileUser data) { - data.getThrown().remove(); } @Override public void Expire(ProjectileUser data) { - data.getThrown().remove(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java new file mode 100644 index 000000000..7cabddd2a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java @@ -0,0 +1,50 @@ +package nautilus.game.arcade.game.games.moba.shop; + +import org.bukkit.inventory.ItemStack; + +import java.util.ArrayList; +import java.util.List; + +public class MobaItem +{ + + private final ItemStack _item; + private final int _cost; + private List _effects; + + public MobaItem(ItemStack item, int cost) + { + _item = item; + _cost = cost; + } + + public MobaItem addEffects(MobaItemEffect... effects) + { + if (_effects == null) + { + _effects = new ArrayList<>(effects.length); + } + + for (MobaItemEffect effect : _effects) + { + _effects.add(effect); + } + return this; + } + + public ItemStack getItem() + { + return _item; + } + + public int getCost() + { + return _cost; + } + + public List getEffects() + { + return _effects; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java new file mode 100644 index 000000000..8af399784 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java @@ -0,0 +1,17 @@ +package nautilus.game.arcade.game.games.moba.shop; + +import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; +import org.bukkit.entity.Player; + +public class MobaItemEffect +{ + + public void onCooldownCheck(CooldownCalculateEvent event) + { + } + + public void onDeath(Player killed, Player killer) + { + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaMainMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaMainMenu.java deleted file mode 100644 index b080347bb..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaMainMenu.java +++ /dev/null @@ -1,89 +0,0 @@ -package nautilus.game.arcade.game.games.moba.shop; - -import mineplex.core.common.util.UtilUI; -import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.menu.Button; -import mineplex.core.menu.Menu; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.games.moba.MobaPlayer; -import nautilus.game.arcade.game.games.moba.kit.HeroKit; -import nautilus.game.arcade.game.games.moba.kit.HeroSkill; -import nautilus.game.arcade.game.games.moba.kit.common.SkillSword; -import nautilus.game.arcade.kit.Perk; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemStack; - -import java.util.ArrayList; -import java.util.List; - -public class MobaMainMenu extends Menu -{ - - private static final int SLOTS = 27; - - private final MobaPlayer _player; - - public MobaMainMenu(MobaPlayer player, ArcadeManager plugin) - { - super(player.Kit.GetName() + " Shop", plugin); - - _player = player; - } - - @Override - protected Button[] setUp(Player player) - { - Button[] buttons = new Button[SLOTS]; - HeroKit kit = _player.Kit; - List skills = new ArrayList<>(3); - - for (Perk perk : kit.GetPerks()) - { - if (!(perk instanceof HeroSkill)) - { - continue; - } - - skills.add((HeroSkill) perk); - } - - int slots[] = UtilUI.getIndicesFor(skills.size(), 1, 3); - - for (HeroSkill skill : skills) - { - - } - - return buttons; - } - - private ItemStack getMainMenuItem(HeroSkill skill) - { - ItemBuilder builder; - - if (skill instanceof SkillSword) - { - builder = - } - } - - class MobaMainButton extends Button - { - - private MobaPlayer _player; - - public MobaMainButton(MobaPlayer player, ArcadeManager plugin) - { - super(item, plugin); - - _player = player; - } - - @Override - public void onClick(Player player, ClickType clickType) - { - - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index d40d78dd1..0518b8c21 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -1,10 +1,21 @@ package nautilus.game.arcade.game.games.moba.shop; +import mineplex.core.common.Rank; +import mineplex.core.common.util.*; +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 nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaPlayer; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; +import nautilus.game.arcade.game.games.moba.shop.assassin.MobaAssassinShop; import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -13,22 +24,29 @@ import org.bukkit.entity.Villager.Profession; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; import java.util.*; +import java.util.Map.Entry; public class MobaShop implements Listener { private final Moba _host; - private final List _entities; - private final Map> _upgrades; + private final Map _entities; + private final Map _roleMenus; + private final Map> _upgrades; public MobaShop(Moba host) { _host = host; - _entities = new ArrayList<>(2); + _entities = new HashMap<>(2); + _roleMenus = new HashMap<>(4); _upgrades = new HashMap<>(); + + // Create menus + _roleMenus.put(MobaRole.ASSASSIN, new MobaAssassinShop(host, this)); } @EventHandler @@ -41,6 +59,7 @@ public class MobaShop implements Listener List locations = _host.WorldData.GetDataLocs("CYAN"); + _host.CreatureAllowOverride = true; for (Location location : locations) { Villager villager = location.getWorld().spawn(location, Villager.class); @@ -48,20 +67,61 @@ public class MobaShop implements Listener villager.setProfession(Profession.LIBRARIAN); villager.setAgeLock(true); villager.setRemoveWhenFarAway(false); + villager.setCustomName(C.cGoldB + "GOLD UPGRADES"); + villager.setCustomNameVisible(true); + UtilEnt.vegetate(villager); + UtilEnt.silence(villager, true); + UtilEnt.CreatureForceLook(villager, 0, UtilAlg.GetYaw(UtilAlg.getTrajectory(villager.getLocation(), _host.GetSpectatorLocation()))); - _entities.add(villager); + _entities.put(villager, location); } - } - - public void purchaseUpgrade(Player player, MobaUpgrade upgrade) - { - _upgrades.putIfAbsent(player, new HashSet<>(3)); - _upgrades.get(player).add(upgrade); + _host.CreatureAllowOverride = false; } private void openShop(MobaPlayer player) { + MobaShopMenu menu = _roleMenus.get(player.Role); + if (menu == null) + { + player.Player.sendMessage(F.main("Game", "There isn't an upgrade shop for that kit yet.")); + return; + } + + menu.open(player.Player); + } + + @EventHandler + public void npcMove(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + { + return; + } + + for (Entry entry : _entities.entrySet()) + { + LivingEntity entity = entry.getKey(); + Location location = entry.getValue(); + + ((CraftLivingEntity) entity).getHandle().setPosition(location.getX(), location.getY(), location.getZ()); + } + } + + @EventHandler + public void npcDamage(EntityDamageEvent event) + { + for (Entry entry : _entities.entrySet()) + { + LivingEntity entity = entry.getKey(); + + if (entity.equals(event.getEntity())) + { + entity.setFireTicks(0); + event.setCancelled(true); + return; + } + } } @EventHandler @@ -83,9 +143,9 @@ public class MobaShop implements Listener return; } - Player player = (Player) clicked; + Player player = (Player) clicker; - for (LivingEntity shop : _entities) + for (LivingEntity shop : _entities.keySet()) { if (clicked.equals(shop)) { @@ -93,6 +153,7 @@ public class MobaShop implements Listener if (data == null) { + player.sendMessage(F.main("Game", "You don't appear to have any data?")); return; } @@ -101,4 +162,93 @@ public class MobaShop implements Listener } } } + + public void purchaseItem(Player player, MobaItem item) + { + player.sendMessage(F.main("Game", "Purchased " + F.greenElem(item.getItem().getItemMeta().getDisplayName()) + ".")); + _host.getGoldManager().removeGold(player, item.getCost()); + _upgrades.get(player).add(item); + } + + public boolean ownsItem(Player player, MobaItem item) + { + return _upgrades.get(player).contains(item); + } + + public List getOwnedItems(Player player) + { + return _upgrades.get(player); + } + + /* + Handle MobaItem events + */ + + @EventHandler + public void prepare(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + for (Player player : _host.GetPlayers(true)) + { + _upgrades.put(player, new ArrayList<>()); + } + } + + @EventHandler + public void cooldownCalculate(CooldownCalculateEvent event) + { + Player player = event.getPlayer(); + List items = _upgrades.get(player); + + for (MobaItem item : items) + { + if (item.getEffects() == null) + { + continue; + } + + for (MobaItemEffect effect : item.getEffects()) + { + effect.onCooldownCheck(event); + } + } + } + + @EventHandler + public void combatDeath(CombatDeathEvent event) + { + CombatComponent component = event.GetLog().GetKiller(); + + if (component == null || !component.IsPlayer() || !(event.GetEvent().getEntity() instanceof Player)) + { + return; + } + + Player killed = (Player) event.GetEvent().getEntity(); + Player killer = UtilPlayer.searchExact(component.getUniqueIdOfEntity()); + + if (killer == null) + { + return; + } + + List items = _upgrades.get(killer); + + for (MobaItem item : items) + { + if (item.getEffects() == null) + { + continue; + } + + for (MobaItemEffect effect : item.getEffects()) + { + effect.onDeath(killed, killer); + } + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategory.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategory.java new file mode 100644 index 000000000..224433e3f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategory.java @@ -0,0 +1,47 @@ +package nautilus.game.arcade.game.games.moba.shop; + +import org.bukkit.inventory.ItemStack; + +import java.util.List; + +public class MobaShopCategory +{ + + private final String _name; + private final List _items; + private final ItemStack _menuItem; + private boolean _allowMultiple; + + public MobaShopCategory(String name, List items, ItemStack menuItem) + { + _name = name; + _items = items; + _menuItem = menuItem; + } + + public String getName() + { + return _name; + } + + public List getItems() + { + return _items; + } + + public ItemStack getMenuItem() + { + return _menuItem; + } + + public MobaShopCategory allowMultiple(boolean allow) + { + _allowMultiple = allow; + return this; + } + + public boolean isAllowingMultiple() + { + return _allowMultiple; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java new file mode 100644 index 000000000..3dd51cc3a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java @@ -0,0 +1,96 @@ +package nautilus.game.arcade.game.games.moba.shop; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; +import mineplex.core.menu.Menu; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +public class MobaShopCategoryMenu extends Menu +{ + + private static final int SLOTS = 27; + private static final int STARTING_SLOT = 10; + + private final Moba _host; + private final MobaShop _shop; + private final MobaShopCategory _category; + + public MobaShopCategoryMenu(Moba host, MobaShop shop, MobaShopCategory category, ArcadeManager plugin) + { + super(category.getName() + " Shop", plugin); + + _host = host; + _shop = shop; + _category = category; + } + + @Override + protected Button[] setUp(Player player) + { + Button[] buttons = new Button[SLOTS]; + int slot = STARTING_SLOT; + + for (MobaItem item : _category.getItems()) + { + ItemBuilder builder = new ItemBuilder(item.getItem()); + boolean owns = _shop.ownsItem(player, item); + boolean canPurchase = _host.getGoldManager().hasGold(player, item.getCost()); + + builder.setTitle((canPurchase ? C.cGreen : C.cRed) + item.getItem().getItemMeta().getDisplayName()); + + if (owns) + { + builder.addLore(C.cRed + "You already have purchased this upgrade"); + } + else + { + builder.addLore("Cost: " + C.cGold + item.getCost()); + + if (canPurchase) + { + builder.addLore(C.cGreen + "Click to purchase"); + } + else + { + builder.addLore(C.cRed + "You cannot afford this item."); + } + } + + buttons[slot++] = new MobaPurchaseButton(builder.build(), getPlugin(), item); + } + + return buttons; + } + + class MobaPurchaseButton extends Button + { + + private MobaItem _item; + + public MobaPurchaseButton(ItemStack itemStack, ArcadeManager plugin, MobaItem item) + { + super(itemStack, plugin); + + _item = item; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + boolean owns = _shop.ownsItem(player, _item); + boolean canPurchase = _host.getGoldManager().hasGold(player, _item.getCost()); + + if (!owns && canPurchase) + { + _shop.purchaseItem(player, _item); + player.closeInventory(); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java new file mode 100644 index 000000000..5c3d4582e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java @@ -0,0 +1,124 @@ +package nautilus.game.arcade.game.games.moba.shop; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilUI; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.menu.Button; +import mineplex.core.menu.Menu; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaRole; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +import java.util.ArrayList; +import java.util.List; + +public class MobaShopMenu extends Menu +{ + + private static final int SLOTS = 27; + + private final Moba _host; + private final MobaShop _shop; + private final List _categories; + + public MobaShopMenu(Moba host, MobaShop shop, MobaRole role) + { + super(role.getName() + " Upgrade Shop", host.getArcadeManager()); + + _host = host; + _shop = shop; + _categories = new ArrayList<>(); + } + + protected void addCategory(MobaShopCategory category) + { + _categories.add(category); + } + + @Override + protected Button[] setUp(Player player) + { + Button[] buttons = new Button[SLOTS]; + int[] slots = UtilUI.getIndicesFor(_categories.size(), 1); + int slot = 0; + + for (MobaShopCategory category : _categories) + { + ItemBuilder builder; + MobaItem owned = null; + + for (MobaItem item : category.getItems()) + { + if (_shop.ownsItem(player, item)) + { + owned = item; + break; + } + } + + if (owned == null) + { + builder = new ItemBuilder(category.getMenuItem()); + } + else + { + builder = new ItemBuilder(owned.getItem()); + } + + builder.setTitle(C.cGreen + category.getName()); + builder.addLore("", "Not sure what to put here", ""); + + if (category.isAllowingMultiple()) + { + builder.addLore(C.cWhite + "Current Upgrades:"); + boolean ownsAtLeastOne = false; + + for (MobaItem item : category.getItems()) + { + if (_shop.ownsItem(player, item)) + { + ownsAtLeastOne = true; + builder.addLore(" - " + item.getItem().getItemMeta().getDisplayName()); + } + } + + if (!ownsAtLeastOne) + { + builder.addLore(" - None"); + } + } + else + { + builder.addLore(C.cWhite + "Current Upgrade: " + (owned == null ? C.cGray + "None" : owned.getItem().getItemMeta().getDisplayName())); + } + + builder.addLore("", C.cYellow + "Click to view the upgrades."); + + buttons[slots[slot++]] = new MobaCategoryButton(builder.build(), getPlugin(), category); + } + + return buttons; + } + + class MobaCategoryButton extends Button + { + + private MobaShopCategory _category; + + public MobaCategoryButton(ItemStack itemStack, ArcadeManager plugin, MobaShopCategory category) + { + super(itemStack, plugin); + + _category = category; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + new MobaShopCategoryMenu(_host, _shop, _category, getPlugin()).open(player); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgrade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgrade.java deleted file mode 100644 index 55312fdc6..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgrade.java +++ /dev/null @@ -1,19 +0,0 @@ -package nautilus.game.arcade.game.games.moba.shop; - -import org.bukkit.inventory.ItemStack; - -public class MobaUpgrade -{ - - private ItemStack _item; - - public MobaUpgrade(ItemStack item) - { - _item = item; - } - - public ItemStack getItem() - { - return _item; - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgradeType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgradeType.java deleted file mode 100644 index 432e868a8..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaUpgradeType.java +++ /dev/null @@ -1,13 +0,0 @@ -package nautilus.game.arcade.game.games.moba.shop; - -public enum MobaUpgradeType -{ - - SWORD, - BOW, - HELMET, - CHEST, - LEGS, - BOOTS - -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java new file mode 100644 index 000000000..5908c9c6a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java @@ -0,0 +1,43 @@ +package nautilus.game.arcade.game.games.moba.shop.assassin; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.shop.MobaItem; +import nautilus.game.arcade.game.games.moba.shop.MobaShop; +import nautilus.game.arcade.game.games.moba.shop.MobaShopCategory; +import nautilus.game.arcade.game.games.moba.shop.MobaShopMenu; +import nautilus.game.arcade.game.games.moba.shop.effects.MobaKillHealEffect; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemStack; + +import java.util.Arrays; + +public class MobaAssassinShop extends MobaShopMenu +{ + + private static final MobaShopCategory SWORD = new MobaShopCategory("Sword", Arrays.asList( + new MobaItem(new ItemBuilder(Material.GOLD_SWORD) + .setTitle(C.cGreenB + "Sword of Time") + .build(), 800) + .addEffects( + new MobaKillHealEffect(3) + ), + new MobaItem(new ItemBuilder(Material.IRON_SWORD) + .setTitle(C.cYellowB + "Adventurer's Sword") + .build(), 1000), + new MobaItem(new ItemBuilder(Material.DIAMOND_SWORD) + .setTitle(C.cDRedB + "Pumpkin King's Blade") + .addEnchantment(Enchantment.DAMAGE_ALL, 3) + .build(), 1750) + ), new ItemStack(Material.WOOD_SWORD)); + + public MobaAssassinShop(Moba host, MobaShop shop) + { + super(host, shop, MobaRole.ASSASSIN); + + addCategory(SWORD); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/common/CooldownUpgrade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/common/CooldownUpgrade.java deleted file mode 100644 index 0c7d0c84c..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/common/CooldownUpgrade.java +++ /dev/null @@ -1,22 +0,0 @@ -package nautilus.game.arcade.game.games.moba.shop.common; - -import nautilus.game.arcade.game.games.moba.shop.MobaUpgrade; -import org.bukkit.inventory.ItemStack; - -public class CooldownUpgrade extends MobaUpgrade -{ - - private double _reductionFactor; - - public CooldownUpgrade(ItemStack item, double reductionFactor) - { - super(item); - - _reductionFactor = reductionFactor; - } - - public double getReductionFactor() - { - return _reductionFactor; - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java new file mode 100644 index 000000000..ea6b08db8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java @@ -0,0 +1,22 @@ +package nautilus.game.arcade.game.games.moba.shop.effects; + +import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; +import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; +import org.bukkit.entity.Player; + +public class MobaCDREffect extends MobaItemEffect +{ + + private double _factor; + + public MobaCDREffect(double factor) + { + _factor = factor; + } + + @Override + public void onCooldownCheck(CooldownCalculateEvent event) + { + event.decreaseCooldown(_factor); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java new file mode 100644 index 000000000..4aaca0a0c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java @@ -0,0 +1,21 @@ +package nautilus.game.arcade.game.games.moba.shop.effects; + +import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; +import org.bukkit.entity.Player; + +public class MobaKillHealEffect extends MobaItemEffect +{ + + private double _health; + + public MobaKillHealEffect(double health) + { + _health = health; + } + + @Override + public void onDeath(Player killed, Player killer) + { + killer.setHealth(Math.min(killer.getMaxHealth(), killer.getHealth() + _health)); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java index 3c5167baa..c97b92bee 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java @@ -168,6 +168,12 @@ public class CapturePoint private void setOwner(GameTeam team) { + // Same team + if (_owner != null && _owner.equals(team)) + { + return; + } + _owner = team; setBeaconColour(team); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointCaptureEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointCaptureEvent.java index 4383350aa..c7443a151 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointCaptureEvent.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointCaptureEvent.java @@ -1,11 +1,8 @@ package nautilus.game.arcade.game.games.moba.structure.point; -import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import java.util.List; - public class CapturePointCaptureEvent extends Event { From 50da7139476a989b3a6555ad7733917749bb8405 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 8 May 2017 22:01:27 +0100 Subject: [PATCH 07/57] Remove the previous upgrade when switching upgrades --- .../game/games/moba/gold/GoldManager.java | 12 ++++++ .../arcade/game/games/moba/kit/HeroKit.java | 38 +---------------- .../game/games/moba/kit/common/SkillBow.java | 23 ++++++++++ .../games/moba/kit/common/SkillSword.java | 24 +++++++++++ .../arcade/game/games/moba/shop/MobaShop.java | 42 +++++++++++++++---- .../games/moba/shop/MobaShopCategoryMenu.java | 8 ++-- .../game/games/moba/shop/MobaShopMenu.java | 5 +++ 7 files changed, 103 insertions(+), 49 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java index cfd386e62..79edc6baa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java @@ -13,6 +13,7 @@ import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerQuitEvent; import java.util.Collections; import java.util.HashMap; @@ -74,6 +75,12 @@ public class GoldManager implements Listener } } + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + _playerGold.remove(event.getPlayer()); + } + @EventHandler public void passiveGain(UpdateEvent event) { @@ -105,6 +112,11 @@ public class GoldManager implements Listener } } + public int getGold(Player player) + { + return _playerGold.get(player); + } + public void addGold(Player player, int amount) { _playerGold.put(player, _playerGold.get(player) + amount); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index cf31fe78e..ce57121ca 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -2,30 +2,22 @@ package nautilus.game.arcade.game.games.moba.kit; import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilPlayer; 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.ArcadeManager; -import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaRole; -import nautilus.game.arcade.game.games.moba.kit.common.SkillBow; -import nautilus.game.arcade.game.games.moba.kit.common.SkillSword; -import nautilus.game.arcade.game.games.moba.shop.MobaItem; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; -import java.util.List; - public class HeroKit extends Kit { @@ -147,10 +139,7 @@ public class HeroKit extends Kit inventory.setItem(AMMO_SLOT, _ammo); inventory.setItem(RECALL_SLOT, RECALL_ITEM); - Moba host = (Moba) Manager.GetGame(); - List ownedItems = host.getShop().getOwnedItems(player); - - perkLoop: for (Perk perk : GetPerks()) + for (Perk perk : GetPerks()) { if (!(perk instanceof HeroSkill)) { @@ -159,31 +148,6 @@ public class HeroKit extends Kit HeroSkill skill = (HeroSkill) perk; - // Sword upgrades - if (skill instanceof SkillSword) - { - for (MobaItem item : ownedItems) - { - if (UtilItem.isSword(item.getItem())) - { - player.getInventory().setItem(skill.getSlot(), item.getItem()); - continue perkLoop; - } - } - } - // Bow upgrades - else if (skill instanceof SkillBow) - { - for (MobaItem item : ownedItems) - { - if (item.getItem().getType() == Material.BOW) - { - player.getInventory().setItem(skill.getSlot(), item.getItem()); - continue perkLoop; - } - } - } - if (skill.isOnCooldown(player)) { player.getInventory().setItem(skill.getSlot(), skill.getCooldownItem()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillBow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillBow.java index 3ce67db5e..3edfe97a5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillBow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillBow.java @@ -1,9 +1,14 @@ package nautilus.game.arcade.game.games.moba.kit.common; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.shop.MobaItem; import org.bukkit.Material; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import java.util.List; + public class SkillBow extends HeroSkill { @@ -17,4 +22,22 @@ public class SkillBow extends HeroSkill { super("Bow", DESCRIPTION, SKILL_ITEM, slot, null); } + + @Override + public void giveItem(Player player) + { + Moba host = (Moba) Manager.GetGame(); + List ownedItems = host.getShop().getOwnedItems(player); + + for (MobaItem item : ownedItems) + { + if (item.getItem().getType() == Material.BOW) + { + player.getInventory().setItem(getSlot(), item.getItem()); + return; + } + } + + player.getInventory().setItem(getSlot(), SKILL_ITEM); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java index 864c35188..8b892c4eb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java @@ -1,12 +1,18 @@ package nautilus.game.arcade.game.games.moba.kit.common; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilItem; import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.shop.MobaItem; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import java.util.List; + public class SkillSword extends HeroSkill { @@ -23,4 +29,22 @@ public class SkillSword extends HeroSkill { super("Sword", DESCRIPTION, SKILL_ITEM, slot, null); } + + @Override + public void giveItem(Player player) + { + Moba host = (Moba) Manager.GetGame(); + List ownedItems = host.getShop().getOwnedItems(player); + + for (MobaItem item : ownedItems) + { + if (UtilItem.isSword(item.getItem())) + { + player.getInventory().setItem(getSlot(), item.getItem()); + return; + } + } + + player.getInventory().setItem(getSlot(), SKILL_ITEM); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index 0518b8c21..fd0933d45 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -1,18 +1,18 @@ package nautilus.game.arcade.game.games.moba.shop; -import mineplex.core.common.Rank; import mineplex.core.common.util.*; 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.events.GameStateChangeEvent; -import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaPlayer; import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; +import nautilus.game.arcade.game.games.moba.shop.MobaShopMenu.MobaCategoryButton; import nautilus.game.arcade.game.games.moba.shop.assassin.MobaAssassinShop; import org.bukkit.Location; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; @@ -22,6 +22,7 @@ import org.bukkit.entity.Player; import org.bukkit.entity.Villager; import org.bukkit.entity.Villager.Profession; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; @@ -109,16 +110,14 @@ public class MobaShop implements Listener } @EventHandler - public void npcDamage(EntityDamageEvent event) + public void npcDamage(CustomDamageEvent event) { - for (Entry entry : _entities.entrySet()) + for (LivingEntity entity : _entities.keySet()) { - LivingEntity entity = entry.getKey(); - - if (entity.equals(event.getEntity())) + if (entity.equals(event.GetDamageeEntity())) { entity.setFireTicks(0); - event.setCancelled(true); + event.SetCancelled("Shop NPC"); return; } } @@ -165,9 +164,18 @@ public class MobaShop implements Listener public void purchaseItem(Player player, MobaItem item) { + List owned = _upgrades.get(player); + MobaShopCategory category = getCategory(item); + + if (!category.isAllowingMultiple()) + { + owned.removeIf(previousItem -> getCategory(previousItem) == category); + } + player.sendMessage(F.main("Game", "Purchased " + F.greenElem(item.getItem().getItemMeta().getDisplayName()) + ".")); _host.getGoldManager().removeGold(player, item.getCost()); - _upgrades.get(player).add(item); + owned.add(item); + _host.GetKit(player).ApplyKit(player); } public boolean ownsItem(Player player, MobaItem item) @@ -180,6 +188,22 @@ public class MobaShop implements Listener return _upgrades.get(player); } + private MobaShopCategory getCategory(MobaItem item) + { + for (MobaShopMenu menu : _roleMenus.values()) + { + for (MobaShopCategory category : menu.getCategories()) + { + if (category.getItems().contains(item)) + { + return category; + } + } + } + + return null; + } + /* Handle MobaItem events */ diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java index 3dd51cc3a..69477ad5b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java @@ -41,20 +41,22 @@ public class MobaShopCategoryMenu extends Menu ItemBuilder builder = new ItemBuilder(item.getItem()); boolean owns = _shop.ownsItem(player, item); boolean canPurchase = _host.getGoldManager().hasGold(player, item.getCost()); + int gold = _host.getGoldManager().getGold(player); builder.setTitle((canPurchase ? C.cGreen : C.cRed) + item.getItem().getItemMeta().getDisplayName()); + builder.addLore(""); if (owns) { - builder.addLore(C.cRed + "You already have purchased this upgrade"); + builder.addLore(C.cRed + "You already have purchased this upgrade."); } else { - builder.addLore("Cost: " + C.cGold + item.getCost()); + builder.addLore(C.cWhite + "Cost: " + C.cGold + item.getCost(), C.cWhite + "Your Gold: " + C.cGold + gold, ""); if (canPurchase) { - builder.addLore(C.cGreen + "Click to purchase"); + builder.addLore(C.cGreen + "Click to purchase."); } else { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java index 5c3d4582e..515445f82 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java @@ -121,4 +121,9 @@ public class MobaShopMenu extends Menu new MobaShopCategoryMenu(_host, _shop, _category, getPlugin()).open(player); } } + + public List getCategories() + { + return _categories; + } } From 5f7574a0affa231b69a1d8edfee9921bf33dda51 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 8 May 2017 22:07:14 +0100 Subject: [PATCH 08/57] Increase particles displayed when selecting a kit --- .../game/arcade/game/games/moba/kit/PregameSelection.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java index cc620307f..168e0a97e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java @@ -132,7 +132,8 @@ public class PregameSelection implements Listener, IPacketHandler // stand.setChestplate(buildColouredStack(Material.LEATHER_CHESTPLATE, role)); // stand.setLeggings(buildColouredStack(Material.LEATHER_LEGGINGS, role)); // stand.setBoots(buildColouredStack(Material.LEATHER_BOOTS, role)); - UtilParticle.PlayParticle(ParticleType.CLOUD, location.clone().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.01F, 1, ViewDist.LONG, player); + player.playSound(player.getLocation(), Sound.LEVEL_UP, 1, 0.5F); + UtilParticle.PlayParticle(ParticleType.CLOUD, location.clone().add(0, 2, 0), 0.5F, 0.5F, 0.5F, 0.01F, 20, ViewDist.LONG, player); _kitStands.put(stand, kit); From eec8e5143d7d7cc5eeebc27598382e5ea07a2099 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 9 May 2017 23:16:34 +0100 Subject: [PATCH 09/57] Per player scoreboards --- .../nautilus/game/arcade/ArcadeManager.java | 5 + .../src/nautilus/game/arcade/game/Game.java | 1 + .../game/arcade/game/games/moba/Moba.java | 45 +++- .../games/moba/shop/MobaShopCategoryMenu.java | 6 + .../game/modules/CustomScoreboardModule.java | 200 ++++++++++++++++++ .../game/arcade/managers/GameManager.java | 9 +- .../arcade/managers/GamePlayerManager.java | 19 +- .../arcade/managers/lobby/LobbyManager.java | 10 +- .../arcade/scoreboard/GameScoreboard.java | 9 +- 9 files changed, 280 insertions(+), 24 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 20c226a03..9cce4fec6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -416,6 +416,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation @Override public void handlePlayerJoin(String playerName) { + if (GetGame() != null && GetGame().GetState() != GameState.Loading && GetGame().GetState() != GameState.Recruit && GetGame().UseCustomScoreboard) + { + return; + } + CoreClient client = GetClients().Get(playerName); for (MineplexScoreboard scoreboard : getScoreboards().values()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 74f2baf73..26aacf6fe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -177,6 +177,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed // Scoreboard protected GameScoreboard Scoreboard; + public boolean UseCustomScoreboard = false; // Loaded from Map Config public WorldData WorldData = null; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 98f5a29a7..a9f1c238c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -28,6 +28,7 @@ import nautilus.game.arcade.game.games.moba.recall.Recall; import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; +import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Perk; @@ -77,22 +78,15 @@ public class Moba extends TeamGame new HeroBob(Manager) }; + DontAllowOverfill = true; PrepareAutoAnnounce = false; PrepareFreeze = false; PrepareTime = PREPARE_TIME; DeathOut = false; DeathSpectateSecs = 10; HungerSet = 20; - DontAllowOverfill = true; - DamageFall = false; - new CompassModule() - .setGiveCompass(true) - .setGiveCompassToSpecs(true) - .setGiveCompassToAlive(false) - .register(this); - Listener preGameSelection = new PregameSelection(this); _listeners.add(preGameSelection); @@ -107,6 +101,37 @@ public class Moba extends TeamGame _goldManager = goldManager; _listeners.add(goldManager); + new CompassModule() + .setGiveCompass(true) + .setGiveCompassToSpecs(true) + .setGiveCompassToAlive(false) + .register(this); + + new CustomScoreboardModule() + .setSidebar((player, scoreboard) -> + { + scoreboard.writeNewLine(); + + scoreboard.write("Testing"); + + int gold = _goldManager.getGold(player); + scoreboard.write("Gold " + gold); + + scoreboard.writeNewLine(); + }) + .setPrefix((perspective, subject) -> + { + if (!IsAlive(subject)) + { + return C.cGray; + } + + GameTeam team = GetTeam(subject); + + return team.GetColor().toString(); + }) + .register(this); + registerDebugCommand(new DebugCommand("kit", Rank.ADMIN) { @Override @@ -114,9 +139,9 @@ public class Moba extends TeamGame { String kit = ""; - for (int i = 0; i < args.length; i++) + for (String arg : args) { - kit += args[i] + " "; + kit += arg + " "; } kit = kit.trim(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java index 69477ad5b..5a6ed5f70 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java @@ -7,6 +7,7 @@ import mineplex.core.menu.Button; import mineplex.core.menu.Menu; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; @@ -90,9 +91,14 @@ public class MobaShopCategoryMenu extends Menu if (!owns && canPurchase) { + player.playSound(player.getLocation(), Sound.NOTE_PLING, 1, 1.6F); _shop.purchaseItem(player, _item); player.closeInventory(); } + else + { + player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, 0.6F); + } } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java new file mode 100644 index 000000000..a14c40e36 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java @@ -0,0 +1,200 @@ +package nautilus.game.arcade.game.modules; + +import mineplex.core.common.util.C; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.scoreboard.GameScoreboard; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.scoreboard.Scoreboard; +import org.bukkit.scoreboard.Team; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import java.util.function.BiConsumer; +import java.util.function.BiFunction; + +public class CustomScoreboardModule extends Module +{ + + private final Map _scoreboard; + + private BiConsumer _scoreboardConsumer; + private BiFunction _prefixFunction; + + public CustomScoreboardModule() + { + _scoreboard = new HashMap<>(); + } + + @Override + protected void setup() + { + getGame().UseCustomScoreboard = true; + } + + @EventHandler + public void playerJoin(PlayerJoinEvent event) + { + Player player = event.getPlayer(); + GameState state = getGame().GetState(); + + if (state == GameState.Loading || state == GameState.Recruit) + { + return; + } + + setupScoreboard(player); + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + Player player = event.getPlayer(); + + _scoreboard.remove(player.getUniqueId()); + + for (CustomArcadeScoreboard scoreboard : _scoreboard.values()) + { + scoreboard.getHandle().getTeam(player.getName()).unregister(); + } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void prepare(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + for (Player player : Bukkit.getOnlinePlayers()) + { + setupScoreboard(player); + } + + refresh(); + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + for (CustomArcadeScoreboard scoreboard : _scoreboard.values()) + { + scoreboard.draw(); + } + } + + private void setupScoreboard(Player player) + { + UUID key = player.getUniqueId(); + CustomArcadeScoreboard scoreboard = _scoreboard.get(key); + + if (scoreboard == null) + { + scoreboard = new CustomArcadeScoreboard(player); + _scoreboard.put(player.getUniqueId(), scoreboard); + player.setScoreboard(scoreboard.getHandle()); + } + else + { + player.setScoreboard(scoreboard.getHandle()); + } + } + + public CustomScoreboardModule setSidebar(BiConsumer consumer) + { + _scoreboardConsumer = consumer; + return this; + } + + public CustomScoreboardModule setPrefix(BiFunction function) + { + _prefixFunction = function; + return this; + } + + public void refresh() + { + for (CustomArcadeScoreboard scoreboard : _scoreboard.values()) + { + scoreboard.draw(false); + } + } + + @Override + public void cleanup() + { + _scoreboard.clear(); + } + + class CustomArcadeScoreboard extends GameScoreboard + { + + CustomArcadeScoreboard(Player owner) + { + super(getGame(), owner); + } + + public void setTag(Player subject, String prefix, String suffix) + { + Scoreboard handle = getHandle(); + String teamName = subject.getName(); + Team team = handle.getTeam(teamName); + + if (team == null) + { + team = handle.registerNewTeam(teamName); + team.addEntry(subject.getName()); + } + + if (prefix != null) + { + team.setPrefix(prefix + C.Reset + " "); + } + else if (suffix != null) + { + team.setSuffix(suffix + C.Reset + " "); + } + } + + @Override + public void draw() + { + draw(true); + } + + public void draw(boolean sidebarOnly) + { + if (_scoreboardConsumer != null) + { + _scoreboardConsumer.accept(getOwner(), this); + } + if (sidebarOnly) + { + if (_prefixFunction != null) + { + for (Player player : Bukkit.getOnlinePlayers()) + { + _prefixFunction.apply(getOwner(), player); + } + } + } + super.draw(); + } + } + + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java index 2b94686d0..57a1eff12 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java @@ -475,9 +475,12 @@ public class GameManager implements Listener return; Game game = Manager.GetGame(); - if (game == null) return; - - game.GetScoreboard().updateTitle(); + if (game == null) return; + + if (!game.UseCustomScoreboard) + { + game.GetScoreboard().updateTitle(); + } } public void TeamPreferenceJoin(Game game) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java index 00e52236a..98d0cfb35 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.managers; import java.util.ArrayList; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; @@ -83,14 +84,15 @@ public class GamePlayerManager implements Listener final Player player = event.getPlayer(); //Player List - UtilTabTitle.setHeaderAndFooter(player, - Manager.GetGame() != null ? C.cGold + C.Bold + Manager.GetGame().GetType().GetName() : " ", - "Visit " + C.cGreen + "www.mineplex.com" + ChatColor.RESET + " for News, Forums and Shop"); + UtilTabTitle.setHeaderAndFooter(player, + Manager.GetGame() != null ? C.cGold + C.Bold + Manager.GetGame().GetType().GetName() : " ", + "Visit " + C.cGreen + "www.mineplex.com" + ChatColor.RESET + " for News, Forums and Shop"); //Lobby Spawn if (Manager.GetGame() == null || !Manager.GetGame().InProgress()) { Manager.Clear(player); + Manager.getScoreboardManager().getScoreboards().entrySet().stream().filter(ent -> Bukkit.getPlayer(ent.getKey()) != null).forEach(ent -> Bukkit.getPlayer(ent.getKey()).setScoreboard(ent.getValue().getHandle())); player.teleport(Manager.GetLobby().getSpawn()); //Load default kit for this game if (Manager.GetGame() != null && Manager.GetGame().GetType().name().toLowerCase().contains("champions")) @@ -133,19 +135,24 @@ public class GamePlayerManager implements Listener if (loc != null && !loc.getWorld().getName().equalsIgnoreCase("world")) { player.teleport(loc); - } else + } + else { Manager.Clear(player); player.teleport(Manager.GetGame().GetTeam(player).GetSpawn()); } - } else + } + else { Manager.Clear(player); Manager.addSpectator(player, true); UtilPlayer.message(player, F.main("Game", Manager.GetGame().GetName() + " is in progress, please wait for next game!")); } - player.setScoreboard(Manager.GetGame().GetScoreboard().getScoreboard()); + if (!Manager.GetGame().UseCustomScoreboard) + { + player.setScoreboard(Manager.GetGame().GetScoreboard().getScoreboard()); + } } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java index 72f1dc35f..c27497c40 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java @@ -479,10 +479,14 @@ public abstract class LobbyManager implements Listener return; } - if (_manager.GetGame() != null && - (_manager.GetGame().GetState() != GameState.Loading && - _manager.GetGame().GetState() != GameState.Recruit)) + Game game = _manager.GetGame(); + if (game != null && game.GetState() != GameState.Loading && game.GetState() != GameState.Recruit) { + if (game.UseCustomScoreboard) + { + return; + } + for (Player player : UtilServer.getPlayers()) player.setScoreboard(_manager.GetGame().GetScoreboard().getScoreboard()); //XXX } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java index def71d516..e912a550b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java @@ -29,10 +29,15 @@ public class GameScoreboard extends WritableMineplexScoreboard public GameScoreboard(Game game) { + this(game, null); + } + + public GameScoreboard(Game game, Player player) + { + super(player); + _game = game; - _title = " MINEPLEX "; - setSidebarName(C.Bold + _title); } From dcb676c57be5854664975ae17aed1d4d5b18dd07 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 10 May 2017 19:25:56 +0100 Subject: [PATCH 10/57] Item upgrade effects --- .../nautilus/game/arcade/ArcadeManager.java | 1 + .../game/arcade/game/games/moba/Moba.java | 46 +++++++++- .../game/games/moba/MobaHPRegenEvent.java | 49 ++++++++++ .../games/moba/fountain/MobaFountain.java | 91 +++++++++++++++++++ .../moba/kit/CooldownCalculateEvent.java | 2 +- .../arcade/game/games/moba/kit/HeroKit.java | 32 +++++++ .../arcade/game/games/moba/kit/HeroSkill.java | 3 +- .../games/moba/kit/anath/SkillBurnBeam.java | 2 +- .../games/moba/kit/hattori/SkillSnowball.java | 2 +- .../arcade/game/games/moba/shop/MobaItem.java | 24 ++++- .../game/games/moba/shop/MobaItemEffect.java | 18 ++-- .../arcade/game/games/moba/shop/MobaShop.java | 60 +++++++++++- .../games/moba/shop/MobaShopCategoryMenu.java | 26 +++++- .../game/games/moba/shop/MobaShopMenu.java | 2 +- .../moba/shop/assassin/MobaAssassinShop.java | 87 +++++++++++++++++- .../moba/shop/effects/MobaCDREffect.java | 26 +++++- .../moba/shop/effects/MobaHPRegenEffect.java | 46 ++++++++++ .../moba/shop/effects/MobaKillHealEffect.java | 28 +++++- .../moba/shop/effects/MobaSpeedEffect.java | 48 ++++++++++ .../shop/effects/MobaTotalHealthEffect.java | 50 ++++++++++ .../game/modules/CustomScoreboardModule.java | 16 +++- 21 files changed, 629 insertions(+), 30 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaHPRegenEvent.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 9cce4fec6..49effeb23 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -1217,6 +1217,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation player.setGameMode(GameMode.SURVIVAL); player.setAllowFlight(false); player.setFlySpeed(0.1F); + player.setWalkSpeed(0.2F); UtilInv.Clear(player); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index a9f1c238c..aaf8d4cb6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -17,6 +17,7 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.games.moba.fountain.MobaFountain; import nautilus.game.arcade.game.games.moba.gold.GoldManager; import nautilus.game.arcade.game.games.moba.kit.*; import nautilus.game.arcade.game.games.moba.kit.anath.HeroAnath; @@ -38,6 +39,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityRegainHealthEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.metadata.FixedMetadataValue; @@ -50,9 +53,11 @@ public class Moba extends TeamGame { private static final String[] DESCRIPTION = { - "MORE CAPTURE POINTS" + "..." }; private static final long PREPARE_TIME = TimeUnit.MINUTES.toMillis(1); + // Health per 5 seconds. + private static final double HP5 = 0.33; private final HeroKit[] _kits; @@ -101,6 +106,9 @@ public class Moba extends TeamGame _goldManager = goldManager; _listeners.add(goldManager); + MobaFountain fountain = new MobaFountain(this); + _listeners.add(fountain); + new CompassModule() .setGiveCompass(true) .setGiveCompassToSpecs(true) @@ -444,7 +452,6 @@ public class Moba extends TeamGame } } - //TODO announce to all @Override public DeathMessageType GetDeathMessageType() { @@ -522,6 +529,41 @@ public class Moba extends TeamGame } } + /* + HP Regeneration + */ + @EventHandler + public void regeneration(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC_05) + { + return; + } + + for (Player player : GetPlayers(true)) + { + if (UtilPlayer.isSpectator(player)) + { + continue; + } + + MobaHPRegenEvent regenEvent = new MobaHPRegenEvent(player, HP5); + UtilServer.CallEvent(regenEvent); + + player.setHealth(Math.min(player.getMaxHealth(), player.getHealth() + regenEvent.getHealth())); + } + } + + @EventHandler + public void preventHungerRegeneration(EntityRegainHealthEvent event) + { + if (event.getRegainReason() == RegainReason.SATIATED) + { + event.setCancelled(true); + } + } + + public Map getLocationStartsWith(String s) { Map map = new HashMap<>(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaHPRegenEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaHPRegenEvent.java new file mode 100644 index 000000000..0ec5994c8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaHPRegenEvent.java @@ -0,0 +1,49 @@ +package nautilus.game.arcade.game.games.moba; + +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +public class MobaHPRegenEvent extends PlayerEvent +{ + + private static final HandlerList _handlers = new HandlerList(); + + private final double _initialHealth; + private double _health; + + public MobaHPRegenEvent(Player who, double health) + { + super(who); + + _initialHealth = health; + _health = health; + } + + public void setHealth(double health) + { + _health = health; + } + + public void increaseHealth(double factor) + { + _health = _initialHealth * factor; + } + + public double getHealth() + { + return _health; + } + + public static HandlerList getHandlerList() + { + return _handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java new file mode 100644 index 000000000..c77112f5c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java @@ -0,0 +1,91 @@ +package nautilus.game.arcade.game.games.moba.fountain; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.events.PlayerGameRespawnEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +public class MobaFountain implements Listener +{ + + private static final int FOUNTAIN_SIZE_SQUARED = 5; + + private final Moba _host; + private final Map _average; + + public MobaFountain(Moba host) + { + _host = host; + _average = new HashMap<>(); + } + + @EventHandler + public void prepare(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + for (GameTeam team : _host.GetTeamList()) + { + _average.put(team, UtilAlg.getAverageLocation(team.GetSpawns())); + } + } + + @EventHandler + public void respawn(PlayerGameRespawnEvent event) + { + Player player = event.GetPlayer(); + + _host.getArcadeManager().GetCondition().Factory().Regen("Fountain", player, null, 3, 9, false, true, false); + } + + @EventHandler + public void updateInFountain(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC || !_host.IsLive()) + { + return; + } + + for (Player player : _host.GetPlayers(true)) + { + GameTeam playerTeam = _host.GetTeam(player); + + for (Entry entry : _average.entrySet()) + { + GameTeam team = entry.getKey(); + Location location = entry.getValue(); + + if (UtilMath.offsetSquared(player.getLocation(), location) > FOUNTAIN_SIZE_SQUARED) + { + continue; + } + + if (playerTeam.equals(team)) + { + player.setHealth(Math.min(player.getMaxHealth(), player.getHealth() + 6)); + } + else + { + _host.getArcadeManager().GetDamage().NewDamageEvent(player, null, null, DamageCause.CUSTOM, 6, false, true, true, "Fountain", "Fountain"); + } + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/CooldownCalculateEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/CooldownCalculateEvent.java index 93c0cee45..caeab4cfa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/CooldownCalculateEvent.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/CooldownCalculateEvent.java @@ -27,7 +27,7 @@ public class CooldownCalculateEvent extends PlayerEvent public void decreaseCooldown(double factor) { - _cooldown = (long) ((double) _initialCooldown * factor); + _cooldown -= (long) ((double) _initialCooldown * factor); } public long getCooldown() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index ce57121ca..276e92374 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -2,13 +2,16 @@ package nautilus.game.arcade.game.games.moba.kit; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilPlayer; 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.ArcadeManager; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.shop.MobaItem; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; @@ -18,6 +21,8 @@ import org.bukkit.event.EventHandler; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; +import java.util.List; + public class HeroKit extends Kit { @@ -136,9 +141,36 @@ public class HeroKit extends Kit { PlayerInventory inventory = player.getInventory(); + // Give standard items inventory.setItem(AMMO_SLOT, _ammo); inventory.setItem(RECALL_SLOT, RECALL_ITEM); + // Give armour + List items = ((Moba) Manager.GetGame()).getShop().getOwnedItems(player); + + for (MobaItem item : items) + { + ItemStack armour = item.getItem(); + + if (UtilItem.isHelmet(armour)) + { + inventory.setHelmet(armour); + } + else if (UtilItem.isChestplate(armour)) + { + inventory.setChestplate(armour); + } + else if (UtilItem.isLeggings(armour)) + { + inventory.setLeggings(armour); + } + else if (UtilItem.isBoots(armour)) + { + inventory.setBoots(armour); + } + } + + // Give all skill related items for (Perk perk : GetPerks()) { if (!(perk instanceof HeroSkill)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 991e2afe5..9f228b05c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -23,7 +23,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; import java.util.*; -import java.util.function.Consumer; public class HeroSkill extends Perk { @@ -289,7 +288,7 @@ public class HeroSkill extends Perk ItemStack itemStack = player.getInventory().getItem(getSlot()); itemStack.setAmount((int) (ticks / 20D)); UtilInv.addDullEnchantment(itemStack); - Recharge.Instance.useForce(player, GetName(), ticks, true); + Recharge.Instance.useForce(player, GetName(), time, true); Recharge.Instance.setDisplayForce(player, GetName(), true); Manager.runSyncTimer(new BukkitRunnable() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java index 2a2f1f23d..e4289850a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java @@ -87,7 +87,7 @@ public class SkillBurnBeam extends HeroSkill } entity.getLocation().getWorld().playSound(entity.getLocation(), Sound.EXPLODE, 2, 0.5F); - Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, 20, true, true, false, UtilEnt.getName(player), GetName()); + Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, 15, true, true, false, UtilEnt.getName(player), GetName()); } } }, 0, 1); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java index 2d353db1c..9eef19c67 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java @@ -72,7 +72,7 @@ public class SkillSnowball extends HeroSkill implements IThrown { Player thrower = (Player) data.getThrower(); - if (target != null) + if (target != null && !isTeamDamage(target, thrower)) { thrower.playSound(thrower.getLocation(), Sound.LAVA_POP, 1, 1.3F); Manager.GetDamage().NewDamageEvent(target, thrower, (Projectile) data.getThrown(), DamageCause.PROJECTILE, 3, true, true, false, UtilEnt.getName(thrower), GetName()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java index 7cabddd2a..dd5f49e9f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java @@ -1,8 +1,11 @@ package nautilus.game.arcade.game.games.moba.shop; +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; import org.bukkit.inventory.ItemStack; import java.util.ArrayList; +import java.util.Collections; import java.util.List; public class MobaItem @@ -25,16 +28,27 @@ public class MobaItem _effects = new ArrayList<>(effects.length); } - for (MobaItemEffect effect : _effects) - { - _effects.add(effect); - } + Collections.addAll(_effects, effects); return this; } public ItemStack getItem() { - return _item; + ItemBuilder builder = new ItemBuilder(_item); + + if (getEffects() != null) + { + builder.addLore("", C.cWhite + "Effects:"); + + for (MobaItemEffect effect : getEffects()) + { + builder.addLore(" - " + effect.getDescription()); + } + + builder.addLore(""); + } + + return builder.build(); } public int getCost() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java index 8af399784..d04f2d149 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java @@ -1,17 +1,21 @@ package nautilus.game.arcade.game.games.moba.shop; +import nautilus.game.arcade.events.PlayerGameRespawnEvent; +import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent; import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; import org.bukkit.entity.Player; -public class MobaItemEffect +public interface MobaItemEffect { - public void onCooldownCheck(CooldownCalculateEvent event) - { - } + void onCooldownCheck(CooldownCalculateEvent event); - public void onDeath(Player killed, Player killer) - { - } + void onDeath(Player killed, Player killer); + + void onHPRegen(MobaHPRegenEvent event); + + void onRespawn(PlayerGameRespawnEvent event); + + String getDescription(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index fd0933d45..c64ddcc16 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -7,8 +7,10 @@ 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.events.GameStateChangeEvent; +import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent; import nautilus.game.arcade.game.games.moba.MobaPlayer; import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; @@ -79,7 +81,7 @@ public class MobaShop implements Listener _host.CreatureAllowOverride = false; } - private void openShop(MobaPlayer player) + public void openShop(MobaPlayer player) { MobaShopMenu menu = _roleMenus.get(player.Role); @@ -172,6 +174,20 @@ public class MobaShop implements Listener owned.removeIf(previousItem -> getCategory(previousItem) == category); } + // The respawn event needs to be called here so that effects like "Total Health Increase" will work straight away, instead of after the next respawn, + if (item.getEffects() != null) + { + // Prevents an infinite speed + player.setWalkSpeed(0.2F); + + PlayerGameRespawnEvent fakeEvent = new PlayerGameRespawnEvent(null, player); + + for (MobaItemEffect effect : item.getEffects()) + { + effect.onRespawn(fakeEvent); + } + } + player.sendMessage(F.main("Game", "Purchased " + F.greenElem(item.getItem().getItemMeta().getDisplayName()) + ".")); _host.getGoldManager().removeGold(player, item.getCost()); owned.add(item); @@ -223,7 +239,7 @@ public class MobaShop implements Listener } @EventHandler - public void cooldownCalculate(CooldownCalculateEvent event) + public void hpRegeneration(CooldownCalculateEvent event) { Player player = event.getPlayer(); List items = _upgrades.get(player); @@ -275,4 +291,44 @@ public class MobaShop implements Listener } } } + + @EventHandler + public void hpRegeneration(MobaHPRegenEvent event) + { + Player player = event.getPlayer(); + List items = _upgrades.get(player); + + for (MobaItem item : items) + { + if (item.getEffects() == null) + { + continue; + } + + for (MobaItemEffect effect : item.getEffects()) + { + effect.onHPRegen(event); + } + } + } + + @EventHandler + public void repawn(PlayerGameRespawnEvent event) + { + Player player = event.GetPlayer(); + List items = _upgrades.get(player); + + for (MobaItem item : items) + { + if (item.getEffects() == null) + { + continue; + } + + for (MobaItemEffect effect : item.getEffects()) + { + effect.onRespawn(event); + } + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java index 5a6ed5f70..5a9567966 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java @@ -1,12 +1,13 @@ package nautilus.game.arcade.game.games.moba.shop; +import javafx.scene.shape.Arc; import mineplex.core.common.util.C; -import mineplex.core.common.util.F; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.menu.Button; import mineplex.core.menu.Menu; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -17,6 +18,9 @@ public class MobaShopCategoryMenu extends Menu private static final int SLOTS = 27; private static final int STARTING_SLOT = 10; + private static final ItemStack GO_BACK_ITEM = new ItemBuilder(Material.BED) + .setTitle(C.cGreen + "Go Back") + .build(); private final Moba _host; private final MobaShop _shop; @@ -37,6 +41,8 @@ public class MobaShopCategoryMenu extends Menu Button[] buttons = new Button[SLOTS]; int slot = STARTING_SLOT; + buttons[4] = new GoBackButton(getPlugin()); + for (MobaItem item : _category.getItems()) { ItemBuilder builder = new ItemBuilder(item.getItem()); @@ -45,10 +51,11 @@ public class MobaShopCategoryMenu extends Menu int gold = _host.getGoldManager().getGold(player); builder.setTitle((canPurchase ? C.cGreen : C.cRed) + item.getItem().getItemMeta().getDisplayName()); - builder.addLore(""); if (owns) { + builder.setType(Material.WOOL); + builder.setData((byte) 5); builder.addLore(C.cRed + "You already have purchased this upgrade."); } else @@ -101,4 +108,19 @@ public class MobaShopCategoryMenu extends Menu } } } + + class GoBackButton extends Button + { + + public GoBackButton(ArcadeManager plugin) + { + super(GO_BACK_ITEM, plugin); + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _shop.openShop(_host.getData(player)); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java index 515445f82..af128575b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java @@ -69,7 +69,7 @@ public class MobaShopMenu extends Menu } builder.setTitle(C.cGreen + category.getName()); - builder.addLore("", "Not sure what to put here", ""); + builder.addLore(""); if (category.isAllowingMultiple()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java index 5908c9c6a..9d3a43a7a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java @@ -8,7 +8,7 @@ import nautilus.game.arcade.game.games.moba.shop.MobaItem; import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.shop.MobaShopCategory; import nautilus.game.arcade.game.games.moba.shop.MobaShopMenu; -import nautilus.game.arcade.game.games.moba.shop.effects.MobaKillHealEffect; +import nautilus.game.arcade.game.games.moba.shop.effects.*; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; @@ -34,10 +34,95 @@ public class MobaAssassinShop extends MobaShopMenu .build(), 1750) ), new ItemStack(Material.WOOD_SWORD)); + private static final MobaShopCategory HELMET = new MobaShopCategory("Helmet", Arrays.asList( + new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cGreen + "Leather Cap") + .build(), 200) + .addEffects( + new MobaHPRegenEffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cGreen + "Ninja's Rainment") + .build(), 500) + .addEffects( + new MobaHPRegenEffect(0.1) + ), + new MobaItem(new ItemBuilder(Material.CHAINMAIL_HELMET) + .setTitle(C.cYellow + "Bruiser's Helm") + .build(), 1000) + .addEffects( + new MobaHPRegenEffect(0.15) + ) + ), new ItemStack(Material.LEATHER_HELMET)); + + private static final MobaShopCategory CHESTPLATE = new MobaShopCategory("Chestplate", Arrays.asList( + new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) + .setTitle(C.cGreen + "Leather Chestplate") + .build(), 250) + .addEffects( + new MobaCDREffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) + .setTitle(C.cGreen + "Ninja's Rainment") + .build(), 750) + .addEffects( + new MobaCDREffect(0.15) + ), + new MobaItem(new ItemBuilder(Material.CHAINMAIL_CHESTPLATE) + .setTitle(C.cYellow + "Bruiser's Chestplate") + .build(), 1250) + .addEffects( + new MobaCDREffect(0.1) + ) + ), new ItemStack(Material.LEATHER_CHESTPLATE)); + + private static final MobaShopCategory LEGGINGS = new MobaShopCategory("Leggings", Arrays.asList( + new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) + .setTitle(C.cGreen + "Leather Leggings") + .build(), 250), + new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) + .setTitle(C.cGreen + "Ninja's Rainment") + .build(), 750) + .addEffects( + new MobaTotalHealthEffect(2) + ), + new MobaItem(new ItemBuilder(Material.CHAINMAIL_LEGGINGS) + .setTitle(C.cYellow + "Bruiser's Leggings") + .build(), 1250) + .addEffects( + new MobaTotalHealthEffect(4) + ) + ), new ItemStack(Material.LEATHER_LEGGINGS)); + + private static final MobaShopCategory BOOTS = new MobaShopCategory("Boots", Arrays.asList( + new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) + .setTitle(C.cGreen + "Leather Boots") + .build(), 200) + .addEffects( + new MobaSpeedEffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) + .setTitle(C.cGreen + "Ninja's Rainment") + .build(), 500) + .addEffects( + new MobaSpeedEffect(0.15) + ), + new MobaItem(new ItemBuilder(Material.CHAINMAIL_BOOTS) + .setTitle(C.cYellow + "Bruiser's Boots") + .build(), 1000) + .addEffects( + new MobaSpeedEffect(0.1) + ) + ), new ItemStack(Material.LEATHER_BOOTS)); + public MobaAssassinShop(Moba host, MobaShop shop) { super(host, shop, MobaRole.ASSASSIN); addCategory(SWORD); + addCategory(HELMET); + addCategory(CHESTPLATE); + addCategory(LEGGINGS); + addCategory(BOOTS); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java index ea6b08db8..f3a64be2a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java @@ -1,10 +1,13 @@ package nautilus.game.arcade.game.games.moba.shop.effects; +import mineplex.core.common.util.F; +import nautilus.game.arcade.events.PlayerGameRespawnEvent; +import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent; import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; import org.bukkit.entity.Player; -public class MobaCDREffect extends MobaItemEffect +public class MobaCDREffect implements MobaItemEffect { private double _factor; @@ -19,4 +22,25 @@ public class MobaCDREffect extends MobaItemEffect { event.decreaseCooldown(_factor); } + + @Override + public void onDeath(Player killed, Player killer) + { + } + + @Override + public void onHPRegen(MobaHPRegenEvent event) + { + } + + @Override + public void onRespawn(PlayerGameRespawnEvent event) + { + } + + @Override + public String getDescription() + { + return "Decreases ability cooldowns by " + F.greenElem(String.valueOf(_factor * 100)) + "%."; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java new file mode 100644 index 000000000..dabdddf48 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java @@ -0,0 +1,46 @@ +package nautilus.game.arcade.game.games.moba.shop.effects; + +import mineplex.core.common.util.F; +import nautilus.game.arcade.events.PlayerGameRespawnEvent; +import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent; +import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; +import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; +import org.bukkit.entity.Player; + +public class MobaHPRegenEffect implements MobaItemEffect +{ + + private double _factor; + + public MobaHPRegenEffect(double factor) + { + _factor = factor; + } + + @Override + public void onCooldownCheck(CooldownCalculateEvent event) + { + } + + @Override + public void onDeath(Player killed, Player killer) + { + } + + @Override + public void onHPRegen(MobaHPRegenEvent event) + { + event.increaseHealth(_factor); + } + + @Override + public void onRespawn(PlayerGameRespawnEvent event) + { + } + + @Override + public String getDescription() + { + return "Increases HP regeneration by " + F.greenElem(String.valueOf(_factor * 100)) + "%."; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java index 4aaca0a0c..d869a752f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java @@ -1,9 +1,14 @@ package nautilus.game.arcade.game.games.moba.shop.effects; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import nautilus.game.arcade.events.PlayerGameRespawnEvent; +import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent; +import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; import org.bukkit.entity.Player; -public class MobaKillHealEffect extends MobaItemEffect +public class MobaKillHealEffect implements MobaItemEffect { private double _health; @@ -13,9 +18,30 @@ public class MobaKillHealEffect extends MobaItemEffect _health = health; } + @Override + public void onCooldownCheck(CooldownCalculateEvent event) + { + } + @Override public void onDeath(Player killed, Player killer) { killer.setHealth(Math.min(killer.getMaxHealth(), killer.getHealth() + _health)); } + + @Override + public void onHPRegen(MobaHPRegenEvent event) + { + } + + @Override + public void onRespawn(PlayerGameRespawnEvent event) + { + } + + @Override + public String getDescription() + { + return "Killing a player heals you for " + F.greenElem(String.valueOf(_health / 2)) + C.cRed + "❤" + C.cGray + "."; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java new file mode 100644 index 000000000..41cf6e3e8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java @@ -0,0 +1,48 @@ +package nautilus.game.arcade.game.games.moba.shop.effects; + +import mineplex.core.common.util.F; +import nautilus.game.arcade.events.PlayerGameRespawnEvent; +import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent; +import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; +import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; +import org.bukkit.entity.Player; + +public class MobaSpeedEffect implements MobaItemEffect +{ + + private double _factor; + + public MobaSpeedEffect(double factor) + { + _factor = factor; + } + + @Override + public void onCooldownCheck(CooldownCalculateEvent event) + { + } + + @Override + public void onDeath(Player killed, Player killer) + { + } + + @Override + public void onHPRegen(MobaHPRegenEvent event) + { + } + + @Override + public void onRespawn(PlayerGameRespawnEvent event) + { + Player player = event.GetPlayer(); + + player.setWalkSpeed((float) (player.getWalkSpeed() + (player.getWalkSpeed() * _factor))); + } + + @Override + public String getDescription() + { + return "Increases your movement speed by " + F.greenElem(String.valueOf(_factor * 100)) + "%."; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java new file mode 100644 index 000000000..2fe9565b4 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java @@ -0,0 +1,50 @@ +package nautilus.game.arcade.game.games.moba.shop.effects; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import nautilus.game.arcade.events.PlayerGameRespawnEvent; +import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent; +import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; +import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; +import org.bukkit.entity.Player; + +public class MobaTotalHealthEffect implements MobaItemEffect +{ + + private int _health; + + public MobaTotalHealthEffect(int health) + { + _health = health; + } + + @Override + public void onCooldownCheck(CooldownCalculateEvent event) + { + } + + @Override + public void onDeath(Player killed, Player killer) + { + } + + @Override + public void onHPRegen(MobaHPRegenEvent event) + { + } + + @Override + public void onRespawn(PlayerGameRespawnEvent event) + { + Player player = event.GetPlayer(); + + player.setMaxHealth(player.getMaxHealth() + _health); + player.setHealth(player.getMaxHealth()); + } + + @Override + public String getDescription() + { + return "Increases your total hearts by " + F.greenElem(String.valueOf(_health / 2)) + C.cRed + "❤" + C.cGray + "."; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java index a14c40e36..b167a378d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java @@ -162,11 +162,21 @@ public class CustomScoreboardModule extends Module if (prefix != null) { - team.setPrefix(prefix + C.Reset + " "); + String prefixF = prefix + C.Reset + " "; + + if (!team.getPrefix().equals(prefixF)) + { + team.setPrefix(prefixF); + } } else if (suffix != null) { - team.setSuffix(suffix + C.Reset + " "); + String suffixF = suffix + C.Reset + " "; + + if (!team.getPrefix().equals(suffixF)) + { + team.setSuffix(suffixF); + } } } @@ -188,7 +198,7 @@ public class CustomScoreboardModule extends Module { for (Player player : Bukkit.getOnlinePlayers()) { - _prefixFunction.apply(getOwner(), player); + setTag(getOwner(), _prefixFunction.apply(getOwner(), player), null); } } } From 321acce3c39021c3c51dc06d0b0459a47fe28629 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 13 May 2017 15:34:13 +0100 Subject: [PATCH 11/57] Make Bob Ross an invisible kit --- .../nautilus/game/arcade/game/games/moba/Moba.java | 2 +- .../game/arcade/game/games/moba/kit/HeroKit.java | 12 ++++++++++++ .../game/arcade/game/games/moba/kit/bob/HeroBob.java | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index aaf8d4cb6..9c1bc4e7e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -603,7 +603,7 @@ public class Moba extends TeamGame for (HeroKit kit : _kits) { - if (kit.getRole() == role) + if (kit.getRole() == role && kit.isVisible()) { kits.add(kit); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index 276e92374..7b93f23b8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -39,6 +39,8 @@ public class HeroKit extends Kit .addLore("Clicking this item will teleport you back to your", "base after " + F.time("5") + " seconds.", "Taking damage or moving will cancel", "your teleport.") .build(); + private boolean _visible = true; + public HeroKit(ArcadeManager manager, String name, String[] kitDesc, Perk[] kitPerks, ItemStack itemInHand, MobaRole role) { super(manager, name, KitAvailability.Free, kitDesc, kitPerks, null, itemInHand); @@ -190,4 +192,14 @@ public class HeroKit extends Kit } } } + + public boolean isVisible() + { + return _visible; + } + + public void setVisible(boolean visible) + { + _visible = visible; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java index 82ad6b064..bffc5c1d3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java @@ -35,6 +35,7 @@ public class HeroBob extends HeroKit setAmmo(AMMO, 500); setMaxAmmo(8); + setVisible(false); } } From 85a384bad735e18734e4784e92519003adf97b90 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 13 May 2017 15:34:39 +0100 Subject: [PATCH 12/57] Unneeded if statement --- .../game/games/moba/kit/common/DashSkill.java | 30 +++++++------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java index b9e51c378..e3ff6f068 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java @@ -186,29 +186,21 @@ public class DashSkill extends HeroSkill continue; } - // If allowing collisions with players - if (entity instanceof Player) + // If not allowing collisions with players + if (!_collidePlayers) { - if (!_collidePlayers) - { - continue; - } - - boolean sameTeam = isTeamDamage(entity, player); - - // If their teams are the same and we don't allow collisions with teammates, ignore - if (sameTeam && !_collideTeammates) - { - continue; - } - - collideEntity(entity, player, scale, sameTeam); + continue; } - // Any other entities and if we allow collisions with them - else if (_collideEntities) + + boolean sameTeam = isTeamDamage(entity, player); + + // If their teams are the same and we don't allow collisions with teammates, ignore + if (sameTeam && !_collideTeammates) { - collideEntity(entity, player, scale, false); + continue; } + + collideEntity(entity, player, scale, sameTeam); } } From bc5a9a1d5e9f287b785818643e26f4bfdbe878be Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 13 May 2017 15:34:49 +0100 Subject: [PATCH 13/57] Healing particle standard --- .../game/games/moba/kit/bob/SkillHappyTrees.java | 5 +++-- .../game/games/moba/kit/dana/SkillRally.java | 3 ++- .../game/games/moba/util/MobaParticles.java | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaParticles.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java index 3b429be01..4f18d3ae3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java @@ -7,6 +7,7 @@ import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.util.MobaParticles; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -55,7 +56,7 @@ public class SkillHappyTrees extends HeroSkill @EventHandler public void update(UpdateEvent event) { - if (event.getType() != UpdateType.FASTEST) + if (event.getType() != UpdateType.FASTER) { return; } @@ -152,7 +153,7 @@ public class SkillHappyTrees extends HeroSkill } entity.setHealth(Math.min(entity.getHealth() + 2, entity.getMaxHealth())); - UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, entity.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 4, ViewDist.LONG); + MobaParticles.healing(entity, 3); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java index c0ac9b8a2..df4d3f0a1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java @@ -8,6 +8,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.util.MobaParticles; import org.bukkit.*; import org.bukkit.block.Banner; import org.bukkit.block.Block; @@ -101,7 +102,7 @@ public class SkillRally extends HeroSkill continue; } - UtilParticle.PlayParticleToAll(ParticleType.HEART, nearby.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.01F, 1, ViewDist.LONG); + MobaParticles.healing(nearby, 3); Manager.GetCondition().Factory().Regen(GetName(), nearby, data.Owner, 3, 1, false, true, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaParticles.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaParticles.java new file mode 100644 index 000000000..ce6024784 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaParticles.java @@ -0,0 +1,16 @@ +package nautilus.game.arcade.game.games.moba.util; + +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import org.bukkit.entity.LivingEntity; + +public class MobaParticles +{ + + public static void healing(LivingEntity entity, int amount) + { + UtilParticle.PlayParticleToAll(ParticleType.HEART, entity.getEyeLocation(), 0.5F, 0.5F, 0.5F, 0.1F, amount, ViewDist.LONG); + } + +} From 5edbddb3d22fc4c9e7b4651db31b605215f04686 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 13 May 2017 17:30:59 +0100 Subject: [PATCH 14/57] Make MobaItemEffect abstract --- .../game/games/moba/shop/MobaItemEffect.java | 20 +++++++++++++------ .../moba/shop/effects/MobaCDREffect.java | 20 +------------------ .../moba/shop/effects/MobaHPRegenEffect.java | 20 +------------------ .../moba/shop/effects/MobaKillHealEffect.java | 17 +--------------- .../moba/shop/effects/MobaSpeedEffect.java | 17 +--------------- .../shop/effects/MobaTotalHealthEffect.java | 19 +----------------- 6 files changed, 19 insertions(+), 94 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java index d04f2d149..6c55b15b9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java @@ -5,17 +5,25 @@ import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent; import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; import org.bukkit.entity.Player; -public interface MobaItemEffect +public abstract class MobaItemEffect { - void onCooldownCheck(CooldownCalculateEvent event); + protected void onCooldownCheck(CooldownCalculateEvent event) + { + } - void onDeath(Player killed, Player killer); + protected void onDeath(Player killed, Player killer) + { + } - void onHPRegen(MobaHPRegenEvent event); + protected void onHPRegen(MobaHPRegenEvent event) + { + } - void onRespawn(PlayerGameRespawnEvent event); + protected void onRespawn(PlayerGameRespawnEvent event) + { + } - String getDescription(); + public abstract String getDescription(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java index f3a64be2a..8b139c25c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java @@ -1,13 +1,10 @@ package nautilus.game.arcade.game.games.moba.shop.effects; import mineplex.core.common.util.F; -import nautilus.game.arcade.events.PlayerGameRespawnEvent; -import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent; import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; -import org.bukkit.entity.Player; -public class MobaCDREffect implements MobaItemEffect +public class MobaCDREffect extends MobaItemEffect { private double _factor; @@ -23,21 +20,6 @@ public class MobaCDREffect implements MobaItemEffect event.decreaseCooldown(_factor); } - @Override - public void onDeath(Player killed, Player killer) - { - } - - @Override - public void onHPRegen(MobaHPRegenEvent event) - { - } - - @Override - public void onRespawn(PlayerGameRespawnEvent event) - { - } - @Override public String getDescription() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java index dabdddf48..8e0b2491f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java @@ -1,13 +1,10 @@ package nautilus.game.arcade.game.games.moba.shop.effects; import mineplex.core.common.util.F; -import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent; -import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; -import org.bukkit.entity.Player; -public class MobaHPRegenEffect implements MobaItemEffect +public class MobaHPRegenEffect extends MobaItemEffect { private double _factor; @@ -17,27 +14,12 @@ public class MobaHPRegenEffect implements MobaItemEffect _factor = factor; } - @Override - public void onCooldownCheck(CooldownCalculateEvent event) - { - } - - @Override - public void onDeath(Player killed, Player killer) - { - } - @Override public void onHPRegen(MobaHPRegenEvent event) { event.increaseHealth(_factor); } - @Override - public void onRespawn(PlayerGameRespawnEvent event) - { - } - @Override public String getDescription() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java index d869a752f..da364fee6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java @@ -8,7 +8,7 @@ import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; import org.bukkit.entity.Player; -public class MobaKillHealEffect implements MobaItemEffect +public class MobaKillHealEffect extends MobaItemEffect { private double _health; @@ -18,27 +18,12 @@ public class MobaKillHealEffect implements MobaItemEffect _health = health; } - @Override - public void onCooldownCheck(CooldownCalculateEvent event) - { - } - @Override public void onDeath(Player killed, Player killer) { killer.setHealth(Math.min(killer.getMaxHealth(), killer.getHealth() + _health)); } - @Override - public void onHPRegen(MobaHPRegenEvent event) - { - } - - @Override - public void onRespawn(PlayerGameRespawnEvent event) - { - } - @Override public String getDescription() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java index 41cf6e3e8..41aee38b9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java @@ -7,7 +7,7 @@ import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; import org.bukkit.entity.Player; -public class MobaSpeedEffect implements MobaItemEffect +public class MobaSpeedEffect extends MobaItemEffect { private double _factor; @@ -17,21 +17,6 @@ public class MobaSpeedEffect implements MobaItemEffect _factor = factor; } - @Override - public void onCooldownCheck(CooldownCalculateEvent event) - { - } - - @Override - public void onDeath(Player killed, Player killer) - { - } - - @Override - public void onHPRegen(MobaHPRegenEvent event) - { - } - @Override public void onRespawn(PlayerGameRespawnEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java index 2fe9565b4..2cce7bb6d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java @@ -3,12 +3,10 @@ package nautilus.game.arcade.game.games.moba.shop.effects; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import nautilus.game.arcade.events.PlayerGameRespawnEvent; -import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent; -import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; import org.bukkit.entity.Player; -public class MobaTotalHealthEffect implements MobaItemEffect +public class MobaTotalHealthEffect extends MobaItemEffect { private int _health; @@ -18,21 +16,6 @@ public class MobaTotalHealthEffect implements MobaItemEffect _health = health; } - @Override - public void onCooldownCheck(CooldownCalculateEvent event) - { - } - - @Override - public void onDeath(Player killed, Player killer) - { - } - - @Override - public void onHPRegen(MobaHPRegenEvent event) - { - } - @Override public void onRespawn(PlayerGameRespawnEvent event) { From c3b5b9a8bdca2983d434d02b62b4f18592c96406 Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 14 May 2017 11:41:09 +0100 Subject: [PATCH 15/57] Implement shops for all roles --- .../game/arcade/game/games/moba/Moba.java | 123 +++++++---- .../games/moba/fountain/MobaFountain.java | 2 +- .../game/games/moba/kit/AmmoGiveEvent.java | 54 +++++ .../moba/kit/CooldownCalculateEvent.java | 9 +- .../arcade/game/games/moba/kit/HeroKit.java | 45 ++-- .../arcade/game/games/moba/kit/HeroSkill.java | 9 +- .../game/games/moba/kit/anath/HeroAnath.java | 2 +- .../games/moba/kit/anath/SkillBurnBeam.java | 3 +- .../moba/kit/anath/SkillFireProjectile.java | 3 +- .../games/moba/kit/anath/SkillMeteor.java | 3 +- .../game/games/moba/kit/bob/HeroBob.java | 4 +- .../games/moba/kit/bob/SkillHappyTrees.java | 2 +- .../game/games/moba/kit/dana/SkillRally.java | 5 +- .../game/games/moba/kit/devon/HeroDevon.java | 1 + .../games/moba/kit/devon/SkillInfinity.java | 11 +- .../games/moba/kit/hattori/SkillSnowball.java | 2 +- .../arcade/game/games/moba/recall/Recall.java | 4 +- .../arcade/game/games/moba/shop/MobaItem.java | 2 +- .../game/games/moba/shop/MobaItemEffect.java | 34 +++ .../arcade/game/games/moba/shop/MobaShop.java | 97 +++++++- .../games/moba/shop/MobaShopCategoryMenu.java | 9 +- .../shop/effects/MobaAbilityDamageEffect.java | 37 ++++ .../shop/effects/MobaAmmoIncreaseEffect.java | 28 +++ .../effects/MobaBasicAttackDamageEffect.java | 36 +++ .../moba/shop/effects/MobaCDRAmmoEffect.java | 34 +++ .../moba/shop/effects/MobaCDREffect.java | 8 +- .../effects/MobaConditionImmunityEffect.java | 32 +++ .../moba/shop/effects/MobaHPRegenEffect.java | 2 +- .../shop/effects/MobaHitArrowAmmoEffect.java | 36 +++ .../shop/effects/MobaHitArrowHealEffect.java | 37 ++++ .../shop/effects/MobaHitConditionEffect.java | 56 +++++ .../moba/shop/effects/MobaKillHealEffect.java | 2 +- .../moba/shop/effects/MobaSpeedEffect.java | 2 +- .../shop/effects/MobaTotalHealthEffect.java | 2 +- .../moba/shop/hunter/MobaHunterShop.java | 207 ++++++++++++++++++ .../games/moba/shop/mage/MobaMageShop.java | 152 +++++++++++++ .../moba/shop/warrior/MobaWarriorShop.java | 201 +++++++++++++++++ .../game/games/moba/util/MobaConstants.java | 10 + .../game/games/moba/util/MobaParticles.java | 2 +- 39 files changed, 1209 insertions(+), 99 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/AmmoGiveEvent.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAbilityDamageEffect.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAmmoIncreaseEffect.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaBasicAttackDamageEffect.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDRAmmoEffect.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaConditionImmunityEffect.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitArrowAmmoEffect.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitArrowHealEffect.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitConditionEffect.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/mage/MobaMageShop.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/warrior/MobaWarriorShop.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 9c1bc4e7e..7ffeea140 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -33,6 +33,7 @@ import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.scoreboard.GameScoreboard; import org.bukkit.Location; import org.bukkit.entity.Arrow; import org.bukkit.entity.Player; @@ -118,14 +119,21 @@ public class Moba extends TeamGame new CustomScoreboardModule() .setSidebar((player, scoreboard) -> { - scoreboard.writeNewLine(); + GameState state = GetState(); - scoreboard.write("Testing"); - - int gold = _goldManager.getGold(player); - scoreboard.write("Gold " + gold); - - scoreboard.writeNewLine(); + switch (state) + { + case Prepare: + writePrepare(player, scoreboard); + break; + case Live: + writeLive(player, scoreboard); + break; + case End: + case WinRoom: + writeEnd(player, scoreboard); + break; + } }) .setPrefix((perspective, subject) -> { @@ -138,6 +146,34 @@ public class Moba extends TeamGame return team.GetColor().toString(); }) + .setSuffix((perspective, subject) -> + { + if (!IsAlive(subject)) + { + return ""; + } + + GameState state = GetState(); + GameTeam perspectiveTeam = GetTeam(perspective); + GameTeam subjectTeam = GetTeam(subject); + MobaPlayer mobaPlayer = getData(subject); + String suffix; + + if (state == GameState.Prepare && !perspectiveTeam.equals(subjectTeam)) + { + suffix = "Unknown"; + } + else if (mobaPlayer.Kit == null) + { + suffix = "Selecting"; + } + else + { + suffix = mobaPlayer.Kit.GetName(); + } + + return C.cYellow + " " + suffix + C.Reset; + }) .register(this); registerDebugCommand(new DebugCommand("kit", Rank.ADMIN) @@ -233,68 +269,65 @@ public class Moba extends TeamGame _listeners.forEach(UtilServer::RegisterEvents); } - @Override - @EventHandler - public void ScoreboardUpdate(UpdateEvent event) + private void writePrepare(Player player, GameScoreboard scoreboard) { - if (event.getType() != UpdateType.FAST) - { - return; - } + MobaPlayer mobaPlayer = getData(player); - GameState state = GetState(); + scoreboard.writeNewLine(); - switch (state) - { - case Prepare: - writePrepare(); - break; - case Live: - writeLive(); - break; - case End: - writeEnd(); - break; - default: - return; - } + scoreboard.write(C.cYellowB + "Hero Selection"); + scoreboard.write(UtilTime.MakeStr(GetStateTime() + PREPARE_TIME - System.currentTimeMillis())); - Scoreboard.draw(); - } + scoreboard.writeNewLine(); - private void writePrepare() - { - Scoreboard.writeNewLine(); + scoreboard.write(C.cYellowB + "Hero"); + scoreboard.write(mobaPlayer.Kit == null ? "Unselected " : mobaPlayer.Kit.GetName() + " (" + mobaPlayer.Role.getName() + ")"); - Scoreboard.write(C.cYellowB + "Hero Selection"); - Scoreboard.write(UtilTime.MakeStr(GetStateTime() + PREPARE_TIME - System.currentTimeMillis())); + scoreboard.writeNewLine(); - Scoreboard.writeNewLine(); - - Scoreboard.write(C.cYellowB + "Players"); + scoreboard.write(C.cYellowB + "Players"); int kits = 0; - for (MobaPlayer player : _playerData) + for (MobaPlayer otherMobaPlayer : _playerData) { - if (player.Kit != null) + if (otherMobaPlayer.Kit != null) { kits++; } } - Scoreboard.write(kits + "/" + GetPlayers(true).size()); + scoreboard.write(kits + "/" + GetPlayers(true).size()); - Scoreboard.writeNewLine(); + scoreboard.writeNewLine(); } - private void writeLive() + private void writeLive(Player player, GameScoreboard scoreboard) { + scoreboard.writeNewLine(); + if (IsAlive(player)) + { + int gold = _goldManager.getGold(player); + + scoreboard.write(C.cGoldB + "Gold"); + scoreboard.write(String.valueOf(gold)); + } + else + { + scoreboard.write("You are dead lol"); + } + + + scoreboard.writeNewLine(); } - private void writeEnd() + private void writeEnd(Player player, GameScoreboard scoreboard) { + scoreboard.writeNewLine(); + scoreboard.write("Game Over"); + + scoreboard.writeNewLine(); } @EventHandler(priority = EventPriority.LOWEST) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java index c77112f5c..f5c1027b9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java @@ -22,7 +22,7 @@ import java.util.Map.Entry; public class MobaFountain implements Listener { - private static final int FOUNTAIN_SIZE_SQUARED = 5; + private static final int FOUNTAIN_SIZE_SQUARED = 25; private final Moba _host; private final Map _average; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/AmmoGiveEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/AmmoGiveEvent.java new file mode 100644 index 000000000..9bb26419a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/AmmoGiveEvent.java @@ -0,0 +1,54 @@ +package nautilus.game.arcade.game.games.moba.kit; + +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerEvent; + +public class AmmoGiveEvent extends PlayerEvent +{ + + private static final HandlerList _handlers = new HandlerList(); + + private int _ammoToGive; + private int _maxAmmo; + + public AmmoGiveEvent(Player who, int ammoToGive, int maxAmmo) + { + super(who); + + _ammoToGive = ammoToGive; + _maxAmmo = maxAmmo; + } + + public void setAmmoToGive(int ammo) + { + _ammoToGive = ammo; + } + + public int getAmmoToGive() + { + return _ammoToGive; + } + + public void setMaxAmmo(int ammo) + { + _maxAmmo = ammo; + } + + public int getMaxAmmo() + { + return _maxAmmo; + } + + public static HandlerList getHandlerList() + { + return _handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/CooldownCalculateEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/CooldownCalculateEvent.java index caeab4cfa..e2df2cc62 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/CooldownCalculateEvent.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/CooldownCalculateEvent.java @@ -10,16 +10,23 @@ public class CooldownCalculateEvent extends PlayerEvent private static final HandlerList _handlers = new HandlerList(); private final long _initialCooldown; + private final String _ability; private long _cooldown; - public CooldownCalculateEvent(Player who, long cooldown) + public CooldownCalculateEvent(Player who, String ability, long cooldown) { super(who); _initialCooldown = cooldown; + _ability = ability; _cooldown = cooldown; } + public String getAbility() + { + return _ability; + } + public void setCooldown(long cooldown) { _cooldown = cooldown; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index 7b93f23b8..04ebb87b0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -1,9 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilItem; -import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.*; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -12,6 +9,7 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.shop.MobaItem; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; @@ -112,32 +110,47 @@ public class HeroKit extends Kit continue; } - ItemStack itemStack = player.getInventory().getItem(AMMO_SLOT); long giveTime = _giveTime; - //TODO shop cooldown reduction - - if (!Recharge.Instance.use(player, "Ammo", giveTime, false, false)) + if (!Recharge.Instance.usable(player, MobaConstants.AMMO)) { continue; } - if (itemStack == null) - { - itemStack = _ammo; - player.getInventory().setItem(AMMO_SLOT, itemStack); - continue; - } + CooldownCalculateEvent cooldownEvent = new CooldownCalculateEvent(player, MobaConstants.AMMO, giveTime); + UtilServer.CallEvent(cooldownEvent); - if (itemStack.getAmount() >= _maxAmmo) + if (!Recharge.Instance.use(player, MobaConstants.AMMO, cooldownEvent.getCooldown(), false, false)) { continue; } - itemStack.setAmount(itemStack.getAmount() + 1); + giveAmmo(player, 1); } } + public void giveAmmo(Player player, int amount) + { + ItemStack itemStack = player.getInventory().getItem(AMMO_SLOT); + + AmmoGiveEvent event = new AmmoGiveEvent(player, amount, _maxAmmo); + UtilServer.CallEvent(event); + + if (itemStack == null) + { + itemStack = _ammo; + player.getInventory().setItem(AMMO_SLOT, itemStack); + return; + } + + if (itemStack.getAmount() >= event.getMaxAmmo()) + { + return; + } + + itemStack.setAmount(itemStack.getAmount() + event.getAmmoToGive()); + } + @Override public void GiveItems(Player player) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 9f228b05c..97c682495 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -240,7 +240,7 @@ public class HeroSkill extends Perk long cooldown = _cooldown; // Modify the cooldown with respect to the upgrade items purchased from the shop - CooldownCalculateEvent cooldownEvent = new CooldownCalculateEvent(player, cooldown); + CooldownCalculateEvent cooldownEvent = new CooldownCalculateEvent(player, GetName(), cooldown); UtilServer.CallEvent(cooldownEvent); cooldown = cooldownEvent.getCooldown(); @@ -255,7 +255,10 @@ public class HeroSkill extends Perk else { long timeDiff = current - start; - double amount = (int) (cooldown / 1000) - Math.ceil((double) timeDiff / 1000); + // Work out the itemstack amount based on the cooldowns. + // Adding 1 as due to the nature of cooldowns it seems to take much longer to go + // from 2 -> 1 -> 0 as the itemstack doesn't change + double amount = (cooldown / 1000) - Math.ceil((double) timeDiff / 1000) + 1; if (itemStack == null) { @@ -316,7 +319,7 @@ public class HeroSkill extends Perk protected boolean isTeamDamage(LivingEntity damagee, LivingEntity damager) { - if (!(damagee instanceof Player || damager instanceof Player)) + if (!(damagee instanceof Player) || !(damager instanceof Player)) { return false; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java index d4ef4a78f..b7f805b65 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java @@ -31,7 +31,7 @@ public class HeroAnath extends HeroKit public HeroAnath(ArcadeManager manager) { - super(manager, "Anath the Unsworn", DESCRIPTION, PERKS, IN_HAND, MobaRole.MAGE); + super(manager, "Anath", DESCRIPTION, PERKS, IN_HAND, MobaRole.MAGE); setAmmo(AMMO, 1000); setMaxAmmo(4); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java index e4289850a..752d81e78 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java @@ -7,6 +7,7 @@ import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.particles.effects.LineParticle; +import mineplex.core.recharge.Recharge; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Material; import org.bukkit.Sound; @@ -81,7 +82,7 @@ public class SkillBurnBeam extends HeroSkill for (LivingEntity entity : UtilEnt.getInRadius(particle.getLastLocation(), 2).keySet()) { - if (entity.equals(player)) + if (entity.equals(player) || !Recharge.Instance.use(player, GetName() + entity.getName() + player.getName(), 2000, false, false)) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java index 895064ae7..0ac1d5c5e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.moba.kit.anath; import mineplex.core.common.util.UtilEvent.ActionType; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.Material; import org.bukkit.entity.Item; import org.bukkit.entity.Player; @@ -44,6 +45,6 @@ public class SkillFireProjectile extends HeroSkill Item item = player.getWorld().dropItem(player.getEyeLocation().add(direction), _kit.getAmmo()); item.setVelocity(direction); - Manager.GetFire().Add(item, player, 3, 0, 1, 5, GetName(), false); + Manager.GetFire().Add(item, player, 3, 0, 1, 5, MobaConstants.BASIC_ATTACK, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java index 3fa7a24b7..89fee9780 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java @@ -62,7 +62,7 @@ public class SkillMeteor extends HeroSkill implements IThrown FallingBlock block = player.getWorld().spawnFallingBlock(player.getEyeLocation().add(player.getLocation().getDirection()), Material.NETHERRACK, (byte) 0); block.setVelocity(player.getLocation().getDirection()); - Manager.GetProjectile().AddThrow(block, player, this, 2000, true, true, true, false, 0.5F); + Manager.GetProjectile().AddThrow(block, player, this, 1000, true, true, true, false, 0.5F); useActiveSkill(player, 7000); } @@ -153,6 +153,7 @@ public class SkillMeteor extends HeroSkill implements IThrown } startShower(data); + data.getThrown().remove(); } private void startShower(ProjectileUser data) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java index bffc5c1d3..89b56fa7f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java @@ -26,12 +26,12 @@ public class HeroBob extends HeroKit private static final ItemStack IN_HAND = new ItemStack(Material.PAINTING); private static final ItemStack AMMO = new ItemBuilder(Material.SNOW_BALL) - .setTitle(C.cYellowB + "Paint") + .setTitle(C.cYellowB + "Titanium Hwhite") .build(); public HeroBob(ArcadeManager manager) { - super(manager, "Robert Ross", DESCRIPTION, PERKS, IN_HAND, MobaRole.MAGE); + super(manager, "Bob Ross", DESCRIPTION, PERKS, IN_HAND, MobaRole.MAGE); setAmmo(AMMO, 500); setMaxAmmo(8); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java index 4f18d3ae3..801f63ba4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java @@ -153,7 +153,7 @@ public class SkillHappyTrees extends HeroSkill } entity.setHealth(Math.min(entity.getHealth() + 2, entity.getMaxHealth())); - MobaParticles.healing(entity, 3); + MobaParticles.healing(entity, 1); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java index df4d3f0a1..ef24c59c9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java @@ -102,7 +102,10 @@ public class SkillRally extends HeroSkill continue; } - MobaParticles.healing(nearby, 3); + if (Math.random() > 0.75) + { + MobaParticles.healing(nearby, 1); + } Manager.GetCondition().Factory().Regen(GetName(), nearby, data.Owner, 3, 1, false, true, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java index b7bd131c5..f40f3db4e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java @@ -28,6 +28,7 @@ public class HeroDevon extends HeroKit private static final ItemStack AMMO = new ItemBuilder(Material.ARROW) .setTitle(C.cYellowB + "Hunting Arrow") + .setUnbreakable(true) .build(); public HeroDevon(ArcadeManager manager) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java index 279dd195f..395955bad 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java @@ -14,6 +14,7 @@ import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Arrow; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -118,7 +119,7 @@ public class SkillInfinity extends HeroSkill } } - UtilAction.velocity(nearby, UtilAlg.getTrajectory(entity.getLocation(), nearby.getLocation().add(0, 1.5, 0))); + UtilAction.velocity(entity, UtilAlg.getTrajectory(entity.getLocation(), nearby.getLocation().add(0, 1.5, 0))); } } } @@ -126,11 +127,6 @@ public class SkillInfinity extends HeroSkill @EventHandler public void arrowDamage(CustomDamageEvent event) { - if (event.GetProjectile() == null) - { - return; - } - if (_arrows.containsKey(event.GetProjectile())) { Bukkit.broadcastMessage("Wither"); @@ -141,7 +137,8 @@ public class SkillInfinity extends HeroSkill @EventHandler public void projectileHit(ProjectileHitEvent event) { - _arrows.remove(event.getEntity()); + // Delay this as the when the CustomDamageEvent is run. The arrow is already removed from the map. + Manager.runSyncLater(() -> _arrows.remove(event.getEntity()), 1); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java index 9eef19c67..eeb1c0f57 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java @@ -75,7 +75,7 @@ public class SkillSnowball extends HeroSkill implements IThrown if (target != null && !isTeamDamage(target, thrower)) { thrower.playSound(thrower.getLocation(), Sound.LAVA_POP, 1, 1.3F); - Manager.GetDamage().NewDamageEvent(target, thrower, (Projectile) data.getThrown(), DamageCause.PROJECTILE, 3, true, true, false, UtilEnt.getName(thrower), GetName()); + Manager.GetDamage().NewDamageEvent(target, thrower, (Projectile) data.getThrown(), DamageCause.CUSTOM, 3, true, true, false, UtilEnt.getName(thrower), GetName()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java index ebf2a3a83..2725ecf1f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/recall/Recall.java @@ -96,7 +96,7 @@ public class Recall implements Listener } else { - Location location = player.getLocation().add(0, 0.25, 0); + Location location = session.Location.clone(); double height = (double) (now - session.Start) / (double) RECALL_TIME; for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 10) @@ -104,7 +104,7 @@ public class Recall implements Listener double x = PARTICLE_RADIUS * Math.sin(theta); double z = PARTICLE_RADIUS * Math.cos(theta); - for (double y = 0; y < height * PARTICLE_HEIGHT; y += 0.5) + for (double y = 0.25; y < height * PARTICLE_HEIGHT; y += 0.5) { location.add(x, y, z); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java index dd5f49e9f..576bc305c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java @@ -34,7 +34,7 @@ public class MobaItem public ItemStack getItem() { - ItemBuilder builder = new ItemBuilder(_item); + ItemBuilder builder = new ItemBuilder(_item).setUnbreakable(true); if (getEffects() != null) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java index 6c55b15b9..6adeb01db 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java @@ -1,17 +1,47 @@ package nautilus.game.arcade.game.games.moba.shop; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent; +import nautilus.game.arcade.game.games.moba.kit.AmmoGiveEvent; import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; import org.bukkit.entity.Player; +import java.text.DecimalFormat; + public abstract class MobaItemEffect { + private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("0.#"); + + protected static String format(double d) + { + return DECIMAL_FORMAT.format(d); + } + + protected static String format(ConditionType conditionType, int multi) + { + String condition = conditionType.toString().toLowerCase(); + char first = Character.toUpperCase(condition.charAt(0)); + condition = first + condition.substring(1); + + return condition + (multi == -1 ? "" : " " + (multi + 1)); + } + + protected void onAmmoGive(AmmoGiveEvent event) + { + } + protected void onCooldownCheck(CooldownCalculateEvent event) { } + protected void onDamage(CustomDamageEvent event) + { + } + protected void onDeath(Player killed, Player killer) { } @@ -24,6 +54,10 @@ public abstract class MobaItemEffect { } + protected void onCondition(ConditionApplyEvent event) + { + } + public abstract String getDescription(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index c64ddcc16..1ef2b3511 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -5,6 +5,7 @@ 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.condition.events.ConditionApplyEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerGameRespawnEvent; @@ -13,9 +14,12 @@ import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent; import nautilus.game.arcade.game.games.moba.MobaPlayer; import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.AmmoGiveEvent; import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; -import nautilus.game.arcade.game.games.moba.shop.MobaShopMenu.MobaCategoryButton; import nautilus.game.arcade.game.games.moba.shop.assassin.MobaAssassinShop; +import nautilus.game.arcade.game.games.moba.shop.hunter.MobaHunterShop; +import nautilus.game.arcade.game.games.moba.shop.mage.MobaMageShop; +import nautilus.game.arcade.game.games.moba.shop.warrior.MobaWarriorShop; import org.bukkit.Location; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; import org.bukkit.entity.Entity; @@ -24,13 +28,14 @@ import org.bukkit.entity.Player; import org.bukkit.entity.Villager; import org.bukkit.entity.Villager.Profession; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; public class MobaShop implements Listener @@ -50,6 +55,9 @@ public class MobaShop implements Listener // Create menus _roleMenus.put(MobaRole.ASSASSIN, new MobaAssassinShop(host, this)); + _roleMenus.put(MobaRole.WARRIOR, new MobaWarriorShop(host, this)); + _roleMenus.put(MobaRole.HUNTER, new MobaHunterShop(host, this)); + _roleMenus.put(MobaRole.MAGE, new MobaMageShop(host, this)); } @EventHandler @@ -177,8 +185,9 @@ public class MobaShop implements Listener // The respawn event needs to be called here so that effects like "Total Health Increase" will work straight away, instead of after the next respawn, if (item.getEffects() != null) { - // Prevents an infinite speed + // Prevents infinite speed player.setWalkSpeed(0.2F); + player.setMaxHealth(20); PlayerGameRespawnEvent fakeEvent = new PlayerGameRespawnEvent(null, player); @@ -239,7 +248,27 @@ public class MobaShop implements Listener } @EventHandler - public void hpRegeneration(CooldownCalculateEvent event) + public void ammoGive(AmmoGiveEvent event) + { + Player player = event.getPlayer(); + List items = _upgrades.get(player); + + for (MobaItem item : items) + { + if (item.getEffects() == null) + { + continue; + } + + for (MobaItemEffect effect : item.getEffects()) + { + effect.onAmmoGive(event); + } + } + } + + @EventHandler + public void cooldownCheck(CooldownCalculateEvent event) { Player player = event.getPlayer(); List items = _upgrades.get(player); @@ -258,6 +287,34 @@ public class MobaShop implements Listener } } + @EventHandler + public void damage(CustomDamageEvent event) + { + Player damagee = event.GetDamageePlayer(); + Player damager = event.GetDamagerPlayer(true); + + if (damagee == null || damager == null) + { + return; + } + + List items = _upgrades.get(damager); + + for (MobaItem item : items) + { + if (item.getEffects() == null) + { + continue; + } + + for (MobaItemEffect effect : item.getEffects()) + { + effect.onDamage(event); + } + } + } + + @EventHandler public void combatDeath(CombatDeathEvent event) { @@ -331,4 +388,32 @@ public class MobaShop implements Listener } } } + + @EventHandler + public void conditionApply(ConditionApplyEvent event) + { + LivingEntity entity = event.GetCondition().GetEnt(); + + if (!(entity instanceof Player)) + { + return; + } + + Player player = (Player) entity; + + List items = _upgrades.get(player); + + for (MobaItem item : items) + { + if (item.getEffects() == null) + { + continue; + } + + for (MobaItemEffect effect : item.getEffects()) + { + effect.onCondition(event); + } + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java index 5a9567966..a6026d4fb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java @@ -1,6 +1,5 @@ package nautilus.game.arcade.game.games.moba.shop; -import javafx.scene.shape.Arc; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.menu.Button; @@ -28,7 +27,7 @@ public class MobaShopCategoryMenu extends Menu public MobaShopCategoryMenu(Moba host, MobaShop shop, MobaShopCategory category, ArcadeManager plugin) { - super(category.getName() + " Shop", plugin); + super(category.getName() + " Category", plugin); _host = host; _shop = shop; @@ -73,6 +72,12 @@ public class MobaShopCategoryMenu extends Menu } buttons[slot++] = new MobaPurchaseButton(builder.build(), getPlugin(), item); + + // Reached the end of the row, wrap it to keep it neat. + if (slot == 17) + { + slot = 19; + } } return buttons; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAbilityDamageEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAbilityDamageEffect.java new file mode 100644 index 000000000..6485a4082 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAbilityDamageEffect.java @@ -0,0 +1,37 @@ +package nautilus.game.arcade.game.games.moba.shop.effects; + +import mineplex.core.common.util.F; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +public class MobaAbilityDamageEffect extends MobaItemEffect +{ + + private String _reason; + private double _factor; + + public MobaAbilityDamageEffect(String reason, double factor) + { + _reason = reason; + _factor = factor; + } + + @Override + protected void onDamage(CustomDamageEvent event) + { + if (event.GetCause() != DamageCause.CUSTOM || event.GetReason().contains(MobaConstants.BASIC_ATTACK)) + { + return; + } + + event.AddMod(_reason, event.GetDamage() * _factor); + } + + @Override + public String getDescription() + { + return "Increases ability damage by " + F.greenElem(format(_factor * 100)) + "%."; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAmmoIncreaseEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAmmoIncreaseEffect.java new file mode 100644 index 000000000..c62f9d935 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAmmoIncreaseEffect.java @@ -0,0 +1,28 @@ +package nautilus.game.arcade.game.games.moba.shop.effects; + +import mineplex.core.common.util.F; +import nautilus.game.arcade.game.games.moba.kit.AmmoGiveEvent; +import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; + +public class MobaAmmoIncreaseEffect extends MobaItemEffect +{ + + private int _maxAmmoIncrease; + + public MobaAmmoIncreaseEffect(int maxAmmoIncrease) + { + _maxAmmoIncrease = maxAmmoIncrease; + } + + @Override + protected void onAmmoGive(AmmoGiveEvent event) + { + event.setMaxAmmo(event.getMaxAmmo() + _maxAmmoIncrease); + } + + @Override + public String getDescription() + { + return "Increases max ammo by " + F.greenElem(format(_maxAmmoIncrease)) + "."; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaBasicAttackDamageEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaBasicAttackDamageEffect.java new file mode 100644 index 000000000..3f19d483c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaBasicAttackDamageEffect.java @@ -0,0 +1,36 @@ +package nautilus.game.arcade.game.games.moba.shop.effects; + +import mineplex.core.common.util.F; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; + +public class MobaBasicAttackDamageEffect extends MobaItemEffect +{ + + private String _reason; + private double _factor; + + public MobaBasicAttackDamageEffect(String reason, double factor) + { + _reason = reason; + _factor = factor; + } + + @Override + protected void onDamage(CustomDamageEvent event) + { + if (!event.GetReason().contains(MobaConstants.BASIC_ATTACK)) + { + return; + } + + event.AddMod(_reason, event.GetDamage() * _factor); + } + + @Override + public String getDescription() + { + return "Increases basic attack damage by " + F.greenElem(format(_factor * 100)) + "%."; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDRAmmoEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDRAmmoEffect.java new file mode 100644 index 000000000..ab0269862 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDRAmmoEffect.java @@ -0,0 +1,34 @@ +package nautilus.game.arcade.game.games.moba.shop.effects; + +import mineplex.core.common.util.F; +import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; +import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; + +public class MobaCDRAmmoEffect extends MobaItemEffect +{ + + private double _factor; + + public MobaCDRAmmoEffect(double factor) + { + _factor = factor; + } + + @Override + public void onCooldownCheck(CooldownCalculateEvent event) + { + if (!event.getAbility().equals(MobaConstants.AMMO)) + { + return; + } + + event.decreaseCooldown(_factor); + } + + @Override + public String getDescription() + { + return "Decreases ammo reload time by " + F.greenElem(format(_factor * 100)) + "%."; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java index 8b139c25c..a141f2a3a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaCDREffect.java @@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.moba.shop.effects; import mineplex.core.common.util.F; import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; public class MobaCDREffect extends MobaItemEffect { @@ -17,12 +18,17 @@ public class MobaCDREffect extends MobaItemEffect @Override public void onCooldownCheck(CooldownCalculateEvent event) { + if (event.getAbility().equals(MobaConstants.AMMO)) + { + return; + } + event.decreaseCooldown(_factor); } @Override public String getDescription() { - return "Decreases ability cooldowns by " + F.greenElem(String.valueOf(_factor * 100)) + "%."; + return "Decreases ability cooldowns by " + F.greenElem(format(_factor * 100)) + "%."; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaConditionImmunityEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaConditionImmunityEffect.java new file mode 100644 index 000000000..d79a5e76c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaConditionImmunityEffect.java @@ -0,0 +1,32 @@ +package nautilus.game.arcade.game.games.moba.shop.effects; + +import mineplex.core.common.util.F; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent; +import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; + +public class MobaConditionImmunityEffect extends MobaItemEffect +{ + + private ConditionType _conditionType; + + public MobaConditionImmunityEffect(ConditionType conditionType) + { + _conditionType = conditionType; + } + + @Override + protected void onCondition(ConditionApplyEvent event) + { + if (event.GetCondition().GetType() == _conditionType) + { + event.setCancelled(true); + } + } + + @Override + public String getDescription() + { + return "Grants immunity to " + F.greenElem(format(_conditionType, -1)) + " effects."; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java index 8e0b2491f..b9d8fc749 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java @@ -23,6 +23,6 @@ public class MobaHPRegenEffect extends MobaItemEffect @Override public String getDescription() { - return "Increases HP regeneration by " + F.greenElem(String.valueOf(_factor * 100)) + "%."; + return "Increases HP regeneration by " + F.greenElem(format(_factor * 100)) + "%."; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitArrowAmmoEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitArrowAmmoEffect.java new file mode 100644 index 000000000..4d2393326 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitArrowAmmoEffect.java @@ -0,0 +1,36 @@ +package nautilus.game.arcade.game.games.moba.shop.effects; + +import mineplex.core.Managers; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; + +public class MobaHitArrowAmmoEffect extends MobaItemEffect +{ + + @Override + protected void onDamage(CustomDamageEvent event) + { + if (!(event.GetProjectile() instanceof Arrow)) + { + return; + } + + Player damager = event.GetDamagerPlayer(true); + + Moba host = (Moba) Managers.get(ArcadeManager.class).GetGame(); + HeroKit kit = host.getData(damager).Kit; + + kit.giveAmmo(damager, 1); + } + + @Override + public String getDescription() + { + return "Hitting a player with an arrow gives you a new arrow."; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitArrowHealEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitArrowHealEffect.java new file mode 100644 index 000000000..f5e22be7a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitArrowHealEffect.java @@ -0,0 +1,37 @@ +package nautilus.game.arcade.game.games.moba.shop.effects; + +import mineplex.core.common.util.F; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; + +public class MobaHitArrowHealEffect extends MobaItemEffect +{ + + private double _factor; + + public MobaHitArrowHealEffect(double factor) + { + _factor = factor; + } + + @Override + protected void onDamage(CustomDamageEvent event) + { + if (!(event.GetProjectile() instanceof Arrow)) + { + return; + } + + Player damager = event.GetDamagerPlayer(true); + + damager.setHealth(Math.min(damager.getMaxHealth(), damager.getHealth() + (event.GetDamage() * _factor))); + } + + @Override + public String getDescription() + { + return "Hitting a player with an arrow heals for " + F.greenElem(format(_factor * 100)) + "% of the damage."; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitConditionEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitConditionEffect.java new file mode 100644 index 000000000..296c5e073 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitConditionEffect.java @@ -0,0 +1,56 @@ +package nautilus.game.arcade.game.games.moba.shop.effects; + +import mineplex.core.Managers; +import mineplex.core.common.util.F; +import mineplex.minecraft.game.core.condition.Condition; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.condition.ConditionManager; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +public class MobaHitConditionEffect extends MobaItemEffect +{ + + private String _reason; + private ConditionType _conditionType; + private double _duration; + private int _multi; + private boolean _applyToDamagee; + + public MobaHitConditionEffect(String reason, ConditionType conditionType, double duration, int multi, boolean applyToDamagee) + { + _reason = reason; + _conditionType = conditionType; + _duration = duration; + _multi = multi; + _applyToDamagee = applyToDamagee; + } + + @Override + protected void onDamage(CustomDamageEvent event) + { + Player damagee = event.GetDamageePlayer(); + Player damager = event.GetDamagerPlayer(true); + + if (!_applyToDamagee) + { + // Swap damagee and damager + Player temp = damagee; + damagee = damager; + damager = temp; + } + + ConditionManager conditionManager = Managers.get(ArcadeManager.class).GetCondition(); + + conditionManager.AddCondition(new Condition(conditionManager, _reason, damagee, damager, _conditionType, _multi, (int) (_duration * 20), false, Material.WEB, (byte) 0, true, false)); + } + + @Override + public String getDescription() + { + return "Hitting a player applies " + F.greenElem(format(_conditionType, _multi)) + " for " + F.time(format(_duration)) + " seconds."; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java index da364fee6..3086e7b84 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java @@ -27,6 +27,6 @@ public class MobaKillHealEffect extends MobaItemEffect @Override public String getDescription() { - return "Killing a player heals you for " + F.greenElem(String.valueOf(_health / 2)) + C.cRed + "❤" + C.cGray + "."; + return "Killing a player heals for " + F.greenElem(format(_health / 2)) + C.cRed + "❤" + C.cGray + "."; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java index 41aee38b9..23f3e4bbe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java @@ -28,6 +28,6 @@ public class MobaSpeedEffect extends MobaItemEffect @Override public String getDescription() { - return "Increases your movement speed by " + F.greenElem(String.valueOf(_factor * 100)) + "%."; + return "Increases movement speed by " + F.greenElem(format(_factor * 100)) + "%."; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java index 2cce7bb6d..80af5c495 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaTotalHealthEffect.java @@ -28,6 +28,6 @@ public class MobaTotalHealthEffect extends MobaItemEffect @Override public String getDescription() { - return "Increases your total hearts by " + F.greenElem(String.valueOf(_health / 2)) + C.cRed + "❤" + C.cGray + "."; + return "Increases total hearts by " + F.greenElem(format(_health / 2)) + C.cRed + "❤" + C.cGray + "."; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java new file mode 100644 index 000000000..06b6fdaf7 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java @@ -0,0 +1,207 @@ +package nautilus.game.arcade.game.games.moba.shop.hunter; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.shop.MobaItem; +import nautilus.game.arcade.game.games.moba.shop.MobaShop; +import nautilus.game.arcade.game.games.moba.shop.MobaShopCategory; +import nautilus.game.arcade.game.games.moba.shop.MobaShopMenu; +import nautilus.game.arcade.game.games.moba.shop.effects.*; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemStack; + +import java.util.Arrays; + +public class MobaHunterShop extends MobaShopMenu +{ + + private static final MobaShopCategory BOW = new MobaShopCategory("Bow", Arrays.asList( + new MobaItem(new ItemBuilder(Material.BOW) + .setTitle(C.cGreenB + "Hunter's Bow") + .addEnchantment(Enchantment.ARROW_DAMAGE, 1) + .build(), 500), + new MobaItem(new ItemBuilder(Material.BOW) + .setTitle(C.cGreenB + "Elven Bow") + .addEnchantment(Enchantment.ARROW_DAMAGE, 2) + .build(), 750), + new MobaItem(new ItemBuilder(Material.BOW) + .setTitle(C.cGreenB + "Eagle's Bow") + .addEnchantment(Enchantment.ARROW_DAMAGE, 3) + .build(), 1000), + new MobaItem(new ItemBuilder(Material.BOW) + .setTitle(C.cYellowB + "Bow of Pursuit") + .addEnchantment(Enchantment.ARROW_DAMAGE, 2) + .build(), 1200) + .addEffects( + new MobaHitConditionEffect("Bow of Pursuit", ConditionType.SPEED, 2, 0, false) + ), + new MobaItem(new ItemBuilder(Material.BOW) + .setTitle(C.cYellowB + "Vampiric Bow") + .addEnchantment(Enchantment.ARROW_DAMAGE, 1) + .build(), 1500) + .addEffects( + new MobaHitArrowHealEffect(0.25) + ), + new MobaItem(new ItemBuilder(Material.BOW) + .setTitle(C.cYellowB + "Bow of Renewal") + .addEnchantment(Enchantment.ARROW_DAMAGE, 1) + .build(), 1750) + .addEffects( + new MobaHitArrowAmmoEffect() + ), + new MobaItem(new ItemBuilder(Material.BOW) + .setTitle(C.cYellowB + "Specialist's Bow") + .build(), 1000) + .addEffects( + new MobaCDREffect(0.1), + new MobaAbilityDamageEffect("Specialist's Bow", 0.2) + ) + ), new ItemStack(Material.BOW)); + + private static final MobaShopCategory HELMET = new MobaShopCategory("Helmet", Arrays.asList( + new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cGreen + "Leather Helmet") + .build(), 200), + new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cGreen + "Leather Cap of Holding") + .build(), 400) + .addEffects( + new MobaAmmoIncreaseEffect(1) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cGreen + "Leather Cap of Nimble Fingers") + .build(), 400) + .addEffects( + new MobaCDRAmmoEffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cGreen + "Focused Cap") + .build(), 500) + .addEffects( + new MobaCDREffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cGreen + "Vampiric Helmet") + .build(), 500) + .addEffects( + new MobaHitArrowHealEffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.CHAINMAIL_HELMET) + .setTitle(C.cGreen + "Chainmail Helmet") + .build(), 500) + ), new ItemStack(Material.LEATHER_HELMET)); + + private static final MobaShopCategory CHESTPLATE = new MobaShopCategory("Chestplate", Arrays.asList( + new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) + .setTitle(C.cGreen + "Leather Chestplate") + .build(), 250), + new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) + .setTitle(C.cGreen + "Leather Chestplate of Nimble Fingers") + .build(), 750) + .addEffects( + new MobaCDRAmmoEffect(0.15) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) + .setTitle(C.cGreen + "Focused Chestplate") + .build(), 750) + .addEffects( + new MobaCDREffect(0.1) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) + .setTitle(C.cGreen + "Vampiric Chestplate") + .build(), 750) + .addEffects( + new MobaHitArrowHealEffect(0.15) + ), + new MobaItem(new ItemBuilder(Material.CHAINMAIL_CHESTPLATE) + .setTitle(C.cGreen + "Chainmail Chestplate") + .build(), 500) + ), new ItemStack(Material.LEATHER_CHESTPLATE)); + + private static final MobaShopCategory LEGGINGS = new MobaShopCategory("Leggings", Arrays.asList( + new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) + .setTitle(C.cGreen + "Leather Leggings") + .build(), 250), + new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) + .setTitle(C.cGreen + "Leather Leggings of Nimble Fingers") + .build(), 750) + .addEffects( + new MobaCDRAmmoEffect(0.1) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) + .setTitle(C.cGreen + "Focused Leggings") + .build(), 750) + .addEffects( + new MobaCDREffect(0.1) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) + .setTitle(C.cGreen + "Vampiric Leggings") + .build(), 700) + .addEffects( + new MobaHitArrowHealEffect(0.1) + ), + new MobaItem(new ItemBuilder(Material.CHAINMAIL_LEGGINGS) + .setTitle(C.cGreen + "Chainmail Leggings") + .build(), 500) + ), new ItemStack(Material.LEATHER_LEGGINGS)); + + private static final MobaShopCategory BOOTS = new MobaShopCategory("Boots", Arrays.asList( + new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) + .setTitle(C.cGreen + "Leather Boots") + .build(), 250), + new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) + .setTitle(C.cGreen + "Leather Boots of Nimble Fingers") + .build(), 400) + .addEffects( + new MobaCDRAmmoEffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) + .setTitle(C.cGreen + "Focused Boots") + .build(), 600) + .addEffects( + new MobaCDREffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) + .setTitle(C.cGreen + "Vampiric Boots") + .build(), 500) + .addEffects( + new MobaHitArrowHealEffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) + .setTitle(C.cGreen + "Leather Hiking Boots") + .build(), 300) + .addEffects( + new MobaSpeedEffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.CHAINMAIL_BOOTS) + .setTitle(C.cGreen + "Leather Moccasins") + .build(), 500) + .addEffects( + new MobaSpeedEffect(0.1) + ), + new MobaItem(new ItemBuilder(Material.CHAINMAIL_BOOTS) + .setTitle(C.cGreen + "Leather Crosstrainers") + .build(), 800) + .addEffects( + new MobaSpeedEffect(0.15) + ), + new MobaItem(new ItemBuilder(Material.CHAINMAIL_BOOTS) + .setTitle(C.cGreen + "Chainmail Boots") + .build(), 500) + ), new ItemStack(Material.LEATHER_BOOTS)); + + public MobaHunterShop(Moba host, MobaShop shop) + { + super(host, shop, MobaRole.HUNTER); + + addCategory(BOW); + addCategory(HELMET); + addCategory(CHESTPLATE); + addCategory(LEGGINGS); + addCategory(BOOTS); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/mage/MobaMageShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/mage/MobaMageShop.java new file mode 100644 index 000000000..15103bdcd --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/mage/MobaMageShop.java @@ -0,0 +1,152 @@ +package nautilus.game.arcade.game.games.moba.shop.mage; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.shop.MobaItem; +import nautilus.game.arcade.game.games.moba.shop.MobaShop; +import nautilus.game.arcade.game.games.moba.shop.MobaShopCategory; +import nautilus.game.arcade.game.games.moba.shop.MobaShopMenu; +import nautilus.game.arcade.game.games.moba.shop.effects.MobaAbilityDamageEffect; +import nautilus.game.arcade.game.games.moba.shop.effects.MobaBasicAttackDamageEffect; +import nautilus.game.arcade.game.games.moba.shop.effects.MobaCDREffect; +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +import java.util.Arrays; + +public class MobaMageShop extends MobaShopMenu +{ + + private static final MobaShopCategory HELMET = new MobaShopCategory("Helmet", Arrays.asList( + new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cGreen + "Leather Cap") + .build(), 200), + new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cGreen + "Adept's Cap") + .setColor(Color.BLACK) + .build(), 500) + .addEffects( + new MobaAbilityDamageEffect("Adept's Cap", 0.05) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cGreen + "Helm of Focus") + .setColor(Color.PURPLE) + .build(), 500) + .addEffects( + new MobaCDREffect(0.03) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cGreen + "Battle Mage Cap") + .setColor(Color.YELLOW) + .build(), 500) + .addEffects( + new MobaBasicAttackDamageEffect("Battle Mage Cap", 0.03) + ), + new MobaItem(new ItemBuilder(Material.GOLD_HELMET) + .setTitle(C.cYellow + "Golden Helmet") + .build(), 750) + ), new ItemStack(Material.LEATHER_HELMET)); + + private static final MobaShopCategory CHESTPLATE = new MobaShopCategory("Chestplate", Arrays.asList( + new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) + .setTitle(C.cGreen + "Leather Chestplate") + .build(), 400), + new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) + .setTitle(C.cGreen + "Adept's Chestplate") + .setColor(Color.BLACK) + .build(), 1250) + .addEffects( + new MobaAbilityDamageEffect("Adept's Chestplate", 0.15) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) + .setTitle(C.cGreen + "Chestplate of Focus") + .setColor(Color.PURPLE) + .build(), 1000) + .addEffects( + new MobaCDREffect(0.1) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) + .setTitle(C.cGreen + "Battle Mage Chestplate") + .setColor(Color.YELLOW) + .build(), 1000) + .addEffects( + new MobaBasicAttackDamageEffect("Battle Mage Chestplate", 0.1) + ), + new MobaItem(new ItemBuilder(Material.GOLD_CHESTPLATE) + .setTitle(C.cYellow + "Golden Chestplate") + .build(), 1000) + ), new ItemStack(Material.LEATHER_CHESTPLATE)); + + private static final MobaShopCategory LEGGINGS = new MobaShopCategory("Leggings", Arrays.asList( + new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) + .setTitle(C.cGreen + "Leather Leggings") + .build(), 400), + new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) + .setTitle(C.cGreen + "Adept's Leggings") + .setColor(Color.BLACK) + .build(), 750) + .addEffects( + new MobaAbilityDamageEffect("Adept's Leggings", 0.1) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) + .setTitle(C.cGreen + "Leggings of Focus") + .setColor(Color.PURPLE) + .build(), 750) + .addEffects( + new MobaCDREffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) + .setTitle(C.cGreen + "Battle Mage Leggings") + .setColor(Color.YELLOW) + .build(), 750) + .addEffects( + new MobaBasicAttackDamageEffect("Battle Mage Leggings", 0.05) + ), + new MobaItem(new ItemBuilder(Material.GOLD_LEGGINGS) + .setTitle(C.cYellow + "Golden Leggings") + .build(), 1000) + ), new ItemStack(Material.LEATHER_LEGGINGS)); + + private static final MobaShopCategory BOOTS = new MobaShopCategory("Boots", Arrays.asList( + new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) + .setTitle(C.cGreen + "Leather Boots") + .build(), 200), + new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) + .setTitle(C.cGreen + "Adept's Boots") + .setColor(Color.BLACK) + .build(), 500) + .addEffects( + new MobaAbilityDamageEffect("Adept's Boots", 0.05) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) + .setTitle(C.cGreen + "Boots of Focus") + .setColor(Color.PURPLE) + .build(), 500) + .addEffects( + new MobaCDREffect(0.03) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) + .setTitle(C.cGreen + "Battle Mage Boots") + .setColor(Color.YELLOW) + .build(), 500) + .addEffects( + new MobaBasicAttackDamageEffect("Battle Mage Boots", 0.03) + ), + new MobaItem(new ItemBuilder(Material.GOLD_BOOTS) + .setTitle(C.cYellow + "Golden Boots") + .build(), 750) + ), new ItemStack(Material.LEATHER_BOOTS)); + + public MobaMageShop(Moba host, MobaShop shop) + { + super(host, shop, MobaRole.MAGE); + + addCategory(HELMET); + addCategory(CHESTPLATE); + addCategory(LEGGINGS); + addCategory(BOOTS); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/warrior/MobaWarriorShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/warrior/MobaWarriorShop.java new file mode 100644 index 000000000..03bc1f529 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/warrior/MobaWarriorShop.java @@ -0,0 +1,201 @@ +package nautilus.game.arcade.game.games.moba.shop.warrior; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.shop.MobaItem; +import nautilus.game.arcade.game.games.moba.shop.MobaShop; +import nautilus.game.arcade.game.games.moba.shop.MobaShopCategory; +import nautilus.game.arcade.game.games.moba.shop.MobaShopMenu; +import nautilus.game.arcade.game.games.moba.shop.effects.*; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemStack; + +import java.util.Arrays; + +public class MobaWarriorShop extends MobaShopMenu +{ + + private static final MobaShopCategory SWORD = new MobaShopCategory("Sword", Arrays.asList( + new MobaItem(new ItemBuilder(Material.STONE_SWORD) + .setTitle(C.cGreenB + "Stone Sword") + .build(), 500), + new MobaItem(new ItemBuilder(Material.GOLD_SWORD) + .setTitle(C.cYellowB + "Frostbound Sword") + .build(), 750) + .addEffects( + new MobaHitConditionEffect("Frostbound Sword", ConditionType.SLOW, 3, 0, true) + ), + new MobaItem(new ItemBuilder(Material.GOLD_SWORD) + .setTitle(C.cYellowB + "Swift Blade") + .build(), 750) + .addEffects( + new MobaConditionImmunityEffect(ConditionType.SLOW) + ), + new MobaItem(new ItemBuilder(Material.IRON_SWORD) + .setTitle(C.cDRedB + "Knight's Blade") + .build(), 1250) + ), new ItemStack(Material.WOOD_SWORD)); + + private static final MobaShopCategory HELMET = new MobaShopCategory("Helmet", Arrays.asList( + new MobaItem(new ItemBuilder(Material.IRON_HELMET) + .setTitle(C.cGreenB + "Archer's Bane") + .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 1) + .build(), 400) + .addEffects( + new MobaHPRegenEffect(0.03) + ), + new MobaItem(new ItemBuilder(Material.IRON_HELMET) + .setTitle(C.cYellowB + "Superior Archer's Bane") + .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) + .build(), 750) + .addEffects( + new MobaHPRegenEffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.IRON_HELMET) + .setTitle(C.cGreenB + "Brawler's Plate") + .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1) + .build(), 400) + .addEffects( + new MobaHPRegenEffect(0.03) + ), + new MobaItem(new ItemBuilder(Material.IRON_HELMET) + .setTitle(C.cYellowB + "Superior Brawler's Plate") + .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2) + .build(), 750) + .addEffects( + new MobaHPRegenEffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.DIAMOND_HELMET) + .setTitle(C.cDRedB + "Prince's Plate") + .build(), 2000) + .addEffects( + new MobaHPRegenEffect(0.15) + ) + ), new ItemStack(Material.IRON_HELMET)); + + private static final MobaShopCategory CHESTPLATE = new MobaShopCategory("Chestplate", Arrays.asList( + new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE) + .setTitle(C.cGreenB + "Archer's Bane") + .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 1) + .build(), 600) + .addEffects( + new MobaTotalHealthEffect(2) + ), + new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE) + .setTitle(C.cYellowB + "Superior Archer's Bane") + .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) + .build(), 1000) + .addEffects( + new MobaTotalHealthEffect(4) + ), + new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE) + .setTitle(C.cGreenB + "Brawler's Plate") + .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1) + .build(), 600) + .addEffects( + new MobaTotalHealthEffect(2) + ), + new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE) + .setTitle(C.cYellowB + "Superior Brawler's Plate") + .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2) + .build(), 1000) + .addEffects( + new MobaTotalHealthEffect(4) + ), + new MobaItem(new ItemBuilder(Material.DIAMOND_CHESTPLATE) + .setTitle(C.cDRedB + "Prince's Plate") + .build(), 2500) + .addEffects( + new MobaTotalHealthEffect(4) + ) + ), new ItemStack(Material.IRON_CHESTPLATE)); + + private static final MobaShopCategory LEGGINGS = new MobaShopCategory("Leggings", Arrays.asList( + new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS) + .setTitle(C.cGreenB + "Archer's Bane") + .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 1) + .build(), 600) + .addEffects( + new MobaCDREffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS) + .setTitle(C.cYellowB + "Superior Archer's Bane") + .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) + .build(), 1000) + .addEffects( + new MobaCDREffect(0.07) + ), + new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS) + .setTitle(C.cGreenB + "Brawler's Plate") + .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1) + .build(), 600) + .addEffects( + new MobaCDREffect(0.05) + ), + new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS) + .setTitle(C.cYellowB + "Superior Brawler's Plate") + .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2) + .build(), 1000) + .addEffects( + new MobaCDREffect(0.07) + ), + new MobaItem(new ItemBuilder(Material.DIAMOND_LEGGINGS) + .setTitle(C.cDRedB + "Prince's Plate") + .build(), 2500) + .addEffects( + new MobaCDREffect(0.1) + ) + ), new ItemStack(Material.IRON_LEGGINGS)); + + private static final MobaShopCategory BOOTS = new MobaShopCategory("Boots", Arrays.asList( + new MobaItem(new ItemBuilder(Material.IRON_BOOTS) + .setTitle(C.cGreenB + "Archer's Bane") + .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 1) + .build(), 400) + .addEffects( + new MobaSpeedEffect(0.04) + ), + new MobaItem(new ItemBuilder(Material.IRON_BOOTS) + .setTitle(C.cYellowB + "Superior Archer's Bane") + .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) + .build(), 750) + .addEffects( + new MobaSpeedEffect(0.06) + ), + new MobaItem(new ItemBuilder(Material.IRON_BOOTS) + .setTitle(C.cGreenB + "Brawler's Plate") + .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1) + .build(), 400) + .addEffects( + new MobaSpeedEffect(0.04) + ), + new MobaItem(new ItemBuilder(Material.IRON_BOOTS) + .setTitle(C.cYellowB + "Superior Brawler's Plate") + .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2) + .build(), 750) + .addEffects( + new MobaSpeedEffect(0.06) + ), + new MobaItem(new ItemBuilder(Material.DIAMOND_BOOTS) + .setTitle(C.cDRedB + "Prince's Plate") + .build(), 2000) + .addEffects( + new MobaSpeedEffect(0.1) + ) + ), new ItemStack(Material.IRON_BOOTS)); + + public MobaWarriorShop(Moba host, MobaShop shop) + { + super(host, shop, MobaRole.WARRIOR); + + addCategory(SWORD); + addCategory(HELMET); + addCategory(CHESTPLATE); + addCategory(LEGGINGS); + addCategory(BOOTS); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java new file mode 100644 index 000000000..01ef28c06 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java @@ -0,0 +1,10 @@ +package nautilus.game.arcade.game.games.moba.util; + +public class MobaConstants +{ + + // String constants + public static final String BASIC_ATTACK = "Basic Attack"; + public static final String AMMO = "Ammo"; + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaParticles.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaParticles.java index ce6024784..0964306f4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaParticles.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaParticles.java @@ -10,7 +10,7 @@ public class MobaParticles public static void healing(LivingEntity entity, int amount) { - UtilParticle.PlayParticleToAll(ParticleType.HEART, entity.getEyeLocation(), 0.5F, 0.5F, 0.5F, 0.1F, amount, ViewDist.LONG); + UtilParticle.PlayParticleToAll(ParticleType.HEART, entity.getLocation().add(0, 1.3, 0), 0.5F, 0.5F, 0.5F, 0.1F, amount, ViewDist.LONG); } } From f2130515f39ad36e938577e7427c20b98282bf7a Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 14 May 2017 11:41:26 +0100 Subject: [PATCH 16/57] Add suffixes to the scoreboard --- .../game/modules/CustomScoreboardModule.java | 46 +++++++++++-------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java index b167a378d..95ce3bbb5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java @@ -1,6 +1,5 @@ package nautilus.game.arcade.game.modules; -import mineplex.core.common.util.C; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -28,6 +27,7 @@ public class CustomScoreboardModule extends Module private BiConsumer _scoreboardConsumer; private BiFunction _prefixFunction; + private BiFunction _suffixFunction; public CustomScoreboardModule() { @@ -83,6 +83,17 @@ public class CustomScoreboardModule extends Module refresh(); } + @EventHandler(priority = EventPriority.MONITOR) + public void live(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + + refresh(); + } + @EventHandler public void update(UpdateEvent event) { @@ -106,12 +117,9 @@ public class CustomScoreboardModule extends Module { scoreboard = new CustomArcadeScoreboard(player); _scoreboard.put(player.getUniqueId(), scoreboard); - player.setScoreboard(scoreboard.getHandle()); - } - else - { - player.setScoreboard(scoreboard.getHandle()); } + + player.setScoreboard(scoreboard.getHandle()); } public CustomScoreboardModule setSidebar(BiConsumer consumer) @@ -126,6 +134,12 @@ public class CustomScoreboardModule extends Module return this; } + public CustomScoreboardModule setSuffix(BiFunction function) + { + _suffixFunction = function; + return this; + } + public void refresh() { for (CustomArcadeScoreboard scoreboard : _scoreboard.values()) @@ -148,7 +162,7 @@ public class CustomScoreboardModule extends Module super(getGame(), owner); } - public void setTag(Player subject, String prefix, String suffix) + private void setTag(Player subject, String prefix, String suffix) { Scoreboard handle = getHandle(); String teamName = subject.getName(); @@ -162,20 +176,16 @@ public class CustomScoreboardModule extends Module if (prefix != null) { - String prefixF = prefix + C.Reset + " "; - - if (!team.getPrefix().equals(prefixF)) + if (team.getPrefix() == null || !team.getPrefix().equals(prefix)) { - team.setPrefix(prefixF); + team.setPrefix(prefix); } } - else if (suffix != null) + if (suffix != null) { - String suffixF = suffix + C.Reset + " "; - - if (!team.getPrefix().equals(suffixF)) + if (team.getSuffix() == null || !team.getSuffix().equals(suffix)) { - team.setSuffix(suffixF); + team.setSuffix(suffix); } } } @@ -192,13 +202,13 @@ public class CustomScoreboardModule extends Module { _scoreboardConsumer.accept(getOwner(), this); } - if (sidebarOnly) + if (!sidebarOnly) { if (_prefixFunction != null) { for (Player player : Bukkit.getOnlinePlayers()) { - setTag(getOwner(), _prefixFunction.apply(getOwner(), player), null); + setTag(player, _prefixFunction.apply(getOwner(), player), _suffixFunction.apply(getOwner(), player)); } } } From d510dd9f580234726e589d1d3e9757b1aa933716 Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 14 May 2017 11:46:24 +0100 Subject: [PATCH 17/57] Increase Fountain damage range --- .../game/arcade/game/games/moba/fountain/MobaFountain.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java index f5c1027b9..0905cd1b8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java @@ -22,7 +22,7 @@ import java.util.Map.Entry; public class MobaFountain implements Listener { - private static final int FOUNTAIN_SIZE_SQUARED = 25; + private static final int FOUNTAIN_SIZE_SQUARED = 50; private final Moba _host; private final Map _average; From a450b23d226fb2b067191f636ccd3be39dd11508 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 15 May 2017 19:32:25 +0100 Subject: [PATCH 18/57] Wither and AI base --- .../game/arcade/game/games/moba/Moba.java | 48 +++--- .../game/arcade/game/games/moba/MobaLane.java | 43 +++++ .../arcade/game/games/moba/ai/MobaAI.java | 124 ++++++++++++++ .../game/games/moba/ai/goal/MobaAIMethod.java | 11 ++ .../moba/ai/goal/MobaDirectAIMethod.java | 70 ++++++++ .../moba/ai/goal/MobaEntityAIMethod.java | 15 ++ .../game/games/moba/boss/BossManager.java | 72 ++++++++ .../arcade/game/games/moba/boss/MobaBoss.java | 90 ++++++++++ .../games/moba/boss/wither/WitherBoss.java | 162 ++++++++++++++++++ .../boss/wither/WitherSkullProjectile.java | 82 +++++++++ .../game/games/moba/kit/common/SkillBow.java | 7 +- .../games/moba/kit/devon/SkillInfinity.java | 5 - .../arcade/game/games/moba/shop/MobaShop.java | 5 + .../games/moba/structure/tower/Tower.java | 58 ++++++- 14 files changed, 762 insertions(+), 30 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaAIMethod.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaEntityAIMethod.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 7ffeea140..b3cf92d73 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -17,6 +17,7 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.games.moba.boss.BossManager; import nautilus.game.arcade.game.games.moba.fountain.MobaFountain; import nautilus.game.arcade.game.games.moba.gold.GoldManager; import nautilus.game.arcade.game.games.moba.kit.*; @@ -34,6 +35,7 @@ import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.scoreboard.GameScoreboard; +import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.entity.Arrow; import org.bukkit.entity.Player; @@ -110,6 +112,9 @@ public class Moba extends TeamGame MobaFountain fountain = new MobaFountain(this); _listeners.add(fountain); + Listener boss = new BossManager(this); + _listeners.add(boss); + new CompassModule() .setGiveCompass(true) .setGiveCompassToSpecs(true) @@ -228,21 +233,7 @@ public class Moba extends TeamGame } String team = components[1]; - String lane = components[2]; - int laneInt = 0; - - switch (lane) - { - case "A": - laneInt = 0; - break; - case "B": - laneInt = 1; - break; - case "C": - laneInt = 2; - break; - } + MobaLane lane = MobaLane.valueOf(components[2]); boolean firstTower; @@ -263,7 +254,7 @@ public class Moba extends TeamGame continue; } - _towers.add(new Tower(this, location, gameTeam, laneInt, health, firstTower)); + _towers.add(new Tower(this, location, gameTeam, lane, health, firstTower)); } _listeners.forEach(UtilServer::RegisterEvents); @@ -305,19 +296,29 @@ public class Moba extends TeamGame { scoreboard.writeNewLine(); +// GameTeam team = GetTeam(player); +// boolean blueBottom = team == null || team.GetColor() == ChatColor.BLUE; +// +// // Tower Data +// List lines = new ArrayList<>(); +// GameTeam red = GetTeam(ChatColor.RED); +// GameTeam blue = GetTeam(ChatColor.AQUA); +// +// lines.add("♚"); + + // Gold + scoreboard.write(C.cGoldB + "Gold"); if (IsAlive(player)) { int gold = _goldManager.getGold(player); - scoreboard.write(C.cGoldB + "Gold"); scoreboard.write(String.valueOf(gold)); } else { - scoreboard.write("You are dead lol"); + scoreboard.write("None"); } - scoreboard.writeNewLine(); } @@ -377,6 +378,13 @@ public class Moba extends TeamGame } } + @Override + public void RespawnPlayer(Player player) + { + super.RespawnPlayer(player); + player.setGameMode(GameMode.ADVENTURE); + } + @Override public void disable() { @@ -680,7 +688,7 @@ public class Moba extends TeamGame { for (HeroKit kit : _kits) { - if (kit.getRole() == role) + if (kit.getRole() == role && kit.isVisible()) { return kit; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java new file mode 100644 index 000000000..4681c4a42 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java @@ -0,0 +1,43 @@ +package nautilus.game.arcade.game.games.moba; + +import nautilus.game.arcade.game.GameTeam; +import org.bukkit.ChatColor; + +public enum MobaLane +{ + + A, + B, + C; + + public String getName(GameTeam team) + { + if (this == B) + { + return "Middle"; + } + else if (this == A) + { + if (team.GetColor() == ChatColor.AQUA) + { + return "Left"; + } + else + { + return "Right"; + } + } + else + { + if (team.GetColor() == ChatColor.AQUA) + { + return "Right"; + } + else + { + return "Left"; + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java new file mode 100644 index 000000000..013c97050 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java @@ -0,0 +1,124 @@ +package nautilus.game.arcade.game.games.moba.ai; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; + +import java.util.Map.Entry; + +public class MobaAI +{ + + public static final int TARGET_RANGE = 11; + public static final int TARGET_RANGE_SQUARED = TARGET_RANGE * TARGET_RANGE; + + private final Moba _host; + private final GameTeam _owner; + + private LivingEntity _entity; + private LivingEntity _target; + private Location _home; + + private MobaAIMethod _aiMethod; + + public MobaAI(Moba host, GameTeam owner, LivingEntity entity, Location home, MobaAIMethod aiMethod) + { + _host = host; + _owner = owner; + _entity = entity; + _home = home; + _aiMethod = aiMethod; + } + + public void updateTarget() + { + // Entity not spawned + if (_entity == null || !_entity.isValid()) + { + return; + } + + if (_target == null) + { + _target = getBestEntityTarget(); + + if (_target == null) + { + returnToHome(); + return; + } + } + else + { + double dist = UtilMath.offsetSquared(_home, _target.getLocation()); + + if (dist > TARGET_RANGE_SQUARED || UtilPlayer.isSpectator(_target)) + { + _target = null; + returnToHome(); + } + } + + if (_target != null) + { + _aiMethod.updateMovement(_entity, _target.getLocation(), 2.5F); + } + } + + private void returnToHome() + { + _aiMethod.updateMovement(_entity, _home, 3.5F); + } + + private LivingEntity getBestEntityTarget() + { + LivingEntity highest = null; + double bestDist = 0; + + for (Entry entry : UtilEnt.getInRadius(_home, TARGET_RANGE).entrySet()) + { + LivingEntity entity = entry.getKey(); + double dist = entry.getValue(); + + if (_entity.equals(entity)) + { + continue; + } + + // Make players more desirable + if (entity instanceof Player) + { + if (_owner.equals(_host.GetTeam((Player) entity))) + { + continue; + } + + dist += 0.5; + } + + if (bestDist < dist) + { + highest = entity; + bestDist = dist; + } + } + + return highest; + } + + public void setEntity(LivingEntity entity) + { + _entity = entity; + } + + public LivingEntity getTarget() + { + return _target; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaAIMethod.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaAIMethod.java new file mode 100644 index 000000000..cb20ef390 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaAIMethod.java @@ -0,0 +1,11 @@ +package nautilus.game.arcade.game.games.moba.ai.goal; + +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; + +public interface MobaAIMethod +{ + + void updateMovement(LivingEntity entity, Location goal, float speed); + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java new file mode 100644 index 000000000..65e458420 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java @@ -0,0 +1,70 @@ +package nautilus.game.arcade.game.games.moba.ai.goal; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.bukkit.util.Vector; + +public class MobaDirectAIMethod implements MobaAIMethod +{ + + private static final float YAW_SNAP_LIMIT = 20F; + + @Override + public void updateMovement(LivingEntity entity, Location goal, float speed) + { + Location entityLocation = entity.getLocation(); + + float entityYaw = entityLocation.getYaw(); + + // Speed is blocks per second + float magnitude = speed / 20F; + + // Get the direct vector between the entity and the goal + Vector direction = UtilAlg.getTrajectory(entityLocation, goal); + + // From the direction, get the yaw of this direction + float directionYaw = UtilAlg.GetYaw(direction); + + // Get the absolute yaw offset from the direction + // This can then be used to see how far the entity is + // looking away from the goal + float yawOffset = Math.abs(directionYaw - entityYaw); + + // If the entity is facing too far away from the goal to consider the + // "Head Snapping" of turning the entity too severe + if (yawOffset > YAW_SNAP_LIMIT) + { + // Facing too far right + if (entityYaw > directionYaw) + { + entityYaw -= YAW_SNAP_LIMIT; + } + // Facing too far left + else + { + entityYaw += YAW_SNAP_LIMIT; + } + + // Only alter the entity's yaw + entityLocation.setYaw(entityYaw); + } + // If reached the goal + else if (UtilMath.offsetSquared(entityLocation, goal) < 0.5) + { + entityLocation = goal; + } + else + { + // Modify the direction's magnitude to be at the same rate as the speed + direction.multiply(magnitude); + + // Add the modified direction to the original entity location + entityLocation.add(direction); + } + + // Move the entity to its new location + entity.teleport(entityLocation); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaEntityAIMethod.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaEntityAIMethod.java new file mode 100644 index 000000000..6e6b605cc --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaEntityAIMethod.java @@ -0,0 +1,15 @@ +package nautilus.game.arcade.game.games.moba.ai.goal; + +import mineplex.core.common.util.UtilEnt; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; + +public class MobaEntityAIMethod implements MobaAIMethod +{ + + @Override + public void updateMovement(LivingEntity entity, Location goal, float speed) + { + UtilEnt.CreatureMoveFast(entity, goal, speed); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java new file mode 100644 index 000000000..73ba34407 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java @@ -0,0 +1,72 @@ +package nautilus.game.arcade.game.games.moba.boss; + +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; +import nautilus.game.arcade.world.WorldData; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +import java.util.HashMap; +import java.util.Map; + +public class BossManager implements Listener +{ + + private final Moba _host; + + private Map _teamBosses; + + public BossManager(Moba host) + { + _host = host; + _teamBosses = new HashMap<>(2); + } + + private void spawnBosses() + { + _host.CreatureAllowOverride = true; + + WorldData worldData = _host.WorldData; + + // Spawn Team Withers + for (GameTeam team : _host.GetTeamList()) + { + WitherBoss boss = new WitherBoss(_host, worldData.GetDataLocs(team.GetName().toUpperCase()).get(0), team); + boss.setup(); + + _teamBosses.put(team, boss); + } + + _host.CreatureAllowOverride = false; + } + + @EventHandler + public void prepare(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + spawnBosses(); + } + + @EventHandler + public void cleanup(GameStateChangeEvent event) + { + if (event.GetState() != GameState.End && event.GetState() != GameState.Dead) + { + return; + } + + _teamBosses.forEach((team, witherBoss) -> witherBoss.cleanup()); + } + + public WitherBoss getWitherBoss(GameTeam team) + { + return _teamBosses.get(team); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java new file mode 100644 index 000000000..b995f0cd8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java @@ -0,0 +1,90 @@ +package nautilus.game.arcade.game.games.moba.boss; + +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.ai.MobaAI; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDeathEvent; + +public abstract class MobaBoss implements Listener +{ + + protected final Moba _host; + protected LivingEntity _entity; + protected Location _location; + protected int _respawnTime; + private long _lastDeath; + + public MobaBoss(Moba host, Location location) + { + this(host, location, -1); + } + + public MobaBoss(Moba host, Location location, int respawnTime) + { + _host = host; + _location = location; + _respawnTime = respawnTime; + _lastDeath = -1; + } + + public void setup() + { + _entity = spawnEntity(); + UtilServer.RegisterEvents(this); + } + + public void cleanup() + { + UtilServer.Unregister(this); + } + + @EventHandler + public void updateMovement(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK || _entity == null || !_host.IsLive()) + { + return; + } + + getAi().updateTarget(); + } + + @EventHandler + public void entityDeath(EntityDeathEvent event) + { + if (_entity != null && _entity.equals(event.getEntity())) + { + _entity = null; + _lastDeath = System.currentTimeMillis(); + getAi().setEntity(null); + } + } + + @EventHandler + public void updateRespawn(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC || _lastDeath == -1 || UtilTime.elapsed(_lastDeath, _respawnTime)) + { + return; + } + + _lastDeath = -1; + _entity = spawnEntity(); + } + + public abstract LivingEntity spawnEntity(); + + public abstract MobaAI getAi(); + + public LivingEntity getEntity() + { + return _entity; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java new file mode 100644 index 000000000..c722ff083 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -0,0 +1,162 @@ +package nautilus.game.arcade.game.games.moba.boss.wither; + +import mineplex.core.common.util.UtilAlg; +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.UtilTextTop; +import mineplex.core.disguise.disguises.DisguiseWither; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.ai.MobaAI; +import nautilus.game.arcade.game.games.moba.ai.goal.MobaDirectAIMethod; +import nautilus.game.arcade.game.games.moba.boss.MobaBoss; +import nautilus.game.arcade.game.games.moba.structure.tower.Tower; +import nautilus.game.arcade.game.games.moba.structure.tower.TowerDestroyEvent; +import org.bukkit.EntityEffect; +import org.bukkit.Location; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +public class WitherBoss extends MobaBoss +{ + + private static final int INITIAL_HEALTH = 1750; + private static final int FIRST_TOWER_HEALTH_REDUCTION = 100; + private static final int SECOND_TOWER_HEALTH_REDUCTION = 250; + + private GameTeam _team; + private MobaAI _ai; + + public WitherBoss(Moba host, Location location, GameTeam team) + { + super(host, location); + + _location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, host.GetSpectatorLocation()))); + _team = team; + } + + @Override + public LivingEntity spawnEntity() + { + ArmorStand stand = _location.getWorld().spawn(_location, ArmorStand.class); + + stand.setMaxHealth(INITIAL_HEALTH); + stand.setHealth(INITIAL_HEALTH); + stand.setGravity(false); + + DisguiseWither disguiseWither = new DisguiseWither(stand); + disguiseWither.setName(_team.GetColor() + _team.GetName() + "\'s Wither"); + disguiseWither.setCustomNameVisible(true); + _host.getArcadeManager().GetDisguise().disguise(disguiseWither); + + return stand; + } + + @Override + public MobaAI getAi() + { + if (_ai == null) + { + _ai = new MobaAI(_host, _team, _entity, _location, new MobaDirectAIMethod()); + } + + return _ai; + } + + @Override + @EventHandler + public void updateMovement(UpdateEvent event) + { + super.updateMovement(event); + + if (event.getType() == UpdateType.SEC && _entity != null && _host.IsLive() && getAi().getTarget() != null) + { + new WitherSkullProjectile(_host, _entity, getAi().getTarget(), _team); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void damage(CustomDamageEvent event) + { + // Not a Wither Boss + if (event.isCancelled() || !(event.GetDamageeEntity().equals(_entity))) + { + return; + } + + event.SetCancelled("Wither Boss"); + + if (event.GetDamagerPlayer(true) == null || event.GetCause() == DamageCause.FIRE || event.GetCause() == DamageCause.FIRE_TICK) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + Player damager = event.GetDamagerPlayer(true); + GameTeam team = _host.GetTeam(damager); + + if (_team.equals(team)) + { + return; + } + + double newHealth = damagee.getHealth() - event.GetDamage(); + + // Don't allow the wither to move because of damage + damagee.playEffect(EntityEffect.HURT); + + if (newHealth > 0) + { + damagee.setHealth(newHealth); + } + else + { + UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _entity.getLocation().add(0, 1.5, 0), 0F, 0F, 0F, 0.1F, 1, ViewDist.LONG); + _entity.remove(); + } + } + + @EventHandler + public void towerDestroy(TowerDestroyEvent event) + { + Tower tower = event.getTower(); + + if (!_team.equals(tower.getOwner())) + { + return; + } + + if (tower.isFirstTower()) + { + _entity.setHealth(_entity.getHealth() - FIRST_TOWER_HEALTH_REDUCTION); + } + else + { + _entity.damage(_entity.getHealth() - SECOND_TOWER_HEALTH_REDUCTION); + } + } + + @EventHandler + public void updateTeamDisplay(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC || _entity == null) + { + return; + } + + double percent = _entity.getHealth() / _entity.getMaxHealth(); + + for (Player player : _team.GetPlayers(true)) + { + UtilTextTop.displayTextBar(player, percent, _team.GetColor() + "Your Wither"); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java new file mode 100644 index 000000000..48c2173ee --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java @@ -0,0 +1,82 @@ +package nautilus.game.arcade.game.games.moba.boss.wither; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.WitherSkull; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +public class WitherSkullProjectile implements IThrown +{ + + private static final int DAMAGE = 10; + + private final Moba _host; + private final ArcadeManager _manager; + private final GameTeam _owner; + + public WitherSkullProjectile(Moba host, LivingEntity shooter, LivingEntity target, GameTeam owner) + { + _host = host; + _manager = host.getArcadeManager(); + _owner = owner; + + WitherSkull skull = shooter.launchProjectile(WitherSkull.class); + + skull.setYield(0); + skull.setVelocity(skull.getVelocity().add(UtilAlg.getTrajectory(shooter, target)).normalize().multiply(3)); + + _manager.GetProjectile().AddThrow(skull, shooter, this, 2000, true, true, true, false, 0.5F); + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + if (target == null) + { + Expire(data); + return; + } + + if (target instanceof Player) + { + Player targetPlayer = (Player) target; + GameTeam targetTeam = _host.GetTeam(targetPlayer); + + // Not team damage + if (!_owner.equals(targetTeam)) + { + _manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, DamageCause.CUSTOM, DAMAGE, true, true, false, UtilEnt.getName(data.getThrower()), "Wither Skull"); + } + + Expire(data); + } + } + + @Override + public void Idle(ProjectileUser data) + { + } + + @Override + public void Expire(ProjectileUser data) + { + Entity thrown = data.getThrown(); + + thrown.getWorld().playSound(thrown.getLocation(), Sound.EXPLODE, 1, 1.6F); + UtilParticle.PlayParticleToAll(ParticleType.LARGE_EXPLODE, thrown.getLocation(), 0, 0, 0, 0.1F, 1, ViewDist.LONG); + thrown.remove(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillBow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillBow.java index 3edfe97a5..2d2a105a1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillBow.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillBow.java @@ -1,5 +1,7 @@ package nautilus.game.arcade.game.games.moba.kit.common; +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.shop.MobaItem; @@ -16,7 +18,10 @@ public class SkillBow extends HeroSkill "Please work" }; - private static final ItemStack SKILL_ITEM = new ItemStack(Material.BOW); + private static final ItemStack SKILL_ITEM = new ItemBuilder(Material.BOW) + .setTitle(C.cGreenB + "Bow") + .setUnbreakable(true) + .build(); public SkillBow(int slot) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java index 395955bad..2f8d54223 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java @@ -5,16 +5,13 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilPlayer; -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.GameTeam; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; -import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Arrow; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -23,7 +20,6 @@ import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; -import org.bukkit.scheduler.BukkitRunnable; import java.util.HashMap; import java.util.HashSet; @@ -129,7 +125,6 @@ public class SkillInfinity extends HeroSkill { if (_arrows.containsKey(event.GetProjectile())) { - Bukkit.broadcastMessage("Wither"); Manager.GetCondition().Factory().Wither(GetName(), event.GetDamageeEntity(), event.GetDamagerEntity(true), 3, 0, false, true, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index 1ef2b3511..b259725f4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -91,6 +91,11 @@ public class MobaShop implements Listener public void openShop(MobaPlayer player) { + if (UtilPlayer.isSpectator(player.Player) || _host.GetState() != GameState.Live) + { + return; + } + MobaShopMenu menu = _roleMenus.get(player.Role); if (menu == null) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index 48156e3e3..1a6decd79 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -3,9 +3,9 @@ package nautilus.game.arcade.game.games.moba.structure.tower; import mineplex.core.common.util.*; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.utils.UtilVariant; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaLane; import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.entity.Guardian; @@ -16,14 +16,14 @@ public class Tower private final Moba _host; private final Location _location; private final GameTeam _team; - private int _lane; + private MobaLane _lane; private double _health; private int _maxHealth; private boolean _firstTower; private Guardian _guardian; private boolean _dead; - public Tower(Moba host, Location location, GameTeam team, int lane, int health, boolean firstTower) + public Tower(Moba host, Location location, GameTeam team, MobaLane lane, int health, boolean firstTower) { _host = host; _location = location; @@ -79,7 +79,7 @@ public class Tower { float percentage = (float) _health / (float) _maxHealth; - _guardian.setCustomName(UtilTextMiddle.progress(percentage)); + _guardian.setCustomName(getHealthBar(40)); } private void explode() @@ -93,4 +93,54 @@ public class Tower { return _dead; } + + private String getHealthBar(int bars) + { + String out = ""; + String colour; + double health = _guardian.getHealth() / _guardian.getMaxHealth(); + + if (health < 0.25) + { + colour = C.cRedB; + } + else if (health < 0.5) + { + colour = C.cGoldB; + } + else if (health < 0.75) + { + colour = C.cYellowB; + } + else + { + colour = C.cGreenB; + } + + for (int i = 0; i < bars; i++) + { + double cur = i * (1D / (double) bars); + + if (cur < health) + { + out += colour + "|"; + } + else + { + out += C.cGrayB + "|"; + } + } + + return out; + } + + public GameTeam getOwner() + { + return _team; + } + + public boolean isFirstTower() + { + return _firstTower; + } } From 989c9a028c015ed0d417f5eb692a3af224f2d64c Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 15 May 2017 19:55:39 +0100 Subject: [PATCH 19/57] End the game when a wither is killed --- .../game/arcade/game/games/moba/Moba.java | 71 +++++++++++++++++-- .../game/arcade/game/games/moba/MobaLane.java | 9 ++- .../game/arcade/game/games/moba/MobaRole.java | 17 +++-- .../boss/wither/WitherSkullProjectile.java | 2 +- 4 files changed, 87 insertions(+), 12 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index b3cf92d73..cdca741ad 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -18,6 +18,7 @@ import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.moba.boss.BossManager; +import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.game.games.moba.fountain.MobaFountain; import nautilus.game.arcade.game.games.moba.gold.GoldManager; import nautilus.game.arcade.game.games.moba.kit.*; @@ -38,6 +39,7 @@ import nautilus.game.arcade.scoreboard.GameScoreboard; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -73,12 +75,13 @@ public class Moba extends TeamGame private final MobaShop _shop; private final GoldManager _goldManager; + private final BossManager _boss; public Moba(ArcadeManager manager) { - super(manager, GameType.MOBA, new Kit[] { new KitPlayer(manager) }, DESCRIPTION); + super(manager, GameType.MOBA, new Kit[]{new KitPlayer(manager)}, DESCRIPTION); - _kits = new HeroKit[] { + _kits = new HeroKit[]{ new HeroHattori(Manager), new HeroDevon(Manager), new HeroAnath(Manager), @@ -112,7 +115,8 @@ public class Moba extends TeamGame MobaFountain fountain = new MobaFountain(this); _listeners.add(fountain); - Listener boss = new BossManager(this); + BossManager boss = new BossManager(this); + _boss = boss; _listeners.add(boss); new CompassModule() @@ -368,13 +372,72 @@ public class Moba extends TeamGame for (MobaPlayer mobaPlayer : _playerData) { + Player player = mobaPlayer.Player; HeroKit kit = mobaPlayer.Kit; Perk perk = kit.GetPerks()[kit.GetPerks().length - 1]; + // Put Ultimates on cooldown if (perk instanceof HeroSkill) { ((HeroSkill) perk).useSkill(mobaPlayer.Player); } + + // Teleport players to their respective spawns + GameTeam team = GetTeam(player); + toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(toTeleport, GetSpectatorLocation()))); + player.teleport(toTeleport); + } + } + + @Override + public void EndCheck() + { + if (!IsLive()) + { + return; + } + + // Only one team online check + List teamsWithPlayers = new ArrayList<>(GetTeamList().size()); + + for (GameTeam team : GetTeamList()) + { + if (team.GetPlayers(true).isEmpty()) + { + continue; + } + + teamsWithPlayers.add(team); + } + + if (teamsWithPlayers.size() == 1) + { + AnnounceEnd(teamsWithPlayers.get(0)); + SetState(GameState.End); + return; + } + + // Wither Dead check + for (GameTeam team : GetTeamList()) + { + WitherBoss boss = _boss.getWitherBoss(team); + LivingEntity entity = boss.getEntity(); + + // Dead Wither + if (entity == null || !entity.isValid() || entity.isDead()) + { + // Get the other team + for (GameTeam otherTeam : GetTeamList()) + { + if (team.equals(otherTeam)) + { + continue; + } + + AnnounceEnd(otherTeam); + SetState(GameState.End); + } + } } } @@ -646,7 +709,7 @@ public class Moba extends TeamGame { if (kit.getRole() == role && kit.isVisible()) { - kits.add(kit); + kits.add(kit); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java index 4681c4a42..a6426575e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java @@ -8,11 +8,16 @@ public enum MobaLane A, B, - C; + C, + D; public String getName(GameTeam team) { - if (this == B) + if (this == D) + { + return "Jungle"; + } + else if (this == B) { return "Middle"; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java index ee648883c..9f74a4a3f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java @@ -1,22 +1,24 @@ package nautilus.game.arcade.game.games.moba; +import mineplex.core.common.util.C; import org.bukkit.ChatColor; import org.bukkit.Color; public enum MobaRole { - ASSASSIN("Assassin", Color.BLUE, ChatColor.AQUA), - HUNTER("Hunter", Color.LIME, ChatColor.GREEN), - MAGE("Mage", Color.RED, ChatColor.RED), - WARRIOR("Warrior", Color.YELLOW, ChatColor.GOLD), + ASSASSIN("Assassin", MobaLane.D, Color.BLUE, ChatColor.AQUA), + HUNTER("Hunter", MobaLane.A, Color.LIME, ChatColor.GREEN), + MAGE("Mage", MobaLane.B, Color.RED, ChatColor.RED), + WARRIOR("Warrior", MobaLane.C, Color.YELLOW, ChatColor.GOLD), ; private String _name; + private MobaLane _lane; private Color _color; private ChatColor _chatColor; - MobaRole(String name, Color color, ChatColor chatColor) + MobaRole(String name, MobaLane lane, Color color, ChatColor chatColor) { _name = name; _color = color; @@ -28,6 +30,11 @@ public enum MobaRole return _name; } + public MobaLane getLane() + { + return _lane; + } + public Color getColor() { return _color; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java index 48c2173ee..753c06575 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java @@ -36,7 +36,7 @@ public class WitherSkullProjectile implements IThrown WitherSkull skull = shooter.launchProjectile(WitherSkull.class); skull.setYield(0); - skull.setVelocity(skull.getVelocity().add(UtilAlg.getTrajectory(shooter, target)).normalize().multiply(3)); + skull.setVelocity(skull.getVelocity().add(UtilAlg.getTrajectory(shooter, target)).normalize().multiply(2)); _manager.GetProjectile().AddThrow(skull, shooter, this, 2000, true, true, true, false, 0.5F); } From 4b6b04d4eb6bb915a55fc3f46118c56620f79e41 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 15 May 2017 19:55:58 +0100 Subject: [PATCH 20/57] Fix incorrect custom location --- .../src/nautilus/game/arcade/game/games/moba/Moba.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index cdca741ad..2e6b8598a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -384,6 +384,7 @@ public class Moba extends TeamGame // Teleport players to their respective spawns GameTeam team = GetTeam(player); + Location toTeleport = WorldData.GetCustomLocs("SPAWN " + team.GetName().toUpperCase() + " " + mobaPlayer.Role.getLane().toString()).get(0); toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(toTeleport, GetSpectatorLocation()))); player.teleport(toTeleport); } From f9cdddf1ad88d898b7bb68a526cc46a8cc3d52dc Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 15 May 2017 23:16:30 +0100 Subject: [PATCH 21/57] Towers --- .../game/arcade/game/games/moba/Moba.java | 62 +---- .../arcade/game/games/moba/ai/MobaAI.java | 39 +-- .../game/games/moba/kit/PregameSelection.java | 2 +- .../games/moba/structure/tower/Tower.java | 193 ++++++++++---- .../moba/structure/tower/TowerManager.java | 252 ++++++++++++++++++ .../arcade/game/games/moba/util/MobaUtil.java | 101 +++++++ 6 files changed, 501 insertions(+), 148 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 2e6b8598a..a06844e6d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -31,6 +31,7 @@ import nautilus.game.arcade.game.games.moba.recall.Recall; import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; +import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; @@ -67,7 +68,6 @@ public class Moba extends TeamGame private final HeroKit[] _kits; private final List _capturePoints = new ArrayList<>(3); - private final List _towers = new ArrayList<>(12); private final Set _playerData = new HashSet<>(); @@ -119,6 +119,9 @@ public class Moba extends TeamGame _boss = boss; _listeners.add(boss); + Listener tower = new TowerManager(this); + _listeners.add(tower); + new CompassModule() .setGiveCompass(true) .setGiveCompassToSpecs(true) @@ -223,44 +226,6 @@ public class Moba extends TeamGame _capturePoints.add(new CapturePoint(this, location)); } - Map towers = getLocationStartsWith("TOWER"); - - for (Entry entry : towers.entrySet()) - { - String key = entry.getKey(); - Location location = entry.getValue(); - String[] components = key.split(" "); - - if (components.length < 4) - { - continue; - } - - String team = components[1]; - MobaLane lane = MobaLane.valueOf(components[2]); - - boolean firstTower; - - try - { - firstTower = components[3].equalsIgnoreCase("1"); - } - catch (NumberFormatException e) - { - continue; - } - - int health = firstTower ? 250 : 500; - GameTeam gameTeam = getTeam(team); - - if (gameTeam == null) - { - continue; - } - - _towers.add(new Tower(this, location, gameTeam, lane, health, firstTower)); - } - _listeners.forEach(UtilServer::RegisterEvents); } @@ -351,13 +316,6 @@ public class Moba extends TeamGame { _playerData.add(new MobaPlayer(player)); } - - CreatureAllowOverride = true; - for (Tower tower : _towers) - { - tower.setup(); - } - CreatureAllowOverride = false; } @EventHandler @@ -382,11 +340,11 @@ public class Moba extends TeamGame ((HeroSkill) perk).useSkill(mobaPlayer.Player); } - // Teleport players to their respective spawns - GameTeam team = GetTeam(player); - Location toTeleport = WorldData.GetCustomLocs("SPAWN " + team.GetName().toUpperCase() + " " + mobaPlayer.Role.getLane().toString()).get(0); - toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(toTeleport, GetSpectatorLocation()))); - player.teleport(toTeleport); +// // Teleport players to their respective spawns +// GameTeam team = GetTeam(player); +// Location toTeleport = WorldData.GetCustomLocs("SPAWN " + team.GetName().toUpperCase() + " " + mobaPlayer.Role.getLane().toString()).get(0); +// toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(toTeleport, GetSpectatorLocation()))); +// player.teleport(toTeleport); } } @@ -684,7 +642,7 @@ public class Moba extends TeamGame return map; } - private GameTeam getTeam(String name) + public GameTeam getTeam(String name) { for (GameTeam team : GetTeamList()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java index 013c97050..c92293b9f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java @@ -6,6 +6,7 @@ import mineplex.core.common.util.UtilPlayer; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -46,7 +47,7 @@ public class MobaAI if (_target == null) { - _target = getBestEntityTarget(); + _target = MobaUtil.getBestEntityTarget(_host, _owner, _entity, _home, TARGET_RANGE); if (_target == null) { @@ -76,42 +77,6 @@ public class MobaAI _aiMethod.updateMovement(_entity, _home, 3.5F); } - private LivingEntity getBestEntityTarget() - { - LivingEntity highest = null; - double bestDist = 0; - - for (Entry entry : UtilEnt.getInRadius(_home, TARGET_RANGE).entrySet()) - { - LivingEntity entity = entry.getKey(); - double dist = entry.getValue(); - - if (_entity.equals(entity)) - { - continue; - } - - // Make players more desirable - if (entity instanceof Player) - { - if (_owner.equals(_host.GetTeam((Player) entity))) - { - continue; - } - - dist += 0.5; - } - - if (bestDist < dist) - { - highest = entity; - bestDist = dist; - } - } - - return highest; - } - public void setEntity(LivingEntity entity) { _entity = entity; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java index 168e0a97e..63d96919e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java @@ -100,7 +100,7 @@ public class PregameSelection implements Listener, IPacketHandler _roleStands.put(stand, role); } - }, 5); + }, 20); } private void spawnKitUI(Player player, String dataKey) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index 1a6decd79..19c1c5152 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -3,26 +3,48 @@ package nautilus.game.arcade.game.games.moba.structure.tower; import mineplex.core.common.util.*; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.disguise.disguises.DisguiseGuardian; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaLane; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.entity.Guardian; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.EnderCrystal; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; public class Tower { + private static final int DAMAGE = 3; + private static final int TARGET_RANGE = 10; + public static final int TARGET_RANGE_SQUARED = TARGET_RANGE * TARGET_RANGE; + private final Moba _host; + private final Location _location; private final GameTeam _team; - private MobaLane _lane; + private final MobaLane _lane; + private double _health; private int _maxHealth; private boolean _firstTower; - private Guardian _guardian; + + private ArmorStand _stand; + private DisguiseGuardian _guardian; + private EnderCrystal _crystal; + private boolean _dead; + private float _fallbackYaw; + + private LivingEntity _target; + public Tower(Moba host, Location location, GameTeam team, MobaLane lane, int health, boolean firstTower) { _host = host; @@ -36,26 +58,78 @@ public class Tower public void setup() { -// if (_firstTower) -// { - _guardian = _location.getWorld().spawn(_location, Guardian.class); -// } -// else -// { -// _guardian = UtilVariant.spawnElderGuardian(_location); -// } + _fallbackYaw = UtilAlg.GetYaw(UtilAlg.getTrajectory(_location, _host.GetSpectatorLocation())); + _location.setYaw(_fallbackYaw); + _stand = _location.getWorld().spawn(_location, ArmorStand.class); + _stand.setGravity(false); + _stand.setMaxHealth(_maxHealth); + _stand.setHealth(_health); + + _guardian = new DisguiseGuardian(_stand); + _host.getArcadeManager().GetDisguise().disguise(_guardian); + + if (!_firstTower) + { + _guardian.setElder(true); + } - UtilEnt.vegetate(_guardian); - UtilEnt.setFakeHead(_guardian, true); - UtilEnt.silence(_guardian, true); - _guardian.setRemoveWhenFarAway(false); _guardian.setCustomNameVisible(true); + + _crystal = _location.getWorld().spawn(getTowerBase(), EnderCrystal.class); + _crystal.setCustomNameVisible(true); + updateDisplay(); } public void updateTarget() { + if (_target == null) + { + LivingEntity target = MobaUtil.getBestEntityTarget(_host, _team, _stand, _location, TARGET_RANGE, false); + _target = target; + setLaserTarget(target); + } + else + { + double dist = UtilMath.offsetSquared(_location, _target.getLocation()); + if (dist > TARGET_RANGE_SQUARED || UtilPlayer.isSpectator(_target)) + { + _target = null; + setLaserTarget(null); + } + } + } + + public void updateDamage() + { + if (_target == null || _dead) + { + return; + } + + _target.getWorld().playSound(_target.getLocation(), Sound.EXPLODE, 1, 0.2F); + UtilParticle.PlayParticleToAll(ParticleType.LARGE_EXPLODE, _target.getLocation().add(0, 1.5, 0), 0, 0, 0, 0.2F, 1, ViewDist.LONG); + _host.getArcadeManager().GetDamage().NewDamageEvent(_target, null, null, DamageCause.CUSTOM, DAMAGE, false, true, false, "Tower", "Tower"); + } + + private void setLaserTarget(LivingEntity target) + { + if (target == null) + { + _guardian.setTarget(0); + + Location standLocation = _stand.getLocation(); + standLocation.setYaw(_fallbackYaw); + + _guardian.getEntity().setLocation(standLocation.getX(), standLocation.getY(), standLocation.getZ(), standLocation.getYaw(), 0); + } + else + { + _guardian.setTarget(target.getEntityId()); + } + + _host.getArcadeManager().GetDisguise().updateDisguise(_guardian); } public void damage(double damage) @@ -65,73 +139,60 @@ public class Tower if (_health <= 0) { UtilServer.CallEvent(new TowerDestroyEvent(this)); + _target = null; + setLaserTarget(null); _dead = true; - _guardian.remove(); + _stand.remove(); + _crystal.remove(); explode(); } else { + _stand.setHealth(_health); updateDisplay(); } } private void updateDisplay() { - float percentage = (float) _health / (float) _maxHealth; + String out = MobaUtil.getHealthBar(_stand, 40); - _guardian.setCustomName(getHealthBar(40)); + _guardian.setName(out); + _crystal.setCustomName(out); } private void explode() { - _host.getArcadeManager().GetExplosion().BlockExplosion(UtilBlock.getBlocksInRadius(_location.clone().subtract(0, 4, 0), 4), _location, false); + _host.getArcadeManager().GetExplosion().BlockExplosion(UtilBlock.getBlocksInRadius(_location.clone().subtract(0, 3, 0), 3), _location, false); _location.getWorld().playSound(_location, Sound.EXPLODE, 2, 0.6F); UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _location, 0, 0, 0, 0.1F, 1, ViewDist.LONG); } - public boolean isDead() + private Location getTowerBase() { - return _dead; + Block last = _location.getBlock(); + boolean firstAir = false; + + while (true) + { + last = last.getRelative(BlockFace.DOWN); + + if (!firstAir && last.getType() == Material.AIR) + { + firstAir = true; + } + else if (firstAir && last.getType() != Material.AIR) + { + break; + } + } + + return last.getLocation().add(0.5, 0.5, 0.5); } - private String getHealthBar(int bars) + public Location getLocation() { - String out = ""; - String colour; - double health = _guardian.getHealth() / _guardian.getMaxHealth(); - - if (health < 0.25) - { - colour = C.cRedB; - } - else if (health < 0.5) - { - colour = C.cGoldB; - } - else if (health < 0.75) - { - colour = C.cYellowB; - } - else - { - colour = C.cGreenB; - } - - for (int i = 0; i < bars; i++) - { - double cur = i * (1D / (double) bars); - - if (cur < health) - { - out += colour + "|"; - } - else - { - out += C.cGrayB + "|"; - } - } - - return out; + return _location; } public GameTeam getOwner() @@ -139,8 +200,24 @@ public class Tower return _team; } + public MobaLane getLane() + { + return _lane; + } + + public EnderCrystal getCrystal() + { + return _crystal; + } + public boolean isFirstTower() { return _firstTower; } + + public boolean isDead() + { + return _dead; + } + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java new file mode 100644 index 000000000..500de6b7e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -0,0 +1,252 @@ +package nautilus.game.arcade.game.games.moba.structure.tower; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaLane; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.EnderCrystal; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.projectiles.ProjectileSource; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +public class TowerManager implements Listener +{ + + private static final int FIRST_TOWER_HEALTH = 250; + private static final int SECOND_TOWER_HEALTH = 500; + + private final Moba _host; + + private final List _towers; + + public TowerManager(Moba host) + { + _host = host; + + _towers = new ArrayList<>(12); + } + + @EventHandler + public void prepare(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + Map towers = _host.getLocationStartsWith("TOWER"); + + for (Entry entry : towers.entrySet()) + { + String key = entry.getKey(); + Location location = entry.getValue(); + String[] components = key.split(" "); + + if (components.length < 4) + { + continue; + } + + String team = components[1]; + MobaLane lane = MobaLane.valueOf(components[2]); + + boolean firstTower; + + try + { + firstTower = components[3].equalsIgnoreCase("1"); + } + catch (NumberFormatException e) + { + continue; + } + + int health = firstTower ? FIRST_TOWER_HEALTH : SECOND_TOWER_HEALTH; + GameTeam gameTeam = _host.getTeam(team); + + if (gameTeam == null) + { + continue; + } + + _towers.add(new Tower(_host, location, gameTeam, lane, health, firstTower)); + } + + _host.CreatureAllowOverride = true; + for (Tower tower : _towers) + { + tower.setup(); + } + _host.CreatureAllowOverride = false; + } + + @EventHandler + public void updateTower(UpdateEvent event) + { + if (event.getType() == UpdateType.FASTEST) + { + for (Tower tower : _towers) + { + tower.updateTarget(); + } + } + else if (event.getType() == UpdateType.SEC) + { + for (Tower tower : _towers) + { + tower.updateDamage(); + } + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void crystalDamage(EntityDamageEvent event) + { + if (event.getEntity() instanceof EnderCrystal) + { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.LOW) + public void crystalDamage(EntityDamageByEntityEvent event) + { + if (!(event.getEntity() instanceof EnderCrystal)) + { + return; + } + + Entity entity = event.getDamager(); + Player player = null; + + if (entity instanceof Player) + { + player = (Player) entity; + } + else if (entity instanceof Projectile) + { + Projectile projectile = (Projectile) entity; + ProjectileSource source = projectile.getShooter(); + + if (source instanceof Player) + { + player = (Player) source; + + // TODO TEMP + if (UtilMath.offsetSquared(player.getLocation(), event.getEntity().getLocation()) > Tower.TARGET_RANGE_SQUARED) + { + return; + } + } + } + + if (player == null) + { + return; + } + + GameTeam team = _host.GetTeam(player); + + if (UtilPlayer.isSpectator(player) || team == null) + { + return; + } + + for (Tower tower : _towers) + { + if (!event.getEntity().equals(tower.getCrystal()) || !canDamage(tower, team)) + { + continue; + } + + event.setCancelled(true); + tower.damage(event.getDamage()); + + if (Recharge.Instance.use(player, "Tower Sound", 1500, false, false)) + { + player.playSound(tower.getCrystal().getLocation(), Sound.BLAZE_HIT, 1, 0.8F); + } + return; + } + } + +// /* +// Hacky work arounds!!!! +// */ +// @EventHandler +// public void updateAnathBlazePowder(UpdateEvent event) +// { +// if (event.getType() != UpdateType.FASTEST) +// { +// return; +// } +// +// for (Tower tower : _towers) +// { +// for (Entity entity : UtilEnt.getAllInRadius(tower.getCrystal().getLocation(), 1.5).keySet()) +// { +// if (entity instanceof Item) +// { +// Item item = (Item) entity; +// if (item.getItemStack().getType() == Material.BLAZE_POWDER) +// { +// +// } +// } +// } +// } +// } + + private boolean canDamage(Tower tower, GameTeam team) + { + // Dead tower, nothing + // Same team + if (tower.isDead() || team.equals(tower.getOwner())) + { + return false; + } + + MobaLane lane = tower.getLane(); + + // First tower, all it + if (tower.isFirstTower()) + { + return true; + } + + // Second tower + // Need to check if previous was destroyed + for (Tower other : _towers) + { + // Is other team + // Is first tower + // Is same lane + // Is dead + if (team.equals(other.getOwner()) && other.isFirstTower() && lane == other.getLane() && other.isDead()) + { + return true; + } + } + + return false; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java new file mode 100644 index 000000000..81f0ab583 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -0,0 +1,101 @@ +package nautilus.game.arcade.game.games.moba.util; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEnt; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; + +import java.util.Map.Entry; + +public class MobaUtil +{ + + public static LivingEntity getBestEntityTarget(Moba host, GameTeam owner, LivingEntity source, Location location, int targetRange) + { + return getBestEntityTarget(host, owner, source, location, targetRange, true); + } + + public static LivingEntity getBestEntityTarget(Moba host, GameTeam owner, LivingEntity source, Location location, int targetRange, boolean targetPlayersMore) + { + LivingEntity highest = null; + double bestDist = 0; + + for (Entry entry : UtilEnt.getInRadius(location, targetRange).entrySet()) + { + LivingEntity entity = entry.getKey(); + double dist = entry.getValue(); + + if (source.equals(entity)) + { + continue; + } + + // Make players more desirable + if (entity instanceof Player) + { + if (owner.equals(host.GetTeam((Player) entity))) + { + continue; + } + + if (targetPlayersMore) + { + dist += 0.5; + } + } + + if (bestDist < dist) + { + highest = entity; + bestDist = dist; + } + } + + return highest; + } + + public static String getHealthBar(LivingEntity entity, int bars) + { + String out = ""; + String colour; + double health = entity.getHealth() / entity.getMaxHealth(); + + if (health < 0.25) + { + colour = C.cRedB; + } + else if (health < 0.5) + { + colour = C.cGoldB; + } + else if (health < 0.75) + { + colour = C.cYellowB; + } + else + { + colour = C.cGreenB; + } + + for (int i = 0; i < bars; i++) + { + double cur = i * (1D / (double) bars); + + if (cur < health) + { + out += colour + "|"; + } + else + { + out += C.cGrayB + "|"; + } + } + + return out; + } + + +} From 977907de61ba683d9b872fda1e33b28f0e88646d Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 16 May 2017 11:56:50 +0100 Subject: [PATCH 22/57] Fix NPCs not spawning for some players --- .../game/arcade/game/games/moba/kit/PregameSelection.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java index 63d96919e..152a537c2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java @@ -100,7 +100,8 @@ public class PregameSelection implements Listener, IPacketHandler _roleStands.put(stand, role); } - }, 20); + // Only spawn the NPCs once all players have been loaded into the world. + }, _host.GetPlayers(true).size() * _host.TickPerTeleport + 10); } private void spawnKitUI(Player player, String dataKey) From 119b041ec1ae6c7132867f21fdd5557dd944a1ea Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 16 May 2017 11:57:04 +0100 Subject: [PATCH 23/57] Fix second towers being invincible --- .../arcade/game/games/moba/structure/tower/TowerManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index 500de6b7e..d5bc87989 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -241,7 +241,7 @@ public class TowerManager implements Listener // Is first tower // Is same lane // Is dead - if (team.equals(other.getOwner()) && other.isFirstTower() && lane == other.getLane() && other.isDead()) + if (!team.equals(other.getOwner()) && other.isFirstTower() && lane == other.getLane() && other.isDead()) { return true; } From 08744587542e5f46966dbb16e7c00635824afa73 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 16 May 2017 11:58:00 +0100 Subject: [PATCH 24/57] Make the wither display its health --- .../games/moba/boss/wither/WitherBoss.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index c722ff083..bd54f0376 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -5,6 +5,7 @@ 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.UtilTextTop; +import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseWither; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -16,6 +17,7 @@ import nautilus.game.arcade.game.games.moba.ai.goal.MobaDirectAIMethod; import nautilus.game.arcade.game.games.moba.boss.MobaBoss; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.structure.tower.TowerDestroyEvent; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.EntityEffect; import org.bukkit.Location; import org.bukkit.entity.ArmorStand; @@ -35,6 +37,8 @@ public class WitherBoss extends MobaBoss private GameTeam _team; private MobaAI _ai; + private DisguiseWither _disguise; + public WitherBoss(Moba host, Location location, GameTeam team) { super(host, location); @@ -52,10 +56,10 @@ public class WitherBoss extends MobaBoss stand.setHealth(INITIAL_HEALTH); stand.setGravity(false); - DisguiseWither disguiseWither = new DisguiseWither(stand); - disguiseWither.setName(_team.GetColor() + _team.GetName() + "\'s Wither"); - disguiseWither.setCustomNameVisible(true); - _host.getArcadeManager().GetDisguise().disguise(disguiseWither); + _disguise = new DisguiseWither(stand); + _disguise.setName(_team.GetColor() + _team.GetName() + "\'s Wither"); + _disguise.setCustomNameVisible(true); + _host.getArcadeManager().GetDisguise().disguise(_disguise); return stand; } @@ -116,6 +120,7 @@ public class WitherBoss extends MobaBoss if (newHealth > 0) { damagee.setHealth(newHealth); + updateDisplay(); } else { @@ -140,7 +145,7 @@ public class WitherBoss extends MobaBoss } else { - _entity.damage(_entity.getHealth() - SECOND_TOWER_HEALTH_REDUCTION); + _entity.setHealth(_entity.getHealth() - SECOND_TOWER_HEALTH_REDUCTION); } } @@ -159,4 +164,9 @@ public class WitherBoss extends MobaBoss UtilTextTop.displayTextBar(player, percent, _team.GetColor() + "Your Wither"); } } + + private void updateDisplay() + { + _disguise.setName(MobaUtil.getHealthBar(_entity, 40)); + } } From 73ac34ec3d6196fde06bb8da5682a02ea4df7e12 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 16 May 2017 11:58:11 +0100 Subject: [PATCH 25/57] Enable teleporting to lanes --- .../nautilus/game/arcade/game/games/moba/Moba.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index a06844e6d..c0ff0f7e8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -30,7 +30,6 @@ import nautilus.game.arcade.game.games.moba.kit.hattori.HeroHattori; import nautilus.game.arcade.game.games.moba.recall.Recall; import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; -import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; @@ -52,7 +51,6 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.metadata.FixedMetadataValue; import java.util.*; -import java.util.Map.Entry; import java.util.concurrent.TimeUnit; public class Moba extends TeamGame @@ -340,11 +338,11 @@ public class Moba extends TeamGame ((HeroSkill) perk).useSkill(mobaPlayer.Player); } -// // Teleport players to their respective spawns -// GameTeam team = GetTeam(player); -// Location toTeleport = WorldData.GetCustomLocs("SPAWN " + team.GetName().toUpperCase() + " " + mobaPlayer.Role.getLane().toString()).get(0); -// toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(toTeleport, GetSpectatorLocation()))); -// player.teleport(toTeleport); + // Teleport players to their respective spawns + GameTeam team = GetTeam(player); + Location toTeleport = WorldData.GetCustomLocs("SPAWN " + team.GetName().toUpperCase() + " " + mobaPlayer.Role.getLane().toString()).get(0); + toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(toTeleport, GetSpectatorLocation()))); + player.teleport(toTeleport); } } From 4148af92140b66add2aff7ce411a621b89c23dc3 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 16 May 2017 12:16:50 +0100 Subject: [PATCH 26/57] Teleport players "correctly" to their lanes --- .../game/arcade/game/games/moba/Moba.java | 21 ++++++++++++++++--- .../game/arcade/game/games/moba/MobaRole.java | 10 ++++----- .../moba/structure/tower/TowerManager.java | 15 ++++++++++++- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index c0ff0f7e8..e5a3632f5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -30,6 +30,7 @@ import nautilus.game.arcade.game.games.moba.kit.hattori.HeroHattori; import nautilus.game.arcade.game.games.moba.recall.Recall; import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; +import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; @@ -74,6 +75,7 @@ public class Moba extends TeamGame private final MobaShop _shop; private final GoldManager _goldManager; private final BossManager _boss; + private final TowerManager _tower; public Moba(ArcadeManager manager) { @@ -117,7 +119,8 @@ public class Moba extends TeamGame _boss = boss; _listeners.add(boss); - Listener tower = new TowerManager(this); + TowerManager tower = new TowerManager(this); + _tower = tower; _listeners.add(tower); new CompassModule() @@ -340,8 +343,20 @@ public class Moba extends TeamGame // Teleport players to their respective spawns GameTeam team = GetTeam(player); - Location toTeleport = WorldData.GetCustomLocs("SPAWN " + team.GetName().toUpperCase() + " " + mobaPlayer.Role.getLane().toString()).get(0); - toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(toTeleport, GetSpectatorLocation()))); + MobaLane lane = mobaPlayer.Role.getLane(); + Location toTeleport = WorldData.GetCustomLocs("SPAWN " + team.GetName().toUpperCase() + " " + lane.toString()).get(0); + + // Face the location toward the first tower of that lane + Tower tower = _tower.getFirsrtTower(lane); + if (tower != null) + { + toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(player.getLocation(), tower.getLocation()))); + } + else + { + toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(player.getLocation(), GetSpectatorLocation()))); + } + player.teleport(toTeleport); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java index 9f74a4a3f..29e746afd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java @@ -1,6 +1,5 @@ package nautilus.game.arcade.game.games.moba; -import mineplex.core.common.util.C; import org.bukkit.ChatColor; import org.bukkit.Color; @@ -13,14 +12,15 @@ public enum MobaRole WARRIOR("Warrior", MobaLane.C, Color.YELLOW, ChatColor.GOLD), ; - private String _name; - private MobaLane _lane; - private Color _color; - private ChatColor _chatColor; + private final String _name; + private final MobaLane _lane; + private final Color _color; + private final ChatColor _chatColor; MobaRole(String name, MobaLane lane, Color color, ChatColor chatColor) { _name = name; + _lane = lane; _color = color; _chatColor = chatColor; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index d5bc87989..fc8ae6a06 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -181,7 +181,7 @@ public class TowerManager implements Listener event.setCancelled(true); tower.damage(event.getDamage()); - if (Recharge.Instance.use(player, "Tower Sound", 1500, false, false)) + if (Recharge.Instance.use(player, "Tower Sound", 500, false, false)) { player.playSound(tower.getCrystal().getLocation(), Sound.BLAZE_HIT, 1, 0.8F); } @@ -189,6 +189,19 @@ public class TowerManager implements Listener } } + public Tower getFirsrtTower(MobaLane lane) + { + for (Tower tower : _towers) + { + if (tower.isFirstTower() && tower.getLane() == lane) + { + return tower; + } + } + + return null; + } + // /* // Hacky work arounds!!!! // */ From 833ebd310e460ff837a6dc593cc5194f46149c3d Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 16 May 2017 18:02:34 +0100 Subject: [PATCH 27/57] Reorganise of code --- .../game/arcade/game/games/moba/Moba.java | 355 ++++-------------- .../arcade/game/games/moba/MobaPlayer.java | 44 ++- .../game/arcade/game/games/moba/MobaRole.java | 41 +- .../games/moba/boss/wither/WitherBoss.java | 2 + .../boss/wither/WitherSkullProjectile.java | 2 +- .../games/moba/general/TeamDamageManager.java | 76 ++++ .../game/games/moba/gold/GoldManager.java | 2 +- .../games/moba/kit/anath/SkillMeteor.java | 4 +- .../game/games/moba/kit/hp/HPManager.java | 57 +++ .../moba/{ => kit/hp}/MobaHPRegenEvent.java | 2 +- .../arcade/game/games/moba/minion/Minion.java | 6 + .../game/games/moba/minion/MinionManager.java | 17 + .../moba/prepare/PrepareInformation.java | 114 ++++++ .../games/moba/prepare/PrepareManager.java | 168 +++++++++ .../PrepareSelection.java} | 15 +- .../game/games/moba/shop/MobaItemEffect.java | 2 +- .../arcade/game/games/moba/shop/MobaShop.java | 12 +- .../games/moba/shop/MobaShopCategoryMenu.java | 2 +- .../moba/shop/effects/MobaHPRegenEffect.java | 2 +- .../shop/effects/MobaHitArrowAmmoEffect.java | 2 +- .../moba/shop/effects/MobaKillHealEffect.java | 3 - .../moba/shop/effects/MobaSpeedEffect.java | 2 - .../structure/point/CapturePointManager.java | 64 ++++ .../games/moba/structure/tower/Tower.java | 7 +- 24 files changed, 675 insertions(+), 326 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/TeamDamageManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/{ => kit/hp}/MobaHPRegenEvent.java (93%) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/{kit/PregameSelection.java => prepare/PrepareSelection.java} (94%) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index e5a3632f5..ad0a4624f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -1,18 +1,10 @@ package nautilus.game.arcade.game.games.moba; import mineplex.core.common.Rank; -import mineplex.core.common.entity.ClientArmorStand; import mineplex.core.common.util.*; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.DeathMessageType; -import mineplex.minecraft.game.core.condition.Condition; -import mineplex.minecraft.game.core.condition.Condition.ConditionType; -import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GamePrepareCountdownCommence; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.GameTeam; @@ -20,22 +12,26 @@ import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.moba.boss.BossManager; import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.game.games.moba.fountain.MobaFountain; +import nautilus.game.arcade.game.games.moba.general.TeamDamageManager; import nautilus.game.arcade.game.games.moba.gold.GoldManager; -import nautilus.game.arcade.game.games.moba.kit.*; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.game.games.moba.kit.KitPlayer; import nautilus.game.arcade.game.games.moba.kit.anath.HeroAnath; import nautilus.game.arcade.game.games.moba.kit.bob.HeroBob; import nautilus.game.arcade.game.games.moba.kit.dana.HeroDana; import nautilus.game.arcade.game.games.moba.kit.devon.HeroDevon; import nautilus.game.arcade.game.games.moba.kit.hattori.HeroHattori; +import nautilus.game.arcade.game.games.moba.kit.hp.HPManager; +import nautilus.game.arcade.game.games.moba.minion.MinionManager; +import nautilus.game.arcade.game.games.moba.prepare.PrepareManager; +import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection; import nautilus.game.arcade.game.games.moba.recall.Recall; import nautilus.game.arcade.game.games.moba.shop.MobaShop; -import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; -import nautilus.game.arcade.game.games.moba.structure.tower.Tower; +import nautilus.game.arcade.game.games.moba.structure.point.CapturePointManager; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.scoreboard.GameScoreboard; import org.bukkit.GameMode; import org.bukkit.Location; @@ -45,11 +41,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityRegainHealthEvent; -import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.metadata.FixedMetadataValue; import java.util.*; import java.util.concurrent.TimeUnit; @@ -61,13 +54,9 @@ public class Moba extends TeamGame "..." }; private static final long PREPARE_TIME = TimeUnit.MINUTES.toMillis(1); - // Health per 5 seconds. - private static final double HP5 = 0.33; private final HeroKit[] _kits; - private final List _capturePoints = new ArrayList<>(3); - private final Set _playerData = new HashSet<>(); private final Set _listeners = new HashSet<>(); @@ -76,6 +65,7 @@ public class Moba extends TeamGame private final GoldManager _goldManager; private final BossManager _boss; private final TowerManager _tower; + private final CapturePointManager _capturePoint; public Moba(ArcadeManager manager) { @@ -98,30 +88,29 @@ public class Moba extends TeamGame HungerSet = 20; DamageFall = false; - Listener preGameSelection = new PregameSelection(this); - _listeners.add(preGameSelection); + // Instantiate managers - Listener recall = new Recall(this); - _listeners.add(recall); + // Global managers + _shop = registerManager(new MobaShop(this)); + _goldManager = registerManager(new GoldManager(this)); + registerManager(new HPManager(this)); + registerManager(new TeamDamageManager(this)); + registerManager(new MobaFountain(this)); + registerManager(new Recall(this)); - MobaShop shop = new MobaShop(this); - _shop = shop; - _listeners.add(shop); + // Pregame managers + registerManager(new PrepareManager(this)); + registerManager(new PrepareSelection(this)); - GoldManager goldManager = new GoldManager(this); - _goldManager = goldManager; - _listeners.add(goldManager); + // Bosses + _boss = registerManager(new BossManager(this)); - MobaFountain fountain = new MobaFountain(this); - _listeners.add(fountain); + // Structures + _tower = registerManager(new TowerManager(this)); + _capturePoint = registerManager(new CapturePointManager(this)); - BossManager boss = new BossManager(this); - _boss = boss; - _listeners.add(boss); - - TowerManager tower = new TowerManager(this); - _tower = tower; - _listeners.add(tower); + // Minions + //registerManager(new MinionManager(this)); new CompassModule() .setGiveCompass(true) @@ -169,20 +158,20 @@ public class Moba extends TeamGame GameState state = GetState(); GameTeam perspectiveTeam = GetTeam(perspective); GameTeam subjectTeam = GetTeam(subject); - MobaPlayer mobaPlayer = getData(subject); + MobaPlayer mobaPlayer = getMobaData(subject); String suffix; if (state == GameState.Prepare && !perspectiveTeam.equals(subjectTeam)) { suffix = "Unknown"; } - else if (mobaPlayer.Kit == null) + else if (mobaPlayer.getKit() == null) { suffix = "Selecting"; } else { - suffix = mobaPlayer.Kit.GetName(); + suffix = mobaPlayer.getKit().GetName(); } return C.cYellow + " " + suffix + C.Reset; @@ -217,22 +206,22 @@ public class Moba extends TeamGame }); } + private T registerManager(T listener) + { + _listeners.add(listener); + return listener; + } + @Override public void ParseData() { - Collection capturePoints = getLocationStartsWith("POINT").values(); - - for (Location location : capturePoints) - { - _capturePoints.add(new CapturePoint(this, location)); - } - + // Register all "Managers" _listeners.forEach(UtilServer::RegisterEvents); } private void writePrepare(Player player, GameScoreboard scoreboard) { - MobaPlayer mobaPlayer = getData(player); + MobaPlayer mobaPlayer = getMobaData(player); scoreboard.writeNewLine(); @@ -242,7 +231,7 @@ public class Moba extends TeamGame scoreboard.writeNewLine(); scoreboard.write(C.cYellowB + "Hero"); - scoreboard.write(mobaPlayer.Kit == null ? "Unselected " : mobaPlayer.Kit.GetName() + " (" + mobaPlayer.Role.getName() + ")"); + scoreboard.write(mobaPlayer.getKit() == null ? "Unselected " : mobaPlayer.getKit().GetName() + " (" + mobaPlayer.getRole().getName() + ")"); scoreboard.writeNewLine(); @@ -251,7 +240,7 @@ public class Moba extends TeamGame for (MobaPlayer otherMobaPlayer : _playerData) { - if (otherMobaPlayer.Kit != null) + if (otherMobaPlayer.getKit() != null) { kits++; } @@ -319,48 +308,6 @@ public class Moba extends TeamGame } } - @EventHandler - public void live(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Live) - { - return; - } - - UtilTextBottom.display(C.cRedB + "!!! Battle !!!", UtilServer.getPlayers()); - - for (MobaPlayer mobaPlayer : _playerData) - { - Player player = mobaPlayer.Player; - HeroKit kit = mobaPlayer.Kit; - Perk perk = kit.GetPerks()[kit.GetPerks().length - 1]; - - // Put Ultimates on cooldown - if (perk instanceof HeroSkill) - { - ((HeroSkill) perk).useSkill(mobaPlayer.Player); - } - - // Teleport players to their respective spawns - GameTeam team = GetTeam(player); - MobaLane lane = mobaPlayer.Role.getLane(); - Location toTeleport = WorldData.GetCustomLocs("SPAWN " + team.GetName().toUpperCase() + " " + lane.toString()).get(0); - - // Face the location toward the first tower of that lane - Tower tower = _tower.getFirsrtTower(lane); - if (tower != null) - { - toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(player.getLocation(), tower.getLocation()))); - } - else - { - toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(player.getLocation(), GetSpectatorLocation()))); - } - - player.teleport(toTeleport); - } - } - @Override public void EndCheck() { @@ -428,95 +375,6 @@ public class Moba extends TeamGame _listeners.clear(); } - @EventHandler - public void update(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - { - return; - } - - for (CapturePoint point : _capturePoints) - { - point.update(); - } - } - - @EventHandler - public void updatePrepare(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC || GetState() != GameState.Prepare) - { - return; - } - - if (!UtilTime.elapsed(GetStateTime(), PREPARE_TIME)) - { - for (Player player : GetPlayers(true)) - { - Kit kit = GetKit(player); - - if (!(kit instanceof HeroKit)) - { - return; - } - } - } - - AnnounceGame(); - StartPrepareCountdown(); - - //Event - GamePrepareCountdownCommence countdownEvent = new GamePrepareCountdownCommence(this); - UtilServer.CallEvent(countdownEvent); - - // If players took too long, just give them a random free role and kit. - for (Player player : GetPlayers(true)) - { - Kit kit = GetKit(player); - - if (kit instanceof HeroKit) - { - continue; - } - - HeroKit heroKit = getFirstKit(player); - MobaPlayer mobaPlayer = getData(player); - - mobaPlayer.Role = heroKit.getRole(); - mobaPlayer.Kit = heroKit; - - SetKit(player, heroKit, true); - } - - PrepareTime = 0; - Manager.GetChat().Silence(0, false); - } - - @EventHandler - public void roleSelect(RoleSelectEvent event) - { - Player player = event.getPlayer(); - MobaRole role = event.getRole(); - ClientArmorStand stand = event.getStand(); - - if (stand.hasMetadata("owned")) - { - player.sendMessage(F.main("Game", "Another player has already chosen this role.")); - event.setCancelled(true); - return; - } - - // Store inside the stand that it is claimed by a player - stand.setMetadata("owned", new FixedMetadataValue(Manager.getPlugin(), true)); - - // Show that the kit is claimed. - stand.setCustomName(C.cGreenB + role.getName() + C.cGray + " - " + player.getName()); - - // Store the role of the player - getData(player).Role = role; - } - @Override public void SetKit(Player player, Kit kit, boolean announce) { @@ -524,7 +382,7 @@ public class Moba extends TeamGame if (kit instanceof HeroKit) { - getData(player).Kit = (HeroKit) kit; + getMobaData(player).setKit((HeroKit) kit); } } @@ -534,68 +392,16 @@ public class Moba extends TeamGame return DeathMessageType.Detailed; } - @EventHandler - public void preventTeamDamage(CustomDamageEvent event) - { - Player damagee = event.GetDamageePlayer(); - Player damager = event.GetDamagerPlayer(true); - - if (damagee == null || damager == null) - { - return; - } - - GameTeam damageeTeam = GetTeam(damagee); - GameTeam damagerTeam = GetTeam(damager); - - if (damageeTeam == null || damagerTeam == null) - { - return; - } - - if (damageeTeam.equals(damagerTeam)) - { - event.SetCancelled("Team Damage"); - } - } - - @EventHandler - public void preventTeamFire(ConditionApplyEvent event) - { - Condition condition = event.GetCondition(); - - if (condition.GetType() != ConditionType.BURNING) - { - return; - } - - if (condition.GetEnt() == null || condition.GetSource() == null) - { - return; - } - - if (!(condition.GetEnt() instanceof Player && condition.GetSource() instanceof Player)) - { - return; - } - - if (!GetTeam((Player) condition.GetEnt()).equals(GetTeam((Player) condition.GetSource()))) - { - return; - } - - event.setCancelled(true); - } - // Clear up memory @EventHandler public void playerQuit(PlayerQuitEvent event) { Player player = event.getPlayer(); - _playerData.removeIf(mobaPlayer -> mobaPlayer.Player.equals(player)); + _playerData.removeIf(mobaPlayer -> mobaPlayer.getPlayer().equals(player)); } + // Clean up arrows @EventHandler public void projectileHit(ProjectileHitEvent event) { @@ -605,41 +411,6 @@ public class Moba extends TeamGame } } - /* - HP Regeneration - */ - @EventHandler - public void regeneration(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC_05) - { - return; - } - - for (Player player : GetPlayers(true)) - { - if (UtilPlayer.isSpectator(player)) - { - continue; - } - - MobaHPRegenEvent regenEvent = new MobaHPRegenEvent(player, HP5); - UtilServer.CallEvent(regenEvent); - - player.setHealth(Math.min(player.getMaxHealth(), player.getHealth() + regenEvent.getHealth())); - } - } - - @EventHandler - public void preventHungerRegeneration(EntityRegainHealthEvent event) - { - if (event.getRegainReason() == RegainReason.SATIATED) - { - event.setCancelled(true); - } - } - - public Map getLocationStartsWith(String s) { Map map = new HashMap<>(); @@ -688,11 +459,16 @@ public class Moba extends TeamGame return kits; } - public MobaPlayer getData(Player player) + public Set getMobaData() + { + return _playerData; + } + + public MobaPlayer getMobaData(Player player) { for (MobaPlayer mobaPlayer : _playerData) { - if (mobaPlayer.Player.equals(player)) + if (mobaPlayer.getPlayer().equals(player)) { return mobaPlayer; } @@ -701,19 +477,19 @@ public class Moba extends TeamGame return null; } - private HeroKit getFirstKit(Player player) + public HeroKit getFirstKit(Player player) { - MobaPlayer mobaPlayer = getData(player); + MobaPlayer mobaPlayer = getMobaData(player); - if (mobaPlayer.Role == null) + if (mobaPlayer.getRole() == null) { MobaRole role = getRandomRole(player); return getFirstKit(role); } - else if (mobaPlayer.Kit == null) + else if (mobaPlayer.getKit() == null) { - return getFirstKit(mobaPlayer.Role); + return getFirstKit(mobaPlayer.getRole()); } return null; @@ -738,7 +514,7 @@ public class Moba extends TeamGame for (MobaPlayer mobaPlayer : getTeamData(GetTeam(player))) { - MobaRole role = mobaPlayer.Role; + MobaRole role = mobaPlayer.getRole(); if (role != null) { @@ -749,13 +525,13 @@ public class Moba extends TeamGame return UtilAlg.Random(Arrays.asList(MobaRole.values()), roles); } - public List getTeamData(GameTeam team) + private List getTeamData(GameTeam team) { List players = new ArrayList<>(); for (MobaPlayer mobaPlayer : _playerData) { - GameTeam otherTeam = GetTeam(mobaPlayer.Player); + GameTeam otherTeam = GetTeam(mobaPlayer.getPlayer()); if (team.equals(otherTeam)) { @@ -766,11 +542,6 @@ public class Moba extends TeamGame return players; } - public List getCapturePoints() - { - return _capturePoints; - } - public MobaShop getShop() { return _shop; @@ -780,4 +551,14 @@ public class Moba extends TeamGame { return _goldManager; } + + public TowerManager getTowerManager() + { + return _tower; + } + + public CapturePointManager getCapturePointManager() + { + return _capturePoint; + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java index 82c06bf33..a085b8eaa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java @@ -6,12 +6,48 @@ import org.bukkit.entity.Player; public class MobaPlayer { - public final Player Player; - public MobaRole Role; - public HeroKit Kit; + private final Player _player; + private MobaRole _role; + private HeroKit _kit; + private int _gold; public MobaPlayer(Player player) { - Player = player; + _player = player; + } + + public Player getPlayer() + { + return _player; + } + + public void setRole(MobaRole role) + { + _role = role; + } + + public MobaRole getRole() + { + return _role; + } + + public void setKit(HeroKit kit) + { + _kit = kit; + } + + public HeroKit getKit() + { + return _kit; + } + + public void setGold(int gold) + { + _gold = gold; + } + + public int getGold() + { + return _gold; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java index 29e746afd..a0c431980 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java @@ -1,25 +1,51 @@ package nautilus.game.arcade.game.games.moba; +import mineplex.core.common.util.C; import org.bukkit.ChatColor; import org.bukkit.Color; public enum MobaRole { - ASSASSIN("Assassin", MobaLane.D, Color.BLUE, ChatColor.AQUA), - HUNTER("Hunter", MobaLane.A, Color.LIME, ChatColor.GREEN), - MAGE("Mage", MobaLane.B, Color.RED, ChatColor.RED), - WARRIOR("Warrior", MobaLane.C, Color.YELLOW, ChatColor.GOLD), + ASSASSIN("Assassin", new String[] + { + + "You are playing", + "the " + C.cAqua + "Assassin" + C.cWhite + " role this game", + + }, MobaLane.D, Color.BLUE, ChatColor.AQUA), + HUNTER("Hunter", new String[] + { + "You are playing", + "the " + C.cGreen + "Hunter" + C.cWhite + " role this game", + + }, MobaLane.A, Color.LIME, ChatColor.GREEN), + MAGE("Mage", new String[] + { + + "You are playing", + "the " + C.cRed + "Mage" + C.cWhite + " role this game", + + }, MobaLane.B, Color.RED, ChatColor.RED), + WARRIOR("Warrior", new String[] + { + + "You are playing", + "the " + C.cGold + "Warrior" + C.cWhite + " role this game", + + }, MobaLane.C, Color.YELLOW, ChatColor.GOLD), ; private final String _name; + private final String[] _description; private final MobaLane _lane; private final Color _color; private final ChatColor _chatColor; - MobaRole(String name, MobaLane lane, Color color, ChatColor chatColor) + MobaRole(String name, String[] description, MobaLane lane, Color color, ChatColor chatColor) { _name = name; + _description = description; _lane = lane; _color = color; _chatColor = chatColor; @@ -30,6 +56,11 @@ public enum MobaRole return _name; } + public String[] getDescription() + { + return _description; + } + public MobaLane getLane() { return _lane; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index bd54f0376..ca472d25f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -147,6 +147,8 @@ public class WitherBoss extends MobaBoss { _entity.setHealth(_entity.getHealth() - SECOND_TOWER_HEALTH_REDUCTION); } + + updateDisplay(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java index 753c06575..787bfe95f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java @@ -36,7 +36,7 @@ public class WitherSkullProjectile implements IThrown WitherSkull skull = shooter.launchProjectile(WitherSkull.class); skull.setYield(0); - skull.setVelocity(skull.getVelocity().add(UtilAlg.getTrajectory(shooter, target)).normalize().multiply(2)); + skull.setVelocity(skull.getVelocity().add(UtilAlg.getTrajectory(shooter, target))); _manager.GetProjectile().AddThrow(skull, shooter, this, 2000, true, true, true, false, 0.5F); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/TeamDamageManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/TeamDamageManager.java new file mode 100644 index 000000000..78c6cb874 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/TeamDamageManager.java @@ -0,0 +1,76 @@ +package nautilus.game.arcade.game.games.moba.general; + +import mineplex.minecraft.game.core.condition.Condition; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +public class TeamDamageManager implements Listener +{ + + private final Moba _host; + + public TeamDamageManager(Moba host) + { + _host = host; + } + + @EventHandler + public void preventTeamDamage(CustomDamageEvent event) + { + Player damagee = event.GetDamageePlayer(); + Player damager = event.GetDamagerPlayer(true); + + if (damagee == null || damager == null) + { + return; + } + + GameTeam damageeTeam = _host.GetTeam(damagee); + GameTeam damagerTeam = _host.GetTeam(damager); + + if (damageeTeam == null || damagerTeam == null) + { + return; + } + + if (damageeTeam.equals(damagerTeam)) + { + event.SetCancelled("Team Damage"); + } + } + + @EventHandler + public void preventTeamFire(ConditionApplyEvent event) + { + Condition condition = event.GetCondition(); + + if (condition.GetType() != ConditionType.BURNING) + { + return; + } + + if (condition.GetEnt() == null || condition.GetSource() == null) + { + return; + } + + if (!(condition.GetEnt() instanceof Player && condition.GetSource() instanceof Player)) + { + return; + } + + if (!_host.GetTeam((Player) condition.GetEnt()).equals(_host.GetTeam((Player) condition.GetSource()))) + { + return; + } + + event.setCancelled(true); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java index 79edc6baa..e4fedc4a0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java @@ -96,7 +96,7 @@ public class GoldManager implements Listener } // Capture points - for (CapturePoint point : _host.getCapturePoints()) + for (CapturePoint point : _host.getCapturePointManager().getCapturePoints()) { GameTeam owner = point.getOwner(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java index 89fee9780..5314786c3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java @@ -62,7 +62,7 @@ public class SkillMeteor extends HeroSkill implements IThrown FallingBlock block = player.getWorld().spawnFallingBlock(player.getEyeLocation().add(player.getLocation().getDirection()), Material.NETHERRACK, (byte) 0); block.setVelocity(player.getLocation().getDirection()); - Manager.GetProjectile().AddThrow(block, player, this, 1000, true, true, true, false, 0.5F); + Manager.GetProjectile().AddThrow(block, player, this, 2000, true, true, true, false, 0.5F); useActiveSkill(player, 7000); } @@ -138,7 +138,7 @@ public class SkillMeteor extends HeroSkill implements IThrown @Override public void Idle(ProjectileUser data) { - + Expire(data); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java new file mode 100644 index 000000000..298c46afa --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java @@ -0,0 +1,57 @@ +package nautilus.game.arcade.game.games.moba.kit.hp; + +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityRegainHealthEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; + +public class HPManager implements Listener +{ + + // Health per 5 seconds. + private static final double HP5 = 0.33; + + private final Moba _host; + + public HPManager(Moba host) + { + _host = host; + } + + @EventHandler + public void regeneration(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC_05 || !_host.IsLive()) + { + return; + } + + for (Player player : _host.GetPlayers(true)) + { + if (UtilPlayer.isSpectator(player)) + { + continue; + } + + MobaHPRegenEvent regenEvent = new MobaHPRegenEvent(player, HP5); + UtilServer.CallEvent(regenEvent); + + player.setHealth(Math.min(player.getMaxHealth(), player.getHealth() + regenEvent.getHealth())); + } + } + + @EventHandler + public void preventHungerRegeneration(EntityRegainHealthEvent event) + { + if (event.getRegainReason() == RegainReason.SATIATED) + { + event.setCancelled(true); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaHPRegenEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java similarity index 93% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaHPRegenEvent.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java index 0ec5994c8..770d2acfc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaHPRegenEvent.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.moba; +package nautilus.game.arcade.game.games.moba.kit.hp; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java new file mode 100644 index 000000000..364b15edd --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java @@ -0,0 +1,6 @@ +package nautilus.game.arcade.game.games.moba.minion; + +public class Minion +{ + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java new file mode 100644 index 000000000..6a64db0d6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -0,0 +1,17 @@ +package nautilus.game.arcade.game.games.moba.minion; + +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.event.Listener; + +public class MinionManager implements Listener +{ + + private final Moba _host; + + public MinionManager(Moba host) + { + _host = host; + } + + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java new file mode 100644 index 000000000..4a2207562 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java @@ -0,0 +1,114 @@ +package nautilus.game.arcade.game.games.moba.prepare; + +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaPlayer; +import nautilus.game.arcade.game.games.moba.MobaRole; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerMoveEvent; + +import java.util.concurrent.TimeUnit; + +public class PrepareInformation implements Listener +{ + + private static final long MESSAGE_TIME = TimeUnit.SECONDS.toMillis(5); + private static final int MESSAGE_TIME_TICKS = (int) (MESSAGE_TIME / 50D + 5); + + private final Moba _host; + + private long _lastMessage; + private int _messageIndex; + + public PrepareInformation(Moba host) + { + _host = host; + + // How long should the prepare time be. + int longestDescription = 0; + for (MobaRole role : MobaRole.values()) + { + int length = role.getDescription().length; + + if (length > longestDescription) + { + longestDescription = length; + } + } + + // Modify the prepare time + _host.PrepareTime = longestDescription * 1000 + 1000; + + UtilServer.RegisterEvents(this); + } + + @EventHandler + public void updateMessages(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST || !UtilTime.elapsed(_lastMessage, MESSAGE_TIME)) + { + return; + } + + Bukkit.broadcastMessage("updateMessages"); + + for (MobaPlayer mobaPlayer : _host.getMobaData()) + { + Bukkit.broadcastMessage(mobaPlayer.getPlayer().getName()); + String[] description = mobaPlayer.getRole().getDescription(); + + // Description is too short + if (description.length > _messageIndex + 2) + { + Bukkit.broadcastMessage("Too short"); + continue; + } + + UtilTextMiddle.display(description[_messageIndex], description[_messageIndex + 1], 0, MESSAGE_TIME_TICKS, 0, mobaPlayer.getPlayer()); + } + + _messageIndex++; + _lastMessage = System.currentTimeMillis(); + } + + @EventHandler + public void playerMove(PlayerMoveEvent event) + { + if (UtilPlayer.isSpectator(event.getPlayer())) + { + return; + } + + Location to = event.getTo(); + Location from = event.getFrom(); + + // Player hasn't moved along the X or Z axis + if (to.getX() == from.getX() && to.getZ() == from.getZ()) + { + return; + } + + event.setCancelled(true); + } + + @EventHandler + public void live(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + + UtilServer.Unregister(this); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java new file mode 100644 index 000000000..bcc6e7ca6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java @@ -0,0 +1,168 @@ +package nautilus.game.arcade.game.games.moba.prepare; + +import mineplex.core.common.entity.ClientArmorStand; +import mineplex.core.common.util.*; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.GamePrepareCountdownCommence; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaLane; +import nautilus.game.arcade.game.games.moba.MobaPlayer; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.kit.RoleSelectEvent; +import nautilus.game.arcade.game.games.moba.structure.tower.Tower; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.metadata.FixedMetadataValue; + +import java.util.concurrent.TimeUnit; + +public class PrepareManager implements Listener +{ + + private static final long PREPARE_TIME = TimeUnit.MINUTES.toMillis(1); + private static final String OWNED_METADATA = "owned"; + + private final Moba _host; + + private boolean _informationStage; + + public PrepareManager(Moba host) + { + _host = host; + } + + @EventHandler(priority = EventPriority.LOW) + public void updatePrepare(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC || _host.GetState() != GameState.Prepare || _informationStage) + { + return; + } + + if (!UtilTime.elapsed(_host.GetStateTime(), PREPARE_TIME)) + { + for (Player player : _host.GetPlayers(true)) + { + Kit kit = _host.GetKit(player); + + if (!(kit instanceof HeroKit)) + { + return; + } + } + } + + _informationStage = true; + + _host.AnnounceGame(); + _host.StartPrepareCountdown(); + + //Event + GamePrepareCountdownCommence countdownEvent = new GamePrepareCountdownCommence(_host); + UtilServer.CallEvent(countdownEvent); + + // If players took too long, just give them a random free role and kit. + for (Player player : _host.GetPlayers(true)) + { + Kit kit = _host.GetKit(player); + + if (kit instanceof HeroKit) + { + continue; + } + + HeroKit heroKit = _host.getFirstKit(player); + MobaPlayer mobaPlayer = _host.getMobaData(player); + + mobaPlayer.setRole(heroKit.getRole()); + + _host.SetKit(player, heroKit, true); + } + + for (MobaPlayer mobaPlayer : _host.getMobaData()) + { + // Teleport players to their respective spawns + Player player = mobaPlayer.getPlayer(); + GameTeam team = _host.GetTeam(player); + MobaLane lane = mobaPlayer.getRole().getLane(); + Location toTeleport = _host.WorldData.GetCustomLocs("SPAWN " + team.GetName().toUpperCase() + " " + lane.toString()).get(0); + + // Face the location toward the first tower of that lane + Tower tower = _host.getTowerManager().getFirsrtTower(lane); + if (tower != null) + { + toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(player.getLocation(), tower.getLocation()))); + } + else + { + toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(player.getLocation(), _host.GetSpectatorLocation()))); + } + + player.teleport(toTeleport); + } + + _host.SetStateTime(System.currentTimeMillis()); + _host.getArcadeManager().GetChat().Silence(-1, false); + + // Start the pregame role information + new PrepareInformation(_host); + } + + @EventHandler + public void roleSelect(RoleSelectEvent event) + { + Player player = event.getPlayer(); + MobaRole role = event.getRole(); + ClientArmorStand stand = event.getStand(); + + if (stand.hasMetadata(OWNED_METADATA)) + { + player.sendMessage(F.main("Game", "Another player has already chosen this role.")); + event.setCancelled(true); + return; + } + + // Store inside the stand that it is claimed by a player + stand.setMetadata(OWNED_METADATA, new FixedMetadataValue(_host.getArcadeManager().getPlugin(), true)); + + // Show that the kit is claimed. + stand.setCustomName(C.cGreenB + role.getName() + C.cGray + " - " + player.getName()); + + // Store the role of the player + _host.getMobaData(player).setRole(role); + } + + @EventHandler + public void live(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + { + return; + } + + for (MobaPlayer mobaPlayer : _host.getMobaData()) + { + HeroKit kit = mobaPlayer.getKit(); + Perk perk = kit.GetPerks()[kit.GetPerks().length - 1]; + + // Put Ultimates on cooldown + if (perk instanceof HeroSkill) + { + ((HeroSkill) perk).useSkill(mobaPlayer.getPlayer()); + } + } + + _host.getArcadeManager().GetChat().Silence(0, true); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java similarity index 94% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java index 152a537c2..c4c3bccba 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/PregameSelection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.moba.kit; +package nautilus.game.arcade.game.games.moba.prepare; import mineplex.core.common.entity.ClientArmorStand; import mineplex.core.common.util.*; @@ -9,16 +9,15 @@ import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.PacketHandler.ListenerPriority; import mineplex.core.packethandler.PacketInfo; import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.events.PlayerKitApplyEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaPlayer; import nautilus.game.arcade.game.games.moba.MobaRole; -import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.game.games.moba.kit.RoleSelectEvent; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; import org.bukkit.*; -import org.bukkit.FireworkEffect.Type; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -31,14 +30,14 @@ import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; -public class PregameSelection implements Listener, IPacketHandler +public class PrepareSelection implements Listener, IPacketHandler { private final Moba _host; private final Map _roleStands = new HashMap<>(); private final Map _kitStands = new HashMap<>(); - public PregameSelection(Moba host) + public PrepareSelection(Moba host) { _host = host; @@ -111,9 +110,9 @@ public class PregameSelection implements Listener, IPacketHandler List spawns = _host.WorldData.GetDataLocs(dataKey); Location average = UtilAlg.getAverageLocation(team.GetSpawns()); - MobaPlayer mobaPlayer = _host.getData(player); + MobaPlayer mobaPlayer = _host.getMobaData(player); - List heroKits = _host.getKits(mobaPlayer.Role); + List heroKits = _host.getKits(mobaPlayer.getRole()); ItemStack head = new ItemBuilder(Material.SKULL_ITEM, (byte) 2).build(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java index 6adeb01db..ce3b3a233 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java @@ -4,7 +4,7 @@ import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.events.PlayerGameRespawnEvent; -import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent; +import nautilus.game.arcade.game.games.moba.kit.hp.MobaHPRegenEvent; import nautilus.game.arcade.game.games.moba.kit.AmmoGiveEvent; import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; import org.bukkit.entity.Player; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index b259725f4..407450cc2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -11,11 +11,11 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.moba.Moba; -import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent; import nautilus.game.arcade.game.games.moba.MobaPlayer; import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.AmmoGiveEvent; import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; +import nautilus.game.arcade.game.games.moba.kit.hp.MobaHPRegenEvent; import nautilus.game.arcade.game.games.moba.shop.assassin.MobaAssassinShop; import nautilus.game.arcade.game.games.moba.shop.hunter.MobaHunterShop; import nautilus.game.arcade.game.games.moba.shop.mage.MobaMageShop; @@ -91,20 +91,20 @@ public class MobaShop implements Listener public void openShop(MobaPlayer player) { - if (UtilPlayer.isSpectator(player.Player) || _host.GetState() != GameState.Live) + if (UtilPlayer.isSpectator(player.getPlayer()) || _host.GetState() != GameState.Live) { return; } - MobaShopMenu menu = _roleMenus.get(player.Role); + MobaShopMenu menu = _roleMenus.get(player.getRole()); if (menu == null) { - player.Player.sendMessage(F.main("Game", "There isn't an upgrade shop for that kit yet.")); + player.getPlayer().sendMessage(F.main("Game", "There isn't an upgrade shop for that kit yet.")); return; } - menu.open(player.Player); + menu.open(player.getPlayer()); } @EventHandler @@ -163,7 +163,7 @@ public class MobaShop implements Listener { if (clicked.equals(shop)) { - MobaPlayer data = _host.getData(player); + MobaPlayer data = _host.getMobaData(player); if (data == null) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java index a6026d4fb..f6ca8ac51 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java @@ -125,7 +125,7 @@ public class MobaShopCategoryMenu extends Menu @Override public void onClick(Player player, ClickType clickType) { - _shop.openShop(_host.getData(player)); + _shop.openShop(_host.getMobaData(player)); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java index b9d8fc749..0489fe986 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHPRegenEffect.java @@ -1,7 +1,7 @@ package nautilus.game.arcade.game.games.moba.shop.effects; import mineplex.core.common.util.F; -import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent; +import nautilus.game.arcade.game.games.moba.kit.hp.MobaHPRegenEvent; import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; public class MobaHPRegenEffect extends MobaItemEffect diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitArrowAmmoEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitArrowAmmoEffect.java index 4d2393326..791794fc2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitArrowAmmoEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitArrowAmmoEffect.java @@ -23,7 +23,7 @@ public class MobaHitArrowAmmoEffect extends MobaItemEffect Player damager = event.GetDamagerPlayer(true); Moba host = (Moba) Managers.get(ArcadeManager.class).GetGame(); - HeroKit kit = host.getData(damager).Kit; + HeroKit kit = host.getMobaData(damager).getKit(); kit.giveAmmo(damager, 1); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java index 3086e7b84..7c6bdfba7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java @@ -2,9 +2,6 @@ package nautilus.game.arcade.game.games.moba.shop.effects; import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import nautilus.game.arcade.events.PlayerGameRespawnEvent; -import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent; -import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; import org.bukkit.entity.Player; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java index 23f3e4bbe..15d7d7196 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaSpeedEffect.java @@ -2,8 +2,6 @@ package nautilus.game.arcade.game.games.moba.shop.effects; import mineplex.core.common.util.F; import nautilus.game.arcade.events.PlayerGameRespawnEvent; -import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent; -import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; import org.bukkit.entity.Player; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java new file mode 100644 index 000000000..70fe02415 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java @@ -0,0 +1,64 @@ +package nautilus.game.arcade.game.games.moba.structure.point; + +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.Location; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +public class CapturePointManager implements Listener +{ + + private final Moba _host; + + private final List _capturePoints; + + public CapturePointManager(Moba host) + { + _host = host; + + _capturePoints = new ArrayList<>(3); + } + + @EventHandler + public void prepare(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + { + return; + } + + Collection capturePoints = _host.getLocationStartsWith("POINT").values(); + + for (Location location : capturePoints) + { + _capturePoints.add(new CapturePoint(_host, location)); + } + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + for (CapturePoint point : _capturePoints) + { + point.update(); + } + } + + public List getCapturePoints() + { + return _capturePoints; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index 19c1c5152..84d9e7717 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -139,12 +139,16 @@ public class Tower if (_health <= 0) { UtilServer.CallEvent(new TowerDestroyEvent(this)); + + // Boom! + explode(); + + // Nullify everything and remove all entities _target = null; setLaserTarget(null); _dead = true; _stand.remove(); _crystal.remove(); - explode(); } else { @@ -163,7 +167,6 @@ public class Tower private void explode() { - _host.getArcadeManager().GetExplosion().BlockExplosion(UtilBlock.getBlocksInRadius(_location.clone().subtract(0, 3, 0), 3), _location, false); _location.getWorld().playSound(_location, Sound.EXPLODE, 2, 0.6F); UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _location, 0, 0, 0, 0.1F, 1, ViewDist.LONG); } From 604804ff96bfd48c9116a3e0d865107115c1090b Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 16 May 2017 18:02:50 +0100 Subject: [PATCH 28/57] Fix tower explosions not working as intended --- .../game/arcade/game/games/moba/structure/tower/Tower.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index 84d9e7717..74624f3a6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -167,6 +167,7 @@ public class Tower private void explode() { + _host.getArcadeManager().GetExplosion().BlockExplosion(UtilBlock.getBlocksInRadius(_crystal.getLocation().add(0, 2, 0), 3), _location, false); _location.getWorld().playSound(_location, Sound.EXPLODE, 2, 0.6F); UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _location, 0, 0, 0, 0.1F, 1, ViewDist.LONG); } From 5d63a19506203a0d7aefe647d8930640239556dd Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 16 May 2017 22:33:08 +0100 Subject: [PATCH 29/57] Minion AI Base --- .../game/arcade/game/games/moba/Moba.java | 2 +- .../game/arcade/game/games/moba/MobaLane.java | 20 +- .../arcade/game/games/moba/ai/MobaAI.java | 4 - .../game/games/moba/ai/goal/MobaAIMethod.java | 2 +- .../moba/ai/goal/MobaDirectAIMethod.java | 3 +- .../moba/ai/goal/MobaEntityAIMethod.java | 10 +- .../games/moba/kit/anath/SkillBurnBeam.java | 2 +- .../game/games/moba/kit/common/DashSkill.java | 2 +- .../games/moba/kit/dana/SkillDanaDash.java | 2 +- .../arcade/game/games/moba/minion/Minion.java | 52 +++++ .../game/games/moba/minion/MinionManager.java | 122 ++++++++++++ .../game/games/moba/minion/MinionWave.java | 184 ++++++++++++++++++ .../moba/prepare/PrepareInformation.java | 7 +- .../arcade/game/games/moba/shop/MobaShop.java | 6 +- .../games/moba/structure/tower/Tower.java | 9 +- .../moba/structure/tower/TowerManager.java | 13 ++ .../arcade/game/games/moba/util/MobaUtil.java | 6 + 17 files changed, 421 insertions(+), 25 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index ad0a4624f..9131a3e7e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -110,7 +110,7 @@ public class Moba extends TeamGame _capturePoint = registerManager(new CapturePointManager(this)); // Minions - //registerManager(new MinionManager(this)); + registerManager(new MinionManager(this)); new CompassModule() .setGiveCompass(true) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java index a6426575e..19857dd19 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java @@ -6,10 +6,22 @@ import org.bukkit.ChatColor; public enum MobaLane { - A, - B, - C, - D; + A("ORANGE"), + B("YELLOW"), + C("LIME"), + D(null); + + private final String _minionPath; + + MobaLane(String minionPath) + { + _minionPath = minionPath; + } + + public String getMinionPathKey() + { + return _minionPath; + } public String getName(GameTeam team) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java index c92293b9f..2a7588bf9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java @@ -1,6 +1,5 @@ package nautilus.game.arcade.game.games.moba.ai; -import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import nautilus.game.arcade.game.GameTeam; @@ -9,9 +8,6 @@ import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; - -import java.util.Map.Entry; public class MobaAI { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaAIMethod.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaAIMethod.java index cb20ef390..bba2324af 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaAIMethod.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaAIMethod.java @@ -6,6 +6,6 @@ import org.bukkit.entity.LivingEntity; public interface MobaAIMethod { - void updateMovement(LivingEntity entity, Location goal, float speed); + boolean updateMovement(LivingEntity entity, Location goal, float speed); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java index 65e458420..b8b95c59a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java @@ -12,7 +12,7 @@ public class MobaDirectAIMethod implements MobaAIMethod private static final float YAW_SNAP_LIMIT = 20F; @Override - public void updateMovement(LivingEntity entity, Location goal, float speed) + public boolean updateMovement(LivingEntity entity, Location goal, float speed) { Location entityLocation = entity.getLocation(); @@ -66,5 +66,6 @@ public class MobaDirectAIMethod implements MobaAIMethod // Move the entity to its new location entity.teleport(entityLocation); + return true; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaEntityAIMethod.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaEntityAIMethod.java index 6e6b605cc..44c921af7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaEntityAIMethod.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaEntityAIMethod.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.moba.ai.goal; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; @@ -8,8 +9,13 @@ public class MobaEntityAIMethod implements MobaAIMethod { @Override - public void updateMovement(LivingEntity entity, Location goal, float speed) + public boolean updateMovement(LivingEntity entity, Location goal, float speed) { - UtilEnt.CreatureMoveFast(entity, goal, speed); + if (UtilMath.offsetSquared(entity.getLocation(), goal) < 4) + { + return false; + } + + return UtilEnt.CreatureMoveFast(entity, goal, speed); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java index 752d81e78..2349123f2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java @@ -82,7 +82,7 @@ public class SkillBurnBeam extends HeroSkill for (LivingEntity entity : UtilEnt.getInRadius(particle.getLastLocation(), 2).keySet()) { - if (entity.equals(player) || !Recharge.Instance.use(player, GetName() + entity.getName() + player.getName(), 2000, false, false)) + if (entity.equals(player) || !Recharge.Instance.use(player, GetName() + entity.getUniqueId() + player.getName(), 2000, false, false)) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java index e3ff6f068..b3217cd23 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java @@ -181,7 +181,7 @@ public class DashSkill extends HeroSkill continue; } - if (!(entity instanceof Player) || !Recharge.Instance.use((Player) entity, GetName() + " by " + player.getName(), 500, false, false) && _collideOnce) + if (_collideOnce && !Recharge.Instance.use(player, GetName() + player.getName() + entity.getUniqueId(), 500, false, false)) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java index f6ca20836..0bb7af0f9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java @@ -69,7 +69,7 @@ public class SkillDanaDash extends DashSkill } entity.getWorld().playSound(entity.getLocation(), Sound.IRONGOLEM_HIT, 1, 0.5F); - Manager.GetDamage().NewDamageEvent(entity, damager, null, DamageCause.CUSTOM, damage, false, false, false, UtilEnt.getName(damager), GetName()); + Manager.GetDamage().NewDamageEvent(entity, damager, null, DamageCause.CUSTOM, damage, false, true, false, UtilEnt.getName(damager), GetName()); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java index 364b15edd..5b70ace78 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java @@ -1,6 +1,58 @@ package nautilus.game.arcade.game.games.moba.minion; +import mineplex.core.common.util.UtilEnt; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Zombie; + public class Minion { + private static final int HEALTH = 10; + + private final LivingEntity _entity; + + private int _targetIndex; + + public Minion(Location spawn, Class clazz, int targetIndex) + { + _targetIndex = targetIndex; + + LivingEntity entity = spawn.getWorld().spawn(spawn, clazz); + _entity = entity; + entity.setMaxHealth(HEALTH); + entity.setRemoveWhenFarAway(false); + + if (entity instanceof Zombie) + { + ((Zombie) entity).setBaby(true); + } + + UtilEnt.vegetate(entity); + UtilEnt.silence(entity, true); + + entity.setCustomNameVisible(true); + updateDisplay(); + } + + public void updateDisplay() + { + _entity.setCustomName(MobaUtil.getHealthBar(_entity, 10)); + } + + public LivingEntity getEntity() + { + return _entity; + } + + public void setTargetIndex(int index) + { + _targetIndex = index; + } + + public int getTargetIndex() + { + return _targetIndex; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java index 6a64db0d6..e796ef204 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -1,17 +1,139 @@ package nautilus.game.arcade.game.games.moba.minion; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.events.GamePrepareCountdownCommence; +import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.MobaLane; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.entity.PigZombie; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import java.util.*; +import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; + public class MinionManager implements Listener { + private static final int MINION_SPAWN_DELAY_TICKS = 40; + private static final long MINION_SPAWN_TIME = TimeUnit.SECONDS.toMillis(30); + private final Moba _host; + private final Map> _path; + private final Set _waves; + + private long _lastWave; + private boolean _enabled; + public MinionManager(Moba host) { _host = host; + _path = new HashMap<>(3); + _waves = new HashSet<>(); } + @EventHandler + public void gameCountdownCommence(GamePrepareCountdownCommence event) + { + UtilServer.runSyncLater(() -> setEnabled(true), MINION_SPAWN_DELAY_TICKS); + } + + @EventHandler + public void spawnMinions(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC || !_enabled || !_host.IsLive() || !UtilTime.elapsed(_lastWave, MINION_SPAWN_TIME)) + { + return; + } + + _lastWave = System.currentTimeMillis(); + + Set>> entries = _path.entrySet(); + + for (GameTeam team : _host.GetTeamList()) + { + boolean reverse = team.GetColor() == ChatColor.RED; + + for (Entry> entry : entries) + { + List path = new ArrayList<>(entry.getValue()); + + // If red team, reverse the pat + if (reverse) + { + Collections.reverse(path); + } + + MinionWave wave = new MinionWave(_host, this, team, path, reverse ? Zombie.class : PigZombie.class); + + _waves.add(wave); + } + } + } + + public void setEnabled(boolean enabled) + { + _enabled = enabled; + + if (enabled) + { + preparePaths(); + } + } + + public void unregisterWave(MinionWave wave) + { + _waves.remove(wave); + } + + /** + * This method fills the {@link #_path} map with the organised list of locations that the minions must follow.
+ * + * This says that the blue team is the start and the red team is the end. + */ + private void preparePaths() + { + for (MobaLane lane : MobaLane.values()) + { + // Jungle "Lane" + if (lane.getMinionPathKey() == null) + { + continue; + } + + // Step 1 - Find the starting location for the blue team + Location start = _host.WorldData.GetCustomLocs("SPAWN BLUE " + lane.toString()).get(0); + + // Step 2 - Fill a list with ordered locations, from blue to red + ArrayList path = new ArrayList<>(_host.WorldData.GetDataLocs(lane.getMinionPathKey())); + ArrayList organisedPath = new ArrayList<>(path.size()); + + while (organisedPath.size() != path.size()) + { + Location closest = UtilAlg.findClosest(start, path); + + if (closest == null) + { + // Rra rro Shaggy + continue; + } + + organisedPath.add(closest); + start = closest; + } + + // Step 3 - Put the ordered path inside the map + _path.put(lane, path); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java new file mode 100644 index 000000000..ceb36ae3c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -0,0 +1,184 @@ +package nautilus.game.arcade.game.games.moba.minion; + +import mineplex.core.common.util.UtilServer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; +import nautilus.game.arcade.game.games.moba.ai.goal.MobaEntityAIMethod; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.scheduler.BukkitRunnable; + +import java.util.ArrayList; +import java.util.List; + +public class MinionWave implements Listener +{ + + private static final int MAX_MINIONS_PER_WAVE = 6; + private static final MobaAIMethod AI_METHOD = new MobaEntityAIMethod(); + + private final Moba _host; + private final MinionManager _minionManager; + private final GameTeam _owner; + private final Class _clazz; + + private final List _path; + private final List _minions; + + public MinionWave(Moba host, MinionManager minionManager, GameTeam owner, List path, Class clazz) + { + _host = host; + _minionManager = minionManager; + _owner = owner; + _clazz = clazz; + _path = path; + _minions = new ArrayList<>(MAX_MINIONS_PER_WAVE); + + UtilServer.RegisterEvents(this); + + spawn(); + + UtilServer.runSyncTimer(new BukkitRunnable() + { + + @Override + public void run() + { + if (spawn()) + { + cancel(); + } + } + }, 0, 20); + } + + private boolean spawn() + { + _host.CreatureAllowOverride = true; + + Minion minion = new Minion(_path.get(0), _clazz, 1); + + minion.getEntity().setMetadata("team", new FixedMetadataValue(_host.getArcadeManager().getPlugin(), _owner.GetName())); + + _minions.add(minion); + + _host.CreatureAllowOverride = false; + + return _minions.size() >= MAX_MINIONS_PER_WAVE; + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (Minion minion : _minions) + { + LivingEntity entity = minion.getEntity(); + + if (!AI_METHOD.updateMovement(entity, _path.get(minion.getTargetIndex()), 0.9F)) + { + int newTarget = minion.getTargetIndex() + 1; + + if (newTarget == _path.size()) + { + // TODO target wither, probably... + continue; + } + + minion.setTargetIndex(newTarget); + } + } + + _minions.removeIf(minion -> minion.getEntity() == null || minion.getEntity().isDead() || !minion.getEntity().isValid()); + + if (_minions.isEmpty()) + { + UtilServer.Unregister(this); + _minionManager.unregisterWave(this); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void damage(CustomDamageEvent event) + { + // Not a Minion + if (event.isCancelled() || !isMinion(event.GetDamageeEntity())) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + Player damager = event.GetDamagerPlayer(true); + GameTeam team = _host.GetTeam(damager); + + if (team != null && !_owner.equals(team)) + { + event.SetCancelled("Same Team Minion"); + } + else + { + Minion minion = getMinion(damagee); + + if (minion != null) + { + minion.updateDisplay(); + } + } + } + + @EventHandler + public void entityCombust(EntityCombustEvent event) + { + if (isMinion(event.getEntity())) + { + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void entityDeath(EntityDeathEvent event) + { + if (!isMinion(event.getEntity())) + { + return; + } + + event.getDrops().clear(); + } + + private Minion getMinion(Entity entity) + { + for (Minion minion : _minions) + { + if (entity.equals(minion.getEntity())) + { + return minion; + } + } + + return null; + } + + private boolean isMinion(Entity entity) + { + return getMinion(entity) != null; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java index 4a2207562..94e9347e3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java @@ -11,7 +11,6 @@ import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaPlayer; import nautilus.game.arcade.game.games.moba.MobaRole; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -60,17 +59,13 @@ public class PrepareInformation implements Listener return; } - Bukkit.broadcastMessage("updateMessages"); - for (MobaPlayer mobaPlayer : _host.getMobaData()) { - Bukkit.broadcastMessage(mobaPlayer.getPlayer().getName()); String[] description = mobaPlayer.getRole().getDescription(); // Description is too short if (description.length > _messageIndex + 2) { - Bukkit.broadcastMessage("Too short"); continue; } @@ -98,7 +93,7 @@ public class PrepareInformation implements Listener return; } - event.setCancelled(true); + event.setTo(from); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index 407450cc2..542b8b354 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -405,9 +405,13 @@ public class MobaShop implements Listener } Player player = (Player) entity; - List items = _upgrades.get(player); + if (_upgrades == null) + { + return; + } + for (MobaItem item : items) { if (item.getEffects() == null) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index 74624f3a6..826ae00e7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -93,7 +93,7 @@ public class Tower { double dist = UtilMath.offsetSquared(_location, _target.getLocation()); - if (dist > TARGET_RANGE_SQUARED || UtilPlayer.isSpectator(_target)) + if (dist > TARGET_RANGE_SQUARED || UtilPlayer.isSpectator(_target) || _target.isDead() || !_target.isValid()) { _target = null; setLaserTarget(null); @@ -167,7 +167,7 @@ public class Tower private void explode() { - _host.getArcadeManager().GetExplosion().BlockExplosion(UtilBlock.getBlocksInRadius(_crystal.getLocation().add(0, 2, 0), 3), _location, false); + _host.getArcadeManager().GetExplosion().BlockExplosion(UtilBlock.getBlocksInRadius(_crystal.getLocation().add(0, 4, 0), 4), _location, false); _location.getWorld().playSound(_location, Sound.EXPLODE, 2, 0.6F); UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _location, 0, 0, 0, 0.1F, 1, ViewDist.LONG); } @@ -209,6 +209,11 @@ public class Tower return _lane; } + public ArmorStand getStand() + { + return _stand; + } + public EnderCrystal getCrystal() { return _crystal; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index fc8ae6a06..92a646ba9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -5,6 +5,7 @@ import mineplex.core.common.util.UtilPlayer; 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.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; @@ -118,6 +119,18 @@ public class TowerManager implements Listener } } + @EventHandler + public void guardianDamage(CustomDamageEvent event) + { + for (Tower tower : _towers) + { + if (tower.getStand().equals(event.GetDamageeEntity())) + { + event.SetCancelled("Tower Guardian"); + } + } + } + @EventHandler(priority = EventPriority.LOWEST) public void crystalDamage(EntityDamageEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index 81f0ab583..6aaec428b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -33,6 +33,12 @@ public class MobaUtil continue; } + // Check for team entities + if (entity.hasMetadata("team") && !entity.getMetadata("team").get(0).asString().equals(owner.GetName())) + { + continue; + } + // Make players more desirable if (entity instanceof Player) { From 176253faec656b24d27334d2fde2e31110fd8c76 Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 21 May 2017 17:33:33 +0100 Subject: [PATCH 30/57] Remove minion command --- .../game/games/moba/minion/MinionManager.java | 18 ++++++++++++++++++ .../game/games/moba/minion/MinionWave.java | 8 ++++++++ 2 files changed, 26 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java index e796ef204..450482bae 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -1,17 +1,21 @@ package nautilus.game.arcade.game.games.moba.minion; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.GamePrepareCountdownCommence; +import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaLane; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.entity.PigZombie; +import org.bukkit.entity.Player; import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -39,6 +43,20 @@ public class MinionManager implements Listener _host = host; _path = new HashMap<>(3); _waves = new HashSet<>(); + + host.registerDebugCommand(new DebugCommand("removeminions", Rank.DEVELOPER) + { + @Override + public void Execute(Player caller, String[] args) + { + for (MinionWave wave : _waves) + { + wave.cleanup(); + } + + caller.sendMessage(F.main("Debug", "Removed all minions.")); + } + }); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index ceb36ae3c..b3cf29a53 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -163,6 +163,14 @@ public class MinionWave implements Listener event.getDrops().clear(); } + public void cleanup() + { + for (Minion minion : _minions) + { + minion.getEntity().remove(); + } + } + private Minion getMinion(Entity entity) { for (Minion minion : _minions) From 4ed3135cdf38f85a091929c639887ca892b8afe8 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 22 May 2017 20:53:22 +0100 Subject: [PATCH 31/57] Implement improved targetting system --- .../mineplex/core/common/util/UtilPlayer.java | 2 +- .../game/arcade/game/games/moba/MobaLane.java | 60 ----------- .../game/arcade/game/games/moba/MobaRole.java | 17 +--- .../arcade/game/games/moba/ai/MobaAI.java | 8 +- .../game/games/moba/minion/MinionManager.java | 80 ++++++--------- .../game/games/moba/minion/MinionWave.java | 3 +- .../games/moba/prepare/PrepareManager.java | 22 +---- .../games/moba/prepare/PrepareSelection.java | 15 ++- .../arcade/game/games/moba/shop/MobaShop.java | 3 +- .../games/moba/structure/tower/Tower.java | 10 +- .../moba/structure/tower/TowerManager.java | 14 +-- .../game/games/moba/util/MobaConstants.java | 7 ++ .../arcade/game/games/moba/util/MobaUtil.java | 99 ++++++++++++++++++- 13 files changed, 168 insertions(+), 172 deletions(-) delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java index 19b7b6059..6294181ab 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java @@ -654,7 +654,7 @@ public class UtilPlayer continue; } - double dist = UtilMath.offset(cur.getLocation(), loc); + double dist = UtilMath.offsetSquared(cur.getLocation(), loc); if (best == null || dist < bestDist) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java deleted file mode 100644 index 19857dd19..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaLane.java +++ /dev/null @@ -1,60 +0,0 @@ -package nautilus.game.arcade.game.games.moba; - -import nautilus.game.arcade.game.GameTeam; -import org.bukkit.ChatColor; - -public enum MobaLane -{ - - A("ORANGE"), - B("YELLOW"), - C("LIME"), - D(null); - - private final String _minionPath; - - MobaLane(String minionPath) - { - _minionPath = minionPath; - } - - public String getMinionPathKey() - { - return _minionPath; - } - - public String getName(GameTeam team) - { - if (this == D) - { - return "Jungle"; - } - else if (this == B) - { - return "Middle"; - } - else if (this == A) - { - if (team.GetColor() == ChatColor.AQUA) - { - return "Left"; - } - else - { - return "Right"; - } - } - else - { - if (team.GetColor() == ChatColor.AQUA) - { - return "Right"; - } - else - { - return "Left"; - } - } - } - -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java index a0c431980..70baf4c97 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java @@ -13,40 +13,38 @@ public enum MobaRole "You are playing", "the " + C.cAqua + "Assassin" + C.cWhite + " role this game", - }, MobaLane.D, Color.BLUE, ChatColor.AQUA), + }, Color.BLUE, ChatColor.AQUA), HUNTER("Hunter", new String[] { "You are playing", "the " + C.cGreen + "Hunter" + C.cWhite + " role this game", - }, MobaLane.A, Color.LIME, ChatColor.GREEN), + }, Color.LIME, ChatColor.GREEN), MAGE("Mage", new String[] { "You are playing", "the " + C.cRed + "Mage" + C.cWhite + " role this game", - }, MobaLane.B, Color.RED, ChatColor.RED), + }, Color.RED, ChatColor.RED), WARRIOR("Warrior", new String[] { "You are playing", "the " + C.cGold + "Warrior" + C.cWhite + " role this game", - }, MobaLane.C, Color.YELLOW, ChatColor.GOLD), + }, Color.YELLOW, ChatColor.GOLD), ; private final String _name; private final String[] _description; - private final MobaLane _lane; private final Color _color; private final ChatColor _chatColor; - MobaRole(String name, String[] description, MobaLane lane, Color color, ChatColor chatColor) + MobaRole(String name, String[] description, Color color, ChatColor chatColor) { _name = name; _description = description; - _lane = lane; _color = color; _chatColor = chatColor; } @@ -61,11 +59,6 @@ public enum MobaRole return _description; } - public MobaLane getLane() - { - return _lane; - } - public Color getColor() { return _color; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java index 2a7588bf9..a410b88b7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java @@ -6,6 +6,7 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; import nautilus.game.arcade.game.games.moba.util.MobaUtil; +import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; @@ -43,7 +44,7 @@ public class MobaAI if (_target == null) { - _target = MobaUtil.getBestEntityTarget(_host, _owner, _entity, _home, TARGET_RANGE); + _target = MobaUtil.getBestEntityTarget(_host, _owner, _entity, _home, _host.WorldData.GetDataLocs(getBoundaryKey())); if (_target == null) { @@ -82,4 +83,9 @@ public class MobaAI { return _target; } + + private String getBoundaryKey() + { + return _owner.GetColor() == ChatColor.RED ? "ORANGE" : "LIGHT_BLUE"; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java index 450482bae..525b2946d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -11,7 +11,7 @@ import nautilus.game.arcade.events.GamePrepareCountdownCommence; import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; -import nautilus.game.arcade.game.games.moba.MobaLane; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.entity.PigZombie; @@ -21,7 +21,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import java.util.*; -import java.util.Map.Entry; import java.util.concurrent.TimeUnit; public class MinionManager implements Listener @@ -32,7 +31,7 @@ public class MinionManager implements Listener private final Moba _host; - private final Map> _path; + private List _path; private final Set _waves; private long _lastWave; @@ -41,7 +40,6 @@ public class MinionManager implements Listener public MinionManager(Moba host) { _host = host; - _path = new HashMap<>(3); _waves = new HashSet<>(); host.registerDebugCommand(new DebugCommand("removeminions", Rank.DEVELOPER) @@ -75,26 +73,20 @@ public class MinionManager implements Listener _lastWave = System.currentTimeMillis(); - Set>> entries = _path.entrySet(); - for (GameTeam team : _host.GetTeamList()) { + List path = new ArrayList<>(_path); boolean reverse = team.GetColor() == ChatColor.RED; - for (Entry> entry : entries) + // If red team, reverse the pat + if (reverse) { - List path = new ArrayList<>(entry.getValue()); - - // If red team, reverse the pat - if (reverse) - { - Collections.reverse(path); - } - - MinionWave wave = new MinionWave(_host, this, team, path, reverse ? Zombie.class : PigZombie.class); - - _waves.add(wave); + Collections.reverse(path); } + + MinionWave wave = new MinionWave(_host, this, team, path, reverse ? Zombie.class : PigZombie.class); + + _waves.add(wave); } } @@ -104,7 +96,7 @@ public class MinionManager implements Listener if (enabled) { - preparePaths(); + preparePath(); } } @@ -114,44 +106,34 @@ public class MinionManager implements Listener } /** - * This method fills the {@link #_path} map with the organised list of locations that the minions must follow.
- * + * This method fills the {@link #_path} with the organised list of locations that the minions must follow.
+ *

* This says that the blue team is the start and the red team is the end. */ - private void preparePaths() + private void preparePath() { - for (MobaLane lane : MobaLane.values()) + // Step 1 - Find the starting location for the blue team + Location start = _host.WorldData.GetDataLocs(MobaConstants.MINION_PATH_START).get(0); + + // Step 2 - Fill a list with ordered locations, from blue to red + ArrayList path = new ArrayList<>(_host.WorldData.GetDataLocs(MobaConstants.MINION_PATH)); + ArrayList organisedPath = new ArrayList<>(path.size()); + + while (organisedPath.size() != path.size()) { - // Jungle "Lane" - if (lane.getMinionPathKey() == null) + Location closest = UtilAlg.findClosest(start, path); + + if (closest == null) { + // Rra rro Shaggy continue; } - // Step 1 - Find the starting location for the blue team - Location start = _host.WorldData.GetCustomLocs("SPAWN BLUE " + lane.toString()).get(0); - - // Step 2 - Fill a list with ordered locations, from blue to red - ArrayList path = new ArrayList<>(_host.WorldData.GetDataLocs(lane.getMinionPathKey())); - ArrayList organisedPath = new ArrayList<>(path.size()); - - while (organisedPath.size() != path.size()) - { - Location closest = UtilAlg.findClosest(start, path); - - if (closest == null) - { - // Rra rro Shaggy - continue; - } - - organisedPath.add(closest); - start = closest; - } - - // Step 3 - Put the ordered path inside the map - _path.put(lane, path); + organisedPath.add(closest); + start = closest; } - } + // Step 3 - Put the ordered path inside the map + _path = path; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index b3cf29a53..bc533eeed 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -8,6 +8,7 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; import nautilus.game.arcade.game.games.moba.ai.goal.MobaEntityAIMethod; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Entity; @@ -71,7 +72,7 @@ public class MinionWave implements Listener Minion minion = new Minion(_path.get(0), _clazz, 1); - minion.getEntity().setMetadata("team", new FixedMetadataValue(_host.getArcadeManager().getPlugin(), _owner.GetName())); + minion.getEntity().setMetadata(MobaConstants.TEAM_METADATA, new FixedMetadataValue(_host.getArcadeManager().getPlugin(), _owner.GetName())); _minions.add(minion); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java index bcc6e7ca6..2dd066b55 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java @@ -9,7 +9,6 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; -import nautilus.game.arcade.game.games.moba.MobaLane; import nautilus.game.arcade.game.games.moba.MobaPlayer; import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.HeroKit; @@ -90,26 +89,9 @@ public class PrepareManager implements Listener _host.SetKit(player, heroKit, true); } - for (MobaPlayer mobaPlayer : _host.getMobaData()) + for (GameTeam team : _host.GetTeamList()) { - // Teleport players to their respective spawns - Player player = mobaPlayer.getPlayer(); - GameTeam team = _host.GetTeam(player); - MobaLane lane = mobaPlayer.getRole().getLane(); - Location toTeleport = _host.WorldData.GetCustomLocs("SPAWN " + team.GetName().toUpperCase() + " " + lane.toString()).get(0); - - // Face the location toward the first tower of that lane - Tower tower = _host.getTowerManager().getFirsrtTower(lane); - if (tower != null) - { - toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(player.getLocation(), tower.getLocation()))); - } - else - { - toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(player.getLocation(), _host.GetSpectatorLocation()))); - } - - player.teleport(toTeleport); + team.SpawnTeleport(); } _host.SetStateTime(System.currentTimeMillis()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java index c4c3bccba..8cd08ee95 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java @@ -17,7 +17,10 @@ import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.kit.RoleSelectEvent; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; -import org.bukkit.*; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -28,6 +31,7 @@ import org.bukkit.inventory.ItemStack; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.concurrent.atomic.AtomicInteger; public class PrepareSelection implements Listener, IPacketHandler @@ -68,8 +72,7 @@ public class PrepareSelection implements Listener, IPacketHandler private void spawnRoleUI(GameTeam team, String dataKey) { - AtomicInteger i = new AtomicInteger(); - List spawns = _host.WorldData.GetDataLocs(dataKey); + Map spawns = _host.getLocationStartsWith("KIT " + dataKey); Location average = UtilAlg.getAverageLocation(team.GetSpawns()); Player[] players = team.GetPlayers(true).toArray(new Player[0]); @@ -82,11 +85,13 @@ public class PrepareSelection implements Listener, IPacketHandler displayRoleInformation(player); } - for (Location location : spawns) + for (Entry entry : spawns.entrySet()) { + Location location = entry.getValue(); + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, average))); - MobaRole role = MobaRole.values()[i.getAndIncrement()]; + MobaRole role = MobaRole.valueOf(entry.getKey().split(" ")[2]); ClientArmorStand stand = ClientArmorStand.spawn(prepareLocation(location), players); stand.setCustomNameVisible(true); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index 542b8b354..6350670f0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -20,6 +20,7 @@ import nautilus.game.arcade.game.games.moba.shop.assassin.MobaAssassinShop; import nautilus.game.arcade.game.games.moba.shop.hunter.MobaHunterShop; import nautilus.game.arcade.game.games.moba.shop.mage.MobaMageShop; import nautilus.game.arcade.game.games.moba.shop.warrior.MobaWarriorShop; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.Location; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; import org.bukkit.entity.Entity; @@ -68,7 +69,7 @@ public class MobaShop implements Listener return; } - List locations = _host.WorldData.GetDataLocs("CYAN"); + List locations = _host.WorldData.GetDataLocs(MobaConstants.SHOP); _host.CreatureAllowOverride = true; for (Location location : locations) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index 826ae00e7..83cddf9d0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -6,7 +6,6 @@ import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.disguise.disguises.DisguiseGuardian; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; -import nautilus.game.arcade.game.games.moba.MobaLane; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.Material; @@ -29,7 +28,6 @@ public class Tower private final Location _location; private final GameTeam _team; - private final MobaLane _lane; private double _health; private int _maxHealth; @@ -45,12 +43,11 @@ public class Tower private LivingEntity _target; - public Tower(Moba host, Location location, GameTeam team, MobaLane lane, int health, boolean firstTower) + public Tower(Moba host, Location location, GameTeam team, int health, boolean firstTower) { _host = host; _location = location; _team = team; - _lane = lane; _health = health; _maxHealth = health; _firstTower = firstTower; @@ -204,11 +201,6 @@ public class Tower return _team; } - public MobaLane getLane() - { - return _lane; - } - public ArmorStand getStand() { return _stand; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index 92a646ba9..98c72e1ab 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -10,7 +10,6 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; -import nautilus.game.arcade.game.games.moba.MobaLane; import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.entity.EnderCrystal; @@ -68,13 +67,12 @@ public class TowerManager implements Listener } String team = components[1]; - MobaLane lane = MobaLane.valueOf(components[2]); boolean firstTower; try { - firstTower = components[3].equalsIgnoreCase("1"); + firstTower = components[2].equalsIgnoreCase("1"); } catch (NumberFormatException e) { @@ -89,7 +87,7 @@ public class TowerManager implements Listener continue; } - _towers.add(new Tower(_host, location, gameTeam, lane, health, firstTower)); + _towers.add(new Tower(_host, location, gameTeam, health, firstTower)); } _host.CreatureAllowOverride = true; @@ -202,11 +200,11 @@ public class TowerManager implements Listener } } - public Tower getFirsrtTower(MobaLane lane) + public Tower getFirstTower(GameTeam team) { for (Tower tower : _towers) { - if (tower.isFirstTower() && tower.getLane() == lane) + if (tower.isFirstTower() && tower.getOwner().equals(team)) { return tower; } @@ -251,8 +249,6 @@ public class TowerManager implements Listener return false; } - MobaLane lane = tower.getLane(); - // First tower, all it if (tower.isFirstTower()) { @@ -267,7 +263,7 @@ public class TowerManager implements Listener // Is first tower // Is same lane // Is dead - if (!team.equals(other.getOwner()) && other.isFirstTower() && lane == other.getLane() && other.isDead()) + if (!team.equals(other.getOwner()) && other.isFirstTower() && other.isDead()) { return true; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java index 01ef28c06..8c0dfb62e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java @@ -6,5 +6,12 @@ public class MobaConstants // String constants public static final String BASIC_ATTACK = "Basic Attack"; public static final String AMMO = "Ammo"; + public static final String TEAM_METADATA = "team"; + + // Location Constants + public static final String MINION_PATH_START = "WHITE"; + public static final String MINION_PATH = "BROWN"; + public static final String SHOP = "LIGHT_GRAY"; + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index 6aaec428b..7d9e73918 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -1,14 +1,18 @@ package nautilus.game.arcade.game.games.moba.util; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.*; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.util.Vector; +import java.util.HashSet; +import java.util.List; import java.util.Map.Entry; +import java.util.Set; public class MobaUtil { @@ -34,7 +38,7 @@ public class MobaUtil } // Check for team entities - if (entity.hasMetadata("team") && !entity.getMetadata("team").get(0).asString().equals(owner.GetName())) + if (entity.hasMetadata(MobaConstants.TEAM_METADATA) && !entity.getMetadata(MobaConstants.TEAM_METADATA).get(0).asString().equals(owner.GetName())) { continue; } @@ -42,7 +46,7 @@ public class MobaUtil // Make players more desirable if (entity instanceof Player) { - if (owner.equals(host.GetTeam((Player) entity))) + if (owner.equals(host.GetTeam((Player) entity)) || UtilPlayer.isSpectator(entity)) { continue; } @@ -63,6 +67,93 @@ public class MobaUtil return highest; } + public static LivingEntity getBestEntityTarget(Moba host, GameTeam owner, LivingEntity source, Location center, List boundaries) + { + Set ignored = new HashSet<>(); + + if (owner != null) + { + // Add teammates to ignored players + ignored.addAll(owner.GetPlayers(true)); + } + + // Add all spectators to ignored players + for (Player player : Bukkit.getOnlinePlayers()) + { + if (UtilPlayer.isSpectator(player)) + { + ignored.add(player); + } + } + + // For each boundary + for (Location boundary : boundaries) + { + Location boundaryCloned = boundary.clone(); + // Get direction from center to boundary + Vector direction = UtilAlg.getTrajectory(center, boundary); + // Store the checked distance + double checkedDist = 0; + // Get the distance squared from the center to the boundary + double maxDist = UtilMath.offsetSquared(center, boundary); + + // Keep advancing the distance until it hits the boundary + while (checkedDist < maxDist) + { + // Advance the location + boundaryCloned.add(direction); + + LivingEntity highest = null; + double bestDist = 0; + + // Check for nearby entities + for (Entry entry : UtilEnt.getInRadius(boundaryCloned, 2).entrySet()) + { + LivingEntity entity = entry.getKey(); + double dist = entry.getValue(); + + if (source.equals(entity)) + { + continue; + } + + if (owner != null) + { + // Check for team entities + if (entity.hasMetadata(MobaConstants.TEAM_METADATA) && !entity.getMetadata(MobaConstants.TEAM_METADATA).get(0).asString().equals(owner.GetName())) + { + continue; + } + + // Check for same team players + if (entity instanceof Player) + { + if (owner.equals(host.GetTeam((Player) entity)) || UtilPlayer.isSpectator(entity)) + { + continue; + } + } + } + + if (bestDist < dist) + { + highest = entity; + bestDist = dist; + } + } + + if (highest != null) + { + return highest; + } + + checkedDist++; + } + } + + return null; + } + public static String getHealthBar(LivingEntity entity, int bars) { String out = ""; From 78b10e3cb8dc7d27804f2bd6659867b96c039ba1 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 23 May 2017 20:37:31 +0100 Subject: [PATCH 32/57] Fix the majority of bugs for the 1 lane game --- .../game/arcade/game/games/moba/Moba.java | 6 +++ .../arcade/game/games/moba/ai/MobaAI.java | 6 +-- .../moba/ai/goal/MobaEntityAIMethod.java | 21 -------- .../arcade/game/games/moba/boss/MobaBoss.java | 2 +- .../games/moba/boss/wither/WitherBoss.java | 4 +- .../arcade/game/games/moba/minion/Minion.java | 18 ++++++- .../game/games/moba/minion/MinionWave.java | 49 ++++++++++++++++--- .../games/moba/prepare/PrepareSelection.java | 26 ++++------ .../arcade/game/games/moba/shop/MobaShop.java | 31 ++++++------ .../moba/structure/tower/TowerManager.java | 7 ++- .../game/games/moba/util/MobaConstants.java | 2 +- .../arcade/game/games/moba/util/MobaUtil.java | 26 +++++----- 12 files changed, 117 insertions(+), 81 deletions(-) delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaEntityAIMethod.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 9131a3e7e..3e937efba 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -217,6 +217,12 @@ public class Moba extends TeamGame { // Register all "Managers" _listeners.forEach(UtilServer::RegisterEvents); + + // Make all spawns face the center of the map + for (List locations : WorldData.SpawnLocs.values()) + { + locations.forEach(location -> location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, GetSpectatorLocation())))); + } } private void writePrepare(Player player, GameScoreboard scoreboard) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java index a410b88b7..e8f3d0a8a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java @@ -13,8 +13,8 @@ import org.bukkit.entity.LivingEntity; public class MobaAI { - public static final int TARGET_RANGE = 11; - public static final int TARGET_RANGE_SQUARED = TARGET_RANGE * TARGET_RANGE; + private static final int TARGET_RANGE = 11; + private static final int TARGET_RANGE_SQUARED = TARGET_RANGE * TARGET_RANGE; private final Moba _host; private final GameTeam _owner; @@ -54,7 +54,7 @@ public class MobaAI } else { - double dist = UtilMath.offsetSquared(_home, _target.getLocation()); + double dist = UtilMath.offsetSquared(_entity, _target); if (dist > TARGET_RANGE_SQUARED || UtilPlayer.isSpectator(_target)) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaEntityAIMethod.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaEntityAIMethod.java deleted file mode 100644 index 44c921af7..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaEntityAIMethod.java +++ /dev/null @@ -1,21 +0,0 @@ -package nautilus.game.arcade.game.games.moba.ai.goal; - -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilMath; -import org.bukkit.Location; -import org.bukkit.entity.LivingEntity; - -public class MobaEntityAIMethod implements MobaAIMethod -{ - - @Override - public boolean updateMovement(LivingEntity entity, Location goal, float speed) - { - if (UtilMath.offsetSquared(entity.getLocation(), goal) < 4) - { - return false; - } - - return UtilEnt.CreatureMoveFast(entity, goal, speed); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java index b995f0cd8..35ec8f8e4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java @@ -48,7 +48,7 @@ public abstract class MobaBoss implements Listener @EventHandler public void updateMovement(UpdateEvent event) { - if (event.getType() != UpdateType.TICK || _entity == null || !_host.IsLive()) + if (event.getType() != UpdateType.FASTEST || _entity == null || !_host.IsLive()) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index ca472d25f..e3f1ed077 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -13,6 +13,7 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.ai.MobaAI; +import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; import nautilus.game.arcade.game.games.moba.ai.goal.MobaDirectAIMethod; import nautilus.game.arcade.game.games.moba.boss.MobaBoss; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; @@ -33,6 +34,7 @@ public class WitherBoss extends MobaBoss private static final int INITIAL_HEALTH = 1750; private static final int FIRST_TOWER_HEALTH_REDUCTION = 100; private static final int SECOND_TOWER_HEALTH_REDUCTION = 250; + private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); private GameTeam _team; private MobaAI _ai; @@ -69,7 +71,7 @@ public class WitherBoss extends MobaBoss { if (_ai == null) { - _ai = new MobaAI(_host, _team, _entity, _location, new MobaDirectAIMethod()); + _ai = new MobaAI(_host, _team, _entity, _location, AI_METHOD); } return _ai; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java index 5b70ace78..b13e7d433 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java @@ -13,11 +13,12 @@ public class Minion private final LivingEntity _entity; + private Location _target; private int _targetIndex; - public Minion(Location spawn, Class clazz, int targetIndex) + public Minion(Location spawn, Class clazz) { - _targetIndex = targetIndex; + _target = spawn; LivingEntity entity = spawn.getWorld().spawn(spawn, clazz); _entity = entity; @@ -46,6 +47,19 @@ public class Minion return _entity; } + public void setTarget(Location location) + { + // Keep the Y constant + location.setY(_target.getY()); + + _target = location; + } + + public Location getTarget() + { + return _target; + } + public void setTargetIndex(int index) { _targetIndex = index; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index bc533eeed..3f61d7b9a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.minion; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -7,9 +8,9 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; -import nautilus.game.arcade.game.games.moba.ai.goal.MobaEntityAIMethod; +import nautilus.game.arcade.game.games.moba.ai.goal.MobaDirectAIMethod; +import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.util.MobaConstants; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; @@ -29,7 +30,7 @@ public class MinionWave implements Listener { private static final int MAX_MINIONS_PER_WAVE = 6; - private static final MobaAIMethod AI_METHOD = new MobaEntityAIMethod(); + private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); private final Moba _host; private final MinionManager _minionManager; @@ -70,7 +71,7 @@ public class MinionWave implements Listener { _host.CreatureAllowOverride = true; - Minion minion = new Minion(_path.get(0), _clazz, 1); + Minion minion = new Minion(_path.get(0), _clazz); minion.getEntity().setMetadata(MobaConstants.TEAM_METADATA, new FixedMetadataValue(_host.getArcadeManager().getPlugin(), _owner.GetName())); @@ -93,7 +94,11 @@ public class MinionWave implements Listener { LivingEntity entity = minion.getEntity(); - if (!AI_METHOD.updateMovement(entity, _path.get(minion.getTargetIndex()), 0.9F)) + if (targetTower(minion)) + { + + } + else if (!AI_METHOD.updateMovement(entity, minion.getTarget(), 0.1F)) { int newTarget = minion.getTargetIndex() + 1; @@ -116,6 +121,38 @@ public class MinionWave implements Listener } } + private boolean targetTower(Minion minion) + { + for (Tower tower : _host.getTowerManager().getTowers()) + { + if (tower.isDead() || tower.getOwner().equals(_owner)) + { + continue; + } + + double distSquared = UtilMath.offsetSquared(minion.getEntity(), tower.getCrystal()); + + if (distSquared < 3) + { + return true; + } + else if (distSquared > Tower.TARGET_RANGE_SQUARED) + { + continue; + } + + minion.setTarget(tower.getCrystal().getLocation()); + return true; + } + + return false; + } + + private void targetWither(Minion minion) + { + + } + @EventHandler(priority = EventPriority.HIGHEST) public void damage(CustomDamageEvent event) { @@ -129,7 +166,7 @@ public class MinionWave implements Listener Player damager = event.GetDamagerPlayer(true); GameTeam team = _host.GetTeam(damager); - if (team != null && !_owner.equals(team)) + if (team != null && _owner.equals(team)) { event.SetCancelled("Same Team Minion"); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java index 8cd08ee95..0d5f125c0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java @@ -59,20 +59,13 @@ public class PrepareSelection implements Listener, IPacketHandler for (GameTeam team : _host.GetTeamList()) { - if (team.GetColor() == ChatColor.RED) - { - spawnRoleUI(team, "PINK"); - } - else - { - spawnRoleUI(team, "PURPLE"); - } + spawnRoleUI(team); } } - private void spawnRoleUI(GameTeam team, String dataKey) + private void spawnRoleUI(GameTeam team) { - Map spawns = _host.getLocationStartsWith("KIT " + dataKey); + Map spawns = _host.getLocationStartsWith("KIT " + team.GetName().toUpperCase()); Location average = UtilAlg.getAverageLocation(team.GetSpawns()); Player[] players = team.GetPlayers(true).toArray(new Player[0]); @@ -108,11 +101,11 @@ public class PrepareSelection implements Listener, IPacketHandler }, _host.GetPlayers(true).size() * _host.TickPerTeleport + 10); } - private void spawnKitUI(Player player, String dataKey) + private void spawnKitUI(Player player) { AtomicInteger i = new AtomicInteger(); GameTeam team = _host.GetTeam(player); - List spawns = _host.WorldData.GetDataLocs(dataKey); + Map spawns = _host.getLocationStartsWith("KIT " + team.GetName().toUpperCase()); Location average = UtilAlg.getAverageLocation(team.GetSpawns()); MobaPlayer mobaPlayer = _host.getMobaData(player); @@ -123,7 +116,7 @@ public class PrepareSelection implements Listener, IPacketHandler UtilServer.runSyncLater(() -> { - for (Location location : spawns) + for (Location location : spawns.values()) { location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, average))); @@ -167,8 +160,7 @@ public class PrepareSelection implements Listener, IPacketHandler private void removePodiums() { - _host.WorldData.GetDataLocs("PINK").forEach(location -> location.getBlock().setType(Material.AIR)); - _host.WorldData.GetDataLocs("PURPLE").forEach(location -> location.getBlock().setType(Material.AIR)); + _host.getLocationStartsWith("KIT").forEach((key, location) -> location.getBlock().setType(Material.AIR)); } // Listen for those packety clicks @@ -211,11 +203,11 @@ public class PrepareSelection implements Listener, IPacketHandler if (team.GetColor() == ChatColor.RED) { - spawnKitUI(player, "PINK"); + spawnKitUI(player); } else { - spawnKitUI(player, "PURPLE"); + spawnKitUI(player); } displayKitInformation(player, role); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index 6350670f0..c244dba1c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -188,24 +188,25 @@ public class MobaShop implements Listener owned.removeIf(previousItem -> getCategory(previousItem) == category); } - // The respawn event needs to be called here so that effects like "Total Health Increase" will work straight away, instead of after the next respawn, - if (item.getEffects() != null) - { - // Prevents infinite speed - player.setWalkSpeed(0.2F); - player.setMaxHealth(20); - - PlayerGameRespawnEvent fakeEvent = new PlayerGameRespawnEvent(null, player); - - for (MobaItemEffect effect : item.getEffects()) - { - effect.onRespawn(fakeEvent); - } - } - player.sendMessage(F.main("Game", "Purchased " + F.greenElem(item.getItem().getItemMeta().getDisplayName()) + ".")); _host.getGoldManager().removeGold(player, item.getCost()); owned.add(item); + + // The respawn event needs to be called here so that effects like "Total Health Increase" will work straight away, instead of after the next respawn, + // Prevents infinite speed + player.setWalkSpeed(0.2F); + player.setMaxHealth(20); + + PlayerGameRespawnEvent fakeEvent = new PlayerGameRespawnEvent(null, player); + + for (MobaItem ownedItem : owned) + { + if (ownedItem.getEffects() != null) + { + ownedItem.getEffects().forEach(effect -> effect.onRespawn(fakeEvent)); + } + } + _host.GetKit(player).ApplyKit(player); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index 98c72e1ab..fb5a02f31 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -61,7 +61,7 @@ public class TowerManager implements Listener Location location = entry.getValue(); String[] components = key.split(" "); - if (components.length < 4) + if (components.length < 3) { continue; } @@ -271,4 +271,9 @@ public class TowerManager implements Listener return false; } + + public List getTowers() + { + return _towers; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java index 8c0dfb62e..3dab8cbf2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java @@ -11,7 +11,7 @@ public class MobaConstants // Location Constants public static final String MINION_PATH_START = "WHITE"; public static final String MINION_PATH = "BROWN"; - public static final String SHOP = "LIGHT_GRAY"; + public static final String SHOP = "SILVER"; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index 7d9e73918..94478a893 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -1,6 +1,10 @@ package nautilus.game.arcade.game.games.moba.util; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import org.bukkit.Bukkit; @@ -17,11 +21,6 @@ import java.util.Set; public class MobaUtil { - public static LivingEntity getBestEntityTarget(Moba host, GameTeam owner, LivingEntity source, Location location, int targetRange) - { - return getBestEntityTarget(host, owner, source, location, targetRange, true); - } - public static LivingEntity getBestEntityTarget(Moba host, GameTeam owner, LivingEntity source, Location location, int targetRange, boolean targetPlayersMore) { LivingEntity highest = null; @@ -38,7 +37,7 @@ public class MobaUtil } // Check for team entities - if (entity.hasMetadata(MobaConstants.TEAM_METADATA) && !entity.getMetadata(MobaConstants.TEAM_METADATA).get(0).asString().equals(owner.GetName())) + if (entity.hasMetadata(MobaConstants.TEAM_METADATA) && entity.getMetadata(MobaConstants.TEAM_METADATA).get(0).asString().equals(owner.GetName())) { continue; } @@ -89,7 +88,7 @@ public class MobaUtil // For each boundary for (Location boundary : boundaries) { - Location boundaryCloned = boundary.clone(); + Location checking = center.clone(); // Get direction from center to boundary Vector direction = UtilAlg.getTrajectory(center, boundary); // Store the checked distance @@ -98,21 +97,21 @@ public class MobaUtil double maxDist = UtilMath.offsetSquared(center, boundary); // Keep advancing the distance until it hits the boundary - while (checkedDist < maxDist) + while (checkedDist * checkedDist < maxDist) { // Advance the location - boundaryCloned.add(direction); + checking.add(direction); LivingEntity highest = null; double bestDist = 0; // Check for nearby entities - for (Entry entry : UtilEnt.getInRadius(boundaryCloned, 2).entrySet()) + for (Entry entry : UtilEnt.getInRadius(checking, 2).entrySet()) { LivingEntity entity = entry.getKey(); double dist = entry.getValue(); - if (source.equals(entity)) + if (source.equals(entity) || ignored.contains(entity)) { continue; } @@ -120,7 +119,7 @@ public class MobaUtil if (owner != null) { // Check for team entities - if (entity.hasMetadata(MobaConstants.TEAM_METADATA) && !entity.getMetadata(MobaConstants.TEAM_METADATA).get(0).asString().equals(owner.GetName())) + if (entity.hasMetadata(MobaConstants.TEAM_METADATA) && entity.getMetadata(MobaConstants.TEAM_METADATA).get(0).asString().equals(owner.GetName())) { continue; } @@ -144,6 +143,7 @@ public class MobaUtil if (highest != null) { + Bukkit.broadcastMessage("Found " + highest.getCustomName()); return highest; } From 6f48d0ee43b8f58adf18bccc3adb2a72fc8fa53d Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 23 May 2017 22:57:13 +0100 Subject: [PATCH 33/57] Improve the path finding ai --- .../game/arcade/game/games/moba/Moba.java | 5 ++ .../moba/ai/goal/MobaDirectAIMethod.java | 5 ++ .../game/games/moba/boss/BossManager.java | 11 +++ .../arcade/game/games/moba/boss/MobaBoss.java | 5 ++ .../games/moba/boss/wither/WitherBoss.java | 5 ++ .../game/games/moba/minion/MinionWave.java | 80 ++++++++++++++++--- 6 files changed, 100 insertions(+), 11 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 3e937efba..d0ada1134 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -567,4 +567,9 @@ public class Moba extends TeamGame { return _capturePoint; } + + public BossManager getBossManager() + { + return _boss; + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java index b8b95c59a..21e3f6ad3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java @@ -16,6 +16,11 @@ public class MobaDirectAIMethod implements MobaAIMethod { Location entityLocation = entity.getLocation(); + if (UtilMath.offsetSquared(entity.getLocation(), goal) < 6) + { + return false; + } + float entityYaw = entityLocation.getYaw(); // Speed is blocks per second diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java index 73ba34407..a7b1be645 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java @@ -9,7 +9,9 @@ import nautilus.game.arcade.world.WorldData; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; public class BossManager implements Listener @@ -69,4 +71,13 @@ public class BossManager implements Listener { return _teamBosses.get(team); } + + public List getBosses() + { + List bosses = new ArrayList<>(); + + bosses.addAll(_teamBosses.values()); + + return bosses; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java index 35ec8f8e4..a429a6f63 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java @@ -87,4 +87,9 @@ public abstract class MobaBoss implements Listener { return _entity; } + + public boolean isDead() + { + return _entity == null || _entity.isDead() || !_entity.isValid(); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index e3f1ed077..4d7cfe3f2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -173,4 +173,9 @@ public class WitherBoss extends MobaBoss { _disguise.setName(MobaUtil.getHealthBar(_entity, 40)); } + + public GameTeam getTeam() + { + return _team; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index 3f61d7b9a..130c279d0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -9,8 +9,11 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; import nautilus.game.arcade.game.games.moba.ai.goal.MobaDirectAIMethod; +import nautilus.game.arcade.game.games.moba.boss.MobaBoss; +import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.util.MobaConstants; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; @@ -29,7 +32,7 @@ import java.util.List; public class MinionWave implements Listener { - private static final int MAX_MINIONS_PER_WAVE = 6; + private static final int MAX_MINIONS_PER_WAVE = 1; private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); private final Moba _host; @@ -93,22 +96,44 @@ public class MinionWave implements Listener for (Minion minion : _minions) { LivingEntity entity = minion.getEntity(); + Location target = null; + Location towerTarget = targetTower(minion); + Location witherTarget = targetWither(minion); - if (targetTower(minion)) + if (towerTarget != null) { - + target = towerTarget; } - else if (!AI_METHOD.updateMovement(entity, minion.getTarget(), 0.1F)) + else if (witherTarget != null) + { + target = witherTarget; + } + + if (target != null) + { + minion.setTarget(target); + + // Too close + if (UtilMath.offsetSquared(entity.getLocation(), target) < 12) + { + Bukkit.broadcastMessage("Too close"); + continue; + } + } + + if (!AI_METHOD.updateMovement(entity, minion.getTarget(), 4F)) { int newTarget = minion.getTargetIndex() + 1; if (newTarget == _path.size()) { - // TODO target wither, probably... + Bukkit.broadcastMessage("Done"); continue; } minion.setTargetIndex(newTarget); + minion.setTarget(_path.get(newTarget)); + Bukkit.broadcastMessage("Advance target " + newTarget); } } @@ -121,7 +146,7 @@ public class MinionWave implements Listener } } - private boolean targetTower(Minion minion) + private Location targetTower(Minion minion) { for (Tower tower : _host.getTowerManager().getTowers()) { @@ -130,27 +155,60 @@ public class MinionWave implements Listener continue; } + Location location = tower.getCrystal().getLocation(); double distSquared = UtilMath.offsetSquared(minion.getEntity(), tower.getCrystal()); if (distSquared < 3) { - return true; + return location; } else if (distSquared > Tower.TARGET_RANGE_SQUARED) { continue; } - minion.setTarget(tower.getCrystal().getLocation()); - return true; + return location; } - return false; + return null; } - private void targetWither(Minion minion) + private Location targetWither(Minion minion) { + for (MobaBoss boss : _host.getBossManager().getBosses()) + { + if (boss.isDead()) + { + continue; + } + if (boss instanceof WitherBoss) + { + WitherBoss witherBoss = (WitherBoss) boss; + + if (witherBoss.getTeam().equals(_owner)) + { + continue; + } + } + + Location location = boss.getEntity().getLocation(); + double distSquared = UtilMath.offsetSquared(minion.getEntity(), boss.getEntity()); + + if (distSquared < 3) + { + return location; + } + else if (distSquared > Tower.TARGET_RANGE_SQUARED) + { + continue; + } + + minion.setTarget(boss.getEntity().getLocation()); + return location; + } + + return null; } @EventHandler(priority = EventPriority.HIGHEST) From a6c1e6c892989eb40b653c48b025e1cdd19c2122 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 24 May 2017 18:27:10 +0100 Subject: [PATCH 34/57] Make minions target each other --- .../games/moba/boss/wither/WitherBoss.java | 12 +- .../game/games/moba/minion/MinionManager.java | 5 + .../game/games/moba/minion/MinionWave.java | 161 +++++++++++++++++- .../moba/structure/tower/TowerManager.java | 2 +- 4 files changed, 172 insertions(+), 8 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index 4d7cfe3f2..5e82dc48b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -100,18 +100,22 @@ public class WitherBoss extends MobaBoss event.SetCancelled("Wither Boss"); - if (event.GetDamagerPlayer(true) == null || event.GetCause() == DamageCause.FIRE || event.GetCause() == DamageCause.FIRE_TICK) + if (event.GetCause() == DamageCause.FIRE || event.GetCause() == DamageCause.FIRE_TICK) { return; } LivingEntity damagee = event.GetDamageeEntity(); Player damager = event.GetDamagerPlayer(true); - GameTeam team = _host.GetTeam(damager); - if (_team.equals(team)) + if (damager != null) { - return; + GameTeam team = _host.GetTeam(damager); + + if (team == null || _team.equals(team)) + { + return; + } } double newHealth = damagee.getHealth() - event.GetDamage(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java index 525b2946d..6253b9ef9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -105,6 +105,11 @@ public class MinionManager implements Listener _waves.remove(wave); } + public Set getWaves() + { + return _waves; + } + /** * This method fills the {@link #_path} with the organised list of locations that the minions must follow.
*

diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index 130c279d0..bc89371f3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.minion; +import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; import mineplex.core.updater.UpdateType; @@ -22,6 +23,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.scheduler.BukkitRunnable; @@ -33,6 +35,10 @@ public class MinionWave implements Listener { private static final int MAX_MINIONS_PER_WAVE = 1; + private static final int TOO_CLOSE_SQUARED = 12; + private static final int MINION_TOO_CLOSE_SQUARED = 4; + private static final int DAMAGE_RANGE_SQUARED = 15; + private static final int DAMAGE_AMOUNT = 4; private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); private final Moba _host; @@ -67,7 +73,7 @@ public class MinionWave implements Listener cancel(); } } - }, 0, 20); + }, 20, 20); } private boolean spawn() @@ -98,12 +104,28 @@ public class MinionWave implements Listener LivingEntity entity = minion.getEntity(); Location target = null; Location towerTarget = targetTower(minion); + Minion minionTarget = targetMinion(minion); Location witherTarget = targetWither(minion); + // Priority -> Tower -> Minion -> Wither + if (towerTarget != null) { target = towerTarget; } + else if (minionTarget != null) + { + target = minionTarget.getEntity().getLocation(); + minion.setTarget(target); + + // Too close + if (UtilMath.offsetSquared(entity.getLocation(), target) < MINION_TOO_CLOSE_SQUARED) + { + Bukkit.broadcastMessage("Attack"); + _host.getArcadeManager().GetDamage().NewDamageEvent(minion.getEntity(), minionTarget.getEntity(), null, DamageCause.CUSTOM, DAMAGE_AMOUNT, false, false, false, UtilEnt.getName(minion.getEntity()), "Minion"); + continue; + } + } else if (witherTarget != null) { target = witherTarget; @@ -114,7 +136,7 @@ public class MinionWave implements Listener minion.setTarget(target); // Too close - if (UtilMath.offsetSquared(entity.getLocation(), target) < 12) + if (UtilMath.offsetSquared(entity.getLocation(), target) < TOO_CLOSE_SQUARED) { Bukkit.broadcastMessage("Too close"); continue; @@ -146,6 +168,36 @@ public class MinionWave implements Listener } } + private Minion targetMinion(Minion minion) + { + for (MinionWave wave : _minionManager.getWaves()) + { + // Same team + if (wave.getOwner().equals(_owner)) + { + continue; + } + + for (Minion otherMinion : wave.getMinions()) + { + double distSquared = UtilMath.offsetSquared(minion.getEntity(), otherMinion.getEntity()); + + if (distSquared < 3) + { + return otherMinion; + } + else if (distSquared > Tower.TARGET_RANGE_SQUARED) + { + continue; + } + + return otherMinion; + } + } + + return null; + } + private Location targetTower(Minion minion) { for (Tower tower : _host.getTowerManager().getTowers()) @@ -204,13 +256,106 @@ public class MinionWave implements Listener continue; } - minion.setTarget(boss.getEntity().getLocation()); return location; } return null; } + @EventHandler + public void damageMinions(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + for (Minion minion : _minions) + { + for (MinionWave wave : _minionManager.getWaves()) + { + // Same team + if (wave.getOwner().equals(_owner)) + { + continue; + } + + for (Minion otherMinion : wave.getMinions()) + { + // Cannot damage, not close enough + if (UtilMath.offsetSquared(minion.getEntity(), otherMinion.getEntity()) > DAMAGE_RANGE_SQUARED) + { + continue; + } + + + } + } + } + + for (Minion minion : _minions) + { + for (Tower tower : _host.getTowerManager().getTowers()) + { + // Cannot damage, not close enough + if (!_host.getTowerManager().canDamage(tower, _owner) || UtilMath.offsetSquared(minion.getEntity(), tower.getCrystal()) > DAMAGE_RANGE_SQUARED) + { + continue; + } + + tower.damage(DAMAGE_AMOUNT); + } + } + } + + @EventHandler + public void damageTower(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + for (Minion minion : _minions) + { + for (Tower tower : _host.getTowerManager().getTowers()) + { + // Cannot damage, not close enough + if (!_host.getTowerManager().canDamage(tower, _owner) || UtilMath.offsetSquared(minion.getEntity(), tower.getCrystal()) > DAMAGE_RANGE_SQUARED) + { + continue; + } + + tower.damage(DAMAGE_AMOUNT); + } + } + } + + @EventHandler + public void damageWither(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + List bosses = _host.getBossManager().getBosses(); + + for (Minion minion : _minions) + { + for (MobaBoss boss : bosses) + { + // Dead, not close enough + if (boss.isDead() || UtilMath.offsetSquared(minion.getEntity(), boss.getEntity()) > DAMAGE_RANGE_SQUARED) + { + continue; + } + + _host.getArcadeManager().GetDamage().NewDamageEvent(boss.getEntity(), minion.getEntity(), null, DamageCause.CUSTOM, DAMAGE_AMOUNT, false, false, false, UtilEnt.getName(minion.getEntity()), "Minion"); + } + } + } + @EventHandler(priority = EventPriority.HIGHEST) public void damage(CustomDamageEvent event) { @@ -267,6 +412,16 @@ public class MinionWave implements Listener } } + public List getMinions() + { + return _minions; + } + + public GameTeam getOwner() + { + return _owner; + } + private Minion getMinion(Entity entity) { for (Minion minion : _minions) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index fb5a02f31..7cd2e69f1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -240,7 +240,7 @@ public class TowerManager implements Listener // } // } - private boolean canDamage(Tower tower, GameTeam team) + public boolean canDamage(Tower tower, GameTeam team) { // Dead tower, nothing // Same team From 5c8a36b024f9475875ba5e942acf0ad1ca0b9217 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 26 May 2017 18:33:06 +0100 Subject: [PATCH 35/57] Sigils bug fixes --- .../game/arcade/game/games/moba/Moba.java | 2 +- .../arcade/game/games/moba/ai/MobaAI.java | 4 +- .../moba/ai/goal/MobaDirectAIMethod.java | 8 +- .../games/moba/kit/dana/SkillPulseHeal.java | 6 +- .../game/games/moba/kit/dana/SkillRally.java | 13 +++ .../game/games/moba/kit/devon/HeroDevon.java | 2 +- .../games/moba/kit/devon/SkillInfinity.java | 13 +-- .../games/moba/kit/devon/SkillTNTArrows.java | 88 ++++++++++--------- .../games/moba/kit/hattori/HeroHattori.java | 2 +- .../arcade/game/games/moba/minion/Minion.java | 15 ++++ .../game/games/moba/minion/MinionWave.java | 26 +++--- .../moba/prepare/PrepareInformation.java | 4 +- .../structure/point/CapturePointManager.java | 2 +- .../moba/structure/tower/TowerManager.java | 4 +- 14 files changed, 104 insertions(+), 85 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index d0ada1134..f409ea48f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -237,7 +237,7 @@ public class Moba extends TeamGame scoreboard.writeNewLine(); scoreboard.write(C.cYellowB + "Hero"); - scoreboard.write(mobaPlayer.getKit() == null ? "Unselected " : mobaPlayer.getKit().GetName() + " (" + mobaPlayer.getRole().getName() + ")"); + scoreboard.write((mobaPlayer == null || mobaPlayer.getKit() == null) ? "Unselected " : mobaPlayer.getKit().GetName() + " (" + mobaPlayer.getRole().getName() + ")"); scoreboard.writeNewLine(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java index e8f3d0a8a..712b31aa9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java @@ -65,13 +65,13 @@ public class MobaAI if (_target != null) { - _aiMethod.updateMovement(_entity, _target.getLocation(), 2.5F); + _aiMethod.updateMovement(_entity, _target.getLocation(), 5F); } } private void returnToHome() { - _aiMethod.updateMovement(_entity, _home, 3.5F); + _aiMethod.updateMovement(_entity, _home, 7F); } public void setEntity(LivingEntity entity) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java index 21e3f6ad3..1bfe6a4b1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java @@ -15,12 +15,6 @@ public class MobaDirectAIMethod implements MobaAIMethod public boolean updateMovement(LivingEntity entity, Location goal, float speed) { Location entityLocation = entity.getLocation(); - - if (UtilMath.offsetSquared(entity.getLocation(), goal) < 6) - { - return false; - } - float entityYaw = entityLocation.getYaw(); // Speed is blocks per second @@ -58,7 +52,7 @@ public class MobaDirectAIMethod implements MobaAIMethod // If reached the goal else if (UtilMath.offsetSquared(entityLocation, goal) < 0.5) { - entityLocation = goal; + return false; } else { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java index dd815d1df..5529afd8b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java @@ -89,7 +89,7 @@ public class SkillPulseHeal extends HeroSkill for (Player player : Manager.GetGame().GetPlayers(true)) { - if (!hasPerk(player) || UtilPlayer.isSpectator(player) || !Recharge.Instance.use(player, GetName(), 10000, false, false)) + if (!hasPerk(player) || UtilPlayer.isSpectator(player) || !Recharge.Instance.use(player, GetName(), 5000, false, false)) { continue; } @@ -106,14 +106,14 @@ public class SkillPulseHeal extends HeroSkill continue; } - entity.setHealth(Math.min(entity.getHealth() + 2, entity.getMaxHealth())); + entity.setHealth(Math.min(entity.getHealth() + 4, entity.getMaxHealth())); } displayPulse(location, false); } else { - player.setHealth(Math.min(player.getHealth() + 2, player.getMaxHealth())); + player.setHealth(Math.min(player.getHealth() + 4, player.getMaxHealth())); displayPulse(location, true); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java index ef24c59c9..35f94cafa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.dana; +import mineplex.core.common.events.EntityVelocityChangeEvent; import mineplex.core.common.util.*; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle.ParticleType; @@ -184,6 +185,18 @@ public class SkillRally extends HeroSkill } } + @EventHandler + public void velocityChange(EntityVelocityChangeEvent event) + { + for (RallyData data : _data) + { + if (!data.Landed && data.Owner.equals(event.getEntity())) + { + event.setCancelled(true); + } + } + } + private Pattern getPattern(GameTeam team) { return team.GetColor() == ChatColor.RED ? new Pattern(DyeColor.WHITE, PatternType.CROSS) : new Pattern(DyeColor.WHITE, PatternType.CIRCLE_MIDDLE); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java index f40f3db4e..656679db5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java @@ -36,6 +36,6 @@ public class HeroDevon extends HeroKit super(manager, "Devon", DESCRIPTION, PERKS, IN_HAND, MobaRole.HUNTER); setAmmo(AMMO, 3000); - setMaxAmmo(3); + setMaxAmmo(1); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java index 2f8d54223..76fe165fe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java @@ -2,7 +2,6 @@ package nautilus.game.arcade.game.games.moba.kit.devon; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilPlayer; import mineplex.core.updater.UpdateType; @@ -13,7 +12,6 @@ import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityShootBowEvent; @@ -104,15 +102,12 @@ public class SkillInfinity extends HeroSkill Player player = entry.getValue(); GameTeam team = Manager.GetGame().GetTeam(player); - for (LivingEntity nearby : UtilEnt.getInRadius(entity.getLocation(), 6).keySet()) + for (Player nearby : UtilPlayer.getInRadius(entity.getLocation(), 6).keySet()) { - if (nearby instanceof Player) + // If the target is on the same team + if (UtilPlayer.isSpectator(player) || team.equals(Manager.GetGame().GetTeam(nearby))) { - // If the target is on the same team - if (UtilPlayer.isSpectator(player) || team.equals(Manager.GetGame().GetTeam((Player) nearby))) - { - continue; - } + continue; } UtilAction.velocity(entity, UtilAlg.getTrajectory(entity.getLocation(), nearby.getLocation().add(0, 1.5, 0))); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java index 9dcd7895c..d94b7d9ec 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java @@ -6,29 +6,32 @@ 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.projectile.IThrown; -import mineplex.core.projectile.ProjectileUser; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.block.Block; import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.projectiles.ProjectileSource; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; -public class SkillTNTArrows extends HeroSkill implements IThrown +public class SkillTNTArrows extends HeroSkill { private static final String[] DESCRIPTION = { @@ -37,7 +40,8 @@ public class SkillTNTArrows extends HeroSkill implements IThrown }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.TNT); - private final Map _arrows = new HashMap<>(); + private final Map _playerArrows = new HashMap<>(); + private final Set _arrows = new HashSet<>(); public SkillTNTArrows(int slot) { @@ -56,7 +60,7 @@ public class SkillTNTArrows extends HeroSkill implements IThrown Player player = event.getPlayer(); - _arrows.put(player, 3); + _playerArrows.put(player, 3); player.getItemInHand().addEnchantment(UtilInv.getDullEnchantment(), 1); player.getItemInHand().setAmount(3); } @@ -71,87 +75,85 @@ public class SkillTNTArrows extends HeroSkill implements IThrown Player player = (Player) event.getEntity(); - if (!hasPerk(player) || !_arrows.containsKey(player)) + if (!hasPerk(player) || !_playerArrows.containsKey(player)) { return; } ItemStack itemStack = player.getInventory().getItem(getSlot()); - int arrows = _arrows.get(player); + int arrows = _playerArrows.get(player); if (arrows == 1) { - _arrows.remove(player); + _playerArrows.remove(player); useSkill(player); } else { arrows--; - _arrows.put(player, arrows); + _playerArrows.put(player, arrows); itemStack.setAmount(arrows); } - Manager.GetProjectile().AddThrow(event.getProjectile(), player, this, -1, true, true, true, false, 0); + _arrows.add((Arrow) event.getProjectile()); } @EventHandler - public void playerDeath(CombatDeathEvent event) + public void projectileHit(ProjectileHitEvent event) { - _arrows.remove(event.GetEvent().getEntity()); - } + ProjectileSource source = event.getEntity().getShooter(); - @EventHandler - public void playerQuit(PlayerQuitEvent event) - { - _arrows.remove(event.getPlayer()); - } + if (!(source instanceof Player)) + { + return; + } - @Override - public void Collide(LivingEntity target, Block block, ProjectileUser data) - { - LivingEntity thrower = data.getThrower(); - Location location = data.getThrown().getLocation(); + Player player = (Player) source; + Projectile projectile = event.getEntity(); + + if (!_arrows.contains(projectile)) + { + return; + } + + _arrows.remove(projectile); + + Location location = projectile.getLocation(); location.getWorld().playSound(location, Sound.EXPLODE, 1, 0.9F); UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, location, 0, 0, 0, 0.1F, 1, ViewDist.LONG); double damage = 10; // Scale damage with the damage on the player's bow - if (thrower instanceof Player) - { - Player throwerPlayer = (Player) thrower; - ItemStack itemStack = throwerPlayer.getInventory().getItem(0); + ItemStack itemStack = player.getInventory().getItem(0); - // Player has a bow - if (itemStack != null && itemStack.getType() == Material.BOW) - { - damage += damage * itemStack.getEnchantmentLevel(Enchantment.ARROW_DAMAGE) * 0.25; - } + // Player has a bow + if (itemStack != null && itemStack.getType() == Material.BOW) + { + damage += damage * itemStack.getEnchantmentLevel(Enchantment.ARROW_DAMAGE) * 0.25; } for (Entry entry : UtilEnt.getInRadius(location, 5).entrySet()) { - if (entry.getKey().equals(thrower)) + if (entry.getKey().equals(player)) { continue; } - Manager.GetDamage().NewDamageEvent(entry.getKey(), thrower, null, DamageCause.BLOCK_EXPLOSION, (entry.getValue() + 0.5) * damage, true, true, false, UtilEnt.getName(data.getThrower()), GetName()); + Manager.GetDamage().NewDamageEvent(entry.getKey(), player, null, DamageCause.BLOCK_EXPLOSION, (entry.getValue() + 0.5) * damage, true, true, false, UtilEnt.getName(player), GetName()); } - - data.getThrown().remove(); } - @Override - public void Idle(ProjectileUser data) + @EventHandler + public void playerDeath(CombatDeathEvent event) { - + _playerArrows.remove(event.GetEvent().getEntity()); } - @Override - public void Expire(ProjectileUser data) + @EventHandler + public void playerQuit(PlayerQuitEvent event) { - + _playerArrows.remove(event.getPlayer()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java index 539768e27..1cec7ac34 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java @@ -17,7 +17,7 @@ public class HeroHattori extends HeroKit }; private static final Perk[] PERKS = { - new PerkDoubleJump("Double Jump", 1, 1, true), + new PerkDoubleJump("Double Jump", 1, 1, true, 3000, true), new SkillSnowball(0), new SkillSword(1), new SkillNinjaDash(2), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java index b13e7d433..ac8678ca8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.moba.minion; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilTime; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; @@ -10,15 +11,19 @@ public class Minion { private static final int HEALTH = 10; + private static final int DAMAGE_RATE = 500; private final LivingEntity _entity; private Location _target; private int _targetIndex; + private long _lastDamage; + public Minion(Location spawn, Class clazz) { _target = spawn; + damage(); LivingEntity entity = spawn.getWorld().spawn(spawn, clazz); _entity = entity; @@ -69,4 +74,14 @@ public class Minion { return _targetIndex; } + + public boolean canDamage() + { + return UtilTime.elapsed(_lastDamage, DAMAGE_RATE); + } + + public void damage() + { + _lastDamage = System.currentTimeMillis(); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index bc89371f3..6d9e12fa3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.moba.minion; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -14,7 +15,6 @@ import nautilus.game.arcade.game.games.moba.boss.MobaBoss; import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.util.MobaConstants; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; @@ -34,11 +34,11 @@ import java.util.List; public class MinionWave implements Listener { - private static final int MAX_MINIONS_PER_WAVE = 1; - private static final int TOO_CLOSE_SQUARED = 12; - private static final int MINION_TOO_CLOSE_SQUARED = 4; - private static final int DAMAGE_RANGE_SQUARED = 15; - private static final int DAMAGE_AMOUNT = 4; + private static final int MAX_MINIONS_PER_WAVE = 6; + private static final int TOO_CLOSE_SQUARED = 9; + private static final int MINION_TOO_CLOSE_SQUARED = 16; + private static final int DAMAGE_RANGE_SQUARED = 16; + private static final double DAMAGE_AMOUNT = 0.2; private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); private final Moba _host; @@ -73,7 +73,7 @@ public class MinionWave implements Listener cancel(); } } - }, 20, 20); + }, 15, 15); } private boolean spawn() @@ -119,10 +119,10 @@ public class MinionWave implements Listener minion.setTarget(target); // Too close - if (UtilMath.offsetSquared(entity.getLocation(), target) < MINION_TOO_CLOSE_SQUARED) + if (UtilMath.offsetSquared(entity.getLocation(), target) < MINION_TOO_CLOSE_SQUARED && minionTarget.canDamage()) { - Bukkit.broadcastMessage("Attack"); - _host.getArcadeManager().GetDamage().NewDamageEvent(minion.getEntity(), minionTarget.getEntity(), null, DamageCause.CUSTOM, DAMAGE_AMOUNT, false, false, false, UtilEnt.getName(minion.getEntity()), "Minion"); + minionTarget.damage(); + _host.getArcadeManager().GetDamage().NewDamageEvent(minion.getEntity(), minionTarget.getEntity(), null, DamageCause.CUSTOM, DAMAGE_AMOUNT, false, true, false, UtilEnt.getName(minion.getEntity()), "Minion"); continue; } } @@ -138,7 +138,7 @@ public class MinionWave implements Listener // Too close if (UtilMath.offsetSquared(entity.getLocation(), target) < TOO_CLOSE_SQUARED) { - Bukkit.broadcastMessage("Too close"); + //Bukkit.broadcastMessage("Too close"); continue; } } @@ -149,13 +149,13 @@ public class MinionWave implements Listener if (newTarget == _path.size()) { - Bukkit.broadcastMessage("Done"); + //Bukkit.broadcastMessage("Done"); continue; } minion.setTargetIndex(newTarget); minion.setTarget(_path.get(newTarget)); - Bukkit.broadcastMessage("Advance target " + newTarget); + //Bukkit.broadcastMessage("Advance target " + newTarget); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java index 94e9347e3..559fdd4dd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java @@ -21,7 +21,7 @@ import java.util.concurrent.TimeUnit; public class PrepareInformation implements Listener { - private static final long MESSAGE_TIME = TimeUnit.SECONDS.toMillis(5); + private static final long MESSAGE_TIME = TimeUnit.SECONDS.toMillis(3); private static final int MESSAGE_TIME_TICKS = (int) (MESSAGE_TIME / 50D + 5); private final Moba _host; @@ -46,7 +46,7 @@ public class PrepareInformation implements Listener } // Modify the prepare time - _host.PrepareTime = longestDescription * 1000 + 1000; + _host.PrepareTime = longestDescription * MESSAGE_TIME + 1000; UtilServer.RegisterEvents(this); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java index 70fe02415..8534f1b32 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java @@ -46,7 +46,7 @@ public class CapturePointManager implements Listener @EventHandler public void update(UpdateEvent event) { - if (event.getType() != UpdateType.SEC) + if (event.getType() != UpdateType.SEC || !_host.IsLive()) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index 7cd2e69f1..92ff670ac 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -31,8 +31,8 @@ import java.util.Map.Entry; public class TowerManager implements Listener { - private static final int FIRST_TOWER_HEALTH = 250; - private static final int SECOND_TOWER_HEALTH = 500; + private static final int FIRST_TOWER_HEALTH = 500; + private static final int SECOND_TOWER_HEALTH = 1000; private final Moba _host; From 36733e9918087be57ed30d29ec80e1b5d3b238a1 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 26 May 2017 18:37:35 +0100 Subject: [PATCH 36/57] Fix gametype imports --- .../src/mineplex/core/game/GameDisplay.java | 2 ++ .../src/nautilus/game/arcade/GameType.java | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index 159124422..405178375 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -102,6 +102,8 @@ public enum GameDisplay StrikeGames("Strike Games", Material.DIAMOND_LEGGINGS, (byte) 0, GameCategory.SURVIVAL, 66, false), + AlienInvasion("Alien Invasion", Material.ENDER_STONE, (byte) 0, GameCategory.EVENT, 69, false), + MOBA("Heroes of the Craft", Material.SKULL_ITEM, (byte)1, GameCategory.CLASSICS, 70, true), Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999, false), 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 d24483811..ac4f37774 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -1,14 +1,11 @@ package nautilus.game.arcade; -import nautilus.game.arcade.game.games.moba.Moba; -import nautilus.game.arcade.game.games.smash.SuperSmashTraining; -import org.bukkit.Material; - import mineplex.core.common.MinecraftVersion; import mineplex.core.common.Pair; import mineplex.core.game.GameCategory; import mineplex.core.game.GameDisplay; import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.alieninvasion.AlienInvasion; import nautilus.game.arcade.game.games.baconbrawl.BaconBrawl; import nautilus.game.arcade.game.games.barbarians.Barbarians; import nautilus.game.arcade.game.games.basketball.Basketball; @@ -65,6 +62,7 @@ import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; import nautilus.game.arcade.game.games.minestrike.Minestrike; import nautilus.game.arcade.game.games.minestrike.modes.SuperPaintstrike; import nautilus.game.arcade.game.games.mineware.BawkBawkBattles; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.monsterleague.MonsterLeague; import nautilus.game.arcade.game.games.monstermaze.MonsterMaze; import nautilus.game.arcade.game.games.oldmineware.OldMineWare; @@ -93,6 +91,7 @@ import nautilus.game.arcade.game.games.skywars.modes.SkySmash; import nautilus.game.arcade.game.games.skywars.modes.UHCSkywars; import nautilus.game.arcade.game.games.smash.SoloSuperSmash; import nautilus.game.arcade.game.games.smash.SuperSmashDominate; +import nautilus.game.arcade.game.games.smash.SuperSmashTraining; import nautilus.game.arcade.game.games.smash.TeamSuperSmash; import nautilus.game.arcade.game.games.smash.modes.RandomKitSSM; import nautilus.game.arcade.game.games.snake.Snake; @@ -124,6 +123,7 @@ import nautilus.game.arcade.game.games.valentines.Valentines; import nautilus.game.arcade.game.games.wither.WitherGame; import nautilus.game.arcade.game.games.wizards.Wizards; import nautilus.game.arcade.game.games.zombiesurvival.ZombieSurvival; +import org.bukkit.Material; public enum GameType { @@ -230,6 +230,8 @@ public enum GameType Valentines(Valentines.class, GameDisplay.Valentines), + AlienInvasion(AlienInvasion.class, GameDisplay.AlienInvasion), + MOBA(Moba.class, GameDisplay.MOBA), Event(EventGame.class, GameDisplay.Event, new GameType[]{ From b9ad85dd1ec0b1807b9366e7aa92139c2ebbfcb0 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 27 May 2017 18:19:14 +0100 Subject: [PATCH 37/57] Pumpkin King boss --- .../arcade/game/games/moba/ai/MobaAI.java | 2 +- .../games/moba/boss/pumpkin/PumpkinBoss.java | 78 +++++++++++++++++++ .../moba/boss/pumpkin/PumpkinBossAI.java | 22 ++++++ 3 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBossAI.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java index 712b31aa9..199273682 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java @@ -84,7 +84,7 @@ public class MobaAI return _target; } - private String getBoundaryKey() + public String getBoundaryKey() { return _owner.GetColor() == ChatColor.RED ? "ORANGE" : "LIGHT_BLUE"; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java new file mode 100644 index 000000000..42ae0099c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java @@ -0,0 +1,78 @@ +package nautilus.game.arcade.game.games.moba.boss.pumpkin; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilVariant; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.ai.MobaAI; +import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; +import nautilus.game.arcade.game.games.moba.ai.goal.MobaDirectAIMethod; +import nautilus.game.arcade.game.games.moba.boss.MobaBoss; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Skeleton; +import org.bukkit.event.EventHandler; + +import java.util.concurrent.TimeUnit; + +public class PumpkinBoss extends MobaBoss +{ + + private static final int SPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(10); + private static final int RESPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(5); + private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); + + private MobaAI _ai; + + public PumpkinBoss(Moba host, Location location) + { + super(host, location, RESPAWN_TIME); + } + + @Override + public void setup() + { + // Override this so that the entity isn't spawned as soon as the game starts. + UtilServer.RegisterEvents(this); + } + + @Override + public LivingEntity spawnEntity() + { + Skeleton skeleton = UtilVariant.spawnWitherSkeleton(_location); + + skeleton.setCustomName(C.cDRedB + "Pumpkin King"); + skeleton.setCustomNameVisible(true); + + skeleton.getWorld().strikeLightningEffect(skeleton.getLocation()); + + UtilTextMiddle.display(C.cDRedB + "The Pumpkin King", "Has Awoken!", 10, 40, 10); + _host.Announce("The Pumpkin King Has Awoken!", false); + + return skeleton; + } + + @Override + public MobaAI getAi() + { + if (_ai == null) + { + _ai = new PumpkinBossAI(_host, _entity, _location, AI_METHOD); + } + + return _ai; + } + + @EventHandler + public void updateSpawn(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC || !_host.IsLive() || !UtilTime.elapsed(_host.GetStateTime(), SPAWN_TIME)) + { + return; + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBossAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBossAI.java new file mode 100644 index 000000000..6237de968 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBossAI.java @@ -0,0 +1,22 @@ +package nautilus.game.arcade.game.games.moba.boss.pumpkin; + +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.ai.MobaAI; +import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; + +public class PumpkinBossAI extends MobaAI +{ + + public PumpkinBossAI(Moba host, LivingEntity entity, Location home, MobaAIMethod aiMethod) + { + super(host, null, entity, home, aiMethod); + } + + @Override + public String getBoundaryKey() + { + return "GRAY"; + } +} From 9e9bfe79de1da9d511415e492e7b6faf80c2f0df Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 28 May 2017 16:27:54 +0100 Subject: [PATCH 38/57] Pumpkin king boss --- .../arcade/game/games/moba/MobaPlayer.java | 11 ----------- .../arcade/game/games/moba/ai/MobaAI.java | 2 +- .../moba/ai/goal/MobaDirectAIMethod.java | 2 +- .../game/games/moba/boss/BossManager.java | 8 ++++++++ .../arcade/game/games/moba/boss/MobaBoss.java | 4 ++++ .../games/moba/boss/pumpkin/PumpkinBoss.java | 14 +++++++++++--- .../game/games/moba/gold/GoldManager.java | 12 ------------ .../arcade/game/games/moba/minion/Minion.java | 15 --------------- .../game/games/moba/minion/MinionWave.java | 19 ++++++++++--------- .../games/moba/structure/tower/Tower.java | 2 +- .../moba/structure/tower/TowerManager.java | 6 +++++- 11 files changed, 41 insertions(+), 54 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java index a085b8eaa..29d7083ed 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaPlayer.java @@ -9,7 +9,6 @@ public class MobaPlayer private final Player _player; private MobaRole _role; private HeroKit _kit; - private int _gold; public MobaPlayer(Player player) { @@ -40,14 +39,4 @@ public class MobaPlayer { return _kit; } - - public void setGold(int gold) - { - _gold = gold; - } - - public int getGold() - { - return _gold; - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java index 199273682..16482e005 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java @@ -13,7 +13,7 @@ import org.bukkit.entity.LivingEntity; public class MobaAI { - private static final int TARGET_RANGE = 11; + private static final int TARGET_RANGE = 15; private static final int TARGET_RANGE_SQUARED = TARGET_RANGE * TARGET_RANGE; private final Moba _host; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java index 1bfe6a4b1..4ceb43e6b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java @@ -50,7 +50,7 @@ public class MobaDirectAIMethod implements MobaAIMethod entityLocation.setYaw(entityYaw); } // If reached the goal - else if (UtilMath.offsetSquared(entityLocation, goal) < 0.5) + else if (UtilMath.offsetSquared(entityLocation, goal) < 4) { return false; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java index a7b1be645..156271af5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java @@ -4,6 +4,7 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.boss.pumpkin.PumpkinBoss; import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.world.WorldData; import org.bukkit.event.EventHandler; @@ -20,6 +21,7 @@ public class BossManager implements Listener private final Moba _host; private Map _teamBosses; + private PumpkinBoss _pumpkinBoss; public BossManager(Moba host) { @@ -42,6 +44,10 @@ public class BossManager implements Listener _teamBosses.put(team, boss); } + // Pumpkin King + _pumpkinBoss = new PumpkinBoss(_host, worldData.GetDataLocs("BLACK").get(0)); + _pumpkinBoss.setup(); + _host.CreatureAllowOverride = false; } @@ -65,6 +71,7 @@ public class BossManager implements Listener } _teamBosses.forEach((team, witherBoss) -> witherBoss.cleanup()); + _pumpkinBoss.cleanup(); } public WitherBoss getWitherBoss(GameTeam team) @@ -77,6 +84,7 @@ public class BossManager implements Listener List bosses = new ArrayList<>(); bosses.addAll(_teamBosses.values()); + bosses.add(_pumpkinBoss); return bosses; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java index a429a6f63..2335509ca 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java @@ -6,6 +6,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.ai.MobaAI; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.event.EventHandler; @@ -59,8 +60,11 @@ public abstract class MobaBoss implements Listener @EventHandler public void entityDeath(EntityDeathEvent event) { + Bukkit.broadcastMessage(event.getEventName()); + if (_entity != null && _entity.equals(event.getEntity())) { + Bukkit.broadcastMessage(""); _entity = null; _lastDeath = System.currentTimeMillis(); getAi().setEntity(null); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java index 42ae0099c..84038e2f7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java @@ -22,11 +22,12 @@ import java.util.concurrent.TimeUnit; public class PumpkinBoss extends MobaBoss { - private static final int SPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(10); + private static final int SPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(1); private static final int RESPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(5); private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); private MobaAI _ai; + private boolean _initialSpawn; public PumpkinBoss(Moba host, Location location) { @@ -43,6 +44,8 @@ public class PumpkinBoss extends MobaBoss @Override public LivingEntity spawnEntity() { + _host.CreatureAllowOverride = true; + Skeleton skeleton = UtilVariant.spawnWitherSkeleton(_location); skeleton.setCustomName(C.cDRedB + "Pumpkin King"); @@ -51,7 +54,9 @@ public class PumpkinBoss extends MobaBoss skeleton.getWorld().strikeLightningEffect(skeleton.getLocation()); UtilTextMiddle.display(C.cDRedB + "The Pumpkin King", "Has Awoken!", 10, 40, 10); - _host.Announce("The Pumpkin King Has Awoken!", false); + _host.Announce(C.cRedB + "The Pumpkin King Has Awoken!", false); + + _host.CreatureAllowOverride = false; return skeleton; } @@ -70,9 +75,12 @@ public class PumpkinBoss extends MobaBoss @EventHandler public void updateSpawn(UpdateEvent event) { - if (event.getType() != UpdateType.SEC || !_host.IsLive() || !UtilTime.elapsed(_host.GetStateTime(), SPAWN_TIME)) + if (event.getType() != UpdateType.SEC || !_host.IsLive() || _initialSpawn || !UtilTime.elapsed(_host.GetStateTime(), SPAWN_TIME)) { return; } + + _initialSpawn = true; + spawnEntity(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java index e4fedc4a0..7cf95af29 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java @@ -132,16 +132,4 @@ public class GoldManager implements Listener return _playerGold.get(player) >= amount; } - /** - * Returns a map binding the player to the amount of gold they currently have. - * - * @return An unmodifiable version of the internal map used. If you want to edit the player's gold consider using the other methods within this class. - */ - public Map getPlayerGoldMap() - { - return Collections.unmodifiableMap(_playerGold); - } - - - } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java index ac8678ca8..b13e7d433 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java @@ -1,7 +1,6 @@ package nautilus.game.arcade.game.games.moba.minion; import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilTime; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; @@ -11,19 +10,15 @@ public class Minion { private static final int HEALTH = 10; - private static final int DAMAGE_RATE = 500; private final LivingEntity _entity; private Location _target; private int _targetIndex; - private long _lastDamage; - public Minion(Location spawn, Class clazz) { _target = spawn; - damage(); LivingEntity entity = spawn.getWorld().spawn(spawn, clazz); _entity = entity; @@ -74,14 +69,4 @@ public class Minion { return _targetIndex; } - - public boolean canDamage() - { - return UtilTime.elapsed(_lastDamage, DAMAGE_RATE); - } - - public void damage() - { - _lastDamage = System.currentTimeMillis(); - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index 6d9e12fa3..07b9106e3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -117,14 +117,6 @@ public class MinionWave implements Listener { target = minionTarget.getEntity().getLocation(); minion.setTarget(target); - - // Too close - if (UtilMath.offsetSquared(entity.getLocation(), target) < MINION_TOO_CLOSE_SQUARED && minionTarget.canDamage()) - { - minionTarget.damage(); - _host.getArcadeManager().GetDamage().NewDamageEvent(minion.getEntity(), minionTarget.getEntity(), null, DamageCause.CUSTOM, DAMAGE_AMOUNT, false, true, false, UtilEnt.getName(minion.getEntity()), "Minion"); - continue; - } } else if (witherTarget != null) { @@ -288,7 +280,7 @@ public class MinionWave implements Listener continue; } - + _host.getArcadeManager().GetDamage().NewDamageEvent(otherMinion.getEntity(), minion.getEntity(), null, DamageCause.CUSTOM, DAMAGE_AMOUNT, false, true, false, UtilEnt.getName(minion.getEntity()), "Minion"); } } } @@ -393,6 +385,15 @@ public class MinionWave implements Listener } } + @EventHandler + public void suffocation(CustomDamageEvent event) + { + if (isMinion(event.GetDamageeEntity()) && event.GetCause() == DamageCause.SUFFOCATION) + { + event.SetCancelled("Minion Suffocation"); + } + } + @EventHandler(priority = EventPriority.HIGHEST) public void entityDeath(EntityDeathEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index 83cddf9d0..5d50cc6a0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -88,7 +88,7 @@ public class Tower } else { - double dist = UtilMath.offsetSquared(_location, _target.getLocation()); + double dist = UtilMath.offsetSquared(_crystal.getLocation(), _target.getEyeLocation()); if (dist > TARGET_RANGE_SQUARED || UtilPlayer.isSpectator(_target) || _target.isDead() || !_target.isValid()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index 92ff670ac..9dab1ca0d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -162,8 +162,12 @@ public class TowerManager implements Listener { player = (Player) source; + Location entityLocation = event.getEntity().getLocation(); + Location playerLocation = player.getLocation(); + playerLocation.setY(entityLocation.getY()); + // TODO TEMP - if (UtilMath.offsetSquared(player.getLocation(), event.getEntity().getLocation()) > Tower.TARGET_RANGE_SQUARED) + if (UtilMath.offsetSquared(playerLocation, entityLocation) > Tower.TARGET_RANGE_SQUARED) { return; } From c3a80ed0cb0cba23a26229070f4e0a540fbfd6f4 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 29 May 2017 12:40:18 +0100 Subject: [PATCH 39/57] Fix pumpkin king's death not being logged properly --- .../game/arcade/game/games/moba/Moba.java | 5 + .../arcade/game/games/moba/ai/MobaAI.java | 10 +- .../moba/ai/goal/MobaDirectAIMethod.java | 2 +- .../arcade/game/games/moba/boss/MobaBoss.java | 10 +- .../games/moba/boss/pumpkin/PumpkinBoss.java | 196 +++++++++++++++++- .../moba/boss/pumpkin/PumpkinBossAI.java | 5 +- .../games/moba/boss/wither/WitherBoss.java | 4 +- .../arcade/game/games/moba/minion/Minion.java | 2 + .../games/moba/structure/tower/Tower.java | 2 +- .../arcade/game/games/moba/util/MobaUtil.java | 5 +- 10 files changed, 224 insertions(+), 17 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index f409ea48f..e5bedf6cb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -285,6 +285,11 @@ public class Moba extends TeamGame } scoreboard.writeNewLine(); + + scoreboard.write(C.cYellowB + "Time"); + scoreboard.write(UtilTime.MakeStr(System.currentTimeMillis() - GetStateTime())); + + scoreboard.writeNewLine(); } private void writeEnd(Player player, GameScoreboard scoreboard) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java index 16482e005..0bd0540ce 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java @@ -18,6 +18,8 @@ public class MobaAI private final Moba _host; private final GameTeam _owner; + private final float _speedTarget; + private final float _speedHome; private LivingEntity _entity; private LivingEntity _target; @@ -25,10 +27,12 @@ public class MobaAI private MobaAIMethod _aiMethod; - public MobaAI(Moba host, GameTeam owner, LivingEntity entity, Location home, MobaAIMethod aiMethod) + public MobaAI(Moba host, GameTeam owner, LivingEntity entity, Location home, float speedTarget, float speedHome, MobaAIMethod aiMethod) { _host = host; _owner = owner; + _speedTarget = speedTarget; + _speedHome = speedHome; _entity = entity; _home = home; _aiMethod = aiMethod; @@ -65,13 +69,13 @@ public class MobaAI if (_target != null) { - _aiMethod.updateMovement(_entity, _target.getLocation(), 5F); + _aiMethod.updateMovement(_entity, _target.getLocation(), _speedTarget); } } private void returnToHome() { - _aiMethod.updateMovement(_entity, _home, 7F); + _aiMethod.updateMovement(_entity, _home, _speedTarget); } public void setEntity(LivingEntity entity) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java index 4ceb43e6b..69ebbaa4c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java @@ -9,7 +9,7 @@ import org.bukkit.util.Vector; public class MobaDirectAIMethod implements MobaAIMethod { - private static final float YAW_SNAP_LIMIT = 20F; + private static final float YAW_SNAP_LIMIT = 30F; @Override public boolean updateMovement(LivingEntity entity, Location goal, float speed) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java index 2335509ca..4158ed179 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java @@ -4,9 +4,9 @@ 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.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.ai.MobaAI; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.event.EventHandler; @@ -60,11 +60,10 @@ public abstract class MobaBoss implements Listener @EventHandler public void entityDeath(EntityDeathEvent event) { - Bukkit.broadcastMessage(event.getEventName()); - if (_entity != null && _entity.equals(event.getEntity())) { - Bukkit.broadcastMessage(""); + event.getDrops().clear(); + event.setDroppedExp(0); _entity = null; _lastDeath = System.currentTimeMillis(); getAi().setEntity(null); @@ -74,13 +73,14 @@ public abstract class MobaBoss implements Listener @EventHandler public void updateRespawn(UpdateEvent event) { - if (event.getType() != UpdateType.SEC || _lastDeath == -1 || UtilTime.elapsed(_lastDeath, _respawnTime)) + if (event.getType() != UpdateType.SEC || _lastDeath == -1 || !UtilTime.elapsed(_lastDeath, _respawnTime)) { return; } _lastDeath = -1; _entity = spawnEntity(); + getAi().setEntity(_entity); } public abstract LivingEntity spawnEntity(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java index 84038e2f7..741b0b15b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java @@ -1,37 +1,82 @@ package nautilus.game.arcade.game.games.moba.boss.pumpkin; import mineplex.core.common.util.C; +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.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.utils.UtilVariant; +import mineplex.minecraft.game.core.condition.ConditionFactory; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.ai.MobaAI; import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; import nautilus.game.arcade.game.games.moba.ai.goal.MobaDirectAIMethod; import nautilus.game.arcade.game.games.moba.boss.MobaBoss; +import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment; +import org.bukkit.Bukkit; 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.craftbukkit.v1_8_R3.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; 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.DamageCause; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.inventory.ItemStack; +import java.util.HashSet; +import java.util.Map.Entry; +import java.util.Set; import java.util.concurrent.TimeUnit; public class PumpkinBoss extends MobaBoss { private static final int SPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(1); - private static final int RESPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(5); + private static final int RESPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(1); private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); + private static final ItemStack HELMET = new ItemStack(Material.PUMPKIN); + private static final ItemStack IN_HAND = new ItemStack(Material.STONE_SWORD); + private static final String DAMAGE_REASON = "Pumpkin King"; + private static final String CONDITION_REASON = DAMAGE_REASON + " Buff"; + private static final int CONDITION_LENGTH = (int) TimeUnit.MINUTES.toSeconds(3); + private static final int DAMAGE_RADIUS = 3; + private static final int DAMAGE_RANGE = 4; + private static final int DAMAGE_DIRECT = 10; + private static final int DAMAGE_DIRECT_RADIUS_SQUARED = 9; + private static final Material[] BLOCKS = { + Material.OBSIDIAN, + Material.NETHERRACK, + Material.NETHER_BRICK + }; private MobaAI _ai; private boolean _initialSpawn; + private final Set _changed; public PumpkinBoss(Moba host, Location location) { super(host, location, RESPAWN_TIME); + + _changed = new HashSet<>(); } @Override @@ -50,12 +95,36 @@ public class PumpkinBoss extends MobaBoss skeleton.setCustomName(C.cDRedB + "Pumpkin King"); skeleton.setCustomNameVisible(true); + skeleton.getEquipment().setHelmet(HELMET); + skeleton.getEquipment().setItemInHand(IN_HAND); + + UtilEnt.vegetate(skeleton); + UtilEnt.setFakeHead(skeleton, true); skeleton.getWorld().strikeLightningEffect(skeleton.getLocation()); UtilTextMiddle.display(C.cDRedB + "The Pumpkin King", "Has Awoken!", 10, 40, 10); _host.Announce(C.cRedB + "The Pumpkin King Has Awoken!", false); + for (Player player : Bukkit.getOnlinePlayers()) + { + player.playSound(player.getLocation(), Sound.WITHER_SPAWN, 1, 0.4F); + } + + for (Entry entry : UtilBlock.getInRadius(skeleton.getLocation(), 20).entrySet()) + { + Block block = entry.getKey(); + double setChance = entry.getValue(); + + if (block.getType() == Material.AIR || block.getRelative(BlockFace.UP).getType() != Material.AIR || Math.random() > setChance) + { + continue; + } + + _host.getArcadeManager().GetBlockRestore().add(block, BLOCKS[UtilMath.r(BLOCKS.length)].getId(), (byte) 0, Integer.MAX_VALUE); + _changed.add(block); + } + _host.CreatureAllowOverride = false; return skeleton; @@ -81,6 +150,129 @@ public class PumpkinBoss extends MobaBoss } _initialSpawn = true; - spawnEntity(); + _entity = spawnEntity(); + } + + @Override + public void cleanup() + { + super.cleanup(); + + for (Block block : _changed) + { + _host.getArcadeManager().GetBlockRestore().restore(block); + } + } + + @Override + @EventHandler + public void entityDeath(EntityDeathEvent event) + { + if (_entity == null || !event.getEntity().equals(_entity)) + { + return; + } + + Player player = _entity.getKiller(); + + if (player == null) + { + return; + } + + super.entityDeath(event); + + GameTeam team = _host.GetTeam(player); + + if (team == null) + { + return; + } + + giveBuffs(team); + + String base = C.mBody + "killed the " + C.cDRedB + "Pumpkin King"; + _host.Announce(team.GetFormattedName() + " " + base + C.mBody + "! They have been given buffs!", false); + UtilTextMiddle.display(team.GetFormattedName(), base, 10, 40, 10); + + for (Block block : _changed) + { + _host.getArcadeManager().GetBlockRestore().restore(block); + } + + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, event.getEntity().getEyeLocation(), 1, 1, 1, 0.1F, 3, ViewDist.LONG); + } + + @EventHandler + public void entityDamage(CustomDamageEvent event) + { + if (!event.GetDamageeEntity().equals(_entity) || event.GetCause() != DamageCause.SUFFOCATION) + { + return; + } + + event.SetCancelled("Pumpkin King Suffocation"); + } + + @EventHandler + public void updateDamage(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST || _entity == null) + { + return; + } + + if (_ai.getTarget() != null && !UtilPlayer.isSpectator(_ai.getTarget()) && UtilMath.offsetSquared(_entity, _ai.getTarget()) < DAMAGE_DIRECT_RADIUS_SQUARED) + { + _host.getArcadeManager().GetDamage().NewDamageEvent(_ai.getTarget(), _entity, null, DamageCause.CUSTOM, DAMAGE_DIRECT, true, true, false, UtilEnt.getName(_entity), DAMAGE_REASON); + + // Send a fake hit packet + // Magic number 0 means swing item/attack + PacketPlayOutAnimation packet = new PacketPlayOutAnimation(((CraftLivingEntity) _entity).getHandle(), 0); + + for (Player player : Bukkit.getOnlinePlayers()) + { + UtilPlayer.sendPacket(player, packet); + } + } + + for (LivingEntity entity : UtilEnt.getInRadius(_entity.getLocation(), DAMAGE_RADIUS).keySet()) + { + if (_entity.equals(entity)) + { + continue; + } + + _host.getArcadeManager().GetDamage().NewDamageEvent(entity, _entity, null, DamageCause.CUSTOM, DAMAGE_RANGE, false, true, false, UtilEnt.getName(entity), DAMAGE_REASON); + UtilAction.velocity(entity, UtilAlg.getTrajectory(_entity, entity).setY(1)); + UtilParticle.PlayParticleToAll(ParticleType.FLAME, entity.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 5, ViewDist.LONG); + } + } + + private void giveBuffs(GameTeam team) + { + ConditionFactory factory = _host.getArcadeManager().GetCondition().Factory(); + + for (Player player : team.GetPlayers(true)) + { + factory.Regen(CONDITION_REASON, player, null, CONDITION_LENGTH, 2, false, true, false); + factory.Strength(CONDITION_REASON, player, null, CONDITION_LENGTH, 1, false, true, false); + UtilParticle.PlayParticleToAll(ParticleType.LAVA, player.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 10, ViewDist.LONG); + player.playSound(player.getLocation(), Sound.PORTAL_TRAVEL, 1, 0.5F); + + // Magic number 4 means helmet + PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(player.getEntityId(), 4, CraftItemStack.asNMSCopy(HELMET)); + + for (Player other : Bukkit.getOnlinePlayers()) + { + // Don't send wearer their own data + if (other.equals(player)) + { + continue; + } + + UtilPlayer.sendPacket(other, packet); + } + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBossAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBossAI.java index 6237de968..66cc68a83 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBossAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBossAI.java @@ -9,9 +9,12 @@ import org.bukkit.entity.LivingEntity; public class PumpkinBossAI extends MobaAI { + private static final float SPEED_TARGET = 12F; + private static final float SPEED_HOME = 16F; + public PumpkinBossAI(Moba host, LivingEntity entity, Location home, MobaAIMethod aiMethod) { - super(host, null, entity, home, aiMethod); + super(host, null, entity, home, SPEED_TARGET, SPEED_HOME, aiMethod); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index 5e82dc48b..9d0ce78dd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -31,6 +31,8 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; public class WitherBoss extends MobaBoss { + private static final float SPEED_TARGET = 7F; + private static final float SPEED_HOME = 9F; private static final int INITIAL_HEALTH = 1750; private static final int FIRST_TOWER_HEALTH_REDUCTION = 100; private static final int SECOND_TOWER_HEALTH_REDUCTION = 250; @@ -71,7 +73,7 @@ public class WitherBoss extends MobaBoss { if (_ai == null) { - _ai = new MobaAI(_host, _team, _entity, _location, AI_METHOD); + _ai = new MobaAI(_host, _team, _entity, _location, SPEED_TARGET, SPEED_HOME, AI_METHOD); } return _ai; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java index b13e7d433..decc4b408 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java @@ -10,6 +10,7 @@ public class Minion { private static final int HEALTH = 10; + private static final float HIT_BOX = 2F; private final LivingEntity _entity; @@ -32,6 +33,7 @@ public class Minion UtilEnt.vegetate(entity); UtilEnt.silence(entity, true); + UtilEnt.setBoundingBox(entity, HIT_BOX, HIT_BOX); entity.setCustomNameVisible(true); updateDisplay(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index 5d50cc6a0..6d84e1a05 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -82,7 +82,7 @@ public class Tower { if (_target == null) { - LivingEntity target = MobaUtil.getBestEntityTarget(_host, _team, _stand, _location, TARGET_RANGE, false); + LivingEntity target = MobaUtil.getBestEntityTarget(_host, _team, _stand, _crystal.getLocation(), TARGET_RANGE, false); _target = target; setLaserTarget(target); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index 94478a893..bb1daef50 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -45,7 +45,7 @@ public class MobaUtil // Make players more desirable if (entity instanceof Player) { - if (owner.equals(host.GetTeam((Player) entity)) || UtilPlayer.isSpectator(entity)) + if (owner.equals(host.GetTeam((Player) entity))) { continue; } @@ -127,7 +127,7 @@ public class MobaUtil // Check for same team players if (entity instanceof Player) { - if (owner.equals(host.GetTeam((Player) entity)) || UtilPlayer.isSpectator(entity)) + if (owner.equals(host.GetTeam((Player) entity))) { continue; } @@ -143,7 +143,6 @@ public class MobaUtil if (highest != null) { - Bukkit.broadcastMessage("Found " + highest.getCustomName()); return highest; } From 0edd2c89478d6f8f9d42d691327a155ac5c1734e Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 31 May 2017 13:05:06 +0100 Subject: [PATCH 40/57] Feedback from testing --- .../game/arcade/game/games/moba/Moba.java | 112 ++++++++++-- .../arcade/game/games/moba/ai/MobaAI.java | 2 +- .../moba/ai/goal/MobaDirectAIMethod.java | 29 +-- .../game/games/moba/boss/BossManager.java | 8 + .../games/moba/boss/pumpkin/PumpkinBoss.java | 125 ++++++++++--- .../games/moba/boss/wither/WitherBoss.java | 40 +++-- .../boss/wither/WitherSkullProjectile.java | 5 +- .../games/moba/fountain/MobaFountain.java | 2 +- .../games/moba/general/ArrowKBManager.java | 41 +++++ ...ageManager.java => MobaDamageManager.java} | 20 ++- .../game/games/moba/gold/GoldManager.java | 44 +++++ .../arcade/game/games/moba/kit/HeroSkill.java | 57 +++++- .../moba/kit/anath/SkillFireProjectile.java | 5 +- .../games/moba/kit/anath/SkillMeteor.java | 2 + .../moba/kit/bob/SkillBuildPainting.java | 2 + .../game/games/moba/kit/bob/SkillPaint.java | 5 +- .../game/games/moba/kit/common/DashSkill.java | 3 +- .../game/games/moba/kit/dana/SkillRally.java | 9 + .../game/games/moba/kit/devon/HeroDevon.java | 3 +- .../game/games/moba/kit/devon/SkillBoost.java | 3 +- .../games/moba/kit/devon/SkillInfinity.java | 7 + .../games/moba/kit/devon/SkillTNTArrows.java | 4 + .../moba/kit/hattori/SkillNinjaBlade.java | 8 +- .../games/moba/kit/hattori/SkillSnowball.java | 5 +- .../arcade/game/games/moba/minion/Minion.java | 6 +- .../game/games/moba/minion/MinionWave.java | 25 ++- .../moba/prepare/PrepareInformation.java | 2 +- .../games/moba/prepare/PrepareManager.java | 9 +- .../moba/structure/point/CapturePoint.java | 84 +++++++-- .../structure/point/CapturePointManager.java | 54 +++++- .../games/moba/structure/tower/Tower.java | 48 ++++- .../moba/structure/tower/TowerManager.java | 120 +++++++++---- .../game/games/moba/util/MobaConstants.java | 1 + .../arcade/game/games/moba/util/MobaUtil.java | 57 +++--- .../game/modules/CustomScoreboardModule.java | 170 ++++++++++++++++-- 35 files changed, 898 insertions(+), 219 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/ArrowKBManager.java rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/{TeamDamageManager.java => MobaDamageManager.java} (78%) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index e5bedf6cb..286854643 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -1,7 +1,11 @@ package nautilus.game.arcade.game.games.moba; import mineplex.core.common.Rank; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; import mineplex.minecraft.game.core.combat.DeathMessageType; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; @@ -12,7 +16,8 @@ import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.moba.boss.BossManager; import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.game.games.moba.fountain.MobaFountain; -import nautilus.game.arcade.game.games.moba.general.TeamDamageManager; +import nautilus.game.arcade.game.games.moba.general.ArrowKBManager; +import nautilus.game.arcade.game.games.moba.general.MobaDamageManager; import nautilus.game.arcade.game.games.moba.gold.GoldManager; import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.kit.KitPlayer; @@ -33,6 +38,7 @@ import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.scoreboard.GameScoreboard; +import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.entity.Arrow; @@ -44,7 +50,13 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerQuitEvent; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.concurrent.TimeUnit; public class Moba extends TeamGame @@ -66,6 +78,7 @@ public class Moba extends TeamGame private final BossManager _boss; private final TowerManager _tower; private final CapturePointManager _capturePoint; + private final ArrowKBManager _arrowKb; public Moba(ArcadeManager manager) { @@ -88,13 +101,15 @@ public class Moba extends TeamGame HungerSet = 20; DamageFall = false; + manager.GetCreature().SetDisableCustomDrops(true); + // Instantiate managers // Global managers _shop = registerManager(new MobaShop(this)); _goldManager = registerManager(new GoldManager(this)); registerManager(new HPManager(this)); - registerManager(new TeamDamageManager(this)); + registerManager(new MobaDamageManager(this)); registerManager(new MobaFountain(this)); registerManager(new Recall(this)); @@ -112,6 +127,9 @@ public class Moba extends TeamGame // Minions registerManager(new MinionManager(this)); + // Arrow Knockback + _arrowKb = registerManager(new ArrowKBManager(this)); + new CompassModule() .setGiveCompass(true) .setGiveCompassToSpecs(true) @@ -176,6 +194,9 @@ public class Moba extends TeamGame return C.cYellow + " " + suffix + C.Reset; }) + .setUnderNameObjective(C.cRed + "❤") + .setUnderName((perspective, subject) -> + (int) (Math.ceil(subject.getHealth() / 2D))) .register(this); registerDebugCommand(new DebugCommand("kit", Rank.ADMIN) @@ -183,14 +204,14 @@ public class Moba extends TeamGame @Override public void Execute(Player caller, String[] args) { - String kit = ""; + StringBuilder builder = new StringBuilder(); for (String arg : args) { - kit += arg + " "; + builder.append(arg).append(" "); } - kit = kit.trim(); + String kit = builder.toString().trim(); for (Kit kits : _kits) { @@ -223,6 +244,8 @@ public class Moba extends TeamGame { locations.forEach(location -> location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, GetSpectatorLocation())))); } + + SpectatorSpawn = WorldData.GetCustomLocs("CENTER").get(0); } private void writePrepare(Player player, GameScoreboard scoreboard) @@ -259,21 +282,44 @@ public class Moba extends TeamGame private void writeLive(Player player, GameScoreboard scoreboard) { + GameTeam team = GetTeam(player); + boolean alive = IsAlive(player); + scoreboard.writeNewLine(); -// GameTeam team = GetTeam(player); -// boolean blueBottom = team == null || team.GetColor() == ChatColor.BLUE; -// -// // Tower Data -// List lines = new ArrayList<>(); -// GameTeam red = GetTeam(ChatColor.RED); -// GameTeam blue = GetTeam(ChatColor.AQUA); -// -// lines.add("♚"); + // Towers + GameTeam red = GetTeam(ChatColor.RED); + GameTeam blue = GetTeam(ChatColor.AQUA); + String redTitle; + String blueTitle; + + if (alive) + { + boolean playerRed = team.equals(red); + redTitle = playerRed ? "Your Team" : "Enemy Team"; + blueTitle = playerRed ? "Enemy Team" : "Your Team"; + } + else + { + redTitle = "Red Team"; + blueTitle = "Blue Team"; + } + + scoreboard.write(red.GetColor() + C.Bold + redTitle); + scoreboard.write("Base: " + _tower.getDisplayString(red) + _boss.getWitherDisplayString(red)); + scoreboard.write("Beacons: " + _capturePoint.getDisplayString(red)); + + scoreboard.writeNewLine(); + + scoreboard.write(blue.GetColor() + C.Bold + blueTitle); + scoreboard.write("Base: " + _tower.getDisplayString(blue) + _boss.getWitherDisplayString(blue)); + scoreboard.write("Beacons: " + _capturePoint.getDisplayString(blue)); + + scoreboard.writeNewLine(); // Gold - scoreboard.write(C.cGoldB + "Gold"); - if (IsAlive(player)) + scoreboard.write(C.cGoldB + "Your Gold"); + if (alive) { int gold = _goldManager.getGold(player); @@ -553,6 +599,31 @@ public class Moba extends TeamGame return players; } + public boolean isRoleFree(Player player, MobaRole role) + { + GameTeam team = GetTeam(player); + + if (team == null) + { + return false; + } + + for (MobaPlayer mobaPlayer : getTeamData(team)) + { + if (mobaPlayer.getRole() == role) + { + return false; + } + } + + return true; + } + + public CustomScoreboardModule getScoreboardModule() + { + return getModule(CustomScoreboardModule.class); + } + public MobaShop getShop() { return _shop; @@ -577,4 +648,9 @@ public class Moba extends TeamGame { return _boss; } + + public ArrowKBManager getArrowKbManager() + { + return _arrowKb; + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java index 0bd0540ce..59ba0cffa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java @@ -46,7 +46,7 @@ public class MobaAI return; } - if (_target == null) + if (_target == null || _target.isDead() || !_target.isValid()) { _target = MobaUtil.getBestEntityTarget(_host, _owner, _entity, _home, _host.WorldData.GetDataLocs(getBoundaryKey())); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java index 69ebbaa4c..45035f8c9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java @@ -9,13 +9,10 @@ import org.bukkit.util.Vector; public class MobaDirectAIMethod implements MobaAIMethod { - private static final float YAW_SNAP_LIMIT = 30F; - @Override public boolean updateMovement(LivingEntity entity, Location goal, float speed) { Location entityLocation = entity.getLocation(); - float entityYaw = entityLocation.getYaw(); // Speed is blocks per second float magnitude = speed / 20F; @@ -25,32 +22,10 @@ public class MobaDirectAIMethod implements MobaAIMethod // From the direction, get the yaw of this direction float directionYaw = UtilAlg.GetYaw(direction); + entityLocation.setYaw(directionYaw); - // Get the absolute yaw offset from the direction - // This can then be used to see how far the entity is - // looking away from the goal - float yawOffset = Math.abs(directionYaw - entityYaw); - - // If the entity is facing too far away from the goal to consider the - // "Head Snapping" of turning the entity too severe - if (yawOffset > YAW_SNAP_LIMIT) - { - // Facing too far right - if (entityYaw > directionYaw) - { - entityYaw -= YAW_SNAP_LIMIT; - } - // Facing too far left - else - { - entityYaw += YAW_SNAP_LIMIT; - } - - // Only alter the entity's yaw - entityLocation.setYaw(entityYaw); - } // If reached the goal - else if (UtilMath.offsetSquared(entityLocation, goal) < 4) + if (UtilMath.offsetSquared(entityLocation, goal) < 4) { return false; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java index 156271af5..f2a0ef23c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/BossManager.java @@ -6,6 +6,7 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.boss.pumpkin.PumpkinBoss; import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import nautilus.game.arcade.world.WorldData; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -74,6 +75,13 @@ public class BossManager implements Listener _pumpkinBoss.cleanup(); } + public String getWitherDisplayString(GameTeam team) + { + WitherBoss boss = getWitherBoss(team); + + return MobaUtil.getColour(boss.getHealthPercentage()) + "♚"; + } + public WitherBoss getWitherBoss(GameTeam team) { return _teamBosses.get(team); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java index 741b0b15b..08e913ece 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.moba.boss.pumpkin; 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; @@ -24,9 +25,11 @@ import nautilus.game.arcade.game.games.moba.ai.MobaAI; import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; import nautilus.game.arcade.game.games.moba.ai.goal.MobaDirectAIMethod; import nautilus.game.arcade.game.games.moba.boss.MobaBoss; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment; import org.bukkit.Bukkit; +import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -38,11 +41,14 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffectType; import java.util.HashSet; +import java.util.Iterator; import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -50,18 +56,20 @@ import java.util.concurrent.TimeUnit; public class PumpkinBoss extends MobaBoss { - private static final int SPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(1); - private static final int RESPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(1); + private static final int SPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(5); + private static final int RESPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(5); private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); private static final ItemStack HELMET = new ItemStack(Material.PUMPKIN); private static final ItemStack IN_HAND = new ItemStack(Material.STONE_SWORD); private static final String DAMAGE_REASON = "Pumpkin King"; private static final String CONDITION_REASON = DAMAGE_REASON + " Buff"; - private static final int CONDITION_LENGTH = (int) TimeUnit.MINUTES.toSeconds(3); - private static final int DAMAGE_RADIUS = 3; - private static final int DAMAGE_RANGE = 4; - private static final int DAMAGE_DIRECT = 10; + private static final int CONDITION_LENGTH = 60; + private static final double CONDITION_DAMAGE_FACTOR = 1.5; + private static final int DAMAGE_RADIUS = 2; + private static final int DAMAGE_RANGE = 3; + private static final int DAMAGE_DIRECT = 8; private static final int DAMAGE_DIRECT_RADIUS_SQUARED = 9; + private static final int HEALTH = 400; private static final Material[] BLOCKS = { Material.OBSIDIAN, Material.NETHERRACK, @@ -71,12 +79,14 @@ public class PumpkinBoss extends MobaBoss private MobaAI _ai; private boolean _initialSpawn; private final Set _changed; + private final Set _buffs; public PumpkinBoss(Moba host, Location location) { super(host, location, RESPAWN_TIME); _changed = new HashSet<>(); + _buffs = new HashSet<>(); } @Override @@ -97,6 +107,8 @@ public class PumpkinBoss extends MobaBoss skeleton.setCustomNameVisible(true); skeleton.getEquipment().setHelmet(HELMET); skeleton.getEquipment().setItemInHand(IN_HAND); + skeleton.setMaxHealth(HEALTH); + skeleton.setHealth(HEALTH); UtilEnt.vegetate(skeleton); UtilEnt.setFakeHead(skeleton, true); @@ -104,7 +116,7 @@ public class PumpkinBoss extends MobaBoss skeleton.getWorld().strikeLightningEffect(skeleton.getLocation()); UtilTextMiddle.display(C.cDRedB + "The Pumpkin King", "Has Awoken!", 10, 40, 10); - _host.Announce(C.cRedB + "The Pumpkin King Has Awoken!", false); + _host.Announce(F.main("Game", C.cRedB + "The Pumpkin King Has Awoken!"), false); for (Player player : Bukkit.getOnlinePlayers()) { @@ -191,27 +203,32 @@ public class PumpkinBoss extends MobaBoss giveBuffs(team); - String base = C.mBody + "killed the " + C.cDRedB + "Pumpkin King"; - _host.Announce(team.GetFormattedName() + " " + base + C.mBody + "! They have been given buffs!", false); - UtilTextMiddle.display(team.GetFormattedName(), base, 10, 40, 10); + _host.Announce(F.main("Game", team.GetFormattedName() + C.mBody + " killed the " + C.cDRedB + DAMAGE_REASON), false); + UtilTextMiddle.display("", team.GetFormattedName() + C.cWhite + " killed the " + C.cDRedB + DAMAGE_REASON, 10, 40, 10); for (Block block : _changed) { _host.getArcadeManager().GetBlockRestore().restore(block); } + event.getEntity().getWorld().playSound(event.getEntity().getLocation(), Sound.EXPLODE, 1, 0.2F); UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, event.getEntity().getEyeLocation(), 1, 1, 1, 0.1F, 3, ViewDist.LONG); } - @EventHandler + @EventHandler(priority = EventPriority.HIGHEST) public void entityDamage(CustomDamageEvent event) { - if (!event.GetDamageeEntity().equals(_entity) || event.GetCause() != DamageCause.SUFFOCATION) + if (!event.GetDamageeEntity().equals(_entity)) { return; } - event.SetCancelled("Pumpkin King Suffocation"); + updateDisplay(); + + if (event.GetCause() == DamageCause.SUFFOCATION) + { + event.SetCancelled("Pumpkin King Suffocation"); + } } @EventHandler @@ -224,7 +241,7 @@ public class PumpkinBoss extends MobaBoss if (_ai.getTarget() != null && !UtilPlayer.isSpectator(_ai.getTarget()) && UtilMath.offsetSquared(_entity, _ai.getTarget()) < DAMAGE_DIRECT_RADIUS_SQUARED) { - _host.getArcadeManager().GetDamage().NewDamageEvent(_ai.getTarget(), _entity, null, DamageCause.CUSTOM, DAMAGE_DIRECT, true, true, false, UtilEnt.getName(_entity), DAMAGE_REASON); + _host.getArcadeManager().GetDamage().NewDamageEvent(_ai.getTarget(), _entity, null, DamageCause.CUSTOM, DAMAGE_DIRECT, true, true, false, DAMAGE_REASON, DAMAGE_REASON); // Send a fake hit packet // Magic number 0 means swing item/attack @@ -243,36 +260,90 @@ public class PumpkinBoss extends MobaBoss continue; } - _host.getArcadeManager().GetDamage().NewDamageEvent(entity, _entity, null, DamageCause.CUSTOM, DAMAGE_RANGE, false, true, false, UtilEnt.getName(entity), DAMAGE_REASON); + _host.getArcadeManager().GetDamage().NewDamageEvent(entity, _entity, null, DamageCause.CUSTOM, DAMAGE_RANGE, false, true, false, DAMAGE_REASON, DAMAGE_REASON); UtilAction.velocity(entity, UtilAlg.getTrajectory(_entity, entity).setY(1)); UtilParticle.PlayParticleToAll(ParticleType.FLAME, entity.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 5, ViewDist.LONG); } } + private void updateDisplay() + { + _entity.setCustomName(MobaUtil.getHealthBar(_entity, 20)); + } + private void giveBuffs(GameTeam team) { ConditionFactory factory = _host.getArcadeManager().GetCondition().Factory(); for (Player player : team.GetPlayers(true)) { - factory.Regen(CONDITION_REASON, player, null, CONDITION_LENGTH, 2, false, true, false); - factory.Strength(CONDITION_REASON, player, null, CONDITION_LENGTH, 1, false, true, false); + factory.Regen(CONDITION_REASON, player, null, CONDITION_LENGTH, 1, false, true, false); UtilParticle.PlayParticleToAll(ParticleType.LAVA, player.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 10, ViewDist.LONG); player.playSound(player.getLocation(), Sound.PORTAL_TRAVEL, 1, 0.5F); + player.sendMessage(F.main("Game", "You feel the power of the Pumpkin King flow through you. Your damage and regeneration are increased!")); + _buffs.add(player); - // Magic number 4 means helmet - PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(player.getEntityId(), 4, CraftItemStack.asNMSCopy(HELMET)); + sendFakeHelmet(player); + } + } - for (Player other : Bukkit.getOnlinePlayers()) + @EventHandler + public void updateFakeHelmet(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOW) + { + return; + } + + Iterator iterator = _buffs.iterator(); + + while (iterator.hasNext()) + { + Player player = iterator.next(); + + if (!player.isOnline() || !player.hasPotionEffect(PotionEffectType.REGENERATION)) { - // Don't send wearer their own data - if (other.equals(player)) - { - continue; - } - - UtilPlayer.sendPacket(other, packet); + iterator.remove(); } + + sendFakeHelmet(player); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void damageIncrease(CustomDamageEvent event) + { + if (event.isCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + Player damager = event.GetDamagerPlayer(true); + + if (damager == null || !_buffs.contains(damager)) + { + return; + } + + UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, damagee.getLocation().add(0, 0.5, 0), 0.25F, 0.25F, 0.25F, 10, 1, ViewDist.NORMAL); + event.AddMod(CONDITION_REASON, CONDITION_DAMAGE_FACTOR); + } + + private void sendFakeHelmet(Player player) + { + // Magic number 4 means helmet + PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(player.getEntityId(), 4, CraftItemStack.asNMSCopy(HELMET)); + + for (Player other : Bukkit.getOnlinePlayers()) + { + // Don't send wearer their own data + if (other.equals(player)) + { + continue; + } + + UtilPlayer.sendPacket(other, packet); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index 9d0ce78dd..b70326896 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -1,11 +1,11 @@ package nautilus.game.arcade.game.games.moba.boss.wither; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; 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.UtilTextTop; -import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseWither; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -34,14 +34,12 @@ public class WitherBoss extends MobaBoss private static final float SPEED_TARGET = 7F; private static final float SPEED_HOME = 9F; private static final int INITIAL_HEALTH = 1750; - private static final int FIRST_TOWER_HEALTH_REDUCTION = 100; - private static final int SECOND_TOWER_HEALTH_REDUCTION = 250; private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); private GameTeam _team; private MobaAI _ai; - private DisguiseWither _disguise; + private boolean _damageable; public WitherBoss(Moba host, Location location, GameTeam team) { @@ -56,10 +54,13 @@ public class WitherBoss extends MobaBoss { ArmorStand stand = _location.getWorld().spawn(_location, ArmorStand.class); + // Reducing the wither's health to 10% gives a shield like effect. stand.setMaxHealth(INITIAL_HEALTH); - stand.setHealth(INITIAL_HEALTH); + stand.setHealth(INITIAL_HEALTH * 0.1); stand.setGravity(false); + UtilEnt.setBoundingBox(stand, 3, 5); + _disguise = new DisguiseWither(stand); _disguise.setName(_team.GetColor() + _team.GetName() + "\'s Wither"); _disguise.setCustomNameVisible(true); @@ -102,11 +103,18 @@ public class WitherBoss extends MobaBoss event.SetCancelled("Wither Boss"); + // Fire doesn't damage the wither if (event.GetCause() == DamageCause.FIRE || event.GetCause() == DamageCause.FIRE_TICK) { return; } + // If not damageable + if (!_damageable) + { + return; + } + LivingEntity damagee = event.GetDamageeEntity(); Player damager = event.GetDamagerPlayer(true); @@ -147,16 +155,13 @@ public class WitherBoss extends MobaBoss return; } - if (tower.isFirstTower()) + // Here we can remove the shield effect, as the wither is no longer invincible + if (!tower.isFirstTower()) { - _entity.setHealth(_entity.getHealth() - FIRST_TOWER_HEALTH_REDUCTION); + _damageable = true; + _entity.setHealth(INITIAL_HEALTH); + updateDisplay(); } - else - { - _entity.setHealth(_entity.getHealth() - SECOND_TOWER_HEALTH_REDUCTION); - } - - updateDisplay(); } @EventHandler @@ -167,14 +172,19 @@ public class WitherBoss extends MobaBoss return; } - double percent = _entity.getHealth() / _entity.getMaxHealth(); + double percent = getHealthPercentage(); for (Player player : _team.GetPlayers(true)) { - UtilTextTop.displayTextBar(player, percent, _team.GetColor() + "Your Wither"); + UtilTextTop.displayTextBar(player, percent, _team.GetColor() + "Your Wither"); } } + public double getHealthPercentage() + { + return _damageable ? (_entity.getHealth() / _entity.getMaxHealth()) : 1; + } + private void updateDisplay() { _disguise.setName(MobaUtil.getHealthBar(_entity, 40)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java index 787bfe95f..e62652fd3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java @@ -33,8 +33,9 @@ public class WitherSkullProjectile implements IThrown _manager = host.getArcadeManager(); _owner = owner; - WitherSkull skull = shooter.launchProjectile(WitherSkull.class); + WitherSkull skull = shooter.getWorld().spawn(shooter.getLocation().add(0, 2, 0), WitherSkull.class); + skull.setShooter(shooter); skull.setYield(0); skull.setVelocity(skull.getVelocity().add(UtilAlg.getTrajectory(shooter, target))); @@ -58,7 +59,7 @@ public class WitherSkullProjectile implements IThrown // Not team damage if (!_owner.equals(targetTeam)) { - _manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, DamageCause.CUSTOM, DAMAGE, true, true, false, UtilEnt.getName(data.getThrower()), "Wither Skull"); + _manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, DamageCause.CUSTOM, DAMAGE, true, true, false, "Wither Boss", "Wither Skull"); } Expire(data); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java index 0905cd1b8..05c8d22da 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/fountain/MobaFountain.java @@ -83,7 +83,7 @@ public class MobaFountain implements Listener } else { - _host.getArcadeManager().GetDamage().NewDamageEvent(player, null, null, DamageCause.CUSTOM, 6, false, true, true, "Fountain", "Fountain"); + _host.getArcadeManager().GetDamage().NewDamageEvent(player, null, null, DamageCause.CUSTOM, 10, false, true, true, "Fountain", "Fountain"); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/ArrowKBManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/ArrowKBManager.java new file mode 100644 index 000000000..4b4239bbd --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/ArrowKBManager.java @@ -0,0 +1,41 @@ +package nautilus.game.arcade.game.games.moba.general; + +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.metadata.FixedMetadataValue; + +public class ArrowKBManager implements Listener +{ + + private static final String ENTITY_METADATA = "KB"; + private final Moba _host; + + public ArrowKBManager(Moba host) + { + _host = host; + } + + @EventHandler + public void arrowDamage(CustomDamageEvent event) + { + Projectile projectile = event.GetProjectile(); + + if (projectile == null || projectile.getType() != EntityType.ARROW || projectile.hasMetadata(ENTITY_METADATA)) + { + return; + } + + event.SetKnockback(false); + } + + public void allowKnockback(Entity projectile) + { + projectile.setMetadata(ENTITY_METADATA, new FixedMetadataValue(_host.getArcadeManager().getPlugin(), true)); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/TeamDamageManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java similarity index 78% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/TeamDamageManager.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java index 78c6cb874..49a7e4c55 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/TeamDamageManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java @@ -1,5 +1,7 @@ package nautilus.game.arcade.game.games.moba.general; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.condition.Condition; import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent; @@ -10,12 +12,12 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -public class TeamDamageManager implements Listener +public class MobaDamageManager implements Listener { private final Moba _host; - public TeamDamageManager(Moba host) + public MobaDamageManager(Moba host) { _host = host; } @@ -43,6 +45,10 @@ public class TeamDamageManager implements Listener { event.SetCancelled("Team Damage"); } + else + { + _host.getScoreboardModule().refreshAsSubject(damagee); + } } @EventHandler @@ -73,4 +79,14 @@ public class TeamDamageManager implements Listener event.setCancelled(true); } + @EventHandler + public void updateDamageScoreboard(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + _host.getScoreboardModule().refresh(); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java index 7cf95af29..79bd7cdb9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.moba.gold; import mineplex.core.common.Rank; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -10,6 +11,9 @@ import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; +import nautilus.game.arcade.game.games.moba.structure.point.CapturePointCaptureEvent; +import nautilus.game.arcade.game.games.moba.structure.tower.TowerDestroyEvent; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -24,6 +28,10 @@ public class GoldManager implements Listener private static final int GOLD_PER_5 = 20; private static final int GOLD_PER_CAPTURE_5 = 5; + private static final int GOLD_PER_CAPTURE_INITIAL = 25; + private static final int GOLD_PER_FIRST_TOWER = 100; + private static final int GOLD_PER_SECOND_TOWER = 250; + private final Moba _host; @@ -112,14 +120,50 @@ public class GoldManager implements Listener } } + @EventHandler + public void towerDestroy(TowerDestroyEvent event) + { + for (Player player : _host.GetPlayers(true)) + { + // Don't give the gold to the owners + if (_host.GetTeam(player).equals(event.getTower().getOwner())) + { + continue; + } + + addGold(player, event.getTower().isFirstTower() ? GOLD_PER_FIRST_TOWER : GOLD_PER_SECOND_TOWER, "Destroying a tower"); + } + } + + @EventHandler + public void pointCapture(CapturePointCaptureEvent event) + { + GameTeam team = event.getPoint().getOwner(); + + for (Player player : team.GetPlayers(true)) + { + addGold(player, GOLD_PER_CAPTURE_INITIAL, "Capturing a beacon"); + } + } + public int getGold(Player player) { return _playerGold.get(player); } public void addGold(Player player, int amount) + { + addGold(player, amount, null); + } + + public void addGold(Player player, int amount, String reason) { _playerGold.put(player, _playerGold.get(player) + amount); + + if (amount > 20 && reason != null) + { + player.sendMessage(F.main("Game", C.cGold + "+" + amount + " gold (" + reason + ")" + C.cGray + ".")); + } } public void removeGold(Player player, int amount) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 97c682495..ca3ebd0ab 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -1,7 +1,12 @@ package nautilus.game.arcade.game.games.moba.kit; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -16,13 +21,18 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; public class HeroSkill extends Perk { @@ -31,7 +41,8 @@ public class HeroSkill extends Perk private ItemStack _cooldownItem; private final int _slot; private final ActionType _actionType; - private final boolean _sneakActivate; + private boolean _sneakActivate; + private boolean _dropItemActivate; protected HeroKit _kit; private long _cooldown; @@ -44,11 +55,6 @@ public class HeroSkill extends Perk } public HeroSkill(String name, String[] perkDesc, ItemStack itemStack, int slot, ActionType actionType) - { - this(name, perkDesc, itemStack, slot, actionType, false); - } - - public HeroSkill(String name, String[] perkDesc, ItemStack itemStack, int slot, ActionType actionType, boolean sneakActivate) { super(name, perkDesc); @@ -56,11 +62,20 @@ public class HeroSkill extends Perk _items.add(itemStack); _slot = slot; _actionType = actionType; - _sneakActivate = sneakActivate; prettifyItems(); } + public void setSneakActivate(boolean activate) + { + _sneakActivate = activate; + } + + public void setDropItemActivate(boolean activate) + { + _dropItemActivate = activate; + } + protected void setCooldown(long cooldown) { _cooldown = cooldown; @@ -149,6 +164,11 @@ public class HeroSkill extends Perk _lastSkill.remove(key); } + @EventHandler + public void interact(PlayerInteractEvent event) + { + } + protected boolean isSkillItem(PlayerInteractEvent event) { if (event.isCancelled()) @@ -209,6 +229,25 @@ public class HeroSkill extends Perk return false; } + @EventHandler + public void dropTrigger(PlayerDropItemEvent event) + { + Player player = event.getPlayer(); + + if (!_dropItemActivate || !hasPerk(player)) + { + return; + } + + // Call interact with a fake PlayerInteractEvent + PlayerInteractEvent interactEvent = new PlayerInteractEvent(event.getPlayer(), Action.RIGHT_CLICK_AIR, player.getInventory().getItem(_slot), null, null); + + // You actually need to setCancelled false here otherwise it remains cancelled by default when the clicked block is null, thanks Bukkit + interactEvent.setCancelled(false); + interact(interactEvent); + } + + public void useSkill(Player player) { _lastSkill.put(player.getUniqueId(), System.currentTimeMillis()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java index 0ac1d5c5e..c17176547 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.moba.kit.anath; import mineplex.core.common.util.UtilEvent.ActionType; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.Material; @@ -18,6 +19,7 @@ public class SkillFireProjectile extends HeroSkill "Fires an Ember at high speed in front of you.", "Any enemies it collides with take damage and are set on fire." }; + private static final int DAMAGE = 5; private static final ItemStack SKILL_ITEM = new ItemStack(Material.BLAZE_ROD); @@ -45,6 +47,7 @@ public class SkillFireProjectile extends HeroSkill Item item = player.getWorld().dropItem(player.getEyeLocation().add(direction), _kit.getAmmo()); item.setVelocity(direction); - Manager.GetFire().Add(item, player, 3, 0, 1, 5, MobaConstants.BASIC_ATTACK, false); + ((Moba) Manager.GetGame()).getTowerManager().addProjectile(player, item, DAMAGE); + Manager.GetFire().Add(item, player, 3, 0, 1, DAMAGE, MobaConstants.BASIC_ATTACK, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java index 5314786c3..73198fdfe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java @@ -42,8 +42,10 @@ public class SkillMeteor extends HeroSkill implements IThrown super("Meteor Shower", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); setCooldown(60000); + setDropItemActivate(true); } + @Override @EventHandler public void interact(PlayerInteractEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java index 63a42f160..59fda7a1e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java @@ -71,8 +71,10 @@ public class SkillBuildPainting extends HeroSkill implements IThrown super("The Joy Of Painting", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); setCooldown(60000); + setDropItemActivate(true); } + @Override @EventHandler public void interact(PlayerInteractEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillPaint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillPaint.java index df990d0dd..b5f8386bf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillPaint.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillPaint.java @@ -6,6 +6,7 @@ import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilMath; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Material; import org.bukkit.Sound; @@ -28,6 +29,7 @@ public class SkillPaint extends HeroSkill implements IThrown "Bob Ross" }; private static final byte[] COLOURS = { 14, 1, 4, 5, 3, 11, 0}; + private static final int DAMAGE = 2; private static final ItemStack SKILL_ITEM = new ItemStack(Material.DIAMOND_BARDING); @@ -55,6 +57,7 @@ public class SkillPaint extends HeroSkill implements IThrown Snowball snowball = player.launchProjectile(Snowball.class); + ((Moba) Manager.GetGame()).getTowerManager().addProjectile(player, snowball, DAMAGE); Manager.GetProjectile().AddThrow(snowball, player, this, -1, true, true, true, false, 0.5F); } @@ -67,7 +70,7 @@ public class SkillPaint extends HeroSkill implements IThrown if (target != null) { thrower.playSound(thrower.getLocation(), Sound.LAVA_POP, 1, 1.3F); - Manager.GetDamage().NewDamageEvent(target, thrower, (Projectile) data.getThrown(), DamageCause.PROJECTILE, 2, true, true, false, UtilEnt.getName(thrower), GetName()); + Manager.GetDamage().NewDamageEvent(target, thrower, (Projectile) data.getThrown(), DamageCause.PROJECTILE, DAMAGE, true, true, false, UtilEnt.getName(thrower), GetName()); } for (Block nearby : UtilBlock.getBlocksInRadius(data.getThrown().getLocation(), 2)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java index b3217cd23..6726e478c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java @@ -49,9 +49,10 @@ public class DashSkill extends HeroSkill public DashSkill(String name, String[] perkDesc, ItemStack itemStack, int slot) { - super(name, perkDesc, itemStack, slot, ActionType.ANY, true); + super(name, perkDesc, itemStack, slot, ActionType.ANY); _startTime = new HashMap<>(); + setSneakActivate(true); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java index 35f94cafa..05331f42d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java @@ -19,6 +19,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; @@ -44,8 +45,10 @@ public class SkillRally extends HeroSkill super("Rally", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); setCooldown(40000); + setDropItemActivate(true); } + @Override @EventHandler public void interact(PlayerInteractEvent event) { @@ -197,6 +200,12 @@ public class SkillRally extends HeroSkill } } + @EventHandler + public void playerDeath(PlayerDeathEvent event) + { + _data.removeIf(rallyData -> rallyData.Owner.equals(event.getEntity())); + } + private Pattern getPattern(GameTeam team) { return team.GetColor() == ChatColor.RED ? new Pattern(DyeColor.WHITE, PatternType.CROSS) : new Pattern(DyeColor.WHITE, PatternType.CIRCLE_MIDDLE); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java index 656679db5..f80d6c6e2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java @@ -8,6 +8,7 @@ import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.kit.common.SkillBow; import nautilus.game.arcade.kit.Perk; import org.bukkit.Material; +import org.bukkit.event.EventHandler; import org.bukkit.inventory.ItemStack; public class HeroDevon extends HeroKit @@ -36,6 +37,6 @@ public class HeroDevon extends HeroKit super(manager, "Devon", DESCRIPTION, PERKS, IN_HAND, MobaRole.HUNTER); setAmmo(AMMO, 3000); - setMaxAmmo(1); + setMaxAmmo(3); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillBoost.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillBoost.java index edfb3e95f..eda785059 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillBoost.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillBoost.java @@ -20,9 +20,10 @@ public class SkillBoost extends HeroSkill public SkillBoost(int slot) { - super("Hunters Boost", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY, true); + super("Hunters Boost", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); setCooldown(10000); + setSneakActivate(true); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java index 76fe165fe..77bc3c242 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java @@ -8,11 +8,13 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ProjectileHitEvent; @@ -42,8 +44,10 @@ public class SkillInfinity extends HeroSkill super("Infinity", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); setCooldown(60000); + setDropItemActivate(true); } + @Override @EventHandler public void interact(PlayerInteractEvent event) { @@ -85,6 +89,9 @@ public class SkillInfinity extends HeroSkill return; } + Moba moba = (Moba) Manager.GetGame(); + + moba.getArrowKbManager().allowKnockback(event.getProjectile()); _arrows.put(event.getProjectile(), player); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java index d94b7d9ec..b7c658777 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java @@ -7,6 +7,7 @@ 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.combat.event.CombatDeathEvent; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Location; import org.bukkit.Material; @@ -95,6 +96,9 @@ public class SkillTNTArrows extends HeroSkill itemStack.setAmount(arrows); } + Moba moba = (Moba) Manager.GetGame(); + + moba.getArrowKbManager().allowKnockback(event.getProjectile()); _arrows.add((Arrow) event.getProjectile()); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java index 9e8546707..638a243a0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java @@ -32,6 +32,7 @@ public class SkillNinjaBlade extends HeroSkill private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); private static final ItemStack ACTIVE_ITEM = new ItemBuilder(Material.DIAMOND_SWORD) .setTitle(C.cGreenB + "NINJA BLADE") + .setUnbreakable(true) .build(); private Set _active = new HashSet<>(); @@ -41,8 +42,10 @@ public class SkillNinjaBlade extends HeroSkill super("Ninja Blade", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); setCooldown(60000); + setDropItemActivate(true); } + @Override @EventHandler public void interact(PlayerInteractEvent event) { @@ -54,6 +57,7 @@ public class SkillNinjaBlade extends HeroSkill Player player = event.getPlayer(); player.getInventory().setItem(getSlot(), ACTIVE_ITEM); + player.getInventory().setHeldItemSlot(getSlot()); _active.add(player.getUniqueId()); useActiveSkill(() -> _active.remove(player.getUniqueId()), player, 7000); @@ -71,7 +75,9 @@ public class SkillNinjaBlade extends HeroSkill return; } - if (!_active.contains(player.getUniqueId()) || player.getItemInHand() == null || player.getItemInHand().getType() != Material.DIAMOND_SWORD) + ItemStack itemStack = player.getItemInHand(); + + if (!_active.contains(player.getUniqueId()) || itemStack == null || itemStack.getType() != Material.DIAMOND_SWORD || itemStack.getItemMeta() == null || !itemStack.getItemMeta().getDisplayName().equals(ACTIVE_ITEM.getItemMeta().getDisplayName())) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java index eeb1c0f57..6d90fd6be 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java @@ -4,6 +4,7 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Material; import org.bukkit.Sound; @@ -25,6 +26,7 @@ public class SkillSnowball extends HeroSkill implements IThrown "Fires 3 snowballs, one after another.", "Each snowball deals 3 damage to any enemy it hits." }; + private static final int DAMAGE = 3; private static final ItemStack SKILL_ITEM = new ItemStack(Material.SNOW_BALL); public SkillSnowball(int slot) @@ -57,6 +59,7 @@ public class SkillSnowball extends HeroSkill implements IThrown { Snowball snowball = player.launchProjectile(Snowball.class); + ((Moba) Manager.GetGame()).getTowerManager().addProjectile(player, snowball, DAMAGE); Manager.GetProjectile().AddThrow(snowball, player, SkillSnowball.this, -1, true, true, true, false, 0.5F); if (++balls == 3) @@ -75,7 +78,7 @@ public class SkillSnowball extends HeroSkill implements IThrown if (target != null && !isTeamDamage(target, thrower)) { thrower.playSound(thrower.getLocation(), Sound.LAVA_POP, 1, 1.3F); - Manager.GetDamage().NewDamageEvent(target, thrower, (Projectile) data.getThrown(), DamageCause.CUSTOM, 3, true, true, false, UtilEnt.getName(thrower), GetName()); + Manager.GetDamage().NewDamageEvent(target, thrower, (Projectile) data.getThrown(), DamageCause.CUSTOM, DAMAGE, true, true, false, UtilEnt.getName(thrower), GetName()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java index decc4b408..514d83dbd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java @@ -36,12 +36,12 @@ public class Minion UtilEnt.setBoundingBox(entity, HIT_BOX, HIT_BOX); entity.setCustomNameVisible(true); - updateDisplay(); + updateDisplay(entity.getMaxHealth()); } - public void updateDisplay() + public void updateDisplay(double health) { - _entity.setCustomName(MobaUtil.getHealthBar(_entity, 10)); + _entity.setCustomName(MobaUtil.getHealthBar(_entity, health, 10)); } public LivingEntity getEntity() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index 07b9106e3..a2de07ee3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -3,7 +3,7 @@ package nautilus.game.arcade.game.games.moba.minion; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; -import mineplex.core.recharge.Recharge; +import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -16,6 +16,7 @@ import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.Location; +import org.bukkit.Sound; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -29,14 +30,15 @@ import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.scheduler.BukkitRunnable; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; public class MinionWave implements Listener { private static final int MAX_MINIONS_PER_WAVE = 6; private static final int TOO_CLOSE_SQUARED = 9; - private static final int MINION_TOO_CLOSE_SQUARED = 16; private static final int DAMAGE_RANGE_SQUARED = 16; private static final double DAMAGE_AMOUNT = 0.2; private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); @@ -49,6 +51,8 @@ public class MinionWave implements Listener private final List _path; private final List _minions; + //private final Map _lastDamage; + public MinionWave(Moba host, MinionManager minionManager, GameTeam owner, List path, Class clazz) { _host = host; @@ -57,6 +61,7 @@ public class MinionWave implements Listener _clazz = clazz; _path = path; _minions = new ArrayList<>(MAX_MINIONS_PER_WAVE); + //_lastDamage = new HashMap<>(MAX_MINIONS_PER_WAVE); UtilServer.RegisterEvents(this); @@ -371,11 +376,24 @@ public class MinionWave implements Listener if (minion != null) { - minion.updateDisplay(); + minion.updateDisplay(minion.getEntity().getHealth() - event.GetDamage()); } } } +// @EventHandler(priority = EventPriority.MONITOR) +// public void damageSound(CustomDamageEvent event) +// { +// LivingEntity damagee = event.GetDamageeEntity(); +// +// if (event.isCancelled() || !isMinion(damagee) || !UtilTime.elapsed(_lastDamage.get(damagee), 2000)) +// { +// return; +// } +// +// damagee.getWorld().playSound(damagee.getLocation(), Sound.ZOMBIE_HURT, 1, 1.4F); +// } + @EventHandler public void entityCombust(EntityCombustEvent event) { @@ -403,6 +421,7 @@ public class MinionWave implements Listener } event.getDrops().clear(); + event.setDroppedExp(0); } public void cleanup() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java index 559fdd4dd..0e0360bfc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java @@ -64,7 +64,7 @@ public class PrepareInformation implements Listener String[] description = mobaPlayer.getRole().getDescription(); // Description is too short - if (description.length > _messageIndex + 2) + if (description.length <= _messageIndex + 1) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java index 2dd066b55..99e01896f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java @@ -30,7 +30,6 @@ public class PrepareManager implements Listener { private static final long PREPARE_TIME = TimeUnit.MINUTES.toMillis(1); - private static final String OWNED_METADATA = "owned"; private final Moba _host; @@ -108,21 +107,21 @@ public class PrepareManager implements Listener MobaRole role = event.getRole(); ClientArmorStand stand = event.getStand(); - if (stand.hasMetadata(OWNED_METADATA)) + if (!_host.isRoleFree(player, role)) { player.sendMessage(F.main("Game", "Another player has already chosen this role.")); event.setCancelled(true); return; } - // Store inside the stand that it is claimed by a player - stand.setMetadata(OWNED_METADATA, new FixedMetadataValue(_host.getArcadeManager().getPlugin(), true)); - // Show that the kit is claimed. stand.setCustomName(C.cGreenB + role.getName() + C.cGray + " - " + player.getName()); // Store the role of the player _host.getMobaData(player).setRole(role); + + // Update the scoreboard + _host.getScoreboardModule().refreshAsSubject(player); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java index c97b92bee..8a1a1acc6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java @@ -1,25 +1,48 @@ package nautilus.game.arcade.game.games.moba.structure.point; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Effect; 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 java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; public class CapturePoint { private static final int MAX_RADIUS = 5; - private static final int MAX_PROGRESS = 10; + private static final int MAX_PROGRESS = 5; + private static final int MAX_PROGRESS_NETURAL = 10; + private static final int MIN_INFORM_TIME = (int) TimeUnit.SECONDS.toMillis(30); private final Moba _host; + private final String _name; + private final ChatColor _colour; + private final Location _center; private final List _wool; private final List _changed; @@ -29,10 +52,13 @@ public class CapturePoint private GameTeam _owner; private GameTeam _side; private int _progress; + private long _lastInform; - public CapturePoint(Moba host, Location center) + public CapturePoint(Moba host, String name, ChatColor colour, Location center) { _host = host; + _name = name; + _colour = colour; _center = center; _wool = new ArrayList<>(36); _changed = new ArrayList<>(_wool.size()); @@ -117,9 +143,23 @@ public class CapturePoint { return; } + // Players on the point + // Only inform if it has been a while + else if (!_owner.equals(highest) && UtilTime.elapsed(_lastInform, MIN_INFORM_TIME)) + { + _lastInform = System.currentTimeMillis(); + + for (Player player : Bukkit.getOnlinePlayers()) + { + player.playSound(player.getLocation(), Sound.GHAST_SCREAM2, 1, 1.2F); + } + + _host.Announce(F.main("Game", "Team " + highest.GetFormattedName() + C.mBody + " is capturing beacon " + _colour + _name + C.mBody + "!"), false); + UtilTextMiddle.display("", "Team " + highest.GetFormattedName() + C.cWhite + " is capturing beacon " + _colour + _name, 0, 30, 10); + } // If it has just reached the maximum progress, set the owner. - if (_owner != null && _owner.equals(highest) && _progress >= MAX_PROGRESS) + if (_owner != null && _owner.equals(highest) && _progress >= (_owner == null ? MAX_PROGRESS_NETURAL : MAX_PROGRESS)) { return; } @@ -143,7 +183,7 @@ public class CapturePoint display(team, true); // Captured - if (_progress >= MAX_PROGRESS) + if (_progress >= (_owner == null ? MAX_PROGRESS_NETURAL : MAX_PROGRESS)) { setOwner(team); } @@ -168,23 +208,36 @@ public class CapturePoint private void setOwner(GameTeam team) { - // Same team - if (_owner != null && _owner.equals(team)) + setBeaconColour(team); + + if (_owner != null) { - return; + // Same team no need to inform + if (_owner.equals(team)) + { + return; + } + } + else + { + // As the point is easier to capture after the initial capture + // We need to adjust the current progress, otherwise it has to go + // from 10 to 0 then to 5 which is unintended + _progress = MAX_PROGRESS; } _owner = team; - setBeaconColour(team); - UtilFirework.playFirework(_center, Type.BURST, team.GetColorBase(), false, false); + _host.Announce(F.main("Game", "Team " + team.GetFormattedName() + C.mBody + " captured beacon " + _colour + _name + C.mBody + "!")); + UtilTextMiddle.display("", "Team " + team.GetFormattedName() + C.cWhite + " captured beacon " + _colour + _name, 0, 30, 10); + UtilFirework.playFirework(_center, Type.BURST, team.GetColorBase(), false, false); UtilServer.CallEvent(new CapturePointCaptureEvent(this)); } private void display(GameTeam team, boolean forward) { - double toChange = Math.ceil(_wool.size() / MAX_PROGRESS) + 1; + double toChange = Math.ceil(_wool.size() / (_owner == null ? MAX_PROGRESS_NETURAL : MAX_PROGRESS)) + 1; int changed = 0; for (Block block : _wool) { @@ -231,6 +284,11 @@ public class CapturePoint _center.getBlock().getRelative(BlockFace.DOWN).setData(colour); } + public ChatColor getColour() + { + return _colour; + } + public GameTeam getOwner() { return _owner; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java index 8534f1b32..ae6697317 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java @@ -1,17 +1,20 @@ package nautilus.game.arcade.game.games.moba.structure.point; +import mineplex.core.common.util.C; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.Map.Entry; public class CapturePointManager implements Listener { @@ -35,11 +38,28 @@ public class CapturePointManager implements Listener return; } - Collection capturePoints = _host.getLocationStartsWith("POINT").values(); - - for (Location location : capturePoints) + for (Entry entry : _host.getLocationStartsWith("POINT").entrySet()) { - _capturePoints.add(new CapturePoint(_host, location)); + String[] split = entry.getKey().split(" "); + + if (split.length < 3) + { + continue; + } + + String name = split[1]; + ChatColor colour; + + try + { + colour = ChatColor.valueOf(split[2]); + } + catch (IllegalArgumentException e) + { + continue; + } + + _capturePoints.add(new CapturePoint(_host, name, colour, entry.getValue())); } } @@ -57,6 +77,30 @@ public class CapturePointManager implements Listener } } + public String getDisplayString(GameTeam team) + { + StringBuilder out = new StringBuilder(); + int owned = 0; + + for (CapturePoint point : _capturePoints) + { + if (point.getOwner() == null || !point.getOwner().equals(team)) + { + continue; + } + + out.append(point.getColour()).append("⚑ "); + owned++; + } + + while (owned++ < 3) + { + out.append(C.cGray).append("⚑ "); + } + + return out.toString().trim(); + } + public List getCapturePoints() { return _capturePoints; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index 6d84e1a05..849b57326 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -7,6 +7,7 @@ import mineplex.core.disguise.disguises.DisguiseGuardian; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.util.MobaUtil; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -15,32 +16,34 @@ import org.bukkit.block.BlockFace; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.EnderCrystal; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import java.util.concurrent.TimeUnit; + public class Tower { private static final int DAMAGE = 3; private static final int TARGET_RANGE = 10; public static final int TARGET_RANGE_SQUARED = TARGET_RANGE * TARGET_RANGE; + private static final int MIN_INFORM_TIME = (int) TimeUnit.SECONDS.toMillis(30); private final Moba _host; private final Location _location; private final GameTeam _team; + private float _fallbackYaw; private double _health; private int _maxHealth; private boolean _firstTower; + private boolean _dead; + private long _lastInform; private ArmorStand _stand; private DisguiseGuardian _guardian; private EnderCrystal _crystal; - - private boolean _dead; - - private float _fallbackYaw; - private LivingEntity _target; public Tower(Moba host, Location location, GameTeam team, int health, boolean firstTower) @@ -51,6 +54,7 @@ public class Tower _health = health; _maxHealth = health; _firstTower = firstTower; + _lastInform = System.currentTimeMillis(); } public void setup() @@ -82,7 +86,15 @@ public class Tower { if (_target == null) { + // Target just entities LivingEntity target = MobaUtil.getBestEntityTarget(_host, _team, _stand, _crystal.getLocation(), TARGET_RANGE, false); + + if (target == null) + { + // Try targeting players + target = MobaUtil.getBestEntityTarget(_host, _team, _stand, _crystal.getLocation(), TARGET_RANGE, true); + } + _target = target; setLaserTarget(target); } @@ -117,9 +129,7 @@ public class Tower _guardian.setTarget(0); Location standLocation = _stand.getLocation(); - standLocation.setYaw(_fallbackYaw); - - _guardian.getEntity().setLocation(standLocation.getX(), standLocation.getY(), standLocation.getZ(), standLocation.getYaw(), 0); + _guardian.getEntity().setLocation(standLocation.getX(), standLocation.getY(), standLocation.getZ(), _fallbackYaw, 0); } else { @@ -160,6 +170,18 @@ public class Tower _guardian.setName(out); _crystal.setCustomName(out); + + if (UtilTime.elapsed(_lastInform, MIN_INFORM_TIME)) + { + _lastInform = System.currentTimeMillis(); + + for (Player player : _team.GetPlayers(true)) + { + player.playSound(player.getLocation(), Sound.ANVIL_LAND, 1, 0.5F); + player.sendMessage(F.main("Game", "Your Tower is under attack!")); + UtilTextMiddle.display("", _team.GetColor() + "Your Tower is under attack!", 0, 30, 10, player); + } + } } private void explode() @@ -221,4 +243,14 @@ public class Tower return _dead; } + public double getHealth() + { + return _health; + } + + public double getMaxHealth() + { + return _maxHealth; + } + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index 9dab1ca0d..02ce53665 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -1,5 +1,7 @@ package nautilus.game.arcade.game.games.moba.structure.tower; +import mineplex.core.common.Pair; +import mineplex.core.common.util.C; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; @@ -10,6 +12,8 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.entity.EnderCrystal; @@ -24,6 +28,8 @@ import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.projectiles.ProjectileSource; import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -33,16 +39,19 @@ public class TowerManager implements Listener private static final int FIRST_TOWER_HEALTH = 500; private static final int SECOND_TOWER_HEALTH = 1000; + private static final int PROJECTILE_RANGE_SQUARED = 4; private final Moba _host; private final List _towers; + private final Map> _projectilesToCheck; public TowerManager(Moba host) { _host = host; _towers = new ArrayList<>(12); + _projectilesToCheck = new HashMap<>(); } @EventHandler @@ -90,6 +99,21 @@ public class TowerManager implements Listener _towers.add(new Tower(_host, location, gameTeam, health, firstTower)); } + _towers.sort((o1, o2) -> + { + if (o1.isFirstTower()) + { + return Integer.MIN_VALUE; + } + + if (!o2.isFirstTower()) + { + return Integer.MAX_VALUE; + } + + return 0; + }); + _host.CreatureAllowOverride = true; for (Tower tower : _towers) { @@ -166,7 +190,6 @@ public class TowerManager implements Listener Location playerLocation = player.getLocation(); playerLocation.setY(entityLocation.getY()); - // TODO TEMP if (UtilMath.offsetSquared(playerLocation, entityLocation) > Tower.TARGET_RANGE_SQUARED) { return; @@ -198,51 +221,52 @@ public class TowerManager implements Listener if (Recharge.Instance.use(player, "Tower Sound", 500, false, false)) { - player.playSound(tower.getCrystal().getLocation(), Sound.BLAZE_HIT, 1, 0.8F); + playSound(player, tower); } return; } } - public Tower getFirstTower(GameTeam team) + public void addProjectile(Player shooter, Entity entity, double damage) { - for (Tower tower : _towers) - { - if (tower.isFirstTower() && tower.getOwner().equals(team)) - { - return tower; - } - } - - return null; + _projectilesToCheck.put(entity, Pair.create(shooter, damage)); } -// /* -// Hacky work arounds!!!! -// */ -// @EventHandler -// public void updateAnathBlazePowder(UpdateEvent event) -// { -// if (event.getType() != UpdateType.FASTEST) -// { -// return; -// } -// -// for (Tower tower : _towers) -// { -// for (Entity entity : UtilEnt.getAllInRadius(tower.getCrystal().getLocation(), 1.5).keySet()) -// { -// if (entity instanceof Item) -// { -// Item item = (Item) entity; -// if (item.getItemStack().getType() == Material.BLAZE_POWDER) -// { -// -// } -// } -// } -// } -// } + @EventHandler + public void updateProjectiles(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator iterator = _projectilesToCheck.keySet().iterator(); + + while (iterator.hasNext()) + { + Entity entity = iterator.next(); + Pair pair = _projectilesToCheck.get(entity); + GameTeam team = _host.GetTeam(pair.getLeft()); + + for (Tower tower : _towers) + { + if (tower.isDead() || tower.getOwner().equals(team) || UtilMath.offsetSquared(tower.getCrystal(), entity) > PROJECTILE_RANGE_SQUARED) + { + continue; + } + + playSound(pair.getLeft(), tower); + tower.damage(pair.getRight()); + entity.remove(); + iterator.remove(); + } + } + } + + private void playSound(Player player, Tower tower) + { + player.playSound(tower.getCrystal().getLocation(), Sound.BLAZE_HIT, 1, 0.8F); + } public boolean canDamage(Tower tower, GameTeam team) { @@ -276,6 +300,26 @@ public class TowerManager implements Listener return false; } + public String getDisplayString(GameTeam team) + { + StringBuilder out = new StringBuilder(); + + for (Tower tower : _towers) + { + if (!tower.getOwner().equals(team)) + { + continue; + } + + double health = tower.getHealth() / tower.getMaxHealth(); + String colour = tower.isDead() ? C.cGray : MobaUtil.getColour(health); + + out.append(colour).append("♛ "); + } + + return out.toString(); + } + public List getTowers() { return _towers; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java index 3dab8cbf2..f9ca54daa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java @@ -7,6 +7,7 @@ public class MobaConstants public static final String BASIC_ATTACK = "Basic Attack"; public static final String AMMO = "Ammo"; public static final String TEAM_METADATA = "team"; + public static final String SHOOTER_METADATA = "shooter"; // Location Constants public static final String MINION_PATH_START = "WHITE"; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index bb1daef50..411f01463 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -21,7 +21,12 @@ import java.util.Set; public class MobaUtil { - public static LivingEntity getBestEntityTarget(Moba host, GameTeam owner, LivingEntity source, Location location, int targetRange, boolean targetPlayersMore) + public static LivingEntity getBestEntityTarget(Moba host, GameTeam owner, LivingEntity source, Location location, int targetRange, boolean targetPlayers) + { + return getBestEntityTarget(host, owner, source, location, targetRange, targetPlayers, false); + } + + public static LivingEntity getBestEntityTarget(Moba host, GameTeam owner, LivingEntity source, Location location, int targetRange, boolean targetPlayers, boolean targetPlayersMore) { LivingEntity highest = null; double bestDist = 0; @@ -45,7 +50,7 @@ public class MobaUtil // Make players more desirable if (entity instanceof Player) { - if (owner.equals(host.GetTeam((Player) entity))) + if (!targetPlayers || owner.equals(host.GetTeam((Player) entity))) { continue; } @@ -155,26 +160,14 @@ public class MobaUtil public static String getHealthBar(LivingEntity entity, int bars) { - String out = ""; - String colour; - double health = entity.getHealth() / entity.getMaxHealth(); + return getHealthBar(entity, entity.getHealth(), bars); + } - if (health < 0.25) - { - colour = C.cRedB; - } - else if (health < 0.5) - { - colour = C.cGoldB; - } - else if (health < 0.75) - { - colour = C.cYellowB; - } - else - { - colour = C.cGreenB; - } + public static String getHealthBar(LivingEntity entity, double newHealth, int bars) + { + StringBuilder out = new StringBuilder(); + double health = newHealth / entity.getMaxHealth(); + String colour = getColour(health); for (int i = 0; i < bars; i++) { @@ -182,16 +175,32 @@ public class MobaUtil if (cur < health) { - out += colour + "|"; + out.append(colour).append("|"); } else { - out += C.cGrayB + "|"; + out.append(C.cGrayB).append("|"); } } - return out; + return out.toString(); } + public static String getColour(double percentage) + { + if (percentage < 0.25) + { + return C.cRedB; + } + else if (percentage < 0.5) + { + return C.cGoldB; + } + else if (percentage < 0.75) + { + return C.cYellowB; + } + return C.cGreenB; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java index 95ce3bbb5..928a2e919 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/modules/CustomScoreboardModule.java @@ -11,6 +11,9 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.scoreboard.DisplaySlot; +import org.bukkit.scoreboard.Objective; +import org.bukkit.scoreboard.Score; import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Team; @@ -20,6 +23,22 @@ import java.util.UUID; import java.util.function.BiConsumer; import java.util.function.BiFunction; +/** + * CustomScoreboardModule allows for the use of per-player scoreboards in an Arcade game. + * Including sidebars, tab-list prefixes, suffixes, undernames and scores.
+ * These scoreboard system is backed by {@link mineplex.core.scoreboard.ScoreboardManager} and is thus optimised + * extremely efficiently, so don't be afraid to call the set methods often as they will not be updated then and there.
+ * Scoreboards are refreshed for all players upon the prepare, live and end state changes. While sidebars are updated every 10 ticks/0.5 seconds.
+ * If you wish to update the scoreboard more frequently than these, the methods: + *

    + *
  • {@link #refresh()}
  • + *
  • {@link #refreshAsPerspective(Player)}
  • + * + *
+ * + * @see mineplex.core.scoreboard.MineplexScoreboard + * @see nautilus.game.arcade.game.games.moba.Moba + */ public class CustomScoreboardModule extends Module { @@ -28,18 +47,28 @@ public class CustomScoreboardModule extends Module private BiConsumer _scoreboardConsumer; private BiFunction _prefixFunction; private BiFunction _suffixFunction; + private BiFunction _tabListFunction; + private String _underNameObjective; + private BiFunction _underNameFunction; public CustomScoreboardModule() { _scoreboard = new HashMap<>(); } + /** + * The use of the boolean UseCustomScoreboard in {@link nautilus.game.arcade.game.Game} is required so the Arcade doesn't + * try and create the scoreboard itself or reference the standard {@link GameScoreboard}, which it does (a lot). + */ @Override protected void setup() { getGame().UseCustomScoreboard = true; } + /** + * Calls {@link #setupScoreboard(Player)} when the players joins, if the game is not in a Lobby state. + */ @EventHandler public void playerJoin(PlayerJoinEvent event) { @@ -54,6 +83,11 @@ public class CustomScoreboardModule extends Module setupScoreboard(player); } + /** + * Removes the player's scoreboard from the {@link #_scoreboard} map. + *
+ * Unregisters the quitting player's entries from all other scoreboards. + */ @EventHandler public void playerQuit(PlayerQuitEvent event) { @@ -67,7 +101,10 @@ public class CustomScoreboardModule extends Module } } - @EventHandler(priority = EventPriority.MONITOR) + /** + * Calls {@link #setupScoreboard(Player)} when the game switches to the prepare state. + */ + @EventHandler(priority = EventPriority.HIGHEST) public void prepare(GameStateChangeEvent event) { if (event.GetState() != GameState.Prepare) @@ -79,14 +116,15 @@ public class CustomScoreboardModule extends Module { setupScoreboard(player); } - - refresh(); } + /** + * Refreshes all player scoreboards upon an in progress state change. + */ @EventHandler(priority = EventPriority.MONITOR) public void live(GameStateChangeEvent event) { - if (event.GetState() != GameState.Live) + if (event.GetState() != GameState.Prepare && event.GetState() != GameState.Live && event.GetState() != GameState.End) { return; } @@ -94,6 +132,9 @@ public class CustomScoreboardModule extends Module refresh(); } + /** + * Calls the draw method every 10 ticks/0.5 seconds. + */ @EventHandler public void update(UpdateEvent event) { @@ -140,6 +181,27 @@ public class CustomScoreboardModule extends Module return this; } + public CustomScoreboardModule setTabList(BiFunction function) + { + _tabListFunction = function; + return this; + } + + public CustomScoreboardModule setUnderNameObjective(String name) + { + _underNameObjective = name; + return this; + } + + public CustomScoreboardModule setUnderName(BiFunction function) + { + _underNameFunction = function; + return this; + } + + /** + * Refreshes all player's scoreboards. + */ public void refresh() { for (CustomArcadeScoreboard scoreboard : _scoreboard.values()) @@ -148,12 +210,43 @@ public class CustomScoreboardModule extends Module } } + /** + * Refreshes an individual player's scoreboard. + * + * @param perspective The player that has the perspective of the scoreboard to be refreshed. + */ + public void refreshAsPerspective(Player perspective) + { + CustomArcadeScoreboard scoreboard = _scoreboard.get(perspective.getUniqueId()); + + if (scoreboard == null) + { + return; + } + + scoreboard.draw(false); + } + + /** + * Refreshes all scoreboards but only where the subject of said scoreboard is the player passed in as the subject parameter. + */ + public void refreshAsSubject(Player subject) + { + for (CustomArcadeScoreboard scoreboard : _scoreboard.values()) + { + scoreboard.draw(subject); + } + } + @Override public void cleanup() { _scoreboard.clear(); } + /** + * An internal class that simply implements the actions set out by {@link CustomScoreboardModule}. + */ class CustomArcadeScoreboard extends GameScoreboard { @@ -162,12 +255,15 @@ public class CustomScoreboardModule extends Module super(getGame(), owner); } - private void setTag(Player subject, String prefix, String suffix) + private void updateTag(Player subject) { Scoreboard handle = getHandle(); String teamName = subject.getName(); Team team = handle.getTeam(teamName); + String prefix = _prefixFunction == null ? null : _prefixFunction.apply(getOwner(), subject); + String suffix = _suffixFunction == null ? null : _suffixFunction.apply(getOwner(), subject); + if (team == null) { team = handle.registerNewTeam(teamName); @@ -190,6 +286,56 @@ public class CustomScoreboardModule extends Module } } + private void updateTabList(Player subject) + { + if (_tabListFunction == null) + { + return; + } + + Scoreboard handle = getHandle(); + Objective objective = handle.getObjective(DisplaySlot.PLAYER_LIST); + int value = _tabListFunction.apply(getOwner(), subject); + + if (objective == null) + { + objective = handle.registerNewObjective("TabList", "dummy"); + objective.setDisplaySlot(DisplaySlot.PLAYER_LIST); + } + + Score score = objective.getScore(subject.getName()); + + if (score.getScore() != value) + { + score.setScore(value); + } + } + + private void updateUnderName(Player subject) + { + if (_underNameFunction == null || _underNameObjective == null) + { + return; + } + + Scoreboard handle = getHandle(); + Objective objective = handle.getObjective(DisplaySlot.BELOW_NAME); + int value = _underNameFunction.apply(getOwner(), subject); + + if (objective == null) + { + objective = handle.registerNewObjective(_underNameObjective, "dummy"); + objective.setDisplaySlot(DisplaySlot.BELOW_NAME); + } + + Score score = objective.getScore(subject.getName()); + + if (score.getScore() != value) + { + score.setScore(value); + } + } + @Override public void draw() { @@ -204,16 +350,20 @@ public class CustomScoreboardModule extends Module } if (!sidebarOnly) { - if (_prefixFunction != null) + for (Player player : Bukkit.getOnlinePlayers()) { - for (Player player : Bukkit.getOnlinePlayers()) - { - setTag(player, _prefixFunction.apply(getOwner(), player), _suffixFunction.apply(getOwner(), player)); - } + draw(player); } } super.draw(); } + + private void draw(Player player) + { + updateTag(player); + updateTabList(player); + updateUnderName(player); + } } From 8a9e113389f75b8f5e5459288ae3742d569fb301 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 31 May 2017 17:09:08 +0100 Subject: [PATCH 41/57] Improvements to the targetting system --- .../core/fallingblock/FallingBlocks.java | 3 +- .../game/arcade/game/games/moba/Moba.java | 3 + .../arcade/game/games/moba/ai/MobaAI.java | 33 +++---- .../moba/ai/goal/MobaDirectAIMethod.java | 2 +- .../arcade/game/games/moba/boss/MobaBoss.java | 47 ++++++++- .../game/games/moba/boss/MobaBossAttack.java | 10 ++ .../games/moba/boss/pumpkin/PumpkinBoss.java | 58 ++++++++--- .../moba/boss/pumpkin/PumpkinBossAI.java | 4 +- .../games/moba/boss/wither/WitherBoss.java | 23 +++-- .../boss/wither/WitherSkullProjectile.java | 83 ---------------- .../wither/attack/BossAttackEarthquake.java | 93 ++++++++++++++++++ .../game/games/moba/gold/GoldManager.java | 2 - .../game/games/moba/minion/MinionWave.java | 34 +++---- .../arcade/game/games/moba/util/MobaUtil.java | 96 ++++++++----------- 14 files changed, 286 insertions(+), 205 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBossAttack.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/attack/BossAttackEarthquake.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/fallingblock/FallingBlocks.java b/Plugins/Mineplex.Core/src/mineplex/core/fallingblock/FallingBlocks.java index 46b462c17..b7655b19f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/fallingblock/FallingBlocks.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/fallingblock/FallingBlocks.java @@ -33,7 +33,7 @@ public class FallingBlocks extends MiniPlugin if (vec.getY() < 0) { - vec.setY(vec.getY() * -1); + vec.setY(-vec.getY()); } Spawn(location, type, data, vec); @@ -46,7 +46,6 @@ public class FallingBlocks extends MiniPlugin UtilAction.velocity(fall, velocity, 0.5 + 0.25 * Math.random(), false, 0, 0.4 + 0.20 * Math.random(), 10, false); - fall.setMetadata(METADATA, new FixedMetadataValue(_plugin, "x")); UtilEnt.SetMetadata(fall, METADATA, "x"); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 286854643..e1af99064 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -34,6 +34,7 @@ import nautilus.game.arcade.game.games.moba.recall.Recall; import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.structure.point.CapturePointManager; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; @@ -49,6 +50,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.metadata.FixedMetadataValue; import java.util.ArrayList; import java.util.Arrays; @@ -362,6 +364,7 @@ public class Moba extends TeamGame for (Player player : GetPlayers(true)) { _playerData.add(new MobaPlayer(player)); + player.setMetadata(MobaConstants.TEAM_METADATA, new FixedMetadataValue(Manager.getPlugin(), GetTeam(player).GetName())); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java index 59ba0cffa..15f4e9e49 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/MobaAI.java @@ -1,7 +1,5 @@ package nautilus.game.arcade.game.games.moba.ai; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; @@ -10,16 +8,15 @@ import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; +import java.util.List; + public class MobaAI { - private static final int TARGET_RANGE = 15; - private static final int TARGET_RANGE_SQUARED = TARGET_RANGE * TARGET_RANGE; - - private final Moba _host; private final GameTeam _owner; private final float _speedTarget; private final float _speedHome; + private final List _boundaries; private LivingEntity _entity; private LivingEntity _target; @@ -29,26 +26,26 @@ public class MobaAI public MobaAI(Moba host, GameTeam owner, LivingEntity entity, Location home, float speedTarget, float speedHome, MobaAIMethod aiMethod) { - _host = host; _owner = owner; _speedTarget = speedTarget; _speedHome = speedHome; _entity = entity; _home = home; _aiMethod = aiMethod; + _boundaries = host.WorldData.GetDataLocs(getBoundaryKey()); } public void updateTarget() { // Entity not spawned - if (_entity == null || !_entity.isValid()) + if (_entity == null || _entity.isDead() || !_entity.isValid()) { return; } if (_target == null || _target.isDead() || !_target.isValid()) { - _target = MobaUtil.getBestEntityTarget(_host, _owner, _entity, _home, _host.WorldData.GetDataLocs(getBoundaryKey())); + _target = MobaUtil.getBestEntityTarget(_owner, _entity, _home, _boundaries); if (_target == null) { @@ -56,15 +53,10 @@ public class MobaAI return; } } - else + else if (!MobaUtil.isInBoundary(_owner, _entity, _home, _boundaries, _target)) { - double dist = UtilMath.offsetSquared(_entity, _target); - - if (dist > TARGET_RANGE_SQUARED || UtilPlayer.isSpectator(_target)) - { - _target = null; - returnToHome(); - } + _target = null; + returnToHome(); } if (_target != null) @@ -75,7 +67,7 @@ public class MobaAI private void returnToHome() { - _aiMethod.updateMovement(_entity, _home, _speedTarget); + _aiMethod.updateMovement(_entity, _home, _speedHome); } public void setEntity(LivingEntity entity) @@ -88,6 +80,11 @@ public class MobaAI return _target; } + public List getBoundaries() + { + return _boundaries; + } + public String getBoundaryKey() { return _owner.GetColor() == ChatColor.RED ? "ORANGE" : "LIGHT_BLUE"; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java index 45035f8c9..d2ad46e97 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/ai/goal/MobaDirectAIMethod.java @@ -14,7 +14,7 @@ public class MobaDirectAIMethod implements MobaAIMethod { Location entityLocation = entity.getLocation(); - // Speed is blocks per second + // Speed is number of ticks to travel 1 block float magnitude = speed / 20F; // Get the direct vector between the entity and the goal diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java index 4158ed179..086858719 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBoss.java @@ -1,27 +1,38 @@ package nautilus.game.arcade.game.games.moba.boss; +import mineplex.core.common.util.UtilAlg; 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 mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.ai.MobaAI; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDeathEvent; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; + public abstract class MobaBoss implements Listener { protected final Moba _host; protected LivingEntity _entity; protected Location _location; - protected int _respawnTime; + private int _respawnTime; private long _lastDeath; + private List _attacks; + public MobaBoss(Moba host, Location location) { this(host, location, -1); @@ -33,6 +44,7 @@ public abstract class MobaBoss implements Listener _location = location; _respawnTime = respawnTime; _lastDeath = -1; + _attacks = new ArrayList<>(3); } public void setup() @@ -44,12 +56,36 @@ public abstract class MobaBoss implements Listener public void cleanup() { UtilServer.Unregister(this); + _attacks.forEach(MobaBossAttack::cleanup); + } + + public void addAttack(MobaBossAttack attack) + { + _attacks.add(attack); + } + + @EventHandler + public void updateAttack(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOW || getAi().getTarget() == null) + { + return; + } + + MobaBossAttack attack = UtilAlg.Random(_attacks); + + if (attack == null) + { + return; + } + + attack.run(); } @EventHandler public void updateMovement(UpdateEvent event) { - if (event.getType() != UpdateType.FASTEST || _entity == null || !_host.IsLive()) + if (event.getType() != UpdateType.TICK || _entity == null || !_host.IsLive()) { return; } @@ -87,6 +123,13 @@ public abstract class MobaBoss implements Listener public abstract MobaAI getAi(); + public abstract String getName(); + + public Moba getHost() + { + return _host; + } + public LivingEntity getEntity() { return _entity; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBossAttack.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBossAttack.java new file mode 100644 index 000000000..4c91d9f6c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/MobaBossAttack.java @@ -0,0 +1,10 @@ +package nautilus.game.arcade.game.games.moba.boss; + +import org.bukkit.event.Listener; + +public interface MobaBossAttack extends Runnable, Listener +{ + + void cleanup(); + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java index 08e913ece..822b9b70d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java @@ -29,7 +29,6 @@ import nautilus.game.arcade.game.games.moba.util.MobaUtil; import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment; import org.bukkit.Bukkit; -import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -56,6 +55,7 @@ import java.util.concurrent.TimeUnit; public class PumpkinBoss extends MobaBoss { + private static final String NAME = "Pumpkin King"; private static final int SPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(5); private static final int RESPAWN_TIME = (int) TimeUnit.MINUTES.toMillis(5); private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); @@ -70,6 +70,7 @@ public class PumpkinBoss extends MobaBoss private static final int DAMAGE_DIRECT = 8; private static final int DAMAGE_DIRECT_RADIUS_SQUARED = 9; private static final int HEALTH = 400; + private static final int HEALTH_OUT_OF_COMBAT = 10; private static final Material[] BLOCKS = { Material.OBSIDIAN, Material.NETHERRACK, @@ -103,7 +104,7 @@ public class PumpkinBoss extends MobaBoss Skeleton skeleton = UtilVariant.spawnWitherSkeleton(_location); - skeleton.setCustomName(C.cDRedB + "Pumpkin King"); + skeleton.setCustomName(C.cDRedB + NAME); skeleton.setCustomNameVisible(true); skeleton.getEquipment().setHelmet(HELMET); skeleton.getEquipment().setItemInHand(IN_HAND); @@ -115,6 +116,10 @@ public class PumpkinBoss extends MobaBoss skeleton.getWorld().strikeLightningEffect(skeleton.getLocation()); + // preDamage uses getAi() which would have been called in a game long before spawnEntity has + // This is unique to the pumpkin king, so we must manually update the AI's corresponding entity + getAi().setEntity(skeleton); + UtilTextMiddle.display(C.cDRedB + "The Pumpkin King", "Has Awoken!", 10, 40, 10); _host.Announce(F.main("Game", C.cRedB + "The Pumpkin King Has Awoken!"), false); @@ -147,12 +152,18 @@ public class PumpkinBoss extends MobaBoss { if (_ai == null) { - _ai = new PumpkinBossAI(_host, _entity, _location, AI_METHOD); + _ai = new PumpkinBossAI(_host, _entity, _location, AI_METHOD); } return _ai; } + @Override + public String getName() + { + return NAME; + } + @EventHandler public void updateSpawn(UpdateEvent event) { @@ -176,6 +187,17 @@ public class PumpkinBoss extends MobaBoss } } + @EventHandler(priority = EventPriority.LOWEST) + public void preDamage(CustomDamageEvent event) + { + if (!event.GetDamageeEntity().equals(_entity) || MobaUtil.isInBoundary(null, _entity, _location, getAi().getBoundaries(), event.GetDamagerPlayer(true))) + { + return; + } + + event.SetCancelled("Outside of area"); + } + @Override @EventHandler public void entityDeath(EntityDeathEvent event) @@ -239,19 +261,29 @@ public class PumpkinBoss extends MobaBoss return; } - if (_ai.getTarget() != null && !UtilPlayer.isSpectator(_ai.getTarget()) && UtilMath.offsetSquared(_entity, _ai.getTarget()) < DAMAGE_DIRECT_RADIUS_SQUARED) + LivingEntity target = _ai.getTarget(); + + if (target != null) { - _host.getArcadeManager().GetDamage().NewDamageEvent(_ai.getTarget(), _entity, null, DamageCause.CUSTOM, DAMAGE_DIRECT, true, true, false, DAMAGE_REASON, DAMAGE_REASON); - - // Send a fake hit packet - // Magic number 0 means swing item/attack - PacketPlayOutAnimation packet = new PacketPlayOutAnimation(((CraftLivingEntity) _entity).getHandle(), 0); - - for (Player player : Bukkit.getOnlinePlayers()) + if (UtilMath.offsetSquared(_entity, target) < DAMAGE_DIRECT_RADIUS_SQUARED) { - UtilPlayer.sendPacket(player, packet); + _host.getArcadeManager().GetDamage().NewDamageEvent(target, _entity, null, DamageCause.CUSTOM, DAMAGE_DIRECT, true, true, false, DAMAGE_REASON, DAMAGE_REASON); + + // Send a fake hit packet + // Magic number 0 means swing item/attack + PacketPlayOutAnimation packet = new PacketPlayOutAnimation(((CraftLivingEntity) _entity).getHandle(), 0); + + for (Player player : Bukkit.getOnlinePlayers()) + { + UtilPlayer.sendPacket(player, packet); + } } } + else + { + _entity.setHealth(Math.min(_entity.getHealth() + HEALTH_OUT_OF_COMBAT, _entity.getMaxHealth())); + updateDisplay(); + } for (LivingEntity entity : UtilEnt.getInRadius(_entity.getLocation(), DAMAGE_RADIUS).keySet()) { @@ -260,7 +292,7 @@ public class PumpkinBoss extends MobaBoss continue; } - _host.getArcadeManager().GetDamage().NewDamageEvent(entity, _entity, null, DamageCause.CUSTOM, DAMAGE_RANGE, false, true, false, DAMAGE_REASON, DAMAGE_REASON); + _host.getArcadeManager().GetDamage().NewDamageEvent(entity, _entity, null, DamageCause.CUSTOM, DAMAGE_RANGE, false, true, false, NAME, DAMAGE_REASON); UtilAction.velocity(entity, UtilAlg.getTrajectory(_entity, entity).setY(1)); UtilParticle.PlayParticleToAll(ParticleType.FLAME, entity.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 5, ViewDist.LONG); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBossAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBossAI.java index 66cc68a83..6ab78895b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBossAI.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBossAI.java @@ -9,8 +9,8 @@ import org.bukkit.entity.LivingEntity; public class PumpkinBossAI extends MobaAI { - private static final float SPEED_TARGET = 12F; - private static final float SPEED_HOME = 16F; + private static final float SPEED_TARGET = 5F; + private static final float SPEED_HOME = 3F; public PumpkinBossAI(Moba host, LivingEntity entity, Location home, MobaAIMethod aiMethod) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index b70326896..691ca05d1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -16,6 +16,7 @@ import nautilus.game.arcade.game.games.moba.ai.MobaAI; import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; import nautilus.game.arcade.game.games.moba.ai.goal.MobaDirectAIMethod; import nautilus.game.arcade.game.games.moba.boss.MobaBoss; +import nautilus.game.arcade.game.games.moba.boss.wither.attack.BossAttackEarthquake; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.structure.tower.TowerDestroyEvent; import nautilus.game.arcade.game.games.moba.util.MobaUtil; @@ -31,8 +32,9 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; public class WitherBoss extends MobaBoss { - private static final float SPEED_TARGET = 7F; - private static final float SPEED_HOME = 9F; + private static final String NAME = "Wither Boss"; + private static final float SPEED_TARGET = 4F; + private static final float SPEED_HOME = 6F; private static final int INITIAL_HEALTH = 1750; private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); @@ -47,6 +49,8 @@ public class WitherBoss extends MobaBoss _location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, host.GetSpectatorLocation()))); _team = team; + + addAttack(new BossAttackEarthquake(this)); } @Override @@ -81,15 +85,20 @@ public class WitherBoss extends MobaBoss } @Override - @EventHandler - public void updateMovement(UpdateEvent event) + public String getName() { - super.updateMovement(event); + return NAME; + } - if (event.getType() == UpdateType.SEC && _entity != null && _host.IsLive() && getAi().getTarget() != null) + @EventHandler(priority = EventPriority.LOWEST) + public void preDamage(CustomDamageEvent event) + { + if (!event.GetDamageeEntity().equals(_entity) || MobaUtil.isInBoundary(_team, _entity, _location, getAi().getBoundaries(), event.GetDamagerPlayer(true))) { - new WitherSkullProjectile(_host, _entity, getAi().getTarget(), _team); + return; } + + event.SetCancelled("Outside of area"); } @EventHandler(priority = EventPriority.HIGHEST) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java deleted file mode 100644 index e62652fd3..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherSkullProjectile.java +++ /dev/null @@ -1,83 +0,0 @@ -package nautilus.game.arcade.game.games.moba.boss.wither; - -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.projectile.IThrown; -import mineplex.core.projectile.ProjectileUser; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.games.moba.Moba; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.WitherSkull; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; - -public class WitherSkullProjectile implements IThrown -{ - - private static final int DAMAGE = 10; - - private final Moba _host; - private final ArcadeManager _manager; - private final GameTeam _owner; - - public WitherSkullProjectile(Moba host, LivingEntity shooter, LivingEntity target, GameTeam owner) - { - _host = host; - _manager = host.getArcadeManager(); - _owner = owner; - - WitherSkull skull = shooter.getWorld().spawn(shooter.getLocation().add(0, 2, 0), WitherSkull.class); - - skull.setShooter(shooter); - skull.setYield(0); - skull.setVelocity(skull.getVelocity().add(UtilAlg.getTrajectory(shooter, target))); - - _manager.GetProjectile().AddThrow(skull, shooter, this, 2000, true, true, true, false, 0.5F); - } - - @Override - public void Collide(LivingEntity target, Block block, ProjectileUser data) - { - if (target == null) - { - Expire(data); - return; - } - - if (target instanceof Player) - { - Player targetPlayer = (Player) target; - GameTeam targetTeam = _host.GetTeam(targetPlayer); - - // Not team damage - if (!_owner.equals(targetTeam)) - { - _manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, DamageCause.CUSTOM, DAMAGE, true, true, false, "Wither Boss", "Wither Skull"); - } - - Expire(data); - } - } - - @Override - public void Idle(ProjectileUser data) - { - } - - @Override - public void Expire(ProjectileUser data) - { - Entity thrown = data.getThrown(); - - thrown.getWorld().playSound(thrown.getLocation(), Sound.EXPLODE, 1, 1.6F); - UtilParticle.PlayParticleToAll(ParticleType.LARGE_EXPLODE, thrown.getLocation(), 0, 0, 0, 0.1F, 1, ViewDist.LONG); - thrown.remove(); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/attack/BossAttackEarthquake.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/attack/BossAttackEarthquake.java new file mode 100644 index 000000000..6279b1ffa --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/attack/BossAttackEarthquake.java @@ -0,0 +1,93 @@ +package nautilus.game.arcade.game.games.moba.boss.wither.attack; + +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.UtilServer; +import nautilus.game.arcade.game.games.moba.boss.MobaBossAttack; +import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +import java.util.HashSet; +import java.util.Map.Entry; +import java.util.Set; + +public class BossAttackEarthquake implements MobaBossAttack +{ + + private static final String ATTACK_NAME = "Earthquake"; + private static final int RADIUS = 8; + private static final int DAMAGE = 8; + private static final double FALLING_BLOCK_CHANCE = 0.1; + + private final WitherBoss _boss; + private final Set _entities; + + public BossAttackEarthquake(WitherBoss boss) + { + _boss = boss; + _entities = new HashSet<>(); + + UtilServer.RegisterEvents(this); + } + + @Override + public void run() + { + LivingEntity boss = _boss.getEntity(); + + for (Block block : UtilBlock.getBlocksInRadius(boss.getLocation(), RADIUS)) + { + // Only want blocks that are on the floor + if (block.getType() == Material.AIR || block.getRelative(BlockFace.UP).getType() != Material.AIR || Math.random() > FALLING_BLOCK_CHANCE) + { + continue; + } + + FallingBlock fallingBlock = block.getWorld().spawnFallingBlock(block.getLocation().add(0.5, 1, 0.5), block.getType(), block.getData()); + fallingBlock.setHurtEntities(false); + fallingBlock.setDropItem(false); + fallingBlock.setVelocity(UtilAlg.getTrajectory(boss, fallingBlock).multiply(0.25).setY(1.5)); + } + + for (Entry entry : UtilEnt.getInRadius(boss.getLocation(), RADIUS).entrySet()) + { + LivingEntity entity = entry.getKey(); + double dist = entry.getValue(); + + if (MobaUtil.isTeamEntity(entity, _boss.getTeam())) + { + continue; + } + + _boss.getHost().getArcadeManager().GetDamage().NewDamageEvent(entity, boss, null, DamageCause.CUSTOM, DAMAGE * (dist + 0.5), false, true, false, _boss.getName(), ATTACK_NAME); + UtilAction.velocity(entity, UtilAlg.getTrajectory(boss, entity).setY(1)); + } + } + + @Override + public void cleanup() + { + UtilServer.Unregister(this); + } + + @EventHandler + public void entityChangeBlock(EntityChangeBlockEvent event) + { + if (_entities.contains(event.getEntity())) + { + event.setCancelled(true); + event.getEntity().remove(); + _entities.remove(event.getEntity()); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java index 79bd7cdb9..c55cf84a5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java @@ -13,13 +13,11 @@ import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; import nautilus.game.arcade.game.games.moba.structure.point.CapturePointCaptureEvent; import nautilus.game.arcade.game.games.moba.structure.tower.TowerDestroyEvent; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; -import java.util.Collections; import java.util.HashMap; import java.util.Map; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index a2de07ee3..aa0c6bc95 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -28,6 +28,7 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.scheduler.BukkitRunnable; +import org.jooq.util.derby.sys.Sys; import java.util.ArrayList; import java.util.HashMap; @@ -47,21 +48,20 @@ public class MinionWave implements Listener private final MinionManager _minionManager; private final GameTeam _owner; private final Class _clazz; + private final long _startTime; private final List _path; private final List _minions; - //private final Map _lastDamage; - public MinionWave(Moba host, MinionManager minionManager, GameTeam owner, List path, Class clazz) { _host = host; _minionManager = minionManager; _owner = owner; _clazz = clazz; + _startTime = System.currentTimeMillis(); _path = path; _minions = new ArrayList<>(MAX_MINIONS_PER_WAVE); - //_lastDamage = new HashMap<>(MAX_MINIONS_PER_WAVE); UtilServer.RegisterEvents(this); @@ -135,7 +135,6 @@ public class MinionWave implements Listener // Too close if (UtilMath.offsetSquared(entity.getLocation(), target) < TOO_CLOSE_SQUARED) { - //Bukkit.broadcastMessage("Too close"); continue; } } @@ -146,19 +145,27 @@ public class MinionWave implements Listener if (newTarget == _path.size()) { - //Bukkit.broadcastMessage("Done"); continue; } minion.setTargetIndex(newTarget); minion.setTarget(_path.get(newTarget)); - //Bukkit.broadcastMessage("Advance target " + newTarget); } } + } + + @EventHandler + public void updateUnregister(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } _minions.removeIf(minion -> minion.getEntity() == null || minion.getEntity().isDead() || !minion.getEntity().isValid()); - if (_minions.isEmpty()) + // Only should unregister the wave after all entities have spawned + if (_minions.isEmpty() && UtilTime.elapsed(_startTime, 10000)) { UtilServer.Unregister(this); _minionManager.unregisterWave(this); @@ -381,19 +388,6 @@ public class MinionWave implements Listener } } -// @EventHandler(priority = EventPriority.MONITOR) -// public void damageSound(CustomDamageEvent event) -// { -// LivingEntity damagee = event.GetDamageeEntity(); -// -// if (event.isCancelled() || !isMinion(damagee) || !UtilTime.elapsed(_lastDamage.get(damagee), 2000)) -// { -// return; -// } -// -// damagee.getWorld().playSound(damagee.getLocation(), Sound.ZOMBIE_HURT, 1, 1.4F); -// } - @EventHandler public void entityCombust(EntityCombustEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index 411f01463..4242ec20f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -5,6 +5,7 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import org.bukkit.Bukkit; @@ -13,6 +14,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.util.Vector; +import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Map.Entry; @@ -22,11 +24,6 @@ public class MobaUtil { public static LivingEntity getBestEntityTarget(Moba host, GameTeam owner, LivingEntity source, Location location, int targetRange, boolean targetPlayers) - { - return getBestEntityTarget(host, owner, source, location, targetRange, targetPlayers, false); - } - - public static LivingEntity getBestEntityTarget(Moba host, GameTeam owner, LivingEntity source, Location location, int targetRange, boolean targetPlayers, boolean targetPlayersMore) { LivingEntity highest = null; double bestDist = 0; @@ -47,18 +44,13 @@ public class MobaUtil continue; } - // Make players more desirable + // Ignore players on the same team if (entity instanceof Player) { if (!targetPlayers || owner.equals(host.GetTeam((Player) entity))) { continue; } - - if (targetPlayersMore) - { - dist += 0.5; - } } if (bestDist < dist) @@ -71,9 +63,34 @@ public class MobaUtil return highest; } - public static LivingEntity getBestEntityTarget(Moba host, GameTeam owner, LivingEntity source, Location center, List boundaries) + public static boolean isInBoundary(GameTeam owner, LivingEntity source, Location center, List boundaries, LivingEntity target) { - Set ignored = new HashSet<>(); + return getEntitiesInBoundary(owner, source, center, boundaries).contains(target); + } + + public static LivingEntity getBestEntityTarget(GameTeam owner, LivingEntity source, Location center, List boundaries) + { + LivingEntity best = null; + double bestDist = Double.MAX_VALUE; + + for (LivingEntity entity : getEntitiesInBoundary(owner, source, center, boundaries)) + { + double dist = UtilMath.offsetSquared(entity.getLocation(), center); + + if (dist < bestDist) + { + best = entity; + bestDist = dist; + } + } + + return best; + } + + public static Set getEntitiesInBoundary(GameTeam owner, LivingEntity source, Location center, List boundaries) + { + Set entities = new HashSet<>(); + List ignored = new ArrayList<>(); if (owner != null) { @@ -81,15 +98,6 @@ public class MobaUtil ignored.addAll(owner.GetPlayers(true)); } - // Add all spectators to ignored players - for (Player player : Bukkit.getOnlinePlayers()) - { - if (UtilPlayer.isSpectator(player)) - { - ignored.add(player); - } - } - // For each boundary for (Location boundary : boundaries) { @@ -107,55 +115,28 @@ public class MobaUtil // Advance the location checking.add(direction); - LivingEntity highest = null; - double bestDist = 0; - // Check for nearby entities - for (Entry entry : UtilEnt.getInRadius(checking, 2).entrySet()) + for (LivingEntity entity : UtilEnt.getInRadius(checking, 3).keySet()) { - LivingEntity entity = entry.getKey(); - double dist = entry.getValue(); - if (source.equals(entity) || ignored.contains(entity)) { continue; } - if (owner != null) + // Check for team entities + if (owner != null && isTeamEntity(entity, owner)) { - // Check for team entities - if (entity.hasMetadata(MobaConstants.TEAM_METADATA) && entity.getMetadata(MobaConstants.TEAM_METADATA).get(0).asString().equals(owner.GetName())) - { - continue; - } - - // Check for same team players - if (entity instanceof Player) - { - if (owner.equals(host.GetTeam((Player) entity))) - { - continue; - } - } + continue; } - if (bestDist < dist) - { - highest = entity; - bestDist = dist; - } - } - - if (highest != null) - { - return highest; + entities.add(entity); } checkedDist++; } } - return null; + return entities; } public static String getHealthBar(LivingEntity entity, int bars) @@ -203,4 +184,9 @@ public class MobaUtil return C.cGreenB; } + + public static boolean isTeamEntity(LivingEntity entity, GameTeam team) + { + return entity.hasMetadata(MobaConstants.TEAM_METADATA) && entity.getMetadata(MobaConstants.TEAM_METADATA).get(0).asString().equals(team.GetName()); + } } From c34bf77dc98b5b3f79ac499c572770b7309573f3 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 1 Jun 2017 00:55:33 +0100 Subject: [PATCH 42/57] More testing feedback --- .../game/arcade/game/games/moba/Moba.java | 11 +-- .../games/moba/boss/pumpkin/PumpkinBoss.java | 12 ++- .../games/moba/boss/wither/WitherBoss.java | 2 +- .../wither/attack/BossAttackEarthquake.java | 4 +- .../games/moba/kit/dana/SkillPulseHeal.java | 89 ++++++------------- .../games/moba/kit/hattori/HeroHattori.java | 4 +- .../games/moba/kit/hattori/SkillSnowball.java | 2 +- .../arcade/game/games/moba/minion/Minion.java | 15 +++- .../game/games/moba/minion/MinionManager.java | 12 ++- .../game/games/moba/minion/MinionWave.java | 6 +- .../moba/structure/point/CapturePoint.java | 10 +-- .../games/moba/structure/tower/Tower.java | 2 +- 12 files changed, 81 insertions(+), 88 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index e1af99064..366ad48c6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -99,7 +99,7 @@ public class Moba extends TeamGame PrepareFreeze = false; PrepareTime = PREPARE_TIME; DeathOut = false; - DeathSpectateSecs = 10; + DeathSpectateSecs = 12; HungerSet = 20; DamageFall = false; @@ -170,14 +170,15 @@ public class Moba extends TeamGame }) .setSuffix((perspective, subject) -> { - if (!IsAlive(subject)) + GameState state = GetState(); + GameTeam perspectiveTeam = GetTeam(perspective); + GameTeam subjectTeam = GetTeam(subject); + + if (!IsAlive(subject) || subjectTeam == null) { return ""; } - GameState state = GetState(); - GameTeam perspectiveTeam = GetTeam(perspective); - GameTeam subjectTeam = GetTeam(subject); MobaPlayer mobaPlayer = getMobaData(subject); String suffix; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java index 822b9b70d..0f69e2bdd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java @@ -69,8 +69,8 @@ public class PumpkinBoss extends MobaBoss private static final int DAMAGE_RANGE = 3; private static final int DAMAGE_DIRECT = 8; private static final int DAMAGE_DIRECT_RADIUS_SQUARED = 9; - private static final int HEALTH = 400; - private static final int HEALTH_OUT_OF_COMBAT = 10; + private static final int HEALTH = 200; + private static final int HEALTH_OUT_OF_COMBAT = 5; private static final Material[] BLOCKS = { Material.OBSIDIAN, Material.NETHERRACK, @@ -333,9 +333,15 @@ public class PumpkinBoss extends MobaBoss { Player player = iterator.next(); - if (!player.isOnline() || !player.hasPotionEffect(PotionEffectType.REGENERATION)) + if (!player.hasPotionEffect(PotionEffectType.REGENERATION)) { + if (player.isOnline()) + { + player.getInventory().setHelmet(player.getInventory().getHelmet()); + } + iterator.remove(); + continue; } sendFakeHelmet(player); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index 691ca05d1..779bdf9f8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -35,7 +35,7 @@ public class WitherBoss extends MobaBoss private static final String NAME = "Wither Boss"; private static final float SPEED_TARGET = 4F; private static final float SPEED_HOME = 6F; - private static final int INITIAL_HEALTH = 1750; + private static final int INITIAL_HEALTH = 500; private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); private GameTeam _team; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/attack/BossAttackEarthquake.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/attack/BossAttackEarthquake.java index 6279b1ffa..09e6e3cf4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/attack/BossAttackEarthquake.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/attack/BossAttackEarthquake.java @@ -26,7 +26,7 @@ public class BossAttackEarthquake implements MobaBossAttack private static final String ATTACK_NAME = "Earthquake"; private static final int RADIUS = 8; - private static final int DAMAGE = 8; + private static final int DAMAGE = 4; private static final double FALLING_BLOCK_CHANCE = 0.1; private final WitherBoss _boss; @@ -56,7 +56,7 @@ public class BossAttackEarthquake implements MobaBossAttack FallingBlock fallingBlock = block.getWorld().spawnFallingBlock(block.getLocation().add(0.5, 1, 0.5), block.getType(), block.getData()); fallingBlock.setHurtEntities(false); fallingBlock.setDropItem(false); - fallingBlock.setVelocity(UtilAlg.getTrajectory(boss, fallingBlock).multiply(0.25).setY(1.5)); + fallingBlock.setVelocity(UtilAlg.getTrajectory(boss, fallingBlock).multiply(0.25).setY(0.7 + Math.random())); } for (Entry entry : UtilEnt.getInRadius(boss.getLocation(), RADIUS).entrySet()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java index 5529afd8b..d71fa9ad3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java @@ -7,7 +7,6 @@ import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilPlayer; 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.games.moba.kit.HeroSkill; @@ -17,13 +16,9 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; -import java.util.HashSet; -import java.util.Set; - public class SkillPulseHeal extends HeroSkill { @@ -33,28 +28,11 @@ public class SkillPulseHeal extends HeroSkill }; private static final ItemStack SKILL_ITEM = new ItemBuilder(Material.INK_SACK, (byte) 10).build(); - private static final ItemStack SKILL_ITEM_TOGGLED = new ItemBuilder(Material.INK_SACK, (byte) 12).build(); - - private Set _toggled = new HashSet<>(); public SkillPulseHeal(int slot) { super("Pulse Heal", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); - addSkillItem(SKILL_ITEM_TOGGLED); - setCooldown(2000); - } - - @Override - public void giveItem(Player player) - { - if (_toggled.contains(player)) - { - player.getInventory().setItem(getSlot(), _items.get(1)); - } - else - { - player.getInventory().setItem(getSlot(), _items.get(0)); - } + setCooldown(8000); } @EventHandler @@ -66,17 +44,20 @@ public class SkillPulseHeal extends HeroSkill } Player player = event.getPlayer(); - - if (_toggled.contains(player)) - { - _toggled.remove(player); - } - else - { - _toggled.add(player); - } - useSkill(player); + + for (LivingEntity entity : UtilEnt.getInRadius(player.getLocation(), 5).keySet()) + { + // Don't heal enemies + if (!isTeamDamage(entity, player)) + { + continue; + } + + entity.setHealth(Math.min(entity.getHealth() + 4, entity.getMaxHealth())); + } + + displayPulse(player.getLocation().add(0, 0.5, 0)); } @EventHandler @@ -89,61 +70,41 @@ public class SkillPulseHeal extends HeroSkill for (Player player : Manager.GetGame().GetPlayers(true)) { - if (!hasPerk(player) || UtilPlayer.isSpectator(player) || !Recharge.Instance.use(player, GetName(), 5000, false, false)) + if (!hasPerk(player) || UtilPlayer.isSpectator(player)) { continue; } - Location location = player.getLocation(); - - if (_toggled.contains(player)) + for (LivingEntity entity : UtilEnt.getInRadius(player.getLocation(), 5).keySet()) { - for (LivingEntity entity : UtilEnt.getInRadius(player.getLocation(), 5).keySet()) + // Don't heal enemies + if (!isTeamDamage(entity, player)) { - // Don't heal self or enemies - if (entity.equals(player) || !isTeamDamage(entity, player)) - { - continue; - } - - entity.setHealth(Math.min(entity.getHealth() + 4, entity.getMaxHealth())); + continue; } - displayPulse(location, false); - } - else - { - player.setHealth(Math.min(player.getHealth() + 4, player.getMaxHealth())); - - displayPulse(location, true); + entity.setHealth(Math.min(entity.getHealth() + 4, entity.getMaxHealth())); } } } - @EventHandler - public void playerQuit(PlayerQuitEvent event) - { - _toggled.remove(event.getPlayer()); - } - - private void displayPulse(Location location, boolean inwards) + private void displayPulse(Location location) { Manager.runSyncTimer(new BukkitRunnable() { double theta = 0; - double radius = inwards ? 5 : 0; + double radius = 0; @Override public void run() { - if (inwards && radius < 0 || !inwards && radius > 5) + if (radius > 5) { cancel(); return; } - double increment = inwards ? -0.2 : 0.2; for (double theta2 = 0; theta2 < 2 * Math.PI; theta2 += Math.PI / 3) { double x = radius * Math.sin(theta + theta2); @@ -151,13 +112,13 @@ public class SkillPulseHeal extends HeroSkill location.add(x, 0.5, z); - UtilParticle.PlayParticleToAll(inwards ? ParticleType.HAPPY_VILLAGER : ParticleType.DRIP_WATER, location, 0, 0, 0, 0.1F, 1, ViewDist.LONG); + UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, location, 0, 0, 0, 0.1F, 1, ViewDist.LONG); location.subtract(x, 0.5, z); } theta += Math.PI / 100; - radius += increment; + radius += 0.2; } }, 0, 1); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java index 1cec7ac34..d9371bad2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java @@ -18,8 +18,8 @@ public class HeroHattori extends HeroKit private static final Perk[] PERKS = { new PerkDoubleJump("Double Jump", 1, 1, true, 3000, true), - new SkillSnowball(0), - new SkillSword(1), + new SkillSword(0), + new SkillSnowball(1), new SkillNinjaDash(2), new SkillNinjaBlade(3) }; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java index 6d90fd6be..43427a091 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java @@ -78,7 +78,7 @@ public class SkillSnowball extends HeroSkill implements IThrown if (target != null && !isTeamDamage(target, thrower)) { thrower.playSound(thrower.getLocation(), Sound.LAVA_POP, 1, 1.3F); - Manager.GetDamage().NewDamageEvent(target, thrower, (Projectile) data.getThrown(), DamageCause.CUSTOM, DAMAGE, true, true, false, UtilEnt.getName(thrower), GetName()); + Manager.GetDamage().NewDamageEvent(target, thrower, (Projectile) data.getThrown(), DamageCause.CUSTOM, DAMAGE, false, true, false, UtilEnt.getName(thrower), GetName()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java index 514d83dbd..d8092f1b1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/Minion.java @@ -3,21 +3,29 @@ package nautilus.game.arcade.game.games.moba.minion; import mineplex.core.common.util.UtilEnt; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Zombie; +import org.bukkit.inventory.ItemStack; public class Minion { private static final int HEALTH = 10; private static final float HIT_BOX = 2F; + private static final ItemStack[] SUPER_ARMOUR = { + new ItemStack(Material.IRON_BOOTS), + new ItemStack(Material.IRON_LEGGINGS), + new ItemStack(Material.IRON_CHESTPLATE), + new ItemStack(Material.IRON_HELMET) + }; private final LivingEntity _entity; private Location _target; private int _targetIndex; - public Minion(Location spawn, Class clazz) + public Minion(Location spawn, Class clazz, boolean superMinion) { _target = spawn; @@ -31,6 +39,11 @@ public class Minion ((Zombie) entity).setBaby(true); } + if (superMinion) + { + entity.getEquipment().setArmorContents(SUPER_ARMOUR); + } + UtilEnt.vegetate(entity); UtilEnt.silence(entity, true); UtilEnt.setBoundingBox(entity, HIT_BOX, HIT_BOX); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java index 6253b9ef9..df717f168 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -11,6 +11,7 @@ import nautilus.game.arcade.events.GamePrepareCountdownCommence; import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -77,6 +78,15 @@ public class MinionManager implements Listener { List path = new ArrayList<>(_path); boolean reverse = team.GetColor() == ChatColor.RED; + boolean superMinions = true; + + for (Tower tower : _host.getTowerManager().getTowers()) + { + if (!tower.isDead() && tower.getOwner().equals(team)) + { + superMinions = false; + } + } // If red team, reverse the pat if (reverse) @@ -84,7 +94,7 @@ public class MinionManager implements Listener Collections.reverse(path); } - MinionWave wave = new MinionWave(_host, this, team, path, reverse ? Zombie.class : PigZombie.class); + MinionWave wave = new MinionWave(_host, this, team, path, reverse ? Zombie.class : PigZombie.class, superMinions); _waves.add(wave); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index aa0c6bc95..032221220 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -48,17 +48,19 @@ public class MinionWave implements Listener private final MinionManager _minionManager; private final GameTeam _owner; private final Class _clazz; + private final boolean _superMinions; private final long _startTime; private final List _path; private final List _minions; - public MinionWave(Moba host, MinionManager minionManager, GameTeam owner, List path, Class clazz) + public MinionWave(Moba host, MinionManager minionManager, GameTeam owner, List path, Class clazz, boolean superMinions) { _host = host; _minionManager = minionManager; _owner = owner; _clazz = clazz; + _superMinions = superMinions; _startTime = System.currentTimeMillis(); _path = path; _minions = new ArrayList<>(MAX_MINIONS_PER_WAVE); @@ -85,7 +87,7 @@ public class MinionWave implements Listener { _host.CreatureAllowOverride = true; - Minion minion = new Minion(_path.get(0), _clazz); + Minion minion = new Minion(_path.get(0), _clazz, _superMinions); minion.getEntity().setMetadata(MobaConstants.TEAM_METADATA, new FixedMetadataValue(_host.getArcadeManager().getPlugin(), _owner.GetName())); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java index 8a1a1acc6..d949be280 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java @@ -145,17 +145,17 @@ public class CapturePoint } // Players on the point // Only inform if it has been a while - else if (!_owner.equals(highest) && UtilTime.elapsed(_lastInform, MIN_INFORM_TIME)) + else if ((_owner == null || !_owner.equals(highest)) && UtilTime.elapsed(_lastInform, MIN_INFORM_TIME)) { _lastInform = System.currentTimeMillis(); for (Player player : Bukkit.getOnlinePlayers()) { - player.playSound(player.getLocation(), Sound.GHAST_SCREAM2, 1, 1.2F); + player.playSound(player.getLocation(), Sound.GHAST_SCREAM2, 1, 1.0F); } _host.Announce(F.main("Game", "Team " + highest.GetFormattedName() + C.mBody + " is capturing beacon " + _colour + _name + C.mBody + "!"), false); - UtilTextMiddle.display("", "Team " + highest.GetFormattedName() + C.cWhite + " is capturing beacon " + _colour + _name, 0, 30, 10); + //UtilTextMiddle.display("", "Team " + highest.GetFormattedName() + C.cWhite + " is capturing beacon " + _colour + _name, 0, 30, 10); } // If it has just reached the maximum progress, set the owner. @@ -228,8 +228,8 @@ public class CapturePoint _owner = team; - _host.Announce(F.main("Game", "Team " + team.GetFormattedName() + C.mBody + " captured beacon " + _colour + _name + C.mBody + "!")); - UtilTextMiddle.display("", "Team " + team.GetFormattedName() + C.cWhite + " captured beacon " + _colour + _name, 0, 30, 10); + _host.Announce(F.main("Game", "Team " + team.GetFormattedName() + C.mBody + " captured the " + _colour + _name + C.mBody + " Beacon!")); + //UtilTextMiddle.display("", "Team " + team.GetFormattedName() + C.cWhite + " captured beacon " + _colour + _name, 0, 30, 10); UtilFirework.playFirework(_center, Type.BURST, team.GetColorBase(), false, false); UtilServer.CallEvent(new CapturePointCaptureEvent(this)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index 849b57326..ed5543597 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -179,7 +179,7 @@ public class Tower { player.playSound(player.getLocation(), Sound.ANVIL_LAND, 1, 0.5F); player.sendMessage(F.main("Game", "Your Tower is under attack!")); - UtilTextMiddle.display("", _team.GetColor() + "Your Tower is under attack!", 0, 30, 10, player); + //UtilTextMiddle.display("", _team.GetColor() + "Your Tower is under attack!", 0, 30, 10, player); } } } From 7e05cbfa877e20b847d060f8e0eab71dd2d13144 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 2 Jun 2017 18:43:07 +0100 Subject: [PATCH 43/57] Biff --- .../game/arcade/game/games/moba/Moba.java | 2 +- .../arcade/game/games/moba/kit/HeroSkill.java | 19 +-- .../moba/kit/anath/SkillFireProjectile.java | 2 +- .../game/games/moba/kit/biff/HeroBiff.java | 30 ++++ .../games/moba/kit/biff/SkillBiffDash.java | 142 ++++++++++++++++++ .../game/games/moba/kit/biff/SkillLeash.java | 112 ++++++++++++++ .../games/moba/kit/biff/SkillWarHorse.java | 108 +++++++++++++ .../games/moba/kit/dana/SkillPulseHeal.java | 31 ---- .../game/games/moba/kit/dana/SkillRally.java | 3 +- .../games/moba/kit/devon/SkillInfinity.java | 2 + .../moba/kit/hattori/SkillNinjaBlade.java | 70 +++++++-- .../moba/kit/hattori/SkillNinjaDash.java | 2 +- .../games/moba/kit/hattori/SkillSnowball.java | 2 +- .../game/games/moba/minion/MinionManager.java | 32 +++- .../moba/structure/point/CapturePoint.java | 2 +- .../games/moba/structure/tower/Tower.java | 7 + .../moba/structure/tower/TowerManager.java | 2 +- 17 files changed, 501 insertions(+), 67 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 366ad48c6..12d2f38ff 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -174,7 +174,7 @@ public class Moba extends TeamGame GameTeam perspectiveTeam = GetTeam(perspective); GameTeam subjectTeam = GetTeam(subject); - if (!IsAlive(subject) || subjectTeam == null) + if (!IsAlive(subject) || perspectiveTeam == null || subjectTeam == null) { return ""; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index ca3ebd0ab..5d0dcddd9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -12,8 +12,8 @@ import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.PlayerKitGiveEvent; -import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Perk; import org.bukkit.Material; @@ -248,7 +248,7 @@ public class HeroSkill extends Perk } - public void useSkill(Player player) + public void useSkill(Player player) { _lastSkill.put(player.getUniqueId(), System.currentTimeMillis()); if (_cooldown > 0 && !UtilPlayer.isSpectator(player)) @@ -358,24 +358,15 @@ public class HeroSkill extends Perk protected boolean isTeamDamage(LivingEntity damagee, LivingEntity damager) { - if (!(damagee instanceof Player) || !(damager instanceof Player)) + if (!(damager instanceof Player)) { return false; } - Player damageePlayer = (Player) damagee; - Player damagerPlayer = (Player) damager; + GameTeam team = Manager.GetGame().GetTeam((Player) damager); - Game game = Manager.GetGame(); - GameTeam damageeTeam = game.GetTeam(damageePlayer); - GameTeam damagerTeam = game.GetTeam(damagerPlayer); + return team != null && MobaUtil.isTeamEntity(damagee, team); - if (damageeTeam == null || damagerTeam == null) - { - return false; - } - - return damageeTeam.equals(damagerTeam); } public int getSlot() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java index c17176547..74591c991 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java @@ -25,7 +25,7 @@ public class SkillFireProjectile extends HeroSkill public SkillFireProjectile(int slot) { - super("Fire Item", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + super("Flame Wand", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java new file mode 100644 index 000000000..7be9bc451 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java @@ -0,0 +1,30 @@ +package nautilus.game.arcade.game.games.moba.kit.biff; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.game.games.moba.kit.common.SkillSword; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +public class HeroBiff extends HeroKit +{ + + private static final String[] DESCRIPTION = { + "Something something" + }; + + private static final Perk[] PERKS = { + new SkillSword(0), + new SkillLeash(1), + new SkillBiffDash(2) + }; + + private static final ItemStack IN_HAND = new ItemStack(Material.IRON_SWORD); + + public HeroBiff(ArcadeManager manager) + { + super(manager, "Biff", DESCRIPTION, PERKS, IN_HAND, MobaRole.WARRIOR); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java new file mode 100644 index 000000000..15fd2c677 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java @@ -0,0 +1,142 @@ +package nautilus.game.arcade.game.games.moba.kit.biff; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +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.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Effect; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +public class SkillBiffDash extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Dash along the ground, leaving fire behind you.", + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); + + private final Map _active = new HashMap<>(); + + public SkillBiffDash(int slot) + { + super("Battle Leap", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + + setCooldown(11000); + setSneakActivate(true); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + useSkill(player); + } + + @EventHandler + public void toggleSneak(PlayerToggleSneakEvent event) + { + if (!isSkillSneak(event)) + { + return; + } + + Player player = event.getPlayer(); + + useSkill(player); + } + + @Override + public void useSkill(Player player) + { + if (_active.containsKey(player)) + { + return; + } + + Vector direction = player.getLocation().getDirection().setY(1); + + UtilAction.velocity(player, direction); + + player.getWorld().playSound(player.getLocation(), Sound.IRONGOLEM_THROW, 1, 1F); + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, player.getLocation().add(0, 0.4, 0), 0.25F, 0.25F, 0.25F, 0.1F, 10, ViewDist.LONG); + + _active.put(player, System.currentTimeMillis()); + } + + @EventHandler + public void landed(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + { + return; + } + + Iterator iterator = _active.keySet().iterator(); + + while (iterator.hasNext()) + { + Player player = iterator.next(); + long start = _active.get(player); + + if (!player.isOnline()) + { + iterator.remove(); + } + + // They haven't just activated it + if (!UtilTime.elapsed(start, 1000) || !UtilEnt.isGrounded(player)) + { + continue; + } + + for (LivingEntity entity : UtilEnt.getInRadius(player.getLocation(), 5).keySet()) + { + if (isTeamDamage(player, entity)) + { + continue; + } + + Block block = entity.getLocation().getBlock().getRelative(BlockFace.DOWN); + entity.getWorld().playEffect(block.getLocation().add(0.5, 0.5, 0.5), Effect.STEP_SOUND, block.getType(), block.getData()); + + Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, 4, false, true, false, UtilEnt.getName(player), GetName()); + UtilAction.velocity(entity, new Vector(0, 0.6 + Math.random() / 2, 0)); + } + } + } + + @EventHandler + public void playerDeath(PlayerDeathEvent event) + { + _active.remove(event.getEntity()); + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java new file mode 100644 index 000000000..cead3d877 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java @@ -0,0 +1,112 @@ +package nautilus.game.arcade.game.games.moba.kit.biff; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffectType; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +public class SkillLeash extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Fires an Ember at high speed in front of you.", + "Any enemies it collides with take damage and are set on fire." + }; + + private static final ItemStack SKILL_ITEM = new ItemStack(Material.LEASH); + + private final Map> _leashed = new HashMap<>(); + + public SkillLeash(int slot) + { + super("Tether", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + setCooldown(12000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + useSkill(player); + + List nearbyPlayers = UtilPlayer.getNearby(player.getLocation(), 3); + + _leashed.put(player, nearbyPlayers); + + for (Player nearby : nearbyPlayers) + { + if (isTeamDamage(nearby, player)) + { + continue; + } + + nearby.setLeashHolder(player); + nearby.setPullWhileLeashed(false); + nearby.setShouldBreakLeash(false); + nearby.sendMessage(F.main("Game", F.name(player.getName()) + " leashed you.")); + Manager.GetCondition().Factory().Slow(GetName(), nearby, player, 5, 0, false, true, true, false); + } + + useActiveSkill(() -> + { + for (Player leashed : _leashed.remove(player)) + { + removeEffect(leashed); + } + + }, player, 5000); + } + + @EventHandler + public void updateLeashed(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + for (Entry> entry : _leashed.entrySet()) + { + Iterator iterator = entry.getValue().iterator(); + + while (iterator.hasNext()) + { + Player leashed = iterator.next(); + + if (UtilMath.offsetSquared(entry.getKey(), leashed) < 25) + { + continue; + } + + removeEffect(leashed); + iterator.remove(); + } + } + } + + private void removeEffect(Player player) + { + player.setLeashHolder(null); + player.removePotionEffect(PotionEffectType.SLOW); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java new file mode 100644 index 000000000..ec8a428d2 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java @@ -0,0 +1,108 @@ +package nautilus.game.arcade.game.games.moba.kit.biff; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Material; +import org.bukkit.entity.Horse; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +public class SkillWarHorse extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Fires an Ember at high speed in front of you.", + "Any enemies it collides with take damage and are set on fire." + }; + + private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); + private static final ItemStack HORSE_ARMOUR = new ItemStack(Material.IRON_BARDING); + + private final Set _data = new HashSet<>(); + + public SkillWarHorse(int slot) + { + super("Cavalry Charge", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + setCooldown(45000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + for (WarHorseData data : _data) + { + if (data.Owner.equals(player)) + { + return; + } + } + + Manager.GetGame().CreatureAllowOverride = true; + + Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class); + + UtilEnt.vegetate(horse); + horse.setJumpStrength(0); + horse.setDomestication(horse.getMaxDomestication()); + horse.getInventory().setArmor(HORSE_ARMOUR); + horse.setPassenger(player); + + Manager.GetGame().CreatureAllowOverride = false; + + _data.add(new WarHorseData(player, horse)); + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator iterator = _data.iterator(); + + while (iterator.hasNext()) + { + WarHorseData data = iterator.next(); + + if (UtilTime.elapsed(data.Start, 6000) + { + data.Horse.remove(); + iterator.remove(); + } + else if () + } + } + + private class WarHorseData + { + public Player Owner; + public Horse Horse; + public long Start; + + WarHorseData(Player owner, Horse horse) + { + Owner = owner; + Horse = horse; + Start = System.currentTimeMillis(); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java index d71fa9ad3..5c17f5fdf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java @@ -5,10 +5,7 @@ import mineplex.core.common.util.UtilEvent.ActionType; 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.itemstack.ItemBuilder; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Location; import org.bukkit.Material; @@ -60,34 +57,6 @@ public class SkillPulseHeal extends HeroSkill displayPulse(player.getLocation().add(0, 0.5, 0)); } - @EventHandler - public void updatePulse(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - { - return; - } - - for (Player player : Manager.GetGame().GetPlayers(true)) - { - if (!hasPerk(player) || UtilPlayer.isSpectator(player)) - { - continue; - } - - for (LivingEntity entity : UtilEnt.getInRadius(player.getLocation(), 5).keySet()) - { - // Don't heal enemies - if (!isTeamDamage(entity, player)) - { - continue; - } - - entity.setHealth(Math.min(entity.getHealth() + 4, entity.getMaxHealth())); - } - } - } - private void displayPulse(Location location) { Manager.runSyncTimer(new BukkitRunnable() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java index 05331f42d..a1cba5e67 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java @@ -68,8 +68,7 @@ public class SkillRally extends HeroSkill } } - vector.setY(Math.min(vector.getY(), 1)); - vector.setY(Math.max(vector.getY(), 1.5)); + vector.setY(1.5); UtilAction.velocity(player, vector); _data.add(new RallyData(player)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java index 77bc3c242..3935b4ec6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java @@ -64,6 +64,8 @@ public class SkillInfinity extends HeroSkill return; } + // Give 1 arrow just incase the player didn't have one + _kit.giveAmmo(player, 1); bow.addEnchantment(Enchantment.ARROW_INFINITE, 1); _active.add(player); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java index 638a243a0..d4d240265 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java @@ -6,10 +6,10 @@ import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.recharge.Recharge; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.kit.common.SkillSword; +import nautilus.game.arcade.kit.Perk; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Entity; @@ -17,9 +17,10 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; -import java.util.HashSet; -import java.util.Set; +import java.util.HashMap; +import java.util.Map; import java.util.UUID; public class SkillNinjaBlade extends HeroSkill @@ -34,12 +35,14 @@ public class SkillNinjaBlade extends HeroSkill .setTitle(C.cGreenB + "NINJA BLADE") .setUnbreakable(true) .build(); + private static final int ACTIVE_SLOT = 0; + private static final int BASE_DAMAGE_INCREASE = 4; - private Set _active = new HashSet<>(); + private Map _active = new HashMap<>(); public SkillNinjaBlade(int slot) { - super("Ninja Blade", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + super("Ender Blade", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); setCooldown(60000); setDropItemActivate(true); @@ -55,12 +58,55 @@ public class SkillNinjaBlade extends HeroSkill } Player player = event.getPlayer(); + PlayerInventory inventory = player.getInventory(); - player.getInventory().setItem(getSlot(), ACTIVE_ITEM); - player.getInventory().setHeldItemSlot(getSlot()); - _active.add(player.getUniqueId()); + inventory.setItem(ACTIVE_SLOT, ACTIVE_ITEM); + inventory.setHeldItemSlot(ACTIVE_SLOT); - useActiveSkill(() -> _active.remove(player.getUniqueId()), player, 7000); + int damage = BASE_DAMAGE_INCREASE; + ItemStack sword = inventory.getItem(ACTIVE_SLOT); + + if (sword == null) + { + return; + } + + Material material = sword.getType(); + + // Increase damage based on the sword they had previously + switch (material) + { + case WOOD_SWORD: + damage += 2; + break; + case STONE_SWORD: + damage += 3; + break; + case GOLD_SWORD: + case IRON_SWORD: + damage += 4; + break; + case DIAMOND_SWORD: + damage += 5; + break; + } + + _active.put(player.getUniqueId(), damage); + + useActiveSkill(() -> + { + + _active.remove(player.getUniqueId()); + + for (Perk perk : Kit.GetPerks()) + { + if (perk instanceof SkillSword) + { + ((SkillSword) perk).giveItem(player); + } + } + + }, player, 7000); } @EventHandler @@ -77,14 +123,14 @@ public class SkillNinjaBlade extends HeroSkill ItemStack itemStack = player.getItemInHand(); - if (!_active.contains(player.getUniqueId()) || itemStack == null || itemStack.getType() != Material.DIAMOND_SWORD || itemStack.getItemMeta() == null || !itemStack.getItemMeta().getDisplayName().equals(ACTIVE_ITEM.getItemMeta().getDisplayName())) + if (!_active.containsKey(player.getUniqueId()) || itemStack == null || itemStack.getType() != Material.DIAMOND_SWORD || itemStack.getItemMeta() == null || !itemStack.getItemMeta().getDisplayName().equals(ACTIVE_ITEM.getItemMeta().getDisplayName())) { return; } UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, entity.getLocation().add(0, 1, 0), 1F, 1F, 1F, 0.1F, 50, ViewDist.LONG); entity.getWorld().playSound(entity.getLocation(), Sound.EXPLODE, 2, 0.5F); - event.AddMod(GetName(), 4); + event.AddMod(GetName(), _active.get(player.getUniqueId())); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaDash.java index 93439e6ca..0b886a430 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaDash.java @@ -37,7 +37,7 @@ public class SkillNinjaDash extends DashSkill public SkillNinjaDash(int slot) { - super("Dash", DESCRIPTION, SKILL_ITEM, slot); + super("Ninja Dash", DESCRIPTION, SKILL_ITEM, slot); setCooldown(7000); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java index 43427a091..5b80853d6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java @@ -31,7 +31,7 @@ public class SkillSnowball extends HeroSkill implements IThrown public SkillSnowball(int slot) { - super("Snowball", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + super("Shuriken", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); setCooldown(1000); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java index df717f168..6c6104a45 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.moba.minion; import mineplex.core.common.Rank; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilServer; @@ -12,6 +13,7 @@ import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; +import nautilus.game.arcade.game.games.moba.structure.tower.TowerDestroyEvent; import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -21,7 +23,11 @@ import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; import java.util.concurrent.TimeUnit; public class MinionManager implements Listener @@ -82,9 +88,10 @@ public class MinionManager implements Listener for (Tower tower : _host.getTowerManager().getTowers()) { - if (!tower.isDead() && tower.getOwner().equals(team)) + if (!tower.isDead() && !tower.getOwner().equals(team)) { superMinions = false; + break; } } @@ -100,6 +107,27 @@ public class MinionManager implements Listener } } + @EventHandler + public void towerDestroy(TowerDestroyEvent event) + { + Tower tower = event.getTower(); + + if (tower.isFirstTower()) + { + return; + } + + for (GameTeam team : _host.GetTeamList()) + { + if (team.equals(tower.getOwner())) + { + continue; + } + + _host.Announce(F.main("Game", team.GetFormattedName() + "'s " + C.mBody + "minions are now " + C.cYellowB + "Super-Charged" + C.mBody + "!"), false); + } + } + public void setEnabled(boolean enabled) { _enabled = enabled; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java index d949be280..e68722aa2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java @@ -154,7 +154,7 @@ public class CapturePoint player.playSound(player.getLocation(), Sound.GHAST_SCREAM2, 1, 1.0F); } - _host.Announce(F.main("Game", "Team " + highest.GetFormattedName() + C.mBody + " is capturing beacon " + _colour + _name + C.mBody + "!"), false); + _host.Announce(F.main("Game", "Team " + highest.GetFormattedName() + C.mBody + " is capturing the " + _colour + _name + C.mBody + "Beacon!"), false); //UtilTextMiddle.display("", "Team " + highest.GetFormattedName() + C.cWhite + " is capturing beacon " + _colour + _name, 0, 30, 10); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index ed5543597..48bddbc19 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -150,6 +150,13 @@ public class Tower // Boom! explode(); + for (Player player : Bukkit.getOnlinePlayers()) + { + player.playSound(player.getLocation(), Sound.BLAZE_BREATH, 1, 0.4F); + } + + _host.Announce(F.main("Game", _team.GetFormattedName() + C.mBody + " has lost a tower!"), false); + // Nullify everything and remove all entities _target = null; setLaserTarget(null); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index 02ce53665..22831e831 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -12,7 +12,6 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; -import nautilus.game.arcade.game.games.moba.util.MobaConstants; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.Sound; @@ -192,6 +191,7 @@ public class TowerManager implements Listener if (UtilMath.offsetSquared(playerLocation, entityLocation) > Tower.TARGET_RANGE_SQUARED) { + event.setCancelled(true); return; } } From e094446be49d09044bfda862c6af320a2336df6f Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 3 Jun 2017 15:33:26 +0100 Subject: [PATCH 44/57] Add biff to the hero list --- .../src/nautilus/game/arcade/game/games/moba/Moba.java | 2 ++ .../game/arcade/game/games/moba/kit/biff/SkillWarHorse.java | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 12d2f38ff..b0a0fb4f1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -22,6 +22,7 @@ import nautilus.game.arcade.game.games.moba.gold.GoldManager; import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.kit.KitPlayer; import nautilus.game.arcade.game.games.moba.kit.anath.HeroAnath; +import nautilus.game.arcade.game.games.moba.kit.biff.HeroBiff; import nautilus.game.arcade.game.games.moba.kit.bob.HeroBob; import nautilus.game.arcade.game.games.moba.kit.dana.HeroDana; import nautilus.game.arcade.game.games.moba.kit.devon.HeroDevon; @@ -91,6 +92,7 @@ public class Moba extends TeamGame new HeroDevon(Manager), new HeroAnath(Manager), new HeroDana(Manager), + new HeroBiff(Manager), new HeroBob(Manager) }; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java index ec8a428d2..f1089f02f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java @@ -83,12 +83,12 @@ public class SkillWarHorse extends HeroSkill { WarHorseData data = iterator.next(); - if (UtilTime.elapsed(data.Start, 6000) + if (UtilTime.elapsed(data.Start, 6000)) { data.Horse.remove(); iterator.remove(); } - else if () + //else if () } } From a3fd81f7637b8e226e13ec76a26cd7a00fb95853 Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 4 Jun 2017 10:52:43 +0100 Subject: [PATCH 45/57] Fix Biff's skills not cleaning up --- .../games/moba/kit/biff/SkillBiffDash.java | 6 +++- .../game/games/moba/kit/biff/SkillLeash.java | 31 +++++++++---------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java index 15fd2c677..a18f97d51 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java @@ -81,6 +81,8 @@ public class SkillBiffDash extends HeroSkill return; } + super.useSkill(player); + Vector direction = player.getLocation().getDirection().setY(1); UtilAction.velocity(player, direction); @@ -111,7 +113,7 @@ public class SkillBiffDash extends HeroSkill iterator.remove(); } - // They haven't just activated it + // They have just activated it if (!UtilTime.elapsed(start, 1000) || !UtilEnt.isGrounded(player)) { continue; @@ -130,6 +132,8 @@ public class SkillBiffDash extends HeroSkill Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, 4, false, true, false, UtilEnt.getName(player), GetName()); UtilAction.velocity(entity, new Vector(0, 0.6 + Math.random() / 2, 0)); } + + iterator.remove(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java index cead3d877..32d7f07c6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java @@ -47,34 +47,33 @@ public class SkillLeash extends HeroSkill } Player player = event.getPlayer(); - useSkill(player); List nearbyPlayers = UtilPlayer.getNearby(player.getLocation(), 3); - _leashed.put(player, nearbyPlayers); + nearbyPlayers.removeIf(other -> isTeamDamage(other, player)); + + if (!nearbyPlayers.isEmpty()) + { + _leashed.put(player, nearbyPlayers); + + useActiveSkill(() -> + { + for (Player leashed : _leashed.remove(player)) + { + removeEffect(leashed); + } + + }, player, 5000); + } for (Player nearby : nearbyPlayers) { - if (isTeamDamage(nearby, player)) - { - continue; - } - nearby.setLeashHolder(player); nearby.setPullWhileLeashed(false); nearby.setShouldBreakLeash(false); nearby.sendMessage(F.main("Game", F.name(player.getName()) + " leashed you.")); Manager.GetCondition().Factory().Slow(GetName(), nearby, player, 5, 0, false, true, true, false); } - - useActiveSkill(() -> - { - for (Player leashed : _leashed.remove(player)) - { - removeEffect(leashed); - } - - }, player, 5000); } @EventHandler From a800fee08ce341b35bd9dfa63d76cc28406efb7b Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 6 Jun 2017 22:59:40 +0100 Subject: [PATCH 46/57] Testing session changes --- .../games/moba/boss/pumpkin/PumpkinBoss.java | 10 ++--- .../game/games/moba/kit/biff/HeroBiff.java | 3 +- .../games/moba/kit/biff/SkillBiffDash.java | 13 +++--- .../game/games/moba/kit/biff/SkillLeash.java | 40 +++++++++++-------- .../games/moba/kit/biff/SkillWarHorse.java | 16 +++++++- .../moba/kit/hattori/SkillNinjaBlade.java | 2 +- .../game/games/moba/minion/MinionManager.java | 30 +++++++++----- .../game/games/moba/minion/MinionWave.java | 13 +++--- .../moba/structure/point/CapturePoint.java | 2 +- 9 files changed, 79 insertions(+), 50 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java index 0f69e2bdd..ce850e828 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java @@ -66,11 +66,11 @@ public class PumpkinBoss extends MobaBoss private static final int CONDITION_LENGTH = 60; private static final double CONDITION_DAMAGE_FACTOR = 1.5; private static final int DAMAGE_RADIUS = 2; - private static final int DAMAGE_RANGE = 3; - private static final int DAMAGE_DIRECT = 8; + private static final int DAMAGE_RANGE = 2; + private static final int DAMAGE_DIRECT = 6; private static final int DAMAGE_DIRECT_RADIUS_SQUARED = 9; - private static final int HEALTH = 200; - private static final int HEALTH_OUT_OF_COMBAT = 5; + private static final int HEALTH = 100; + private static final int HEALTH_OUT_OF_COMBAT = 2; private static final Material[] BLOCKS = { Material.OBSIDIAN, Material.NETHERRACK, @@ -128,7 +128,7 @@ public class PumpkinBoss extends MobaBoss player.playSound(player.getLocation(), Sound.WITHER_SPAWN, 1, 0.4F); } - for (Entry entry : UtilBlock.getInRadius(skeleton.getLocation(), 20).entrySet()) + for (Entry entry : UtilBlock.getInRadius(skeleton.getLocation(), 12).entrySet()) { Block block = entry.getKey(); double setChance = entry.getValue(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java index 7be9bc451..fe65df976 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java @@ -18,7 +18,8 @@ public class HeroBiff extends HeroKit private static final Perk[] PERKS = { new SkillSword(0), new SkillLeash(1), - new SkillBiffDash(2) + new SkillBiffDash(2), + new SkillWarHorse(3) }; private static final ItemStack IN_HAND = new ItemStack(Material.IRON_SWORD); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java index a18f97d51..907d5f7fd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.moba.kit.biff; import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle; @@ -11,10 +12,9 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Effect; +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.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -88,7 +88,7 @@ public class SkillBiffDash extends HeroSkill UtilAction.velocity(player, direction); player.getWorld().playSound(player.getLocation(), Sound.IRONGOLEM_THROW, 1, 1F); - UtilParticle.PlayParticleToAll(ParticleType.CLOUD, player.getLocation().add(0, 0.4, 0), 0.25F, 0.25F, 0.25F, 0.1F, 10, ViewDist.LONG); + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, player.getLocation().add(0, 0.6, 0), 0.5F, 0.5F, 0.5F, 0.1F, 15, ViewDist.LONG); _active.put(player, System.currentTimeMillis()); } @@ -126,8 +126,11 @@ public class SkillBiffDash extends HeroSkill continue; } - Block block = entity.getLocation().getBlock().getRelative(BlockFace.DOWN); - entity.getWorld().playEffect(block.getLocation().add(0.5, 0.5, 0.5), Effect.STEP_SOUND, block.getType(), block.getData()); + for (int i = 0; i < 5; i++) + { + Location location = UtilAlg.getRandomLocation(entity.getEyeLocation(), 3); + entity.getWorld().playEffect(location, Effect.STEP_SOUND, Material.GRASS, 0); + } Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, 4, false, true, false, UtilEnt.getName(player), GetName()); UtilAction.velocity(entity, new Vector(0, 0.6 + Math.random() / 2, 0)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java index 32d7f07c6..7db008510 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java @@ -41,39 +41,45 @@ public class SkillLeash extends HeroSkill @EventHandler public void interact(PlayerInteractEvent event) { - if (!isSkillItem(event)) + Player player = event.getPlayer(); + + if (!isSkillItem(event) || _leashed.containsKey(player)) { return; } - Player player = event.getPlayer(); - - List nearbyPlayers = UtilPlayer.getNearby(player.getLocation(), 3); - + List nearbyPlayers = UtilPlayer.getNearby(player.getLocation(), 5); nearbyPlayers.removeIf(other -> isTeamDamage(other, player)); - if (!nearbyPlayers.isEmpty()) + if (nearbyPlayers.isEmpty()) { - _leashed.put(player, nearbyPlayers); - - useActiveSkill(() -> - { - for (Player leashed : _leashed.remove(player)) - { - removeEffect(leashed); - } - - }, player, 5000); + return; } + _leashed.put(player, nearbyPlayers); + + StringBuilder builder = new StringBuilder(F.main("Game", "You leashed ")); + for (Player nearby : nearbyPlayers) { nearby.setLeashHolder(player); nearby.setPullWhileLeashed(false); nearby.setShouldBreakLeash(false); - nearby.sendMessage(F.main("Game", F.name(player.getName()) + " leashed you.")); + nearby.sendMessage(F.main("Game", F.name(nearby.getName()) + " leashed you.")); + builder.append(F.name(player.getName())).append(", "); Manager.GetCondition().Factory().Slow(GetName(), nearby, player, 5, 0, false, true, true, false); } + + player.sendMessage(builder.toString()); + + useActiveSkill(() -> + { + for (Player leashed : _leashed.remove(player)) + { + removeEffect(leashed); + } + + }, player, 5000); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java index f1089f02f..7aabbcea9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java @@ -6,12 +6,15 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Horse; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.FixedMetadataValue; import java.util.HashSet; import java.util.Iterator; @@ -33,7 +36,9 @@ public class SkillWarHorse extends HeroSkill public SkillWarHorse(int slot) { super("Cavalry Charge", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + setCooldown(45000); + setDropItemActivate(true); } @EventHandler @@ -60,9 +65,12 @@ public class SkillWarHorse extends HeroSkill UtilEnt.vegetate(horse); horse.setJumpStrength(0); + horse.setMaxDomestication(1); horse.setDomestication(horse.getMaxDomestication()); horse.getInventory().setArmor(HORSE_ARMOUR); + horse.setOwner(player); horse.setPassenger(player); + horse.setMetadata(MobaConstants.TEAM_METADATA, new FixedMetadataValue(Manager.getPlugin(), Manager.GetGame().GetTeam(player).GetName())); Manager.GetGame().CreatureAllowOverride = false; @@ -88,7 +96,13 @@ public class SkillWarHorse extends HeroSkill data.Horse.remove(); iterator.remove(); } - //else if () + else + { + Player player = data.Owner; + Location target = player.getLocation().getDirection().multiply(3).toLocation(player.getWorld()); + + UtilEnt.CreatureMoveFast(data.Horse, target, 3F); + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java index d4d240265..9a9ebe0a8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java @@ -32,7 +32,7 @@ public class SkillNinjaBlade extends HeroSkill }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); private static final ItemStack ACTIVE_ITEM = new ItemBuilder(Material.DIAMOND_SWORD) - .setTitle(C.cGreenB + "NINJA BLADE") + .setTitle(C.cGreenB + "ENDER BLADE") .setUnbreakable(true) .build(); private static final int ACTIVE_SLOT = 0; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java index 6c6104a45..1d90780a7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -17,6 +17,9 @@ import nautilus.game.arcade.game.games.moba.structure.tower.TowerDestroyEvent; import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.ChatColor; import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.Sign; import org.bukkit.entity.PigZombie; import org.bukkit.entity.Player; import org.bukkit.entity.Zombie; @@ -162,21 +165,26 @@ public class MinionManager implements Listener ArrayList path = new ArrayList<>(_host.WorldData.GetDataLocs(MobaConstants.MINION_PATH)); ArrayList organisedPath = new ArrayList<>(path.size()); - while (organisedPath.size() != path.size()) + while (!path.isEmpty()) { - Location closest = UtilAlg.findClosest(start, path); + Location dataPoint = UtilAlg.findClosest(start, path); - if (closest == null) - { - // Rra rro Shaggy - continue; - } - - organisedPath.add(closest); - start = closest; + organisedPath.add(dataPoint); + path.remove(dataPoint); + start = dataPoint; } // Step 3 - Put the ordered path inside the map - _path = path; + _path = organisedPath; + +// int i = 0; +// for (Location location : _path) +// { +// Block block = location.getBlock(); +// block.setType(Material.SIGN_POST); +// Sign sign = (Sign) block.getState(); +// sign.setLine(0, "P" + i++); +// sign.update(); +// } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index 032221220..a00dcfa24 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -235,19 +235,16 @@ public class MinionWave implements Listener { for (MobaBoss boss : _host.getBossManager().getBosses()) { - if (boss.isDead()) + if (boss.isDead() || !(boss instanceof WitherBoss)) { continue; } - if (boss instanceof WitherBoss) - { - WitherBoss witherBoss = (WitherBoss) boss; + WitherBoss witherBoss = (WitherBoss) boss; - if (witherBoss.getTeam().equals(_owner)) - { - continue; - } + if (witherBoss.getTeam().equals(_owner)) + { + continue; } Location location = boss.getEntity().getLocation(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java index e68722aa2..25bb5599c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java @@ -154,7 +154,7 @@ public class CapturePoint player.playSound(player.getLocation(), Sound.GHAST_SCREAM2, 1, 1.0F); } - _host.Announce(F.main("Game", "Team " + highest.GetFormattedName() + C.mBody + " is capturing the " + _colour + _name + C.mBody + "Beacon!"), false); + _host.Announce(F.main("Game", "Team " + highest.GetFormattedName() + C.mBody + " is capturing the " + _colour + _name + C.mBody + " Beacon!"), false); //UtilTextMiddle.display("", "Team " + highest.GetFormattedName() + C.cWhite + " is capturing beacon " + _colour + _name, 0, 30, 10); } From 044927252c54ad457e12105ca09b1e4daba87289 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 8 Jun 2017 01:55:07 +0100 Subject: [PATCH 47/57] More changes! --- .../mineplex/core/itemstack/ItemBuilder.java | 68 ++++++--- .../game/arcade/game/games/moba/Moba.java | 15 +- .../game/arcade/game/games/moba/MobaRole.java | 41 +----- .../arcade/game/games/moba/buff/Buff.java | 20 +++ .../game/games/moba/buff/BuffManager.java | 16 +++ .../moba/buff/buffs/BuffPumpkinKing.java | 20 +++ .../games/moba/general/EnderPearlManager.java | 100 +++++++++++++ .../arcade/game/games/moba/kit/HeroKit.java | 44 ++++-- .../arcade/game/games/moba/kit/HeroSkill.java | 21 ++- .../games/moba/kit/anath/SkillMeteor.java | 15 +- .../games/moba/kit/biff/SkillBiffDash.java | 7 +- .../game/games/moba/kit/biff/SkillLeash.java | 25 ++-- .../games/moba/kit/biff/SkillWarHorse.java | 7 +- .../moba/kit/bob/SkillBuildPainting.java | 1 + .../games/moba/kit/common/LeashedEntity.java | 76 ++++++++++ .../game/games/moba/kit/dana/SkillRally.java | 1 + .../games/moba/kit/devon/SkillInfinity.java | 2 +- .../games/moba/kit/devon/SkillTNTArrows.java | 2 +- .../moba/kit/hattori/SkillNinjaBlade.java | 16 ++- .../game/games/moba/minion/MinionWave.java | 5 +- .../moba/prepare/PrepareInformation.java | 109 --------------- .../games/moba/prepare/PrepareManager.java | 35 +++-- .../games/moba/prepare/PrepareSelection.java | 10 +- .../arcade/game/games/moba/shop/MobaItem.java | 2 + .../arcade/game/games/moba/shop/MobaShop.java | 132 ++++++++++++++++-- .../games/moba/shop/MobaShopCategory.java | 59 +++++++- .../games/moba/shop/MobaShopCategoryMenu.java | 10 +- .../game/games/moba/shop/MobaShopMenu.java | 30 ++++ .../moba/shop/assassin/MobaAssassinShop.java | 1 + .../moba/shop/hunter/MobaHunterShop.java | 1 + .../games/moba/shop/mage/MobaMageShop.java | 62 ++++---- .../moba/shop/warrior/MobaWarriorShop.java | 113 +++++++-------- .../moba/structure/tower/TowerManager.java | 88 +++++++----- .../arcade/game/games/moba/util/MobaUtil.java | 7 + .../mineplex/gemhunters/loot/LootModule.java | 1 + 35 files changed, 811 insertions(+), 351 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/Buff.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/EnderPearlManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/LeashedEntity.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java index 603f5e150..8a07b03fa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java @@ -1,13 +1,7 @@ package mineplex.core.itemstack; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; - +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilInv; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; @@ -21,10 +15,18 @@ import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.inventory.meta.FireworkEffectMeta; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.inventory.meta.SkullMeta; +import org.bukkit.potion.PotionEffect; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilInv; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; public class ItemBuilder { @@ -53,14 +55,15 @@ public class ItemBuilder private Color _color; private short _data; private short _durability; - private final HashMap _enchants = new HashMap(); - private final List _lore = new ArrayList(); + private final Map _enchants = new HashMap<>(); + private final List _lore = new ArrayList<>(); private Material _mat; private String _title = null; private boolean _unbreakable; private boolean _glow; private String _playerHeadName = null; - private HashSet _itemFlags = new HashSet(); + private Set _itemFlags = new HashSet<>(); + private List _potionEffects = new ArrayList<>(); public ItemBuilder(ItemStack item) { @@ -86,6 +89,13 @@ public class ItemBuilder { setColor(((LeatherArmorMeta) meta).getColor()); } + else if (meta instanceof PotionMeta) + { + for (PotionEffect effect : ((PotionMeta) meta).getCustomEffects()) + { + addPotionEffect(effect); + } + } _itemFlags.addAll(meta.getItemFlags()); @@ -124,7 +134,7 @@ public class ItemBuilder return this; } - public HashSet getItemFlags() + public Set getItemFlags() { return _itemFlags; } @@ -279,6 +289,22 @@ public class ItemBuilder { ((BannerMeta) meta).setBaseColor(DyeColor.getByColor(_color)); } + else if (meta instanceof PotionMeta) + { + PotionMeta potionMeta = (PotionMeta) meta; + + for (PotionEffect effect : _potionEffects) + { + potionMeta.addCustomEffect(effect, true); + } + + if (!_potionEffects.isEmpty()) + { + potionMeta.setMainEffect(_potionEffects.get(0).getType()); + } + + meta = potionMeta; + } meta.addItemFlags(getItemFlags().toArray(new ItemFlag[0])); meta.spigot().setUnbreakable(isUnbreakable()); @@ -307,7 +333,7 @@ public class ItemBuilder } newBuilder.setColor(_color); - // newBuilder.potion = potion; + newBuilder.setDurability(_durability); newBuilder.setData(_data); @@ -321,11 +347,16 @@ public class ItemBuilder newBuilder.setItemFlags(_itemFlags); newBuilder.setPlayerHead(_playerHeadName); + + for (PotionEffect potionEffect : _potionEffects) + { + newBuilder.addPotionEffect(potionEffect); + } return newBuilder; } - public HashMap getAllEnchantments() + public Map getAllEnchantments() { return _enchants; } @@ -452,4 +483,9 @@ public class ItemBuilder return this; } + public ItemBuilder addPotionEffect(PotionEffect effect) + { + _potionEffects.add(effect); + return this; + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index b0a0fb4f1..393901b58 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -17,6 +17,7 @@ import nautilus.game.arcade.game.games.moba.boss.BossManager; import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.game.games.moba.fountain.MobaFountain; import nautilus.game.arcade.game.games.moba.general.ArrowKBManager; +import nautilus.game.arcade.game.games.moba.general.EnderPearlManager; import nautilus.game.arcade.game.games.moba.general.MobaDamageManager; import nautilus.game.arcade.game.games.moba.gold.GoldManager; import nautilus.game.arcade.game.games.moba.kit.HeroKit; @@ -36,6 +37,7 @@ import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.structure.point.CapturePointManager; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; import nautilus.game.arcade.game.games.moba.util.MobaConstants; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; @@ -134,6 +136,9 @@ public class Moba extends TeamGame // Arrow Knockback _arrowKb = registerManager(new ArrowKBManager(this)); + // Ender Pearls + registerManager(new EnderPearlManager()); + new CompassModule() .setGiveCompass(true) .setGiveCompassToSpecs(true) @@ -186,18 +191,18 @@ public class Moba extends TeamGame if (state == GameState.Prepare && !perspectiveTeam.equals(subjectTeam)) { - suffix = "Unknown"; + suffix = C.cYellow + " Unknown"; } else if (mobaPlayer.getKit() == null) { - suffix = "Selecting"; + suffix = C.cYellow + " Selecting"; } else { - suffix = mobaPlayer.getKit().GetName(); + suffix = mobaPlayer.getRole().getChatColor() + " " + mobaPlayer.getKit().GetName(); } - return C.cYellow + " " + suffix + C.Reset; + return suffix + C.Reset; }) .setUnderNameObjective(C.cRed + "❤") .setUnderName((perspective, subject) -> @@ -367,7 +372,7 @@ public class Moba extends TeamGame for (Player player : GetPlayers(true)) { _playerData.add(new MobaPlayer(player)); - player.setMetadata(MobaConstants.TEAM_METADATA, new FixedMetadataValue(Manager.getPlugin(), GetTeam(player).GetName())); + MobaUtil.setTeamEntity(player, GetTeam(player)); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java index 70baf4c97..014d12a4d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/MobaRole.java @@ -1,50 +1,24 @@ package nautilus.game.arcade.game.games.moba; -import mineplex.core.common.util.C; import org.bukkit.ChatColor; import org.bukkit.Color; public enum MobaRole { - ASSASSIN("Assassin", new String[] - { - - "You are playing", - "the " + C.cAqua + "Assassin" + C.cWhite + " role this game", - - }, Color.BLUE, ChatColor.AQUA), - HUNTER("Hunter", new String[] - { - "You are playing", - "the " + C.cGreen + "Hunter" + C.cWhite + " role this game", - - }, Color.LIME, ChatColor.GREEN), - MAGE("Mage", new String[] - { - - "You are playing", - "the " + C.cRed + "Mage" + C.cWhite + " role this game", - - }, Color.RED, ChatColor.RED), - WARRIOR("Warrior", new String[] - { - - "You are playing", - "the " + C.cGold + "Warrior" + C.cWhite + " role this game", - - }, Color.YELLOW, ChatColor.GOLD), + ASSASSIN("Assassin", Color.GRAY, ChatColor.DARK_GRAY), + HUNTER("Hunter", Color.LIME, ChatColor.GREEN), + MAGE("Mage", Color.PURPLE, ChatColor.DARK_PURPLE), + WARRIOR("Warrior", Color.YELLOW, ChatColor.GOLD), ; private final String _name; - private final String[] _description; private final Color _color; private final ChatColor _chatColor; - MobaRole(String name, String[] description, Color color, ChatColor chatColor) + MobaRole(String name, Color color, ChatColor chatColor) { _name = name; - _description = description; _color = color; _chatColor = chatColor; } @@ -54,11 +28,6 @@ public enum MobaRole return _name; } - public String[] getDescription() - { - return _description; - } - public Color getColor() { return _color; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/Buff.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/Buff.java new file mode 100644 index 000000000..e986996c0 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/Buff.java @@ -0,0 +1,20 @@ +package nautilus.game.arcade.game.games.moba.buff; + +import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; + +public abstract class Buff +{ + + private final LivingEntity _entity; + + public Buff(LivingEntity entity) + { + _entity = entity; + } + + public abstract void onApply(Player player); + + public abstract void onUpdate(UpdateEvent event); +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java new file mode 100644 index 000000000..23e59140c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java @@ -0,0 +1,16 @@ +package nautilus.game.arcade.game.games.moba.buff; + +import mineplex.minecraft.game.core.condition.Condition; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.event.Listener; + +public class BuffManager implements Listener +{ + + private final Moba _host; + + public BuffManager(Moba host) + { + _host = host; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java new file mode 100644 index 000000000..d72217b09 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java @@ -0,0 +1,20 @@ +package nautilus.game.arcade.game.games.moba.buff.buffs; + +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.buff.Buff; +import org.bukkit.entity.LivingEntity; + +public class BuffPumpkinKing extends Buff +{ + + public BuffPumpkinKing(LivingEntity entity) + { + super(entity); + } + + @Override + public void onUpdate(UpdateEvent event) + { + + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/EnderPearlManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/EnderPearlManager.java new file mode 100644 index 000000000..4daeedeed --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/EnderPearlManager.java @@ -0,0 +1,100 @@ +package nautilus.game.arcade.game.games.moba.general; + +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.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Location; +import org.bukkit.entity.EnderPearl; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.bukkit.projectiles.ProjectileSource; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +public class EnderPearlManager implements Listener +{ + + private static final int MAX_TICKS = 2 * 20; + private final Map _pearls; + + public EnderPearlManager() + { + _pearls = new HashMap<>(); + } + + @EventHandler + public void projectileLaunch(ProjectileLaunchEvent event) + { + Projectile entity = event.getEntity(); + + if (!(entity instanceof EnderPearl) || !(entity.getShooter() instanceof Player)) + { + return; + } + + Player shooter = (Player) event.getEntity().getShooter(); + + _pearls.put(shooter, event.getEntity()); + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator iterator = _pearls.keySet().iterator(); + + while (iterator.hasNext()) + { + Player shooter = iterator.next(); + Projectile entity = _pearls.get(shooter); + + if (UtilPlayer.isSpectator(shooter)) + { + iterator.remove(); + entity.remove(); + } + else if (entity.getTicksLived() > MAX_TICKS) + { + teleport(shooter, entity); + entity.remove(); + iterator.remove(); + } + + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, entity.getLocation(), 0, 0, 0, 0.1F, 3, ViewDist.LONG); + } + } + + @EventHandler + public void projectileHit(ProjectileHitEvent event) + { + ProjectileSource source = event.getEntity().getShooter(); + + if (_pearls.remove(source) != null) + { + teleport((Player) source, event.getEntity()); + } + } + + private void teleport(Player shooter, Projectile entity) + { + Location toTeleport = entity.getLocation(); + Location playerLocation = shooter.getLocation(); + toTeleport.setYaw(playerLocation.getYaw()); + toTeleport.setPitch(playerLocation.getPitch()); + + shooter.teleport(toTeleport); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index 04ebb87b0..ab3f56ad7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -1,6 +1,11 @@ package nautilus.game.arcade.game.games.moba.kit; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -160,28 +165,43 @@ public class HeroKit extends Kit inventory.setItem(AMMO_SLOT, _ammo); inventory.setItem(RECALL_SLOT, RECALL_ITEM); - // Give armour - List items = ((Moba) Manager.GetGame()).getShop().getOwnedItems(player); + Moba game = (Moba) Manager.GetGame(); + List items = game.getShop().getOwnedItems(player); for (MobaItem item : items) { - ItemStack armour = item.getItem(); + ItemStack itemstack = item.getItem(); - if (UtilItem.isHelmet(armour)) + // Give armour + if (UtilItem.isHelmet(itemstack)) { - inventory.setHelmet(armour); + inventory.setHelmet(itemstack); } - else if (UtilItem.isChestplate(armour)) + else if (UtilItem.isChestplate(itemstack)) { - inventory.setChestplate(armour); + inventory.setChestplate(itemstack); } - else if (UtilItem.isLeggings(armour)) + else if (UtilItem.isLeggings(itemstack)) { - inventory.setLeggings(armour); + inventory.setLeggings(itemstack); } - else if (UtilItem.isBoots(armour)) + else if (UtilItem.isBoots(itemstack)) { - inventory.setBoots(armour); + inventory.setBoots(itemstack); + } + + // Give consumable items + else if (!UtilItem.isSword(itemstack) && !UtilGear.isBow(itemstack)) + { + // Keep moving left from the ammo slot until a free slot is available + for (int i = AMMO_SLOT - 1; i >= GetPerks().length - 1; i--) + { + if (inventory.getItem(i) == null) + { + inventory.setItem(i, itemstack); + break; + } + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 5d0dcddd9..53e5cf73b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -13,10 +13,12 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.PlayerKitGiveEvent; import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Perk; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -248,7 +250,7 @@ public class HeroSkill extends Perk } - public void useSkill(Player player) + public void useSkill(Player player) { _lastSkill.put(player.getUniqueId(), System.currentTimeMillis()); if (_cooldown > 0 && !UtilPlayer.isSpectator(player)) @@ -257,6 +259,21 @@ public class HeroSkill extends Perk } } + protected void broadcast(Player player) + { + Moba game = (Moba) Manager.GetGame(); + GameTeam team = game.GetTeam(player); + HeroKit kit = game.getMobaData(player).getKit(); + + if (team == null || kit == null) + { + return; + } + + game.Announce(team.GetColor() + C.Bold + player.getName() + " " + kit.getRole().getChatColor() + kit.GetName() + C.cWhiteB + " activated their " + team.GetColor() + C.Bold + GetName() + C.cWhiteB + ".", false); + player.getWorld().playSound(player.getLocation(), Sound.NOTE_PLING, 10, 0.5F); + } + @EventHandler public void updateCooldowns(UpdateEvent event) { @@ -269,7 +286,7 @@ public class HeroSkill extends Perk for (Player player : Manager.GetGame().GetPlayers(true)) { - if (!hasPerk(player) || UtilPlayer.isSpectator(player) || !_lastSkill.containsKey(player.getUniqueId())) + if (!hasPerk(player) || !_lastSkill.containsKey(player.getUniqueId())) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java index 73198fdfe..d91b18850 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java @@ -7,7 +7,6 @@ import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; 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.games.moba.kit.HeroSkill; @@ -15,7 +14,11 @@ import nautilus.game.arcade.kit.perks.data.MeteorShowerData; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.entity.*; +import org.bukkit.entity.Entity; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.LargeFireball; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityChangeBlockEvent; @@ -56,9 +59,12 @@ public class SkillMeteor extends HeroSkill implements IThrown Player player = event.getPlayer(); - if (!Recharge.Instance.use(player, GetName() + " Trigger", 10000, false, false)) + for (MeteorShowerData data : _data) { - return; + if (data.Shooter.equals(player)) + { + return; + } } FallingBlock block = player.getWorld().spawnFallingBlock(player.getEyeLocation().add(player.getLocation().getDirection()), Material.NETHERRACK, (byte) 0); @@ -66,6 +72,7 @@ public class SkillMeteor extends HeroSkill implements IThrown Manager.GetProjectile().AddThrow(block, player, this, 2000, true, true, true, false, 0.5F); + broadcast(player); useActiveSkill(player, 7000); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java index 907d5f7fd..2bd3d292d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java @@ -126,12 +126,7 @@ public class SkillBiffDash extends HeroSkill continue; } - for (int i = 0; i < 5; i++) - { - Location location = UtilAlg.getRandomLocation(entity.getEyeLocation(), 3); - entity.getWorld().playEffect(location, Effect.STEP_SOUND, Material.GRASS, 0); - } - + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, player.getLocation().add(0, 0.6, 0), 0.5F, 0.5F, 0.5F, 0.1F, 15, ViewDist.LONG); Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, 4, false, true, false, UtilEnt.getName(player), GetName()); UtilAction.velocity(entity, new Vector(0, 0.6 + Math.random() / 2, 0)); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java index 7db008510..65da2dceb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java @@ -7,6 +7,7 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.kit.common.LeashedEntity; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -14,6 +15,7 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; +import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -30,7 +32,7 @@ public class SkillLeash extends HeroSkill private static final ItemStack SKILL_ITEM = new ItemStack(Material.LEASH); - private final Map> _leashed = new HashMap<>(); + private final Map> _leashed = new HashMap<>(); public SkillLeash(int slot) { @@ -56,7 +58,7 @@ public class SkillLeash extends HeroSkill return; } - _leashed.put(player, nearbyPlayers); + List leashedEntities = new ArrayList<>(nearbyPlayers.size()); StringBuilder builder = new StringBuilder(F.main("Game", "You leashed ")); @@ -68,13 +70,16 @@ public class SkillLeash extends HeroSkill nearby.sendMessage(F.main("Game", F.name(nearby.getName()) + " leashed you.")); builder.append(F.name(player.getName())).append(", "); Manager.GetCondition().Factory().Slow(GetName(), nearby, player, 5, 0, false, true, true, false); + leashedEntities.add(new LeashedEntity(Manager, nearby, player)); } + _leashed.put(player, leashedEntities); + player.sendMessage(builder.toString()); useActiveSkill(() -> { - for (Player leashed : _leashed.remove(player)) + for (LeashedEntity leashed : _leashed.remove(player)) { removeEffect(leashed); } @@ -90,15 +95,15 @@ public class SkillLeash extends HeroSkill return; } - for (Entry> entry : _leashed.entrySet()) + for (Entry> entry : _leashed.entrySet()) { - Iterator iterator = entry.getValue().iterator(); + Iterator iterator = entry.getValue().iterator(); while (iterator.hasNext()) { - Player leashed = iterator.next(); + LeashedEntity leashed = iterator.next(); - if (UtilMath.offsetSquared(entry.getKey(), leashed) < 25) + if (UtilMath.offsetSquared(entry.getKey(), leashed.getHost()) < 25) { continue; } @@ -109,9 +114,9 @@ public class SkillLeash extends HeroSkill } } - private void removeEffect(Player player) + private void removeEffect(LeashedEntity entity) { - player.setLeashHolder(null); - player.removePotionEffect(PotionEffectType.SLOW); + entity.getHost().removePotionEffect(PotionEffectType.SLOW); + entity.remove(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java index 7aabbcea9..d4a141fca 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.biff; +import mineplex.core.Managers; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilTime; @@ -7,6 +8,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.util.MobaConstants; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Horse; @@ -63,18 +65,19 @@ public class SkillWarHorse extends HeroSkill Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class); - UtilEnt.vegetate(horse); horse.setJumpStrength(0); horse.setMaxDomestication(1); horse.setDomestication(horse.getMaxDomestication()); horse.getInventory().setArmor(HORSE_ARMOUR); horse.setOwner(player); horse.setPassenger(player); - horse.setMetadata(MobaConstants.TEAM_METADATA, new FixedMetadataValue(Manager.getPlugin(), Manager.GetGame().GetTeam(player).GetName())); + MobaUtil.setTeamEntity(horse, Manager.GetGame().GetTeam(player)); Manager.GetGame().CreatureAllowOverride = false; _data.add(new WarHorseData(player, horse)); + + broadcast(player); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java index 59fda7a1e..862caa9f5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBuildPainting.java @@ -91,6 +91,7 @@ public class SkillBuildPainting extends HeroSkill implements IThrown } useActiveSkill(player, 4000); + broadcast(player); Set blocks = new HashSet<>(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/LeashedEntity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/LeashedEntity.java new file mode 100644 index 000000000..6c3bfb0e6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/LeashedEntity.java @@ -0,0 +1,76 @@ +package nautilus.game.arcade.game.games.moba.kit.common; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilServer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +public class LeashedEntity implements Listener +{ + + private final LivingEntity _host; + private final Zombie _fakeLeash; + + public LeashedEntity(ArcadeManager manager, LivingEntity host, LivingEntity leasher) + { + manager.GetGame().CreatureAllowOverride = true; + + _host = host; + _fakeLeash = host.getWorld().spawn(host.getLocation(), Zombie.class); + UtilEnt.vegetate(_fakeLeash); + UtilEnt.silence(_fakeLeash, true); + _fakeLeash.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0, false, false)); + _fakeLeash.setBaby(true); + _fakeLeash.setLeashHolder(leasher); + + manager.GetGame().CreatureAllowOverride = false; + + UtilServer.RegisterEvents(this); + } + + public void remove() + { + _fakeLeash.setLeashHolder(null); + _fakeLeash.remove(); + UtilServer.Unregister(this); + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Location location = _host.getLocation(); + ((CraftLivingEntity) _fakeLeash).getHandle().setPosition(location.getX(), location.getY() + 0.8, location.getZ()); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void fakeLeashDamage(CustomDamageEvent event) + { + if (event.GetDamageeEntity().equals(_fakeLeash) && event.GetCause() == DamageCause.ENTITY_ATTACK) + { + event.setDamagee(_host); + event.SetIgnoreRate(false); + } + } + + public LivingEntity getHost() + { + return _host; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java index a1cba5e67..d1d302a78 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java @@ -72,6 +72,7 @@ public class SkillRally extends HeroSkill UtilAction.velocity(player, vector); _data.add(new RallyData(player)); + broadcast(player); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java index 3935b4ec6..24f975e58 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java @@ -14,7 +14,6 @@ import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ProjectileHitEvent; @@ -69,6 +68,7 @@ public class SkillInfinity extends HeroSkill bow.addEnchantment(Enchantment.ARROW_INFINITE, 1); _active.add(player); + broadcast(player); useActiveSkill(() -> { bow.removeEnchantment(Enchantment.ARROW_INFINITE); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java index b7c658777..94d7b02a5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java @@ -62,7 +62,7 @@ public class SkillTNTArrows extends HeroSkill Player player = event.getPlayer(); _playerArrows.put(player, 3); - player.getItemInHand().addEnchantment(UtilInv.getDullEnchantment(), 1); + UtilInv.addDullEnchantment(player.getItemInHand()); player.getItemInHand().setAmount(3); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java index 9a9ebe0a8..4f775fa8d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.moba.kit.hattori; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; @@ -52,7 +53,7 @@ public class SkillNinjaBlade extends HeroSkill @EventHandler public void interact(PlayerInteractEvent event) { - if (!isSkillItem(event)) + if (!isSkillItem(event) || _active.containsKey(event.getPlayer().getUniqueId())) { return; } @@ -93,9 +94,20 @@ public class SkillNinjaBlade extends HeroSkill _active.put(player.getUniqueId(), damage); + int i = 0; + for (ItemStack itemStack : inventory.getContents()) + { + if (!itemStack.equals(ACTIVE_ITEM) && UtilItem.isSword(itemStack)) + { + inventory.setItem(i, null); + } + + i++; + } + + broadcast(player); useActiveSkill(() -> { - _active.remove(player.getUniqueId()); for (Perk perk : Kit.GetPerks()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index a00dcfa24..edb5c9917 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -15,6 +15,7 @@ import nautilus.game.arcade.game.games.moba.boss.MobaBoss; import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.util.MobaConstants; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.entity.Entity; @@ -88,9 +89,7 @@ public class MinionWave implements Listener _host.CreatureAllowOverride = true; Minion minion = new Minion(_path.get(0), _clazz, _superMinions); - - minion.getEntity().setMetadata(MobaConstants.TEAM_METADATA, new FixedMetadataValue(_host.getArcadeManager().getPlugin(), _owner.GetName())); - + MobaUtil.setTeamEntity(minion.getEntity(), _owner); _minions.add(minion); _host.CreatureAllowOverride = false; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java deleted file mode 100644 index 0e0360bfc..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareInformation.java +++ /dev/null @@ -1,109 +0,0 @@ -package nautilus.game.arcade.game.games.moba.prepare; - -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.common.util.UtilTime; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.Game.GameState; -import nautilus.game.arcade.game.games.moba.Moba; -import nautilus.game.arcade.game.games.moba.MobaPlayer; -import nautilus.game.arcade.game.games.moba.MobaRole; -import org.bukkit.Location; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerMoveEvent; - -import java.util.concurrent.TimeUnit; - -public class PrepareInformation implements Listener -{ - - private static final long MESSAGE_TIME = TimeUnit.SECONDS.toMillis(3); - private static final int MESSAGE_TIME_TICKS = (int) (MESSAGE_TIME / 50D + 5); - - private final Moba _host; - - private long _lastMessage; - private int _messageIndex; - - public PrepareInformation(Moba host) - { - _host = host; - - // How long should the prepare time be. - int longestDescription = 0; - for (MobaRole role : MobaRole.values()) - { - int length = role.getDescription().length; - - if (length > longestDescription) - { - longestDescription = length; - } - } - - // Modify the prepare time - _host.PrepareTime = longestDescription * MESSAGE_TIME + 1000; - - UtilServer.RegisterEvents(this); - } - - @EventHandler - public void updateMessages(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST || !UtilTime.elapsed(_lastMessage, MESSAGE_TIME)) - { - return; - } - - for (MobaPlayer mobaPlayer : _host.getMobaData()) - { - String[] description = mobaPlayer.getRole().getDescription(); - - // Description is too short - if (description.length <= _messageIndex + 1) - { - continue; - } - - UtilTextMiddle.display(description[_messageIndex], description[_messageIndex + 1], 0, MESSAGE_TIME_TICKS, 0, mobaPlayer.getPlayer()); - } - - _messageIndex++; - _lastMessage = System.currentTimeMillis(); - } - - @EventHandler - public void playerMove(PlayerMoveEvent event) - { - if (UtilPlayer.isSpectator(event.getPlayer())) - { - return; - } - - Location to = event.getTo(); - Location from = event.getFrom(); - - // Player hasn't moved along the X or Z axis - if (to.getX() == from.getX() && to.getZ() == from.getZ()) - { - return; - } - - event.setTo(from); - } - - @EventHandler - public void live(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Live) - { - return; - } - - UtilServer.Unregister(this); - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java index 99e01896f..eacc7cdd0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareManager.java @@ -14,15 +14,12 @@ import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.kit.RoleSelectEvent; -import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Perk; -import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.metadata.FixedMetadataValue; import java.util.concurrent.TimeUnit; @@ -30,10 +27,12 @@ public class PrepareManager implements Listener { private static final long PREPARE_TIME = TimeUnit.MINUTES.toMillis(1); + private static final long POST_SELECTION_PREPARE_TIME = TimeUnit.SECONDS.toMillis(5); + private static final int MAX_DISTANCE_WITHOUT_SELECTION_SQUARED = 400; private final Moba _host; - private boolean _informationStage; + private boolean _postPrepareStage; public PrepareManager(Moba host) { @@ -43,7 +42,7 @@ public class PrepareManager implements Listener @EventHandler(priority = EventPriority.LOW) public void updatePrepare(UpdateEvent event) { - if (event.getType() != UpdateType.SEC || _host.GetState() != GameState.Prepare || _informationStage) + if (event.getType() != UpdateType.SEC || _host.GetState() != GameState.Prepare || _postPrepareStage) { return; } @@ -61,7 +60,7 @@ public class PrepareManager implements Listener } } - _informationStage = true; + _postPrepareStage = true; _host.AnnounceGame(); _host.StartPrepareCountdown(); @@ -95,9 +94,29 @@ public class PrepareManager implements Listener _host.SetStateTime(System.currentTimeMillis()); _host.getArcadeManager().GetChat().Silence(-1, false); + _host.PrepareTime = POST_SELECTION_PREPARE_TIME; + _host.PrepareFreeze = true; + } - // Start the pregame role information - new PrepareInformation(_host); + @EventHandler + public void updateNearSpawn(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOW || _host.GetState() != GameState.Prepare) + { + return; + } + + for (MobaPlayer mobaPlayer : _host.getMobaData()) + { + Player player = mobaPlayer.getPlayer(); + GameTeam team = _host.GetTeam(player); + + if (UtilMath.offsetSquared(player.getLocation(), team.GetSpawns().get(0)) > MAX_DISTANCE_WITHOUT_SELECTION_SQUARED && (mobaPlayer.getRole() == null || mobaPlayer.getKit() == null)) + { + player.sendMessage(F.main("Game", "You haven't finished selecting your hero.")); + team.SpawnTeleport(player); + } + } } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java index 0d5f125c0..23f01e5e9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/prepare/PrepareSelection.java @@ -73,7 +73,7 @@ public class PrepareSelection implements Listener, IPacketHandler UtilServer.runSyncLater(() -> { - for (Player player : _host.GetPlayers(true)) + for (Player player : team.GetPlayers(true)) { displayRoleInformation(player); } @@ -235,12 +235,18 @@ public class PrepareSelection implements Listener, IPacketHandler private void displayRoleInformation(Player player) { - UtilTextMiddle.display(C.cYellowB + "Role", "Select the role you would like to play", 10, 40, 10, player); + String base = "Select the role you would like to play!"; + + UtilTextMiddle.display(C.cYellowB + "Role", base, 10, 40, 10, player); + player.sendMessage(F.main("Game", base)); } private void displayKitInformation(Player player, MobaRole role) { + String base = "Select your " + role.getChatColor() + "Hero"; + UtilTextMiddle.display(role.getChatColor() + role.getName(), "Select your " + role.getChatColor() + "Hero", 10, 40, 10, player); + player.sendMessage(F.main("Game", base + C.mBody + "!")); } // Unregister diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java index 576bc305c..a4f9f78ac 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItem.java @@ -2,7 +2,9 @@ package nautilus.game.arcade.game.games.moba.shop; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.leaderboard.Leaderboard; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; import java.util.ArrayList; import java.util.Collections; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index c244dba1c..2c0ba235b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -1,6 +1,11 @@ package nautilus.game.arcade.game.games.moba.shop; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.itemstack.ItemBuilder; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.CombatComponent; @@ -21,7 +26,9 @@ import nautilus.game.arcade.game.games.moba.shop.hunter.MobaHunterShop; import nautilus.game.arcade.game.games.moba.shop.mage.MobaMageShop; import nautilus.game.arcade.game.games.moba.shop.warrior.MobaWarriorShop; import nautilus.game.arcade.game.games.moba.util.MobaConstants; +import nautilus.game.arcade.kit.Kit; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; @@ -29,9 +36,14 @@ import org.bukkit.entity.Player; import org.bukkit.entity.Villager; import org.bukkit.entity.Villager.Profession; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerItemConsumeEvent; +import org.bukkit.inventory.ItemStack; import java.util.ArrayList; import java.util.HashMap; @@ -42,6 +54,11 @@ import java.util.Map.Entry; public class MobaShop implements Listener { + private static final ItemStack SHOP_ITEM = new ItemBuilder(Material.GOLD_INGOT) + .setTitle(C.cGold + "Open Gold Upgrades") + .addLore("Click to open the Gold Upgrades", "shop while you are respawning.") + .build(); + private final Moba _host; private final Map _entities; private final Map _roleMenus; @@ -84,6 +101,7 @@ public class MobaShop implements Listener UtilEnt.vegetate(villager); UtilEnt.silence(villager, true); UtilEnt.CreatureForceLook(villager, 0, UtilAlg.GetYaw(UtilAlg.getTrajectory(villager.getLocation(), _host.GetSpectatorLocation()))); + ((CraftLivingEntity) villager).getHandle().k = false; _entities.put(villager, location); } @@ -92,7 +110,7 @@ public class MobaShop implements Listener public void openShop(MobaPlayer player) { - if (UtilPlayer.isSpectator(player.getPlayer()) || _host.GetState() != GameState.Live) + if (_host.GetState() != GameState.Live) { return; } @@ -153,7 +171,7 @@ public class MobaShop implements Listener private void npcInteract(Entity clicked, Entity clicker) { - if (!(clicker instanceof Player)) + if (!(clicker instanceof Player) || UtilPlayer.isSpectator(clicker)) { return; } @@ -183,6 +201,11 @@ public class MobaShop implements Listener List owned = _upgrades.get(player); MobaShopCategory category = getCategory(item); + if (category == null) + { + return; + } + if (!category.isAllowingMultiple()) { owned.removeIf(previousItem -> getCategory(previousItem) == category); @@ -191,6 +214,14 @@ public class MobaShop implements Listener player.sendMessage(F.main("Game", "Purchased " + F.greenElem(item.getItem().getItemMeta().getDisplayName()) + ".")); _host.getGoldManager().removeGold(player, item.getCost()); owned.add(item); + category.purchase(player); + + // This would happen when the player is respawning and is purchasing upgrades + // In this case giving them the item is not needed + if (UtilPlayer.isSpectator(player)) + { + return; + } // The respawn event needs to be called here so that effects like "Total Health Increase" will work straight away, instead of after the next respawn, // Prevents infinite speed @@ -236,6 +267,82 @@ public class MobaShop implements Listener return null; } + /* + Allow players to access the shop while dead. + */ + + @EventHandler + public void playerDeath(PlayerDeathEvent event) + { + final Player player = event.getEntity(); + + _host.getArcadeManager().runSyncLater(() -> + { + // Certain categories such as consumables drop on death so here we remove them from upgrades + List owned = _upgrades.get(player); + + if (owned != null) + { + owned.removeIf(item -> + { + MobaShopCategory category = getCategory(item); + return category == null || category.isDroppingOnDeath(); + }); + + // Reset the max amount of purchasable items + MobaPlayer mobaPlayer = _host.getMobaData(player); + + if (mobaPlayer == null || mobaPlayer.getRole() == null) + { + return; + } + + _roleMenus.get(mobaPlayer.getRole()).getCategories().forEach(category -> category.onDeath(player)); + } + + // Give the player their kit items + Kit kit = _host.GetKit(player); + + if (kit == null) + { + return; + } + + kit.GiveItems(player); + player.getInventory().setItem(8, SHOP_ITEM); + }, 1); + } + + @EventHandler + public void interactShopItem(PlayerInteractEvent event) + { + if (event.getItem() == null || !event.getItem().isSimilar(SHOP_ITEM)) + { + return; + } + + MobaPlayer mobaPlayer = _host.getMobaData(event.getPlayer()); + + if (mobaPlayer == null) + { + return; + } + + openShop(mobaPlayer); + } + + /* + Remove empty potions + */ + @EventHandler + public void removeEmptyPotions(PlayerItemConsumeEvent event) + { + if (event.getItem().getType() == Material.POTION) + { + _host.getArcadeManager().runSyncLater(() -> event.getPlayer().setItemInHand(null), 1); + } + } + /* Handle MobaItem events */ @@ -294,9 +401,14 @@ public class MobaShop implements Listener } } - @EventHandler + @EventHandler(priority = EventPriority.HIGH) public void damage(CustomDamageEvent event) { + if (event.isCancelled()) + { + return; + } + Player damagee = event.GetDamageePlayer(); Player damager = event.GetDamagerPlayer(true); @@ -396,9 +508,14 @@ public class MobaShop implements Listener } } - @EventHandler + @EventHandler(priority = EventPriority.HIGH) public void conditionApply(ConditionApplyEvent event) { + if (event.isCancelled()) + { + return; + } + LivingEntity entity = event.GetCondition().GetEnt(); if (!(entity instanceof Player)) @@ -409,11 +526,6 @@ public class MobaShop implements Listener Player player = (Player) entity; List items = _upgrades.get(player); - if (_upgrades == null) - { - return; - } - for (MobaItem item : items) { if (item.getEffects() == null) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategory.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategory.java index 224433e3f..a978f4545 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategory.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategory.java @@ -1,8 +1,12 @@ package nautilus.game.arcade.game.games.moba.shop; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.UUID; public class MobaShopCategory { @@ -10,13 +14,17 @@ public class MobaShopCategory private final String _name; private final List _items; private final ItemStack _menuItem; - private boolean _allowMultiple; + private final Map _purchased; + private int _max; + private boolean _dropOnDeath; public MobaShopCategory(String name, List items, ItemStack menuItem) { _name = name; _items = items; _menuItem = menuItem; + _max = Integer.MAX_VALUE; + _purchased = new HashMap<>(); } public String getName() @@ -34,14 +42,57 @@ public class MobaShopCategory return _menuItem; } - public MobaShopCategory allowMultiple(boolean allow) + public void purchase(Player player) { - _allowMultiple = allow; + UUID key = player.getUniqueId(); + + if (!_purchased.containsKey(key)) + { + _purchased.put(key, 1); + } + else + { + _purchased.put(key, _purchased.get(key) + 1); + } + } + + public void onDeath(Player player) + { + if (isDroppingOnDeath()) + { + _purchased.remove(player.getUniqueId()); + } + } + + public int getPurchased(Player player) + { + return _purchased.getOrDefault(player.getUniqueId(), 0); + } + + public MobaShopCategory setMax(int max) + { + _max = max; return this; } + public int getMax() + { + return _max; + } + + public MobaShopCategory dropOnDeath() + { + _dropOnDeath = true; + return this; + } + + public boolean isDroppingOnDeath() + { + return _dropOnDeath; + } + public boolean isAllowingMultiple() { - return _allowMultiple; + return _max < Integer.MAX_VALUE; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java index f6ca8ac51..7c7c3aba5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopCategoryMenu.java @@ -47,6 +47,7 @@ public class MobaShopCategoryMenu extends Menu ItemBuilder builder = new ItemBuilder(item.getItem()); boolean owns = _shop.ownsItem(player, item); boolean canPurchase = _host.getGoldManager().hasGold(player, item.getCost()); + boolean maxed = _category.getPurchased(player) == _category.getMax(); int gold = _host.getGoldManager().getGold(player); builder.setTitle((canPurchase ? C.cGreen : C.cRed) + item.getItem().getItemMeta().getDisplayName()); @@ -61,7 +62,11 @@ public class MobaShopCategoryMenu extends Menu { builder.addLore(C.cWhite + "Cost: " + C.cGold + item.getCost(), C.cWhite + "Your Gold: " + C.cGold + gold, ""); - if (canPurchase) + if (maxed) + { + builder.addLore(C.cRed + "You have already purchased the maximum amount", C.cRed + "of upgrades from this category."); + } + else if (canPurchase) { builder.addLore(C.cGreen + "Click to purchase."); } @@ -100,8 +105,9 @@ public class MobaShopCategoryMenu extends Menu { boolean owns = _shop.ownsItem(player, _item); boolean canPurchase = _host.getGoldManager().hasGold(player, _item.getCost()); + boolean maxed = _category.getPurchased(player) == _category.getMax(); - if (!owns && canPurchase) + if (!owns && canPurchase && !maxed) { player.playSound(player.getLocation(), Sound.NOTE_PLING, 1, 1.6F); _shop.purchaseItem(player, _item); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java index af128575b..db0c94fa3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShopMenu.java @@ -8,16 +8,41 @@ import mineplex.core.menu.Menu; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaRole; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; public class MobaShopMenu extends Menu { + private static final MobaShopCategory CONSUMABLES = new MobaShopCategory("Consumables", Arrays.asList( + new MobaItem(new ItemBuilder(Material.POTION) + .setTitle(C.cGreenB + "Small Health Potion") + .addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 0)) + .build(), 100), + new MobaItem(new ItemBuilder(Material.POTION) + .setTitle(C.cYellowB + "Large Health Potion") + .addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 1)) + .build(), 200), + new MobaItem(new ItemBuilder(Material.POTION) + .setTitle(C.cYellowB + "Power Potion") + .addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 90 * 20, 0)) + .build(), 1000), + new MobaItem(new ItemBuilder(Material.POTION) + .setTitle(C.cYellowB + "Speed Potion") + .addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 180 * 20, 0)) + .build(), 500), + new MobaItem(new ItemBuilder(Material.ENDER_PEARL) + .setTitle(C.cYellowB + "Ender Pearl") + .build(), 750) + ), new ItemStack(Material.POTION)).dropOnDeath().setMax(3); private static final int SLOTS = 27; private final Moba _host; @@ -38,6 +63,11 @@ public class MobaShopMenu extends Menu _categories.add(category); } + protected void addConsumables() + { + _categories.add(CONSUMABLES); + } + @Override protected Button[] setUp(Player player) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java index 9d3a43a7a..5ba6f17f5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java @@ -124,5 +124,6 @@ public class MobaAssassinShop extends MobaShopMenu addCategory(CHESTPLATE); addCategory(LEGGINGS); addCategory(BOOTS); + addConsumables(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java index 06b6fdaf7..2723bdf3e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java @@ -203,5 +203,6 @@ public class MobaHunterShop extends MobaShopMenu addCategory(CHESTPLATE); addCategory(LEGGINGS); addCategory(BOOTS); + addConsumables(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/mage/MobaMageShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/mage/MobaMageShop.java index 15103bdcd..e8b5a38b4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/mage/MobaMageShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/mage/MobaMageShop.java @@ -20,34 +20,41 @@ import java.util.Arrays; public class MobaMageShop extends MobaShopMenu { + // Dark Purple + private static final Color ABILITY_DAMAGE_COLOUR = Color.fromBGR(181, 7, 123); + // Purple + private static final Color COOLDOWN_COLOUR = Color.PURPLE; + // Light Purple + private static final Color BASIC_DAMAGE_COLOUR = Color.fromBGR(254, 89, 200); + private static final MobaShopCategory HELMET = new MobaShopCategory("Helmet", Arrays.asList( new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) .setTitle(C.cGreen + "Leather Cap") .build(), 200), new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) .setTitle(C.cGreen + "Adept's Cap") - .setColor(Color.BLACK) - .build(), 500) + .setColor(ABILITY_DAMAGE_COLOUR) + .build(), 750) .addEffects( new MobaAbilityDamageEffect("Adept's Cap", 0.05) ), new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) .setTitle(C.cGreen + "Helm of Focus") - .setColor(Color.PURPLE) - .build(), 500) + .setColor(COOLDOWN_COLOUR) + .build(), 750) .addEffects( new MobaCDREffect(0.03) ), new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) .setTitle(C.cGreen + "Battle Mage Cap") - .setColor(Color.YELLOW) - .build(), 500) + .setColor(BASIC_DAMAGE_COLOUR) + .build(), 750) .addEffects( new MobaBasicAttackDamageEffect("Battle Mage Cap", 0.03) ), new MobaItem(new ItemBuilder(Material.GOLD_HELMET) .setTitle(C.cYellow + "Golden Helmet") - .build(), 750) + .build(), 1000) ), new ItemStack(Material.LEATHER_HELMET)); private static final MobaShopCategory CHESTPLATE = new MobaShopCategory("Chestplate", Arrays.asList( @@ -56,28 +63,28 @@ public class MobaMageShop extends MobaShopMenu .build(), 400), new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) .setTitle(C.cGreen + "Adept's Chestplate") - .setColor(Color.BLACK) - .build(), 1250) + .setColor(ABILITY_DAMAGE_COLOUR) + .build(), 1500) .addEffects( new MobaAbilityDamageEffect("Adept's Chestplate", 0.15) ), new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) .setTitle(C.cGreen + "Chestplate of Focus") - .setColor(Color.PURPLE) - .build(), 1000) + .setColor(COOLDOWN_COLOUR) + .build(), 1250) .addEffects( new MobaCDREffect(0.1) ), new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) .setTitle(C.cGreen + "Battle Mage Chestplate") - .setColor(Color.YELLOW) - .build(), 1000) + .setColor(BASIC_DAMAGE_COLOUR) + .build(), 1250) .addEffects( new MobaBasicAttackDamageEffect("Battle Mage Chestplate", 0.1) ), new MobaItem(new ItemBuilder(Material.GOLD_CHESTPLATE) .setTitle(C.cYellow + "Golden Chestplate") - .build(), 1000) + .build(), 1250) ), new ItemStack(Material.LEATHER_CHESTPLATE)); private static final MobaShopCategory LEGGINGS = new MobaShopCategory("Leggings", Arrays.asList( @@ -86,22 +93,22 @@ public class MobaMageShop extends MobaShopMenu .build(), 400), new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) .setTitle(C.cGreen + "Adept's Leggings") - .setColor(Color.BLACK) - .build(), 750) + .setColor(ABILITY_DAMAGE_COLOUR) + .build(), 1000) .addEffects( new MobaAbilityDamageEffect("Adept's Leggings", 0.1) ), new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) .setTitle(C.cGreen + "Leggings of Focus") - .setColor(Color.PURPLE) - .build(), 750) + .setColor(COOLDOWN_COLOUR) + .build(), 1000) .addEffects( new MobaCDREffect(0.05) ), new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) .setTitle(C.cGreen + "Battle Mage Leggings") - .setColor(Color.YELLOW) - .build(), 750) + .setColor(BASIC_DAMAGE_COLOUR) + .build(), 1000) .addEffects( new MobaBasicAttackDamageEffect("Battle Mage Leggings", 0.05) ), @@ -116,28 +123,28 @@ public class MobaMageShop extends MobaShopMenu .build(), 200), new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) .setTitle(C.cGreen + "Adept's Boots") - .setColor(Color.BLACK) - .build(), 500) + .setColor(ABILITY_DAMAGE_COLOUR) + .build(), 750) .addEffects( new MobaAbilityDamageEffect("Adept's Boots", 0.05) ), new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) .setTitle(C.cGreen + "Boots of Focus") - .setColor(Color.PURPLE) - .build(), 500) + .setColor(COOLDOWN_COLOUR) + .build(), 750) .addEffects( new MobaCDREffect(0.03) ), new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) .setTitle(C.cGreen + "Battle Mage Boots") - .setColor(Color.YELLOW) - .build(), 500) + .setColor(BASIC_DAMAGE_COLOUR) + .build(), 750) .addEffects( new MobaBasicAttackDamageEffect("Battle Mage Boots", 0.03) ), new MobaItem(new ItemBuilder(Material.GOLD_BOOTS) .setTitle(C.cYellow + "Golden Boots") - .build(), 750) + .build(), 1000) ), new ItemStack(Material.LEATHER_BOOTS)); public MobaMageShop(Moba host, MobaShop shop) @@ -148,5 +155,6 @@ public class MobaMageShop extends MobaShopMenu addCategory(CHESTPLATE); addCategory(LEGGINGS); addCategory(BOOTS); + addConsumables(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/warrior/MobaWarriorShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/warrior/MobaWarriorShop.java index 03bc1f529..2d0ca6f60 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/warrior/MobaWarriorShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/warrior/MobaWarriorShop.java @@ -48,13 +48,13 @@ public class MobaWarriorShop extends MobaShopMenu .addEffects( new MobaHPRegenEffect(0.03) ), - new MobaItem(new ItemBuilder(Material.IRON_HELMET) - .setTitle(C.cYellowB + "Superior Archer's Bane") - .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) - .build(), 750) - .addEffects( - new MobaHPRegenEffect(0.05) - ), +// new MobaItem(new ItemBuilder(Material.IRON_HELMET) +// .setTitle(C.cYellowB + "Superior Archer's Bane") +// .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) +// .build(), 750) +// .addEffects( +// new MobaHPRegenEffect(0.05) +// ), new MobaItem(new ItemBuilder(Material.IRON_HELMET) .setTitle(C.cGreenB + "Brawler's Plate") .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1) @@ -62,13 +62,13 @@ public class MobaWarriorShop extends MobaShopMenu .addEffects( new MobaHPRegenEffect(0.03) ), - new MobaItem(new ItemBuilder(Material.IRON_HELMET) - .setTitle(C.cYellowB + "Superior Brawler's Plate") - .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2) - .build(), 750) - .addEffects( - new MobaHPRegenEffect(0.05) - ), +// new MobaItem(new ItemBuilder(Material.IRON_HELMET) +// .setTitle(C.cYellowB + "Superior Brawler's Plate") +// .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2) +// .build(), 750) +// .addEffects( +// new MobaHPRegenEffect(0.05) +// ), new MobaItem(new ItemBuilder(Material.DIAMOND_HELMET) .setTitle(C.cDRedB + "Prince's Plate") .build(), 2000) @@ -85,13 +85,13 @@ public class MobaWarriorShop extends MobaShopMenu .addEffects( new MobaTotalHealthEffect(2) ), - new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE) - .setTitle(C.cYellowB + "Superior Archer's Bane") - .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) - .build(), 1000) - .addEffects( - new MobaTotalHealthEffect(4) - ), +// new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE) +// .setTitle(C.cYellowB + "Superior Archer's Bane") +// .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) +// .build(), 1000) +// .addEffects( +// new MobaTotalHealthEffect(4) +// ), new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE) .setTitle(C.cGreenB + "Brawler's Plate") .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1) @@ -99,13 +99,13 @@ public class MobaWarriorShop extends MobaShopMenu .addEffects( new MobaTotalHealthEffect(2) ), - new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE) - .setTitle(C.cYellowB + "Superior Brawler's Plate") - .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2) - .build(), 1000) - .addEffects( - new MobaTotalHealthEffect(4) - ), +// new MobaItem(new ItemBuilder(Material.IRON_CHESTPLATE) +// .setTitle(C.cYellowB + "Superior Brawler's Plate") +// .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2) +// .build(), 1000) +// .addEffects( +// new MobaTotalHealthEffect(4) +// ), new MobaItem(new ItemBuilder(Material.DIAMOND_CHESTPLATE) .setTitle(C.cDRedB + "Prince's Plate") .build(), 2500) @@ -122,13 +122,13 @@ public class MobaWarriorShop extends MobaShopMenu .addEffects( new MobaCDREffect(0.05) ), - new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS) - .setTitle(C.cYellowB + "Superior Archer's Bane") - .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) - .build(), 1000) - .addEffects( - new MobaCDREffect(0.07) - ), +// new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS) +// .setTitle(C.cYellowB + "Superior Archer's Bane") +// .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) +// .build(), 1000) +// .addEffects( +// new MobaCDREffect(0.07) +// ), new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS) .setTitle(C.cGreenB + "Brawler's Plate") .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1) @@ -136,13 +136,13 @@ public class MobaWarriorShop extends MobaShopMenu .addEffects( new MobaCDREffect(0.05) ), - new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS) - .setTitle(C.cYellowB + "Superior Brawler's Plate") - .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2) - .build(), 1000) - .addEffects( - new MobaCDREffect(0.07) - ), +// new MobaItem(new ItemBuilder(Material.IRON_LEGGINGS) +// .setTitle(C.cYellowB + "Superior Brawler's Plate") +// .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2) +// .build(), 1000) +// .addEffects( +// new MobaCDREffect(0.07) +// ), new MobaItem(new ItemBuilder(Material.DIAMOND_LEGGINGS) .setTitle(C.cDRedB + "Prince's Plate") .build(), 2500) @@ -159,13 +159,13 @@ public class MobaWarriorShop extends MobaShopMenu .addEffects( new MobaSpeedEffect(0.04) ), - new MobaItem(new ItemBuilder(Material.IRON_BOOTS) - .setTitle(C.cYellowB + "Superior Archer's Bane") - .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) - .build(), 750) - .addEffects( - new MobaSpeedEffect(0.06) - ), +// new MobaItem(new ItemBuilder(Material.IRON_BOOTS) +// .setTitle(C.cYellowB + "Superior Archer's Bane") +// .addEnchantment(Enchantment.PROTECTION_PROJECTILE, 2) +// .build(), 750) +// .addEffects( +// new MobaSpeedEffect(0.06) +// ), new MobaItem(new ItemBuilder(Material.IRON_BOOTS) .setTitle(C.cGreenB + "Brawler's Plate") .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1) @@ -173,13 +173,13 @@ public class MobaWarriorShop extends MobaShopMenu .addEffects( new MobaSpeedEffect(0.04) ), - new MobaItem(new ItemBuilder(Material.IRON_BOOTS) - .setTitle(C.cYellowB + "Superior Brawler's Plate") - .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2) - .build(), 750) - .addEffects( - new MobaSpeedEffect(0.06) - ), +// new MobaItem(new ItemBuilder(Material.IRON_BOOTS) +// .setTitle(C.cYellowB + "Superior Brawler's Plate") +// .addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2) +// .build(), 750) +// .addEffects( +// new MobaSpeedEffect(0.06) +// ), new MobaItem(new ItemBuilder(Material.DIAMOND_BOOTS) .setTitle(C.cDRedB + "Prince's Plate") .build(), 2000) @@ -197,5 +197,6 @@ public class MobaWarriorShop extends MobaShopMenu addCategory(CHESTPLATE); addCategory(LEGGINGS); addCategory(BOOTS); + addConsumables(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index 22831e831..6efb7e551 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.moba.structure.tower; import mineplex.core.common.Pair; import mineplex.core.common.util.C; +import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; @@ -147,6 +148,7 @@ public class TowerManager implements Listener { if (tower.getStand().equals(event.GetDamageeEntity())) { + tower.getStand().setFireTicks(0); event.SetCancelled("Tower Guardian"); } } @@ -169,31 +171,36 @@ public class TowerManager implements Listener return; } - Entity entity = event.getDamager(); + Entity damager = event.getDamager(); Player player = null; + Tower tower = null; - if (entity instanceof Player) + for (Tower other : _towers) { - player = (Player) entity; + if (other.getCrystal().equals(event.getEntity())) + { + tower = other; + break; + } } - else if (entity instanceof Projectile) + + if (tower == null) { - Projectile projectile = (Projectile) entity; + return; + } + + if (damager instanceof Player) + { + player = (Player) damager; + } + else if (damager instanceof Projectile) + { + Projectile projectile = (Projectile) damager; ProjectileSource source = projectile.getShooter(); if (source instanceof Player) { player = (Player) source; - - Location entityLocation = event.getEntity().getLocation(); - Location playerLocation = player.getLocation(); - playerLocation.setY(entityLocation.getY()); - - if (UtilMath.offsetSquared(playerLocation, entityLocation) > Tower.TARGET_RANGE_SQUARED) - { - event.setCancelled(true); - return; - } } } @@ -204,26 +211,16 @@ public class TowerManager implements Listener GameTeam team = _host.GetTeam(player); - if (UtilPlayer.isSpectator(player) || team == null) + if (UtilPlayer.isSpectator(player) || team == null || !canDamage(tower, team) || shouldCancelDamage(tower, player)) { return; } - for (Tower tower : _towers) + tower.damage(event.getDamage()); + + if (Recharge.Instance.use(player, "Tower Sound", 500, false, false)) { - if (!event.getEntity().equals(tower.getCrystal()) || !canDamage(tower, team)) - { - continue; - } - - event.setCancelled(true); - tower.damage(event.getDamage()); - - if (Recharge.Instance.use(player, "Tower Sound", 500, false, false)) - { - playSound(player, tower); - } - return; + playSound(player, tower); } } @@ -246,7 +243,8 @@ public class TowerManager implements Listener { Entity entity = iterator.next(); Pair pair = _projectilesToCheck.get(entity); - GameTeam team = _host.GetTeam(pair.getLeft()); + Player player = pair.getLeft(); + GameTeam team = _host.GetTeam(player); for (Tower tower : _towers) { @@ -255,14 +253,38 @@ public class TowerManager implements Listener continue; } - playSound(pair.getLeft(), tower); - tower.damage(pair.getRight()); + if (!shouldCancelDamage(tower, player)) + { + playSound(player, tower); + tower.damage(pair.getRight()); + } + entity.remove(); iterator.remove(); } } } + private boolean shouldCancelDamage(Tower tower, Player shooter) + { + Location entityLocation = tower.getCrystal().getLocation(); + Location playerLocation = shooter.getLocation(); + playerLocation.setY(entityLocation.getY()); + + if (UtilMath.offsetSquared(playerLocation, entityLocation) > Tower.TARGET_RANGE_SQUARED) + { + shooter.playSound(shooter.getLocation(), Sound.NOTE_PLING, 1, 0.9F); + if (Recharge.Instance.use(shooter, "Tower Cancel Inform", 2000, false, false)) + { + shooter.sendMessage(F.main("Game", "You cannot damage the enemy tower while outside of the circle! Step inside the circle to deal damage to it.")); + } + + return true; + } + + return false; + } + private void playSound(Player player, Tower tower) { player.playSound(tower.getCrystal().getLocation(), Sound.BLAZE_HIT, 1, 0.8F); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index 4242ec20f..46c3eac2f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -5,6 +5,7 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; @@ -12,6 +13,7 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.util.Vector; import java.util.ArrayList; @@ -185,6 +187,11 @@ public class MobaUtil return C.cGreenB; } + public static void setTeamEntity(LivingEntity entity, GameTeam team) + { + entity.setMetadata(MobaConstants.TEAM_METADATA, new FixedMetadataValue(UtilServer.getPlugin(), team.GetName())); + } + public static boolean isTeamEntity(LivingEntity entity, GameTeam team) { return entity.hasMetadata(MobaConstants.TEAM_METADATA) && entity.getMetadata(MobaConstants.TEAM_METADATA).get(0).asString().equals(team.GetName()); diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java index dbff05dc6..0d0487a8d 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java @@ -28,6 +28,7 @@ import org.bukkit.block.BlockState; import org.bukkit.block.Chest; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerPickupItemEvent; From 9844ca338a5c4ba7572c1ac150a10fbde4fdc23b Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 8 Jun 2017 16:09:32 +0100 Subject: [PATCH 48/57] Complete Biff --- .../game/core/damage/CustomDamageEvent.java | 2 +- .../game/arcade/game/games/moba/Moba.java | 12 +- .../games/moba/boss/pumpkin/PumpkinBoss.java | 108 +++--------------- .../arcade/game/games/moba/buff/Buff.java | 51 +++++++-- .../game/games/moba/buff/BuffManager.java | 65 ++++++++++- .../moba/buff/buffs/BuffPumpkinKing.java | 94 ++++++++++++++- .../games/moba/buff/buffs/BuffRooting.java | 78 +++++++++++++ .../games/moba/kit/biff/SkillBiffDash.java | 16 ++- .../game/games/moba/kit/biff/SkillLeash.java | 5 +- .../games/moba/kit/biff/SkillWarHorse.java | 51 +++++++-- .../games/moba/kit/common/LeashedEntity.java | 13 ++- .../games/moba/kit/devon/SkillInfinity.java | 2 +- .../moba/kit/hattori/SkillNinjaBlade.java | 2 +- 13 files changed, 367 insertions(+), 132 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffRooting.java diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java index a4830cb56..6b4b9fde8 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/CustomDamageEvent.java @@ -100,7 +100,7 @@ public class CustomDamageEvent extends Event implements Cancellable public void AddMod(String source, double mod) { - AddMod(source, new String(), mod, false); + AddMod(source, "", mod, false); } public void AddMod(String source, String reason, double mod, boolean useAttackName) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 393901b58..e1f9bcc3e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -15,6 +15,7 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.moba.boss.BossManager; import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; +import nautilus.game.arcade.game.games.moba.buff.BuffManager; import nautilus.game.arcade.game.games.moba.fountain.MobaFountain; import nautilus.game.arcade.game.games.moba.general.ArrowKBManager; import nautilus.game.arcade.game.games.moba.general.EnderPearlManager; @@ -36,7 +37,6 @@ import nautilus.game.arcade.game.games.moba.recall.Recall; import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.structure.point.CapturePointManager; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; -import nautilus.game.arcade.game.games.moba.util.MobaConstants; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; @@ -53,7 +53,6 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.metadata.FixedMetadataValue; import java.util.ArrayList; import java.util.Arrays; @@ -84,6 +83,7 @@ public class Moba extends TeamGame private final TowerManager _tower; private final CapturePointManager _capturePoint; private final ArrowKBManager _arrowKb; + private final BuffManager _buffs; public Moba(ArcadeManager manager) { @@ -139,6 +139,9 @@ public class Moba extends TeamGame // Ender Pearls registerManager(new EnderPearlManager()); + // Buffs + _buffs = registerManager(new BuffManager()); + new CompassModule() .setGiveCompass(true) .setGiveCompassToSpecs(true) @@ -664,4 +667,9 @@ public class Moba extends TeamGame { return _arrowKb; } + + public BuffManager getBuffManager() + { + return _buffs; + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java index ce850e828..e0ec6c8fb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java @@ -17,7 +17,6 @@ import mineplex.core.common.util.UtilTime; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.utils.UtilVariant; -import mineplex.minecraft.game.core.condition.ConditionFactory; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; @@ -25,9 +24,10 @@ import nautilus.game.arcade.game.games.moba.ai.MobaAI; import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod; import nautilus.game.arcade.game.games.moba.ai.goal.MobaDirectAIMethod; import nautilus.game.arcade.game.games.moba.boss.MobaBoss; +import nautilus.game.arcade.game.games.moba.buff.BuffManager; +import nautilus.game.arcade.game.games.moba.buff.buffs.BuffPumpkinKing; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation; -import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -35,7 +35,6 @@ import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; @@ -44,10 +43,8 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.inventory.ItemStack; -import org.bukkit.potion.PotionEffectType; import java.util.HashSet; -import java.util.Iterator; import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -62,9 +59,6 @@ public class PumpkinBoss extends MobaBoss private static final ItemStack HELMET = new ItemStack(Material.PUMPKIN); private static final ItemStack IN_HAND = new ItemStack(Material.STONE_SWORD); private static final String DAMAGE_REASON = "Pumpkin King"; - private static final String CONDITION_REASON = DAMAGE_REASON + " Buff"; - private static final int CONDITION_LENGTH = 60; - private static final double CONDITION_DAMAGE_FACTOR = 1.5; private static final int DAMAGE_RADIUS = 2; private static final int DAMAGE_RANGE = 2; private static final int DAMAGE_DIRECT = 6; @@ -80,14 +74,12 @@ public class PumpkinBoss extends MobaBoss private MobaAI _ai; private boolean _initialSpawn; private final Set _changed; - private final Set _buffs; public PumpkinBoss(Moba host, Location location) { super(host, location, RESPAWN_TIME); _changed = new HashSet<>(); - _buffs = new HashSet<>(); } @Override @@ -223,8 +215,6 @@ public class PumpkinBoss extends MobaBoss return; } - giveBuffs(team); - _host.Announce(F.main("Game", team.GetFormattedName() + C.mBody + " killed the " + C.cDRedB + DAMAGE_REASON), false); UtilTextMiddle.display("", team.GetFormattedName() + C.cWhite + " killed the " + C.cDRedB + DAMAGE_REASON, 10, 40, 10); @@ -235,6 +225,18 @@ public class PumpkinBoss extends MobaBoss event.getEntity().getWorld().playSound(event.getEntity().getLocation(), Sound.EXPLODE, 1, 0.2F); UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, event.getEntity().getEyeLocation(), 1, 1, 1, 0.1F, 3, ViewDist.LONG); + + // Give the team members the buff + BuffManager buffManager = _host.getBuffManager(); + for (Player teamMember : team.GetPlayers(true)) + { + if (UtilPlayer.isSpectator(teamMember)) + { + continue; + } + + buffManager.apply(new BuffPumpkinKing(_host, teamMember)); + } } @EventHandler(priority = EventPriority.HIGHEST) @@ -302,86 +304,4 @@ public class PumpkinBoss extends MobaBoss { _entity.setCustomName(MobaUtil.getHealthBar(_entity, 20)); } - - private void giveBuffs(GameTeam team) - { - ConditionFactory factory = _host.getArcadeManager().GetCondition().Factory(); - - for (Player player : team.GetPlayers(true)) - { - factory.Regen(CONDITION_REASON, player, null, CONDITION_LENGTH, 1, false, true, false); - UtilParticle.PlayParticleToAll(ParticleType.LAVA, player.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 10, ViewDist.LONG); - player.playSound(player.getLocation(), Sound.PORTAL_TRAVEL, 1, 0.5F); - player.sendMessage(F.main("Game", "You feel the power of the Pumpkin King flow through you. Your damage and regeneration are increased!")); - _buffs.add(player); - - sendFakeHelmet(player); - } - } - - @EventHandler - public void updateFakeHelmet(UpdateEvent event) - { - if (event.getType() != UpdateType.SLOW) - { - return; - } - - Iterator iterator = _buffs.iterator(); - - while (iterator.hasNext()) - { - Player player = iterator.next(); - - if (!player.hasPotionEffect(PotionEffectType.REGENERATION)) - { - if (player.isOnline()) - { - player.getInventory().setHelmet(player.getInventory().getHelmet()); - } - - iterator.remove(); - continue; - } - - sendFakeHelmet(player); - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void damageIncrease(CustomDamageEvent event) - { - if (event.isCancelled()) - { - return; - } - - LivingEntity damagee = event.GetDamageeEntity(); - Player damager = event.GetDamagerPlayer(true); - - if (damager == null || !_buffs.contains(damager)) - { - return; - } - - UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, damagee.getLocation().add(0, 0.5, 0), 0.25F, 0.25F, 0.25F, 10, 1, ViewDist.NORMAL); - event.AddMod(CONDITION_REASON, CONDITION_DAMAGE_FACTOR); - } - - private void sendFakeHelmet(Player player) - { - // Magic number 4 means helmet - PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(player.getEntityId(), 4, CraftItemStack.asNMSCopy(HELMET)); - - for (Player other : Bukkit.getOnlinePlayers()) - { - // Don't send wearer their own data - if (other.equals(player)) - { - continue; - } - - UtilPlayer.sendPacket(other, packet); - } - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/Buff.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/Buff.java index e986996c0..0e9949db2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/Buff.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/Buff.java @@ -1,20 +1,57 @@ package nautilus.game.arcade.game.games.moba.buff; -import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.common.util.UtilServer; +import nautilus.game.arcade.game.games.moba.Moba; import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; +import org.bukkit.event.Listener; -public abstract class Buff +public abstract class Buff implements Listener { - private final LivingEntity _entity; + protected final Moba _host; + protected final BuffManager _manager; + protected final T _entity; + private final long _duration; - public Buff(LivingEntity entity) + private long _start; + + public Buff(Moba host, T entity, long duration) { + _host = host; + _manager = host.getBuffManager(); _entity = entity; + _duration = duration; } - public abstract void onApply(Player player); + public abstract void onApply(); - public abstract void onUpdate(UpdateEvent event); + public abstract void onExpire(); + + final void apply() + { + _start = System.currentTimeMillis(); + UtilServer.RegisterEvents(this); + onApply(); + } + + final void expire() + { + UtilServer.Unregister(this); + onExpire(); + } + + public final T getEntity() + { + return _entity; + } + + public final long getDuration() + { + return _duration; + } + + public final long getStart() + { + return _start; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java index 23e59140c..341ce035c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java @@ -1,16 +1,71 @@ package nautilus.game.arcade.game.games.moba.buff; -import mineplex.minecraft.game.core.condition.Condition; -import nautilus.game.arcade.game.games.moba.Moba; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + public class BuffManager implements Listener { - private final Moba _host; + private final Map>> _buffs; - public BuffManager(Moba host) + public BuffManager() { - _host = host; + _buffs = new HashMap<>(); + } + + public void apply(Buff buff) + { + _buffs.putIfAbsent(buff.getEntity(), new ArrayList<>(3)); + _buffs.get(buff.getEntity()).add(buff); + buff.apply(); + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + Iterator iterator = _buffs.keySet().iterator(); + + while (iterator.hasNext()) + { + LivingEntity entity = iterator.next(); + List> buffs = _buffs.get(entity); + + if (entity.isDead() || !entity.isValid() || UtilPlayer.isSpectator(entity) || entity instanceof Player && !((Player) entity).isOnline()) + { + buffs.forEach(Buff::expire); + iterator.remove(); + continue; + } + + Iterator> buffIterator = buffs.iterator(); + + while (buffIterator.hasNext()) + { + Buff buff = buffIterator.next(); + + if (UtilTime.elapsed(buff.getStart(), buff.getDuration())) + { + buff.expire(); + buffIterator.remove(); + } + } + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java index d72217b09..13868ec67 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffPumpkinKing.java @@ -1,20 +1,104 @@ package nautilus.game.arcade.game.games.moba.buff.buffs; +import mineplex.core.common.util.F; +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.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.buff.Buff; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; -public class BuffPumpkinKing extends Buff +import java.util.concurrent.TimeUnit; + +public class BuffPumpkinKing extends Buff { - public BuffPumpkinKing(LivingEntity entity) + private static final long DURATION = TimeUnit.MINUTES.toMillis(1); + private static final String DAMAGE_REASON = "Pumpkin King Buff"; + private static final double DAMAGE_FACTOR = 1.5; + private static final ItemStack HELMET = new ItemStack(Material.PUMPKIN); + + public BuffPumpkinKing(Moba host, Player entity) { - super(entity); + super(host, entity, DURATION); } @Override - public void onUpdate(UpdateEvent event) + public void onApply() { - + _entity.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 60 * 20, 1)); + UtilParticle.PlayParticleToAll(ParticleType.LAVA, _entity.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 10, ViewDist.LONG); + _entity.playSound(_entity.getLocation(), Sound.PORTAL_TRAVEL, 1, 0.5F); + _entity.sendMessage(F.main("Game", "You feel the power of the Pumpkin King flow through you. Your damage and regeneration are increased!")); } + + @Override + public void onExpire() + { + sendFakeHelmet(_entity, _entity.getInventory().getHelmet()); + } + + @EventHandler + public void updateFakeHelmet(UpdateEvent event) + { + if (event.getType() != UpdateType.SLOW) + { + return; + } + + sendFakeHelmet(_entity, HELMET); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void damageIncrease(CustomDamageEvent event) + { + if (event.isCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + Player damager = event.GetDamagerPlayer(true); + + if (damager == null || !damager.equals(_entity)) + { + return; + } + + UtilParticle.PlayParticleToAll(ParticleType.LARGE_SMOKE, damagee.getLocation().add(0, 0.5, 0), 0.25F, 0.25F, 0.25F, 0.1F, 10, ViewDist.NORMAL); + event.AddMod(DAMAGE_REASON, DAMAGE_FACTOR); + } + + private void sendFakeHelmet(Player player, ItemStack itemStack) + { + // Magic number 4 means helmet + PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(player.getEntityId(), 4, CraftItemStack.asNMSCopy(itemStack)); + + for (Player other : Bukkit.getOnlinePlayers()) + { + // Don't send wearer their own data + if (other.equals(player)) + { + continue; + } + + UtilPlayer.sendPacket(other, packet); + } + } + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffRooting.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffRooting.java new file mode 100644 index 000000000..8c4e862dc --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffRooting.java @@ -0,0 +1,78 @@ +package nautilus.game.arcade.game.games.moba.buff.buffs; + +import mineplex.core.common.events.EntityVelocityChangeEvent; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAction; +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.UtilTextMiddle; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.buff.Buff; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerMoveEvent; + +public class BuffRooting extends Buff +{ + + public BuffRooting(Moba host, Player entity, long duration) + { + super(host, entity, duration); + } + + @Override + public void onApply() + { + UtilAction.zeroVelocity(_entity); + UtilTextMiddle.display("", C.cRed + "Rooted", 10, 20, 10, (Player) _entity); + } + + @Override + public void onExpire() + { + + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + { + return; + } + + UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, _entity.getLocation().add(0, 0.5, 0), 0.5F, 0.2F, 0.5F, 0.1F, 5, ViewDist.LONG); + } + + @EventHandler + public void velocityApply(EntityVelocityChangeEvent event) + { + if (event.getEntity().equals(_entity)) + { + event.setCancelled(true); + } + } + + @EventHandler + public void move(PlayerMoveEvent event) + { + if (!event.getPlayer().equals(_entity)) + { + return; + } + + Location from = event.getFrom(); + Location to = event.getTo(); + + if (from.getX() == to.getX() && from.getZ() == to.getZ()) + { + return; + } + + event.setTo(from); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java index 2bd3d292d..6fa9c4ac4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.moba.kit.biff; 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.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle; @@ -15,6 +16,8 @@ import org.bukkit.Effect; 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.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -114,11 +117,22 @@ public class SkillBiffDash extends HeroSkill } // They have just activated it - if (!UtilTime.elapsed(start, 1000) || !UtilEnt.isGrounded(player)) + if (!UtilTime.elapsed(start, 1000) || player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.AIR) { continue; } + for (Block block : UtilBlock.getBlocksInRadius(player.getLocation(), 5)) + { + if (block.getType() == Material.AIR || block.getRelative(BlockFace.UP).getType() != Material.AIR || Math.random() > 0.5) + { + continue; + } + + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType()); + } + + for (LivingEntity entity : UtilEnt.getInRadius(player.getLocation(), 5).keySet()) { if (isTeamDamage(player, entity)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java index 65da2dceb..a89c426be 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.biff; +import mineplex.core.common.events.EntityVelocityChangeEvent; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilMath; @@ -50,7 +51,7 @@ public class SkillLeash extends HeroSkill return; } - List nearbyPlayers = UtilPlayer.getNearby(player.getLocation(), 5); + List nearbyPlayers = UtilPlayer.getNearby(player.getLocation(), 4); nearbyPlayers.removeIf(other -> isTeamDamage(other, player)); if (nearbyPlayers.isEmpty()) @@ -69,7 +70,7 @@ public class SkillLeash extends HeroSkill nearby.setShouldBreakLeash(false); nearby.sendMessage(F.main("Game", F.name(nearby.getName()) + " leashed you.")); builder.append(F.name(player.getName())).append(", "); - Manager.GetCondition().Factory().Slow(GetName(), nearby, player, 5, 0, false, true, true, false); + Manager.GetCondition().Factory().Slow(GetName(), nearby, player, 5, 1, false, true, true, false); leashedEntities.add(new LeashedEntity(Manager, nearby, player)); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java index d4a141fca..60e552d65 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java @@ -1,22 +1,29 @@ package nautilus.game.arcade.game.games.moba.kit.biff; -import mineplex.core.Managers; +import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent.ActionType; +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.UtilTime; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.buff.BuffManager; +import nautilus.game.arcade.game.games.moba.buff.buffs.BuffRooting; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; -import nautilus.game.arcade.game.games.moba.util.MobaConstants; import nautilus.game.arcade.game.games.moba.util.MobaUtil; -import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.entity.Horse; 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.inventory.ItemStack; -import org.bukkit.metadata.FixedMetadataValue; import java.util.HashSet; import java.util.Iterator; @@ -32,6 +39,7 @@ public class SkillWarHorse extends HeroSkill private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); private static final ItemStack HORSE_ARMOUR = new ItemStack(Material.IRON_BARDING); + private static final ItemStack SADDLE = new ItemStack(Material.SADDLE); private final Set _data = new HashSet<>(); @@ -65,10 +73,16 @@ public class SkillWarHorse extends HeroSkill Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class); - horse.setJumpStrength(0); + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, horse.getLocation().add(0, 1, 0), 1, 1, 1, 0.1F, 50, ViewDist.LONG); + horse.getWorld().strikeLightningEffect(horse.getLocation()); + horse.getWorld().playSound(horse.getLocation(), Sound.HORSE_DEATH, 1, 1.1F); + horse.setHealth(20); + horse.setMaxHealth(horse.getHealth()); + horse.setJumpStrength(1); horse.setMaxDomestication(1); horse.setDomestication(horse.getMaxDomestication()); horse.getInventory().setArmor(HORSE_ARMOUR); + horse.getInventory().setSaddle(SADDLE); horse.setOwner(player); horse.setPassenger(player); MobaUtil.setTeamEntity(horse, Manager.GetGame().GetTeam(player)); @@ -78,12 +92,13 @@ public class SkillWarHorse extends HeroSkill _data.add(new WarHorseData(player, horse)); broadcast(player); + useActiveSkill(player, 6000); } @EventHandler public void update(UpdateEvent event) { - if (event.getType() != UpdateType.TICK) + if (event.getType() != UpdateType.FASTER) { return; } @@ -93,18 +108,32 @@ public class SkillWarHorse extends HeroSkill while (iterator.hasNext()) { WarHorseData data = iterator.next(); + Player owner = data.Owner; + Horse horse = data.Horse; - if (UtilTime.elapsed(data.Start, 6000)) + if (UtilTime.elapsed(data.Start, 6000) || horse.isDead() || !horse.isValid()) { - data.Horse.remove(); + horse.getWorld().playSound(horse.getLocation(), Sound.HORSE_BREATHE, 1, 1.1F); + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, horse.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 50, ViewDist.LONG); + horse.remove(); iterator.remove(); } else { - Player player = data.Owner; - Location target = player.getLocation().getDirection().multiply(3).toLocation(player.getWorld()); + Moba game = (Moba) Manager.GetGame(); + BuffManager buffManager = game.getBuffManager(); - UtilEnt.CreatureMoveFast(data.Horse, target, 3F); + for (Player player : UtilPlayer.getNearby(horse.getLocation(), 5)) + { + if (isTeamDamage(owner, player) || !Recharge.Instance.use(player, GetName() + "Rooting", 2000, false, false)) + { + continue; + } + + owner.sendMessage(F.main("Game", "You hit " + F.name(player.getName()) + ".")); + Manager.GetDamage().NewDamageEvent(player, owner, null, DamageCause.CUSTOM, 10, false, true, false, UtilEnt.getName(owner), GetName()); + buffManager.apply(new BuffRooting(game, player, 1000)); + } } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/LeashedEntity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/LeashedEntity.java index 6c3bfb0e6..b0100b73d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/LeashedEntity.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/LeashedEntity.java @@ -13,6 +13,7 @@ import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @@ -32,7 +33,6 @@ public class LeashedEntity implements Listener UtilEnt.vegetate(_fakeLeash); UtilEnt.silence(_fakeLeash, true); _fakeLeash.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0, false, false)); - _fakeLeash.setBaby(true); _fakeLeash.setLeashHolder(leasher); manager.GetGame().CreatureAllowOverride = false; @@ -56,7 +56,7 @@ public class LeashedEntity implements Listener } Location location = _host.getLocation(); - ((CraftLivingEntity) _fakeLeash).getHandle().setPosition(location.getX(), location.getY() + 0.8, location.getZ()); + ((CraftLivingEntity) _fakeLeash).getHandle().setPosition(location.getX(), location.getY(), location.getZ()); } @EventHandler(priority = EventPriority.LOWEST) @@ -69,6 +69,15 @@ public class LeashedEntity implements Listener } } + @EventHandler + public void fakeLeashFire(EntityCombustEvent event) + { + if (event.getEntity().equals(_fakeLeash)) + { + event.setCancelled(true); + } + } + public LivingEntity getHost() { return _host; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java index 24f975e58..6097e9a28 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillInfinity.java @@ -50,7 +50,7 @@ public class SkillInfinity extends HeroSkill @EventHandler public void interact(PlayerInteractEvent event) { - if (!isSkillItem(event)) + if (!isSkillItem(event) || _active.contains(event.getPlayer())) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java index 4f775fa8d..d0f8bf1f4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillNinjaBlade.java @@ -97,7 +97,7 @@ public class SkillNinjaBlade extends HeroSkill int i = 0; for (ItemStack itemStack : inventory.getContents()) { - if (!itemStack.equals(ACTIVE_ITEM) && UtilItem.isSword(itemStack)) + if (itemStack != null && !itemStack.equals(ACTIVE_ITEM) && UtilItem.isSword(itemStack)) { inventory.setItem(i, null); } From 4fb4c2c865cdb3ee92026d79707f473c20e783fe Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 8 Jun 2017 16:11:25 +0100 Subject: [PATCH 49/57] Fix merge imports --- .../src/mineplex/gemhunters/loot/LootModule.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java index 3b18690ce..9aa42e3ac 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/LootModule.java @@ -41,10 +41,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -<<<<<<< HEAD -======= import org.bukkit.event.EventPriority; ->>>>>>> refs/remotes/origin/develop import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerInteractEvent; From e94ab9598a944370831ec47880cd1981848e7fd0 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 8 Jun 2017 22:43:50 +0100 Subject: [PATCH 50/57] New Heroes --- .../game/arcade/game/games/moba/Moba.java | 4 + .../games/moba/boss/wither/WitherBoss.java | 2 +- .../game/games/moba/buff/BuffManager.java | 5 + .../arcade/game/games/moba/kit/HeroKit.java | 11 +- .../arcade/game/games/moba/kit/HeroSkill.java | 2 +- .../game/games/moba/kit/anath/HeroAnath.java | 8 +- .../moba/kit/anath/SkillFireProjectile.java | 56 +++++- .../games/moba/kit/anath/SkillMeteor.java | 4 +- .../game/games/moba/kit/biff/HeroBiff.java | 10 +- .../game/games/moba/kit/biff/SkillLeash.java | 14 +- .../games/moba/kit/biff/SkillWarHorse.java | 4 +- .../game/games/moba/kit/bob/HeroBob.java | 8 +- .../game/games/moba/kit/dana/HeroDana.java | 10 +- .../game/games/moba/kit/devon/HeroDevon.java | 9 +- .../games/moba/kit/hattori/HeroHattori.java | 11 +- .../game/games/moba/kit/hp/HPManager.java | 17 +- .../games/moba/kit/hp/MobaHPRegenEvent.java | 16 +- .../games/moba/kit/larissa/HeroLarissa.java | 35 ++++ .../games/moba/kit/larissa/SkillAOEHeal.java | 182 ++++++++++++++++++ .../moba/kit/larissa/SkillAquaCannon.java | 76 ++++++++ .../moba/kit/larissa/SkillStormHeal.java | 133 +++++++++++++ .../moba/kit/larissa/SkillWaterDash.java | 57 ++++++ .../arcade/game/games/moba/shop/MobaShop.java | 58 +----- .../moba/structure/tower/TowerManager.java | 24 +++ 24 files changed, 629 insertions(+), 127 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/HeroLarissa.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillStormHeal.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index e1f9bcc3e..aade9ac0d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -30,6 +30,7 @@ import nautilus.game.arcade.game.games.moba.kit.dana.HeroDana; import nautilus.game.arcade.game.games.moba.kit.devon.HeroDevon; import nautilus.game.arcade.game.games.moba.kit.hattori.HeroHattori; import nautilus.game.arcade.game.games.moba.kit.hp.HPManager; +import nautilus.game.arcade.game.games.moba.kit.larissa.HeroLarissa; import nautilus.game.arcade.game.games.moba.minion.MinionManager; import nautilus.game.arcade.game.games.moba.prepare.PrepareManager; import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection; @@ -95,9 +96,11 @@ public class Moba extends TeamGame new HeroAnath(Manager), new HeroDana(Manager), new HeroBiff(Manager), + new HeroLarissa(Manager), new HeroBob(Manager) }; + AllowParticles = false; DontAllowOverfill = true; PrepareAutoAnnounce = false; PrepareFreeze = false; @@ -107,6 +110,7 @@ public class Moba extends TeamGame HungerSet = 20; DamageFall = false; + manager.getCosmeticManager().setHideParticles(true); manager.GetCreature().SetDisableCustomDrops(true); // Instantiate managers diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index 779bdf9f8..41b4a242c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -35,7 +35,7 @@ public class WitherBoss extends MobaBoss private static final String NAME = "Wither Boss"; private static final float SPEED_TARGET = 4F; private static final float SPEED_HOME = 6F; - private static final int INITIAL_HEALTH = 500; + private static final int INITIAL_HEALTH = 125; private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); private GameTeam _team; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java index 341ce035c..25ba3d101 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java @@ -27,6 +27,11 @@ public class BuffManager implements Listener public void apply(Buff buff) { + if (UtilPlayer.isSpectator(buff.getEntity())) + { + return; + } + _buffs.putIfAbsent(buff.getEntity(), new ArrayList<>(3)); _buffs.get(buff.getEntity()).add(buff); buff.apply(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index ab3f56ad7..efd7abfe5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -41,12 +41,16 @@ public class HeroKit extends Kit .setTitle(C.cGreenB + "Recall to your Base") .addLore("Clicking this item will teleport you back to your", "base after " + F.time("5") + " seconds.", "Taking damage or moving will cancel", "your teleport.") .build(); + private static final ItemStack SHOP_ITEM = new ItemBuilder(Material.GOLD_INGOT) + .setTitle(C.cGold + "Open Gold Upgrades") + .addLore("Click to open the Gold Upgrades", "shop while you are respawning.") + .build(); private boolean _visible = true; - public HeroKit(ArcadeManager manager, String name, String[] kitDesc, Perk[] kitPerks, ItemStack itemInHand, MobaRole role) + public HeroKit(ArcadeManager manager, String name, Perk[] kitPerks, MobaRole role) { - super(manager, name, KitAvailability.Free, kitDesc, kitPerks, null, itemInHand); + super(manager, name, KitAvailability.Free, new String[0], kitPerks, null, null); _role = role; _maxAmmo = 64; @@ -163,7 +167,8 @@ public class HeroKit extends Kit // Give standard items inventory.setItem(AMMO_SLOT, _ammo); - inventory.setItem(RECALL_SLOT, RECALL_ITEM); + //inventory.setItem(RECALL_SLOT, RECALL_ITEM); + inventory.setItem(RECALL_SLOT, SHOP_ITEM); Moba game = (Moba) Manager.GetGame(); List items = game.getShop().getOwnedItems(player); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 53e5cf73b..6239445ea 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -286,7 +286,7 @@ public class HeroSkill extends Perk for (Player player : Manager.GetGame().GetPlayers(true)) { - if (!hasPerk(player) || !_lastSkill.containsKey(player.getUniqueId())) + if (!hasPerk(player) || UtilPlayer.isSpectator(player) || !_lastSkill.containsKey(player.getUniqueId())) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java index b7f805b65..59e33556d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java @@ -12,10 +12,6 @@ import org.bukkit.inventory.ItemStack; public class HeroAnath extends HeroKit { - private static final String[] DESCRIPTION = { - "Something something" - }; - private static final Perk[] PERKS = { new SkillFireProjectile(0), new SkillBurnBeam(1), @@ -23,15 +19,13 @@ public class HeroAnath extends HeroKit new SkillMeteor(3) }; - private static final ItemStack IN_HAND = new ItemStack(Material.BLAZE_ROD); - private static final ItemStack AMMO = new ItemBuilder(Material.BLAZE_POWDER) .setTitle(C.cYellowB + "Embers") .build(); public HeroAnath(ArcadeManager manager) { - super(manager, "Anath", DESCRIPTION, PERKS, IN_HAND, MobaRole.MAGE); + super(manager, "Anath", PERKS, MobaRole.MAGE); setAmmo(AMMO, 1000); setMaxAmmo(4); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java index 74591c991..4d8d69b35 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java @@ -1,17 +1,25 @@ package nautilus.game.arcade.game.games.moba.kit.anath; +import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; -import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.Material; -import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.SmallFireball; import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; +import java.util.ArrayList; +import java.util.List; + public class SkillFireProjectile extends HeroSkill { @@ -20,9 +28,10 @@ public class SkillFireProjectile extends HeroSkill "Any enemies it collides with take damage and are set on fire." }; private static final int DAMAGE = 5; - private static final ItemStack SKILL_ITEM = new ItemStack(Material.BLAZE_ROD); + private final List _fireballs = new ArrayList<>(); + public SkillFireProjectile(int slot) { super("Flame Wand", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); @@ -44,10 +53,43 @@ public class SkillFireProjectile extends HeroSkill } Vector direction = player.getLocation().getDirection().multiply(1.25); - Item item = player.getWorld().dropItem(player.getEyeLocation().add(direction), _kit.getAmmo()); - item.setVelocity(direction); - ((Moba) Manager.GetGame()).getTowerManager().addProjectile(player, item, DAMAGE); - Manager.GetFire().Add(item, player, 3, 0, 1, DAMAGE, MobaConstants.BASIC_ATTACK, false); + SmallFireball fireball = player.getWorld().spawn(player.getEyeLocation().add(direction), SmallFireball.class); + fireball.setShooter(player); + fireball.setVelocity(direction); + _fireballs.add(fireball); + + ((Moba) Manager.GetGame()).getTowerManager().addProjectile(player, fireball, DAMAGE); + } + + @EventHandler + public void fireballPrevention(CustomDamageEvent event) + { + if (event.GetProjectile() != null && _fireballs.contains(event.GetProjectile())) + { + event.SetCancelled("Fireball Damage"); + } + } + + @EventHandler + public void projectileHit(ProjectileHitEvent event) + { + Projectile entity = event.getEntity(); + + if (!_fireballs.contains(entity)) + { + return; + } + + Player player = (Player) entity.getShooter(); + + for (LivingEntity nearby : UtilEnt.getInRadius(entity.getLocation(), 1.5).keySet()) + { + nearby.setFireTicks(40); + Manager.GetDamage().NewDamageEvent(nearby, player, null, DamageCause.CUSTOM, DAMAGE, true, true, false, player.getName(), GetName()); + } + + _fireballs.remove(entity); + entity.remove(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java index d91b18850..2b7cd0523 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java @@ -9,6 +9,7 @@ import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.kit.perks.data.MeteorShowerData; import org.bukkit.Location; @@ -99,6 +100,7 @@ public class SkillMeteor extends HeroSkill implements IThrown for (MeteorShowerData data : _data) { Location location = data.Target; + GameTeam team = Manager.GetGame().GetTeam(data.Shooter); for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 100) { @@ -107,7 +109,7 @@ public class SkillMeteor extends HeroSkill implements IThrown location.add(x, 0.25, z); - UtilParticle.PlayParticleToAll(ParticleType.FLAME, location, 0, 0, 0, 0.001F, 1, ViewDist.LONG); + UtilParticle.playColoredParticleToAll(team.GetColorBase(), ParticleType.RED_DUST, location, 1, ViewDist.LONG); location.subtract(x, 0.25, z); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java index fe65df976..78314c186 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java @@ -5,16 +5,10 @@ import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.kit.common.SkillSword; import nautilus.game.arcade.kit.Perk; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; public class HeroBiff extends HeroKit { - private static final String[] DESCRIPTION = { - "Something something" - }; - private static final Perk[] PERKS = { new SkillSword(0), new SkillLeash(1), @@ -22,10 +16,8 @@ public class HeroBiff extends HeroKit new SkillWarHorse(3) }; - private static final ItemStack IN_HAND = new ItemStack(Material.IRON_SWORD); - public HeroBiff(ArcadeManager manager) { - super(manager, "Biff", DESCRIPTION, PERKS, IN_HAND, MobaRole.WARRIOR); + super(manager, "Biff", PERKS, MobaRole.WARRIOR); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java index a89c426be..5c9e28f4d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.moba.kit.biff; import mineplex.core.common.events.EntityVelocityChangeEvent; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; @@ -10,6 +11,7 @@ import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.kit.common.LeashedEntity; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractEvent; @@ -51,11 +53,12 @@ public class SkillLeash extends HeroSkill return; } - List nearbyPlayers = UtilPlayer.getNearby(player.getLocation(), 4); + List nearbyPlayers = UtilPlayer.getNearby(player.getLocation(), 8); nearbyPlayers.removeIf(other -> isTeamDamage(other, player)); if (nearbyPlayers.isEmpty()) { + player.sendMessage(F.main("Game", "There was no one in range to leash.")); return; } @@ -68,14 +71,17 @@ public class SkillLeash extends HeroSkill nearby.setLeashHolder(player); nearby.setPullWhileLeashed(false); nearby.setShouldBreakLeash(false); - nearby.sendMessage(F.main("Game", F.name(nearby.getName()) + " leashed you.")); - builder.append(F.name(player.getName())).append(", "); + nearby.sendMessage(F.main("Game", F.name(player.getName()) + " leashed you.")); + nearby.playSound(nearby.getLocation(), Sound.DOOR_CLOSE, 1, 1); + builder.append(F.name(nearby.getName())).append(", "); + UtilAction.zeroVelocity(nearby); Manager.GetCondition().Factory().Slow(GetName(), nearby, player, 5, 1, false, true, true, false); leashedEntities.add(new LeashedEntity(Manager, nearby, player)); } _leashed.put(player, leashedEntities); + player.playSound(player.getLocation(), Sound.DOOR_CLOSE, 1, 1); player.sendMessage(builder.toString()); useActiveSkill(() -> @@ -104,7 +110,7 @@ public class SkillLeash extends HeroSkill { LeashedEntity leashed = iterator.next(); - if (UtilMath.offsetSquared(entry.getKey(), leashed.getHost()) < 25) + if (!UtilPlayer.isSpectator(entry.getKey()) && UtilMath.offsetSquared(entry.getKey(), leashed.getHost()) < 100) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java index 60e552d65..27784b829 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java @@ -92,7 +92,7 @@ public class SkillWarHorse extends HeroSkill _data.add(new WarHorseData(player, horse)); broadcast(player); - useActiveSkill(player, 6000); + useActiveSkill(player, 5500); } @EventHandler @@ -111,7 +111,7 @@ public class SkillWarHorse extends HeroSkill Player owner = data.Owner; Horse horse = data.Horse; - if (UtilTime.elapsed(data.Start, 6000) || horse.isDead() || !horse.isValid()) + if (UtilTime.elapsed(data.Start, 6000) || UtilPlayer.isSpectator(owner) || horse.isDead() || !horse.isValid()) { horse.getWorld().playSound(horse.getLocation(), Sound.HORSE_BREATHE, 1, 1.1F); UtilParticle.PlayParticleToAll(ParticleType.CLOUD, horse.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.1F, 50, ViewDist.LONG); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java index 89b56fa7f..8c851c98b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java @@ -12,10 +12,6 @@ import org.bukkit.inventory.ItemStack; public class HeroBob extends HeroKit { - private static final String[] DESCRIPTION = { - "Something something" - }; - private static final Perk[] PERKS = { new SkillPaint(0), new SkillHappyTrees(1), @@ -23,15 +19,13 @@ public class HeroBob extends HeroKit new SkillBuildPainting(3) }; - private static final ItemStack IN_HAND = new ItemStack(Material.PAINTING); - private static final ItemStack AMMO = new ItemBuilder(Material.SNOW_BALL) .setTitle(C.cYellowB + "Titanium Hwhite") .build(); public HeroBob(ArcadeManager manager) { - super(manager, "Bob Ross", DESCRIPTION, PERKS, IN_HAND, MobaRole.MAGE); + super(manager, "Bob Ross", PERKS, MobaRole.MAGE); setAmmo(AMMO, 500); setMaxAmmo(8); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/HeroDana.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/HeroDana.java index ce24c96b5..e6e0f1e8b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/HeroDana.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/HeroDana.java @@ -5,16 +5,10 @@ import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.kit.common.SkillSword; import nautilus.game.arcade.kit.Perk; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; public class HeroDana extends HeroKit { - private static final String[] DESCRIPTION = { - "Something something" - }; - private static final Perk[] PERKS = { new SkillSword(0), new SkillPulseHeal(1), @@ -22,10 +16,8 @@ public class HeroDana extends HeroKit new SkillRally(3), }; - private static final ItemStack IN_HAND = new ItemStack(Material.IRON_SWORD); - public HeroDana(ArcadeManager manager) { - super(manager, "Dana", DESCRIPTION, PERKS, IN_HAND, MobaRole.WARRIOR); + super(manager, "Dana", PERKS, MobaRole.WARRIOR); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java index f80d6c6e2..c50db2648 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java @@ -8,16 +8,11 @@ import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.kit.common.SkillBow; import nautilus.game.arcade.kit.Perk; import org.bukkit.Material; -import org.bukkit.event.EventHandler; import org.bukkit.inventory.ItemStack; public class HeroDevon extends HeroKit { - private static final String[] DESCRIPTION = { - "Something something" - }; - private static final Perk[] PERKS = { new SkillBow(0), new SkillTNTArrows(1), @@ -25,8 +20,6 @@ public class HeroDevon extends HeroKit new SkillInfinity(3) }; - private static final ItemStack IN_HAND = new ItemStack(Material.BOW); - private static final ItemStack AMMO = new ItemBuilder(Material.ARROW) .setTitle(C.cYellowB + "Hunting Arrow") .setUnbreakable(true) @@ -34,7 +27,7 @@ public class HeroDevon extends HeroKit public HeroDevon(ArcadeManager manager) { - super(manager, "Devon", DESCRIPTION, PERKS, IN_HAND, MobaRole.HUNTER); + super(manager, "Devon", PERKS, MobaRole.HUNTER); setAmmo(AMMO, 3000); setMaxAmmo(3); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java index d9371bad2..284a78e01 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java @@ -6,16 +6,10 @@ import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.kit.common.SkillSword; import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.perks.PerkDoubleJump; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; public class HeroHattori extends HeroKit { - private static final String[] DESCRIPTION = { - "Something something" - }; - private static final Perk[] PERKS = { new PerkDoubleJump("Double Jump", 1, 1, true, 3000, true), new SkillSword(0), @@ -24,11 +18,8 @@ public class HeroHattori extends HeroKit new SkillNinjaBlade(3) }; - private static final ItemStack IN_HAND = new ItemStack(Material.NETHER_STAR); - - public HeroHattori(ArcadeManager manager) { - super(manager, "Hattori", DESCRIPTION, PERKS, IN_HAND, MobaRole.ASSASSIN); + super(manager, "Hattori", PERKS, MobaRole.ASSASSIN); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java index 298c46afa..a23c4d4ac 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java @@ -10,12 +10,13 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; +import org.bukkit.potion.PotionEffectType; public class HPManager implements Listener { // Health per 5 seconds. - private static final double HP5 = 0.33; + private static final double HP5 = 0.66; private final Moba _host; @@ -42,6 +43,11 @@ public class HPManager implements Listener MobaHPRegenEvent regenEvent = new MobaHPRegenEvent(player, HP5); UtilServer.CallEvent(regenEvent); + if (regenEvent.isCancelled()) + { + continue; + } + player.setHealth(Math.min(player.getMaxHealth(), player.getHealth() + regenEvent.getHealth())); } } @@ -54,4 +60,13 @@ public class HPManager implements Listener event.setCancelled(true); } } + + @EventHandler + public void preventRegenerationWither(MobaHPRegenEvent event) + { + if (event.getPlayer().hasPotionEffect(PotionEffectType.WITHER)) + { + event.setCancelled(true); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java index 770d2acfc..793c170ba 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java @@ -1,16 +1,18 @@ package nautilus.game.arcade.game.games.moba.kit.hp; import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerEvent; -public class MobaHPRegenEvent extends PlayerEvent +public class MobaHPRegenEvent extends PlayerEvent implements Cancellable { private static final HandlerList _handlers = new HandlerList(); private final double _initialHealth; private double _health; + private boolean _cancel; public MobaHPRegenEvent(Player who, double health) { @@ -35,6 +37,18 @@ public class MobaHPRegenEvent extends PlayerEvent return _health; } + @Override + public boolean isCancelled() + { + return _cancel; + } + + @Override + public void setCancelled(boolean b) + { + _cancel = b; + } + public static HandlerList getHandlerList() { return _handlers; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/HeroLarissa.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/HeroLarissa.java new file mode 100644 index 000000000..f208d672b --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/HeroLarissa.java @@ -0,0 +1,35 @@ +package nautilus.game.arcade.game.games.moba.kit.larissa; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +public class HeroLarissa extends HeroKit +{ + + private static final Perk[] PERKS = { + new SkillAquaCannon(0), + new SkillAOEHeal(1), + new SkillWaterDash(2), + new SkillStormHeal(3) + }; + + private static final ItemStack AMMO = new ItemBuilder(Material.INK_SACK, (byte) 4) + .setTitle(C.cYellowB + "Water Stone") + .setUnbreakable(true) + .build(); + + public HeroLarissa(ArcadeManager manager) + { + super(manager, "Larissa", PERKS, MobaRole.MAGE); + + setAmmo(AMMO, 3000); + setMaxAmmo(5); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java new file mode 100644 index 000000000..9b7ff9c76 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java @@ -0,0 +1,182 @@ +package nautilus.game.arcade.game.games.moba.kit.larissa; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilFirework; +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.UtilTime; +import mineplex.core.projectile.IThrown; +import mineplex.core.projectile.ProjectileUser; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.util.MobaParticles; +import org.bukkit.Bukkit; +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +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.entity.Entity; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +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.inventory.ItemStack; +import org.bukkit.util.Vector; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +public class SkillAOEHeal extends HeroSkill implements IThrown +{ + + private static final String[] DESCRIPTION = { + "Fires an Ember at high speed in front of you.", + "Any enemies it collides with take damage and are set on fire." + }; + private static final long DURATION = TimeUnit.SECONDS.toMillis(6); + private static final int RADIUS = 3; + private static final int HEALTH_PER_SECOND = 4; + private static final int DAMAGE_PER_SECOND = 2; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.WATER_BUCKET); + private static final ItemStack THROWN_ITEM = new ItemStack(Material.WATER_BUCKET); + + private final Set _data = new HashSet<>(); + + public SkillAOEHeal(int slot) + { + super("Dancing Fountain", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + + setCooldown(14000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + Vector direction = player.getLocation().getDirection(); + Item item = player.getWorld().dropItem(player.getEyeLocation().add(direction), THROWN_ITEM); + item.setVelocity(direction); + + useSkill(player); + Manager.GetProjectile().AddThrow(item, player, this, 1000, true, true, true, false, 1F); + } + + @Override + public void Collide(LivingEntity target, Block block, ProjectileUser data) + { + deployAoe((Player) data.getThrower(), data.getThrown(), data.getThrown().getLocation()); + } + + @Override + public void Idle(ProjectileUser data) + { + } + + @Override + public void Expire(ProjectileUser data) + { + deployAoe((Player) data.getThrower(), data.getThrown(), data.getThrown().getLocation()); + } + + @EventHandler + public void updateAOE(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator iterator = _data.iterator(); + + while (iterator.hasNext()) + { + AOEHealData data = iterator.next(); + Player owner = data.Owner; + GameTeam team = Manager.GetGame().GetTeam(owner); + + if (UtilTime.elapsed(data.Start, DURATION)) + { + iterator.remove(); + } + else if (UtilTime.elapsed(data.LastHeal, 1000)) + { + data.LastHeal = System.currentTimeMillis(); + + for (LivingEntity entity : UtilEnt.getInRadius(data.Center, RADIUS).keySet()) + { + if (isTeamDamage(entity, owner)) + { + MobaParticles.healing(entity, HEALTH_PER_SECOND); + entity.setHealth(Math.min(entity.getHealth() + HEALTH_PER_SECOND, entity.getMaxHealth())); + } + else + { + Manager.GetDamage().NewDamageEvent(entity, owner, null, DamageCause.CUSTOM, DAMAGE_PER_SECOND, true, true, false, owner.getName(), GetName()); + } + } + } + + UtilParticle.PlayParticleToAll(ParticleType.DRIP_WATER, data.Center, RADIUS - 0.5F, 0.2F, RADIUS - 0.5F, 0.1F, 5, ViewDist.LONG); + + for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 15) + { + double x = RADIUS * Math.cos(theta); + double z = RADIUS * Math.sin(theta); + + data.Center.add(x, 0, z); + + UtilParticle.playColoredParticleToAll(team.GetColorBase(), ParticleType.RED_DUST, data.Center, 1, ViewDist.LONG); + + data.Center.subtract(x, 0, z); + } + } + } + + private void deployAoe(Player thrower, Entity item, Location location) + { + GameTeam team = Manager.GetGame().GetTeam(thrower); + + if (team == null) + { + return; + } + + UtilFirework.playFirework(location, FireworkEffect.builder().with(Type.BURST).withColor(team.GetColorBase()).withFade(Color.WHITE).withFlicker().build()); + thrower.getWorld().playSound(location, Sound.SPLASH2, 1, 1); + item.remove(); + _data.add(new AOEHealData(thrower, location)); + } + + private class AOEHealData + { + + Player Owner; + Location Center; + long Start; + long LastHeal; + + AOEHealData(Player owner, Location center) + { + Owner = owner; + Center = center; + Start = System.currentTimeMillis(); + LastHeal = Start; + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java new file mode 100644 index 000000000..4e1a2bdca --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java @@ -0,0 +1,76 @@ +package nautilus.game.arcade.game.games.moba.kit.larissa; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +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.UtilServer; +import mineplex.core.common.util.particles.effects.LineParticle; +import mineplex.core.recharge.Recharge; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.LivingEntity; +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.inventory.ItemStack; +import org.bukkit.util.Vector; + +public class SkillAquaCannon extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Fires an Ember at high speed in front of you.", + "Any enemies it collides with take damage and are set on fire." + }; + private static final int DAMAGE = 6; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.DIAMOND_HOE); + + public SkillAquaCannon(int slot) + { + super("Aqua Cannon", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + if (!_kit.useAmmo(player, 1)) + { + return; + } + + TowerManager towerManager = ((Moba) Manager.GetGame()).getTowerManager(); + Vector direction = player.getLocation().getDirection(); + + LineParticle lineParticle = new LineParticle(player.getLocation().add(0, 1.7, 0), direction, 0.2, 10, ParticleType.DRIP_WATER, UtilServer.getPlayers()); + + while (!lineParticle.update() && towerManager.damageTowerAt(lineParticle.getLastLocation(), player, DAMAGE) == null) + { + for (LivingEntity entity : UtilEnt.getInRadius(lineParticle.getLastLocation(), 2).keySet()) + { + if (isTeamDamage(entity, player)) + { + continue; + } + + Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, DAMAGE, true, false, false, player.getName(), GetName()); + break; + } + } + + player.getWorld().playSound(lineParticle.getLastLocation(), Sound.BLAZE_HIT, 1, 1.4F); + UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, lineParticle.getLastLocation(), 0, 0, 0, 0.2F, 10, ViewDist.LONG); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillStormHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillStormHeal.java new file mode 100644 index 000000000..34adb0612 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillStormHeal.java @@ -0,0 +1,133 @@ +package nautilus.game.arcade.game.games.moba.kit.larissa; + +import mineplex.core.Managers; +import mineplex.core.common.util.UtilEvent.ActionType; +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.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +public class SkillStormHeal extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Fires an Ember at high speed in front of you.", + "Any enemies it collides with take damage and are set on fire." + }; + private static final long DURATION = TimeUnit.SECONDS.toMillis(7); + private static final int HEALTH_PER_SECOND = 2; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); + + private final Map _active = new HashMap<>(); + + public SkillStormHeal(int slot) + { + super("Storm's Blessing", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + + setCooldown(60000); + setDropItemActivate(true); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event) || _active.containsKey(event.getPlayer())) + { + return; + } + + Player player = event.getPlayer(); + + for (Player teamMember : Manager.GetGame().GetTeam(player).GetPlayers(true)) + { + teamMember.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, (int) (DURATION / 50D), 0)); + } + + _active.put(player, System.currentTimeMillis()); + broadcast(player); + useActiveSkill(player, DURATION - 500); + } + + @EventHandler + public void updateHeal(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + _active.forEach((player, start) -> + { + GameTeam team = Manager.GetGame().GetTeam(player); + + if (team == null) + { + return; + } + + for (Player teamMember : team.GetPlayers(true)) + { + teamMember.setHealth(Math.min(teamMember.getHealth() + HEALTH_PER_SECOND, teamMember.getMaxHealth())); + } + }); + } + + @EventHandler + public void updateParticles(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + { + return; + } + + Iterator iterator = _active.keySet().iterator(); + + while (iterator.hasNext()) + { + Player player = iterator.next(); + + if (UtilTime.elapsed(_active.get(player), DURATION)) + { + iterator.remove(); + } + + GameTeam team = Manager.GetGame().GetTeam(player); + + if (team == null) + { + return; + } + + for (Player teamMember : team.GetPlayers(true)) + { + if (UtilPlayer.isSpectator(teamMember)) + { + continue; + } + + Location location = teamMember.getLocation().add(0, 3, 0); + + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, location, 0.5F, 0.2F, 0.5F, 0.001F, 12, ViewDist.LONG); + UtilParticle.PlayParticleToAll(ParticleType.DRIP_WATER, location.subtract(0, 0.2, 0), 0.4F, 0.1F, 0.4F, 0.1F, 2, ViewDist.LONG); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java new file mode 100644 index 000000000..85d9f93ee --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java @@ -0,0 +1,57 @@ +package nautilus.game.arcade.game.games.moba.kit.larissa; + +import mineplex.core.common.util.UtilBlock; +import nautilus.game.arcade.game.games.moba.kit.common.DashSkill; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.BlockFromToEvent; +import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.inventory.ItemStack; + +public class SkillWaterDash extends DashSkill +{ + + private static final String[] DESCRIPTION = { + "Dash along the ground, leaving water behind you.", + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); + + public SkillWaterDash(int slot) + { + super("Water Dash", DESCRIPTION, SKILL_ITEM, slot); + + setCooldown(10000); + + _collide = false; + _velocityTime = 600; + _velocityStopOnEnd = true; + _horizontial = true; + } + + @Override + public void dashTick(Player player) + { + Block block = player.getLocation().getBlock(); + + while (!UtilBlock.solid(block)) + { + block = block.getRelative(BlockFace.DOWN); + } + + Block fBlock = block; + Manager.runSyncLater(() -> Manager.GetBlockRestore().add(fBlock.getRelative(BlockFace.UP), Material.WATER.getId(), (byte) 0, 7000), 10); + } + + @EventHandler + public void onBlockFromTo(BlockFromToEvent event) + { + if (event.getBlock().isLiquid() || event.getToBlock().isLiquid()) + { + event.setCancelled(true); + } + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index 2c0ba235b..1538a04e4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -54,11 +54,6 @@ import java.util.Map.Entry; public class MobaShop implements Listener { - private static final ItemStack SHOP_ITEM = new ItemBuilder(Material.GOLD_INGOT) - .setTitle(C.cGold + "Open Gold Upgrades") - .addLore("Click to open the Gold Upgrades", "shop while you are respawning.") - .build(); - private final Moba _host; private final Map _entities; private final Map _roleMenus; @@ -216,13 +211,6 @@ public class MobaShop implements Listener owned.add(item); category.purchase(player); - // This would happen when the player is respawning and is purchasing upgrades - // In this case giving them the item is not needed - if (UtilPlayer.isSpectator(player)) - { - return; - } - // The respawn event needs to be called here so that effects like "Total Health Increase" will work straight away, instead of after the next respawn, // Prevents infinite speed player.setWalkSpeed(0.2F); @@ -268,55 +256,13 @@ public class MobaShop implements Listener } /* - Allow players to access the shop while dead. + Allow players to access the shop through an item */ - @EventHandler - public void playerDeath(PlayerDeathEvent event) - { - final Player player = event.getEntity(); - - _host.getArcadeManager().runSyncLater(() -> - { - // Certain categories such as consumables drop on death so here we remove them from upgrades - List owned = _upgrades.get(player); - - if (owned != null) - { - owned.removeIf(item -> - { - MobaShopCategory category = getCategory(item); - return category == null || category.isDroppingOnDeath(); - }); - - // Reset the max amount of purchasable items - MobaPlayer mobaPlayer = _host.getMobaData(player); - - if (mobaPlayer == null || mobaPlayer.getRole() == null) - { - return; - } - - _roleMenus.get(mobaPlayer.getRole()).getCategories().forEach(category -> category.onDeath(player)); - } - - // Give the player their kit items - Kit kit = _host.GetKit(player); - - if (kit == null) - { - return; - } - - kit.GiveItems(player); - player.getInventory().setItem(8, SHOP_ITEM); - }, 1); - } - @EventHandler public void interactShopItem(PlayerInteractEvent event) { - if (event.getItem() == null || !event.getItem().isSimilar(SHOP_ITEM)) + if (event.getItem() == null || event.getItem().getType() != Material.GOLD_INGOT) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index 6efb7e551..a8a8319db 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -265,6 +265,30 @@ public class TowerManager implements Listener } } + public Tower damageTowerAt(Location location, Player shooter, double damage) + { + GameTeam team = _host.GetTeam(shooter); + + if (team == null) + { + return null; + } + + for (Tower tower : _towers) + { + if (tower.isDead() || tower.getOwner().equals(team) || UtilMath.offsetSquared(tower.getCrystal().getLocation(), location) > PROJECTILE_RANGE_SQUARED) + { + continue; + } + + playSound(shooter, tower); + tower.damage(damage); + return tower; + } + + return null; + } + private boolean shouldCancelDamage(Tower tower, Player shooter) { Location entityLocation = tower.getCrystal().getLocation(); From 79b983536d05bf1a81ed70d31cddcd2e6e5d802f Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 8 Jun 2017 22:55:17 +0100 Subject: [PATCH 51/57] While Withered, prevent regeneration --- .../games/moba/kit/bob/SkillHappyTrees.java | 3 ++- .../games/moba/kit/dana/SkillPulseHeal.java | 3 ++- .../game/games/moba/kit/hp/HPManager.java | 15 ++++++++++++++ .../games/moba/kit/larissa/SkillAOEHeal.java | 3 ++- .../moba/kit/larissa/SkillStormHeal.java | 3 ++- .../arcade/game/games/moba/util/MobaUtil.java | 20 ++++++++++++++++--- 6 files changed, 40 insertions(+), 7 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java index 801f63ba4..f5e0fbc4b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java @@ -8,6 +8,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.util.MobaParticles; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -152,7 +153,7 @@ public class SkillHappyTrees extends HeroSkill continue; } - entity.setHealth(Math.min(entity.getHealth() + 2, entity.getMaxHealth())); + MobaUtil.heal(entity, 2); MobaParticles.healing(entity, 1); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java index 5c17f5fdf..358db05c1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java @@ -7,6 +7,7 @@ import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.LivingEntity; @@ -51,7 +52,7 @@ public class SkillPulseHeal extends HeroSkill continue; } - entity.setHealth(Math.min(entity.getHealth() + 4, entity.getMaxHealth())); + MobaUtil.heal(entity, 4); } displayPulse(player.getLocation().add(0, 0.5, 0)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java index a23c4d4ac..7f91b073d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java @@ -10,6 +10,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; +import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.potion.PotionEffectType; public class HPManager implements Listener @@ -17,6 +18,7 @@ public class HPManager implements Listener // Health per 5 seconds. private static final double HP5 = 0.66; + private static final double HP_KILL_FACTOR = 0.25; private final Moba _host; @@ -52,6 +54,19 @@ public class HPManager implements Listener } } + @EventHandler + public void playerDeath(PlayerDeathEvent event) + { + Player killer = event.getEntity().getKiller(); + + if (killer == null) + { + return; + } + + killer.setHealth(Math.min(killer.getHealth() + killer.getMaxHealth() * HP_KILL_FACTOR, killer.getMaxHealth())); + } + @EventHandler public void preventHungerRegeneration(EntityRegainHealthEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java index 9b7ff9c76..ebda5b79a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java @@ -14,6 +14,7 @@ import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.util.MobaParticles; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.FireworkEffect; @@ -123,7 +124,7 @@ public class SkillAOEHeal extends HeroSkill implements IThrown if (isTeamDamage(entity, owner)) { MobaParticles.healing(entity, HEALTH_PER_SECOND); - entity.setHealth(Math.min(entity.getHealth() + HEALTH_PER_SECOND, entity.getMaxHealth())); + MobaUtil.heal(entity, HEALTH_PER_SECOND); } else { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillStormHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillStormHeal.java index 34adb0612..9c2fbbaca 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillStormHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillStormHeal.java @@ -11,6 +11,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -85,7 +86,7 @@ public class SkillStormHeal extends HeroSkill for (Player teamMember : team.GetPlayers(true)) { - teamMember.setHealth(Math.min(teamMember.getHealth() + HEALTH_PER_SECOND, teamMember.getMaxHealth())); + MobaUtil.heal(teamMember, HEALTH_PER_SECOND); } }); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index 46c3eac2f..97bb33361 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -4,12 +4,10 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; -import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; -import org.bukkit.Bukkit; +import nautilus.game.arcade.game.games.moba.kit.hp.MobaHPRegenEvent; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -196,4 +194,20 @@ public class MobaUtil { return entity.hasMetadata(MobaConstants.TEAM_METADATA) && entity.getMetadata(MobaConstants.TEAM_METADATA).get(0).asString().equals(team.GetName()); } + + public static void heal(LivingEntity entity, double health) + { + if (entity instanceof Player) + { + MobaHPRegenEvent regenEvent = new MobaHPRegenEvent((Player) entity, health); + UtilServer.CallEvent(regenEvent); + + if (regenEvent.isCancelled()) + { + return; + } + } + + entity.setHealth(Math.min(entity.getHealth() + health, entity.getMaxHealth())); + } } From ac52903b7d02ba839cbe0e76d7c7291aee282bcc Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 9 Jun 2017 13:10:11 +0100 Subject: [PATCH 52/57] QOL changes --- .../core/common/util/UtilParticle.java | 4 +- .../game/arcade/game/games/moba/Moba.java | 2 + .../arcade/game/games/moba/kit/HeroSkill.java | 3 +- .../moba/kit/anath/SkillFireProjectile.java | 15 +- .../games/moba/kit/anath/SkillMeteor.java | 10 +- .../games/moba/kit/bardolf/HeroBardolf.java | 286 ++++++++++++++++++ .../games/moba/kit/bardolf/SkillFullMoon.java | 109 +++++++ .../moba/kit/bardolf/SkillSummonWolf.java | 96 ++++++ .../moba/kit/bardolf/SkillWolfPounce.java | 168 ++++++++++ .../games/moba/kit/larissa/SkillAOEHeal.java | 7 +- 10 files changed, 689 insertions(+), 11 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillWolfPounce.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java index 7b85b4971..a87bb2565 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java @@ -258,11 +258,9 @@ public class UtilParticle } } - PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleType.particle, displayFar, + return new PacketPlayOutWorldParticles(particleType.particle, displayFar, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count, details); - - return packet; } public static void PlayParticle(ParticleType type, Location location, float offsetX, float offsetY, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index aade9ac0d..211416885 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -24,6 +24,7 @@ import nautilus.game.arcade.game.games.moba.gold.GoldManager; import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.kit.KitPlayer; import nautilus.game.arcade.game.games.moba.kit.anath.HeroAnath; +import nautilus.game.arcade.game.games.moba.kit.bardolf.HeroBardolf; import nautilus.game.arcade.game.games.moba.kit.biff.HeroBiff; import nautilus.game.arcade.game.games.moba.kit.bob.HeroBob; import nautilus.game.arcade.game.games.moba.kit.dana.HeroDana; @@ -97,6 +98,7 @@ public class Moba extends TeamGame new HeroDana(Manager), new HeroBiff(Manager), new HeroLarissa(Manager), + new HeroBardolf(Manager), new HeroBob(Manager) }; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 6239445ea..5b86d95a4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -64,8 +64,6 @@ public class HeroSkill extends Perk _items.add(itemStack); _slot = slot; _actionType = actionType; - - prettifyItems(); } public void setSneakActivate(boolean activate) @@ -136,6 +134,7 @@ public class HeroSkill extends Perk super.SetHost(kit); _kit = (HeroKit) kit; + prettifyItems(); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java index 4d8d69b35..401693e05 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java @@ -6,6 +6,7 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; @@ -19,6 +20,7 @@ import org.bukkit.util.Vector; import java.util.ArrayList; import java.util.List; +import java.util.Set; public class SkillFireProjectile extends HeroSkill { @@ -82,9 +84,20 @@ public class SkillFireProjectile extends HeroSkill } Player player = (Player) entity.getShooter(); + Set entities = UtilEnt.getInRadius(entity.getLocation(), 1.5).keySet(); - for (LivingEntity nearby : UtilEnt.getInRadius(entity.getLocation(), 1.5).keySet()) + if (!entities.isEmpty()) { + player.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 1, 1.2F); + } + + for (LivingEntity nearby : entities) + { + if (isTeamDamage(nearby, player)) + { + continue; + } + nearby.setFireTicks(40); Manager.GetDamage().NewDamageEvent(nearby, player, null, DamageCause.CUSTOM, DAMAGE, true, true, false, player.getName(), GetName()); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java index 2b7cd0523..f2d90f7a7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java @@ -2,9 +2,10 @@ package nautilus.game.arcade.game.games.moba.kit.anath; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent.ActionType; -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.particles.ColoredParticle; +import mineplex.core.common.util.particles.DustSpellColor; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; import mineplex.core.updater.UpdateType; @@ -12,6 +13,7 @@ import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.kit.perks.data.MeteorShowerData; +import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -28,6 +30,7 @@ import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; +import java.awt.*; import java.util.HashSet; import java.util.Set; @@ -101,6 +104,7 @@ public class SkillMeteor extends HeroSkill implements IThrown { Location location = data.Target; GameTeam team = Manager.GetGame().GetTeam(data.Shooter); + DustSpellColor colour = new DustSpellColor(team.GetColor() == ChatColor.RED ? Color.RED : Color.CYAN); for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 100) { @@ -109,7 +113,7 @@ public class SkillMeteor extends HeroSkill implements IThrown location.add(x, 0.25, z); - UtilParticle.playColoredParticleToAll(team.GetColorBase(), ParticleType.RED_DUST, location, 1, ViewDist.LONG); + new ColoredParticle(ParticleType.RED_DUST, colour, location).display(ViewDist.LONG); location.subtract(x, 0.25, z); } @@ -122,7 +126,7 @@ public class SkillMeteor extends HeroSkill implements IThrown } nearby.setFireTicks(20); - Manager.GetDamage().NewDamageEvent(nearby, data.Shooter, null, DamageCause.CUSTOM, 2, true, true, false, UtilEnt.getName(data.Shooter), GetName()); + Manager.GetDamage().NewDamageEvent(nearby, data.Shooter, null, DamageCause.CUSTOM, 2, true, true, false, UtilEnt.getName(data.Shooter), GetName()); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java new file mode 100644 index 000000000..e338d5313 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java @@ -0,0 +1,286 @@ +package nautilus.game.arcade.game.games.moba.kit.bardolf; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.game.games.moba.kit.common.SkillSword; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wolf; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class HeroBardolf extends HeroKit +{ + + private static final int MAX_DIST_SQUARED = 400; + + private final List _data; + + private static final Perk[] PERKS = { + new SkillSword(0), + new SkillSummonWolf(1), + new SkillWolfPounce(2), + new SkillFullMoon(3) + }; + + public HeroBardolf(ArcadeManager manager) + { + super(manager, "Bardolf", PERKS, MobaRole.ASSASSIN); + + _data = new ArrayList<>(2); + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + _data.removeIf(data -> data.getOwner().equals(event.getPlayer())); + } + + @EventHandler + public void updateWolves(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK || !Manager.GetGame().IsLive()) + { + return; + } + + for (WolfData data : _data) + { + data.getWolves().removeIf(wolf -> wolf.isDead() || !wolf.isValid()); + + data.getWolves().forEach(wolf -> + { + if (data.getOverrideTarget().containsKey(wolf)) + { + UtilEnt.CreatureMoveFast(wolf, data.getOverrideTarget().get(wolf), data.isUltmate() ? 3F : 2F); + return; + } + + double ownerOffset = UtilMath.offsetSquared(data.getOwner(), wolf); + + if (wolf.getTarget() != null) + { + LivingEntity target = wolf.getTarget(); + + if (UtilPlayer.isSpectator(target) || target.isDead() || !target.isValid()) + { + wolf.setTarget(null); + return; + } + + UtilEnt.CreatureMoveFast(wolf, wolf.getTarget().getLocation(), data.isUltmate() ? 3F : 2F); + + if (UtilMath.offsetSquared(wolf.getTarget(), wolf) < 9) + { + Manager.GetDamage().NewDamageEvent(wolf.getTarget(), data.getOwner(), null, DamageCause.CUSTOM, 2, true, false, false, data.getOwner().getName(), "Wolf"); + } + } + else if (ownerOffset > MAX_DIST_SQUARED) + { + wolf.teleport(data.getOwner()); + } + else if (ownerOffset > 4) + { + UtilEnt.CreatureMoveFast(wolf, data.getOwner().getLocation(), data.isUltmate() ? 3F : 2F); + } + }); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void updateTarget(CustomDamageEvent event) + { + if (event.isCancelled()) + { + return; + } + + Player damager = event.GetDamagerPlayer(true); + WolfData data = getWolfData(damager); + + if (damager == null || data == null) + { + return; + } + + for (Wolf wolf : data.getWolves()) + { + wolf.setTarget(event.GetDamageeEntity()); + } + } + + @EventHandler + public void preventTeamDamage(CustomDamageEvent event) + { + if (event.isCancelled()) + { + return; + } + + LivingEntity damagee = event.GetDamageeEntity(); + LivingEntity damager = event.GetDamagerEntity(true); + WolfData data = getWolfData(damagee); + + if (data == null || !(damager instanceof Player)) + { + return; + } + GameTeam team = Manager.GetGame().GetTeam((Player) damager); + + if (team != null && MobaUtil.isTeamEntity(damagee, team)) + { + event.SetCancelled("Team Wolf"); + } + } + + @EventHandler(priority = EventPriority.LOWEST) + public void entityDeath(EntityDeathEvent event) + { + for (WolfData data : _data) + { + if (data.getWolves().contains(event.getEntity())) + { + event.setDroppedExp(0); + event.getDrops().clear(); + } + } + } + + @EventHandler + public void playerDeath(PlayerDeathEvent event) + { + WolfData data = getWolfData(event.getEntity()); + + if (data == null) + { + return; + } + + data.getWolves().forEach(Entity::remove); + } + + public WolfData getWolfData(Player player) + { + if (player == null) + { + return null; + } + + for (WolfData data : _data) + { + if (data.getOwner().equals(player)) + { + return data; + } + } + + if (Manager.GetGame().GetKit(player).equals(this)) + { + WolfData data = new WolfData(player); + _data.add(data); + return data; + } + + return null; + } + + public WolfData getWolfData(LivingEntity entity) + { + if (entity == null) + { + return null; + } + + for (WolfData data : _data) + { + if (data.getOwner().equals(entity)) + { + return data; + } + + for (Wolf wolf : data.getWolves()) + { + if (wolf.equals(entity)) + { + return data; + } + } + } + + return null; + } + + class WolfData + { + + private Player _owner; + private List _wolves; + private final Map _overrideTarget; + private boolean _ultimate; + private float _lastSpeedIncrease; + + WolfData(Player owner) + { + _owner = owner; + _wolves = new ArrayList<>(5); + _overrideTarget = new HashMap<>(5); + } + + public Player getOwner() + { + return _owner; + } + + public List getWolves() + { + return _wolves; + } + + public Map getOverrideTarget() + { + return _overrideTarget; + } + + public void setUltimate(boolean ultimate) + { + _ultimate = ultimate; + } + + public boolean isUltmate() + { + return _ultimate; + } + + public void setLastSpeedIncrease(float increase) + { + _lastSpeedIncrease = increase; + } + + public float getLastSpeedIncrease() + { + return _lastSpeedIncrease; + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java new file mode 100644 index 000000000..7e74745d8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java @@ -0,0 +1,109 @@ +package nautilus.game.arcade.game.games.moba.kit.bardolf; + +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.kit.bardolf.HeroBardolf.WolfData; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wolf; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +public class SkillFullMoon extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Fires an Ember at high speed in front of you.", + "Any enemies it collides with take damage and are set on fire." + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); + private static final long DURATION = TimeUnit.SECONDS.toMillis(10); + private static final int HEALTH = 20; + private static final float SPEED_FACTOR = 0.05F; + + private final Set _active = new HashSet<>(); + + public SkillFullMoon(int slot) + { + super("Full Moon", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + + setCooldown(60000); + setDropItemActivate(true); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if (!isSkillItem(event) || _active.contains(player)) + { + return; + } + + WolfData data = ((HeroBardolf) Kit).getWolfData(player); + + if (data == null) + { + return; + } + _active.add(player); + Manager.GetGame().WorldTimeSet = 18000; + player.getWorld().strikeLightningEffect(player.getLocation()); + data.setUltimate(true); + + float speedIncrease = (float) data.getWolves().size() * SPEED_FACTOR; + data.setLastSpeedIncrease(speedIncrease); + + player.setWalkSpeed(player.getWalkSpeed() + speedIncrease); + for (Wolf wolf : data.getWolves()) + { + wolf.setMaxHealth(HEALTH); + wolf.setHealth(wolf.getMaxHealth()); + wolf.setTamed(false); + wolf.setAngry(true); + wolf.getWorld().playSound(wolf.getLocation(), Sound.WOLF_GROWL, 1, 1); + } + + useActiveSkill(() -> + { + _active.remove(player); + Manager.GetGame().WorldTimeSet = 12000; + data.setUltimate(false); + player.setWalkSpeed(player.getWalkSpeed() - data.getLastSpeedIncrease()); + + for (Wolf wolf : data.getWolves()) + { + wolf.setHealth(0); + } + + }, player, DURATION); + } + + @EventHandler + public void damagePlayer(CustomDamageEvent event) + { + LivingEntity damagerEntity = event.GetDamagerEntity(true); + Player damagerPlayer = event.GetDamagerPlayer(true); + WolfData data = ((HeroBardolf) Kit).getWolfData(damagerEntity); + + if (data == null) + { + return; + } + + // Player Damage + if (damagerPlayer != null && _active.contains(damagerPlayer)) + { + event.AddMod(GetName(), data.getWolves().size()); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java new file mode 100644 index 000000000..40138bf8f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java @@ -0,0 +1,96 @@ +package nautilus.game.arcade.game.games.moba.kit.bardolf; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.SpigotUtil; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.kit.bardolf.HeroBardolf.WolfData; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; +import org.bukkit.ChatColor; +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wolf; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +public class SkillSummonWolf extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Fires an Ember at high speed in front of you.", + "Any enemies it collides with take damage and are set on fire." + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.BONE); + private static final int MAX_WOLVES = 5; + private static final int HEALTH = 6; + + public SkillSummonWolf(int slot) + { + super("Summon Wolf", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + setCooldown(1000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if (!isSkillItem(event)) + { + return; + } + + WolfData data = ((HeroBardolf) Kit).getWolfData(player); + + if (data == null) + { + return; + } + else if (data.getWolves().size() == MAX_WOLVES) + { + player.sendMessage(F.main("Game", "You have already summoned the maximum amount of wolves.")); + return; + } + else if (data.isUltmate()) + { + player.sendMessage(F.main("Game", "You cannot summon new wolves right now.")); + return; + } + + Game game = Manager.GetGame(); + GameTeam team = game.GetTeam(player); + + if (team == null) + { + return; + } + + game.CreatureAllowOverride = true; + + Wolf wolf = player.getWorld().spawn(player.getLocation(), Wolf.class); + DyeColor dyeColor = team.GetColor() == ChatColor.RED ? DyeColor.RED : DyeColor.BLUE; + + wolf.setCollarColor(dyeColor); + wolf.setTamed(true); + SpigotUtil.setOldOwner_RemoveMeWhenSpigotFixesThis(wolf, player); + wolf.setOwner(player); + wolf.setHealth(HEALTH); + wolf.setMaxHealth(HEALTH); + UtilEnt.vegetate(wolf); + MobaUtil.setTeamEntity(wolf, team); + + player.getWorld().playSound(player.getLocation(), Sound.WOLF_BARK, 1, 1.1F); + + data.getWolves().add(wolf); + + game.CreatureAllowOverride = false; + + useSkill(player); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillWolfPounce.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillWolfPounce.java new file mode 100644 index 000000000..20e1444dc --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillWolfPounce.java @@ -0,0 +1,168 @@ +package nautilus.game.arcade.game.games.moba.kit.bardolf; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +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.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.kit.bardolf.HeroBardolf.WolfData; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wolf; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +public class SkillWolfPounce extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Dash along the ground, leaving fire behind you.", + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); + private static final int COOLDOWN = 7000; + + private final Set _data = new HashSet<>(2); + + public SkillWolfPounce(int slot) + { + super("Wolf Pounce", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + + setCooldown(COOLDOWN); + setSneakActivate(true); + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + _data.removeIf(data -> data.Leader.equals(event.getPlayer())); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + useSkill(player); + } + + @EventHandler + public void toggleSneak(PlayerToggleSneakEvent event) + { + if (!isSkillSneak(event)) + { + return; + } + + Player player = event.getPlayer(); + + useSkill(player); + } + + @Override + public void useSkill(Player player) + { + super.useSkill(player); + + WolfData data = ((HeroBardolf) Kit).getWolfData(player); + + if (data == null) + { + return; + } + + for (Wolf wolf : data.getWolves()) + { + data.getOverrideTarget().put(wolf, player.getLocation()); + } + + Vector direction = player.getLocation().getDirection(); + direction.setY(Math.max(0.8, direction.getY())); + _data.add(new PounceData(player, data, direction)); + + UtilAction.velocity(player, direction); + + player.getWorld().playSound(player.getLocation(), Sound.WOLF_BARK, 2, 1F); + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, player.getLocation().add(0, 0.6, 0), 0.5F, 0.5F, 0.5F, 0.1F, 15, ViewDist.LONG); + } + + @EventHandler + public void updateWolves(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTEST) + { + return; + } + + Iterator iterator = _data.iterator(); + + while (iterator.hasNext()) + { + PounceData data = iterator.next(); + + for (Wolf wolf : data.WolfData.getWolves()) + { + // Wolf has already leaped + if (data.LeapedWolves.contains(wolf) || UtilMath.offsetSquared(data.Target, wolf.getLocation()) > 4) + { + continue; + } + + data.LeapedWolves.add(wolf); + wolf.setVelocity(data.Direction); + wolf.getWorld().playSound(wolf.getLocation(), Sound.WOLF_WHINE, 1, 1.5F); + data.WolfData.getOverrideTarget().remove(wolf); + } + + if (UtilTime.elapsed(data.Time, COOLDOWN - 500)) + { + iterator.remove(); + data.WolfData.getOverrideTarget().clear(); + } + } + } + + private class PounceData + { + + Player Leader; + WolfData WolfData; + Location Target; + Vector Direction; + long Time; + List LeapedWolves; + + PounceData(Player leader, WolfData wolfData, Vector direction) + { + Leader = leader; + WolfData = wolfData; + Target = leader.getLocation(); + Direction = direction.multiply(1.5); + Time = System.currentTimeMillis(); + LeapedWolves = new ArrayList<>(5); + } + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java index ebda5b79a..15a6fe9f8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java @@ -7,6 +7,8 @@ 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.UtilTime; +import mineplex.core.common.util.particles.ColoredParticle; +import mineplex.core.common.util.particles.DustSpellColor; import mineplex.core.projectile.IThrown; import mineplex.core.projectile.ProjectileUser; import mineplex.core.updater.UpdateType; @@ -15,7 +17,7 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.util.MobaParticles; import nautilus.game.arcade.game.games.moba.util.MobaUtil; -import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.FireworkEffect; import org.bukkit.FireworkEffect.Type; @@ -110,6 +112,7 @@ public class SkillAOEHeal extends HeroSkill implements IThrown AOEHealData data = iterator.next(); Player owner = data.Owner; GameTeam team = Manager.GetGame().GetTeam(owner); + DustSpellColor colour = new DustSpellColor(team.GetColor() == ChatColor.RED ? java.awt.Color.RED : java.awt.Color.CYAN); if (UtilTime.elapsed(data.Start, DURATION)) { @@ -142,7 +145,7 @@ public class SkillAOEHeal extends HeroSkill implements IThrown data.Center.add(x, 0, z); - UtilParticle.playColoredParticleToAll(team.GetColorBase(), ParticleType.RED_DUST, data.Center, 1, ViewDist.LONG); + new ColoredParticle(ParticleType.RED_DUST, colour, data.Center).display(ViewDist.LONG); data.Center.subtract(x, 0, z); } From c8340730adf40090681a471938cb0c10ebd79c89 Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 11 Jun 2017 00:00:28 +0100 Subject: [PATCH 53/57] Improve Bardolfs wolves --- .../arcade/game/games/moba/kit/HeroSkill.java | 5 + .../games/moba/kit/bardolf/HeroBardolf.java | 15 +- .../moba/kit/bardolf/SkillSummonWolf.java | 4 +- .../game/games/moba/kit/common/DashSkill.java | 2 +- .../games/moba/kit/devon/SkillTNTArrows.java | 13 +- .../games/moba/kit/rowena/HeroRowena.java | 34 ++++ .../moba/kit/rowena/SkillCombatDash.java | 40 +++++ .../moba/kit/rowena/SkillLightArrows.java | 154 ++++++++++++++++++ .../arcade/game/games/moba/shop/MobaShop.java | 16 +- .../arcade/game/games/moba/util/MobaUtil.java | 17 ++ 10 files changed, 276 insertions(+), 24 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillCombatDash.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 5b86d95a4..a813cd146 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -103,6 +103,11 @@ public class HeroSkill extends Perk action += "/Sneak"; } + if (_dropItemActivate) + { + action += "/Drop Item"; + } + List items = new ArrayList<>(2); for (ItemStack itemStack : _items) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java index e338d5313..b356195c6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java @@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.moba.kit.bardolf; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -33,7 +34,7 @@ import java.util.Map; public class HeroBardolf extends HeroKit { - private static final int MAX_DIST_SQUARED = 400; + private static final int MAX_DIST_SQUARED = 100; private final List _data; @@ -73,7 +74,7 @@ public class HeroBardolf extends HeroKit { if (data.getOverrideTarget().containsKey(wolf)) { - UtilEnt.CreatureMoveFast(wolf, data.getOverrideTarget().get(wolf), data.isUltmate() ? 3F : 2F); + UtilEnt.CreatureMoveFast(wolf, data.getOverrideTarget().get(wolf), data.isUltimate() ? 2F : 1.5F); return; } @@ -89,11 +90,11 @@ public class HeroBardolf extends HeroKit return; } - UtilEnt.CreatureMoveFast(wolf, wolf.getTarget().getLocation(), data.isUltmate() ? 3F : 2F); + UtilEnt.CreatureMoveFast(wolf, wolf.getTarget().getLocation(), data.isUltimate() ? 2F : 1.5F); - if (UtilMath.offsetSquared(wolf.getTarget(), wolf) < 9) + if (UtilMath.offsetSquared(wolf.getTarget(), wolf) < 9 && Recharge.Instance.use(data.getOwner(), "Wolf" + wolf.getTarget().getUniqueId(), 500, false, false)) { - Manager.GetDamage().NewDamageEvent(wolf.getTarget(), data.getOwner(), null, DamageCause.CUSTOM, 2, true, false, false, data.getOwner().getName(), "Wolf"); + Manager.GetDamage().NewDamageEvent(wolf.getTarget(), data.getOwner(), null, DamageCause.CUSTOM, 2, true, true, false, data.getOwner().getName(), "Wolf"); } } else if (ownerOffset > MAX_DIST_SQUARED) @@ -102,7 +103,7 @@ public class HeroBardolf extends HeroKit } else if (ownerOffset > 4) { - UtilEnt.CreatureMoveFast(wolf, data.getOwner().getLocation(), data.isUltmate() ? 3F : 2F); + UtilEnt.CreatureMoveFast(wolf, data.getOwner().getLocation(), data.isUltimate() ? 2F : 1.5F); } }); } @@ -267,7 +268,7 @@ public class HeroBardolf extends HeroKit _ultimate = ultimate; } - public boolean isUltmate() + public boolean isUltimate() { return _ultimate; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java index 40138bf8f..39e7a95ec 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java @@ -33,7 +33,7 @@ public class SkillSummonWolf extends HeroSkill public SkillSummonWolf(int slot) { super("Summon Wolf", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); - setCooldown(1000); + setCooldown(5000); } @EventHandler @@ -57,7 +57,7 @@ public class SkillSummonWolf extends HeroSkill player.sendMessage(F.main("Game", "You have already summoned the maximum amount of wolves.")); return; } - else if (data.isUltmate()) + else if (data.isUltimate()) { player.sendMessage(F.main("Game", "You cannot summon new wolves right now.")); return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java index 6726e478c..7d8899320 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/DashSkill.java @@ -182,7 +182,7 @@ public class DashSkill extends HeroSkill continue; } - if (_collideOnce && !Recharge.Instance.use(player, GetName() + player.getName() + entity.getUniqueId(), 500, false, false)) + if (_collideOnce && !Recharge.Instance.use(player, GetName() + entity.getUniqueId(), 500, false, false)) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java index 94d7b02a5..9149558ce 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/SkillTNTArrows.java @@ -9,10 +9,10 @@ import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -126,16 +126,7 @@ public class SkillTNTArrows extends HeroSkill location.getWorld().playSound(location, Sound.EXPLODE, 1, 0.9F); UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, location, 0, 0, 0, 0.1F, 1, ViewDist.LONG); - double damage = 10; - - // Scale damage with the damage on the player's bow - ItemStack itemStack = player.getInventory().getItem(0); - - // Player has a bow - if (itemStack != null && itemStack.getType() == Material.BOW) - { - damage += damage * itemStack.getEnchantmentLevel(Enchantment.ARROW_DAMAGE) * 0.25; - } + double damage = MobaUtil.scaleDamageWithBow(player.getInventory().getItem(0),5); for (Entry entry : UtilEnt.getInRadius(location, 5).entrySet()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java new file mode 100644 index 000000000..81de69740 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java @@ -0,0 +1,34 @@ +package nautilus.game.arcade.game.games.moba.kit.rowena; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.moba.MobaRole; +import nautilus.game.arcade.game.games.moba.kit.HeroKit; +import nautilus.game.arcade.game.games.moba.kit.common.SkillBow; +import nautilus.game.arcade.kit.Perk; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +public class HeroRowena extends HeroKit +{ + + private static final Perk[] PERKS = { + new SkillBow(0), + new SkillLightArrows(1), + new SkillCombatDash(2) + }; + + private static final ItemStack AMMO = new ItemBuilder(Material.ARROW) + .setTitle(C.cYellowB + "Hunting Arrow") + .setUnbreakable(true) + .build(); + + public HeroRowena(ArcadeManager manager) + { + super(manager, "Rowena", PERKS, MobaRole.HUNTER); + + setAmmo(AMMO, 2000); + setMaxAmmo(2); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillCombatDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillCombatDash.java new file mode 100644 index 000000000..7a1db55a7 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillCombatDash.java @@ -0,0 +1,40 @@ +package nautilus.game.arcade.game.games.moba.kit.rowena; + +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import nautilus.game.arcade.game.games.moba.kit.common.DashSkill; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class SkillCombatDash extends DashSkill +{ + + private static final String[] DESCRIPTION = { + "Dash along the ground, leaving fire behind you.", + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); + + public SkillCombatDash(int slot) + { + super("Combat Slide", DESCRIPTION, SKILL_ITEM, slot); + + setCooldown(8000); + + _collide = false; + _velocityTime = 400; + _velocityStopOnEnd = true; + _velocityMagnitude = 1.5; + _horizontial = true; + } + + @Override + public void preDash(Player player) + { + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, player.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.001F, 20, ViewDist.LONG); + player.getWorld().playSound(player.getLocation(), Sound.BAT_TAKEOFF, 1, 1); + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java new file mode 100644 index 000000000..fe7221e1a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java @@ -0,0 +1,154 @@ +package nautilus.game.arcade.game.games.moba.kit.rowena; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilParticle.ParticleType; +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 nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +public class SkillLightArrows extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Your next 3 arrows are infused with TNT.", + "They explode on contact dealing damage and knockback." + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.GOLD_NUGGET); + + private final Map _playerArrows = new HashMap<>(); + private final Map> _arrows = new HashMap<>(); + + public SkillLightArrows(int slot) + { + super("Light Arrows", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + + setCooldown(12000); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + _playerArrows.put(player, 5); + UtilInv.addDullEnchantment(player.getItemInHand()); + player.getItemInHand().setAmount(5); + } + + @EventHandler + public void shootArrow(EntityShootBowEvent event) + { + if (!(event.getEntity() instanceof Player)) + { + return; + } + + Player player = (Player) event.getEntity(); + + if (!hasPerk(player) || !_playerArrows.containsKey(player)) + { + return; + } + + ItemStack itemStack = player.getInventory().getItem(getSlot()); + int arrows = _playerArrows.get(player); + + if (arrows == 1) + { + _playerArrows.remove(player); + useSkill(player); + } + else + { + arrows--; + _playerArrows.put(player, arrows); + itemStack.setAmount(arrows); + } + + event.getProjectile().remove(); + + _arrows.putIfAbsent(player, new HashSet<>()); + _arrows.get(player).add(new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.4, 20, ParticleType.FIREWORKS_SPARK, UtilServer.getPlayers())); + } + + @EventHandler + public void updateArrows(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (Entry> entry : _arrows.entrySet()) + { + Player player = entry.getKey(); + Iterator iterator = entry.getValue().iterator(); + double damage = MobaUtil.scaleDamageWithBow(player.getInventory().getItem(0), 0); + + while (iterator.hasNext()) + { + LineParticle lineParticle = iterator.next(); + + if (!lineParticle.update()) + { + for (LivingEntity entity : UtilEnt.getInRadius(lineParticle.getLastLocation(), 1.5).keySet()) + { + if (Recharge.Instance.use(player, GetName() + entity.getUniqueId(), 500, false, false)) + { + player.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 1, 0.8F); + Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, damage, true, true, false, player.getName(), GetName()); + } + } + } + else + { + iterator.remove(); + } + } + } + } + + @EventHandler + public void playerDeath(PlayerDeathEvent event) + { + _playerArrows.remove(event.getEntity()); + _arrows.remove(event.getEntity()); + } + + @EventHandler + public void playerQuit(PlayerQuitEvent event) + { + _playerArrows.remove(event.getPlayer()); + _arrows.remove(event.getPlayer()); + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index 1538a04e4..fb75fd78a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -5,7 +5,6 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.itemstack.ItemBuilder; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.CombatComponent; @@ -26,7 +25,6 @@ import nautilus.game.arcade.game.games.moba.shop.hunter.MobaHunterShop; import nautilus.game.arcade.game.games.moba.shop.mage.MobaMageShop; import nautilus.game.arcade.game.games.moba.shop.warrior.MobaWarriorShop; import nautilus.game.arcade.game.games.moba.util.MobaConstants; -import nautilus.game.arcade.kit.Kit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; @@ -43,7 +41,6 @@ import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerItemConsumeEvent; -import org.bukkit.inventory.ItemStack; import java.util.ArrayList; import java.util.HashMap; @@ -255,6 +252,19 @@ public class MobaShop implements Listener return null; } + @EventHandler + public void playerDeath(PlayerDeathEvent event) + { + List owned = _upgrades.get(event.getEntity()); + + owned.removeIf(item -> + { + MobaShopCategory category = getCategory(item); + + return category == null || category.isDroppingOnDeath(); + }); + } + /* Allow players to access the shop through an item */ diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index 97bb33361..08c3923e3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -9,8 +9,11 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.hp.MobaHPRegenEvent; import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.util.Vector; @@ -210,4 +213,18 @@ public class MobaUtil entity.setHealth(Math.min(entity.getHealth() + health, entity.getMaxHealth())); } + + public static double scaleDamageWithBow(ItemStack itemStack, double initialDamage) + { + // Set a base damage + initialDamage += 5; + + // Scale damage with the damage on the player's bow + if (itemStack != null && itemStack.getType() == Material.BOW) + { + initialDamage += initialDamage * itemStack.getEnchantmentLevel(Enchantment.ARROW_DAMAGE) * 0.25; + } + + return initialDamage; + } } From 3efeb38a0169e41b8d178b0ff7a09e55e40048b7 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 13 Jun 2017 00:29:05 +0100 Subject: [PATCH 54/57] Working through JIRA --- .../game/arcade/game/games/moba/Moba.java | 2 + .../games/moba/boss/wither/WitherBoss.java | 19 ++++++ .../arcade/game/games/moba/buff/Buff.java | 2 +- .../game/games/moba/buff/BuffManager.java | 18 +++++ .../games/moba/buff/buffs/BuffCripple.java | 30 +++++++++ .../arcade/game/games/moba/kit/HeroSkill.java | 8 +++ .../moba/kit/anath/SkillFireProjectile.java | 67 ++----------------- .../game/games/moba/kit/dana/SkillRally.java | 10 +++ .../game/games/moba/kit/hp/HPManager.java | 2 +- .../games/moba/kit/hp/MobaHPRegenEvent.java | 14 +++- .../moba/kit/larissa/SkillWaterDash.java | 39 ++++++----- .../moba/kit/rowena/SkillCombatDash.java | 2 +- .../moba/kit/rowena/SkillLightArrows.java | 35 +++++++--- .../moba/shop/assassin/MobaAssassinShop.java | 63 ++++++++--------- .../shop/effects/MobaAbilityDamageEffect.java | 14 +++- .../moba/shop/effects/MobaKillHealEffect.java | 3 +- .../shop/effects/MobaMeleeDamageEffect.java | 30 +++++++++ .../moba/shop/hunter/MobaHunterShop.java | 12 ++-- .../games/moba/structure/tower/Tower.java | 17 ++++- .../game/games/moba/util/MobaConstants.java | 1 - .../arcade/game/games/moba/util/MobaUtil.java | 4 +- 21 files changed, 253 insertions(+), 139 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffCripple.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaMeleeDamageEffect.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 211416885..db0ee8014 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -32,6 +32,7 @@ import nautilus.game.arcade.game.games.moba.kit.devon.HeroDevon; import nautilus.game.arcade.game.games.moba.kit.hattori.HeroHattori; import nautilus.game.arcade.game.games.moba.kit.hp.HPManager; import nautilus.game.arcade.game.games.moba.kit.larissa.HeroLarissa; +import nautilus.game.arcade.game.games.moba.kit.rowena.HeroRowena; import nautilus.game.arcade.game.games.moba.minion.MinionManager; import nautilus.game.arcade.game.games.moba.prepare.PrepareManager; import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection; @@ -99,6 +100,7 @@ public class Moba extends TeamGame new HeroBiff(Manager), new HeroLarissa(Manager), new HeroBardolf(Manager), + new HeroRowena(Manager), new HeroBob(Manager) }; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index 41b4a242c..c9483bbe1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -1,11 +1,13 @@ package nautilus.game.arcade.game.games.moba.boss.wither; +import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; 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.UtilTextTop; +import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.disguises.DisguiseWither; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -22,6 +24,7 @@ import nautilus.game.arcade.game.games.moba.structure.tower.TowerDestroyEvent; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.EntityEffect; import org.bukkit.Location; +import org.bukkit.Sound; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -29,6 +32,8 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import java.util.concurrent.TimeUnit; + public class WitherBoss extends MobaBoss { @@ -37,11 +42,13 @@ public class WitherBoss extends MobaBoss private static final float SPEED_HOME = 6F; private static final int INITIAL_HEALTH = 125; private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); + private static final int MIN_INFORM_TIME = (int) TimeUnit.SECONDS.toMillis(30); private GameTeam _team; private MobaAI _ai; private DisguiseWither _disguise; private boolean _damageable; + private long _lastInform; public WitherBoss(Moba host, Location location, GameTeam team) { @@ -137,6 +144,18 @@ public class WitherBoss extends MobaBoss } } + // Inform the team + if (UtilTime.elapsed(_lastInform, MIN_INFORM_TIME)) + { + _lastInform = System.currentTimeMillis(); + + for (Player player : _team.GetPlayers(true)) + { + player.playSound(player.getLocation(), Sound.ANVIL_LAND, 1, 0.5F); + player.sendMessage(F.main("Game", "Your Wither is under attack.")); + } + } + double newHealth = damagee.getHealth() - event.GetDamage(); // Don't allow the wither to move because of damage diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/Buff.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/Buff.java index 0e9949db2..5c1d996cc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/Buff.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/Buff.java @@ -11,7 +11,7 @@ public abstract class Buff implements Listener protected final Moba _host; protected final BuffManager _manager; protected final T _entity; - private final long _duration; + protected final long _duration; private long _start; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java index 25ba3d101..66ce3aba8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/BuffManager.java @@ -37,6 +37,24 @@ public class BuffManager implements Listener buff.apply(); } + public boolean hasBuff(LivingEntity entity, Class> clazz) + { + if (!_buffs.containsKey(entity)) + { + return false; + } + + for (Buff buff : _buffs.get(entity)) + { + if (buff.getClass().equals(clazz)) + { + return true; + } + } + + return false; + } + @EventHandler public void update(UpdateEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffCripple.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffCripple.java new file mode 100644 index 000000000..c72f8fe2b --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffCripple.java @@ -0,0 +1,30 @@ +package nautilus.game.arcade.game.games.moba.buff.buffs; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilTextMiddle; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.buff.Buff; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public class BuffCripple extends Buff +{ + + private static final ItemStack + + public BuffCripple(Moba host, Player entity, long duration) + { + super(host, entity, duration); + } + + @Override + public void onApply() + { + UtilTextMiddle.display("", C.cRed + "Crippled", 10, 20, 10, _entity); + } + + @Override + public void onExpire() + { + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index a813cd146..97a31933a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -14,6 +14,7 @@ import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.PlayerKitGiveEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.buff.buffs.BuffCripple; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Perk; @@ -286,6 +287,7 @@ public class HeroSkill extends Perk return; } + Moba moba = (Moba) Manager.GetGame(); long current = System.currentTimeMillis(); for (Player player : Manager.GetGame().GetPlayers(true)) @@ -307,6 +309,12 @@ public class HeroSkill extends Perk boolean done = UtilTime.elapsed(start, cooldown); + // If the player is crippled say they are + if (moba.getBuffManager().hasBuff(player, BuffCripple.class)) + { + itemStack = + } + if (done) { _lastSkill.remove(player.getUniqueId()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java index 401693e05..53f2313a5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java @@ -1,27 +1,16 @@ package nautilus.game.arcade.game.games.moba.kit.anath; -import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Item; import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; -import org.bukkit.entity.SmallFireball; import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - public class SkillFireProjectile extends HeroSkill { @@ -32,8 +21,6 @@ public class SkillFireProjectile extends HeroSkill private static final int DAMAGE = 5; private static final ItemStack SKILL_ITEM = new ItemStack(Material.BLAZE_ROD); - private final List _fireballs = new ArrayList<>(); - public SkillFireProjectile(int slot) { super("Flame Wand", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); @@ -55,54 +42,10 @@ public class SkillFireProjectile extends HeroSkill } Vector direction = player.getLocation().getDirection().multiply(1.25); + Item item = player.getWorld().dropItem(player.getEyeLocation().add(direction), _kit.getAmmo()); + item.setVelocity(direction); - SmallFireball fireball = player.getWorld().spawn(player.getEyeLocation().add(direction), SmallFireball.class); - fireball.setShooter(player); - fireball.setVelocity(direction); - _fireballs.add(fireball); - - ((Moba) Manager.GetGame()).getTowerManager().addProjectile(player, fireball, DAMAGE); - } - - @EventHandler - public void fireballPrevention(CustomDamageEvent event) - { - if (event.GetProjectile() != null && _fireballs.contains(event.GetProjectile())) - { - event.SetCancelled("Fireball Damage"); - } - } - - @EventHandler - public void projectileHit(ProjectileHitEvent event) - { - Projectile entity = event.getEntity(); - - if (!_fireballs.contains(entity)) - { - return; - } - - Player player = (Player) entity.getShooter(); - Set entities = UtilEnt.getInRadius(entity.getLocation(), 1.5).keySet(); - - if (!entities.isEmpty()) - { - player.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 1, 1.2F); - } - - for (LivingEntity nearby : entities) - { - if (isTeamDamage(nearby, player)) - { - continue; - } - - nearby.setFireTicks(40); - Manager.GetDamage().NewDamageEvent(nearby, player, null, DamageCause.CUSTOM, DAMAGE, true, true, false, player.getName(), GetName()); - } - - _fireballs.remove(entity); - entity.remove(); + Manager.GetFire().Add(item, player, 3, 0, 1, DAMAGE, GetName(), false); + ((Moba) Manager.GetGame()).getTowerManager().addProjectile(player, item, DAMAGE); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java index d1d302a78..ba64117fe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java @@ -19,6 +19,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; @@ -200,6 +201,15 @@ public class SkillRally extends HeroSkill } } + @EventHandler + public void itemSpawn(ItemSpawnEvent event) + { + if (event.getEntity().getItemStack().getType() == Material.BANNER) + { + event.setCancelled(true); + } + } + @EventHandler public void playerDeath(PlayerDeathEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java index 7f91b073d..02ad04e8e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java @@ -42,7 +42,7 @@ public class HPManager implements Listener continue; } - MobaHPRegenEvent regenEvent = new MobaHPRegenEvent(player, HP5); + MobaHPRegenEvent regenEvent = new MobaHPRegenEvent(player, HP5, true); UtilServer.CallEvent(regenEvent); if (regenEvent.isCancelled()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java index 793c170ba..903ed115c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java @@ -12,14 +12,16 @@ public class MobaHPRegenEvent extends PlayerEvent implements Cancellable private final double _initialHealth; private double _health; + private boolean _natural; private boolean _cancel; - public MobaHPRegenEvent(Player who, double health) + public MobaHPRegenEvent(Player who, double health, boolean natural) { super(who); _initialHealth = health; _health = health; + _natural = natural; } public void setHealth(double health) @@ -37,6 +39,16 @@ public class MobaHPRegenEvent extends PlayerEvent implements Cancellable return _health; } + public void setNatural(boolean natural) + { + _natural = natural; + } + + public boolean isNatural() + { + return _natural; + } + @Override public boolean isCancelled() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java index 85d9f93ee..d66be7c20 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java @@ -1,16 +1,19 @@ package nautilus.game.arcade.game.games.moba.kit.larissa; -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; +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.game.games.moba.Moba; +import nautilus.game.arcade.game.games.moba.buff.BuffManager; +import nautilus.game.arcade.game.games.moba.buff.buffs.BuffCripple; import nautilus.game.arcade.game.games.moba.kit.common.DashSkill; import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.BlockFromToEvent; -import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.inventory.ItemStack; +import java.util.concurrent.TimeUnit; + public class SkillWaterDash extends DashSkill { @@ -18,6 +21,7 @@ public class SkillWaterDash extends DashSkill "Dash along the ground, leaving water behind you.", }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); + private static final long CRIPPLE_DURATION = TimeUnit.SECONDS.toMillis(3); public SkillWaterDash(int slot) { @@ -34,23 +38,18 @@ public class SkillWaterDash extends DashSkill @Override public void dashTick(Player player) { - Block block = player.getLocation().getBlock(); + UtilParticle.PlayParticleToAll(ParticleType.DRIP_WATER, player.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.01F, 5, ViewDist.LONG); + Moba moba = (Moba) Manager.GetGame(); + BuffManager buffManager = moba.getBuffManager(); - while (!UtilBlock.solid(block)) + for (Player nearby : UtilPlayer.getNearby(player.getLocation(), 2)) { - block = block.getRelative(BlockFace.DOWN); - } + if (isTeamDamage(nearby, player) || buffManager.hasBuff(nearby, BuffCripple.class)) + { + continue; + } - Block fBlock = block; - Manager.runSyncLater(() -> Manager.GetBlockRestore().add(fBlock.getRelative(BlockFace.UP), Material.WATER.getId(), (byte) 0, 7000), 10); - } - - @EventHandler - public void onBlockFromTo(BlockFromToEvent event) - { - if (event.getBlock().isLiquid() || event.getToBlock().isLiquid()) - { - event.setCancelled(true); + buffManager.apply(new BuffCripple(moba, nearby, CRIPPLE_DURATION)); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillCombatDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillCombatDash.java index 7a1db55a7..27de6635a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillCombatDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillCombatDash.java @@ -24,7 +24,7 @@ public class SkillCombatDash extends DashSkill setCooldown(8000); _collide = false; - _velocityTime = 400; + _velocityTime = 250; _velocityStopOnEnd = true; _velocityMagnitude = 1.5; _horizontial = true; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java index fe7221e1a..81f3d536d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java @@ -9,7 +9,9 @@ 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 nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Material; import org.bukkit.Sound; @@ -96,8 +98,11 @@ public class SkillLightArrows extends HeroSkill event.getProjectile().remove(); + LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.4, 40, ParticleType.FIREWORKS_SPARK, UtilServer.getPlayers()); + lineParticle.setIgnoreAllBlocks(true); + _arrows.putIfAbsent(player, new HashSet<>()); - _arrows.get(player).add(new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.4, 20, ParticleType.FIREWORKS_SPARK, UtilServer.getPlayers())); + _arrows.get(player).add(lineParticle); } @EventHandler @@ -108,30 +113,38 @@ public class SkillLightArrows extends HeroSkill return; } + TowerManager towerManager = ((Moba) Manager.GetGame()).getTowerManager(); + for (Entry> entry : _arrows.entrySet()) { Player player = entry.getKey(); Iterator iterator = entry.getValue().iterator(); double damage = MobaUtil.scaleDamageWithBow(player.getInventory().getItem(0), 0); - while (iterator.hasNext()) + lineParticleLoop : while (iterator.hasNext()) { LineParticle lineParticle = iterator.next(); - if (!lineParticle.update()) + for (int i = 0; i < 4; i++) { - for (LivingEntity entity : UtilEnt.getInRadius(lineParticle.getLastLocation(), 1.5).keySet()) + if (!lineParticle.update()) { - if (Recharge.Instance.use(player, GetName() + entity.getUniqueId(), 500, false, false)) + towerManager.damageTowerAt(lineParticle.getLastLocation(), player, damage); + + for (LivingEntity entity : UtilEnt.getInRadius(lineParticle.getLastLocation(), 1.5).keySet()) { - player.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 1, 0.8F); - Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, damage, true, true, false, player.getName(), GetName()); + if (Recharge.Instance.use(player, GetName() + entity.getUniqueId(), 500, false, false)) + { + player.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 1, 0.8F); + Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, damage, true, true, false, player.getName(), GetName()); + } } } - } - else - { - iterator.remove(); + else + { + iterator.remove(); + continue lineParticleLoop; + } } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java index 5ba6f17f5..96c28be81 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/assassin/MobaAssassinShop.java @@ -37,43 +37,43 @@ public class MobaAssassinShop extends MobaShopMenu private static final MobaShopCategory HELMET = new MobaShopCategory("Helmet", Arrays.asList( new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) .setTitle(C.cGreen + "Leather Cap") - .build(), 200) - .addEffects( - new MobaHPRegenEffect(0.05) - ), + .build(), 200), new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) - .setTitle(C.cGreen + "Ninja's Rainment") + .setTitle(C.cGreen + "Ninja's Mask") .build(), 500) .addEffects( - new MobaHPRegenEffect(0.1) + new MobaKillHealEffect(2) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) + .setTitle(C.cGreen + "Urchin's Cap") + .build(), 600) + .addEffects( + new MobaHPRegenEffect(0.2) ), new MobaItem(new ItemBuilder(Material.CHAINMAIL_HELMET) .setTitle(C.cYellow + "Bruiser's Helm") .build(), 1000) - .addEffects( - new MobaHPRegenEffect(0.15) - ) ), new ItemStack(Material.LEATHER_HELMET)); private static final MobaShopCategory CHESTPLATE = new MobaShopCategory("Chestplate", Arrays.asList( new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) .setTitle(C.cGreen + "Leather Chestplate") - .build(), 250) - .addEffects( - new MobaCDREffect(0.05) - ), + .build(), 250), new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) - .setTitle(C.cGreen + "Ninja's Rainment") + .setTitle(C.cGreen + "Ninja's Chestcloth") .build(), 750) .addEffects( new MobaCDREffect(0.15) ), + new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) + .setTitle(C.cGreen + "Urchin's Chestcloth") + .build(), 850) + .addEffects( + new MobaMeleeDamageEffect("Urchin's Chestcloth", 1) + ), new MobaItem(new ItemBuilder(Material.CHAINMAIL_CHESTPLATE) .setTitle(C.cYellow + "Bruiser's Chestplate") .build(), 1250) - .addEffects( - new MobaCDREffect(0.1) - ) ), new ItemStack(Material.LEATHER_CHESTPLATE)); private static final MobaShopCategory LEGGINGS = new MobaShopCategory("Leggings", Arrays.asList( @@ -81,38 +81,41 @@ public class MobaAssassinShop extends MobaShopMenu .setTitle(C.cGreen + "Leather Leggings") .build(), 250), new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) - .setTitle(C.cGreen + "Ninja's Rainment") + .setTitle(C.cGreen + "Ninja's Leggings") .build(), 750) .addEffects( - new MobaTotalHealthEffect(2) + new MobaCDREffect(0.1) + ), + new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) + .setTitle(C.cGreen + "Urchin's Leggings") + .build(), 850) + .addEffects( + new MobaAbilityDamageEffect("Urchin's Leggings", 0.1) ), new MobaItem(new ItemBuilder(Material.CHAINMAIL_LEGGINGS) .setTitle(C.cYellow + "Bruiser's Leggings") .build(), 1250) - .addEffects( - new MobaTotalHealthEffect(4) - ) ), new ItemStack(Material.LEATHER_LEGGINGS)); private static final MobaShopCategory BOOTS = new MobaShopCategory("Boots", Arrays.asList( new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) .setTitle(C.cGreen + "Leather Boots") - .build(), 200) - .addEffects( - new MobaSpeedEffect(0.05) - ), + .build(), 200), new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) - .setTitle(C.cGreen + "Ninja's Rainment") + .setTitle(C.cGreen + "Ninja's Boots") .build(), 500) .addEffects( new MobaSpeedEffect(0.15) ), + new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) + .setTitle(C.cGreen + "Urchin's Boots") + .build(), 600) + .addEffects( + new MobaSpeedEffect(0.17) + ), new MobaItem(new ItemBuilder(Material.CHAINMAIL_BOOTS) .setTitle(C.cYellow + "Bruiser's Boots") .build(), 1000) - .addEffects( - new MobaSpeedEffect(0.1) - ) ), new ItemStack(Material.LEATHER_BOOTS)); public MobaAssassinShop(Moba host, MobaShop shop) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAbilityDamageEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAbilityDamageEffect.java index 6485a4082..b3aedb2ed 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAbilityDamageEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAbilityDamageEffect.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.moba.shop.effects; import mineplex.core.common.util.F; import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.moba.kit.hp.MobaHPRegenEvent; import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; @@ -29,9 +30,20 @@ public class MobaAbilityDamageEffect extends MobaItemEffect event.AddMod(_reason, event.GetDamage() * _factor); } + @Override + protected void onHPRegen(MobaHPRegenEvent event) + { + if (event.isNatural()) + { + return; + } + + event.increaseHealth(_factor); + } + @Override public String getDescription() { - return "Increases ability damage by " + F.greenElem(format(_factor * 100)) + "%."; + return "Increases ability damage/healing by " + F.greenElem(format(_factor * 100)) + "%."; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java index 7c6bdfba7..d31ff421e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java @@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.moba.shop.effects; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.entity.Player; public class MobaKillHealEffect extends MobaItemEffect @@ -18,7 +19,7 @@ public class MobaKillHealEffect extends MobaItemEffect @Override public void onDeath(Player killed, Player killer) { - killer.setHealth(Math.min(killer.getMaxHealth(), killer.getHealth() + _health)); + MobaUtil.heal(killer, _health); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaMeleeDamageEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaMeleeDamageEffect.java new file mode 100644 index 000000000..5dde0b641 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaMeleeDamageEffect.java @@ -0,0 +1,30 @@ +package nautilus.game.arcade.game.games.moba.shop.effects; + +import mineplex.core.common.util.F; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; + +public class MobaMeleeDamageEffect extends MobaItemEffect +{ + + private String _reason; + private double _increase; + + public MobaMeleeDamageEffect(String reason, double increase) + { + _reason = reason; + _increase = increase; + } + + @Override + protected void onDamage(CustomDamageEvent event) + { + event.AddMod(_reason, _increase); + } + + @Override + public String getDescription() + { + return "All your melee attacks deal " + F.greenElem("+" + format(_increase)) + "."; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java index 2723bdf3e..2c9b75b86 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/hunter/MobaHunterShop.java @@ -37,14 +37,14 @@ public class MobaHunterShop extends MobaShopMenu .addEnchantment(Enchantment.ARROW_DAMAGE, 2) .build(), 1200) .addEffects( - new MobaHitConditionEffect("Bow of Pursuit", ConditionType.SPEED, 2, 0, false) + new MobaHitConditionEffect("Bow of Pursuit", ConditionType.SPEED, 3, 1, false) ), new MobaItem(new ItemBuilder(Material.BOW) .setTitle(C.cYellowB + "Vampiric Bow") .addEnchantment(Enchantment.ARROW_DAMAGE, 1) .build(), 1500) .addEffects( - new MobaHitArrowHealEffect(0.25) + new MobaKillHealEffect(0.15) ), new MobaItem(new ItemBuilder(Material.BOW) .setTitle(C.cYellowB + "Bow of Renewal") @@ -88,7 +88,7 @@ public class MobaHunterShop extends MobaShopMenu .setTitle(C.cGreen + "Vampiric Helmet") .build(), 500) .addEffects( - new MobaHitArrowHealEffect(0.05) + new MobaHPRegenEffect(0.2) ), new MobaItem(new ItemBuilder(Material.CHAINMAIL_HELMET) .setTitle(C.cGreen + "Chainmail Helmet") @@ -115,7 +115,7 @@ public class MobaHunterShop extends MobaShopMenu .setTitle(C.cGreen + "Vampiric Chestplate") .build(), 750) .addEffects( - new MobaHitArrowHealEffect(0.15) + new MobaKillHealEffect(3) ), new MobaItem(new ItemBuilder(Material.CHAINMAIL_CHESTPLATE) .setTitle(C.cGreen + "Chainmail Chestplate") @@ -142,7 +142,7 @@ public class MobaHunterShop extends MobaShopMenu .setTitle(C.cGreen + "Vampiric Leggings") .build(), 700) .addEffects( - new MobaHitArrowHealEffect(0.1) + new MobaKillHealEffect(3) ), new MobaItem(new ItemBuilder(Material.CHAINMAIL_LEGGINGS) .setTitle(C.cGreen + "Chainmail Leggings") @@ -169,7 +169,7 @@ public class MobaHunterShop extends MobaShopMenu .setTitle(C.cGreen + "Vampiric Boots") .build(), 500) .addEffects( - new MobaHitArrowHealEffect(0.05) + new MobaKillHealEffect(1) ), new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) .setTitle(C.cGreen + "Leather Hiking Boots") diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java index 48bddbc19..efb13fcb6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/Tower.java @@ -1,8 +1,16 @@ package nautilus.game.arcade.game.games.moba.structure.tower; -import mineplex.core.common.util.*; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.disguises.DisguiseGuardian; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; @@ -40,6 +48,7 @@ public class Tower private boolean _firstTower; private boolean _dead; private long _lastInform; + private double _damage; private ArmorStand _stand; private DisguiseGuardian _guardian; @@ -55,6 +64,7 @@ public class Tower _maxHealth = health; _firstTower = firstTower; _lastInform = System.currentTimeMillis(); + _damage = DAMAGE; } public void setup() @@ -86,6 +96,9 @@ public class Tower { if (_target == null) { + // Reset damage + _damage = DAMAGE; + // Target just entities LivingEntity target = MobaUtil.getBestEntityTarget(_host, _team, _stand, _crystal.getLocation(), TARGET_RANGE, false); @@ -119,7 +132,7 @@ public class Tower _target.getWorld().playSound(_target.getLocation(), Sound.EXPLODE, 1, 0.2F); UtilParticle.PlayParticleToAll(ParticleType.LARGE_EXPLODE, _target.getLocation().add(0, 1.5, 0), 0, 0, 0, 0.2F, 1, ViewDist.LONG); - _host.getArcadeManager().GetDamage().NewDamageEvent(_target, null, null, DamageCause.CUSTOM, DAMAGE, false, true, false, "Tower", "Tower"); + _host.getArcadeManager().GetDamage().NewDamageEvent(_target, null, null, DamageCause.CUSTOM, _damage++, false, true, false, "Tower", "Tower"); } private void setLaserTarget(LivingEntity target) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java index f9ca54daa..3dab8cbf2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaConstants.java @@ -7,7 +7,6 @@ public class MobaConstants public static final String BASIC_ATTACK = "Basic Attack"; public static final String AMMO = "Ammo"; public static final String TEAM_METADATA = "team"; - public static final String SHOOTER_METADATA = "shooter"; // Location Constants public static final String MINION_PATH_START = "WHITE"; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index 08c3923e3..72fe45918 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -202,13 +202,15 @@ public class MobaUtil { if (entity instanceof Player) { - MobaHPRegenEvent regenEvent = new MobaHPRegenEvent((Player) entity, health); + MobaHPRegenEvent regenEvent = new MobaHPRegenEvent((Player) entity, health, false); UtilServer.CallEvent(regenEvent); if (regenEvent.isCancelled()) { return; } + + health = regenEvent.getHealth(); } entity.setHealth(Math.min(entity.getHealth() + health, entity.getMaxHealth())); From 4978f924a79fb308d7045be6455abe2e543934a1 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 13 Jun 2017 21:49:34 +0100 Subject: [PATCH 55/57] Lots of bug fixes --- .../src/mineplex/core/game/GameDisplay.java | 2 +- .../src/mineplex/mapparser/GameType.java | 1 + .../game/arcade/game/games/moba/Moba.java | 23 +- .../games/moba/boss/pumpkin/PumpkinBoss.java | 2 +- .../games/moba/buff/buffs/BuffCripple.java | 11 +- .../games/moba/general/MobaDamageManager.java | 15 ++ .../arcade/game/games/moba/kit/HeroSkill.java | 8 +- .../moba/kit/anath/SkillFireProjectile.java | 3 +- .../games/moba/kit/anath/SkillMeteor.java | 6 + .../games/moba/kit/bardolf/SkillFullMoon.java | 1 + .../moba/kit/bardolf/SkillSummonWolf.java | 26 +++ .../games/moba/kit/biff/SkillWarHorse.java | 15 ++ .../games/moba/kit/hp/MobaHPRegenEvent.java | 12 +- .../moba/kit/larissa/SkillAquaCannon.java | 3 +- .../games/moba/kit/rowena/HeroRowena.java | 3 +- .../moba/kit/rowena/SkillBombardment.java | 219 ++++++++++++++++++ .../moba/kit/rowena/SkillLightArrows.java | 14 +- .../game/games/moba/shop/MobaItemEffect.java | 4 + .../arcade/game/games/moba/shop/MobaShop.java | 24 ++ .../shop/effects/MobaAbilityDamageEffect.java | 2 +- .../shop/effects/MobaHitConditionEffect.java | 2 +- .../shop/effects/MobaMeleeDamageEffect.java | 3 +- .../moba/structure/point/CapturePoint.java | 5 + .../structure/point/CapturePointManager.java | 41 ++-- .../moba/structure/tower/TowerManager.java | 2 +- 25 files changed, 414 insertions(+), 33 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index 659be4430..8b7ec8606 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -104,7 +104,7 @@ public enum GameDisplay AlienInvasion("Alien Invasion", Material.ENDER_STONE, (byte) 0, GameCategory.EVENT, 69, false), - MOBA("Heroes of the Craft", Material.SKULL_ITEM, (byte)1, GameCategory.CLASSICS, 70, true), + MOBA("Heroes of GWEN", Material.SKULL_ITEM, (byte)1, GameCategory.CLASSICS, 70, true), GemHunters("Gem Hunters", Material.EMERALD, (byte) 0, GameCategory.SURVIVAL, 71, false), diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java index b3b28d303..b8c09946c 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java @@ -44,6 +44,7 @@ public enum GameType MineWare("MineWare"), MinecraftLeague("MCL"), MilkCow("Milk the Cow"), + HOG("Heroes of GWEN"), MonsterLeague("MonsterLeague"), MonsterMaze("Monster Maze"), Paintball("Super Paintball"), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index db0ee8014..f6992f67a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -10,6 +10,7 @@ import mineplex.minecraft.game.core.combat.DeathMessageType; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; @@ -328,13 +329,16 @@ public class Moba extends TeamGame scoreboard.write(red.GetColor() + C.Bold + redTitle); scoreboard.write("Base: " + _tower.getDisplayString(red) + _boss.getWitherDisplayString(red)); - scoreboard.write("Beacons: " + _capturePoint.getDisplayString(red)); scoreboard.writeNewLine(); scoreboard.write(blue.GetColor() + C.Bold + blueTitle); scoreboard.write("Base: " + _tower.getDisplayString(blue) + _boss.getWitherDisplayString(blue)); - scoreboard.write("Beacons: " + _capturePoint.getDisplayString(blue)); + + scoreboard.writeNewLine(); + + scoreboard.write(C.cGreenB + "Beacons"); + scoreboard.write(_capturePoint.getDisplayString()); scoreboard.writeNewLine(); @@ -355,8 +359,6 @@ public class Moba extends TeamGame scoreboard.write(C.cYellowB + "Time"); scoreboard.write(UtilTime.MakeStr(System.currentTimeMillis() - GetStateTime())); - - scoreboard.writeNewLine(); } private void writeEnd(Player player, GameScoreboard scoreboard) @@ -387,6 +389,19 @@ public class Moba extends TeamGame } } + @EventHandler + public void preventOverfill(PlayerPrepareTeleportEvent event) + { + Player player = event.GetPlayer(); + + if (GetPlayers(true).size() > 8) + { + SetPlayerState(player, GameTeam.PlayerState.OUT); + Manager.addSpectator(player, true); + player.sendMessage(F.main("Game", "Too many players are in this server. You are now spectating, sorry.")); + } + } + @Override public void EndCheck() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java index e0ec6c8fb..133a8277e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/pumpkin/PumpkinBoss.java @@ -125,7 +125,7 @@ public class PumpkinBoss extends MobaBoss Block block = entry.getKey(); double setChance = entry.getValue(); - if (block.getType() == Material.AIR || block.getRelative(BlockFace.UP).getType() != Material.AIR || Math.random() > setChance) + if (!UtilBlock.solid(block)|| block.getRelative(BlockFace.UP).getType() != Material.AIR || Math.random() > setChance) { continue; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffCripple.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffCripple.java index c72f8fe2b..aa06f1003 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffCripple.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/buff/buffs/BuffCripple.java @@ -2,15 +2,24 @@ package nautilus.game.arcade.game.games.moba.buff.buffs; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.buff.Buff; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; public class BuffCripple extends Buff { - private static final ItemStack + private static final ItemStack ITEM = new ItemBuilder(Material.IRON_INGOT) + .setTitle(C.cGray + "Crippled") + .build(); + + public static ItemStack getItemRepresentation() + { + return ITEM; + } public BuffCripple(Moba host, Player entity, long duration) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java index 49a7e4c55..e989d5b09 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/MobaDamageManager.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.moba.general; 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; import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent; @@ -10,6 +11,7 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; public class MobaDamageManager implements Listener @@ -89,4 +91,17 @@ public class MobaDamageManager implements Listener _host.getScoreboardModule().refresh(); } + + @EventHandler(priority = EventPriority.HIGH) + public void unifyKilledWith(CombatDeathEvent event) + { + String word = event.getKilledWord(); + String[] split = word.split("-"); + + if (word.contains("Click") && split.length > 1) + { + word = split[1].trim(); + event.setKilledWord(word); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index 97a31933a..df6e2e3e2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -312,7 +312,8 @@ public class HeroSkill extends Perk // If the player is crippled say they are if (moba.getBuffManager().hasBuff(player, BuffCripple.class)) { - itemStack = + player.getInventory().setItem(_slot, BuffCripple.getItemRepresentation()); + continue; } if (done) @@ -385,6 +386,11 @@ public class HeroSkill extends Perk }, 0, 20); } + public void resetCooldown(Player player) + { + _lastSkill.put(player.getUniqueId(), 0L); + } + protected boolean isTeamDamage(LivingEntity damagee, LivingEntity damager) { if (!(damager instanceof Player)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java index 53f2313a5..59b39a822 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillFireProjectile.java @@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.moba.kit.anath; import mineplex.core.common.util.UtilEvent.ActionType; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.Material; import org.bukkit.entity.Item; import org.bukkit.entity.Player; @@ -45,7 +46,7 @@ public class SkillFireProjectile extends HeroSkill Item item = player.getWorld().dropItem(player.getEyeLocation().add(direction), _kit.getAmmo()); item.setVelocity(direction); - Manager.GetFire().Add(item, player, 3, 0, 1, DAMAGE, GetName(), false); + Manager.GetFire().Add(item, player, 3, 0, 1, DAMAGE, MobaConstants.BASIC_ATTACK, false); ((Moba) Manager.GetGame()).getTowerManager().addProjectile(player, item, DAMAGE); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java index f2d90f7a7..9d7421a1b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java @@ -8,6 +8,7 @@ import mineplex.core.common.util.particles.ColoredParticle; import mineplex.core.common.util.particles.DustSpellColor; 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.GameTeam; @@ -63,6 +64,11 @@ public class SkillMeteor extends HeroSkill implements IThrown Player player = event.getPlayer(); + if (!Recharge.Instance.use(player, GetName() + "Trigger", 2000, false, false)) + { + return; + } + for (MeteorShowerData data : _data) { if (data.Shooter.equals(player)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java index 7e74745d8..6bfa262bc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java @@ -73,6 +73,7 @@ public class SkillFullMoon extends HeroSkill wolf.getWorld().playSound(wolf.getLocation(), Sound.WOLF_GROWL, 1, 1); } + broadcast(player); useActiveSkill(() -> { _active.remove(player); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java index 39e7a95ec..4fa75b94f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java @@ -4,6 +4,8 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.SpigotUtil; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; @@ -93,4 +95,28 @@ public class SkillSummonWolf extends HeroSkill useSkill(player); } + + @EventHandler + public void updateWolfItem(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + { + return; + } + + HeroBardolf kit = (HeroBardolf) Kit; + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + WolfData data = kit.getWolfData(player); + ItemStack itemStack = player.getInventory().getItem(getSlot()); + + if (data == null || itemStack == null || itemStack.getType() != SKILL_ITEM.getType()) + { + continue; + } + + itemStack.setAmount(data.getWolves().size()); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java index 27784b829..1564ed858 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java @@ -11,6 +11,7 @@ import mineplex.core.common.util.UtilTime; 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.games.moba.Moba; import nautilus.game.arcade.game.games.moba.buff.BuffManager; import nautilus.game.arcade.game.games.moba.buff.buffs.BuffRooting; @@ -138,6 +139,20 @@ public class SkillWarHorse extends HeroSkill } } + @EventHandler + public void horseDamage(CustomDamageEvent event) + { + for (WarHorseData data : _data) + { + if (data.Horse.equals(event.GetDamageeEntity())) + { + event.SetCancelled("Biff Horse"); + return; + } + } + + } + private class WarHorseData { public Player Owner; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java index 903ed115c..2ef3e9875 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/MobaHPRegenEvent.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.hp; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; @@ -10,20 +11,27 @@ public class MobaHPRegenEvent extends PlayerEvent implements Cancellable private static final HandlerList _handlers = new HandlerList(); + private final Player _source; private final double _initialHealth; private double _health; private boolean _natural; private boolean _cancel; - public MobaHPRegenEvent(Player who, double health, boolean natural) + public MobaHPRegenEvent(Player who, Player source, double health, boolean natural) { super(who); + _source = source; _initialHealth = health; _health = health; _natural = natural; } + public Player getSource() + { + return _source; + } + public void setHealth(double health) { _health = health; @@ -31,7 +39,7 @@ public class MobaHPRegenEvent extends PlayerEvent implements Cancellable public void increaseHealth(double factor) { - _health = _initialHealth * factor; + _health = _initialHealth + (_initialHealth * factor); } public double getHealth() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java index 4e1a2bdca..74e61a7f3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java @@ -11,6 +11,7 @@ import mineplex.core.recharge.Recharge; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; +import nautilus.game.arcade.game.games.moba.util.MobaConstants; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.LivingEntity; @@ -65,7 +66,7 @@ public class SkillAquaCannon extends HeroSkill continue; } - Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, DAMAGE, true, false, false, player.getName(), GetName()); + Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, DAMAGE, true, false, false, player.getName(), MobaConstants.BASIC_ATTACK); break; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java index 81de69740..d196ad8cb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java @@ -16,7 +16,8 @@ public class HeroRowena extends HeroKit private static final Perk[] PERKS = { new SkillBow(0), new SkillLightArrows(1), - new SkillCombatDash(2) + new SkillCombatDash(2), + new SkillBombardment(3) }; private static final ItemStack AMMO = new ItemBuilder(Material.ARROW) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java new file mode 100644 index 000000000..1a704d5e8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java @@ -0,0 +1,219 @@ +package nautilus.game.arcade.game.games.moba.kit.rowena; + +import mineplex.core.common.events.EntityVelocityChangeEvent; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEvent.ActionType; +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.UtilTime; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.kit.Perk; +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.EventPriority; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +public class SkillBombardment extends HeroSkill +{ + + private static final String[] DESCRIPTION = { + "Turns into a Diamond Sword that deals extreme", + "damage to any player hit by it." + }; + private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); + private static final int SHOTS = 3; + private static final int MAX_TIME = 10000; + private static final int DAMAGE_INCREASE = 5; + + private Set _data = new HashSet<>(); + + public SkillBombardment(int slot) + { + super("Bombardment", DESCRIPTION, SKILL_ITEM, slot, ActionType.ANY); + + setCooldown(60000); + setDropItemActivate(true); + } + + @Override + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (!isSkillItem(event)) + { + return; + } + + Player player = event.getPlayer(); + + for (BombardmentData data : _data) + { + if (data.Shooter.equals(player)) + { + return; + } + } + + for (Perk perk : Kit.GetPerks()) + { + if (perk instanceof SkillLightArrows) + { + SkillLightArrows skill = (SkillLightArrows) perk; + + skill.resetCooldown(player); + skill.setPlayerArrows(player, SHOTS); + } + } + + broadcast(player); + UtilAction.velocity(player, new Vector(0, 2, 0)); + _data.add(new BombardmentData(player)); + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator iterator = _data.iterator(); + + while (iterator.hasNext()) + { + BombardmentData data = iterator.next(); + Player player = data.Shooter; + + if (data.Block == null && player.getVelocity().getY() <= 0) + { + data.Block = player.getLocation().getBlock().getRelative(BlockFace.DOWN); + data.Block.setType(Material.BARRIER); + + Location playerLocation = player.getLocation(); + Location toTeleport = data.Block.getLocation(); + toTeleport.setYaw(playerLocation.getYaw()); + toTeleport.setPitch(playerLocation.getPitch()); + + player.getInventory().setHeldItemSlot(0); + } + else if (UtilTime.elapsed(data.Start, MAX_TIME) || data.Shots == 0) + { + useSkill(player); + data.Block.setType(Material.AIR); + iterator.remove(); + } + else if (data.Block != null) + { + UtilParticle.PlayParticleToAll(ParticleType.CLOUD, data.Block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.001F, 3, ViewDist.LONG); + } + } + } + + @EventHandler + public void shootArrow(EntityShootBowEvent event) + { + if (!(event.getEntity() instanceof Player)) + { + return; + } + + Player player = (Player) event.getEntity(); + + for (BombardmentData data : _data) + { + if (data.Shooter.equals(player)) + { + data.Shots--; + return; + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void increaseDamage(CustomDamageEvent event) + { + if (event.isCancelled()) + { + return; + } + + Player damager = event.GetDamagerPlayer(true); + + if (damager == null || event.GetReason() == null || !event.GetReason().contains("Light Arrows")) + { + return; + } + + damager.playSound(event.GetDamageeEntity().getLocation(), Sound.EXPLODE, 1, 0.6F); + UtilParticle.PlayParticleToAll(ParticleType.LARGE_EXPLODE, event.GetDamageeEntity().getLocation().add(0, 1, 0), 0, 0, 0, 0.1F, 1, ViewDist.LONG); + event.AddMod(GetName(), DAMAGE_INCREASE); + } + + @EventHandler + public void playerMove(PlayerMoveEvent event) + { + Player player = event.getPlayer(); + + for (BombardmentData data : _data) + { + if (data.Block != null && data.Shooter.equals(player) && (event.getTo().getX() != event.getFrom().getX() || event.getTo().getZ() != event.getFrom().getZ())) + { + event.setTo(event.getFrom()); + } + } + } + + @EventHandler + public void playerVelocity(EntityVelocityChangeEvent event) + { + if (!(event.getEntity() instanceof Player)) + { + return; + } + + Player player = (Player) event.getEntity(); + + for (BombardmentData data : _data) + { + if (data.Block != null && data.Shooter.equals(player)) + { + event.setCancelled(true); + } + } + } + + private class BombardmentData + { + + Player Shooter; + int Shots; + Block Block; + long Start; + + BombardmentData(Player shooter) + { + Shooter = shooter; + Shots = SHOTS; + Start = System.currentTimeMillis(); + } + } +} + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java index 81f3d536d..b71653c29 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java @@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.moba.kit.rowena; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.particles.effects.LineParticle; @@ -11,6 +12,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; +import nautilus.game.arcade.game.games.moba.structure.tower.Tower; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; import nautilus.game.arcade.game.games.moba.util.MobaUtil; import org.bukkit.Material; @@ -129,7 +131,12 @@ public class SkillLightArrows extends HeroSkill { if (!lineParticle.update()) { - towerManager.damageTowerAt(lineParticle.getLastLocation(), player, damage); + Tower hitTower = towerManager.damageTowerAt(lineParticle.getLastLocation(), player, damage); + + if (hitTower != null && UtilMath.offsetSquared(hitTower.getCrystal(), player) > Tower.TARGET_RANGE_SQUARED) + { + continue; + } for (LivingEntity entity : UtilEnt.getInRadius(lineParticle.getLastLocation(), 1.5).keySet()) { @@ -163,5 +170,10 @@ public class SkillLightArrows extends HeroSkill _playerArrows.remove(event.getPlayer()); _arrows.remove(event.getPlayer()); } + + void setPlayerArrows(Player player, int amount) + { + _playerArrows.put(player, amount); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java index ce3b3a233..3e37e1cc4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaItemEffect.java @@ -50,6 +50,10 @@ public abstract class MobaItemEffect { } + protected void onHPRegenOthers(MobaHPRegenEvent event) + { + } + protected void onRespawn(PlayerGameRespawnEvent event) { } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java index fb75fd78a..8af803c11 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/MobaShop.java @@ -444,6 +444,30 @@ public class MobaShop implements Listener } } + @EventHandler + public void hpOther(MobaHPRegenEvent event) + { + if (event.getSource() == null) + { + return; + } + + List items = _upgrades.get(event.getSource()); + + for (MobaItem item : items) + { + if (item.getEffects() == null) + { + continue; + } + + for (MobaItemEffect effect : item.getEffects()) + { + effect.onHPRegenOthers(event); + } + } + } + @EventHandler public void repawn(PlayerGameRespawnEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAbilityDamageEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAbilityDamageEffect.java index b3aedb2ed..63d15b7df 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAbilityDamageEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaAbilityDamageEffect.java @@ -31,7 +31,7 @@ public class MobaAbilityDamageEffect extends MobaItemEffect } @Override - protected void onHPRegen(MobaHPRegenEvent event) + protected void onHPRegenOthers(MobaHPRegenEvent event) { if (event.isNatural()) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitConditionEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitConditionEffect.java index 296c5e073..60095e421 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitConditionEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaHitConditionEffect.java @@ -51,6 +51,6 @@ public class MobaHitConditionEffect extends MobaItemEffect @Override public String getDescription() { - return "Hitting a player applies " + F.greenElem(format(_conditionType, _multi)) + " for " + F.time(format(_duration)) + " seconds."; + return "Hitting a player gives " + (_applyToDamagee ? "them" : "you") + " " + F.greenElem(format(_conditionType, _multi)) + " for " + F.time(format(_duration)) + " seconds."; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaMeleeDamageEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaMeleeDamageEffect.java index 5dde0b641..8e2e348bc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaMeleeDamageEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaMeleeDamageEffect.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.shop.effects; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; @@ -25,6 +26,6 @@ public class MobaMeleeDamageEffect extends MobaItemEffect @Override public String getDescription() { - return "All your melee attacks deal " + F.greenElem("+" + format(_increase)) + "."; + return "All your melee attacks deal " + F.greenElem("+" + format(_increase / 2)) + C.cRed + "❤" + C.cGray + "."; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java index 25bb5599c..11ab9881d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePoint.java @@ -284,6 +284,11 @@ public class CapturePoint _center.getBlock().getRelative(BlockFace.DOWN).setData(colour); } + public String getName() + { + return _name; + } + public ChatColor getColour() { return _colour; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java index ae6697317..51b6d7944 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/point/CapturePointManager.java @@ -5,7 +5,6 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; -import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.moba.Moba; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -77,30 +76,42 @@ public class CapturePointManager implements Listener } } - public String getDisplayString(GameTeam team) + public String getDisplayString() { StringBuilder out = new StringBuilder(); - int owned = 0; for (CapturePoint point : _capturePoints) { - if (point.getOwner() == null || !point.getOwner().equals(team)) - { - continue; - } - - out.append(point.getColour()).append("⚑ "); - owned++; - } - - while (owned++ < 3) - { - out.append(C.cGray).append("⚑ "); + out.append(point.getOwner() == null ? C.cWhite : point.getOwner().GetColor()).append(point.getName()).append(" "); } return out.toString().trim(); } +// public String getDisplayString(GameTeam team) +// { +// StringBuilder out = new StringBuilder(); +// int owned = 0; +// +// for (CapturePoint point : _capturePoints) +// { +// if (point.getOwner() == null || !point.getOwner().equals(team)) +// { +// continue; +// } +// +// out.append(point.getColour()).append("⚑ "); +// owned++; +// } +// +// while (owned++ < 3) +// { +// out.append(C.cGray).append("⚑ "); +// } +// +// return out.toString().trim(); +// } + public List getCapturePoints() { return _capturePoints; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index a8a8319db..f31a6c380 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -211,7 +211,7 @@ public class TowerManager implements Listener GameTeam team = _host.GetTeam(player); - if (UtilPlayer.isSpectator(player) || team == null || !canDamage(tower, team) || shouldCancelDamage(tower, player)) + if (UtilPlayer.isSpectator(player) || team == null || !canDamage(tower, team) || shouldCancelDamage(tower, player) || !Recharge.Instance.use(player, "Damage Tower", 200, false, false)) { return; } From 29d5a80a67ee3c9f7eb1131624c7e821f711ffd4 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 15 Jun 2017 01:33:20 +0100 Subject: [PATCH 56/57] Final changes --- .../mineplex/core/common/skin/SkinData.java | 10 ++ .../core/achievement/AchievementCategory.java | 6 +- .../ui/page/AchievementMainPage.java | 2 +- .../game/arcade/game/games/moba/Moba.java | 80 +++++++++++ .../games/moba/boss/wither/WitherBoss.java | 8 ++ .../game/games/moba/general/BetaManager.java | 34 +++++ .../game/games/moba/gold/GoldManager.java | 2 + .../arcade/game/games/moba/kit/HeroKit.java | 32 ++++- .../arcade/game/games/moba/kit/HeroSkill.java | 56 ++------ .../game/games/moba/kit/anath/HeroAnath.java | 3 +- .../games/moba/kit/anath/SkillBurnBeam.java | 5 +- .../games/moba/kit/anath/SkillMeteor.java | 4 +- .../games/moba/kit/bardolf/HeroBardolf.java | 6 +- .../games/moba/kit/bardolf/SkillFullMoon.java | 14 +- .../moba/kit/bardolf/SkillSummonWolf.java | 6 +- .../moba/kit/bardolf/SkillWolfPounce.java | 3 +- .../game/games/moba/kit/biff/HeroBiff.java | 3 +- .../games/moba/kit/biff/SkillBiffDash.java | 6 +- .../game/games/moba/kit/biff/SkillLeash.java | 6 +- .../games/moba/kit/biff/SkillWarHorse.java | 5 +- .../game/games/moba/kit/bob/HeroBob.java | 3 +- .../games/moba/kit/bob/SkillBeatTheDevil.java | 2 +- .../games/moba/kit/bob/SkillHappyTrees.java | 2 +- .../games/moba/kit/common/SkillSword.java | 6 +- .../game/games/moba/kit/dana/HeroDana.java | 3 +- .../games/moba/kit/dana/SkillDanaDash.java | 3 +- .../games/moba/kit/dana/SkillPulseHeal.java | 5 +- .../game/games/moba/kit/dana/SkillRally.java | 5 +- .../game/games/moba/kit/devon/HeroDevon.java | 3 +- .../games/moba/kit/hattori/HeroHattori.java | 3 +- .../games/moba/kit/hattori/SkillSnowball.java | 2 +- .../game/games/moba/kit/hp/HPManager.java | 2 +- .../games/moba/kit/larissa/HeroLarissa.java | 3 +- .../games/moba/kit/larissa/SkillAOEHeal.java | 7 +- .../moba/kit/larissa/SkillAquaCannon.java | 4 +- .../moba/kit/larissa/SkillStormHeal.java | 7 +- .../moba/kit/larissa/SkillWaterDash.java | 3 +- .../games/moba/kit/rowena/HeroRowena.java | 3 +- .../moba/kit/rowena/SkillBombardment.java | 136 ++++++++---------- .../moba/kit/rowena/SkillCombatDash.java | 3 +- .../moba/kit/rowena/SkillLightArrows.java | 9 +- .../game/games/moba/minion/MinionManager.java | 5 + .../game/games/moba/minion/MinionWave.java | 19 ++- .../moba/shop/effects/MobaKillHealEffect.java | 4 +- .../moba/structure/tower/TowerManager.java | 7 +- .../arcade/game/games/moba/util/MobaUtil.java | 4 +- 46 files changed, 356 insertions(+), 188 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/BetaManager.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java index 88dde15c3..f803154ce 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java @@ -69,6 +69,16 @@ public class SkinData public final static SkinData SLENDERMAN = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTA0NzUyNzk4NTUsInByb2ZpbGVJZCI6IjlmY2FlZDhiMTRiNTRmN2ZhNjRjYjYwNDBlNzA1MjcyIiwicHJvZmlsZU5hbWUiOiJMQ2FzdHIxIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9hMWNkOTI5OTFmYTRjZGQ2MGVlZDNhZTM3ZmI5NWRmZjFkNWNkOGNiZmYwYWFjMzE4MmQ0ODU2NDU5NTIzYyJ9fX0=", "OVqWFLCekyZcdGli6kPBKNh8/VYPhKZGNqlAvSOKc3RLgh4pIkI6TDPr/Y+VQdhz1wZozARFYSeoDJJJ4nZTi7gi3rVPG2rL1ZnKo7so5hdT8caEzSTRmgwPKzo03ZhEEsW9AEJo9mpiUxGSJdBlgEb9UgodpYFW1IjRC09CcBUqzRWP8QGZTSFSN5x9emQ97DyiFmt0NFWubHCKHdb7CExhchPRtbahL3hOEzPY8/Y+Irl9OZjx7jONE7O/sYItCuZoXc3FaTgCV0riiXHCgH2eA54s5TQVWumtp3FU7VIcKR6pm/o61+GusvqhNgdFNk9XSHWMUyp+HNU0R8sConZQN/eaVx9laJmUUb4zNZ7hX/hLYV+r9LFU1NXOeIZWJPShD+bYfZgEorIpD+EAL4BHht/f5e6a1IZUDBWb001PFibby2t9WWjoDVKz4McbxZ2Xui7EHKFG1K3biPibhWx6fvnOeJ2xW6UDIZcD+TCXwlW/knkFt44Xpyv3oNHk3UNkyrQgghd6qkc3gZHxP8PQCNvKIyK1I+pHR6JMZvSStp7ZQRDpvsvIUyOJvq+7Bs7lFYs8hcJHMzEB+8PYlH2k7P7iLuA6ZYFUmvOW1LLq0+hvxK96ZdNEsJdmMkVVTZBRw7vsZ4GPbkdp2cMOFH2lHcQj80xKqVbd43IqFDA="); public final static SkinData BOB_ROSS = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTU2NjEyOTc2NTcsInByb2ZpbGVJZCI6IjdkYTJhYjNhOTNjYTQ4ZWU4MzA0OGFmYzNiODBlNjhlIiwicHJvZmlsZU5hbWUiOiJHb2xkYXBmZWwiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzVhNzZhN2NlMzZlZGRiYmZhNWMzMmJhZmVhYmUyNmQ3ZWJlNWRlOTBkNzYyYzJmNWY3OTQ1ZTQ1ODUxOTU2ZDYifX19", "b7pUQSZ1UkMZJNSqdaBPGWfm+rfvFkEh58pBvYTG2RBPwVju1kKinb1LfsyYhFKlyPvL1jfqi30udmb0302QvE0SKg7p3txxULa3Hr94+eCJWFxrOxUNorRT9E+TurJxH6jimu6KW1p6goPn77/kgNaWb9xn3+E84+vH0z9ETjgc5G0aYLT+cSzThUorhvOQ7DRLfRgSWiFxfm3Er0g+waLfDEeNNAd6OJ5k3X+kgM/+V6QTIFofnZZ6NdZZInTARAVol2H0pRfQfAuVYfJyVyvA0uF+ZX+wlMuBTG1MeyWjZgI1iUKmGaQADXsAV796kT+Z+tAXpbRYYYZnxil5jx5P4druiHvaQfV2KK3lbKm2uH9M3SZr5d57C3V24BKRRWGS4C9INzgO8ORIIomes7kp0gECS4MnSMI6hcl0JsXVlaAy88BgmT/PKxM+3q4PCQE1N9fTCuhoil7vVYIU3uBXwFUE7NTAOUdBee+3TtMstIu2WP8rtEZBVpGH9CmomaLTCzPZSdXGY31goOFXSRYMNi8j4ykuBgP0qJqimipWH0rBF1bMdHqMu359h62tTLRKipHWXPxj4N8c/n1CVPYjuXH9X3f1HAU4DnET+v93Vb/uzbx8rXFrz6jLPwAjSlJ8Th3VE+4ey/ZBHWPB+SuHetN+e0r/LYxiqwwlnwI="); + public static final SkinData HATTORI = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0NjEyMTczMDgsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS83MjczMTBiMzlhMTIzOWI3ZTI4Y2JjNTkzMWY1MzlkNGVlNmQxOTc3ODhjNWI1YTY3YWY1NDJlYzk0MmZkMyJ9fX0=", "aHfFqPOZmcQkUqFPjVa27h27k5gyvkZMCOyIaIdIZfqVDg/69/hakkDQazvKg/U8KTlYaDSRyOp9ZD5qOUSCPvRtRDMhuX/Tn68KD9BdW5jYKsXo0puOa7IJDKAE47z7YQ8AvfOtxuOAg6S0ihjYEQqRA56UQ+gPbkd+pxpMxvXoLyAx7IEIKWmlkibG/rmaX8J7OEgq8Wi9s6BhtPVNMaLoznzdzOiiYkcza/zEG5zMXnj/hFHHUpWrYff0Oj7/SUB+krLsiMficASzzs/9HZq81V0ketqUhJYX66HL8F5fQniP8kYu9LbNNcVJmtlER03QaEqP/H8udemlVskFkOYLkTmhxfSetL46N+ZVf0Sxp2xYcFOH3djH/Q26IIXtzEqVyUW5Gun/ZJp8B8zYMOXbXSmaALAYPoX9cs91ZilNX/W7zn7b5Kb9kUBGt58eUpKoXjgK7rSvmH0X2JOZGFVji5QKzp/eOQAqMhkBOU8sEm9AT6mfZjjlyIDOZxSX6hjEJXRVVzFFlzTiRPTcAtaHWRnlRFywsDDSgVBGvQMPNMNa6CFeo0ajnhmfHWa4Ga77kpfQ75PzOoJ/j6Z/2sSIHfQFWE6INAGAyypX/x0Fd/AH6SmYfilnX6lhtd7OsDlxS01QGoRLPBh/ol+wY6rHSM1N6Qta0ulpQZLYIms="); + public static final SkinData ANATH = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0Njg4NjM4MTYsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS81NGI5NGQ4NzE5ZWFhYjc0YjVhMzhjN2Q5NDliM2FkMmIyYzA0ODIxZGY4OWM1ZDA0YjY5ZjNjZmExYmJhNjUifX19", "IKlnXzQ2k57XyTHge5V2ttnV1AqbRKrV0JktZS4+nLXx+ROM77/HRuf3/bYTqg48SB8npXy+c6nLYTCY1fTZOl3t2puS6BpZMBXuTV//A0OMQ1pJKzDb8vW6CwPYw2Nu6o0QX3J/FeUIaBj16GZAPxXOtSekkeOw9qsdh57GyqSmzODlEA/7CnJWqX2Ani5DACzo6j5rzfsz2qRgOzVlnbVlVzpXicRuYYLxKvT4nMS+B3HpQdsyFKAx8nTO/GmCHDzW97jck6w/VDlW9x+J39tPDEaKPLbDz1YV59yJt6hjNAcnwgbf3KvHSAbGZNLqRegq/Rk20ZI2J5GYT5ipiyf+p8rHfkRTxIsVCMyVecnSKaz59YQ7AleiWVGzYHDETU702UyigAZFHGHQ/0Kj9UyyZ4ew228FQuGo7iGY4dS/PKq40d1v3fq+czwBhcXR+Msi1Zqg/4dTh+QwwwWsIS3CKtOInpJgZ3U/tkn4STB3o+oKBbmBWvpJk8SrA6DVKKJMjHQig+67hXKSbdcRUWAoGc/iuRhRXgILkC99Ot4PHohEbwbEW8MsKxm49OFqzP4zptaUaiQpMK4YCxENhLrI7X+w51tt2XTjroIHu4oLYS4pG16ZnhUmd/RFg8Ar7mBVOv/2lUtOO5aMAv88CpyD+XXNcCQB4G5pv4c0F14="); + public static final SkinData DEVON = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0Njk0NDE1MDYsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS85N2FkNjY1MjFmNzNjOWFmYzE4MzliZGExYzE5ZDNkMjg3YjNmMjRmY2EwZTBlMTE1NzhiOTE0ZTNiNWIwZDIifX19", "BNIc7N3SGIXOEUKFe3hrQp4YmniPxkiL5aKAUNkTmYqbygAQlrCCrwJTuK6JrzkWmD5AzMSzMDKkmoMWOikgulhSmDyC88lQz/LQH3co7WldPHaPL6kk27ZirmIIZEm5WKcvWhQ7ChNWQd2KsZuFqxZSdLSQmsbujF9vpuVbhlU4hajsUwbdiOJRZ18fOAFoJYq/g3RlvqC9VtAA/IAAN7jIpXf9Pn5+vjLqN+AdKm27YknCpqMtBfkYaIhMrpTBe2gP+o50TmH0xm0IZPCS+ORYNGwFdCsg6DzEU7a0rtcUdcZgdInc09mS8tMY9eeMAISYYq5MpyliHQ/areGKk0RJEYg7muc9r/N6vBUpxZtZH8BioDj2dNj4JOoH/58cwU3+hv/Woykc9o5NUPyz0nndiOtTUp1SaDXleKyHryoYnIkPyaDPyuA7qTbIKZQHxyAdrRsnknb0PYku6T8RA4kWNK2jlOH+R9D4eiKFcbLRU2Zl6L57lJTZFFI6GUvzDsyD/vBb59gjvXYzRmvguX9CHUc1aLDeUKhV8NFXeaonoYM9VPIUBQRWNdMery9OlBiQvg4VXy1w2yKLvlHRhJZJpDm/IDdsfg27o8+BUOZ0xHF9iXPBDkOiLXXZ02X4IonLcopVNImCMRZJ1dKHwgu9qnFqVTEKH4mwXUz2Zq8="); + public static final SkinData DANA = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0NjkyMzgxMDAsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9hOWRhYTg5OGVkN2E0N2YyOGFkMjVmNjk5Y2Y4MzQyODFmMTVkZTY5OWM1MWVhMTRkOWRlYzVhM2VlNzY1MiJ9fX0=", "KUI3h0MDUNWQ3avjozkw0KnZf1UAMkRHzRKY9yGS/iUh9EMmDbfLcRfBhUvR5Dd6//75Yw2tElBrvPx+VqfJk0LqMACQc71n0lDY1NzqnXbpf6vNGyuhyumjhMSjJTG3BJ8Qtdd1yCsPK2x5ym+cGPS1FevJj4Vcu6rxg9HXZokgfjD11NXEwulFuPIiWHpJlnd8NlBw4a3txlrVwDnaHo7GqYSJeM1uOCrdICdpThSA2N2mOUEmOHvH9rHUhQvkKHipbsQMIxIX4oiXDWeK6P/GtT+Iv0DIeJfQdDkhDiIG5/zUyxmpC2mma1FQIsFsQOaJfgYZLfcOXGdhwlL/OcZ9ULBIKhgSx7Ozwzsc+JKonqlaBOuaietq5z/XvMClgFG9U2a1LXc5BIgaN/ClsO0uTksuoA8H0SDx9k3EmOjaPdrJOsQ/fgWQSkWN2XniLLFiEtSOEOI58vw6ORVXDgjbP+TqD0b6/d10z0jUzS2FD7AO51LHzTw+BjqoyVef4fszNNSqMi5QEgfBl++EAolZBAMHgN7hq6k52ry2LPlO5L8sm6NoZ4DrLyrx1oFNtXZZgYvNVy7rtEpIDdQczwAZkJFV0fuz8tRH3CkW/roA5HbfX3Fv19mQoteoemrSUrOwLlQsyVPxsFsn8uX94Cw88Q5KgBCGmGY2vpXHuiI="); + public static final SkinData BARDOLF = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0NjkxMTE4NjEsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS84MjUxNjZmNzc0ZjcyNmZmMDE3NTQ3OTk0NDc0MGYxNjRmMTZmYmI2M2I3NGI3NmNmNzk0NDMxZGZkNzUyIn19fQ==", "W8TO4M/IQ4rQ91627EaudboKwR8TuKTp5mAYOCyOJLCD0vyyEJmnZFy1Hv9HlXKiXsEm9iC36+cmQ8JfSE0JlIfU2vRH5qbXUL4HUHZi20SHVA5YKM2ztxI9uouc14ctv8pxlhT/huKxYNgB/eJR+ckT1gyc78RBoJj5YLwUTsptO87KE/vFg9hbHVo5lVSdk//jhfDsMRyf0RXp/wKZ1KGxaRA5hWQUc86mLJTiQU1EBVh3Lfb2zUq2w/gpLCoxdwiX8KnNuX1a1iC8pFCZm4VJ20yvNPaIgzFYDFfNQO6Vwv9fcLsdxVH819cEkjxg5do9MpZBj1OVmaWnTmQ4w4r3iKFzL6LMae4eOEyA/vJ8e7mbWUNrxM3+EPUPlxpG/NKr2VsR2ihIIF9GTduBZa2ayj7BJAkL9UK5PEGh/UxG6jf0YS7RjQ9ROaRgmTLMFsOVnQlFlp2UFRTe+heh/woD8/QSpd9MELdWFzeKRAlo7+hvo5AfWyjBI/3e9PIJfCXp+nF3Z92HKoR5V0m9QoYu2WGzbkhU49DJF7n+Bnd3ur0qefHFVl3USdVU2DJLcdcKU+Qn5G6E8NSy/3TVkjDg6u/o38b203b0tUBZNftAYYmCCpx/HVMEoNC03orIBPrwGYD6g//RC1TZ2ZxkLDU4QxeaM6neWq1xryXbvS4="); + public static final SkinData BARDOLF_WEREWOLF = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0NjkxODMxOTAsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9kNzc0ZGY3OWU1OGFiNDQ5OGQ2YzY3ZTdlMjY2NWFjZmE2OTViOWNjOWNkZTE1MmQ3ZTVlM2NjMTUyNzM5In19fQ==", "nqc7IdRVa2RF2SZXRli/HVhw7q5NfY7rnZFWbDyzjQ90Y/H6NWhb+9gwDDdnh7B1WolyptyUnukzTOQmrAcSecVO5vblhCTYY8PEOfcwUKznjpCmL/BgXdzBoYJHs43HFbtvzt3yhshcQ8Wvh7mtdmNu0MEYKbIX7lTqcfSoUbDk+A1PZDINuOF5RM8disGCrkq6WTdLij+k7pd3e7MJhtf8vJbtSoo5TjfzyzJyFvEvZqa+3lxobbPA9Z4cels0DVWVU8I/FEJhB29aSVXDVAZps3vWUr1sLMM9+PRaZdxHPZfNHx6q9R3oHXgjAlqzJwkljtJGExyOV+vOHEUuxrytdwMcW0XGjalukHVJ1A9DCgNMZqAXEbfYKk+BsN2BzOwT/+dtGfsOU+Rq7Kzp1/iit9saQy1QEG8Bynj6A2Vmg9XZsvbYsXZXsE+qNG6TOADEV0yrS9icEhLhOnO0re/+wE4Zsd5WDF51e87+ugvoH3iM4zrzvaWQb6McgxD/wlYlJyVHD+2f5VYCIw2yacNXp6LaZuXpfQyyDCqpHAosTYNLxWwjinl05C/TprQw+sZoLHFCGbVFQjTPEkDhQzG73PHecnO5Px3USBVleDoTb1kZfq6J2wJ1B1/7MTBW21Din3j2DmmuAVUNJYe6kifaNOhY1ghG2WVRNdIf1b4="); + public static final SkinData LARISSA = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0NjE0MTUxMzQsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9jYThjNDRhOWVmZTY3NzExMDYzMjM5ODEwNDRmOTdjYmM1OWJmZmRlOGI1ODdlMGQzMWE4N2ViMDhhMmExZiJ9fX0=", "Lyac51CrnMK/CI2dWgGQLowAm/ZnQMpf0Ict/gqVrUgJVlGWDIVG77Rd1JyMQDEeESvTmoyivH+usiO0ePW95qjisqT3R43YEmLi85CqctGYqLKeSYpGYwYRz8Euw57LwJAALKOMLhVc2s4h2Or9nTecunG8KSmkCuZc4H1qh3frU+ltuV4HLqgdFUULbIHTggyvqiINov2tBqkkXeEjT7sOcTJCJNgNYU2O7//qg5kJmhso2CKHlRLpmy9LsaUK/Z+BzUmoRbwQgSwr3mz7dFAdlVWWKvKNcgX3nt1et0DIig3JKYmrnQX2Fprg+kWcr3nuizzLgjVwAlADC48P3DN0s/VBty2AYoWie16VNPIM+CV4BF2JRQ34GxZ8XceXbCKURrOjoCBgLGHvIhRW35eicoh26xp3/mwLvk5anPi5StJ/qEuzWJALeWcNbLsnt21m2MZp9h/MxaY6ftWOTzjTr5CYVd/teJyscMnGK4+lcV1dlt12lhbDMv6I+iz8iG9NIzuW5OvGkax90dA/Gq+Cd9FXVThPY4ufxWttHcTqgPB64GfMn6rywRm1B0eO1pJpYc/KlJZlW/PuaO8L1assyJs5KkOypBSy3zc6TO6pzgeOZv+VpQfA/UWpogv6ofmTpgdtwpjLFGSzIKTDXvF6FftALKVlYypG0fYbssA="); + public static final SkinData ROWENA = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0Njk1MTcxOTgsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9jNDY1OGExODY4YzNhNjhhZWVhZmZkOTUxZDQyYmZkN2QxYTRjNGZjNDJjZDI2YTlmYzhkNTNmOTkxMTM1ZCJ9fX0=", "OqXMyH9SMmQ/Pwmb21In29YnCxbsN6yqUxfudN6KNgDwRUK6y072XhW6TIoTh9JQLAUKftpeVB53tk0LxHIxnsuBMrIHvETPDQFysIc/6xq3ABogs+zqFzcp5jk6S73HiD78JxLq5pzfUzhgDPMPuZP5Q/u2q1rYbe6B9lVEJ5sUcxBLUTossgucoR4qXYAlWVQdHRhq85Ol8a+OU7ruw3HackNGto6wt6u2MigCtiHVTt9XhJ/AJE4ScodQ3XwW4L6urpl/lV2OMCsr3mCjjjEz2EMhDbCWxrAorQ9aPpMbDkHBS+4TC1tbMGUlKhj5n+EZBYVaeLr4NGPACPSdT35p/2Zra49+DXn9Xn+681yNEB0ghTdsnsgwXg76+HVPHPqRHQMuTBQGQyGZaaTX/zE0tFjH+osMElLdb8dmz3dC7kQA4A13B2phj3YbMSF1FoU4GvnPKIQn6JIuEd6hd+pRLUW7Y+mgYIHHX1FT0ihrXAyVO6lQQ6rs92gSQr7sxC7tnhPSMFcmh7OcJYcbRpn97GMubthPLanOhVy7CKqjmwIkEVtYgP28idigKwNJ+sJuUONrOu7nMKl1UTD5EEapOacc/np6UhdSw8yW+LnWD/x9ueYz9ksnyRrJgcOa41izo/WCbjPK/j3JVezr9Q3x1yveWuFmdl7CGYdXngw="); + public static final SkinData BIFF = new SkinData("eyJ0aW1lc3RhbXAiOjE0OTc0NjEzMDQzNjYsInByb2ZpbGVJZCI6Ijg1MmE4YWNmNzMzNzQwZDc5OWVjYjA4ZmQ5OTY1MGI1IiwicHJvZmlsZU5hbWUiOiJLaW5nQ3JhenlfIiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9mOWMyMTE3ZDY0ZWE0ZmUxMWZiY2NhZmE2YzU5YzhlZjY3NDVkZjVkMTZjM2QwMmI4NmI2OTlmZWJjNTA0OGI1In19fQ==", "mJMpEvQ4A02z0S/chgLm5bKrrrd+zmp7A0012AB7b3KlyIHoLKEDDz+ZJgJtvN6skOqed3P+yNVqkxitugXaZZP8Af9J+/TseHn+vOy6CTK5tykRSY3Zb8Zmw1kn36v/SARAVtDIHD53yuPgJayYSAbVB7aknj1Q8XBQGUmZRMRxWWxeD7rQTOwgRYI4YJeKFf4UL9i6zxvOJuHsOAouJ7scu7VohG8vgR77Js/Z8rSu8/aSG+O9AQdzP6h9ixYNFkkQOHm7DseK/5tsWKHM4FYBgjIDKt3ApQokSbhThzGB55BA1qjXZkfCoOb13y1nOMC8WoIL6Ees1qzxG3VloGx2WAZLh+Q+/irwrFDMxk1zeU5fIRuj1c/UIM2HKdxxWgoRdrZ8ww/Jrll6maiOBx7geMn/0aOUbJ2U7gkTif6RG6YNS5YN9ZQDLh72l/akJMxF3SlmuAPmLs2kBghQ6eD2YQKuxWR/Hf1yS1YXtogFVNsGnzC1nda7F48EGL3zI+kCajbDlAGQ32aRt0btbEQ+Gj575kir3Aa53qiZ0YOIYQlhgZdOsTN2NE2s8uuy/15Rgc6K3ydgEmSZfdqyMyW0Dy7pE5TfVL8DumKRVRXdOceT5WfnW7MyqSmdorP5ab1fw2wLOnAVzhJmW8oXXNSs77WJ1/PURclxOWB4IF8="); + // Comments this out for now, so it doesn't load the player profile // A better way to do this would check for the properties when getting the skull or the skin // Might change on the next version diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index f0273f3e1..123e9db4d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -217,7 +217,11 @@ public enum AchievementCategory GEM_HUNTERS("Gem Hunters", null, new StatDisplay[] {StatDisplay.KILLS, StatDisplay.GEMS_EARNED, StatDisplay.fromGame("Quests Completed", GameDisplay.GemHunters, "QuestsCompleted"), StatDisplay.fromGame("Chests Opened", GameDisplay.GemHunters, "ChestsOpened")}, - Material.EMERALD, 0, GameCategory.SURVIVAL, null, false, GameDisplay.GemHunters.getGameId()); + Material.EMERALD, 0, GameCategory.SURVIVAL, null, false, GameDisplay.GemHunters.getGameId()), + + MOBA("Heroes Of Gwen", null, + new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED, null, StatDisplay.fromGame("Gold Earned", GameDisplay.MOBA, "GoldEarned")}, + Material.PRISMARINE_SHARD, 0, GameCategory.CLASSICS, null, false, GameDisplay.MOBA.getGameId()); private String _name; private String[] _statsToPull; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java index 0ff566c82..bab3f5efd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java @@ -51,7 +51,7 @@ public class AchievementMainPage extends ShopPageBase pageLayout = new ItemLayout( - "XXOXOXOXO", + "OXOXOXOXO", "OXOXOXOXO", "OXOXOXOXO", "OXOXOXOXO", diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index f6992f67a..277fbd021 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -1,11 +1,17 @@ package nautilus.game.arcade.game.games.moba; +import mineplex.core.Managers; +import mineplex.core.common.Pair; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; +import mineplex.core.disguise.disguises.DisguiseBase; +import mineplex.core.leaderboard.Leaderboard; +import mineplex.core.leaderboard.LeaderboardManager; +import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; import mineplex.minecraft.game.core.combat.DeathMessageType; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; @@ -19,6 +25,7 @@ import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.game.games.moba.buff.BuffManager; import nautilus.game.arcade.game.games.moba.fountain.MobaFountain; import nautilus.game.arcade.game.games.moba.general.ArrowKBManager; +import nautilus.game.arcade.game.games.moba.general.BetaManager; import nautilus.game.arcade.game.games.moba.general.EnderPearlManager; import nautilus.game.arcade.game.games.moba.general.MobaDamageManager; import nautilus.game.arcade.game.games.moba.gold.GoldManager; @@ -45,7 +52,9 @@ import nautilus.game.arcade.game.games.moba.util.MobaUtil; import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager; import nautilus.game.arcade.scoreboard.GameScoreboard; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Location; @@ -151,6 +160,9 @@ public class Moba extends TeamGame // Buffs _buffs = registerManager(new BuffManager()); + // Beta Message + registerManager(new BetaManager(this)); + new CompassModule() .setGiveCompass(true) .setGiveCompassToSpecs(true) @@ -268,6 +280,44 @@ public class Moba extends TeamGame } SpectatorSpawn = WorldData.GetCustomLocs("CENTER").get(0); + + // Leaderboards + if (Manager.IsRewardStats()) + { + if (Manager.GetLobby() instanceof NewGameLobbyManager) + { + Map> lobbyCustomLocs = ((NewGameLobbyManager) Manager.GetLobby()).getCustomLocs(); + LeaderboardManager leaderboard = Managers.get(LeaderboardManager.class); + Pair winPair = Pair.create("Win", "Wins"); + Pair killPair = Pair.create("Kill", "Kills"); + Pair goldPair = Pair.create("Gold", "Gold"); + + { + Location location = lobbyCustomLocs.get("TOP_DAILY_WINS").get(0); + leaderboard.registerLeaderboard("TOP_HOG_DAILY_WINS", new Leaderboard("Top Daily Wins", winPair, new String[]{GetName() + ".Wins"}, LeaderboardSQLType.DAILY, location, 10)); + } + { + Location location = lobbyCustomLocs.get("TOP_DAILY_KILLS").get(0); + leaderboard.registerLeaderboard("TOP_HOG_DAILY_KILLS", new Leaderboard("Top Daily Kills", killPair, new String[]{GetName() + ".Kills"}, LeaderboardSQLType.DAILY, location, 10)); + } + { + Location location = lobbyCustomLocs.get("TOP_DAILY_GOLD").get(0); + leaderboard.registerLeaderboard("TOP_HOG_DAILY_GOLD", new Leaderboard("Top Daily Gold Earned", goldPair, new String[]{GetName() + ".GoldEarned"}, LeaderboardSQLType.DAILY, location, 10)); + } + { + Location location = lobbyCustomLocs.get("TOP_WINS").get(0); + leaderboard.registerLeaderboard("TOP_HOG_WINS", new Leaderboard("Top Wins", winPair, new String[]{GetName() + ".Wins"}, LeaderboardSQLType.ALL, location, 10)); + } + { + Location location = lobbyCustomLocs.get("TOP_KILLS").get(0); + leaderboard.registerLeaderboard("TOP_HOG_KILLS", new Leaderboard("Top Kills", killPair, new String[]{GetName() + ".Kills"}, LeaderboardSQLType.ALL, location, 10)); + } + { + Location location = lobbyCustomLocs.get("TOP_GOLD").get(0); + leaderboard.registerLeaderboard("TOP_HOG_GOLD", new Leaderboard("Top Gold Earned", goldPair, new String[]{GetName() + ".GoldEarned"}, LeaderboardSQLType.ALL, location, 10)); + } + } + } } private void writePrepare(Player player, GameScoreboard scoreboard) @@ -442,11 +492,21 @@ public class Moba extends TeamGame // Get the other team for (GameTeam otherTeam : GetTeamList()) { + for (Player player : otherTeam.GetPlayers(true)) + { + AddGems(player, 10, "Participation", true, true); + } + if (team.equals(otherTeam)) { continue; } + for (Player player : otherTeam.GetPlayers(true)) + { + AddGems(player, 20, "Winning", true, true); + } + AnnounceEnd(otherTeam); SetState(GameState.End); } @@ -505,6 +565,26 @@ public class Moba extends TeamGame } } + // Undisguise everyone upon game end + @EventHandler + public void end(GameStateChangeEvent event) + { + if (event.GetState() != GameState.End) + { + return; + } + + for (Player player : Bukkit.getOnlinePlayers()) + { + DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(player); + + if (disguise != null) + { + Manager.GetDisguise().undisguise(disguise); + } + } + } + public Map getLocationStartsWith(String s) { Map map = new HashMap<>(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java index c9483bbe1..edf900681 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/boss/wither/WitherBoss.java @@ -128,6 +128,14 @@ public class WitherBoss extends MobaBoss // If not damageable if (!_damageable) { + Player damager = event.GetDamagerPlayer(true); + + if (damager != null) + { + damager.sendMessage(F.main("Game", "You must destroy both towers before attacking the Wither!")); + damager.playSound(damager.getLocation(), Sound.NOTE_BASS, 1, 0.8F); + } + return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/BetaManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/BetaManager.java new file mode 100644 index 000000000..f8f08448a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/general/BetaManager.java @@ -0,0 +1,34 @@ +package nautilus.game.arcade.game.games.moba.general; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.moba.Moba; +import org.bukkit.Bukkit; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +public class BetaManager implements Listener +{ + + private static final String MESSAGE = F.main("Game", "You can suggest improvements for the game on our Trello here ") + C.cYellow + "https://trello.com/b/MrxWVhlI/mineplex-heroes-of-gwen-feedback-update"; + private final Moba _host; + + public BetaManager(Moba host) + { + _host = host; + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.MIN_02 || _host.GetState() != GameState.Recruit) + { + return; + } + + Bukkit.broadcastMessage(MESSAGE); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java index c55cf84a5..afdd3582d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/gold/GoldManager.java @@ -157,9 +157,11 @@ public class GoldManager implements Listener public void addGold(Player player, int amount, String reason) { _playerGold.put(player, _playerGold.get(player) + amount); + _host.getArcadeManager().GetStatsManager().incrementStat(player, _host.GetName() + ".GoldEarned", amount); if (amount > 20 && reason != null) { + _host.AddGems(player, (double) amount / 2D, reason, true, true); player.sendMessage(F.main("Game", C.cGold + "+" + amount + " gold (" + reason + ")" + C.cGray + ".")); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java index efd7abfe5..1fc1d18d0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroKit.java @@ -1,15 +1,19 @@ package nautilus.game.arcade.game.games.moba.kit; +import com.mojang.authlib.GameProfile; +import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilGameProfile; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.MobaRole; @@ -35,6 +39,7 @@ public class HeroKit extends Kit private ItemStack _ammo; private long _giveTime; private int _maxAmmo; + private SkinData _skin; private static final int RECALL_SLOT = 8; private static final ItemStack RECALL_ITEM = new ItemBuilder(Material.BED) @@ -48,12 +53,13 @@ public class HeroKit extends Kit private boolean _visible = true; - public HeroKit(ArcadeManager manager, String name, Perk[] kitPerks, MobaRole role) + public HeroKit(ArcadeManager manager, String name, Perk[] kitPerks, MobaRole role, SkinData skin) { super(manager, name, KitAvailability.Free, new String[0], kitPerks, null, null); _role = role; _maxAmmo = 64; + _skin = skin; } public MobaRole getRole() @@ -231,6 +237,30 @@ public class HeroKit extends Kit } } + @Override + public void GiveItemsCall(Player player) + { + super.GiveItemsCall(player); + + disguise(player); + } + + public void disguise(Player player) + { + disguise(player, _skin); + } + + public void disguise(Player player, SkinData skin) + { + GameProfile profile = UtilGameProfile.getGameProfile(player); + profile.getProperties().clear(); + profile.getProperties().put("textures", skin.getProperty()); + DisguisePlayer disguise = new DisguisePlayer(player, profile); + disguise.showInTabList(true, 0); + + Manager.GetDisguise().disguise(disguise); + } + public boolean isVisible() { return _visible; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java index df6e2e3e2..59cdd544a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/HeroSkill.java @@ -31,16 +31,14 @@ import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.UUID; public class HeroSkill extends Perk { - protected List _items; + private ItemStack _item; private ItemStack _cooldownItem; private final int _slot; private final ActionType _actionType; @@ -61,8 +59,7 @@ public class HeroSkill extends Perk { super(name, perkDesc); - _items = new ArrayList<>(2); - _items.add(itemStack); + _item = itemStack; _slot = slot; _actionType = actionType; } @@ -109,18 +106,12 @@ public class HeroSkill extends Perk action += "/Drop Item"; } - List items = new ArrayList<>(2); + _item = new ItemBuilder(_item) + .setTitle((action != null ? C.cYellowB + action + C.cGray + " - " : "") + C.cGreenB + GetName()) + .addLore(GetDesc()) + .setUnbreakable(true) + .build(); - for (ItemStack itemStack : _items) - { - items.add(new ItemBuilder(itemStack) - .setTitle((action != null ? C.cYellowB + action + C.cGray + " - " : "") + C.cGreenB + GetName()) - .addLore(GetDesc()) - .setUnbreakable(true) - .build()); - } - - _items = items; _cooldownItem = new ItemBuilder(Material.INK_SACK, (byte) 8) .setTitle(C.cRed + GetName()) .addLore(GetDesc()) @@ -128,12 +119,6 @@ public class HeroSkill extends Perk .build(); } - protected void addSkillItem(ItemStack itemStack) - { - _items.add(itemStack); - prettifyItems(); - } - @Override public void SetHost(Kit kit) { @@ -199,15 +184,8 @@ public class HeroSkill extends Perk return false; } - for (ItemStack correctItem : _items) - { - if (itemStack.isSimilar(correctItem)) - { - return true; - } - } + return itemStack.isSimilar(_item); - return false; } protected boolean isSkillSneak(PlayerToggleSneakEvent event) @@ -225,15 +203,8 @@ public class HeroSkill extends Perk return false; } - for (ItemStack correctItem : _items) - { - if (itemStack.isSimilar(correctItem)) - { - return true; - } - } + return itemStack.isSimilar(_item); - return false; } @EventHandler @@ -282,7 +253,7 @@ public class HeroSkill extends Perk @EventHandler public void updateCooldowns(UpdateEvent event) { - if (event.getType() != UpdateType.FASTEST || _items == null) + if (event.getType() != UpdateType.FASTEST || _item == null) { return; } @@ -341,12 +312,7 @@ public class HeroSkill extends Perk public void giveItem(Player player) { - if (_items.isEmpty()) - { - return; - } - - player.getInventory().setItem(_slot, _items.get(0)); + player.getInventory().setItem(_slot, _item); } public void useActiveSkill(Player player, long time) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java index 59e33556d..6023bd3ed 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/HeroAnath.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.anath; +import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.ArcadeManager; @@ -25,7 +26,7 @@ public class HeroAnath extends HeroKit public HeroAnath(ArcadeManager manager) { - super(manager, "Anath", PERKS, MobaRole.MAGE); + super(manager, "Anath", PERKS, MobaRole.MAGE, SkinData.ANATH); setAmmo(AMMO, 1000); setMaxAmmo(4); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java index 2349123f2..7938148b3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillBurnBeam.java @@ -25,8 +25,9 @@ public class SkillBurnBeam extends HeroSkill { private static final String[] DESCRIPTION = { - "Fires an Ember at high speed in front of you.", - "Any enemies it collides with take damage and are set on fire." + "Fires a single, vertical beam of Flames which move forward in a straight.", + "It passes through enemies and structures dealing damage", + "to anything it passes through." }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.FIREBALL); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java index 9d7421a1b..dc255d790 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/anath/SkillMeteor.java @@ -39,7 +39,9 @@ public class SkillMeteor extends HeroSkill implements IThrown { private static final String[] DESCRIPTION = { - "It doesn't blow up the map :)", + "Shoot out a Block of Netherrack which is placed where it lands.", + "Meteors rain from the sky around the block.", + "Enemies within the area are damaged.", }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java index b356195c6..d28975e95 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/HeroBardolf.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.bardolf; +import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; @@ -34,6 +35,7 @@ import java.util.Map; public class HeroBardolf extends HeroKit { + private static final int MIN_DIST_SQUARED = 2; private static final int MAX_DIST_SQUARED = 100; private final List _data; @@ -47,7 +49,7 @@ public class HeroBardolf extends HeroKit public HeroBardolf(ArcadeManager manager) { - super(manager, "Bardolf", PERKS, MobaRole.ASSASSIN); + super(manager, "Bardolf", PERKS, MobaRole.ASSASSIN, SkinData.BARDOLF); _data = new ArrayList<>(2); } @@ -101,7 +103,7 @@ public class HeroBardolf extends HeroKit { wolf.teleport(data.getOwner()); } - else if (ownerOffset > 4) + else if (ownerOffset > MIN_DIST_SQUARED) { UtilEnt.CreatureMoveFast(wolf, data.getOwner().getLocation(), data.isUltimate() ? 2F : 1.5F); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java index 6bfa262bc..c68fab17d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillFullMoon.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.bardolf; +import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; @@ -21,8 +22,11 @@ public class SkillFullMoon extends HeroSkill { private static final String[] DESCRIPTION = { - "Fires an Ember at high speed in front of you.", - "Any enemies it collides with take damage and are set on fire." + "Turns the character into a Werewolf.", + "He gains +1 attack Damage and +5% Movement speed for each Wolf alive in his pack.", + "The Wolves gain movement speed to catch up and are healed to their full HP.", + "As wolves die his power decreases.", + "All Wolves in the pack die after the ultimate ends" }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); private static final long DURATION = TimeUnit.SECONDS.toMillis(10); @@ -49,15 +53,18 @@ public class SkillFullMoon extends HeroSkill return; } - WolfData data = ((HeroBardolf) Kit).getWolfData(player); + HeroBardolf kit = (HeroBardolf) Kit; + WolfData data = kit.getWolfData(player); if (data == null) { return; } + _active.add(player); Manager.GetGame().WorldTimeSet = 18000; player.getWorld().strikeLightningEffect(player.getLocation()); + kit.disguise(player, SkinData.BARDOLF_WEREWOLF); data.setUltimate(true); float speedIncrease = (float) data.getWolves().size() * SPEED_FACTOR; @@ -79,6 +86,7 @@ public class SkillFullMoon extends HeroSkill _active.remove(player); Manager.GetGame().WorldTimeSet = 12000; data.setUltimate(false); + kit.disguise(player); player.setWalkSpeed(player.getWalkSpeed() - data.getLastSpeedIncrease()); for (Wolf wolf : data.getWolves()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java index 4fa75b94f..d0e43367b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillSummonWolf.java @@ -25,8 +25,10 @@ public class SkillSummonWolf extends HeroSkill { private static final String[] DESCRIPTION = { - "Fires an Ember at high speed in front of you.", - "Any enemies it collides with take damage and are set on fire." + "Click to summon a Wolf to your pack.", + "Wolves are tamed and will attack your target or people who damage you.", + "Wolves are weak and can be killed.", + "Maximum of 5." }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.BONE); private static final int MAX_WOLVES = 5; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillWolfPounce.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillWolfPounce.java index 20e1444dc..e69fdc4c0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillWolfPounce.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bardolf/SkillWolfPounce.java @@ -34,7 +34,8 @@ public class SkillWolfPounce extends HeroSkill { private static final String[] DESCRIPTION = { - "Dash along the ground, leaving fire behind you.", + "Dash into the air", + "Your wolves will follow you." }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); private static final int COOLDOWN = 7000; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java index 78314c186..3ea9175bc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/HeroBiff.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.biff; +import mineplex.core.common.skin.SkinData; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.HeroKit; @@ -18,6 +19,6 @@ public class HeroBiff extends HeroKit public HeroBiff(ArcadeManager manager) { - super(manager, "Biff", PERKS, MobaRole.WARRIOR); + super(manager, "Biff", PERKS, MobaRole.WARRIOR, SkinData.BIFF); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java index 6fa9c4ac4..8db6b27f9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillBiffDash.java @@ -1,7 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.biff; 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.UtilEvent.ActionType; @@ -13,7 +12,6 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; import org.bukkit.Effect; -import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; @@ -36,7 +34,9 @@ public class SkillBiffDash extends HeroSkill { private static final String[] DESCRIPTION = { - "Dash along the ground, leaving fire behind you.", + "Dash into the air.", + "When you land any enemies near you are damaged", + "and thrown up into the air." }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java index 5c9e28f4d..dcbb2ff1d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillLeash.java @@ -1,6 +1,5 @@ package nautilus.game.arcade.game.games.moba.kit.biff; -import mineplex.core.common.events.EntityVelocityChangeEvent; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilEvent.ActionType; @@ -29,8 +28,9 @@ public class SkillLeash extends HeroSkill { private static final String[] DESCRIPTION = { - "Fires an Ember at high speed in front of you.", - "Any enemies it collides with take damage and are set on fire." + "Enemy heroes near to Biff are hooked with a leash to you.", + "Leashed players are slowed and it breaks if the leashed player moves", + "too far away." }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.LEASH); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java index 1564ed858..9a45a201d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/biff/SkillWarHorse.java @@ -34,8 +34,9 @@ public class SkillWarHorse extends HeroSkill { private static final String[] DESCRIPTION = { - "Fires an Ember at high speed in front of you.", - "Any enemies it collides with take damage and are set on fire." + "Mounts you on a horse.", + "Any nearby enemy heroes are rooted and will be", + "unable to move." }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java index 8c851c98b..06ad4b260 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/HeroBob.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.bob; +import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.ArcadeManager; @@ -25,7 +26,7 @@ public class HeroBob extends HeroKit public HeroBob(ArcadeManager manager) { - super(manager, "Bob Ross", PERKS, MobaRole.MAGE); + super(manager, "Bob Ross", PERKS, MobaRole.MAGE, SkinData.BOB_ROSS); setAmmo(AMMO, 500); setMaxAmmo(8); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBeatTheDevil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBeatTheDevil.java index 596b43a76..55cc18082 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBeatTheDevil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillBeatTheDevil.java @@ -18,7 +18,7 @@ public class SkillBeatTheDevil extends DashSkill { private static final String[] DESCRIPTION = { - "Dash along the ground, leaving fire behind you.", + "Bob Ross" }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java index f5e0fbc4b..9590d39f9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/bob/SkillHappyTrees.java @@ -153,7 +153,7 @@ public class SkillHappyTrees extends HeroSkill continue; } - MobaUtil.heal(entity, 2); + MobaUtil.heal(entity, owner, 2); MobaParticles.healing(entity, 1); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java index 8b892c4eb..c7834d07d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/common/SkillSword.java @@ -16,10 +16,6 @@ import java.util.List; public class SkillSword extends HeroSkill { - private static final String[] DESCRIPTION = { - "Please work" - }; - private static final ItemStack SKILL_ITEM = new ItemBuilder(Material.WOOD_SWORD) .setTitle(C.cGreenB + "Sword") .setUnbreakable(true) @@ -27,7 +23,7 @@ public class SkillSword extends HeroSkill public SkillSword(int slot) { - super("Sword", DESCRIPTION, SKILL_ITEM, slot, null); + super("Sword", new String[0], SKILL_ITEM, slot, null); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/HeroDana.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/HeroDana.java index e6e0f1e8b..f305be717 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/HeroDana.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/HeroDana.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.dana; +import mineplex.core.common.skin.SkinData; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.HeroKit; @@ -18,6 +19,6 @@ public class HeroDana extends HeroKit public HeroDana(ArcadeManager manager) { - super(manager, "Dana", PERKS, MobaRole.WARRIOR); + super(manager, "Dana", PERKS, MobaRole.WARRIOR, SkinData.DANA); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java index 0bb7af0f9..8fcb89839 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillDanaDash.java @@ -23,7 +23,8 @@ public class SkillDanaDash extends DashSkill { private static final String[] DESCRIPTION = { - "Dash along the ground, leaving fire behind you.", + "Dash along the ground.", + "Nearby enemies are thrown up into the air." }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java index 358db05c1..6d26e4cc3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillPulseHeal.java @@ -21,8 +21,7 @@ public class SkillPulseHeal extends HeroSkill { private static final String[] DESCRIPTION = { - "Fires an Ember at high speed in front of you.", - "Any enemies it collides with take damage and are set on fire." + "Heals nearby allies and minions." }; private static final ItemStack SKILL_ITEM = new ItemBuilder(Material.INK_SACK, (byte) 10).build(); @@ -52,7 +51,7 @@ public class SkillPulseHeal extends HeroSkill continue; } - MobaUtil.heal(entity, 4); + MobaUtil.heal(entity, player, 4); } displayPulse(player.getLocation().add(0, 0.5, 0)); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java index ba64117fe..ec5ac4cc9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/dana/SkillRally.java @@ -33,8 +33,9 @@ public class SkillRally extends HeroSkill { private static final String[] DESCRIPTION = { - "Fires an Ember at high speed in front of you.", - "Any enemies it collides with take damage and are set on fire." + "You leap up into the air, and upon landing", + "you plant a banner that heals nearby allies", + "and minions." }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java index c50db2648..7ff52d150 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/devon/HeroDevon.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.devon; +import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.ArcadeManager; @@ -27,7 +28,7 @@ public class HeroDevon extends HeroKit public HeroDevon(ArcadeManager manager) { - super(manager, "Devon", PERKS, MobaRole.HUNTER); + super(manager, "Devon", PERKS, MobaRole.HUNTER, SkinData.DEVON); setAmmo(AMMO, 3000); setMaxAmmo(3); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java index 284a78e01..e9438b9c1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/HeroHattori.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.hattori; +import mineplex.core.common.skin.SkinData; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.kit.HeroKit; @@ -20,6 +21,6 @@ public class HeroHattori extends HeroKit public HeroHattori(ArcadeManager manager) { - super(manager, "Hattori", PERKS, MobaRole.ASSASSIN); + super(manager, "Hattori", PERKS, MobaRole.ASSASSIN, SkinData.HATTORI); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java index 5b80853d6..f1d06a1dc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hattori/SkillSnowball.java @@ -24,7 +24,7 @@ public class SkillSnowball extends HeroSkill implements IThrown private static final String[] DESCRIPTION = { "Fires 3 snowballs, one after another.", - "Each snowball deals 3 damage to any enemy it hits." + "Each snowball deals damage to any enemy it hits." }; private static final int DAMAGE = 3; private static final ItemStack SKILL_ITEM = new ItemStack(Material.SNOW_BALL); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java index 02ad04e8e..956968e06 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/hp/HPManager.java @@ -42,7 +42,7 @@ public class HPManager implements Listener continue; } - MobaHPRegenEvent regenEvent = new MobaHPRegenEvent(player, HP5, true); + MobaHPRegenEvent regenEvent = new MobaHPRegenEvent(player, null, HP5, true); UtilServer.CallEvent(regenEvent); if (regenEvent.isCancelled()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/HeroLarissa.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/HeroLarissa.java index f208d672b..a1f2cb08b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/HeroLarissa.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/HeroLarissa.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.larissa; +import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.ArcadeManager; @@ -26,7 +27,7 @@ public class HeroLarissa extends HeroKit public HeroLarissa(ArcadeManager manager) { - super(manager, "Larissa", PERKS, MobaRole.MAGE); + super(manager, "Larissa", PERKS, MobaRole.MAGE, SkinData.LARISSA); setAmmo(AMMO, 3000); setMaxAmmo(5); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java index 15a6fe9f8..93e4e5055 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAOEHeal.java @@ -44,8 +44,9 @@ public class SkillAOEHeal extends HeroSkill implements IThrown { private static final String[] DESCRIPTION = { - "Fires an Ember at high speed in front of you.", - "Any enemies it collides with take damage and are set on fire." + "Throws a water bucket which upon coming into", + "contact with the ground will heal nearby", + "players and minions." }; private static final long DURATION = TimeUnit.SECONDS.toMillis(6); private static final int RADIUS = 3; @@ -127,7 +128,7 @@ public class SkillAOEHeal extends HeroSkill implements IThrown if (isTeamDamage(entity, owner)) { MobaParticles.healing(entity, HEALTH_PER_SECOND); - MobaUtil.heal(entity, HEALTH_PER_SECOND); + MobaUtil.heal(entity, owner, HEALTH_PER_SECOND); } else { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java index 74e61a7f3..2a64ce53c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillAquaCannon.java @@ -26,8 +26,8 @@ public class SkillAquaCannon extends HeroSkill { private static final String[] DESCRIPTION = { - "Fires an Ember at high speed in front of you.", - "Any enemies it collides with take damage and are set on fire." + "Fires a beam of water that deals damage", + "to the first enemy it comes in contact with." }; private static final int DAMAGE = 6; private static final ItemStack SKILL_ITEM = new ItemStack(Material.DIAMOND_HOE); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillStormHeal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillStormHeal.java index 9c2fbbaca..a26b02cfe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillStormHeal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillStormHeal.java @@ -1,6 +1,5 @@ package nautilus.game.arcade.game.games.moba.kit.larissa; -import mineplex.core.Managers; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; @@ -30,8 +29,8 @@ public class SkillStormHeal extends HeroSkill { private static final String[] DESCRIPTION = { - "Fires an Ember at high speed in front of you.", - "Any enemies it collides with take damage and are set on fire." + "All team members are consistently healed", + "over the next 7 seconds." }; private static final long DURATION = TimeUnit.SECONDS.toMillis(7); private static final int HEALTH_PER_SECOND = 2; @@ -86,7 +85,7 @@ public class SkillStormHeal extends HeroSkill for (Player teamMember : team.GetPlayers(true)) { - MobaUtil.heal(teamMember, HEALTH_PER_SECOND); + MobaUtil.heal(teamMember, player, HEALTH_PER_SECOND); } }); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java index d66be7c20..69cc3a8f4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/larissa/SkillWaterDash.java @@ -18,7 +18,8 @@ public class SkillWaterDash extends DashSkill { private static final String[] DESCRIPTION = { - "Dash along the ground, leaving water behind you.", + "Dash along the ground, crippling enemies you", + "come into contact with." }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); private static final long CRIPPLE_DURATION = TimeUnit.SECONDS.toMillis(3); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java index d196ad8cb..d15ab3174 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/HeroRowena.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.moba.kit.rowena; +import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.ArcadeManager; @@ -27,7 +28,7 @@ public class HeroRowena extends HeroKit public HeroRowena(ArcadeManager manager) { - super(manager, "Rowena", PERKS, MobaRole.HUNTER); + super(manager, "Rowena", PERKS, MobaRole.HUNTER, SkinData.ROWENA); setAmmo(AMMO, 2000); setMaxAmmo(2); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java index 1a704d5e8..2499f8d6e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillBombardment.java @@ -1,30 +1,32 @@ package nautilus.game.arcade.game.games.moba.kit.rowena; import mineplex.core.common.events.EntityVelocityChangeEvent; -import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent.ActionType; 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.UtilServer; import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.particles.effects.LineParticle; +import mineplex.core.itemstack.ItemBuilder; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.game.games.moba.kit.HeroSkill; -import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.game.games.moba.util.MobaUtil; 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.LivingEntity; 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.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.inventory.ItemStack; -import org.bukkit.util.Vector; import java.util.HashSet; import java.util.Iterator; @@ -34,13 +36,16 @@ public class SkillBombardment extends HeroSkill { private static final String[] DESCRIPTION = { - "Turns into a Diamond Sword that deals extreme", - "damage to any player hit by it." + "Take to the sky!", + "Your shots become fast high power explosive shots." }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.NETHER_STAR); + private static final int DAMAGE_FACTOR = 2; private static final int SHOTS = 3; private static final int MAX_TIME = 10000; - private static final int DAMAGE_INCREASE = 5; + private static final ItemStack ACTIVE_ITEM = new ItemBuilder(Material.DIAMOND_BARDING) + .setTitle(C.cDRedB + "Bombardment") + .build(); private Set _data = new HashSet<>(); @@ -71,20 +76,54 @@ public class SkillBombardment extends HeroSkill } } - for (Perk perk : Kit.GetPerks()) - { - if (perk instanceof SkillLightArrows) - { - SkillLightArrows skill = (SkillLightArrows) perk; + Location toTeleport = player.getLocation().add(0, 15, 0); - skill.resetCooldown(player); - skill.setPlayerArrows(player, SHOTS); - } + player.teleport(toTeleport); + player.getInventory().setItem(0, ACTIVE_ITEM); + player.getInventory().setHeldItemSlot(0); + broadcast(player); + _data.add(new BombardmentData(player)); + } + + @EventHandler + public void interactActive(PlayerInteractEvent event) + { + if (event.getItem() == null || !event.getItem().isSimilar(ACTIVE_ITEM)) + { + return; } - broadcast(player); - UtilAction.velocity(player, new Vector(0, 2, 0)); - _data.add(new BombardmentData(player)); + Player player = event.getPlayer(); + + for (BombardmentData data : _data) + { + if (data.Shooter.equals(player)) + { + Location location = player.getEyeLocation(); + LineParticle lineParticle = new LineParticle(location, location.getDirection(), 0.4, 40, ParticleType.FIREWORKS_SPARK, UtilServer.getPlayers()); + double damage = MobaUtil.scaleDamageWithBow(player.getInventory().getItem(0), 0) * DAMAGE_FACTOR; + + while (!lineParticle.update()) + { + } + + player.playSound(player.getLocation(), Sound.EXPLODE, 1, 0.8F); + UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, lineParticle.getDestination(), 0, 0, 0, 0.1F, 1, ViewDist.LONG); + + for (LivingEntity entity : UtilEnt.getInRadius(lineParticle.getLastLocation(), 5).keySet()) + { + if (isTeamDamage(entity, player)) + { + continue; + } + + Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, damage, true, true, false, player.getName(), GetName()); + } + + data.Shots--; + return; + } + } } @EventHandler @@ -102,21 +141,10 @@ public class SkillBombardment extends HeroSkill BombardmentData data = iterator.next(); Player player = data.Shooter; - if (data.Block == null && player.getVelocity().getY() <= 0) - { - data.Block = player.getLocation().getBlock().getRelative(BlockFace.DOWN); - data.Block.setType(Material.BARRIER); - - Location playerLocation = player.getLocation(); - Location toTeleport = data.Block.getLocation(); - toTeleport.setYaw(playerLocation.getYaw()); - toTeleport.setPitch(playerLocation.getPitch()); - - player.getInventory().setHeldItemSlot(0); - } - else if (UtilTime.elapsed(data.Start, MAX_TIME) || data.Shots == 0) + if (UtilTime.elapsed(data.Start, MAX_TIME) || data.Shots == 0) { useSkill(player); + Kit.GiveItems(player); data.Block.setType(Material.AIR); iterator.remove(); } @@ -127,46 +155,6 @@ public class SkillBombardment extends HeroSkill } } - @EventHandler - public void shootArrow(EntityShootBowEvent event) - { - if (!(event.getEntity() instanceof Player)) - { - return; - } - - Player player = (Player) event.getEntity(); - - for (BombardmentData data : _data) - { - if (data.Shooter.equals(player)) - { - data.Shots--; - return; - } - } - } - - @EventHandler(priority = EventPriority.HIGH) - public void increaseDamage(CustomDamageEvent event) - { - if (event.isCancelled()) - { - return; - } - - Player damager = event.GetDamagerPlayer(true); - - if (damager == null || event.GetReason() == null || !event.GetReason().contains("Light Arrows")) - { - return; - } - - damager.playSound(event.GetDamageeEntity().getLocation(), Sound.EXPLODE, 1, 0.6F); - UtilParticle.PlayParticleToAll(ParticleType.LARGE_EXPLODE, event.GetDamageeEntity().getLocation().add(0, 1, 0), 0, 0, 0, 0.1F, 1, ViewDist.LONG); - event.AddMod(GetName(), DAMAGE_INCREASE); - } - @EventHandler public void playerMove(PlayerMoveEvent event) { @@ -212,6 +200,8 @@ public class SkillBombardment extends HeroSkill { Shooter = shooter; Shots = SHOTS; + Block = shooter.getLocation().getBlock().getRelative(BlockFace.DOWN); + Block.setType(Material.BARRIER); Start = System.currentTimeMillis(); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillCombatDash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillCombatDash.java index 27de6635a..a3edb19df 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillCombatDash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillCombatDash.java @@ -13,7 +13,7 @@ public class SkillCombatDash extends DashSkill { private static final String[] DESCRIPTION = { - "Dash along the ground, leaving fire behind you.", + "Dash very fast along the ground.", }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER); @@ -25,7 +25,6 @@ public class SkillCombatDash extends DashSkill _collide = false; _velocityTime = 250; - _velocityStopOnEnd = true; _velocityMagnitude = 1.5; _horizontial = true; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java index b71653c29..d4037aa5f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/kit/rowena/SkillLightArrows.java @@ -38,8 +38,8 @@ public class SkillLightArrows extends HeroSkill { private static final String[] DESCRIPTION = { - "Your next 3 arrows are infused with TNT.", - "They explode on contact dealing damage and knockback." + "Your next 5 arrows become light infused.", + "They pass through blocks and deal high damage." }; private static final ItemStack SKILL_ITEM = new ItemStack(Material.GOLD_NUGGET); @@ -170,10 +170,5 @@ public class SkillLightArrows extends HeroSkill _playerArrows.remove(event.getPlayer()); _arrows.remove(event.getPlayer()); } - - void setPlayerArrows(Player player, int amount) - { - _playerArrows.put(player, amount); - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java index 1d90780a7..e3c663632 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionManager.java @@ -143,6 +143,11 @@ public class MinionManager implements Listener public void unregisterWave(MinionWave wave) { + for (Minion minion : wave.getMinions()) + { + minion.getEntity().remove(); + } + _waves.remove(wave); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java index edb5c9917..5d9f3e77f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/minion/MinionWave.java @@ -33,6 +33,7 @@ import org.jooq.util.derby.sys.Sys; import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; @@ -163,7 +164,23 @@ public class MinionWave implements Listener return; } - _minions.removeIf(minion -> minion.getEntity() == null || minion.getEntity().isDead() || !minion.getEntity().isValid()); + Iterator iterator = _minions.iterator(); + + while (iterator.hasNext()) + { + Minion minion = iterator.next(); + LivingEntity entity = minion.getEntity(); + + if (entity == null || entity.isDead() || !entity.isValid()) + { + if (entity != null && entity.getKiller() != null) + { + _host.AddGems(entity.getKiller(), 0.1, "Minion Kills", true, true); + } + + iterator.remove(); + } + } // Only should unregister the wave after all entities have spawned if (_minions.isEmpty() && UtilTime.elapsed(_startTime, 10000)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java index d31ff421e..0565ef5e5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/shop/effects/MobaKillHealEffect.java @@ -19,12 +19,12 @@ public class MobaKillHealEffect extends MobaItemEffect @Override public void onDeath(Player killed, Player killer) { - MobaUtil.heal(killer, _health); + MobaUtil.heal(killer, killer, _health); } @Override public String getDescription() { - return "Killing a player heals for " + F.greenElem(format(_health / 2)) + C.cRed + "❤" + C.cGray + "."; + return "Killing a player heals for an additional " + F.greenElem(format(_health / 2)) + C.cRed + "❤" + C.cGray + "."; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java index f31a6c380..a7c9d4d54 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/structure/tower/TowerManager.java @@ -125,6 +125,11 @@ public class TowerManager implements Listener @EventHandler public void updateTower(UpdateEvent event) { + if (!_host.IsLive()) + { + return; + } + if (event.getType() == UpdateType.FASTEST) { for (Tower tower : _towers) @@ -166,7 +171,7 @@ public class TowerManager implements Listener @EventHandler(priority = EventPriority.LOW) public void crystalDamage(EntityDamageByEntityEvent event) { - if (!(event.getEntity() instanceof EnderCrystal)) + if (!(event.getEntity() instanceof EnderCrystal) || !_host.IsLive()) { return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java index 72fe45918..ac09e9aac 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/util/MobaUtil.java @@ -198,11 +198,11 @@ public class MobaUtil return entity.hasMetadata(MobaConstants.TEAM_METADATA) && entity.getMetadata(MobaConstants.TEAM_METADATA).get(0).asString().equals(team.GetName()); } - public static void heal(LivingEntity entity, double health) + public static void heal(LivingEntity entity, Player source, double health) { if (entity instanceof Player) { - MobaHPRegenEvent regenEvent = new MobaHPRegenEvent((Player) entity, health, false); + MobaHPRegenEvent regenEvent = new MobaHPRegenEvent((Player) entity, source, health, false); UtilServer.CallEvent(regenEvent); if (regenEvent.isCancelled()) From 2a0796472bada88760a53cb5f078f4114cb9df82 Mon Sep 17 00:00:00 2001 From: cnr Date: Wed, 14 Jun 2017 19:54:23 -0500 Subject: [PATCH 57/57] Add beta whitelist to MOBA --- .../src/nautilus/game/arcade/game/games/moba/Moba.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java index 277fbd021..dd98c6884 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/moba/Moba.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.moba; import mineplex.core.Managers; +import mineplex.core.beta.BetaWhitelist; import mineplex.core.common.Pair; import mineplex.core.common.Rank; import mineplex.core.common.util.C; @@ -97,6 +98,7 @@ public class Moba extends TeamGame private final CapturePointManager _capturePoint; private final ArrowKBManager _arrowKb; private final BuffManager _buffs; + private final BetaWhitelist _betaWhitelist; public Moba(ArcadeManager manager) { @@ -163,6 +165,9 @@ public class Moba extends TeamGame // Beta Message registerManager(new BetaManager(this)); + // Beta Whitelist + _betaWhitelist = new BetaWhitelist(manager.GetClients(), manager.getBonusManager().getPowerPlayClubRepository()); + new CompassModule() .setGiveCompass(true) .setGiveCompassToSpecs(true) @@ -527,6 +532,7 @@ public class Moba extends TeamGame super.disable(); _listeners.forEach(UtilServer::Unregister); _listeners.clear(); + _betaWhitelist.deregisterSelf(); } @Override