Load communities in the login process, fix a few bugs

This commit is contained in:
Dan Mulloy 2018-06-15 12:28:52 -04:00 committed by Alexander Meech
parent 66bfcc9d9b
commit e0245b562c
8 changed files with 201 additions and 152 deletions

View File

@ -16,7 +16,6 @@ import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -42,7 +41,6 @@ import mineplex.core.common.util.UtilServer;
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;
@ -87,7 +85,6 @@ import mineplex.core.recharge.Recharge;
import mineplex.core.serverConfig.ServerConfiguration;
import mineplex.serverdata.Region;
import mineplex.serverdata.commands.ServerCommandManager;
import mineplex.serverdata.data.DataRepository;
import mineplex.serverdata.data.PlayerStatus;
import mineplex.serverdata.data.ServerGroup;
import mineplex.serverdata.redis.RedisDataRepository;
@ -119,25 +116,25 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
public final static String CHAT_PREFIX = "!";
public final static String COMMUNITY_CHAT_KEY = "core.communities.chat.selected";
public final static int MAX_NAME_LENGTH = 15;
private final static int MAX_NAME_LENGTH = 15;
private final int UPDATE_CYCLE_SECONDS = 10; // The number of seconds between dirty communities refreshes
private final int CACHE_INVALIDATION_SECONDS = 300; // The number of seconds between full communities refreshes
public final Pattern VALID_NAME_PATTERN = Pattern.compile("^[A-Za-z0-9]{1," + MAX_NAME_LENGTH + "}$");
private static final int UPDATE_CYCLE_SECONDS = 10; // The number of seconds between dirty communities refreshes
private static final int CACHE_INVALIDATION_SECONDS = 300; // The number of seconds between full communities refreshes
private final Pattern VALID_NAME_PATTERN = Pattern.compile("^[A-Za-z0-9]{1," + MAX_NAME_LENGTH + "}$");
public final Pattern NON_ALPHANUMERIC_PATTERN = Pattern.compile("[^A-Za-z0-9]");
public final List<String> BLOCKED_NAMES = Arrays.asList("help", "chat", "create", "description", "disband", "invite", "join", "mcs", "rename", "uninvite", "trainee", "mod", "moderator", "srmod", "seniormod", "seniormoderator", "builder", "maplead", "twitch", "youtube", "support", "admin", "administrator", "leader", "dev", "developer", "owner", "party", "mineplex", "mineplexofficial", "staff", "mineplexstaff", "qualityassurance", "traineemanagement", "modcoordination", "forumninja", "communitymanagement", "event", "socialmedia");
private final CommunityRepository _repo;
private final Map<Integer, Community> _loadedCommunities;
private final Map<Integer, BrowserCommunity> _browserCommunities;
private final Map<Integer, Community> _loadedCommunities = new ConcurrentHashMap<>();
private final Map<Integer, BrowserCommunity> _browserCommunities = new ConcurrentHashMap<>();
private final Random _rand = new Random();
private final List<Integer> _browserIds = new LinkedList<>();
private final List<UUID> _creating = new ArrayList<>();
private Integer mcsCommunity = null;
private boolean _us;
private Integer _mcsCommunity = null;
private Region _region;
private final Set<Community> _dirty = Collections.newSetFromMap(new ConcurrentHashMap<>()); // Communities with redis updates
@ -149,20 +146,16 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
private final CoreClientManager _clientManager;
private final CustomDataManager _customDataManager;
@SuppressWarnings("deprecation")
@SuppressWarnings({"deprecation", "unchecked"})
private CommunityManager()
{
super("Communities");
DataRepository<PlayerStatus> statusRepo = new RedisDataRepository<>(ServerManager.getMasterConnection(),
RedisDataRepository<PlayerStatus> statusRepo = new RedisDataRepository<>(ServerManager.getMasterConnection(),
ServerManager.getSlaveConnection(), Region.currentRegion(), PlayerStatus.class, "playerStatus");
_us = _plugin.getConfig().getBoolean("serverstatus.us");
_repo = new CommunityRepository(_plugin, statusRepo, _us);
_loadedCommunities = new ConcurrentHashMap<>();
_browserCommunities = new ConcurrentHashMap<>();
_region = Region.currentRegion();
_repo = new CommunityRepository(statusRepo, _region);
runAsync(() ->
{
@ -189,7 +182,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
while (resultSet.next())
{
String region = resultSet.getString("region");
if ((_us && region.equalsIgnoreCase("US")) || (!_us && region.equalsIgnoreCase("EU")))
if (region.equalsIgnoreCase(_region.name()))
{
CommunityManager.this.Get(uuid).Invites.add(resultSet.getInt("communityId"));
}
@ -225,12 +218,12 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
ServerGroup group = require(ServerConfiguration.class).getServerGroup();
if (group.getName().startsWith("COM-"))
{
mcsCommunity = Integer.valueOf(group.getName().split("-")[1]);
_mcsCommunity = Integer.valueOf(group.getName().split("-")[1]);
Community community = getLoadedCommunity(mcsCommunity);
Community community = getLoadedCommunity(_mcsCommunity);
if (community == null)
{
_repo.loadCommunity(_loadedCommunities, mcsCommunity);
_repo.loadCommunity(_loadedCommunities, _mcsCommunity);
}
}
@ -343,20 +336,30 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
public void loadBrowserCommunities(final List<Integer> displaying, final Runnable onComplete)
{
runAsync(() ->
final List<Integer> load = new ArrayList<>(displaying.size());
for (Integer id : displaying)
{
List<Integer> load = new ArrayList<>(displaying.size());
for (Integer id : displaying)
if (!_loadedCommunities.containsKey(id) && !_browserCommunities.containsKey(id))
{
if (!_loadedCommunities.containsKey(id) && !_browserCommunities.containsKey(id))
{
load.add(id);
}
load.add(id);
}
}
_repo.loadBrowserCommunities(_browserCommunities, load);
if (!load.isEmpty())
{
runAsync(() ->
{
_repo.loadBrowserCommunities(_browserCommunities, load);
if (onComplete != null)
{
runSync(onComplete);
}
});
} else if (onComplete != null)
{
runSync(onComplete);
});
}
}
public void tempLoadCommunity(final int id, final Consumer<Community> consumer)
@ -377,10 +380,9 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
return community != null ? community : _browserCommunities.get(id);
}
public void updateBrowserStatus(Community community)
private void updateBrowserStatus(ICommunity community)
{
_repo.updateBrowserStatus(community, community.getPrivacySetting() != PrivacySetting.PRIVATE
&& community.getMembers().size() >= 5);
_repo.updateBrowserStatus(community, community.isBrowserEligible());
}
public int getCount()
@ -676,7 +678,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
public void handleInvite(Player sender, Community community, String target)
{
CommunityJoinRequestInfo[] jr = community.getJoinRequests().values().stream().filter(data -> data.Name.equalsIgnoreCase(target)).toArray(size -> new CommunityJoinRequestInfo[size]);
CommunityJoinRequestInfo[] jr = community.getJoinRequests().values().stream().filter(data -> data.Name.equalsIgnoreCase(target)).toArray(CommunityJoinRequestInfo[]::new);
if (jr.length == 1)
{
UtilPlayer.message(sender, F.main(getName(), "You have accepted " + F.name(target) + "'s join request to " + F.name(community.getName()) + "!"));
@ -725,15 +727,15 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
});
}
public void handleRejectInvite(Player sender, Community community)
public void handleRejectInvite(Player sender, int id)
{
final String playerName = _clientManager.Get(sender).getName();
runAsync(() ->
{
_repo.deleteInviteToCommunity(community.getId(), playerName);
_repo.deleteInviteToCommunity(id, playerName);
});
new CommunityUnInvite(community.getId(), sender.getName(), sender.getName(), sender.getUniqueId().toString(), false).publish();
new CommunityUnInvite(id, sender.getName(), sender.getName(), sender.getUniqueId().toString(), false).publish();
}
public void handleJoinRequest(Player sender, Community community)
@ -768,7 +770,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
new CommunityCloseJoinRequest(community.getId(), sender.getName(), info.Name, info.UUID.toString(), info.AccountId, announce).publish();
}
public void handleJoin(Player sender, Community community, boolean fromInvite)
public void handleJoin(Player sender, ICommunity community, boolean fromInvite)
{
final int accountId = _clientManager.getAccountId(sender);
final String playerName = _clientManager.Get(sender).getName();
@ -780,6 +782,8 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
_repo.deleteInviteToCommunity(community.getId(), playerName);
}
updateBrowserStatus(community);
_repo.handlePlayerJoin(_loadedCommunities, Collections.singletonList(community.getId()), accountId);
_browserCommunities.remove(community.getId());
});
new CommunityUpdateMembership(community.getId(), sender.getName(), sender.getName(), sender.getUniqueId().toString(), accountId, false, false).publish();
if (fromInvite)
@ -901,18 +905,36 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
@Override
public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException
{
List<Integer> load = new ArrayList<>();
CommunityMemberData data = new CommunityMemberData();
while (resultSet.next())
{
Integer communityId = resultSet.getInt("communityId");
CommunityRole role = CommunityRole.parseRole(resultSet.getString("communityRole"));
String region = resultSet.getString("region");
if ((_us && region.equalsIgnoreCase("US")) || (!_us && region.equalsIgnoreCase("EU")))
if (region.equalsIgnoreCase(_region.name()))
{
data.joinCommunity(communityId, role);
if (getLoadedCommunity(communityId) == null)
{
load.add(communityId);
}
}
}
Set(uuid, data);
if (!load.isEmpty())
{
_browserCommunities.keySet().removeAll(load);
_repo.handlePlayerJoin(_loadedCommunities, load, accountId);
System.out.println("Loaded communities: " + load + "; Total: " + _loadedCommunities.size());
}
System.out.println("invites = " + data.Invites); // TODO debug
if (!data.Invites.isEmpty())
{
loadBrowserCommunities(data.Invites, null);
}
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
@ -992,44 +1014,25 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
{
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());
if (load.isEmpty())
{
return;
}
final int accountId = _clientManager.getAccountId(player);
_browserCommunities.keySet().removeAll(load);
runAsync(() ->
{
_repo.handlePlayerJoin(_loadedCommunities, load, accountId);
System.out.println("Loaded communities: " + load + "; Total: " + _loadedCommunities.size());
});
}
@EventHandler(priority = EventPriority.LOW)
public void onPlayerQuit(PlayerQuitEvent event)
{
// Remove their communities from memory if they're the last player
List<Integer> unloaded = new ArrayList<>();
Player player = event.getPlayer();
List<Community> communities = Get(player).getCommunities();
for (Community community : communities)
{
if (community.getId().equals(mcsCommunity)
if (community.getId().equals(_mcsCommunity)
|| community.getMembers().keySet().stream().anyMatch(uuid -> !player.getUniqueId().equals(uuid) && Bukkit.getPlayer(uuid) != null))
{
continue;
}
System.out.println("Unloading community: " + community.getId());
// If it's a browser community, keep some of the data
if (community.isBrowserEilgible())
if (community.isBrowserEligible())
{
_browserCommunities.put(community.getId(), community.toBrowser());
}
@ -1037,6 +1040,12 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
// Unload this community from memory
_dirty.remove(community);
_loadedCommunities.remove(community.getId());
unloaded.add(community.getId());
}
if (!unloaded.isEmpty())
{
System.out.println("Unloaded communities: " + unloaded + "; Total: " + _loadedCommunities.size());
}
}

View File

@ -22,7 +22,9 @@ 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.communities.data.ICommunity;
import mineplex.core.game.GameDisplay;
import mineplex.serverdata.Region;
import mineplex.serverdata.data.DataRepository;
import mineplex.serverdata.data.PlayerStatus;
import mineplex.serverdata.database.DBPool;
@ -30,6 +32,7 @@ import mineplex.serverdata.database.RepositoryBase;
import mineplex.serverdata.database.column.ColumnBoolean;
import mineplex.serverdata.database.column.ColumnInt;
import mineplex.serverdata.database.column.ColumnVarChar;
import mineplex.serverdata.redis.RedisDataRepository;
public class CommunityRepository extends RepositoryBase
{
@ -55,14 +58,14 @@ public class CommunityRepository extends RepositoryBase
private static final String SET_READING_CHAT_IN = "UPDATE communityMembers SET readingChat=? WHERE accountId=? AND communityId=?;";
private DataRepository<PlayerStatus> _repo;
private boolean _us;
private Region _region;
public CommunityRepository(JavaPlugin plugin, DataRepository<PlayerStatus> statusRepo, boolean us)
public CommunityRepository(RedisDataRepository<PlayerStatus> statusRepo, Region region)
{
super(DBPool.getAccount());
_repo = statusRepo;
_us = us;
_region = region;
}
public void communityExists(String name, Consumer<Boolean> result)
@ -188,7 +191,7 @@ public class CommunityRepository extends RepositoryBase
updateMembersAndJoinRequests(communities);
}
public void updateBrowserStatus(Community community, boolean flag)
public void updateBrowserStatus(ICommunity community, boolean flag)
{
updateCommunitySetting(CommunitySetting.SHOW_IN_BROWSER, community.getId(), String.valueOf(flag));
}
@ -285,7 +288,8 @@ public class CommunityRepository extends RepositoryBase
{
if (!com.isBrowserFlagSet())
{
updateBrowserStatus(com, com.isBrowserEilgible());
updateBrowserStatus(com, com.isBrowserEligible());
com.setBrowserFlag();
}
}
}
@ -444,7 +448,7 @@ public class CommunityRepository extends RepositoryBase
{
idCallback.run(-1);
}
}, () -> idCallback.run(-1), new ColumnVarChar("name", 15, name), new ColumnVarChar("region", 5, _us ? "US" : "EU"));
}, () -> idCallback.run(-1), new ColumnVarChar("name", 15, name), new ColumnVarChar("region", 5, _region.name()));
}
catch (SQLException e)
{

View File

@ -1,50 +0,0 @@
package mineplex.core.communities;
import org.bukkit.Material;
import mineplex.core.common.util.C;
public enum MCSTheme
{
CANDYLAND(1, C.cPurple + "Candyland", Material.COOKIE, 1000, "Lobby_MPS_Candyland.zip")
;
private final int _id;
private final String _displayName, _file;
private final Material _displayType;
private final int _cost;
private MCSTheme(int id, String displayName, Material displayType, int cost, String file)
{
_id = id;
_displayName = displayName;
_displayType = displayType;
_cost = cost;
_file = file;
}
public int getId()
{
return _id;
}
public String getDisplayName()
{
return _displayName;
}
public Material getDisplayType()
{
return _displayType;
}
public int getCost()
{
return _cost;
}
public String getFile()
{
return _file;
}
}

View File

@ -1,5 +1,7 @@
package mineplex.core.communities.data;
import com.google.common.base.Preconditions;
import mineplex.core.game.GameDisplay;
public class BrowserCommunity implements ICommunity
@ -15,6 +17,9 @@ public class BrowserCommunity implements ICommunity
{
_id = id;
_name = name;
_description = "No Description Set";
_favoriteGame = GameDisplay.ChampionsCTF;
_privacySetting = Community.PrivacySetting.RECRUITING;
}
@Override
@ -61,19 +66,19 @@ public class BrowserCommunity implements ICommunity
public BrowserCommunity setDescription(String description)
{
_description = description;
_description = Preconditions.checkNotNull(description);
return this;
}
public BrowserCommunity setFavoriteGame(GameDisplay favoriteGame)
{
_favoriteGame = favoriteGame;
_favoriteGame = Preconditions.checkNotNull(favoriteGame);
return this;
}
public BrowserCommunity setPrivacySetting(Community.PrivacySetting privacySetting)
{
_privacySetting = privacySetting;
_privacySetting = Preconditions.checkNotNull(privacySetting);
return this;
}
@ -88,4 +93,17 @@ public class BrowserCommunity implements ICommunity
{
return o == this || (o instanceof BrowserCommunity && ((BrowserCommunity) o)._id == _id);
}
@Override
public String toString()
{
return "BrowserCommunity{" +
"_id=" + _id +
", _members=" + _members +
", _name='" + _name + '\'' +
", _description='" + _description + '\'' +
", _favoriteGame=" + _favoriteGame +
", _privacySetting=" + _privacySetting +
'}';
}
}

View File

@ -1,6 +1,7 @@
package mineplex.core.communities.data;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
@ -152,11 +153,6 @@ public class Community implements ICommunity
.setMembers(getMemberCount());
}
public boolean isBrowserEilgible()
{
return getMemberCount() >= 5 && getPrivacySetting() != PrivacySetting.PRIVATE;
}
public enum PrivacySetting
{
OPEN("Open to Join"),
@ -188,5 +184,38 @@ public class Community implements ICommunity
return PrivacySetting.RECRUITING;
}
@Override
public String toString()
{
return _display;
}
}
@Override
public boolean equals(Object o)
{
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Community community = (Community) o;
return _id == community._id;
}
@Override
public int hashCode()
{
return Objects.hash(_id);
}
@Override
public String toString()
{
return "Community{" +
"_id=" + _id +
", _name='" + _name + '\'' +
", _description='" + _description + '\'' +
", _favoriteGame=" + _favoriteGame +
", _privacy=" + _privacy +
'}';
}
}

View File

@ -15,4 +15,9 @@ public interface ICommunity
GameDisplay getFavoriteGame();
Community.PrivacySetting getPrivacySetting();
default boolean isBrowserEligible()
{
return getPrivacySetting() != Community.PrivacySetting.PRIVATE && getMemberCount() >= 5;
}
}

View File

@ -9,16 +9,17 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilText;
import mineplex.core.communities.data.Community;
import mineplex.core.communities.data.ICommunity;
import mineplex.core.communities.gui.pages.CommunityMembersPage;
import mineplex.core.itemstack.ItemBuilder;
public class CommunityVisualizationButton extends CommunitiesGUIButton
{
private Player _viewer;
private Community _community;
private ICommunity _community;
private boolean _invite;
public CommunityVisualizationButton(Player viewer, Community community, boolean invite)
public CommunityVisualizationButton(Player viewer, ICommunity community, boolean invite)
{
super(new ItemBuilder(Material.BARRIER).build());
@ -28,15 +29,25 @@ public class CommunityVisualizationButton extends CommunitiesGUIButton
update();
}
@SuppressWarnings("deprecation")
@Override
public void update()
{
ItemBuilder builder = 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 + "Description " + C.cWhite + _community.getDescription()}, LineFormat.LORE));
ItemBuilder builder = 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 + "Description " + C.cWhite + _community.getDescription()}, LineFormat.LORE));
if (_invite)
{
builder.addLore(UtilText.splitLinesToArray(new String[] {C.cGold, C.cYellow + "Shift-Left Click " + C.cWhite + "Join", C.cYellow + "Shift-Right Click " + C.cWhite + "Decline"}, LineFormat.LORE));
builder.addLore(UtilText.splitLinesToArray(new String[] {
C.cGold,
C.cYellow + "Shift-Left Click " + C.cWhite + "Join",
C.cYellow + "Shift-Right Click " + C.cWhite + "Decline"}, LineFormat.LORE));
}
builder.addLore(C.cBlue, C.cGreen + "Click to view community");
Button = builder.build();
}
@ -46,7 +57,7 @@ public class CommunityVisualizationButton extends CommunitiesGUIButton
{
if (_invite && type == ClickType.SHIFT_RIGHT)
{
getCommunityManager().handleRejectInvite(_viewer, _community);
getCommunityManager().handleRejectInvite(_viewer, _community.getId());
}
else if (_invite && type == ClickType.SHIFT_LEFT)
{
@ -54,7 +65,8 @@ public class CommunityVisualizationButton extends CommunitiesGUIButton
}
else
{
new CommunityMembersPage(_viewer, _community).open();
getCommunityManager().tempLoadCommunity(_community.getId(), community ->
new CommunityMembersPage(_viewer, community));
}
}
}

View File

@ -1,10 +1,17 @@
package mineplex.core.communities.gui.pages;
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.CommunityManager;
import mineplex.core.communities.data.CommunityMemberData;
import mineplex.core.communities.data.ICommunity;
import mineplex.core.communities.events.CommunityDisbandEvent;
import mineplex.core.communities.events.CommunityMemberDataUpdateEvent;
import mineplex.core.communities.gui.buttons.ActionButton;
@ -70,29 +77,44 @@ public class CommunityInvitesPage extends CommunitiesGUIPage
Buttons.put(53, next);
Inv.setItem(53, next.Button);
}
int slot = 18;
boolean cleared = false;
for (int i = (page - 1) * COMMUNITIES_PER_PAGE; i < (page - 1) * COMMUNITIES_PER_PAGE + COMMUNITIES_PER_PAGE && i < getCommunityManager().Get(Viewer).Invites.size(); i++)
final CommunityManager manager = getCommunityManager();
final List<Integer> invites = manager.Get(Viewer).Invites;
manager.loadBrowserCommunities(invites, () ->
{
if (!cleared && !initial)
int slot = 18;
boolean cleared = false;
for (int i = (page - 1) * COMMUNITIES_PER_PAGE; i < (page - 1) * COMMUNITIES_PER_PAGE + COMMUNITIES_PER_PAGE && i < invites.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 communityId = invites.get(i);
ICommunity community = manager.getBrowserCommunity(communityId);
if (community == null)
{
Inv.setItem(slot, new ItemStack(Material.INK_SACK, 1, DyeColor.GRAY.getDyeData()));
} else
{
CommunityVisualizationButton button = new CommunityVisualizationButton(Viewer, community, true);
Buttons.put(slot, button);
Inv.setItem(slot, button.Button);
}
slot++;
}
CommunityVisualizationButton button = new CommunityVisualizationButton(Viewer, getCommunityManager().getLoadedCommunity(getCommunityManager().Get(Viewer).Invites.get(i)), true);
Buttons.put(slot, button);
Inv.setItem(slot, button.Button);
slot++;
}
Viewer.updateInventory();
Viewer.updateInventory();
});
}
@EventHandler