Implement more settings for communities
This commit is contained in:
parent
fd30fca035
commit
f6362676ff
@ -1,7 +1,11 @@
|
|||||||
package mineplex.core.communities;
|
package mineplex.core.communities;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
import mineplex.core.common.Pair;
|
import mineplex.core.common.Pair;
|
||||||
import mineplex.core.common.util.Callback;
|
import mineplex.core.common.util.Callback;
|
||||||
|
import mineplex.core.communities.Community.PrivacySetting;
|
||||||
|
import mineplex.core.game.GameDisplay;
|
||||||
|
|
||||||
public enum CommunitySetting
|
public enum CommunitySetting
|
||||||
{
|
{
|
||||||
@ -9,20 +13,82 @@ public enum CommunitySetting
|
|||||||
{
|
{
|
||||||
String value = pair.getLeft();
|
String value = pair.getLeft();
|
||||||
Community community = pair.getRight();
|
Community community = pair.getRight();
|
||||||
|
|
||||||
|
ChatColor color = ChatColor.valueOf(value);
|
||||||
|
if (color == null || !color.isColor())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
community.setChatFormatting(new ChatColor[] {color, community.getChatFormatting()[1], community.getChatFormatting()[2]});
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
CHAT_MESSAGE_COLOR(1, pair ->
|
CHAT_PLAYER_COLOR(2, pair ->
|
||||||
{
|
{
|
||||||
String value = pair.getLeft();
|
String value = pair.getLeft();
|
||||||
Community community = pair.getRight();
|
Community community = pair.getRight();
|
||||||
|
|
||||||
|
ChatColor color = ChatColor.valueOf(value);
|
||||||
|
if (color == null || !color.isColor())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
community.setChatFormatting(new ChatColor[] {community.getChatFormatting()[0], color, community.getChatFormatting()[2]});
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
CHAT_DELAY(3, pair ->
|
CHAT_MESSAGE_COLOR(3, pair ->
|
||||||
{
|
{
|
||||||
String value = pair.getLeft();
|
String value = pair.getLeft();
|
||||||
Community community = pair.getRight();
|
Community community = pair.getRight();
|
||||||
|
|
||||||
|
ChatColor color = ChatColor.valueOf(value);
|
||||||
|
if (color == null || !color.isColor())
|
||||||
|
{
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
);
|
community.setChatFormatting(new ChatColor[] {community.getChatFormatting()[0], community.getChatFormatting()[1], color});
|
||||||
|
}
|
||||||
|
),
|
||||||
|
CHAT_DELAY(4, pair ->
|
||||||
|
{
|
||||||
|
String value = pair.getLeft();
|
||||||
|
Community community = pair.getRight();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Long delay = Long.parseLong(value);
|
||||||
|
community.setChatDelay(delay);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
),
|
||||||
|
FAVORITE_GAME(5, pair ->
|
||||||
|
{
|
||||||
|
String value = pair.getLeft();
|
||||||
|
Community community = pair.getRight();
|
||||||
|
|
||||||
|
GameDisplay display = GameDisplay.matchName(value);
|
||||||
|
community.setFavoriteGame(display);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
PRIVACY(6, pair ->
|
||||||
|
{
|
||||||
|
String value = pair.getLeft();
|
||||||
|
Community community = pair.getRight();
|
||||||
|
|
||||||
|
PrivacySetting setting = PrivacySetting.parsePrivacy(value);
|
||||||
|
community.setPrivacySetting(setting);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
DESCRIPTION(7, pair ->
|
||||||
|
{
|
||||||
|
String value = pair.getLeft();
|
||||||
|
Community community = pair.getRight();
|
||||||
|
|
||||||
|
community.setDescription(value);
|
||||||
|
});
|
||||||
|
|
||||||
private int _id;
|
private int _id;
|
||||||
private Callback<Pair<String, Community>> _parser;
|
private Callback<Pair<String, Community>> _parser;
|
||||||
@ -42,4 +108,17 @@ public enum CommunitySetting
|
|||||||
{
|
{
|
||||||
_parser.run(Pair.create(value, community));
|
_parser.run(Pair.create(value, community));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static CommunitySetting getSetting(Integer id)
|
||||||
|
{
|
||||||
|
for (CommunitySetting setting : CommunitySetting.values())
|
||||||
|
{
|
||||||
|
if (setting.getId() == id)
|
||||||
|
{
|
||||||
|
return setting;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user