Complete setting up community data class

This commit is contained in:
AlexTheCoder 2016-12-14 22:09:47 -05:00 committed by cnr
parent 471ea8942f
commit 2a971d616c

View File

@ -1,26 +1,154 @@
package mineplex.core.communities;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.game.GameDisplay;
public class Community
{
private final int _id;
private String _name;
private String _description;
private Map<UUID, CommunityMemberInfo> _members = new HashMap<>();
private Map<UUID, CommunityJoinRequestInfo> _joinRequests = new HashMap<>();
private ChatColor[] _chatFormat;
private long _chatDelay;
private GameDisplay _favoriteGame;
private PrivacySetting _privacy;
public Community(int id, String name)
{
_id = id;
_name = name;
_description = "No Description Set";
_chatFormat = new ChatColor[] {ChatColor.BLUE, ChatColor.RED, ChatColor.GREEN};
_chatDelay = 1000;
_favoriteGame = GameDisplay.ChampionsCTF;
_privacy = PrivacySetting.RECRUITING;
}
public Integer getId()
{
return 1;
return _id;
}
public String getName()
{
return "";
return _name;
}
public void setName(String name)
{
_name = name;
}
public String getDescription()
{
return _description;
}
public void setDescription(String description)
{
_description = description;
}
public Map<UUID, CommunityMemberInfo> getMembers()
{
return _members;
}
public Map<UUID, CommunityJoinRequestInfo> getJoinRequests()
{
return _joinRequests;
}
public ChatColor[] getChatFormatting()
{
return new ChatColor[] {ChatColor.RED, ChatColor.GREEN};
return _chatFormat;
}
public void setChatFormatting(ChatColor[] colors)
{
_chatFormat = colors;
}
public Long getChatDelay()
{
return _chatDelay;
}
public void setChatDelay(Long delay)
{
_chatDelay = delay;
}
public GameDisplay getFavoriteGame()
{
return _favoriteGame;
}
public void setFavoriteGame(GameDisplay game)
{
_favoriteGame = game;
}
public PrivacySetting getPrivacySetting()
{
return _privacy;
}
public void setPrivacySetting(PrivacySetting privacy)
{
_privacy = privacy;
}
public void message(String message)
{
getMembers().values().forEach(member -> UtilPlayer.message(Bukkit.getPlayer(member.UUID), message));
}
public void message(String message, CommunityRole minimumRole)
{
getMembers().values().stream().filter(member -> member.Role.ordinal() <= minimumRole.ordinal()).forEach(member -> UtilPlayer.message(Bukkit.getPlayer(member.UUID), message));
}
public static enum PrivacySetting
{
OPEN(C.cGreen + "Open to Join"),
RECRUITING(C.cGold + "Accepting Join Requests"),
PRIVATE(C.cRed + "Closed")
;
private String _display;
private PrivacySetting(String display)
{
_display = display;
}
public String getDisplayText()
{
return _display;
}
public static PrivacySetting parsePrivacy(String privacy)
{
for (PrivacySetting setting : PrivacySetting.values())
{
if (setting.toString().equalsIgnoreCase(privacy))
{
return setting;
}
}
return PrivacySetting.RECRUITING;
}
}
}