From 97471b0d9cde69ff67b67d04b5af2867b1ef8869 Mon Sep 17 00:00:00 2001 From: Sarah Date: Fri, 20 Nov 2015 23:38:02 +0100 Subject: [PATCH 01/58] Finalizing Game Tutorials. --- .../src/nautilus/game/arcade/game/Game.java | 5 + .../nautilus/game/arcade/game/GameTeam.java | 14 ++ .../arcade/gametutorial/GameTutorial.java | 167 +++++++++++++++ .../arcade/gametutorial/TutorialPhase.java | 193 ++++++++++++++++++ .../arcade/gametutorial/TutorialText.java | 38 ++++ .../events/GameTutorialEndEvent.java | 32 +++ .../events/GameTutorialStartEvent.java | 32 +++ .../game/arcade/managers/GameManager.java | 73 +++++++ 8 files changed, 554 insertions(+) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/events/GameTutorialEndEvent.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/events/GameTutorialStartEvent.java 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 23dc523e1..d09ecb8fc 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 @@ -72,6 +72,7 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.events.PlayerStateChangeEvent; import nautilus.game.arcade.game.GameTeam.PlayerState; +import nautilus.game.arcade.gametutorial.GameTutorial; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; @@ -299,6 +300,8 @@ public abstract class Game implements Listener public boolean DeadBodiesQuit = true; public boolean DeadBodiesDeath = true; public int DeadBodiesExpire = -1; + + public boolean EnableTutorials = false; private IPacketHandler _useEntityPacketHandler; private int _deadBodyCount; @@ -1719,4 +1722,6 @@ public abstract class Game implements Listener } } } + + public void addTutorials(){} } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java index 6527ec0ea..528d01aa1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java @@ -14,6 +14,7 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.visibility.VisibilityManager; import nautilus.game.arcade.game.GameTeam.PlayerState; +import nautilus.game.arcade.gametutorial.GameTutorial; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; @@ -58,6 +59,8 @@ public class GameTeam private String _name; private String _displayName; private ChatColor _color; + + private GameTutorial _tutorial; private HashMap _players = new HashMap(); @@ -441,4 +444,15 @@ public class GameTeam return _places; } + + public GameTutorial getTutorial() + { + return _tutorial; + } + + public void setTutorial(GameTutorial tutorial) + { + _tutorial = tutorial; + } + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java new file mode 100644 index 000000000..65d129eb3 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java @@ -0,0 +1,167 @@ +package nautilus.game.arcade.gametutorial; + +import java.util.ArrayList; +import java.util.HashMap; + +import mineplex.core.common.util.UtilServer; +import mineplex.core.visibility.VisibilityManager; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.gametutorial.events.GameTutorialEndEvent; +import nautilus.game.arcade.gametutorial.events.GameTutorialStartEvent; + +import org.bukkit.Location; +import org.bukkit.entity.Player; + +public abstract class GameTutorial +{ + + public ArcadeManager Manager; + + private TutorialPhase[] _phases; + private GameTeam _team; + private HashMap _players; + + private TutorialPhase _currentPhase; + + private boolean _hasEnded; + private boolean _hasStarted; + + private int _tick; + + public GameTutorial(ArcadeManager manager, TutorialPhase[] phases) + { + Manager = manager; + _phases = phases; + _players = new HashMap<>(); + } + + final public void start() + { + _hasStarted = true; + _tick = 0; + for(TutorialPhase phase : _phases) + phase.setTutorial(this); + + Manager.GetGame().PrepareTime = 60000; + Manager.GetChat().Silence(60000, false); + Manager.getPluginManager().callEvent(new GameTutorialStartEvent(this)); + onStart(); + preparePlayers(); + nextPhase(); + } + + protected void nextPhase() + { + _currentPhase = getNextPhase(); + if(_currentPhase == null) + { + onEnd(); + endTutorial(); + _hasEnded = true; + Manager.getPluginManager().callEvent(new GameTutorialEndEvent(this)); + } + else + { + Manager.GetChat().Silence((System.currentTimeMillis() - Manager.GetGame().GetStateTime()) + 7000, false); + onPhaseChange(_currentPhase); + _currentPhase.start(); + } + } + + public void setTeam(GameTeam team) + { + _team = team; + } + + private void endTutorial() + { + Manager.runSync(new Runnable() + { + @Override + public void run() + { + for(Player player : _players.keySet()) + { + VisibilityManager.Instance.setVisibility(player, true, UtilServer.getPlayers()); + player.setAllowFlight(false); + player.setFlying(false); + player.teleport(_players.get(player)); + } + } + }); + Manager.GetChat().Silence((System.currentTimeMillis() - Manager.GetGame().GetStateTime()) + 5000, false); + Manager.GetGame().PrepareTime = (System.currentTimeMillis() - Manager.GetGame().GetStateTime()) + 5000; + } + + protected TutorialPhase getNextPhase() + { + for(TutorialPhase phase : _phases) + { + if(_currentPhase == null && phase.ID() == 1) + { + return phase; + } + else if(_currentPhase != null && _currentPhase.ID() + 1 == phase.ID()) + { + return phase; + } + } + return null; + } + + private void preparePlayers() + { + for(Player player : UtilServer.getPlayers()) + { + int i = 0; + if(Manager.GetGame().GetTeam(player) == _team) + { + _players.put(player, Manager.GetGame().GetTeam(player).GetSpawns().get(i)); + player.setAllowFlight(true); + player.setFlying(true); + VisibilityManager.Instance.setVisibility(player, false, UtilServer.getPlayers()); + i++; + } + } + } + + public TutorialPhase getPhase(int index) + { + for(TutorialPhase phase : _phases) + { + if(phase.ID() == index) + return phase; + } + return null; + } + + public boolean hasEnded() + { + return _hasEnded; + } + + public boolean hasStarted() + { + return _hasStarted; + } + + public HashMap getPlayers() + { + return _players; + } + + public void onTick(int tick){} + + public void onStart(){} + + public void onPhaseChange(TutorialPhase phase){} + + public void onEnd(){} + + public int tick() + { + _tick++; + return _tick; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java new file mode 100644 index 000000000..f64c9aed3 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java @@ -0,0 +1,193 @@ +package nautilus.game.arcade.gametutorial; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilTextMiddle; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +public abstract class TutorialPhase +{ + + public abstract int ID(); + + private GameTutorial _tutorial; + private TutorialText[] _text; + private Location _location; + private Location _target; + private boolean _hasEnded; + + private TutorialText _currentText; + + public TutorialPhase(TutorialText[] text) + { + _text = text; + } + + public TutorialText[] getText() + { + return _text; + } + + public Location getLocation() + { + return _location; + } + + final public void start() + { + _hasEnded = false; + onStart(); + if(_location != null && _target != null) + { + prepareLocations(); + updatePlayers(); + } + displayText(); + } + + private void prepareLocations() + { + Vector vector = new Vector(_target.getBlockX() - _location.getBlockX(), _target.getBlockY() - _location.getBlockY(), _target.getBlockZ() - _location.getBlockZ()); + float pitch = UtilAlg.GetPitch(vector); + float yaw = UtilAlg.GetYaw(vector); + _location.setPitch(pitch); + _location.setYaw(yaw); + } + + private void updatePlayers() + { + new Thread(new Runnable() + { + @Override + public void run() + { + while(!_hasEnded) + { + _tutorial.Manager.runSync(new Runnable() + { + @Override + public void run() + { + for(Player player : _tutorial.getPlayers().keySet()) + { + player.setAllowFlight(true); + player.setFlying(true); + player.teleport(_location); + } + } + }); + try + { + Thread.sleep(50); + } catch (InterruptedException e) + { + e.printStackTrace(); + } + } + } + }).start(); + } + + public void displayText() + { + new Thread(new Runnable() + { + @Override + public void run() + { + while(true) + { + TutorialText text = getNextMessage(); + if(text == null) + { + _tutorial.Manager.runSync(new Runnable() + { + @Override + public void run() + { + _hasEnded = true; + _tutorial.nextPhase(); + onEnd(); + } + }); + break; + } + else + { + Player[] players = new Player[_tutorial.getPlayers().keySet().size()]; + int i = 0; + for(Player player : _tutorial.getPlayers().keySet()) + { + players[i] = player; + i++; + } + UtilTextMiddle.display("", text.getText(), 0, text.getStayTime(), 0, players); + displayMessage(text); + try + { + Thread.sleep(text.getStayTime() * 50); + } catch (InterruptedException e) + { + e.printStackTrace(); + } + } + } + + } + }).start(); + } + + private void displayMessage(final TutorialText text) + { + _tutorial.Manager.runSync(new Runnable() + { + @Override + public void run() + { + onMessageDisplay(text); + } + }); + } + + protected TutorialText getNextMessage() + { + for(TutorialText text : _text) + { + if(_currentText == null && text.ID() == 1) + { + _currentText = text; + return text; + } + else if(_currentText != null && _currentText.ID() + 1 == text.ID()) + { + _currentText = text; + return text; + } + } + return null; + } + + public void setTutorial(GameTutorial tutorial) + { + _tutorial = tutorial; + } + + public void setLocation(Location location) + { + _location = location; + } + + public void setTarget(Location target) + { + _target = target; + } + + public void onStart(){} + + public void onMessageDisplay(TutorialText text){} + + public void onEnd(){} + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java new file mode 100644 index 000000000..dd278faec --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java @@ -0,0 +1,38 @@ +package nautilus.game.arcade.gametutorial; + + +public class TutorialText +{ + + private String _text; + private int _stayTime; + private int _id; + + public TutorialText(String text, int stayTime, int id) + { + _text = text; + _id = id; + _stayTime = stayTime; + } + + public TutorialText(String text, int id) + { + this(text, text.length() + 20, id); + } + + public String getText() + { + return _text; + } + + public int ID() + { + return _id; + } + + public int getStayTime() + { + return _stayTime; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/events/GameTutorialEndEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/events/GameTutorialEndEvent.java new file mode 100644 index 000000000..10a540759 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/events/GameTutorialEndEvent.java @@ -0,0 +1,32 @@ +package nautilus.game.arcade.gametutorial.events; + +import nautilus.game.arcade.gametutorial.GameTutorial; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class GameTutorialEndEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + private GameTutorial _tutorial; + + public GameTutorialEndEvent(GameTutorial tutorial) + { + _tutorial = tutorial; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + + public GameTutorial getTutorial() + { + return _tutorial; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/events/GameTutorialStartEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/events/GameTutorialStartEvent.java new file mode 100644 index 000000000..38b93f2ca --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/events/GameTutorialStartEvent.java @@ -0,0 +1,32 @@ +package nautilus.game.arcade.gametutorial.events; + +import nautilus.game.arcade.gametutorial.GameTutorial; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class GameTutorialStartEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + private GameTutorial _tutorial; + + public GameTutorialStartEvent(GameTutorial tutorial) + { + _tutorial = tutorial; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + + public GameTutorial getTutorial() + { + return _tutorial; + } +} 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 21d8c6501..e720636be 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 @@ -35,6 +35,7 @@ import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.uhc.UHC; +import nautilus.game.arcade.gametutorial.GameTutorial; import org.bukkit.ChatColor; import org.bukkit.Color; @@ -131,6 +132,35 @@ public class GameManager implements Listener return; Game game = Manager.GetGame(); + + boolean tutorialSet = false; + for(GameTeam team : game.GetTeamList()) + { + if(team.getTutorial() != null) + tutorialSet = true; + } + if(!tutorialSet) + { + game.addTutorials(); + } + if(game.EnableTutorials) + { + for(GameTeam team : game.GetTeamList()) + { + if(team.getTutorial() != null) + { + if(!team.getTutorial().hasStarted()) + { + team.getTutorial().setTeam(team); + team.getTutorial().start(); + } + if(!team.getTutorial().hasEnded()) + { + return; + } + } + } + } double percentage = (double) (System.currentTimeMillis() - game.GetStateTime()) / game.PrepareTime; @@ -138,6 +168,36 @@ public class GameManager implements Listener UtilTextBottom.displayProgress("Game Start", percentage, UtilTime.MakeStr(Math.max(0, game.PrepareTime - (System.currentTimeMillis() - game.GetStateTime()))), player); } + + @EventHandler + public void updateGameTutorials(UpdateEvent event) + { + if(event.getType() != UpdateType.TICK) + return; + + Game game = Manager.GetGame(); + + if(game == null) + return; + + if(game.GetState() != GameState.Prepare) + return; + + + if(game.EnableTutorials) + { + for(GameTeam team : game.GetTeamList()) + { + if(team.getTutorial() != null) + { + if(!team.getTutorial().hasEnded() && team.getTutorial().hasStarted()) + { + team.getTutorial().onTick(team.getTutorial().tick()); + } + } + } + } + } @EventHandler public void StateUpdate(UpdateEvent event) @@ -185,6 +245,19 @@ public class GameManager implements Listener } else if (game.GetState() == GameState.Prepare) { + if(game.EnableTutorials) + { + for(GameTeam team : game.GetTeamList()) + { + if(team.getTutorial() != null) + { + if(!team.getTutorial().hasEnded()) + { + return; + } + } + } + } if (game.CanStartPrepareCountdown()) { if (UtilTime.elapsed(game.GetStateTime(), game.PrepareTime)) From 6a29d2a2d6a2ee91bb920aa3e712e496da37dd57 Mon Sep 17 00:00:00 2001 From: Sarah Date: Sat, 21 Nov 2015 17:01:17 +0100 Subject: [PATCH 02/58] adding some getters. --- .../arcade/gametutorial/GameTutorial.java | 6 +++- .../arcade/gametutorial/TutorialPhase.java | 30 ++++++++++++------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java index 65d129eb3..38118c99c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java @@ -1,6 +1,5 @@ package nautilus.game.arcade.gametutorial; -import java.util.ArrayList; import java.util.HashMap; import mineplex.core.common.util.UtilServer; @@ -151,6 +150,11 @@ public abstract class GameTutorial return _players; } + public GameTeam getTeam() + { + return _team; + } + public void onTick(int tick){} public void onStart(){} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java index f64c9aed3..1082fe6db 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java @@ -25,16 +25,6 @@ public abstract class TutorialPhase _text = text; } - public TutorialText[] getText() - { - return _text; - } - - public Location getLocation() - { - return _location; - } - final public void start() { _hasEnded = false; @@ -169,6 +159,16 @@ public abstract class TutorialPhase return null; } + public TutorialText[] getText() + { + return _text; + } + + public Location getLocation() + { + return _location; + } + public void setTutorial(GameTutorial tutorial) { _tutorial = tutorial; @@ -184,6 +184,16 @@ public abstract class TutorialPhase _target = target; } + public GameTutorial getTutorial() + { + return _tutorial; + } + + public Location getTarget() + { + return _target; + } + public void onStart(){} public void onMessageDisplay(TutorialText text){} From cba5aef9f1ffa922c995bbcb855ed2ec45dec085 Mon Sep 17 00:00:00 2001 From: Sarah Date: Sat, 21 Nov 2015 18:18:13 +0100 Subject: [PATCH 03/58] small fix --- .../src/nautilus/game/arcade/managers/GameManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 e720636be..8618525f4 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 @@ -143,6 +143,7 @@ public class GameManager implements Listener { game.addTutorials(); } + boolean finished = true; if(game.EnableTutorials) { for(GameTeam team : game.GetTeamList()) @@ -156,10 +157,12 @@ public class GameManager implements Listener } if(!team.getTutorial().hasEnded()) { - return; + finished = false; } } } + if(!finished) + return; } double percentage = (double) (System.currentTimeMillis() - game.GetStateTime()) / game.PrepareTime; From 66598ce97e7f91e542d665536d526548f4a0a78b Mon Sep 17 00:00:00 2001 From: Sarah Date: Mon, 23 Nov 2015 16:16:33 +0100 Subject: [PATCH 04/58] adding teleport flag. --- .../arcade/gametutorial/GameTutorial.java | 22 ++++------ .../arcade/gametutorial/TutorialPhase.java | 4 +- .../game/arcade/managers/GameManager.java | 43 ++++++++++--------- 3 files changed, 33 insertions(+), 36 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java index 38118c99c..d90a83e6a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java @@ -28,6 +28,8 @@ public abstract class GameTutorial private int _tick; + public boolean TeleportOnEnd = true; + public GameTutorial(ArcadeManager manager, TutorialPhase[] phases) { Manager = manager; @@ -75,20 +77,14 @@ public abstract class GameTutorial private void endTutorial() { - Manager.runSync(new Runnable() + for(Player player : _players.keySet()) { - @Override - public void run() - { - for(Player player : _players.keySet()) - { - VisibilityManager.Instance.setVisibility(player, true, UtilServer.getPlayers()); - player.setAllowFlight(false); - player.setFlying(false); - player.teleport(_players.get(player)); - } - } - }); + VisibilityManager.Instance.setVisibility(player, true, UtilServer.getPlayers()); + player.setAllowFlight(false); + player.setFlying(false); + if(TeleportOnEnd) + _team.SpawnTeleport(); + } Manager.GetChat().Silence((System.currentTimeMillis() - Manager.GetGame().GetStateTime()) + 5000, false); Manager.GetGame().PrepareTime = (System.currentTimeMillis() - Manager.GetGame().GetStateTime()) + 5000; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java index 1082fe6db..d10bd6427 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java @@ -98,8 +98,8 @@ public abstract class TutorialPhase public void run() { _hasEnded = true; - _tutorial.nextPhase(); - onEnd(); + onEnd(); + _tutorial.nextPhase(); } }); break; 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 8618525f4..39c84e3d0 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 @@ -122,14 +122,10 @@ public class GameManager implements Listener } } - @EventHandler - public void DisplayPrepareTime(UpdateEvent event) + public boolean isInTutorial() { - if (event.getType() != UpdateType.TICK) - return; - if (Manager.GetGame() == null || Manager.GetGame().GetState() != GameState.Prepare) - return; + return false; Game game = Manager.GetGame(); @@ -162,8 +158,24 @@ public class GameManager implements Listener } } if(!finished) - return; + return true; } + return false; + } + + @EventHandler + public void DisplayPrepareTime(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (Manager.GetGame() == null || Manager.GetGame().GetState() != GameState.Prepare) + return; + + Game game = Manager.GetGame(); + + if(isInTutorial()) + return; double percentage = (double) (System.currentTimeMillis() - game.GetStateTime()) / game.PrepareTime; @@ -186,7 +198,6 @@ public class GameManager implements Listener if(game.GetState() != GameState.Prepare) return; - if(game.EnableTutorials) { for(GameTeam team : game.GetTeamList()) @@ -248,19 +259,9 @@ public class GameManager implements Listener } else if (game.GetState() == GameState.Prepare) { - if(game.EnableTutorials) - { - for(GameTeam team : game.GetTeamList()) - { - if(team.getTutorial() != null) - { - if(!team.getTutorial().hasEnded()) - { - return; - } - } - } - } + if(isInTutorial()) + return; + if (game.CanStartPrepareCountdown()) { if (UtilTime.elapsed(game.GetStateTime(), game.PrepareTime)) From 95b4ad74e845119b1705869dfd980d51378200c3 Mon Sep 17 00:00:00 2001 From: Sarah Date: Tue, 24 Nov 2015 16:23:03 +0100 Subject: [PATCH 05/58] fixed silencing and adding possibilty to change text. --- .../src/nautilus/game/arcade/gametutorial/GameTutorial.java | 4 ++-- .../src/nautilus/game/arcade/gametutorial/TutorialPhase.java | 2 +- .../src/nautilus/game/arcade/gametutorial/TutorialText.java | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java index d90a83e6a..35f58dd0a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java @@ -64,7 +64,7 @@ public abstract class GameTutorial } else { - Manager.GetChat().Silence((System.currentTimeMillis() - Manager.GetGame().GetStateTime()) + 7000, false); + Manager.GetChat().Silence(7000, false); onPhaseChange(_currentPhase); _currentPhase.start(); } @@ -85,7 +85,7 @@ public abstract class GameTutorial if(TeleportOnEnd) _team.SpawnTeleport(); } - Manager.GetChat().Silence((System.currentTimeMillis() - Manager.GetGame().GetStateTime()) + 5000, false); + Manager.GetChat().Silence(5000, false); Manager.GetGame().PrepareTime = (System.currentTimeMillis() - Manager.GetGame().GetStateTime()) + 5000; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java index d10bd6427..65c4f4e4b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java @@ -113,8 +113,8 @@ public abstract class TutorialPhase players[i] = player; i++; } - UtilTextMiddle.display("", text.getText(), 0, text.getStayTime(), 0, players); displayMessage(text); + UtilTextMiddle.display("", text.getText(), 0, text.getStayTime(), 0, players); try { Thread.sleep(text.getStayTime() * 50); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java index dd278faec..03729af65 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java @@ -35,4 +35,9 @@ public class TutorialText return _stayTime; } + public void setText(String text) + { + _text = text; + } + } From 809faf3098ce463c025cde1f88beec9015f08d9b Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 26 Nov 2015 00:14:15 +0100 Subject: [PATCH 06/58] changing teleport mechanic. --- .../src/nautilus/game/arcade/managers/GameManager.java | 5 +++++ 1 file changed, 5 insertions(+) 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 39c84e3d0..43759a930 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 @@ -142,6 +142,11 @@ public class GameManager implements Listener boolean finished = true; if(game.EnableTutorials) { + for(Player player : UtilServer.getPlayers()) + { + if(player.getWorld() == Manager.GetLobby().GetSpawn().getWorld()) + return true; + } for(GameTeam team : game.GetTeamList()) { if(team.getTutorial() != null) From eddbde5ebdd9e454db393993e3c25c9cfdd26fc4 Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 26 Nov 2015 16:06:15 +0100 Subject: [PATCH 07/58] Changing length formula. --- .../src/nautilus/game/arcade/gametutorial/TutorialText.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java index 03729af65..9abdf6c9b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java @@ -17,7 +17,7 @@ public class TutorialText public TutorialText(String text, int id) { - this(text, text.length() + 20, id); + this(text, (int) (Math.round(1.5 * text.length()) + 25), id); } public String getText() From a653f053a5bb11b67473579bb6fe07a76ad3d2ba Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 26 Nov 2015 16:12:13 +0100 Subject: [PATCH 08/58] Adding 2 Seconds delay. --- .../nautilus/game/arcade/gametutorial/GameTutorial.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java index 35f58dd0a..a4f0e170a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java @@ -49,7 +49,14 @@ public abstract class GameTutorial Manager.getPluginManager().callEvent(new GameTutorialStartEvent(this)); onStart(); preparePlayers(); - nextPhase(); + Manager.runSyncLater(new Runnable() + { + @Override + public void run() + { + nextPhase(); + } + }, 40); } protected void nextPhase() From 21f859f57907cf73d734e6503236a29e8574b23f Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 26 Nov 2015 16:26:49 +0100 Subject: [PATCH 09/58] fixing 2 seconds delay. --- .../game/arcade/gametutorial/GameTutorial.java | 9 +++++---- .../game/arcade/gametutorial/TutorialPhase.java | 14 +++++++++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java index a4f0e170a..5f425ba55 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java @@ -53,13 +53,14 @@ public abstract class GameTutorial { @Override public void run() - { - nextPhase(); + { + nextPhase(true); } }, 40); + _currentPhase.teleport(); } - protected void nextPhase() + protected void nextPhase(boolean phaseOne) { _currentPhase = getNextPhase(); if(_currentPhase == null) @@ -73,7 +74,7 @@ public abstract class GameTutorial { Manager.GetChat().Silence(7000, false); onPhaseChange(_currentPhase); - _currentPhase.start(); + _currentPhase.start(phaseOne); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java index 65c4f4e4b..ed16a0e20 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java @@ -25,16 +25,24 @@ public abstract class TutorialPhase _text = text; } - final public void start() + final public void start(boolean phaseOne) { _hasEnded = false; onStart(); + if(!phaseOne) + { + teleport(); + } + displayText(); + } + + final public void teleport() + { if(_location != null && _target != null) { prepareLocations(); updatePlayers(); } - displayText(); } private void prepareLocations() @@ -99,7 +107,7 @@ public abstract class TutorialPhase { _hasEnded = true; onEnd(); - _tutorial.nextPhase(); + _tutorial.nextPhase(false); } }); break; From c74732af39afd11c6425eb1a5d1b2cf332431410 Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 26 Nov 2015 16:37:18 +0100 Subject: [PATCH 10/58] One more fix. --- .../src/nautilus/game/arcade/gametutorial/GameTutorial.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java index 5f425ba55..c591220e1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java @@ -49,6 +49,7 @@ public abstract class GameTutorial Manager.getPluginManager().callEvent(new GameTutorialStartEvent(this)); onStart(); preparePlayers(); + _currentPhase = getNextPhase(); Manager.runSyncLater(new Runnable() { @Override @@ -62,7 +63,9 @@ public abstract class GameTutorial protected void nextPhase(boolean phaseOne) { - _currentPhase = getNextPhase(); + if(!phaseOne) + _currentPhase = getNextPhase(); + if(_currentPhase == null) { onEnd(); From fd0c5cf27367d3454352e63c0ad6ad6114418c7f Mon Sep 17 00:00:00 2001 From: Sarah Date: Fri, 27 Nov 2015 20:47:57 +0100 Subject: [PATCH 11/58] Adding some more flags. --- .../nautilus/game/arcade/gametutorial/GameTutorial.java | 9 ++++++--- .../nautilus/game/arcade/gametutorial/TutorialPhase.java | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java index c591220e1..dc157fa3e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java @@ -27,8 +27,11 @@ public abstract class GameTutorial private boolean _hasStarted; private int _tick; - + + public boolean SetTutorialPositions = true; public boolean TeleportOnEnd = true; + + public long StartAfterTutorial = 5000; public GameTutorial(ArcadeManager manager, TutorialPhase[] phases) { @@ -96,8 +99,8 @@ public abstract class GameTutorial if(TeleportOnEnd) _team.SpawnTeleport(); } - Manager.GetChat().Silence(5000, false); - Manager.GetGame().PrepareTime = (System.currentTimeMillis() - Manager.GetGame().GetStateTime()) + 5000; + Manager.GetChat().Silence(StartAfterTutorial, false); + Manager.GetGame().PrepareTime = (System.currentTimeMillis() - Manager.GetGame().GetStateTime()) + StartAfterTutorial; } protected TutorialPhase getNextPhase() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java index ed16a0e20..76445fe42 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java @@ -38,6 +38,9 @@ public abstract class TutorialPhase final public void teleport() { + if(!getTutorial().SetTutorialPositions) + return; + if(_location != null && _target != null) { prepareLocations(); From ad54d28b0d42d035bf7cc6310af0c9048aaa3382 Mon Sep 17 00:00:00 2001 From: Sarah Date: Fri, 27 Nov 2015 22:29:29 +0100 Subject: [PATCH 12/58] fixing teleportation issues. --- .../game/arcade/gametutorial/GameTutorial.java | 13 +++++++++++-- .../game/arcade/gametutorial/TutorialPhase.java | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java index dc157fa3e..770898720 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java @@ -72,8 +72,8 @@ public abstract class GameTutorial if(_currentPhase == null) { onEnd(); - endTutorial(); _hasEnded = true; + endTutorial(); Manager.getPluginManager().callEvent(new GameTutorialEndEvent(this)); } else @@ -97,7 +97,16 @@ public abstract class GameTutorial player.setAllowFlight(false); player.setFlying(false); if(TeleportOnEnd) - _team.SpawnTeleport(); + { + Manager.runSyncLater(new Runnable() + { + @Override + public void run() + { + _team.SpawnTeleport(); + } + }, 5); + } } Manager.GetChat().Silence(StartAfterTutorial, false); Manager.GetGame().PrepareTime = (System.currentTimeMillis() - Manager.GetGame().GetStateTime()) + StartAfterTutorial; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java index 76445fe42..18b1b513b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java @@ -64,7 +64,7 @@ public abstract class TutorialPhase @Override public void run() { - while(!_hasEnded) + while(!_hasEnded && !getTutorial().hasEnded()) { _tutorial.Manager.runSync(new Runnable() { From 66fd85af1f237b0b146491bfa9e5df67ff954667 Mon Sep 17 00:00:00 2001 From: Sarah Date: Sat, 28 Nov 2015 23:32:09 +0100 Subject: [PATCH 13/58] Adding Phase Event. --- .../arcade/gametutorial/GameTutorial.java | 3 ++ .../events/GameTutorialPhaseEvent.java | 49 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/events/GameTutorialPhaseEvent.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java index 770898720..a6e8f0dc5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java @@ -7,6 +7,7 @@ import mineplex.core.visibility.VisibilityManager; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.gametutorial.events.GameTutorialEndEvent; +import nautilus.game.arcade.gametutorial.events.GameTutorialPhaseEvent; import nautilus.game.arcade.gametutorial.events.GameTutorialStartEvent; import org.bukkit.Location; @@ -66,6 +67,7 @@ public abstract class GameTutorial protected void nextPhase(boolean phaseOne) { + TutorialPhase from = _currentPhase; if(!phaseOne) _currentPhase = getNextPhase(); @@ -80,6 +82,7 @@ public abstract class GameTutorial { Manager.GetChat().Silence(7000, false); onPhaseChange(_currentPhase); + Manager.getPluginManager().callEvent(new GameTutorialPhaseEvent(this, from, _currentPhase)); _currentPhase.start(phaseOne); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/events/GameTutorialPhaseEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/events/GameTutorialPhaseEvent.java new file mode 100644 index 000000000..6d9bbf631 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/events/GameTutorialPhaseEvent.java @@ -0,0 +1,49 @@ +package nautilus.game.arcade.gametutorial.events; + +import nautilus.game.arcade.gametutorial.GameTutorial; +import nautilus.game.arcade.gametutorial.TutorialPhase; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class GameTutorialPhaseEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + private GameTutorial _tutorial; + + private TutorialPhase _from; + private TutorialPhase _to; + + public GameTutorialPhaseEvent(GameTutorial tutorial, TutorialPhase from, TutorialPhase to) + { + _tutorial = tutorial; + _from = from; + _to = to; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + + public GameTutorial getTutorial() + { + return _tutorial; + } + + public TutorialPhase getFrom() + { + return _from; + } + + public TutorialPhase getTo() + { + return _to; + } + +} From dc68375ec8a32d5a47d1434b1846b576eded5381 Mon Sep 17 00:00:00 2001 From: Sarah Date: Sun, 29 Nov 2015 21:48:39 +0100 Subject: [PATCH 14/58] TimeBetweenPhase Flag. --- .../src/nautilus/game/arcade/gametutorial/GameTutorial.java | 1 + .../src/nautilus/game/arcade/gametutorial/TutorialPhase.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java index a6e8f0dc5..edfef5c0d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java @@ -32,6 +32,7 @@ public abstract class GameTutorial public boolean SetTutorialPositions = true; public boolean TeleportOnEnd = true; + public long TimeBetweenPhase = 0; public long StartAfterTutorial = 5000; public GameTutorial(ArcadeManager manager, TutorialPhase[] phases) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java index 18b1b513b..5b1eab19c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java @@ -103,7 +103,7 @@ public abstract class TutorialPhase TutorialText text = getNextMessage(); if(text == null) { - _tutorial.Manager.runSync(new Runnable() + _tutorial.Manager.runSyncLater(new Runnable() { @Override public void run() @@ -112,7 +112,7 @@ public abstract class TutorialPhase onEnd(); _tutorial.nextPhase(false); } - }); + }, getTutorial().TimeBetweenPhase); break; } else From e2cfcef55b6f86cd08ae118d39e5c8dde7e1b8c7 Mon Sep 17 00:00:00 2001 From: Sarah Date: Mon, 30 Nov 2015 16:58:41 +0100 Subject: [PATCH 15/58] RunTasksSync Flag. --- .../arcade/gametutorial/GameTutorial.java | 3 ++- .../arcade/gametutorial/TutorialPhase.java | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java index edfef5c0d..7809a561e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java @@ -31,7 +31,8 @@ public abstract class GameTutorial public boolean SetTutorialPositions = true; public boolean TeleportOnEnd = true; - + public boolean RunTasksSync = true; + public long TimeBetweenPhase = 0; public long StartAfterTutorial = 5000; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java index 5b1eab19c..978a75928 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java @@ -142,14 +142,21 @@ public abstract class TutorialPhase private void displayMessage(final TutorialText text) { - _tutorial.Manager.runSync(new Runnable() + if(_tutorial.RunTasksSync) { - @Override - public void run() + _tutorial.Manager.runSync(new Runnable() { - onMessageDisplay(text); - } - }); + @Override + public void run() + { + onMessageDisplay(text); + } + }); + } + else + { + onMessageDisplay(text); + } } protected TutorialText getNextMessage() From 27f335779abb3399504d5ba006ae232ef2db9d96 Mon Sep 17 00:00:00 2001 From: Sarah Date: Wed, 2 Dec 2015 19:39:44 +0100 Subject: [PATCH 16/58] adding tutorial sounds and flag for it. --- .../arcade/gametutorial/GameTutorial.java | 1 + .../arcade/gametutorial/TutorialPhase.java | 6 +++++ .../arcade/gametutorial/TutorialText.java | 23 +++++++++++++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java index 7809a561e..151cbf02f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java @@ -32,6 +32,7 @@ public abstract class GameTutorial public boolean SetTutorialPositions = true; public boolean TeleportOnEnd = true; public boolean RunTasksSync = true; + public boolean PlayTutorialSounds = false; public long TimeBetweenPhase = 0; public long StartAfterTutorial = 5000; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java index 978a75928..f6858e2d2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java @@ -4,6 +4,7 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilTextMiddle; import org.bukkit.Location; +import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.util.Vector; @@ -121,6 +122,11 @@ public abstract class TutorialPhase int i = 0; for(Player player : _tutorial.getPlayers().keySet()) { + if(_tutorial.PlayTutorialSounds) + { + if(text.getSound() != null) + player.playSound(player.getLocation(), text.getSound(), 2f, 2f); + } players[i] = player; i++; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java index 9abdf6c9b..dba1d39a6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java @@ -1,5 +1,7 @@ package nautilus.game.arcade.gametutorial; +import org.bukkit.Sound; + public class TutorialText { @@ -7,17 +9,29 @@ public class TutorialText private String _text; private int _stayTime; private int _id; + private Sound _sound; - public TutorialText(String text, int stayTime, int id) + public TutorialText(String text, int stayTime, int id, Sound sound) { _text = text; _id = id; _stayTime = stayTime; + _sound = sound; } public TutorialText(String text, int id) { - this(text, (int) (Math.round(1.5 * text.length()) + 25), id); + this(text, (int) (Math.round(1.5 * text.length()) + 25), id, Sound.NOTE_PLING); + } + + public TutorialText(String text, int id, Sound sound) + { + this(text, (int) (Math.round(1.5 * text.length()) + 25), id, sound); + } + + public TutorialText(String text, int stayTime, int id) + { + this(text, stayTime, id, Sound.NOTE_PLING); } public String getText() @@ -30,6 +44,11 @@ public class TutorialText return _id; } + public Sound getSound() + { + return _sound; + } + public int getStayTime() { return _stayTime; From 19254fc4a02a5947038e458933676a57d595df45 Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 3 Dec 2015 18:06:27 +0100 Subject: [PATCH 17/58] Prepare Timer flag. --- .../game/arcade/gametutorial/GameTutorial.java | 1 + .../nautilus/game/arcade/managers/GameManager.java | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java index 151cbf02f..2583a1f65 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java @@ -33,6 +33,7 @@ public abstract class GameTutorial public boolean TeleportOnEnd = true; public boolean RunTasksSync = true; public boolean PlayTutorialSounds = false; + public boolean ShowPrepareTimer = false; public long TimeBetweenPhase = 0; public long StartAfterTutorial = 5000; 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 43759a930..9c60cc850 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 @@ -122,7 +122,7 @@ public class GameManager implements Listener } } - public boolean isInTutorial() + public boolean isInTutorial(boolean checkForTimer) { if (Manager.GetGame() == null || Manager.GetGame().GetState() != GameState.Prepare) return false; @@ -160,6 +160,13 @@ public class GameManager implements Listener { finished = false; } + if(checkForTimer) + { + if(team.getTutorial().ShowPrepareTimer) + finished = false; + else + finished = true; + } } } if(!finished) @@ -179,7 +186,7 @@ public class GameManager implements Listener Game game = Manager.GetGame(); - if(isInTutorial()) + if(isInTutorial(true)) return; double percentage = (double) (System.currentTimeMillis() - game.GetStateTime()) / game.PrepareTime; @@ -264,7 +271,7 @@ public class GameManager implements Listener } else if (game.GetState() == GameState.Prepare) { - if(isInTutorial()) + if(isInTutorial(false)) return; if (game.CanStartPrepareCountdown()) From 1bb40b21d3cf9a71dd56b4880ef197de95338dfa Mon Sep 17 00:00:00 2001 From: Sarah Date: Fri, 4 Dec 2015 19:49:28 +0100 Subject: [PATCH 18/58] Tutorial/Phase Time. --- .../game/arcade/gametutorial/GameTutorial.java | 13 +++++++++++++ .../game/arcade/gametutorial/TutorialPhase.java | 9 ++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java index 2583a1f65..4a9868134 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java @@ -28,6 +28,8 @@ public abstract class GameTutorial private boolean _hasStarted; private int _tick; + + private long _started; public boolean SetTutorialPositions = true; public boolean TeleportOnEnd = true; @@ -54,6 +56,7 @@ public abstract class GameTutorial Manager.GetGame().PrepareTime = 60000; Manager.GetChat().Silence(60000, false); + _started = System.currentTimeMillis(); Manager.getPluginManager().callEvent(new GameTutorialStartEvent(this)); onStart(); preparePlayers(); @@ -194,4 +197,14 @@ public abstract class GameTutorial _tick++; return _tick; } + + public long getTutorialStart() + { + return _started; + } + + public long getPhaseTime() + { + return _currentPhase.getPhaseTime(); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java index f6858e2d2..d583f5014 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java @@ -4,7 +4,6 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilTextMiddle; import org.bukkit.Location; -import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.util.Vector; @@ -19,6 +18,8 @@ public abstract class TutorialPhase private Location _target; private boolean _hasEnded; + private long _started; + private TutorialText _currentText; public TutorialPhase(TutorialText[] text) @@ -29,6 +30,7 @@ public abstract class TutorialPhase final public void start(boolean phaseOne) { _hasEnded = false; + _started = System.currentTimeMillis(); onStart(); if(!phaseOne) { @@ -218,6 +220,11 @@ public abstract class TutorialPhase return _target; } + public long getPhaseTime() + { + return _started; + } + public void onStart(){} public void onMessageDisplay(TutorialText text){} From 35534afd4a02270e49e9031835e420ba1dda238f Mon Sep 17 00:00:00 2001 From: Sarah Date: Fri, 4 Dec 2015 19:54:02 +0100 Subject: [PATCH 19/58] overall runtime. --- .../src/nautilus/game/arcade/gametutorial/GameTutorial.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java index 4a9868134..ac63bc328 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java @@ -203,6 +203,11 @@ public abstract class GameTutorial return _started; } + public long getRunning() + { + return System.currentTimeMillis() - _started; + } + public long getPhaseTime() { return _currentPhase.getPhaseTime(); From 64f8ee728006f1cf4ec56a4fee64de49d2c7a39c Mon Sep 17 00:00:00 2001 From: Sarah Date: Sun, 6 Dec 2015 21:48:21 +0100 Subject: [PATCH 20/58] fixing some timings. --- .../arcade/gametutorial/GameTutorial.java | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java index ac63bc328..fd28fe9de 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java @@ -83,11 +83,19 @@ public abstract class GameTutorial onEnd(); _hasEnded = true; endTutorial(); - Manager.getPluginManager().callEvent(new GameTutorialEndEvent(this)); + final GameTutorial tutorial = this; + Manager.runSyncLater(new Runnable() + { + @Override + public void run() + { + Manager.getPluginManager().callEvent(new GameTutorialEndEvent(tutorial)); + } + }, 5); } else { - Manager.GetChat().Silence(7000, false); + Manager.GetChat().Silence(70000, false); onPhaseChange(_currentPhase); Manager.getPluginManager().callEvent(new GameTutorialPhaseEvent(this, from, _currentPhase)); _currentPhase.start(phaseOne); @@ -101,11 +109,18 @@ public abstract class GameTutorial private void endTutorial() { - for(Player player : _players.keySet()) + for(final Player player : _players.keySet()) { VisibilityManager.Instance.setVisibility(player, true, UtilServer.getPlayers()); - player.setAllowFlight(false); - player.setFlying(false); + Manager.runSyncLater(new Runnable() + { + @Override + public void run() + { + player.setAllowFlight(false); + player.setFlying(false); + } + }, 5); if(TeleportOnEnd) { Manager.runSyncLater(new Runnable() From 10d26ca32ba58e8493f12c84b3fb00a98147c323 Mon Sep 17 00:00:00 2001 From: Sarah Date: Sun, 6 Dec 2015 22:41:04 +0100 Subject: [PATCH 21/58] timer fixes. --- .../game/arcade/gametutorial/GameTutorial.java | 7 ++++++- .../game/arcade/managers/GameManager.java | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java index fd28fe9de..5a0207e30 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java @@ -54,7 +54,7 @@ public abstract class GameTutorial for(TutorialPhase phase : _phases) phase.setTutorial(this); - Manager.GetGame().PrepareTime = 60000; + //Manager.GetGame().PrepareTime = 60000; Manager.GetChat().Silence(60000, false); _started = System.currentTimeMillis(); Manager.getPluginManager().callEvent(new GameTutorialStartEvent(this)); @@ -213,6 +213,11 @@ public abstract class GameTutorial return _tick; } + public TutorialPhase[] getPhases() + { + return _phases; + } + public long getTutorialStart() { return _started; 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 9c60cc850..a4fac6a32 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 @@ -36,6 +36,8 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.games.uhc.UHC; import nautilus.game.arcade.gametutorial.GameTutorial; +import nautilus.game.arcade.gametutorial.TutorialPhase; +import nautilus.game.arcade.gametutorial.TutorialText; import org.bukkit.ChatColor; import org.bukkit.Color; @@ -147,14 +149,25 @@ public class GameManager implements Listener if(player.getWorld() == Manager.GetLobby().GetSpawn().getWorld()) return true; } + long prepTime = 0; for(GameTeam team : game.GetTeamList()) { + long timeUsage = 0; if(team.getTutorial() != null) { if(!team.getTutorial().hasStarted()) { team.getTutorial().setTeam(team); team.getTutorial().start(); + timeUsage = team.getTutorial().StartAfterTutorial; + timeUsage = timeUsage + (team.getTutorial().TimeBetweenPhase * team.getTutorial().getPhases().length); + for(TutorialPhase phase : team.getTutorial().getPhases()) + { + for(TutorialText text : phase.getText()) + { + timeUsage = timeUsage + (text.getStayTime() * 50); + } + } } if(!team.getTutorial().hasEnded()) { @@ -168,7 +181,12 @@ public class GameManager implements Listener finished = true; } } + if(prepTime <= timeUsage) + prepTime = timeUsage; } + if(prepTime > 0) + Manager.GetGame().PrepareTime = prepTime; + if(!finished) return true; } From 072856be7ddb64cf3951b41b5b5c22cb307e553e Mon Sep 17 00:00:00 2001 From: Sarah Date: Sun, 6 Dec 2015 23:19:53 +0100 Subject: [PATCH 22/58] teleportations. --- .../game/arcade/gametutorial/TutorialPhase.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java index d583f5014..b140b79bc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java @@ -74,12 +74,15 @@ public abstract class TutorialPhase @Override public void run() { - for(Player player : _tutorial.getPlayers().keySet()) + if(!_hasEnded && !getTutorial().hasEnded()) { - player.setAllowFlight(true); - player.setFlying(true); - player.teleport(_location); - } + for(Player player : _tutorial.getPlayers().keySet()) + { + player.setAllowFlight(true); + player.setFlying(true); + player.teleport(_location); + } + } } }); try From 0619fb857f03e7382af02975b659ee5b6653236b Mon Sep 17 00:00:00 2001 From: Sarah Date: Mon, 7 Dec 2015 23:44:02 +0100 Subject: [PATCH 23/58] fixing invisibility. --- .../arcade/gametutorial/GameTutorial.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java index 5a0207e30..fc4457377 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java @@ -111,12 +111,19 @@ public abstract class GameTutorial { for(final Player player : _players.keySet()) { - VisibilityManager.Instance.setVisibility(player, true, UtilServer.getPlayers()); + //VisibilityManager.Instance.setVisibility(player, true, UtilServer.getPlayers()); Manager.runSyncLater(new Runnable() { @Override public void run() { + for(Player player : Manager.GetGame().GetPlayers(true)) + { + for(Player other : Manager.GetGame().GetPlayers(true)) + { + player.showPlayer(other); + } + } player.setAllowFlight(false); player.setFlying(false); } @@ -163,7 +170,7 @@ public abstract class GameTutorial _players.put(player, Manager.GetGame().GetTeam(player).GetSpawns().get(i)); player.setAllowFlight(true); player.setFlying(true); - VisibilityManager.Instance.setVisibility(player, false, UtilServer.getPlayers()); + // VisibilityManager.Instance.setVisibility(player, false, UtilServer.getPlayers()); i++; } } @@ -209,6 +216,16 @@ public abstract class GameTutorial public int tick() { + if(!_hasEnded && hasStarted()) + { + for(Player player : UtilServer.getPlayers()) + { + for(Player other : _players.keySet()) + { + player.hidePlayer(other); + } + } + } _tick++; return _tick; } From 55f04538979461a1f8a54f2e603db254e565f5d1 Mon Sep 17 00:00:00 2001 From: William Burns Date: Mon, 7 Dec 2015 23:20:03 +0000 Subject: [PATCH 24/58] Start of re-write --- .../src/mineplex/core/game/GameDisplay.java | 2 + .../src/nautilus/game/arcade/GameType.java | 2 + .../game/games/gladiators/ArenaType.java | 243 ++++++++++++++++++ .../game/games/gladiators/Gladiators.java | 28 ++ .../arcade/game/games/gladiators/Loadout.java | 22 ++ .../games/gladiators/kits/KitGladiator.java | 38 +++ 6 files changed, 335 insertions(+) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/ArenaType.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Loadout.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/kits/KitGladiator.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index 6c43e8729..ebdc89a02 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -72,6 +72,8 @@ public enum GameDisplay BouncyBalls("Bouncy Balls", Material.SLIME_BALL, (byte)0, GameCategory.ARCADE, 57), + Gladiators("Gladiators", Material.IRON_SWORD, (byte)0, GameCategory.ARCADE, 58), + Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999); String _name; 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 5eedb306e..5ff9e576c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -26,6 +26,7 @@ import nautilus.game.arcade.game.games.dragons.DragonsTeams; import nautilus.game.arcade.game.games.draw.Draw; import nautilus.game.arcade.game.games.event.EventGame; import nautilus.game.arcade.game.games.evolution.Evolution; +import nautilus.game.arcade.game.games.gladiators.Gladiators; import nautilus.game.arcade.game.games.gravity.Gravity; import nautilus.game.arcade.game.games.halloween.Halloween; import nautilus.game.arcade.game.games.hideseek.HideSeek; @@ -128,6 +129,7 @@ public enum GameType SkywarsTeams(TeamSkywars.class, GameDisplay.SkywarsTeams, new GameType[]{GameType.Skywars}, false), MonsterMaze(MonsterMaze.class, GameDisplay.MonsterMaze), MonsterLeague(MonsterLeague.class, GameDisplay.MonsterLeague), + Gladiators(Gladiators.class, GameDisplay.Gladiators), BouncyBalls(BouncyBalls.class, GameDisplay.BouncyBalls), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/ArenaType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/ArenaType.java new file mode 100644 index 000000000..73506445e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/ArenaType.java @@ -0,0 +1,243 @@ +package nautilus.game.arcade.game.games.gladiators; + +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +/** + * Created by William (WilliamTiger). + * 07/12/15 + */ +public enum ArenaType +{ + + RED(1, new Loadout() + { + @Override + public ItemStack getSword() + { + return new ItemStack(Material.DIAMOND_SWORD, 1); + } + + @Override + public ItemStack getRod() + { + return new ItemStack(Material.FISHING_ROD, 1); + } + + @Override + public ItemStack getBow() + { + return new ItemStack(Material.BOW, 1); + } + + @Override + public ItemStack getArrows() + { + return new ItemStack(Material.ARROW, 10); + } + + @Override + public ItemStack getHelmet() + { + return new ItemStack(Material.IRON_HELMET, 1); + } + + @Override + public ItemStack getChestplate() + { + return new ItemStack(Material.IRON_CHESTPLATE, 1); + } + + @Override + public ItemStack getLeggings() + { + return new ItemStack(Material.IRON_LEGGINGS, 1); + } + + @Override + public ItemStack getBoots() + { + return new ItemStack(Material.IRON_BOOTS, 1); + } + }), + ORANGE(2, new Loadout() + { + @Override + public ItemStack getSword() + { + return new ItemStack(Material.IRON_SWORD, 1); + } + + @Override + public ItemStack getRod() + { + return new ItemStack(Material.FISHING_ROD, 1); + } + + @Override + public ItemStack getBow() + { + return new ItemStack(Material.BOW, 1); + } + + @Override + public ItemStack getArrows() + { + return new ItemStack(Material.ARROW, 7); + } + + @Override + public ItemStack getHelmet() + { + return new ItemStack(Material.CHAINMAIL_HELMET); + } + + @Override + public ItemStack getChestplate() + { + return new ItemStack(Material.CHAINMAIL_CHESTPLATE, 1); + } + + @Override + public ItemStack getLeggings() + { + return new ItemStack(Material.CHAINMAIL_LEGGINGS, 1); + } + + @Override + public ItemStack getBoots() + { + return new ItemStack(Material.CHAINMAIL_BOOTS, 1); + } + }), + YELLOW(4, new Loadout() + { + @Override + public ItemStack getSword() + { + return new ItemStack(Material.STONE_SWORD, 1); + } + + @Override + public ItemStack getRod() + { + return new ItemStack(Material.FISHING_ROD, 1); + } + + @Override + public ItemStack getBow() + { + return new ItemStack(Material.BOW, 1); + } + + @Override + public ItemStack getArrows() + { + return new ItemStack(Material.ARROW, 5); + } + + @Override + public ItemStack getHelmet() + { + return new ItemStack(Material.GOLD_HELMET, 1); + } + + @Override + public ItemStack getChestplate() + { + return new ItemStack(Material.GOLD_CHESTPLATE, 1); + } + + @Override + public ItemStack getLeggings() + { + return new ItemStack(Material.GOLD_LEGGINGS, 1); + } + + @Override + public ItemStack getBoots() + { + return new ItemStack(Material.GOLD_BOOTS, 1); + } + }), + GREEN(8, new Loadout() + { + @Override + public ItemStack getSword() + { + return new ItemStack(Material.WOOD_SWORD, 1); + } + + @Override + public ItemStack getRod() + { + return new ItemStack(Material.FISHING_ROD, 1); + } + + @Override + public ItemStack getBow() + { + return new ItemStack(Material.BOW, 1); + } + + @Override + public ItemStack getArrows() + { + return new ItemStack(Material.ARROW, 3); + } + + @Override + public ItemStack getHelmet() + { + return new ItemStack(Material.LEATHER_HELMET, 1); + } + + @Override + public ItemStack getChestplate() + { + return new ItemStack(Material.LEATHER_CHESTPLATE, 1); + } + + @Override + public ItemStack getLeggings() + { + return new ItemStack(Material.LEATHER_LEGGINGS, 1); + } + + @Override + public ItemStack getBoots() + { + return new ItemStack(Material.LEATHER_BOOTS, 1); + } + }); + + private int _endsAt; + private Loadout _loadout; + + ArenaType(int endsAt, Loadout loadout) + { + _endsAt = endsAt; + _loadout = loadout; + } + + public Loadout getLoadout() + { + return _loadout; + } + + public int getEndsAt() + { + return _endsAt; + } + + public String getName() + { + return toString().toLowerCase(); + } + + public boolean furtherOut(ArenaType other) + { + return !(compareTo(other) <= 0); + } + +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java new file mode 100644 index 000000000..144b191a7 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -0,0 +1,28 @@ +package nautilus.game.arcade.game.games.gladiators; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.game.SoloGame; +import nautilus.game.arcade.game.games.gladiators.kits.KitGladiator; +import nautilus.game.arcade.kit.Kit; + +/** + * Created by William (WilliamTiger). + * 07/12/15 + */ +public class Gladiators extends SoloGame +{ + public Gladiators(ArcadeManager manager) + { + super(manager, GameType.Gladiators, + new Kit[0], + new String[] + { + "This is a 1v1 tournament!", + "Kill and then run to the next arena!", + "There is only one victor!" + }); + + setKits(new Kit[]{new KitGladiator(manager)}); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Loadout.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Loadout.java new file mode 100644 index 000000000..4d9f23c61 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Loadout.java @@ -0,0 +1,22 @@ +package nautilus.game.arcade.game.games.gladiators; + +import org.bukkit.inventory.ItemStack; + +/** + * Created by William (WilliamTiger). + * 07/12/15 + */ +public interface Loadout +{ + + public ItemStack getSword(); + public ItemStack getRod(); + public ItemStack getBow(); + public ItemStack getArrows(); + + public ItemStack getHelmet(); + public ItemStack getChestplate(); + public ItemStack getLeggings(); + public ItemStack getBoots(); + +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/kits/KitGladiator.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/kits/KitGladiator.java new file mode 100644 index 000000000..1a0df8140 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/kits/KitGladiator.java @@ -0,0 +1,38 @@ +package nautilus.game.arcade.game.games.gladiators.kits; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +/** + * Created by William (WilliamTiger). + * 07/12/15 + */ +public class KitGladiator extends Kit +{ + public KitGladiator(ArcadeManager manager) + { + super(manager, "Gladiator", KitAvailability.Free, + new String[] + { + "At my signal, unleash hell." + }, + new Perk[] + { + + }, + EntityType.ZOMBIE, new ItemStack(Material.IRON_SWORD)); + } + + @Override + public void GiveItems(Player player) + { + //todo: items based on loadout + } +} From e6d995008ef88f114553a5c7b0a914e87e935df4 Mon Sep 17 00:00:00 2001 From: William Burns Date: Tue, 8 Dec 2015 10:44:24 +0000 Subject: [PATCH 25/58] Arenas --- .../arcade/game/games/gladiators/Arena.java | 223 ++++++++++++++++++ .../game/games/gladiators/Gladiators.java | 103 ++++++++ 2 files changed, 326 insertions(+) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java new file mode 100644 index 000000000..026e0ba86 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java @@ -0,0 +1,223 @@ +package nautilus.game.arcade.game.games.gladiators; + +import java.util.ArrayList; +import java.util.HashMap; + +import org.bukkit.Location; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; + +/** + * Created by William (WilliamTiger). + * 07/12/15 + */ +public class Arena +{ + + private Gladiators _host; + private ArenaType _colour; + private Location _mid; + private ArrayList _spawns; + + private Arena _parent; + private Arena[] _childs = new Arena[2]; + private boolean _isUsed; + + private ArrayList _doorBlocks; + private boolean _closedDoor; + + public Arena(Gladiators host, Location mid, ArenaType colour) + { + _host = host; + _mid = mid; + _colour = colour; + _spawns = new ArrayList<>(); + _parent = null; + _isUsed = false; + _doorBlocks = new ArrayList<>(); + _closedDoor = false; + + setupSpawns(); + } + + public Arena getParent() + { + return _parent; + } + + public void setParent(Arena parent) + { + _parent = parent; + } + + public Arena getChildAt(int index) + { + return _childs[index]; + } + + public Arena[] getChilds() + { + return _childs; + } + + public int getCapacity() + { + int cap = _childs.length; + + for(Arena child : _childs) + { + if(child != null) + if(child.isUsed()) cap--; + } + + return cap; + } + + public ArrayList getDoorBlocks() + { + return _doorBlocks; + } + + public void setChild(int index, Arena child) + { + _childs[index] = child; + child.setParent(this); + } + + public void getUsageMap(HashMap used) + { + if(isUsed()) used.put(this, getCapacity()); + + for(Arena child : _childs) + { + if(child != null) child.getUsageMap(used); + } + } + + public boolean areChildrenUsed() + { + for(Arena child : _childs) + { + if(child != null) + if(!child.isUsed()) return false; + } + + return true; + } + + public Arena getUnusedChild() + { + for(Arena child : _childs) + { + if(child != null) + if(!child.isUsed()) return child; + } + + return null; + } + + private void setupSpawns() + { + ArrayList possible = (ArrayList) _host.WorldData.GetDataLocs("BLACK").clone(); + _mid.setY(UtilAlg.findClosest(_mid, possible).getY()); + + _spawns.add(correctFace(UtilAlg.findClosest(_mid, possible))); + possible.remove(_spawns.get(0)); + _spawns.add(correctFace(UtilAlg.findClosest(_mid, possible))); + } + + private Location correctFace(Location l) + { + l.setPitch(UtilAlg.GetPitch(UtilAlg.getTrajectory(l, _mid))); + l.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(l, _mid))); + return l; + } + + public Gladiators getHost() + { + return _host; + } + + public ArenaType getColour() + { + return _colour; + } + + public Location getMid() + { + return _mid; + } + + public ArrayList getSpawns() + { + return _spawns; + } + + public ArrayList capacitySpawns() + { + ArrayList ret = new ArrayList<>(); + + if (getCapacity() == 0) return ret; + if (getCapacity() == 1) + { + ret.add(_spawns.get(0)); + return ret; + } + if (getCapacity() == 2) + { + ret.add(_spawns.get(0)); + ret.add(_spawns.get(1)); + return ret; + } + + return ret; + } + + public ArrayList getPlayers() + { + ArrayList pls = new ArrayList<>(); + + for (Player p : _host.GetPlayers(true)) + { + if (UtilMath.offset(p.getLocation(), _mid) <= 21) + pls.add(p); + } + + return pls; + } + + public int getPlayerCount() + { + ArrayList pls = new ArrayList<>(); + + for (Player p : _host.GetPlayers(true)) + { + if (UtilMath.offset(p.getLocation(), _mid) <= 21) + pls.add(p); + } + + return pls.size(); + } + + public boolean isUsed() + { + return _isUsed; + } + + public void setIsUsed(boolean isUsed) + { + _isUsed = isUsed; + } + + public boolean isClosedDoor() + { + return _closedDoor; + } + + public void setClosedDoor(boolean closedDoor) + { + _closedDoor = closedDoor; + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index 144b191a7..ae5645bad 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -1,5 +1,10 @@ package nautilus.game.arcade.game.games.gladiators; +import java.util.ArrayList; + +import org.bukkit.Location; + +import mineplex.core.common.util.UtilAlg; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.SoloGame; @@ -12,6 +17,10 @@ import nautilus.game.arcade.kit.Kit; */ public class Gladiators extends SoloGame { + + private ArrayList _allArenas; + private ArrayList _gameArenaSet; + public Gladiators(ArcadeManager manager) { super(manager, GameType.Gladiators, @@ -25,4 +34,98 @@ public class Gladiators extends SoloGame setKits(new Kit[]{new KitGladiator(manager)}); } + + @Override + public void ParseData() + { + parseArenas(); + } + + private void parseArenas() + { + _allArenas = new ArrayList<>(); + + for (Location mid : WorldData.GetDataLocs("RED")) + _allArenas.add(new Arena(this, mid, ArenaType.RED)); + + for (Location mid : WorldData.GetDataLocs("ORANGE")) + _allArenas.add(new Arena(this, mid, ArenaType.ORANGE)); + + for (Location mid : WorldData.GetDataLocs("YELLOW")) + _allArenas.add(new Arena(this, mid, ArenaType.YELLOW)); + + for (Location mid : WorldData.GetDataLocs("GREEN")) + _allArenas.add(new Arena(this, mid, ArenaType.GREEN)); + + for (Arena a : _allArenas) + { + if (a.getColour().equals(ArenaType.GREEN)) + continue; + + // Set the children of that arena. + ArrayList possible = (ArrayList) getAllArenaMidsOfType(getPreviousColour(a.getColour())).clone(); + a.setChild(0, getArenaByMid(UtilAlg.findClosest(a.getMid(), possible))); + possible.remove(a.getChildAt(0).getMid()); + a.setChild(1, getArenaByMid(UtilAlg.findClosest(a.getMid(), possible))); + } + } + + private void findGameArenaSet() + { + _gameArenaSet = new ArrayList<>(); + } + + public Arena getArenaByMid(Location mid) + { + for (Arena a : _allArenas) + if (a.getMid().equals(mid)) + return a; + + return null; + } + + public ArrayList getAllArenaMidsOfType(ArenaType type) + { + ArrayList mids = new ArrayList<>(); + + for (Arena a : _allArenas) + if (a.getColour().equals(type)) + mids.add(a.getMid()); + + return mids; + } + + public ArrayList getAllArenaMids() + { + ArrayList mids = new ArrayList<>(); + + for (Arena a : _allArenas) + mids.add(a.getMid()); + + return mids; + } + + public ArenaType getNextColour(ArenaType old) + { + switch (old) + { + case GREEN: return ArenaType.YELLOW; + case YELLOW: return ArenaType.ORANGE; + case ORANGE: return ArenaType.RED; + } + + return null; + } + + public ArenaType getPreviousColour(ArenaType old) + { + switch (old) + { + case RED: return ArenaType.ORANGE; + case ORANGE: return ArenaType.YELLOW; + case YELLOW: return ArenaType.GREEN; + } + + return null; + } } From 2b12016e147f7de79dc6029aa81271a7691c6186 Mon Sep 17 00:00:00 2001 From: William Burns Date: Tue, 8 Dec 2015 13:12:30 +0000 Subject: [PATCH 26/58] Progress --- .../arcade/game/games/gladiators/Arena.java | 13 +- .../game/games/gladiators/Gladiators.java | 208 +++++++++++++++++- .../events/PlayerChangeArenaEvent.java | 53 +++++ .../games/smash/perks/PerkCowAngryHerd.java | 6 +- 4 files changed, 265 insertions(+), 15 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/events/PlayerChangeArenaEvent.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java index 026e0ba86..e2aab1fb8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashMap; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.entity.Player; import mineplex.core.common.util.UtilAlg; @@ -26,7 +27,6 @@ public class Arena private boolean _isUsed; private ArrayList _doorBlocks; - private boolean _closedDoor; public Arena(Gladiators host, Location mid, ArenaType colour) { @@ -37,7 +37,6 @@ public class Arena _parent = null; _isUsed = false; _doorBlocks = new ArrayList<>(); - _closedDoor = false; setupSpawns(); } @@ -211,13 +210,9 @@ public class Arena _isUsed = isUsed; } - public boolean isClosedDoor() + public void closeDoor() { - return _closedDoor; - } - - public void setClosedDoor(boolean closedDoor) - { - _closedDoor = closedDoor; + for (Location loc : _doorBlocks) + loc.getBlock().setType(Material.OBSIDIAN); } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index ae5645bad..a4010e009 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -1,13 +1,23 @@ package nautilus.game.arcade.game.games.gladiators; import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; +import java.util.Queue; import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerMoveEvent; import mineplex.core.common.util.UtilAlg; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.SoloGame; +import nautilus.game.arcade.game.games.gladiators.events.PlayerChangeArenaEvent; import nautilus.game.arcade.game.games.gladiators.kits.KitGladiator; import nautilus.game.arcade.kit.Kit; @@ -21,24 +31,54 @@ public class Gladiators extends SoloGame private ArrayList _allArenas; private ArrayList _gameArenaSet; + private HashMap _playerArenas; + public Gladiators(ArcadeManager manager) { super(manager, GameType.Gladiators, new Kit[0], new String[] - { - "This is a 1v1 tournament!", - "Kill and then run to the next arena!", - "There is only one victor!" - }); + { + "This is a 1v1 tournament!", + "Kill and then run to the next arena!", + "There is only one victor!" + }); + + Damage = true; + DamageFall = false; + DamagePvP = true; + DamageSelf = true; + DamageTeamSelf = true; + HungerSet = 20; setKits(new Kit[]{new KitGladiator(manager)}); + + _playerArenas = new HashMap<>(); } @Override public void ParseData() { parseArenas(); + parseDoors(); + } + + private void parseDoors() + { + for (Location loc : WorldData.GetCustomLocs("129")) + { + ArrayList mids = new ArrayList<>(getAllArenaMids()); + Arena arena1 = getArenaByMid(UtilAlg.findClosest(loc, mids)); + mids.remove(UtilAlg.findClosest(loc, mids)); + Arena arena2 = getArenaByMid(UtilAlg.findClosest(loc, mids)); + + if (arena1.getColour().furtherOut(arena2.getColour())) + arena1.getDoorBlocks().add(loc); + else + arena2.getDoorBlocks().add(loc); + + loc.getBlock().setType(Material.FENCE); + } } private void parseArenas() @@ -73,6 +113,107 @@ public class Gladiators extends SoloGame private void findGameArenaSet() { _gameArenaSet = new ArrayList<>(); + + GetTeamList().get(0).GetSpawns().clear(); // Clear the original game spawns. + + int neededSpawns = Math.min(GetPlayers(true).size(), 16); // Quick fix + Arena masterNode = getArenasOfType(ArenaType.RED).get(0); + + HashMap spawnsPerRoom = new HashMap<>(); + + Queue queue = new LinkedList<>(); + Queue nextQueue = new LinkedList<>(); + queue.add(masterNode); + + int sum; + boolean solved = false; + + while (!queue.isEmpty() && !solved) + { + sum = 0; + ArrayList currentNodes = new ArrayList<>(); + while (!queue.isEmpty()) + { + currentNodes.add(queue.poll()); + } + + for (Arena node : currentNodes) + { + sum += node.getCapacity(); + node.setIsUsed(true); + } + + if (sum >= neededSpawns) + { + solved = true; + } + else + { + for (Arena node : currentNodes) + { + for(int i = 0; i < node.getChilds().length; i++) + { + System.out.println("Adding child of node: " + node.getColour() + "number of childs: " + node.getChilds().length); + nextQueue.add(node.getChildAt(i)); + queue.add(node.getChildAt(i)); + } + } + + while (!nextQueue.isEmpty()) + { + Arena node = nextQueue.poll(); + node.setIsUsed(true); + + System.out.println("Node: " + node.getColour()); + sum = sum + node.getCapacity() - 1; + + /* + if (node.getParent().areChildrenUsed()) + { + node.getParent().setIsUsed(false); + } + */ + + if (sum >= neededSpawns) + { + solved = true; + break; + } + } + } + + if (solved) + { + masterNode.getUsageMap(spawnsPerRoom); + System.out.println("Solution: "); + + for (Map.Entry entry : spawnsPerRoom.entrySet()) + { + System.out.println("Color: " + entry.getKey().getColour() + ", Spawns: " + entry.getValue()); + _gameArenaSet.add(entry.getKey()); + } + } + } + + for (Arena a : _gameArenaSet) + { + if (a.getCapacity() <= 0) + continue; + + for (Location l : a.capacitySpawns()) + GetTeamList().get(0).GetSpawns().add(l); + } + } + + public ArrayList getArenasOfType(ArenaType type) + { + ArrayList arenas = new ArrayList<>(); + + for (Arena a : _allArenas) + if (a.getColour().equals(type)) + arenas.add(a); + + return arenas; } public Arena getArenaByMid(Location mid) @@ -128,4 +269,61 @@ public class Gladiators extends SoloGame return null; } + + @EventHandler + public void setups(GameStateChangeEvent e) + { + if (e.GetState().equals(GameState.Live)) + { + for (Player p : GetPlayers(true)) + { + for (Arena a : _allArenas) + { + if (a.getPlayers().contains(p)) + _playerArenas.put(p, a); + } + } + return; + } + + if (e.GetState() != GameState.Prepare) + return; + + findGameArenaSet(); + } + + @EventHandler + public void arenaMoveCheck(PlayerMoveEvent e){ + if (!GetPlayers(true).contains(e.getPlayer())) + return; + + if (!_playerArenas.containsKey(e.getPlayer())) + return; + + for (Arena a : _allArenas) + { + if (a.getPlayers().contains(e.getPlayer())) + { + if (_playerArenas.get(e.getPlayer()) != a) + { + Manager.getPluginManager().callEvent(new PlayerChangeArenaEvent(e.getPlayer(), + a, _playerArenas.get(e.getPlayer()))); + + _playerArenas.put(e.getPlayer(), a); + } + } + } + } + + @EventHandler + public void arenaChange(PlayerChangeArenaEvent e) + { + Player p = e.getPlayer(); + Arena old = e.getFrom(); + Arena current = e.getTo(); + + old.closeDoor(); + + p.sendMessage("§7§lDEBUG: §3You left §b" + old.getColour().toString() + " §3and entered §b" + current.getColour().toString() + "§3."); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/events/PlayerChangeArenaEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/events/PlayerChangeArenaEvent.java new file mode 100644 index 000000000..c948b3d90 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/events/PlayerChangeArenaEvent.java @@ -0,0 +1,53 @@ +package nautilus.game.arcade.game.games.gladiators.events; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import nautilus.game.arcade.game.games.gladiators.Arena; + +/** + * Created by William (WilliamTiger). + * 08/12/15 + */ +public class PlayerChangeArenaEvent extends Event +{ + private static final HandlerList _handlers = new HandlerList(); + + private Player player; + private Arena to; + private Arena from; + + public PlayerChangeArenaEvent(Player player, Arena to, Arena from) + { + this.player = player; + this.to = to; + this.from = from; + } + + public Player getPlayer() + { + return player; + } + + public Arena getTo() + { + return to; + } + + public Arena getFrom() + { + return from; + } + + 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/smash/perks/PerkCowAngryHerd.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkCowAngryHerd.java index 79f51f53b..dd0564f47 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkCowAngryHerd.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkCowAngryHerd.java @@ -87,7 +87,11 @@ public class PerkCowAngryHerd extends SmashPerk loc.add(UtilAlg.getLeft(dir).multiply(i*1.5)); Manager.GetGame().CreatureAllowOverride = true; - Cow cow = player.getWorld().spawn(loc, isSuperActive(player) ? MushroomCow.class : Cow.class); + Cow cow; + if (isSuperActive(player)) + cow = player.getWorld().spawn(loc, MushroomCow.class); + else + cow = player.getWorld().spawn(loc, Cow.class); Manager.GetGame().CreatureAllowOverride = false; _active.add(new DataCowCharge(player, cow)); From f8f95c64e5a7b1feb98e260b3d5d778a261b5a25 Mon Sep 17 00:00:00 2001 From: William Burns Date: Tue, 8 Dec 2015 15:10:29 +0000 Subject: [PATCH 27/58] Fixing arena moving --- .../core/achievement/Achievement.java | 2 + .../core/achievement/AchievementCategory.java | 4 + .../arcade/game/games/gladiators/Arena.java | 50 +++++----- .../game/games/gladiators/Gladiators.java | 98 +++++++++++++++---- .../gladiators/trackers/BrawlerTracker.java | 39 ++++++++ 5 files changed, 152 insertions(+), 41 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/BrawlerTracker.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index 6f36f0dd3..56fe4ba6e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -770,6 +770,8 @@ public enum Achievement new String[]{"Get hit by a monster and", "land on the Safe Pad"}, new int[]{1}, AchievementCategory.MONSTER_MAZE), + + ; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index 2bf9be288..265e031a4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -150,6 +150,10 @@ public enum AchievementCategory MONSTER_MAZE("Monster Maze", null, new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED}, Material.ROTTEN_FLESH, 0, GameCategory.ARCADE, "SoonTM"), + + GLADIATORS("Gladiators", null, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, + Material.IRON_SWORD, 0, GameCategory.ARCADE, null) ; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java index e2aab1fb8..48a37ec50 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java @@ -8,7 +8,6 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilMath; /** * Created by William (WilliamTiger). @@ -27,6 +26,9 @@ public class Arena private boolean _isUsed; private ArrayList _doorBlocks; + private boolean _isOpenDoor; + + private ArrayList _pastPlayers; public Arena(Gladiators host, Location mid, ArenaType colour) { @@ -37,6 +39,8 @@ public class Arena _parent = null; _isUsed = false; _doorBlocks = new ArrayList<>(); + _isOpenDoor = false; + _pastPlayers = new ArrayList<>(); setupSpawns(); } @@ -174,30 +178,9 @@ public class Arena return ret; } - public ArrayList getPlayers() + public ArrayList getPastPlayers() { - ArrayList pls = new ArrayList<>(); - - for (Player p : _host.GetPlayers(true)) - { - if (UtilMath.offset(p.getLocation(), _mid) <= 21) - pls.add(p); - } - - return pls; - } - - public int getPlayerCount() - { - ArrayList pls = new ArrayList<>(); - - for (Player p : _host.GetPlayers(true)) - { - if (UtilMath.offset(p.getLocation(), _mid) <= 21) - pls.add(p); - } - - return pls.size(); + return _pastPlayers; } public boolean isUsed() @@ -215,4 +198,23 @@ public class Arena for (Location loc : _doorBlocks) loc.getBlock().setType(Material.OBSIDIAN); } + + public boolean isOpenDoor() + { + return _isOpenDoor; + } + + public void openDoor() + { + _isOpenDoor = true; + + _host.Manager.getScheduler().scheduleSyncDelayedTask(_host.Manager.getPlugin(), () -> { + + for (Location loc : _doorBlocks) + { + loc.getBlock().setType(Material.AIR); + } + + }, 5L); + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index a4010e009..971abe53f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -13,6 +13,8 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerMoveEvent; import mineplex.core.common.util.UtilAlg; +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; @@ -36,7 +38,10 @@ public class Gladiators extends SoloGame public Gladiators(ArcadeManager manager) { super(manager, GameType.Gladiators, - new Kit[0], + new Kit[] + { + new KitGladiator(manager) + }, new String[] { "This is a 1v1 tournament!", @@ -51,8 +56,6 @@ public class Gladiators extends SoloGame DamageTeamSelf = true; HungerSet = 20; - setKits(new Kit[]{new KitGladiator(manager)}); - _playerArenas = new HashMap<>(); } @@ -277,11 +280,11 @@ public class Gladiators extends SoloGame { for (Player p : GetPlayers(true)) { - for (Arena a : _allArenas) - { - if (a.getPlayers().contains(p)) - _playerArenas.put(p, a); - } + Location closest = UtilAlg.findClosest(p.getLocation(), getAllArenaMids()); + Arena arena = getArenaByMid(closest); + _playerArenas.put(p, arena); + + giveLoadout(p, _playerArenas.get(p).getColour()); } return; } @@ -300,17 +303,20 @@ public class Gladiators extends SoloGame if (!_playerArenas.containsKey(e.getPlayer())) return; - for (Arena a : _allArenas) + for (Player p : GetPlayers(true)) { - if (a.getPlayers().contains(e.getPlayer())) - { - if (_playerArenas.get(e.getPlayer()) != a) - { - Manager.getPluginManager().callEvent(new PlayerChangeArenaEvent(e.getPlayer(), - a, _playerArenas.get(e.getPlayer()))); + if (!_playerArenas.containsKey(p)) + continue; - _playerArenas.put(e.getPlayer(), a); - } + if (!_playerArenas.get(p).isOpenDoor()) + continue; // No need to check since no door to go through. + + Arena closest = getArenaByMid(UtilAlg.findClosest(p.getLocation(), getAllArenaMids())); + + if (closest != _playerArenas.get(p)) + { + Manager.getPluginManager().callEvent(new PlayerChangeArenaEvent(e.getPlayer(), closest, _playerArenas.get(p))); + _playerArenas.put(p, closest); } } } @@ -323,7 +329,65 @@ public class Gladiators extends SoloGame Arena current = e.getTo(); old.closeDoor(); + old.getPastPlayers().remove(p); + current.getPastPlayers().add(p); p.sendMessage("§7§lDEBUG: §3You left §b" + old.getColour().toString() + " §3and entered §b" + current.getColour().toString() + "§3."); + + giveLoadout(p, current.getColour()); + + } + + private void giveLoadout(Player p, ArenaType type) + { + if (!GetPlayers(true).contains(p)) + return; + + p.getInventory().clear(); + p.getInventory().setArmorContents(null); + + p.getInventory().setItem(0, type.getLoadout().getSword()); + p.getInventory().setItem(1, type.getLoadout().getRod()); + p.getInventory().setItem(2, type.getLoadout().getBow()); + p.getInventory().setItem(8, type.getLoadout().getArrows()); + + p.getInventory().setHelmet(type.getLoadout().getHelmet()); + p.getInventory().setChestplate(type.getLoadout().getChestplate()); + p.getInventory().setLeggings(type.getLoadout().getLeggings()); + p.getInventory().setBoots(type.getLoadout().getBoots()); + } + + @EventHandler + public void arenaNeedsMoving(UpdateEvent e) + { + if (e.getType() != UpdateType.TICK) + return; + + for (Arena a : _gameArenaSet) + { + for (Player p : a.getPastPlayers()) + { + if (!GetPlayers(true).contains(p)) + a.getPastPlayers().remove(p); + } + + if (a.getPastPlayers().size() == 1) + { + if (a.isOpenDoor()) + continue; + + a.openDoor(); + a.getPastPlayers().get(0).sendMessage("§7§lDEBUG: §3Door has been opened in your arena."); + } + } + } + + @EventHandler + public void alert(UpdateEvent e) + { + if (e.getType() != UpdateType.SEC) + return; + + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/BrawlerTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/BrawlerTracker.java new file mode 100644 index 000000000..6aa1da3d7 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/BrawlerTracker.java @@ -0,0 +1,39 @@ +package nautilus.game.arcade.game.games.gladiators.trackers; + +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import nautilus.game.arcade.game.games.gladiators.Gladiators; +import nautilus.game.arcade.stats.StatTracker; + +/** + * Created by William (WilliamTiger). + * 08/12/15 + */ +public class BrawlerTracker extends StatTracker +{ + public BrawlerTracker(Gladiators game) + { + super(game); + } + + @EventHandler + public void death(CombatDeathEvent e) + { + if (e.GetLog().GetKiller() == null) + return; + + if (Bukkit.getPlayerExact(e.GetLog().GetKiller().GetName()) != null) + { + Player p = Bukkit.getPlayerExact(e.GetLog().GetKiller().GetName()); + if (p.getItemInHand() == null) + return; + + if (p.getItemInHand().getType().equals(Material.AIR)) + addStat(p, "Brawler", 1, false, false); + } + } +} \ No newline at end of file From d598f83ec054b175815c450f64c27f420ee5fb38 Mon Sep 17 00:00:00 2001 From: William Burns Date: Tue, 8 Dec 2015 18:17:43 +0000 Subject: [PATCH 28/58] More progress --- .../arcade/game/games/gladiators/Arena.java | 13 +++ .../game/games/gladiators/ArenaState.java | 14 ++++ .../game/games/gladiators/Gladiators.java | 79 ++++++++++++++++++- .../game/games/gladiators/RoundState.java | 16 ++++ 4 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/ArenaState.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/RoundState.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java index 48a37ec50..4913f55ce 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java @@ -30,6 +30,8 @@ public class Arena private ArrayList _pastPlayers; + private ArenaState _state; + public Arena(Gladiators host, Location mid, ArenaType colour) { _host = host; @@ -41,6 +43,7 @@ public class Arena _doorBlocks = new ArrayList<>(); _isOpenDoor = false; _pastPlayers = new ArrayList<>(); + _state = ArenaState.EMPTY; setupSpawns(); } @@ -78,6 +81,16 @@ public class Arena return cap; } + public ArenaState getState() + { + return _state; + } + + public void setState(ArenaState state) + { + _state = state; + } + public ArrayList getDoorBlocks() { return _doorBlocks; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/ArenaState.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/ArenaState.java new file mode 100644 index 000000000..c92405389 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/ArenaState.java @@ -0,0 +1,14 @@ +package nautilus.game.arcade.game.games.gladiators; + +/** + * Created by William (WilliamTiger). + * 08/12/15 + */ +public enum ArenaState +{ + EMPTY, + WAITING, + FIGHTING, + RUNNING, + ENDED; +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index 971abe53f..b44ad8990 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -10,9 +10,13 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerMoveEvent; +import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; @@ -35,6 +39,8 @@ public class Gladiators extends SoloGame private HashMap _playerArenas; + private RoundState _roundState; + public Gladiators(ArcadeManager manager) { super(manager, GameType.Gladiators, @@ -57,6 +63,8 @@ public class Gladiators extends SoloGame HungerSet = 20; _playerArenas = new HashMap<>(); + + _roundState = RoundState.FIGHTING; } @Override @@ -282,6 +290,8 @@ public class Gladiators extends SoloGame { Location closest = UtilAlg.findClosest(p.getLocation(), getAllArenaMids()); Arena arena = getArenaByMid(closest); + arena.getPastPlayers().add(p); + arena.setState(ArenaState.WAITING); _playerArenas.put(p, arena); giveLoadout(p, _playerArenas.get(p).getColour()); @@ -330,7 +340,9 @@ public class Gladiators extends SoloGame old.closeDoor(); old.getPastPlayers().remove(p); + old.setState(ArenaState.ENDED); current.getPastPlayers().add(p); + current.setState(ArenaState.WAITING); p.sendMessage("§7§lDEBUG: §3You left §b" + old.getColour().toString() + " §3and entered §b" + current.getColour().toString() + "§3."); @@ -357,6 +369,40 @@ public class Gladiators extends SoloGame p.getInventory().setBoots(type.getLoadout().getBoots()); } + @EventHandler + public void debug(PlayerCommandPreprocessEvent e){ + if (e.getMessage().startsWith("/debuginfo")) + return; + + if (e.getPlayer().getName() != "WilliamTiger") + return; + + e.setCancelled(true); + Player p = e.getPlayer(); + + Player target = UtilPlayer.searchExact(e.getMessage().split(" ")[1]); + + if (target == null) + { + p.sendMessage("Target is null / not online"); + return; + } + + if (!GetPlayers(true).contains(target)) + { + p.sendMessage("That player isn't alive"); + return; + } + + Arena arena = _playerArenas.get(target); + + p.sendMessage("Info of " + target.getName() + "'s arena:"); + p.sendMessage("Type - " + arena.getColour().toString()); + p.sendMessage("Players - " + arena.getPastPlayers().toString()); + p.sendMessage("Players Size - " + arena.getPastPlayers().size()); + p.sendMessage("Door Open - " + arena.isOpenDoor()); + } + @EventHandler public void arenaNeedsMoving(UpdateEvent e) { @@ -382,12 +428,43 @@ public class Gladiators extends SoloGame } } + @EventHandler + public void updateRound(UpdateEvent e) + { + if (e.getType() != UpdateType.TICK) + return; + + boolean allWaiting = true; + + for (Arena a : _gameArenaSet) + { + if (a.getState() != ArenaState.WAITING) + return; + } + } + @EventHandler public void alert(UpdateEvent e) { if (e.getType() != UpdateType.SEC) return; - + for (Arena a : _gameArenaSet) + { + if (a.getState().equals(ArenaState.WAITING)) + { + for (Player p : a.getPastPlayers()) + UtilTextMiddle.display("", C.cRed + "Wait for the round to begin", 0, 60 , 0, p); + } + else if (a.getState().equals(ArenaState.FIGHTING)) + { + //TODO: poison etc, round end times + } + else if (a.getState().equals(ArenaState.RUNNING)) + { + //TODO: particles + UtilTextMiddle.display(C.cGreen + "Next Battle", "Follow the particle trail", 0, 60, 0, a.getPastPlayers().get(0)); + } + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/RoundState.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/RoundState.java new file mode 100644 index 000000000..bb717f6fc --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/RoundState.java @@ -0,0 +1,16 @@ +package nautilus.game.arcade.game.games.gladiators; + +/** + * Created by William (WilliamTiger). + * 08/12/15 + */ +public enum RoundState +{ + WAITING, + STARTING_5, + STARTING_4, + STARTING_3, + STARTING_2, + STARTING_1, + FIGHTING; +} From 7bdbd5a6af247927d8055962d8be4777035601f4 Mon Sep 17 00:00:00 2001 From: William Burns Date: Tue, 8 Dec 2015 21:10:27 +0000 Subject: [PATCH 29/58] Woo almost done! --- .../arcade/game/games/gladiators/Arena.java | 115 ++++++++++++++ .../game/games/gladiators/Gladiators.java | 141 ++++++++++++++---- .../game/games/gladiators/ParticleData.java | 56 +++++++ .../game/games/gladiators/RoundState.java | 2 +- 4 files changed, 285 insertions(+), 29 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/ParticleData.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java index 4913f55ce..28c001771 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java @@ -2,12 +2,19 @@ package nautilus.game.arcade.game.games.gladiators; import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent; +import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; /** * Created by William (WilliamTiger). @@ -31,6 +38,9 @@ public class Arena private ArrayList _pastPlayers; private ArenaState _state; + private long _stateTime; + + private HashMap> _particles; public Arena(Gladiators host, Location mid, ArenaType colour) { @@ -44,6 +54,8 @@ public class Arena _isOpenDoor = false; _pastPlayers = new ArrayList<>(); _state = ArenaState.EMPTY; + _stateTime = System.currentTimeMillis(); + _particles = new HashMap<>(); setupSpawns(); } @@ -53,6 +65,16 @@ public class Arena return _parent; } + public long getStateTime() + { + return _stateTime; + } + + public void setStateTime(long stateTime) + { + _stateTime = stateTime; + } + public void setParent(Arena parent) { _parent = parent; @@ -230,4 +252,97 @@ public class Arena }, 5L); } + + public void update() + { + if (getPastPlayers().size() <= 0) + _state = ArenaState.EMPTY; + + if (_state.equals(ArenaState.EMPTY)) + return; + + if (_state.equals(ArenaState.WAITING)) + { + for (Player p : getPastPlayers()) + { + UtilTextMiddle.display(C.cAqua + "Please Wait", "The next round will start shortly", 0, 20, 0, p); + } + } + else if (_state.equals(ArenaState.FIGHTING)) + { + if (!UtilTime.elapsed(_stateTime, 60000)) + return; // 60 seconds before poison + + for (Player p : getPastPlayers()) + { + UtilTextBottom.display(C.cRed + C.Bold + "YOU ARE POISONED! KEEP FIGHTING!", p); + _host.Manager.GetDamage().NewDamageEvent(p, null, null, EntityDamageEvent.DamageCause.CUSTOM, 1D, false, true, true, "Health Loss", "Health Loss"); + } + } + else if (_state.equals(ArenaState.RUNNING)) + { + for (Player p : getPastPlayers()) + { + UtilTextMiddle.display(C.cGreen + "Next Battle", "Follow the particles", 0, 20, 0, p); + } + + if (UtilTime.elapsed(_stateTime, 15000)) + handleSlowMovers(); + } + } + + public void updateTick() + { + if (_state.equals(ArenaState.RUNNING)) + { + getPastPlayers().stream().forEach(this::showParticles); + } + } + + private void showParticles(Player p) + { + if (!getPastPlayers().contains(p) || !_state.equals(ArenaState.RUNNING)) + { + _particles.remove(p); + return; + } + + //New Trails + if (Recharge.Instance.use(p, "Particle Trail", 3000, false, false)) + { + if (!_particles.containsKey(p)) + _particles.put(p, new ArrayList()); + + Location end = UtilAlg.findClosest(_mid, _host.WorldData.GetDataLocs("PINK")); + + _particles.get(p).add(new ParticleData(p, end)); + } + + //Old Trails + if (_particles.containsKey(p) && !_particles.get(p).isEmpty()) + { + Iterator trailIter = _particles.get(p).iterator(); + + while (trailIter.hasNext()) + { + ParticleData data = trailIter.next(); + + //Returns true if its hit the endpoint + if (data.update()) + trailIter.remove(); + } + } + } + + private void handleSlowMovers() + { + Arena next = _host.getArenaByMid(UtilAlg.findClosest(_mid, _host.getAllArenaMidsOfType(_host.getNextColour(_colour)))); + + for (Player p : getPastPlayers()) + { + //Teleport after 15 seconds of waiting. + + p.teleport(UtilAlg.getLocationAwayFromPlayers(next.getSpawns(), _host.GetPlayers(true)).clone()); + } + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index b44ad8990..d7612b205 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -10,6 +10,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerMoveEvent; @@ -424,47 +425,131 @@ public class Gladiators extends SoloGame a.openDoor(); a.getPastPlayers().get(0).sendMessage("§7§lDEBUG: §3Door has been opened in your arena."); + a.setState(ArenaState.RUNNING); + a.setStateTime(System.currentTimeMillis()); } } } @EventHandler - public void updateRound(UpdateEvent e) - { - if (e.getType() != UpdateType.TICK) - return; - - boolean allWaiting = true; - - for (Arena a : _gameArenaSet) - { - if (a.getState() != ArenaState.WAITING) - return; - } - } - - @EventHandler - public void alert(UpdateEvent e) + public void arenaUpdateTick(UpdateEvent e) { if (e.getType() != UpdateType.SEC) return; for (Arena a : _gameArenaSet) + a.updateTick(); + } + + @EventHandler + public void arenaUpdate(UpdateEvent e) + { + if (e.getType() != UpdateType.SEC) + return; + + for (Arena a : _gameArenaSet) + a.update(); + } + + @EventHandler + public void damageCancel(EntityDamageEvent e) + { + if (!(e.getEntity() instanceof Player)) + return; + + Player p = (Player) e.getEntity(); + + if (!_playerArenas.containsKey(p)) + return; + + if (_playerArenas.get(p).getState() != ArenaState.FIGHTING) + e.setCancelled(true); + } + + @EventHandler + public void startCountdown(UpdateEvent e) + { + if (e.getType() != UpdateType.SEC) + return; + + if (_roundState.equals(RoundState.FIGHTING)) + return; + + if (_roundState.equals(RoundState.STARTING_5)) { - if (a.getState().equals(ArenaState.WAITING)) + _roundState = RoundState.STARTING_4; + return; + } + else if (_roundState.equals(RoundState.STARTING_4)) + { + _roundState = RoundState.STARTING_3; + return; + } + else if (_roundState.equals(RoundState.STARTING_3)) + { + _roundState = RoundState.STARTING_2; + UtilTextMiddle.display(C.cGreen + "3", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0); + return; + } + else if (_roundState.equals(RoundState.STARTING_2)) + { + _roundState = RoundState.STARTING_1; + UtilTextMiddle.display(C.cYellow + "2", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0); + return; + } + else if (_roundState.equals(RoundState.STARTING_1)) + { + _roundState = RoundState.STARTED; + UtilTextMiddle.display(C.cGold + "1", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0); + return; + } + else if (_roundState.equals(RoundState.STARTED)) + { + _roundState = RoundState.FIGHTING; + UtilTextMiddle.display(C.cRed + "FIGHT", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0); + for (Arena a : _gameArenaSet) { - for (Player p : a.getPastPlayers()) - UtilTextMiddle.display("", C.cRed + "Wait for the round to begin", 0, 60 , 0, p); - } - else if (a.getState().equals(ArenaState.FIGHTING)) - { - //TODO: poison etc, round end times - } - else if (a.getState().equals(ArenaState.RUNNING)) - { - //TODO: particles - UtilTextMiddle.display(C.cGreen + "Next Battle", "Follow the particle trail", 0, 60, 0, a.getPastPlayers().get(0)); + if (a.getState().equals(ArenaState.WAITING)) + { + a.setState(ArenaState.FIGHTING); + a.setStateTime(System.currentTimeMillis()); + } } + return; } } + + @EventHandler + public void roundUpdate(UpdateEvent e) + { + if (e.getType() != UpdateType.TICK) + return; + + if (_roundState.equals(RoundState.FIGHTING)) + { + for (Arena a : _gameArenaSet) + if (a.getState() != ArenaState.WAITING) + return; + + //All of the arenas are waiting for the next fight. + _roundState = RoundState.STARTING_5; + + UtilTextMiddle.display("", C.cGreen + C.Bold + getRoundNotation(), 0, 80 , 0); + return; + } + } + + private String getRoundNotation() + { + int size = GetPlayers(true).size(); + + if (size == 2) + return "FINALS"; + else if (size == 4) + return "SEMI-FINALS"; + else if (size == 8) + return "QUARTER-FINALS"; + else return "ROUND OF " + size; + } + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/ParticleData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/ParticleData.java new file mode 100644 index 000000000..2ec4129b2 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/ParticleData.java @@ -0,0 +1,56 @@ +package nautilus.game.arcade.game.games.gladiators; + +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; + +/** + * Created by William (WilliamTiger). + * 08/12/15 + */ +public class ParticleData +{ + public Player Player; + public Location CurrentLocation; + public Vector Velocity; + public Location Target; + + public ParticleData(Player player, Location target) + { + Player = player; + + Velocity = player.getLocation().getDirection(); + if (Velocity.getY() < 0) + Velocity.setY(0); + Velocity.normalize(); + + CurrentLocation = player.getLocation().add(0, 1, 0); + Target = target; + } + + public boolean update() + { + //Turn + Velocity.add(UtilAlg.getTrajectory(CurrentLocation, Target).multiply(0.15)); + + //Normalize Speed + UtilAlg.Normalize(Velocity); + + //Move + CurrentLocation.add(Velocity.clone().multiply(0.5)); + + //Particle + UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, CurrentLocation, 0.03f, 0.03f, 0.03f, 0, 3, + UtilParticle.ViewDist.LONG, Player); + + //Sound + CurrentLocation.getWorld().playSound(CurrentLocation, Sound.FIZZ, 0.2f, 3f); + + return UtilMath.offset(CurrentLocation, Target) < 4; + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/RoundState.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/RoundState.java index bb717f6fc..54cd18b16 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/RoundState.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/RoundState.java @@ -6,11 +6,11 @@ package nautilus.game.arcade.game.games.gladiators; */ public enum RoundState { - WAITING, STARTING_5, STARTING_4, STARTING_3, STARTING_2, STARTING_1, + STARTED, FIGHTING; } From a83ede3caacf5b0d7fdc9396bacd7e9035b1a83c Mon Sep 17 00:00:00 2001 From: William Burns Date: Tue, 8 Dec 2015 21:14:19 +0000 Subject: [PATCH 30/58] Handling slow movers --- .../game/arcade/game/games/gladiators/Arena.java | 6 +++++- .../game/arcade/game/games/gladiators/Gladiators.java | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java index 28c001771..d415767d7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java @@ -15,6 +15,7 @@ import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.recharge.Recharge; +import nautilus.game.arcade.game.games.gladiators.events.PlayerChangeArenaEvent; /** * Created by William (WilliamTiger). @@ -340,9 +341,12 @@ public class Arena for (Player p : getPastPlayers()) { - //Teleport after 15 seconds of waiting. + // TP after 15 seconds of waiting p.teleport(UtilAlg.getLocationAwayFromPlayers(next.getSpawns(), _host.GetPlayers(true)).clone()); + _host.Manager.getPluginManager().callEvent(new PlayerChangeArenaEvent(p, next, this)); + _host.setPlayerArena(p, next); + UtilTextBottom.display("§c§lTELEPORTED! YOU TOOK TOO LONG!", p); } } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index d7612b205..b8d32b4f2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -347,8 +347,8 @@ public class Gladiators extends SoloGame p.sendMessage("§7§lDEBUG: §3You left §b" + old.getColour().toString() + " §3and entered §b" + current.getColour().toString() + "§3."); - giveLoadout(p, current.getColour()); - + giveLoadout(p, current.getColour()); //Kit + p.setHealth(p.getMaxHealth()); //Heal } private void giveLoadout(Player p, ArenaType type) @@ -552,4 +552,9 @@ public class Gladiators extends SoloGame else return "ROUND OF " + size; } + public void setPlayerArena(Player p, Arena a) + { + _playerArenas.put(p, a); + } + } From d709071febc0dffabff7dd52ccf7cb567e2cb45b Mon Sep 17 00:00:00 2001 From: William Burns Date: Tue, 8 Dec 2015 23:20:42 +0000 Subject: [PATCH 31/58] Much fix, many wow. --- .../core/achievement/Achievement.java | 40 ++++++++++ .../arcade/game/games/gladiators/Arena.java | 16 +++- .../game/games/gladiators/Gladiators.java | 77 ++++++++++++++++-- .../gladiators/trackers/FlawlessTracker.java | 61 ++++++++++++++ .../gladiators/trackers/PrecisionTracker.java | 79 +++++++++++++++++++ 5 files changed, 265 insertions(+), 8 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/FlawlessTracker.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/PrecisionTracker.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index 56fe4ba6e..cc80b6904 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -771,7 +771,47 @@ public enum Achievement new int[]{1}, AchievementCategory.MONSTER_MAZE), + GLADIATORS_HARDENED_GLADIATOR("Hardened Gladiator", 1000, + new String[]{"Gladiators.Wins"}, + new String[]{"Win 50 games of Gladiators"}, + new int[]{50}, + AchievementCategory.GLADIATORS), + GLADIATORS_BATTLE_BRED("Battle Bred", 1500, + new String[]{"Gladiators.Wins"}, + new String[]{"Win 100 games of Gladiators"}, + new int[]{100}, + AchievementCategory.GLADIATORS), + + GLADIATORS_BRAWLER("Brawler", 1000, + new String[]{"Gladiators.Brawler"}, + new String[]{"Kill 3 Gladiators", "with your bare hands"}, + new int[]{3}, + AchievementCategory.GLADIATORS), + + GLADIATORS_UNTOUCHABLE("Untouchable", 1500, + new String[]{"Gladiators.Untouchable"}, + new String[]{"Kill 10 Gladiators", "without taking any damage"}, + new int[]{10}, + AchievementCategory.GLADIATORS), + + GLADIATORS_FLAWLESS("Flawless", 1000, + new String[]{"Gladiators.Flawless"}, + new String[]{"Win a game of gladiators", "without taking any damage"}, + new int[]{1}, + AchievementCategory.GLADIATORS), + + GLADIATORS_PRECISION("Precision", 800, + new String[]{"Gladiators.Precision"}, + new String[]{"Don't miss a single", "arrow in a game of", "Gladiators (Minimum 3)"}, + new int[]{1}, + AchievementCategory.GLADIATORS), + + GLADIATORS_SWIFT_KILL("Swift Kill", 1000, + new String[]{"Gladiators.SwiftKill"}, + new String[]{"Earn 15 first bloods", "in Gladiators"}, + new int[]{15}, + AchievementCategory.GLADIATORS) ; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java index d415767d7..3659b5714 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java @@ -11,6 +11,7 @@ import org.bukkit.event.entity.EntityDamageEvent; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; @@ -264,6 +265,9 @@ public class Arena if (_state.equals(ArenaState.WAITING)) { + if (_host.getRoundState() != RoundState.FIGHTING) + return; + for (Player p : getPastPlayers()) { UtilTextMiddle.display(C.cAqua + "Please Wait", "The next round will start shortly", 0, 20, 0, p); @@ -272,7 +276,14 @@ public class Arena else if (_state.equals(ArenaState.FIGHTING)) { if (!UtilTime.elapsed(_stateTime, 60000)) + { + double elapsed = UtilMath.trim(1, System.currentTimeMillis() - _stateTime); + + for (Player p : getPastPlayers()) + UtilTextBottom.display(C.cRed + C.Bold + "Poison in " + (UtilTime.MakeStr((long)(60 - elapsed))), p); + return; // 60 seconds before poison + } for (Player p : getPastPlayers()) { @@ -296,7 +307,8 @@ public class Arena { if (_state.equals(ArenaState.RUNNING)) { - getPastPlayers().stream().forEach(this::showParticles); + for (Player p : getPastPlayers()) + showParticles(p); } } @@ -337,6 +349,8 @@ public class Arena private void handleSlowMovers() { + _state = ArenaState.ENDED; + Arena next = _host.getArenaByMid(UtilAlg.findClosest(_mid, _host.getAllArenaMidsOfType(_host.getNextColour(_colour)))); for (Player p : getPastPlayers()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index b8d32b4f2..598488f4f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -6,6 +6,7 @@ import java.util.LinkedList; import java.util.Map; import java.util.Queue; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -292,11 +293,24 @@ public class Gladiators extends SoloGame Location closest = UtilAlg.findClosest(p.getLocation(), getAllArenaMids()); Arena arena = getArenaByMid(closest); arena.getPastPlayers().add(p); - arena.setState(ArenaState.WAITING); _playerArenas.put(p, arena); giveLoadout(p, _playerArenas.get(p).getColour()); } + + for (Arena a : _gameArenaSet) + { + if (a.getPastPlayers().size() > 1) + { + a.setState(ArenaState.FIGHTING); + a.setStateTime(System.currentTimeMillis()); + } + else if (a.getPastPlayers().size() == 0) + a.setState(ArenaState.EMPTY); + else if (a.getPastPlayers().size() == 1) + a.setState(ArenaState.WAITING); + } + return; } @@ -304,10 +318,22 @@ public class Gladiators extends SoloGame return; findGameArenaSet(); + closeUnusedArenas(); + } + + private void closeUnusedArenas() + { + for (Arena a : _allArenas) + if (!_gameArenaSet.contains(a)) + a.closeDoor(); } @EventHandler - public void arenaMoveCheck(PlayerMoveEvent e){ + public void arenaMoveCheck(PlayerMoveEvent e) + { + if (!IsLive()) + return; + if (!GetPlayers(true).contains(e.getPlayer())) return; @@ -345,7 +371,7 @@ public class Gladiators extends SoloGame current.getPastPlayers().add(p); current.setState(ArenaState.WAITING); - p.sendMessage("§7§lDEBUG: §3You left §b" + old.getColour().toString() + " §3and entered §b" + current.getColour().toString() + "§3."); + Bukkit.broadcastMessage("§7§lDEBUG: §3" + p.getName() + " left §b" + old.getColour().toString() + " §3and entered §b" + current.getColour().toString() + "§3."); giveLoadout(p, current.getColour()); //Kit p.setHealth(p.getMaxHealth()); //Heal @@ -372,7 +398,8 @@ public class Gladiators extends SoloGame @EventHandler public void debug(PlayerCommandPreprocessEvent e){ - if (e.getMessage().startsWith("/debuginfo")) + + if (!e.getMessage().startsWith("/debuginfo")) return; if (e.getPlayer().getName() != "WilliamTiger") @@ -407,6 +434,9 @@ public class Gladiators extends SoloGame @EventHandler public void arenaNeedsMoving(UpdateEvent e) { + if (!IsLive()) + return; + if (e.getType() != UpdateType.TICK) return; @@ -420,7 +450,7 @@ public class Gladiators extends SoloGame if (a.getPastPlayers().size() == 1) { - if (a.isOpenDoor()) + if (a.isOpenDoor() || a.getColour().equals(ArenaType.RED)) continue; a.openDoor(); @@ -434,7 +464,10 @@ public class Gladiators extends SoloGame @EventHandler public void arenaUpdateTick(UpdateEvent e) { - if (e.getType() != UpdateType.SEC) + if (!IsLive()) + return; + + if (e.getType() != UpdateType.TICK) return; for (Arena a : _gameArenaSet) @@ -444,6 +477,9 @@ public class Gladiators extends SoloGame @EventHandler public void arenaUpdate(UpdateEvent e) { + if (!IsLive()) + return; + if (e.getType() != UpdateType.SEC) return; @@ -454,6 +490,9 @@ public class Gladiators extends SoloGame @EventHandler public void damageCancel(EntityDamageEvent e) { + if (!IsLive()) + return; + if (!(e.getEntity() instanceof Player)) return; @@ -469,6 +508,9 @@ public class Gladiators extends SoloGame @EventHandler public void startCountdown(UpdateEvent e) { + if (!IsLive()) + return; + if (e.getType() != UpdateType.SEC) return; @@ -522,13 +564,18 @@ public class Gladiators extends SoloGame @EventHandler public void roundUpdate(UpdateEvent e) { + if (!IsLive()) + return; + if (e.getType() != UpdateType.TICK) return; if (_roundState.equals(RoundState.FIGHTING)) { for (Arena a : _gameArenaSet) - if (a.getState() != ArenaState.WAITING) + if (!(a.getState() == ArenaState.WAITING || + a.getState() == ArenaState.ENDED || + a.getState() == ArenaState.EMPTY)) return; //All of the arenas are waiting for the next fight. @@ -557,4 +604,20 @@ public class Gladiators extends SoloGame _playerArenas.put(p, a); } + public RoundState getRoundState() + { + return _roundState; + } + + @EventHandler + public void arenaBounce(UpdateEvent e) + { + if (e.getType() != UpdateType.TICK) + return; + + for (Player p : GetPlayers(true)) + { + + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/FlawlessTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/FlawlessTracker.java new file mode 100644 index 000000000..088a428aa --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/FlawlessTracker.java @@ -0,0 +1,61 @@ +package nautilus.game.arcade.game.games.gladiators.trackers; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent; + +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.gladiators.Gladiators; +import nautilus.game.arcade.stats.StatTracker; + +/** + * Created by William (WilliamTiger). + * 08/12/15 + */ +public class FlawlessTracker extends StatTracker +{ + + private List _noWin; + + public FlawlessTracker(Gladiators game) + { + super(game); + + _noWin = new ArrayList<>(); + } + + @EventHandler + public void onDmg(EntityDamageEvent e) + { + if (e.isCancelled()) + return; + + if (e.getEntity() instanceof Player) + { + _noWin.add(((Player)e.getEntity()).getName()); + } + } + + @EventHandler + public void end(GameStateChangeEvent e) + { + if (e.GetState() != Game.GameState.End) + return; + + if (getGame().getWinners() == null) + return; + + for (Player p : getGame().getWinners()) + { + if (_noWin.contains(p.getName())) + continue; + + addStat(p, "Flawless", 1, true, false); + } + } + +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/PrecisionTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/PrecisionTracker.java new file mode 100644 index 000000000..975e040be --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/PrecisionTracker.java @@ -0,0 +1,79 @@ +package nautilus.game.arcade.game.games.gladiators.trackers; + +import java.util.HashMap; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; + +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.games.gladiators.Gladiators; +import nautilus.game.arcade.stats.StatTracker; + +/** + * Created by William (WilliamTiger). + * 08/12/15 + */ +public class PrecisionTracker extends StatTracker +{ + private HashMap _shot; + private HashMap _hit; + + public PrecisionTracker(Gladiators game) + { + super(game); + + _shot = new HashMap<>(); + _hit = new HashMap<>(); + } + + @EventHandler + public void end(GameStateChangeEvent e) + { + if (e.GetState() != Game.GameState.End) + return; + + for (Player p : getGame().getWinners()) + { + if (_shot.containsKey(p.getName()) && _hit.containsKey(p.getName())) + { + if (_shot.get(p.getName()) == _hit.get(p.getName())) + { + if (_shot.get(p.getName()) >= 3) + addStat(p, "Precision", 1, true, false); + } + } + } + } + + @EventHandler + public void shoot(EntityShootBowEvent e) + { + if (!(e.getEntity() instanceof Player)) + return; + + Player p = (Player) e.getEntity(); + + if (_shot.containsKey(p.getName())) + _shot.put(p.getName(), _shot.get(p.getName()) + 1); + else + _shot.put(p.getName(), 1); + } + + @EventHandler + public void hit(ProjectileHitEvent e) + { + if (e.getEntity().getShooter() instanceof Player) + { + Player p = (Player) e.getEntity().getShooter(); + + if (_hit.containsKey(p.getName())) + _hit.put(p.getName(), _hit.get(p.getName()) + 1); + else + _hit.put(p.getName(), 1); + } + } + +} \ No newline at end of file From c021fbf9ed2f9d7ea189a9b7a4d671a332301916 Mon Sep 17 00:00:00 2001 From: William Burns Date: Tue, 8 Dec 2015 23:27:38 +0000 Subject: [PATCH 32/58] Bounce baby bounce. --- .../game/games/gladiators/Gladiators.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index 598488f4f..73405381c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -16,9 +16,11 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerMoveEvent; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; @@ -352,6 +354,17 @@ public class Gladiators extends SoloGame if (closest != _playerArenas.get(p)) { + if (_playerArenas.get(p).getColour().furtherOut(closest.getColour())) + { + // No going backwards. Bounce baby bounce. + if (Recharge.Instance.use(p, "Arena Bounce", 500, false, false)) + { + UtilAction.velocity(p, UtilAlg.getTrajectory2d(e.getTo(), p.getLocation()), 1.7, true, 0.5, 0, 5, true); + } + + return; + } + Manager.getPluginManager().callEvent(new PlayerChangeArenaEvent(e.getPlayer(), closest, _playerArenas.get(p))); _playerArenas.put(p, closest); } @@ -608,16 +621,4 @@ public class Gladiators extends SoloGame { return _roundState; } - - @EventHandler - public void arenaBounce(UpdateEvent e) - { - if (e.getType() != UpdateType.TICK) - return; - - for (Player p : GetPlayers(true)) - { - - } - } } From a5c46545df503df2d2f42417becae4df6b0e7c2e Mon Sep 17 00:00:00 2001 From: Sarah Date: Wed, 9 Dec 2015 14:44:22 +0100 Subject: [PATCH 33/58] fixing timer being shown. --- .../nautilus/game/arcade/managers/GameManager.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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 a4fac6a32..a1739088f 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 @@ -172,13 +172,13 @@ public class GameManager implements Listener if(!team.getTutorial().hasEnded()) { finished = false; - } - if(checkForTimer) - { - if(team.getTutorial().ShowPrepareTimer) - finished = false; - else - finished = true; + if(checkForTimer) + { + if(team.getTutorial().ShowPrepareTimer) + finished = false; + else + finished = true; + } } } if(prepTime <= timeUsage) From 852be97bae6a7ee9a88d0089706498036bbb7ae7 Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 9 Dec 2015 20:16:16 +0000 Subject: [PATCH 34/58] Work --- .../arcade/game/games/gladiators/Arena.java | 84 +++++++- .../game/games/gladiators/Gladiators.java | 187 +++++++++++++----- .../game/games/gladiators/RoundState.java | 26 ++- 3 files changed, 239 insertions(+), 58 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java index 3659b5714..5f4585135 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.gladiators; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; @@ -36,6 +37,7 @@ public class Arena private ArrayList _doorBlocks; private boolean _isOpenDoor; + private boolean _doorWaitNextRound; private ArrayList _pastPlayers; @@ -58,10 +60,21 @@ public class Arena _state = ArenaState.EMPTY; _stateTime = System.currentTimeMillis(); _particles = new HashMap<>(); + _doorWaitNextRound = false; setupSpawns(); } + public boolean isDoorWaitNextRound() + { + return _doorWaitNextRound; + } + + public void setDoorWaitNextRound(boolean doorWaitNextRound) + { + _doorWaitNextRound = doorWaitNextRound; + } + public Arena getParent() { return _parent; @@ -257,9 +270,21 @@ public class Arena public void update() { + arenaStateCheck(); + if (getPastPlayers().size() <= 0) _state = ArenaState.EMPTY; + if (_colour == ArenaType.RED) + { + // Manual red override. + if (getState() == ArenaState.RUNNING) + setState(ArenaState.WAITING); + + if (getState() == ArenaState.FIGHTING && getPastPlayers().size() == 1) + setState(ArenaState.WAITING); + } + if (_state.equals(ArenaState.EMPTY)) return; @@ -279,8 +304,8 @@ public class Arena { double elapsed = UtilMath.trim(1, System.currentTimeMillis() - _stateTime); - for (Player p : getPastPlayers()) - UtilTextBottom.display(C.cRed + C.Bold + "Poison in " + (UtilTime.MakeStr((long)(60 - elapsed))), p); + //for (Player p : getPastPlayers()) + //UtilTextBottom.display(C.cRed + C.Bold + "Poison in " + (UtilTime.MakeStr((long)(60 - elapsed))), p); return; // 60 seconds before poison } @@ -303,6 +328,52 @@ public class Arena } } + private void arenaStateCheck() + { + if (_state == ArenaState.EMPTY) + { + // It's empty. Nothing to see here. + return; + } + else if (_state == ArenaState.WAITING) + { + if (isDoorWaitNextRound()) + { + // They just have to wait. We don't want their door to open just yet. They are a 'bye'. + return; + } + else + { + if (getPastPlayers().size() == 1) + { + // Run! + _state = ArenaState.RUNNING; + return; + } + else + { + // They have to just wait there. + return; + } + } + } + else if (_state == ArenaState.FIGHTING) + { + if (getPastPlayers().size() == 1) + { + // They should be running or waiting on a bye. + _state = ArenaState.WAITING; + // Set to waiting, and let the above handle that state. + return; + } + else + { + // Fighting. No problem here. + return; + } + } + } + public void updateTick() { if (_state.equals(ArenaState.RUNNING)) @@ -353,14 +424,19 @@ public class Arena Arena next = _host.getArenaByMid(UtilAlg.findClosest(_mid, _host.getAllArenaMidsOfType(_host.getNextColour(_colour)))); - for (Player p : getPastPlayers()) + for (Player p : _pastPlayers) { - // TP after 15 seconds of waiting + // TP after 15 seconds of waiting. p.teleport(UtilAlg.getLocationAwayFromPlayers(next.getSpawns(), _host.GetPlayers(true)).clone()); + //p.sendMessage("HANDLE SLOW MOVERS METHOD!"); _host.Manager.getPluginManager().callEvent(new PlayerChangeArenaEvent(p, next, this)); + closeDoor(); _host.setPlayerArena(p, next); UtilTextBottom.display("§c§lTELEPORTED! YOU TOOK TOO LONG!", p); + next.setDoorWaitNextRound(true); } + + _pastPlayers.clear(); // Clear out the un-used players. } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index 73405381c..02a086b31 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -12,13 +12,16 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.inventory.ItemStack; 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.UtilPlayer; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -26,6 +29,8 @@ import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; +import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.games.gladiators.events.PlayerChangeArenaEvent; import nautilus.game.arcade.game.games.gladiators.kits.KitGladiator; @@ -65,6 +70,7 @@ public class Gladiators extends SoloGame DamageSelf = true; DamageTeamSelf = true; HungerSet = 20; + DontAllowOverfill = true; _playerArenas = new HashMap<>(); @@ -310,7 +316,10 @@ public class Gladiators extends SoloGame else if (a.getPastPlayers().size() == 0) a.setState(ArenaState.EMPTY); else if (a.getPastPlayers().size() == 1) + { + a.setDoorWaitNextRound(true); a.setState(ArenaState.WAITING); + } } return; @@ -320,7 +329,7 @@ public class Gladiators extends SoloGame return; findGameArenaSet(); - closeUnusedArenas(); + //closeUnusedArenas(); } private void closeUnusedArenas() @@ -342,32 +351,30 @@ public class Gladiators extends SoloGame if (!_playerArenas.containsKey(e.getPlayer())) return; - for (Player p : GetPlayers(true)) + Player p = e.getPlayer(); + + //if (!_playerArenas.get(p).isOpenDoor()) + //return; // No need to check since no door to go through. + + Arena closest = getArenaByMid(UtilAlg.findClosest(p.getLocation(), getAllArenaMids())); + + if (closest != _playerArenas.get(p)) { - if (!_playerArenas.containsKey(p)) - continue; - - if (!_playerArenas.get(p).isOpenDoor()) - continue; // No need to check since no door to go through. - - Arena closest = getArenaByMid(UtilAlg.findClosest(p.getLocation(), getAllArenaMids())); - - if (closest != _playerArenas.get(p)) + if (closest.getColour().furtherOut(_playerArenas.get(p).getColour())) { - if (_playerArenas.get(p).getColour().furtherOut(closest.getColour())) + // No going backwards. Bounce baby bounce. + if (Recharge.Instance.use(p, "Arena Bounce", 500, false, false)) { - // No going backwards. Bounce baby bounce. - if (Recharge.Instance.use(p, "Arena Bounce", 500, false, false)) - { - UtilAction.velocity(p, UtilAlg.getTrajectory2d(e.getTo(), p.getLocation()), 1.7, true, 0.5, 0, 5, true); - } - - return; + //p.sendMessage("bounce. closest = " + closest.toString() + " player arena = " + _playerArenas.get(p).toString()); + UtilAction.velocity(p, UtilAlg.getTrajectory2d(e.getTo(), p.getLocation()), 1.7, true, 0.5, 0, 5, true); } - Manager.getPluginManager().callEvent(new PlayerChangeArenaEvent(e.getPlayer(), closest, _playerArenas.get(p))); - _playerArenas.put(p, closest); + return; } + + //p.sendMessage("ARENA MOVE CHECK METHOD!"); + Manager.getPluginManager().callEvent(new PlayerChangeArenaEvent(e.getPlayer(), closest, _playerArenas.get(p))); + _playerArenas.put(p, closest); } } @@ -383,6 +390,7 @@ public class Gladiators extends SoloGame old.setState(ArenaState.ENDED); current.getPastPlayers().add(p); current.setState(ArenaState.WAITING); + current.setDoorWaitNextRound(true); Bukkit.broadcastMessage("§7§lDEBUG: §3" + p.getName() + " left §b" + old.getColour().toString() + " §3and entered §b" + current.getColour().toString() + "§3."); @@ -411,37 +419,19 @@ public class Gladiators extends SoloGame @EventHandler public void debug(PlayerCommandPreprocessEvent e){ - - if (!e.getMessage().startsWith("/debuginfo")) + if (!e.getPlayer().getName().equalsIgnoreCase("WilliamTiger")) return; - if (e.getPlayer().getName() != "WilliamTiger") + if (!e.getMessage().equalsIgnoreCase("/arenas")) return; - e.setCancelled(true); Player p = e.getPlayer(); - Player target = UtilPlayer.searchExact(e.getMessage().split(" ")[1]); - - if (target == null) + p.sendMessage("Round State = " + _roundState.toString()); + for (Arena a : _gameArenaSet) { - p.sendMessage("Target is null / not online"); - return; + p.sendMessage(a.getColour().toString() + " - " + a.getPastPlayers().size() + " - " + a.getState().toString()); } - - if (!GetPlayers(true).contains(target)) - { - p.sendMessage("That player isn't alive"); - return; - } - - Arena arena = _playerArenas.get(target); - - p.sendMessage("Info of " + target.getName() + "'s arena:"); - p.sendMessage("Type - " + arena.getColour().toString()); - p.sendMessage("Players - " + arena.getPastPlayers().toString()); - p.sendMessage("Players Size - " + arena.getPastPlayers().size()); - p.sendMessage("Door Open - " + arena.isOpenDoor()); } @EventHandler @@ -463,11 +453,11 @@ public class Gladiators extends SoloGame if (a.getPastPlayers().size() == 1) { - if (a.isOpenDoor() || a.getColour().equals(ArenaType.RED)) + if (a.isOpenDoor() || a.getColour().equals(ArenaType.RED) || a.isDoorWaitNextRound()) continue; a.openDoor(); - a.getPastPlayers().get(0).sendMessage("§7§lDEBUG: §3Door has been opened in your arena."); + //a.getPastPlayers().get(0).sendMessage("§7§lDEBUG: §3Door has been opened in your arena."); a.setState(ArenaState.RUNNING); a.setStateTime(System.currentTimeMillis()); } @@ -594,6 +584,10 @@ public class Gladiators extends SoloGame //All of the arenas are waiting for the next fight. _roundState = RoundState.STARTING_5; + for (Arena a : _gameArenaSet) + if (a.isDoorWaitNextRound()) + a.setDoorWaitNextRound(false); + UtilTextMiddle.display("", C.cGreen + C.Bold + getRoundNotation(), 0, 80 , 0); return; } @@ -621,4 +615,103 @@ public class Gladiators extends SoloGame { return _roundState; } + + @EventHandler + public void onShoot(EntityShootBowEvent e) + { + if (_roundState == null) + return; + + if (_roundState.equals(RoundState.FIGHTING)) + return; + + e.setCancelled(true); + + if (e.getEntity() instanceof Player) + { + ((Player)e.getEntity()).getInventory().addItem(new ItemStack(Material.ARROW, 1)); // Arrow fix. + ((Player)e.getEntity()).updateInventory(); + } + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (GetState() != GameState.Live) + return; + + Scoreboard.Reset(); + + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cGreen + C.Bold + "Status"); + if (_roundState == RoundState.FIGHTING) + { + double start = -1D; + for (Arena a : _gameArenaSet) + { + if (start != -1D) + continue; + + if (a.getState() == ArenaState.FIGHTING) + start = a.getStateTime(); + } + double time = UtilMath.trim(1, ((60000L + start) - System.currentTimeMillis())); + if (time < 0) + Scoreboard.Write("Poison Active"); + else + Scoreboard.Write("Poison in " + time + "s"); + } + else + { + Scoreboard.Write(_roundState.getScoreboardText()); + } + + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cAqua + C.Bold + "Matches Left"); + Scoreboard.Write(C.cWhite + getMatchesFighting()); + + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cYellow + C.Bold + "Players"); + if (GetPlayers(true).size() > 7) + { + Scoreboard.Write(C.cWhite + GetPlayers(true).size() + " Players"); + } + else + { + for (Player p : GetPlayers(true)) + { + Scoreboard.Write(C.cWhite + p.getName()); + } + } + + Scoreboard.Draw(); + } + + private int getMatchesFighting() + { + if (_gameArenaSet == null) + return 0; + + int count = 0; + for (Arena a : _gameArenaSet) + { + if (a.getState() == ArenaState.FIGHTING) + count++; + } + + return count; + } + + @EventHandler + public void overfillCheck(PlayerPrepareTeleportEvent e) + { + Player p = e.GetPlayer(); + if (GetPlayers(true).size() > 16) + { + SetPlayerState(p, GameTeam.PlayerState.OUT); + Manager.addSpectator(p, true); + p.sendMessage(F.main("Game", "Too many players are in this server. You are now spectating, sorry.")); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/RoundState.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/RoundState.java index 54cd18b16..20072f6cc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/RoundState.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/RoundState.java @@ -6,11 +6,23 @@ package nautilus.game.arcade.game.games.gladiators; */ public enum RoundState { - STARTING_5, - STARTING_4, - STARTING_3, - STARTING_2, - STARTING_1, - STARTED, - FIGHTING; + STARTING_5("Starting in 5s"), + STARTING_4("Starting in 4s"), + STARTING_3("Starting in 3s"), + STARTING_2("Starting in 2s"), + STARTING_1("Starting in 1s"), + STARTED("FIGHT!"), + FIGHTING("Fighting"); + + private String scoreboardText; + + RoundState(String scoreboardText) + { + this.scoreboardText = scoreboardText; + } + + public String getScoreboardText() + { + return scoreboardText; + } } From 513db5dd8de12efb82a2903b2f4fc825c86cb717 Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 9 Dec 2015 21:33:31 +0000 Subject: [PATCH 35/58] doing byes --- .../game/arcade/game/games/gladiators/Arena.java | 16 ++++++++-------- .../arcade/game/games/gladiators/Gladiators.java | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java index 5f4585135..860e7d5d9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java @@ -37,7 +37,7 @@ public class Arena private ArrayList _doorBlocks; private boolean _isOpenDoor; - private boolean _doorWaitNextRound; + private boolean _doBye; private ArrayList _pastPlayers; @@ -60,19 +60,19 @@ public class Arena _state = ArenaState.EMPTY; _stateTime = System.currentTimeMillis(); _particles = new HashMap<>(); - _doorWaitNextRound = false; + _doBye = false; setupSpawns(); } - public boolean isDoorWaitNextRound() + public boolean isDoBye() { - return _doorWaitNextRound; + return _doBye; } - public void setDoorWaitNextRound(boolean doorWaitNextRound) + public void setDoBye(boolean doBye) { - _doorWaitNextRound = doorWaitNextRound; + _doBye = doBye; } public Arena getParent() @@ -337,7 +337,7 @@ public class Arena } else if (_state == ArenaState.WAITING) { - if (isDoorWaitNextRound()) + if (isDoBye()) { // They just have to wait. We don't want their door to open just yet. They are a 'bye'. return; @@ -434,7 +434,7 @@ public class Arena closeDoor(); _host.setPlayerArena(p, next); UtilTextBottom.display("§c§lTELEPORTED! YOU TOOK TOO LONG!", p); - next.setDoorWaitNextRound(true); + next.setDoBye(true); } _pastPlayers.clear(); // Clear out the un-used players. diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index 02a086b31..00177a5f8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -317,7 +317,7 @@ public class Gladiators extends SoloGame a.setState(ArenaState.EMPTY); else if (a.getPastPlayers().size() == 1) { - a.setDoorWaitNextRound(true); + a.setDoBye(true); a.setState(ArenaState.WAITING); } } @@ -390,7 +390,7 @@ public class Gladiators extends SoloGame old.setState(ArenaState.ENDED); current.getPastPlayers().add(p); current.setState(ArenaState.WAITING); - current.setDoorWaitNextRound(true); + current.setDoBye(true); Bukkit.broadcastMessage("§7§lDEBUG: §3" + p.getName() + " left §b" + old.getColour().toString() + " §3and entered §b" + current.getColour().toString() + "§3."); @@ -453,7 +453,7 @@ public class Gladiators extends SoloGame if (a.getPastPlayers().size() == 1) { - if (a.isOpenDoor() || a.getColour().equals(ArenaType.RED) || a.isDoorWaitNextRound()) + if (a.isOpenDoor() || a.getColour().equals(ArenaType.RED) || a.isDoBye()) continue; a.openDoor(); @@ -585,8 +585,8 @@ public class Gladiators extends SoloGame _roundState = RoundState.STARTING_5; for (Arena a : _gameArenaSet) - if (a.isDoorWaitNextRound()) - a.setDoorWaitNextRound(false); + if (a.isDoBye()) + a.setDoBye(false); UtilTextMiddle.display("", C.cGreen + C.Bold + getRoundNotation(), 0, 80 , 0); return; From 17c989d9415d432dfcdc63a9c8ad52fe73c77670 Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 9 Dec 2015 22:39:04 +0000 Subject: [PATCH 36/58] Less per-player arena stuff --- .../arcade/game/games/gladiators/Arena.java | 77 ++-------- .../game/games/gladiators/Gladiators.java | 144 ++++++++---------- .../game/games/gladiators/RoundState.java | 1 + 3 files changed, 71 insertions(+), 151 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java index 860e7d5d9..079af448d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java @@ -270,24 +270,12 @@ public class Arena public void update() { - arenaStateCheck(); - if (getPastPlayers().size() <= 0) - _state = ArenaState.EMPTY; - - if (_colour == ArenaType.RED) { - // Manual red override. - if (getState() == ArenaState.RUNNING) - setState(ArenaState.WAITING); - - if (getState() == ArenaState.FIGHTING && getPastPlayers().size() == 1) - setState(ArenaState.WAITING); + setState(ArenaState.EMPTY); + return; // Empty check. } - if (_state.equals(ArenaState.EMPTY)) - return; - if (_state.equals(ArenaState.WAITING)) { if (_host.getRoundState() != RoundState.FIGHTING) @@ -300,16 +288,17 @@ public class Arena } else if (_state.equals(ArenaState.FIGHTING)) { - if (!UtilTime.elapsed(_stateTime, 60000)) + if (getPastPlayers().size() == 1) { - double elapsed = UtilMath.trim(1, System.currentTimeMillis() - _stateTime); + openDoor(); - //for (Player p : getPastPlayers()) - //UtilTextBottom.display(C.cRed + C.Bold + "Poison in " + (UtilTime.MakeStr((long)(60 - elapsed))), p); - - return; // 60 seconds before poison + setState(ArenaState.RUNNING); + return; } + if (!UtilTime.elapsed(_stateTime, 60000)) + return; // No poison yet. + for (Player p : getPastPlayers()) { UtilTextBottom.display(C.cRed + C.Bold + "YOU ARE POISONED! KEEP FIGHTING!", p); @@ -328,52 +317,6 @@ public class Arena } } - private void arenaStateCheck() - { - if (_state == ArenaState.EMPTY) - { - // It's empty. Nothing to see here. - return; - } - else if (_state == ArenaState.WAITING) - { - if (isDoBye()) - { - // They just have to wait. We don't want their door to open just yet. They are a 'bye'. - return; - } - else - { - if (getPastPlayers().size() == 1) - { - // Run! - _state = ArenaState.RUNNING; - return; - } - else - { - // They have to just wait there. - return; - } - } - } - else if (_state == ArenaState.FIGHTING) - { - if (getPastPlayers().size() == 1) - { - // They should be running or waiting on a bye. - _state = ArenaState.WAITING; - // Set to waiting, and let the above handle that state. - return; - } - else - { - // Fighting. No problem here. - return; - } - } - } - public void updateTick() { if (_state.equals(ArenaState.RUNNING)) @@ -420,7 +363,7 @@ public class Arena private void handleSlowMovers() { - _state = ArenaState.ENDED; + setState(ArenaState.ENDED); Arena next = _host.getArenaByMid(UtilAlg.findClosest(_mid, _host.getAllArenaMidsOfType(_host.getNextColour(_colour)))); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index 00177a5f8..ec69eb73d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -50,6 +50,8 @@ public class Gladiators extends SoloGame private RoundState _roundState; + private ArenaType _furthestOutCurrent; + public Gladiators(ArcadeManager manager) { super(manager, GameType.Gladiators, @@ -74,7 +76,7 @@ public class Gladiators extends SoloGame _playerArenas = new HashMap<>(); - _roundState = RoundState.FIGHTING; + _roundState = RoundState.WAITING; } @Override @@ -306,22 +308,6 @@ public class Gladiators extends SoloGame giveLoadout(p, _playerArenas.get(p).getColour()); } - for (Arena a : _gameArenaSet) - { - if (a.getPastPlayers().size() > 1) - { - a.setState(ArenaState.FIGHTING); - a.setStateTime(System.currentTimeMillis()); - } - else if (a.getPastPlayers().size() == 0) - a.setState(ArenaState.EMPTY); - else if (a.getPastPlayers().size() == 1) - { - a.setDoBye(true); - a.setState(ArenaState.WAITING); - } - } - return; } @@ -332,6 +318,63 @@ public class Gladiators extends SoloGame //closeUnusedArenas(); } + /** + *------------------- + * MAIN UPDATE METHOD + *------------------- + */ + @EventHandler + public void roundUpdateCheck(UpdateEvent e) + { + if (!IsLive()) + return; + + if (e.getType() != UpdateType.TICK) + return; + + if (_roundState == RoundState.WAITING) + { + _roundState = RoundState.STARTING_5; + UtilTextMiddle.display("", C.cGreen + C.Bold + getRoundNotation(), 0, 80 , 0); + + _furthestOutCurrent = getFurthestOut(); // Find furthest out for fight. + + for (Arena a : _gameArenaSet) + { + if (a.getState() == ArenaState.WAITING && a.getColour() == _furthestOutCurrent) + { + // This arena is going to fight. + a.setState(ArenaState.FIGHTING); + a.setStateTime(System.currentTimeMillis()); + } + } + } + else if (_roundState.equals(RoundState.FIGHTING)) + { + for (Arena a : _gameArenaSet) + if (!(a.getState() == ArenaState.WAITING || + a.getState() == ArenaState.ENDED || + a.getState() == ArenaState.EMPTY)) + return; + + //All of the arenas are waiting for the next fight, so let's make them wait a bit. + _roundState = RoundState.WAITING; + return; + } + } + + private ArenaType getFurthestOut() + { + ArenaType best = null; + for (Arena a : _gameArenaSet) + { + if (best == null || a.getColour().furtherOut(best)) + best = a.getColour(); + } + + return best; + } + private void closeUnusedArenas() { for (Arena a : _allArenas) @@ -434,36 +477,6 @@ public class Gladiators extends SoloGame } } - @EventHandler - public void arenaNeedsMoving(UpdateEvent e) - { - if (!IsLive()) - return; - - if (e.getType() != UpdateType.TICK) - return; - - for (Arena a : _gameArenaSet) - { - for (Player p : a.getPastPlayers()) - { - if (!GetPlayers(true).contains(p)) - a.getPastPlayers().remove(p); - } - - if (a.getPastPlayers().size() == 1) - { - if (a.isOpenDoor() || a.getColour().equals(ArenaType.RED) || a.isDoBye()) - continue; - - a.openDoor(); - //a.getPastPlayers().get(0).sendMessage("§7§lDEBUG: §3Door has been opened in your arena."); - a.setState(ArenaState.RUNNING); - a.setStateTime(System.currentTimeMillis()); - } - } - } - @EventHandler public void arenaUpdateTick(UpdateEvent e) { @@ -552,43 +565,6 @@ public class Gladiators extends SoloGame { _roundState = RoundState.FIGHTING; UtilTextMiddle.display(C.cRed + "FIGHT", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0); - for (Arena a : _gameArenaSet) - { - if (a.getState().equals(ArenaState.WAITING)) - { - a.setState(ArenaState.FIGHTING); - a.setStateTime(System.currentTimeMillis()); - } - } - return; - } - } - - @EventHandler - public void roundUpdate(UpdateEvent e) - { - if (!IsLive()) - return; - - if (e.getType() != UpdateType.TICK) - return; - - if (_roundState.equals(RoundState.FIGHTING)) - { - for (Arena a : _gameArenaSet) - if (!(a.getState() == ArenaState.WAITING || - a.getState() == ArenaState.ENDED || - a.getState() == ArenaState.EMPTY)) - return; - - //All of the arenas are waiting for the next fight. - _roundState = RoundState.STARTING_5; - - for (Arena a : _gameArenaSet) - if (a.isDoBye()) - a.setDoBye(false); - - UtilTextMiddle.display("", C.cGreen + C.Bold + getRoundNotation(), 0, 80 , 0); return; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/RoundState.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/RoundState.java index 20072f6cc..1807db499 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/RoundState.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/RoundState.java @@ -6,6 +6,7 @@ package nautilus.game.arcade.game.games.gladiators; */ public enum RoundState { + WAITING("Waiting"), STARTING_5("Starting in 5s"), STARTING_4("Starting in 4s"), STARTING_3("Starting in 3s"), From 3ad0a3db6ea9fb07bd946adbb54310624f23aa68 Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 9 Dec 2015 23:14:08 +0000 Subject: [PATCH 37/58] fix --- .../game/games/gladiators/Gladiators.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index ec69eb73d..fb35f2472 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -308,6 +308,12 @@ public class Gladiators extends SoloGame giveLoadout(p, _playerArenas.get(p).getColour()); } + for (Arena a : _gameArenaSet) + { + if (a.getPastPlayers().size() != 0) + a.setState(ArenaState.WAITING); + } + return; } @@ -421,6 +427,25 @@ public class Gladiators extends SoloGame } } + @EventHandler + public void arenaCheckPlayer(UpdateEvent e) + { + if (!IsLive()) + return; + + if (e.getType() != UpdateType.TICK) + return; + + for (Arena a : _gameArenaSet) + { + for (Player p : a.getPastPlayers()) + { + if (!GetPlayers(true).contains(p)) + a.getPastPlayers().remove(p); + } + } + } + @EventHandler public void arenaChange(PlayerChangeArenaEvent e) { From b8a2304eddc110f0bb96c5d3a68284817d410865 Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 9 Dec 2015 23:39:00 +0000 Subject: [PATCH 38/58] work --- .../arcade/game/games/gladiators/Arena.java | 2 +- .../game/games/gladiators/Gladiators.java | 36 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java index 079af448d..329b67a05 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java @@ -367,7 +367,7 @@ public class Arena Arena next = _host.getArenaByMid(UtilAlg.findClosest(_mid, _host.getAllArenaMidsOfType(_host.getNextColour(_colour)))); - for (Player p : _pastPlayers) + for (Player p : new ArrayList(_pastPlayers)) { // TP after 15 seconds of waiting. diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index fb35f2472..c7a31c85e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -427,24 +427,24 @@ public class Gladiators extends SoloGame } } - @EventHandler - public void arenaCheckPlayer(UpdateEvent e) - { - if (!IsLive()) - return; - - if (e.getType() != UpdateType.TICK) - return; - - for (Arena a : _gameArenaSet) - { - for (Player p : a.getPastPlayers()) - { - if (!GetPlayers(true).contains(p)) - a.getPastPlayers().remove(p); - } - } - } +// @EventHandler +// public void arenaCheckPlayer(UpdateEvent e) +// { +// if (!IsLive()) +// return; +// +// if (e.getType() != UpdateType.TICK) +// return; +// +// for (Arena a : _gameArenaSet) +// { +// for (Player p : a.getPastPlayers()) +// { +// if (!GetPlayers(true).contains(p)) +// a.getPastPlayers().remove(p); +// } +// } +// } @EventHandler public void arenaChange(PlayerChangeArenaEvent e) From 05bd55f720fd65337da03848a7c30d01a9b1fcc2 Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 9 Dec 2015 23:53:04 +0000 Subject: [PATCH 39/58] iter --- .../game/games/gladiators/Gladiators.java | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index c7a31c85e..d1c400b49 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.gladiators; import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.LinkedList; import java.util.Map; import java.util.Queue; @@ -388,6 +389,28 @@ public class Gladiators extends SoloGame a.closeDoor(); } + @EventHandler + public void arenaCheckPlayer(UpdateEvent e) + { + if (!IsLive()) + return; + + if (e.getType() != UpdateType.TICK) + return; + + for (Arena a : _gameArenaSet) + { + Iterator pls = a.getPastPlayers().iterator(); + while (pls.hasNext()) + { + Player p = pls.next(); + + if (!GetPlayers(true).contains(p)) + pls.remove(); + } + } + } + @EventHandler public void arenaMoveCheck(PlayerMoveEvent e) { @@ -427,25 +450,6 @@ public class Gladiators extends SoloGame } } -// @EventHandler -// public void arenaCheckPlayer(UpdateEvent e) -// { -// if (!IsLive()) -// return; -// -// if (e.getType() != UpdateType.TICK) -// return; -// -// for (Arena a : _gameArenaSet) -// { -// for (Player p : a.getPastPlayers()) -// { -// if (!GetPlayers(true).contains(p)) -// a.getPastPlayers().remove(p); -// } -// } -// } - @EventHandler public void arenaChange(PlayerChangeArenaEvent e) { From cea2716851726c9b869e27dcb22c78e90a2397f4 Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 9 Dec 2015 23:59:20 +0000 Subject: [PATCH 40/58] fight man --- .../nautilus/game/arcade/game/games/gladiators/Gladiators.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index d1c400b49..ecc05a635 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -365,7 +365,7 @@ public class Gladiators extends SoloGame return; //All of the arenas are waiting for the next fight, so let's make them wait a bit. - _roundState = RoundState.WAITING; + _roundState = RoundState.FIGHTING; return; } } From 90896073d4ae8ead265f27be7bd7e31e1083e74d Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 10 Dec 2015 00:03:17 +0000 Subject: [PATCH 41/58] debug --- .../game/arcade/game/games/gladiators/Gladiators.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index ecc05a635..f4cb9dfa3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -365,7 +365,7 @@ public class Gladiators extends SoloGame return; //All of the arenas are waiting for the next fight, so let's make them wait a bit. - _roundState = RoundState.FIGHTING; + _roundState = RoundState.WAITING; return; } } @@ -491,15 +491,13 @@ public class Gladiators extends SoloGame @EventHandler public void debug(PlayerCommandPreprocessEvent e){ - if (!e.getPlayer().getName().equalsIgnoreCase("WilliamTiger")) - return; - if (!e.getMessage().equalsIgnoreCase("/arenas")) return; e.setCancelled(true); Player p = e.getPlayer(); p.sendMessage("Round State = " + _roundState.toString()); + p.sendMessage("Out state = " + _furthestOutCurrent.toString()); for (Arena a : _gameArenaSet) { p.sendMessage(a.getColour().toString() + " - " + a.getPastPlayers().size() + " - " + a.getState().toString()); @@ -593,6 +591,7 @@ public class Gladiators extends SoloGame else if (_roundState.equals(RoundState.STARTED)) { _roundState = RoundState.FIGHTING; + UtilTextMiddle.display(C.cRed + "FIGHT", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0); return; } From 87a834c01bad5f96cb77161329b6a8124d82b56f Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 10 Dec 2015 00:03:57 +0000 Subject: [PATCH 42/58] FIX --- .../nautilus/game/arcade/game/games/gladiators/Gladiators.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index f4cb9dfa3..cc98772bf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -375,6 +375,9 @@ public class Gladiators extends SoloGame ArenaType best = null; for (Arena a : _gameArenaSet) { + if (a.getState() != ArenaState.WAITING) + continue; + if (best == null || a.getColour().furtherOut(best)) best = a.getColour(); } From af7c058f220a1f32641e96698520c65393a43c71 Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 10 Dec 2015 19:06:07 +0000 Subject: [PATCH 43/58] Lots of bug fixes / additions since the testing 12/9/15. --- .../game/arcade/events/FirstBloodEvent.java | 39 +++++ .../arcade/game/games/gladiators/Arena.java | 3 +- .../game/games/gladiators/Gladiators.java | 138 +++++++++++++++--- .../gladiators/events/RoundStartEvent.java | 24 +++ .../gladiators/trackers/SwiftKillTracker.java | 26 ++++ .../trackers/UntouchableTracker.java | 55 +++++++ .../game/arcade/managers/GameGemManager.java | 3 + 7 files changed, 262 insertions(+), 26 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/events/FirstBloodEvent.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/events/RoundStartEvent.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/SwiftKillTracker.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/UntouchableTracker.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/events/FirstBloodEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/events/FirstBloodEvent.java new file mode 100644 index 000000000..a3a5bcbae --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/events/FirstBloodEvent.java @@ -0,0 +1,39 @@ +package nautilus.game.arcade.events; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +/** + * Created by William (WilliamTiger). + * 10/12/15 + */ +public class FirstBloodEvent extends Event +{ + + private Player player; + + public FirstBloodEvent(Player player) + { + this.player = player; + } + + public Player getPlayer() + { + return player; + } + + private static HandlerList _handlers = new HandlerList(); + + public static HandlerList getHandlerList() + { + return _handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java index 329b67a05..52079b41d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java @@ -1,7 +1,6 @@ package nautilus.game.arcade.game.games.gladiators; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; @@ -12,7 +11,6 @@ import org.bukkit.event.entity.EntityDamageEvent; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; @@ -293,6 +291,7 @@ public class Arena openDoor(); setState(ArenaState.RUNNING); + setStateTime(System.currentTimeMillis()); return; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index cc98772bf..34baa0a1b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -8,25 +8,32 @@ import java.util.Map; import java.util.Queue; import org.bukkit.Bukkit; +import org.bukkit.Color; +import org.bukkit.FireworkEffect; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; 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.UtilMath; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import nautilus.game.arcade.ArcadeFormat; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -34,7 +41,13 @@ import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.games.gladiators.events.PlayerChangeArenaEvent; +import nautilus.game.arcade.game.games.gladiators.events.RoundStartEvent; import nautilus.game.arcade.game.games.gladiators.kits.KitGladiator; +import nautilus.game.arcade.game.games.gladiators.trackers.BrawlerTracker; +import nautilus.game.arcade.game.games.gladiators.trackers.FlawlessTracker; +import nautilus.game.arcade.game.games.gladiators.trackers.PrecisionTracker; +import nautilus.game.arcade.game.games.gladiators.trackers.SwiftKillTracker; +import nautilus.game.arcade.game.games.gladiators.trackers.UntouchableTracker; import nautilus.game.arcade.kit.Kit; /** @@ -75,6 +88,14 @@ public class Gladiators extends SoloGame HungerSet = 20; DontAllowOverfill = true; + registerStatTrackers( + new BrawlerTracker(this), + new UntouchableTracker(this), + new FlawlessTracker(this), + new PrecisionTracker(this), + new SwiftKillTracker(this) + ); + _playerArenas = new HashMap<>(); _roundState = RoundState.WAITING; @@ -177,7 +198,7 @@ public class Gladiators extends SoloGame { for(int i = 0; i < node.getChilds().length; i++) { - System.out.println("Adding child of node: " + node.getColour() + "number of childs: " + node.getChilds().length); + //System.out.println("Adding child of node: " + node.getColour() + "number of childs: " + node.getChilds().length); nextQueue.add(node.getChildAt(i)); queue.add(node.getChildAt(i)); } @@ -188,7 +209,7 @@ public class Gladiators extends SoloGame Arena node = nextQueue.poll(); node.setIsUsed(true); - System.out.println("Node: " + node.getColour()); + //System.out.println("Node: " + node.getColour()); sum = sum + node.getCapacity() - 1; /* @@ -209,11 +230,11 @@ public class Gladiators extends SoloGame if (solved) { masterNode.getUsageMap(spawnsPerRoom); - System.out.println("Solution: "); + //System.out.println("Solution: "); for (Map.Entry entry : spawnsPerRoom.entrySet()) { - System.out.println("Color: " + entry.getKey().getColour() + ", Spawns: " + entry.getValue()); + //System.out.println("Color: " + entry.getKey().getColour() + ", Spawns: " + entry.getValue()); _gameArenaSet.add(entry.getKey()); } } @@ -354,7 +375,21 @@ public class Gladiators extends SoloGame a.setState(ArenaState.FIGHTING); a.setStateTime(System.currentTimeMillis()); } + + if (a.getState() == ArenaState.WAITING) + { + // No fight for them, they have a bye. + for (Player p : a.getPastPlayers()) + { + p.sendMessage(ArcadeFormat.Line); + p.sendMessage(" " + C.cWhite + C.Bold + "You have a bye!"); + p.sendMessage(" " + C.cGreen + "You automatically go through this round."); + p.sendMessage(ArcadeFormat.Line); + } + } } + + Manager.getPluginManager().callEvent(new RoundStartEvent()); } else if (_roundState.equals(RoundState.FIGHTING)) { @@ -467,7 +502,7 @@ public class Gladiators extends SoloGame current.setState(ArenaState.WAITING); current.setDoBye(true); - Bukkit.broadcastMessage("§7§lDEBUG: §3" + p.getName() + " left §b" + old.getColour().toString() + " §3and entered §b" + current.getColour().toString() + "§3."); + //Bukkit.broadcastMessage("§7§lDEBUG: §3" + p.getName() + " left §b" + old.getColour().toString() + " §3and entered §b" + current.getColour().toString() + "§3."); giveLoadout(p, current.getColour()); //Kit p.setHealth(p.getMaxHealth()); //Heal @@ -490,22 +525,24 @@ public class Gladiators extends SoloGame p.getInventory().setChestplate(type.getLoadout().getChestplate()); p.getInventory().setLeggings(type.getLoadout().getLeggings()); p.getInventory().setBoots(type.getLoadout().getBoots()); + + p.playSound(p.getLocation(), Sound.LEVEL_UP, 1f, 1f); } - @EventHandler - public void debug(PlayerCommandPreprocessEvent e){ - if (!e.getMessage().equalsIgnoreCase("/arenas")) - return; - e.setCancelled(true); - Player p = e.getPlayer(); - - p.sendMessage("Round State = " + _roundState.toString()); - p.sendMessage("Out state = " + _furthestOutCurrent.toString()); - for (Arena a : _gameArenaSet) - { - p.sendMessage(a.getColour().toString() + " - " + a.getPastPlayers().size() + " - " + a.getState().toString()); - } - } +// @EventHandler +// public void debug(PlayerCommandPreprocessEvent e){ +// if (!e.getMessage().equalsIgnoreCase("/arenas")) +// return; +// e.setCancelled(true); +// Player p = e.getPlayer(); +// +// p.sendMessage("Round State = " + _roundState.toString()); +// p.sendMessage("Out state = " + _furthestOutCurrent.toString()); +// for (Arena a : _gameArenaSet) +// { +// p.sendMessage(a.getColour().toString() + " - " + a.getPastPlayers().size() + " - " + a.getState().toString()); +// } +// } @EventHandler public void arenaUpdateTick(UpdateEvent e) @@ -547,7 +584,7 @@ public class Gladiators extends SoloGame if (!_playerArenas.containsKey(p)) return; - if (_playerArenas.get(p).getState() != ArenaState.FIGHTING) + if ((_playerArenas.get(p).getState() != ArenaState.FIGHTING) || (_roundState != RoundState.FIGHTING)) e.setCancelled(true); } @@ -577,25 +614,37 @@ public class Gladiators extends SoloGame { _roundState = RoundState.STARTING_2; UtilTextMiddle.display(C.cGreen + "3", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0); + + for (Player p : UtilServer.getPlayers()) + p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1f, 1f); return; } else if (_roundState.equals(RoundState.STARTING_2)) { _roundState = RoundState.STARTING_1; UtilTextMiddle.display(C.cYellow + "2", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0); + + for (Player p : UtilServer.getPlayers()) + p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1f, 1f); return; } else if (_roundState.equals(RoundState.STARTING_1)) { _roundState = RoundState.STARTED; UtilTextMiddle.display(C.cGold + "1", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0); + + for (Player p : UtilServer.getPlayers()) + p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1f, 1f); return; } else if (_roundState.equals(RoundState.STARTED)) { _roundState = RoundState.FIGHTING; - UtilTextMiddle.display(C.cRed + "FIGHT", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0); + UtilTextMiddle.display(C.cRed + "FIGHT", C.cGreen + C.Bold + getRoundNotation(), 0, 40, 0); + + for (Player p : UtilServer.getPlayers()) + p.playSound(p.getLocation(), Sound.NOTE_PLING, 2f, 2f); return; } } @@ -610,7 +659,7 @@ public class Gladiators extends SoloGame return "SEMI-FINALS"; else if (size == 8) return "QUARTER-FINALS"; - else return "ROUND OF " + size; + else return "ROUND OF " + size + " PLAYERS"; } public void setPlayerArena(Player p, Arena a) @@ -663,7 +712,7 @@ public class Gladiators extends SoloGame if (a.getState() == ArenaState.FIGHTING) start = a.getStateTime(); } - double time = UtilMath.trim(1, ((60000L + start) - System.currentTimeMillis())); + int time = Math.round((float)((60000L + start) - System.currentTimeMillis())); if (time < 0) Scoreboard.Write("Poison Active"); else @@ -721,4 +770,45 @@ public class Gladiators extends SoloGame p.sendMessage(F.main("Game", "Too many players are in this server. You are now spectating, sorry.")); } } + + @EventHandler + public void fireworkDeath(CombatDeathEvent e) + { + Location loc = e.GetEvent().getEntity().getLocation(); + Color color = Color.AQUA; + switch (_furthestOutCurrent) + { + case RED: + color = Color.RED; + break; + case ORANGE: + color = Color.ORANGE; + break; + case YELLOW: + color = Color.YELLOW; + break; + case GREEN: + color = Color.GREEN; + break; + } + UtilFirework.playFirework(loc, FireworkEffect.Type.BALL, color, false, false); + } + + @EventHandler + public void quitAlert(PlayerQuitEvent e) + { + if (_playerArenas.containsKey(e.getPlayer())) + { + for (Player p : _playerArenas.get(e.getPlayer()).getPastPlayers()) + { + if (p.equals(e.getPlayer())) + continue; + + p.sendMessage(ArcadeFormat.Line); + p.sendMessage(" " + C.cWhite + C.Bold + "Your opponent has QUIT!"); + p.sendMessage(" " + C.cGreen + "You automatically win the fight."); + p.sendMessage(ArcadeFormat.Line); + } + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/events/RoundStartEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/events/RoundStartEvent.java new file mode 100644 index 000000000..91d654d94 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/events/RoundStartEvent.java @@ -0,0 +1,24 @@ +package nautilus.game.arcade.game.games.gladiators.events; + +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +/** + * Created by William (WilliamTiger). + * 10/12/15 + */ +public class RoundStartEvent extends Event +{ + private static final HandlerList _handlers = new HandlerList(); + + 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/gladiators/trackers/SwiftKillTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/SwiftKillTracker.java new file mode 100644 index 000000000..52caeec89 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/SwiftKillTracker.java @@ -0,0 +1,26 @@ +package nautilus.game.arcade.game.games.gladiators.trackers; + +import org.bukkit.event.EventHandler; + +import nautilus.game.arcade.events.FirstBloodEvent; +import nautilus.game.arcade.game.games.gladiators.Gladiators; +import nautilus.game.arcade.stats.StatTracker; + +/** + * Created by William (WilliamTiger). + * 10/12/15 + */ +public class SwiftKillTracker extends StatTracker +{ + public SwiftKillTracker(Gladiators game) + { + super(game); + } + + @EventHandler + public void blood(FirstBloodEvent e) + { + addStat(e.getPlayer(), "SwiftKill", 1, false, false); + } + +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/UntouchableTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/UntouchableTracker.java new file mode 100644 index 000000000..bd9f68e61 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/UntouchableTracker.java @@ -0,0 +1,55 @@ +package nautilus.game.arcade.game.games.gladiators.trackers; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent; + +import nautilus.game.arcade.game.games.gladiators.Gladiators; +import nautilus.game.arcade.game.games.gladiators.events.RoundStartEvent; +import nautilus.game.arcade.stats.StatTracker; + +/** + * Created by William (WilliamTiger). + * 10/12/15 + */ +public class UntouchableTracker extends StatTracker +{ + private List _noWin; + + public UntouchableTracker(Gladiators game) + { + super(game); + + _noWin = new ArrayList<>(); + } + + @EventHandler + public void onDmg(EntityDamageEvent e) + { + if (e.isCancelled()) + return; + + if (e.getEntity() instanceof Player) + { + _noWin.add(((Player)e.getEntity()).getName()); + } + } + + @EventHandler + public void onEnd(RoundStartEvent e) + { + for (Player p : getGame().GetPlayers(true)) + { + if (_noWin.contains(p.getName())) + return; + + addStat(p, "Untouchable", 1, false, false); + } + + _noWin.clear(); + } + +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java index 83230ab09..b49f5bb06 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java @@ -16,6 +16,7 @@ import mineplex.serverdata.Utility; import nautilus.game.arcade.ArcadeFormat; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.FirstBloodEvent; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerStateChangeEvent; import nautilus.game.arcade.game.Game; @@ -77,6 +78,8 @@ public class GameGemManager implements Listener { game.AddGems(killer, 10, "First Blood", false, false); + Manager.getPluginManager().callEvent(new FirstBloodEvent(killer)); + game.FirstKill = false; game.Announce(F.main("Game", Manager.GetColor(killer) + killer.getName() + " drew first blood!")); From 358664241408f0babf4754d263f2aa47dc466d5d Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 10 Dec 2015 19:32:25 +0000 Subject: [PATCH 44/58] Added back the tutorial. --- .../game/games/gladiators/Gladiators.java | 161 +++++++++++++++++- .../tutorial/TutorialGladiators.java | 135 +++++++++++++++ .../tutorial/TutorialPhaseGladiators.java | 27 +++ 3 files changed, 314 insertions(+), 9 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialGladiators.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index 34baa0a1b..8a4956992 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -1,23 +1,24 @@ package nautilus.game.arcade.game.games.gladiators; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.Map; import java.util.Queue; -import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.FireworkEffect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; +import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; @@ -26,8 +27,11 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilShapes; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -48,6 +52,8 @@ import nautilus.game.arcade.game.games.gladiators.trackers.FlawlessTracker; import nautilus.game.arcade.game.games.gladiators.trackers.PrecisionTracker; import nautilus.game.arcade.game.games.gladiators.trackers.SwiftKillTracker; import nautilus.game.arcade.game.games.gladiators.trackers.UntouchableTracker; +import nautilus.game.arcade.game.games.gladiators.tutorial.TutorialGladiators; +import nautilus.game.arcade.gametutorial.events.GameTutorialStartEvent; import nautilus.game.arcade.kit.Kit; /** @@ -87,6 +93,7 @@ public class Gladiators extends SoloGame DamageTeamSelf = true; HungerSet = 20; DontAllowOverfill = true; + EnableTutorials = true; registerStatTrackers( new BrawlerTracker(this), @@ -101,6 +108,135 @@ public class Gladiators extends SoloGame _roundState = RoundState.WAITING; } + @EventHandler + public void tutorialStart(GameTutorialStartEvent e) + { + Location white = WorldData.GetDataLocs("WHITE").get(0); + Location orange = UtilAlg.findClosest(white, WorldData.GetDataLocs("ORANGE")); + Location pink = UtilAlg.findClosest(orange, WorldData.GetDataLocs("PINK")); + ArrayList spawns = new ArrayList<>(WorldData.GetDataLocs("BROWN")); + Location spawn1 = spawns.get(0); + spawns.remove(spawn1); + Location spawn2 = spawns.get(0); + + e.getTutorial().getPhase(1).setLocation(white); + e.getTutorial().getPhase(1).setTarget(orange); + + CreatureAllowOverride = true; + Zombie zombie1 = (Zombie) WorldData.World.spawnEntity(spawn1, EntityType.ZOMBIE); + Zombie zombie2 = (Zombie) WorldData.World.spawnEntity(spawn2, EntityType.ZOMBIE); + CreatureAllowOverride = false; + for (Zombie zombie : Arrays.asList(zombie1, zombie2)) + { + //DisguisePlayer player = new DisguisePlayer(zombie); + //Manager.GetDisguise().disguise(player); + UtilEnt.Vegetate(zombie); + zombie.getEquipment().setHelmet(ArenaType.ORANGE.getLoadout().getHelmet()); + zombie.getEquipment().setChestplate(ArenaType.ORANGE.getLoadout().getChestplate()); + zombie.getEquipment().setLeggings(ArenaType.ORANGE.getLoadout().getLeggings()); + zombie.getEquipment().setBoots(ArenaType.ORANGE.getLoadout().getBoots()); + zombie.getEquipment().setItemInHand(ArenaType.ORANGE.getLoadout().getSword()); + + UtilEnt.CreatureMoveFast(zombie, orange, 1); + } + + ((TutorialGladiators)e.getTutorial()).setOrange(orange); + ((TutorialGladiators)e.getTutorial()).setPink(pink); + ((TutorialGladiators)e.getTutorial()).setZombie1(zombie1); + ((TutorialGladiators)e.getTutorial()).setZombie2(zombie2); + } + + @EventHandler + public void tutorialUpdate(UpdateEvent e) + { + if (e.getType() != UpdateType.FASTEST) + return; + + if (GetState() != GameState.Prepare) + return; + + if (GetTeamList().get(0).getTutorial() == null) + return; + + TutorialGladiators tutorial = (TutorialGladiators) GetTeamList().get(0).getTutorial(); + + if (tutorial == null) + { + System.out.println("tutorial object null"); + + if (GetTeamList().get(0).getTutorial() == null) + System.out.println("tutorial is null"); + + if (!(GetTeamList().get(0).getTutorial() instanceof TutorialGladiators)) + System.out.println("its not a gladiators one"); + + return; + } + + if (tutorial.hasEnded()) + return; + + UtilEnt.CreatureMoveFast(tutorial.getZombie1(), tutorial.getOrange(), 1); + UtilEnt.CreatureMoveFast(tutorial.getZombie2(), tutorial.getOrange(), 1); + + if (tutorial.getRunning() >= 2000 && !tutorial.isHasHit1()) + { + tutorial.setHasHit1(true); + + // Zombie hit one + +// EntityZombie zombie1 = ((CraftZombie)tutorial.getZombie1()).getHandle(); +// zombie1.world.broadcastEntityEffect(zombie1, (byte) 4); // Attack effect +// + tutorial.getZombie2().damage(1); // Hurt effect + + return; + } + + if (tutorial.getRunning() >= 4000 && !tutorial.isHasHit2()) + { + tutorial.setHasHit2(true); + + // Zombie hit two + +// EntityZombie zombie1 = ((CraftZombie)tutorial.getZombie1()).getHandle(); +// zombie1.world.broadcastEntityEffect(zombie1, (byte) 4); // Attack effect +// + tutorial.getZombie2().damage(1); // Hurt effect + + return; + } + + if (tutorial.getRunning() >= 5000 && !tutorial.getZombie2().isDead()) + { + // Zombie remove time + + tutorial.getZombie2().remove(); + } + + if (tutorial.getRunning() > 5000) + { + // Particles + + if (tutorial.getZombie1() == null || tutorial.getPink() == null) + return; + + UtilEnt.CreatureMoveFast(tutorial.getZombie1(), tutorial.getPink(), 1); + + for (Location loc : UtilShapes.getLinesDistancedPoints(tutorial.getZombie1().getLocation(), tutorial.getPink(), 0.2)) + { + UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, loc, 0.03f, 0.03f, 0.03f, 0, 3, + UtilParticle.ViewDist.LONG, UtilServer.getPlayers()); + } + } + } + + @Override + public void addTutorials() + { + GetTeamList().get(0).setTutorial(new TutorialGladiators(Manager)); + } + @Override public void ParseData() { @@ -240,14 +376,21 @@ public class Gladiators extends SoloGame } } - for (Arena a : _gameArenaSet) - { - if (a.getCapacity() <= 0) - continue; + // Moved the below to tutorial - for (Location l : a.capacitySpawns()) - GetTeamList().get(0).GetSpawns().add(l); - } +// for (Arena a : _gameArenaSet) +// { +// if (a.getCapacity() <= 0) +// continue; +// +// for (Location l : a.capacitySpawns()) +// GetTeamList().get(0).GetSpawns().add(l); +// } + } + + public ArrayList getGameArenaSet() + { + return _gameArenaSet; } public ArrayList getArenasOfType(ArenaType type) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialGladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialGladiators.java new file mode 100644 index 000000000..bb4e97c2e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialGladiators.java @@ -0,0 +1,135 @@ +package nautilus.game.arcade.game.games.gladiators.tutorial; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.entity.Zombie; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.gladiators.Arena; +import nautilus.game.arcade.game.games.gladiators.Gladiators; +import nautilus.game.arcade.gametutorial.GameTutorial; +import nautilus.game.arcade.gametutorial.TutorialPhase; + +/** + * Created by William (WilliamTiger). + * 10/12/15 + */ +public class TutorialGladiators extends GameTutorial +{ + + private Gladiators _host; + + private Location _pink, _orange; + private Zombie _zombie1, _zombie2; + + private boolean hasHit1, hasHit2; + + public TutorialGladiators(ArcadeManager manager) + { + super(manager, new TutorialPhase[]{ + new TutorialPhaseGladiators() + }); + + TeleportOnEnd = false; + + hasHit1 = false; + hasHit2 = false; + + _host = (Gladiators) manager.GetGame(); + } + + public Location getPink() + { + return _pink; + } + + public void setPink(Location pink) + { + _pink = pink; + } + + public Location getOrange() + { + return _orange; + } + + public void setOrange(Location orange) + { + _orange = orange; + } + + public Zombie getZombie1() + { + return _zombie1; + } + + public void setZombie1(Zombie zombie1) + { + _zombie1 = zombie1; + } + + public Zombie getZombie2() + { + return _zombie2; + } + + public void setZombie2(Zombie zombie2) + { + _zombie2 = zombie2; + } + + public boolean isHasHit1() + { + return hasHit1; + } + + public void setHasHit1(boolean hasHit1) + { + this.hasHit1 = hasHit1; + } + + public boolean isHasHit2() + { + return hasHit2; + } + + public void setHasHit2(boolean hasHit2) + { + this.hasHit2 = hasHit2; + } + + @Override + public void onEnd() + { + Gladiators game = (Gladiators) Manager.GetGame(); + + for (Player p : game.GetPlayers(true)) + { + p.teleport(game.GetTeam(p).GetSpawn().clone()); + } + + if (_zombie1 != null) + _zombie1.remove(); + + if (_zombie2 != null) + _zombie2.remove(); + + // Spawns + + _host.GetTeamList().get(0).GetSpawns().clear(); + + for (Arena a : _host.getGameArenaSet()) + { + if (a.getCapacity() <= 0) + continue; + + for (Location l : a.capacitySpawns()) + _host.GetTeamList().get(0).GetSpawns().add(l); + } + + for (Player p : _host.GetPlayers(true)) + { + _host.GetTeam(p).SpawnTeleport(p); + } + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java new file mode 100644 index 000000000..8df753ec4 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java @@ -0,0 +1,27 @@ +package nautilus.game.arcade.game.games.gladiators.tutorial; + +import nautilus.game.arcade.gametutorial.TutorialPhase; +import nautilus.game.arcade.gametutorial.TutorialText; + +/** + * Created by William (WilliamTiger). + * 10/12/15 + */ +public class TutorialPhaseGladiators extends TutorialPhase +{ + + public TutorialPhaseGladiators() + { + super(new TutorialText[]{ + new TutorialText("Defeat your opponent!", 20 * 6, 1), + new TutorialText("Follow the particles...", 20 * 2, 2), + new TutorialText("...to the next arena!", 20 * 2, 3) + }); + } + + @Override + public int ID() + { + return 1; + } +} \ No newline at end of file From 29510880057568433f083d2b2fe5778b88d4fd20 Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 10 Dec 2015 20:48:13 +0000 Subject: [PATCH 45/58] Tutorial changes/additions. --- .../game/games/gladiators/Gladiators.java | 35 +++++++++++++++---- .../tutorial/TutorialGladiators.java | 5 +++ .../tutorial/TutorialPhaseGladiators.java | 6 ++-- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index 8a4956992..f93ff258f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -23,6 +23,8 @@ import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; +import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation; + import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -30,6 +32,7 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilShapes; import mineplex.core.common.util.UtilTextMiddle; @@ -185,9 +188,15 @@ public class Gladiators extends SoloGame // Zombie hit one -// EntityZombie zombie1 = ((CraftZombie)tutorial.getZombie1()).getHandle(); -// zombie1.world.broadcastEntityEffect(zombie1, (byte) 4); // Attack effect -// + PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); + packet.a = tutorial.getZombie1().getEntityId(); + packet.b = 0; + + for (Player p : UtilServer.getPlayers()) + { + UtilPlayer.sendPacket(p, packet); // Attack effect + } + tutorial.getZombie2().damage(1); // Hurt effect return; @@ -199,9 +208,15 @@ public class Gladiators extends SoloGame // Zombie hit two -// EntityZombie zombie1 = ((CraftZombie)tutorial.getZombie1()).getHandle(); -// zombie1.world.broadcastEntityEffect(zombie1, (byte) 4); // Attack effect -// + PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); + packet.a = tutorial.getZombie1().getEntityId(); + packet.b = 0; + + for (Player p : UtilServer.getPlayers()) + { + UtilPlayer.sendPacket(p, packet); // Attack effect + } + tutorial.getZombie2().damage(1); // Hurt effect return; @@ -211,7 +226,13 @@ public class Gladiators extends SoloGame { // Zombie remove time + tutorial.getZombie2().damage(1); + UtilFirework.playFirework(tutorial.getZombie2().getLocation(), FireworkEffect.Type.BALL, Color.ORANGE, false, false); tutorial.getZombie2().remove(); + + Arena gateArena = getArenaByMid(tutorial.getOrange()); + for (Location loc : gateArena.getDoorBlocks()) + loc.getBlock().setType(Material.AIR); // Manual door open. } if (tutorial.getRunning() > 5000) @@ -295,7 +316,7 @@ public class Gladiators extends SoloGame { _gameArenaSet = new ArrayList<>(); - GetTeamList().get(0).GetSpawns().clear(); // Clear the original game spawns. + //GetTeamList().get(0).GetSpawns().clear(); // Clear the original game spawns. int neededSpawns = Math.min(GetPlayers(true).size(), 16); // Quick fix Arena masterNode = getArenasOfType(ArenaType.RED).get(0); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialGladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialGladiators.java index bb4e97c2e..48bfebcba 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialGladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialGladiators.java @@ -1,6 +1,7 @@ package nautilus.game.arcade.game.games.gladiators.tutorial; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.entity.Zombie; @@ -114,6 +115,10 @@ public class TutorialGladiators extends GameTutorial if (_zombie2 != null) _zombie2.remove(); + Arena gateArena = _host.getArenaByMid(getOrange()); + for (Location loc : gateArena.getDoorBlocks()) + loc.getBlock().setType(Material.FENCE); // Manual door close. + // Spawns _host.GetTeamList().get(0).GetSpawns().clear(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java index 8df753ec4..2299651f3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java @@ -13,9 +13,9 @@ public class TutorialPhaseGladiators extends TutorialPhase public TutorialPhaseGladiators() { super(new TutorialText[]{ - new TutorialText("Defeat your opponent!", 20 * 6, 1), - new TutorialText("Follow the particles...", 20 * 2, 2), - new TutorialText("...to the next arena!", 20 * 2, 3) + new TutorialText("Defeat your opponent!", 20 * 5, 1), + new TutorialText("", 20 * 2, 2), + new TutorialText("") }); } From 8d7b03e3f64fc1e94f8c596e3974c07024e48762 Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 10 Dec 2015 20:52:41 +0000 Subject: [PATCH 46/58] Added the ability to have title AND subtitle per TutorialText. --- .../arcade/gametutorial/TutorialPhase.java | 2 +- .../arcade/gametutorial/TutorialText.java | 25 ++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java index b140b79bc..222028622 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java @@ -136,7 +136,7 @@ public abstract class TutorialPhase i++; } displayMessage(text); - UtilTextMiddle.display("", text.getText(), 0, text.getStayTime(), 0, players); + UtilTextMiddle.display((text.getBigText() == null ? "" : text.getBigText()), text.getText(), 0, text.getStayTime(), 0, players); try { Thread.sleep(text.getStayTime() * 50); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java index dba1d39a6..cc438d484 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java @@ -7,6 +7,7 @@ public class TutorialText { private String _text; + private String _bigText; private int _stayTime; private int _id; private Sound _sound; @@ -33,6 +34,24 @@ public class TutorialText { this(text, stayTime, id, Sound.NOTE_PLING); } + + public TutorialText(String text, String bigText, int id) + { + this(text, (int) (Math.round(1.5 * text.length()) + 25), id, Sound.NOTE_PLING); + _bigText = bigText; + } + + public TutorialText(String text, String bigText, int id, Sound sound) + { + this(text, (int) (Math.round(1.5 * text.length()) + 25), id, sound); + _bigText = bigText; + } + + public TutorialText(String text, String bigText, int stayTime, int id) + { + this(text, stayTime, id, Sound.NOTE_PLING); + _bigText = bigText; + } public String getText() { @@ -58,5 +77,9 @@ public class TutorialText { _text = text; } - + + public String getBigText() + { + return _bigText; + } } From 4cf33eef056ddb3996b754a92e727fa8ae773f07 Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 10 Dec 2015 21:32:14 +0000 Subject: [PATCH 47/58] Tutorial changes! --- .../game/games/gladiators/Gladiators.java | 28 +++++++++++++++---- .../tutorial/TutorialPhaseGladiators.java | 4 +-- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index f93ff258f..260f7bd2c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -7,12 +7,14 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.Map; import java.util.Queue; +import java.util.UUID; import org.bukkit.Color; import org.bukkit.FireworkEffect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.entity.Zombie; @@ -25,8 +27,11 @@ import org.bukkit.inventory.ItemStack; import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation; +import com.mojang.authlib.GameProfile; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.ProfileLoader; +import mineplex.core.common.util.UUIDFetcher; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; @@ -36,6 +41,7 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilShapes; import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -131,8 +137,11 @@ public class Gladiators extends SoloGame CreatureAllowOverride = false; for (Zombie zombie : Arrays.asList(zombie1, zombie2)) { - //DisguisePlayer player = new DisguisePlayer(zombie); - //Manager.GetDisguise().disguise(player); + GameProfile tiger = new ProfileLoader(UUIDFetcher.getUUIDOf("WilliamTiger").toString(), "WilliamTiger").loadProfile(); + GameProfile random = stealGameProfile(); + DisguisePlayer player = new DisguisePlayer(zombie, (zombie.equals(zombie1) ? tiger : random)); + Manager.GetDisguise().disguise(player); + UtilEnt.Vegetate(zombie); zombie.getEquipment().setHelmet(ArenaType.ORANGE.getLoadout().getHelmet()); zombie.getEquipment().setChestplate(ArenaType.ORANGE.getLoadout().getChestplate()); @@ -149,6 +158,14 @@ public class Gladiators extends SoloGame ((TutorialGladiators)e.getTutorial()).setZombie2(zombie2); } + private GameProfile stealGameProfile() + { + Player random = UtilServer.getPlayers()[0]; + GameProfile gp = new GameProfile(UUID.randomUUID(), random.getName()); + gp.getProperties().putAll(((CraftPlayer)random).getHandle().getProfile().getProperties()); + return gp; + } + @EventHandler public void tutorialUpdate(UpdateEvent e) { @@ -189,7 +206,7 @@ public class Gladiators extends SoloGame // Zombie hit one PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); - packet.a = tutorial.getZombie1().getEntityId(); + packet.a = Manager.GetDisguise().getDisguise(tutorial.getZombie1()).GetEntityId(); packet.b = 0; for (Player p : UtilServer.getPlayers()) @@ -209,7 +226,7 @@ public class Gladiators extends SoloGame // Zombie hit two PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); - packet.a = tutorial.getZombie1().getEntityId(); + packet.a = Manager.GetDisguise().getDisguise(tutorial.getZombie1()).GetEntityId(); packet.b = 0; for (Player p : UtilServer.getPlayers()) @@ -876,7 +893,8 @@ public class Gladiators extends SoloGame if (a.getState() == ArenaState.FIGHTING) start = a.getStateTime(); } - int time = Math.round((float)((60000L + start) - System.currentTimeMillis())); + double number = ((start + 60000) - System.currentTimeMillis()); + int time = (int)(number / 1000.0 + 0.5); if (time < 0) Scoreboard.Write("Poison Active"); else diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java index 2299651f3..80ff77bca 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java @@ -13,9 +13,9 @@ public class TutorialPhaseGladiators extends TutorialPhase public TutorialPhaseGladiators() { super(new TutorialText[]{ - new TutorialText("Defeat your opponent!", 20 * 5, 1), + new TutorialText("Defeat your opponent!", 20 * 4, 1), new TutorialText("", 20 * 2, 2), - new TutorialText("") + new TutorialText("To the next arena!", "Follow the particles", 20 * 4, 3) }); } From 626a81284454339bbca2159ace6ec3ba2096a333 Mon Sep 17 00:00:00 2001 From: William Burns Date: Fri, 11 Dec 2015 00:40:54 +0000 Subject: [PATCH 48/58] Many changes --- .../mineplex/core/common/util/UtilItem.java | 9 + .../mineplex/core/gadget/GadgetManager.java | 9 + .../arcade/game/games/gladiators/Arena.java | 16 +- .../game/games/gladiators/Gladiators.java | 219 ++++++++++-------- .../trackers/UntouchableTracker.java | 2 +- .../tutorial/TutorialGladiators.java | 55 +++-- .../tutorial/TutorialPhaseGladiators.java | 18 +- 7 files changed, 208 insertions(+), 120 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java index c82d37f9f..5a300322c 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java @@ -12,6 +12,7 @@ import java.util.Map.Entry; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; import mineplex.core.common.structs.ItemContainer; @@ -1116,4 +1117,12 @@ public class UtilItem { return _materials.containsKey(material); } + + public static ItemStack makeUnbreakable(ItemStack i) + { + ItemMeta im = i.getItemMeta(); + im.spigot().setUnbreakable(true); + i.setItemMeta(im); + return i; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index bb17d1e2f..f6ae08bb5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -298,6 +298,15 @@ public class GadgetManager extends MiniPlugin } } } + + public void DisableParticles() + { + for (Gadget gadget : _gadgets.get(GadgetType.Particle)) + { + for (Player player : UtilServer.getPlayers()) + gadget.Disable(player); + } + } public void DisableAll() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java index 52079b41d..63191e213 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java @@ -44,6 +44,8 @@ public class Arena private HashMap> _particles; + private ArrayList _sentParticles; + public Arena(Gladiators host, Location mid, ArenaType colour) { _host = host; @@ -59,6 +61,7 @@ public class Arena _stateTime = System.currentTimeMillis(); _particles = new HashMap<>(); _doBye = false; + _sentParticles = new ArrayList<>(); setupSpawns(); } @@ -256,6 +259,8 @@ public class Arena { _isOpenDoor = true; + _sentParticles.clear(); + _host.Manager.getScheduler().scheduleSyncDelayedTask(_host.Manager.getPlugin(), () -> { for (Location loc : _doorBlocks) @@ -281,7 +286,11 @@ public class Arena for (Player p : getPastPlayers()) { - UtilTextMiddle.display(C.cAqua + "Please Wait", "The next round will start shortly", 0, 20, 0, p); + if (_sentParticles.contains(p)) + continue; + + UtilTextMiddle.display(C.cAqua + "Please Wait", "The next round will start shortly", 0, 20 * 100, 0, p); + _sentParticles.add(p); } } else if (_state.equals(ArenaState.FIGHTING)) @@ -308,7 +317,10 @@ public class Arena { for (Player p : getPastPlayers()) { - UtilTextMiddle.display(C.cGreen + "Next Battle", "Follow the particles", 0, 20, 0, p); + if (_sentParticles.contains(p)) + continue; + + UtilTextMiddle.display(C.cGreen + "Next Battle", "Follow the particles", 0, 20 * 100, 0, p); } if (UtilTime.elapsed(_stateTime, 15000)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index 260f7bd2c..4c79a20bd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -5,21 +5,26 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; +import java.util.List; import java.util.Map; import java.util.Queue; -import java.util.UUID; +import java.util.Random; import org.bukkit.Color; import org.bukkit.FireworkEffect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; +import org.bukkit.entity.Golem; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.entity.Villager; import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -36,6 +41,7 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -120,8 +126,11 @@ public class Gladiators extends SoloGame @EventHandler public void tutorialStart(GameTutorialStartEvent e) { + Manager.getCosmeticManager().getGadgetManager().DisableParticles(); // Particles blocking tutorial... + Location white = WorldData.GetDataLocs("WHITE").get(0); - Location orange = UtilAlg.findClosest(white, WorldData.GetDataLocs("ORANGE")); + Location purple = WorldData.GetDataLocs("PURPLE").get(0); + Location orange = UtilAlg.findClosest(purple, WorldData.GetDataLocs("ORANGE")); Location pink = UtilAlg.findClosest(orange, WorldData.GetDataLocs("PINK")); ArrayList spawns = new ArrayList<>(WorldData.GetDataLocs("BROWN")); Location spawn1 = spawns.get(0); @@ -129,41 +138,46 @@ public class Gladiators extends SoloGame Location spawn2 = spawns.get(0); e.getTutorial().getPhase(1).setLocation(white); - e.getTutorial().getPhase(1).setTarget(orange); + e.getTutorial().getPhase(1).setTarget(purple); CreatureAllowOverride = true; - Zombie zombie1 = (Zombie) WorldData.World.spawnEntity(spawn1, EntityType.ZOMBIE); - Zombie zombie2 = (Zombie) WorldData.World.spawnEntity(spawn2, EntityType.ZOMBIE); + Zombie zombie = (Zombie) WorldData.World.spawnEntity(spawn1, EntityType.ZOMBIE); + Golem villager = (Golem) WorldData.World.spawnEntity(spawn2, EntityType.IRON_GOLEM); CreatureAllowOverride = false; - for (Zombie zombie : Arrays.asList(zombie1, zombie2)) + for (LivingEntity ent : Arrays.asList(zombie, villager)) { GameProfile tiger = new ProfileLoader(UUIDFetcher.getUUIDOf("WilliamTiger").toString(), "WilliamTiger").loadProfile(); GameProfile random = stealGameProfile(); - DisguisePlayer player = new DisguisePlayer(zombie, (zombie.equals(zombie1) ? tiger : random)); + DisguisePlayer player = new DisguisePlayer(ent, (ent.equals(zombie) ? random : tiger)); Manager.GetDisguise().disguise(player); - UtilEnt.Vegetate(zombie); - zombie.getEquipment().setHelmet(ArenaType.ORANGE.getLoadout().getHelmet()); - zombie.getEquipment().setChestplate(ArenaType.ORANGE.getLoadout().getChestplate()); - zombie.getEquipment().setLeggings(ArenaType.ORANGE.getLoadout().getLeggings()); - zombie.getEquipment().setBoots(ArenaType.ORANGE.getLoadout().getBoots()); - zombie.getEquipment().setItemInHand(ArenaType.ORANGE.getLoadout().getSword()); + ent.getEquipment().setHelmet(ArenaType.ORANGE.getLoadout().getHelmet()); + ent.getEquipment().setChestplate(ArenaType.ORANGE.getLoadout().getChestplate()); + ent.getEquipment().setLeggings(ArenaType.ORANGE.getLoadout().getLeggings()); + ent.getEquipment().setBoots(ArenaType.ORANGE.getLoadout().getBoots()); + ent.getEquipment().setItemInHand(ArenaType.ORANGE.getLoadout().getSword()); - UtilEnt.CreatureMoveFast(zombie, orange, 1); + if (ent.equals(villager)) + ent.setHealth(100); + + //UtilEnt.CreatureMoveFast(zombie, purple, 1); } - ((TutorialGladiators)e.getTutorial()).setOrange(orange); - ((TutorialGladiators)e.getTutorial()).setPink(pink); - ((TutorialGladiators)e.getTutorial()).setZombie1(zombie1); - ((TutorialGladiators)e.getTutorial()).setZombie2(zombie2); + zombie.setTarget(villager); + villager.setTarget(zombie); + + ((TutorialGladiators) e.getTutorial()).setOrange(orange); + ((TutorialGladiators) e.getTutorial()).setPink(pink); + ((TutorialGladiators) e.getTutorial()).setZombie(zombie); + ((TutorialGladiators) e.getTutorial()).setVillager(villager); + ((TutorialGladiators) e.getTutorial()).setPurple(purple); } private GameProfile stealGameProfile() { - Player random = UtilServer.getPlayers()[0]; - GameProfile gp = new GameProfile(UUID.randomUUID(), random.getName()); - gp.getProperties().putAll(((CraftPlayer)random).getHandle().getProfile().getProperties()); - return gp; + List steal = Arrays.asList("Chiss", "Sigils", "Mysticate", "b2_mp", "Bitjump"); + String random = steal.get(new Random().nextInt(steal.size())); + return new ProfileLoader(UUIDFetcher.getUUIDOf(random).toString(), random).loadProfile(); } @EventHandler @@ -196,72 +210,14 @@ public class Gladiators extends SoloGame if (tutorial.hasEnded()) return; - UtilEnt.CreatureMoveFast(tutorial.getZombie1(), tutorial.getOrange(), 1); - UtilEnt.CreatureMoveFast(tutorial.getZombie2(), tutorial.getOrange(), 1); - - if (tutorial.getRunning() >= 2000 && !tutorial.isHasHit1()) + if (tutorial.isParticleStage()) { - tutorial.setHasHit1(true); + if (tutorial.getZombie() != null) + tutorial.getZombie().damage(200); - // Zombie hit one + UtilEnt.CreatureMoveFast(tutorial.getVillager(), tutorial.getPink(), 1F); - PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); - packet.a = Manager.GetDisguise().getDisguise(tutorial.getZombie1()).GetEntityId(); - packet.b = 0; - - for (Player p : UtilServer.getPlayers()) - { - UtilPlayer.sendPacket(p, packet); // Attack effect - } - - tutorial.getZombie2().damage(1); // Hurt effect - - return; - } - - if (tutorial.getRunning() >= 4000 && !tutorial.isHasHit2()) - { - tutorial.setHasHit2(true); - - // Zombie hit two - - PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); - packet.a = Manager.GetDisguise().getDisguise(tutorial.getZombie1()).GetEntityId(); - packet.b = 0; - - for (Player p : UtilServer.getPlayers()) - { - UtilPlayer.sendPacket(p, packet); // Attack effect - } - - tutorial.getZombie2().damage(1); // Hurt effect - - return; - } - - if (tutorial.getRunning() >= 5000 && !tutorial.getZombie2().isDead()) - { - // Zombie remove time - - tutorial.getZombie2().damage(1); - UtilFirework.playFirework(tutorial.getZombie2().getLocation(), FireworkEffect.Type.BALL, Color.ORANGE, false, false); - tutorial.getZombie2().remove(); - - Arena gateArena = getArenaByMid(tutorial.getOrange()); - for (Location loc : gateArena.getDoorBlocks()) - loc.getBlock().setType(Material.AIR); // Manual door open. - } - - if (tutorial.getRunning() > 5000) - { - // Particles - - if (tutorial.getZombie1() == null || tutorial.getPink() == null) - return; - - UtilEnt.CreatureMoveFast(tutorial.getZombie1(), tutorial.getPink(), 1); - - for (Location loc : UtilShapes.getLinesDistancedPoints(tutorial.getZombie1().getLocation(), tutorial.getPink(), 0.2)) + for (Location loc : UtilShapes.getLinesDistancedPoints(tutorial.getVillager().getLocation(), tutorial.getPink(), 0.2)) { UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, loc, 0.03f, 0.03f, 0.03f, 0, 3, UtilParticle.ViewDist.LONG, UtilServer.getPlayers()); @@ -563,8 +519,8 @@ public class Gladiators extends SoloGame for (Player p : a.getPastPlayers()) { p.sendMessage(ArcadeFormat.Line); - p.sendMessage(" " + C.cWhite + C.Bold + "You have a bye!"); - p.sendMessage(" " + C.cGreen + "You automatically go through this round."); + p.sendMessage(" " + C.cWhite + C.Bold + "Please Wait!"); + p.sendMessage(" " + C.cGreen + "Your fight will begin next round."); p.sendMessage(ArcadeFormat.Line); } } @@ -697,8 +653,8 @@ public class Gladiators extends SoloGame p.getInventory().clear(); p.getInventory().setArmorContents(null); - p.getInventory().setItem(0, type.getLoadout().getSword()); - p.getInventory().setItem(1, type.getLoadout().getRod()); + p.getInventory().setItem(0, UtilItem.makeUnbreakable(type.getLoadout().getSword())); + p.getInventory().setItem(1, UtilItem.makeUnbreakable(type.getLoadout().getRod())); p.getInventory().setItem(2, type.getLoadout().getBow()); p.getInventory().setItem(8, type.getLoadout().getArrows()); @@ -794,38 +750,94 @@ public class Gladiators extends SoloGame else if (_roundState.equals(RoundState.STARTING_3)) { _roundState = RoundState.STARTING_2; - UtilTextMiddle.display(C.cGreen + "3", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0); - for (Player p : UtilServer.getPlayers()) + for (Arena a : _gameArenaSet) + { + if (a.getState() != ArenaState.FIGHTING) + continue; + + for (Player p : a.getPastPlayers()) + { + UtilTextMiddle.display(C.cGreen + "3", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0, p); + p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1f, 1f); + } + } + + for (Player p : GetPlayers(false)) + { + UtilTextMiddle.display(C.cGreen + "3", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0, p); p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1f, 1f); + } + return; } else if (_roundState.equals(RoundState.STARTING_2)) { - _roundState = RoundState.STARTING_1; - UtilTextMiddle.display(C.cYellow + "2", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0); + for (Arena a : _gameArenaSet) + { + if (a.getState() != ArenaState.FIGHTING) + continue; - for (Player p : UtilServer.getPlayers()) + for (Player p : a.getPastPlayers()) + { + UtilTextMiddle.display(C.cYellow + "2", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0, p); + p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1f, 1f); + } + } + + for (Player p : GetPlayers(false)) + { + UtilTextMiddle.display(C.cYellow + "2", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0, p); p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1f, 1f); + } + return; } else if (_roundState.equals(RoundState.STARTING_1)) { _roundState = RoundState.STARTED; - UtilTextMiddle.display(C.cGold + "1", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0); + for (Arena a : _gameArenaSet) + { + if (a.getState() != ArenaState.FIGHTING) + continue; - for (Player p : UtilServer.getPlayers()) + for (Player p : a.getPastPlayers()) + { + UtilTextMiddle.display(C.cGold + "1", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0, p); + p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1f, 1f); + } + } + + for (Player p : GetPlayers(false)) + { + UtilTextMiddle.display(C.cGold + "1", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0, p); p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1f, 1f); + } + return; } else if (_roundState.equals(RoundState.STARTED)) { _roundState = RoundState.FIGHTING; - UtilTextMiddle.display(C.cRed + "FIGHT", C.cGreen + C.Bold + getRoundNotation(), 0, 40, 0); + for (Arena a : _gameArenaSet) + { + if (a.getState() != ArenaState.FIGHTING) + continue; + + for (Player p : a.getPastPlayers()) + { + UtilTextMiddle.display(C.cRed + "FIGHT", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0, p); + p.playSound(p.getLocation(), Sound.NOTE_BASS, 1f, 1f); + } + } + + for (Player p : GetPlayers(false)) + { + UtilTextMiddle.display(C.cRed + "FIGHT", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0, p); + p.playSound(p.getLocation(), Sound.NOTE_BASS, 1f, 1f); + } - for (Player p : UtilServer.getPlayers()) - p.playSound(p.getLocation(), Sound.NOTE_PLING, 2f, 2f); return; } } @@ -993,4 +1005,11 @@ public class Gladiators extends SoloGame } } } + + @EventHandler + public void tutorialDie(EntityDeathEvent e) + { + e.getDrops().clear(); + e.setDroppedExp(0); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/UntouchableTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/UntouchableTracker.java index bd9f68e61..44115ca72 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/UntouchableTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/UntouchableTracker.java @@ -44,7 +44,7 @@ public class UntouchableTracker extends StatTracker for (Player p : getGame().GetPlayers(true)) { if (_noWin.contains(p.getName())) - return; + continue; addStat(p, "Untouchable", 1, false, false); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialGladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialGladiators.java index 48bfebcba..f26bbe8d2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialGladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialGladiators.java @@ -2,7 +2,9 @@ package nautilus.game.arcade.game.games.gladiators.tutorial; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.entity.Golem; import org.bukkit.entity.Player; +import org.bukkit.entity.Villager; import org.bukkit.entity.Zombie; import nautilus.game.arcade.ArcadeManager; @@ -20,8 +22,11 @@ public class TutorialGladiators extends GameTutorial private Gladiators _host; - private Location _pink, _orange; - private Zombie _zombie1, _zombie2; + private Location _pink, _orange, _purple; + private Zombie _zombie; + private Golem _villager; + + private boolean _particleStage; private boolean hasHit1, hasHit2; @@ -36,6 +41,8 @@ public class TutorialGladiators extends GameTutorial hasHit1 = false; hasHit2 = false; + _particleStage = false; + _host = (Gladiators) manager.GetGame(); } @@ -59,24 +66,24 @@ public class TutorialGladiators extends GameTutorial _orange = orange; } - public Zombie getZombie1() + public Zombie getZombie() { - return _zombie1; + return _zombie; } - public void setZombie1(Zombie zombie1) + public void setZombie(Zombie zombie) { - _zombie1 = zombie1; + _zombie = zombie; } - public Zombie getZombie2() + public Golem getVillager() { - return _zombie2; + return _villager; } - public void setZombie2(Zombie zombie2) + public void setVillager(Golem villager) { - _zombie2 = zombie2; + _villager = villager; } public boolean isHasHit1() @@ -99,6 +106,26 @@ public class TutorialGladiators extends GameTutorial this.hasHit2 = hasHit2; } + public Location getPurple() + { + return _purple; + } + + public void setPurple(Location purple) + { + _purple = purple; + } + + public boolean isParticleStage() + { + return _particleStage; + } + + public void setParticleStage(boolean particleStage) + { + _particleStage = particleStage; + } + @Override public void onEnd() { @@ -109,11 +136,11 @@ public class TutorialGladiators extends GameTutorial p.teleport(game.GetTeam(p).GetSpawn().clone()); } - if (_zombie1 != null) - _zombie1.remove(); + if (_zombie != null) + _zombie.remove(); - if (_zombie2 != null) - _zombie2.remove(); + if (_villager != null) + _villager.remove(); Arena gateArena = _host.getArenaByMid(getOrange()); for (Location loc : gateArena.getDoorBlocks()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java index 80ff77bca..ca18b6c09 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.gladiators.tutorial; +import mineplex.core.common.util.C; import nautilus.game.arcade.gametutorial.TutorialPhase; import nautilus.game.arcade.gametutorial.TutorialText; @@ -10,12 +11,14 @@ import nautilus.game.arcade.gametutorial.TutorialText; public class TutorialPhaseGladiators extends TutorialPhase { + private static final TutorialText TUT1 = new TutorialText(C.cGreen + "Defeat your opponent!", 20 * 3, 1); + private static final TutorialText TUT2 = new TutorialText("", 20 * 4, 2); + private static final TutorialText TUT3 = new TutorialText(C.cGreen + "To the next arena!", C.cGreen + "Follow the particles", 20 * 3, 3); + public TutorialPhaseGladiators() { super(new TutorialText[]{ - new TutorialText("Defeat your opponent!", 20 * 4, 1), - new TutorialText("", 20 * 2, 2), - new TutorialText("To the next arena!", "Follow the particles", 20 * 4, 3) + TUT1, TUT2, TUT3 }); } @@ -24,4 +27,13 @@ public class TutorialPhaseGladiators extends TutorialPhase { return 1; } + + @Override + public void onMessageDisplay(TutorialText text) + { + if (text.equals(TUT3)) + { + ((TutorialGladiators)getTutorial()).setParticleStage(true); + } + } } \ No newline at end of file From dda5ac6728a182a48457589bbc85a04d77cce6f9 Mon Sep 17 00:00:00 2001 From: William Burns Date: Fri, 11 Dec 2015 01:20:36 +0000 Subject: [PATCH 49/58] work --- .../game/games/gladiators/Gladiators.java | 99 +--------------- .../tutorial/TutorialGladiators.java | 112 ------------------ .../tutorial/TutorialPhaseGladiators.java | 15 +-- 3 files changed, 6 insertions(+), 220 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index 4c79a20bd..6b82e972a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -128,101 +128,10 @@ public class Gladiators extends SoloGame { Manager.getCosmeticManager().getGadgetManager().DisableParticles(); // Particles blocking tutorial... - Location white = WorldData.GetDataLocs("WHITE").get(0); - Location purple = WorldData.GetDataLocs("PURPLE").get(0); - Location orange = UtilAlg.findClosest(purple, WorldData.GetDataLocs("ORANGE")); - Location pink = UtilAlg.findClosest(orange, WorldData.GetDataLocs("PINK")); - ArrayList spawns = new ArrayList<>(WorldData.GetDataLocs("BROWN")); - Location spawn1 = spawns.get(0); - spawns.remove(spawn1); - Location spawn2 = spawns.get(0); + Location loc = WorldData.GetDataLocs("RED").get(0); - e.getTutorial().getPhase(1).setLocation(white); - e.getTutorial().getPhase(1).setTarget(purple); - - CreatureAllowOverride = true; - Zombie zombie = (Zombie) WorldData.World.spawnEntity(spawn1, EntityType.ZOMBIE); - Golem villager = (Golem) WorldData.World.spawnEntity(spawn2, EntityType.IRON_GOLEM); - CreatureAllowOverride = false; - for (LivingEntity ent : Arrays.asList(zombie, villager)) - { - GameProfile tiger = new ProfileLoader(UUIDFetcher.getUUIDOf("WilliamTiger").toString(), "WilliamTiger").loadProfile(); - GameProfile random = stealGameProfile(); - DisguisePlayer player = new DisguisePlayer(ent, (ent.equals(zombie) ? random : tiger)); - Manager.GetDisguise().disguise(player); - - ent.getEquipment().setHelmet(ArenaType.ORANGE.getLoadout().getHelmet()); - ent.getEquipment().setChestplate(ArenaType.ORANGE.getLoadout().getChestplate()); - ent.getEquipment().setLeggings(ArenaType.ORANGE.getLoadout().getLeggings()); - ent.getEquipment().setBoots(ArenaType.ORANGE.getLoadout().getBoots()); - ent.getEquipment().setItemInHand(ArenaType.ORANGE.getLoadout().getSword()); - - if (ent.equals(villager)) - ent.setHealth(100); - - //UtilEnt.CreatureMoveFast(zombie, purple, 1); - } - - zombie.setTarget(villager); - villager.setTarget(zombie); - - ((TutorialGladiators) e.getTutorial()).setOrange(orange); - ((TutorialGladiators) e.getTutorial()).setPink(pink); - ((TutorialGladiators) e.getTutorial()).setZombie(zombie); - ((TutorialGladiators) e.getTutorial()).setVillager(villager); - ((TutorialGladiators) e.getTutorial()).setPurple(purple); - } - - private GameProfile stealGameProfile() - { - List steal = Arrays.asList("Chiss", "Sigils", "Mysticate", "b2_mp", "Bitjump"); - String random = steal.get(new Random().nextInt(steal.size())); - return new ProfileLoader(UUIDFetcher.getUUIDOf(random).toString(), random).loadProfile(); - } - - @EventHandler - public void tutorialUpdate(UpdateEvent e) - { - if (e.getType() != UpdateType.FASTEST) - return; - - if (GetState() != GameState.Prepare) - return; - - if (GetTeamList().get(0).getTutorial() == null) - return; - - TutorialGladiators tutorial = (TutorialGladiators) GetTeamList().get(0).getTutorial(); - - if (tutorial == null) - { - System.out.println("tutorial object null"); - - if (GetTeamList().get(0).getTutorial() == null) - System.out.println("tutorial is null"); - - if (!(GetTeamList().get(0).getTutorial() instanceof TutorialGladiators)) - System.out.println("its not a gladiators one"); - - return; - } - - if (tutorial.hasEnded()) - return; - - if (tutorial.isParticleStage()) - { - if (tutorial.getZombie() != null) - tutorial.getZombie().damage(200); - - UtilEnt.CreatureMoveFast(tutorial.getVillager(), tutorial.getPink(), 1F); - - for (Location loc : UtilShapes.getLinesDistancedPoints(tutorial.getVillager().getLocation(), tutorial.getPink(), 0.2)) - { - UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, loc, 0.03f, 0.03f, 0.03f, 0, 3, - UtilParticle.ViewDist.LONG, UtilServer.getPlayers()); - } - } + e.getTutorial().getPhase(1).setLocation(loc.add(0, 50, 0)); + e.getTutorial().getPhase(1).setTarget(loc); } @Override @@ -773,6 +682,8 @@ public class Gladiators extends SoloGame } else if (_roundState.equals(RoundState.STARTING_2)) { + _roundState = RoundState.STARTING_1; + for (Arena a : _gameArenaSet) { if (a.getState() != ArenaState.FIGHTING) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialGladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialGladiators.java index f26bbe8d2..3829cc68d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialGladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialGladiators.java @@ -22,14 +22,6 @@ public class TutorialGladiators extends GameTutorial private Gladiators _host; - private Location _pink, _orange, _purple; - private Zombie _zombie; - private Golem _villager; - - private boolean _particleStage; - - private boolean hasHit1, hasHit2; - public TutorialGladiators(ArcadeManager manager) { super(manager, new TutorialPhase[]{ @@ -38,116 +30,12 @@ public class TutorialGladiators extends GameTutorial TeleportOnEnd = false; - hasHit1 = false; - hasHit2 = false; - - _particleStage = false; - _host = (Gladiators) manager.GetGame(); } - public Location getPink() - { - return _pink; - } - - public void setPink(Location pink) - { - _pink = pink; - } - - public Location getOrange() - { - return _orange; - } - - public void setOrange(Location orange) - { - _orange = orange; - } - - public Zombie getZombie() - { - return _zombie; - } - - public void setZombie(Zombie zombie) - { - _zombie = zombie; - } - - public Golem getVillager() - { - return _villager; - } - - public void setVillager(Golem villager) - { - _villager = villager; - } - - public boolean isHasHit1() - { - return hasHit1; - } - - public void setHasHit1(boolean hasHit1) - { - this.hasHit1 = hasHit1; - } - - public boolean isHasHit2() - { - return hasHit2; - } - - public void setHasHit2(boolean hasHit2) - { - this.hasHit2 = hasHit2; - } - - public Location getPurple() - { - return _purple; - } - - public void setPurple(Location purple) - { - _purple = purple; - } - - public boolean isParticleStage() - { - return _particleStage; - } - - public void setParticleStage(boolean particleStage) - { - _particleStage = particleStage; - } - @Override public void onEnd() { - Gladiators game = (Gladiators) Manager.GetGame(); - - for (Player p : game.GetPlayers(true)) - { - p.teleport(game.GetTeam(p).GetSpawn().clone()); - } - - if (_zombie != null) - _zombie.remove(); - - if (_villager != null) - _villager.remove(); - - Arena gateArena = _host.getArenaByMid(getOrange()); - for (Location loc : gateArena.getDoorBlocks()) - loc.getBlock().setType(Material.FENCE); // Manual door close. - - // Spawns - _host.GetTeamList().get(0).GetSpawns().clear(); for (Arena a : _host.getGameArenaSet()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java index ca18b6c09..105119a83 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java @@ -11,14 +11,10 @@ import nautilus.game.arcade.gametutorial.TutorialText; public class TutorialPhaseGladiators extends TutorialPhase { - private static final TutorialText TUT1 = new TutorialText(C.cGreen + "Defeat your opponent!", 20 * 3, 1); - private static final TutorialText TUT2 = new TutorialText("", 20 * 4, 2); - private static final TutorialText TUT3 = new TutorialText(C.cGreen + "To the next arena!", C.cGreen + "Follow the particles", 20 * 3, 3); - public TutorialPhaseGladiators() { super(new TutorialText[]{ - TUT1, TUT2, TUT3 + new TutorialText(C.cGreen + "Defeat your opponent to advance", C.cGreen + "Gladiators!", 20 * 5, 1) }); } @@ -27,13 +23,4 @@ public class TutorialPhaseGladiators extends TutorialPhase { return 1; } - - @Override - public void onMessageDisplay(TutorialText text) - { - if (text.equals(TUT3)) - { - ((TutorialGladiators)getTutorial()).setParticleStage(true); - } - } } \ No newline at end of file From f8d7aeb5eaae5ddb59fd1ba1d5da5e58fabef5e0 Mon Sep 17 00:00:00 2001 From: William Burns Date: Fri, 11 Dec 2015 01:32:32 +0000 Subject: [PATCH 50/58] before revert --- .../nautilus/game/arcade/game/games/gladiators/Gladiators.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index 6b82e972a..deaa8ace6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -130,7 +130,7 @@ public class Gladiators extends SoloGame Location loc = WorldData.GetDataLocs("RED").get(0); - e.getTutorial().getPhase(1).setLocation(loc.add(0, 50, 0)); + e.getTutorial().getPhase(1).setLocation(loc.clone().add(0, 50, 0)); e.getTutorial().getPhase(1).setTarget(loc); } From 2694787590ec3c836feb3861b03a4e976abc2d35 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Thu, 10 Dec 2015 20:59:57 -0500 Subject: [PATCH 51/58] Reverting --- .../mineplex/core/common/util/UtilItem.java | 9 - .../mineplex/core/gadget/GadgetManager.java | 9 - .../arcade/game/games/gladiators/Arena.java | 16 +- .../game/games/gladiators/Gladiators.java | 250 +++++++++++------- .../trackers/UntouchableTracker.java | 2 +- .../tutorial/TutorialGladiators.java | 89 ++++++- .../tutorial/TutorialPhaseGladiators.java | 5 +- .../arcade/gametutorial/TutorialPhase.java | 2 +- .../arcade/gametutorial/TutorialText.java | 25 +- 9 files changed, 255 insertions(+), 152 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java index 5a300322c..c82d37f9f 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java @@ -12,7 +12,6 @@ import java.util.Map.Entry; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; import mineplex.core.common.structs.ItemContainer; @@ -1117,12 +1116,4 @@ public class UtilItem { return _materials.containsKey(material); } - - public static ItemStack makeUnbreakable(ItemStack i) - { - ItemMeta im = i.getItemMeta(); - im.spigot().setUnbreakable(true); - i.setItemMeta(im); - return i; - } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index f6ae08bb5..bb17d1e2f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -298,15 +298,6 @@ public class GadgetManager extends MiniPlugin } } } - - public void DisableParticles() - { - for (Gadget gadget : _gadgets.get(GadgetType.Particle)) - { - for (Player player : UtilServer.getPlayers()) - gadget.Disable(player); - } - } public void DisableAll() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java index 63191e213..52079b41d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java @@ -44,8 +44,6 @@ public class Arena private HashMap> _particles; - private ArrayList _sentParticles; - public Arena(Gladiators host, Location mid, ArenaType colour) { _host = host; @@ -61,7 +59,6 @@ public class Arena _stateTime = System.currentTimeMillis(); _particles = new HashMap<>(); _doBye = false; - _sentParticles = new ArrayList<>(); setupSpawns(); } @@ -259,8 +256,6 @@ public class Arena { _isOpenDoor = true; - _sentParticles.clear(); - _host.Manager.getScheduler().scheduleSyncDelayedTask(_host.Manager.getPlugin(), () -> { for (Location loc : _doorBlocks) @@ -286,11 +281,7 @@ public class Arena for (Player p : getPastPlayers()) { - if (_sentParticles.contains(p)) - continue; - - UtilTextMiddle.display(C.cAqua + "Please Wait", "The next round will start shortly", 0, 20 * 100, 0, p); - _sentParticles.add(p); + UtilTextMiddle.display(C.cAqua + "Please Wait", "The next round will start shortly", 0, 20, 0, p); } } else if (_state.equals(ArenaState.FIGHTING)) @@ -317,10 +308,7 @@ public class Arena { for (Player p : getPastPlayers()) { - if (_sentParticles.contains(p)) - continue; - - UtilTextMiddle.display(C.cGreen + "Next Battle", "Follow the particles", 0, 20 * 100, 0, p); + UtilTextMiddle.display(C.cGreen + "Next Battle", "Follow the particles", 0, 20, 0, p); } if (UtilTime.elapsed(_stateTime, 15000)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index deaa8ace6..260f7bd2c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -5,26 +5,21 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; -import java.util.List; import java.util.Map; import java.util.Queue; -import java.util.Random; +import java.util.UUID; import org.bukkit.Color; import org.bukkit.FireworkEffect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.entity.Entity; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.EntityType; -import org.bukkit.entity.Golem; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; -import org.bukkit.entity.Villager; import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -41,7 +36,6 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -126,12 +120,153 @@ public class Gladiators extends SoloGame @EventHandler public void tutorialStart(GameTutorialStartEvent e) { - Manager.getCosmeticManager().getGadgetManager().DisableParticles(); // Particles blocking tutorial... + Location white = WorldData.GetDataLocs("WHITE").get(0); + Location orange = UtilAlg.findClosest(white, WorldData.GetDataLocs("ORANGE")); + Location pink = UtilAlg.findClosest(orange, WorldData.GetDataLocs("PINK")); + ArrayList spawns = new ArrayList<>(WorldData.GetDataLocs("BROWN")); + Location spawn1 = spawns.get(0); + spawns.remove(spawn1); + Location spawn2 = spawns.get(0); - Location loc = WorldData.GetDataLocs("RED").get(0); + e.getTutorial().getPhase(1).setLocation(white); + e.getTutorial().getPhase(1).setTarget(orange); - e.getTutorial().getPhase(1).setLocation(loc.clone().add(0, 50, 0)); - e.getTutorial().getPhase(1).setTarget(loc); + CreatureAllowOverride = true; + Zombie zombie1 = (Zombie) WorldData.World.spawnEntity(spawn1, EntityType.ZOMBIE); + Zombie zombie2 = (Zombie) WorldData.World.spawnEntity(spawn2, EntityType.ZOMBIE); + CreatureAllowOverride = false; + for (Zombie zombie : Arrays.asList(zombie1, zombie2)) + { + GameProfile tiger = new ProfileLoader(UUIDFetcher.getUUIDOf("WilliamTiger").toString(), "WilliamTiger").loadProfile(); + GameProfile random = stealGameProfile(); + DisguisePlayer player = new DisguisePlayer(zombie, (zombie.equals(zombie1) ? tiger : random)); + Manager.GetDisguise().disguise(player); + + UtilEnt.Vegetate(zombie); + zombie.getEquipment().setHelmet(ArenaType.ORANGE.getLoadout().getHelmet()); + zombie.getEquipment().setChestplate(ArenaType.ORANGE.getLoadout().getChestplate()); + zombie.getEquipment().setLeggings(ArenaType.ORANGE.getLoadout().getLeggings()); + zombie.getEquipment().setBoots(ArenaType.ORANGE.getLoadout().getBoots()); + zombie.getEquipment().setItemInHand(ArenaType.ORANGE.getLoadout().getSword()); + + UtilEnt.CreatureMoveFast(zombie, orange, 1); + } + + ((TutorialGladiators)e.getTutorial()).setOrange(orange); + ((TutorialGladiators)e.getTutorial()).setPink(pink); + ((TutorialGladiators)e.getTutorial()).setZombie1(zombie1); + ((TutorialGladiators)e.getTutorial()).setZombie2(zombie2); + } + + private GameProfile stealGameProfile() + { + Player random = UtilServer.getPlayers()[0]; + GameProfile gp = new GameProfile(UUID.randomUUID(), random.getName()); + gp.getProperties().putAll(((CraftPlayer)random).getHandle().getProfile().getProperties()); + return gp; + } + + @EventHandler + public void tutorialUpdate(UpdateEvent e) + { + if (e.getType() != UpdateType.FASTEST) + return; + + if (GetState() != GameState.Prepare) + return; + + if (GetTeamList().get(0).getTutorial() == null) + return; + + TutorialGladiators tutorial = (TutorialGladiators) GetTeamList().get(0).getTutorial(); + + if (tutorial == null) + { + System.out.println("tutorial object null"); + + if (GetTeamList().get(0).getTutorial() == null) + System.out.println("tutorial is null"); + + if (!(GetTeamList().get(0).getTutorial() instanceof TutorialGladiators)) + System.out.println("its not a gladiators one"); + + return; + } + + if (tutorial.hasEnded()) + return; + + UtilEnt.CreatureMoveFast(tutorial.getZombie1(), tutorial.getOrange(), 1); + UtilEnt.CreatureMoveFast(tutorial.getZombie2(), tutorial.getOrange(), 1); + + if (tutorial.getRunning() >= 2000 && !tutorial.isHasHit1()) + { + tutorial.setHasHit1(true); + + // Zombie hit one + + PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); + packet.a = Manager.GetDisguise().getDisguise(tutorial.getZombie1()).GetEntityId(); + packet.b = 0; + + for (Player p : UtilServer.getPlayers()) + { + UtilPlayer.sendPacket(p, packet); // Attack effect + } + + tutorial.getZombie2().damage(1); // Hurt effect + + return; + } + + if (tutorial.getRunning() >= 4000 && !tutorial.isHasHit2()) + { + tutorial.setHasHit2(true); + + // Zombie hit two + + PacketPlayOutAnimation packet = new PacketPlayOutAnimation(); + packet.a = Manager.GetDisguise().getDisguise(tutorial.getZombie1()).GetEntityId(); + packet.b = 0; + + for (Player p : UtilServer.getPlayers()) + { + UtilPlayer.sendPacket(p, packet); // Attack effect + } + + tutorial.getZombie2().damage(1); // Hurt effect + + return; + } + + if (tutorial.getRunning() >= 5000 && !tutorial.getZombie2().isDead()) + { + // Zombie remove time + + tutorial.getZombie2().damage(1); + UtilFirework.playFirework(tutorial.getZombie2().getLocation(), FireworkEffect.Type.BALL, Color.ORANGE, false, false); + tutorial.getZombie2().remove(); + + Arena gateArena = getArenaByMid(tutorial.getOrange()); + for (Location loc : gateArena.getDoorBlocks()) + loc.getBlock().setType(Material.AIR); // Manual door open. + } + + if (tutorial.getRunning() > 5000) + { + // Particles + + if (tutorial.getZombie1() == null || tutorial.getPink() == null) + return; + + UtilEnt.CreatureMoveFast(tutorial.getZombie1(), tutorial.getPink(), 1); + + for (Location loc : UtilShapes.getLinesDistancedPoints(tutorial.getZombie1().getLocation(), tutorial.getPink(), 0.2)) + { + UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, loc, 0.03f, 0.03f, 0.03f, 0, 3, + UtilParticle.ViewDist.LONG, UtilServer.getPlayers()); + } + } } @Override @@ -428,8 +563,8 @@ public class Gladiators extends SoloGame for (Player p : a.getPastPlayers()) { p.sendMessage(ArcadeFormat.Line); - p.sendMessage(" " + C.cWhite + C.Bold + "Please Wait!"); - p.sendMessage(" " + C.cGreen + "Your fight will begin next round."); + p.sendMessage(" " + C.cWhite + C.Bold + "You have a bye!"); + p.sendMessage(" " + C.cGreen + "You automatically go through this round."); p.sendMessage(ArcadeFormat.Line); } } @@ -562,8 +697,8 @@ public class Gladiators extends SoloGame p.getInventory().clear(); p.getInventory().setArmorContents(null); - p.getInventory().setItem(0, UtilItem.makeUnbreakable(type.getLoadout().getSword())); - p.getInventory().setItem(1, UtilItem.makeUnbreakable(type.getLoadout().getRod())); + p.getInventory().setItem(0, type.getLoadout().getSword()); + p.getInventory().setItem(1, type.getLoadout().getRod()); p.getInventory().setItem(2, type.getLoadout().getBow()); p.getInventory().setItem(8, type.getLoadout().getArrows()); @@ -659,96 +794,38 @@ public class Gladiators extends SoloGame else if (_roundState.equals(RoundState.STARTING_3)) { _roundState = RoundState.STARTING_2; + UtilTextMiddle.display(C.cGreen + "3", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0); - for (Arena a : _gameArenaSet) - { - if (a.getState() != ArenaState.FIGHTING) - continue; - - for (Player p : a.getPastPlayers()) - { - UtilTextMiddle.display(C.cGreen + "3", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0, p); - p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1f, 1f); - } - } - - for (Player p : GetPlayers(false)) - { - UtilTextMiddle.display(C.cGreen + "3", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0, p); + for (Player p : UtilServer.getPlayers()) p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1f, 1f); - } - return; } else if (_roundState.equals(RoundState.STARTING_2)) { _roundState = RoundState.STARTING_1; + UtilTextMiddle.display(C.cYellow + "2", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0); - for (Arena a : _gameArenaSet) - { - if (a.getState() != ArenaState.FIGHTING) - continue; - - for (Player p : a.getPastPlayers()) - { - UtilTextMiddle.display(C.cYellow + "2", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0, p); - p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1f, 1f); - } - } - - for (Player p : GetPlayers(false)) - { - UtilTextMiddle.display(C.cYellow + "2", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0, p); + for (Player p : UtilServer.getPlayers()) p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1f, 1f); - } - return; } else if (_roundState.equals(RoundState.STARTING_1)) { _roundState = RoundState.STARTED; - for (Arena a : _gameArenaSet) - { - if (a.getState() != ArenaState.FIGHTING) - continue; + UtilTextMiddle.display(C.cGold + "1", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0); - for (Player p : a.getPastPlayers()) - { - UtilTextMiddle.display(C.cGold + "1", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0, p); - p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1f, 1f); - } - } - - for (Player p : GetPlayers(false)) - { - UtilTextMiddle.display(C.cGold + "1", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0, p); + for (Player p : UtilServer.getPlayers()) p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1f, 1f); - } - return; } else if (_roundState.equals(RoundState.STARTED)) { _roundState = RoundState.FIGHTING; - for (Arena a : _gameArenaSet) - { - if (a.getState() != ArenaState.FIGHTING) - continue; - - for (Player p : a.getPastPlayers()) - { - UtilTextMiddle.display(C.cRed + "FIGHT", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0, p); - p.playSound(p.getLocation(), Sound.NOTE_BASS, 1f, 1f); - } - } - - for (Player p : GetPlayers(false)) - { - UtilTextMiddle.display(C.cRed + "FIGHT", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0, p); - p.playSound(p.getLocation(), Sound.NOTE_BASS, 1f, 1f); - } + UtilTextMiddle.display(C.cRed + "FIGHT", C.cGreen + C.Bold + getRoundNotation(), 0, 40, 0); + for (Player p : UtilServer.getPlayers()) + p.playSound(p.getLocation(), Sound.NOTE_PLING, 2f, 2f); return; } } @@ -916,11 +993,4 @@ public class Gladiators extends SoloGame } } } - - @EventHandler - public void tutorialDie(EntityDeathEvent e) - { - e.getDrops().clear(); - e.setDroppedExp(0); - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/UntouchableTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/UntouchableTracker.java index 44115ca72..bd9f68e61 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/UntouchableTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/UntouchableTracker.java @@ -44,7 +44,7 @@ public class UntouchableTracker extends StatTracker for (Player p : getGame().GetPlayers(true)) { if (_noWin.contains(p.getName())) - continue; + return; addStat(p, "Untouchable", 1, false, false); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialGladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialGladiators.java index 3829cc68d..48bfebcba 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialGladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialGladiators.java @@ -2,9 +2,7 @@ package nautilus.game.arcade.game.games.gladiators.tutorial; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.entity.Golem; import org.bukkit.entity.Player; -import org.bukkit.entity.Villager; import org.bukkit.entity.Zombie; import nautilus.game.arcade.ArcadeManager; @@ -22,6 +20,11 @@ public class TutorialGladiators extends GameTutorial private Gladiators _host; + private Location _pink, _orange; + private Zombie _zombie1, _zombie2; + + private boolean hasHit1, hasHit2; + public TutorialGladiators(ArcadeManager manager) { super(manager, new TutorialPhase[]{ @@ -30,12 +33,94 @@ public class TutorialGladiators extends GameTutorial TeleportOnEnd = false; + hasHit1 = false; + hasHit2 = false; + _host = (Gladiators) manager.GetGame(); } + public Location getPink() + { + return _pink; + } + + public void setPink(Location pink) + { + _pink = pink; + } + + public Location getOrange() + { + return _orange; + } + + public void setOrange(Location orange) + { + _orange = orange; + } + + public Zombie getZombie1() + { + return _zombie1; + } + + public void setZombie1(Zombie zombie1) + { + _zombie1 = zombie1; + } + + public Zombie getZombie2() + { + return _zombie2; + } + + public void setZombie2(Zombie zombie2) + { + _zombie2 = zombie2; + } + + public boolean isHasHit1() + { + return hasHit1; + } + + public void setHasHit1(boolean hasHit1) + { + this.hasHit1 = hasHit1; + } + + public boolean isHasHit2() + { + return hasHit2; + } + + public void setHasHit2(boolean hasHit2) + { + this.hasHit2 = hasHit2; + } + @Override public void onEnd() { + Gladiators game = (Gladiators) Manager.GetGame(); + + for (Player p : game.GetPlayers(true)) + { + p.teleport(game.GetTeam(p).GetSpawn().clone()); + } + + if (_zombie1 != null) + _zombie1.remove(); + + if (_zombie2 != null) + _zombie2.remove(); + + Arena gateArena = _host.getArenaByMid(getOrange()); + for (Location loc : gateArena.getDoorBlocks()) + loc.getBlock().setType(Material.FENCE); // Manual door close. + + // Spawns + _host.GetTeamList().get(0).GetSpawns().clear(); for (Arena a : _host.getGameArenaSet()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java index 105119a83..80ff77bca 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java @@ -1,6 +1,5 @@ package nautilus.game.arcade.game.games.gladiators.tutorial; -import mineplex.core.common.util.C; import nautilus.game.arcade.gametutorial.TutorialPhase; import nautilus.game.arcade.gametutorial.TutorialText; @@ -14,7 +13,9 @@ public class TutorialPhaseGladiators extends TutorialPhase public TutorialPhaseGladiators() { super(new TutorialText[]{ - new TutorialText(C.cGreen + "Defeat your opponent to advance", C.cGreen + "Gladiators!", 20 * 5, 1) + new TutorialText("Defeat your opponent!", 20 * 4, 1), + new TutorialText("", 20 * 2, 2), + new TutorialText("To the next arena!", "Follow the particles", 20 * 4, 3) }); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java index 222028622..b140b79bc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java @@ -136,7 +136,7 @@ public abstract class TutorialPhase i++; } displayMessage(text); - UtilTextMiddle.display((text.getBigText() == null ? "" : text.getBigText()), text.getText(), 0, text.getStayTime(), 0, players); + UtilTextMiddle.display("", text.getText(), 0, text.getStayTime(), 0, players); try { Thread.sleep(text.getStayTime() * 50); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java index cc438d484..dba1d39a6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java @@ -7,7 +7,6 @@ public class TutorialText { private String _text; - private String _bigText; private int _stayTime; private int _id; private Sound _sound; @@ -34,24 +33,6 @@ public class TutorialText { this(text, stayTime, id, Sound.NOTE_PLING); } - - public TutorialText(String text, String bigText, int id) - { - this(text, (int) (Math.round(1.5 * text.length()) + 25), id, Sound.NOTE_PLING); - _bigText = bigText; - } - - public TutorialText(String text, String bigText, int id, Sound sound) - { - this(text, (int) (Math.round(1.5 * text.length()) + 25), id, sound); - _bigText = bigText; - } - - public TutorialText(String text, String bigText, int stayTime, int id) - { - this(text, stayTime, id, Sound.NOTE_PLING); - _bigText = bigText; - } public String getText() { @@ -77,9 +58,5 @@ public class TutorialText { _text = text; } - - public String getBigText() - { - return _bigText; - } + } From 563a0f0ec7081b079acf69d05e951250cf5e0e7a Mon Sep 17 00:00:00 2001 From: William Burns Date: Fri, 11 Dec 2015 02:30:44 +0000 Subject: [PATCH 52/58] remove tutorial and no flicker --- .../mineplex/core/common/util/UtilItem.java | 9 ++++++ .../arcade/game/games/gladiators/Arena.java | 29 +++++++++++++++++-- .../game/games/gladiators/Gladiators.java | 25 ++++++++-------- .../trackers/UntouchableTracker.java | 2 +- .../tutorial/TutorialPhaseGladiators.java | 1 - 5 files changed, 49 insertions(+), 17 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java index c82d37f9f..5a300322c 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java @@ -12,6 +12,7 @@ import java.util.Map.Entry; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; import mineplex.core.common.structs.ItemContainer; @@ -1116,4 +1117,12 @@ public class UtilItem { return _materials.containsKey(material); } + + public static ItemStack makeUnbreakable(ItemStack i) + { + ItemMeta im = i.getItemMeta(); + im.spigot().setUnbreakable(true); + i.setItemMeta(im); + return i; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java index 52079b41d..c63c4e922 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java @@ -42,6 +42,9 @@ public class Arena private ArenaState _state; private long _stateTime; + private boolean _alertedAlready; + private boolean _alertedAlready2; + private HashMap> _particles; public Arena(Gladiators host, Location mid, ArenaType colour) @@ -59,6 +62,8 @@ public class Arena _stateTime = System.currentTimeMillis(); _particles = new HashMap<>(); _doBye = false; + _alertedAlready = false; + _alertedAlready2 = false; setupSpawns(); } @@ -169,6 +174,16 @@ public class Arena return null; } + public boolean isAlertedAlready() + { + return _alertedAlready; + } + + public void setAlertedAlready(boolean alertedAlready) + { + _alertedAlready = alertedAlready; + } + private void setupSpawns() { ArrayList possible = (ArrayList) _host.WorldData.GetDataLocs("BLACK").clone(); @@ -279,10 +294,15 @@ public class Arena if (_host.getRoundState() != RoundState.FIGHTING) return; + if (_alertedAlready) + return; + for (Player p : getPastPlayers()) { - UtilTextMiddle.display(C.cAqua + "Please Wait", "The next round will start shortly", 0, 20, 0, p); + UtilTextMiddle.display(C.cAqua + "Please Wait", "The next round will start shortly", 0, 20 * 100, 0, p); } + + _alertedAlready = true; } else if (_state.equals(ArenaState.FIGHTING)) { @@ -306,11 +326,16 @@ public class Arena } else if (_state.equals(ArenaState.RUNNING)) { + if (_alertedAlready2) + return; + for (Player p : getPastPlayers()) { - UtilTextMiddle.display(C.cGreen + "Next Battle", "Follow the particles", 0, 20, 0, p); + UtilTextMiddle.display(C.cGreen + "Next Battle", "Follow the particles", 0, 20 * 100, 0, p); } + _alertedAlready2 = true; + if (UtilTime.elapsed(_stateTime, 15000)) handleSlowMovers(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index 260f7bd2c..dad8ea6b9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -36,6 +36,7 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -102,7 +103,7 @@ public class Gladiators extends SoloGame DamageTeamSelf = true; HungerSet = 20; DontAllowOverfill = true; - EnableTutorials = true; + EnableTutorials = false; registerStatTrackers( new BrawlerTracker(this), @@ -333,7 +334,7 @@ public class Gladiators extends SoloGame { _gameArenaSet = new ArrayList<>(); - //GetTeamList().get(0).GetSpawns().clear(); // Clear the original game spawns. + GetTeamList().get(0).GetSpawns().clear(); // Clear the original game spawns. int neededSpawns = Math.min(GetPlayers(true).size(), 16); // Quick fix Arena masterNode = getArenasOfType(ArenaType.RED).get(0); @@ -414,16 +415,14 @@ public class Gladiators extends SoloGame } } - // Moved the below to tutorial + for (Arena a : _gameArenaSet) + { + if (a.getCapacity() <= 0) + continue; -// for (Arena a : _gameArenaSet) -// { -// if (a.getCapacity() <= 0) -// continue; -// -// for (Location l : a.capacitySpawns()) -// GetTeamList().get(0).GetSpawns().add(l); -// } + for (Location l : a.capacitySpawns()) + GetTeamList().get(0).GetSpawns().add(l); + } } public ArrayList getGameArenaSet() @@ -697,8 +696,8 @@ public class Gladiators extends SoloGame p.getInventory().clear(); p.getInventory().setArmorContents(null); - p.getInventory().setItem(0, type.getLoadout().getSword()); - p.getInventory().setItem(1, type.getLoadout().getRod()); + p.getInventory().setItem(0, UtilItem.makeUnbreakable(type.getLoadout().getSword())); + p.getInventory().setItem(1, UtilItem.makeUnbreakable(type.getLoadout().getRod())); p.getInventory().setItem(2, type.getLoadout().getBow()); p.getInventory().setItem(8, type.getLoadout().getArrows()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/UntouchableTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/UntouchableTracker.java index bd9f68e61..44115ca72 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/UntouchableTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/UntouchableTracker.java @@ -44,7 +44,7 @@ public class UntouchableTracker extends StatTracker for (Player p : getGame().GetPlayers(true)) { if (_noWin.contains(p.getName())) - return; + continue; addStat(p, "Untouchable", 1, false, false); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java index 80ff77bca..1839b204a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/tutorial/TutorialPhaseGladiators.java @@ -15,7 +15,6 @@ public class TutorialPhaseGladiators extends TutorialPhase super(new TutorialText[]{ new TutorialText("Defeat your opponent!", 20 * 4, 1), new TutorialText("", 20 * 2, 2), - new TutorialText("To the next arena!", "Follow the particles", 20 * 4, 3) }); } From 1607345f045515b6aa8e4856985701b48ee9664f Mon Sep 17 00:00:00 2001 From: William Burns Date: Fri, 11 Dec 2015 02:41:44 +0000 Subject: [PATCH 53/58] title + debug --- .../game/games/gladiators/Gladiators.java | 25 ++++++++++++++++++- .../gladiators/trackers/FlawlessTracker.java | 2 ++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index dad8ea6b9..798763d67 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -82,6 +82,8 @@ public class Gladiators extends SoloGame private ArenaType _furthestOutCurrent; + private boolean _firstRound; + public Gladiators(ArcadeManager manager) { super(manager, GameType.Gladiators, @@ -116,6 +118,7 @@ public class Gladiators extends SoloGame _playerArenas = new HashMap<>(); _roundState = RoundState.WAITING; + _firstRound = true; } @EventHandler @@ -516,6 +519,8 @@ public class Gladiators extends SoloGame a.setState(ArenaState.WAITING); } + UtilTextMiddle.display(C.cGreen + "Gladiators!", C.cGreen + "Defeat your opponent to advance", 20, 60, 20); + return; } @@ -656,7 +661,7 @@ public class Gladiators extends SoloGame if (Recharge.Instance.use(p, "Arena Bounce", 500, false, false)) { //p.sendMessage("bounce. closest = " + closest.toString() + " player arena = " + _playerArenas.get(p).toString()); - UtilAction.velocity(p, UtilAlg.getTrajectory2d(e.getTo(), p.getLocation()), 1.7, true, 0.5, 0, 5, true); + UtilAction.velocity(p, UtilAlg.getTrajectory2d(e.getTo(), p.getLocation()), 1.7, true, 0.2, 0, 3, true); } return; @@ -793,6 +798,10 @@ public class Gladiators extends SoloGame else if (_roundState.equals(RoundState.STARTING_3)) { _roundState = RoundState.STARTING_2; + + if (_firstRound) + return; + UtilTextMiddle.display(C.cGreen + "3", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0); for (Player p : UtilServer.getPlayers()) @@ -802,6 +811,10 @@ public class Gladiators extends SoloGame else if (_roundState.equals(RoundState.STARTING_2)) { _roundState = RoundState.STARTING_1; + + if (_firstRound) + return; + UtilTextMiddle.display(C.cYellow + "2", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0); for (Player p : UtilServer.getPlayers()) @@ -811,6 +824,10 @@ public class Gladiators extends SoloGame else if (_roundState.equals(RoundState.STARTING_1)) { _roundState = RoundState.STARTED; + + if (_firstRound) + return; + UtilTextMiddle.display(C.cGold + "1", C.cGreen + C.Bold + getRoundNotation(), 0, 80, 0); for (Player p : UtilServer.getPlayers()) @@ -821,6 +838,12 @@ public class Gladiators extends SoloGame { _roundState = RoundState.FIGHTING; + if (_firstRound) + { + _firstRound = false; + return; + } + UtilTextMiddle.display(C.cRed + "FIGHT", C.cGreen + C.Bold + getRoundNotation(), 0, 40, 0); for (Player p : UtilServer.getPlayers()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/FlawlessTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/FlawlessTracker.java index 088a428aa..ebdbad1cf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/FlawlessTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/trackers/FlawlessTracker.java @@ -34,6 +34,8 @@ public class FlawlessTracker extends StatTracker if (e.isCancelled()) return; + System.out.println(e.getEventName() + " took damage by " + e.getCause().toString()); + if (e.getEntity() instanceof Player) { _noWin.add(((Player)e.getEntity()).getName()); From 7a597d90b783350df54802f686259dfd961cd937 Mon Sep 17 00:00:00 2001 From: William Burns Date: Fri, 11 Dec 2015 02:48:06 +0000 Subject: [PATCH 54/58] final push goodnight --- .../src/mineplex/core/achievement/Achievement.java | 10 +++++----- .../game/arcade/game/games/gladiators/Gladiators.java | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index cc80b6904..026355cf1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -795,11 +795,11 @@ public enum Achievement new int[]{10}, AchievementCategory.GLADIATORS), - GLADIATORS_FLAWLESS("Flawless", 1000, - new String[]{"Gladiators.Flawless"}, - new String[]{"Win a game of gladiators", "without taking any damage"}, - new int[]{1}, - AchievementCategory.GLADIATORS), +// GLADIATORS_FLAWLESS("Flawless", 1000, +// new String[]{"Gladiators.Flawless"}, +// new String[]{"Win a game of gladiators", "without taking any damage"}, +// new int[]{1}, +// AchievementCategory.GLADIATORS), GLADIATORS_PRECISION("Precision", 800, new String[]{"Gladiators.Precision"}, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index 798763d67..f4bec1e85 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -110,7 +110,7 @@ public class Gladiators extends SoloGame registerStatTrackers( new BrawlerTracker(this), new UntouchableTracker(this), - new FlawlessTracker(this), + //new FlawlessTracker(this), new PrecisionTracker(this), new SwiftKillTracker(this) ); From a760dba78310548bd3b4e5c4a6a9acd4fcd9ac3d Mon Sep 17 00:00:00 2001 From: William Burns Date: Fri, 11 Dec 2015 02:59:16 +0000 Subject: [PATCH 55/58] i lied. --- .../src/mineplex/core/achievement/Achievement.java | 10 +++++----- .../game/arcade/game/games/gladiators/Gladiators.java | 6 +++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index 026355cf1..ee32d3854 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -789,11 +789,11 @@ public enum Achievement new int[]{3}, AchievementCategory.GLADIATORS), - GLADIATORS_UNTOUCHABLE("Untouchable", 1500, - new String[]{"Gladiators.Untouchable"}, - new String[]{"Kill 10 Gladiators", "without taking any damage"}, - new int[]{10}, - AchievementCategory.GLADIATORS), +// GLADIATORS_UNTOUCHABLE("Untouchable", 1500, +// new String[]{"Gladiators.Untouchable"}, +// new String[]{"Kill 10 Gladiators", "without taking any damage"}, +// new int[]{10}, +// AchievementCategory.GLADIATORS), // GLADIATORS_FLAWLESS("Flawless", 1000, // new String[]{"Gladiators.Flawless"}, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java index f4bec1e85..9fa85f642 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Gladiators.java @@ -109,7 +109,7 @@ public class Gladiators extends SoloGame registerStatTrackers( new BrawlerTracker(this), - new UntouchableTracker(this), + //new UntouchableTracker(this), //new FlawlessTracker(this), new PrecisionTracker(this), new SwiftKillTracker(this) @@ -548,6 +548,10 @@ public class Gladiators extends SoloGame if (_roundState == RoundState.WAITING) { _roundState = RoundState.STARTING_5; + + if (_firstRound) + return; + UtilTextMiddle.display("", C.cGreen + C.Bold + getRoundNotation(), 0, 80 , 0); _furthestOutCurrent = getFurthestOut(); // Find furthest out for fight. From b5c157c12326a096fa446d6fc620ea6a0effa7ef Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Fri, 11 Dec 2015 01:24:16 -0500 Subject: [PATCH 56/58] Changed PlayerCache to Cache --- Plugins/Mineplex.Bungee.Mineplexer/.classpath | 2 +- .../src/mineplex/bungee/playerStats/PlayerStats.java | 4 ++-- .../mineplex/bungee/playerStats/PlayerStatsRepository.java | 2 +- Plugins/Mineplex.Core/.classpath | 2 +- .../src/mineplex/core/account/CoreClientManager.java | 5 +++-- .../src/mineplex/core/cosmetic/ui/page/PetTagPage.java | 2 +- .../src/mineplex/core/donation/DonationManager.java | 3 ++- .../src/mineplex/core/inventory/InventoryManager.java | 2 +- .../src/mineplex/core/preferences/PreferencesRepository.java | 1 - .../src/mineplex/core/reward/rewards/PetReward.java | 2 +- .../Mineplex.Core/src/mineplex/core/stats/StatsManager.java | 2 +- .../Mineplex.Core/src/mineplex/core/task/TaskManager.java | 2 +- Plugins/Mineplex.Game.Clans.Core/.classpath | 2 +- Plugins/Mineplex.PlayerCache/.project | 2 +- .../mineplex/{playerCache => cache/player}/PlayerCache.java | 2 +- .../mineplex/{playerCache => cache/player}/PlayerInfo.java | 2 +- 16 files changed, 19 insertions(+), 18 deletions(-) rename Plugins/Mineplex.PlayerCache/src/mineplex/{playerCache => cache/player}/PlayerCache.java (97%) rename Plugins/Mineplex.PlayerCache/src/mineplex/{playerCache => cache/player}/PlayerInfo.java (97%) diff --git a/Plugins/Mineplex.Bungee.Mineplexer/.classpath b/Plugins/Mineplex.Bungee.Mineplexer/.classpath index 40645fe06..c06b6c559 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/.classpath +++ b/Plugins/Mineplex.Bungee.Mineplexer/.classpath @@ -8,6 +8,6 @@ - + diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStats.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStats.java index fcae65a57..cc805cbe2 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStats.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStats.java @@ -5,8 +5,8 @@ import java.util.UUID; import java.util.concurrent.TimeUnit; import mineplex.bungee.playerStats.data.IpInfo; -import mineplex.playerCache.PlayerCache; -import mineplex.playerCache.PlayerInfo; +import mineplex.cache.player.PlayerCache; +import mineplex.cache.player.PlayerInfo; import net.md_5.bungee.api.event.PlayerDisconnectEvent; import net.md_5.bungee.api.event.PostLoginEvent; import net.md_5.bungee.api.plugin.Listener; diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStatsRepository.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStatsRepository.java index 1e9f765f5..5227ab818 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStatsRepository.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStatsRepository.java @@ -9,7 +9,7 @@ import java.sql.Statement; import java.util.UUID; import mineplex.bungee.playerStats.data.IpInfo; -import mineplex.playerCache.PlayerInfo; +import mineplex.cache.player.PlayerInfo; public class PlayerStatsRepository { diff --git a/Plugins/Mineplex.Core/.classpath b/Plugins/Mineplex.Core/.classpath index 1b29691dd..ea3a54132 100644 --- a/Plugins/Mineplex.Core/.classpath +++ b/Plugins/Mineplex.Core/.classpath @@ -13,7 +13,7 @@ - + diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index 3c01d37a3..26859a6b3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -9,6 +9,9 @@ import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; import com.google.gson.Gson; + +import mineplex.cache.player.PlayerCache; +import mineplex.cache.player.PlayerInfo; import mineplex.core.MiniPlugin; import mineplex.core.account.command.TestRank; import mineplex.core.account.command.UpdateRank; @@ -24,8 +27,6 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.timing.TimingManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.playerCache.PlayerCache; -import mineplex.playerCache.PlayerInfo; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java index 84da7d074..2ca6490f6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetTagPage.java @@ -1,5 +1,6 @@ package mineplex.core.cosmetic.ui.page; +import mineplex.cache.player.PlayerCache; import mineplex.core.account.CoreClientManager; import mineplex.core.common.CurrencyType; import mineplex.core.common.util.C; @@ -16,7 +17,6 @@ import mineplex.core.pet.repository.token.PetChangeToken; import mineplex.core.pet.repository.token.PetToken; import mineplex.core.shop.page.ConfirmationPage; import mineplex.core.shop.page.ShopPageBase; -import mineplex.playerCache.PlayerCache; import net.minecraft.server.v1_8_R3.ItemStack; import net.minecraft.server.v1_8_R3.Items; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java index 54209e7db..813873d73 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java @@ -10,6 +10,8 @@ import org.bukkit.event.EventHandler; import org.bukkit.plugin.java.JavaPlugin; import com.google.gson.Gson; + +import mineplex.cache.player.PlayerCache; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.event.ClientWebResponseEvent; @@ -24,7 +26,6 @@ import mineplex.core.donation.repository.token.DonorTokenWrapper; import mineplex.core.server.util.TransactionResponse; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.playerCache.PlayerCache; public class DonationManager extends MiniDbClientPlugin { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java index 82becc622..7df564134 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java @@ -22,6 +22,7 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.cache.player.PlayerCache; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.Callback; @@ -31,7 +32,6 @@ import mineplex.core.inventory.data.InventoryRepository; import mineplex.core.inventory.data.Item; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.playerCache.PlayerCache; public class InventoryManager extends MiniDbClientPlugin { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java index 7449c83c9..94749ce2f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java @@ -122,7 +122,6 @@ public class PreferencesRepository extends RepositoryBase preferences.PendingFriendRequests = resultSet.getBoolean(11); preferences.friendDisplayInventoryUI = resultSet.getBoolean(12); preferences.ClanTips = resultSet.getBoolean(13); - System.out.println("<< " + resultSet.getBoolean(13)); } return preferences; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java index 113f8a6cf..c683c100f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java @@ -5,6 +5,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import mineplex.cache.player.PlayerCache; import mineplex.core.donation.DonationManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.pet.PetManager; @@ -13,7 +14,6 @@ import mineplex.core.pet.repository.token.PetToken; import mineplex.core.reward.RewardData; import mineplex.core.reward.RewardRarity; import mineplex.core.reward.RewardType; -import mineplex.playerCache.PlayerCache; /** * Created by shaun on 14-09-18. diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java index 4b60646f1..f2edadcc1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java @@ -9,6 +9,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.cache.player.PlayerCache; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.NautHashMap; @@ -16,7 +17,6 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.stats.command.GiveStatCommand; import mineplex.core.stats.command.TimeCommand; import mineplex.core.stats.event.StatChangeEvent; -import mineplex.playerCache.PlayerCache; public class StatsManager extends MiniDbClientPlugin { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java b/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java index 3a9e8601f..85608613e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java @@ -5,12 +5,12 @@ import java.sql.SQLException; import java.util.List; import java.util.UUID; +import mineplex.cache.player.PlayerCache; import mineplex.core.MiniDbClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.Callback; import mineplex.core.common.util.NautHashMap; import mineplex.core.task.repository.TaskRepository; -import mineplex.playerCache.PlayerCache; import org.bukkit.Bukkit; import org.bukkit.entity.Player; diff --git a/Plugins/Mineplex.Game.Clans.Core/.classpath b/Plugins/Mineplex.Game.Clans.Core/.classpath index fa4ddd8ed..c6a118cbe 100644 --- a/Plugins/Mineplex.Game.Clans.Core/.classpath +++ b/Plugins/Mineplex.Game.Clans.Core/.classpath @@ -1,7 +1,7 @@ - + diff --git a/Plugins/Mineplex.PlayerCache/.project b/Plugins/Mineplex.PlayerCache/.project index 0abebe638..5321c2157 100644 --- a/Plugins/Mineplex.PlayerCache/.project +++ b/Plugins/Mineplex.PlayerCache/.project @@ -1,6 +1,6 @@ - Mineplex.PlayerCache + Mineplex.Cache diff --git a/Plugins/Mineplex.PlayerCache/src/mineplex/playerCache/PlayerCache.java b/Plugins/Mineplex.PlayerCache/src/mineplex/cache/player/PlayerCache.java similarity index 97% rename from Plugins/Mineplex.PlayerCache/src/mineplex/playerCache/PlayerCache.java rename to Plugins/Mineplex.PlayerCache/src/mineplex/cache/player/PlayerCache.java index cf320dbde..e83eabf74 100644 --- a/Plugins/Mineplex.PlayerCache/src/mineplex/playerCache/PlayerCache.java +++ b/Plugins/Mineplex.PlayerCache/src/mineplex/cache/player/PlayerCache.java @@ -1,4 +1,4 @@ -package mineplex.playerCache; +package mineplex.cache.player; import java.util.UUID; diff --git a/Plugins/Mineplex.PlayerCache/src/mineplex/playerCache/PlayerInfo.java b/Plugins/Mineplex.PlayerCache/src/mineplex/cache/player/PlayerInfo.java similarity index 97% rename from Plugins/Mineplex.PlayerCache/src/mineplex/playerCache/PlayerInfo.java rename to Plugins/Mineplex.PlayerCache/src/mineplex/cache/player/PlayerInfo.java index 3ab44b0d5..c7cf6faec 100644 --- a/Plugins/Mineplex.PlayerCache/src/mineplex/playerCache/PlayerInfo.java +++ b/Plugins/Mineplex.PlayerCache/src/mineplex/cache/player/PlayerInfo.java @@ -1,4 +1,4 @@ -package mineplex.playerCache; +package mineplex.cache.player; import java.util.UUID; From 222173ab17c12a879b0397979c2c2a8083ebac12 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Fri, 11 Dec 2015 01:24:59 -0500 Subject: [PATCH 57/58] Improved and implemented GameProfile caching. --- .../ProfileCacheLookupCallback.java | 29 +++ .../profileCache/ProfileCacheManager.java | 215 +++++++++++------- .../Mineplex.Hub/src/mineplex/hub/Hub.java | 3 + .../src/mineplex/staffServer/StaffServer.java | 5 +- .../src/nautilus/game/arcade/Arcade.java | 3 + 5 files changed, 173 insertions(+), 82 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/profileCache/ProfileCacheLookupCallback.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/profileCache/ProfileCacheLookupCallback.java b/Plugins/Mineplex.Core/src/mineplex/core/profileCache/ProfileCacheLookupCallback.java new file mode 100644 index 000000000..81d62ada2 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/profileCache/ProfileCacheLookupCallback.java @@ -0,0 +1,29 @@ +package mineplex.core.profileCache; + +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.ProfileLookupCallback; + +public class ProfileCacheLookupCallback implements ProfileLookupCallback +{ + private ProfileCacheManager _profileCacheManager; + private ProfileLookupCallback _profileLookupCallback; + + public ProfileCacheLookupCallback(ProfileCacheManager profileCacheManager, ProfileLookupCallback profileLookupCallback) + { + _profileCacheManager = profileCacheManager; + _profileLookupCallback = profileLookupCallback; + } + + @Override + public void onProfileLookupFailed(GameProfile gameProfile, Exception exception) + { + _profileLookupCallback.onProfileLookupFailed(gameProfile, exception); + } + + @Override + public void onProfileLookupSucceeded(GameProfile gameProfile) + { + _profileCacheManager.cacheProfile(gameProfile); + _profileLookupCallback.onProfileLookupSucceeded(gameProfile); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/profileCache/ProfileCacheManager.java b/Plugins/Mineplex.Core/src/mineplex/core/profileCache/ProfileCacheManager.java index 3f2af0ea7..102df1712 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/profileCache/ProfileCacheManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/profileCache/ProfileCacheManager.java @@ -1,81 +1,134 @@ -//package mineplex.core.profileCache; -// -//import java.util.UUID; -// -//import org.bukkit.plugin.java.JavaPlugin; -//import net.minecraft.util.com.google.gson.Gson; -//import net.minecraft.util.com.google.gson.GsonBuilder; -//import net.minecraft.util.com.mojang.authlib.GameProfile; -//import net.minecraft.util.com.mojang.authlib.properties.PropertyMap; -//import net.minecraft.util.com.mojang.authlib.yggdrasil.ProfileCache; -//import net.minecraft.util.com.mojang.authlib.yggdrasil.YggdrasilGameProfileRepository; -//import net.minecraft.util.com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService; -//import net.minecraft.util.com.mojang.authlib.yggdrasil.response.ProfileSearchResultsResponse; -//import net.minecraft.util.com.mojang.util.UUIDTypeAdapter; -// -//import mineplex.core.MiniPlugin; -//import mineplex.serverdata.Region; -//import mineplex.serverdata.redis.RedisDataRepository; -//import mineplex.serverdata.servers.ServerManager; -// -//public class ProfileCacheManager extends MiniPlugin implements ProfileCache -//{ -// private RedisDataRepository _profileRepository; -// private Gson _gson; -// -// public ProfileCacheManager(JavaPlugin plugin) -// { -// super("Profile Cache", plugin); -// -// _profileRepository = new RedisDataRepository(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(), -// Region.ALL, ProfileData.class, "profileCacheRepo"); -// -// GsonBuilder builder = new GsonBuilder(); -// builder.registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer()); -// builder.registerTypeAdapter(UUID.class, new UUIDTypeAdapter()); -// builder.registerTypeAdapter(ProfileSearchResultsResponse.class, new net.minecraft.util.com.mojang.authlib.yggdrasil.response.ProfileSearchResultsResponse.Serializer()); -// _gson = builder.create(); -// -// try -// { -// YggdrasilMinecraftSessionService.setProfileCache(this); -// YggdrasilGameProfileRepository.setProfileCache(this); -// } -// catch (Exception e) -// { -// System.out.println("================================================"); -// System.out.println("Failed to load Profile Cache (Skins)"); -// System.out.println("Are you using the correct modified Craftbukkit?"); -// System.out.println("================================================"); -// } -// } -// -// -// @Override -// public GameProfile attemptToLoadProfile(String playerName) -// { -// ProfileData profile = _profileRepository.getElement(playerName.toLowerCase()); -// -// if (profile != null) -// { -// PropertyMap propertyMap = _gson.fromJson(profile.getPropertyMap(), PropertyMap.class); -// GameProfile gameProfile = new GameProfile(profile.getUuid(), profile.getPlayerName()); -// gameProfile.getProperties().putAll(propertyMap); -// -//// System.out.println("Loaded profile " + playerName + " from repository!"); -// return gameProfile; -// } -// -//// System.out.println("Profile Null"); -// -// return null; -// } -// -// @Override -// public void cacheProfile(GameProfile profile) -// { -//// System.out.println("Cached profile: " + profile.getName()); -// ProfileData data = new ProfileData(profile.getId(), profile.getName(), _gson.toJson(profile.getProperties())); -// _profileRepository.addElement(data, 60 * 60 * 24); // 1 day -// } -//} +package mineplex.core.profileCache; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_8_R3.CraftServer; +import org.bukkit.event.EventHandler; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitRunnable; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.mojang.authlib.Agent; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.GameProfileRepository; +import com.mojang.authlib.ProfileLookupCallback; +import com.mojang.authlib.properties.PropertyMap; +import com.mojang.authlib.yggdrasil.YggdrasilGameProfileRepository; +import com.mojang.authlib.yggdrasil.response.ProfileSearchResultsResponse; +import com.mojang.util.UUIDTypeAdapter; + +import mineplex.core.MiniPlugin; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.serverdata.Region; +import mineplex.serverdata.redis.RedisDataRepository; +import mineplex.serverdata.servers.ServerManager; + +public class ProfileCacheManager extends MiniPlugin implements GameProfileRepository +{ + private YggdrasilGameProfileRepository _mojangProfileRepository; + private RedisDataRepository _profileRepository; + private Gson _gson; + + public ProfileCacheManager(JavaPlugin plugin) + { + super("Profile Cache", plugin); + + _profileRepository = new RedisDataRepository(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(), + Region.ALL, ProfileData.class, "profileCacheRepo"); + + GsonBuilder builder = new GsonBuilder(); + builder.registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer()); + builder.registerTypeAdapter(UUID.class, new UUIDTypeAdapter()); + builder.registerTypeAdapter(ProfileSearchResultsResponse.class, new com.mojang.authlib.yggdrasil.response.ProfileSearchResultsResponse.Serializer()); + _gson = builder.create(); + + try + { + Field mojangProfileRepo = net.minecraft.server.v1_8_R3.MinecraftServer.class.getDeclaredField("Y"); + + mojangProfileRepo.setAccessible(true); + + _mojangProfileRepository = (YggdrasilGameProfileRepository) mojangProfileRepo.get(((CraftServer)Bukkit.getServer()).getServer()); + mojangProfileRepo.set(((CraftServer)Bukkit.getServer()).getServer(), this); + } + catch (Exception e) + { + e.printStackTrace(); + System.out.println("================================================"); + System.out.println("Failed to load Profile Cache (Skins)"); + System.out.println("Are you using the correct modified Craftbukkit?"); + System.out.println("================================================"); + } + } + + + public GameProfile attemptToLoadProfile(String playerName) + { + ProfileData profile = _profileRepository.getElement(playerName.toLowerCase()); + + if (profile != null) + { + PropertyMap propertyMap = _gson.fromJson(profile.getPropertyMap(), PropertyMap.class); + GameProfile gameProfile = new GameProfile(profile.getUuid(), profile.getPlayerName()); + gameProfile.getProperties().putAll(propertyMap); + return gameProfile; + } + + return null; + } + + public void cacheProfile(final GameProfile profile) + { + if (Bukkit.isPrimaryThread()) + { + runAsync(new Runnable() + { + public void run() + { + cacheProfileSafely(profile); + } + }); + } + else + cacheProfileSafely(profile); + } + + @Override + public void findProfilesByNames(String[] profileNames, Agent agent, ProfileLookupCallback profileLookupCallback) + { + List uncachedProfileNames = new ArrayList<>(); + + for (String profileName : profileNames) + { + GameProfile profile = attemptToLoadProfile(profileName); + + if (profile == null) + uncachedProfileNames.add(profileName); + else + profileLookupCallback.onProfileLookupSucceeded(profile); + } + + _mojangProfileRepository.findProfilesByNames(uncachedProfileNames.toArray(new String[uncachedProfileNames.size()]), agent, new ProfileCacheLookupCallback(this, profileLookupCallback)); + } + + @EventHandler + public void clearRepository(UpdateEvent event) + { + if (event.getType() != UpdateType.MIN_10) + return; + + _profileRepository.clean(); + } + + private void cacheProfileSafely(GameProfile profile) + { + ProfileData data = new ProfileData(profile.getId(), profile.getName(), _gson.toJson(profile.getProperties())); + _profileRepository.addElement(data, 60 * 60 * 24); // 1 day + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index f52155acb..9940694cc 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -38,6 +38,7 @@ import mineplex.core.pet.PetManager; import mineplex.core.poll.PollManager; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; +import mineplex.core.profileCache.ProfileCacheManager; import mineplex.core.projectile.ProjectileManager; import mineplex.core.punish.Punish; import mineplex.core.recharge.Recharge; @@ -182,6 +183,8 @@ public class Hub extends JavaPlugin implements IRelation new ClassCombatShop(shopManager, clientManager, donationManager, false, "Knight", classManager.GetClass("Knight"), true); new ClassCombatShop(shopManager, clientManager, donationManager, false, "Assassin", classManager.GetClass("Assassin"), true); + new ProfileCacheManager(this); + //Updates getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java index c1c98cf3b..cdb02169a 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java @@ -15,6 +15,7 @@ import mineplex.core.monitor.LagMeter; import mineplex.core.npc.NpcManager; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; +import mineplex.core.profileCache.ProfileCacheManager; import mineplex.core.punish.Punish; import mineplex.core.recharge.Recharge; import mineplex.core.stats.StatsManager; @@ -88,6 +89,8 @@ public class StaffServer extends JavaPlugin ((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("377bdea3-badc-448d-81c1-65db43b17ea4"), "Strutt20")); ((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("efaf9a17-2304-4f42-8433-421523c308dc"), "B2_mp")); - ((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("cf85f470-5248-4978-8208-435736fa136e"), "RustyRoo")); + ((CraftServer)getServer()).getHandle().addOp(new GameProfile(UUID.fromString("cf85f470-5248-4978-8208-435736fa136e"), "RustyRoo")); + + new ProfileCacheManager(this); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index 7a710683b..aa1468fdf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -45,6 +45,7 @@ import mineplex.core.pet.PetManager; import mineplex.core.poll.PollManager; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; +import mineplex.core.profileCache.ProfileCacheManager; import mineplex.core.projectile.ProjectileManager; import mineplex.core.punish.Punish; import mineplex.core.recharge.Recharge; @@ -160,6 +161,8 @@ public class Arcade extends JavaPlugin new PacketsInteractionFix(this, packetHandler); new FoodDupeFix(this); + new ProfileCacheManager(this); + //Updates getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); From 523c1875ef12e84f002401469e80378216ca19e6 Mon Sep 17 00:00:00 2001 From: William Burns Date: Fri, 11 Dec 2015 06:58:11 +0000 Subject: [PATCH 58/58] fix --- .../nautilus/game/arcade/game/games/gladiators/Arena.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java index c63c4e922..a4dca2dcc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/gladiators/Arena.java @@ -326,11 +326,11 @@ public class Arena } else if (_state.equals(ArenaState.RUNNING)) { - if (_alertedAlready2) - return; - for (Player p : getPastPlayers()) { + if (_alertedAlready2) + continue; + UtilTextMiddle.display(C.cGreen + "Next Battle", "Follow the particles", 0, 20 * 100, 0, p); }