More tutorial tweaking

This commit is contained in:
Shaun Bennett 2016-04-04 12:32:22 +10:00
parent a1f284670a
commit e11a9379b9
17 changed files with 204 additions and 38 deletions

View File

@ -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

View File

@ -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);

View File

@ -821,7 +821,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
List<Player> recipients = new ArrayList<>();
for (Player other : UtilServer.getPlayers())
for (Player other : event.getRecipients())
{
ClanInfo otherClan = _clanUtility.getClanByPlayer(other);

View File

@ -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<Player, TutorialSession> 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<Player, TutorialSession> 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);

View File

@ -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))

View File

@ -9,6 +9,7 @@ import mineplex.core.hologram.Hologram;
public class TutorialSession
{
private final long _startTime;
private int _objectiveIndex;
private TutorialRegion _region;
private List<Hologram> _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<Hologram> 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;
}
}

View File

@ -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<TutorialManager>
{
public FinishCommand(TutorialManager plugin)
{
super(plugin, Rank.MODERATOR, "finish", "end");
}
@Override
public void Execute(Player caller, String[] args)
{
Plugin.finishTutorial(caller);
}
}

View File

@ -13,7 +13,7 @@ public class StartCommand extends CommandBase<TutorialManager>
{
public StartCommand(TutorialManager plugin)
{
super(plugin, Rank.JNR_DEV, "start");
super(plugin, Rank.MODERATOR, "start");
}
@Override

View File

@ -13,9 +13,10 @@ public class TutorialCommand extends MultiCommandBase<TutorialManager>
{
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

View File

@ -199,8 +199,6 @@ public abstract class Objective<Plugin extends Tutorial, Data extends ObjectiveD
{
System.out.println(String.format("Tutorial> [%s] finished objective [%s]", player.getName(), getName(player)));
showFinishMessage(player);
_active.remove(player.getUniqueId());
if (_displayFinishMessage)
@ -277,11 +275,36 @@ public abstract class Objective<Plugin extends Tutorial, Data extends ObjectiveD
UtilTextMiddle.display(C.cGreen + "Tutorial Completed", getName(player), 20, 60, 20, player);
}
public void displayChatMessages(Player player)
{
for (int i = 0; i < 8; i++)
{
UtilPlayer.message(player, "");
}
ObjectiveGoal<?> 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;

View File

@ -152,7 +152,7 @@ public abstract class ObjectiveGoal <T extends Objective<?, ?>> implements Liste
*/
protected void clean(Player player, TutorialRegion region)
{
_removeList.add(player.getUniqueId());
}
public T getObjective()
@ -174,18 +174,7 @@ public abstract class ObjectiveGoal <T extends Objective<?, ?>> 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)

View File

@ -73,6 +73,14 @@ public abstract class OrderedObjective<Plugin extends Tutorial> 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)
{

View File

@ -36,6 +36,12 @@ public abstract class SingleObjective<Plugin extends Tutorial> extends Objective
// Do Nothing
}
@Override
public ObjectiveGoal<?> getLatestGoal(Player player)
{
return null;
}
@Override
protected List<ObjectiveGoal<?>> getGoals()
{

View File

@ -74,6 +74,15 @@ public abstract class UnorderedObjective<Plugin extends Tutorial> 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)
{

View File

@ -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);

View File

@ -115,7 +115,7 @@ public class StealEnemyPotatoesGoal extends ObjectiveGoal<AttackEnemyObjective>
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());
}

View File

@ -33,7 +33,7 @@ public class LeaveSpawnGoal extends ObjectiveGoal<ClanObjective>
);
// 2 seconds after start message
// setStartMessageDelay(20 * 3);
setStartMessageDelay(20 * 11);
}
@Override