Rewrote Theme

This commit is contained in:
Rsl1122 2017-12-01 17:08:08 +02:00
parent aaed757af9
commit e19760c531
22 changed files with 334 additions and 243 deletions

View File

@ -47,6 +47,7 @@ import main.java.com.djrapitops.plan.database.databases.SQLiteDB;
import main.java.com.djrapitops.plan.settings.Settings;
import main.java.com.djrapitops.plan.settings.locale.Locale;
import main.java.com.djrapitops.plan.settings.locale.Msg;
import main.java.com.djrapitops.plan.settings.theme.Theme;
import main.java.com.djrapitops.plan.systems.cache.DataCache;
import main.java.com.djrapitops.plan.systems.cache.GeolocationCache;
import main.java.com.djrapitops.plan.systems.info.BukkitInformationManager;
@ -87,6 +88,7 @@ public class Plan extends BukkitPlugin implements IPlan {
private API api;
private Config config;
private Theme theme;
private ProcessingQueue processingQueue;
private HookHandler hookHandler; // Manages 3rd party data sources
@ -182,6 +184,8 @@ public class Plan extends BukkitPlugin implements IPlan {
new Locale(this).loadLocale();
theme = new Theme();
Benchmark.start("Reading server variables");
serverVariableHolder = new ServerVariableHolder(getServer());
Benchmark.stop("Enable", "Reading server variables");
@ -563,4 +567,9 @@ public class Plan extends BukkitPlugin implements IPlan {
public API getApi() {
return api;
}
@Override
public Theme getTheme() {
return theme;
}
}

View File

@ -24,6 +24,7 @@ import main.java.com.djrapitops.plan.database.databases.MySQLDB;
import main.java.com.djrapitops.plan.settings.Settings;
import main.java.com.djrapitops.plan.settings.locale.Locale;
import main.java.com.djrapitops.plan.settings.locale.Msg;
import main.java.com.djrapitops.plan.settings.theme.Theme;
import main.java.com.djrapitops.plan.systems.info.BungeeInformationManager;
import main.java.com.djrapitops.plan.systems.info.InformationManager;
import main.java.com.djrapitops.plan.systems.info.server.BungeeServerInfoManager;
@ -49,6 +50,7 @@ import java.util.UUID;
public class PlanBungee extends BungeePlugin implements IPlan {
private Config config;
private Theme theme;
private WebServer webServer;
private Database db;
@ -88,6 +90,8 @@ public class PlanBungee extends BungeePlugin implements IPlan {
new Locale(this).loadLocale();
theme = new Theme();
Log.info(Locale.get(Msg.ENABLE_DB_INIT).toString());
initDatabase();
@ -258,4 +262,8 @@ public class PlanBungee extends BungeePlugin implements IPlan {
return serverInfoManager.getServerUUID();
}
@Override
public Theme getTheme() {
return theme;
}
}

View File

@ -9,6 +9,7 @@ import com.djrapitops.plugin.api.config.Config;
import com.djrapitops.plugin.settings.ColorScheme;
import main.java.com.djrapitops.plan.ServerVariableHolder;
import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.settings.theme.Theme;
import main.java.com.djrapitops.plan.systems.info.InformationManager;
import main.java.com.djrapitops.plan.systems.processing.Processor;
import main.java.com.djrapitops.plan.systems.queue.ProcessingQueue;
@ -45,4 +46,6 @@ public interface IPlan extends IPlugin {
Config getMainConfig();
ColorScheme getColorScheme();
Theme getTheme();
}

View File

@ -7,7 +7,8 @@ import main.java.com.djrapitops.plan.data.additional.PluginData;
import main.java.com.djrapitops.plan.data.time.WorldTimes;
import main.java.com.djrapitops.plan.database.tables.Actions;
import main.java.com.djrapitops.plan.settings.Settings;
import main.java.com.djrapitops.plan.settings.theme.Colors;
import main.java.com.djrapitops.plan.settings.theme.ThemeVal;
import main.java.com.djrapitops.plan.settings.theme.Theme;
import main.java.com.djrapitops.plan.utilities.FormatUtils;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;
@ -63,17 +64,17 @@ public class AnalysisData extends RawData {
private void addConstants() {
addValue("version", MiscUtils.getIPlan().getVersion());
addValue("worldPieColors", Settings.THEME_GRAPH_WORLD_PIE.toString());
addValue("gmPieColors", Settings.THEME_GRAPH_GM_PIE.toString());
addValue("worldPieColors", Theme.getValue(ThemeVal.GRAPH_WORLD_PIE));
addValue("gmPieColors", Theme.getValue(ThemeVal.GRAPH_GM_PIE));
addValue("serverName", Settings.SERVER_NAME.toString());
addValue("timeZone", MiscUtils.getTimeZoneOffsetHours());
addValue("refresh", FormatUtils.formatTimeStamp(refreshDate));
addValue("activityPieColors", Settings.THEME_GRAPH_ACTIVITY_PIE.toString());
addValue("playersGraphColor", Colors.PLAYERS_ONLINE.getColor());
addValue("tpsHighColor", Colors.TPS_HIGH.getColor());
addValue("tpsMediumColor", Colors.TPS_MED.getColor());
addValue("tpsLowColor", Colors.TPS_LOW.getColor());
addValue("activityPieColors", Theme.getValue(ThemeVal.GRAPH_ACTIVITY_PIE));
addValue("playersGraphColor", Theme.getValue(ThemeVal.GRAPH_PLAYERS_ONLINE));
addValue("tpsHighColor", Theme.getValue(ThemeVal.GRAPH_TPS_HIGH));
addValue("tpsMediumColor", Theme.getValue(ThemeVal.GRAPH_TPS_MED));
addValue("tpsLowColor", Theme.getValue(ThemeVal.GRAPH_TPS_LOW));
addValue("tpsMedium", Settings.THEME_GRAPH_TPS_THRESHOLD_MED.getNumber());
addValue("tpsHigh", Settings.THEME_GRAPH_TPS_THRESHOLD_HIGH.getNumber());

View File

@ -26,6 +26,7 @@ public enum Settings {
DEV_MODE("Plugin.Dev"),
USE_SERVER_TIME("Customization.UseServerTime"),
DISPLAY_SESSIONS_AS_TABLE("Customization.Display.SessionsAsTable"),
APPEND_WORLD_PERC("Customization.Display.LargestWorldPercInSessionTitle"),
ORDER_WORLD_PIE_BY_PERC("Customization.Display.OrderWorldPieByPercentage"),
// Integer
@ -74,33 +75,9 @@ public enum Settings {
COLOR_TER("Commands.Colors.Highlight"),
//
THEME_BASE("Theme.Base"),
THEME_FONT_STYLESHEET("Theme.Font.FontStyleSheet"),
THEME_FONT_FAMILY("Theme.Font.FontFamily"),
THEME_FONT_COLOR_DARK("Theme.Font.Color.Dark"),
THEME_FONT_COLOR_LIGHT("Theme.Font.Color.Light"),
THEME_COLOR_MAIN("Theme.Colors.Main"),
THEME_COLOR_MAIN_DARK("Theme.Colors.Main-Dark"),
THEME_COLOR_SECONDARY("Theme.Colors.Secondary"),
THEME_COLOR_SECONDARY_DARK("Theme.Colors.Secondary-Dark"),
THEME_COLOR_TERTIARY("Theme.Colors.Tertiary"),
THEME_COLOR_BACKGROUND("Theme.Colors.Background"),
THEME_COLOR_TABLE_DARK("Theme.Colors.Table-Dark"),
THEME_COLOR_TABLE_LIGHT("Theme.Colors.Table-Light"),
THEME_GRAPH_PUNCHCARD("Theme.Graphs.PunchCard"),
THEME_GRAPH_PLAYERS_ONLINE("Theme.Graphs.PlayersOnline"),
THEME_GRAPH_TPS_THRESHOLD_HIGH("Theme.Graphs.TPS.High-Threshold"),
THEME_GRAPH_TPS_THRESHOLD_MED("Theme.Graphs.TPS.Medium-Threshold"),
THEME_GRAPH_TPS_HIGH("Theme.Graphs.TPS.High"),
THEME_GRAPH_TPS_MED("Theme.Graphs.TPS.Medium"),
THEME_GRAPH_TPS_LOW("Theme.Graphs.TPS.Low"),
THEME_GRAPH_CPU("Theme.Graphs.CPU"),
THEME_GRAPH_RAM("Theme.Graphs.RAM"),
THEME_GRAPH_CHUNKS("Theme.Graphs.Chunks"),
THEME_GRAPH_ENTITIES("Theme.Graphs.Entities"),
THEME_GRAPH_WORLD_PIE("Theme.Graphs.WorldPie"),
THEME_GRAPH_GM_PIE("Theme.Graphs.GMDrilldown"),
THEME_GRAPH_ACTIVITY_PIE("Theme.Graphs.ActivityPie"),
THEME_GRAPH_SERVER_PREF_PIE("Theme.Graphs.ServerPreferencePie"),
// StringList
HIDE_FACTIONS("Plugins.Factions.HideFactions"),
HIDE_TOWNS("Plugins.Towny.HideTowns"),

View File

@ -1,81 +0,0 @@
/*
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package main.java.com.djrapitops.plan.settings.theme;
import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.settings.Settings;
/**
* Enum class used for getting the Html colors that match the config settings.
*
* @author Rsl1122
*/
public enum Colors {
MAIN(0, Settings.THEME_COLOR_MAIN),
MAIN_DARK(1, Settings.THEME_COLOR_MAIN_DARK),
SECONDARY(2, Settings.THEME_COLOR_SECONDARY),
SECONDARY_DARK(3, Settings.THEME_COLOR_SECONDARY_DARK),
TERTIARY(4, Settings.THEME_COLOR_TERTIARY),
TABLE_LIGHT(5, Settings.THEME_COLOR_TABLE_LIGHT),
TABLE_DARK(6, Settings.THEME_COLOR_TABLE_DARK),
FONT_LIGHT(7, Settings.THEME_FONT_COLOR_LIGHT),
FONT_DARK(8, Settings.THEME_FONT_COLOR_DARK),
TPS_HIGH(9, Settings.THEME_GRAPH_TPS_HIGH),
TPS_MED(10, Settings.THEME_GRAPH_TPS_MED),
TPS_LOW(11, Settings.THEME_GRAPH_TPS_LOW),
PLAYERS_ONLINE(12, Settings.THEME_GRAPH_PLAYERS_ONLINE),
CPU(13, Settings.THEME_GRAPH_CPU),
RAM(14, Settings.THEME_GRAPH_RAM),
CHUNKS(15, Settings.THEME_GRAPH_CHUNKS),
ENTITIES(16, Settings.THEME_GRAPH_ENTITIES),
PUNCHCARD(17, Settings.THEME_GRAPH_PUNCHCARD),
BACKGROUND(18, Settings.THEME_COLOR_BACKGROUND);
private final int id;
private final Settings setting;
Colors(int themeId, Settings setting) {
id = themeId;
this.setting = setting;
}
/**
* Method responsible for parsing the setting into a usable css background property.
*
* @return #HEXCOD or url("url") for images.
*/
public String getColor() {
String settingValue = setting.toString();
try {
String returnValue = "";
if ("base".equalsIgnoreCase(settingValue)) {
returnValue = "#" + Theme.valueOf(Settings.THEME_BASE.toString().toUpperCase()).getColor(id);
} else if ('#' == settingValue.charAt(0)) {
returnValue = settingValue;
} else {
for (Theme t : Theme.values()) {
if (t.name().equalsIgnoreCase(settingValue)) {
returnValue = "#" + t.getColor(id);
}
}
}
if (returnValue.isEmpty()) {
returnValue = "#" + Theme.valueOf(Settings.THEME_BASE.toString().toUpperCase()).getColor(id);
}
if (settingValue.contains(".")) {
returnValue += " url(\"" + settingValue + "\")";
}
return returnValue;
} catch (Exception | NoSuchFieldError e) {
Log.error("Something went wrong with getting color " + id + " for theme: " + settingValue);
}
return Theme.DEFAULT.getColor(id);
}
public int getId() {
return id;
}
}

View File

@ -4,8 +4,15 @@
*/
package main.java.com.djrapitops.plan.settings.theme;
import com.djrapitops.plugin.api.utility.EnumUtility;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.api.exceptions.PlanEnableException;
import main.java.com.djrapitops.plan.settings.Settings;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
import java.io.IOException;
import java.util.List;
/**
* Enum that contains available themes.
@ -14,77 +21,78 @@ import main.java.com.djrapitops.plan.settings.Settings;
*
* @author Rsl1122
*/
public enum Theme {
public class Theme {
// Main, Main-Dark, Secondary, Secondary-Dark, Tertiary, Table-Light, Table-Dark,
// White, Black, TPSHigh, TPSMed, TPSLow, PlayersOnline
// CPU, RAM, Chunks, Entities, PunchCard, Background
DEFAULT("348e0f", "267f00", "5da341", "348e0f", "89c471", "eee", "e2e2e2",
"fff", "000", "267F00", "e5cc12", "b74343", "1E90FF",
"e0d264", "7dcc24", "b58310", "ac69ef", "222", "ddd"),
GREYSCALE("222", "111", "424242", "212121", "9e9e9e", "eee", "e2e2e2",
"fff", "000", "111", "616161", "9e9e9e", "bdbdbd",
"bdbdbd", "9e9e9e", "bdbdbd", "9e9e9e", "222", "ddd"),
BLAZE("ff8f00", "ff6100", "ffb300", "ffa000", "ffca28", "fff8e1", "ffecb3",
"fff", "000", "ffa000", "ff8f00", "ff6f00", "ff8f00",
"ffb300", "ff8f00", "ffb300", "ff8f00", "e65100", "ddd"),
DARKRED("8A3324", "832A0D", "a54433", "954535", "826644", "eee", "e2e2e2",
"fff", "000", "267F00", "e5cc12", "b74343", "CD853F",
"BC8F8F", "CD853F", "C19A6B", "D2B48C", "222", "89524f"),
BLUEGRAY("2f3f47", "293338", "37474f", "263238", "546e7a", "eee", "e2e2e2",
"fff", "000", "78909c", "455a64", "546e7a", "78909c",
"78909c", "546e7a", "78909c", "546e7a", "222", "ddd"),
PURPLE("4527a0", "311b92", "5e35b1", "512da8", "7c4dff", "eee", "e2e2e2",
"fff", "000", "9575cd", "7e57c2", "673ab7", "b39ddb",
"651fff", "7c4dff", "9575cd", "b39ddb", "222", "ede7f6"),
INDIGO("283593", "1a237e", "3949ab", "303f9f", "5c6bc0", "eee", "e2e2e2",
"fff", "000", "7986cb", "5c6bc0", "3f51b5", "536dfe",
"9fa8da", "5c6bc0", "3d5afe", "536dfe", "222", "e8eaf6"),
PINK("c2185b", "ad1457", "e91e63", "d81b60", "ff80ab", "eee", "e2e2e2",
"fff", "000", "f06292", "ec407a", "880e4f", "f06292",
"f48fb1", "ec407a", "f48fb1", "f06292", "222", "fce4ec"),
// TODO Tweak table colors
NIGHT("212021", "494849", "333133", "6B686B", "514F51", "BCB8BC", "ccc",
"fff", "000", "267F00", "e5cc12", "b74343", "1E90FF",
"e0d264", "7dcc24", "b58310", "ac69ef", "ddd", "565556");
private final ThemeConfig config;
private final String[] colors;
public Theme() throws PlanEnableException {
String themeName = Settings.THEME_BASE.toString();
try {
Theme(String... colors) {
int length = colors.length;
if (length < Colors.values().length) {
Log.error("Not All colors (" + length + ") were specified in the theme file: " + name());
Log.error("If the theme is used it WILL CAUSE EXCEPTIONS.");
config = new ThemeConfig(themeName);
} catch (IOException e) {
throw new PlanEnableException("Theme could not be loaded: " + themeName, e);
}
this.colors = colors;
}
public static String replaceColors(String resourceString) {
String replaced = resourceString;
for (Colors c : Colors.values()) {
String color = c.getColor();
if (!color.contains("url")) {
replaced = replaced.replace("#" + Theme.DEFAULT.getColor(c.getId()), color);
public String getColor(ThemeVal color) {
String path = color.getThemePath();
try {
String value = config.getString(path);
String returnValue = "";
if (value.isEmpty()) {
return value;
} else if (value.contains(".")) {
returnValue += "url(\"" + value + "\")";
} else {
String[] colorAndUrl = color.split(" ");
replaced = replaced.replace("color: #" + Theme.DEFAULT.getColor(c.getId()), "color: " + colorAndUrl[0]);
replaced = replaced.replace("background: #" + Theme.DEFAULT.getColor(c.getId()), "background: " + colorAndUrl[1]);
returnValue = value;
}
}
replaced = replaced.replace("https://fonts.googleapis.com/css?family=Quicksand:300,400", Settings.THEME_FONT_STYLESHEET.toString());
replaced = replaced.replace("''Quicksand'', sans-serif", Settings.THEME_FONT_FAMILY.toString());
return replaced;
}
public String getColor(int i) {
return colors[i];
if (returnValue.isEmpty()) {
returnValue = color.getDefaultValue();
}
return returnValue;
} catch (Exception | NoSuchFieldError e) {
Log.error("Something went wrong with getting color " + color.name() + " for: " + path);
}
return color.getDefaultValue();
}
public String replaceThemeColors(String resourceString) {
String replaced = resourceString;
for (Colors c : Colors.values()) {
replaced = replaced.replace("#" + Theme.DEFAULT.getColor(c.getId()), "#" + this.getColor(c.getId()));
List<ThemeVal> themeVariables = EnumUtility.getSupportedEnumValues(ThemeVal.class, "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")) {
replaced = replaced.replace(defaultValue, value);
} else {
String[] colorAndUrl = value.split(" ");
replaced = replaced.replace("background: " + defaultValue, "background: " + colorAndUrl[1]);
replaced = replaced.replace(defaultValue, colorAndUrl[0]);
}
}
return replaced;
}
public String getThemeValue(ThemeVal color) {
return config.getString(color.getThemePath());
}
public static String getValue(ThemeVal color) {
return MiscUtils.getIPlan().getTheme().getThemeValue(color);
}
public static String replaceColors(String resourceString) {
return MiscUtils.getIPlan().getTheme().replaceThemeColors(resourceString);
}
}

View File

@ -0,0 +1,55 @@
/*
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package main.java.com.djrapitops.plan.settings.theme;
import com.djrapitops.plugin.api.config.Config;
import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.file.FileUtil;
import java.io.File;
import java.io.IOException;
import java.util.List;
/**
* Config that keeps track of theme.yml.
*
* @author Rsl1122
*/
public class ThemeConfig extends Config {
private ThemeConfig(File file, List<String> defaults) {
super(file, defaults);
}
public ThemeConfig(String fileName) throws IOException {
this(getConfigFile(), getDefaults(fileName));
save();
}
private static List<String> getDefaults(String fileName) throws IOException {
String fileLocation = "themes/";
switch (fileName.toLowerCase()) {
default:
fileLocation += "theme.yml";
break;
}
IPlan plugin = MiscUtils.getIPlan();
return FileUtil.lines(plugin, fileLocation);
}
private static File getConfigFile() throws IOException {
File folder = MiscUtils.getIPlan().getDataFolder();
folder.mkdirs();
File themeFile = new File(folder, "theme.yml");
if (!themeFile.exists()) {
themeFile.createNewFile();
}
return themeFile;
}
}

View File

@ -0,0 +1,73 @@
/*
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package main.java.com.djrapitops.plan.settings.theme;
/**
* Enum class used for getting the Html colors that match the config settings.
*
* @author Rsl1122
*/
public enum ThemeVal {
THEME_DEFAULT("DefaultColor", "light-green"),
//
FONT_STYLESHEET("Font.FontStyleSheet", "https://fonts.googleapis.com/css?family=Roboto:400,700&subset=latin,cyrillic-ext"),
FONT_FAMILY("Font.FontFamily", "\"Roboto\", sans-serif"),
//
RED("Colors.red", "#E91E63"),
PINK("Colors.pink", "#F44336"),
PURPLE("Colors.purple", "#9C27B0"),
DEEP_PURPLE("Colors.deep-purple", "#673AB7"),
INDIGO("Colors.indigo", "#3F51B5"),
BLUE("Colors.blue", "#2196F3"),
LIGHT_BLUE("Colors.light-blue", "#03A9F4"),
CYAN("Colors.cyan", "#00BCD4"),
TEAL("Colors.teal", "#009688"),
GREEN("Colors.green", "#4CAF50"),
LIGHT_GREEN("Colors.light-green", "#8BC34A"),
LIME("Colors.lime", "#CDDC39"),
YELLOW("Colors.yellow", "#FFEB3B"),
AMBER("Colors.amber", "#FFC107"),
ORANGE("Colors.orange", "#FF9800"),
DEEP_ORANGE("Colors.deep-orange", "#FF5722"),
BROWN("Colors.brown", "#795548"),
GREY("Colors.brown", "#9E9E9E"),
BLUE_GREY("Colors.blue-grey", "#607D8B"),
BLACK("Colors.black", "#000000"),
WHITE("Colors.Extra.White", "#fff"),
//
GRAPH_PUNCHCARD("GraphColors.PunchCard", "#222"),
GRAPH_PLAYERS_ONLINE("GraphColors.PlayersOnline", "#1E90FF"),
GRAPH_TPS_HIGH("GraphColors.TPS.High", "#267F00"),
GRAPH_TPS_MED("GraphColors.TPS.Medium", "#e5cc12"),
GRAPH_TPS_LOW("GraphColors.TPS.Low", "#b74343"),
GRAPH_CPU("GraphColors.CPU", "#e0d264"),
GRAPH_RAM("GraphColors.RAM", "#7dcc24"),
GRAPH_CHUNKS("GraphColors.Chunks", "#b58310"),
GRAPH_ENTITIES("GraphColors.Entities", "#ac69ef"),
GRAPH_WORLD_PIE("GraphColors.WorldPie", "\"#0099C6\", \"#66AA00\", \"#316395\", \"#994499\", \"#22AA99\", \"#AAAA11\", \"#6633CC\", \"#E67300\", \"#329262\", \"#5574A6\""),
GRAPH_GM_PIE("GraphColors.GMDrilldown", "\"#438c99\", \"#639A67\", \"#D8EBB5\", \"#D9BF77\""),
GRAPH_ACTIVITY_PIE("GraphColors.ActivityPie", "\"#4CAF50\", \"#8BC34A\", \"#CDDC39\", \"#FFC107\", \"#607D8B\""),
GRAPH_SERVER_PREF_PIE("GraphColors.ServerPreferencePie", "\"#0099C6\", \"#66AA00\", \"#316395\", \"#994499\", \"#22AA99\", \"#AAAA11\", \"#6633CC\", \"#E67300\", \"#329262\", \"#5574A6\""),
//
PARSED_SESSION_ACCORDION("ParsedElements.SessionAccordion", "teal"),
PARSED_SERVER_ACCORDION("ParsedElements.ServerAccordion", "light-green");
private final String themePath;
private final String defaultValue;
ThemeVal(String themePath, String defaultValue) {
this.themePath = themePath;
this.defaultValue = defaultValue;
}
public String getThemePath() {
return themePath;
}
public String getDefaultValue() {
return defaultValue;
}
}

View File

@ -15,6 +15,8 @@ import main.java.com.djrapitops.plan.data.Session;
import main.java.com.djrapitops.plan.data.time.WorldTimes;
import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.settings.Settings;
import main.java.com.djrapitops.plan.settings.theme.ThemeVal;
import main.java.com.djrapitops.plan.settings.theme.Theme;
import main.java.com.djrapitops.plan.utilities.FormatUtils;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;
@ -99,9 +101,9 @@ public class InspectPageParser extends PageParser {
Map<UUID, WorldTimes> worldTimesPerServer = profile.getWorldTimesPerServer();
addValue("serverPieSeries", ServerPreferencePieCreator.createSeriesData(serverNames, worldTimesPerServer));
addValue("worldPieColors", Settings.THEME_GRAPH_WORLD_PIE.toString());
addValue("gmPieColors", Settings.THEME_GRAPH_GM_PIE.toString());
addValue("serverPieColors", Settings.THEME_GRAPH_SERVER_PREF_PIE.toString());
addValue("worldPieColors", Theme.getValue(ThemeVal.GRAPH_WORLD_PIE));
addValue("gmPieColors", Theme.getValue(ThemeVal.GRAPH_GM_PIE));
addValue("serverPieColors", Theme.getValue(ThemeVal.GRAPH_SERVER_PREF_PIE));
String favoriteServer = serverNames.get(profile.getFavoriteServer());
addValue("favoriteServer", favoriteServer != null ? favoriteServer : "Unknown");

View File

@ -11,7 +11,8 @@ import main.java.com.djrapitops.plan.data.Session;
import main.java.com.djrapitops.plan.data.TPS;
import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.settings.Settings;
import main.java.com.djrapitops.plan.settings.theme.Colors;
import main.java.com.djrapitops.plan.settings.theme.ThemeVal;
import main.java.com.djrapitops.plan.settings.theme.Theme;
import main.java.com.djrapitops.plan.systems.info.BungeeInformationManager;
import main.java.com.djrapitops.plan.utilities.FormatUtils;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
@ -56,7 +57,7 @@ public class NetworkPageParser extends PageParser {
addValue("networkName", Settings.BUNGEE_NETWORK_NAME.toString());
addValue("version", plugin.getVersion());
addValue("playersOnlineSeries", PlayerActivityGraphCreator.buildSeriesDataString(networkOnlineData));
addValue("playersGraphColor", Colors.PLAYERS_ONLINE.getColor());
addValue("playersGraphColor", Theme.getValue(ThemeVal.GRAPH_PLAYERS_ONLINE));
addValue("playersOnline", plugin.getProxy().getOnlineCount());
addValue("playersTotal", db.getUsersTable().getPlayerCount());

View File

@ -1,5 +1,12 @@
package main.java.com.djrapitops.plan.systems.webserver.response;
import main.java.com.djrapitops.plan.settings.theme.ThemeVal;
import main.java.com.djrapitops.plan.settings.theme.Theme;
import org.apache.commons.lang3.text.StrSubstitutor;
import java.util.HashMap;
import java.util.Map;
/**
* @author Rsl1122
* @since 3.5.2
@ -9,5 +16,8 @@ public class JavaScriptResponse extends FileResponse {
public JavaScriptResponse(String fileName) {
super(format(fileName));
super.setType(ResponseType.JAVASCRIPT);
Map<String, String> replace = new HashMap<>();
replace.put("defaultTheme", Theme.getValue(ThemeVal.THEME_DEFAULT));
setContent(StrSubstitutor.replace(Theme.replaceColors(getContent()), replace));
}
}

View File

@ -4,7 +4,8 @@
*/
package main.java.com.djrapitops.plan.utilities.html.graphs;
import main.java.com.djrapitops.plan.settings.Settings;
import main.java.com.djrapitops.plan.settings.theme.ThemeVal;
import main.java.com.djrapitops.plan.settings.theme.Theme;
import main.java.com.djrapitops.plan.utilities.FormatUtils;
import main.java.com.djrapitops.plan.utilities.html.graphs.pie.ActivityPieCreator;
@ -26,7 +27,7 @@ public class ActivityStackGraphCreator {
public static String[] createSeries(TreeMap<Long, Map<String, Set<UUID>>> activityData) {
String[] sliceNames = ActivityPieCreator.getSliceNames();
String[] colors = Settings.THEME_GRAPH_ACTIVITY_PIE.toString().split(", ");
String[] colors = Theme.getValue(ThemeVal.GRAPH_ACTIVITY_PIE).split(", ");
int maxCol = colors.length;
StringBuilder[] series = new StringBuilder[sliceNames.length + 1];

View File

@ -4,7 +4,8 @@
*/
package main.java.com.djrapitops.plan.utilities.html.graphs.pie;
import main.java.com.djrapitops.plan.settings.Settings;
import main.java.com.djrapitops.plan.settings.theme.ThemeVal;
import main.java.com.djrapitops.plan.settings.theme.Theme;
import java.util.*;
@ -24,7 +25,7 @@ public class ActivityPieCreator {
}
public static String createSeriesData(Map<String, Set<UUID>> activityData) {
String[] colors = Settings.THEME_GRAPH_ACTIVITY_PIE.toString().split(", ");
String[] colors = Theme.getValue(ThemeVal.GRAPH_ACTIVITY_PIE).split(", ");
int maxCol = colors.length;
List<PieSlice> slices = new ArrayList<>();

View File

@ -5,6 +5,8 @@ import main.java.com.djrapitops.plan.data.time.GMTimes;
import main.java.com.djrapitops.plan.data.time.WorldTimes;
import main.java.com.djrapitops.plan.settings.Settings;
import main.java.com.djrapitops.plan.settings.WorldAliasSettings;
import main.java.com.djrapitops.plan.settings.theme.ThemeVal;
import main.java.com.djrapitops.plan.settings.theme.Theme;
import main.java.com.djrapitops.plan.utilities.comparators.PieSliceComparator;
import java.util.*;
@ -37,7 +39,7 @@ public class WorldPieCreator {
}
private static List<PieSlice> turnToSlices(WorldTimes worldTimes) {
String[] colors = Settings.THEME_GRAPH_WORLD_PIE.toString().split(", ");
String[] colors = Theme.getValue(ThemeVal.GRAPH_WORLD_PIE).split(", ");
int colLenght = colors.length;
// WorldTimes Map<String, GMTimes> (GMTimes.getTotal)

View File

@ -7,6 +7,8 @@ package main.java.com.djrapitops.plan.utilities.html.structure;
import main.java.com.djrapitops.plan.data.PlayerProfile;
import main.java.com.djrapitops.plan.data.Session;
import main.java.com.djrapitops.plan.data.time.WorldTimes;
import main.java.com.djrapitops.plan.settings.theme.ThemeVal;
import main.java.com.djrapitops.plan.settings.theme.Theme;
import main.java.com.djrapitops.plan.utilities.FormatUtils;
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
@ -65,7 +67,7 @@ public class ServerAccordionCreator {
String[] worldData = WorldPieCreator.createSeriesData(worldTimes);
// Accordion panel header
html.append("<div class=\"panel panel-col-light-green\">")
html.append("<div class=\"panel panel-col-").append(Theme.getValue(ThemeVal.PARSED_SERVER_ACCORDION)).append("\">")
.append("<div class=\"panel-heading\" role=\"tab\" id=\"heading_").append(htmlID).append("\">")
.append("<h4 class=\"panel-title\">")
.append("<a class=\"collapsed\" role=\"button\" data-toggle=\"collapse\" data-parent=\"#session_accordion\" ")

View File

@ -9,6 +9,8 @@ import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.Session;
import main.java.com.djrapitops.plan.data.time.WorldTimes;
import main.java.com.djrapitops.plan.settings.Settings;
import main.java.com.djrapitops.plan.settings.theme.ThemeVal;
import main.java.com.djrapitops.plan.settings.theme.Theme;
import main.java.com.djrapitops.plan.utilities.FormatUtils;
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;
import main.java.com.djrapitops.plan.utilities.html.Html;
@ -48,6 +50,9 @@ public class SessionTabStructureCreator {
if (maxSessions <= 0) {
maxSessions = 50;
}
boolean appendWorldPerc = Settings.APPEND_WORLD_PERC.isTrue();
for (Session session : allSessions) {
if (i >= maxSessions) {
break;
@ -58,8 +63,9 @@ public class SessionTabStructureCreator {
String serverName = serverNameIDMap.get(sessionID);
String sessionStart = FormatUtils.formatTimeStampYear(session.getSessionStart());
String sessionLength = FormatUtils.formatTimeAmount(session.getLength());
String sessionEnd = session.getSessionEnd() == -1 ? "Online" : FormatUtils.formatTimeStampYear(session.getSessionEnd());
long endOfSession = session.getSessionEnd();
String sessionLength = endOfSession == -1 ? "Online" : FormatUtils.formatTimeAmount(session.getLength());
String sessionEnd = endOfSession == -1 ? "Online" : FormatUtils.formatTimeStampYear(endOfSession);
int playerKillCount = session.getPlayerKills().size();
@ -68,6 +74,9 @@ public class SessionTabStructureCreator {
String dotSeparated = appendName ?
HtmlStructure.separateWithDots(name, sessionStart) :
HtmlStructure.separateWithDots(serverName, sessionStart);
String dotSeparated2 = appendWorldPerc
? HtmlStructure.separateWithDots(SessionsTableCreator.getLongestWorldPlayed(session), sessionLength)
: sessionEnd;
String htmlID = "" + session.getSessionStart() + sessionID + i;
@ -80,13 +89,14 @@ public class SessionTabStructureCreator {
String killTable = KillsTableCreator.createTable(session.getPlayerKills());
// Accordion panel header
html.append("<div title=\"Session ID: ").append(sessionID).append("\"class=\"panel panel-col-teal\">")
html.append("<div title=\"Session ID: ").append(sessionID)
.append("\"class=\"panel panel-col-").append(Theme.getValue(ThemeVal.PARSED_SESSION_ACCORDION)).append("\">")
.append("<div class=\"panel-heading\" role=\"tab\" id=\"heading_").append(htmlID).append("\">")
.append("<h4 class=\"panel-title\">")
.append("<a class=\"collapsed\" role=\"button\" data-toggle=\"collapse\" data-parent=\"#session_accordion\" ")
.append("href=\"#session_").append(htmlID).append("\" aria-expanded=\"false\" ")
.append("aria-controls=\"session_").append(htmlID).append("\">")
.append(dotSeparated).append("<span class=\"pull-right\">").append(session.getSessionEnd() == -1 ? "Online" : sessionLength).append("</span>") // Title (header)
.append(dotSeparated).append("<span class=\"pull-right\">").append(dotSeparated2).append("</span>") // Title (header)
.append("</a></h4>") // Closes collapsed, panel title
.append("</div>"); // Closes panel heading

View File

@ -104,7 +104,7 @@ public class SessionsTableCreator {
return new String[]{sessionTableBuilder.toString(), recentLoginsBuilder.toString()};
}
private static String getLongestWorldPlayed(Session session) {
public static String getLongestWorldPlayed(Session session) {
WorldAliasSettings aliasSettings = new WorldAliasSettings(Plan.getInstance());
Map<String, String> aliases = aliasSettings.getAliases();
if (session.getSessionEnd() == -1) {

View File

@ -73,6 +73,7 @@ Customization:
UseServerTime: true
Display:
SessionsAsTable: false
LargestWorldPercInSessionTitle: false
# By Default WorldPie is ordered alphabetically, colors are still determined alphabetically.
OrderWorldPieByPercentage: false
MaxSessions: 50
@ -97,41 +98,15 @@ Customization:
# -----------------------------------------------------
# More information about Themes:
# https://github.com/Rsl1122/Plan-PlayerAnalytics/wiki/Themes
#
# Since 4.1.0 colors are set in theme.yml
# -----------------------------------------------------
Theme:
Base: Default
Font:
FontStyleSheet: https://fonts.googleapis.com/css?family=Quicksand:300,400
FontFamily: "'Quicksand', sans-serif"
Color:
Dark: Base
Light: Base
Colors:
Main: Base
Main-Dark: Base
Secondary: Base
Secondary-Dark: Base
Tertiary: Base
Background: Base
Table-Light: Base
Table-Dark: Base
Graphs:
PunchCard: Base
PlayersOnline: Base
TPS:
High-Threshold: 18
Medium-Threshold: 10
High: Base
Medium: Base
Low: Base
CPU: Base
RAM: Base
Chunks: Base
Entities: Base
WorldPie: '"#0099C6", "#66AA00", "#316395", "#994499", "#22AA99", "#AAAA11", "#6633CC", "#E67300", "#329262", "#5574A6"'
GMDrilldown: '"#438c99", "#639A67", "#D8EBB5", "#D9BF77"'
ActivityPie: '"#4CAF50", "#8BC34A", "#CDDC39", "#FFC107", "#607D8B"'
ServerPreferencePie: '"#0099C6", "#66AA00", "#316395", "#994499", "#22AA99", "#AAAA11", "#6633CC", "#E67300", "#329262", "#5574A6"'
# -----------------------------------------------------
Plugins:
Factions:

View File

@ -1,23 +0,0 @@
DefaultColor: "light-green"
Colors:
red: "#F44336"
pink: "#E91E63"
purple: "#9C27B0"
deep-purple: "#673AB7"
indigo: "#3F51B5"
blue: "#2196F3"
light-blue: "#03A9F4"
cyan: "#00BCD4"
teal: "#009688"
green: "#4CAF50"
light-green: "#8BC34A"
lime: "#CDDC39"
yellow: "#FFEB3B"
amber: "#FFC107"
orange: "#FF9800"
deep-orange: "#FF5722"
brown: "#795548"
grey: "#9E9E9E"
blue-grey: "#607D8B"
black: "#000000"

View File

@ -0,0 +1,57 @@
# Default Theme bar color when user has not chosen a color
DefaultColor: "light-green"
Font:
# Location of the FontStyleSheet, eg. https://fonts.googleapis.com/css?family=Quicksand:300,400
FontStyleSheet: https://fonts.googleapis.com/css?family=Roboto:400,700&subset=latin,cyrillic-ext
# Name of the Font for CSS eg "'Quicksand', sans-serif"
FontFamily: '"Roboto", sans-serif'
# Color codes for each theme element color
# These affect icons & backgrounds of all elements of this color.
Colors:
red: "#F44336"
pink: "#E91E63"
purple: "#9C27B0"
deep-purple: "#673AB7"
indigo: "#3F51B5"
blue: "#2196F3"
light-blue: "#03A9F4"
cyan: "#00BCD4"
teal: "#009688"
green: "#4CAF50"
light-green: "#8BC34A"
lime: "#CDDC39"
yellow: "#FFEB3B"
amber: "#FFC107"
orange: "#FF9800"
deep-orange: "#FF5722"
brown: "#795548"
grey: "#9E9E9E"
blue-grey: "#607D8B"
black: "#000000"
Extra:
White: "#fff"
# Useful tool for html colors
# https://www.w3schools.com/colors/colors_picker.asp
GraphColors:
PunchCard: "#222"
PlayersOnline: "#1E90FF"
TPS:
High: "#267F00"
Medium: "#e5cc12"
Low: "#b74343"
CPU: "#e0d264"
RAM: "#7dcc24"
Chunks: "#b58310"
Entities: "#ac69ef"
WorldPie: '"#0099C6", "#66AA00", "#316395", "#994499", "#22AA99", "#AAAA11", "#6633CC", "#E67300", "#329262", "#5574A6"'
GMDrilldown: '"#438c99", "#639A67", "#D8EBB5", "#D9BF77"'
ActivityPie: '"#4CAF50", "#8BC34A", "#CDDC39", "#FFC107", "#607D8B"'
ServerPreferencePie: '"#0099C6", "#66AA00", "#316395", "#994499", "#22AA99", "#AAAA11", "#6633CC", "#E67300", "#329262", "#5574A6"'
# Leave blank "" for white
ParsedElements:
SessionAccordion: "teal"
ServerAccordion: "light-green"

View File

@ -29,7 +29,7 @@ function skinChanger() {
function setSkin() {
var theme = localStorage.getItem("plan_skin");
if (theme === null) {
theme = 'light-green'
theme = '${defaultTheme}'
}
var body = document.getElementsByTagName('body')[0];