added hub tutorial

This commit is contained in:
Chiss 2013-09-03 10:16:44 +10:00
parent 5aec6509ca
commit 835d78e0e7
5 changed files with 359 additions and 15 deletions

View File

@ -64,6 +64,7 @@ import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.tutorial.Tutorial;
public class HubManager extends MiniClientPlugin<HubClient> public class HubManager extends MiniClientPlugin<HubClient>
{ {
@ -71,6 +72,9 @@ public class HubManager extends MiniClientPlugin<HubClient>
private DonationManager _donationManager; private DonationManager _donationManager;
private DisguiseManager _disguiseManager; private DisguiseManager _disguiseManager;
private Tutorial _tutorial;
private TextCreator _textCreator;
private Location _spawn; private Location _spawn;
private int _scoreboardTick = 0; private int _scoreboardTick = 0;
@ -91,9 +95,12 @@ public class HubManager extends MiniClientPlugin<HubClient>
_spawn = new Location(UtilWorld.getWorld("world"), 0.5, 74, 0.5); _spawn = new Location(UtilWorld.getWorld("world"), 0.5, 74, 0.5);
new TextCreator(this); _textCreator = new TextCreator(this);
new Dragon(this); new Dragon(this);
_tutorial = new Tutorial(this, _textCreator);
DragonTextB = GetDragonText(); DragonTextB = GetDragonText();
} }
@ -252,6 +259,9 @@ public class HubManager extends MiniClientPlugin<HubClient>
for (Player other : UtilServer.getPlayers()) for (Player other : UtilServer.getPlayers())
{ {
if (_tutorial.InTutorial(other))
continue;
UtilPlayer.message(other, rankStr + C.cYellow + player.getName() + " " + C.cWhite + event.getMessage()); UtilPlayer.message(other, rankStr + C.cYellow + player.getName() + " " + C.cWhite + event.getMessage());
} }
} }
@ -540,7 +550,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
if (player.equals(other)) if (player.equals(other))
continue; continue;
if (UtilMath.offset(player.getLocation(), GetSpawn()) < 4) if (UtilMath.offset(player.getLocation(), GetSpawn()) < 4 || _tutorial.InTutorial(other))
{ {
((CraftPlayer)other).hidePlayer(player, true, false); ((CraftPlayer)other).hidePlayer(player, true, false);
} }

View File

@ -14,10 +14,10 @@ public class TextCreator extends MiniPlugin
{ {
public HubManager Manager; public HubManager Manager;
Location locComp; public Location locComp;
Location locArcade; public Location locArcade;
Location locSurvival; public Location locSurvival;
Location locOther; public Location locClassics;
BlockFace faceComp = BlockFace.SOUTH; BlockFace faceComp = BlockFace.SOUTH;
BlockFace faceArcade = BlockFace.WEST; BlockFace faceArcade = BlockFace.WEST;
@ -38,7 +38,7 @@ public class TextCreator extends MiniPlugin
locComp = manager.GetSpawn().add(40, 10, 0); locComp = manager.GetSpawn().add(40, 10, 0);
locArcade = manager.GetSpawn().add(0, 10, 40); locArcade = manager.GetSpawn().add(0, 10, 40);
locSurvival = manager.GetSpawn().add(-40, 10, 0); locSurvival = manager.GetSpawn().add(-40, 10, 0);
locOther = manager.GetSpawn().add(0, 10, -40); locClassics = manager.GetSpawn().add(0, 10, -40);
arcadeGames = new String[] arcadeGames = new String[]
{ {
@ -84,14 +84,14 @@ public class TextCreator extends MiniPlugin
//Other //Other
UtilText.MakeText("CLASSICS", locOther, faceOther, 159, (byte)5, TextAlign.CENTER); UtilText.MakeText("CLASSICS", locClassics, faceOther, 159, (byte)5, TextAlign.CENTER);
UtilText.MakeText("CLASSICS", locOther.add(0, 0, -1), faceOther, 159, (byte)15, TextAlign.CENTER); UtilText.MakeText("CLASSICS", locClassics.add(0, 0, -1), faceOther, 159, (byte)15, TextAlign.CENTER);
UtilText.MakeText("SUPER SMASH MOBS", locOther.clone().add(0, 14, -15), faceOther, 159, (byte)4, TextAlign.CENTER); UtilText.MakeText("SUPER SMASH MOBS", locClassics.clone().add(0, 14, -15), faceOther, 159, (byte)4, TextAlign.CENTER);
UtilText.MakeText("SUPER SMASH MOBS", locOther.clone().add(0, 14, -16), faceOther, 159, (byte)15, TextAlign.CENTER); UtilText.MakeText("SUPER SMASH MOBS", locClassics.clone().add(0, 14, -16), faceOther, 159, (byte)15, TextAlign.CENTER);
UtilText.MakeText("MINEKART", locOther.clone().add(0, 21, -15), faceOther, 159, (byte)1, TextAlign.CENTER); UtilText.MakeText("MINEKART", locClassics.clone().add(0, 21, -15), faceOther, 159, (byte)1, TextAlign.CENTER);
UtilText.MakeText("MINEKART", locOther.clone().add(0, 21, -16), faceOther, 159, (byte)15, TextAlign.CENTER); UtilText.MakeText("MINEKART", locClassics.clone().add(0, 21, -16), faceOther, 159, (byte)15, TextAlign.CENTER);
} }
@EventHandler @EventHandler
@ -134,8 +134,8 @@ public class TextCreator extends MiniPlugin
//UtilText.MakeText("SUPER SMASH MOBS", locOther, faceOther, 159, color, TextAlign.CENTER); //UtilText.MakeText("SUPER SMASH MOBS", locOther, faceOther, 159, color, TextAlign.CENTER);
//UtilText.MakeText("SUPER SMASH MOBS", locOther.clone().add(0, 0, -1), faceOther, 159, (byte)15, TextAlign.CENTER); //UtilText.MakeText("SUPER SMASH MOBS", locOther.clone().add(0, 0, -1), faceOther, 159, (byte)15, TextAlign.CENTER);
UtilText.MakeText("SUPER SMASH MOBS", locOther.clone().add(0, 14, -15), faceOther, 159, color, TextAlign.CENTER); UtilText.MakeText("SUPER SMASH MOBS", locClassics.clone().add(0, 14, -15), faceOther, 159, color, TextAlign.CENTER);
UtilText.MakeText("SUPER SMASH MOBS", locOther.clone().add(0, 14, -16), faceOther, 159, (byte)15, TextAlign.CENTER); UtilText.MakeText("SUPER SMASH MOBS", locClassics.clone().add(0, 14, -16), faceOther, 159, (byte)15, TextAlign.CENTER);
UtilText.MakeText("DOMINATE", locComp.clone().add(15, 14, 0), faceComp, 159, color, TextAlign.CENTER); UtilText.MakeText("DOMINATE", locComp.clone().add(15, 14, 0), faceComp, 159, color, TextAlign.CENTER);
UtilText.MakeText("DOMINATE", locComp.clone().add(16, 14, 0), faceComp, 159, (byte)15, TextAlign.CENTER); UtilText.MakeText("DOMINATE", locComp.clone().add(16, 14, 0), faceComp, 159, (byte)15, TextAlign.CENTER);

View File

@ -0,0 +1,224 @@
package mineplex.hub.tutorial;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.HubManager;
import mineplex.hub.TextCreator;
public class Tutorial extends MiniPlugin
{
private TextCreator HubText;
private ArrayList<TutorialPhase> phases = new ArrayList<TutorialPhase>();
private HashMap<Player, TutorialData> tute = new HashMap<Player, TutorialData>();
private String main = ChatColor.RESET + "";
private String elem = C.cYellow + C.Bold;
public Tutorial(HubManager manager, TextCreator text)
{
super("Hub Tutorial", manager.GetPlugin());
HubText = text;
double y = -manager.GetSpawn().getY();
//Welcome
phases.add(new TutorialPhase(
manager.GetSpawn().add(-40, y+85, 0),
manager.GetSpawn(),
"Welcome to Mineplex",
new String[]
{
"Hello!",
"This is a very quick tutorial to help you start.",
"If you complete it, you will get " + elem + "5000 Gems" + main + "!",
"Seriously, it will only take 30 seconds!!!",
"",
"Mineplex has many different games to play.",
"I will show you them, and tell you how to join!"
}
));
//Arcade
phases.add(new TutorialPhase(
manager.GetSpawn().add(0, -3, 13),
HubText.locArcade,
"Arcade",
new String[]
{
"This is the " + elem + "Arcade" + main + " game mode.",
"",
"Servers will rotate through many different games.",
"So there's no need to quit after each game!",
"",
"They are all quick, fun 16 player games!"
}
));
//Bridges
phases.add(new TutorialPhase(
manager.GetSpawn().add(-13, -3, 0),
HubText.locSurvival,
"Survival",
new String[]
{
"This is the " + elem + "The Bridges" + main + " game mode.",
"This is a great team combat game.",
"You get 10 minutes to prepare for battle,",
"then the bridges drop, and you fight to the death!",
"",
elem + "Hunger Games" + main + " will be added here soon!"
}
));
//Pig
phases.add(new TutorialPhase(
manager.GetSpawn().add(-9, y+73, 53),
manager.GetSpawn().add(-11, y+72.5, 57),
"???",
new String[]
{
"",
"",
"This is a pig standing on a log."
}
));
//Classics
phases.add(new TutorialPhase(
manager.GetSpawn().add(0, -3, -13),
HubText.locClassics,
"Classics",
new String[]
{
"Here, you can play our " + elem + "Classics" + main + " game modes.",
"",
elem + "MineKart" + main + " is an exciting racing game.",
"Complete with weapons, drifting and more!",
"",
"In " + elem + "Super Smash Mobs" + main + " you become a monster,",
"then fight to the death with other players, using fun skills!"
}
));
//Comp
phases.add(new TutorialPhase(
manager.GetSpawn().add(13, -3, 0),
HubText.locComp,
"Champions",
new String[]
{
"Finally, these are the " + elem + "Champions" + main + " games.",
"These are extremely competitive skill based games.",
"",
"Each class can be customised with unlockable skills.",
"",
"Fight with other in three different game types!"
}
));
//HORSE
phases.add(new TutorialPhase(
manager.GetSpawn().add(0, -3, 19),
manager.GetSpawn().add(0, -3.1, 23),
"Joining Games",
new String[]
{
"Click on this " + elem + "HORSE" + main + " to join an " + elem + "ARCADE" + main + " server.",
"This will open the server select menu.",
"Click an " + elem + "Emerald Block" + main + " to join a server!",
"",
"Easy huh?",
"",
"Thanks for listening! Have fun!"
}
));
}
@EventHandler(priority = EventPriority.MONITOR)
public void PlayerJoin(PlayerJoinEvent event)
{
//XXX IF BLA BLA BLA JOINED
tute.put(event.getPlayer(), new TutorialData(event.getPlayer(), phases.get(0)));
}
@EventHandler
public void PlayerQuit(PlayerQuitEvent event)
{
tute.remove(event.getPlayer());
}
@EventHandler
public void InteractCancel(PlayerInteractEvent event)
{
if (InTutorial(event.getPlayer()))
event.setCancelled(true);
}
@EventHandler
public void MoveCancel(PlayerMoveEvent event)
{
if (InTutorial(event.getPlayer()))
event.setTo(event.getFrom());
}
@EventHandler
public void Update(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
Iterator<Player> tuteIterator = tute.keySet().iterator();
while (tuteIterator.hasNext())
{
Player player = tuteIterator.next();
TutorialData data = tute.get(player);
if (data.Update())
{
if (data.PhaseStep < phases.size())
{
data.SetNextPhase(phases.get(data.PhaseStep));
}
else
{
tuteIterator.remove();
System.out.println("Completed Tutorial: " + player.getName());
//XXX SET BLA BLA BLA FINISHED
//XXX Give 5000 Gems
UtilPlayer.message(player, C.cAqua + C.Bold + "You completed the Tutorial.");
UtilPlayer.message(player, C.cGreen + C.Bold + "You received 5000 Gems.");
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
}
}
}
}
public boolean InTutorial(Player player)
{
return tute.containsKey(player);
}
}

View File

@ -0,0 +1,87 @@
package mineplex.hub.tutorial;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
public class TutorialData
{
public Player Player;
public TutorialPhase Phase;
public int PhaseStep;
public int TextStep;
public long Sleep;
public TutorialData(Player player, TutorialPhase phase)
{
Player = player;
Phase = phase;
TextStep = 0;
PhaseStep = 0;
Sleep = System.currentTimeMillis() + 3000;
}
public boolean Update()
{
if (!Player.getLocation().equals(Phase.Location))
Player.teleport(Phase.Location);
if (System.currentTimeMillis() < Sleep)
return false;
//Next Phase
if (TextStep >= Phase.Text.length)
{
PhaseStep++;
Sleep = System.currentTimeMillis() + 2000;
return true;
}
//Display Text
String text = Phase.Text[TextStep];
UtilPlayer.message(Player, " ");
UtilPlayer.message(Player, " ");
UtilPlayer.message(Player, " ");
UtilPlayer.message(Player, C.cGreen + C.Strike + C.Bold + "========================================");
UtilPlayer.message(Player, C.cGold + C.Bold + Phase.Header);
UtilPlayer.message(Player, " ");
for (int i=0 ; i<=TextStep ; i++)
UtilPlayer.message(Player, " " + Phase.Text[i]);
for (int i=TextStep ; i<=5 ; i++)
UtilPlayer.message(Player, " ");
UtilPlayer.message(Player, C.cGreen + C.Strike + C.Bold + "========================================");
if (text.length() > 0)
{
Player.playSound(Player.getLocation(), Sound.ORB_PICKUP, 2f, 1.5f);
Sleep = System.currentTimeMillis() + 1200 + (60*text.length());
}
else
{
Sleep = System.currentTimeMillis() + 600;
}
TextStep++;
return false;
}
public void SetNextPhase(TutorialPhase phase)
{
Phase = phase;
TextStep = 0;
Player.teleport(Phase.Location);
}
}

View File

@ -0,0 +1,23 @@
package mineplex.hub.tutorial;
import mineplex.core.common.util.UtilAlg;
import org.bukkit.Location;
public class TutorialPhase
{
public Location Location;
public String Header;
public String[] Text;
public TutorialPhase(Location player, Location target, String header, String[] text)
{
Location = player;
Location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(player, target)));
Location.setPitch(UtilAlg.GetPitch(UtilAlg.getTrajectory(player, target)));
Header = header;
Text = text;
}
}