diff --git a/src/main/java/net/Indyuce/mmocore/api/player/social/guilds/Guild.java b/src/main/java/net/Indyuce/mmocore/api/player/social/guilds/Guild.java index 0ee5f6cc..6bde032f 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/social/guilds/Guild.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/social/guilds/Guild.java @@ -29,9 +29,6 @@ public class Guild { */ private UUID owner; - // used to check if two parties are the same - // private UUID uuid = UUID.randomUUID(); - public Guild(UUID owner, String name, String tag) { this.owner = owner; this.guildId = tag.toLowerCase(); @@ -66,23 +63,17 @@ public class Guild { public void removeLastInvite(Player player) { invites.remove(player.getUniqueId()); } - - //public void disband() { - //for(UUID uuid : getMembers().members) - // removeMember(uuid, true); - - - //} - //public void removeMember(UUID uuid) - //{ removeMember(uuid, false); } + public void removeMember(UUID uuid) + { removeMember(uuid, false); } - public void removeMember(UUID uuid) {//, boolean disband) { + // Disband boolean is to prevent co-modification exception when disbanding a guild + public void removeMember(UUID uuid, boolean disband) { PlayerData data = PlayerData.get(uuid); if (data != null && data.isOnline() && data.getPlayer().getOpenInventory() != null && data.getPlayer().getOpenInventory().getTopInventory().getHolder() instanceof GuildViewInventory) InventoryManager.GUILD_CREATION.newInventory(data).open(); - members.remove(uuid); + if(!disband) members.remove(uuid); if(data != null) data.setGuild(null); reopenInventories(); @@ -114,7 +105,6 @@ public class Guild { } public void registerMember(UUID uuid) { - MMOCore.log("Registered Member"); members.add(uuid); } @@ -168,10 +158,6 @@ public class Guild { members.forEach(action); } - public int count() { - return members.size(); - } - public int countOnline() { int online = 0; @@ -181,5 +167,10 @@ public class Guild { return online; } + + public int count() + { return members.size(); } + public void clear() + { members.clear(); } } } diff --git a/src/main/java/net/Indyuce/mmocore/listener/GuildListener.java b/src/main/java/net/Indyuce/mmocore/listener/GuildListener.java index 250c20bb..9787481e 100644 --- a/src/main/java/net/Indyuce/mmocore/listener/GuildListener.java +++ b/src/main/java/net/Indyuce/mmocore/listener/GuildListener.java @@ -19,7 +19,7 @@ public class GuildListener implements Listener { return; PlayerData data = PlayerData.get(event.getPlayer()); - if (!data.hasParty()) + if (!data.inGuild()) return; event.setCancelled(true); diff --git a/src/main/java/net/Indyuce/mmocore/manager/social/GuildManager.java b/src/main/java/net/Indyuce/mmocore/manager/social/GuildManager.java index 9427300a..f05139e1 100644 --- a/src/main/java/net/Indyuce/mmocore/manager/social/GuildManager.java +++ b/src/main/java/net/Indyuce/mmocore/manager/social/GuildManager.java @@ -37,7 +37,8 @@ public class GuildManager extends MMOManager { } public void unregisterGuild(Guild guild) { - guild.getMembers().forEach(member -> guild.removeMember(member)); + guild.getMembers().forEach(member -> guild.removeMember(member, true)); + guild.getMembers().clear(); guilds.remove(guild.getId()); new ConfigFile(guild).delete(); @@ -121,7 +122,7 @@ public class GuildManager extends MMOManager { // Used to check if player was kicked while offline public Guild stillInGuild(UUID uuid, String id) { Guild guild = getGuild(id); - if(guild.getMembers().has(uuid)) + if(guild != null && guild.getMembers().has(uuid)) return guild; return null; }