From 27f335779abb3399504d5ba006ae232ef2db9d96 Mon Sep 17 00:00:00 2001 From: Sarah Date: Wed, 2 Dec 2015 19:39:44 +0100 Subject: [PATCH 1/7] 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 2/7] 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 3/7] 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 4/7] 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 5/7] 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 6/7] 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 7/7] 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