Base 1.13.2
This commit is contained in:
@@ -31,7 +31,7 @@ public class Metrics {
|
||||
public static final int B_STATS_VERSION = 1;
|
||||
|
||||
// The url to which the data is sent
|
||||
private static final String URL = "https://bStats.org/submitData/server-implementation";
|
||||
private static final String URL = "https://bStats.org/submitData/bukkit"; // Akarin
|
||||
|
||||
// Should failed requests be logged?
|
||||
private static boolean logFailedRequests = false;
|
||||
@@ -103,6 +103,7 @@ public class Metrics {
|
||||
JSONObject data = new JSONObject();
|
||||
|
||||
data.put("pluginName", name); // Append the name of the server software
|
||||
data.put("pluginVersion", Metrics.class.getPackage().getImplementationVersion() != null ? Metrics.class.getPackage().getImplementationVersion() : "unknown"); // Akarin
|
||||
JSONArray customCharts = new JSONArray();
|
||||
for (CustomChart customChart : charts) {
|
||||
// Add the data of the custom charts
|
||||
@@ -123,13 +124,24 @@ public class Metrics {
|
||||
* @return The server specific data.
|
||||
*/
|
||||
private JSONObject getServerData() {
|
||||
// Akarin start - Minecraft specific data
|
||||
int playerAmount = Bukkit.getOnlinePlayers().size();
|
||||
int onlineMode = Bukkit.getOnlineMode() ? 1 : 0;
|
||||
String bukkitVersion = org.bukkit.Bukkit.getVersion();
|
||||
bukkitVersion = bukkitVersion.substring(bukkitVersion.indexOf("MC: ") + 4, bukkitVersion.length() - 1);
|
||||
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("playerAmount", playerAmount);
|
||||
data.put("onlineMode", onlineMode);
|
||||
data.put("bukkitVersion", bukkitVersion);
|
||||
// Akarin end
|
||||
// OS specific data
|
||||
String osName = System.getProperty("os.name");
|
||||
String osArch = System.getProperty("os.arch");
|
||||
String osVersion = System.getProperty("os.version");
|
||||
int coreCount = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
JSONObject data = new JSONObject();
|
||||
//JSONObject data = new JSONObject(); // Akarin
|
||||
|
||||
data.put("serverUUID", serverUUID);
|
||||
|
||||
@@ -578,8 +590,10 @@ public class Metrics {
|
||||
boolean logFailedRequests = config.getBoolean("logFailedRequests", false);
|
||||
// Only start Metrics, if it's enabled in the config
|
||||
if (config.getBoolean("enabled", true)) {
|
||||
Metrics metrics = new Metrics("Paper", serverUUID, logFailedRequests, Bukkit.getLogger());
|
||||
// Akarin start
|
||||
Metrics metrics = new Metrics("Torch", serverUUID, logFailedRequests, Bukkit.getLogger());
|
||||
|
||||
/*
|
||||
metrics.addCustomChart(new Metrics.SimplePie("minecraft_version", () -> {
|
||||
String minecraftVersion = Bukkit.getVersion();
|
||||
minecraftVersion = minecraftVersion.substring(minecraftVersion.indexOf("MC: ") + 4, minecraftVersion.length() - 1);
|
||||
@@ -620,6 +634,8 @@ public class Metrics {
|
||||
|
||||
return map;
|
||||
}));
|
||||
*/
|
||||
// Akarin end
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
158
src/main/java/io/akarin/server/core/AkarinGlobalConfig.java
Normal file
158
src/main/java/io/akarin/server/core/AkarinGlobalConfig.java
Normal file
@@ -0,0 +1,158 @@
|
||||
package io.akarin.server.core;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
public class AkarinGlobalConfig {
|
||||
public final static Logger LOGGER = LogManager.getLogger("Akarin");
|
||||
|
||||
private static File CONFIG_FILE;
|
||||
private static final String HEADER = "This is the global configuration file for Akarin.\n"
|
||||
+ "Some options may impact gameplay, so use with caution,\n"
|
||||
+ "and make sure you know what each option does before configuring.\n"
|
||||
+ "\n"
|
||||
+ "Akarin website: https://akarin.io/ \n";
|
||||
/*========================================================================*/
|
||||
public static YamlConfiguration config;
|
||||
static int version;
|
||||
/*========================================================================*/
|
||||
public static void init(File configFile) {
|
||||
CONFIG_FILE = configFile;
|
||||
config = new YamlConfiguration();
|
||||
try {
|
||||
config.load(CONFIG_FILE);
|
||||
} catch (IOException ex) {
|
||||
} catch (InvalidConfigurationException ex) {
|
||||
LOGGER.error("Could not load akarin.yml, please correct your syntax errors", ex);
|
||||
throw Throwables.propagate(ex);
|
||||
}
|
||||
config.options().header(HEADER);
|
||||
config.options().copyDefaults(true);
|
||||
|
||||
version = getInt("config-version", 2);
|
||||
set("config-version", 2);
|
||||
readConfig(AkarinGlobalConfig.class, null);
|
||||
}
|
||||
|
||||
static void readConfig(Class<?> clazz, Object instance) {
|
||||
for (Method method : clazz.getDeclaredMethods()) {
|
||||
if (Modifier.isPrivate(method.getModifiers())) {
|
||||
if (method.getParameterTypes().length == 0 && method.getReturnType() == Void.TYPE) {
|
||||
try {
|
||||
method.setAccessible(true);
|
||||
method.invoke(instance);
|
||||
} catch (InvocationTargetException ex) {
|
||||
throw Throwables.propagate(ex.getCause());
|
||||
} catch (Exception ex) {
|
||||
LOGGER.error("Error invoking " + method, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
config.save(CONFIG_FILE);
|
||||
} catch (IOException ex) {
|
||||
LOGGER.error("Could not save " + CONFIG_FILE, ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static final Pattern SPACE = Pattern.compile(" ");
|
||||
private static final Pattern NOT_NUMERIC = Pattern.compile("[^-\\d.]");
|
||||
public static int getSeconds(String str) {
|
||||
str = SPACE.matcher(str).replaceAll("");
|
||||
final char unit = str.charAt(str.length() - 1);
|
||||
str = NOT_NUMERIC.matcher(str).replaceAll("");
|
||||
double num;
|
||||
try {
|
||||
num = Double.parseDouble(str);
|
||||
} catch (Exception e) {
|
||||
num = 0D;
|
||||
}
|
||||
switch (unit) {
|
||||
case 'd': num *= (double) 60*60*24; break;
|
||||
case 'h': num *= (double) 60*60; break;
|
||||
case 'm': num *= 60; break;
|
||||
default: case 's': break;
|
||||
}
|
||||
return (int) num;
|
||||
}
|
||||
|
||||
protected static String timeSummary(int seconds) {
|
||||
String time = "";
|
||||
|
||||
if (seconds > 60 * 60 * 24) {
|
||||
time += TimeUnit.SECONDS.toDays(seconds) + "d";
|
||||
seconds %= 60 * 60 * 24;
|
||||
}
|
||||
|
||||
if (seconds > 60 * 60) {
|
||||
time += TimeUnit.SECONDS.toHours(seconds) + "h";
|
||||
seconds %= 60 * 60;
|
||||
}
|
||||
|
||||
if (seconds > 0) {
|
||||
time += TimeUnit.SECONDS.toMinutes(seconds) + "m";
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
public static void set(String path, Object val) {
|
||||
config.set(path, val);
|
||||
}
|
||||
|
||||
private static boolean getBoolean(String path, boolean def) {
|
||||
config.addDefault(path, def);
|
||||
return config.getBoolean(path, config.getBoolean(path));
|
||||
}
|
||||
|
||||
private static double getDouble(String path, double def) {
|
||||
config.addDefault(path, def);
|
||||
return config.getDouble(path, config.getDouble(path));
|
||||
}
|
||||
|
||||
private static float getFloat(String path, float def) {
|
||||
// TODO: Figure out why getFloat() always returns the default value.
|
||||
return (float) getDouble(path, def);
|
||||
}
|
||||
|
||||
private static int getInt(String path, int def) {
|
||||
config.addDefault(path, def);
|
||||
return config.getInt(path, config.getInt(path));
|
||||
}
|
||||
|
||||
private static <T> List getList(String path, T def) {
|
||||
config.addDefault(path, def);
|
||||
return config.getList(path, config.getList(path));
|
||||
}
|
||||
|
||||
private static String getString(String path, String def) {
|
||||
config.addDefault(path, def);
|
||||
return config.getString(path, config.getString(path));
|
||||
}
|
||||
/*========================================================================*/
|
||||
public static boolean noResponseDoGC;
|
||||
private static void noResponseDoGC() {
|
||||
noResponseDoGC = getBoolean("alternative.gc-before-stuck-restart", true);
|
||||
}
|
||||
|
||||
public static String serverBrandName;
|
||||
private static void serverBrandName() {
|
||||
serverBrandName = getString("alternative.modified-server-brand-name", "");
|
||||
}
|
||||
}
|
||||
@@ -169,7 +169,7 @@ import javax.annotation.Nonnull; // Paper
|
||||
|
||||
|
||||
public final class CraftServer implements Server {
|
||||
private final String serverName = "Paper"; // Paper
|
||||
private final String serverName = org.apache.commons.lang3.StringUtils.isBlank(io.akarin.server.core.AkarinGlobalConfig.serverBrandName) ? "Akarin" : io.akarin.server.core.AkarinGlobalConfig.serverBrandName; // Paper // Akarin - configurable brand name
|
||||
private final String serverVersion;
|
||||
private final String bukkitVersion = Versioning.getBukkitVersion();
|
||||
private final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
@@ -21,6 +21,7 @@ public class Main {
|
||||
public static boolean useConsole = true;
|
||||
|
||||
public static void main(String[] args) {
|
||||
io.akarin.server.core.AkarinGlobalConfig.init(new File("akarin.yml")); // Akarin
|
||||
// Todo: Installation script
|
||||
OptionParser parser = new OptionParser() {
|
||||
{
|
||||
@@ -219,7 +220,7 @@ public class Main {
|
||||
if (buildDate.before(deadline.getTime())) {
|
||||
// Paper start - This is some stupid bullshit
|
||||
System.err.println("*** Warning, you've not updated in a while! ***");
|
||||
System.err.println("*** Please download a new build as per instructions from https://papermc.io/downloads ***"); // Paper
|
||||
System.err.println("*** Please visit our website for the latest information: https://akarin.io/ ***"); // Paper // Akarin
|
||||
//System.err.println("*** Server will start in 20 seconds ***");
|
||||
//Thread.sleep(TimeUnit.SECONDS.toMillis(20));
|
||||
// Paper End
|
||||
|
||||
@@ -42,6 +42,13 @@ public class RestartCommand extends Command
|
||||
|
||||
private static void restart(final String restartScript)
|
||||
{
|
||||
// Akarin start
|
||||
if (io.akarin.server.core.AkarinGlobalConfig.noResponseDoGC) {
|
||||
System.out.println("Attempting to garbage collect, this may takes a few seconds");
|
||||
System.runFinalization();
|
||||
System.gc();
|
||||
}
|
||||
// Akarin end
|
||||
AsyncCatcher.enabled = false; // Disable async catcher incase it interferes with us
|
||||
org.spigotmc.AsyncCatcher.shuttingDown = true; // Paper
|
||||
try
|
||||
|
||||
@@ -24,7 +24,7 @@ public class WatchdogThread extends Thread
|
||||
|
||||
private WatchdogThread(long timeoutTime, boolean restart)
|
||||
{
|
||||
super( "Paper Watchdog Thread" );
|
||||
super( "Akarin Watchdog Thread" ); // Akarin
|
||||
this.timeoutTime = timeoutTime;
|
||||
this.restart = restart;
|
||||
earlyWarningEvery = Math.min(PaperConfig.watchdogPrintEarlyWarningEvery, timeoutTime); // Paper
|
||||
@@ -75,12 +75,12 @@ public class WatchdogThread extends Thread
|
||||
if (isLongTimeout) {
|
||||
// Paper end
|
||||
log.log( Level.SEVERE, "------------------------------" );
|
||||
log.log( Level.SEVERE, "The server has stopped responding! This is (probably) not a Paper bug." ); // Paper
|
||||
log.log( Level.SEVERE, "The server has stopped responding! This is (probably) not a Akarin bug." ); // Paper // Akarin
|
||||
log.log( Level.SEVERE, "If you see a plugin in the Server thread dump below, then please report it to that author" );
|
||||
log.log( Level.SEVERE, "\t *Especially* if it looks like HTTP or MySQL operations are occurring" );
|
||||
log.log( Level.SEVERE, "\t *Especially* if it looks like HTTP or disk operations are occurring" ); // Akarin - MYSQL -> disk
|
||||
log.log( Level.SEVERE, "If you see a world save or edit, then it means you did far more than your server can handle at once" );
|
||||
log.log( Level.SEVERE, "\t If this is the case, consider increasing timeout-time in spigot.yml but note that this will replace the crash with LARGE lag spikes" );
|
||||
log.log( Level.SEVERE, "If you are unsure or still think this is a Paper bug, please report this to https://github.com/PaperMC/Paper/issues" );
|
||||
log.log( Level.SEVERE, "If you are unsure or still think this is a Akarin bug, please report this to https://github.com/Akarin-project/Akarin/issues" ); // Akarin
|
||||
log.log( Level.SEVERE, "Be sure to include ALL relevant console errors and Minecraft crash reports" );
|
||||
log.log( Level.SEVERE, "Paper version: " + Bukkit.getServer().getVersion() );
|
||||
//
|
||||
@@ -105,14 +105,14 @@ public class WatchdogThread extends Thread
|
||||
// Paper end
|
||||
} else
|
||||
{
|
||||
log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH - " + Bukkit.getServer().getVersion() + " ---");
|
||||
log.log(Level.SEVERE, "The server has not responded for " + (currentTime - lastTick) / 1000 + " seconds! Creating thread dump");
|
||||
log.log(Level.WARNING, "--- DO NOT REPORT THIS TO AKARIN - THIS IS NOT A BUG OR A CRASH - " + Bukkit.getServer().getVersion() + " ---"); // Akarin - use WARNING level
|
||||
log.log(Level.WARNING, "The server has not responded for " + (currentTime - lastTick) / 1000 + " seconds! Creating thread dump"); // Akarin - use WARNING level
|
||||
}
|
||||
// Paper end - Different message for short timeout
|
||||
log.log( Level.SEVERE, "------------------------------" );
|
||||
log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):" );
|
||||
log.log( Level.WARNING, "------------------------------" ); // Akarin - use WARNING level
|
||||
log.log( Level.WARNING, "Server thread dump (Look for plugins here before reporting to Paper!):" ); // Akarin - use WARNING level
|
||||
dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.getServer().primaryThread.getId(), Integer.MAX_VALUE ), log );
|
||||
log.log( Level.SEVERE, "------------------------------" );
|
||||
log.log( Level.WARNING, "------------------------------" ); // Akarin - use WARNING level
|
||||
//
|
||||
// Paper start - Only print full dump on long timeouts
|
||||
if ( isLongTimeout )
|
||||
@@ -124,11 +124,11 @@ public class WatchdogThread extends Thread
|
||||
dumpThread( thread, log );
|
||||
}
|
||||
} else {
|
||||
log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH ---");
|
||||
log.log(Level.WARNING, "--- DO NOT REPORT THIS TO AKARIN - THIS IS NOT A BUG OR A CRASH ---"); // Akarin - use WARNING level
|
||||
}
|
||||
|
||||
|
||||
log.log( Level.SEVERE, "------------------------------" );
|
||||
log.log( isLongTimeout ? Level.SEVERE : Level.WARNING, "------------------------------" ); // Akarin - use WARNING level
|
||||
|
||||
if ( isLongTimeout )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user