diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index 60d059276..a731057a3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -55,14 +55,14 @@ public class ClansCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { + if (UtilServer.CallEvent(new ClansCommandPreExecutedEvent(caller, args)).isCancelled()) + return; + if (args == null || args.length == 0) { _clansManager.getClanShop().attemptShopOpen(caller); return; } - - if (UtilServer.CallEvent(new ClansCommandPreExecutedEvent(caller, args)).isCancelled()) - return; if (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("h")) help(caller); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/AttackEnemyObjective.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/AttackEnemyObjective.java index 65f8c6af4..00c7eea61 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/AttackEnemyObjective.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/AttackEnemyObjective.java @@ -20,11 +20,12 @@ import java.util.Map; public class AttackEnemyObjective extends OrderedObjective { - private Map _cannon = new HashMap<>(); + private Map _cannon; public AttackEnemyObjective(ClansMainTutorial clansMainTutorial, JavaPlugin javaPlugin) { super(clansMainTutorial, javaPlugin, "Attack Enemy", "Attack and raid this enemy!"); + _cannon = new HashMap<>(); addGoal(new GetMapGoal(this)); addGoal(new HoldItemGoal(this, Material.MAP, "Identify Enemy Clan", "By looking at your map, identify your new enemy")); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/ClanObjective.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/ClanObjective.java index 9126afab5..e8b2b4a7a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/ClanObjective.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/ClanObjective.java @@ -1,5 +1,6 @@ package mineplex.game.clans.tutorial.tutorials.clans.objective; +import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.*; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; @@ -7,12 +8,6 @@ import mineplex.game.clans.tutorial.objective.OrderedObjective; import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial; import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.BlowUpWallGoal; import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.attackenemy.StealEnemyPotatoesGoal; -import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.BuildHouseGoal; -import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.ClaimLandGoal; -import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.ClanDetailsGoal; -import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.CreateClanGoal; -import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.LeaveSpawnGoal; -import mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan.SetHomeGoal; public class ClanObjective extends OrderedObjective { @@ -22,7 +17,9 @@ public class ClanObjective extends OrderedObjective addGoal(new LeaveSpawnGoal(this)); addGoal(new CreateClanGoal(this)); + addGoal(new ClanManagementGoal(this)); addGoal(new ClanDetailsGoal(this)); + addGoal(new ClanInfoGoal(this)); addGoal(new ClaimLandGoal(this)); addGoal(new BuildHouseGoal(this)); addGoal(new SetHomeGoal(this)); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/clan/ClanInfoGoal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/clan/ClanInfoGoal.java new file mode 100644 index 000000000..3e51686d8 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/clan/ClanInfoGoal.java @@ -0,0 +1,75 @@ +package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan; + +/** + * Created by Adam on 29/03/2016. + */ + +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.F; +import mineplex.game.clans.Clans; +import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.ClientClan; +import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; +import mineplex.game.clans.clans.event.ClansCommandPreExecutedEvent; +import mineplex.game.clans.tutorial.objective.ObjectiveGoal; +import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +/** + * Created by Adam on 29/03/2016. + */ +public class ClanInfoGoal extends ObjectiveGoal +{ + public ClanInfoGoal(ClanObjective objective) + { + super(objective, "Info on other clan", "Get info on other clans by using the command /c "); + } + + @Override + protected void customStart(Player player) + { + player.sendMessage(F.main("Clans", "You can use the command /c to get information about other clans. Try typing /c randomClan")); + } + + @Override + protected void customFinish(Player player) + { + } + + @EventHandler + public void onClanInfo(ClansCommandPreExecutedEvent event) + { + if (contains(event.getPlayer())) + { + event.setCancelled(true); + if(event.getArguments().length < 1) return; + + event.setCancelled(true); + ClanInfo clan = ClansManager.getInstance().getClan(event.getArguments()[0]); + if(clan == null) + { + ClansManager.getInstance().getClanDataAccess().create("Chiss", event.getArguments()[0], false, new Callback() { + @Override + public void run(ClanInfo data) { + ClansManager.getInstance().getClanShop().openClanWho(event.getPlayer(), clan); + finish(event.getPlayer()); + ClansManager.getInstance().runSyncLater(() -> { + ClansManager.getInstance().getClanDataAccess().delete(ClansManager.getInstance().getClan(event.getArguments()[0]), null); + }, 100L); + } + }); + } else { + ClansManager.getInstance().getClanShop().openClanWho(event.getPlayer(), clan); + finish(event.getPlayer()); + } + + + + + //TODO finish + finish(event.getPlayer()); + } + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/clan/ClanManagementGoal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/clan/ClanManagementGoal.java new file mode 100644 index 000000000..68deb498c --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/clan/ClanManagementGoal.java @@ -0,0 +1,45 @@ +package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan; + +import mineplex.core.common.util.F; +import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; +import mineplex.game.clans.clans.event.ClansCommandPreExecutedEvent; +import mineplex.game.clans.tutorial.objective.ObjectiveGoal; +import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +/** + * Created by Adam on 29/03/2016. + */ +public class ClanManagementGoal extends ObjectiveGoal +{ + public ClanManagementGoal(ClanObjective objective) + { + super(objective, "Manage your clan", "Manage your clan by using the command /c"); + } + + @Override + protected void customStart(Player player) + { + player.sendMessage(F.main("Clans", "You can use the command /c to manage your clan.")); + } + + @Override + protected void customFinish(Player player) + { + } + + @EventHandler + public void onClanInfo(ClansCommandPreExecutedEvent event) + { + if (contains(event.getPlayer())) + { + if (event.getArguments() == null || event.getArguments().length == 0) + { + finish(event.getPlayer()); + } + } + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/clan/CreateClanGoal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/clan/CreateClanGoal.java index b3fc57bc0..c05793033 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/clan/CreateClanGoal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/clan/CreateClanGoal.java @@ -12,7 +12,7 @@ public class CreateClanGoal extends ObjectiveGoal { public CreateClanGoal(ClanObjective objective) { - super(objective, "Create a Clan", "Create a Clan"); + super(objective, "Create a Clan", "Create a Clan using /c create"); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/energy/ExplainEnergyGoal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/energy/ExplainEnergyGoal.java index 48b69ea4b..2577ffb0f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/energy/ExplainEnergyGoal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/energy/ExplainEnergyGoal.java @@ -14,7 +14,7 @@ public class ExplainEnergyGoal extends ObjectiveGoal { public ExplainEnergyGoal(EnergyObjective objective) { - super(objective, "Check your Energy", "Check your Energy"); + super(objective, "About Energy", "Check your Energy"); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/finalobj/DisbandClanGoal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/finalobj/DisbandClanGoal.java index 056b9d597..a69e6139d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/finalobj/DisbandClanGoal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/finalobj/DisbandClanGoal.java @@ -1,5 +1,6 @@ package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.finalobj; +import mineplex.game.clans.clans.event.ClanDisbandedEvent; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -17,7 +18,7 @@ public class DisbandClanGoal extends ObjectiveGoal { public DisbandClanGoal(FinalObjective objective) { - super(objective, "Disband Clan", "Use the /c command to disband your Tutorial Clan"); + super(objective, "Disband Clan", "Use the /c command to disband your Tutorial Clan"); } @Override @@ -31,21 +32,16 @@ public class DisbandClanGoal extends ObjectiveGoal } @EventHandler(priority = EventPriority.HIGHEST) - public void teleport(ClansCommandPreExecutedEvent event) + public void teleport(ClanDisbandedEvent event) { - if (event.getArguments().length != 1 || !event.getArguments()[0].equalsIgnoreCase("disband")) + if (!contains(event.getDisbander())) { return; } - - if (!contains(event.getPlayer())) - { - return; - } - - UtilPlayer.message(event.getPlayer(), F.main("Clans", "You have disbanded your Tutorial Clan.")); - ClansManager.getInstance().getClanDataAccess().delete(ClansManager.getInstance().getClan(event.getPlayer()), null); - finish(event.getPlayer()); event.setCancelled(true); + + UtilPlayer.message(event.getDisbander(), F.main("Clans", "You have disbanded your Tutorial Clan.")); + ClansManager.getInstance().getClanDataAccess().delete(ClansManager.getInstance().getClan(event.getDisbander()), null); + finish(event.getDisbander()); } }