From 6fefcbd9537fbe08b00e63667fbf011517cc219c Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sun, 30 Aug 2015 17:13:08 -0400 Subject: [PATCH] Kit Changes/Fixes: - Fixed Kit Mobs not opening guis in Champions games - Fixed Abilities not working in CTF - Added new event when a player attempts to choose a kit - Cancelled changing kit while holding a flag --- .../nautilus/game/arcade/ArcadeManager.java | 204 +++++++++--------- .../arcade/events/PlayerKitApplyEvent.java | 73 +++++++ .../game/games/common/CaptureTheFlag.java | 16 ++ .../game/games/common/ctf_data/Flag.java | 71 +++--- .../src/nautilus/game/arcade/kit/Kit.java | 22 +- .../arcade/managers/GamePlayerManager.java | 103 +++++---- 6 files changed, 298 insertions(+), 191 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/events/PlayerKitApplyEvent.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 30871a8e7..6e61b7f05 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -1,12 +1,109 @@ package nautilus.game.arcade; -import java.awt.Event; import java.io.File; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.Map.Entry; +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.achievement.AchievementManager; +import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.blood.Blood; +import mineplex.core.bonuses.BonusManager; +import mineplex.core.chat.Chat; +import mineplex.core.common.Rank; +import mineplex.core.common.jsonchat.ClickEvent; +import mineplex.core.common.jsonchat.JsonMessage; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.cosmetic.CosmeticManager; +import mineplex.core.creature.Creature; +import mineplex.core.disguise.DisguiseManager; +import mineplex.core.donation.DonationManager; +import mineplex.core.elo.EloManager; +import mineplex.core.energy.Energy; +import mineplex.core.explosion.Explosion; +import mineplex.core.hologram.HologramManager; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.movement.Movement; +import mineplex.core.notifier.NotificationManager; +import mineplex.core.npc.NpcManager; +import mineplex.core.packethandler.IPacketHandler; +import mineplex.core.packethandler.PacketHandler; +import mineplex.core.packethandler.PacketInfo; +import mineplex.core.packethandler.PacketPlayResourcePackStatus; +import mineplex.core.packethandler.PacketPlayResourcePackStatus.EnumResourcePackStatus; +import mineplex.core.party.PartyManager; +import mineplex.core.pet.PetManager; +import mineplex.core.poll.PollManager; +import mineplex.core.portal.Portal; +import mineplex.core.preferences.PreferencesManager; +import mineplex.core.projectile.ProjectileManager; +import mineplex.core.resourcepack.ResPackManager; +import mineplex.core.resourcepack.ResUnloadCheck; +import mineplex.core.resourcepack.redis.RedisUnloadResPack; +import mineplex.core.reward.RewardRarity; +import mineplex.core.reward.rewards.PetReward; +import mineplex.core.stats.StatsManager; +import mineplex.core.status.ServerStatusManager; +import mineplex.core.task.TaskManager; +import mineplex.core.teleport.Teleport; +import mineplex.core.timing.TimingManager; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.classcombat.Class.ClassManager; +import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager; +import mineplex.minecraft.game.classcombat.Skill.SkillFactory; +import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; +import mineplex.minecraft.game.classcombat.item.ItemFactory; +import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent; +import mineplex.minecraft.game.classcombat.shop.ClassCombatShop; +import mineplex.minecraft.game.classcombat.shop.ClassShopManager; +import mineplex.minecraft.game.core.IRelation; +import mineplex.minecraft.game.core.condition.ConditionManager; +import mineplex.minecraft.game.core.damage.DamageManager; +import mineplex.minecraft.game.core.fire.Fire; +import nautilus.game.arcade.addons.SoupAddon; +import nautilus.game.arcade.addons.TeamArmorAddon; +import nautilus.game.arcade.addons.compass.CompassAddon; +import nautilus.game.arcade.command.DisguiseCommand; +import nautilus.game.arcade.command.GameCommand; +import nautilus.game.arcade.command.KitUnlockCommand; +import nautilus.game.arcade.command.WriteCommand; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameServerConfig; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.event.EventModule; +import nautilus.game.arcade.game.games.uhc.UHC; +import nautilus.game.arcade.managers.GameAchievementManager; +import nautilus.game.arcade.managers.GameChatManager; +import nautilus.game.arcade.managers.GameCreationManager; +import nautilus.game.arcade.managers.GameFlagManager; +import nautilus.game.arcade.managers.GameGemManager; +import nautilus.game.arcade.managers.GameHostManager; +import nautilus.game.arcade.managers.GameLobbyManager; +import nautilus.game.arcade.managers.GameLootManager; +import nautilus.game.arcade.managers.GameManager; +import nautilus.game.arcade.managers.GamePlayerManager; +import nautilus.game.arcade.managers.GameSpectatorManager; +import nautilus.game.arcade.managers.GameStatManager; +import nautilus.game.arcade.managers.GameTournamentManager; +import nautilus.game.arcade.managers.GameWorldManager; +import nautilus.game.arcade.managers.IdleManager; +import nautilus.game.arcade.managers.MiscManager; +import nautilus.game.arcade.shop.ArcadeShop; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; @@ -36,107 +133,6 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.util.Vector; import com.google.common.base.Objects; - -import mineplex.core.MiniPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.achievement.AchievementManager; -import mineplex.core.blockrestore.BlockRestore; -import mineplex.core.blood.Blood; -import mineplex.core.bonuses.BonusManager; -import mineplex.core.chat.Chat; -import mineplex.core.common.Rank; -import mineplex.core.common.jsonchat.ClickEvent; -import mineplex.core.common.jsonchat.JsonMessage; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.cosmetic.CosmeticManager; -import mineplex.core.creature.Creature; -import mineplex.core.disguise.DisguiseManager; -import mineplex.core.donation.DonationManager; -import mineplex.core.elo.EloManager; -import mineplex.core.energy.Energy; -import mineplex.core.explosion.Explosion; -import mineplex.core.gadget.gadgets.OutfitTeam; -import mineplex.core.gadget.types.Gadget; -import mineplex.core.gadget.types.GadgetType; -import mineplex.core.hologram.HologramManager; -import mineplex.core.inventory.InventoryManager; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.movement.Movement; -import mineplex.core.notifier.NotificationManager; -import mineplex.core.npc.NpcManager; -import mineplex.core.packethandler.IPacketHandler; -import mineplex.core.packethandler.PacketHandler; -import mineplex.core.packethandler.PacketInfo; -import mineplex.core.packethandler.PacketPlayResourcePackStatus; -import mineplex.core.packethandler.PacketPlayResourcePackStatus.EnumResourcePackStatus; -import mineplex.core.party.PartyManager; -import mineplex.core.pet.PetManager; -import mineplex.core.poll.PollManager; -import mineplex.core.portal.Portal; -import mineplex.core.preferences.PreferencesManager; -import mineplex.core.projectile.ProjectileManager; -import mineplex.core.resourcepack.ResUnloadCheck; -import mineplex.core.resourcepack.ResPackManager; -import mineplex.core.resourcepack.redis.RedisUnloadResPack; -import mineplex.core.reward.RewardRarity; -import mineplex.core.reward.rewards.PetReward; -import mineplex.core.stats.StatsManager; -import mineplex.core.status.ServerStatusManager; -import mineplex.core.task.TaskManager; -import mineplex.core.teleport.Teleport; -import mineplex.core.timing.TimingManager; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.classcombat.Class.ClassManager; -import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager; -import mineplex.minecraft.game.classcombat.Skill.SkillFactory; -import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; -import mineplex.minecraft.game.classcombat.item.ItemFactory; -import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent; -import mineplex.minecraft.game.classcombat.shop.ClassCombatShop; -import mineplex.minecraft.game.classcombat.shop.ClassShopManager; -import mineplex.minecraft.game.core.IRelation; -import mineplex.minecraft.game.core.condition.ConditionManager; -import mineplex.minecraft.game.core.damage.DamageManager; -import mineplex.minecraft.game.core.fire.Fire; -import nautilus.game.arcade.addons.SoupAddon; -import nautilus.game.arcade.addons.TeamArmorAddon; -import nautilus.game.arcade.addons.compass.CompassAddon; -import nautilus.game.arcade.command.DisguiseCommand; -import nautilus.game.arcade.command.GameCommand; -import nautilus.game.arcade.command.WriteCommand; -import nautilus.game.arcade.command.KitUnlockCommand; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.Game.GameState; -import nautilus.game.arcade.game.GameServerConfig; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.games.event.EventModule; -import nautilus.game.arcade.game.games.uhc.UHC; -import nautilus.game.arcade.managers.GameAchievementManager; -import nautilus.game.arcade.managers.GameChatManager; -import nautilus.game.arcade.managers.GameCreationManager; -import nautilus.game.arcade.managers.GameFlagManager; -import nautilus.game.arcade.managers.GameGemManager; -import nautilus.game.arcade.managers.GameHostManager; -import nautilus.game.arcade.managers.GameLobbyManager; -import nautilus.game.arcade.managers.GameLootManager; -import nautilus.game.arcade.managers.GameManager; -import nautilus.game.arcade.managers.GamePlayerManager; -import nautilus.game.arcade.managers.GameSpectatorManager; -import nautilus.game.arcade.managers.GameStatManager; -import nautilus.game.arcade.managers.GameTournamentManager; -import nautilus.game.arcade.managers.GameWorldManager; -import nautilus.game.arcade.managers.IdleManager; -import nautilus.game.arcade.managers.MiscManager; -import nautilus.game.arcade.shop.ArcadeShop; public class ArcadeManager extends MiniPlugin implements IRelation { @@ -231,7 +227,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation _explosionManager.SetDebris(false); if (serverConfig.GameList.contains(GameType.ChampionsDominate) - || serverConfig.GameList.contains(GameType.ChampionsTDM)) + || serverConfig.GameList.contains(GameType.ChampionsTDM) || serverConfig.GameList.contains(GameType.ChampionsCTF)) { _conditionManager = new SkillConditionManager(plugin); } @@ -1292,7 +1288,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation public void toggleChampionsModules(GameType gameType) { - boolean isChamps = gameType == GameType.ChampionsDominate || gameType == GameType.ChampionsTDM; + boolean isChamps = gameType == GameType.ChampionsDominate || gameType == GameType.ChampionsTDM || gameType == GameType.ChampionsCTF; if (_enabled == isChamps) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/events/PlayerKitApplyEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/events/PlayerKitApplyEvent.java new file mode 100644 index 000000000..7ec303648 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/events/PlayerKitApplyEvent.java @@ -0,0 +1,73 @@ +package nautilus.game.arcade.events; + +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.kit.Kit; + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class PlayerKitApplyEvent extends Event implements Cancellable +{ + private static final HandlerList handlers = new HandlerList(); + private Game _game; + private Kit _kit; + private Player _player; + private boolean _cancelled = false; + private String _cancelMessage = ""; + + public PlayerKitApplyEvent(Game game, Kit kit, Player player) + { + _game = game; + _kit = kit; + _player = player; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + + public Game GetGame() + { + return _game; + } + + public Kit GetKit() + { + return _kit; + } + + public Player GetPlayer() + { + return _player; + } + + public String getCancelMessage() + { + return _cancelMessage; + } + + public void setCancelMessage(String message) + { + _cancelMessage = message; + } + + @Override + public boolean isCancelled() + { + return _cancelled; + } + + @Override + public void setCancelled(boolean cancelled) + { + _cancelled = cancelled; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java index cee20538a..0932554bf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/CaptureTheFlag.java @@ -20,6 +20,7 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerGameRespawnEvent; +import nautilus.game.arcade.events.PlayerKitApplyEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; @@ -462,4 +463,19 @@ public class CaptureTheFlag extends TeamGame if (flag.Pickup(event.getPlayer(), event.getClickedBlock())) event.setCancelled(true); } + + @EventHandler + public void selectKit(PlayerKitApplyEvent event) + { + if (this instanceof ChampionsCTF) + { + for (Flag flag : _flags) + if (!flag.isAtHome()) + if (flag.getCarrier().getName().equals(event.GetPlayer().getName())) + { + event.setCancelled(true); + event.setCancelMessage("You cannot change kits while holding a flag!"); + } + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/ctf_data/Flag.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/ctf_data/Flag.java index d6af71d21..b60847161 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/ctf_data/Flag.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/common/ctf_data/Flag.java @@ -69,6 +69,11 @@ public class Flag return !_moved; } + public Player getCarrier() + { + return _holding; + } + private void AnnounceCapture() { UtilTextMiddle.display("Your flag has", "been stolen! Retrieve it!", _team.GetPlayers(true).toArray(new Player[0])); @@ -156,43 +161,49 @@ public class Flag { if (_holding == null) { - if (Host.GetTeam(player) != _team) + if (!UtilPlayer.isSpectator(player)) { - if (block != null) + if (Host.IsAlive(player)) { - if (block.getType() == _representation.getType()) + if (Host.GetTeam(player) != _team) { - boolean isFlag = false; - for (Block flagBlock : _flagBlocks) + if (block != null) { - if (block.getLocation().equals(flagBlock.getLocation())) + if (block.getType() == _representation.getType()) { - isFlag = true; - break; + boolean isFlag = false; + for (Block flagBlock : _flagBlocks) + { + if (block.getLocation().equals(flagBlock.getLocation())) + { + isFlag = true; + break; + } + } + + if (!isFlag) + return false; + + for (Block flagBlock : _flagBlocks) + { + flagBlock.setType(Material.AIR); + } + + for (int i = 0; i < 9; i++) + { + player.getInventory().setItem(i, _representation); + } + player.updateInventory(); + + AnnounceCapture(); + _holding = player; + _dropped = false; + _dropTime = 0; + _moved = true; + + return true; } } - - if (!isFlag) - return false; - - for (Block flagBlock : _flagBlocks) - { - flagBlock.setType(Material.AIR); - } - - for (int i = 0; i < 9; i++) - { - player.getInventory().setItem(i, _representation); - } - player.updateInventory(); - - AnnounceCapture(); - _holding = player; - _dropped = false; - _dropTime = 0; - _moved = true; - - return true; } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java index e23422a01..5ae95e196 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Kit.java @@ -1,5 +1,17 @@ package nautilus.game.arcade.kit; +import mineplex.core.achievement.Achievement; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import nautilus.game.arcade.ArcadeFormat; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.events.PlayerKitApplyEvent; +import nautilus.game.arcade.events.PlayerKitGiveEvent; + import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Entity; @@ -11,16 +23,6 @@ import org.bukkit.entity.Skeleton.SkeletonType; import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; -import mineplex.core.achievement.Achievement; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import nautilus.game.arcade.ArcadeFormat; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.events.PlayerKitGiveEvent; - public abstract class Kit implements Listener { public ArcadeManager Manager; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java index 1a68d11ff..4eb209118 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java @@ -7,6 +7,7 @@ import mineplex.core.common.Rank; 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.common.util.UtilTabTitle; import mineplex.core.donation.Donor; import mineplex.core.recharge.Recharge; @@ -15,6 +16,7 @@ import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.PlayerKitApplyEvent; import nautilus.game.arcade.events.PlayerStateChangeEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game.GameState; @@ -316,58 +318,65 @@ public class GamePlayerManager implements Listener public void KitClick(final Player player, final Kit kit, final Entity entity) { - kit.DisplayDesc(player); - - if (Manager.GetGame() == null) - return; - - if (!Manager.GetGame().HasKit(kit)) - return; - - Donor donor = Manager.GetDonation().Get(player.getName()); - - if (kit.GetAvailability() == KitAvailability.Free || //Free - - Manager.hasKitsUnlocked(player) || //YouTube - - (kit.GetAvailability() == KitAvailability.Achievement && //Achievement - Manager.GetAchievement().hasCategory(player, kit.getAchievementRequirement())) || - - donor.OwnsUnknownPackage(Manager.GetGame().GetType().GetKitGameName() + " " + kit.GetName()) || //Green - - Manager.GetClients().Get(player).GetRank().has(Rank.MAPDEV) || //STAFF - - donor.OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA") || //Single Ultra (Old) - - Manager.GetServerConfig().Tournament) //Tournament + PlayerKitApplyEvent kitEvent = new PlayerKitApplyEvent(Manager.GetGame(), kit, player); + UtilServer.getServer().getPluginManager().callEvent(kitEvent); + if (!kitEvent.isCancelled()) { - Manager.GetGame().SetKit(player, kit, true); - } - else if (kit.GetAvailability() == KitAvailability.Gem && donor.GetBalance(CurrencyType.Gems) >= kit.GetCost()) - { - Manager.GetShop().openPageForPlayer(player, new ConfirmationPage( - Manager, Manager.GetShop(), Manager.GetClients(), Manager.GetDonation(), new Runnable() + kit.DisplayDesc(player); + + if (Manager.GetGame() == null) + return; + + if (!Manager.GetGame().HasKit(kit)) + return; + + Donor donor = Manager.GetDonation().Get(player.getName()); + + if (kit.GetAvailability() == KitAvailability.Free || //Free + + Manager.hasKitsUnlocked(player) || //YouTube + + (kit.GetAvailability() == KitAvailability.Achievement && //Achievement + Manager.GetAchievement().hasCategory(player, kit.getAchievementRequirement())) || + + donor.OwnsUnknownPackage(Manager.GetGame().GetType().GetKitGameName() + " " + kit.GetName()) || //Green + + Manager.GetClients().Get(player).GetRank().has(Rank.MAPDEV) || //STAFF + + donor.OwnsUnknownPackage(Manager.GetServerConfig().ServerType + " ULTRA") || //Single Ultra (Old) + + Manager.GetServerConfig().Tournament) //Tournament { - public void run() - { - if (player.isOnline()) + Manager.GetGame().SetKit(player, kit, true); + } + else if (kit.GetAvailability() == KitAvailability.Gem && donor.GetBalance(CurrencyType.Gems) >= kit.GetCost()) + { + Manager.GetShop().openPageForPlayer(player, new ConfirmationPage( + Manager, Manager.GetShop(), Manager.GetClients(), Manager.GetDonation(), new Runnable() { - Manager.GetGame().SetKit(player, kit, true); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entity.getEntityId(), ((CraftEntity) entity).getHandle().getDataWatcher(), true)); - } - } - }, null, new KitPackage(Manager.GetGame().GetType().GetKitGameName(), kit), CurrencyType.Gems, player)); - } - else if (kit.GetAvailability() == KitAvailability.Achievement) - { - UtilPlayer.message(player, F.main("Kit", "You have not unlocked all " + F.elem(C.cPurple + Manager.GetGame().GetName() + " Achievements") + ".")); + public void run() + { + if (player.isOnline()) + { + Manager.GetGame().SetKit(player, kit, true); + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entity.getEntityId(), ((CraftEntity) entity).getHandle().getDataWatcher(), true)); + } + } + }, null, new KitPackage(Manager.GetGame().GetType().GetKitGameName(), kit), CurrencyType.Gems, player)); + } + else if (kit.GetAvailability() == KitAvailability.Achievement) + { + UtilPlayer.message(player, F.main("Kit", "You have not unlocked all " + F.elem(C.cPurple + Manager.GetGame().GetName() + " Achievements") + ".")); + } + else + { + player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 0.5f); + + UtilPlayer.message(player, F.main("Kit", "You do not have enough " + F.elem(C.cGreen + "Gems") + ".")); + } } else - { - player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 0.5f); - - UtilPlayer.message(player, F.main("Kit", "You do not have enough " + F.elem(C.cGreen + "Gems") + ".")); - } + UtilPlayer.message(player, F.main("Game", kitEvent.getCancelMessage())); } @EventHandler(priority = EventPriority.HIGHEST)