Bugfixes from iteration, & new features requested by sampson sigils and relyh

This commit is contained in:
AlexTheCoder 2016-12-15 20:51:41 -05:00 committed by cnr
parent 2cacbcbc1c
commit 2611ba7a7a
41 changed files with 647 additions and 163 deletions

View File

@ -109,6 +109,11 @@ public class Community
_privacy = privacy;
}
public void sendChat(String chat)
{
getMembers().values().stream().filter(info -> info.ReadingChat).forEach(member -> UtilPlayer.message(Bukkit.getPlayer(member.UUID), chat));
}
public void message(String message)
{
getMembers().values().forEach(member -> UtilPlayer.message(Bukkit.getPlayer(member.UUID), message));

View File

@ -29,7 +29,7 @@ public class CommunityJoinRequestInfo
ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM);
builder.setTitle(C.cGold + Name);
builder.setLore(C.cGray + "Left Click to Accept", C.cGray + "Right Click to Deny");
builder.setAmount((short)3);
builder.setData((short)3);
builder.setPlayerHead(Name);
_icon = builder.build();
}

View File

@ -7,6 +7,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import java.util.UUID;
import org.bukkit.Bukkit;
@ -22,9 +23,10 @@ import com.google.common.collect.Lists;
import mineplex.core.Managers;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.jsonchat.ClickEvent;
import mineplex.core.common.jsonchat.JsonMessage;
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.common.util.UtilServer;
import mineplex.core.communities.Community.PrivacySetting;
@ -43,6 +45,8 @@ import mineplex.core.communities.redis.CommunityJoinRequest;
import mineplex.core.communities.redis.CommunityJoinRequestHandler;
import mineplex.core.communities.redis.CommunityUnInvite;
import mineplex.core.communities.redis.CommunityUnInviteHandler;
import mineplex.core.communities.redis.CommunityUpdateMemberChatReading;
import mineplex.core.communities.redis.CommunityUpdateMemberChatReadingHandler;
import mineplex.core.communities.redis.CommunityUpdateMemberRole;
import mineplex.core.communities.redis.CommunityUpdateMemberRoleHandler;
import mineplex.core.communities.redis.CommunityUpdateMembership;
@ -65,6 +69,7 @@ import mineplex.serverdata.servers.ServerRepository;
public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
{
public final String[] BLOCKED_NAMES = new String[] {"help", "chat", "create", "description", "disband", "invite", "join", "mcs", "rename", "uninvite"};
private final CommunityRepository _repo;
private final Map<Integer, Community> _loadedCommunities;
@ -122,6 +127,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
ServerCommandManager.getInstance().registerCommandType(CommunityInvite.class, new CommunityInviteHandler(this));
ServerCommandManager.getInstance().registerCommandType(CommunityJoinRequest.class, new CommunityJoinRequestHandler(this));
ServerCommandManager.getInstance().registerCommandType(CommunityUnInvite.class, new CommunityUnInviteHandler(this));
ServerCommandManager.getInstance().registerCommandType(CommunityUpdateMemberChatReading.class, new CommunityUpdateMemberChatReadingHandler(this));
ServerCommandManager.getInstance().registerCommandType(CommunityUpdateMemberRole.class, new CommunityUpdateMemberRoleHandler(this));
ServerCommandManager.getInstance().registerCommandType(CommunityUpdateMembership.class, new CommunityUpdateMembershipHandler(this));
ServerCommandManager.getInstance().registerCommandType(CommunityUpdateName.class, new CommunityUpdateNameHandler(this));
@ -141,12 +147,10 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
List<Integer> ids = new LinkedList<>();
_loadedCommunities.values().stream().filter(c -> c.getMembers().size() >= 5 && c.getPrivacySetting() != PrivacySetting.PRIVATE).forEach(c -> resultant.add(c.getId()));
Random random = new Random();
while (!resultant.isEmpty())
{
if (UtilMath.random.nextBoolean())
{
ids.add(resultant.get(0));
}
ids.add(resultant.remove(random.nextInt(resultant.size())));
}
BrowserIds.clear();
@ -182,7 +186,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
return;
}
setting.parseValueInto(newValue, community);
community.message(F.main(getName(), F.name(sender) + " has changed settings in " + F.name(community.getName()) + "!"));
//community.message(F.main(getName(), F.name(sender) + " has changed settings in " + F.name(community.getName()) + "!"));
UtilServer.CallEvent(new CommunitySettingUpdateEvent(community));
}
@ -194,6 +198,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
return;
}
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()) + "!"));
UtilServer.CallEvent(new CommunityNameUpdateEvent(community));
}
@ -209,10 +214,11 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
member.Role = role;
if (Bukkit.getPlayer(uuid) != null)
{
UtilPlayer.message(Bukkit.getPlayer(uuid), F.main(getName(), F.name(sender) + " has changed your role to " + F.elem(role.getDisplay()) + " in " + F.name(community.getName()) + "!"));
Get(Bukkit.getPlayer(uuid)).setRoleIn(community, role);
}
String name = member.Name;
community.message(F.main(getName(), F.name(sender) + " has changed " + F.name(name + "'s") + " role to " + F.elem(role.getDisplay()) + " in " + F.name(community.getName()) + "!"));
community.message(F.main(getName(), F.name(sender) + " has changed " + F.name(name + "'s") + " role to " + F.elem(role.getDisplay()) + " in " + F.name(community.getName()) + "!"), CommunityRole.COLEADER);
UtilServer.CallEvent(new CommunityMembershipUpdateEvent(community));
}
@ -223,6 +229,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
{
return;
}
if (kick)
{
community.message(F.main(getName(), F.name(sender) + " has kicked " + F.name(playerName) + " from " + F.name(community.getName()) + "!"));
@ -272,10 +279,10 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
Get(Bukkit.getPlayer(targetUUID)).Invites.add(community.getId());
if (Managers.get(PreferencesManager.class).get(Bukkit.getPlayer(targetUUID)).isActive(Preference.COMMUNITY_INVITES))
{
UtilPlayer.message(Bukkit.getPlayer(targetUUID), F.main(getName(), "You have been invited to join " + F.elem(community.getName()) + " by " + F.name(sender) + "!"));
new JsonMessage(F.main(getName(), "You have been invited to join " + F.elem(community.getName()) + " by " + F.name(sender) + "! Click to join!")).click(ClickEvent.RUN_COMMAND, "/community join " + community.getName()).sendToPlayer(Bukkit.getPlayer(targetUUID));
}
}
community.message(F.main(getName(), F.name(sender) + " has invited " + F.name(targetName) + " to " + F.name(community.getName()) + "!"));
community.message(F.main(getName(), F.name(sender) + " has invited " + F.name(targetName) + " to " + F.name(community.getName()) + "!"), CommunityRole.COLEADER);
if (Bukkit.getPlayer(targetUUID) != null)
{
@ -300,7 +307,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
}
if (announce)
{
community.message(F.main(getName(), F.name(targetName) + "'s invitation to join " + F.name(community.getName()) + " has been revoked by " + F.name(sender) + "!"));
community.message(F.main(getName(), F.name(targetName) + "'s invitation to join " + F.name(community.getName()) + " has been revoked by " + F.name(sender) + "!"), CommunityRole.COLEADER);
}
if (Bukkit.getPlayer(targetUUID) != null)
@ -379,6 +386,28 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
BrowserIds.remove(community.getId());
}
public void handleToggleReadingCommunityChat(Integer id, UUID uuid, boolean reading)
{
Community community = _loadedCommunities.get(id);
if (community == null)
{
return;
}
if (community.getMembers().containsKey(uuid))
{
community.getMembers().get(uuid).ReadingChat = reading;
if (reading)
{
UtilPlayer.message(Bukkit.getPlayer(uuid), F.main(getName(), "You are now reading chat from " + F.name(community.getName()) + "!"));
}
else
{
UtilPlayer.message(Bukkit.getPlayer(uuid), F.main(getName(), "You are no longer reading chat from " + F.name(community.getName()) + "!"));
}
}
}
public void handleCommunityChat(Integer id, String senderName, String message)
{
Community community = _loadedCommunities.get(id);
@ -386,7 +415,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
{
return;
}
community.message(community.getChatFormatting()[0] + C.Bold + community.getName() + " " + community.getChatFormatting()[1] + C.Bold + senderName + " " + community.getChatFormatting()[2] + message);
community.sendChat(community.getChatFormatting()[0] + C.Bold + community.getName() + " " + community.getChatFormatting()[1] + C.Bold + senderName + " " + community.getChatFormatting()[2] + message);
}
public void handleInvite(Player sender, Community community, String target)
@ -457,13 +486,32 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
new CommunityJoinRequest(community.getId(), sender.getName(), sender.getUniqueId().toString(), accountId).publish();
}
public void handleCloseJoinRequest(Player sender, Community community, CommunityJoinRequestInfo info)
public void handleCloseJoinRequest(Player sender, Community community, CommunityJoinRequestInfo info, boolean announce)
{
runAsync(() ->
{
_repo.removeJoinRequest(community.getId(), info.AccountId);
});
new CommunityCloseJoinRequest(community.getId(), sender.getName(), info.Name, info.UUID.toString(), info.AccountId, true).publish();
new CommunityCloseJoinRequest(community.getId(), sender.getName(), info.Name, info.UUID.toString(), info.AccountId, announce).publish();
}
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();
runAsync(() ->
{
_repo.addToCommunity(accountId, community.getId());
if (fromInvite)
{
_repo.deleteInviteToCommunity(community.getId(), playerName);
}
});
new CommunityUpdateMembership(community.getId(), sender.getName(), sender.getName(), sender.getUniqueId().toString(), accountId, false, false).publish();
if (fromInvite)
{
new CommunityUnInvite(community.getId(), sender.getName(), sender.getName(), sender.getUniqueId().toString(), false).publish();
}
}
public void handleKick(Player sender, Community community, CommunityMemberInfo info)
@ -538,6 +586,18 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
});
new CommunityDisband(sender.getName(), community.getId()).publish();
}
public void handleToggleReadingChat(Player sender, Community community)
{
final int accountId = Managers.get(CoreClientManager.class).getAccountId(sender);
final boolean reading = !community.getMembers().get(sender.getUniqueId()).ReadingChat;
runAsync(() ->
{
_repo.setReadingChat(accountId, community.getId(), reading);
});
new CommunityUpdateMemberChatReading(community.getId(), sender.getUniqueId().toString(), reading).publish();
}
@Override
public String getQuery(int accountId, String uuid, String name)
@ -569,7 +629,13 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
runAsync(() ->
{
_repo.loadInvites(accountId, data.Invites);
UtilPlayer.message(event.getPlayer(), F.main(getName(), "You have been invited to join " + F.elem(data.Invites.size()) + " communities!"));
runSync(() ->
{
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!"));
}
});
});
}
@ -593,7 +659,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
{
if (Recharge.Instance.use(sender, "Community Chat to " + target.getId(), target.getChatDelay(), false, false))
{
new CommunityChat(sender.getName(), target.getId(), event.getMessage()).publish();
new CommunityChat(sender.getName(), target.getId(), event.getMessage().substring(1)).publish();
}
else
{

View File

@ -5,6 +5,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import mineplex.core.Managers;
public class CommunityMemberData
{
private final Map<Integer, CommunityRole> _communities = new HashMap<>();
@ -40,7 +42,14 @@ public class CommunityMemberData
public Community[] getCommunities()
{
return _communities.values().toArray(new Community[_communities.size()]);
Community[] communities = new Community[_communities.size()];
int index = 0;
for (Integer comId : _communities.keySet())
{
communities[index] = Managers.get(CommunityManager.class).getLoadedCommunity(comId);
index++;
}
return communities;
}
public boolean isMemberOf(Community community)

View File

@ -15,6 +15,8 @@ public class CommunityMemberInfo
public final UUID UUID;
public final int AccountId;
public CommunityRole Role;
public boolean OwnsCommunity = false;
public boolean ReadingChat = true;
private ItemStack _memberIcon, _outsiderIcon;
private long _sinceLastLogin;
private boolean _online = false;
@ -78,7 +80,7 @@ public class CommunityMemberInfo
ItemBuilder builder = new ItemBuilder(_memberIcon);
if (viewerRole == CommunityRole.LEADER && Role != CommunityRole.LEADER)
{
builder.addLore(C.cGreen + "Left Click to Promote");
builder.addLore(C.cGreen + (Role == CommunityRole.COLEADER ? "Shift " : "" ) + "Left Click to Promote");
if (Role != CommunityRole.MEMBER)
{
builder.addLore(C.cRed + "Right Click to Demote");

View File

@ -35,7 +35,7 @@ public class CommunityChatCommand extends CommandBase<CommunityManager>
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are not in " + F.name(c.getName()) + "!"));
return;
}
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are now chatting to " + F.name(c.getName()) + "!"));
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are now chatting to " + F.name(c.getName()) + "! Use " + F.elem("!") + " before your message to use community chat!"));
Plugin.Get(caller).setCommunityChattingTo(c);
}
}

View File

@ -9,6 +9,7 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.communities.Community;
import mineplex.core.communities.CommunityManager;
import mineplex.core.communities.gui.community.CommunityMembersPage;
import mineplex.core.communities.gui.overview.CommunityOverviewPage;
public class CommunityCommand extends MultiCommandBase<CommunityManager>
{
@ -21,8 +22,9 @@ public class CommunityCommand extends MultiCommandBase<CommunityManager>
AddCommand(new CommunityDescriptionCommand(plugin));
AddCommand(new CommunityDisbandCommand(plugin));
AddCommand(new CommunityInviteCommand(plugin));
AddCommand(new CommunityJoinCommand(plugin));
AddCommand(new CommunityMCSCommand(plugin));
AddCommand(new CommunityMenuCommand(plugin));
//AddCommand(new CommunityMenuCommand(plugin));
AddCommand(new CommunityRenameCommand(plugin));
AddCommand(new CommunityUnInviteCommand(plugin));
}
@ -32,6 +34,22 @@ public class CommunityCommand extends MultiCommandBase<CommunityManager>
{
if (args.length > 0)
{
if (args[0].equalsIgnoreCase("help"))
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "Community Commands:"));
UtilPlayer.message(caller, F.help("/com <community>", "Opens a community's menu", Rank.ALL));
//UtilPlayer.message(caller, F.help("/com menu", "Opens your community menu", Rank.ALL));
UtilPlayer.message(caller, F.help("/com invite <player> <community>", "Invites a player to a community you manage", Rank.ALL));
UtilPlayer.message(caller, F.help("/com uninvite <player> <community>", "Revokes a player's invitation to a community you manage", Rank.ALL));
UtilPlayer.message(caller, F.help("/com join <community>", "Joins a community that is open or you have been invited to", Rank.ALL));
UtilPlayer.message(caller, F.help("/com chat <community>", "Selects which community you chat to", Rank.ALL));
UtilPlayer.message(caller, F.help("/com create <name>", "Creates a new community", Rank.ETERNAL));
UtilPlayer.message(caller, F.help("/com rename <community> <name>", "Changes the name of a community you own", Rank.ETERNAL));
UtilPlayer.message(caller, F.help("/com mcs <community>", "Opens the Mineplex Community Server of a community you manage", Rank.ALL));
UtilPlayer.message(caller, F.help("/com description <community> <description>", "Sets the description of a community you manage", Rank.ALL));
UtilPlayer.message(caller, F.help("/com disband <community>", "Disbands a community you own", Rank.ETERNAL));
return;
}
Community community = Plugin.getLoadedCommunity(args[0]);
if (community == null)
{
@ -43,16 +61,7 @@ public class CommunityCommand extends MultiCommandBase<CommunityManager>
}
return;
}
UtilPlayer.message(caller, F.main(Plugin.getName(), "Community Commands:"));
UtilPlayer.message(caller, F.help("/com <community>", "Opens a community's menu", Rank.ALL));
UtilPlayer.message(caller, F.help("/com menu", "Opens your community menu", Rank.ALL));
UtilPlayer.message(caller, F.help("/com invite <player> <community>", "Invites a player to a community you manage", Rank.ALL));
UtilPlayer.message(caller, F.help("/com uninvite <player> <community>", "Revokes a player's invitation to a community you manage", Rank.ALL));
UtilPlayer.message(caller, F.help("/com chat <community>", "Selects which community you chat to", Rank.ALL));
UtilPlayer.message(caller, F.help("/com create <name>", "Creates a new community", Rank.ETERNAL));
UtilPlayer.message(caller, F.help("/com rename <community> <name>", "Changes the name of a community you own", Rank.ETERNAL));
UtilPlayer.message(caller, F.help("/com mcs <community>", "Opens the Mineplex Community Server of a community you manage", Rank.ALL));
UtilPlayer.message(caller, F.help("/com description <community> <description>", "Sets the description of a community you manage", Rank.ALL));
UtilPlayer.message(caller, F.help("/com disband <community>", "Disbands a community you own", Rank.ETERNAL));
}
new CommunityOverviewPage(caller);
}
}

View File

@ -1,8 +1,12 @@
package mineplex.core.communities.commands;
import java.util.Arrays;
import org.apache.commons.lang.StringUtils;
import org.bukkit.entity.Player;
import mineplex.core.Managers;
import mineplex.core.chat.Chat;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
@ -41,6 +45,21 @@ public class CommunityCreateCommand extends CommandBase<CommunityManager>
UtilPlayer.message(caller, F.main(Plugin.getName(), "A community name cannot be longer than 15 characters and must be alphanumeric!"));
return;
}
Plugin.handleCreate(caller, args[0]);
if (Arrays.asList(Plugin.BLOCKED_NAMES).contains(args[0].toLowerCase()))
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "That name is not appropriate!"));
return;
}
Plugin.runAsync(() ->
{
if (Managers.get(Chat.class).getFilteredMessage(caller, args[0]).contains("*"))
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "That name is not appropriate!"));
}
else
{
Plugin.handleCreate(caller, args[0]);
}
});
}
}

View File

@ -4,6 +4,7 @@ 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.Rank;
import mineplex.core.common.util.F;
@ -40,7 +41,7 @@ public class CommunityDescriptionCommand extends CommandBase<CommunityManager>
UtilPlayer.message(caller, F.main(Plugin.getName(), "That community was not found!"));
return;
}
if (c.getMembers().getOrDefault(caller, new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role.ordinal() > CommunityRole.COLEADER.ordinal())
if (c.getMembers().getOrDefault(caller.getUniqueId(), new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role.ordinal() > CommunityRole.COLEADER.ordinal())
{
if (!Managers.get(CoreClientManager.class).Get(caller).GetRank().has(Rank.ADMIN))
{
@ -53,7 +54,18 @@ public class CommunityDescriptionCommand extends CommandBase<CommunityManager>
UtilPlayer.message(caller, F.main(Plugin.getName(), "A community description cannot be longer than 30 characters!"));
return;
}
UtilPlayer.message(caller, F.main(Plugin.getName(), "You have changed the description of " + F.name(c.getName()) + " to " + desc + "!"));
Plugin.handleSettingUpdate(caller, c, CommunitySetting.DESCRIPTION, desc);
final String description = desc;
Plugin.runAsync(() ->
{
if (Managers.get(Chat.class).getFilteredMessage(caller, description).contains("*"))
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "That description is not appropriate!"));
}
else
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "You have changed the description of " + F.name(c.getName()) + " to " + description + "!"));
Plugin.handleSettingUpdate(caller, c, CommunitySetting.DESCRIPTION, description);
}
});
}
}

View File

@ -34,7 +34,7 @@ public class CommunityDisbandCommand extends CommandBase<CommunityManager>
UtilPlayer.message(caller, F.main(Plugin.getName(), "That community was not found!"));
return;
}
if (c.getMembers().getOrDefault(caller, new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role != CommunityRole.LEADER)
if (c.getMembers().getOrDefault(caller.getUniqueId(), new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role != CommunityRole.LEADER)
{
if (!Managers.get(CoreClientManager.class).Get(caller).GetRank().has(Rank.ADMIN))
{

View File

@ -35,7 +35,7 @@ public class CommunityInviteCommand extends CommandBase<CommunityManager>
UtilPlayer.message(caller, F.main(Plugin.getName(), "That community was not found!"));
return;
}
if (c.getMembers().getOrDefault(caller, new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role.ordinal() > CommunityRole.COLEADER.ordinal())
if (c.getMembers().getOrDefault(caller.getUniqueId(), new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role.ordinal() > CommunityRole.COLEADER.ordinal())
{
if (!Managers.get(CoreClientManager.class).Get(caller).GetRank().has(Rank.ADMIN))
{
@ -43,6 +43,14 @@ public class CommunityInviteCommand extends CommandBase<CommunityManager>
return;
}
}
for (CommunityMemberInfo info : c.getMembers().values())
{
if (info.Name.equalsIgnoreCase(player))
{
UtilPlayer.message(caller, F.main(Plugin.getName(), F.name(player) + " is already a member of " + F.name(c.getName()) + "!"));
return;
}
}
Plugin.handleInvite(caller, c, player);
}
}

View File

@ -0,0 +1,46 @@
package mineplex.core.communities.commands;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
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.CommunityManager;
public class CommunityJoinCommand extends CommandBase<CommunityManager>
{
public CommunityJoinCommand(CommunityManager plugin)
{
super(plugin, Rank.ALL, "join");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args.length < 1)
{
UtilPlayer.message(caller, F.help("/com join <community>", "Joins a community that is open or you have been invited to", Rank.ALL));
return;
}
Community c = Plugin.getLoadedCommunity(args[0]);
if (c == null)
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "That community was not found!"));
return;
}
if (c.getMembers().containsKey(caller.getUniqueId()))
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are already in " + F.name(c.getName()) + "!"));
return;
}
if (c.getPrivacySetting() != PrivacySetting.OPEN && !Plugin.Get(caller).Invites.contains(c.getId()))
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "You are have not been invited to " + F.name(c.getName()) + "!"));
return;
}
Plugin.handleJoin(caller, c, Plugin.Get(caller).Invites.contains(c.getId()));
}
}

View File

@ -35,7 +35,7 @@ public class CommunityMCSCommand extends CommandBase<CommunityManager>
UtilPlayer.message(caller, F.main(Plugin.getName(), "That community was not found!"));
return;
}
if (c.getMembers().getOrDefault(caller, new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role.ordinal() <= CommunityRole.COLEADER.ordinal())
if (c.getMembers().getOrDefault(caller.getUniqueId(), new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role.ordinal() > CommunityRole.COLEADER.ordinal())
{
if (!Managers.get(CoreClientManager.class).Get(caller).GetRank().has(Rank.ADMIN))
{

View File

@ -1,9 +1,12 @@
package mineplex.core.communities.commands;
import java.util.Arrays;
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.Rank;
import mineplex.core.common.util.F;
@ -35,7 +38,7 @@ public class CommunityRenameCommand extends CommandBase<CommunityManager>
UtilPlayer.message(caller, F.main(Plugin.getName(), "That community was not found!"));
return;
}
if (c.getMembers().getOrDefault(caller, new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role != CommunityRole.LEADER)
if (c.getMembers().getOrDefault(caller.getUniqueId(), new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role != CommunityRole.LEADER)
{
if (!Managers.get(CoreClientManager.class).Get(caller).GetRank().has(Rank.ADMIN))
{
@ -48,7 +51,22 @@ public class CommunityRenameCommand extends CommandBase<CommunityManager>
UtilPlayer.message(caller, F.main(Plugin.getName(), "A community already exists with that name!"));
return;
}
UtilPlayer.message(caller, F.main(Plugin.getName(), "You have changed the name of " + F.name(c.getName()) + " to " + F.name(newName) + "!"));
Plugin.handleNameUpdate(caller, c, newName);
if (Arrays.asList(Plugin.BLOCKED_NAMES).contains(newName.toLowerCase()))
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "That name is not appropriate!"));
return;
}
Plugin.runAsync(() ->
{
if (Managers.get(Chat.class).getFilteredMessage(caller, newName).contains("*"))
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "That name is not appropriate!"));
}
else
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "You have changed the name of " + F.name(c.getName()) + " to " + F.name(newName) + "!"));
Plugin.handleNameUpdate(caller, c, newName);
}
});
}
}

View File

@ -35,7 +35,7 @@ public class CommunityUnInviteCommand extends CommandBase<CommunityManager>
UtilPlayer.message(caller, F.main(Plugin.getName(), "That community was not found!"));
return;
}
if (c.getMembers().getOrDefault(caller, new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role.ordinal() > CommunityRole.COLEADER.ordinal())
if (c.getMembers().getOrDefault(caller.getUniqueId(), new CommunityMemberInfo(caller.getName(), caller.getUniqueId(), -1, CommunityRole.MEMBER, -1L)).Role.ordinal() > CommunityRole.COLEADER.ordinal())
{
if (!Managers.get(CoreClientManager.class).Get(caller).GetRank().has(Rank.ADMIN))
{

View File

@ -12,13 +12,13 @@ import mineplex.core.communities.gui.CommunitiesGUIButton;
import mineplex.core.communities.gui.community.CommunityMembersPage;
import mineplex.core.itemstack.ItemBuilder;
public class CommunityButton extends CommunitiesGUIButton
public class CommunityBrowserButton extends CommunitiesGUIButton
{
private Player _viewer;
private Community _community;
@SuppressWarnings("deprecation")
public CommunityButton(Player viewer, Community community)
public CommunityBrowserButton(Player viewer, Community community)
{
super(new ItemBuilder(new ItemStack(community.getFavoriteGame().getMaterial(), 1, community.getFavoriteGame().getMaterialData(), null)).setTitle(C.cGreen + community.getName()).addLore(UtilText.splitLinesToArray(new String[] {C.cGold + "Members: " + C.cGray + community.getMembers().size(), C.cGold + "Privacy: " + C.cGray + community.getPrivacySetting().getDisplayText(), C.cGold + "Favorite Game: " + C.cGray + community.getFavoriteGame().getName(), C.cGold + "Description: " + C.cGray + community.getDescription()}, LineFormat.LORE)).build());
@ -36,9 +36,6 @@ public class CommunityButton extends CommunitiesGUIButton
@Override
public void handleClick(ClickType type)
{
if (type == ClickType.SHIFT_LEFT)
{
new CommunityMembersPage(_viewer, _community).open();
}
new CommunityMembersPage(_viewer, _community).open();
}
}

View File

@ -12,7 +12,8 @@ import mineplex.core.communities.CommunityBrowserUpdateEvent;
import mineplex.core.communities.CommunityDisbandEvent;
import mineplex.core.communities.gui.ActionButton;
import mineplex.core.communities.gui.CommunitiesGUIPage;
import mineplex.core.communities.gui.community.CommunityButton;
import mineplex.core.communities.gui.overview.CommunityInvitesPage;
import mineplex.core.communities.gui.overview.CommunityOverviewPage;
import mineplex.core.itemstack.ItemBuilder;
public class CommunityBrowserPage extends CommunitiesGUIPage
@ -28,7 +29,7 @@ public class CommunityBrowserPage extends CommunitiesGUIPage
public CommunityBrowserPage(Player viewer)
{
super("Community Browser", 9 * 5, viewer);
super("Community Browser", 6, viewer);
setup(1, true);
open();
@ -41,22 +42,46 @@ public class CommunityBrowserPage extends CommunitiesGUIPage
Buttons.clear();
Inv.clear();
}
{
//1
ActionButton communitiesButton = new ActionButton(new ItemBuilder(Material.EMERALD).setTitle(C.cGold + "Your Communities").build(), clickType ->
{
new CommunityOverviewPage(Viewer).open();
});
Buttons.put(1, communitiesButton);
Inv.setItem(1, communitiesButton.Button);
//4
ActionButton browserButton = new ActionButton(new ItemBuilder(Material.COMPASS).setTitle(C.cGold + "Browse Communities").build(), clickType -> {});
Buttons.put(4, browserButton);
Inv.setItem(4, browserButton.Button);
//7
ActionButton invitesButton = new ActionButton(new ItemBuilder(Material.PAPER).setTitle(C.cGold + "Your Community Invites").build(), clickType ->
{
new CommunityInvitesPage(Viewer);
});
Buttons.put(7, invitesButton);
Inv.setItem(7, invitesButton.Button);
}
{
ActionButton back = new ActionButton(new ItemBuilder(Material.ARROW).setTitle(C.cRed + "Previous Page").build(), clickType ->
{
if (_page == 1)
{
return;
}
setup(_page - 1, false);
});
ActionButton next = new ActionButton(new ItemBuilder(Material.ARROW).setTitle(C.cGreen + "Next Page").build(), clickType ->
{
setup(_page + 1, false);
});
Buttons.put(27, back);
Inv.setItem(27, back.Button);
Buttons.put(35, next);
Inv.setItem(35, next.Button);
Buttons.put(45, back);
Inv.setItem(45, back.Button);
Buttons.put(53, next);
Inv.setItem(53, next.Button);
}
int slot = 0;
int slot = 18;
boolean cleared = false;
_displaying.clear();
for (int i = (page - 1) * COMMUNITIES_PER_PAGE; i < (page - 1) * COMMUNITIES_PER_PAGE + COMMUNITIES_PER_PAGE && i < getCommunityManager().BrowserIds.size(); i++)
@ -65,13 +90,13 @@ public class CommunityBrowserPage extends CommunitiesGUIPage
{
cleared = true;
_page = page;
for (int clear = 0; clear < 27; clear++)
for (int clear = 18; clear < 45; clear++)
{
Buttons.remove(clear);
Inv.setItem(clear, null);
}
}
CommunityButton button = new CommunityButton(Viewer, getCommunityManager().getLoadedCommunity(getCommunityManager().BrowserIds.get(i)));
CommunityBrowserButton button = new CommunityBrowserButton(Viewer, getCommunityManager().getLoadedCommunity(getCommunityManager().BrowserIds.get(i)));
_displaying.add(getCommunityManager().BrowserIds.get(i));
Buttons.put(slot, button);
Inv.setItem(slot, button.Button);

View File

@ -3,11 +3,16 @@ package mineplex.core.communities.gui.community;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
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.CommunityRole;
import mineplex.core.communities.Community.PrivacySetting;
import mineplex.core.communities.gui.CommunitiesGUIButton;
import mineplex.core.itemstack.ItemBuilder;
@ -18,45 +23,73 @@ public class CommunityButton extends CommunitiesGUIButton
public CommunityButton(Player viewer, Community community)
{
super(community.getMembers().containsKey(viewer.getUniqueId()) ?
new ItemBuilder(Material.EMERALD_BLOCK).setTitle(C.cGold + community.getName()).addLore(UtilText.splitLinesToArray(new String[] {C.cRed + "Description: " + C.cGray + community.getDescription(), C.cRed + "Members: " + C.cGray + community.getMembers().size(), C.cRed, C.cDRed + "Shift Left Click to Leave"}, LineFormat.LORE)).build()
: (!community.getJoinRequests().containsKey(viewer.getUniqueId()) ?
new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(C.cGold + community.getName()).addLore(UtilText.splitLinesToArray(new String[] {C.cRed + "Description: " + C.cGray + community.getDescription(), C.cRed + "Members: " + C.cGray + community.getMembers().size(), C.cRed, C.cDRed + "Shift Left Click to Request to Join"}, LineFormat.LORE)).build() :
new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(C.cGold + community.getName()).addLore(UtilText.splitLinesToArray(new String[] {C.cRed + "Description: " + C.cGray + community.getDescription(), C.cRed + "Members: " + C.cGray + community.getMembers().size(), C.cRed, C.cDRed + "Join Request Pending"}, LineFormat.LORE)).build()));
super(getDisplay(community, viewer));
_viewer = viewer;
_community = community;
}
private static ItemStack getDisplay(Community community, Player viewer)
{
ItemStack item = new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(C.cGold + community.getName()).addLore(UtilText.splitLinesToArray(new String[] {C.cRed + "Description: " + C.cGray + community.getDescription(), C.cRed + "Members: " + C.cGray + community.getMembers().size(), C.cRed, C.cGreen + "Shift Left Click to Request to Join"}, LineFormat.LORE)).build();
if (community.getMembers().containsKey(viewer.getUniqueId()))
{
item = new ItemBuilder(Material.EMERALD_BLOCK).setTitle(C.cGold + community.getName()).addLore(UtilText.splitLinesToArray(new String[] {C.cRed + "Description: " + C.cGray + community.getDescription(), C.cRed + "Members: " + C.cGray + community.getMembers().size(), C.cRed, C.cGray + "Right Click to Toggle Chat View", C.cDRed + "Shift Left Click to Leave"}, LineFormat.LORE)).build();
}
else if (community.getJoinRequests().containsKey(viewer.getUniqueId()))
{
item = new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(C.cGold + community.getName()).addLore(UtilText.splitLinesToArray(new String[] {C.cRed + "Description: " + C.cGray + community.getDescription(), C.cRed + "Members: " + C.cGray + community.getMembers().size(), C.cRed, C.cGold + "Join Request Pending", C.cGold + "Shift Left Click to Cancel"}, LineFormat.LORE)).build();
}
else if (getCommunityManager().Get(viewer).Invites.contains(community.getId()) || community.getPrivacySetting() == PrivacySetting.OPEN)
{
item = new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(C.cGold + community.getName()).addLore(UtilText.splitLinesToArray(new String[] {C.cRed + "Description: " + C.cGray + community.getDescription(), C.cRed + "Members: " + C.cGray + community.getMembers().size(), C.cRed, C.cGreen + "Shift Left Click to Join"}, LineFormat.LORE)).build();
}
return item;
}
@Override
public void update()
{
if (_community.getMembers().containsKey(_viewer.getUniqueId()))
{
Button = new ItemBuilder(Material.EMERALD_BLOCK).setTitle(C.cGold + _community.getName()).addLore(UtilText.splitLinesToArray(new String[] {C.cRed + "Description: " + C.cGray + _community.getDescription(), C.cRed + "Members: " + C.cGray + _community.getMembers().size(), C.cRed, C.cDRed + "Shift Left Click to Leave"}, LineFormat.LORE)).build();
}
if (!_community.getJoinRequests().containsKey(_viewer.getUniqueId()))
{
Button = new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(C.cGold + _community.getName()).addLore(UtilText.splitLinesToArray(new String[] {C.cRed + "Description: " + C.cGray + _community.getDescription(), C.cRed + "Members: " + C.cGray + _community.getMembers().size(), C.cRed, C.cDRed + "Shift Left Click to Request to Join"}, LineFormat.LORE)).build();
}
else
{
Button = new ItemBuilder(Material.REDSTONE_BLOCK).setTitle(C.cGold + _community.getName()).addLore(UtilText.splitLinesToArray(new String[] {C.cRed + "Description: " + C.cGray + _community.getDescription(), C.cRed + "Members: " + C.cGray + _community.getMembers().size(), C.cRed, C.cDRed + "Join Request Pending"}, LineFormat.LORE)).build();
}
Button = getDisplay(_community, _viewer);
}
@Override
public void handleClick(ClickType type)
{
if (type == ClickType.RIGHT)
{
if (_community.getMembers().containsKey(_viewer.getUniqueId()))
{
getCommunityManager().handleToggleReadingChat(_viewer, _community);
}
}
if (type == ClickType.SHIFT_LEFT)
{
if (_community.getMembers().containsKey(_viewer.getUniqueId()))
{
if (_community.getMembers().get(_viewer.getUniqueId()).Role == CommunityRole.LEADER)
{
UtilPlayer.message(_viewer, F.main(getCommunityManager().getName(), "You cannot leave " + F.name(_community.getName()) + " without passing on leadership first!"));
return;
}
getCommunityManager().handleLeave(_viewer, _community, _community.getMembers().get(_viewer.getUniqueId()));
}
else if (!_community.getJoinRequests().containsKey(_viewer.getUniqueId()))
else if (_community.getJoinRequests().containsKey(_viewer.getUniqueId()))
{
getCommunityManager().handleJoinRequest(_viewer, _community);
getCommunityManager().handleCloseJoinRequest(_viewer, _community, _community.getJoinRequests().get(_viewer.getUniqueId()), false);
}
else if (getCommunityManager().Get(_viewer).Invites.contains(_community.getId()) || _community.getPrivacySetting() == PrivacySetting.OPEN)
{
getCommunityManager().handleJoin(_viewer, _community, getCommunityManager().Get(_viewer).Invites.contains(_community.getId()));
}
else
{
if (_community.getPrivacySetting() != PrivacySetting.PRIVATE)
{
getCommunityManager().handleJoinRequest(_viewer, _community);
}
}
}
}

View File

@ -43,7 +43,7 @@ public class CommunityJoinRequestButton extends CommunitiesGUIButton
{
if (getCommunityManager().Get(_viewer).getRoleIn(_community) != null && getCommunityManager().Get(_viewer).getRoleIn(_community).ordinal() <= CommunityRole.COLEADER.ordinal())
{
getCommunityManager().handleCloseJoinRequest(_viewer, _community, _info);
getCommunityManager().handleCloseJoinRequest(_viewer, _community, _info, true);
}
}
}

View File

@ -12,6 +12,7 @@ import mineplex.core.communities.Community;
import mineplex.core.communities.CommunityDisbandEvent;
import mineplex.core.communities.CommunityJoinRequestInfo;
import mineplex.core.communities.CommunityJoinRequestsUpdateEvent;
import mineplex.core.communities.CommunityMemberDataUpdateEvent;
import mineplex.core.communities.CommunityMembershipUpdateEvent;
import mineplex.core.communities.CommunityRole;
import mineplex.core.communities.gui.ActionButton;
@ -28,7 +29,7 @@ public class CommunityJoinRequestsPage extends CommunitiesGUIPage
public CommunityJoinRequestsPage(Player viewer, Community community)
{
super(C.cGold + community.getName() + C.cBlack, 6, viewer);
super(community.getName() + C.cBlack, 6, viewer);
_community = community;
setup(1, true);
@ -78,6 +79,10 @@ public class CommunityJoinRequestsPage extends CommunitiesGUIPage
{
ActionButton back = new ActionButton(new ItemBuilder(Material.ARROW).setTitle(C.cRed + "Previous Page").build(), clickType ->
{
if (_page == 1)
{
return;
}
setup(_page - 1, false);
});
ActionButton next = new ActionButton(new ItemBuilder(Material.ARROW).setTitle(C.cGreen + "Next Page").build(), clickType ->
@ -159,4 +164,15 @@ public class CommunityJoinRequestsPage extends CommunitiesGUIPage
Viewer.closeInventory();
}
}
@EventHandler
public void onMembershipUpdate(CommunityMemberDataUpdateEvent event)
{
if (!event.getPlayer().getUniqueId().toString().equalsIgnoreCase(Viewer.getUniqueId().toString()))
{
return;
}
setup(1, false);
}
}

View File

@ -44,7 +44,7 @@ public class CommunityMemberButton extends CommunitiesGUIButton
getCommunityManager().handleKick(_viewer, _community, _info);
}
}
if (type == ClickType.LEFT)
if (type == ClickType.LEFT || type == ClickType.SHIFT_LEFT)
{
if (getCommunityManager().Get(_viewer).getRoleIn(_community) != null && getCommunityManager().Get(_viewer).getRoleIn(_community) == CommunityRole.LEADER && _info.Role != CommunityRole.LEADER)
{
@ -52,8 +52,13 @@ public class CommunityMemberButton extends CommunitiesGUIButton
{
getCommunityManager().handleRoleUpdate(_viewer, _community, _info, CommunityRole.COLEADER);
}
if (_info.Role == CommunityRole.COLEADER)
if (_info.Role == CommunityRole.COLEADER && type == ClickType.SHIFT_LEFT)
{
if (_info.OwnsCommunity)
{
UtilPlayer.message(_viewer, F.main(getCommunityManager().getName(), F.name(_info.Name) + " can only own one community at a time!"));
return;
}
if (!Rank.valueOf(Managers.get(CoreClientManager.class).loadOfflineClient(_info.UUID).Rank).has(Rank.ETERNAL))
{
UtilPlayer.message(_viewer, F.main(getCommunityManager().getName(), "Only Eternal rank and above can own a community!"));

View File

@ -10,6 +10,7 @@ import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C;
import mineplex.core.communities.Community;
import mineplex.core.communities.CommunityDisbandEvent;
import mineplex.core.communities.CommunityMemberDataUpdateEvent;
import mineplex.core.communities.CommunityMemberInfo;
import mineplex.core.communities.CommunityMembershipUpdateEvent;
import mineplex.core.communities.CommunityRole;
@ -27,7 +28,7 @@ public class CommunityMembersPage extends CommunitiesGUIPage
public CommunityMembersPage(Player viewer, Community community)
{
super(C.cGold + community.getName() + C.cAqua, 6, viewer);
super(community.getName() + C.cAqua, 6, viewer);
_community = community;
setup(1, true);
@ -77,6 +78,10 @@ public class CommunityMembersPage extends CommunitiesGUIPage
{
ActionButton back = new ActionButton(new ItemBuilder(Material.ARROW).setTitle(C.cRed + "Previous Page").build(), clickType ->
{
if (_page == 1)
{
return;
}
setup(_page - 1, false);
});
ActionButton next = new ActionButton(new ItemBuilder(Material.ARROW).setTitle(C.cGreen + "Next Page").build(), clickType ->
@ -150,4 +155,15 @@ public class CommunityMembersPage extends CommunitiesGUIPage
Viewer.closeInventory();
}
}
@EventHandler
public void onMembershipUpdate(CommunityMemberDataUpdateEvent event)
{
if (!event.getPlayer().getUniqueId().toString().equalsIgnoreCase(Viewer.getUniqueId().toString()))
{
return;
}
setup(1, false);
}
}

View File

@ -9,6 +9,8 @@ import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import mineplex.core.common.util.C;
import mineplex.core.communities.Community;
@ -80,12 +82,13 @@ public class CommunitySettingButton extends CommunitiesGUIButton
update();
}
@SuppressWarnings("deprecation")
@Override
public void update()
{
if (_setting == CommunitySetting.FAVORITE_GAME)
{
Button = new ItemBuilder(Material.SKULL_ITEM).setData((short)4).setTitle(C.cGreen + "Favorite Game").addLore(C.cGold + "Currently: " + C.cGray + _community.getFavoriteGame().getName()).build();
Button = new ItemBuilder(new ItemStack(_community.getFavoriteGame().getMaterial(), 1, _community.getFavoriteGame().getMaterialData(), null)).setTitle(C.cGreen + "Favorite Game").addLore(C.cGold + "Currently: " + C.cGray + _community.getFavoriteGame().getName()).build();
}
else if (_setting == CommunitySetting.PRIVACY)
{
@ -97,15 +100,18 @@ public class CommunitySettingButton extends CommunitiesGUIButton
}
else if (_setting == CommunitySetting.CHAT_NAME_COLOR)
{
Button = new ItemBuilder(Material.WOOL).setColor(COLOR_MAP.get(_community.getChatFormatting()[0]).getColor()).setTitle(C.cGreen + "Chat Community Color").addLore(C.cGold + "Currently: " + C.cGray + COLOR_NAME_MAP.get(_community.getChatFormatting()[0])).build();
ItemStack base = new MaterialData(Material.WOOL, COLOR_MAP.get(_community.getChatFormatting()[0]).getWoolData()).toItemStack(1);
Button = new ItemBuilder(base).setTitle(C.cGreen + "Chat Community Color").addLore(C.cGold + "Currently: " + C.cGray + COLOR_NAME_MAP.get(_community.getChatFormatting()[0])).build();
}
else if (_setting == CommunitySetting.CHAT_PLAYER_COLOR)
{
Button = new ItemBuilder(Material.WOOL).setColor(COLOR_MAP.get(_community.getChatFormatting()[1]).getColor()).setTitle(C.cGreen + "Chat Player Color").addLore(C.cGold + "Currently: " + C.cGray + COLOR_NAME_MAP.get(_community.getChatFormatting()[1])).build();
ItemStack base = new MaterialData(Material.WOOL, COLOR_MAP.get(_community.getChatFormatting()[1]).getWoolData()).toItemStack(1);
Button = new ItemBuilder(base).setTitle(C.cGreen + "Chat Player Color").addLore(C.cGold + "Currently: " + C.cGray + COLOR_NAME_MAP.get(_community.getChatFormatting()[1])).build();
}
else if (_setting == CommunitySetting.CHAT_MESSAGE_COLOR)
{
Button = new ItemBuilder(Material.WOOL).setColor(COLOR_MAP.get(_community.getChatFormatting()[2]).getColor()).setTitle(C.cGreen + "Chat Message Color").addLore(C.cGold + "Currently: " + C.cGray + COLOR_NAME_MAP.get(_community.getChatFormatting()[2])).build();
ItemStack base = new MaterialData(Material.WOOL, COLOR_MAP.get(_community.getChatFormatting()[2]).getWoolData()).toItemStack(1);
Button = new ItemBuilder(base).setTitle(C.cGreen + "Chat Message Color").addLore(C.cGold + "Currently: " + C.cGray + COLOR_NAME_MAP.get(_community.getChatFormatting()[2])).build();
}
}
@ -148,10 +154,10 @@ public class CommunitySettingButton extends CommunitiesGUIButton
valueArray = new String[colors.length];
for (int i = 0; i < colors.length; i++)
{
valueArray[i] = colors[i].toString();
valueArray[i] = colors[i].name();
}
index = Arrays.asList(valueArray).indexOf(_community.getChatFormatting()[0].toString());
index = Arrays.asList(valueArray).indexOf(_community.getChatFormatting()[0].name());
}
else if (_setting == CommunitySetting.CHAT_PLAYER_COLOR)
{
@ -159,10 +165,10 @@ public class CommunitySettingButton extends CommunitiesGUIButton
valueArray = new String[colors.length];
for (int i = 0; i < colors.length; i++)
{
valueArray[i] = colors[i].toString();
valueArray[i] = colors[i].name();
}
index = Arrays.asList(valueArray).indexOf(_community.getChatFormatting()[1].toString());
index = Arrays.asList(valueArray).indexOf(_community.getChatFormatting()[1].name());
}
else if (_setting == CommunitySetting.CHAT_MESSAGE_COLOR)
{
@ -170,10 +176,10 @@ public class CommunitySettingButton extends CommunitiesGUIButton
valueArray = new String[colors.length];
for (int i = 0; i < colors.length; i++)
{
valueArray[i] = colors[i].toString();
valueArray[i] = colors[i].name();
}
index = Arrays.asList(valueArray).indexOf(_community.getChatFormatting()[2].toString());
index = Arrays.asList(valueArray).indexOf(_community.getChatFormatting()[2].name());
}
int newIndex = (index + 1 >= valueArray.length) ? 0 : (index + 1);
@ -216,10 +222,10 @@ public class CommunitySettingButton extends CommunitiesGUIButton
valueArray = new String[colors.length];
for (int i = 0; i < colors.length; i++)
{
valueArray[i] = colors[i].toString();
valueArray[i] = colors[i].name();
}
index = Arrays.asList(valueArray).indexOf(_community.getChatFormatting()[0].toString());
index = Arrays.asList(valueArray).indexOf(_community.getChatFormatting()[0].name());
}
else if (_setting == CommunitySetting.CHAT_PLAYER_COLOR)
{
@ -227,10 +233,10 @@ public class CommunitySettingButton extends CommunitiesGUIButton
valueArray = new String[colors.length];
for (int i = 0; i < colors.length; i++)
{
valueArray[i] = colors[i].toString();
valueArray[i] = colors[i].name();
}
index = Arrays.asList(valueArray).indexOf(_community.getChatFormatting()[1].toString());
index = Arrays.asList(valueArray).indexOf(_community.getChatFormatting()[1].name());
}
else if (_setting == CommunitySetting.CHAT_MESSAGE_COLOR)
{
@ -238,10 +244,10 @@ public class CommunitySettingButton extends CommunitiesGUIButton
valueArray = new String[colors.length];
for (int i = 0; i < colors.length; i++)
{
valueArray[i] = colors[i].toString();
valueArray[i] = colors[i].name();
}
index = Arrays.asList(valueArray).indexOf(_community.getChatFormatting()[2].toString());
index = Arrays.asList(valueArray).indexOf(_community.getChatFormatting()[2].name());
}
int newIndex = (index - 1 < 0) ? (valueArray.length - 1) : (index - 1);

View File

@ -7,6 +7,7 @@ import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C;
import mineplex.core.communities.Community;
import mineplex.core.communities.CommunityDisbandEvent;
import mineplex.core.communities.CommunityMemberDataUpdateEvent;
import mineplex.core.communities.CommunityMembershipUpdateEvent;
import mineplex.core.communities.CommunityRole;
import mineplex.core.communities.CommunitySetting;
@ -22,7 +23,7 @@ public class CommunitySettingsPage extends CommunitiesGUIPage
public CommunitySettingsPage(Player viewer, Community community)
{
super(C.cGold + community.getName() + C.cBlue, 6, viewer);
super(community.getName() + C.cBlue, 6, viewer);
_community = community;
setup();
@ -125,4 +126,14 @@ public class CommunitySettingsPage extends CommunitiesGUIPage
Viewer.closeInventory();
}
}
@EventHandler
public void onMembershipUpdate(CommunityMemberDataUpdateEvent event)
{
if (!event.getPlayer().getUniqueId().toString().equalsIgnoreCase(Viewer.getUniqueId().toString()))
{
return;
}
setup();
}
}

View File

@ -10,7 +10,6 @@ import mineplex.core.communities.CommunityMemberDataUpdateEvent;
import mineplex.core.communities.gui.ActionButton;
import mineplex.core.communities.gui.CommunitiesGUIPage;
import mineplex.core.communities.gui.browser.CommunityBrowserPage;
import mineplex.core.communities.gui.community.CommunityButton;
import mineplex.core.itemstack.ItemBuilder;
public class CommunityInvitesPage extends CommunitiesGUIPage
@ -21,7 +20,7 @@ public class CommunityInvitesPage extends CommunitiesGUIPage
public CommunityInvitesPage(Player viewer)
{
super(C.cGold + "Your Community Invites", 6, viewer);
super("Your Community Invites", 6, viewer);
setup(1, true);
open();
@ -50,13 +49,17 @@ public class CommunityInvitesPage extends CommunitiesGUIPage
Buttons.put(4, browserButton);
Inv.setItem(4, browserButton.Button);
//7
ActionButton invitesButton = new ActionButton(new ItemBuilder(Material.BED).setTitle(C.cGold + "Your Community Invites").build(), clickType -> {});
ActionButton invitesButton = new ActionButton(new ItemBuilder(Material.PAPER).setTitle(C.cGold + "Your Community Invites").build(), clickType -> {});
Buttons.put(7, invitesButton);
Inv.setItem(7, invitesButton.Button);
}
{
ActionButton back = new ActionButton(new ItemBuilder(Material.ARROW).setTitle(C.cRed + "Previous Page").build(), clickType ->
{
if (_page == 1)
{
return;
}
setup(_page - 1, false);
});
ActionButton next = new ActionButton(new ItemBuilder(Material.ARROW).setTitle(C.cGreen + "Next Page").build(), clickType ->
@ -71,7 +74,7 @@ public class CommunityInvitesPage extends CommunitiesGUIPage
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).getTotalCommunities(); i++)
for (int i = (page - 1) * COMMUNITIES_PER_PAGE; i < (page - 1) * COMMUNITIES_PER_PAGE + COMMUNITIES_PER_PAGE && i < getCommunityManager().Get(Viewer).Invites.size(); i++)
{
if (!cleared && !initial)
{
@ -83,7 +86,7 @@ public class CommunityInvitesPage extends CommunitiesGUIPage
Inv.setItem(clear, null);
}
}
CommunityButton button = new CommunityButton(Viewer, getCommunityManager().Get(Viewer).getCommunities()[i]);
CommunityVisualizationButton button = new CommunityVisualizationButton(Viewer, getCommunityManager().getLoadedCommunity(getCommunityManager().Get(Viewer).Invites.get(i)));
Buttons.put(slot, button);
Inv.setItem(slot, button.Button);

View File

@ -1,16 +1,19 @@
package mineplex.core.communities.gui.overview;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Material;
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.CommunityDisbandEvent;
import mineplex.core.communities.CommunityMemberDataUpdateEvent;
import mineplex.core.communities.gui.ActionButton;
import mineplex.core.communities.gui.CommunitiesGUIPage;
import mineplex.core.communities.gui.browser.CommunityBrowserPage;
import mineplex.core.communities.gui.community.CommunityButton;
import mineplex.core.itemstack.ItemBuilder;
public class CommunityOverviewPage extends CommunitiesGUIPage
@ -21,7 +24,7 @@ public class CommunityOverviewPage extends CommunitiesGUIPage
public CommunityOverviewPage(Player viewer)
{
super(C.cGold + "Your Communities", 6, viewer);
super("Your Communities", 6, viewer);
setup(1, true);
open();
@ -47,7 +50,7 @@ public class CommunityOverviewPage extends CommunitiesGUIPage
Buttons.put(4, browserButton);
Inv.setItem(4, browserButton.Button);
//7
ActionButton invitesButton = new ActionButton(new ItemBuilder(Material.BED).setTitle(C.cGold + "Your Community Invites").build(), clickType ->
ActionButton invitesButton = new ActionButton(new ItemBuilder(Material.PAPER).setTitle(C.cGold + "Your Community Invites").build(), clickType ->
{
new CommunityInvitesPage(Viewer);
});
@ -57,6 +60,10 @@ public class CommunityOverviewPage extends CommunitiesGUIPage
{
ActionButton back = new ActionButton(new ItemBuilder(Material.ARROW).setTitle(C.cRed + "Previous Page").build(), clickType ->
{
if (_page == 1)
{
return;
}
setup(_page - 1, false);
});
ActionButton next = new ActionButton(new ItemBuilder(Material.ARROW).setTitle(C.cGreen + "Next Page").build(), clickType ->
@ -83,7 +90,21 @@ public class CommunityOverviewPage extends CommunitiesGUIPage
Inv.setItem(clear, null);
}
}
CommunityButton button = new CommunityButton(Viewer, getCommunityManager().Get(Viewer).getCommunities()[i]);
List<Community> coms = Arrays.asList(getCommunityManager().Get(Viewer).getCommunities());
coms.sort((c1, c2) ->
{
if (c1.getMembers().get(Viewer.getUniqueId()).Role == c2.getMembers().get(Viewer.getUniqueId()).Role)
{
return c1.getName().compareTo(c2.getName());
}
if (c1.getMembers().get(Viewer.getUniqueId()).Role.ordinal() < c2.getMembers().get(Viewer.getUniqueId()).Role.ordinal())
{
return -1;
}
return 1;
});
CommunityVisualizationButton button = new CommunityVisualizationButton(Viewer, getCommunityManager().Get(Viewer).getCommunities()[i]);
Buttons.put(slot, button);
Inv.setItem(slot, button.Button);

View File

@ -12,15 +12,15 @@ import mineplex.core.communities.gui.CommunitiesGUIButton;
import mineplex.core.communities.gui.community.CommunityMembersPage;
import mineplex.core.itemstack.ItemBuilder;
public class CommunityButton extends CommunitiesGUIButton
public class CommunityVisualizationButton extends CommunitiesGUIButton
{
private Player _viewer;
private Community _community;
@SuppressWarnings("deprecation")
public CommunityButton(Player viewer, Community community)
public CommunityVisualizationButton(Player viewer, Community community)
{
super(new ItemBuilder(new ItemStack(community.getFavoriteGame().getMaterial(), 1, community.getFavoriteGame().getMaterialData(), null)).setTitle(C.cGreen + community.getName()).addLore(UtilText.splitLinesToArray(new String[] {C.cGold + "Members: " + C.cGray + community.getMembers().size(), C.cGold + "Privacy: " + C.cGray + community.getPrivacySetting().getDisplayText(), C.cGold + "Favorite Game: " + C.cGray + community.getFavoriteGame().getName(), C.cGold + "Description: " + C.cGray + community.getDescription()}, LineFormat.LORE)).build());
super(new ItemBuilder(new ItemStack(community.getFavoriteGame().getMaterial(), 1, community.getFavoriteGame().getMaterialData(), null)).setTitle(C.cGreen + community.getName()).addLore(UtilText.splitLinesToArray(new String[] {C.cGold + "Members: " + C.cGray + community.getMembers().size(), C.cGold + "Favorite Game: " + C.cGray + community.getFavoriteGame().getName(), C.cGold + "Description: " + C.cGray + community.getDescription()}, LineFormat.LORE)).build());
_viewer = viewer;
_community = community;
@ -36,9 +36,6 @@ public class CommunityButton extends CommunitiesGUIButton
@Override
public void handleClick(ClickType type)
{
if (type == ClickType.SHIFT_LEFT)
{
new CommunityMembersPage(_viewer, _community).open();
}
new CommunityMembersPage(_viewer, _community).open();
}
}

View File

@ -0,0 +1,32 @@
package mineplex.core.communities.redis;
import mineplex.serverdata.commands.ServerCommand;
public class CommunityUpdateMemberChatReading extends ServerCommand
{
private Integer _communityId;
private String _playerUUID;
private boolean _reading;
public CommunityUpdateMemberChatReading(Integer communityId, String playerUUID, boolean reading)
{
_communityId = communityId;
_playerUUID = playerUUID;
_reading = reading;
}
public Integer getCommunityId()
{
return _communityId;
}
public String getPlayerUUID()
{
return _playerUUID;
}
public boolean reading()
{
return _reading;
}
}

View File

@ -0,0 +1,31 @@
package mineplex.core.communities.redis;
import java.util.UUID;
import mineplex.core.communities.CommunityManager;
import mineplex.serverdata.commands.CommandCallback;
import mineplex.serverdata.commands.ServerCommand;
public class CommunityUpdateMemberChatReadingHandler implements CommandCallback
{
private CommunityManager _manager;
public CommunityUpdateMemberChatReadingHandler(CommunityManager manager)
{
_manager = manager;
}
@Override
public void run(ServerCommand command)
{
if (command instanceof CommunityUpdateMemberChatReading)
{
CommunityUpdateMemberChatReading update = ((CommunityUpdateMemberChatReading) command);
Integer id = update.getCommunityId();
UUID uuid = UUID.fromString(update.getPlayerUUID());
boolean reading = update.reading();
_manager.handleToggleReadingCommunityChat(id, uuid, reading);
}
}
}

View File

@ -16,7 +16,9 @@ public class CommunityUpdateMembership extends ServerCommand
{
_communityId = communityId;
_sender = sender;
_playerName = playerName;
_playerUUID = playerUUID;
_accountId = accountId;
_kick = kick;
_leave = leave;
}

View File

@ -22,6 +22,7 @@ import mineplex.core.database.MinecraftRepository;
import mineplex.serverdata.data.DataRepository;
import mineplex.serverdata.data.PlayerStatus;
import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.column.ColumnBoolean;
import mineplex.serverdata.database.column.ColumnInt;
import mineplex.serverdata.database.column.ColumnVarChar;
@ -30,13 +31,13 @@ public class CommunityRepository extends MinecraftRepository
private static final String GET_ALL_COMMUNITIES = "SELECT * FROM communities;";
private static final String GET_COMMUNITY_BY_ID = "SELECT * FROM communities WHERE id=?;";
private static final String GET_COMMUNITY_BY_NAME = "SELECT * FROM communities WHERE name=?;";
private static final String GET_COMMUNITY_MEMBERS = "SELECT cm.accountId, cm.communityRole, ac.name, ac.uuid, ac.lastLogin, now() FROM communityMembers cm INNER JOIN accounts ac ON ac.id=cm.accountId WHERE communityId=?;";
private static final String GET_COMMUNITY_MEMBERS = "SELECT cm.accountId, cm.communityRole, ac.name, ac.uuid, ac.lastLogin, now(), cm.readingChat, (SELECT COUNT(id) FROM communityMembers WHERE accountId=cm.accountId AND communityRole='LEADER') FROM communityMembers cm INNER JOIN accounts ac ON ac.id=cm.accountId WHERE communityId=?;";
private static final String GET_COMMUNITY_JOIN_REQUESTS = "SELECT cjr.accountId, ac.name, ac.uuid FROM communityJoinRequests cjr INNER JOIN accounts ac ON ac.id=cjr.accountId WHERE communityId=?;";
private static final String GET_COMMUNITY_SETTINGS = "SELECT settingId, settingValue FROM communitySettings WHERE communityId=?;";
private static final String REMOVE_FROM_COMMUNITY = "DELETE * FROM communityMembers WHERE accountId=? AND communityId=?;";
private static final String REMOVE_FROM_COMMUNITY = "DELETE FROM communityMembers WHERE accountId=? AND communityId=?;";
private static final String UPDATE_COMMUNITY_ROLE = "UPDATE communityMembers SET communityRole=? WHERE accountId=? AND communityId=?;";
private static final String ADD_TO_COMMUNITY = "INSERT INTO communityMembers (accountId, communityId, communityRole) VALUES (?, ?, ?);";
private static final String ADD_TO_COMMUNITY = "INSERT INTO communityMembers (accountId, communityId, communityRole, readingChat) VALUES (?, ?, ?, true);";
private static final String UPDATE_COMMUNITY_SETTING = "INSERT INTO communitySettings (settingId, communityId, settingValue) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE settingValue=VALUES(settingValue);";
private static final String UPDATE_COMMUNITY_NAME = "UPDATE communities SET name=? WHERE id=?;";
private static final String INVITE_TO_COMMUNITY = "INSERT INTO communityInvites (accountId, communityId) SELECT a.id AS accountId, ? FROM accounts as a WHERE a.name = ? ORDER BY a.lastLogin DESC LIMIT 1;";
@ -46,6 +47,8 @@ public class CommunityRepository extends MinecraftRepository
private static final String CREATE_COMMUNITY = "INSERT INTO communities (name) VALUES (?);";
private static final String SET_READING_CHAT_IN = "UPDATE communityMembers SET readingChat=? WHERE accountId=? AND communityId=?;";
private DataRepository<PlayerStatus> _repo;
public CommunityRepository(JavaPlugin plugin, DataRepository<PlayerStatus> statusRepo)
@ -72,7 +75,9 @@ public class CommunityRepository extends MinecraftRepository
final String name = memberSet.getString("name");
final UUID uuid = UUID.fromString(memberSet.getString("uuid"));
final CommunityRole role = CommunityRole.parseRole(memberSet.getString("communityRole"));
final long timeSinceOnline = memberSet.getTimestamp(5).getTime() - memberSet.getTimestamp(4).getTime();
final long timeSinceOnline = memberSet.getTimestamp(6).getTime() - memberSet.getTimestamp(5).getTime();
boolean readingChat = memberSet.getBoolean("readingChat");
final int owns = memberSet.getInt(8);
CommunityMemberInfo info = new CommunityMemberInfo(name, uuid, accountId, role, timeSinceOnline);
PlayerStatus status = _repo.getElement(name);
@ -80,6 +85,8 @@ public class CommunityRepository extends MinecraftRepository
{
info.update(name, role, timeSinceOnline, true, status.getServer());
}
info.ReadingChat = readingChat;
info.OwnsCommunity = owns > 0;
community.getMembers().put(info.UUID, info);
}
}, new ColumnInt("communityId", community.getId()));
@ -134,7 +141,9 @@ public class CommunityRepository extends MinecraftRepository
final String name = memberSet.getString("name");
final UUID uuid = UUID.fromString(memberSet.getString("uuid"));
final CommunityRole role = CommunityRole.parseRole(memberSet.getString("communityRole"));
final long timeSinceOnline = memberSet.getTimestamp(5).getTime() - memberSet.getTimestamp(4).getTime();
final long timeSinceOnline = memberSet.getTimestamp(6).getTime() - memberSet.getTimestamp(5).getTime();
boolean readingChat = memberSet.getBoolean("readingChat");
final int owns = memberSet.getInt(8);
CommunityMemberInfo info = new CommunityMemberInfo(name, uuid, accountId, role, timeSinceOnline);
PlayerStatus status = _repo.getElement(name);
@ -142,6 +151,8 @@ public class CommunityRepository extends MinecraftRepository
{
info.update(name, role, timeSinceOnline, true, status.getServer());
}
info.ReadingChat = readingChat;
info.OwnsCommunity = owns > 0;
community.getMembers().put(info.UUID, info);
}
}, new ColumnInt("communityId", community.getId()));
@ -210,7 +221,9 @@ public class CommunityRepository extends MinecraftRepository
final UUID uuid = UUID.fromString(memberSet.getString("uuid"));
final String name = memberSet.getString("name");
final CommunityRole role = CommunityRole.parseRole(memberSet.getString("communityRole"));
final long timeSinceOnline = memberSet.getTimestamp(5).getTime() - memberSet.getTimestamp(4).getTime();
final long timeSinceOnline = memberSet.getTimestamp(6).getTime() - memberSet.getTimestamp(5).getTime();
//boolean readingChat = memberSet.getBoolean("readingChat");
final int owns = memberSet.getInt(8);
if (c.getMembers().containsKey(uuid))
{
@ -222,6 +235,8 @@ public class CommunityRepository extends MinecraftRepository
online = true;
server = status.getServer();
}
//c.getMembers().get(uuid).ReadingChat = readingChat;
c.getMembers().get(uuid).OwnsCommunity = owns > 0;
c.getMembers().get(uuid).update(name, role, timeSinceOnline, online, server);
}
}
@ -259,6 +274,8 @@ public class CommunityRepository extends MinecraftRepository
final String name = memberSet.getString("name");
final CommunityRole role = CommunityRole.parseRole(memberSet.getString("communityRole"));
final long timeSinceOnline = memberSet.getTimestamp(5).getTime() - memberSet.getTimestamp(4).getTime();
//boolean readingChat = memberSet.getBoolean("readingChat");
final int owns = memberSet.getInt(8);
if (members.containsKey(uuid))
{
@ -270,6 +287,8 @@ public class CommunityRepository extends MinecraftRepository
online = true;
server = status.getServer();
}
//members.get(uuid).ReadingChat = readingChat;
members.get(uuid).OwnsCommunity = owns > 0;
members.get(uuid).update(name, role, timeSinceOnline, online, server);
}
}
@ -301,7 +320,7 @@ public class CommunityRepository extends MinecraftRepository
{
invites.add(resultSet.getInt("communityId"));
}
});
}, new ColumnInt("accountId", accountId));
}
public void removeFromCommunity(int accountId, int communityId)
@ -331,7 +350,7 @@ public class CommunityRepository extends MinecraftRepository
public boolean inviteToCommunity(int communityId, String name)
{
return executeUpdate(INVITE_TO_COMMUNITY, new ColumnInt("communityId"), new ColumnVarChar("name", 32, name)) > 0;
return executeUpdate(INVITE_TO_COMMUNITY, new ColumnInt("communityId", communityId), new ColumnVarChar("name", 32, name)) > 0;
}
public boolean deleteInviteToCommunity(int communityId, String name)
@ -372,6 +391,11 @@ public class CommunityRepository extends MinecraftRepository
executeUpdate("DELETE FROM communitySettings WHERE communityId=?;", new ColumnInt("communityId", communityId));
executeUpdate("DELETE FROM communityMembers WHERE communityId=?;", new ColumnInt("communityId", communityId));
}
public void setReadingChat(int accountId, int communityId, boolean reading)
{
executeUpdate(SET_READING_CHAT_IN, new ColumnBoolean("readingChat", reading), new ColumnInt("accountId", accountId), new ColumnInt("communityId", communityId));
}
protected void initialize() {}
protected void update() {}

View File

@ -126,6 +126,7 @@ public enum GameDisplay
_data = data;
_gameCategory = gameCategory;
_gameId = gameId;
_communityFavorite = communityFavorite;
}
public String getName()

View File

@ -37,6 +37,7 @@ public class PersonalServerManager extends MiniPlugin
private int _interfaceSlot = 6;
private ItemStack _interfaceItem;
private boolean _useInterfaceItem = true;
private boolean _giveInterfaceItem = true;
public PersonalServerManager(JavaPlugin plugin, CoreClientManager clientManager)
@ -66,6 +67,10 @@ public class PersonalServerManager extends MiniPlugin
@EventHandler
public void openServer(PlayerInteractEvent event)
{
if (!_useInterfaceItem)
{
return;
}
if (_interfaceItem.equals(event.getPlayer().getItemInHand()))
{
if (!Recharge.Instance.use(event.getPlayer(), "Host Server Melon", 30000, false, false))
@ -157,7 +162,7 @@ public class PersonalServerManager extends MiniPlugin
}
}
final ServerGroup serverGroup = new ServerGroup("COM-" + community.getId(), "COM-" + community.getName(), "COM-" + community.getName(), ram, cpu, 1, 0, UtilMath.random.nextInt(250) + 19999, "", true, "Lobby_MPS.zip", "Arcade.jar", "plugins/Arcade/", 40, 80,
final ServerGroup serverGroup = new ServerGroup("COM-" + community.getId(), "COM-" + community.getName(), "COM-" + community.getName(), ram, cpu, 1, 0, UtilMath.random.nextInt(250) + 19999, "", true, "Lobby_MPS.zip", "Arcade.jar", "plugins/Arcade/", 15, 20,
true, false, false, "Smash", "", "", "Player", true, false, false, true, false, true, true, false, false, false, false, true, true, true, false, false, "", _us ? Region.US : Region.EU, "", "", "", "");
_repository.updateServerGroup(serverGroup);
@ -214,4 +219,9 @@ public class PersonalServerManager extends MiniPlugin
{
return _clientManager;
}
public void setUseInterfaceItem(boolean use)
{
_useInterfaceItem = use;
}
}

View File

@ -54,6 +54,7 @@ import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.communities.CommunityManager;
import mineplex.core.creature.Creature;
import mineplex.core.creature.event.CreatureSpawnCustomEvent;
import mineplex.core.disguise.DisguiseManager;
@ -70,6 +71,7 @@ import mineplex.core.menu.MenuManager;
import mineplex.core.movement.Movement;
import mineplex.core.npc.NpcManager;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.personalServer.PersonalServerManager;
import mineplex.core.portal.Portal;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.projectile.ProjectileManager;
@ -405,6 +407,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
loadClan(token, false);
}
_bannerManager.loadBanners(this);
new PersonalServerManager(plugin, _clientManager).setUseInterfaceItem(false);
new CommunityManager(plugin, _clientManager);
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "Replay|Restrict");

View File

@ -67,6 +67,7 @@ import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTextTop;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.communities.CommunityManager;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.customdata.CustomDataManager;
import mineplex.core.disguise.DisguiseManager;
@ -93,6 +94,7 @@ import mineplex.core.npc.NpcManager;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.party.Party;
import mineplex.core.party.PartyManager;
import mineplex.core.personalServer.PersonalServerManager;
import mineplex.core.pet.PetManager;
import mineplex.core.playerCount.PlayerCountManager;
import mineplex.core.playwire.PlayWireManager;
@ -259,6 +261,9 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter
_serverName = _serverName.substring(0, Math.min(16, _serverName.length()));
new SalesAnnouncementManager(plugin);
new PersonalServerManager(plugin, _clientManager).setUseInterfaceItem(false);
new CommunityManager(plugin, _clientManager);
}
@Override

View File

@ -58,6 +58,7 @@ import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.communities.CommunityManager;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.customdata.CustomDataManager;
import mineplex.core.disguise.DisguiseManager;
@ -273,6 +274,8 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
_valentinesManager = new ValentinesManager(plugin, clientManager, donationManager);
new SalesAnnouncementManager(plugin);
new CommunityManager(plugin, _clientManager);
ScoreboardManager scoreboardManager = new ScoreboardManager(plugin)
{

View File

@ -4,8 +4,6 @@ import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;
import net.minecraft.server.v1_8_R3.EntityLiving;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
@ -54,6 +52,7 @@ import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.communities.CommunityManager;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.creature.Creature;
import mineplex.core.customdata.CustomDataManager;
@ -83,6 +82,7 @@ import mineplex.core.movement.Movement;
import mineplex.core.npc.NpcManager;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.party.PartyManager;
import mineplex.core.personalServer.PersonalServerManager;
import mineplex.core.pet.PetManager;
import mineplex.core.playwire.PlayWireManager;
import mineplex.core.poll.PollManager;
@ -120,7 +120,6 @@ import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.minecraft.game.core.damage.DamageManager;
import mineplex.minecraft.game.core.fire.Fire;
import mineplex.serverdata.Region;
import nautilus.game.arcade.addons.SoupAddon;
import nautilus.game.arcade.addons.TeamArmorAddon;
import nautilus.game.arcade.booster.GameBoosterManager;
@ -166,7 +165,7 @@ import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager;
import nautilus.game.arcade.managers.lobby.legacy.LegacyGameLobbyManager;
import nautilus.game.arcade.player.ArcadePlayer;
import nautilus.game.arcade.shop.ArcadeShop;
import static mineplex.core.Managers.require;
import net.minecraft.server.v1_8_R3.EntityLiving;
public class ArcadeManager extends MiniPlugin implements IRelation
{
@ -406,6 +405,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation
addCommand(new OpenGameMechPrefsCommand(this));
addCommand(new CancelNextGameCommand(this));
addCommand(new TauntCommand(this));
new PersonalServerManager(plugin, _clientManager).setUseInterfaceItem(false);
new CommunityManager(plugin, _clientManager);
_scoreboardManager = new ScoreboardManager(_plugin)
{

View File

@ -11,6 +11,7 @@ import org.bukkit.inventory.meta.ItemMeta;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilServer;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.shop.item.ShopItem;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.gui.privateServer.PrivateServerShop;
@ -100,9 +101,12 @@ public class MenuPage extends BasePage
GameVotingButton votingButton = new GameVotingButton(getPlugin(), getShop());
addButton(3 + 27, new ShopItem(Material.BOOKSHELF, "Game Voting", new String[]{}, 1, false), votingButton);
WhitelistButton whitelistButton = new WhitelistButton(getPlugin(), getShop());
addButton(5 + 27, new ShopItem(Material.PAPER, "Whitelisted Players", new String[]{}, 1, false), whitelistButton);
if (!_manager.isCommunityServer())
{
WhitelistButton whitelistButton = new WhitelistButton(getPlugin(), getShop());
addButton(5 + 27, new ShopItem(Material.PAPER, "Whitelisted Players", new String[]{}, 1, false), whitelistButton);
}
}
OptionsButton optionsButton = new OptionsButton(getPlugin(), getShop());
@ -114,6 +118,24 @@ public class MenuPage extends BasePage
private ShopItem getOwnerHead()
{
if (_manager.isCommunityServer())
{
String title = C.cGreen + C.Bold + _manager.getOwner().getName() + "'s Mineplex Community Server";
ItemStack head = new ItemBuilder(new ItemStack(_manager.getOwner().getFavoriteGame().getMaterial(), 1, _manager.getOwner().getFavoriteGame().getMaterialData(), null)).setTitle(ChatColor.RESET + title).build();
ArrayList<String> lore = new ArrayList<String>();
lore.add(" ");
lore.add(ChatColor.RESET + C.cYellow + "Server Name: " + C.cWhite + getPlugin().getPlugin().getConfig().getString("serverstatus.name"));
lore.add(ChatColor.RESET + C.cYellow + "Players Online: " + C.cWhite + UtilServer.getPlayers().length);
lore.add(ChatColor.RESET + C.cYellow + "Players Max: " + C.cWhite + getPlugin().GetServerConfig().MaxPlayers);
lore.add(" ");
lore.add(ChatColor.RESET + "Left-Click to increase Max Players");
lore.add(ChatColor.RESET + "Right-Click to decrease Max Players");
ItemMeta meta = head.getItemMeta();
meta.setLore(lore);
head.setItemMeta(meta);
return new ShopItem(head, title, title, 1, false, false);
}
String title = C.cGreen + C.Bold + getPlugin().GetHost() + "'s Mineplex Private Server";
ItemStack head = getPlayerHead(getPlugin().GetHost(), ChatColor.RESET + title);
ArrayList<String> lore = new ArrayList<String>();

View File

@ -33,24 +33,30 @@ public class OptionsPage extends BasePage
//GameAutoStart
//GameTimeout
//PlayerKickIdle
buildPreference(11, Material.EYE_OF_ENDER, "Public Server", _config.PublicServer, new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
togglePublic();
}
});
buildPreference(13, Material.PAPER, "Enforce Whitelist", _config.PlayerServerWhitelist, new IButton()
if (!_plugin.GetGameHostManager().isCommunityServer())
{
@Override
public void onClick(Player player, ClickType clickType)
buildPreference(11, Material.EYE_OF_ENDER, "Public Server", _config.PublicServer, new IButton()
{
toggleWhitelist();
}
});
@Override
public void onClick(Player player, ClickType clickType)
{
togglePublic();
}
});
}
if (!_plugin.GetGameHostManager().isCommunityServer())
{
buildPreference(13, Material.PAPER, "Enforce Whitelist", _config.PlayerServerWhitelist, new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
toggleWhitelist();
}
});
}
buildPreference(15, Material.RAILS, "Force Team Balancing", _config.TeamForceBalance, new IButton()
{

View File

@ -214,28 +214,35 @@ public class GameHostManager implements Listener
public void handleLogin(PlayerLoginEvent event)
{
Player p = event.getPlayer();
if (isCommunityServer())
{
if (getOwner().getMembers().containsKey(p.getUniqueId()))
{
return;
}
event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "You are not a member of this MCS.");
return;
}
if (Manager.GetServerConfig().PlayerServerWhitelist){
if (!getWhitelist().contains(p.getName().toLowerCase())){
if ((Manager.GetHost() != null) && (Manager.GetHost().equalsIgnoreCase(p.getName())))
{
return;
}
if (isCommunityServer())
{
if (getOwner().getMembers().containsKey(p.getUniqueId()))
{
return;
}
event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "This MCS is whitelisted.");
}
else
{
event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "This MPS is whitelisted.");
}
event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "This MPS is whitelisted.");
}
}
if (_blacklist.contains(p.getName()))
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, "You were removed from this Mineplex Private Server.");
{
if (isCommunityServer())
{
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, "You were removed from this Mineplex Community Server.");
}
else
{
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, "You were removed from this Mineplex Private Server.");
}
}
}
@EventHandler
@ -525,14 +532,14 @@ public class GameHostManager implements Listener
{
if (isCommunityServer())
{
return (getOwner().getMembers().containsKey(player.getUniqueId()) && getOwner().getMembers().get(player.getUniqueId()).Role.ordinal() <= CommunityRole.COLEADER.ordinal()) || (includeStaff && Manager.GetClients().Get(_host).GetRank().has(Rank.ADMIN));
return (getOwner().getMembers().containsKey(player.getUniqueId()) && getOwner().getMembers().get(player.getUniqueId()).Role.ordinal() <= CommunityRole.COLEADER.ordinal()) || (includeStaff && Manager.GetClients().Get(player).GetRank().has(Rank.ADMIN));
}
return player.equals(_host) || _adminList.contains(player.getName()) || (includeStaff && Manager.GetClients().Get(player).GetRank().has(Rank.ADMIN));
}
public boolean isHost(Player player)
{
if (Manager.GetHost().startsWith("COM-"))
if (Manager.GetHost() != null && Manager.GetHost().startsWith("COM-"))
{
CommunityManager cmanager = Managers.get(CommunityManager.class);
int communityId = Integer.parseInt(Manager.GetHost().replace("COM-", ""));
@ -551,7 +558,9 @@ public class GameHostManager implements Listener
@EventHandler
public void whitelistCommand(PlayerCommandPreprocessEvent event)
{
if ((_host == null || !event.getPlayer().equals(_host)) || (isCommunityServer() && getOwner().getMembers().containsKey(event.getPlayer().getUniqueId()) && getOwner().getMembers().get(event.getPlayer().getUniqueId()).Role.ordinal() <= CommunityRole.COLEADER.ordinal()))
if (_host == null || !event.getPlayer().equals(_host))
return;
if (isCommunityServer())
return;
if (!event.getMessage().toLowerCase().startsWith("/whitelist"))
@ -577,6 +586,10 @@ public class GameHostManager implements Listener
public boolean hasRank(Rank rank)
{
if (isCommunityServer())
{
return Rank.ETERNAL.has(rank);
}
if (_hostRank == null)
return false;
@ -719,7 +732,7 @@ public class GameHostManager implements Listener
{
if (isCommunityServer())
{
return 100;
return 20;
}
if (hasRank(Rank.SNR_MODERATOR) || _hostRank == Rank.YOUTUBE || _hostRank == Rank.TWITCH)
return 100;

View File

@ -96,6 +96,8 @@ public class GameChatManager implements Listener
{
if (_manager.GetGameHostManager().isEventServer())
rankStr = C.cDGreen + C.Bold + "Event Host " + C.Reset;
else if (_manager.GetGameHostManager().isCommunityServer())
rankStr = C.cDGreen + C.Bold + "MCS Host " + C.Reset;
else
rankStr = C.cDGreen + C.Bold + "MPS Host " + C.Reset;
}
@ -103,6 +105,8 @@ public class GameChatManager implements Listener
{
if (_manager.GetGameHostManager().isEventServer())
rankStr = C.cDGreen + C.Bold + "Event Co-Host " + C.Reset;
else if (_manager.GetGameHostManager().isCommunityServer())
rankStr = C.cDGreen + C.Bold + "MCS Co-Host " + C.Reset;
else
rankStr = C.cDGreen + C.Bold + "MPS Co-Host " + C.Reset;
}