From e11a9379b9f825e743084521244a708cc8db0ada Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Mon, 4 Apr 2016 12:32:22 +1000 Subject: [PATCH] More tutorial tweaking --- .../src/mineplex/core/npc/NpcManager.java | 1 + .../src/mineplex/game/clans/Clans.java | 2 +- .../game/clans/clans/ClansManager.java | 2 +- .../game/clans/tutorial/Tutorial.java | 50 ++++++++++++++----- .../game/clans/tutorial/TutorialManager.java | 9 ++++ .../game/clans/tutorial/TutorialSession.java | 34 +++++++++++++ .../clans/tutorial/command/FinishCommand.java | 23 +++++++++ .../clans/tutorial/command/StartCommand.java | 2 +- .../tutorial/command/TutorialCommand.java | 3 +- .../clans/tutorial/objective/Objective.java | 27 +++++++++- .../tutorial/objective/ObjectiveGoal.java | 15 +----- .../tutorial/objective/OrderedObjective.java | 8 +++ .../tutorial/objective/SingleObjective.java | 6 +++ .../objective/UnorderedObjective.java | 9 ++++ .../tutorials/clans/ClansMainTutorial.java | 47 +++++++++++++++-- .../attackenemy/StealEnemyPotatoesGoal.java | 2 +- .../objective/goals/clan/LeaveSpawnGoal.java | 2 +- 17 files changed, 204 insertions(+), 38 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/FinishCommand.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java index 3e7bfe05b..87c84076d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/npc/NpcManager.java @@ -486,6 +486,7 @@ public class NpcManager extends MiniPlugin public void removeFakeNpc(Npc npc) { _npcs.remove(npc); + npc.getEntity().remove(); } public void loadNpcs() throws SQLException diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index c8665c8be..8385bc856 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -130,7 +130,7 @@ public class Clans extends JavaPlugin new Explosion(this, blockRestore); new InventoryManager(this, _clientManager); ResourcePackManager resourcePackManager = new ResourcePackManager(this, portal); - resourcePackManager.setResourcePack("http://garblox.com/files/b/ResClans.zip", "http://garblox.com/files/mineplex/ResClans19.zip", true); + resourcePackManager.setResourcePack("http://phinary.ca/ResClans.zip", "http://phinary.ca/ResClans19.zip", true); // Enable custom-gear related managers new CustomTagFix(this, packetHandler); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 299bcd519..7563c4c2c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -821,7 +821,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati List recipients = new ArrayList<>(); - for (Player other : UtilServer.getPlayers()) + for (Player other : event.getRecipients()) { ClanInfo otherClan = _clanUtility.getClanByPlayer(other); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/Tutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/Tutorial.java index 15bf9b6e0..f66c84fdd 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/Tutorial.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/Tutorial.java @@ -159,7 +159,7 @@ public abstract class Tutorial implements Listener, ObjectiveListener { } - private void finish(Player player) + protected final void finish(Player player) { _objectives.forEach(objective -> objective.clean(player, getRegion(player))); @@ -281,7 +281,7 @@ public abstract class Tutorial implements Listener, ObjectiveListener for (Map.Entry entry : _playerSessionMap.entrySet()) { - String prefix = entry.getValue().incrementAndGetColorTick() % 2 == 0 ? C.cYellow : C.cGold; + String prefix = entry.getValue().incrementAndGetColorTick() % 2 == 0 ? C.cWhite : C.cGreen; Objective objective = _objectives.get(entry.getValue().getObjectiveIndex()); UtilTextBottom.display(prefix + objective.getDescription(entry.getKey()), entry.getKey()); } @@ -297,12 +297,8 @@ public abstract class Tutorial implements Listener, ObjectiveListener for (Map.Entry entry : _playerSessionMap.entrySet()) { - String extra = _objectives.get(entry.getValue().getObjectiveIndex()).getExtraDescription(entry.getKey()); - if (extra == null) - { - // None defined. - continue; - } + Player player = entry.getKey(); + Objective objective = _objectives.get(entry.getValue().getObjectiveIndex()); if (entry.getValue().incrementAndGetTextSeconds() < 20) { @@ -310,10 +306,7 @@ public abstract class Tutorial implements Listener, ObjectiveListener return; } - UtilPlayer.message(entry.getKey(), C.cGold + C.Strike + "---------------------------------------------"); - UtilPlayer.message(entry.getKey(), C.cGray + " " + extra); - UtilPlayer.message(entry.getKey(), C.cGold + C.Strike + "---------------------------------------------"); - entry.getValue().setTextSeconds(0); + objective.displayChatMessages(player); } } @@ -327,6 +320,39 @@ public abstract class Tutorial implements Listener, ObjectiveListener } } + public void setSpawnHologram(Player player, Location location, String... text) + { + if (_playerSessionMap.containsKey(player)) + { + TutorialSession session = _playerSessionMap.get(player); + if (session.getSpawnHologram() == null && !session.isRemovedHologram()) + { + Hologram hologram = new Hologram(_hologram, location, text); + session.setSpawnHologram(hologram); + hologram.start(); + } + else + { + session.getSpawnHologram().setText(text); + } + } + } + + public void removeSpawnHologram(Player player) + { + if (_playerSessionMap.containsKey(player)) + { + TutorialSession session = _playerSessionMap.get(player); + if (session.getSpawnHologram() != null) + { + session.getSpawnHologram().stop(); + session.setSpawnHologram(null); + } + + session.setRemovedHologram(true); + } + } + public TutorialSession getTutorialSession(Player player) { return _playerSessionMap.get(player); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java index e8b43f243..4bd716595 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialManager.java @@ -121,6 +121,15 @@ public class TutorialManager extends MiniPlugin implements ScoreboardElement return null; } + public void finishTutorial(Player player) + { + Tutorial tutorial = getTutorial(player); + if (tutorial != null) + { + tutorial.finish(player); + } + } + public boolean startTutorial(Player player, TutorialType type) { if (inTutorial(player)) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialSession.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialSession.java index ced0ea35f..271db3e05 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialSession.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/TutorialSession.java @@ -9,6 +9,7 @@ import mineplex.core.hologram.Hologram; public class TutorialSession { + private final long _startTime; private int _objectiveIndex; private TutorialRegion _region; private List _hologramList = new ArrayList<>(); @@ -16,9 +17,12 @@ public class TutorialSession private int _colorTick; private int _textSeconds; private Location _mapTargetLocation; + private Hologram _spawnHologram; + private boolean _removedHologram; public TutorialSession() { + _startTime = System.currentTimeMillis(); } public List getHolograms() @@ -81,4 +85,34 @@ public class TutorialSession { return _mapTargetLocation; } + + public long getStartTime() + { + return _startTime; + } + + public long getElapsedTime() + { + return System.currentTimeMillis() - _startTime; + } + + public boolean isRemovedHologram() + { + return _removedHologram; + } + + public void setRemovedHologram(boolean removedHologram) + { + _removedHologram = removedHologram; + } + + public void setSpawnHologram(Hologram spawnHologram) + { + _spawnHologram = spawnHologram; + } + + public Hologram getSpawnHologram() + { + return _spawnHologram; + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/FinishCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/FinishCommand.java new file mode 100644 index 000000000..be204fd2e --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/FinishCommand.java @@ -0,0 +1,23 @@ +package mineplex.game.clans.tutorial.command; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.game.clans.tutorial.TutorialManager; + +public class FinishCommand extends CommandBase +{ + public FinishCommand(TutorialManager plugin) + { + super(plugin, Rank.MODERATOR, "finish", "end"); + } + + @Override + public void Execute(Player caller, String[] args) + { + Plugin.finishTutorial(caller); + + + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/StartCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/StartCommand.java index 3bfa840b5..859503bbc 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/StartCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/StartCommand.java @@ -13,7 +13,7 @@ public class StartCommand extends CommandBase { public StartCommand(TutorialManager plugin) { - super(plugin, Rank.JNR_DEV, "start"); + super(plugin, Rank.MODERATOR, "start"); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/TutorialCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/TutorialCommand.java index 139655bbb..a2814ddd3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/TutorialCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/command/TutorialCommand.java @@ -13,9 +13,10 @@ public class TutorialCommand extends MultiCommandBase { public TutorialCommand(TutorialManager plugin) { - super(plugin, Rank.JNR_DEV, "tutorial", "tut"); + super(plugin, Rank.MODERATOR, "tutorial", "tut"); AddCommand(new StartCommand(plugin)); + AddCommand(new FinishCommand(plugin)); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/Objective.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/Objective.java index 6139a0cb1..caf405c4e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/Objective.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/Objective.java @@ -199,8 +199,6 @@ public abstract class Objective [%s] finished objective [%s]", player.getName(), getName(player))); - showFinishMessage(player); - _active.remove(player.getUniqueId()); if (_displayFinishMessage) @@ -277,11 +275,36 @@ public abstract class Objective goal = getLatestGoal(player); + String name = goal == null ? getName(player) : goal.getName(player); + String extra = getExtraDescription(player); +// UtilPlayer.message(player, C.cGold + C.Strike + "---------------------------------------------"); + UtilPlayer.message(player, C.cPurpleB + name); + if (extra != null) + { + UtilPlayer.message(player, ""); + UtilPlayer.message(player, C.cGray + " " + extra); + } + UtilPlayer.message(player, ""); + UtilPlayer.message(player, C.cGreen + getDescription(player)); +// UtilPlayer.message(player, C.cGold + C.Strike + "---------------------------------------------"); + getPlugin().getTutorialSession(player).setTextSeconds(0); + } + public void setDisplayStartMessage(boolean displayStartMessage) { _displayStartMessage = displayStartMessage; } + public abstract ObjectiveGoal getLatestGoal(Player player); + public void setDisplayFinishMessage(boolean displayFinishMessage) { _displayFinishMessage = displayFinishMessage; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/ObjectiveGoal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/ObjectiveGoal.java index 36f92a3ef..88f58cf34 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/ObjectiveGoal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/ObjectiveGoal.java @@ -152,7 +152,7 @@ public abstract class ObjectiveGoal > implements Liste */ protected void clean(Player player, TutorialRegion region) { - + _removeList.add(player.getUniqueId()); } public T getObjective() @@ -174,18 +174,7 @@ public abstract class ObjectiveGoal > implements Liste UtilTextMiddle.display(C.cYellow + "New Objective", getName(player), player); - if (getExtraDescription(player) != null) - { - for (int i = 0; i < 5; i++) - { - UtilPlayer.message(player, ""); - } - // Display extra information for the first time. - UtilPlayer.message(player, C.cGold + C.Strike + "---------------------------------------------"); - UtilPlayer.message(player, C.cGray + " " + getExtraDescription(player)); - UtilPlayer.message(player, C.cGold + C.Strike + "---------------------------------------------"); - getObjective().getPlugin().getTutorialSession(player).setTextSeconds(0); - } + _objective.displayChatMessages(player); } public void setDisplayStartMessage(boolean displayStartMessage) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/OrderedObjective.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/OrderedObjective.java index 95e1a7145..91302df37 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/OrderedObjective.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/OrderedObjective.java @@ -73,6 +73,14 @@ public abstract class OrderedObjective extends Objectiv return _goals.get(index).getExtraDescription(player); } + @Override + public ObjectiveGoal getLatestGoal(Player player) + { + OrderedObjectiveData data = getData(player); + int index = data == null ? 0 : data.getIndex(); + return _goals.get(index); + } + @Override protected void customStart(Player player) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/SingleObjective.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/SingleObjective.java index 2dcf162e1..78e47d648 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/SingleObjective.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/SingleObjective.java @@ -36,6 +36,12 @@ public abstract class SingleObjective extends Objective // Do Nothing } + @Override + public ObjectiveGoal getLatestGoal(Player player) + { + return null; + } + @Override protected List> getGoals() { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/UnorderedObjective.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/UnorderedObjective.java index 4d38a9c45..f145c2270 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/UnorderedObjective.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/objective/UnorderedObjective.java @@ -74,6 +74,15 @@ public abstract class UnorderedObjective extends Object return index == -1 ? super.getExtraDescription(player) : _goals.get(index).getExtraDescription(player); } + @Override + public ObjectiveGoal getLatestGoal(Player player) + { + UnorderedObjectiveData data = getData(player); + if (data == null) return null; + int index = data.getFirstIncompleteIndex(); + return index == -1 ? null : _goals.get(index); + } + @Override protected void customStart(Player player) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java index 222828d2e..5465cad44 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Objects; import java.util.UUID; +import mineplex.core.hologram.Hologram; import mineplex.core.common.util.*; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent; @@ -40,6 +41,7 @@ import mineplex.game.clans.message.ClansMessageManager; import mineplex.game.clans.spawn.Spawn; import mineplex.game.clans.tutorial.Tutorial; import mineplex.game.clans.tutorial.TutorialRegion; +import mineplex.game.clans.tutorial.TutorialSession; import mineplex.game.clans.tutorial.TutorialWorldManager; import mineplex.game.clans.tutorial.map.TutorialMapManager; import mineplex.game.clans.tutorial.tutorials.clans.objective.AttackEnemyObjective; @@ -105,7 +107,7 @@ public class ClansMainTutorial extends Tutorial ClansManager.getInstance().getItemMapManager().setMap(player); }, 20 * 10L); - + player.setWalkSpeed(0.2F); //ClansManager.getInstance().getPvpTimer().unpause(player); @@ -148,15 +150,17 @@ public class ClansMainTutorial extends Tutorial //ClansManager.getInstance().getPvpTimer().pause(player); // Spawn Holograms - addHologram(player, - getPoint(region, ClansMainTutorial.Point.SPAWN).add(0, 1.5, -6), + setSpawnHologram(player, + getPoint(region, ClansMainTutorial.Point.SPAWN).add(0, 1.5, -3), C.cGoldB + "Welcome to the Clans Tutorial!", " ", "This will teach you the basics of Clans.", "It will take about 5 minutes to complete.", "You must complete it before playing Clans.", " ", - "Walk forward to begin!"); + "Starting in " + C.cGreen + "10 Seconds"); + + player.setWalkSpeed(0); addHologram(player, getPoint(region, ClansMainTutorial.Point.SPAWN).add(0, 1.5, -23), @@ -429,6 +433,39 @@ public class ClansMainTutorial extends Tutorial */ } + @EventHandler + public void preventMovement(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + for (Player player : getPlayers()) + { + TutorialSession session = getTutorialSession(player); + long time = session.getElapsedTime(); + if (time <= 10000) // 10 seconds + { +// player.teleport(getSpawn(session.getRegion())); + + String secondsLeft = UtilTime.convertString(10000 - time, 0, UtilTime.TimeUnit.SECONDS); + setSpawnHologram(player, + getPoint(session.getRegion(), ClansMainTutorial.Point.SPAWN).add(0, 1.5, -3), + C.cGoldB + "Welcome to the Clans Tutorial!", + " ", + "This will teach you the basics of Clans.", + "It will take about 5 minutes to complete.", + "You must complete it before playing Clans.", + " ", + "Starting in " + C.cGreen + secondsLeft); + } + else if (!session.isRemovedHologram()) + { + removeSpawnHologram(player); + player.setWalkSpeed(0.2F); + } + } + } + public void performGateCheck(Player player, DyeColor key) { if(player == null || !player.isOnline()) return; @@ -442,7 +479,7 @@ public class ClansMainTutorial extends Tutorial return; } - if (player.getLocation().distanceSquared(fence) <= (GATE_OPEN_DISTANCE * 2)) + if (player.getLocation().distanceSquared(fence) <= (GATE_OPEN_DISTANCE * GATE_OPEN_DISTANCE)) { // Within the correct blocks of the gates. destroyFences(getRegion(player), key); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/attackenemy/StealEnemyPotatoesGoal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/attackenemy/StealEnemyPotatoesGoal.java index b046c693d..8339ed67c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/attackenemy/StealEnemyPotatoesGoal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/attackenemy/StealEnemyPotatoesGoal.java @@ -115,7 +115,7 @@ public class StealEnemyPotatoesGoal extends ObjectiveGoal if (event.getItem().getItemStack().getType() == Material.POTATO_ITEM) { - int count = _playersMap.get(event.getPlayer().getUniqueId()).getAndIncrement(); + int count = _playersMap.get(event.getPlayer().getUniqueId()).incrementAndGet(); if (count == 10) finish(event.getPlayer()); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/clan/LeaveSpawnGoal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/clan/LeaveSpawnGoal.java index d7347e245..80d01bcd7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/clan/LeaveSpawnGoal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/clan/LeaveSpawnGoal.java @@ -33,7 +33,7 @@ public class LeaveSpawnGoal extends ObjectiveGoal ); // 2 seconds after start message -// setStartMessageDelay(20 * 3); + setStartMessageDelay(20 * 11); } @Override