mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-03-12 14:49:56 +01:00
Fix Bungee Startup, include apache lang3 in jar.
This commit is contained in:
parent
98860f0076
commit
a731db656c
@ -40,7 +40,7 @@ public class ServerVariableHolder {
|
||||
public ServerVariableHolder(net.md_5.bungee.api.ProxyServer server) {
|
||||
ip = Settings.BUNGEE_IP.toString();
|
||||
name = "BungeeCord";
|
||||
port = Settings.BUNGEE_PORT.getNumber();
|
||||
port = -1;
|
||||
version = server.getVersion();
|
||||
implVersion = server.getVersion();
|
||||
usingPaper = false;
|
||||
|
@ -87,8 +87,7 @@ public enum Settings {
|
||||
HIDE_TOWNS("Plugins.Towny.HideTowns"),
|
||||
//
|
||||
// Bungee
|
||||
BUNGEE_IP("Server.IP"),
|
||||
BUNGEE_PORT("Server.Port")
|
||||
BUNGEE_IP("Server.IP")
|
||||
;
|
||||
|
||||
|
||||
|
@ -8,14 +8,19 @@ import com.djrapitops.plugin.BungeePlugin;
|
||||
import com.djrapitops.plugin.settings.ColorScheme;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.ServerVariableHolder;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.api.IPlan;
|
||||
import main.java.com.djrapitops.plan.database.Database;
|
||||
import main.java.com.djrapitops.plan.database.databases.MySQLDB;
|
||||
import main.java.com.djrapitops.plan.locale.Locale;
|
||||
import main.java.com.djrapitops.plan.locale.Msg;
|
||||
import main.java.com.djrapitops.plan.systems.info.InformationManager;
|
||||
import main.java.com.djrapitops.plan.systems.info.server.ServerInfoManager;
|
||||
import main.java.com.djrapitops.plan.systems.processing.Processor;
|
||||
import main.java.com.djrapitops.plan.systems.queue.ProcessingQueue;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.WebServer;
|
||||
import main.java.com.djrapitops.plan.utilities.Benchmark;
|
||||
import main.java.com.djrapitops.plan.utilities.Check;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import java.io.InputStream;
|
||||
@ -42,7 +47,8 @@ public class PlanBungee extends BungeePlugin<PlanBungee> implements IPlan {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
super.setInstance(this);
|
||||
|
||||
super.setDebugMode(Settings.DEBUG.toString());
|
||||
super.getPluginLogger().setFolder(getDataFolder());
|
||||
super.setColorScheme(new ColorScheme(ChatColor.GREEN, ChatColor.GRAY, ChatColor.WHITE));
|
||||
super.setLogPrefix("[Plan]");
|
||||
super.setUpdateCheckUrl("https://raw.githubusercontent.com/Rsl1122/Plan-PlayerAnalytics/master/Plan/src/main/resources/plugin.yml");
|
||||
@ -54,12 +60,29 @@ public class PlanBungee extends BungeePlugin<PlanBungee> implements IPlan {
|
||||
|
||||
variableHolder = new ServerVariableHolder(getProxy());
|
||||
|
||||
new Locale(this).loadLocale();
|
||||
|
||||
processingQueue = new ProcessingQueue();
|
||||
|
||||
Log.info(Locale.get(Msg.ENABLE_DB_INIT).toString());
|
||||
if (!initDatabase()) {
|
||||
disablePlugin();
|
||||
return;
|
||||
}
|
||||
|
||||
String ip = variableHolder.getIp();
|
||||
if ("0.0.0.0".equals(ip)) {
|
||||
Log.error("IP setting still 0.0.0.0 - Set up AlternativeIP/IP that connects to the Proxy server.");
|
||||
}
|
||||
|
||||
Benchmark.start("WebServer Initialization");
|
||||
webServer = new WebServer(this);
|
||||
webServer.initServer();
|
||||
|
||||
if (!webServer.isEnabled()) {
|
||||
Log.error("WebServer was not successfully initialized.");
|
||||
disablePlugin();
|
||||
return;
|
||||
}
|
||||
|
||||
serverInfoManager = new ServerInfoManager(this);
|
||||
@ -67,8 +90,7 @@ public class PlanBungee extends BungeePlugin<PlanBungee> implements IPlan {
|
||||
webServer.setInfoManager(infoManager);
|
||||
|
||||
Benchmark.stop("Enable", "WebServer Initialization");
|
||||
|
||||
processingQueue = new ProcessingQueue();
|
||||
Log.info(Locale.get(Msg.ENABLED).toString());
|
||||
}
|
||||
|
||||
public static PlanBungee getInstance() {
|
||||
@ -82,6 +104,12 @@ public class PlanBungee extends BungeePlugin<PlanBungee> implements IPlan {
|
||||
for (Processor processor : processors) {
|
||||
processor.process();
|
||||
}
|
||||
Log.info(Locale.get(Msg.DISABLED).toString());
|
||||
}
|
||||
|
||||
private boolean initDatabase() {
|
||||
db = new MySQLDB(this);
|
||||
return Check.errorIfFalse(db.init(), Locale.get(Msg.ENABLE_DB_FAIL_DISABLE_INFO).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,6 @@
|
||||
package main.java.com.djrapitops.plan.database;
|
||||
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.api.IPlan;
|
||||
import main.java.com.djrapitops.plan.data.UserInfo;
|
||||
import main.java.com.djrapitops.plan.database.tables.*;
|
||||
import org.apache.commons.dbcp2.BasicDataSource;
|
||||
@ -22,7 +22,7 @@ public abstract class Database {
|
||||
/**
|
||||
* Instance of Plan used with this database.
|
||||
*/
|
||||
protected final Plan plugin;
|
||||
protected final IPlan plugin;
|
||||
|
||||
/**
|
||||
* Table representing plan_users in the database.
|
||||
@ -109,7 +109,7 @@ public abstract class Database {
|
||||
*
|
||||
* @param plugin current instance of Plan.
|
||||
*/
|
||||
public Database(Plan plugin) {
|
||||
public Database(IPlan plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
package main.java.com.djrapitops.plan.database.databases;
|
||||
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plugin.config.fileconfig.IFileConfig;
|
||||
import main.java.com.djrapitops.plan.api.IPlan;
|
||||
import org.apache.commons.dbcp2.BasicDataSource;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author Rsl1122
|
||||
@ -14,7 +16,7 @@ public class MySQLDB extends SQLDB {
|
||||
*
|
||||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
public MySQLDB(Plan plugin) {
|
||||
public MySQLDB(IPlan plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@ -22,14 +24,15 @@ public class MySQLDB extends SQLDB {
|
||||
* Setups the {@link BasicDataSource}
|
||||
*/
|
||||
@Override
|
||||
public void setupDataSource() {
|
||||
FileConfiguration config = plugin.getConfig();
|
||||
public void setupDataSource() throws IOException {
|
||||
IFileConfig config = null;
|
||||
config = plugin.getIConfig().getConfig();
|
||||
|
||||
dataSource = new BasicDataSource();
|
||||
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
|
||||
|
||||
String host = config.getString("Database.MySQL.Host");
|
||||
String port = config.getString("Database.MySQL.Port");
|
||||
String port = config.getInt("Database.MySQL.Port").toString();
|
||||
String database = config.getString("Database.MySQL.Database");
|
||||
|
||||
dataSource.setUrl("jdbc:mysql://" + host + ":" + port + "/" + database + "?rewriteBatchedStatements=true");
|
||||
|
@ -1,13 +1,14 @@
|
||||
package main.java.com.djrapitops.plan.database.databases;
|
||||
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.api.IPlan;
|
||||
import main.java.com.djrapitops.plan.data.UserInfo;
|
||||
import main.java.com.djrapitops.plan.database.Database;
|
||||
import main.java.com.djrapitops.plan.database.tables.*;
|
||||
import main.java.com.djrapitops.plan.utilities.Benchmark;
|
||||
import org.apache.commons.dbcp2.BasicDataSource;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
@ -29,7 +30,7 @@ public abstract class SQLDB extends Database {
|
||||
/**
|
||||
* @param plugin
|
||||
*/
|
||||
public SQLDB(Plan plugin) {
|
||||
public SQLDB(IPlan plugin) {
|
||||
super(plugin);
|
||||
usingMySQL = getName().equals("MySQL");
|
||||
|
||||
@ -75,7 +76,7 @@ public abstract class SQLDB extends Database {
|
||||
|
||||
clean();
|
||||
return true;
|
||||
} catch (SQLException e) {
|
||||
} catch (IOException | SQLException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
return false;
|
||||
} finally {
|
||||
@ -174,7 +175,7 @@ public abstract class SQLDB extends Database {
|
||||
/**
|
||||
* Setups the {@link BasicDataSource}
|
||||
*/
|
||||
public abstract void setupDataSource();
|
||||
public abstract void setupDataSource() throws IOException;
|
||||
|
||||
/**
|
||||
* @throws SQLException
|
||||
|
@ -12,7 +12,6 @@ import main.java.com.djrapitops.plan.utilities.comparators.LocaleEntryComparator
|
||||
import main.java.com.djrapitops.plan.utilities.comparators.StringLengthComparator;
|
||||
import main.java.com.djrapitops.plan.utilities.file.FileUtil;
|
||||
import main.java.com.djrapitops.plan.utilities.html.Html;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@ -112,9 +111,9 @@ public class Locale {
|
||||
private void loadDefault() {
|
||||
String analysis = "Analysis | ";
|
||||
String prefix = "[Plan] ";
|
||||
String green = ChatColor.GREEN.toString();
|
||||
String yellow = ChatColor.YELLOW.toString();
|
||||
String red = ChatColor.RED.toString();
|
||||
String green = "§a";
|
||||
String yellow = "§e";
|
||||
String red = "§c";
|
||||
String arrowsRight = DefaultMessages.ARROWS_RIGHT.parse();
|
||||
ColorScheme cs = plugin.getColorScheme();
|
||||
String mCol = cs.getMainColor();
|
||||
|
@ -1,7 +1,7 @@
|
||||
package main.java.com.djrapitops.plan.locale;
|
||||
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import org.apache.commons.lang.text.StrSubstitutor;
|
||||
import org.apache.commons.lang3.text.StrSubstitutor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
|
@ -8,7 +8,6 @@ import com.djrapitops.plugin.config.BukkitConfig;
|
||||
import com.djrapitops.plugin.config.fileconfig.IFileConfig;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
@ -26,7 +25,7 @@ import java.util.UUID;
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class ServerInfoFile extends BukkitConfig {
|
||||
public ServerInfoFile(Plan plugin) throws IOException, InvalidConfigurationException {
|
||||
public ServerInfoFile(Plan plugin) throws IOException {
|
||||
super(plugin, "ServerInfoFile");
|
||||
IFileConfig config = super.getConfig();
|
||||
config.copyDefaults();
|
||||
|
@ -13,7 +13,6 @@ import main.java.com.djrapitops.plan.api.IPlan;
|
||||
import main.java.com.djrapitops.plan.bungee.PlanBungee;
|
||||
import main.java.com.djrapitops.plan.database.Database;
|
||||
import main.java.com.djrapitops.plan.database.tables.ServerTable;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
@ -41,7 +40,7 @@ public class ServerInfoManager {
|
||||
|
||||
try {
|
||||
serverInfoFile = new ServerInfoFile(plugin);
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
} catch (IOException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
Log.error("Failed to read server info from local file, disabling plugin.");
|
||||
plugin.disablePlugin();
|
||||
|
@ -1,6 +1,9 @@
|
||||
package main.java.com.djrapitops.plan.systems.queue;
|
||||
|
||||
import com.djrapitops.plugin.task.RunnableFactory;
|
||||
import com.djrapitops.plugin.utilities.Compatibility;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.bungee.PlanBungee;
|
||||
|
||||
/**
|
||||
* Abstract representation of a queue setup.
|
||||
@ -24,7 +27,7 @@ public abstract class Setup<T> {
|
||||
|
||||
public void go() {
|
||||
for (Consumer<T> consumer : consumers) {
|
||||
Plan.getInstance().getRunnableFactory().createNew(consumer).runTaskAsynchronously();
|
||||
getRunnableFactory().createNew(consumer).runTaskAsynchronously();
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,4 +36,12 @@ public abstract class Setup<T> {
|
||||
consumer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
private RunnableFactory getRunnableFactory() {
|
||||
if (Compatibility.isBukkitAvailable()) {
|
||||
return Plan.getInstance().getRunnableFactory();
|
||||
} else {
|
||||
return PlanBungee.getInstance().getRunnableFactory();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ import main.java.com.djrapitops.plan.utilities.Benchmark;
|
||||
import main.java.com.djrapitops.plan.utilities.PassEncryptUtil;
|
||||
import main.java.com.djrapitops.plan.utilities.html.HtmlUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import javax.net.ssl.*;
|
||||
import java.io.*;
|
||||
@ -95,7 +94,7 @@ public class WebServer {
|
||||
Log.debug(usingHttps ? "Https Start Successful." : "Https Start Failed.");
|
||||
|
||||
if (!usingHttps) {
|
||||
Log.infoColor(ChatColor.YELLOW + "User Authorization Disabled! (Not possible over http)");
|
||||
Log.infoColor("§eUser Authorization Disabled! (Not possible over http)");
|
||||
server = HttpServer.create(new InetSocketAddress(port), 10);
|
||||
}
|
||||
|
||||
@ -273,7 +272,7 @@ public class WebServer {
|
||||
Log.error("WebServer: SSL Context Initialization Failed.");
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
} catch (FileNotFoundException e) {
|
||||
Log.infoColor(ChatColor.YELLOW + "WebServer: SSL Certificate KeyStore File not Found: " + keyStorePath);
|
||||
Log.infoColor("§eWebServer: SSL Certificate KeyStore File not Found: " + keyStorePath);
|
||||
Log.info("No Certificate -> Using Http server for Visualization.");
|
||||
} catch (IOException e) {
|
||||
Log.error("WebServer: " + e);
|
||||
|
@ -1,7 +1,10 @@
|
||||
package main.java.com.djrapitops.plan.utilities;
|
||||
|
||||
import com.djrapitops.plugin.utilities.BenchUtil;
|
||||
import com.djrapitops.plugin.utilities.Compatibility;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.bungee.PlanBungee;
|
||||
|
||||
/**
|
||||
* @author Rsl1122
|
||||
@ -19,7 +22,7 @@ public class Benchmark {
|
||||
* @param source
|
||||
*/
|
||||
public static void start(String source) {
|
||||
Plan.getInstance().benchmark().start(source);
|
||||
getBenchUtil().start(source);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -27,7 +30,7 @@ public class Benchmark {
|
||||
* @return
|
||||
*/
|
||||
public static long stop(String source) {
|
||||
long ms = Plan.getInstance().benchmark().stop(source);
|
||||
long ms = getBenchUtil().stop(source);
|
||||
if (ms != -1) {
|
||||
Log.debug(source + " took " + ms + " ms");
|
||||
}
|
||||
@ -42,6 +45,14 @@ public class Benchmark {
|
||||
* @return Execution time in ms.
|
||||
*/
|
||||
public static long stop(String task, String source) {
|
||||
return Plan.getInstance().benchmark().stop(task, source);
|
||||
return getBenchUtil().stop(task, source);
|
||||
}
|
||||
|
||||
private static BenchUtil getBenchUtil() {
|
||||
if (Compatibility.isBukkitAvailable()) {
|
||||
return Plan.getInstance().benchmark();
|
||||
} else {
|
||||
return PlanBungee.getInstance().benchmark();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package main.java.com.djrapitops.plan.utilities.html;
|
||||
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import org.apache.commons.lang.text.StrSubstitutor;
|
||||
import org.apache.commons.lang3.text.StrSubstitutor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
|
97
Plan/src/main/resources/bungeeconfig.yml
Normal file
97
Plan/src/main/resources/bungeeconfig.yml
Normal file
@ -0,0 +1,97 @@
|
||||
Server:
|
||||
IP: 0.0.0.0
|
||||
|
||||
Plugin:
|
||||
Debug: 'false'
|
||||
Locale: default
|
||||
WriteNewLocaleFileOnEnable: false
|
||||
|
||||
WebServer:
|
||||
Port: 8804
|
||||
InternalIP: 0.0.0.0
|
||||
Security:
|
||||
SSL-Certificate:
|
||||
KeyStorePath: 'SSLCertificate.keystore'
|
||||
KeyPass: 'default'
|
||||
StorePass: 'default'
|
||||
Alias: 'alias'
|
||||
Servers:
|
||||
TODO: TODO AUTO GENERATE
|
||||
Server1:
|
||||
Port: 8805
|
||||
Server2:
|
||||
Port: 8806
|
||||
|
||||
Database:
|
||||
MySQL:
|
||||
Host: localhost
|
||||
Port: 3306
|
||||
User: root
|
||||
Password: minecraft
|
||||
Database: Plan
|
||||
|
||||
Commands:
|
||||
AlternativeIP:
|
||||
Enabled: false
|
||||
Link: your.domain.here:%port%
|
||||
Colors:
|
||||
Main: '&2'
|
||||
Secondary: '&7'
|
||||
Highlight: '&f'
|
||||
|
||||
Analysis:
|
||||
AutoRefreshPeriod: 60
|
||||
Export:
|
||||
Enabled: false
|
||||
ExternalWebServerLinkProtocol: http
|
||||
DestinationFolder: 'Analysis Results'
|
||||
|
||||
Data:
|
||||
Commands:
|
||||
LogUnknownCommands: false
|
||||
CombineCommandAliases: true
|
||||
|
||||
Customization:
|
||||
Formatting:
|
||||
DecimalPoints: '#.##'
|
||||
TimeAmount:
|
||||
Year: '1 year, '
|
||||
Years: '%years% years, '
|
||||
Month: '1 month, '
|
||||
Months: '%months% months, '
|
||||
Day: '1d '
|
||||
Days: '%days%d '
|
||||
Hours: '%hours%h '
|
||||
Minutes: '%minutes%m '
|
||||
Seconds: '%seconds%s'
|
||||
|
||||
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
|
@ -6,7 +6,7 @@ import main.java.com.djrapitops.plan.data.UserInfo;
|
||||
import main.java.com.djrapitops.plan.data.WebUser;
|
||||
import main.java.com.djrapitops.plan.utilities.PassEncryptUtil;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.Point;
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
Loading…
Reference in New Issue
Block a user