public String getValue(ThemeVal variable) { try { return getThemeValue(variable); } catch (NullPointerException | IllegalStateException e) { return variable.getDefaultValue(); } }
private String getThemeValue(ThemeVal color) { return themeConfig.getString(color.getThemePath()); } }
@Override public void disable() { theme.disable(); }
@Override public ColorScheme getColorScheme() { return PlanColorScheme.create(system.getConfigSystem().getConfig(), logger); }
private String getColor(ThemeVal variable) { String path = variable.getThemePath(); try { String value = themeConfig.getString(path); if (value.contains(".")) { return "url(\"" + value + "\")"; } else { return value; } } catch (Exception | NoSuchFieldError e) { logger.error("Something went wrong with getting variable " + variable.name() + " for: " + path); } return variable.getDefaultValue(); }
private ThemeConfig(File configFile, ConfigNode defaults) { super(configFile, defaults); if (defaults.isLeafNode()) { ConfigNode util = new ConfigNode("", null, ""); for (ThemeVal themeVal : ThemeVal.values()) { util.set(themeVal.getThemePath(), themeVal.getDefaultValue()); } copyMissing(util); } }
public String replaceThemeColors(String resourceString) { String replaced = resourceString; ThemeVal[] themeVariables = new ThemeVal[]{ RED, PINK, PURPLE, DEEP_PURPLE, INDIGO, BLUE, LIGHT_BLUE, CYAN, TEAL, GREEN, LIGHT_GREEN, LIME, YELLOW, AMBER, ORANGE, DEEP_ORANGE, BROWN, GREY, BLUE_GREY, BLACK, WHITE, GRAPH_PUNCHCARD, GRAPH_PLAYERS_ONLINE, GRAPH_TPS_HIGH, GRAPH_TPS_MED, GRAPH_TPS_LOW, GRAPH_CPU, GRAPH_RAM, GRAPH_CHUNKS, GRAPH_ENTITIES, GRAPH_WORLD_PIE, GRAPH_GM_PIE, GRAPH_ACTIVITY_PIE, GRAPH_SERVER_PREF_PIE, FONT_STYLESHEET, FONT_FAMILY }; for (ThemeVal variable : themeVariables) { String value = getColor(variable); String defaultValue = variable.getDefaultValue(); if (Verify.equalsOne(value, defaultValue)) { continue; } if (value.contains("url")) { String[] colorAndUrl = value.split(" "); if (colorAndUrl.length >= 2) { replaced = replaced.replace("background: " + defaultValue, "background: " + colorAndUrl[1]); replaced = replaced.replace(defaultValue, colorAndUrl[0]); return replaced; } } else { replaced = replaced.replace(defaultValue, value); } } return replaced.replace("${defaultTheme}", getValue(ThemeVal.THEME_DEFAULT)); }
public ThemeConfig(PlanFiles files, PlanConfig config, PluginLogger logger) { this(getConfigFile(files), getDefaults(files, config, logger)); }
private void addThemeColors() { putRawData(AnalysisKeys.ACTIVITY_PIE_COLORS, theme.getValue(ThemeVal.GRAPH_ACTIVITY_PIE)); putRawData(AnalysisKeys.GM_PIE_COLORS, theme.getValue(ThemeVal.GRAPH_GM_PIE)); putRawData(AnalysisKeys.PLAYERS_GRAPH_COLOR, theme.getValue(ThemeVal.GRAPH_PLAYERS_ONLINE)); putRawData(AnalysisKeys.TPS_LOW_COLOR, theme.getValue(ThemeVal.GRAPH_TPS_LOW)); putRawData(AnalysisKeys.TPS_MEDIUM_COLOR, theme.getValue(ThemeVal.GRAPH_TPS_MED)); putRawData(AnalysisKeys.TPS_HIGH_COLOR, theme.getValue(ThemeVal.GRAPH_TPS_HIGH)); putRawData(AnalysisKeys.WORLD_MAP_LOW_COLOR, theme.getValue(ThemeVal.WORLD_MAP_LOW)); putRawData(AnalysisKeys.WORLD_MAP_HIGH_COLOR, theme.getValue(ThemeVal.WORLD_MAP_HIGH)); putRawData(AnalysisKeys.WORLD_PIE_COLORS, theme.getValue(ThemeVal.GRAPH_WORLD_PIE)); putRawData(AnalysisKeys.AVG_PING_COLOR, theme.getValue(ThemeVal.GRAPH_AVG_PING)); putRawData(AnalysisKeys.MAX_PING_COLOR, theme.getValue(ThemeVal.GRAPH_MAX_PING)); putRawData(AnalysisKeys.MIN_PING_COLOR, theme.getValue(ThemeVal.GRAPH_MIN_PING)); }
@Override public void enable() throws EnableException { try { themeConfig = new ThemeConfig(files, config, logger); themeConfig.save(); } catch (IOException e) { throw new EnableException("theme.yml could not be saved.", e); } }
public static PlanColorScheme create(PlanConfig config, PluginLogger logger) { try { String main = "§" + config.get(DisplaySettings.CMD_COLOR_MAIN).charAt(1); String secondary = "§" + config.get(DisplaySettings.CMD_COLOR_SECONDARY).charAt(1); String tertiary = "§" + config.get(DisplaySettings.CMD_COLOR_TERTIARY).charAt(1); return new PlanColorScheme(main, secondary, tertiary); } catch (Exception e) { logger.log(L.INFO_COLOR, "§cCustomization, Chat colors set-up wrong, using defaults."); return new PlanColorScheme("§2", "§7", "§f"); } }
private static ConfigNode getDefaults(PlanFiles files, PlanConfig config, PluginLogger logger) { String fileName = config.get(DisplaySettings.THEME); String fileLocation = getFileLocation(fileName); try (ConfigReader reader = new ConfigReader(files.readStreamFromResource(fileLocation))) { return reader.read(); } catch (IOException e) { logger.error("Could not find theme " + fileLocation + ". Attempting to use default."); return new ConfigNode(null, null, null); } }
@Override public ColorScheme getColorScheme() { return PlanColorScheme.create(system.getConfigSystem().getConfig(), logger); }
public StackGraph activityStackGraph(TreeMap<Long, Map<String, Set<UUID>>> activityData) { String[] colors = theme.getValue(ThemeVal.GRAPH_ACTIVITY_PIE).split(", "); return new ActivityStackGraph(activityData, colors, dayFormatter); } }
@Override public ColorScheme getColorScheme() { return PlanColorScheme.create(system.getConfigSystem().getConfig(), logger); }
private void appendRegister(StringBuilder series) { series.append("{title: 'Registered: ").append(yearLongFormatter.apply(registered)).append("'," + "start: ").append(this.registered).append(",color: '").append(theme.getValue(ThemeVal.LIGHT_GREEN)).append("'}"); } }
@Override public ColorScheme getColorScheme() { return PlanColorScheme.create(system.getConfigSystem().getConfig(), logger); }
public Pie activityPie(Map<String, Set<UUID>> activityData) { String[] colors = theme.getValue(ThemeVal.GRAPH_ACTIVITY_PIE).split(", "); return new ActivityPie(activityData, colors); }
private void appendRegistered(StringBuilder series) { Map<String, Integer> registeredByDay = getRegisteredByDay(); for (Map.Entry<String, Integer> entry : registeredByDay.entrySet()) { Integer newPlayers = entry.getValue(); if (newPlayers <= 0) { continue; } String day = entry.getKey(); series.append(",{title: 'New: ").append(newPlayers) .append("',start:'").append(day) .append("',color: '").append(theme.getValue(ThemeVal.LIGHT_GREEN)).append("'") .append("}"); } }
public WorldPie worldPie(WorldTimes worldTimes) { WorldAliasSettings worldAliasSettings = config.getWorldAliasSettings(); Map<String, Long> playtimePerAlias = worldAliasSettings.getPlaytimePerAlias(worldTimes); Map<String, GMTimes> gmTimesPerAlias = worldAliasSettings.getGMTimesPerAlias(worldTimes); String[] colors = theme.getValue(ThemeVal.GRAPH_WORLD_PIE).split(", "); boolean orderByPercentage = config.isTrue(DisplaySettings.ORDER_WORLD_PIE_BY_PERC); return new WorldPie(playtimePerAlias, gmTimesPerAlias, colors, orderByPercentage); } }