Redo how browser communities are stored, update members on join

This commit is contained in:
Dan Mulloy 2018-06-14 20:58:40 -04:00 committed by Alexander Meech
parent 9b83566605
commit 42e68d0d7f
41 changed files with 510 additions and 314 deletions

View File

@ -5,6 +5,7 @@ import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -25,7 +26,6 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import mineplex.core.Managers;
import mineplex.core.MiniDbClientPlugin; import mineplex.core.MiniDbClientPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
@ -39,8 +39,16 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.communities.Community.PrivacySetting;
import mineplex.core.communities.commands.CommunityCommand; import mineplex.core.communities.commands.CommunityCommand;
import mineplex.core.communities.data.BrowserCommunity;
import mineplex.core.communities.data.Community;
import mineplex.core.communities.data.Community.PrivacySetting;
import mineplex.core.communities.data.CommunityJoinRequestInfo;
import mineplex.core.communities.data.CommunityMemberData;
import mineplex.core.communities.data.CommunityMemberInfo;
import mineplex.core.communities.data.CommunityRole;
import mineplex.core.communities.data.CommunitySetting;
import mineplex.core.communities.data.ICommunity;
import mineplex.core.communities.events.CommunityBrowserUpdateEvent; import mineplex.core.communities.events.CommunityBrowserUpdateEvent;
import mineplex.core.communities.events.CommunityDisbandEvent; import mineplex.core.communities.events.CommunityDisbandEvent;
import mineplex.core.communities.events.CommunityJoinRequestsUpdateEvent; import mineplex.core.communities.events.CommunityJoinRequestsUpdateEvent;
@ -121,19 +129,23 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
private final CommunityRepository _repo; private final CommunityRepository _repo;
private final Map<Integer, Community> _loadedCommunities; private final Map<Integer, Community> _loadedCommunities;
private final Map<Integer, BrowserCommunity> _browserCommunities;
private final Random _rand = new Random(); private final Random _rand = new Random();
private final List<Integer> _browserIds = new LinkedList<>(); private final List<Integer> _browserIds = new LinkedList<>();
private final List<UUID> _creating = new ArrayList<>(); private final List<UUID> _creating = new ArrayList<>();
private Integer mcsCommunity = null;
private boolean _us; private boolean _us;
private final Set<Community> dirty = Collections.newSetFromMap(new ConcurrentHashMap<>()); // Communities with redis updates private final Set<Community> _dirty = Collections.newSetFromMap(new ConcurrentHashMap<>()); // Communities with redis updates
private int _updateCycleCount; // The number of update cycles since we've updated all communities private int _updateCycleCount; // The number of update cycles since we've updated all communities
private volatile boolean _cycling = false; private volatile boolean _cycling = false;
private final Chat _chat;
private final PreferencesManager _prefManager;
private final CoreClientManager _clientManager; private final CoreClientManager _clientManager;
private final CustomDataManager _customDataManager; private final CustomDataManager _customDataManager;
@ -150,13 +162,16 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
_repo = new CommunityRepository(_plugin, statusRepo, _us); _repo = new CommunityRepository(_plugin, statusRepo, _us);
_loadedCommunities = new ConcurrentHashMap<>(); _loadedCommunities = new ConcurrentHashMap<>();
_browserCommunities = new ConcurrentHashMap<>();
runAsync(() -> runAsync(() ->
{ {
_repo.loadBrowserCommunities(_browserIds); _repo.loadBrowserIds(_browserIds);
log("Loaded " + _browserIds.size() + " communities to show in browser"); log("Loaded " + _browserIds.size() + " communities to show in browser");
}); });
_chat = require(Chat.class);
_prefManager = require(PreferencesManager.class);
_clientManager = require(CoreClientManager.class); _clientManager = require(CoreClientManager.class);
_customDataManager = require(CustomDataManager.class); _customDataManager = require(CustomDataManager.class);
@ -188,41 +203,9 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
} }
}); });
Bukkit.getScheduler().scheduleAsyncRepeatingTask(_plugin, () -> Bukkit.getScheduler().scheduleAsyncRepeatingTask(_plugin, this::runUpdateCycle, 0L, 20 * UPDATE_CYCLE_SECONDS);
{
_updateCycleCount++;
if (_cycling)
{
return;
}
LinkedList<Community> communities = new LinkedList<>();
if (UPDATE_CYCLE_SECONDS * _updateCycleCount > CACHE_INVALIDATION_SECONDS)
{
// It's been five minutes since a full update; update all communities
_updateCycleCount = 0;
// Make sure to include communities that should be unloaded after their update
dirty.stream().filter(com -> com.getFlag("unloaded")).forEach(communities::add);
dirty.clear();
communities.addAll(_loadedCommunities.values());
}
else
{
communities.addAll(dirty);
dirty.clear();
}
_repo.updateMembersAndJoinRequests(communities);
}, 0L, 20 * UPDATE_CYCLE_SECONDS);
Bukkit.getScheduler().scheduleSyncRepeatingTask(_plugin, this::cycleBrowser, 0L, 20 * 30); Bukkit.getScheduler().scheduleSyncRepeatingTask(_plugin, this::cycleBrowser, 0L, 20 * 30);
// Handled in join events now
// _repo.handlePlayerJoin(_loadedCommunities);
addCommand(new CommunityCommand(this)); addCommand(new CommunityCommand(this));
ServerCommandManager.getInstance().registerCommandType(CommunityChat.class, new CommunityChatHandler(this)); ServerCommandManager.getInstance().registerCommandType(CommunityChat.class, new CommunityChatHandler(this));
@ -242,19 +225,50 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
ServerGroup group = require(ServerConfiguration.class).getServerGroup(); ServerGroup group = require(ServerConfiguration.class).getServerGroup();
if (group.getName().startsWith("COM-")) if (group.getName().startsWith("COM-"))
{ {
int comId = Integer.parseInt(group.getName().split("-")[1]); mcsCommunity = Integer.valueOf(group.getName().split("-")[1]);
Community community = getLoadedCommunity(comId);
Community community = getLoadedCommunity(mcsCommunity);
if (community == null) if (community == null)
{ {
community = _repo.loadCommunity(_loadedCommunities, comId); _repo.loadCommunity(_loadedCommunities, mcsCommunity);
} }
community.setFlag("persist", true);
} }
generatePermissions(); generatePermissions();
} }
private void runUpdateCycle()
{
_updateCycleCount++;
if (_cycling)
{
return;
}
List<Community> communities = new ArrayList<>();
if (UPDATE_CYCLE_SECONDS * _updateCycleCount > CACHE_INVALIDATION_SECONDS)
{
// It's been five minutes since a full update; update all communities
_updateCycleCount = 0;
_dirty.clear();
communities.addAll(_loadedCommunities.values());
}
else
{
communities.addAll(_dirty);
_dirty.clear();
}
updateCommunities(communities);
}
private void updateCommunities(List<Community> communities)
{
_repo.updateMembersAndJoinRequests(communities);
}
private void generatePermissions() private void generatePermissions()
{ {
PermissionGroup.ETERNAL.setPermission(Perm.OWN_COMMUNITY, true, true); PermissionGroup.ETERNAL.setPermission(Perm.OWN_COMMUNITY, true, true);
@ -288,7 +302,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
public boolean isNameAllowed(Player caller, String communityName) public boolean isNameAllowed(Player caller, String communityName)
{ {
return !Managers.get(Chat.class).filterMessage(caller, communityName).contains("*"); return !_chat.filterMessage(caller, communityName).contains("*");
} }
public void communityExists(String name, Consumer<Boolean> result) public void communityExists(String name, Consumer<Boolean> result)
@ -327,28 +341,40 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
return _browserIds; return _browserIds;
} }
public void loadCommunitiesForDisplay(List<Integer> communities) public void loadBrowserCommunities(final List<Integer> displaying, final Runnable onComplete)
{ {
List<Integer> load = communities.stream().filter(com -> getLoadedCommunity(com) == null).collect(Collectors.toList()); runAsync(() ->
_repo.loadCommunities(_loadedCommunities, load);
for (int id : load)
{ {
Community com = _loadedCommunities.get(id); List<Integer> load = new ArrayList<>(displaying.size());
if (com != null) for (Integer id : displaying)
{ {
com.setFlag("display", true); if (!_loadedCommunities.containsKey(id) && !_browserCommunities.containsKey(id))
{
load.add(id);
}
} }
}
_repo.loadBrowserCommunities(_browserCommunities, load);
runSync(onComplete);
});
} }
public void unloadDisplayCommunities(List<Integer> unload) public void tempLoadCommunity(final int id, final Consumer<Community> consumer)
{ {
unload.stream().filter(com -> Community community = _loadedCommunities.get(id);
if (community != null)
{ {
Community community = getLoadedCommunity(com); consumer.accept(community);
return community == null || (community.getFlag("display") && !community.getFlag("persist")); return;
}).forEach(_loadedCommunities::remove); }
runAsync(() -> consumer.accept(_repo.loadCommunity(new HashMap<>(1), id)));
}
public ICommunity getBrowserCommunity(int id)
{
ICommunity community = _loadedCommunities.get(id);
return community != null ? community : _browserCommunities.get(id);
} }
public void updateBrowserStatus(Community community) public void updateBrowserStatus(Community community)
@ -387,7 +413,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
{ {
return; return;
} }
dirty.add(community); _dirty.add(community);
setting.parseValueInto(newValue, community); setting.parseValueInto(newValue, community);
//community.message(F.main(getName(), F.name(sender) + " has changed settings in " + F.name(community.getName()) + "!")); //community.message(F.main(getName(), F.name(sender) + " has changed settings in " + F.name(community.getName()) + "!"));
runSync(() -> UtilServer.CallEvent(new CommunitySettingUpdateEvent(community))); runSync(() -> UtilServer.CallEvent(new CommunitySettingUpdateEvent(community)));
@ -400,7 +426,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
{ {
return; return;
} }
dirty.add(community); _dirty.add(community);
String oldName = community.getName(); String oldName = community.getName();
community.setName(name); community.setName(name);
community.message(F.main(getName(), F.name(sender) + " has changed the name of " + F.name(oldName) + " to " + F.name(community.getName()) + "!")); community.message(F.main(getName(), F.name(sender) + " has changed the name of " + F.name(oldName) + " to " + F.name(community.getName()) + "!"));
@ -414,7 +440,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
{ {
return; return;
} }
dirty.add(community); _dirty.add(community);
CommunityMemberInfo member = community.getMembers().get(uuid); CommunityMemberInfo member = community.getMembers().get(uuid);
member.updateRole(role); member.updateRole(role);
if (Bukkit.getPlayer(uuid) != null) if (Bukkit.getPlayer(uuid) != null)
@ -437,7 +463,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
{ {
return; return;
} }
dirty.add(community); _dirty.add(community);
if (kick) if (kick)
{ {
@ -486,7 +512,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
{ {
return; return;
} }
dirty.add(community); _dirty.add(community);
runSync(() -> runSync(() ->
{ {
if (Bukkit.getPlayer(targetUUID) != null) if (Bukkit.getPlayer(targetUUID) != null)
@ -494,7 +520,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
if (!Get(Bukkit.getPlayer(targetUUID)).Invites.contains(community.getId())) if (!Get(Bukkit.getPlayer(targetUUID)).Invites.contains(community.getId()))
{ {
Get(Bukkit.getPlayer(targetUUID)).Invites.add(community.getId()); Get(Bukkit.getPlayer(targetUUID)).Invites.add(community.getId());
if (Managers.get(PreferencesManager.class).get(Bukkit.getPlayer(targetUUID)).isActive(Preference.COMMUNITY_INVITES)) if (_prefManager.get(Bukkit.getPlayer(targetUUID)).isActive(Preference.COMMUNITY_INVITES))
{ {
new JsonMessage(F.main(getName(), "You have been invited to join " + F.elem(community.getName()) + " by " + F.name(sender) + "! " + C.cGreen + "Click this message to join!")).click(ClickEvent.RUN_COMMAND, "/community join " + community.getName()).sendToPlayer(Bukkit.getPlayer(targetUUID)); new JsonMessage(F.main(getName(), "You have been invited to join " + F.elem(community.getName()) + " by " + F.name(sender) + "! " + C.cGreen + "Click this message to join!")).click(ClickEvent.RUN_COMMAND, "/community join " + community.getName()).sendToPlayer(Bukkit.getPlayer(targetUUID));
} }
@ -513,13 +539,13 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
{ {
return; return;
} }
dirty.add(community); _dirty.add(community);
runSync(() -> runSync(() ->
{ {
if (Bukkit.getPlayer(targetUUID) != null) if (Bukkit.getPlayer(targetUUID) != null)
{ {
Get(Bukkit.getPlayer(targetUUID)).Invites.remove(community.getId()); Get(Bukkit.getPlayer(targetUUID)).Invites.remove(community.getId());
if (Managers.get(PreferencesManager.class).get(Bukkit.getPlayer(targetUUID)).isActive(Preference.COMMUNITY_INVITES) && announce) if (_prefManager.get(Bukkit.getPlayer(targetUUID)).isActive(Preference.COMMUNITY_INVITES) && announce)
{ {
UtilPlayer.message(Bukkit.getPlayer(targetUUID), F.main(getName(), "Your invitation to join " + F.elem(community.getName()) + " has been revoked by " + F.name(sender) + "!")); UtilPlayer.message(Bukkit.getPlayer(targetUUID), F.main(getName(), "Your invitation to join " + F.elem(community.getName()) + " has been revoked by " + F.name(sender) + "!"));
} }
@ -539,7 +565,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
{ {
return; return;
} }
dirty.add(community); _dirty.add(community);
if (Bukkit.getPlayer(playerUUID) != null) if (Bukkit.getPlayer(playerUUID) != null)
{ {
UtilPlayer.message(Bukkit.getPlayer(playerUUID), F.main(getName(), "You have requested to join " + F.elem(community.getName()) + "!")); UtilPlayer.message(Bukkit.getPlayer(playerUUID), F.main(getName(), "You have requested to join " + F.elem(community.getName()) + "!"));
@ -557,7 +583,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
{ {
return; return;
} }
dirty.add(community); _dirty.add(community);
community.getJoinRequests().remove(playerUUID); community.getJoinRequests().remove(playerUUID);
if (announce) if (announce)
{ {
@ -580,7 +606,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
runSync(() -> runSync(() ->
{ {
Community community = _loadedCommunities.get(id); Community community = _loadedCommunities.get(id);
dirty.add(community); _dirty.add(community);
if (Bukkit.getPlayer(leaderUUID) != null) if (Bukkit.getPlayer(leaderUUID) != null)
{ {
Player leader = Bukkit.getPlayer(leaderUUID); Player leader = Bukkit.getPlayer(leaderUUID);
@ -670,7 +696,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
{ {
UtilPlayer.message(sender, F.main(getName(), "You have invited " + F.name(target) + " to join " + F.name(community.getName()) + "!")); UtilPlayer.message(sender, F.main(getName(), "You have invited " + F.name(target) + " to join " + F.name(community.getName()) + "!"));
} }
new CommunityInvite(community.getId(), sender.getName(), target, Managers.get(CoreClientManager.class).loadUUIDFromDB(target).toString()).publish(); new CommunityInvite(community.getId(), sender.getName(), target, _clientManager.loadUUIDFromDB(target).toString()).publish();
} }
else else
{ {
@ -689,7 +715,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
{ {
UtilPlayer.message(sender, F.main(getName(), "You have revoked " + F.name(target) + "'s invitation to join " + F.name(community.getName()) + "!")); UtilPlayer.message(sender, F.main(getName(), "You have revoked " + F.name(target) + "'s invitation to join " + F.name(community.getName()) + "!"));
} }
new CommunityUnInvite(community.getId(), sender.getName(), target, Managers.get(CoreClientManager.class).loadUUIDFromDB(target).toString(), true).publish(); new CommunityUnInvite(community.getId(), sender.getName(), target, _clientManager.loadUUIDFromDB(target).toString(), true).publish();
} }
else else
{ {
@ -700,7 +726,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
public void handleRejectInvite(Player sender, Community community) public void handleRejectInvite(Player sender, Community community)
{ {
final String playerName = Managers.get(CoreClientManager.class).Get(sender).getName(); final String playerName = _clientManager.Get(sender).getName();
runAsync(() -> runAsync(() ->
{ {
_repo.deleteInviteToCommunity(community.getId(), playerName); _repo.deleteInviteToCommunity(community.getId(), playerName);
@ -711,11 +737,11 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
public void handleJoinRequest(Player sender, Community community) public void handleJoinRequest(Player sender, Community community)
{ {
final int accountId = Managers.get(CoreClientManager.class).getAccountId(sender); final int accountId = _clientManager.getAccountId(sender);
if (Get(sender).Invites.contains(community.getId())) if (Get(sender).Invites.contains(community.getId()))
{ {
String playerName = Managers.get(CoreClientManager.class).Get(sender).getName(); //Guarantee real name (important in this instance) String playerName = _clientManager.Get(sender).getName(); //Guarantee real name (important in this instance)
runAsync(() -> runAsync(() ->
{ {
_repo.addToCommunity(accountId, community.getId()); _repo.addToCommunity(accountId, community.getId());
@ -743,8 +769,8 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
public void handleJoin(Player sender, Community community, boolean fromInvite) public void handleJoin(Player sender, Community community, boolean fromInvite)
{ {
final int accountId = Managers.get(CoreClientManager.class).getAccountId(sender); final int accountId = _clientManager.getAccountId(sender);
final String playerName = Managers.get(CoreClientManager.class).Get(sender).getName(); final String playerName = _clientManager.Get(sender).getName();
runAsync(() -> runAsync(() ->
{ {
_repo.addToCommunity(accountId, community.getId()); _repo.addToCommunity(accountId, community.getId());
@ -855,7 +881,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
public void handleToggleReadingChat(Player sender, Community community) public void handleToggleReadingChat(Player sender, Community community)
{ {
final int accountId = Managers.get(CoreClientManager.class).getAccountId(sender); final int accountId = _clientManager.getAccountId(sender);
final boolean reading = !community.getMembers().get(sender.getUniqueId()).ReadingChat; final boolean reading = !community.getMembers().get(sender.getUniqueId()).ReadingChat;
runAsync(() -> runAsync(() ->
@ -888,16 +914,6 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
Set(uuid, data); Set(uuid, data);
} }
@EventHandler
public void loadInvites(PlayerJoinEvent event)
{
final CommunityMemberData data = Get(event.getPlayer());
if (data.Invites.size() > 0 && Managers.get(PreferencesManager.class).get(event.getPlayer()).isActive(Preference.COMMUNITY_INVITES))
{
UtilPlayer.message(event.getPlayer(), F.main(getName(), "You have been invited to join " + F.elem(data.Invites.size()) + " communities!"));
}
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onChat(AsyncPlayerChatEvent event) public void onChat(AsyncPlayerChatEvent event)
{ {
@ -969,7 +985,14 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
{ {
// Load their communities if it hasn't already been done // Load their communities if it hasn't already been done
Player player = event.getPlayer(); Player player = event.getPlayer();
Set<Integer> communityIds = Get(player).getCommunityIds(); CommunityMemberData data = Get(player);
if (data.Invites.size() > 0 && _prefManager.get(event.getPlayer()).isActive(Preference.COMMUNITY_INVITES))
{
UtilPlayer.message(event.getPlayer(), F.main(getName(), "You have been invited to join " + F.elem(data.Invites.size()) + " communities!"));
}
Set<Integer> communityIds = data.getCommunityIds();
final List<Integer> load = communityIds.stream().filter(id -> getLoadedCommunity(id) == null).collect(Collectors.toList()); final List<Integer> load = communityIds.stream().filter(id -> getLoadedCommunity(id) == null).collect(Collectors.toList());
if (load.isEmpty()) if (load.isEmpty())
@ -979,6 +1002,8 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
final int accountId = _clientManager.getAccountId(player); final int accountId = _clientManager.getAccountId(player);
_browserCommunities.keySet().removeAll(load);
runAsync(() -> runAsync(() ->
{ {
_repo.handlePlayerJoin(_loadedCommunities, load, accountId); _repo.handlePlayerJoin(_loadedCommunities, load, accountId);
@ -994,7 +1019,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
List<Community> communities = Get(player).getCommunities(); List<Community> communities = Get(player).getCommunities();
for (Community community : communities) for (Community community : communities)
{ {
if (community.getFlag("persist") if (community.getId().equals(mcsCommunity)
|| community.getMembers().keySet().stream().anyMatch(uuid -> !player.getUniqueId().equals(uuid) && Bukkit.getPlayer(uuid) != null)) || community.getMembers().keySet().stream().anyMatch(uuid -> !player.getUniqueId().equals(uuid) && Bukkit.getPlayer(uuid) != null))
{ {
continue; continue;
@ -1002,8 +1027,14 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
System.out.println("Unloading community: " + community.getId()); System.out.println("Unloading community: " + community.getId());
// If it's a browser community, keep some of the data
if (community.isBrowserEilgible())
{
_browserCommunities.put(community.getId(), community.toBrowser());
}
// Unload this community from memory // Unload this community from memory
community.setFlag("unloaded", true); _dirty.remove(community);
_loadedCommunities.remove(community.getId()); _loadedCommunities.remove(community.getId());
} }
} }

View File

@ -5,11 +5,8 @@ import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -19,16 +16,17 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.timing.TimingManager; import mineplex.core.common.timing.TimingManager;
import mineplex.core.common.util.Callback; import mineplex.core.common.util.Callback;
import mineplex.core.communities.Community; import mineplex.core.communities.data.BrowserCommunity;
import mineplex.core.communities.CommunityJoinRequestInfo; import mineplex.core.communities.data.Community;
import mineplex.core.communities.CommunityMemberInfo; import mineplex.core.communities.data.CommunityJoinRequestInfo;
import mineplex.core.communities.CommunityRole; import mineplex.core.communities.data.CommunityMemberInfo;
import mineplex.core.communities.CommunitySetting; import mineplex.core.communities.data.CommunityRole;
import mineplex.core.communities.data.CommunitySetting;
import mineplex.core.game.GameDisplay;
import mineplex.serverdata.data.DataRepository; import mineplex.serverdata.data.DataRepository;
import mineplex.serverdata.data.PlayerStatus; import mineplex.serverdata.data.PlayerStatus;
import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.RepositoryBase; import mineplex.serverdata.database.RepositoryBase;
import mineplex.serverdata.database.column.Column;
import mineplex.serverdata.database.column.ColumnBoolean; import mineplex.serverdata.database.column.ColumnBoolean;
import mineplex.serverdata.database.column.ColumnInt; import mineplex.serverdata.database.column.ColumnInt;
import mineplex.serverdata.database.column.ColumnVarChar; import mineplex.serverdata.database.column.ColumnVarChar;
@ -37,6 +35,7 @@ public class CommunityRepository extends RepositoryBase
{ {
private static final String GET_COMMUNITIES_BY_ID = "SELECT * FROM communities"; private static final String GET_COMMUNITIES_BY_ID = "SELECT * FROM communities";
private static final String GET_COMMUNITY_MEMBERS = "SELECT cm.communityId, cm.accountId, cm.communityRole, ac.name, ac.uuid, ac.lastLogin, cm.readingChat FROM communityMembers cm INNER JOIN accounts ac ON ac.id=cm.accountId"; private static final String GET_COMMUNITY_MEMBERS = "SELECT cm.communityId, cm.accountId, cm.communityRole, ac.name, ac.uuid, ac.lastLogin, cm.readingChat FROM communityMembers cm INNER JOIN accounts ac ON ac.id=cm.accountId";
private static final String GET_COMMUNITY_SIZE = "SELECT COUNT(accountId) AS total, communityId FROM communityMembers";
private static final String GET_COMMUNITY_JOIN_REQUESTS = "SELECT cjr.communityId, cjr.accountId, ac.name, ac.uuid FROM communityJoinRequests cjr INNER JOIN accounts ac ON ac.id=cjr.accountId WHERE cjr.accountId=?;"; private static final String GET_COMMUNITY_JOIN_REQUESTS = "SELECT cjr.communityId, cjr.accountId, ac.name, ac.uuid FROM communityJoinRequests cjr INNER JOIN accounts ac ON ac.id=cjr.accountId WHERE cjr.accountId=?;";
private static final String GET_COMMUNITY_SETTINGS = "SELECT communityId, settingId, settingValue FROM communitySettings"; private static final String GET_COMMUNITY_SETTINGS = "SELECT communityId, settingId, settingValue FROM communitySettings";
private static final String GET_PUBLIC_COMMUNITIES = "SELECT communityId FROM communitySettings WHERE settingId=8 AND settingValue='true';"; private static final String GET_PUBLIC_COMMUNITIES = "SELECT communityId FROM communitySettings WHERE settingId=8 AND settingValue='true';";
@ -84,7 +83,7 @@ public class CommunityRepository extends RepositoryBase
* Loads all communities that are eligible to be shown in the browser. * Loads all communities that are eligible to be shown in the browser.
* That is, they have 5 or more members and aren't private. * That is, they have 5 or more members and aren't private.
*/ */
public void loadBrowserCommunities(final Collection<Integer> store) public void loadBrowserIds(final Collection<Integer> store)
{ {
try (Connection connection = getConnection()) try (Connection connection = getConnection())
{ {
@ -103,21 +102,81 @@ public class CommunityRepository extends RepositoryBase
} }
} }
public void loadBrowserCommunities(final Map<Integer, BrowserCommunity> store, final List<Integer> load)
{
if (load.isEmpty())
{
return;
}
try (Connection connection = getConnection())
{
String inClause = getInClause(load);
ColumnInt[] idColumns = genIdColumns("id", load);
executeQuery(connection, GET_COMMUNITIES_BY_ID + inClause.replace("%col", "id"), resultSet ->
{
while (resultSet.next())
{
int id = resultSet.getInt("id");
String cName = resultSet.getString("name");
BrowserCommunity community = new BrowserCommunity(id, cName);
store.put(id, community);
}
}, idColumns);
idColumns = genIdColumns("communityId", load);
executeQuery(GET_COMMUNITY_SIZE + inClause.replace("%col", "communityId"), resultSet ->
{
while (resultSet.next())
{
int members = resultSet.getInt("total");
int id = resultSet.getInt("communityId");
BrowserCommunity com = store.get(id);
if (com != null)
{
com.setMembers(members);
}
}
}, idColumns);
idColumns = genIdColumns("communityId", load);
executeQuery(connection, GET_COMMUNITY_SETTINGS + inClause.replace("%col", "communityId"), settingSet ->
{
while (settingSet.next())
{
int communityId = settingSet.getInt("communityId");
int settingId = settingSet.getInt("settingId");
String value = settingSet.getString("settingValue");
BrowserCommunity community = store.get(communityId);
CommunitySetting setting = CommunitySetting.getSetting(settingId);
if (setting == CommunitySetting.DESCRIPTION)
{
community.setDescription(value);
} else if (setting == CommunitySetting.FAVORITE_GAME)
{
community.setFavoriteGame(GameDisplay.matchName(value));
} else if (setting == CommunitySetting.PRIVACY)
{
community.setPrivacySetting(Community.PrivacySetting.parsePrivacy(value));
}
}
}, idColumns);
} catch (SQLException ex)
{
ex.printStackTrace();
}
}
/** /**
* Loads and stores a single community. * Loads and stores a single community.
*/ */
public Community loadCommunity(final Map<Integer, Community> store, final int id) public Community loadCommunity(final Map<Integer, Community> store, final int id)
{ {
loadInternal(store, Collections.singletonList(id), -1); return loadInternal(store, Collections.singletonList(id), -1).get(0);
return store.get(id);
}
/**
* Loads all of the provided communities
*/
public void loadCommunities(final Map<Integer, Community> store, final List<Integer> load)
{
loadInternal(store, load, -1);
} }
/** /**
@ -125,7 +184,8 @@ public class CommunityRepository extends RepositoryBase
*/ */
public void handlePlayerJoin(final Map<Integer, Community> store, final List<Integer> load, final int accountId) public void handlePlayerJoin(final Map<Integer, Community> store, final List<Integer> load, final int accountId)
{ {
loadInternal(store, load, accountId); List<Community> communities = loadInternal(store, load, accountId);
updateMembersAndJoinRequests(communities);
} }
public void updateBrowserStatus(Community community, boolean flag) public void updateBrowserStatus(Community community, boolean flag)
@ -138,35 +198,41 @@ public class CommunityRepository extends RepositoryBase
return nums.stream().map(i -> new ColumnInt(colName, i)).toArray(ColumnInt[]::new); return nums.stream().map(i -> new ColumnInt(colName, i)).toArray(ColumnInt[]::new);
} }
private void loadInternal(final Map<Integer, Community> store, final List<Integer> load, final int accountId) private String getInClause(List<Integer> load)
{ {
StringBuilder builder = new StringBuilder();
builder.append(" WHERE %col IN (");
for (int index = 0; index < load.size(); index++)
{
if (index != 0)
builder.append(", ");
builder.append("?");
}
builder.append(");");
return builder.toString();
}
private List<Community> loadInternal(final Map<Integer, Community> store, final List<Integer> load, final int accountId)
{
List<Community> communities = new ArrayList<>();
try (Connection connection = getConnection()) try (Connection connection = getConnection())
{ {
if (!load.isEmpty()) if (!load.isEmpty())
{ {
// Only load the info for communities with the given IDs String inClause = getInClause(load);
StringBuilder builder = new StringBuilder();
builder.append(" WHERE %col IN (");
for (int index = 0; index < load.size(); index++)
{
if (index != 0)
builder.append(", ");
builder.append("?");
}
builder.append(");");
String inClause = builder.toString();
ColumnInt[] idColumns = genIdColumns("id", load); ColumnInt[] idColumns = genIdColumns("id", load);
executeQuery(connection, GET_COMMUNITIES_BY_ID + inClause.replace("%col", "id"), resultSet -> executeQuery(connection, GET_COMMUNITIES_BY_ID + inClause.replace("%col", "id"), resultSet ->
{ {
while (resultSet.next()) while (resultSet.next())
{ {
final int id = resultSet.getInt("id"); int id = resultSet.getInt("id");
final String cName = resultSet.getString("name"); String cName = resultSet.getString("name");
final Community community = new Community(id, cName); Community community = new Community(id, cName);
communities.add(community);
store.put(id, community); store.put(id, community);
} }
@ -177,12 +243,12 @@ public class CommunityRepository extends RepositoryBase
{ {
while (memberSet.next()) while (memberSet.next())
{ {
final int communityId = memberSet.getInt("communityId"); int communityId = memberSet.getInt("communityId");
final int accountId1 = memberSet.getInt("accountId"); int accountId1 = memberSet.getInt("accountId");
final String name = memberSet.getString("name"); String name = memberSet.getString("name");
final UUID uuid = UUID.fromString(memberSet.getString("uuid")); UUID uuid = UUID.fromString(memberSet.getString("uuid"));
final CommunityRole role = CommunityRole.parseRole(memberSet.getString("communityRole")); CommunityRole role = CommunityRole.parseRole(memberSet.getString("communityRole"));
final long lastLogin = memberSet.getTimestamp("lastLogin").getTime(); long lastLogin = memberSet.getTimestamp("lastLogin").getTime();
boolean readingChat = memberSet.getBoolean("readingChat"); boolean readingChat = memberSet.getBoolean("readingChat");
CommunityMemberInfo info = new CommunityMemberInfo(name, uuid, accountId1, role, lastLogin); CommunityMemberInfo info = new CommunityMemberInfo(name, uuid, accountId1, role, lastLogin);
@ -201,9 +267,9 @@ public class CommunityRepository extends RepositoryBase
{ {
while (settingSet.next()) while (settingSet.next())
{ {
final int communityId = settingSet.getInt("communityId"); int communityId = settingSet.getInt("communityId");
final int settingId = settingSet.getInt("settingId"); int settingId = settingSet.getInt("settingId");
final String value = settingSet.getString("settingValue"); String value = settingSet.getString("settingValue");
Community community = store.get(communityId); Community community = store.get(communityId);
CommunitySetting setting = CommunitySetting.getSetting(settingId); CommunitySetting setting = CommunitySetting.getSetting(settingId);
@ -215,18 +281,11 @@ public class CommunityRepository extends RepositoryBase
}, idColumns); }, idColumns);
// Ensure the browser flag is set // Ensure the browser flag is set
for (int id : load) for (Community com : communities)
{ {
Community com = store.get(id);
if (com == null)
{
continue;
}
if (!com.isBrowserFlagSet()) if (!com.isBrowserFlagSet())
{ {
updateBrowserStatus(com, com.getPrivacySetting() != Community.PrivacySetting.PRIVATE && updateBrowserStatus(com, com.isBrowserEilgible());
com.getMembers().size() >= 5);
} }
} }
} }
@ -237,10 +296,9 @@ public class CommunityRepository extends RepositoryBase
{ {
while (requestSet.next()) while (requestSet.next())
{ {
final int communityId = requestSet.getInt("communityId"); int communityId = requestSet.getInt("communityId");
// final int accountId = requestSet.getInt("accountId"); UUID uuid = UUID.fromString(requestSet.getString("uuid"));
final UUID uuid = UUID.fromString(requestSet.getString("uuid")); String name = requestSet.getString("name");
final String name = requestSet.getString("name");
Community community = store.get(communityId); Community community = store.get(communityId);
if (community != null) if (community != null)
@ -255,6 +313,8 @@ public class CommunityRepository extends RepositoryBase
System.err.println("Encountered an SQL exception loading communities " + load); System.err.println("Encountered an SQL exception loading communities " + load);
ex.printStackTrace(); ex.printStackTrace();
} }
return communities;
} }
public void updateMembersAndJoinRequests(List<Community> communities) public void updateMembersAndJoinRequests(List<Community> communities)
@ -323,30 +383,6 @@ public class CommunityRepository extends RepositoryBase
TimingManager.stop("members + join requests for " + communities.size() + " communities"); TimingManager.stop("members + join requests for " + communities.size() + " communities");
} }
public void updateJoinRequests(LinkedList<Community> communities)
{
if (communities.isEmpty())
{
return;
}
TimingManager.stop("request elements");
}
public void loadInvites(int accountId, List<Integer> invites)
{
executeQuery("SELECT ci.communityId, c.region FROM communityInvites AS ci INNER JOIN communities AS c ON c.id=ci.communityId WHERE accountId=?;", resultSet ->
{
while (resultSet.next())
{
String region = resultSet.getString("region");
if ((_us && region.equalsIgnoreCase("US")) || (!_us && region.equalsIgnoreCase("EU")))
{
invites.add(resultSet.getInt("communityId"));
}
}
}, new ColumnInt("accountId", accountId));
}
public void removeFromCommunity(int accountId, int communityId) public void removeFromCommunity(int accountId, int communityId)
{ {
executeUpdate(REMOVE_FROM_COMMUNITY, new ColumnInt("accountId", accountId), new ColumnInt("communityId", communityId)); executeUpdate(REMOVE_FROM_COMMUNITY, new ColumnInt("accountId", accountId), new ColumnInt("communityId", communityId));

View File

@ -6,7 +6,7 @@ import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase; import mineplex.core.command.CommandBase;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.communities.Community; import mineplex.core.communities.data.Community;
import mineplex.core.communities.CommunityManager; import mineplex.core.communities.CommunityManager;
public class CommunityChatCommand extends CommandBase<CommunityManager> public class CommunityChatCommand extends CommandBase<CommunityManager>

View File

@ -6,7 +6,7 @@ import org.bukkit.entity.Player;
import mineplex.core.command.MultiCommandBase; import mineplex.core.command.MultiCommandBase;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.communities.Community; import mineplex.core.communities.data.Community;
import mineplex.core.communities.CommunityManager; import mineplex.core.communities.CommunityManager;
import mineplex.core.communities.gui.pages.CommunityMembersPage; import mineplex.core.communities.gui.pages.CommunityMembersPage;
import mineplex.core.communities.gui.pages.CommunityOverviewPage; import mineplex.core.communities.gui.pages.CommunityOverviewPage;

View File

@ -1,17 +1,13 @@
package mineplex.core.communities.commands; package mineplex.core.communities.commands;
import java.util.Arrays;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import mineplex.core.Managers; import mineplex.core.Managers;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.chat.Chat;
import mineplex.core.command.CommandBase; import mineplex.core.command.CommandBase;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.communities.Community;
import mineplex.core.communities.CommunityManager; import mineplex.core.communities.CommunityManager;
public class CommunityCreateCommand extends CommandBase<CommunityManager> public class CommunityCreateCommand extends CommandBase<CommunityManager>

View File

@ -9,11 +9,11 @@ import mineplex.core.chat.Chat;
import mineplex.core.command.CommandBase; import mineplex.core.command.CommandBase;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.communities.Community; import mineplex.core.communities.data.Community;
import mineplex.core.communities.CommunityManager; import mineplex.core.communities.CommunityManager;
import mineplex.core.communities.CommunityMemberInfo; import mineplex.core.communities.data.CommunityMemberInfo;
import mineplex.core.communities.CommunityRole; import mineplex.core.communities.data.CommunityRole;
import mineplex.core.communities.CommunitySetting; import mineplex.core.communities.data.CommunitySetting;
public class CommunityDescriptionCommand extends CommandBase<CommunityManager> public class CommunityDescriptionCommand extends CommandBase<CommunityManager>
{ {

View File

@ -8,10 +8,10 @@ import mineplex.core.account.CoreClientManager;
import mineplex.core.command.CommandBase; import mineplex.core.command.CommandBase;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.communities.Community; import mineplex.core.communities.data.Community;
import mineplex.core.communities.CommunityManager; import mineplex.core.communities.CommunityManager;
import mineplex.core.communities.CommunityMemberInfo; import mineplex.core.communities.data.CommunityMemberInfo;
import mineplex.core.communities.CommunityRole; import mineplex.core.communities.data.CommunityRole;
public class CommunityDisbandCommand extends CommandBase<CommunityManager> public class CommunityDisbandCommand extends CommandBase<CommunityManager>
{ {

View File

@ -8,10 +8,10 @@ import mineplex.core.account.CoreClientManager;
import mineplex.core.command.CommandBase; import mineplex.core.command.CommandBase;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.communities.Community; import mineplex.core.communities.data.Community;
import mineplex.core.communities.CommunityManager; import mineplex.core.communities.CommunityManager;
import mineplex.core.communities.CommunityMemberInfo; import mineplex.core.communities.data.CommunityMemberInfo;
import mineplex.core.communities.CommunityRole; import mineplex.core.communities.data.CommunityRole;
public class CommunityInviteCommand extends CommandBase<CommunityManager> public class CommunityInviteCommand extends CommandBase<CommunityManager>
{ {

View File

@ -6,8 +6,8 @@ import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase; import mineplex.core.command.CommandBase;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.communities.Community; import mineplex.core.communities.data.Community;
import mineplex.core.communities.Community.PrivacySetting; import mineplex.core.communities.data.Community.PrivacySetting;
import mineplex.core.communities.CommunityManager; import mineplex.core.communities.CommunityManager;
public class CommunityJoinCommand extends CommandBase<CommunityManager> public class CommunityJoinCommand extends CommandBase<CommunityManager>

View File

@ -8,10 +8,10 @@ import mineplex.core.account.CoreClientManager;
import mineplex.core.command.CommandBase; import mineplex.core.command.CommandBase;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.communities.Community; import mineplex.core.communities.data.Community;
import mineplex.core.communities.CommunityManager; import mineplex.core.communities.CommunityManager;
import mineplex.core.communities.CommunityMemberInfo; import mineplex.core.communities.data.CommunityMemberInfo;
import mineplex.core.communities.CommunityRole; import mineplex.core.communities.data.CommunityRole;
import mineplex.core.personalServer.PersonalServerManager; import mineplex.core.personalServer.PersonalServerManager;
public class CommunityMCSCommand extends CommandBase<CommunityManager> public class CommunityMCSCommand extends CommandBase<CommunityManager>

View File

@ -1,20 +1,17 @@
package mineplex.core.communities.commands; package mineplex.core.communities.commands;
import java.util.Arrays;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import mineplex.core.Managers; import mineplex.core.Managers;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.chat.Chat;
import mineplex.core.command.CommandBase; import mineplex.core.command.CommandBase;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.communities.Community; import mineplex.core.communities.data.Community;
import mineplex.core.communities.CommunityManager; import mineplex.core.communities.CommunityManager;
import mineplex.core.communities.CommunityMemberInfo; import mineplex.core.communities.data.CommunityMemberInfo;
import mineplex.core.communities.CommunityRole; import mineplex.core.communities.data.CommunityRole;
public class CommunityRenameCommand extends CommandBase<CommunityManager> public class CommunityRenameCommand extends CommandBase<CommunityManager>
{ {

View File

@ -8,10 +8,10 @@ import mineplex.core.account.CoreClientManager;
import mineplex.core.command.CommandBase; import mineplex.core.command.CommandBase;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.communities.Community; import mineplex.core.communities.data.Community;
import mineplex.core.communities.CommunityManager; import mineplex.core.communities.CommunityManager;
import mineplex.core.communities.CommunityMemberInfo; import mineplex.core.communities.data.CommunityMemberInfo;
import mineplex.core.communities.CommunityRole; import mineplex.core.communities.data.CommunityRole;
public class CommunityUnInviteCommand extends CommandBase<CommunityManager> public class CommunityUnInviteCommand extends CommandBase<CommunityManager>
{ {

View File

@ -0,0 +1,91 @@
package mineplex.core.communities.data;
import mineplex.core.game.GameDisplay;
public class BrowserCommunity implements ICommunity
{
private int _id;
private int _members;
private String _name;
private String _description;
private GameDisplay _favoriteGame;
private Community.PrivacySetting _privacySetting;
public BrowserCommunity(int id, String name)
{
_id = id;
_name = name;
}
@Override
public Integer getId()
{
return _id;
}
@Override
public Integer getMemberCount()
{
return _members;
}
@Override
public String getName()
{
return _name;
}
@Override
public String getDescription()
{
return _description;
}
@Override
public GameDisplay getFavoriteGame()
{
return _favoriteGame;
}
@Override
public Community.PrivacySetting getPrivacySetting()
{
return _privacySetting;
}
public BrowserCommunity setMembers(int members)
{
_members = members;
return this;
}
public BrowserCommunity setDescription(String description)
{
_description = description;
return this;
}
public BrowserCommunity setFavoriteGame(GameDisplay favoriteGame)
{
_favoriteGame = favoriteGame;
return this;
}
public BrowserCommunity setPrivacySetting(Community.PrivacySetting privacySetting)
{
_privacySetting = privacySetting;
return this;
}
@Override
public int hashCode()
{
return _id;
}
@Override
public boolean equals(Object o)
{
return o == this || (o instanceof BrowserCommunity && ((BrowserCommunity) o)._id == _id);
}
}

View File

@ -1,7 +1,5 @@
package mineplex.core.communities; package mineplex.core.communities.data;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -12,7 +10,7 @@ import org.bukkit.ChatColor;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.game.GameDisplay; import mineplex.core.game.GameDisplay;
public class Community public class Community implements ICommunity
{ {
private final int _id; private final int _id;
private String _name; private String _name;
@ -25,14 +23,12 @@ public class Community
private PrivacySetting _privacy; private PrivacySetting _privacy;
private boolean _showInBrowser; private boolean _showInBrowser;
private transient List<String> flags = new ArrayList<>();
public Community(int id, String name) public Community(int id, String name)
{ {
_id = id; _id = id;
_name = name; _name = name;
_description = "No Description Set"; _description = "No Description Set";
_chatFormat = new ChatColor[] {ChatColor.BLUE, ChatColor.RED, ChatColor.GREEN}; _chatFormat = new ChatColor[] { ChatColor.BLUE, ChatColor.RED, ChatColor.GREEN };
_chatDelay = 1000; _chatDelay = 1000;
_favoriteGame = GameDisplay.ChampionsCTF; _favoriteGame = GameDisplay.ChampionsCTF;
_privacy = PrivacySetting.RECRUITING; _privacy = PrivacySetting.RECRUITING;
@ -43,6 +39,12 @@ public class Community
return _id; return _id;
} }
@Override
public Integer getMemberCount()
{
return _members.size();
}
public String getName() public String getName()
{ {
return _name; return _name;
@ -141,23 +143,21 @@ public class Community
getMembers().values().stream().filter(member -> member.Role.ordinal() <= minimumRole.ordinal()).forEach(member -> UtilPlayer.message(Bukkit.getPlayer(member.UUID), message)); getMembers().values().stream().filter(member -> member.Role.ordinal() <= minimumRole.ordinal()).forEach(member -> UtilPlayer.message(Bukkit.getPlayer(member.UUID), message));
} }
public void setFlag(String flag, boolean value) public BrowserCommunity toBrowser()
{ {
if (value) return new BrowserCommunity(getId(), getName())
{ .setPrivacySetting(getPrivacySetting())
flags.add(flag.toLowerCase()); .setFavoriteGame(getFavoriteGame())
} else .setDescription(getDescription())
{ .setMembers(getMemberCount());
flags.remove(flag.toLowerCase());
}
} }
public boolean getFlag(String flag) public boolean isBrowserEilgible()
{ {
return flags.contains(flag.toLowerCase()); return getMemberCount() >= 5 && getPrivacySetting() != PrivacySetting.PRIVATE;
} }
public static enum PrivacySetting public enum PrivacySetting
{ {
OPEN("Open to Join"), OPEN("Open to Join"),
RECRUITING("Accepting Join Requests"), RECRUITING("Accepting Join Requests"),
@ -166,7 +166,7 @@ public class Community
private String _display; private String _display;
private PrivacySetting(String display) PrivacySetting(String display)
{ {
_display = display; _display = display;
} }

View File

@ -1,4 +1,4 @@
package mineplex.core.communities; package mineplex.core.communities.data;
import java.util.UUID; import java.util.UUID;

View File

@ -1,15 +1,13 @@
package mineplex.core.communities; package mineplex.core.communities.data;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import com.google.common.collect.ImmutableSet;
import mineplex.core.Managers; import mineplex.core.Managers;
import mineplex.core.communities.CommunityManager;
public class CommunityMemberData public class CommunityMemberData
{ {
@ -48,7 +46,7 @@ public class CommunityMemberData
setCommunityChattingTo(community.getId()); setCommunityChattingTo(community.getId());
} }
Set<Integer> getCommunityIds() public Set<Integer> getCommunityIds()
{ {
return _communities.keySet(); return _communities.keySet();
} }

View File

@ -1,4 +1,4 @@
package mineplex.core.communities; package mineplex.core.communities.data;
import java.util.UUID; import java.util.UUID;

View File

@ -1,4 +1,4 @@
package mineplex.core.communities; package mineplex.core.communities.data;
public enum CommunityRole public enum CommunityRole
{ {

View File

@ -1,10 +1,10 @@
package mineplex.core.communities; package mineplex.core.communities.data;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import mineplex.core.common.Pair; import mineplex.core.common.Pair;
import mineplex.core.common.util.Callback; import mineplex.core.common.util.Callback;
import mineplex.core.communities.Community.PrivacySetting; import mineplex.core.communities.data.Community.PrivacySetting;
import mineplex.core.game.GameDisplay; import mineplex.core.game.GameDisplay;
public enum CommunitySetting public enum CommunitySetting

View File

@ -0,0 +1,18 @@
package mineplex.core.communities.data;
import mineplex.core.game.GameDisplay;
public interface ICommunity
{
Integer getId();
Integer getMemberCount();
String getName();
String getDescription();
GameDisplay getFavoriteGame();
Community.PrivacySetting getPrivacySetting();
}

View File

@ -3,7 +3,7 @@ package mineplex.core.communities.events;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import mineplex.core.communities.Community; import mineplex.core.communities.data.Community;
public class CommunityDisbandEvent extends Event public class CommunityDisbandEvent extends Event
{ {

View File

@ -3,7 +3,7 @@ package mineplex.core.communities.events;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import mineplex.core.communities.Community; import mineplex.core.communities.data.Community;
public class CommunityJoinRequestsUpdateEvent extends Event public class CommunityJoinRequestsUpdateEvent extends Event
{ {

View File

@ -3,7 +3,7 @@ package mineplex.core.communities.events;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import mineplex.core.communities.Community; import mineplex.core.communities.data.Community;
public class CommunityMembershipUpdateEvent extends Event public class CommunityMembershipUpdateEvent extends Event
{ {

View File

@ -3,7 +3,7 @@ package mineplex.core.communities.events;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import mineplex.core.communities.Community; import mineplex.core.communities.data.Community;
public class CommunityNameUpdateEvent extends Event public class CommunityNameUpdateEvent extends Event
{ {

View File

@ -3,7 +3,7 @@ package mineplex.core.communities.events;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import mineplex.core.communities.Community; import mineplex.core.communities.data.Community;
public class CommunitySettingUpdateEvent extends Event public class CommunitySettingUpdateEvent extends Event
{ {

View File

@ -7,35 +7,49 @@ import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilText;
import mineplex.core.communities.Community; import mineplex.core.communities.data.ICommunity;
import mineplex.core.communities.gui.buttons.CommunitiesGUIButton;
import mineplex.core.communities.gui.pages.CommunityMembersPage; import mineplex.core.communities.gui.pages.CommunityMembersPage;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
public class CommunityBrowserButton extends CommunitiesGUIButton public class CommunityBrowserButton extends CommunitiesGUIButton
{ {
private ICommunity _community;
private Player _viewer; private Player _viewer;
private Community _community;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public CommunityBrowserButton(Player viewer, Community community) public CommunityBrowserButton(Player viewer, ICommunity community)
{ {
super(new ItemBuilder(new ItemStack(community.getFavoriteGame().getMaterial(), 1, community.getFavoriteGame().getMaterialData(), null)).setTitle(C.cGreenB + community.getName()).addLore(UtilText.splitLinesToArray(new String[] {C.cRed, C.cYellow + "Members " + C.cWhite + community.getMembers().size(), C.cYellow + "Favorite Game " + C.cWhite + community.getFavoriteGame().getName(), C.cYellow + "Privacy " + C.cWhite + community.getPrivacySetting().getDisplayText(), C.cYellow + "Description " + C.cWhite + community.getDescription(), C.cBlue, C.cGreen + "Click to view community"}, LineFormat.LORE)).build()); super(createButton(community));
_viewer = viewer; _viewer = viewer;
_community = community; _community = community;
} }
@SuppressWarnings("deprecation") private static ItemStack createButton(ICommunity community)
{
return new ItemBuilder(new ItemStack(community.getFavoriteGame().getMaterial(), 1, community.getFavoriteGame().getMaterialData()))
.setTitle(C.cGreenB + community.getName())
.addLore(UtilText.splitLinesToArray(new String[] {
C.cRed,
C.cYellow + "Members " + C.cWhite + community.getMemberCount(),
C.cYellow + "Favorite Game " + C.cWhite + community.getFavoriteGame().getName(),
C.cYellow + "Privacy " + C.cWhite + community.getPrivacySetting().getDisplayText(),
C.cYellow + "Description " + C.cWhite + community.getDescription(),
C.cBlue,
C.cGreen + "Click to view community"}, LineFormat.LORE))
.build();
}
@Override @Override
public void update() public void update()
{ {
Button = new ItemBuilder(new ItemStack(_community.getFavoriteGame().getMaterial(), 1, _community.getFavoriteGame().getMaterialData(), null)).setTitle(C.cGreenB + _community.getName()).addLore(UtilText.splitLinesToArray(new String[] {C.cRed, C.cYellow + "Members " + C.cWhite + _community.getMembers().size(), C.cYellow + "Favorite Game " + C.cWhite + _community.getFavoriteGame().getName(), C.cYellow + "Privacy " + C.cWhite + _community.getPrivacySetting().getDisplayText(), C.cYellow + "Description " + C.cWhite + _community.getDescription(), C.cBlue, C.cGreen + "Click to view community"}, LineFormat.LORE)).build(); Button = createButton(_community);
} }
@Override @Override
public void handleClick(ClickType type) public void handleClick(ClickType type)
{ {
new CommunityMembersPage(_viewer, _community).open(); getCommunityManager().tempLoadCommunity(_community.getId(), community ->
new CommunityMembersPage(_viewer, community).open());
} }
} }

View File

@ -10,10 +10,9 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilText;
import mineplex.core.communities.Community; import mineplex.core.communities.data.Community;
import mineplex.core.communities.Community.PrivacySetting; import mineplex.core.communities.data.Community.PrivacySetting;
import mineplex.core.communities.CommunityRole; import mineplex.core.communities.data.CommunityRole;
import mineplex.core.communities.gui.buttons.CommunitiesGUIButton;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
public class CommunityButton extends CommunitiesGUIButton public class CommunityButton extends CommunitiesGUIButton

View File

@ -6,8 +6,7 @@ import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.communities.Community; import mineplex.core.communities.data.Community;
import mineplex.core.communities.gui.buttons.CommunitiesGUIButton;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
public class CommunityChatReadingButton extends CommunitiesGUIButton public class CommunityChatReadingButton extends CommunitiesGUIButton

View File

@ -3,10 +3,9 @@ package mineplex.core.communities.gui.buttons;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;
import mineplex.core.communities.Community; import mineplex.core.communities.data.Community;
import mineplex.core.communities.CommunityJoinRequestInfo; import mineplex.core.communities.data.CommunityJoinRequestInfo;
import mineplex.core.communities.CommunityRole; import mineplex.core.communities.data.CommunityRole;
import mineplex.core.communities.gui.buttons.CommunitiesGUIButton;
public class CommunityJoinRequestButton extends CommunitiesGUIButton public class CommunityJoinRequestButton extends CommunitiesGUIButton
{ {

View File

@ -7,11 +7,10 @@ import mineplex.core.Managers;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.communities.Community; import mineplex.core.communities.data.Community;
import mineplex.core.communities.CommunityManager; import mineplex.core.communities.CommunityManager;
import mineplex.core.communities.CommunityMemberInfo; import mineplex.core.communities.data.CommunityMemberInfo;
import mineplex.core.communities.CommunityRole; import mineplex.core.communities.data.CommunityRole;
import mineplex.core.communities.gui.buttons.CommunitiesGUIButton;
public class CommunityMemberButton extends CommunitiesGUIButton public class CommunityMemberButton extends CommunitiesGUIButton
{ {

View File

@ -13,11 +13,10 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData; import org.bukkit.material.MaterialData;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.communities.Community; import mineplex.core.communities.data.Community;
import mineplex.core.communities.Community.PrivacySetting; import mineplex.core.communities.data.Community.PrivacySetting;
import mineplex.core.communities.CommunityRole; import mineplex.core.communities.data.CommunityRole;
import mineplex.core.communities.CommunitySetting; import mineplex.core.communities.data.CommunitySetting;
import mineplex.core.communities.gui.buttons.CommunitiesGUIButton;
import mineplex.core.game.GameDisplay; import mineplex.core.game.GameDisplay;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;

View File

@ -8,8 +8,7 @@ import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilText;
import mineplex.core.communities.Community; import mineplex.core.communities.data.Community;
import mineplex.core.communities.gui.buttons.CommunitiesGUIButton;
import mineplex.core.communities.gui.pages.CommunityMembersPage; import mineplex.core.communities.gui.pages.CommunityMembersPage;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;

View File

@ -3,11 +3,14 @@ package mineplex.core.communities.gui.pages;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.bukkit.DyeColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.communities.data.ICommunity;
import mineplex.core.communities.events.CommunityBrowserUpdateEvent; import mineplex.core.communities.events.CommunityBrowserUpdateEvent;
import mineplex.core.communities.events.CommunityDisbandEvent; import mineplex.core.communities.events.CommunityDisbandEvent;
import mineplex.core.communities.CommunityManager; import mineplex.core.communities.CommunityManager;
@ -20,12 +23,11 @@ public class CommunityBrowserPage extends CommunitiesGUIPage
private static final int COMMUNITIES_PER_PAGE = 27; private static final int COMMUNITIES_PER_PAGE = 27;
private int _page = 1; private int _page = 1;
private boolean _loading = false;
private boolean _update = false;
private List<Integer> _displaying = new ArrayList<>(); private List<Integer> _displaying = new ArrayList<>();
//protected PrivacySetting PrivacyFilter = null;
//protected GameDisplay GameFilter = null;
public CommunityBrowserPage(Player viewer) public CommunityBrowserPage(Player viewer)
{ {
super("Community Browser", 6, viewer); super("Community Browser", 6, viewer);
@ -36,6 +38,12 @@ public class CommunityBrowserPage extends CommunitiesGUIPage
private void setup(int page, boolean initial) private void setup(int page, boolean initial)
{ {
if (_loading)
{
_update = true;
return;
}
if (initial) if (initial)
{ {
Buttons.clear(); Buttons.clear();
@ -80,45 +88,58 @@ public class CommunityBrowserPage extends CommunitiesGUIPage
Inv.setItem(53, next.Button); Inv.setItem(53, next.Button);
} }
CommunityManager manager = getCommunityManager(); final CommunityManager manager = getCommunityManager();
final List<Integer> browserIds = manager.getBrowserIds();
int slot = 18; _displaying.clear();
boolean cleared = false;
// Unload the old communities
manager.unloadDisplayCommunities(_displaying);
// Generate the list of ids we're going to display // Generate the list of ids we're going to display
_displaying.clear(); for (int i = (page - 1) * COMMUNITIES_PER_PAGE; i < (page - 1) * COMMUNITIES_PER_PAGE + COMMUNITIES_PER_PAGE && i < browserIds.size(); i++)
for (int i = (page - 1) * COMMUNITIES_PER_PAGE; i < (page - 1) * COMMUNITIES_PER_PAGE + COMMUNITIES_PER_PAGE && i < manager.getBrowserIds().size(); i++)
{ {
_displaying.add(manager.getBrowserIds().get(i)); _displaying.add(manager.getBrowserIds().get(i));
} }
// Temporarily load the new ones _loading = true;
manager.loadCommunitiesForDisplay(_displaying);
for (int i = (page - 1) * COMMUNITIES_PER_PAGE; i < (page - 1) * COMMUNITIES_PER_PAGE + COMMUNITIES_PER_PAGE && i < manager.getBrowserIds().size(); i++) // load the missing browser communities
manager.loadBrowserCommunities(_displaying, () ->
{ {
if (!cleared && !initial) _loading = false;
int slot = 18;
boolean cleared = false;
for (int i = (page - 1) * COMMUNITIES_PER_PAGE; i < (page - 1) * COMMUNITIES_PER_PAGE + COMMUNITIES_PER_PAGE && i < browserIds.size(); i++)
{ {
cleared = true; if (!cleared && !initial)
_page = page;
for (int clear = 18; clear < 45; clear++)
{ {
Buttons.remove(clear); cleared = true;
Inv.setItem(clear, null); _page = page;
for (int clear = 18; clear < 45; clear++)
{
Buttons.remove(clear);
Inv.setItem(clear, null);
}
} }
int id = browserIds.get(i);
ICommunity community = manager.getBrowserCommunity(id);
if (community == null)
{
Inv.setItem(slot, new ItemStack(Material.INK_SACK, 1, DyeColor.GRAY.getDyeData()));
} else
{
CommunityBrowserButton button = new CommunityBrowserButton(Viewer, community);
Buttons.put(slot, button);
Inv.setItem(slot, button.Button);
}
slot++;
} }
CommunityBrowserButton button = new CommunityBrowserButton(Viewer, getCommunityManager().getLoadedCommunity(manager.getBrowserIds().get(i)));
// _displaying.add(manager.getBrowserIds().get(i)); -- moved up
Buttons.put(slot, button);
Inv.setItem(slot, button.Button);
slot++; Viewer.updateInventory();
} });
Viewer.updateInventory();
} }
@EventHandler @EventHandler

View File

@ -8,13 +8,13 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.communities.Community; import mineplex.core.communities.data.Community;
import mineplex.core.communities.events.CommunityDisbandEvent; import mineplex.core.communities.events.CommunityDisbandEvent;
import mineplex.core.communities.CommunityJoinRequestInfo; import mineplex.core.communities.data.CommunityJoinRequestInfo;
import mineplex.core.communities.events.CommunityJoinRequestsUpdateEvent; import mineplex.core.communities.events.CommunityJoinRequestsUpdateEvent;
import mineplex.core.communities.events.CommunityMemberDataUpdateEvent; import mineplex.core.communities.events.CommunityMemberDataUpdateEvent;
import mineplex.core.communities.events.CommunityMembershipUpdateEvent; import mineplex.core.communities.events.CommunityMembershipUpdateEvent;
import mineplex.core.communities.CommunityRole; import mineplex.core.communities.data.CommunityRole;
import mineplex.core.communities.gui.buttons.ActionButton; import mineplex.core.communities.gui.buttons.ActionButton;
import mineplex.core.communities.gui.buttons.CommunityButton; import mineplex.core.communities.gui.buttons.CommunityButton;
import mineplex.core.communities.gui.buttons.CommunityChatReadingButton; import mineplex.core.communities.gui.buttons.CommunityChatReadingButton;

View File

@ -8,13 +8,13 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.communities.Community; import mineplex.core.communities.data.Community;
import mineplex.core.communities.events.CommunityDisbandEvent; import mineplex.core.communities.events.CommunityDisbandEvent;
import mineplex.core.communities.events.CommunityJoinRequestsUpdateEvent; import mineplex.core.communities.events.CommunityJoinRequestsUpdateEvent;
import mineplex.core.communities.events.CommunityMemberDataUpdateEvent; import mineplex.core.communities.events.CommunityMemberDataUpdateEvent;
import mineplex.core.communities.CommunityMemberInfo; import mineplex.core.communities.data.CommunityMemberInfo;
import mineplex.core.communities.events.CommunityMembershipUpdateEvent; import mineplex.core.communities.events.CommunityMembershipUpdateEvent;
import mineplex.core.communities.CommunityRole; import mineplex.core.communities.data.CommunityRole;
import mineplex.core.communities.gui.buttons.ActionButton; import mineplex.core.communities.gui.buttons.ActionButton;
import mineplex.core.communities.gui.buttons.CommunitiesGUIButton; import mineplex.core.communities.gui.buttons.CommunitiesGUIButton;
import mineplex.core.communities.gui.buttons.CommunityButton; import mineplex.core.communities.gui.buttons.CommunityButton;

View File

@ -7,7 +7,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.communities.Community; import mineplex.core.communities.data.Community;
import mineplex.core.communities.events.CommunityDisbandEvent; import mineplex.core.communities.events.CommunityDisbandEvent;
import mineplex.core.communities.events.CommunityMemberDataUpdateEvent; import mineplex.core.communities.events.CommunityMemberDataUpdateEvent;
import mineplex.core.communities.gui.buttons.ActionButton; import mineplex.core.communities.gui.buttons.ActionButton;

View File

@ -5,13 +5,13 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.communities.Community; import mineplex.core.communities.data.Community;
import mineplex.core.communities.events.CommunityDisbandEvent; import mineplex.core.communities.events.CommunityDisbandEvent;
import mineplex.core.communities.events.CommunityJoinRequestsUpdateEvent; import mineplex.core.communities.events.CommunityJoinRequestsUpdateEvent;
import mineplex.core.communities.events.CommunityMemberDataUpdateEvent; import mineplex.core.communities.events.CommunityMemberDataUpdateEvent;
import mineplex.core.communities.events.CommunityMembershipUpdateEvent; import mineplex.core.communities.events.CommunityMembershipUpdateEvent;
import mineplex.core.communities.CommunityRole; import mineplex.core.communities.data.CommunityRole;
import mineplex.core.communities.CommunitySetting; import mineplex.core.communities.data.CommunitySetting;
import mineplex.core.communities.events.CommunitySettingUpdateEvent; import mineplex.core.communities.events.CommunitySettingUpdateEvent;
import mineplex.core.communities.gui.buttons.ActionButton; import mineplex.core.communities.gui.buttons.ActionButton;
import mineplex.core.communities.gui.buttons.CommunitiesGUIButton; import mineplex.core.communities.gui.buttons.CommunitiesGUIButton;

View File

@ -3,7 +3,7 @@ package mineplex.core.communities.redis;
import java.util.UUID; import java.util.UUID;
import mineplex.core.communities.CommunityManager; import mineplex.core.communities.CommunityManager;
import mineplex.core.communities.CommunityRole; import mineplex.core.communities.data.CommunityRole;
import mineplex.serverdata.commands.CommandCallback; import mineplex.serverdata.commands.CommandCallback;
import mineplex.serverdata.commands.ServerCommand; import mineplex.serverdata.commands.ServerCommand;

View File

@ -1,7 +1,7 @@
package mineplex.core.communities.redis; package mineplex.core.communities.redis;
import mineplex.core.communities.CommunityManager; import mineplex.core.communities.CommunityManager;
import mineplex.core.communities.CommunitySetting; import mineplex.core.communities.data.CommunitySetting;
import mineplex.serverdata.commands.CommandCallback; import mineplex.serverdata.commands.CommandCallback;
import mineplex.serverdata.commands.ServerCommand; import mineplex.serverdata.commands.ServerCommand;

View File

@ -12,7 +12,7 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.communities.Community; import mineplex.core.communities.data.Community;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.serverdata.Region; import mineplex.serverdata.Region;
import mineplex.serverdata.data.ServerGroup; import mineplex.serverdata.data.ServerGroup;

View File

@ -41,10 +41,10 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.communities.Community; import mineplex.core.communities.data.Community;
import mineplex.core.communities.events.CommunityDisbandEvent; import mineplex.core.communities.events.CommunityDisbandEvent;
import mineplex.core.communities.CommunityManager; import mineplex.core.communities.CommunityManager;
import mineplex.core.communities.CommunityRole; import mineplex.core.communities.data.CommunityRole;
import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.portal.GenericServer; import mineplex.core.portal.GenericServer;
import mineplex.core.portal.Intent; import mineplex.core.portal.Intent;