From 0a3f942575c5166932de15af4725bd2476cf6ebe Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Sun, 18 Oct 2015 12:42:56 -0400 Subject: [PATCH] Fix compile issue --- .../game/clans/clans/ClansManager.java | 263 ++++++++++-------- 1 file changed, 154 insertions(+), 109 deletions(-) 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 c8b64cba3..1c9244a7b 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 @@ -2,6 +2,7 @@ package mineplex.game.clans.clans; import java.util.HashSet; import java.util.TimeZone; +import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -38,12 +39,15 @@ 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.common.util.UtilWorld; import mineplex.core.creature.Creature; import mineplex.core.creature.event.CreatureSpawnCustomEvent; import mineplex.core.disguise.DisguiseManager; import mineplex.core.donation.DonationManager; import mineplex.core.energy.Energy; import mineplex.core.explosion.Explosion; +import mineplex.core.gui.SimpleGuiItem; +import mineplex.core.hologram.HologramManager; import mineplex.core.movement.Movement; import mineplex.core.npc.NpcManager; import mineplex.core.packethandler.PacketHandler; @@ -63,6 +67,7 @@ import mineplex.game.clans.clans.event.ClansPlayerDeathEvent; import mineplex.game.clans.clans.loot.LootManager; import mineplex.game.clans.clans.map.ItemMapManager; import mineplex.game.clans.clans.murder.MurderManager; +import mineplex.game.clans.clans.observer.ObserverManager; import mineplex.game.clans.clans.redis.ClanDeleteCommandHandler; import mineplex.game.clans.clans.redis.ClanLoadCommandHandler; import mineplex.game.clans.clans.regions.ClansRegions; @@ -99,7 +104,11 @@ import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; import mineplex.minecraft.game.core.fire.Fire; import mineplex.minecraft.game.core.mechanics.Weapon; +import mineplex.serverdata.Region; import mineplex.serverdata.commands.ServerCommandManager; +import mineplex.serverdata.redis.RedisDataRepository; +import mineplex.serverdata.servers.ConnectionData; +import mineplex.serverdata.servers.ServerManager; public class ClansManager extends MiniClientPlugin implements IRelation { @@ -110,7 +119,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat public static ClansManager getInstance() { return _instance; } private String _serverName; - + private CoreClientManager _clientManager; private CombatManager _combatManager; private ClansUtility _clanUtility; @@ -125,10 +134,13 @@ public class ClansManager extends MiniClientPlugin implements IRelat private Teleport _teleport; private ConditionManager _condition; private ClassCombatShop _classShop; - + private HologramManager _hologramManager; + private GearManager _gearManager; + private LootManager _lootManager; + private ClassManager _classManager; public ClassManager getClassManager() { return _classManager; } - + private WarManager _warManager; private ProjectileManager _projectileManager; private WorldEventManager _worldEvent; @@ -138,7 +150,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat private NpcManager _npcManager; private Explosion _explosion; private GoldManager _goldManager; - + private int _inviteExpire = 2; private int _nameMin = 3; private int _nameMax = 10; @@ -147,38 +159,41 @@ public class ClansManager extends MiniClientPlugin implements IRelat //Clans private NautHashMap _clanMap = new NautHashMap(); - private NautHashMap _clanMemberMap = new NautHashMap(); + // private NautHashMap _clanMemberNameMap = new NautHashMap(); + private NautHashMap _clanMemberUuidMap = new NautHashMap(); private NautHashMap _claimMap = new NautHashMap(); private NautHashMap _unclaimMap = new NautHashMap(); - + // Spawn area - + public String[] denyClan = new String[] { "neut", "neutral", "sethome", "promote", "demote", "admin", "help", "create", "disband", "delete", "invite", "join", "kick", "ally", "trust", "claim", "unclaim", "territory", "home"}; - - public ClansManager(JavaPlugin plugin, String serverName, CoreClientManager clientManager, DonationManager donationManager, BlockRestore blockRestore, Teleport teleport, Chat chat, GearManager gearManager, String webServerAddress) + + public ClansManager(JavaPlugin plugin, String serverName, CoreClientManager clientManager, DonationManager donationManager, BlockRestore blockRestore, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress) { super("Clans Manager", plugin); - + _instance = this; _serverName = serverName; _clientManager = clientManager; _combatManager = new CombatManager(plugin); - + _hologramManager = hologramManager; + _chat = chat; _blockRestore = blockRestore; _teleport = teleport; _warManager = new WarManager(plugin, this); _goldManager = new GoldManager(this, _clientManager, donationManager); - LootManager lootManager = new LootManager(gearManager, _goldManager); + _gearManager = gearManager; + _lootManager = new LootManager(gearManager, _goldManager); PacketHandler packetHandler = new PacketHandler(plugin); _disguiseManager = new DisguiseManager(plugin, packetHandler); Creature creature = new Creature(plugin); _npcManager = new NpcManager(plugin, creature); _condition = new SkillConditionManager(plugin); DamageManager damageManager = new DamageManager(plugin, _combatManager, _npcManager, _disguiseManager, _condition); - _worldEvent = new WorldEventManager(plugin, this, damageManager, lootManager, blockRestore); + _worldEvent = new WorldEventManager(plugin, this, damageManager, _lootManager, blockRestore); _scoreboard = new ClansScoreboardManager(plugin, this, _warManager, _worldEvent, clientManager, donationManager); new MurderManager(plugin, this); @@ -196,56 +211,57 @@ public class ClansManager extends MiniClientPlugin implements IRelat _explosion = new Explosion(plugin, blockRestore); new ClansLoginManager(getPlugin(), clientManager, _serverName); - + Energy energy = new Energy(plugin); // TODO: Re-enable customtagfix with NCP update? //new CustomTagFix(plugin, packetHandler); new Field(plugin, creature, _condition, this, energy, serverName); - + // Required managers to be initialized new Spawn(plugin, this); new NPCManager(this); new LoggingManager(plugin, this); - + new ObserverManager(plugin, _condition, this); + new Weapon(plugin, energy); new Gameplay(plugin, this, blockRestore, damageManager); _projectileManager = new ProjectileManager(plugin); Fire fire = new Fire(plugin, _condition, damageManager); - + HashSet itemIgnore = new HashSet(); itemIgnore.add("Proximity Explosive"); itemIgnore.add("Proximity Zapper"); - + ItemFactory itemFactory = new ItemFactory(plugin, blockRestore, _condition, damageManager, energy, fire, _projectileManager, webServerAddress, itemIgnore); SkillFactory skillManager = new SkillFactory(plugin, damageManager, this, _combatManager, _condition, _projectileManager, _disguiseManager, blockRestore, fire, new Movement(plugin), teleport, energy, webServerAddress); skillManager.RemoveSkill("Dwarf Toss", "Block Toss"); skillManager.removeSkill("Whirlwind Axe"); skillManager.removeSkill("Shield Smash"); _classManager = new ClassManager(plugin, _clientManager, donationManager, skillManager, itemFactory, webServerAddress); - + // Register redis based server commands - ServerCommandManager.getInstance().registerCommandType(ClanDeleteCommand.class, new ClanDeleteCommandHandler()); + ServerCommandManager.getInstance().registerCommandType(ClanDeleteCommand.class, new ClanDeleteCommandHandler()); ServerCommandManager.getInstance().registerCommandType(ClanLoadCommand.class, new ClanLoadCommandHandler()); - + StatsManager statsManager = new StatsManager(plugin, _clientManager); AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, donationManager); - ClassShopManager shopManager = new ClassShopManager(plugin, _classManager, skillManager, itemFactory, achievementManager, _clientManager); - _classShop = new ClassCombatShop(shopManager, _clientManager, donationManager, true, "Class Shop"); + ClassShopManager shopManager = new ClassShopManager(plugin, _classManager, skillManager, itemFactory, achievementManager, _clientManager); + _classShop = new ClassCombatShop(shopManager, _clientManager, donationManager, true, "Class Shop"); ClanEnergyManager clanEnergyManager = new ClanEnergyManager(plugin, this, clientManager, donationManager); - + for (ClanToken token : _clanDataAccess.getRepository().retrieveClans()) { loadClan(token); } - + //RedisDataRepository(ConnectionData writeConn, ConnectionData readConn, Region region, Class elementType, String elementLabel) // Initialize default region factions and territory (spawn/fields/borderlands) _clanRegions = new ClansRegions(plugin, this); _clanRegions.initializeRegions(); } - + @Override public void addCommands() { @@ -256,29 +272,32 @@ public class ClansManager extends MiniClientPlugin implements IRelat addCommand(new ClanManagementCommand(this)); addCommand(new MapCommand(this)); } - + public void loadClan(ClanToken clanToken) { ClanInfo clan = new ClanInfo(this, clanToken); _clanMap.put(clanToken.Name, clan); - + for (ClanMemberToken memberToken : clanToken.Members) - _clanMemberMap.put(memberToken.Name, clan); - + { + _clanMemberUuidMap.put(memberToken.PlayerUUID, clan); +// _clanMemberMap.put(memberToken.Name, clan); + } + for (ClanTerritoryToken territoryToken : clanToken.Territories) _claimMap.put(territoryToken.Chunk, new ClanTerritory(territoryToken)); } - + public DisguiseManager getDisguiseManager() { return _disguiseManager; } - + public NpcManager getNPCManager() { return _npcManager; } - + public ClansRegions getClanRegions() { return _clanRegions; @@ -304,34 +323,34 @@ public class ClansManager extends MiniClientPlugin implements IRelat return _clanMap; } - public NautHashMap getClanMemberMap() + public NautHashMap getClanMemberUuidMap() { - return _clanMemberMap; + return _clanMemberUuidMap; } public static boolean isClaimable(Location location) { int x = Math.abs(location.getBlockX()); int z = Math.abs(location.getBlockZ()); - + return (x <= CLAIMABLE_RADIUS && z <= CLAIMABLE_RADIUS) && !Spawn.getInstance().isInSpawn(location); } - + public boolean isFields(Location location) { return getClanUtility().isSpecial(location, "Fields"); } - + public boolean canUnclaimChunk(ClanInfo stealer, ClanInfo owner) { return owner.getClaims() > owner.getClaimsMax() && !owner.isAdmin() && !owner.isAlly(stealer); } - + public ClanInfo getClan(Player player) { - return _clanMemberMap.get(player.getName()); + return _clanMemberUuidMap.get(player.getUniqueId()); } public ClanInfo getEnemy(ClanInfo clanInfo) @@ -347,14 +366,14 @@ public class ClansManager extends MiniClientPlugin implements IRelat public boolean isInClan(Player player) { - return _clanMemberMap.containsKey(player.getName()); + return _clanMemberUuidMap.containsKey(player.getUniqueId()); } public ClanInfo getClan(String clan) { return _clanMap.get(clan); } - + /** * @param clanName * @return true, if a Clan with matching {@code clanName} exists, false otherwise. @@ -371,19 +390,19 @@ public class ClansManager extends MiniClientPlugin implements IRelat public long lastPower = System.currentTimeMillis(); - + @EventHandler public void savePlayerActiveBuild(PlayerQuitEvent event) { if (_classManager.Get(event.getPlayer()) != null && _classManager.Get(event.getPlayer()).GetGameClass() != null) { CustomBuildToken activeBuild = _classManager.Get(event.getPlayer()).GetActiveCustomBuild(_classManager.Get(event.getPlayer()).GetGameClass()); - + if (activeBuild == null) return; - + activeBuild.PlayerName = event.getPlayer().getName(); - + // 0 is set aside for active build so we just dupe build to this row whenever we update it. activeBuild.CustomBuildNumber = 0; _classManager.GetRepository().SaveCustomBuild(activeBuild); @@ -400,14 +419,14 @@ public class ClansManager extends MiniClientPlugin implements IRelat event.setCancelled(true); } } - + @EventHandler(priority = EventPriority.HIGHEST) public void BlockCreatureSpawn(CreatureSpawnCustomEvent event) { ClanInfo clan = _clanUtility.getOwner(event.GetLocation()); - - if (clan != null && !clan.isAdmin() - && !clan.getName().equals("Spawn") && event.getReason() != SpawnReason.CUSTOM) + + if (clan != null && !clan.isAdmin() + && !clan.getName().equals("Spawn") && event.getReason() != SpawnReason.CUSTOM) { event.setCancelled(true); } @@ -423,7 +442,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat public void join(PlayerJoinEvent event) { Player player = event.getPlayer(); - ClanInfo clanInfo = getClanMemberMap().get(player.getName()); + ClanInfo clanInfo = _clanMemberUuidMap.get(player.getUniqueId()); if (clanInfo != null) { clanInfo.playerOnline(player); @@ -449,38 +468,38 @@ public class ClansManager extends MiniClientPlugin implements IRelat public void quit(PlayerQuitEvent event) { Player player = event.getPlayer(); - ClanInfo clanInfo = getClanMemberMap().get(player.getName()); + ClanInfo clanInfo = getClanMemberUuidMap().get(player.getUniqueId()); if (clanInfo != null) { clanInfo.playerOffline(player); } } - + @EventHandler public void handlePlayerChat(AsyncPlayerChatEvent event) { if (event.isCancelled()) return; - + ClientClan client = Get(event.getPlayer()); - + if (client == null) return; - + ClanInfo clan = _clanUtility.getClanByPlayer(event.getPlayer()); - + if (client.isClanChat() && clan != null) { event.setFormat(C.cAqua + "%1$s " + C.cDAqua + "%2$s"); event.getRecipients().clear(); - - for (String cur : clan.getMembers().keySet()) + + for (ClansPlayer cur : clan.getMembers().values()) { - Player player = UtilPlayer.searchOnline(null, cur, false); - + Player player = UtilPlayer.searchExact(cur.getUuid()); + if (player == null) continue; - + event.getRecipients().add(player); } } @@ -488,25 +507,25 @@ public class ClansManager extends MiniClientPlugin implements IRelat { event.setFormat(C.cDGreen + clan.getName() + " " + C.cDGreen + "%1$s " + C.cGreen + "%2$s"); event.getRecipients().clear(); - - for (String cur : clan.getMembers().keySet()) + + for (ClansPlayer cur : clan.getMembers().values()) { - Player player = UtilPlayer.searchOnline(null, cur, false); + Player player = UtilPlayer.searchExact(cur.getUuid()); if (player == null) continue; event.getRecipients().add(player); } - + for (String allyName : clan.getAllyMap().keySet()) { ClanInfo ally = _clanUtility.getClanByClanName(allyName); if (ally == null) continue; - - for (String playerName : ally.getMembers().keySet()) + + for (ClansPlayer cur : ally.getMembers().values()) { - Player player = UtilPlayer.searchOnline(null, playerName, false); + Player player = UtilPlayer.searchExact(cur.getUuid()); if (player == null) continue; @@ -517,7 +536,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat } else { - if (clan == null) + if (clan == null) { event.setFormat(C.cYellow + "%1$s " + C.cWhite + "%2$s"); return; @@ -556,7 +575,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat { messageClan(clan, C.cAqua + caller.getName() + " " + C.cDAqua + message); } - + public void chatAlly(ClanInfo clan, Player caller, String message) { String sendMessage = C.cDGreen + clan.getName() + " " + C.cDGreen + caller.getName() + " " + C.cGreen + message; @@ -572,22 +591,22 @@ public class ClansManager extends MiniClientPlugin implements IRelat } } - public int getNameMin() + public int getNameMin() { return _nameMin; } - public int getNameMax() + public int getNameMax() { return _nameMax; } - public long getReclaimTime() + public long getReclaimTime() { return _reclaimTime; } - public boolean canHurt(Player a, Player b) + public boolean canHurt(Player a, Player b) { if (a.equals(b)) return false; @@ -595,34 +614,45 @@ public class ClansManager extends MiniClientPlugin implements IRelat return _clanUtility.canHurt(a, b); } - public boolean canHurt(String a, String b) + public boolean canHurt(String a, String b) { if (a.equals(b)) return false; return _clanUtility.canHurt(UtilPlayer.searchExact(a), UtilPlayer.searchExact(b)); } - - public boolean isSafe(Player a) + + public boolean isSafe(Player a) { return _clanUtility.isSafe(a); } - public ClanRelation getRelation(String playerA, String playerB) +// public ClanRelation getRelation(String playerA, String playerB) +// { +// return getClanUtility().rel(_clanMemberMap.get(playerA), _clanMemberMap.get(playerB)); +// } + + public ClanRelation getRelation(Player playerA, Player playerB) { - return getClanUtility().rel(_clanMemberMap.get(playerA), _clanMemberMap.get(playerB)); + return getRelation(playerA.getUniqueId(), playerB.getUniqueId()); } - + + public ClanRelation getRelation(UUID playerA, UUID playerB) + { + return getClanUtility().rel(getClanMemberUuidMap().get(playerA), getClanMemberUuidMap().get(playerB)); + } + + public long getOnlineTime() { return _onlineTime; } - + public CombatManager getCombatManager() { return _combatManager; } - + public ClansUtility getClanUtility() { return _clanUtility; @@ -663,12 +693,12 @@ public class ClansManager extends MiniClientPlugin implements IRelat { return _clanAdmin; } - + public ClansGame getClanGame() { return _clanGame; } - + public ClansBlocks getClanBlocks() { return _clanBlocks; @@ -709,6 +739,21 @@ public class ClansManager extends MiniClientPlugin implements IRelat return _worldEvent; } + public HologramManager getHologramManager() + { + return _hologramManager; + } + + public GearManager getGearManager() + { + return _gearManager; + } + + public LootManager getLootManager() + { + return _lootManager; + } + public Chat getChat() { return _chat; @@ -735,7 +780,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat _goldManager.onDisable(); } -// @EventHandler + // @EventHandler public void itemBreak(PlayerItemBreakEvent event) { Bukkit.broadcastMessage("Item Break: " + event.getPlayer()); @@ -744,7 +789,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat } -// @EventHandler + // @EventHandler public void blockBreak(BlockBreakEvent event) { Bukkit.broadcastMessage("dur: " + event.getPlayer().getItemInHand().getDurability()); @@ -764,34 +809,13 @@ public class ClansManager extends MiniClientPlugin implements IRelat e.printStackTrace(); } catch (IllegalAccessException e) - { + { e.printStackTrace(); } Bukkit.broadcastMessage("name: " + item.getName() + " max dur: " + item.getMaxDurability()); } - @EventHandler(priority = EventPriority.HIGH) - public void handleClansDeath(PlayerDeathEvent event) - { - PlayerClan playerClan; - PlayerClan killerClan = null; - - Player player = event.getEntity(); - ClanInfo pClan = _clanMemberMap.get(player.getName()); - playerClan = new PlayerClan(player, pClan); - - if (player.getKiller() != null) - { - Player killer = player.getKiller(); - ClanInfo kClan = _clanMemberMap.get(killer.getName()); - killerClan = new PlayerClan(killer, kClan); - } - - ClansPlayerDeathEvent clansPlayerDeathEvent = new ClansPlayerDeathEvent(event, playerClan, killerClan); - Bukkit.getServer().getPluginManager().callEvent(clansPlayerDeathEvent); - } - @EventHandler(priority = EventPriority.HIGHEST) public void onJoin(PlayerLoginEvent event) { @@ -803,4 +827,25 @@ public class ClansManager extends MiniClientPlugin implements IRelat event.setKickMessage("Only Media+ can join this server!"); } } + + @EventHandler(priority = EventPriority.HIGH) + public void handleClansDeath(PlayerDeathEvent event) + { + PlayerClan playerClan; + PlayerClan killerClan = null; + + Player player = event.getEntity(); + ClanInfo pClan = _clanMemberUuidMap.get(player.getUniqueId()); + playerClan = new PlayerClan(player, pClan); + + if (player.getKiller() != null) + { + Player killer = player.getKiller(); + ClanInfo kClan = _clanMemberUuidMap.get(killer.getUniqueId()); + killerClan = new PlayerClan(killer, kClan); + } + + ClansPlayerDeathEvent clansPlayerDeathEvent = new ClansPlayerDeathEvent(event, playerClan, killerClan); + Bukkit.getServer().getPluginManager().callEvent(clansPlayerDeathEvent); + } }