2022-05-06 02:28:39 +00:00
|
|
|
package dev.plex.guild;
|
|
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
2022-05-07 22:49:50 +00:00
|
|
|
import dev.plex.guild.data.Member;
|
2022-05-06 02:28:39 +00:00
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Optional;
|
|
|
|
import java.util.UUID;
|
2022-05-07 22:49:50 +00:00
|
|
|
import java.util.stream.Collectors;
|
2022-05-06 02:28:39 +00:00
|
|
|
|
|
|
|
public class GuildHolder
|
|
|
|
{
|
|
|
|
private static final List<Guild> GUILDS = Lists.newArrayList();
|
|
|
|
|
|
|
|
public void addGuild(Guild guild)
|
|
|
|
{
|
|
|
|
GUILDS.add(guild);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void deleteGuild(UUID owner)
|
|
|
|
{
|
|
|
|
GUILDS.removeIf(guild -> guild.getOwner().equals(owner));
|
|
|
|
}
|
|
|
|
|
|
|
|
public Optional<Guild> getGuild(UUID uuid)
|
|
|
|
{
|
2022-05-07 22:49:50 +00:00
|
|
|
return GUILDS.stream().filter(guild -> guild.getOwner().equals(uuid) || guild.getMembers().stream().map(Member::uuid).toList().contains(uuid)).findFirst();
|
2022-05-06 02:28:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|