changes to tutorial

This commit is contained in:
NewGarbo 2015-12-02 00:19:48 +00:00
parent ba27d94158
commit b8e2086928
7 changed files with 137 additions and 59 deletions

View File

@ -19,9 +19,9 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilWorld;
import mineplex.core.recharge.Recharge;
import mineplex.game.clans.clans.event.ClanDisbandedEvent; import mineplex.game.clans.clans.event.ClanDisbandedEvent;
import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent; import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent;
import mineplex.game.clans.clans.event.PlayerPreClaimTerritoryEvent;
import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent; import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent;
import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.core.repository.ClanTerritory;
@ -689,6 +689,16 @@ public class ClansUtility
{ {
ClanInfo clan = getClanByPlayer(caller); ClanInfo clan = getClanByPlayer(caller);
// Pre Event
PlayerPreClaimTerritoryEvent preEvent = new PlayerPreClaimTerritoryEvent(caller, caller.getLocation().getChunk(), clan);
UtilServer.getServer().getPluginManager().callEvent(preEvent);
if (preEvent.isCancelled())
{
return false;
}
if (clan == null) if (clan == null)
{ {
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan."));

View File

@ -0,0 +1,63 @@
package mineplex.game.clans.clans.event;
import org.bukkit.Chunk;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import mineplex.game.clans.clans.ClanInfo;
public class PlayerPreClaimTerritoryEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Player _claimer;
private Chunk _claimedChunk;
private boolean _cancelled;
private ClanInfo _clan;
public PlayerPreClaimTerritoryEvent(Player claimer, Chunk claimedChunk, ClanInfo clan)
{
_claimer = claimer;
_claimedChunk = claimedChunk;
_clan = clan;
}
public Player getClaimer()
{
return _claimer;
}
public ClanInfo getClan()
{
return _clan;
}
public Chunk getClaimedChunk()
{
return _claimedChunk;
}
public void setCancelled(boolean cancelled)
{
_cancelled = cancelled;
}
public boolean isCancelled()
{
return _cancelled;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -169,6 +169,11 @@ public abstract class Tutorial implements ScoreboardElement, Listener
get(player).LastDescriptionSentTime = 0; get(player).LastDescriptionSentTime = 0;
get(player).CurrentTask.visibleFinish(player); get(player).CurrentTask.visibleFinish(player);
// 6 Seconds for player to read the finish message (sent by the line above)
_manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable()
{
public void run()
{
// Cycle to next task, or null if last task. // Cycle to next task, or null if last task.
get(player).CurrentTask = task.equals(_tasks.get(_tasks.size())) ? null : _tasks.get(task.getID() + 1); get(player).CurrentTask = task.equals(_tasks.get(_tasks.size())) ? null : _tasks.get(task.getID() + 1);
@ -192,7 +197,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
{ {
get(player).CurrentTask.startFor(player); get(player).CurrentTask.startFor(player);
} }
}, 10L); }, 30L);
} }
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
@ -200,6 +205,8 @@ public abstract class Tutorial implements ScoreboardElement, Listener
}, player, String.format(TASK_COMPLETE_TASK, _technicalName, task.getTechnicalName())); }, player, String.format(TASK_COMPLETE_TASK, _technicalName, task.getTechnicalName()));
} }
} }
}, 6 * 20L);
}
public TutorialTask<?> getTask(final String technicalName) public TutorialTask<?> getTask(final String technicalName)
{ {
@ -303,8 +310,6 @@ public abstract class Tutorial implements ScoreboardElement, Listener
public void run() public void run()
{ {
// Sets the tutorial as complete in the TaskManager and effects. // Sets the tutorial as complete in the TaskManager and effects.
if (!_taskManager.hasCompletedTask(player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName)))
{
_taskManager.completedTask(new Callback<Boolean>() _taskManager.completedTask(new Callback<Boolean>()
{ {
public void run(final Boolean completed) public void run(final Boolean completed)
@ -332,7 +337,6 @@ public abstract class Tutorial implements ScoreboardElement, Listener
} }
}, player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName)); }, player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName));
} }
}
}, 20 * 2); }, 20 * 2);
} }
}, 20 * 4); }, 20 * 4);

View File

@ -5,6 +5,7 @@ import org.bukkit.event.EventPriority;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
import mineplex.game.clans.clans.event.PlayerPreClaimTerritoryEvent;
import mineplex.game.clans.tutorials.TutorialTask; import mineplex.game.clans.tutorials.TutorialTask;
public class TaskClaim extends TutorialTask<TutorialGettingStarted> public class TaskClaim extends TutorialTask<TutorialGettingStarted>
@ -19,27 +20,24 @@ public class TaskClaim extends TutorialTask<TutorialGettingStarted>
_description = "Clans can claim 16x16 areas of Territory! " _description = "Clans can claim 16x16 areas of Territory! "
+ "Once claimed, only your Clan can break/place blocks here. " + "Once claimed, only your Clan can break/place blocks here. "
+ "This is the perfect place to build a base and stash your items! " + "This is the perfect place to build a base and stash your items! "
+ "You can only claim in the Wilderness, and not next to other Clans Territory. " + "You can only claim in the Wilderness, and not next to other Clan's Territory. "
+ "Claim some Territory now, by typing {/c claim}!"; + "To claim some territory, go into the Clans GUI by typing {/c} and {Left-Clicking}";
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onClansCommand(ClansCommandExecutedEvent event) public void onClansCommand(PlayerPreClaimTerritoryEvent event)
{ {
if (!isDoing(event.getPlayer())) if (!isDoing(event.getClaimer()))
{ {
return; return;
} }
if (!ClansManager.getInstance().isInClan(event.getPlayer())) if (!ClansManager.getInstance().isInClan(event.getClaimer()))
{ {
return; return;
} }
if (event.getCommand().equals("claim")) finishFor(event.getClaimer());
{
finishFor(event.getPlayer());
event.setCancelled(true); event.setCancelled(true);
} }
}
} }

View File

@ -25,7 +25,8 @@ public class TaskCustomizeClass extends TutorialTask<TutorialGettingStarted>
_technicalName = "CustomizeKlass"; _technicalName = "CustomizeKlass";
_description = "Now that you have equipped a class, use this enchantment table to customize your class builds. " _description = "Now that you have equipped a class, use this enchantment table to customize your class builds. "
+ "Click on the enchantment table, and click the edit build button."; + "Click on the enchantment table, and click the edit build button. "
+ "Make sure to select an axe ability to try out in the next task!";
_taskPos = new Location(Spawn.getSpawnWorld(), 6, 66, -300, -180f, 0f); _taskPos = new Location(Spawn.getSpawnWorld(), 6, 66, -300, -180f, 0f);
} }
@ -44,7 +45,7 @@ public class TaskCustomizeClass extends TutorialTask<TutorialGettingStarted>
Player player = Bukkit.getPlayer(iterator.next()); Player player = Bukkit.getPlayer(iterator.next());
final ClientClass clientclass = ClansManager.getInstance().getClassManager().Get(player); final ClientClass clientclass = ClansManager.getInstance().getClassManager().Get(player);
if (clientclass != null && clientclass.GetSavingCustomBuild() != null) if (clientclass != null && clientclass.GetSavingCustomBuild() != null && clientclass.GetSavingCustomBuild().AxeSkill != null)
{ {
finishFor(player); finishFor(player);
} }

View File

@ -47,7 +47,7 @@ public class TaskLeaveSpawn extends TutorialTask<TutorialGettingStarted>
{ {
Player player = Bukkit.getPlayer(iterator.next()); Player player = Bukkit.getPlayer(iterator.next());
if (player.getLocation().getY() < 100) if (player.getLocation().getY() < 100 && getClans().getClanUtility().getClaim(player.getLocation()) == null)
{ {
finishFor(player); finishFor(player);
} }

View File

@ -28,6 +28,8 @@ public class TaskViewClanDetails extends TutorialTask<TutorialGettingStarted>
return; return;
} }
System.out.println(event.getCommand());
if (event.getCommand().equals("info")) if (event.getCommand().equals("info"))
{ {
finishFor(event.getPlayer()); finishFor(event.getPlayer());