diff --git a/Plugins/.idea/compiler.xml b/Plugins/.idea/compiler.xml index f1153fde6..30263f09d 100644 --- a/Plugins/.idea/compiler.xml +++ b/Plugins/.idea/compiler.xml @@ -23,7 +23,7 @@ - + diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java index 45fd28921..9eeda0347 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java @@ -116,4 +116,12 @@ public enum Rank { return _donor; } + + public String getRawTag() + { + if (Name.equalsIgnoreCase("ALL")) + return ""; + + return Name; + } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java index d5c8f563e..8bbac15bc 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilText.java @@ -106,4 +106,8 @@ public class UtilText { return x <= 0 ? true : x > 1; } + public static String trim(int maxLength, String s) { + return s.length() <= maxLength ? s : s.substring(0, maxLength); + } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java index 3b7c39b97..b253a4ea7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ConfirmationPage.java @@ -79,7 +79,7 @@ public class ConfirmationPage { + public static TaskManager Instance; + private static Object _taskLock = new Object(); private TaskRepository _repository; @@ -27,6 +29,8 @@ public class TaskManager extends MiniDbClientPlugin { super("Task Manager", plugin, clientManager); + Instance = this; + _repository = new TaskRepository(plugin); updateTasks(); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyTracker.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyTracker.java index 36aa20305..307768c84 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyTracker.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyTracker.java @@ -12,7 +12,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.tutorials.types.ClanTips.TipType; +import mineplex.game.clans.clans.ClanTips.TipType; public class ClanEnergyTracker extends MiniPlugin { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java index 547c55e89..dc53b6069 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanInfo.java @@ -670,7 +670,7 @@ public class ClanInfo public int getEnergyMax() { // 10080 = 7 days of minutes - return Math.max(4320, getEnergyCostPerMinute() * 60 * 24 * 3); + return Math.max(10080, getEnergyCostPerMinute() * 60 * 24 * 7); } public int getEnergyCostPerMinute() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/types/ClanTips.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java similarity index 96% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/types/ClanTips.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java index 5dee42973..c4e4f8f87 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/types/ClanTips.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanTips.java @@ -1,4 +1,4 @@ -package mineplex.game.clans.tutorials.types; +package mineplex.game.clans.clans; import java.util.LinkedList; @@ -12,8 +12,9 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.preferences.PreferencesManager; -import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.event.ClanTipEvent; import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent; import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent; import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent; @@ -117,6 +118,15 @@ public class ClanTips extends MiniPlugin return; } + ClanTipEvent event = new ClanTipEvent(tip, player); + + UtilServer.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) + { + return; + } + UtilPlayer.message(player, " "); UtilPlayer.message(player, tip._messages); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 23f3a0964..d9d7233e4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -64,6 +64,7 @@ import mineplex.core.task.TaskManager; import mineplex.core.teleport.Teleport; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClansUtility.ClanRelation; import mineplex.game.clans.clans.commands.ClanManagementCommand; import mineplex.game.clans.clans.commands.ClansAllyChatCommand; @@ -103,8 +104,6 @@ import mineplex.game.clans.gameplay.safelog.npc.NPCManager; import mineplex.game.clans.items.GearManager; import mineplex.game.clans.spawn.Spawn; import mineplex.game.clans.tutorials.TutorialManager; -import mineplex.game.clans.tutorials.types.ClanTips; -import mineplex.game.clans.tutorials.types.ClanTips.TipType; import mineplex.minecraft.game.classcombat.Class.ClassManager; import mineplex.minecraft.game.classcombat.Class.ClientClass; import mineplex.minecraft.game.classcombat.Class.IPvpClass; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java index 54d142720..8625d5b62 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java @@ -674,6 +674,9 @@ public class ClansUtility if (!data) { UtilPlayer.message(caller, F.main("Clans", "There was an error processing your request. Try again later")); + }else + { + UtilPlayer.message(caller, F.main("Clans", "You disbanded your Clan.")); } } }); @@ -724,11 +727,11 @@ public class ClansUtility } } - if (clan.getClaims() >= clan.getClaimsMax()) - { - UtilPlayer.message(caller, F.main("Clans", "Your Clan cannot claim more Territory.")); - return false; - } +// if (clan.getClaims() >= clan.getClaimsMax()) +// { +// UtilPlayer.message(caller, F.main("Clans", "Your Clan cannot claim more Territory.")); +// return false; +// } // Adjacent boolean selfAdj = false; @@ -736,7 +739,13 @@ public class ClansUtility { for (int z = -1; z <= 1; z++) { - if (x == 0 && z == 0) continue; + if ((x == 1 && z == 1) + || (x == -1 && z == 1) + || (x == -1 && z == -1) + || (x == 1 && z == -1) + || (x == 0 && z == 0)) { + continue; + } String other = UtilWorld.chunkToStr(caller.getWorld().getChunkAt(caller.getLocation().getChunk().getX() + x, caller.getLocation().getChunk().getZ() + z)); @@ -837,10 +846,10 @@ public class ClansUtility int boxed = 0; // This is bad. I know. But the other way doesn't seem to work. - String down = UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() + 1, chunk.getZ() + 1)); - String up = UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX(), chunk.getZ() -1 )); + String down = UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() + 0, chunk.getZ() + 1)); + String up = UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX(), chunk.getZ() - 1)); String right = UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() + 1, chunk.getZ())); - String left = UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() - 1, chunk.getZ() + 0)); + String left = UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() - 1, chunk.getZ())); ClanInfo downClan = getOwner(down); ClanInfo upClan = getOwner(up); 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 5f2db85d7..19dd24bd1 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 @@ -16,18 +16,16 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.recharge.Recharge; import mineplex.core.common.util.UtilWorld; -import mineplex.game.clans.Clans; +import mineplex.core.recharge.Recharge; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClanRole; +import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClansBlacklist; import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.ClansUtility; import mineplex.game.clans.clans.ClientClan; import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; import mineplex.game.clans.tutorials.TutorialManager; -import mineplex.game.clans.tutorials.types.ClanTips.TipType; import net.minecraft.server.v1_8_R3.EnumDirection; public class ClansCommand extends CommandBase @@ -275,6 +273,10 @@ public class ClansCommand extends CommandBase // Hopefully shouldn't happen! UtilPlayer.message(caller, F.main("Clans", "There was an error creating the clan. Please try again")); } + else + { + UtilPlayer.message(caller, F.main("Clans", "You created Clan " + C.cYellow + data.getName() + C.cGray + ".")); + } } }); } @@ -777,6 +779,15 @@ public class ClansCommand extends CommandBase { ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller); + // Event + ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "homeset"); + UtilServer.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) + { + return; + } + if (clan == null) { UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); @@ -833,7 +844,7 @@ public class ClansCommand extends CommandBase } public void infoClan(Player caller, String search) - { + {System.out.println(search); if (search == null) { UtilPlayer.message(caller, F.main("Clans", "You did not input a search parameter.")); @@ -854,6 +865,36 @@ public class ClansCommand extends CommandBase _manager.getClanShop().openClanWho(caller, clan); } + public void forceJoinClan(Player caller, String search) + { + if (_manager.getClientManager().hasRank(caller, Rank.ADMIN)) + { + UtilPlayer.message(caller, F.main("Clans", "No no no, this command is not for you ;-)")); + return; + } + + if (search == null) + { + UtilPlayer.message(caller, F.main("Clans", "You did not input a search parameter.")); + return; + } + + ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "info", search); + UtilServer.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) + { + return; + } + + ClanInfo clan = Plugin.getClanUtility().searchClanPlayer(caller, search, true); + if (clan == null) return; + + _manager.getClanUtility().join(caller, clan); + _manager.getClanDataAccess().role(clan, caller.getUniqueId(), ClanRole.LEADER); + } + + public void infoTerritory(Player caller, String[] args) { ClanInfo clan; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RestartTutCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RestartTutCommand.java new file mode 100644 index 000000000..63dce8c34 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/RestartTutCommand.java @@ -0,0 +1,25 @@ +package mineplex.game.clans.clans.commands; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.task.TaskManager; +import mineplex.game.clans.tutorials.TutorialManager; +import mineplex.game.clans.tutorials.gettingstarted.TutorialGettingStarted; + +public class RestartTutCommand extends CommandBase +{ + public RestartTutCommand(TutorialManager plugin) + { + super(plugin, Rank.ALL, "rst", "rstut"); + } + + @Override + public void Execute(Player caller, String[] args) + { + TaskManager.Instance.Get(caller).TasksCompleted.clear(); + TutorialManager.Instance.cancelTutorial(caller); + TutorialManager.Instance.startTutorial(TutorialGettingStarted.class, caller); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/ClanTipEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/ClanTipEvent.java new file mode 100644 index 000000000..38c34851e --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/ClanTipEvent.java @@ -0,0 +1,55 @@ +package mineplex.game.clans.clans.event; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import mineplex.game.clans.clans.ClanTips.TipType; + +public class ClanTipEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private Player _player; + private TipType _tip; + + private boolean _cancelled; + + public ClanTipEvent(TipType tip, Player player) + { + _player = player; + + _tip = tip; + } + + public Player getPlayer() + { + return _player; + } + + public TipType getTip() + { + return _tip; + } + + public void setCancelled(boolean cancelled) + { + _cancelled = cancelled; + } + + public boolean isCancelled() + { + return _cancelled; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/EnergyPageBuildEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/EnergyPageBuildEvent.java new file mode 100644 index 000000000..4212010be --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/EnergyPageBuildEvent.java @@ -0,0 +1,58 @@ +package mineplex.game.clans.clans.event; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import mineplex.core.shop.ShopBase; + +public class EnergyPageBuildEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private boolean _free; + private boolean _cancelled; + + private Player _player; + + public EnergyPageBuildEvent(Player player) + { + _player = player; + } + + public Player getPlayer() + { + return _player; + } + + public boolean free() + { + return _free; + } + + public void setFree(boolean free) + { + _free = free; + } + + public boolean isCancelled() + { + return _cancelled; + } + + public void setCancelled(boolean cancelled) + { + _cancelled = cancelled; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/command/ObserverCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/command/ObserverCommand.java index 0a236a669..e4a016c1f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/command/ObserverCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/command/ObserverCommand.java @@ -14,7 +14,7 @@ public class ObserverCommand extends CommandBase { public ObserverCommand(ObserverManager plugin) { - super(plugin, Rank.ALL, "observer", "o"); + super(plugin, Rank.HELPER, "observer", "o"); } @Override diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java index 607d5ccad..4fc9e80ab 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java @@ -1,6 +1,8 @@ package mineplex.game.clans.clans.scoreboard; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; import org.bukkit.entity.Player; import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; @@ -10,6 +12,7 @@ import org.bukkit.scoreboard.Team; import net.minecraft.server.v1_8_R3.ScoreboardTeam; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilText; import mineplex.core.scoreboard.PlayerScoreboard; import mineplex.core.scoreboard.ScoreboardManager; import mineplex.game.clans.clans.ClanInfo; @@ -73,6 +76,33 @@ public class ClansPlayerScoreboard extends PlayerScoreboard public void add(Scoreboard scoreboard, Player otherPlayer, ClanInfo clanInfo, ClanRelation relation, int ownScore) { + if (otherPlayer.getGameMode().equals(GameMode.CREATIVE)) + { + String teamName = UtilText.trim(16, _clansManager.getClientManager().Get(otherPlayer).GetRank().getRawTag() + "CREATIVE"); + Team team = scoreboard.getTeam(teamName); + if (team == null) + { + team = scoreboard.registerNewTeam(teamName); + team.setPrefix(UtilText.trim(16, _clansManager.getClientManager().Get(otherPlayer).GetRank().getTag(true, true) + ChatColor.RESET + " ")); + team.setSuffix(C.cRed + " STAFF MODE"); + } + + Objective domObjective; + if ((domObjective = scoreboard.getObjective(DisplaySlot.BELOW_NAME)) == null) + { + domObjective = scoreboard.registerNewObjective("war", "dummy"); + domObjective.setDisplayName("War Points"); + domObjective.setDisplaySlot(DisplaySlot.BELOW_NAME); + } + + if (clanInfo != null) + domObjective.getScore(otherPlayer.getName()).setScore(ownScore); + + team.addPlayer(otherPlayer); + + return; + } + String teamName = getTeamName(clanInfo, relation, ownScore); Team team = scoreboard.getTeam(teamName); if (team == null) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/stuck/StuckManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/stuck/StuckManager.java index 965fb25a8..4dd767615 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/stuck/StuckManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/stuck/StuckManager.java @@ -19,7 +19,7 @@ import mineplex.game.clans.spawn.Spawn; public class StuckManager extends MiniClientPlugin { - public static final long UNSTICK_WAIT_TIME = UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS); + public static final long UNSTICK_WAIT_TIME = UtilTime.convert(35, TimeUnit.SECONDS, TimeUnit.MILLISECONDS); public StuckManager(ClansManager clans) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java index 8bdc45f71..cc017df55 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java @@ -27,13 +27,13 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansUtility; +import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.event.ClanDisbandedEvent; import mineplex.game.clans.clans.event.ClansPlayerDeathEvent; import mineplex.game.clans.clans.war.command.WarPointsCommand; import mineplex.game.clans.clans.war.event.WarInvasionEndEvent; import mineplex.game.clans.clans.war.event.WarInvasionStartEvent; import mineplex.game.clans.core.war.ClanWarData; -import mineplex.game.clans.tutorials.types.ClanTips.TipType; public class WarManager extends MiniPlugin implements ScoreboardElement { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java index a5ddc39ff..9539a639e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/safelog/SafeLog.java @@ -20,8 +20,8 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.gameplay.safelog.npc.NPCManager; -import mineplex.game.clans.tutorials.types.ClanTips.TipType; public class SafeLog extends MiniPlugin { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java index 0d67e5689..78169ea47 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java @@ -4,6 +4,7 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilServer; import mineplex.core.donation.DonationManager; import mineplex.core.shop.ShopBase; @@ -79,7 +80,7 @@ public abstract class ClansShopPage> extends Sh if (!event.isCancelled()) { PvpItem item = new PvpItem(material, data, 1, displayName, buyPrice, sellPrice, 64); - addButton(slot, item, new ShopItemButton>(this, buyPrice, sellPrice, material, data, amount)); + addButton(slot, item, new ShopItemButton>(this, buyPrice, sellPrice, material, data, amount, displayName)); } } @@ -88,6 +89,7 @@ public abstract class ClansShopPage> extends Sh addShopItem(index, item, (byte) 0, displayName, 1); } + public void addShopItem(int index, ClansShopItem item) { addShopItem(index, item, (byte) 0); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpItem.java index 7482dde82..1dd6c2183 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpItem.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpItem.java @@ -3,6 +3,7 @@ package mineplex.game.clans.shop; import org.bukkit.Material; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilItem; import mineplex.core.shop.item.ShopItem; public class PvpItem extends ShopItem @@ -25,7 +26,18 @@ public class PvpItem extends ShopItem public PvpItem(Material type, byte data, int displayAmount, String name, int buyPrice, int sellPrice, int bulkCount) { - super(type, data, name, new String[] { C.cWhite + " ", LEFT_CLICK_BUY, C.cWhite + "Costs " + C.cGreen + buyPrice + "g", C.cWhite + " ", C.cYellow + "Shift Left-Click" + C.cWhite + " to Buy " + C.cGreen + bulkCount, C.cWhite + "Costs " + C.cGreen + (buyPrice * bulkCount) + "g", C.cWhite + " ", RIGHT_CLICK_SELL, C.cWhite + "Earns " + C.cGreen + sellPrice + "g", C.cWhite + " ", C.cYellow + "Shift Right-Click" + C.cWhite + " to Sell " + C.cGreen + "All", }, 0, false, false); + super(type, data, name, new String[] { + C.cWhite + " ", + LEFT_CLICK_BUY, + C.cWhite + "Costs " + C.cGreen + (buyPrice == 0 ? "Free" : buyPrice + "g"), + C.cWhite + " ", + UtilItem.isArmor(type) || UtilItem.isTool(type) ? "" : C.cYellow + "Shift Left-Click" + C.cWhite + " to Buy " + C.cGreen + bulkCount, + UtilItem.isArmor(type) || UtilItem.isTool(type) ? "" : C.cWhite + "Costs " + C.cGreen + (buyPrice * bulkCount) + "g", C.cWhite + " ", + RIGHT_CLICK_SELL, + C.cWhite + "Earns " + C.cGreen + (sellPrice == 0 ? "Free" : sellPrice + ""), + C.cWhite + " ", + C.cYellow + "Shift Right-Click" + C.cWhite + " to Sell " + C.cGreen + "All", + }, 0, false, false); _price = buyPrice; _sellPrice = sellPrice; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java index ad4359652..5b879737a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java @@ -1,14 +1,18 @@ package mineplex.game.clans.shop; +import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventory; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.InventoryUtil; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.shop.item.IButton; @@ -24,17 +28,30 @@ public class ShopItemButton> implements IButton private ItemStack _item; private T _page; - public ShopItemButton(T page, int buyPrice, int sellPrice, Material material, byte data, int amount) + public ShopItemButton(T page, int buyPrice, int sellPrice, Material material, byte data, int amount, String displayName) { _page = page; _sellPrice = sellPrice; _buyPrice = buyPrice; _item = new ItemStack(material, amount, data); + + if (displayName != null) + { + ItemMeta meta = _item.getItemMeta(); + if (meta == null) + { + meta = Bukkit.getItemFactory().getItemMeta(material); + } + + meta.setDisplayName(C.Reset + displayName); + + _item.setItemMeta(meta); + } } public ShopItemButton(T page, int buyPrice, int sellPrice, Material material) { - this(page, buyPrice, sellPrice, material, (byte) 0, 1); + this(page, buyPrice, sellPrice, material, (byte) 0, 1, null); } @Override @@ -78,7 +95,7 @@ public class ShopItemButton> implements IButton } else if (clickType == ClickType.SHIFT_LEFT || clickType == ClickType.LEFT) { - final int amount = shiftClick ? 64 : 1; + final int amount = !(UtilItem.isArmor(_item.getType()) || UtilItem.isTool(_item.getType())) && shiftClick ? 64 : 1; final int cost = amount * _buyPrice; int goldCount = GoldManager.getInstance().getGold(player); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPage.java index 6dce1b82b..4e63d4b90 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPage.java @@ -8,12 +8,15 @@ import org.bukkit.entity.Player; import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.donation.DonationManager; import mineplex.core.shop.item.ShopItem; import mineplex.core.shop.page.ShopPageBase; import mineplex.game.clans.clans.ClanEnergyManager; import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.event.ClansShopAddButtonEvent; +import mineplex.game.clans.clans.event.EnergyPageBuildEvent; public class EnergyPage extends ShopPageBase { @@ -44,9 +47,13 @@ public class EnergyPage extends ShopPageBase int oneDayEnergy = oneHourEnergy * 24; int maxEnergy = clanInfo.getEnergyPurchasable(); - addButton(clanInfo, 11, oneHourEnergy, Material.REDSTONE, (byte) 0, " ", ChatColor.RESET + "1 Hour of Energy", " ", ChatColor.RESET + "Costs " + C.cGreen + getPlugin().convertEnergyToGold(oneHourEnergy) + "g"); - addButton(clanInfo, 13, oneDayEnergy, Material.REDSTONE_BLOCK, (byte) 0, " ", ChatColor.RESET + "1 Day of Energy", " ", ChatColor.RESET + "Costs " + C.cGreen + getPlugin().convertEnergyToGold(oneDayEnergy) + "g"); - addButton(clanInfo, 15, maxEnergy, Material.FURNACE, (byte) 0, " ", ChatColor.RESET + "Maxed Out Energy", " ", ChatColor.RESET + "Costs " + C.cGreen + getPlugin().convertEnergyToGold(maxEnergy) + "g"); + EnergyPageBuildEvent event = new EnergyPageBuildEvent(getPlayer()); + + UtilServer.getServer().getPluginManager().callEvent(event); + + addButton(clanInfo, 11, oneHourEnergy, Material.REDSTONE, (byte) 0, event.free(), " ", ChatColor.RESET + "Purchase 1 Hour of Energy for your Clan", " ", ChatColor.RESET + (event.free() ? "FREE! (Tutorial)" : "Costs " + C.cGreen + getPlugin().convertEnergyToGold(oneHourEnergy) + "g")); + addButton(clanInfo, 13, oneDayEnergy, Material.REDSTONE_BLOCK, (byte) 0, event.free(), " ", ChatColor.RESET + "Purchase 1 Day of Energy for your Clan", " ", ChatColor.RESET + (event.free() ? "FREE! (Tutorial)" : "Costs " + C.cGreen + getPlugin().convertEnergyToGold(oneDayEnergy) + "g")); + addButton(clanInfo, 15, maxEnergy, Material.FURNACE, (byte) 0, event.free(), " ", ChatColor.RESET + "Max Out your Clan's Energy", " ", ChatColor.RESET + (event.free() ? "FREE! (Tutorial)" : "Costs " + C.cGreen + getPlugin().convertEnergyToGold(maxEnergy) + "g")); } private void addInfo(ClanInfo clanInfo, int slot) @@ -63,7 +70,7 @@ public class EnergyPage extends ShopPageBase setItem(slot, shopItem); } - private void addButton(ClanInfo clanInfo, int slot, int energyAmount, Material material, byte data, String... lore) + private void addButton(ClanInfo clanInfo, int slot, int energyAmount, Material material, byte data, boolean free, String... lore) { boolean locked = energyAmount > clanInfo.getEnergyPurchasable() || energyAmount == 0; String itemName = "Purchase " + energyAmount + " Energy"; @@ -73,7 +80,7 @@ public class EnergyPage extends ShopPageBase if (locked) setItem(slot, shopItem); else - addButton(slot, shopItem, new EnergyShopButton(getPlugin(), this, energyAmount, clanInfo)); + addButton(slot, shopItem, new EnergyShopButton(getPlugin(), this, energyAmount, clanInfo, free ? 0 : getPlugin().convertEnergyToGold(energyAmount))); } private void buildNoClan() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java index ad8a77725..cd548e9fe 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyShopButton.java @@ -24,13 +24,15 @@ public class EnergyShopButton implements IButton private EnergyPage _page; private int _energyToPurchase; private ClanInfo _clanInfo; + private int _cost; - public EnergyShopButton(ClanEnergyManager energyManager, EnergyPage page, int energyToPurchase, ClanInfo clanInfo) + public EnergyShopButton(ClanEnergyManager energyManager, EnergyPage page, int energyToPurchase, ClanInfo clanInfo, int cost) { _energyManager = energyManager; _clanInfo = clanInfo; _energyToPurchase = energyToPurchase; _page = page; + _cost = cost; } @Override @@ -56,7 +58,7 @@ public class EnergyShopButton implements IButton // Notify _energyManager.getClansManager().messageClan(_clanInfo, F.main("Energy", F.name(player.getName()) + " purchased " + F.elem(_energyToPurchase + " Energy") + " for the clan")); } - }, _page, new EnergyPackage(_energyToPurchase + " Energy", _energyManager.convertEnergyToGold(_energyToPurchase)), CurrencyType.Gold, player)); + }, _page, new EnergyPackage(_energyToPurchase + " Energy", _cost), CurrencyType.Gold, player)); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/DeployedTask.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/DeployedTask.java new file mode 100644 index 000000000..02d6a46c9 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/DeployedTask.java @@ -0,0 +1,46 @@ +package mineplex.game.clans.tutorials; + +import org.bukkit.entity.Player; +import org.bukkit.event.Listener; + +public class DeployedTask implements Listener +{ + protected Player _player; + protected boolean _finished; + + protected TutorialTask _task; + + protected boolean _dead; + + public DeployedTask(Player player, TutorialTask task) + { + _player = player; + + _task = task; + } + + public void postDeploy() + { + } + + public boolean checkForDeath() + { + return _dead || _player == null; + } + + public void finish() + { + onFinish(); + _task.finishFor(_player); + } + + public void kill() + { + _dead = true; + _player = null; + } + + public void onFinish() { + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java index a35a85e12..131401037 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java @@ -1,7 +1,8 @@ package mineplex.game.clans.tutorials; import java.util.ArrayList; -import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -14,6 +15,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerPickupItemEvent; @@ -27,7 +29,6 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilText; import mineplex.core.donation.DonationManager; import mineplex.core.scoreboard.ScoreboardManager; import mineplex.core.scoreboard.elements.ScoreboardElement; @@ -35,6 +36,7 @@ import mineplex.core.task.TaskManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.event.ClanTipEvent; import mineplex.game.clans.economy.GoldManager; /** @@ -46,9 +48,9 @@ import mineplex.game.clans.economy.GoldManager; */ public abstract class Tutorial implements ScoreboardElement, Listener { - public static String TASK_COMPLETE_TASK = "Tutorial%sDoneTask%s"; - public static String TUTORIAL_COMPLETE_TASK = "Tutorial%sFinito"; - public static String SKIPPED_TASK = "Tutorial%sSkipito"; + public static String TASK_COMPLETE_TASK = "tttatatta%sTask%s"; + public static String TUTORIAL_COMPLETE_TASK = "tatatatatat%sDone"; //do not change + public static String SKIPPED_TASK = "tatatatata%sSkip"; protected final TutorialManager _manager; protected final GoldManager _goldManager; @@ -56,17 +58,17 @@ public abstract class Tutorial implements ScoreboardElement, Listener protected final TaskManager _taskManager; protected final DonationManager _donationManager; - private final Map _tasks; - private final Map _nameToTask; - protected final Map _inTutorial; + protected final LinkedHashMap> _tasks; + protected final LinkedHashMap> _nameToTask; + protected final LinkedHashMap _inTutorial; protected boolean _doScoreboard; protected boolean _ghostMode; protected boolean _startOnJoin; - protected String _uniqueId; - protected String _friendlyName; + protected String _technicalName; + protected String _displayName; protected int _goldReward = -1; protected int _gemReward = -1; @@ -79,9 +81,9 @@ public abstract class Tutorial implements ScoreboardElement, Listener _donationManager = donationManager; _taskManager = taskManager; _manager = manager; - _tasks = new HashMap<>(); - _inTutorial = new HashMap<>(); - _nameToTask = new HashMap<>(); + _tasks = new LinkedHashMap<>(); + _inTutorial = new LinkedHashMap<>(); + _nameToTask = new LinkedHashMap<>(); _manager.getPluginManager().registerEvents(this, _manager.getPlugin()); } @@ -91,78 +93,72 @@ public abstract class Tutorial implements ScoreboardElement, Listener { final List lines = new ArrayList<>(); - if (!isInTutorial(player) || !_doScoreboard) + if (!isInTutorial(player)) + { + return lines; + } + + if (!_doScoreboard) + { + return lines; + } + + if (get(player).CurrentTask == null) { return lines; } out.clear(); - final TutorialClient ptutorial = _inTutorial.get(player.getName()); + final TutorialClient client = _inTutorial.get(player.getName()); - lines.add(C.cAqua + _friendlyName + " Tutorial"); + lines.add(C.cAqua + "Tutorial"); - for (final TutorialTask task : _tasks.values()) + for (final TutorialTask task : _tasks.values()) { - if (get(player).getCurrentTask() == task.getID()) + if (get(player).CurrentTask.equals(task)) { - lines.add(C.cDAqua + task.getID() + ". " + task.getFriendlyName()); + lines.add(C.cDAqua + task.getID() + ". " + task.getDisplayName()); } - else if (ptutorial.hasFinishedTask(task)) + else if (client.CurrentTask.getID() > task.getID()) { - lines.add(C.cGreen + task.getID() + ". " + task.getFriendlyName()); + lines.add(C.cGreen + task.getID() + ". " + task.getDisplayName()); } else { - lines.add(C.cRed + task.getID() + ". " + task.getFriendlyName()); + lines.add(C.cRed + task.getID() + ". " + task.getDisplayName()); } } lines.add(C.cYellow + "To skip, type: /skiptutorial"); -// lines.add(C.cYellow + "To get info, type: /taskinfo"); return lines; } - protected void addTask(final int id, final String name, final String description) + protected void addTask(TutorialTask task) { - addTask(id, name, description, null); + _tasks.put(_tasks.size() + 1, task); + _nameToTask.put(task.getTechnicalName(), task); } - protected void addTask(final int id, final String name, final String description, final String finishMessage) + protected boolean hasFinishedTask(Player player, TutorialTask task) { - _tasks.put(id, new TutorialTask(id, name, description, finishMessage)); - _nameToTask.put(name, _tasks.get(id)); + return get(player).CurrentTask.getID() < task.getID(); } - protected boolean hasFinishedTask(Player player, String taskName) + protected void finishTask(final Player player, final TutorialTask task) { - return hasFinishedTask(player, _nameToTask.get(taskName).getID()); - } - - protected boolean hasFinishedTask(Player player, int taskID) - { - return get(player).hasFinishedTask(_tasks.get(taskID)); - } - - protected void finishTask(final Player player, final int taskID) - { - final TutorialTask task = _tasks.get(taskID); - - String taskName = task.getFriendlyName(); - onFinishTask(player, taskName); + get(player).LastDescriptionSentTime = 0; + get(player).CurrentTask.visibleFinish(player); + get(player).CurrentTask = task.equals(_tasks.get(_tasks.size())) ? null : _tasks.get(task.getID() + 1); - _inTutorial.get(player.getName()).setTaskFinished(taskID); - - if (!_taskManager.hasCompletedTask(player, String.format(TASK_COMPLETE_TASK, _uniqueId, task.getUniqueId()))) + if (!_taskManager.hasCompletedTask(player, String.format(TASK_COMPLETE_TASK, _technicalName, task.getTechnicalName()))) { _taskManager.completedTask(new Callback() { public void run(final Boolean completed) { - UtilPlayer.message(player, F.main("Tutorials", "You have completed Task " + F.elem(taskID + ": " + task.getFriendlyName()) + ". " + (_tasks.size() - taskID) + " task" + (UtilText.plural(_tasks.size() - taskID) ? "s" : "") + " to go!")); - - if (taskID == _tasks.size()) + if (task.equals(_tasks.get(_tasks.size()))) { finishFor(player); } @@ -172,30 +168,20 @@ public abstract class Tutorial implements ScoreboardElement, Listener { public void run() { - _tasks.get(taskID + 1).sendDescriptionTo(player); + get(player).CurrentTask.deploy(player); } - }, 40L); + }, 10L); } player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); } - }, player, String.format(TASK_COMPLETE_TASK, _uniqueId, task.getUniqueId())); + }, player, String.format(TASK_COMPLETE_TASK, _technicalName, task.getTechnicalName())); } } - protected void finishTask(final Player player, final String taskName) + public TutorialTask getTask(final String technicalName) { - finishTask(player, _nameToTask.get(taskName).getID()); - } - - public TutorialTask getTask(final int taskID) - { - return _tasks.get(taskID); - } - - public TutorialTask getTask(final String name) - { - return _nameToTask.get(name); + return _nameToTask.get(technicalName); } @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) @@ -239,9 +225,8 @@ public abstract class Tutorial implements ScoreboardElement, Listener _inTutorial.remove(player.getName()); UtilFirework.launchFirework(player.getLocation(), Type.BALL_LARGE, Color.LIME, false, false, new Vector(0, 0, 0), 1); - UtilPlayer.message(player, F.main("Tutorials", "You have completed the " + F.elem(_friendlyName + " Tutorial") + ".")); onFinished(player); - if (!_taskManager.hasCompletedTask(player, String.format(TUTORIAL_COMPLETE_TASK, _uniqueId))) + if (!_taskManager.hasCompletedTask(player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName))) { _taskManager.completedTask(new Callback() { @@ -294,7 +279,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener }, i * 10); } } - }, player, String.format(TUTORIAL_COMPLETE_TASK, _uniqueId)); + }, player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName)); } } @@ -303,11 +288,6 @@ public abstract class Tutorial implements ScoreboardElement, Listener { } - // Implementation left to sub classes. - protected void onFinishTask(final Player player, String task) - { - } - // Implementation left to sub classes. protected void onBegin(final Player player) { @@ -320,7 +300,10 @@ public abstract class Tutorial implements ScoreboardElement, Listener _manager._playerTutorials.put(player.getName(), this); } - _inTutorial.put(player.getName(), TutorialClient.create(player, _taskManager, this)); + _inTutorial.put(player.getName(), new TutorialClient(player, this)); + + get(player).CurrentTask.deploy(player); + player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); if (_ghostMode) @@ -335,8 +318,6 @@ public abstract class Tutorial implements ScoreboardElement, Listener onBegin(player); } - //_playerTutorials.remove(player.getName()); - public void cancelFor(final Player player) { _inTutorial.remove(player.getName()); @@ -345,7 +326,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener { for (Player other : UtilServer.getPlayers()) { - other.showPlayer(player); + if (!isInTutorial(other)) other.showPlayer(player); player.showPlayer(other); } } @@ -361,19 +342,19 @@ public abstract class Tutorial implements ScoreboardElement, Listener return _inTutorial.containsKey(player); } - public Map getTasks() + public Map> getTasks() { return _tasks; } public boolean hasCompleted(final Player player) { - return _taskManager.hasCompletedTask(player, String.format(TUTORIAL_COMPLETE_TASK, _uniqueId)); + return _taskManager.hasCompletedTask(player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName)); } public boolean hasSkipped(final Player player) { - return _taskManager.hasCompletedTask(player, String.format(SKIPPED_TASK, _uniqueId)); + return _taskManager.hasCompletedTask(player, String.format(SKIPPED_TASK, _technicalName)); } public void skip(final Player player) @@ -396,12 +377,15 @@ public abstract class Tutorial implements ScoreboardElement, Listener new JsonMessage( F.main( "Tutorial", - "Click here to confirm you want to skip the tutorial!" + "Click " )) - .click(ClickEvent.RUN_COMMAND, "/yesiconfirmiwanttoskip") + .extra("here") + .color("aqua") + .click(ClickEvent.RUN_COMMAND, "/yesiconfirmiwanttoskip") + .extra(" here to confirm you want to skip the tutorial!") + .color("gray") .sendToPlayer(player); - } public void doSkip(final Player player) @@ -412,12 +396,12 @@ public abstract class Tutorial implements ScoreboardElement, Listener { cancelFor(player); } - }, player, String.format(SKIPPED_TASK, _uniqueId)); + }, player, String.format(SKIPPED_TASK, _technicalName)); } - public String getUniqueId() + public String getTechnicalName() { - return _uniqueId; + return _technicalName; } public TutorialClient get(final Player player) @@ -425,10 +409,19 @@ public abstract class Tutorial implements ScoreboardElement, Listener return _inTutorial.get(player.getName()); } + @EventHandler + public void onClanTip(ClanTipEvent event) + { + if (isInTutorial(event.getPlayer())) + { + event.setCancelled(true); + } + } + @EventHandler public void taskInfo(final UpdateEvent evt) { - if (evt.getType() != UpdateType.SEC_30) + if (evt.getType() != UpdateType.SEC) { return; } @@ -437,10 +430,31 @@ public abstract class Tutorial implements ScoreboardElement, Listener { if (isInTutorial(player)) { - getTask(get(player).getCurrentTask()).sendDescriptionTo(player); + get(player).CurrentTask.trySendDescription(player); } } } + + @EventHandler + public void chat(final AsyncPlayerChatEvent evt) + { + if (!isInTutorial(evt.getPlayer())) + { + return; + } + + Iterator iterator = evt.getRecipients().iterator(); + + while (iterator.hasNext()) + { + if (isInTutorial(iterator.next())) + { + iterator.remove(); + } + } + + evt.setCancelled(true); + } @EventHandler public void onPlayerJoin(final PlayerJoinEvent evt) @@ -459,5 +473,11 @@ public abstract class Tutorial implements ScoreboardElement, Listener }, 40L); } } + + public void cleanup(Player player) + { + if (get(player).CurrentTask != null) get(player).CurrentTask.cleanup(player); + _inTutorial.remove(player.getName()); + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialClient.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialClient.java index 8a585c53f..c6071420e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialClient.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialClient.java @@ -2,70 +2,31 @@ package mineplex.game.clans.tutorials; import org.bukkit.entity.Player; -import mineplex.core.common.util.UtilServer; import mineplex.core.task.TaskManager; public class TutorialClient { - private final Tutorial _tutorial; - private final Player _player; + public Player Player; + public TutorialTask CurrentTask; + public long LastDescriptionSentTime = System.currentTimeMillis() - 3000; - private int _currentTask = 1; - - public TutorialClient(final Player player, final Tutorial tutorial) + public TutorialClient(Player player, Tutorial tutorial) { - _player = player; - _tutorial = tutorial; - } - - public static TutorialClient create(final Player player, final TaskManager taskManager, final Tutorial tutorial) - { - final TutorialClient user = new TutorialClient(player, tutorial); + Player = player; - for (final int i : tutorial.getTasks().keySet()) + CurrentTask = tutorial._tasks.get(1); + + for (TutorialTask task : tutorial._tasks.values()) { - if (taskManager.hasCompletedTask(player, String.format(Tutorial.TASK_COMPLETE_TASK, tutorial.getUniqueId(), tutorial.getTask(i).getUniqueId()))) + if (TaskManager.Instance.hasCompletedTask(player, String.format( + Tutorial.TASK_COMPLETE_TASK, + task.getTutorial().getTechnicalName(), task.getTechnicalName()))) { - user._currentTask = i; + if (CurrentTask.getID() <= task.getID()) + { + CurrentTask = task.getTutorial().getTasks().get(Math.min(task.getTutorial().getTasks().size(), task.getID() + 1)); + } } } - - UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(tutorial._manager.getPlugin(), new Runnable() - { - public void run() - { - tutorial.getTask(user._currentTask).sendDescriptionTo(player); - } - }, 40); - - return user; } - - public int getCurrentTask() - { - return _currentTask; - } - - public Tutorial getTutorial() - { - return _tutorial; - } - - public Player getPlayer() - { - return _player; - } - - public void setTaskFinished(final int taskID) - { - _currentTask = taskID + 1; - - _tutorial.getTask(taskID).onFinish(_player); - } - - public boolean hasFinishedTask(final TutorialTask task) - { - return task != null && task.getID() < _currentTask; - } - } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java index 04c3c35f4..ad4dc21eb 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java @@ -1,13 +1,11 @@ package mineplex.game.clans.tutorials; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; @@ -16,14 +14,12 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.donation.DonationManager; import mineplex.core.preferences.PreferencesManager; import mineplex.core.task.TaskManager; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.commands.RestartTutCommand; import mineplex.game.clans.economy.GoldManager; import mineplex.game.clans.tutorials.commands.DoSkipTutorialCommand; import mineplex.game.clans.tutorials.commands.SkipTutorialCommand; -import mineplex.game.clans.tutorials.commands.TaskInfoCommand; -import mineplex.game.clans.tutorials.types.TutorialGettingStarted; +import mineplex.game.clans.tutorials.gettingstarted.TutorialGettingStarted; public class TutorialManager extends MiniPlugin { @@ -49,7 +45,7 @@ public class TutorialManager extends MiniPlugin { addCommand(new SkipTutorialCommand(this)); addCommand(new DoSkipTutorialCommand(this)); - addCommand(new TaskInfoCommand(this)); + addCommand(new RestartTutCommand(this)); } public boolean startTutorial(final Class tutorial, final Player player) @@ -81,9 +77,9 @@ public class TutorialManager extends MiniPlugin { getTutorial(player).cancelFor(player); - _playerTutorials.remove(player.getName()); - UtilPlayer.message(player, F.main("Tutorials", "You have cancelled the " + F.elem(getTutorial(player)._friendlyName + " Tutorial") + ".")); + UtilPlayer.message(player, F.main("Tutorials", "You have cancelled the " + F.elem(getTutorial(player)._displayName + " Tutorial") + ".")); + _playerTutorials.remove(player.getName()); } } @@ -99,32 +95,17 @@ public class TutorialManager extends MiniPlugin { if (isInTutorial(player)) { - UtilPlayer.message(player, F.main("Tutorials", "You have skipped the " + F.elem(getTutorial(player)._friendlyName + " Tutorial") + ".")); + UtilPlayer.message(player, F.main("Tutorials", "You have skipped the " + F.elem(getTutorial(player)._displayName + " Tutorial") + ".")); getTutorial(player).doSkip(player); } } @EventHandler - public void cleanup(UpdateEvent event) + public void quit(PlayerQuitEvent event) { - if (!event.getType().equals(UpdateType.SLOW)) - { - return; - } + if (!isInTutorial(event.getPlayer())) return; - List del = new ArrayList<>(); - for (String name : _playerTutorials.keySet()) - { - if (Bukkit.getPlayer(name) == null) - { - del.add(name); - } - } - - for (String name : del) - { - _playerTutorials.remove(name); - } + getTutorial(event.getPlayer()).cleanup(event.getPlayer()); } public Tutorial getTutorial(final Player player) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialTask.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialTask.java index fd916051a..8c609b160 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialTask.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialTask.java @@ -1,39 +1,121 @@ package mineplex.game.clans.tutorials; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.UtilServer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; -public class TutorialTask +public class TutorialTask implements Listener { - private final String _name; - private final String _description; - private final String _finishMessage; - private final int _id; + private T _tutorial; - public TutorialTask(final int id, final String name, final String description, String finishMessage) + protected long _autoCompleteTime = -1; + + protected String _displayName; + protected String _technicalName; + + protected String _description; + protected String _finishMessage; + + protected long _descriptionWaitTime = 30000; + + private List _playersFinished = new ArrayList<>(); + + private Map _deployedInstances = new HashMap<>(); + private List _toCull = new ArrayList<>(); + + private int _id; + + public TutorialTask(T tutorial, int id) { + _tutorial = tutorial; _id = id; - _name = name; - _description = description; - _finishMessage = finishMessage; + + UtilServer.getServer().getPluginManager().registerEvents(this, _tutorial._manager.getPlugin()); } - public int getID() + protected DeployedTask deploy(final Player player) { - return _id; + DeployedTask task = customDeploy(player); + + _deployedInstances.put(player.getName(), task); + + UtilServer.getServer().getPluginManager().registerEvents(task, _tutorial._manager.getPlugin()); + + trySendDescription(player); + + if (_autoCompleteTime != -1) + { + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(_tutorial._manager.getPlugin(), new Runnable(){ + public void run() + { + if (_deployedInstances.containsKey(player.getName())) + { + finishFor(player); + } + } + }, _autoCompleteTime); + } + + task.postDeploy(); + + return task; } - public String getFinishMessage() + public void trySendDescription(Player player) { - return _finishMessage; + if (!_tutorial.isInTutorial(player)) + { + return; + } + + TutorialClient client = _tutorial.get(player); + + if (System.currentTimeMillis() - client.LastDescriptionSentTime > client.CurrentTask.getDescriptionWaitTime()) + { + UtilPlayer.message(player, " "); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, C.cYellowB + "Part " + _id + ": " + _displayName); + UtilPlayer.message(player, C.cWhite + _description.replace("{", C.cAqua).replace("}", C.cWhite)); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); + client.LastDescriptionSentTime = System.currentTimeMillis(); + } } - public String getFriendlyName() + protected DeployedTask customDeploy(final Player player) { - return _name; + return new DeployedTask(player, this); + } + + public final void startFor(Player player) + { + deploy(player); + } + + public final boolean hasFinished(final Player player) + { + return _playersFinished.contains(player.getName()); + } + + public String getDisplayName() + { + return _displayName; } public String getDescription() @@ -41,26 +123,79 @@ public class TutorialTask return _description; } - public String getUniqueId() + public String getFinishMessage() { - return _name.replace(" ", ""); + return _finishMessage; } - public void sendDescriptionTo(final Player player) + public String getTechnicalName() { - UtilPlayer.message(player, C.cGreen + "==== Pt." + _id + ": " + _name + " ===="); - UtilPlayer.message(player, C.cYellow + _description.replace("{", C.cAqua).replace("}", C.cYellow)); - UtilPlayer.message(player, C.cGreen + UtilText.repeat("=", _name.length() + ("=== Pt." + _id + ": ===").length())); + return _technicalName; } - public void onFinish(final Player player) + public int getID() { + return _id; + } + + public void finishFor(Player player) + { + _tutorial.finishTask(player, this); + } + + public void visibleFinish(Player player) + { + _deployedInstances.get(player.getName()).kill(); + _toCull.add(_deployedInstances.get(player.getName())); + _deployedInstances.remove(player.getName()); + if (_finishMessage != null) { - UtilPlayer.message(player, C.cGreen + "=================="); - UtilPlayer.message(player, C.cYellow + _finishMessage.replace("{", C.cAqua).replace("}", C.cYellow)); - UtilPlayer.message(player, C.cGreen + "=================="); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, C.cWhite + _finishMessage.replace("{", C.cAqua).replace("}", C.cWhite)); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); } } + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + Iterator iterator = _toCull.iterator(); + + while(iterator.hasNext()) + { + DeployedTask task = iterator.next(); + + task.kill(); + HandlerList.unregisterAll(task); + iterator.remove(); + } + } + + public void cleanup(Player player) + { + _deployedInstances.get(player.getName()).kill(); + _toCull.add(_deployedInstances.get(player.getName())); + _playersFinished.remove(player.getName()); + } + + public long getDescriptionWaitTime() + { + return _descriptionWaitTime; + } + + public T getTutorial() + { + return _tutorial; + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/commands/TaskInfoCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/commands/TaskInfoCommand.java deleted file mode 100644 index 5e98b32c0..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/commands/TaskInfoCommand.java +++ /dev/null @@ -1,31 +0,0 @@ -package mineplex.game.clans.tutorials.commands; - -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.game.clans.tutorials.TutorialManager; - -public class TaskInfoCommand extends CommandBase -{ - public TaskInfoCommand(final TutorialManager plugin) - { - super(plugin, Rank.ALL, "taskinfo", "ti"); - } - - @Override - public void Execute(final Player caller, final String[] args) - { - if (Plugin.isInTutorial(caller)) - { - Plugin.getTutorial(caller).getTask(Plugin.getTutorial(caller).get(caller).getCurrentTask()).sendDescriptionTo(caller); - } - else - { - UtilPlayer.message(caller, F.main("Tutorials", "You are not currently in a tutorial.")); - } - } - -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskClaim.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskClaim.java new file mode 100644 index 000000000..9102fe525 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskClaim.java @@ -0,0 +1,62 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; +import mineplex.game.clans.tutorials.DeployedTask; +import mineplex.game.clans.tutorials.TutorialTask; + +public class TaskClaim extends TutorialTask +{ + public TaskClaim(TutorialGettingStarted tutorial, int id) + { + super(tutorial, id); + + _displayName = "Claim some Territory"; + _technicalName = "ClaimTerr"; + + _description = "Clans can claim 16x16 areas of Territory! " + + "Once claimed, only your Clan can break/place blocks here. " + + "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. " + + "Claim some Territory now, by typing {/c claim}!"; + } + + @Override + public DeployedTask customDeploy(Player player) + { + return new Deployed(player, this); + } + + class Deployed extends DeployedTask + { + public Deployed(Player player, TutorialTask task) + { + super(player, task); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onClansCommand(ClansCommandExecutedEvent event) + { + if (!_player.equals(event.getPlayer())) + { + return; + } + + if (!ClansManager.getInstance().isInClan(event.getPlayer())) + { + return; + } + + if (event.getCommand().equals("claim")) + { + _task.finishFor(_player); + event.setCancelled(true); + } + } + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCreateClan.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCreateClan.java new file mode 100644 index 000000000..c8b3292ad --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCreateClan.java @@ -0,0 +1,48 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.game.clans.clans.event.ClanCreatedEvent; +import mineplex.game.clans.tutorials.DeployedTask; +import mineplex.game.clans.tutorials.TutorialTask; + +public class TaskCreateClan extends TutorialTask +{ + public TaskCreateClan(TutorialGettingStarted tutorial, int id) + { + super(tutorial, id); + + _displayName = "Create a Clan"; + _technicalName = "ClanCreation"; + + _description = "Before beginning, use the {/c create } command to start up your own Clan! "; + } + + @Override + public DeployedTask customDeploy(Player player) + { + return new Deployed(player, this); + } + + class Deployed extends DeployedTask + { + public Deployed(Player player, TutorialTask task) + { + super(player, task); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onClanCreated(ClanCreatedEvent event) + { + if (!_player.equals(event.getFounder())) + { + return; + } + + _task.finishFor(_player); + } + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCustomizeClass.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCustomizeClass.java new file mode 100644 index 000000000..84ca86e7c --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCustomizeClass.java @@ -0,0 +1,69 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.spawn.Spawn; +import mineplex.game.clans.tutorials.DeployedTask; +import mineplex.game.clans.tutorials.TutorialTask; +import mineplex.minecraft.game.classcombat.Class.ClientClass; + +public class TaskCustomizeClass extends TutorialTask +{ + public TaskCustomizeClass(TutorialGettingStarted tutorial, int id) + { + super(tutorial, id); + + _displayName = "Customize Class"; + _technicalName = "CustomizeKlass"; + + _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."; + } + + @Override + public DeployedTask customDeploy(Player player) + { + return new Deployed(player, this); + } + + class Deployed extends DeployedTask + { + public Deployed(Player player, TutorialTask task) + { + super(player, task); + } + + @Override + public void postDeploy() + { + _player.teleport(new Location(Spawn.getSpawnWorld(), 6, 66, -300, -180f, 0f)); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onUpdate(final UpdateEvent event) + { + if (!event.getType().equals(UpdateType.SEC)) + { + return; + } + + if (checkForDeath()) + { + return; + } + + final ClientClass clientclass = ClansManager.getInstance().getClassManager().Get(_player); + + if (clientclass != null && clientclass.GetSavingCustomBuild() != null) + { + _task.finishFor(_player); + } + } + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskDisbandClan.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskDisbandClan.java new file mode 100644 index 000000000..845a2e2e6 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskDisbandClan.java @@ -0,0 +1,48 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.game.clans.clans.event.ClanDisbandedEvent; +import mineplex.game.clans.tutorials.DeployedTask; +import mineplex.game.clans.tutorials.TutorialTask; + +public class TaskDisbandClan extends TutorialTask +{ + public TaskDisbandClan(TutorialGettingStarted tutorial, int id) + { + super(tutorial, id); + + _displayName = "Disband your Clan"; + _technicalName = "DisbandClan"; + + _description = "Finally, let's disband your Clan to end the Tutorial. " + + "Simply type {/c disband} to do this. " + + "This will delete your Clan, and you'll be able to create or join a new one!"; + } + + @Override + public DeployedTask customDeploy(Player player) + { + return new Deployed(player, this); + } + + class Deployed extends DeployedTask + { + public Deployed(Player player, TutorialTask task) + { + super(player, task); + } + + @EventHandler + public void sell(ClanDisbandedEvent event) + { + if (!_player.equals(event.getDisbander())) + { + return; + } + + _task.finishFor(_player); + } + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskEquipClass.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskEquipClass.java new file mode 100644 index 000000000..4ea5a6e66 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskEquipClass.java @@ -0,0 +1,116 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.UtilItem; +import mineplex.core.task.TaskManager; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent; +import mineplex.game.clans.clans.event.ClansShopAddButtonEvent; +import mineplex.game.clans.spawn.Spawn; +import mineplex.game.clans.tutorials.DeployedTask; +import mineplex.game.clans.tutorials.TutorialTask; +import mineplex.minecraft.game.classcombat.Class.event.ClassEquipEvent; + +public class TaskEquipClass extends TutorialTask +{ + public TaskEquipClass(TutorialGettingStarted tutorial, int id) + { + super(tutorial, id); + + _displayName = "Equip a Class"; + _technicalName = "AuszustattenKlasse"; + + _description = "Use the PvP Gear shop, and Right-Click the Villager. " + + "Purchase Iron Armor from the PvP Shop. " + + "Then put on your Armor to equip a Champions Class."; + } + + @Override + public DeployedTask customDeploy(Player player) + { + return new Deployed(player, this); + } + + class Deployed extends DeployedTask + { + private List _bought = new ArrayList<>(); + + public Deployed(Player player, TutorialTask task) + { + super(player, task); + } + + @Override + public void postDeploy() + { + _player.teleport(new Location(Spawn.getSpawnWorld(), 19, 66, -305.844, -100f, 0f)); + } + + @EventHandler + public void onClassEquipped(ClassEquipEvent event) + { + if (!ClansManager.getInstance().getClassManager().Get(_player).equals(event.getPlayer())) + { + return; + } + + _task.finishFor(_player); + } + + @EventHandler + public void button(ClansShopAddButtonEvent event) + { + if (!_player.equals(event.getPlayer())) + { + return; + } + + if (!(UtilItem.isArmor(event.getMaterial()) && UtilItem.isIronProduct(event.getMaterial()))) + { + return; + } + + if (!TaskManager.Instance.hasCompletedTask(event.getPlayer(), "tuttoooooe" + event.getMaterial().name()) && !_bought.contains(event.getMaterial())) + { + event.setBuyPrice(0); + event.setSellPrice(0); + } + } + + @EventHandler + public void buy(final ClansPlayerBuyItemEvent event) + { + if (!_player.equals(event.getPlayer())) + { + return; + } + + if (!(UtilItem.isArmor(event.getItem().getType()) && UtilItem.isIronProduct(event.getItem().getType()))) + { + return; + } + + if (event.getCost() == 0 && _bought.contains(event.getItem().getType())) + { + event.setCancelled(true); + return; + } + + TaskManager.Instance.completedTask(new Callback() { + @Override + public void run(Boolean data) + { + } + }, event.getPlayer(), "tuttoooooe" + event.getItem().getType().name()); + _bought.add(event.getItem().getType()); + } + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskExploreShops.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskExploreShops.java new file mode 100644 index 000000000..cc332b10c --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskExploreShops.java @@ -0,0 +1,87 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.event.EnergyPageBuildEvent; +import mineplex.game.clans.spawn.Spawn; +import mineplex.game.clans.tutorials.DeployedTask; +import mineplex.game.clans.tutorials.TutorialTask; + +public class TaskExploreShops extends TutorialTask +{ + public TaskExploreShops(TutorialGettingStarted tutorial, int id) + { + super(tutorial, id); + + _displayName = "Welcome to the Shops"; + _technicalName = "WillkommenZumGeschaft"; + + _description = "Welcome to the Shops! Here you can buy all kinds of things that you may require during your adventure. " + + "You can also sell certain items to the Villagers to make a bit of extra Gold. " + + "Go to the Energy Shop and buy {Max Energy}. (FREE)"; + } + + @Override + public DeployedTask customDeploy(Player player) + { + return new Deployed(player, this); + } + + class Deployed extends DeployedTask + { + public Deployed(Player player, TutorialTask task) + { + super(player, task); + } + + @Override + public void postDeploy() + { + _player.teleport(new Location(Spawn.getSpawnWorld(), 17, 66.5, -330, -180f, 0f)); + + ClansManager.getInstance().getClan(_player).adjustEnergy(-(ClansManager.getInstance().getClan(_player).getEnergyCostPerMinute() * 60)); + } + + @EventHandler + public void onItemPut(EnergyPageBuildEvent event) + { + if (!_player.equals(event.getPlayer())) + { + return; + } + + if (!ClansManager.getInstance().isInClan(_player)) + { + return; + } + + if (ClansManager.getInstance().getClan(_player).getEnergyPurchasable() == 0) + { + _task.finishFor(_player); + return; + } + + event.setFree(true); + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TWOSEC) + { + return; + } + + if (ClansManager.getInstance().getClan(_player).getEnergy() == ClansManager.getInstance().getClan(_player).getEnergyMax()) + { + _task.finishFor(_player); + } + } + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskGoToWilderness.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskGoToWilderness.java new file mode 100644 index 000000000..6f3a5a92e --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskGoToWilderness.java @@ -0,0 +1,55 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent; +import mineplex.game.clans.tutorials.DeployedTask; +import mineplex.game.clans.tutorials.TutorialTask; + +public class TaskGoToWilderness extends TutorialTask +{ + public TaskGoToWilderness(TutorialGettingStarted tutorial, int id) + { + super(tutorial, id); + + _displayName = "Go To The Wilderness"; + _technicalName = "GoToWildy"; + + _description = "Use your Map (Slot 9) to help find your way to the Wilderness. " + + "The Wilderness is anywhere that is not colored on the Map. " + + "If you don't have a map, you can get one at any time by typing {/map}. " + + "You can zoom in/out by Left and Right Clicking!"; + } + + @Override + public DeployedTask customDeploy(Player player) + { + return new Deployed(player, this); + } + + class Deployed extends DeployedTask + { + public Deployed(Player player, TutorialTask task) + { + super(player, task); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onTerritory(final PlayerEnterTerritoryEvent event) + { + if (!_player.equals(event.getPlayer())) + { + return; + } + + if (event.getNewTerritory().contains("Wilderness")) + { + _task.finishFor(_player); + } + } + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskLeaveSpawn.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskLeaveSpawn.java new file mode 100644 index 000000000..145d9eef2 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskLeaveSpawn.java @@ -0,0 +1,69 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent; +import mineplex.game.clans.tutorials.DeployedTask; +import mineplex.game.clans.tutorials.TutorialTask; + +public class TaskLeaveSpawn extends TutorialTask +{ + public TaskLeaveSpawn(TutorialGettingStarted tutorial, int id) + { + super(tutorial, id); + + _displayName = "Leave Spawn Islands"; + _technicalName = "LeaveSpawn"; + + _description = "Now you can leave the Spawn Island. " + + "Don't worry, you won't get hurt from the fall! " + + "Once you end the tutorial, PvP will be enabled down there, so be careful!"; + } + + @Override + public DeployedTask customDeploy(Player player) + { + return new Deployed(player, this); + } + + class Deployed extends DeployedTask + { + public Deployed(Player player, TutorialTask task) + { + super(player, task); + } + + @Override + public void postDeploy() + { + if (_player.getLocation().getY() < 100) + { + _task.finishFor(_player); + } + } + + @EventHandler + public void update(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + if (checkForDeath()) + { + return; + } + + if (_player.getLocation().getY() < 100){ + _task.finishFor(_player); + } + } + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskMakingMoney.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskMakingMoney.java new file mode 100644 index 000000000..7c05ec2da --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskMakingMoney.java @@ -0,0 +1,71 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.inventory.ItemStack; + +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.event.ClansPlayerSellItemEvent; +import mineplex.game.clans.spawn.Spawn; +import mineplex.game.clans.tutorials.DeployedTask; +import mineplex.game.clans.tutorials.TutorialTask; + +public class TaskMakingMoney extends TutorialTask +{ + public TaskMakingMoney(TutorialGettingStarted tutorial, int id) + { + super(tutorial, id); + + _displayName = "Making Money (Farming)"; + _technicalName = "ImAFarmer"; + + _description = "We have given you a carrot to sell in the Organic Produce Shop. " + + "Click on the Villager, and {Right-Click} the carrot to sell your carrots in exchange for Gold."; + } + + @Override + public DeployedTask customDeploy(Player player) + { + return new Deployed(player, this); + } + + class Deployed extends DeployedTask + { + private int _carrotsSold; + + public Deployed(Player player, TutorialTask task) + { + super(player, task); + player.getInventory().addItem(new ItemStack(Material.CARROT_ITEM, 1)); + } + + @Override + public void postDeploy() + { + _player.teleport(new Location(Spawn.getSpawnWorld(), 25.536, 66, -316.844, -100f, 0f)); + } + + @EventHandler + public void button(ClansPlayerSellItemEvent event) + { + if (!_player.equals(event.getPlayer())) + { + return; + } + + if (!ClansManager.getInstance().isInClan(_player)) + { + return; + } + + if (!event.getItem().getType().equals(Material.CARROT_ITEM)) + { + return; + } + + _task.finishFor(_player); + } + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskSetHome.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskSetHome.java new file mode 100644 index 000000000..8ee0e1e48 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskSetHome.java @@ -0,0 +1,60 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; +import mineplex.game.clans.tutorials.DeployedTask; +import mineplex.game.clans.tutorials.TutorialTask; + +public class TaskSetHome extends TutorialTask +{ + public TaskSetHome(TutorialGettingStarted tutorial, int id) + { + super(tutorial, id); + + _displayName = "Set Clan Home"; + _technicalName = "SetClanHome"; + + _description = "You are now ready to set a Clan Home. " + + "To do this, use the {/c sethome} command."; + } + + @Override + public DeployedTask customDeploy(Player player) + { + return new Deployed(player, this); + } + + class Deployed extends DeployedTask + { + public Deployed(Player player, TutorialTask task) + { + super(player, task); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onSetHome(ClansCommandExecutedEvent event) + { + if (!_player.equals(event.getPlayer())) + { + return; + } + + if (!ClansManager.getInstance().isInClan(event.getPlayer())) + { + return; + } + + if (!event.getCommand().equals("homeset")) + { + return; + } + + _task.finishFor(_player); + } + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskUseAbility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskUseAbility.java new file mode 100644 index 000000000..53733071d --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskUseAbility.java @@ -0,0 +1,108 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.Callback; +import mineplex.core.task.TaskManager; +import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent; +import mineplex.game.clans.clans.event.ClansShopAddButtonEvent; +import mineplex.game.clans.tutorials.DeployedTask; +import mineplex.game.clans.tutorials.TutorialTask; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; + +public class TaskUseAbility extends TutorialTask +{ + public TaskUseAbility(TutorialGettingStarted tutorial, int id) + { + super(tutorial, id); + + _displayName = "Use a Class Ability"; + _technicalName = "KlassAbilityUsage"; + + _description = "Now that you have Equipped a Class, you can start using Abilities. " + + "Purchase an Iron Axe from the PvP Shop. " + + "Right-Click with your Iron Axe to use your Axe Ability!"; + } + + @Override + public DeployedTask customDeploy(Player player) + { + return new Deployed(player, this); + } + + class Deployed extends DeployedTask + { + private List _bought = new ArrayList<>(); + + public Deployed(Player player, TutorialTask task) + { + super(player, task); + } + + @EventHandler + public void onAbilityUesd(SkillTriggerEvent event) + { + if (!_player.equals(event.GetPlayer())) + { + return; + } + + _task.finishFor(_player); + } + + @EventHandler + public void button(ClansShopAddButtonEvent event) + { + if (!_player.equals(event.getPlayer())) + { + return; + } + + System.out.println(event.getDisplayName()); + + if (!event.getMaterial().equals(Material.IRON_AXE)) + { + return; + } + + if (!TaskManager.Instance.hasCompletedTask(event.getPlayer(), "tuttoooooe" + event.getMaterial().name()) && !_bought.contains(event.getMaterial())) + { + event.setBuyPrice(0); + event.setSellPrice(0); + } + } + + @EventHandler + public void buy(final ClansPlayerBuyItemEvent event) + { + if (!_player.equals(event.getPlayer())) + { + return; + } + + if (!event.getItem().getType().equals(Material.IRON_AXE)) + { + return; + } + + if (event.getCost() == 0 && _bought.contains(event.getItem().getType())) + { + event.setCancelled(true); + return; + } + + TaskManager.Instance.completedTask(new Callback() { + @Override + public void run(Boolean data) + { + } + }, event.getPlayer(), "tuttoooooe" + event.getItem().getType().name()); + _bought.add(event.getItem().getType()); + } + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskViewClanDetails.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskViewClanDetails.java new file mode 100644 index 000000000..41d223047 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskViewClanDetails.java @@ -0,0 +1,53 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; +import mineplex.game.clans.tutorials.DeployedTask; +import mineplex.game.clans.tutorials.TutorialTask; + +public class TaskViewClanDetails extends TutorialTask +{ + public TaskViewClanDetails(TutorialGettingStarted tutorial, int id) + { + super(tutorial, id); + + _displayName = "Viewing Clan Details"; + _technicalName = "CommandClanX"; + + _description = "Now you can view information about your Clan. " + + "To do this type {/c [Clan Name]}! " + + "You can also use any Clans name to get some information about them as well."; + } + + @Override + public DeployedTask customDeploy(Player player) + { + return new Deployed(player, this); + } + + class Deployed extends DeployedTask + { + public Deployed(Player player, TutorialTask task) + { + super(player, task); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onClansCommand(ClansCommandExecutedEvent event) + { + if (!_player.equals(event.getPlayer())) + { + return; + } + + if (event.getCommand().equals("info")) + { + _task.finishFor(_player); + } + } + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskWelcome.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskWelcome.java new file mode 100644 index 000000000..9b058b619 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskWelcome.java @@ -0,0 +1,21 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import mineplex.game.clans.tutorials.TutorialTask; + +public class TaskWelcome extends TutorialTask +{ + public TaskWelcome(TutorialGettingStarted tutorial, int id) + { + super(tutorial, id); + + _autoCompleteTime = 20 * 10; + + _displayName = "Welcome"; + _technicalName = "Welcome"; + + _description = "Welcome to Clans! " + + "In this game mode, you are able to create a Clan, invite your friends to the Clan, build a base, claim it to protect, and fight others with your new powerful Clan!" + + "You can also join a friend's Clan if they invite you to it!" + + "When you finish the tutorial, you will be awarded {30,000 Gold}"; + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java new file mode 100644 index 000000000..c05b976ef --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TutorialGettingStarted.java @@ -0,0 +1,107 @@ +package mineplex.game.clans.tutorials.gettingstarted; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.donation.DonationManager; +import mineplex.core.task.TaskManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.economy.GoldManager; +import mineplex.game.clans.spawn.Spawn; +import mineplex.game.clans.tutorials.Tutorial; +import mineplex.game.clans.tutorials.TutorialManager; + +public class TutorialGettingStarted extends Tutorial +{ + public TutorialGettingStarted(final TutorialManager manager, final ClansManager clansManager, final DonationManager donationManager, final GoldManager goldManager, final TaskManager taskManager) + { + super(goldManager, taskManager, clansManager, donationManager, manager); + +// addTask(new TaskWelcome(this, 1)); + + int id = 0; + addTask(new TaskCreateClan(this, ++id)); + addTask(new TaskViewClanDetails(this, ++id)); + addTask(new TaskLeaveSpawn(this, ++id)); + addTask(new TaskGoToWilderness(this, ++id)); + addTask(new TaskClaim(this, ++id)); + addTask(new TaskSetHome(this, ++id)); + addTask(new TaskExploreShops(this, ++id)); + addTask(new TaskEquipClass(this, ++id)); + addTask(new TaskUseAbility(this, ++id)); + addTask(new TaskCustomizeClass(this, ++id)); + addTask(new TaskMakingMoney(this, ++id)); + addTask(new TaskDisbandClan(this, ++id)); + + + + _doScoreboard = true; + _ghostMode = true; + _startOnJoin = true; + _goldReward = 30000; + + _technicalName = "GettingStartedTutorial"; + _displayName = "Getting Started"; + } + + @Override + public void onFinished(final Player player) + { + UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); + UtilPlayer.message(player, C.cYellowB + "CONGRATULATIONS"); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, C.cWhite + "You have completed the CLANS basic tutorial and have been awarded {30,000 Gold}."); + UtilPlayer.message(player, C.cWhite + "You can now begin your adventure but do take a moment to read the signs around spawn for more information."); + UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); + + player.resetPlayerTime(); + player.teleport(Spawn.getEastSpawn()); + } + + @Override + public void onBegin(final Player player) + { + UtilPlayer.message(player, " "); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, C.cYellowB + "Getting Started"); + UtilPlayer.message(player, C.cWhite + "Welcome to Clans! " + + "In this game mode, you are able to create a Clan, invite your friends to the Clan, build a base, claim it to protect, and fight others with your new powerful Clan! " + + "You can also join a friend's Clan if they invite you to it! " + + "When you finish the tutorial, you will be awarded " + C.cAqua + "30,000 Gold"); + UtilPlayer.message(player, " "); + UtilPlayer.message(player, C.cDGreenB + C.Strike + "---------------------------------------------"); + } + + + @EventHandler(priority = EventPriority.MONITOR) + public void onUpdate(final UpdateEvent event) + { + if (!event.getType().equals(UpdateType.SEC)) + { + return; + } + + for (Player player : UtilServer.getPlayers()) + { + if (isInTutorial(player)) + { + for (Player other : UtilServer.getPlayers()) + { + other.hidePlayer(player.getPlayer()); + player.hidePlayer(other); + } + } + } + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/types/TutorialGettingStarted.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/types/TutorialGettingStarted.java deleted file mode 100644 index be8ad0bd2..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/types/TutorialGettingStarted.java +++ /dev/null @@ -1,404 +0,0 @@ -package mineplex.game.clans.tutorials.types; - -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.inventory.ItemStack; - -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilItem; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilItem.ItemCategory; -import mineplex.core.donation.DonationManager; -import mineplex.core.task.TaskManager; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.ClanRole; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.event.ClanCreatedEvent; -import mineplex.game.clans.clans.event.ClanDisbandedEvent; -import mineplex.game.clans.clans.event.ClanJoinEvent; -import mineplex.game.clans.clans.event.ClanSetHomeEvent; -import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; -import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent; -import mineplex.game.clans.clans.event.ClansPlayerSellItemEvent; -import mineplex.game.clans.clans.event.ClansShopAddButtonEvent; -import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent; -import mineplex.game.clans.economy.GoldManager; -import mineplex.game.clans.spawn.Spawn; -import mineplex.game.clans.tutorials.Tutorial; -import mineplex.game.clans.tutorials.TutorialClient; -import mineplex.game.clans.tutorials.TutorialManager; -import mineplex.minecraft.game.classcombat.Class.ClientClass; -import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; - -public class TutorialGettingStarted extends Tutorial -{ - public TutorialGettingStarted(final TutorialManager manager, final ClansManager clansManager, final DonationManager donationManager, final GoldManager goldManager, final TaskManager taskManager) - { - super(goldManager, taskManager, clansManager, donationManager, manager); - - addTask(1, "Welcome", - "Welcome to Clans! " - + "In this game mode, you are able to create a Clan, invite your friends to the Clan, build a base, claim it to protect, and fight others with your new powerful Clan!" - + "You can also join a friend's Clan if they invite you to it!" - + "When you finish the tutorial, you will be awarded {30,000 Gold}"); - - addTask(2, "Create a clan", - "Before beginning, use the {/c create } command to start up your own Clan!" - + "Alternatively, you can join a friend's Clan, if they have invited you, instead of making your own."); - - addTask(3, "Viewing Clan Details", - "Now you can view information about your Clan. " - + "To do this type {/c [Clan Name]}! " - + "You can also use any Clans name to get some information about them as well."); - - addTask(4, "Leave Spawn Islands", - "Now you can leave the Spawn Island. " - + "Don't worry, you won't get hurt from the fall! " - + "Once you end the tutorial, PvP will be enabled down there, so be careful!"); - - addTask(5, "Go To The Wilderness", - "Use your Map (Slot 9) to help find your way to the Wilderness. " - + "The Wilderness is anywhere that is not colored on the Map. " - + "If you don't have a map, you can get one at any time by typing {/map}. " - + "You can zoom in/out by Left and Right Clicking!"); - - addTask(6, "Claim some Territory", - "Clans can claim 16x16 areas of Territory! " - + "Once claimed, only your Clan can break/place blocks here. " - + "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. " - + "Claim some Territory now, by typing {/c claim}! ", - - "Good job! We won't actually claim this Territory yet!"); - - addTask(7, "Set Clan Home", - "You are now ready to set a Clan Home." - + "To do this, use the {/c sethome} command."); - - addTask(8, "Explore the Shops", - "You can buy all sorts of things at the Shops! " - + "You can also sell things to the Villagers for Gold! " - + "Look at your Map and take notice of where the Shops is. " - + "You can also transfer {1,000 Gems} into {32,000 Clans Gold} each day."); - - addTask(9, "Equip a Class", - "Find the PvP Gear shop, and Right-Click the Villager. " - + "Purchase Iron Armor from the PvP Shop. (FREE) " - + "Then put on your Armor to equip a Champions Class. "); - - addTask(10, "Use a Class Ability", - "Now that you have Equipped a Class, you can start using Abilities. " - + "Purchase a Sword from the PvP Shop. (FREE) " - + "Right-Click with your Sword to use your Sword Ability!"); - - addTask(11, "Class Customization", - "To customize your Class, Right-Click an Enchantment Table! " - + "There should be one nearby in the Shops!" - + "Find it, and try customizing your Class! "); - - addTask(12, "Making Money (Farming)", - "We have given you a few Carrots, as a starter for your Farming career. " - + "Go to the Organic Produce Villager in one of the Shops, and sell the Carrots for {Gold}."); - - addTask(13, "Disband your Clan", - "Finally, let's disband your Clan to end the Tutorial. " - + "Simply type {/c disband} to do this. " - + "This will delete your Clan, and you'll be able to create or join a new one!"); - - _doScoreboard = true; - _ghostMode = true; - _startOnJoin = true; - _goldReward = 30000; - - _uniqueId = "GettingStartedTutorial"; - _friendlyName = "Getting Started"; - } - - @Override - public void onFinished(final Player player) - { - UtilPlayer.message(player, F.main("Tutorials", "You are now ready to play, welcome to the game.")); - player.resetPlayerTime(); - } - - @EventHandler - public void button(ClansShopAddButtonEvent event) - { - if (get(event.getPlayer()).hasFinishedTask(getTask("Explore the Shops")) && !get(event.getPlayer()).hasFinishedTask(getTask("Equip a Class"))) - { - if (!(UtilItem.isArmor(event.getMaterial()) && UtilItem.isIronProduct(event.getMaterial()))) - { - return; - } - - if (!_taskManager.hasCompletedTask(event.getPlayer(), "GettingStartedBought" + event.getMaterial().name())) - { - event.setBuyPrice(0); - event.setSellPrice(0); - } - } - } - - @EventHandler - public void swordbutton(ClansShopAddButtonEvent event) - { - if (get(event.getPlayer()).hasFinishedTask(getTask("Equip A Class")) && !get(event.getPlayer()).hasFinishedTask(getTask("Use a Class Ability"))) - { - if (!(UtilItem.isSword(event.getMaterial()))) - { - return; - } - - if (!_taskManager.hasCompletedTask(event.getPlayer(), "GettingStartedBoughtSword")) - { - event.setBuyPrice(0); - event.setSellPrice(0); - } - } - } - - @EventHandler - public void buy(final ClansPlayerBuyItemEvent event) - { - if (get(event.getPlayer()).hasFinishedTask(getTask("Explore the Shops")) && !get(event.getPlayer()).hasFinishedTask(getTask("Equip a Class"))) - { - if (!(UtilItem.isArmor(event.getItem().getType()) && UtilItem.isIronProduct(event.getItem().getType()))) - { - return; - } - - _taskManager.completedTask(new Callback(){ - @Override - public void run(Boolean data) - { - } - }, event.getPlayer(), "GettingStartedBought" + event.getItem().getType().name()); - } - } - - @EventHandler - public void buysword(final ClansPlayerBuyItemEvent event) - { - if (get(event.getPlayer()).hasFinishedTask(getTask("Equip A Class")) && !get(event.getPlayer()).hasFinishedTask(getTask("Use a Class Ability"))) - { - if (UtilItem.isSword(event.getItem().getType())) - { - _taskManager.completedTask(new Callback() { - @Override - public void run(Boolean data) - { - } - }, event.getPlayer(), "GettingStartedBoughtSword"); - } - } - } - - @EventHandler - public void sell(ClansPlayerSellItemEvent event) - { - if (get(event.getPlayer()).hasFinishedTask(getTask("Class Customization")) && !get(event.getPlayer()).hasFinishedTask(getTask("Making Money (Farming)"))) - { - finishTask(event.getPlayer(), "Making Money (Farming)"); - } - } - - @Override - public void onBegin(final Player player) - { - UtilPlayer.message(player, F.main("Tutorials", "Welcome to the " + F.elem("Getting Started Tutorial!"))); - - UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(_clansManager.getPlugin(), new Runnable() { - public void run() - { - finishTask(player, "Welcome"); - - UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(_clansManager.getPlugin(), new Runnable() { - public void run() - { - if (_clansManager.isInClan(player) && _clansManager.getClan(player).getClansPlayerFromName(player.getName()).getRole().has(ClanRole.ADMIN)) - { - finishTask(player, "Create a clan"); - } - } - }, 20L); - } - }, 80L); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onClanCreated(ClanCreatedEvent event) - { - if (event.getFounder() == null) - { - return; - } - - if (isInTutorial(event.getFounder()) && get(event.getFounder()).hasFinishedTask(getTask("Welcome")) && !get(event.getFounder()).hasFinishedTask(getTask("Create a clan"))) - { - finishTask(event.getFounder(), "Create a clan"); - } - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onClanJoined(ClanJoinEvent event) - { - if (event.getPlayer() == null) - { - return; - } - - if (isInTutorial(event.getPlayer()) && get(event.getPlayer()).hasFinishedTask(getTask("Welcome")) && !get(event.getPlayer()).hasFinishedTask(getTask("Create a clan"))) - { - finishTask(event.getPlayer(), "Create a clan"); - } - } - - @EventHandler(priority = EventPriority.LOWEST) - public void handlePlayerChat(AsyncPlayerChatEvent event) - { - for (TutorialClient player : _inTutorial.values()) - { - if (event.getPlayer().equals(player.getPlayer())) - { - event.setCancelled(true); - continue; - } - - event.getRecipients().remove(player.getPlayer()); - } - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onClansCommand(ClansCommandExecutedEvent event) - { - if (event.getCommand().equals("info")) - { - if (isInTutorial(event.getPlayer()) && get(event.getPlayer()).hasFinishedTask(getTask("Create a clan")) && !get(event.getPlayer()).hasFinishedTask(getTask("Viewing Clan Details"))) - { - finishTask(event.getPlayer(), "Viewing Clan Details"); - } - } - else if (event.getCommand().equals("claim")) - { - if (isInTutorial(event.getPlayer()) && get(event.getPlayer()).hasFinishedTask(getTask("Go To The Wilderness")) && !get(event.getPlayer()).hasFinishedTask(getTask("Claiming Territory"))) - { - finishTask(event.getPlayer(), "Claim some Territory"); - event.getPlayer().teleport(Spawn.getNorthTown()); - event.setCancelled(true); - } - } - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onSethome(ClanSetHomeEvent event) - { - if (isInTutorial(event.getPlayer()) && get(event.getPlayer()).hasFinishedTask(getTask("Claim some Territory")) && !get(event.getPlayer()).hasFinishedTask(getTask("Set Clan Home"))) - { - finishTask(event.getPlayer(), "Set Clan Home"); - } - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onTerritory(final PlayerEnterTerritoryEvent event) - { - final Player player = event.getPlayer(); - final String newTerritory = event.getNewTerritory(); - - if (isInTutorial(player) && newTerritory.contains("Spawn") && get(player).hasFinishedTask(getTask("Viewing Clan Details")) && !get(player).hasFinishedTask(getTask("Leave Spawn Islands"))) - { - finishTask(player, "Leave Spawn Islands"); - } - else if (isInTutorial(player) && newTerritory.contains("Wilderness") && get(player).hasFinishedTask(getTask("Leave Spawn Islands")) && !get(player).hasFinishedTask(getTask("Go To The Wilderness"))) - { - finishTask(player, "Go To The Wilderness"); - } - else if (isInTutorial(player) && newTerritory.contains("Shops") && get(player).hasFinishedTask(getTask("Claim some Territory")) && !get(player).hasFinishedTask(getTask("Explore the Shops"))) - { - finishTask(player, "Explore the Shops"); - } - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onSkillTriggered(final SkillTriggerEvent event) - { - final Player player = event.GetPlayer(); - - if (isInTutorial(player) && get(player).hasFinishedTask(getTask("Equip a Class")) && !get(player).hasFinishedTask(getTask("Use a Class Ability"))) - { - finishTask(player, "Use a Class Ability"); - } - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onUpdated(final UpdateEvent event) - { - for (Player player : UtilServer.getPlayers()) - { - if (!isInTutorial(player)) - { - continue; - } - - ClientClass client = _clansManager.getClassManager().Get(player); - - if (client == null) - { - continue; - } - - if (client.GetGameClass() == null) - { - return; - } - - if (isInTutorial(player) && get(player).hasFinishedTask(getTask("Explore the Shops")) && !get(player).hasFinishedTask(getTask("Equip a Class"))) - { - finishTask(player, "Use a Class Ability"); - } - } - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onUpdate(final UpdateEvent event) - { - if (!event.getType().equals(UpdateType.SEC)) - { - return; - } - - for (final TutorialClient client : _inTutorial.values()) - { - if (isInTutorial(client.getPlayer())) - { - client.getPlayer().setPlayerTime(6000, false); - - if (get(client.getPlayer()).hasFinishedTask(getTask("Equip a Class")) && !get(client.getPlayer()).hasFinishedTask(getTask("Class Customization"))) - { - final ClientClass clientclass = _clansManager.getClassManager().Get(client.getPlayer()); - - if (clientclass != null && clientclass.GetSavingCustomBuild() != null) - { - finishTask(client.getPlayer(), "Class Customization"); - client.getPlayer().getInventory().addItem(new ItemStack(Material.CARROT_ITEM, 5)); - } - } - } - } - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onDeletedClan(final ClanDisbandedEvent event) - { - if (isInTutorial(event.getDisbander()) && get(event.getDisbander()).hasFinishedTask(getTask("Making Money (Farming)")) && !get(event.getDisbander()).hasFinishedTask(getTask("Disband your Clan"))) - { - finishTask(event.getDisbander(), "Disband your Clan"); - } - } - -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/world/WorldManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/world/WorldManager.java index 408e33924..f2761bab3 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/world/WorldManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/world/WorldManager.java @@ -3,9 +3,12 @@ package mineplex.game.clans.world; import java.util.ArrayList; import java.util.HashMap; +import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.plugin.java.JavaPlugin; @@ -38,7 +41,23 @@ public class WorldManager extends MiniPlugin for (Entity ent : world.getEntities()) { if (ent.getCustomName() == null) - _ents.get(ent.getType()).add(ent); + { + boolean cull = true; + + for (Player player : world.getPlayers()) + { + if (player.getLocation().distance(ent.getLocation()) <= 64) + { + cull = false; + break; + } + } + + if (cull) + { + _ents.get(ent.getType()).add(ent); + } + } } for (EntityType type : _ents.keySet()) diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java index f1c81cb0a..1bc32cef6 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java @@ -17,9 +17,11 @@ 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.UtilServer; import mineplex.core.donation.Donor; import mineplex.core.itemstack.ItemStackFactory; import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; +import mineplex.minecraft.game.classcombat.Class.event.ClassEquipEvent; import mineplex.minecraft.game.classcombat.Class.repository.token.ClientClassToken; import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken; import mineplex.minecraft.game.classcombat.Class.repository.token.SlotToken; @@ -343,7 +345,16 @@ public class ClientClass } ResetToDefaults(!skillsOnly, !skillsOnly); - + + // Event + ClassEquipEvent event = new ClassEquipEvent(this, customBuild); + UtilServer.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) + { + return; + } + if (notify) { ListSkills(_client.GetPlayer()); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/PvpClass.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/PvpClass.java index 4c28f55eb..488942a3e 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/PvpClass.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/PvpClass.java @@ -5,8 +5,10 @@ import java.util.concurrent.ConcurrentHashMap; import mineplex.core.common.util.Callback; import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilServer; import mineplex.core.gadget.types.GadgetType; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.minecraft.game.classcombat.Class.event.ClassEquipEvent; import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken; import mineplex.minecraft.game.classcombat.Skill.ISkill; diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/event/ClassEquipEvent.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/event/ClassEquipEvent.java new file mode 100644 index 000000000..74f2c5fab --- /dev/null +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/event/ClassEquipEvent.java @@ -0,0 +1,57 @@ +package mineplex.minecraft.game.classcombat.Class.event; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +import mineplex.minecraft.game.classcombat.Class.ClientClass; +import mineplex.minecraft.game.classcombat.Class.PvpClass; +import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken; + +public class ClassEquipEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private ClientClass _client; + + private CustomBuildToken _build; + + private boolean _cancelled; + + public ClassEquipEvent(ClientClass client, CustomBuildToken build) + { + _client = client; + _build = build; + } + + public ClientClass getPlayer() + { + return _client; + } + + public CustomBuildToken getBuild() + { + return _build; + } + + public void setCancelled(boolean cancelled) + { + _cancelled = cancelled; + } + + public boolean isCancelled() + { + return _cancelled; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + +} \ No newline at end of file diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java index 135c0278b..bdda29bd0 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Brute/BlockToss.java @@ -170,6 +170,8 @@ public class BlockToss extends SkillCharge implements IThrown return; } + event.getClickedBlock().setType(Material.AIR); + //Block to Item FallingBlock block = player.getWorld().spawnFallingBlock(player.getEyeLocation(), event.getClickedBlock().getType(), event.getClickedBlock().getData());