forked from Upstream/mmocore
Guilds Hotfix
- Removed debug messages - Added a safecheck when a player tries to load an invalid guild - Fixed a co-mod exception - Fixed having to be in a party for guild chatting
This commit is contained in:
parent
6b05f32d4c
commit
279f12b45d
@ -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(); }
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user