2022-05-06 02:28:39 +00:00
|
|
|
package dev.plex.guild;
|
|
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
2022-05-08 23:34:03 +00:00
|
|
|
import com.google.common.collect.Maps;
|
2022-05-06 02:28:39 +00:00
|
|
|
import dev.morphia.annotations.Entity;
|
|
|
|
import dev.morphia.annotations.Transient;
|
|
|
|
import dev.plex.Plex;
|
2022-05-07 22:49:50 +00:00
|
|
|
import dev.plex.guild.data.Member;
|
|
|
|
import dev.plex.guild.data.Rank;
|
2022-05-06 02:28:39 +00:00
|
|
|
import dev.plex.util.CustomLocation;
|
|
|
|
import lombok.Data;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
import java.time.ZoneId;
|
|
|
|
import java.time.ZonedDateTime;
|
2022-05-08 23:34:03 +00:00
|
|
|
import java.util.*;
|
2022-05-06 02:28:39 +00:00
|
|
|
|
|
|
|
@Data
|
|
|
|
@Entity("guilds")
|
|
|
|
public class Guild
|
|
|
|
{
|
2022-05-08 05:54:22 +00:00
|
|
|
private final UUID guildUuid;
|
2022-05-06 02:28:39 +00:00
|
|
|
private final String name;
|
2022-05-08 23:34:03 +00:00
|
|
|
private final Member owner;
|
2022-05-06 02:28:39 +00:00
|
|
|
private final ZonedDateTime createdAt;
|
2022-05-07 22:49:50 +00:00
|
|
|
private transient final List<UUID> outgoingInvitations = Lists.newArrayList();
|
|
|
|
private final List<Member> members = Lists.newArrayList();
|
2022-05-06 02:28:39 +00:00
|
|
|
private final List<UUID> moderators = Lists.newArrayList();
|
2022-05-07 22:49:50 +00:00
|
|
|
private final List<Rank> ranks = Lists.newArrayList();
|
2022-05-08 23:34:03 +00:00
|
|
|
private final Map<String, CustomLocation> warps = Maps.newHashMap();
|
2022-05-06 02:28:39 +00:00
|
|
|
private String prefix;
|
|
|
|
private String motd;
|
|
|
|
private CustomLocation home;
|
|
|
|
private boolean tagEnabled;
|
2022-05-07 22:49:50 +00:00
|
|
|
private Rank defaultRank = new Rank("default", null);
|
2022-05-08 23:34:03 +00:00
|
|
|
private boolean isPublic = false;
|
|
|
|
|
2022-05-06 02:28:39 +00:00
|
|
|
|
|
|
|
public static Guild create(Player player, String guildName)
|
|
|
|
{
|
2022-05-08 23:34:03 +00:00
|
|
|
return new Guild(UUID.randomUUID(), guildName, new Member(player.getUniqueId()), ZonedDateTime.now(ZoneId.of(Plex.get().config.getString("server.timezone"))));
|
|
|
|
}
|
|
|
|
|
|
|
|
public Member getMember(UUID uuid)
|
|
|
|
{
|
|
|
|
return owner.getUuid().equals(uuid) ? owner : members.stream().filter(member -> member.getUuid().equals(uuid)).findFirst().get();
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<Member> getMembers()
|
|
|
|
{
|
|
|
|
List<Member> allMembers = Lists.newArrayList(members);
|
|
|
|
allMembers.add(owner);
|
|
|
|
return allMembers;
|
2022-05-06 02:28:39 +00:00
|
|
|
}
|
|
|
|
}
|