From 42e68d0d7f2f462a366f10839bddfe9d62c2a32d Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Thu, 14 Jun 2018 20:58:40 -0400 Subject: [PATCH] Redo how browser communities are stored, update members on join --- .../core/communities/CommunityManager.java | 211 ++++++++++-------- .../core/communities/CommunityRepository.java | 206 ++++++++++------- .../commands/CommunityChatCommand.java | 2 +- .../commands/CommunityCommand.java | 2 +- .../commands/CommunityCreateCommand.java | 4 - .../commands/CommunityDescriptionCommand.java | 8 +- .../commands/CommunityDisbandCommand.java | 6 +- .../commands/CommunityInviteCommand.java | 6 +- .../commands/CommunityJoinCommand.java | 4 +- .../commands/CommunityMCSCommand.java | 6 +- .../commands/CommunityRenameCommand.java | 9 +- .../commands/CommunityUnInviteCommand.java | 6 +- .../communities/data/BrowserCommunity.java | 91 ++++++++ .../communities/{ => data}/Community.java | 40 ++-- .../{ => data}/CommunityJoinRequestInfo.java | 2 +- .../{ => data}/CommunityMemberData.java | 8 +- .../{ => data}/CommunityMemberInfo.java | 2 +- .../communities/{ => data}/CommunityRole.java | 2 +- .../{ => data}/CommunitySetting.java | 4 +- .../core/communities/data/ICommunity.java | 18 ++ .../events/CommunityDisbandEvent.java | 2 +- .../CommunityJoinRequestsUpdateEvent.java | 2 +- .../CommunityMembershipUpdateEvent.java | 2 +- .../events/CommunityNameUpdateEvent.java | 2 +- .../events/CommunitySettingUpdateEvent.java | 2 +- .../gui/buttons/CommunityBrowserButton.java | 32 ++- .../gui/buttons/CommunityButton.java | 7 +- .../buttons/CommunityChatReadingButton.java | 3 +- .../buttons/CommunityJoinRequestButton.java | 7 +- .../gui/buttons/CommunityMemberButton.java | 7 +- .../gui/buttons/CommunitySettingButton.java | 9 +- .../buttons/CommunityVisualizationButton.java | 3 +- .../gui/pages/CommunityBrowserPage.java | 79 ++++--- .../gui/pages/CommunityJoinRequestsPage.java | 6 +- .../gui/pages/CommunityMembersPage.java | 6 +- .../gui/pages/CommunityOverviewPage.java | 2 +- .../gui/pages/CommunitySettingsPage.java | 6 +- .../CommunityUpdateMemberRoleHandler.java | 2 +- .../redis/CommunityUpdateSettingHandler.java | 2 +- .../personalServer/PersonalServerManager.java | 2 +- .../game/arcade/managers/GameHostManager.java | 4 +- 41 files changed, 510 insertions(+), 314 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/communities/data/BrowserCommunity.java rename Plugins/Mineplex.Core/src/mineplex/core/communities/{ => data}/Community.java (82%) rename Plugins/Mineplex.Core/src/mineplex/core/communities/{ => data}/CommunityJoinRequestInfo.java (96%) rename Plugins/Mineplex.Core/src/mineplex/core/communities/{ => data}/CommunityMemberData.java (92%) rename Plugins/Mineplex.Core/src/mineplex/core/communities/{ => data}/CommunityMemberInfo.java (98%) rename Plugins/Mineplex.Core/src/mineplex/core/communities/{ => data}/CommunityRole.java (92%) rename Plugins/Mineplex.Core/src/mineplex/core/communities/{ => data}/CommunitySetting.java (96%) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/communities/data/ICommunity.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityManager.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityManager.java index f28427bb6..2b351f800 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityManager.java @@ -5,6 +5,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.LinkedList; import java.util.List; 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.PlayerQuitEvent; -import mineplex.core.Managers; import mineplex.core.MiniDbClientPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; 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.UtilPlayer; import mineplex.core.common.util.UtilServer; -import mineplex.core.communities.Community.PrivacySetting; 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.CommunityDisbandEvent; import mineplex.core.communities.events.CommunityJoinRequestsUpdateEvent; @@ -121,19 +129,23 @@ public class CommunityManager extends MiniDbClientPlugin private final CommunityRepository _repo; private final Map _loadedCommunities; + private final Map _browserCommunities; private final Random _rand = new Random(); private final List _browserIds = new LinkedList<>(); private final List _creating = new ArrayList<>(); + private Integer mcsCommunity = null; private boolean _us; - private final Set dirty = Collections.newSetFromMap(new ConcurrentHashMap<>()); // Communities with redis updates + private final Set _dirty = Collections.newSetFromMap(new ConcurrentHashMap<>()); // Communities with redis updates private int _updateCycleCount; // The number of update cycles since we've updated all communities private volatile boolean _cycling = false; + private final Chat _chat; + private final PreferencesManager _prefManager; private final CoreClientManager _clientManager; private final CustomDataManager _customDataManager; @@ -150,13 +162,16 @@ public class CommunityManager extends MiniDbClientPlugin _repo = new CommunityRepository(_plugin, statusRepo, _us); _loadedCommunities = new ConcurrentHashMap<>(); + _browserCommunities = new ConcurrentHashMap<>(); runAsync(() -> { - _repo.loadBrowserCommunities(_browserIds); + _repo.loadBrowserIds(_browserIds); log("Loaded " + _browserIds.size() + " communities to show in browser"); }); + _chat = require(Chat.class); + _prefManager = require(PreferencesManager.class); _clientManager = require(CoreClientManager.class); _customDataManager = require(CustomDataManager.class); @@ -188,41 +203,9 @@ public class CommunityManager extends MiniDbClientPlugin } }); - Bukkit.getScheduler().scheduleAsyncRepeatingTask(_plugin, () -> - { - _updateCycleCount++; - - if (_cycling) - { - return; - } - - LinkedList 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().scheduleAsyncRepeatingTask(_plugin, this::runUpdateCycle, 0L, 20 * UPDATE_CYCLE_SECONDS); Bukkit.getScheduler().scheduleSyncRepeatingTask(_plugin, this::cycleBrowser, 0L, 20 * 30); - // Handled in join events now - // _repo.handlePlayerJoin(_loadedCommunities); - addCommand(new CommunityCommand(this)); ServerCommandManager.getInstance().registerCommandType(CommunityChat.class, new CommunityChatHandler(this)); @@ -242,19 +225,50 @@ public class CommunityManager extends MiniDbClientPlugin ServerGroup group = require(ServerConfiguration.class).getServerGroup(); if (group.getName().startsWith("COM-")) { - int comId = Integer.parseInt(group.getName().split("-")[1]); - Community community = getLoadedCommunity(comId); + mcsCommunity = Integer.valueOf(group.getName().split("-")[1]); + + Community community = getLoadedCommunity(mcsCommunity); if (community == null) { - community = _repo.loadCommunity(_loadedCommunities, comId); + _repo.loadCommunity(_loadedCommunities, mcsCommunity); } - - community.setFlag("persist", true); } generatePermissions(); } + private void runUpdateCycle() + { + _updateCycleCount++; + + if (_cycling) + { + return; + } + + List 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 communities) + { + _repo.updateMembersAndJoinRequests(communities); + } + private void generatePermissions() { PermissionGroup.ETERNAL.setPermission(Perm.OWN_COMMUNITY, true, true); @@ -288,7 +302,7 @@ public class CommunityManager extends MiniDbClientPlugin 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 result) @@ -327,28 +341,40 @@ public class CommunityManager extends MiniDbClientPlugin return _browserIds; } - public void loadCommunitiesForDisplay(List communities) + public void loadBrowserCommunities(final List displaying, final Runnable onComplete) { - List load = communities.stream().filter(com -> getLoadedCommunity(com) == null).collect(Collectors.toList()); - _repo.loadCommunities(_loadedCommunities, load); - - for (int id : load) + runAsync(() -> { - Community com = _loadedCommunities.get(id); - if (com != null) + List load = new ArrayList<>(displaying.size()); + 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 unload) + public void tempLoadCommunity(final int id, final Consumer consumer) { - unload.stream().filter(com -> + Community community = _loadedCommunities.get(id); + if (community != null) { - Community community = getLoadedCommunity(com); - return community == null || (community.getFlag("display") && !community.getFlag("persist")); - }).forEach(_loadedCommunities::remove); + consumer.accept(community); + return; + } + + 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) @@ -387,7 +413,7 @@ public class CommunityManager extends MiniDbClientPlugin { return; } - dirty.add(community); + _dirty.add(community); setting.parseValueInto(newValue, community); //community.message(F.main(getName(), F.name(sender) + " has changed settings in " + F.name(community.getName()) + "!")); runSync(() -> UtilServer.CallEvent(new CommunitySettingUpdateEvent(community))); @@ -400,7 +426,7 @@ public class CommunityManager extends MiniDbClientPlugin { return; } - dirty.add(community); + _dirty.add(community); String oldName = community.getName(); community.setName(name); 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 { return; } - dirty.add(community); + _dirty.add(community); CommunityMemberInfo member = community.getMembers().get(uuid); member.updateRole(role); if (Bukkit.getPlayer(uuid) != null) @@ -437,7 +463,7 @@ public class CommunityManager extends MiniDbClientPlugin { return; } - dirty.add(community); + _dirty.add(community); if (kick) { @@ -486,7 +512,7 @@ public class CommunityManager extends MiniDbClientPlugin { return; } - dirty.add(community); + _dirty.add(community); runSync(() -> { if (Bukkit.getPlayer(targetUUID) != null) @@ -494,7 +520,7 @@ public class CommunityManager extends MiniDbClientPlugin if (!Get(Bukkit.getPlayer(targetUUID)).Invites.contains(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)); } @@ -513,13 +539,13 @@ public class CommunityManager extends MiniDbClientPlugin { return; } - dirty.add(community); + _dirty.add(community); runSync(() -> { if (Bukkit.getPlayer(targetUUID) != null) { 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) + "!")); } @@ -539,7 +565,7 @@ public class CommunityManager extends MiniDbClientPlugin { return; } - dirty.add(community); + _dirty.add(community); if (Bukkit.getPlayer(playerUUID) != null) { 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 { return; } - dirty.add(community); + _dirty.add(community); community.getJoinRequests().remove(playerUUID); if (announce) { @@ -580,7 +606,7 @@ public class CommunityManager extends MiniDbClientPlugin runSync(() -> { Community community = _loadedCommunities.get(id); - dirty.add(community); + _dirty.add(community); if (Bukkit.getPlayer(leaderUUID) != null) { Player leader = Bukkit.getPlayer(leaderUUID); @@ -670,7 +696,7 @@ public class CommunityManager extends MiniDbClientPlugin { 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 { @@ -689,7 +715,7 @@ public class CommunityManager extends MiniDbClientPlugin { 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 { @@ -700,7 +726,7 @@ public class CommunityManager extends MiniDbClientPlugin 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(() -> { _repo.deleteInviteToCommunity(community.getId(), playerName); @@ -711,11 +737,11 @@ public class CommunityManager extends MiniDbClientPlugin 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())) { - 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(() -> { _repo.addToCommunity(accountId, community.getId()); @@ -743,8 +769,8 @@ public class CommunityManager extends MiniDbClientPlugin public void handleJoin(Player sender, Community community, boolean fromInvite) { - final int accountId = Managers.get(CoreClientManager.class).getAccountId(sender); - final String playerName = Managers.get(CoreClientManager.class).Get(sender).getName(); + final int accountId = _clientManager.getAccountId(sender); + final String playerName = _clientManager.Get(sender).getName(); runAsync(() -> { _repo.addToCommunity(accountId, community.getId()); @@ -855,7 +881,7 @@ public class CommunityManager extends MiniDbClientPlugin 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; runAsync(() -> @@ -887,17 +913,7 @@ public class CommunityManager extends MiniDbClientPlugin } 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) public void onChat(AsyncPlayerChatEvent event) { @@ -969,7 +985,14 @@ public class CommunityManager extends MiniDbClientPlugin { // Load their communities if it hasn't already been done Player player = event.getPlayer(); - Set 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 communityIds = data.getCommunityIds(); final List load = communityIds.stream().filter(id -> getLoadedCommunity(id) == null).collect(Collectors.toList()); if (load.isEmpty()) @@ -979,6 +1002,8 @@ public class CommunityManager extends MiniDbClientPlugin final int accountId = _clientManager.getAccountId(player); + _browserCommunities.keySet().removeAll(load); + runAsync(() -> { _repo.handlePlayerJoin(_loadedCommunities, load, accountId); @@ -994,7 +1019,7 @@ public class CommunityManager extends MiniDbClientPlugin List communities = Get(player).getCommunities(); 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)) { continue; @@ -1002,8 +1027,14 @@ public class CommunityManager extends MiniDbClientPlugin 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 - community.setFlag("unloaded", true); + _dirty.remove(community); _loadedCommunities.remove(community.getId()); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityRepository.java index ae5c8eef1..77ff0c236 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityRepository.java @@ -5,11 +5,8 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.HashSet; -import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.UUID; import java.util.function.Consumer; 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.util.Callback; -import mineplex.core.communities.Community; -import mineplex.core.communities.CommunityJoinRequestInfo; -import mineplex.core.communities.CommunityMemberInfo; -import mineplex.core.communities.CommunityRole; -import mineplex.core.communities.CommunitySetting; +import mineplex.core.communities.data.BrowserCommunity; +import mineplex.core.communities.data.Community; +import mineplex.core.communities.data.CommunityJoinRequestInfo; +import mineplex.core.communities.data.CommunityMemberInfo; +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.PlayerStatus; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; -import mineplex.serverdata.database.column.Column; import mineplex.serverdata.database.column.ColumnBoolean; import mineplex.serverdata.database.column.ColumnInt; 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_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_SETTINGS = "SELECT communityId, settingId, settingValue FROM communitySettings"; 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. * That is, they have 5 or more members and aren't private. */ - public void loadBrowserCommunities(final Collection store) + public void loadBrowserIds(final Collection store) { try (Connection connection = getConnection()) { @@ -103,21 +102,81 @@ public class CommunityRepository extends RepositoryBase } } + public void loadBrowserCommunities(final Map store, final List 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. */ public Community loadCommunity(final Map store, final int id) { - loadInternal(store, Collections.singletonList(id), -1); - return store.get(id); - } - - /** - * Loads all of the provided communities - */ - public void loadCommunities(final Map store, final List load) - { - loadInternal(store, load, -1); + return loadInternal(store, Collections.singletonList(id), -1).get(0); } /** @@ -125,7 +184,8 @@ public class CommunityRepository extends RepositoryBase */ public void handlePlayerJoin(final Map store, final List load, final int accountId) { - loadInternal(store, load, accountId); + List communities = loadInternal(store, load, accountId); + updateMembersAndJoinRequests(communities); } 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); } - private void loadInternal(final Map store, final List load, final int accountId) + private String getInClause(List 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 loadInternal(final Map store, final List load, final int accountId) + { + List communities = new ArrayList<>(); + try (Connection connection = getConnection()) { if (!load.isEmpty()) { - // Only load the info for communities with the given IDs - 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(); + String inClause = getInClause(load); ColumnInt[] idColumns = genIdColumns("id", load); executeQuery(connection, GET_COMMUNITIES_BY_ID + inClause.replace("%col", "id"), resultSet -> { while (resultSet.next()) { - final int id = resultSet.getInt("id"); - final String cName = resultSet.getString("name"); - final Community community = new Community(id, cName); + int id = resultSet.getInt("id"); + String cName = resultSet.getString("name"); + Community community = new Community(id, cName); + communities.add(community); store.put(id, community); } @@ -177,12 +243,12 @@ public class CommunityRepository extends RepositoryBase { while (memberSet.next()) { - final int communityId = memberSet.getInt("communityId"); - final int accountId1 = memberSet.getInt("accountId"); - final String name = memberSet.getString("name"); - final UUID uuid = UUID.fromString(memberSet.getString("uuid")); - final CommunityRole role = CommunityRole.parseRole(memberSet.getString("communityRole")); - final long lastLogin = memberSet.getTimestamp("lastLogin").getTime(); + int communityId = memberSet.getInt("communityId"); + int accountId1 = memberSet.getInt("accountId"); + String name = memberSet.getString("name"); + UUID uuid = UUID.fromString(memberSet.getString("uuid")); + CommunityRole role = CommunityRole.parseRole(memberSet.getString("communityRole")); + long lastLogin = memberSet.getTimestamp("lastLogin").getTime(); boolean readingChat = memberSet.getBoolean("readingChat"); CommunityMemberInfo info = new CommunityMemberInfo(name, uuid, accountId1, role, lastLogin); @@ -201,9 +267,9 @@ public class CommunityRepository extends RepositoryBase { while (settingSet.next()) { - final int communityId = settingSet.getInt("communityId"); - final int settingId = settingSet.getInt("settingId"); - final String value = settingSet.getString("settingValue"); + int communityId = settingSet.getInt("communityId"); + int settingId = settingSet.getInt("settingId"); + String value = settingSet.getString("settingValue"); Community community = store.get(communityId); CommunitySetting setting = CommunitySetting.getSetting(settingId); @@ -215,18 +281,11 @@ public class CommunityRepository extends RepositoryBase }, idColumns); // 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()) { - updateBrowserStatus(com, com.getPrivacySetting() != Community.PrivacySetting.PRIVATE && - com.getMembers().size() >= 5); + updateBrowserStatus(com, com.isBrowserEilgible()); } } } @@ -237,10 +296,9 @@ public class CommunityRepository extends RepositoryBase { while (requestSet.next()) { - final int communityId = requestSet.getInt("communityId"); - // final int accountId = requestSet.getInt("accountId"); - final UUID uuid = UUID.fromString(requestSet.getString("uuid")); - final String name = requestSet.getString("name"); + int communityId = requestSet.getInt("communityId"); + UUID uuid = UUID.fromString(requestSet.getString("uuid")); + String name = requestSet.getString("name"); Community community = store.get(communityId); if (community != null) @@ -255,6 +313,8 @@ public class CommunityRepository extends RepositoryBase System.err.println("Encountered an SQL exception loading communities " + load); ex.printStackTrace(); } + + return communities; } public void updateMembersAndJoinRequests(List communities) @@ -323,30 +383,6 @@ public class CommunityRepository extends RepositoryBase TimingManager.stop("members + join requests for " + communities.size() + " communities"); } - public void updateJoinRequests(LinkedList communities) - { - if (communities.isEmpty()) - { - return; - } - TimingManager.stop("request elements"); - } - - public void loadInvites(int accountId, List 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) { executeUpdate(REMOVE_FROM_COMMUNITY, new ColumnInt("accountId", accountId), new ColumnInt("communityId", communityId)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityChatCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityChatCommand.java index e19c067dc..34dbf6ad4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityChatCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityChatCommand.java @@ -6,7 +6,7 @@ import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.communities.Community; +import mineplex.core.communities.data.Community; import mineplex.core.communities.CommunityManager; public class CommunityChatCommand extends CommandBase diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCommand.java index 6f13d2436..93ed59351 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCommand.java @@ -6,7 +6,7 @@ import org.bukkit.entity.Player; import mineplex.core.command.MultiCommandBase; import mineplex.core.common.util.F; 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.gui.pages.CommunityMembersPage; import mineplex.core.communities.gui.pages.CommunityOverviewPage; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCreateCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCreateCommand.java index 5d4e52235..5b0c2e4b4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCreateCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityCreateCommand.java @@ -1,17 +1,13 @@ package mineplex.core.communities.commands; -import java.util.Arrays; - import org.bukkit.ChatColor; import org.bukkit.entity.Player; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; -import mineplex.core.chat.Chat; import mineplex.core.command.CommandBase; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.communities.Community; import mineplex.core.communities.CommunityManager; public class CommunityCreateCommand extends CommandBase diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityDescriptionCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityDescriptionCommand.java index 8d082251e..b11ef6a9a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityDescriptionCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityDescriptionCommand.java @@ -9,11 +9,11 @@ import mineplex.core.chat.Chat; import mineplex.core.command.CommandBase; import mineplex.core.common.util.F; 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.CommunityMemberInfo; -import mineplex.core.communities.CommunityRole; -import mineplex.core.communities.CommunitySetting; +import mineplex.core.communities.data.CommunityMemberInfo; +import mineplex.core.communities.data.CommunityRole; +import mineplex.core.communities.data.CommunitySetting; public class CommunityDescriptionCommand extends CommandBase { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityDisbandCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityDisbandCommand.java index ad4c5df97..dec2d6c99 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityDisbandCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityDisbandCommand.java @@ -8,10 +8,10 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.command.CommandBase; import mineplex.core.common.util.F; 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.CommunityMemberInfo; -import mineplex.core.communities.CommunityRole; +import mineplex.core.communities.data.CommunityMemberInfo; +import mineplex.core.communities.data.CommunityRole; public class CommunityDisbandCommand extends CommandBase { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityInviteCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityInviteCommand.java index fe2fec71c..294988ebb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityInviteCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityInviteCommand.java @@ -8,10 +8,10 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.command.CommandBase; import mineplex.core.common.util.F; 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.CommunityMemberInfo; -import mineplex.core.communities.CommunityRole; +import mineplex.core.communities.data.CommunityMemberInfo; +import mineplex.core.communities.data.CommunityRole; public class CommunityInviteCommand extends CommandBase { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityJoinCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityJoinCommand.java index e271430fd..53728d919 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityJoinCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityJoinCommand.java @@ -6,8 +6,8 @@ import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.communities.Community; -import mineplex.core.communities.Community.PrivacySetting; +import mineplex.core.communities.data.Community; +import mineplex.core.communities.data.Community.PrivacySetting; import mineplex.core.communities.CommunityManager; public class CommunityJoinCommand extends CommandBase diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityMCSCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityMCSCommand.java index d8232bf37..0592f06ec 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityMCSCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityMCSCommand.java @@ -8,10 +8,10 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.command.CommandBase; import mineplex.core.common.util.F; 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.CommunityMemberInfo; -import mineplex.core.communities.CommunityRole; +import mineplex.core.communities.data.CommunityMemberInfo; +import mineplex.core.communities.data.CommunityRole; import mineplex.core.personalServer.PersonalServerManager; public class CommunityMCSCommand extends CommandBase diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityRenameCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityRenameCommand.java index 9c647fd88..91b49e5b3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityRenameCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityRenameCommand.java @@ -1,20 +1,17 @@ package mineplex.core.communities.commands; -import java.util.Arrays; - import org.bukkit.ChatColor; import org.bukkit.entity.Player; import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; -import mineplex.core.chat.Chat; import mineplex.core.command.CommandBase; import mineplex.core.common.util.F; 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.CommunityMemberInfo; -import mineplex.core.communities.CommunityRole; +import mineplex.core.communities.data.CommunityMemberInfo; +import mineplex.core.communities.data.CommunityRole; public class CommunityRenameCommand extends CommandBase { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityUnInviteCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityUnInviteCommand.java index 02dfc01f3..d855c98f4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityUnInviteCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/commands/CommunityUnInviteCommand.java @@ -8,10 +8,10 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.command.CommandBase; import mineplex.core.common.util.F; 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.CommunityMemberInfo; -import mineplex.core.communities.CommunityRole; +import mineplex.core.communities.data.CommunityMemberInfo; +import mineplex.core.communities.data.CommunityRole; public class CommunityUnInviteCommand extends CommandBase { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/data/BrowserCommunity.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/data/BrowserCommunity.java new file mode 100644 index 000000000..018f838fc --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/data/BrowserCommunity.java @@ -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); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/Community.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/data/Community.java similarity index 82% rename from Plugins/Mineplex.Core/src/mineplex/core/communities/Community.java rename to Plugins/Mineplex.Core/src/mineplex/core/communities/data/Community.java index a2152f759..9eb2c183d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/Community.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/data/Community.java @@ -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.UUID; import java.util.concurrent.ConcurrentHashMap; @@ -12,7 +10,7 @@ import org.bukkit.ChatColor; import mineplex.core.common.util.UtilPlayer; import mineplex.core.game.GameDisplay; -public class Community +public class Community implements ICommunity { private final int _id; private String _name; @@ -25,14 +23,12 @@ public class Community private PrivacySetting _privacy; private boolean _showInBrowser; - private transient List flags = new ArrayList<>(); - public Community(int id, String name) { _id = id; _name = name; _description = "No Description Set"; - _chatFormat = new ChatColor[] {ChatColor.BLUE, ChatColor.RED, ChatColor.GREEN}; + _chatFormat = new ChatColor[] { ChatColor.BLUE, ChatColor.RED, ChatColor.GREEN }; _chatDelay = 1000; _favoriteGame = GameDisplay.ChampionsCTF; _privacy = PrivacySetting.RECRUITING; @@ -42,7 +38,13 @@ public class Community { return _id; } - + + @Override + public Integer getMemberCount() + { + return _members.size(); + } + public String getName() { 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)); } - public void setFlag(String flag, boolean value) + public BrowserCommunity toBrowser() { - if (value) - { - flags.add(flag.toLowerCase()); - } else - { - flags.remove(flag.toLowerCase()); - } + return new BrowserCommunity(getId(), getName()) + .setPrivacySetting(getPrivacySetting()) + .setFavoriteGame(getFavoriteGame()) + .setDescription(getDescription()) + .setMembers(getMemberCount()); } - 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"), RECRUITING("Accepting Join Requests"), @@ -166,7 +166,7 @@ public class Community private String _display; - private PrivacySetting(String display) + PrivacySetting(String display) { _display = display; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityJoinRequestInfo.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/data/CommunityJoinRequestInfo.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityJoinRequestInfo.java rename to Plugins/Mineplex.Core/src/mineplex/core/communities/data/CommunityJoinRequestInfo.java index 3e42d6bcd..1afa1ecac 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityJoinRequestInfo.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/data/CommunityJoinRequestInfo.java @@ -1,4 +1,4 @@ -package mineplex.core.communities; +package mineplex.core.communities.data; import java.util.UUID; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityMemberData.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/data/CommunityMemberData.java similarity index 92% rename from Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityMemberData.java rename to Plugins/Mineplex.Core/src/mineplex/core/communities/data/CommunityMemberData.java index fdc131801..2c39eab28 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityMemberData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/data/CommunityMemberData.java @@ -1,15 +1,13 @@ -package mineplex.core.communities; +package mineplex.core.communities.data; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import com.google.common.collect.ImmutableSet; - import mineplex.core.Managers; +import mineplex.core.communities.CommunityManager; public class CommunityMemberData { @@ -48,7 +46,7 @@ public class CommunityMemberData setCommunityChattingTo(community.getId()); } - Set getCommunityIds() + public Set getCommunityIds() { return _communities.keySet(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityMemberInfo.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/data/CommunityMemberInfo.java similarity index 98% rename from Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityMemberInfo.java rename to Plugins/Mineplex.Core/src/mineplex/core/communities/data/CommunityMemberInfo.java index 03e98963f..44af7c98b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityMemberInfo.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/data/CommunityMemberInfo.java @@ -1,4 +1,4 @@ -package mineplex.core.communities; +package mineplex.core.communities.data; import java.util.UUID; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityRole.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/data/CommunityRole.java similarity index 92% rename from Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityRole.java rename to Plugins/Mineplex.Core/src/mineplex/core/communities/data/CommunityRole.java index c98d7f0b9..c176e2a49 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityRole.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/data/CommunityRole.java @@ -1,4 +1,4 @@ -package mineplex.core.communities; +package mineplex.core.communities.data; public enum CommunityRole { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunitySetting.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/data/CommunitySetting.java similarity index 96% rename from Plugins/Mineplex.Core/src/mineplex/core/communities/CommunitySetting.java rename to Plugins/Mineplex.Core/src/mineplex/core/communities/data/CommunitySetting.java index 1ae99bbbc..11421a9e6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunitySetting.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/data/CommunitySetting.java @@ -1,10 +1,10 @@ -package mineplex.core.communities; +package mineplex.core.communities.data; import org.bukkit.ChatColor; import mineplex.core.common.Pair; import mineplex.core.common.util.Callback; -import mineplex.core.communities.Community.PrivacySetting; +import mineplex.core.communities.data.Community.PrivacySetting; import mineplex.core.game.GameDisplay; public enum CommunitySetting diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/data/ICommunity.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/data/ICommunity.java new file mode 100644 index 000000000..dc06eb1d0 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/data/ICommunity.java @@ -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(); +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/events/CommunityDisbandEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/events/CommunityDisbandEvent.java index 5b18fbb06..998d2e875 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/events/CommunityDisbandEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/events/CommunityDisbandEvent.java @@ -3,7 +3,7 @@ package mineplex.core.communities.events; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import mineplex.core.communities.Community; +import mineplex.core.communities.data.Community; public class CommunityDisbandEvent extends Event { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/events/CommunityJoinRequestsUpdateEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/events/CommunityJoinRequestsUpdateEvent.java index 6afd26aa2..81d1e4b8f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/events/CommunityJoinRequestsUpdateEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/events/CommunityJoinRequestsUpdateEvent.java @@ -3,7 +3,7 @@ package mineplex.core.communities.events; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import mineplex.core.communities.Community; +import mineplex.core.communities.data.Community; public class CommunityJoinRequestsUpdateEvent extends Event { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/events/CommunityMembershipUpdateEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/events/CommunityMembershipUpdateEvent.java index 10dea71df..30f54d8b1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/events/CommunityMembershipUpdateEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/events/CommunityMembershipUpdateEvent.java @@ -3,7 +3,7 @@ package mineplex.core.communities.events; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import mineplex.core.communities.Community; +import mineplex.core.communities.data.Community; public class CommunityMembershipUpdateEvent extends Event { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/events/CommunityNameUpdateEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/events/CommunityNameUpdateEvent.java index 8e49a03f4..84da68416 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/events/CommunityNameUpdateEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/events/CommunityNameUpdateEvent.java @@ -3,7 +3,7 @@ package mineplex.core.communities.events; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import mineplex.core.communities.Community; +import mineplex.core.communities.data.Community; public class CommunityNameUpdateEvent extends Event { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/events/CommunitySettingUpdateEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/events/CommunitySettingUpdateEvent.java index 184cc2d86..366aa5493 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/events/CommunitySettingUpdateEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/events/CommunitySettingUpdateEvent.java @@ -3,7 +3,7 @@ package mineplex.core.communities.events; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import mineplex.core.communities.Community; +import mineplex.core.communities.data.Community; public class CommunitySettingUpdateEvent extends Event { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunityBrowserButton.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunityBrowserButton.java index 5d37d49c9..836a02e6d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunityBrowserButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunityBrowserButton.java @@ -7,35 +7,49 @@ import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilText; -import mineplex.core.communities.Community; -import mineplex.core.communities.gui.buttons.CommunitiesGUIButton; +import mineplex.core.communities.data.ICommunity; import mineplex.core.communities.gui.pages.CommunityMembersPage; import mineplex.core.itemstack.ItemBuilder; public class CommunityBrowserButton extends CommunitiesGUIButton { + private ICommunity _community; private Player _viewer; - private Community _community; @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; _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 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 public void handleClick(ClickType type) { - new CommunityMembersPage(_viewer, _community).open(); + getCommunityManager().tempLoadCommunity(_community.getId(), community -> + new CommunityMembersPage(_viewer, community).open()); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunityButton.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunityButton.java index 61a7dbb8b..999ac3fdc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunityButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunityButton.java @@ -10,10 +10,9 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilText; -import mineplex.core.communities.Community; -import mineplex.core.communities.Community.PrivacySetting; -import mineplex.core.communities.CommunityRole; -import mineplex.core.communities.gui.buttons.CommunitiesGUIButton; +import mineplex.core.communities.data.Community; +import mineplex.core.communities.data.Community.PrivacySetting; +import mineplex.core.communities.data.CommunityRole; import mineplex.core.itemstack.ItemBuilder; public class CommunityButton extends CommunitiesGUIButton diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunityChatReadingButton.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunityChatReadingButton.java index 6b213f7eb..c9a5997bd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunityChatReadingButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunityChatReadingButton.java @@ -6,8 +6,7 @@ import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.C; -import mineplex.core.communities.Community; -import mineplex.core.communities.gui.buttons.CommunitiesGUIButton; +import mineplex.core.communities.data.Community; import mineplex.core.itemstack.ItemBuilder; public class CommunityChatReadingButton extends CommunitiesGUIButton diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunityJoinRequestButton.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunityJoinRequestButton.java index c177eaf21..0e03aee98 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunityJoinRequestButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunityJoinRequestButton.java @@ -3,10 +3,9 @@ package mineplex.core.communities.gui.buttons; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; -import mineplex.core.communities.Community; -import mineplex.core.communities.CommunityJoinRequestInfo; -import mineplex.core.communities.CommunityRole; -import mineplex.core.communities.gui.buttons.CommunitiesGUIButton; +import mineplex.core.communities.data.Community; +import mineplex.core.communities.data.CommunityJoinRequestInfo; +import mineplex.core.communities.data.CommunityRole; public class CommunityJoinRequestButton extends CommunitiesGUIButton { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunityMemberButton.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunityMemberButton.java index 19bfb0717..15a1cf6c2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunityMemberButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunityMemberButton.java @@ -7,11 +7,10 @@ import mineplex.core.Managers; import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.F; 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.CommunityMemberInfo; -import mineplex.core.communities.CommunityRole; -import mineplex.core.communities.gui.buttons.CommunitiesGUIButton; +import mineplex.core.communities.data.CommunityMemberInfo; +import mineplex.core.communities.data.CommunityRole; public class CommunityMemberButton extends CommunitiesGUIButton { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunitySettingButton.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunitySettingButton.java index 4247cbbe2..9d56745e2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunitySettingButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunitySettingButton.java @@ -13,11 +13,10 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.material.MaterialData; import mineplex.core.common.util.C; -import mineplex.core.communities.Community; -import mineplex.core.communities.Community.PrivacySetting; -import mineplex.core.communities.CommunityRole; -import mineplex.core.communities.CommunitySetting; -import mineplex.core.communities.gui.buttons.CommunitiesGUIButton; +import mineplex.core.communities.data.Community; +import mineplex.core.communities.data.Community.PrivacySetting; +import mineplex.core.communities.data.CommunityRole; +import mineplex.core.communities.data.CommunitySetting; import mineplex.core.game.GameDisplay; import mineplex.core.itemstack.ItemBuilder; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunityVisualizationButton.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunityVisualizationButton.java index b6ddae190..3f96aa60d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunityVisualizationButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/buttons/CommunityVisualizationButton.java @@ -8,8 +8,7 @@ import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilText; -import mineplex.core.communities.Community; -import mineplex.core.communities.gui.buttons.CommunitiesGUIButton; +import mineplex.core.communities.data.Community; import mineplex.core.communities.gui.pages.CommunityMembersPage; import mineplex.core.itemstack.ItemBuilder; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/pages/CommunityBrowserPage.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/pages/CommunityBrowserPage.java index 4bdb67c79..40ca2f400 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/pages/CommunityBrowserPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/pages/CommunityBrowserPage.java @@ -3,11 +3,14 @@ package mineplex.core.communities.gui.pages; import java.util.ArrayList; import java.util.List; +import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.C; +import mineplex.core.communities.data.ICommunity; import mineplex.core.communities.events.CommunityBrowserUpdateEvent; import mineplex.core.communities.events.CommunityDisbandEvent; import mineplex.core.communities.CommunityManager; @@ -20,12 +23,11 @@ public class CommunityBrowserPage extends CommunitiesGUIPage private static final int COMMUNITIES_PER_PAGE = 27; private int _page = 1; + private boolean _loading = false; + private boolean _update = false; private List _displaying = new ArrayList<>(); - //protected PrivacySetting PrivacyFilter = null; - //protected GameDisplay GameFilter = null; - public CommunityBrowserPage(Player viewer) { super("Community Browser", 6, viewer); @@ -36,6 +38,12 @@ public class CommunityBrowserPage extends CommunitiesGUIPage private void setup(int page, boolean initial) { + if (_loading) + { + _update = true; + return; + } + if (initial) { Buttons.clear(); @@ -80,45 +88,58 @@ public class CommunityBrowserPage extends CommunitiesGUIPage Inv.setItem(53, next.Button); } - CommunityManager manager = getCommunityManager(); - - int slot = 18; - boolean cleared = false; + final CommunityManager manager = getCommunityManager(); + final List browserIds = manager.getBrowserIds(); - // Unload the old communities - manager.unloadDisplayCommunities(_displaying); + _displaying.clear(); // 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 < manager.getBrowserIds().size(); i++) + for (int i = (page - 1) * COMMUNITIES_PER_PAGE; i < (page - 1) * COMMUNITIES_PER_PAGE + COMMUNITIES_PER_PAGE && i < browserIds.size(); i++) { _displaying.add(manager.getBrowserIds().get(i)); } - // Temporarily load the new ones - manager.loadCommunitiesForDisplay(_displaying); + _loading = true; - 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; - _page = page; - for (int clear = 18; clear < 45; clear++) + if (!cleared && !initial) { - Buttons.remove(clear); - Inv.setItem(clear, null); + cleared = true; + _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 diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/pages/CommunityJoinRequestsPage.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/pages/CommunityJoinRequestsPage.java index 4c94722b8..c881e7ca9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/pages/CommunityJoinRequestsPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/pages/CommunityJoinRequestsPage.java @@ -8,13 +8,13 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; 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.CommunityJoinRequestInfo; +import mineplex.core.communities.data.CommunityJoinRequestInfo; import mineplex.core.communities.events.CommunityJoinRequestsUpdateEvent; import mineplex.core.communities.events.CommunityMemberDataUpdateEvent; 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.CommunityButton; import mineplex.core.communities.gui.buttons.CommunityChatReadingButton; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/pages/CommunityMembersPage.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/pages/CommunityMembersPage.java index 1b37b2c03..d56c9cf92 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/pages/CommunityMembersPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/pages/CommunityMembersPage.java @@ -8,13 +8,13 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; 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.CommunityJoinRequestsUpdateEvent; 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.CommunityRole; +import mineplex.core.communities.data.CommunityRole; import mineplex.core.communities.gui.buttons.ActionButton; import mineplex.core.communities.gui.buttons.CommunitiesGUIButton; import mineplex.core.communities.gui.buttons.CommunityButton; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/pages/CommunityOverviewPage.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/pages/CommunityOverviewPage.java index 832070a31..3c5955697 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/pages/CommunityOverviewPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/pages/CommunityOverviewPage.java @@ -7,7 +7,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; 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.CommunityMemberDataUpdateEvent; import mineplex.core.communities.gui.buttons.ActionButton; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/pages/CommunitySettingsPage.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/pages/CommunitySettingsPage.java index 5d7cc26a8..081e0c33f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/pages/CommunitySettingsPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/pages/CommunitySettingsPage.java @@ -5,13 +5,13 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; 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.CommunityJoinRequestsUpdateEvent; import mineplex.core.communities.events.CommunityMemberDataUpdateEvent; import mineplex.core.communities.events.CommunityMembershipUpdateEvent; -import mineplex.core.communities.CommunityRole; -import mineplex.core.communities.CommunitySetting; +import mineplex.core.communities.data.CommunityRole; +import mineplex.core.communities.data.CommunitySetting; import mineplex.core.communities.events.CommunitySettingUpdateEvent; import mineplex.core.communities.gui.buttons.ActionButton; import mineplex.core.communities.gui.buttons.CommunitiesGUIButton; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/redis/CommunityUpdateMemberRoleHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/redis/CommunityUpdateMemberRoleHandler.java index bced0dc12..bbf58d7a5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/redis/CommunityUpdateMemberRoleHandler.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/redis/CommunityUpdateMemberRoleHandler.java @@ -3,7 +3,7 @@ package mineplex.core.communities.redis; import java.util.UUID; 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.ServerCommand; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/redis/CommunityUpdateSettingHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/redis/CommunityUpdateSettingHandler.java index 198a50694..b172d70fc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/redis/CommunityUpdateSettingHandler.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/redis/CommunityUpdateSettingHandler.java @@ -1,7 +1,7 @@ package mineplex.core.communities.redis; 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.ServerCommand; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java index 8d45312bc..958da0e72 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java @@ -12,7 +12,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.communities.Community; +import mineplex.core.communities.data.Community; import mineplex.core.recharge.Recharge; import mineplex.serverdata.Region; import mineplex.serverdata.data.ServerGroup; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java index 3376507dc..d7c02f7c7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java @@ -41,10 +41,10 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextBottom; 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.CommunityManager; -import mineplex.core.communities.CommunityRole; +import mineplex.core.communities.data.CommunityRole; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.portal.GenericServer; import mineplex.core.portal.Intent;