From f6362676ffad6a4cf10c4cb42c7df24cbe81aa6a Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Wed, 14 Dec 2016 22:06:33 -0500 Subject: [PATCH] Implement more settings for communities --- .../core/communities/CommunitySetting.java | 85 ++++++++++++++++++- 1 file changed, 82 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunitySetting.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunitySetting.java index e36b00580..fc049ac5e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunitySetting.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunitySetting.java @@ -1,7 +1,11 @@ package mineplex.core.communities; +import org.bukkit.ChatColor; + import mineplex.core.common.Pair; import mineplex.core.common.util.Callback; +import mineplex.core.communities.Community.PrivacySetting; +import mineplex.core.game.GameDisplay; public enum CommunitySetting { @@ -9,20 +13,82 @@ public enum CommunitySetting { String value = pair.getLeft(); 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(); 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(); 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 Callback> _parser; @@ -42,4 +108,17 @@ public enum CommunitySetting { _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; + } } \ No newline at end of file