Added Hub Parties

Re-did Hub Tutorials
Added Party Tutorial
This commit is contained in:
Chiss 2013-09-07 14:09:12 +10:00
parent 213b1efb0c
commit 7ab04be00c
10 changed files with 1089 additions and 205 deletions

View File

@ -35,7 +35,7 @@ public class C
public static String mTime = "" + ChatColor.GREEN;
public static String mItem = "" + ChatColor.YELLOW;
public static String mSkill = "" + ChatColor.GREEN;
public static String mLink = "" + ChatColor.WHITE;
public static String mLink = "" + ChatColor.GREEN;
public static String mLoot = "" + ChatColor.RED;
public static String mGame = "" + ChatColor.LIGHT_PURPLE;

View File

@ -7,6 +7,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@ -53,6 +54,7 @@ import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
@ -67,19 +69,24 @@ import mineplex.core.donation.DonationManager;
import mineplex.core.task.TaskManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.tutorial.Tutorial;
import mineplex.hub.party.Party;
import mineplex.hub.party.PartyManager;
import mineplex.hub.tutorial.TutorialManager;
public class HubManager extends MiniClientPlugin<HubClient>
{
private CoreClientManager _clientManager;
private DonationManager _donationManager;
private DisguiseManager _disguiseManager;
private PartyManager _partyManager;
private Tutorial _tutorial;
private TutorialManager _tutorialManager;
private TextCreator _textCreator;
private Location _spawn;
private int _scoreboardTick = 0;
private HashMap<Player, Scoreboard> _scoreboards = new HashMap<Player, Scoreboard>();
private String _pigStacker = "0 - Nobody";
@ -102,7 +109,8 @@ public class HubManager extends MiniClientPlugin<HubClient>
new Dragon(this);
_tutorial = new Tutorial(this, _textCreator, donationManager, taskManager);
_partyManager = new PartyManager(this);
_tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator);
DragonTextB = GetDragonText();
}
@ -212,6 +220,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
//Scoreboard
Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
player.setScoreboard(board);
_scoreboards.put(player, board);
//Objective
Objective obj = board.registerNewObjective(C.Bold + "Player Data", "dummy");
@ -250,6 +259,8 @@ public class HubManager extends MiniClientPlugin<HubClient>
for (Player player : UtilServer.getPlayers())
player.getScoreboard().resetScores(event.getPlayer());
_scoreboards.remove(event.getPlayer());
}
@EventHandler
@ -268,9 +279,30 @@ public class HubManager extends MiniClientPlugin<HubClient>
if (rank != Rank.ALL)
rankStr = rank.Color + C.Bold + GetClients().Get(player).GetRank().Name.toUpperCase() + " ";
//Party Chat
if (event.getMessage().charAt(0) == '@')
{
Party party = _partyManager.GetParty(player);
if (party != null)
{
for (String name : party.GetPlayers())
{
Player other = UtilPlayer.searchExact(name);
if (other != null)
UtilPlayer.message(other, C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + player.getName() + ChatColor.RESET + " " + C.cPurple + event.getMessage().substring(1, event.getMessage().length()));
}
}
else
{
UtilPlayer.message(player, F.main("Party", "You are not in a Party."));
}
return;
}
for (Player other : UtilServer.getPlayers())
{
if (_tutorial.InTutorial(other))
if (_tutorialManager.InTutorial(other))
continue;
UtilPlayer.message(other, rankStr + C.cYellow + player.getName() + " " + C.cWhite + event.getMessage());
@ -371,6 +403,22 @@ public class HubManager extends MiniClientPlugin<HubClient>
}
}
@EventHandler
public void BorderUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
for (Player player : UtilServer.getPlayers())
{
if (UtilMath.offset(player.getLocation(), GetSpawn()) > 200)
{
player.eject();
player.leaveVehicle();
player.teleport(GetSpawn());
}
}
}
@EventHandler
public void FoodHealthUpdate(UpdateEvent event)
@ -442,6 +490,14 @@ public class HubManager extends MiniClientPlugin<HubClient>
for (Player player : UtilServer.getPlayers())
{
//Dont Waste Time
if (_partyManager.GetParty(player) != null)
continue;
//Return to Main Scoreboard
if (!player.getScoreboard().equals(_scoreboards.get(player)))
player.setScoreboard(_scoreboards.get(player));
//Objective
Objective obj = player.getScoreboard().getObjective(DisplaySlot.SIDEBAR);
@ -561,7 +617,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
if (player.equals(other))
continue;
if (UtilMath.offset(player.getLocation(), GetSpawn()) < 4 || _tutorial.InTutorial(other) || _tutorial.InTutorial(player))
if (UtilMath.offset(player.getLocation(), GetSpawn()) < 4 || _tutorialManager.InTutorial(other) || _tutorialManager.InTutorial(player))
{
((CraftPlayer)other).hidePlayer(player, true, false);
}

View File

@ -0,0 +1,333 @@
package mineplex.hub.party;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
public class Party
{
private PartyManager Manager;
private String _creator = null;
private ArrayList<String> _players = new ArrayList<String>();
private NautHashMap<String, Long> _invitee = new NautHashMap<String, Long>();
private Scoreboard _scoreboard;
private Objective _scoreboardObj;
private ArrayList<String> _scoreboardLast = new ArrayList<String>();
private long _partyOfflineTimer = -1;
public Party(PartyManager manager)
{
Manager = manager;
//Scoreboard
_scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
_scoreboardObj = _scoreboard.registerNewObjective("Party", "dummy");
_scoreboardObj.setDisplaySlot(DisplaySlot.SIDEBAR);
_scoreboard.registerNewTeam(ChatColor.GREEN + "Members");
//Scoreboard Ranks
for (Rank rank : Rank.values())
{
if (rank != Rank.ALL)
_scoreboard.registerNewTeam(rank.Name).setPrefix(rank.Color + C.Bold + rank.Name + ChatColor.RESET + " ");
else
_scoreboard.registerNewTeam(rank.Name).setPrefix("");
}
_scoreboard.registerNewTeam("Party").setPrefix(ChatColor.LIGHT_PURPLE + C.Bold + "Party" + ChatColor.RESET + " ");
//Add Players
for (Player player : Bukkit.getOnlinePlayers())
{
_scoreboard.getTeam(Manager.Manager.GetClients().Get(player).GetRank().Name).addPlayer(player);
}
}
public void JoinParty(Player player)
{
//Add Leader
if (_players.isEmpty())
{
_players.add(player.getName());
UtilPlayer.message(player, F.main("Party", "You created a new Party."));
_creator = player.getName();
}
else
{
_players.add(player.getName());
_invitee.remove(player.getName());
Announce(F.elem(player.getName()) + " has joined the party!");
}
_scoreboard.getTeam("Party").addPlayer(player);
}
public void InviteParty(Player player, boolean inviteeInParty)
{
_invitee.put(player.getName(), System.currentTimeMillis());
//Decline
if (_players.contains(player.getName()))
{
UtilPlayer.message(player, F.main("Party", F.name(player.getName()) + " is already in the Party."));
player.playSound(player.getLocation(), Sound.NOTE_BASS, 1f, 1.5f);
}
//Announce
Announce(F.name(player.getName()) + " has been invited to your Party.");
//Inform
UtilPlayer.message(player, F.main("Party", F.name(GetLeader()) + " invited you to their Party."));
//Instruct
if (inviteeInParty)
{
UtilPlayer.message(player, F.main("Party", "Type " + F.link("/party leave") + " then " + F.link("/party " + GetLeader()) + " to join."));
}
else
{
UtilPlayer.message(player, F.main("Party", "Type " + F.link("/party " + GetLeader()) + " to join."));
}
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 1.5f);
}
public void LeaveParty(Player player)
{
//Announce
Announce(F.name(player.getName()) + " has left the Party.");
boolean leader = player.equals(GetLeader());
_players.remove(player.getName());
//Set Scoreboard
_scoreboard.getTeam(Manager.Manager.GetClients().Get(player).GetRank().Name).addPlayer(player);
if (leader && _players.size() > 0)
{
Announce("Party Leadership passed on to " + F.name(GetLeader()) + ".");
}
}
public void KickParty(Player player)
{
//Announce
Announce(F.name(player.getName()) + " was kicked from the Party.");
_players.remove(player.getName());
}
public void PlayerJoin(Player player)
{
//Scoreboard
if (_players.contains(player.getName()))
_scoreboard.getTeam("Party").addPlayer(player);
else
_scoreboard.getTeam(Manager.Manager.GetClients().Get(player).GetRank().Name).addPlayer(player);
if (_creator.equals(player.getName()))
{
_players.remove(player.getName());
_players.add(0, player.getName());
Announce("Party Leadership returned to " + F.name(GetLeader()) + ".");
}
}
//Shuffle Leader
public void PlayerQuit(Player player)
{
if (player.getName().equals(GetLeader()))
{
_players.remove(player.getName());
_players.add(1, player.getName());
Announce("Party Leadership passed on to " + F.name(GetLeader()) + ".");
}
}
public void Announce(String message)
{
for (String name : _players)
{
Player player = UtilPlayer.searchExact(name);
UtilPlayer.message(player, F.main("Party", message));
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 1.5f);
}
}
public void ExpireInvitees()
{
Iterator<String> inviteeIterator = _invitee.keySet().iterator();
while (inviteeIterator.hasNext())
{
String name = inviteeIterator.next();
Player invitee = UtilPlayer.searchExact(name);
if (UtilTime.elapsed(_invitee.get(invitee.getName()), 60000))
{
Announce(F.name(invitee.getName()) + " did not respond to the Party ivnite.");
inviteeIterator.remove();
}
}
}
public String GetLeader()
{
if (_players.isEmpty())
return _creator;
return _players.get(0);
}
public Collection<String> GetPlayers()
{
return _players;
}
public Collection<Player> GetPlayersOnline()
{
ArrayList<Player> players = new ArrayList<Player>();
for (String name : _players)
{
Player player = UtilPlayer.searchExact(name);
if (player != null)
players.add(player);
}
return players;
}
public Collection<String> GetInvitees()
{
return _invitee.keySet();
}
public void UpdateScoreboard()
{
_scoreboardObj.setDisplayName(GetLeader() + "'s Party");
//Clear Past
for (String pastLine : _scoreboardLast)
_scoreboard.resetScores(Bukkit.getOfflinePlayer(pastLine));
_scoreboardLast.clear();
int i=16;
//Add New
for (int j=0 ; j<_players.size() ; j++)
{
String name = _players.get(j);
Player player = UtilPlayer.searchExact(name);
ChatColor col = ChatColor.GREEN;
if (player == null)
col = ChatColor.RED;
String line = col + name;
if (line.length() > 16)
line = line.substring(0, 16);
_scoreboardObj.getScore(Bukkit.getOfflinePlayer(line)).setScore(i);
_scoreboardLast.add(line);
i--;
}
//Add New
for (String name : _invitee.keySet())
{
int time = 1 + (int) ((60000 - (System.currentTimeMillis() - _invitee.get(name)))/1000);
String line = time + " " + ChatColor.GRAY + name;
if (line.length() > 16)
line = line.substring(0, 16);
_scoreboardObj.getScore(Bukkit.getOfflinePlayer(line)).setScore(i);
_scoreboardLast.add(line);
i--;
}
//Set Scoreboard
for (String name : _players)
{
Player player = UtilPlayer.searchExact(name);
if (player != null)
{
if (!player.getScoreboard().equals(_scoreboard))
{
player.setScoreboard(_scoreboard);
}
}
}
}
public boolean IsDead()
{
if (_players.size() == 0)
return true;
if (_players.size() == 1 && _invitee.size() == 0)
return true;
int online = 0;
for (String name : _players)
{
Player player = UtilPlayer.searchExact(name);
if (player != null)
online++;
}
//One or Less Members Online - Expirey Countdown
if (online <= 1)
{
if (_partyOfflineTimer == -1)
{
_partyOfflineTimer = System.currentTimeMillis();
}
else
{
if (UtilTime.elapsed(_partyOfflineTimer, 3600000)) // 1 hour
{
return true;
}
}
}
return false;
}
}

View File

@ -0,0 +1,109 @@
package mineplex.hub.party;
import java.util.HashSet;
import java.util.Iterator;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import mineplex.core.MiniPlugin;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.HubManager;
import mineplex.hub.party.commands.PartyCommand;
public class PartyManager extends MiniPlugin
{
public HubManager Manager;
public HashSet<Party> _parties = new HashSet<Party>();
public PartyManager(HubManager manager)
{
super("Party Manager", manager.GetPlugin());
Manager = manager;
}
@Override
public void AddCommands()
{
AddCommand(new PartyCommand(this));
}
public Party CreateParty(Player player)
{
Party party = new Party(this);
party.JoinParty(player);
_parties.add(party);
return party;
}
@EventHandler(priority = EventPriority.MONITOR)
public void PlayerJoin(PlayerJoinEvent event)
{
for (Party party : _parties)
{
party.PlayerJoin(event.getPlayer());
}
}
@EventHandler
public void PlayerQuit(PlayerQuitEvent event)
{
for (Party party : _parties)
{
party.PlayerQuit(event.getPlayer());
}
}
@EventHandler
public void Update(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
ExpireParties();
for (Party party : _parties)
{
party.ExpireInvitees();
party.UpdateScoreboard();
}
}
public void ExpireParties()
{
Iterator<Party> partyIterator = _parties.iterator();
while (partyIterator.hasNext())
{
Party party = partyIterator.next();
//Empty Party
if (party.IsDead())
{
party.Announce("Your Party has been closed.");
partyIterator.remove();
}
}
}
public Party GetParty(Player player)
{
for (Party party : _parties)
{
if (party.GetPlayers().contains(player.getName()))
{
return party;
}
}
return null;
}
}

View File

@ -0,0 +1,138 @@
package mineplex.hub.party.commands;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.hub.party.Party;
import mineplex.hub.party.PartyManager;
public class PartyCommand extends CommandBase<PartyManager>
{
public PartyCommand(PartyManager plugin)
{
super(plugin, Rank.ALL, new String[] {"party","z"});
}
@Override
public void Execute(Player caller, String[] args)
{
if (args == null || args.length == 0 || (args[0].equalsIgnoreCase("kick") && args.length < 2))
{
UtilPlayer.message(caller, F.main("Party", "Listing Party Commands;"));
UtilPlayer.message(caller, F.value(0, "/party <Player>", "Join/Create/Invite Player"));
UtilPlayer.message(caller, F.value(0, "/party leave", "Leave your current Party"));
UtilPlayer.message(caller, F.value(0, "/party kick <Player>", "Kick player from your Party"));
return;
}
//Callers Party
Party party = Plugin.GetParty(caller);
//Leave
if (args[0].equalsIgnoreCase("leave"))
{
if (party == null)
{
UtilPlayer.message(caller, F.main("Party", "You are not in a Party."));
}
else
{
party.LeaveParty(caller);
}
return;
}
//Leave
if (args[0].equalsIgnoreCase("kick"))
{
if (party == null)
{
UtilPlayer.message(caller, F.main("Party", "You are not in a Party."));
}
else
{
if (party.GetLeader().equals(caller.getName()))
{
Player target = UtilPlayer.searchOnline(caller, args[1], true);
if (target == null) return;
if (target.equals(caller))
{
UtilPlayer.message(caller, F.main("Party", "You cannot kick yourself from the Party."));
return;
}
party.KickParty(target);
}
else
{
UtilPlayer.message(caller, F.main("Party", "You are not the Party Leader."));
}
}
return;
}
//Main
Player target = UtilPlayer.searchOnline(caller, args[0], true);
if (target == null) return;
if (target.equals(caller))
{
UtilPlayer.message(caller, F.main("Party", "You cannot Party with yourself."));
return;
}
//Invite or Suggest
if (party != null)
{
if (party.GetPlayers().size() + party.GetInvitees().size() >= 16)
{
UtilPlayer.message(caller, "Your party cannot be larger than 16 players.");
caller.playSound(caller.getLocation(), Sound.NOTE_BASS, 1f, 1.5f);
}
//Decline
else if (party.GetPlayers().contains(target))
{
UtilPlayer.message(caller, F.main("Party", F.name(target.getName()) + " is already in the Party."));
caller.playSound(caller.getLocation(), Sound.NOTE_BASS, 1f, 1.5f);
}
//Invite
else if (party.GetLeader().equals(caller.getName()))
{
party.InviteParty(target, Plugin.GetParty(target) != null);
}
//Suggest
else
{
party.Announce(F.name(caller.getName()) + " suggested " + F.name(target.getName()) + " be invited to the Party.");
UtilPlayer.message(UtilPlayer.searchExact(party.GetLeader()), F.main("Party", "Type " + F.link("/party " + target.getName()) + " to invite them."));
}
}
//Create or Join
else
{
Party targetParty = Plugin.GetParty(target);
//Try to Join
if (targetParty != null)
{
if (targetParty.GetInvitees().contains(caller.getName()))
{
targetParty.JoinParty(caller);
return;
}
}
//Create
party = Plugin.CreateParty(caller);
party.InviteParty(target, Plugin.GetParty(target) != null);
}
}
}

View File

@ -2,227 +2,72 @@ 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.donation.DonationManager;
import mineplex.core.task.TaskManager;
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 DonationManager _donationManager;
private TaskManager _taskManager;
protected String _name;
protected int _gems;
protected String _task;
protected ArrayList<TutorialPhase> _phases = new ArrayList<TutorialPhase>();
protected HashMap<Player, TutorialData> _tute = new HashMap<Player, TutorialData>();
private ArrayList<TutorialPhase> phases = new ArrayList<TutorialPhase>();
private HashMap<Player, TutorialData> tute = new HashMap<Player, TutorialData>();
protected String _main = ChatColor.RESET + "";
protected String _elem = C.cYellow + C.Bold;
private String main = ChatColor.RESET + "";
private String elem = C.cYellow + C.Bold;
public Tutorial(HubManager manager, TextCreator text, DonationManager donationManager, TaskManager taskManager)
public Tutorial(HubManager manager, String name, int gems, String task)
{
super("Hub Tutorial", manager.GetPlugin());
HubText = text;
_donationManager = donationManager;
_taskManager = taskManager;
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 others 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)
{
if (!_taskManager.hasCompletedTask(event.getPlayer(), "Hub_JoinTutorial"))
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);
_name = name;
_gems = gems;
_task = task;
}
@EventHandler
public void MoveCancel(PlayerMoveEvent event)
public String GetTutName()
{
if (InTutorial(event.getPlayer()))
event.setTo(event.getFrom());
return _name;
}
public int GetGems()
{
return _gems;
}
public String GetTask()
{
return _task;
}
@EventHandler
public void Update(UpdateEvent event)
public void BeginTutorial(Player player)
{
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();
_taskManager.completedTask(player, "Hub_JoinTutorial");
_donationManager.RewardGems(player.getName(), 5000);
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);
}
}
}
_tute.put(player, new TutorialData(player, _phases.get(0)));
}
public boolean InTutorial(Player player)
{
return tute.containsKey(player);
return _tute.containsKey(player);
}
public void EndTutorial(Player player)
{
_tute.remove(player);
}
public HashMap<Player, TutorialData> GetTutorial()
{
return _tute;
}
public ArrayList<TutorialPhase> GetPhases()
{
return _phases;
}
}

View File

@ -66,7 +66,7 @@ public class TutorialData
if (text.length() > 0)
{
Player.playSound(Player.getLocation(), Sound.ORB_PICKUP, 2f, 1.5f);
Sleep = System.currentTimeMillis() + 1200 + (60*text.length());
Sleep = System.currentTimeMillis() + 1000 + (50*text.length());
}
else
{

View File

@ -0,0 +1,154 @@
package mineplex.hub.tutorial;
import java.util.HashSet;
import java.util.Iterator;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
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.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager;
import mineplex.core.task.TaskManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.HubManager;
import mineplex.hub.TextCreator;
import mineplex.hub.tutorial.types.PartyTutorial;
import mineplex.hub.tutorial.types.WelcomeTutorial;
public class TutorialManager extends MiniPlugin
{
//Tutorials
private HashSet<Tutorial> _tutorials;
//Modules
protected DonationManager _donationManager;
protected TaskManager _taskManager;
public TutorialManager(HubManager manager, DonationManager donation, TaskManager task, TextCreator text)
{
super("Tutorial Manager", manager.GetPlugin());
_taskManager = task;
_donationManager = donation;
_tutorials = new HashSet<Tutorial>();
_tutorials.add(new WelcomeTutorial(manager, text));
_tutorials.add(new PartyTutorial(manager));
}
@EventHandler
public void EntityInteract(PlayerInteractEntityEvent event)
{
if (InTutorial(event.getPlayer()))
return;
if (!(event.getRightClicked() instanceof LivingEntity))
return;
LivingEntity ent = (LivingEntity)event.getRightClicked();
String name = ent.getCustomName();
if (name == null)
return;
for (Tutorial tut : _tutorials)
{
if (name.contains(tut.GetTutName()))
{
UtilPlayer.message(event.getPlayer(), F.main("Tutorial", "You started " + F.elem(tut.GetTutName()) + "."));
tut.BeginTutorial(event.getPlayer());
return;
}
}
}
@EventHandler
public void PlayerQuit(PlayerQuitEvent event)
{
for (Tutorial tut : _tutorials)
tut.EndTutorial(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;
for (Tutorial tut : _tutorials)
{
Iterator<Player> tuteIterator = tut.GetTutorial().keySet().iterator();
while (tuteIterator.hasNext())
{
Player player = tuteIterator.next();
TutorialData data = tut.GetTutorial().get(player);
//Check if Phase Completed
if (data.Update())
{
//Next Phase
if (data.PhaseStep < tut.GetPhases().size())
{
data.SetNextPhase(tut.GetPhases().get(data.PhaseStep));
}
//End Tutorial
else
{
tuteIterator.remove();
//Inform
UtilPlayer.message(player, F.main("Tutorial", "You completed " + F.elem(tut.GetTutName()) + "."));
//Gems (Not Completed Yet)
if (!_taskManager.hasCompletedTask(player, tut.GetTask()))
{
_donationManager.RewardGems(player.getName(), tut.GetGems());
UtilPlayer.message(player, F.main("Tutorial", "You received " + F.elem(C.cGreen + tut.GetGems() + " Gems") + "."));
}
//Set Completed
_taskManager.completedTask(player, tut.GetTask());
//Sound
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
}
}
}
}
}
public boolean InTutorial(Player player)
{
for (Tutorial tut : _tutorials)
if (tut.InTutorial(player))
return true;
return false;
}
}

View File

@ -0,0 +1,121 @@
package mineplex.hub.tutorial.types;
import org.bukkit.ChatColor;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.hub.HubManager;
import mineplex.hub.tutorial.Tutorial;
import mineplex.hub.tutorial.TutorialPhase;
public class PartyTutorial extends Tutorial
{
public PartyTutorial(HubManager manager)
{
super(manager, "Party Tutorial", 1000, "Hub_PartyTutorial");
double y = -manager.GetSpawn().getY();
_phases.add(new TutorialPhase(
manager.GetSpawn().add(84, y+69, 10),
manager.GetSpawn().add(81, y+68.5, 10),
"Parties",
new String[]
{
"Hi there!",
"",
"This tutorial will teach you about Parties.",
"",
"Parties are used to group with other players",
"in order to easily play the same game together."
}
));
_phases.add(new TutorialPhase(
manager.GetSpawn().add(84, y+69, 10),
manager.GetSpawn().add(81, y+68.5, 10),
"Creating a Party",
new String[]
{
"To create a Party with someone;",
"",
"Type " + F.link("/party <Player>"),
"",
"This will create a party, and invite them to it!",
"They will receive a notification on how to join.",
}
));
_phases.add(new TutorialPhase(
manager.GetSpawn().add(84, y+69, 10),
manager.GetSpawn().add(81, y+68.5, 10),
"Inviting and Suggesting Players",
new String[]
{
"To invite/suggest more players to a Party;",
"",
"Type " + F.link("/party <Player>"),
"",
"Invitations last for 60 seconds."
}
));
_phases.add(new TutorialPhase(
manager.GetSpawn().add(84, y+69, 10),
manager.GetSpawn().add(81, y+68.5, 10),
"Leaving Parties",
new String[]
{
"To leave your current Party;",
"",
"Type " + F.link("/party leave"),
}
));
_phases.add(new TutorialPhase(
manager.GetSpawn().add(84, y+69, 10),
manager.GetSpawn().add(81, y+68.5, 10),
"Kicking Players from Party",
new String[]
{
"To kick players from your current Party;",
"",
"Type " + F.link("/party kick <Player>"),
"",
"Only the Party Leader can do this."
}
));
_phases.add(new TutorialPhase(
manager.GetSpawn().add(84, y+69, 10),
manager.GetSpawn().add(81, y+68.5, 10),
"Joining Games Together",
new String[]
{
"Only the Party Leader can join games.",
"",
"The game must have enough slots for",
"all Party Members to fit.",
"",
"All members will be connected to the game."
}
));
_phases.add(new TutorialPhase(
manager.GetSpawn().add(84, y+69, 10),
manager.GetSpawn().add(81, y+68.5, 10),
"Party Chat",
new String[]
{
"To send a message to your Party;",
"",
"Type " + F.link("@Hey guys, how are you?"),
"",
"They will see; ",
C.cDPurple + C.Bold + "Party " + C.cWhite + C.Bold + "YourName " + ChatColor.RESET + C.cPurple + "Hey guys, how are you?"
}
));
}
}

View File

@ -0,0 +1,128 @@
package mineplex.hub.tutorial.types;
import mineplex.hub.HubManager;
import mineplex.hub.TextCreator;
import mineplex.hub.tutorial.Tutorial;
import mineplex.hub.tutorial.TutorialPhase;
public class WelcomeTutorial extends Tutorial
{
public WelcomeTutorial(HubManager manager, TextCreator text)
{
super(manager, "Welcome Tutorial", 5000, "Hub_JoinTutorial");
double y = -manager.GetSpawn().getY();
//Welcome
_phases.add(new TutorialPhase(
manager.GetSpawn().add(-40, y+85, 0),
manager.GetSpawn(),
"Welcome to Mineplex",
new String[]
{
"Welcome!",
"",
"This is a very quick tutorial to help you start.",
"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),
text.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),
text.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),
text.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),
text.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 others 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!"
}
));
}
}