From f0fedcc049df82c0fce95cf087336e1c89cf15f5 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 20 Oct 2023 09:39:05 -0400 Subject: [PATCH] Cleanup and reformat --- src/engine/objects/Guild.java | 54 +++++++++-------------------------- 1 file changed, 13 insertions(+), 41 deletions(-) diff --git a/src/engine/objects/Guild.java b/src/engine/objects/Guild.java index 154e286a..8bb733d7 100644 --- a/src/engine/objects/Guild.java +++ b/src/engine/objects/Guild.java @@ -189,22 +189,6 @@ public class Guild extends AbstractWorldObject { return a.getObjectUUID() == b.getObjectUUID(); } - public static boolean sameGuildExcludeErrant(Guild a, Guild b) { - if (a == null || b == null) - return false; - if (a.isEmptyGuild() || b.isEmptyGuild()) - return false; - return a.getObjectUUID() == b.getObjectUUID(); - } - - public static boolean sameGuildIncludeErrant(Guild a, Guild b) { - if (a == null || b == null) - return false; - if (a.isEmptyGuild() || b.isEmptyGuild()) - return true; - return a.getObjectUUID() == b.getObjectUUID(); - } - public static boolean sameNation(Guild a, Guild b) { if (a == null || b == null) return false; @@ -225,11 +209,6 @@ public class Guild extends AbstractWorldObject { return a.nation.getObjectUUID() == b.nation.getObjectUUID() && !a.nation.isEmptyGuild(); } - public static boolean isTaxCollector(int uuid) { - //TODO add the handling for this later - return false; - } - public static boolean canSwearIn(Guild toSub) { boolean canSwear = false; @@ -393,7 +372,9 @@ public class Guild extends AbstractWorldObject { } public static ArrayList GuildRoster(Guild guild) { + ArrayList roster = new ArrayList<>(); + if (guild == null) return roster; @@ -402,6 +383,7 @@ public class Guild extends AbstractWorldObject { if (DbManager.getList(GameObjectType.PlayerCharacter) == null) return roster; + for (AbstractGameObject ago : DbManager.getList(GameObjectType.PlayerCharacter)) { PlayerCharacter toAdd = (PlayerCharacter) ago; @@ -462,14 +444,6 @@ public class Guild extends AbstractWorldObject { return banishList; } - public ArrayList getCharacterKOSList() { - return characterKOSList; - } - - public ArrayList getGuildKOSList() { - return guildKOSList; - } - public ArrayList getAllyList() { return allyList; } @@ -560,9 +534,12 @@ public class Guild extends AbstractWorldObject { } public boolean setGuildLeader(AbstractCharacter ac) { + if (ac == null) return false; + // errant guilds cant be guild leader. + if (this.isEmptyGuild()) return false; @@ -575,6 +552,7 @@ public class Guild extends AbstractWorldObject { PlayerCharacter oldGuildLeader = PlayerCharacter.getFromCache(this.guildLeaderUUID); //old guildLeader no longer has guildLeadership stauts. + if (oldGuildLeader != null) oldGuildLeader.setGuildLeader(false); @@ -586,9 +564,12 @@ public class Guild extends AbstractWorldObject { } public boolean setGuildLeaderForCreate(AbstractCharacter ac) { + if (ac == null) return false; + // errant guilds cant be guild leader. + if (this.isEmptyGuild()) return false; @@ -824,17 +805,6 @@ public class Guild extends AbstractWorldObject { Logger.error("Failed to find Object Type for owner " + this.guildLeaderUUID); } - - //LOad Owners in Cache so we do not have to continuely look in the db for owner. - if (this.ownerIsNPC) { - if (NPC.getNPC(this.guildLeaderUUID) == null) - Logger.info("Guild UID " + this.getObjectUUID() + " Failed to Load NPC Owner with ID " + this.guildLeaderUUID); - - } else if (this.guildLeaderUUID != 0) { - if (PlayerCharacter.getPlayerCharacter(this.guildLeaderUUID) == null) - Logger.info("Guild UID " + this.getObjectUUID() + " Failed to Load Player Owner with ID " + this.guildLeaderUUID); - } - // If loading this guild for the first time write it's character record to disk if (ConfigManager.serverType.equals(ServerType.WORLDSERVER) @@ -859,7 +829,9 @@ public class Guild extends AbstractWorldObject { if (this.nation == null) this.nation = Guild.getErrantGuild(); + //Get guild states. + try { this.subGuildList = DbManager.GuildQueries.GET_SUB_GUILDS(this.getObjectUUID()); } catch (Exception e) { @@ -882,7 +854,6 @@ public class Guild extends AbstractWorldObject { if (this.cityUUID == 0) return; - // Calculate number of realms this guild controls // Only do this on the game server to avoid loading a TOL/City/Zone needlessly @@ -898,6 +869,7 @@ public class Guild extends AbstractWorldObject { //add alliance list, clear all lists as there seems to be a bug where alliances are doubled, need to find where. //possible runAfterLoad being called twice?!?! + this.banishList = dbGuildHandler.GET_GUILD_BANISHED(this.getObjectUUID()); this.characterKOSList = DbManager.GuildQueries.GET_GUILD_KOS_CHARACTER(this.getObjectUUID()); this.guildKOSList = DbManager.GuildQueries.GET_GUILD_KOS_GUILD(this.getObjectUUID());