Success! Finished all events woohoo!

This commit is contained in:
NewGarbo 2015-11-02 10:16:13 +00:00
parent 0bc8413430
commit 27c6ef4e9d
5 changed files with 122 additions and 17 deletions

View File

@ -26,9 +26,9 @@ import mineplex.game.clans.clans.ClansPlayer;
import mineplex.game.clans.clans.ClansUtility.ClanRelation; import mineplex.game.clans.clans.ClansUtility.ClanRelation;
import mineplex.game.clans.clans.ClientClan; import mineplex.game.clans.clans.ClientClan;
import mineplex.game.clans.clans.event.ClanDisbandedEvent; import mineplex.game.clans.clans.event.ClanDisbandedEvent;
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent;
import mineplex.game.clans.tutorials.TutorialManager; import mineplex.game.clans.tutorials.TutorialManager;
import mineplex.game.clans.tutorials.TutorialType;
import mineplex.game.clans.tutorials.types.TutorialGettingStarted;
public class ClansCommand extends CommandBase<ClansManager> public class ClansCommand extends CommandBase<ClansManager>
{ {
@ -48,7 +48,6 @@ public class ClansCommand extends CommandBase<ClansManager>
{ {
if (Plugin.getClanMemberUuidMap().containsKey(caller.getUniqueId())) if (Plugin.getClanMemberUuidMap().containsKey(caller.getUniqueId()))
infoClan(caller, Plugin.getClanMemberUuidMap().get(caller.getUniqueId()).getName()); infoClan(caller, Plugin.getClanMemberUuidMap().get(caller.getUniqueId()).getName());
else else
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
return; return;
@ -169,6 +168,8 @@ public class ClansCommand extends CommandBase<ClansManager>
private void help(Player caller) private void help(Player caller)
{ {
UtilServer.getServer().getPluginManager().callEvent(new ClansCommandExecutedEvent(caller, "help", null));
UtilPlayer.message(caller, F.main("Clans", "Commands List;")); UtilPlayer.message(caller, F.main("Clans", "Commands List;"));
UtilPlayer.message(caller, F.help("/c create <clan>", "Create new Clan", Rank.ALL)); UtilPlayer.message(caller, F.help("/c create <clan>", "Create new Clan", Rank.ALL));
UtilPlayer.message(caller, F.help("/c join <clan>", "Join a Clan", Rank.ALL)); UtilPlayer.message(caller, F.help("/c join <clan>", "Join a Clan", Rank.ALL));
@ -950,8 +951,8 @@ public class ClansCommand extends CommandBase<ClansManager>
// Recharge // Recharge
if (!Recharge.Instance.use(caller, "Territory Claim", 60000, true, false)) return; if (!Recharge.Instance.use(caller, "Territory Claim", 60000, true, false)) return;
// Tutorial // Event
if (!((TutorialGettingStarted) TutorialManager.Instance.getTutorials().get(TutorialType.GETTING_STARTED)).onClaim(caller)) return; PlayerClaimTerritoryEvent event = new PlayerClaimTerritoryEvent(caller, caller.getLocation().getChunk());
// Task // Task
Plugin.getClanDataAccess().claim(clan.getName(), chunk, caller.getName(), false); Plugin.getClanDataAccess().claim(clan.getName(), chunk, caller.getName(), false);
@ -1188,10 +1189,11 @@ public class ClansCommand extends CommandBase<ClansManager>
return; return;
} }
UtilServer.getServer().getPluginManager().callEvent(new ClansCommandExecutedEvent(caller, "info", search));
ClanInfo clan = Plugin.getClanUtility().searchClanPlayer(caller, search, true); ClanInfo clan = Plugin.getClanUtility().searchClanPlayer(caller, search, true);
if (clan == null) return; if (clan == null) return;
((TutorialGettingStarted) TutorialManager.Instance.getTutorials().get(TutorialType.GETTING_STARTED)).onClanInfo(caller, search);
UtilPlayer.message(caller, clan.mDetails(caller)); UtilPlayer.message(caller, clan.mDetails(caller));
} }

View File

@ -1,13 +1,10 @@
package mineplex.game.clans.clans.event; package mineplex.game.clans.clans.event;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.mount.Mount;
import mineplex.game.clans.clans.ClanInfo;
import org.bukkit.entity.Player;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import mineplex.game.clans.clans.ClanInfo;
public class ClanDeleteEvent extends Event public class ClanDeleteEvent extends Event
{ {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();

View File

@ -0,0 +1,46 @@
package mineplex.game.clans.clans.event;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class ClansCommandExecutedEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Player _player;
private String _command;
private String[] _args;
public ClansCommandExecutedEvent(Player player, String command, String... args)
{
_player = player;
_command = command;
_args = args;
}
public Player getPlayer()
{
return _player;
}
public String getCommand()
{
return _command;
}
public String[] getArguments()
{
return _args;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -0,0 +1,53 @@
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;
public class PlayerClaimTerritoryEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Player _claimer;
private Chunk _claimedChunk;
private boolean _cancelled;
public PlayerClaimTerritoryEvent(Player claimer, Chunk claimedChunk)
{
_claimer = claimer;
_claimedChunk = claimedChunk;
}
public Player getClaimer()
{
return _claimer;
}
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

@ -20,8 +20,10 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.ClanCreatedEvent; import mineplex.game.clans.clans.event.ClanCreatedEvent;
import mineplex.game.clans.clans.event.ClanDisbandedEvent; import mineplex.game.clans.clans.event.ClanDisbandedEvent;
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent; import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent;
import mineplex.game.clans.clans.event.ClansShopAddButtonEvent; import mineplex.game.clans.clans.event.ClansShopAddButtonEvent;
import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent;
import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent; import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent;
import mineplex.game.clans.economy.GoldManager; import mineplex.game.clans.economy.GoldManager;
import mineplex.game.clans.tutorials.Tutorial; import mineplex.game.clans.tutorials.Tutorial;
@ -170,11 +172,15 @@ public class TutorialGettingStarted extends Tutorial
} }
} }
public void onClanInfo(final Player caller, final String name) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onClansCommand(ClansCommandExecutedEvent event)
{ {
if (isInTutorial(caller.getName()) && get(caller).hasFinishedTask(getTask("Welcome")) && !get(caller).hasFinishedTask(getTask("Viewing Clan Info"))) if (event.getCommand().equals("info"))
{ {
finishTask(caller, "Viewing Clan Info"); if (isInTutorial(event.getPlayer()) && get(event.getPlayer()).hasFinishedTask(getTask("Welcome")) && !get(event.getPlayer()).hasFinishedTask(getTask("Viewing Clan Info")))
{
finishTask(event.getPlayer(), "Viewing Clan Info");
}
} }
} }
@ -198,11 +204,12 @@ public class TutorialGettingStarted extends Tutorial
} }
} }
public boolean onClaim(final Player caller) @EventHandler(priority = EventPriority.MONITOR)
public boolean onClaim(final PlayerClaimTerritoryEvent event)
{ {
if (isInTutorial(caller) && get(caller).hasFinishedTask(getTask("Go To The Wilderness")) && !get(caller).hasFinishedTask(getTask("Claiming Territory"))) if (isInTutorial(event.getClaimer()) && get(event.getClaimer()).hasFinishedTask(getTask("Go To The Wilderness")) && !get(event.getClaimer()).hasFinishedTask(getTask("Claiming Territory")))
{ {
finishTask(caller, "Claiming Territory"); finishTask(event.getClaimer(), "Claiming Territory");
return false; return false;
} }