mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-27 02:21:30 +01:00
Merge branch '4.0.0-BungeeCord-Support' of https://github.com/Rsl1122/Plan-PlayerAnalytics
This commit is contained in:
commit
14ca9d042c
@ -109,6 +109,7 @@
|
||||
<include>*.keystore</include>
|
||||
<include>*.css</include>
|
||||
<include>*.yml</include>
|
||||
<include>*.html</include>
|
||||
</includes>
|
||||
<excludes>
|
||||
<exclude>licence.yml</exclude>
|
||||
|
@ -39,6 +39,7 @@ import main.java.com.djrapitops.plan.database.databases.MySQLDB;
|
||||
import main.java.com.djrapitops.plan.database.databases.SQLiteDB;
|
||||
import main.java.com.djrapitops.plan.locale.Locale;
|
||||
import main.java.com.djrapitops.plan.locale.Msg;
|
||||
import main.java.com.djrapitops.plan.ui.theme.Theme;
|
||||
import main.java.com.djrapitops.plan.ui.webserver.WebServer;
|
||||
import main.java.com.djrapitops.plan.ui.webserver.api.bukkit.*;
|
||||
import main.java.com.djrapitops.plan.utilities.Benchmark;
|
||||
@ -214,6 +215,8 @@ public class Plan extends BukkitPlugin<Plan> {
|
||||
// BStats bStats = new BStats(this);
|
||||
// bStats.registerMetrics();
|
||||
|
||||
Theme.test(); //TODO Remove
|
||||
|
||||
Log.debug("Verbose debug messages are enabled.");
|
||||
Log.logDebug("Enable", Benchmark.stop("Enable", "Enable"));
|
||||
Log.info(Locale.get(Msg.ENABLED).toString());
|
||||
|
@ -71,9 +71,10 @@ public enum Settings {
|
||||
THEME_BASE("Theme.Base"),
|
||||
THEME_FONT_STYLESHEET("Theme.Font.FontStyleSheet"),
|
||||
THEME_FONT_FAMILY("Theme.Font.FontFamily"),
|
||||
THEME_FONT_COLOR_DARK("Theme.Font.Dark"),
|
||||
THEME_FONT_COLOR_LIGHT("Theme.Font.Light"),
|
||||
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"),
|
||||
|
68
Plan/src/main/java/com/djrapitops/plan/ui/theme/Colors.java
Normal file
68
Plan/src/main/java/com/djrapitops/plan/ui/theme/Colors.java
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.ui.theme;
|
||||
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.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;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
String settingValue = setting.toString();
|
||||
try {
|
||||
if ("base".equalsIgnoreCase(settingValue)) {
|
||||
return "#" + Theme.valueOf(Settings.THEME_BASE.toString().toUpperCase()).getColor(id);
|
||||
} else if ('#' == settingValue.charAt(0)) {
|
||||
return settingValue;
|
||||
} else {
|
||||
for (Theme t : Theme.values()) {
|
||||
if (t.name().equalsIgnoreCase(settingValue)) {
|
||||
return "#" + t.getColor(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
}
|
97
Plan/src/main/java/com/djrapitops/plan/ui/theme/Theme.java
Normal file
97
Plan/src/main/java/com/djrapitops/plan/ui/theme/Theme.java
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* 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.ui.theme;
|
||||
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Enum that contains available themes.
|
||||
* <p>
|
||||
* Change config setting Theme.Base to select one.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public enum 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 String[] colors;
|
||||
|
||||
Theme(String... colors) {
|
||||
int length = colors.length;
|
||||
if (length != 19) {
|
||||
Log.error("Not All colors (" + length + ") were specified in the theme file: " + name());
|
||||
Log.error("If the theme is used it WILL CAUSE EXCEPTIONS.");
|
||||
}
|
||||
this.colors = colors;
|
||||
}
|
||||
|
||||
public String getColor(int i) {
|
||||
return colors[i];
|
||||
}
|
||||
|
||||
public String replaceThemeColors(String resourceString) {
|
||||
Theme def = Theme.DEFAULT;
|
||||
String replaced = resourceString;
|
||||
for (Colors c : Colors.values()) {
|
||||
replaced = replaced.replace("#" + def.getColor(c.getId()), "#" + this.getColor(c.getId()));
|
||||
}
|
||||
return replaced;
|
||||
}
|
||||
|
||||
// TODO Remove
|
||||
public static void test() throws IOException {
|
||||
String serverHtml = HtmlUtils.getStringFromResource("server - Example.html");
|
||||
String css = HtmlUtils.getStringFromResource("main.css");
|
||||
|
||||
File folder = new File(Plan.getInstance().getDataFolder(), "themes");
|
||||
folder.mkdirs();
|
||||
for (Theme t : Theme.values()) {
|
||||
File themeFolder = new File(folder, t.name());
|
||||
themeFolder.mkdirs();
|
||||
File themeHtml = new File(themeFolder, "server.html");
|
||||
File themeCss = new File(themeFolder, "main.css");
|
||||
Files.write(themeHtml.toPath(), Collections.singletonList(t.replaceThemeColors(serverHtml)));
|
||||
Files.write(themeCss.toPath(), Collections.singletonList(t.replaceThemeColors(css)));
|
||||
}
|
||||
}
|
||||
}
|
@ -146,9 +146,9 @@ ${tabContentPlugins} row[column[box-header[h2[i, text]],box plugin], column...],
|
||||
|
||||
STYLE:
|
||||
|
||||
#267f00 - Theme
|
||||
#267f00 - Main Dark (Geolocations)
|
||||
#222 - Punchcard
|
||||
#89c471 - Theme (+sessionLength)
|
||||
#89c471 - Tertiary (Disabled links)
|
||||
#b58310 - Chunks
|
||||
#ac69ef - Entities
|
||||
#7dcc24 - RAM
|
||||
@ -163,7 +163,7 @@ main.css:
|
||||
#e2e2e2 (Table, even)
|
||||
#eee (Table, odd)
|
||||
|
||||
#348e0f Theme (Header, on hover) Darker
|
||||
#5da341 Theme (Main color)
|
||||
#348e0f Secondary Dark (Header, on hover)
|
||||
#5da341 Secondary
|
||||
|
||||
'Quicksand', sans-serif (Font Family)
|
@ -73,6 +73,7 @@ Theme:
|
||||
Light: Base
|
||||
Colors:
|
||||
Main: Base
|
||||
Main-Dark: Base
|
||||
Secondary: Base
|
||||
Secondary-Dark: Base
|
||||
Tertiary: Base
|
||||
|
Loading…
Reference in New Issue
Block a user