Refactored ColorScheme

This commit is contained in:
Rsl1122 2017-12-14 16:00:48 +02:00
parent 0ef23bb751
commit c84ad59da4
3 changed files with 39 additions and 20 deletions

View File

@ -39,6 +39,7 @@ import main.java.com.djrapitops.plan.database.Database;
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.PlanColorScheme;
import main.java.com.djrapitops.plan.settings.theme.Theme;
import main.java.com.djrapitops.plan.systems.Systems;
import main.java.com.djrapitops.plan.systems.cache.DataCache;
@ -62,7 +63,6 @@ import main.java.com.djrapitops.plan.systems.webserver.WebServerSystem;
import main.java.com.djrapitops.plan.systems.webserver.pagecache.PageCache;
import main.java.com.djrapitops.plan.utilities.file.export.HtmlExport;
import main.java.com.djrapitops.plan.utilities.metrics.BStats;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
import java.io.IOException;
@ -232,15 +232,7 @@ public class Plan extends BukkitPlugin implements IPlan {
@Override
public ColorScheme getColorScheme() {
try {
ChatColor mainColor = ChatColor.getByChar(Settings.COLOR_MAIN.toString().charAt(1));
ChatColor secColor = ChatColor.getByChar(Settings.COLOR_SEC.toString().charAt(1));
ChatColor terColor = ChatColor.getByChar(Settings.COLOR_TER.toString().charAt(1));
return new ColorScheme(mainColor, secColor, terColor);
} catch (Exception e) {
Log.infoColor(ChatColor.RED + "Customization, Chat colors set-up wrong, using defaults.");
return new ColorScheme(ChatColor.DARK_GREEN, ChatColor.GRAY, ChatColor.WHITE);
}
return PlanColorScheme.create();
}
/**

View File

@ -17,6 +17,7 @@ import main.java.com.djrapitops.plan.database.Database;
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.PlanColorScheme;
import main.java.com.djrapitops.plan.settings.theme.Theme;
import main.java.com.djrapitops.plan.systems.Systems;
import main.java.com.djrapitops.plan.systems.file.FileSystem;
@ -33,7 +34,6 @@ import main.java.com.djrapitops.plan.systems.update.VersionCheckSystem;
import main.java.com.djrapitops.plan.systems.webserver.WebServer;
import main.java.com.djrapitops.plan.systems.webserver.WebServerSystem;
import main.java.com.djrapitops.plan.utilities.file.export.HtmlExport;
import net.md_5.bungee.api.ChatColor;
import java.io.InputStream;
import java.util.UUID;
@ -180,15 +180,7 @@ public class PlanBungee extends BungeePlugin implements IPlan {
@Override
public ColorScheme getColorScheme() {
try {
ChatColor mainColor = ChatColor.getByChar(Settings.COLOR_MAIN.toString().charAt(1));
ChatColor secColor = ChatColor.getByChar(Settings.COLOR_SEC.toString().charAt(1));
ChatColor terColor = ChatColor.getByChar(Settings.COLOR_TER.toString().charAt(1));
return new ColorScheme(mainColor, secColor, terColor);
} catch (Exception e) {
Log.infoColor(ChatColor.RED + "Customization, Chat colors set-up wrong, using defaults.");
return new ColorScheme(ChatColor.DARK_GREEN, ChatColor.GRAY, ChatColor.WHITE);
}
return PlanColorScheme.create();
}
@Override

View File

@ -0,0 +1,35 @@
/*
* 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 com.djrapitops.plugin.settings.ColorScheme;
import main.java.com.djrapitops.plan.settings.Settings;
/**
* //TODO Class Javadoc Comment
*
* @author Rsl1122
*/
public class PlanColorScheme extends ColorScheme {
private PlanColorScheme(String... colors) {
super(colors);
}
public static PlanColorScheme create() {
try {
String main = "§" + Settings.COLOR_MAIN.toString().charAt(1);
String secondary = "§" + Settings.COLOR_SEC.toString().charAt(1);
String tertiary = "§" + Settings.COLOR_TER.toString().charAt(1);
return new PlanColorScheme(main, secondary, tertiary);
} catch (Exception e) {
Log.infoColor("§cCustomization, Chat colors set-up wrong, using defaults.");
return new PlanColorScheme("§2", "§7", "§f");
}
}
}