Advertisement
thevipershowita

ActiveGame.java

Nov 6th, 2020
2,906
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 47.14 KB | None | 0 0
  1. package me.thevipershow.bedwars.game;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.time.LocalDate;
  6. import java.time.format.DateTimeFormatter;
  7. import java.util.ArrayList;
  8. import java.util.Collection;
  9. import java.util.Collections;
  10. import java.util.EnumMap;
  11. import java.util.EnumSet;
  12. import java.util.HashMap;
  13. import java.util.HashSet;
  14. import java.util.LinkedList;
  15. import java.util.List;
  16. import java.util.Map;
  17. import java.util.Objects;
  18. import java.util.Set;
  19. import java.util.UUID;
  20. import java.util.concurrent.TimeUnit;
  21. import java.util.function.Supplier;
  22. import java.util.stream.Collectors;
  23. import me.thevipershow.bedwars.AllStrings;
  24. import me.thevipershow.bedwars.Bedwars;
  25. import me.thevipershow.bedwars.bedwars.Gamemode;
  26. import me.thevipershow.bedwars.bedwars.objects.BedwarsTeam;
  27. import me.thevipershow.bedwars.bedwars.objects.shops.MerchantType;
  28. import me.thevipershow.bedwars.bedwars.objects.spawners.SpawnerType;
  29. import me.thevipershow.bedwars.config.objects.BedwarsGame;
  30. import me.thevipershow.bedwars.config.objects.Merchant;
  31. import me.thevipershow.bedwars.config.objects.PotionItem;
  32. import me.thevipershow.bedwars.config.objects.Shop;
  33. import me.thevipershow.bedwars.config.objects.ShopItem;
  34. import me.thevipershow.bedwars.config.objects.SpawnPosition;
  35. import me.thevipershow.bedwars.config.objects.TeamSpawnPosition;
  36. import me.thevipershow.bedwars.config.objects.UpgradeItem;
  37. import me.thevipershow.bedwars.config.objects.UpgradeLevel;
  38. import me.thevipershow.bedwars.config.objects.upgradeshop.DragonBuffUpgrade;
  39. import me.thevipershow.bedwars.config.objects.upgradeshop.HealPoolUpgrade;
  40. import me.thevipershow.bedwars.config.objects.upgradeshop.IronForgeUpgrade;
  41. import me.thevipershow.bedwars.config.objects.upgradeshop.ManiacMinerUpgrade;
  42. import me.thevipershow.bedwars.config.objects.upgradeshop.ReinforcedArmorUpgrade;
  43. import me.thevipershow.bedwars.config.objects.upgradeshop.SharpnessUpgrade;
  44. import me.thevipershow.bedwars.config.objects.upgradeshop.TrapUpgrades;
  45. import me.thevipershow.bedwars.config.objects.upgradeshop.UpgradeShop;
  46. import me.thevipershow.bedwars.config.objects.upgradeshop.UpgradeShopItem;
  47. import me.thevipershow.bedwars.config.objects.upgradeshop.UpgradeType;
  48. import me.thevipershow.bedwars.config.objects.upgradeshop.traps.AlarmTrap;
  49. import me.thevipershow.bedwars.config.objects.upgradeshop.traps.BlindnessAndPoisonTrap;
  50. import me.thevipershow.bedwars.config.objects.upgradeshop.traps.CounterOffensiveTrap;
  51. import me.thevipershow.bedwars.config.objects.upgradeshop.traps.MinerFatigueTrap;
  52. import me.thevipershow.bedwars.game.shop.ShopCategory;
  53. import me.thevipershow.bedwars.game.upgrades.ActiveHealPool;
  54. import me.thevipershow.bedwars.game.upgrades.ActiveTrap;
  55. import me.thevipershow.bedwars.listeners.UnregisterableListener;
  56. import me.thevipershow.bedwars.listeners.game.*;
  57. import me.thevipershow.bedwars.storage.sql.tables.GlobalStatsTableUtils;
  58. import me.thevipershow.bedwars.worlds.WorldsManager;
  59. import me.tigerhix.lib.scoreboard.common.EntryBuilder;
  60. import me.tigerhix.lib.scoreboard.type.Entry;
  61. import me.tigerhix.lib.scoreboard.type.Scoreboard;
  62. import me.tigerhix.lib.scoreboard.type.ScoreboardHandler;
  63. import org.apache.commons.io.FileUtils;
  64. import org.bukkit.Bukkit;
  65. import org.bukkit.GameMode;
  66. import org.bukkit.Location;
  67. import org.bukkit.Material;
  68. import org.bukkit.Sound;
  69. import org.bukkit.World;
  70. import org.bukkit.block.Block;
  71. import org.bukkit.entity.Player;
  72. import org.bukkit.entity.Villager;
  73. import org.bukkit.inventory.Inventory;
  74. import org.bukkit.inventory.ItemStack;
  75. import org.bukkit.inventory.meta.ItemMeta;
  76. import org.bukkit.material.Bed;
  77. import org.bukkit.plugin.Plugin;
  78. import org.bukkit.plugin.PluginManager;
  79. import org.bukkit.scheduler.BukkitTask;
  80.  
  81. public abstract class ActiveGame {
  82.  
  83.     protected final String associatedWorldFilename;
  84.     protected final BedwarsGame bedwarsGame;
  85.     protected final World associatedWorld;
  86.     protected final World lobbyWorld;
  87.     protected final Location cachedLobbySpawnLocation;
  88.     protected final Plugin plugin;
  89.     protected final AbstractQueue<Player> associatedQueue;
  90.     protected final Location cachedWaitingLocation;
  91.     protected final Map<BedwarsTeam, List<Player>> assignedTeams;
  92.     protected final Set<ActiveSpawner> activeSpawners;
  93.     protected final Inventory defaultUpgradeInv;
  94.     protected final Inventory defaultTrapsInv;
  95.     protected final AbstractDeathmatch abstractDeathmatch;
  96.     protected final ExperienceManager experienceManager;
  97.     protected final QuestManager questManager;
  98.     protected final GameTrapTriggerer gameTrapTriggerer;
  99.     protected final KillTracker killTracker;
  100.     protected final ShopInventories shopInventories;
  101.     protected final EnderchestManager enderchestManager;
  102.     protected ActiveSpawner diamondSampleSpawner = null;
  103.     protected ActiveSpawner emeraldSampleSpawner = null;
  104.     protected final SwordUpgrades swordUpgrades = new SwordUpgrades();
  105.     protected final List<BedwarsTeam> destroyedTeams = new ArrayList<>();
  106.     protected final List<Player> playersOutOfGame = new ArrayList<>();
  107.     protected final List<Player> playersRespawning = new ArrayList<>();
  108.     protected final List<AbstractActiveMerchant> activeMerchants = new ArrayList<>();
  109.     protected final Set<Block> playerPlacedBlocks = new HashSet<>();
  110.     protected final List<UnregisterableListener> unregisterableListeners = new ArrayList<>();
  111.     protected final List<ActiveHealPool> healPools = new ArrayList<>();
  112.     protected final List<BukkitTask> announcementsTasks = new ArrayList<>();
  113.     protected final List<BukkitTask> emeraldBoostDrops = new ArrayList<>();
  114.     protected final List<Player> immuneTrapPlayers = new ArrayList<>();
  115.     protected final List<Player> hiddenPlayers = new ArrayList<>();
  116.     protected final Map<Player, ArmorSet> playerSetMap = new HashMap<>();
  117.     protected final Map<String, Integer> topKills = new HashMap<>();
  118.     protected final Map<UUID, EnumMap<ShopCategory, Inventory>> playerShop = new HashMap<>();
  119.     protected final Map<UUID, Inventory> associatedUpgradeGUI = new HashMap<>();
  120.     protected final Map<UUID, Inventory> associatedTrapsGUI = new HashMap<>();
  121.     protected final Map<UUID, UUID> placedTntMap = new HashMap<>();
  122.     protected final Map<Player, Map<UpgradeItem, Integer>> playerUpgradeLevelsMap = new HashMap<>();
  123.     protected final Map<Player, Scoreboard> activeScoreboards = new HashMap<>();
  124.     protected final EnumMap<UpgradeType, Map<BedwarsTeam, Integer>> upgradesLevelsMap = new EnumMap<>(UpgradeType.class);
  125.     protected final EnumMap<BedwarsTeam, LinkedList<ActiveTrap>> teamActiveTrapsList = new EnumMap<>(BedwarsTeam.class);
  126.     protected final EnumMap<BedwarsTeam, Long> lastActivatedTraps = new EnumMap<>(BedwarsTeam.class);
  127.  
  128.     ///////////////////////////////////////////////////
  129.     // Internal ActiveGame fields                    //
  130.     //-----------------------------------------------//
  131.     //                                               //
  132.     protected boolean hasStarted = false;            //
  133.     protected boolean winnerDeclared = false;        //
  134.     protected BukkitTask timerTask = null;           //
  135.     protected final GameLobbyTicker gameLobbyTicker; //
  136.     protected long startTime;                        //
  137.     //-----------------------------------------------//
  138.  
  139.     public ActiveGame(String associatedWorldFilename, BedwarsGame bedwarsGame, World lobbyWorld, Plugin plugin) {
  140.         this.associatedWorldFilename = associatedWorldFilename;
  141.         this.bedwarsGame = bedwarsGame;
  142.         this.lobbyWorld = lobbyWorld;
  143.         this.associatedWorld = Bukkit.getWorld(associatedWorldFilename);
  144.         this.plugin = plugin;
  145.         this.cachedLobbySpawnLocation = this.lobbyWorld.getSpawnLocation();
  146.         this.associatedQueue = new MatchmakingQueue(bedwarsGame.getPlayers());
  147.         this.cachedWaitingLocation = bedwarsGame.getLobbySpawn().toLocation(associatedWorld);
  148.         this.assignedTeams = new HashMap<>();
  149.         this.gameLobbyTicker = new GameLobbyTicker(this);
  150.         this.activeSpawners = bedwarsGame.getSpawners()
  151.                 .stream()
  152.                 .map(spawner -> new ActiveSpawner(spawner, this))
  153.                 .collect(Collectors.toSet());
  154.         registerMapListeners();
  155.         gameLobbyTicker.startTicking();
  156.         //    this.defaultShopInv = Objects.requireNonNull(setupShopGUIs());
  157.         this.defaultUpgradeInv = Objects.requireNonNull(setupUpgradeGUIs());
  158.         this.defaultTrapsInv = Objects.requireNonNull(setupTrapsGUIs());
  159.         this.abstractDeathmatch = GameUtils.deathmatchFromGamemode(bedwarsGame.getGamemode(), this);
  160.         this.experienceManager = new ExperienceManager(this);
  161.         this.questManager = new QuestManager(this.experienceManager);
  162.         this.gameTrapTriggerer = new GameTrapTriggerer(this);
  163.         this.killTracker = new KillTracker(this);
  164.         this.shopInventories = new ShopInventories(bedwarsGame.getShop());
  165.         this.enderchestManager = new EnderchestManager(this);
  166.     }
  167.  
  168.     protected final void setupUpgradeLevelsMap() {
  169.         associatedQueue.perform(p -> {
  170.             final Map<UpgradeItem, Integer> emptyMap = new HashMap<>();
  171.  
  172.             for (final UpgradeItem upgradeItem : bedwarsGame.getShop().getUpgradeItems()) {
  173.                 emptyMap.put(upgradeItem, -1);
  174.             }
  175.             this.playerUpgradeLevelsMap.put(p, emptyMap);
  176.         });
  177.     }
  178.  
  179.     protected final void announceNoTeaming() {
  180.         associatedQueue.perform(p -> p.sendMessage(Bedwars.PREFIX + AllStrings.TEAMING_PROHIBITED.get()));
  181.     }
  182.  
  183.     public void hidePlayer(final Player player) {
  184.         final BedwarsTeam playerTeam = getPlayerTeam(player);
  185.         for (Map.Entry<BedwarsTeam, List<Player>> entry : assignedTeams.entrySet()) {
  186.             if (entry.getKey() != playerTeam) {
  187.                 for (final Player p : entry.getValue()) {
  188.                     if (p.isOnline() && !isOutOfGame(p)) {
  189.                         p.hidePlayer(player);
  190.                     }
  191.                 }
  192.             }
  193.         }
  194.         hiddenPlayers.add(player);
  195.     }
  196.  
  197.     public void showPlayer(final Player player) {
  198.    //     player.spigot().getHiddenPlayers()
  199.         for (final List<Player> players : assignedTeams.values()) {
  200.             for (final Player p : players) {
  201.                 if (p.isOnline() && !isOutOfGame(p)) {
  202.                     p.showPlayer(player);
  203.                 }
  204.             }
  205.         }
  206.         hiddenPlayers.remove(player);
  207.     }
  208.  
  209.     public void showAll() {
  210.         associatedWorld.getPlayers().forEach(this::showPlayer);
  211.     }
  212.  
  213.     public final Inventory setupTrapsGUIs() {
  214.         final Inventory trapsInv = Bukkit.createInventory(null, 0x24, AllStrings.BEDWARS_TRAPS_TITLE.get());
  215.         final TrapUpgrades trapUpgrades = bedwarsGame.getUpgradeShop().getTrapUpgrades();
  216.         final BlindnessAndPoisonTrap blindnessAndPoisonTrap = trapUpgrades.getBlindnessAndPoisonTrap();
  217.         final CounterOffensiveTrap counterOffensiveTrap = trapUpgrades.getCounterOffensiveTrap();
  218.         final AlarmTrap alarmTrap = trapUpgrades.getAlarmTrap();
  219.         final MinerFatigueTrap minerFatigueTrap = trapUpgrades.getMinerFatigueTrap();
  220.  
  221.         final ShopItem blindnessAndPoisonItem = blindnessAndPoisonTrap.getShopItem();
  222.         final ShopItem alarmTrapItem = alarmTrap.getShopItem();
  223.         final ShopItem minerFatigueItem = minerFatigueTrap.getShopItem();
  224.         final ShopItem counterOffensiveItem = counterOffensiveTrap.getShopItem();
  225.  
  226.         trapsInv.setItem(blindnessAndPoisonItem.getSlot(), blindnessAndPoisonItem.getCachedFancyStack());
  227.         trapsInv.setItem(alarmTrapItem.getSlot(), alarmTrapItem.getCachedFancyStack());
  228.         trapsInv.setItem(minerFatigueItem.getSlot(), minerFatigueItem.getCachedFancyStack());
  229.         trapsInv.setItem(counterOffensiveItem.getSlot(), counterOffensiveItem.getCachedFancyStack());
  230.  
  231.         for (int i = 1; i <= 3; i++) {
  232.             final ItemStack glass = new ItemStack(Material.STAINED_GLASS_PANE, i);
  233.             final ItemMeta glassMeta = glass.getItemMeta();
  234.             glassMeta.setDisplayName("");
  235.             glass.setItemMeta(glassMeta);
  236.             trapsInv.setItem(29 + i, glass);
  237.         }
  238.  
  239.         return trapsInv;
  240.     }
  241.  
  242.     public final Inventory setupUpgradeGUIs() {
  243.         final Inventory upgradeInv = Bukkit.createInventory(null, bedwarsGame.getUpgradeShop().getSlots(), AllStrings.BEDWARS_UPGRADE_TITLE.get());
  244.         final UpgradeShop upgradeShop = bedwarsGame.getUpgradeShop();
  245.  
  246.         final DragonBuffUpgrade dragonBuffUpgrade = upgradeShop.getDragonBuffUpgrade();
  247.         final HealPoolUpgrade healPoolUpgrade = upgradeShop.getHealPoolUpgrade();
  248.         final IronForgeUpgrade ironForgeUpgrade = upgradeShop.getIronForgeUpgrade();
  249.         final ManiacMinerUpgrade maniacMinerUpgrade = upgradeShop.getManiacMinerUpgrade();
  250.         final ReinforcedArmorUpgrade reinforcedArmorUpgrade = upgradeShop.getReinforcedArmorUpgrade();
  251.         final SharpnessUpgrade sharpnessUpgrade = upgradeShop.getSharpnessUpgrade();
  252.  
  253.         final ShopItem dragonBuffItem = dragonBuffUpgrade.getShopItem();
  254.         final ShopItem healPoolItem = healPoolUpgrade.getItem();
  255.         final UpgradeShopItem ironForgeItem = ironForgeUpgrade.getLevels().get(0);
  256.         final UpgradeShopItem maniacMinerItem = maniacMinerUpgrade.getLevels().get(0);
  257.         final UpgradeShopItem reinforcedArmorItem = reinforcedArmorUpgrade.getLevels().get(0);
  258.         final ShopItem sharpnessItem = sharpnessUpgrade.getItem();
  259.         final TrapUpgrades trapUpgrades = upgradeShop.getTrapUpgrades();
  260.  
  261.         upgradeInv.setItem(dragonBuffItem.getSlot(), dragonBuffItem.getCachedFancyStack());
  262.         upgradeInv.setItem(healPoolItem.getSlot(), healPoolItem.getCachedFancyStack());
  263.         upgradeInv.setItem(ironForgeUpgrade.getSlot(), ironForgeItem.getCachedFancyStack());
  264.         upgradeInv.setItem(maniacMinerUpgrade.getSlot(), maniacMinerItem.getCachedFancyStack());
  265.         upgradeInv.setItem(reinforcedArmorUpgrade.getSlot(), reinforcedArmorItem.getCachedFancyStack());
  266.         upgradeInv.setItem(sharpnessItem.getSlot(), sharpnessItem.getCachedFancyStack());
  267.         upgradeInv.setItem(trapUpgrades.getSlot(), trapUpgrades.getFancyItemStack());
  268.  
  269.         for (int i = 1; i <= 3; i++) {
  270.             final ItemStack glass = new ItemStack(Material.STAINED_GLASS_PANE, i);
  271.             final ItemMeta glassMeta = glass.getItemMeta();
  272.             glassMeta.setDisplayName("");
  273.             glass.setItemMeta(glassMeta);
  274.             upgradeInv.setItem(29 + i, glass);
  275.         }
  276.  
  277.         return upgradeInv;
  278.     }
  279.  
  280.  
  281.     protected final ScoreboardHandler scoreboardHandler = new ScoreboardHandler() {
  282.  
  283.         @Override
  284.         public String getTitle(final Player player) {
  285.             return Bedwars.PREFIX;
  286.         }
  287.  
  288.         @Override
  289.         public List<Entry> getEntries(final Player player) {
  290.             final EntryBuilder builder = new EntryBuilder();
  291.             builder.next("§7   " + LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE));
  292.             builder.blank();
  293.  
  294.             if (diamondSampleSpawner != null && emeraldSampleSpawner != null) {
  295.                 final String diamondText = GameUtils.generateScoreboardMissingTimeSpawners(getDiamondSampleSpawner());
  296.                 final String emeraldText = GameUtils.generateScoreboardMissingTimeSpawners(getEmeraldSampleSpawner());
  297.                 builder.next(diamondText);
  298.                 builder.next(emeraldText);
  299.                 builder.blank();
  300.             }
  301.  
  302.             if (abstractDeathmatch.isRunning()) {
  303.                 builder.next(GameUtils.generateDeathmatch(abstractDeathmatch));
  304.                 builder.next(GameUtils.generateDragons(abstractDeathmatch));
  305.             }
  306.  
  307.             for (final BedwarsTeam team : assignedTeams.keySet()) {
  308.                 builder.next(AllStrings.TEAM_SCOREBOARD.get() + team.getColorCode() + "§l" + team.name() + getTeamChar(team));
  309.             }
  310.  
  311.             builder.blank();
  312.             builder.next(" §e" + AllStrings.SERVER_BRAND.get());
  313.             return builder.build();
  314.         }
  315.  
  316.     };
  317.  
  318.     @SuppressWarnings("deprecation")
  319.     public void destroyTeamBed(final BedwarsTeam destroyed, final Player destroyer) {
  320.         questManager.breakBedReward(destroyer);
  321.  
  322.         associatedQueue.perform(p -> {
  323.             if (p.isOnline() && p.getWorld().equals(associatedWorld)) {
  324.                 if (getPlayerTeam(p) == destroyed) {
  325.                     p.sendTitle("", AllStrings.YOUR_BED_BROKEN.get());
  326.                 } else {
  327.                     final BedwarsTeam destroyerTeam = getPlayerTeam(destroyer);
  328.                     p.sendMessage(Bedwars.PREFIX + "§" + destroyed.getColorCode() + destroyed.name() + AllStrings.BED_BROKEN_BY.get() + destroyerTeam.getColorCode() + destroyer.getName());
  329.                 }
  330.                 p.playSound(p.getLocation(), Sound.ENDERDRAGON_GROWL, 9.0f, 1.0f);
  331.             }
  332.         });
  333.     }
  334.  
  335.     public final void cleanAllAndFinalize() {
  336.         gameTrapTriggerer.stop();
  337.         unregisterAllListeners();
  338.         associatedQueue.cleanQueue();
  339.         assignedTeams.clear();
  340.         activeSpawners.forEach(ActiveSpawner::despawn);
  341.         activeSpawners.clear();
  342.         activeScoreboards.values().forEach(Scoreboard::deactivate);
  343.         activeScoreboards.clear();
  344.         destroyedTeams.clear();
  345.         playersOutOfGame.clear();
  346.         activeMerchants.forEach(AbstractActiveMerchant::delete);
  347.         activeMerchants.clear();
  348.         playerPlacedBlocks.clear();
  349.         playerSetMap.clear();
  350.         topKills.clear();
  351.         gameLobbyTicker.stopTicking();
  352.         abstractDeathmatch.stop();
  353.         healPools.forEach(ActiveHealPool::stop);
  354.         healPools.clear();
  355.         upgradesLevelsMap.clear();
  356.         playerUpgradeLevelsMap.clear();
  357.         announcementsTasks.forEach(BukkitTask::cancel);
  358.         announcementsTasks.clear();
  359.         lastActivatedTraps.clear();
  360.         associatedTrapsGUI.clear();
  361.         hiddenPlayers.clear();
  362.         emeraldBoostDrops.forEach(BukkitTask::cancel);
  363.         emeraldBoostDrops.clear();
  364.         experienceManager.stopRewardTask();
  365.         destroyMap();
  366.         try {
  367.             finalize();
  368.         } catch (final Throwable e) {
  369.             e.printStackTrace();
  370.         }
  371.     }
  372.  
  373.     public final SpawnPosition getTeamSpawn(final BedwarsTeam bedwarsTeam) {
  374.         for (final TeamSpawnPosition mapSpawn : bedwarsGame.getMapSpawns()) {
  375.             if (mapSpawn.getBedwarsTeam() == bedwarsTeam) {
  376.                 return mapSpawn;
  377.             }
  378.         }
  379.         return null;
  380.     }
  381.  
  382.     public List<ActiveSpawner> getTeamSpawners(final BedwarsTeam team) {
  383.         double squaredDistanceGold = -1;
  384.         double squaredDistanceIron = -1;
  385.         ActiveSpawner nearestGold = null;
  386.         ActiveSpawner nearestIron = null;
  387.         for (ActiveSpawner activeSpawner : activeSpawners) {
  388.             if (activeSpawner.getType() == SpawnerType.GOLD) {
  389.                 final double tempDistance = activeSpawner.getSpawner().getSpawnPosition().squaredDistance(getTeamSpawn(team));
  390.                 if (nearestGold == null) {
  391.                     nearestGold = activeSpawner;
  392.                     squaredDistanceGold = tempDistance;
  393.                 } else if (squaredDistanceGold > tempDistance) {
  394.                     squaredDistanceGold = tempDistance;
  395.                     nearestGold = activeSpawner;
  396.                 }
  397.             } else if (activeSpawner.getType() == SpawnerType.IRON) {
  398.                 final double tempDistance = activeSpawner.getSpawner().getSpawnPosition().squaredDistance(getTeamSpawn(team));
  399.                 if (nearestIron == null) {
  400.                     nearestIron = activeSpawner;
  401.                     squaredDistanceIron = tempDistance;
  402.                 } else if (squaredDistanceIron > tempDistance) {
  403.                     squaredDistanceIron = tempDistance;
  404.                     nearestIron = activeSpawner;
  405.                 }
  406.             }
  407.         }
  408.  
  409.         final List<ActiveSpawner> s = new ArrayList<>();
  410.         s.add(nearestIron);
  411.         s.add(nearestGold);
  412.         return s;
  413.     }
  414.  
  415.     public void handleError(final String text) {
  416.         associatedQueue.perform(p -> p.sendMessage(Bedwars.PREFIX + "§c" + text));
  417.     }
  418.  
  419.     public void moveToLobby(final Player player) {
  420.         player.teleport(cachedLobbySpawnLocation);
  421.     }
  422.  
  423.     public void moveAllToLobby() {
  424.         associatedWorld.getPlayers().forEach(p -> {
  425.             GameUtils.clearAllEffects(p);
  426.             p.setGameMode(GameMode.SURVIVAL);
  427.             p.setFallDistance(0.100f);
  428.             GameUtils.clearArmor(p);
  429.             p.getInventory().clear();
  430.             p.teleport(getCachedLobbySpawnLocation());
  431.             p.setAllowFlight(false);
  432.             p.setFlying(false);
  433.         });
  434.     }
  435.  
  436.     public void connectedToQueue(final Player player) {
  437.         associatedQueue.perform(p -> {
  438.             p.sendMessage(Bedwars.PREFIX + player.getName() + AllStrings.JOINED_QUEUE.get() + getAssociatedWorld().getName() + " §r§equeue");
  439.             p.sendMessage(Bedwars.PREFIX + String.format(AllStrings.QUEUE_STATUS.get(), getAssociatedQueue().queueSize() + 1, getBedwarsGame().getPlayers()));
  440.         });
  441.     }
  442.  
  443.     public void registerMapListeners() {
  444.         final UnregisterableListener mapProtectionListener = new MapProtectionListener(this);
  445.         final UnregisterableListener mapIllegalMovementsListener = new MapIllegalMovementsListener(this);
  446.         final UnregisterableListener bedDestroyListener = new BedBreakListener(this);
  447.         final UnregisterableListener lobbyCompassListener = new LobbyCompassListener(this);
  448.         final UnregisterableListener deathListener = new PlayerDeathListener2(this);
  449.         final UnregisterableListener quitListener = new PlayerQuitDuringGameListener(this);
  450.         final UnregisterableListener merchantListener = new ShopMerchantListener(this);
  451.         final UnregisterableListener entityDamageListener = new EntityDamageListener(this);
  452.         final UnregisterableListener hungerLossListener = new HungerLossListener(this);
  453.         final UnregisterableListener spectatorInteractListener = new SpectatorsInteractListener(this);
  454.         final UnregisterableListener tntPlaceListener = new TNTPlaceListener(this);
  455.         final UnregisterableListener fireballInteract = new PlayerFireballInteractListener(this);
  456.         final UnregisterableListener explosionListener = new ExplosionListener(this);
  457.         final UnregisterableListener shopListener = new ShopInteractListener(this);
  458.         final UnregisterableListener upgradeMerchantListener = new UpgradeMerchantListener(this);
  459.         final UnregisterableListener upgradeInteractListener = new UpgradeInteractListener(this);
  460.         final UnregisterableListener spawnersMultigiveListener = new SpawnersMultigiveListener(this);
  461.         final UnregisterableListener itemDegradeListener = new ItemDegradeListener(this);
  462.         final UnregisterableListener playerSpectatePlayerListener = new PlayerSpectatePlayerListener(this);
  463.         final UnregisterableListener potionModifyListener = new PotionModifyListener(this);
  464.         final UnregisterableListener chestInteractListener = new ChestInteractListener(this);
  465.         final UnregisterableListener dingSound = new KillSoundListener(this);
  466.  
  467.         final PluginManager pluginManager = plugin.getServer().getPluginManager();
  468.  
  469.         pluginManager.registerEvents(mapProtectionListener, plugin);
  470.         pluginManager.registerEvents(mapIllegalMovementsListener, plugin);
  471.         pluginManager.registerEvents(bedDestroyListener, plugin);
  472.         pluginManager.registerEvents(lobbyCompassListener, plugin);
  473.         pluginManager.registerEvents(deathListener, plugin);
  474.         pluginManager.registerEvents(quitListener, plugin);
  475.         pluginManager.registerEvents(merchantListener, plugin);
  476.         pluginManager.registerEvents(entityDamageListener, plugin);
  477.         pluginManager.registerEvents(hungerLossListener, plugin);
  478.         pluginManager.registerEvents(spectatorInteractListener, plugin);
  479.         pluginManager.registerEvents(tntPlaceListener, plugin);
  480.         pluginManager.registerEvents(fireballInteract, plugin);
  481.         pluginManager.registerEvents(explosionListener, plugin);
  482.         pluginManager.registerEvents(shopListener, plugin);
  483.         pluginManager.registerEvents(upgradeMerchantListener, plugin);
  484.         pluginManager.registerEvents(upgradeInteractListener, plugin);
  485.         pluginManager.registerEvents(spawnersMultigiveListener, plugin);
  486.         pluginManager.registerEvents(itemDegradeListener, plugin);
  487.         pluginManager.registerEvents(playerSpectatePlayerListener, plugin);
  488.         pluginManager.registerEvents(potionModifyListener, plugin);
  489.         pluginManager.registerEvents(chestInteractListener, plugin);
  490.         pluginManager.registerEvents(dingSound, plugin);
  491.  
  492.         unregisterableListeners.add(mapIllegalMovementsListener);
  493.         unregisterableListeners.add(mapProtectionListener);
  494.         unregisterableListeners.add(bedDestroyListener);
  495.         unregisterableListeners.add(lobbyCompassListener);
  496.         unregisterableListeners.add(deathListener);
  497.         unregisterableListeners.add(quitListener);
  498.         unregisterableListeners.add(merchantListener);
  499.         unregisterableListeners.add(entityDamageListener);
  500.         unregisterableListeners.add(hungerLossListener);
  501.         unregisterableListeners.add(spectatorInteractListener);
  502.         unregisterableListeners.add(tntPlaceListener);
  503.         unregisterableListeners.add(fireballInteract);
  504.         unregisterableListeners.add(explosionListener);
  505.         unregisterableListeners.add(shopListener);
  506.         unregisterableListeners.add(upgradeMerchantListener);
  507.         unregisterableListeners.add(upgradeInteractListener);
  508.         unregisterableListeners.add(spawnersMultigiveListener);
  509.         unregisterableListeners.add(itemDegradeListener);
  510.         unregisterableListeners.add(playerSpectatePlayerListener);
  511.         unregisterableListeners.add(potionModifyListener);
  512.         unregisterableListeners.add(chestInteractListener);
  513.         unregisterableListeners.add(dingSound);
  514.     }
  515.  
  516.     public final void unregisterAllListeners() {
  517.         for (final UnregisterableListener unregisterableListener : unregisterableListeners) {
  518.             if (!unregisterableListener.isUnregistered()) {
  519.                 unregisterableListener.unregister();
  520.             }
  521.         }
  522.     }
  523.  
  524.     public void moveToWaitingRoom(final Player player) {
  525.         if (cachedWaitingLocation != null) {
  526.             if (player.teleport(cachedWaitingLocation)) {
  527.                 connectedToQueue(player);
  528.                 player.setGameMode(GameMode.ADVENTURE);
  529.             }
  530.         } else
  531.             player.sendMessage(Bedwars.PREFIX + AllStrings.TELEPORT_ERROR.get());
  532.     }
  533.  
  534.     public BedwarsTeam getPlayerTeam(final Player player) {
  535.         for (final Map.Entry<BedwarsTeam, List<Player>> entry : assignedTeams.entrySet()) {
  536.             if (entry.getValue().contains(player)) {
  537.                 return entry.getKey();
  538.             }
  539.         }
  540.         return null;
  541.     }
  542.  
  543.     public boolean isMerchantVillager(final Villager villager) {
  544.         for (AbstractActiveMerchant activeMerchant : getActiveMerchants())
  545.             if (activeMerchant.getVillager() == villager)
  546.                 return true;
  547.         return false;
  548.     }
  549.  
  550.     private void createPlayerShops() {
  551.         for (final Map.Entry<BedwarsTeam, List<Player>> entry : assignedTeams.entrySet()) {
  552.             for (Player p : entry.getValue()) {
  553.                 final EnumMap<ShopCategory, Inventory> pInvMap = new EnumMap<>(ShopCategory.class);
  554.                 for (ShopCategory value : ShopCategory.values()) {
  555.                     pInvMap.put(value, cloneInventory(shopInventories.getFromCategory(value)));
  556.                 }
  557.                 this.playerShop.put(p.getUniqueId(), pInvMap);
  558.             }
  559.         }
  560.     }
  561.  
  562.  
  563.     public void start() {
  564.         setHasStarted(true);
  565.         if (associatedQueue.queueSize() >= bedwarsGame.getMinPlayers()) {
  566.             if (associatedWorld == null) {
  567.                 handleError(AllStrings.TELEPORT_ERROR.get());
  568.                 return;
  569.             }
  570.  
  571.             assignTeams();
  572.             createPlayerShops();
  573.             cleanAll();
  574.             assignScoreboards();
  575.             createSpawners();
  576.             createMerchants();
  577.             moveTeamsToSpawns();
  578.             fillUpgradeMaps();
  579.             setupUpgradeLevelsMap();
  580.             announceNoTeaming();
  581.             healAll();
  582.             giveAllDefaultSet();
  583.             fillTraps();
  584.             fillTrapsDelayMap();
  585.             breakNonPlayingBeds();
  586.             showAll();
  587.             gameTrapTriggerer.start();
  588.             abstractDeathmatch.start();
  589.             experienceManager.startRewardTask();
  590.             this.startTime = System.currentTimeMillis();
  591.         }
  592.     }
  593.  
  594.     public void cleanAll() {
  595.         assignedTeams.values().stream().flatMap(Collection::stream).forEach(p -> {
  596.             if (p.isOnline()) {
  597.                 p.getInventory().clear();
  598.             }
  599.         });
  600.     }
  601.  
  602.     public final void fillTrapsDelayMap() {
  603.         final long time = System.currentTimeMillis();
  604.         for (final Map.Entry<BedwarsTeam, List<Player>> entry : assignedTeams.entrySet()) {
  605.             getLastActivatedTraps().put(entry.getKey(), time);
  606.         }
  607.     }
  608.  
  609.     public final void fillTraps() {
  610.         for (final Map.Entry<BedwarsTeam, List<Player>> entry : assignedTeams.entrySet()) {
  611.             this.getTeamActiveTrapsList().put(entry.getKey(), new LinkedList<>());
  612.         }
  613.     }
  614.  
  615.     public final void fillUpgradeMaps() {
  616.  
  617.         for (final UpgradeType upgradeType : UpgradeType.values()) {
  618.             final Map<BedwarsTeam, Integer> teamIntegerMap = new HashMap<>();
  619.             for (final BedwarsTeam bedwarsTeam : assignedTeams.keySet())
  620.                 teamIntegerMap.put(bedwarsTeam, 0x00);
  621.             this.upgradesLevelsMap.put(upgradeType, teamIntegerMap);
  622.         }
  623.  
  624.     }
  625.  
  626.     public final void healAll() {
  627.         associatedWorld.getPlayers().forEach(p -> {
  628.             p.setHealth(p.getMaxHealth());
  629.             p.setFoodLevel(0x14);
  630.         });
  631.     }
  632.  
  633.     public abstract void moveTeamsToSpawns();
  634.  
  635.     public void givePlayerDefaultSet(final Player player) {
  636.  
  637.         final ArmorSet startingSet = new ArmorSet(Objects.requireNonNull(getPlayerTeam(player)));
  638.         startingSet.getArmorSet().forEach((k, v) -> Slots.setArmorPiece(k, player, startingSet.getArmorSet().get(k)));
  639.         GameUtils.giveStackToPlayer(new ItemStack(Material.WOOD_SWORD, 1), player, player.getInventory().getContents());
  640.         this.playerSetMap.put(player, startingSet);
  641.     }
  642.  
  643.     public void giveAllDefaultSet() {
  644.         associatedQueue.perform(this::givePlayerDefaultSet);
  645.     }
  646.  
  647.     public void removePlayer(final Player p) {
  648.         associatedQueue.removeFromQueue(p);
  649.     }
  650.  
  651.     public BedwarsTeam findWinningTeam() {
  652.         if (teamsLeft().size() == 1) {
  653.             return teamsLeft().stream().findAny().get();
  654.         } else {
  655.             return null;
  656.         }
  657.     }
  658.  
  659.     public List<Player> getTeamPlayers(final BedwarsTeam bedwarsTeam) {
  660.         for (final Map.Entry<BedwarsTeam, List<Player>> entry : assignedTeams.entrySet()) {
  661.             if (entry.getKey() == bedwarsTeam)
  662.                 return entry.getValue();
  663.         }
  664.         return null;
  665.     }
  666.  
  667.     public final Set<BedwarsTeam> teamsLeft() {
  668.         if (playersOutOfGame.isEmpty()) return Collections.emptySet();
  669.         final Set<BedwarsTeam> bedwarsTeams = new HashSet<>();
  670.         for (final Map.Entry<BedwarsTeam, List<Player>> entry : assignedTeams.entrySet()) {
  671.             final BedwarsTeam team = entry.getKey();
  672.             final List<Player> playerSet = entry.getValue();
  673.             final boolean isTeamOutOfGame = playersOutOfGame.containsAll(playerSet);
  674.             if (!isTeamOutOfGame) {
  675.                 bedwarsTeams.add(team);
  676.             }
  677.         }
  678.         return bedwarsTeams;
  679.     }
  680.  
  681.     public void breakNonPlayingBeds() {
  682.         final Set<BedwarsTeam> bedwarsTeams = assignedTeams.keySet();
  683.         for (final BedwarsTeam team : BedwarsTeam.values()) {
  684.             if (!bedwarsTeams.contains(team)) {
  685.  
  686.                 final SpawnPosition posOfTeam = bedwarsGame.spawnPosOfTeam(team);
  687.                 SpawnPosition nearestBed = null;
  688.                 double sqdDist = -1;
  689.                 for (final SpawnPosition bedSpawnPosition : bedwarsGame.getBedSpawnPositions()) {
  690.                     final double tempSqdDist = posOfTeam.squaredDistance(bedSpawnPosition);
  691.                     if (nearestBed == null) {
  692.                         nearestBed = bedSpawnPosition;
  693.                         sqdDist = tempSqdDist;
  694.                     } else if (tempSqdDist <= sqdDist) {
  695.                         nearestBed = bedSpawnPosition;
  696.                         sqdDist = tempSqdDist;
  697.                     }
  698.                 }
  699.                 if (nearestBed != null) {
  700.                     final Location bedLoc = nearestBed.toLocation(associatedWorld);
  701.                     final Block block = bedLoc.getBlock();
  702.                     if (block != null && block.getType() == Material.BED) {
  703.                         final Bed b = (Bed) block.getState().getData();
  704.                         final Block facing = block.getRelative(b.getFacing());
  705.                         block.setType(Material.AIR);
  706.                         facing.setType(Material.AIR);
  707.                     }
  708.                 }
  709.             }
  710.         }
  711.     }
  712.  
  713.     @SuppressWarnings("deprecation")
  714.     public void declareWinner(final BedwarsTeam team) {
  715.         if (winnerDeclared) {
  716.             return;
  717.         }
  718.  
  719.         final UnregisterableListener goodGameListener = new GoodGameListener(this);
  720.         plugin.getServer().getPluginManager().registerEvents(goodGameListener, plugin);
  721.         unregisterableListeners.add(goodGameListener);
  722.  
  723.         associatedQueue.perform(p -> {
  724.             if (p.isOnline()) {
  725.                 final BedwarsTeam pTeam = getPlayerTeam(p);
  726.                 if (pTeam == team) {
  727.                     p.sendTitle(AllStrings.YOU_WON_GAME.get(), AllStrings.CONGRATULATIONS.get());
  728.                     p.playSound(p.getLocation(), Sound.FIREWORK_TWINKLE, 7.50f, 1.00f);
  729.                     ExperienceManager.rewardPlayer(bedwarsGame.getGamemode() == Gamemode.QUAD ? 50 : 100, p, this);
  730.                     questManager.winDailyFirstGame(p);
  731.                     GlobalStatsTableUtils.increaseWin(bedwarsGame.getGamemode(), plugin, p.getUniqueId());
  732.                 } else {
  733.                     p.sendTitle(AllStrings.HAS_WON_THE_GAME.get(), AllStrings.RETURNING_LOBBY.get());
  734.                 }
  735.                 questManager.gamePlayedReward(p);
  736.             }
  737.         });
  738.  
  739.         killTracker.announceTopThreeScores();
  740.  
  741.         this.winnerDeclared = true;
  742.     }
  743.  
  744.     public void stop() {
  745.         moveAllToLobby();
  746.         cleanAllAndFinalize();
  747.     }
  748.  
  749.     public abstract void assignTeams();
  750.  
  751.     public abstract void assignScoreboards();
  752.  
  753.     public void createSpawners() {
  754.         for (final ActiveSpawner activeSpawner : getActiveSpawners()) {
  755.             activeSpawner.spawn();
  756.             if (this.diamondSampleSpawner == null) {
  757.                 if (activeSpawner.getType() == SpawnerType.DIAMOND) {
  758.                     this.diamondSampleSpawner = activeSpawner;
  759.                 }
  760.             }
  761.             if (this.emeraldSampleSpawner == null) {
  762.                 if (activeSpawner.getType() == SpawnerType.EMERALD) {
  763.                     this.emeraldSampleSpawner = activeSpawner;
  764.                 }
  765.             }
  766.         }
  767.         if (this.diamondSampleSpawner != null && this.emeraldSampleSpawner != null) {
  768.             diamondSampleSpawner.getSpawner()
  769.                     .getSpawnerLevels()
  770.                     .stream()
  771.                     .filter(lvl -> lvl.getLevel() != 1)
  772.                     .forEach(i -> this.announcementsTasks.add(plugin.getServer().getScheduler()
  773.                             .runTaskLater(plugin, () -> getAssociatedWorld()
  774.                                     .getPlayers()
  775.                                     .forEach(p -> p.sendMessage(Bedwars.PREFIX + AllStrings.DIAMOND_UPGRADE.get() + i.getLevel())), i.getAfterSeconds() * 20L)));
  776.  
  777.             emeraldSampleSpawner.getSpawner()
  778.                     .getSpawnerLevels()
  779.                     .stream()
  780.                     .filter(lvl -> lvl.getLevel() != 1)
  781.                     .forEach(i -> this.announcementsTasks.add(plugin.getServer().getScheduler()
  782.                             .runTaskLater(plugin, () -> getAssociatedWorld()
  783.                                     .getPlayers()
  784.                                     .forEach(p -> p.sendMessage(Bedwars.PREFIX + AllStrings.EMERALD_UPGRADE.get() + i.getLevel())), i.getAfterSeconds() * 20L)));
  785.         }
  786.     }
  787.  
  788.     public void upgradePlayerArmorSet(final Player player, final String type) {
  789.         final ArmorSet pSet = playerSetMap.get(player);
  790.         pSet.upgradeAll(type);
  791.         pSet.getArmorSet().forEach((k, v) -> Slots.setArmorPiece(k, player, pSet.getArmorSet().get(k)));
  792.     }
  793.  
  794.     public void downgradePlayerTools(final Player player) {
  795.         final Map<UpgradeItem, Integer> map = this.getPlayerUpgradeLevelsMap().get(player);
  796.  
  797.         out:
  798.         for (Map.Entry<UpgradeItem, Integer> entry : map.entrySet()) {
  799.             final UpgradeItem item = entry.getKey();
  800.             final int level = entry.getValue();
  801.             if (level > 0) {
  802.                 final List<UpgradeLevel> lvls = item.getLevels();
  803.                 map.put(item, level - 1);
  804.                 final ItemStack originalShopItem = lvls.get(level).getCachedFancyStack();
  805.                 final ItemStack downgradedItem = lvls.get(level - 1).getCachedGameStack();
  806.                 GameUtils.upgradePlayerStack(player, lvls.get(level).getCachedGameStack(), downgradedItem);
  807.                 for (Inventory inventory : playerShop.get(player.getUniqueId()).values()) {
  808.                     final ItemStack[] contents = inventory.getContents();
  809.                     for (int i = 0; i < contents.length; i++) {
  810.                         final ItemStack content = contents[i];
  811.                         if (content != null && content.isSimilar(originalShopItem)) {
  812.                             inventory.setItem(i, lvls.get(level - 1).getCachedFancyStack());
  813.                             continue out;
  814.                         }
  815.                     }
  816.                 }
  817.             }
  818.             player.updateInventory();
  819.         }
  820.     }
  821.  
  822.     public boolean isOutOfGame(final Player p) {
  823.         if (p != null) {
  824.             return playersOutOfGame.contains(p);
  825.         }
  826.         return true;
  827.     }
  828.  
  829.     public void destroyMap() {
  830.         final File wDir = associatedWorld.getWorldFolder();
  831.         try {
  832.             plugin.getServer().unloadWorld(associatedWorld, false);
  833.             WorldsManager.getInstanceUnsafe().getActiveGameList().remove(this);
  834.             FileUtils.deleteDirectory(wDir);
  835.         } catch (IOException e) {
  836.             plugin.getLogger().severe(AllStrings.DESTROY_MAP_ERROR.get() + associatedWorldFilename);
  837.             e.printStackTrace();
  838.         }
  839.     }
  840.  
  841.     public void createMerchants() {
  842.         for (final Merchant merchant : bedwarsGame.getMerchants()) {
  843.             final AbstractActiveMerchant aMerchant = GameUtils.fromMerchant(merchant, this);
  844.             if (aMerchant == null) {
  845.                 continue;
  846.             }
  847.             aMerchant.spawn();
  848.             this.activeMerchants.add(aMerchant);
  849.         }
  850.     }
  851.  
  852.     protected String getTeamChar(final BedwarsTeam t) {
  853.         if (destroyedTeams.contains(t) || abstractDeathmatch.isRunning()) {
  854.             final List<Player> teamMembers = getTeamPlayers(t);
  855.             if (teamMembers.stream().allMatch(this::isOutOfGame)) {
  856.                 return AllStrings.GRAPHIC_CROSS.get();
  857.             } else {
  858.                 return " §f§l" + teamMembers.stream().filter(p -> !isOutOfGame(p)).count();
  859.             }
  860.         } else {
  861.             return AllStrings.GRAPHIC_TICK.get();
  862.         }
  863.     }
  864.  
  865.     public ShopActiveMerchant getTeamShopActiveMerchant(final Villager clickedVillager) {
  866.         for (final AbstractActiveMerchant activeMerchant : activeMerchants) {
  867.             if (activeMerchant.getMerchant().getMerchantType() == MerchantType.SHOP) {
  868.                 if (activeMerchant.getVillager().getUniqueId().equals(clickedVillager.getUniqueId())) {
  869.                     return (ShopActiveMerchant) activeMerchant;
  870.                 }
  871.             }
  872.         }
  873.         return null;
  874.     }
  875.  
  876.     public UpgradeActiveMerchant getTeamUpgradeActiveMerchant(final Villager clickedVillager) {
  877.         for (final AbstractActiveMerchant activeMerchant : activeMerchants) {
  878.             if (activeMerchant.getMerchant().getMerchantType() == MerchantType.UPGRADE) {
  879.                 if (activeMerchant.getVillager().getUniqueId().equals(clickedVillager.getUniqueId())) {
  880.                     return (UpgradeActiveMerchant) activeMerchant;
  881.                 }
  882.             }
  883.         }
  884.         return null;
  885.     }
  886.  
  887.     public static Inventory cloneInventory(final Inventory inv) {
  888.         final Inventory inventory = Bukkit.createInventory(null, inv.getSize(), inv.getTitle());
  889.         final ItemStack[] originalContents = inv.getContents();
  890.         for (int i = 0; i < originalContents.length; i++) {
  891.             final ItemStack o = originalContents[i];
  892.             if (o == null) {
  893.                 continue;
  894.             }
  895.             inventory.setItem(i, o.clone());
  896.         }
  897.         return inventory;
  898.     }
  899.  
  900.     public void openUpgrade(final Player player) {
  901.         if (!this.associatedUpgradeGUI.containsKey(player.getUniqueId())) {
  902.             final Inventory associated = cloneInventory(Objects.requireNonNull(this.defaultUpgradeInv));
  903.             associatedUpgradeGUI.put(player.getUniqueId(), associated);
  904.         }
  905.         player.openInventory(this.associatedUpgradeGUI.get(player.getUniqueId()));
  906.     }
  907.  
  908.     public void openTraps(final Player player) {
  909.         if (!this.associatedTrapsGUI.containsKey(player.getUniqueId())) {
  910.             final Inventory associated = cloneInventory(Objects.requireNonNull(this.defaultTrapsInv));
  911.             associatedTrapsGUI.put(player.getUniqueId(), associated);
  912.         }
  913.         player.openInventory(this.associatedTrapsGUI.get(player.getUniqueId()));
  914.     }
  915.  
  916.     public final List<UnregisterableListener> getUnregisterableListeners() {
  917.         return unregisterableListeners;
  918.     }
  919.  
  920.     public final BedwarsGame getBedwarsGame() {
  921.         return bedwarsGame;
  922.     }
  923.  
  924.     public final String getAssociatedWorldFilename() {
  925.         return associatedWorldFilename;
  926.     }
  927.  
  928.     public final Location getCachedWaitingLocation() {
  929.         return cachedWaitingLocation;
  930.     }
  931.  
  932.     public final World getAssociatedWorld() {
  933.         return associatedWorld;
  934.     }
  935.  
  936.     public final Set<Block> getPlayerPlacedBlocks() {
  937.         return playerPlacedBlocks;
  938.     }
  939.  
  940.     public final World getLobbyWorld() {
  941.         return lobbyWorld;
  942.     }
  943.  
  944.     public final List<Player> getPlayersOutOfGame() {
  945.         return playersOutOfGame;
  946.     }
  947.  
  948.     public final SwordUpgrades getSwordUpgrades() {
  949.         return swordUpgrades;
  950.     }
  951.  
  952.     public final Location getCachedLobbySpawnLocation() {
  953.         return cachedLobbySpawnLocation;
  954.     }
  955.  
  956.     public final Plugin getPlugin() {
  957.         return plugin;
  958.     }
  959.  
  960.     public final AbstractQueue<Player> getAssociatedQueue() {
  961.         return associatedQueue;
  962.     }
  963.  
  964.     public final Set<ActiveSpawner> getActiveSpawners() {
  965.         return activeSpawners;
  966.     }
  967.  
  968.     public final List<AbstractActiveMerchant> getActiveMerchants() {
  969.         return activeMerchants;
  970.     }
  971.  
  972.     public final List<BedwarsTeam> getDestroyedTeams() {
  973.         return destroyedTeams;
  974.     }
  975.  
  976.     public final boolean isWinnerDeclared() {
  977.         return winnerDeclared;
  978.     }
  979.  
  980.     public final boolean isHasStarted() {
  981.         return hasStarted;
  982.     }
  983.  
  984.     public final Map<BedwarsTeam, List<Player>> getAssignedTeams() {
  985.         return assignedTeams;
  986.     }
  987.  
  988.     public Map<Player, Scoreboard> getActiveScoreboards() {
  989.         return activeScoreboards;
  990.     }
  991.  
  992.     public final BukkitTask getTimerTask() {
  993.         return timerTask;
  994.     }
  995.  
  996.     public final void setHasStarted(boolean hasStarted) {
  997.         this.hasStarted = hasStarted;
  998.     }
  999.  
  1000.     public final Map<Player, ArmorSet> getPlayerSetMap() {
  1001.         return playerSetMap;
  1002.     }
  1003.  
  1004.     public final GameLobbyTicker getGameLobbyTicker() {
  1005.         return gameLobbyTicker;
  1006.     }
  1007.  
  1008.     public final Map<String, Integer> getTopKills() {
  1009.         return topKills;
  1010.     }
  1011.  
  1012.     public EnumMap<UpgradeType, Map<BedwarsTeam, Integer>> getUpgradesLevelsMap() {
  1013.         return upgradesLevelsMap;
  1014.     }
  1015.  
  1016.     public final ScoreboardHandler getScoreboardHandler() {
  1017.         return scoreboardHandler;
  1018.     }
  1019.  
  1020.     public Map<UUID, EnumMap<ShopCategory, Inventory>> getPlayerShop() {
  1021.         return playerShop;
  1022.     }
  1023.  
  1024.     public final Map<Player, Map<UpgradeItem, Integer>> getPlayerUpgradeLevelsMap() {
  1025.         return playerUpgradeLevelsMap;
  1026.     }
  1027.  
  1028.     public final Inventory getDefaultUpgradeInv() {
  1029.         return defaultUpgradeInv;
  1030.     }
  1031.  
  1032.     public final Map<UUID, Inventory> getAssociatedUpgradeGUI() {
  1033.         return associatedUpgradeGUI;
  1034.     }
  1035.  
  1036.     public final AbstractDeathmatch getAbstractDeathmatch() {
  1037.         return abstractDeathmatch;
  1038.     }
  1039.  
  1040.     public final ActiveSpawner getDiamondSampleSpawner() {
  1041.         return this.diamondSampleSpawner;
  1042.     }
  1043.  
  1044.     public final ActiveSpawner getEmeraldSampleSpawner() {
  1045.         return this.emeraldSampleSpawner;
  1046.     }
  1047.  
  1048.     public final long getStartTime() {
  1049.         return startTime;
  1050.     }
  1051.  
  1052.     public final List<ActiveHealPool> getHealPools() {
  1053.         return healPools;
  1054.     }
  1055.  
  1056.     public final Inventory getDefaultTrapsInv() {
  1057.         return defaultTrapsInv;
  1058.     }
  1059.  
  1060.     public final List<BukkitTask> getAnnouncementsTasks() {
  1061.         return announcementsTasks;
  1062.     }
  1063.  
  1064.     public final Map<UUID, Inventory> getAssociatedTrapsGUI() {
  1065.         return associatedTrapsGUI;
  1066.     }
  1067.  
  1068.     public final EnumMap<BedwarsTeam, LinkedList<ActiveTrap>> getTeamActiveTrapsList() {
  1069.         return teamActiveTrapsList;
  1070.     }
  1071.  
  1072.     public final EnumMap<BedwarsTeam, Long> getLastActivatedTraps() {
  1073.         return lastActivatedTraps;
  1074.     }
  1075.  
  1076.     public final List<Player> getImmuneTrapPlayers() {
  1077.         return immuneTrapPlayers;
  1078.     }
  1079.  
  1080.     public final List<Player> getPlayersRespawning() {
  1081.         return playersRespawning;
  1082.     }
  1083.  
  1084.     public final List<Player> getHiddenPlayers() {
  1085.         return hiddenPlayers;
  1086.     }
  1087.  
  1088.     public final GameTrapTriggerer getGameTrapTriggerer() {
  1089.         return gameTrapTriggerer;
  1090.     }
  1091.  
  1092.     public final QuestManager getQuestManager() {
  1093.         return questManager;
  1094.     }
  1095.  
  1096.     public final ExperienceManager getExperienceManager() {
  1097.         return experienceManager;
  1098.     }
  1099.  
  1100.     public final EnderchestManager getEnderchestManager() {
  1101.         return enderchestManager;
  1102.     }
  1103.  
  1104.     public final List<BukkitTask> getEmeraldBoostDrops() {
  1105.         return emeraldBoostDrops;
  1106.     }
  1107.  
  1108.     public final Map<UUID, UUID> getPlacedTntMap() {
  1109.         return placedTntMap;
  1110.     }
  1111.  
  1112.     public final KillTracker getKillTracker() {
  1113.         return killTracker;
  1114.     }
  1115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement