2020-09-15 07:44:18 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2020-08-07 02:59:57 +02:00
From: tr7zw <tr7zw@live.de>
2020-08-05 15:21:25 +02:00
Date: Wed, 5 Aug 2020 08:05:10 -0500
2020-09-15 07:43:13 +02:00
Subject: [PATCH] Yatopia configuration
2020-06-27 17:23:21 +02:00
2020-09-15 07:43:13 +02:00
also some basic settings that dont deserve a patch
2020-06-27 17:23:21 +02:00
2020-08-06 16:05:19 +02:00
diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java
2020-09-13 09:00:43 +02:00
index dae2e5d70756c5b61163d57099b65f7e415b288c..21712a6691e00ffaf523f084da6ce5659fc98be9 100644
2020-08-06 16:05:19 +02:00
--- a/src/main/java/co/aikar/timings/TimingsExport.java
+++ b/src/main/java/co/aikar/timings/TimingsExport.java
2020-09-13 09:00:43 +02:00
@@ -234,6 +234,7 @@ public class TimingsExport extends Thread {
pair("paper", mapAsJSON(Bukkit.spigot().getPaperConfig(), null)),
pair("tuinity", mapAsJSON(Bukkit.spigot().getTuinityConfig(), null)), // Tuinity - add config to timings report
pair("purpur", mapAsJSON(Bukkit.spigot().getPurpurConfig(), null))
+ , pair("yatopia", mapAsJSON(Bukkit.spigot().getYatopiaConfig(), null)) // Yatopia - add config to timings report
// Purpur end
2020-08-06 16:05:19 +02:00
));
2020-09-13 09:00:43 +02:00
@@ -324,7 +325,7 @@ public class TimingsExport extends Thread {
String response = null;
String timingsURL = null;
try {
- HttpURLConnection con = (HttpURLConnection) new URL(net.pl3x.purpur.PurpurConfig.timingsUrl + "/post").openConnection(); // Purpur
+ HttpURLConnection con = (HttpURLConnection) new URL("http://timings.aikar.co/post").openConnection(); // Purpur // Yatopia
con.setDoOutput(true);
String hostName = "BrokenHost";
try {
2020-09-01 08:38:17 +02:00
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
2020-09-15 07:43:13 +02:00
index 050e0d7ec29755590dde2f35090b96f6f2457952..72d7a017f2aa7f2fde3b5de437e7fd2e051edd24 100644
2020-09-01 08:38:17 +02:00
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
2020-09-15 07:43:13 +02:00
@@ -177,6 +177,14 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
2020-09-01 08:38:17 +02:00
// Paper end
com.tuinity.tuinity.config.TuinityConfig.init((java.io.File) options.valueOf("tuinity-settings")); // Tuinity - Server Config
+ // Yatopia start
+ try {
+ net.yatopia.server.YatopiaConfig.init((java.io.File) options.valueOf("yatopia-settings"));
+ } catch (Exception e) {
+ DedicatedServer.LOGGER.error("Unable to load server configuration", e);
+ return false;
+ }
+ // Yatopia end
this.setPVP(dedicatedserverproperties.pvp);
this.setAllowFlight(dedicatedserverproperties.allowFlight);
this.setResourcePack(dedicatedserverproperties.resourcePack, this.aZ());
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
2020-09-11 08:03:00 +02:00
index 7083b379568fd101bec19469b60daf062bc4d137..0a7f88de5c5c307ed01c2f4a43336571f118736d 100644
2020-09-01 08:38:17 +02:00
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
2020-09-03 07:41:36 +02:00
@@ -267,6 +267,7 @@ public abstract class EntityLiving extends Entity {
2020-09-01 08:38:17 +02:00
//this.world.getMethodProfiler().enter("livingEntityBaseTick"); // Akarin - remove caller
boolean flag = this instanceof EntityHuman;
+ if (!net.yatopia.server.YatopiaConfig.disableEntityStuckChecks) { // Yatopia
if (this.isAlive()) {
if (this.inBlock()) {
this.damageEntity(DamageSource.STUCK, 1.0F);
2020-09-03 07:41:36 +02:00
@@ -282,6 +283,7 @@ public abstract class EntityLiving extends Entity {
2020-09-01 08:38:17 +02:00
}
}
}
+ } // Yatopia
if (this.isFireProof() || this.world.isClientSide) {
this.extinguish();
2020-09-13 09:00:43 +02:00
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
2020-10-02 13:23:32 +02:00
index 1b7daba994e9ee6d2dcf6562b0650f88e4b6714b..5760b40bdbee417f5bb5210f1271241ff8f36350 100644
2020-09-13 09:00:43 +02:00
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -189,7 +189,7 @@ public abstract class PlayerList {
// Spigot - view distance
playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), entityplayer.playerInteractManager.c(), BiomeManager.a(worldserver1.getSeed()), worlddata.isHardcore(), this.server.F(), this.s, worldserver1.getDimensionManager(), worldserver1.getDimensionKey(), this.getMaxPlayers(), worldserver1.getChunkProvider().playerChunkMap.getLoadViewDistance(), flag1, !flag, worldserver1.isDebugWorld(), worldserver1.isFlatWorld())); // Paper - no-tick view distance
entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit
- playerconnection.sendPacket(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.a, (new PacketDataSerializer(Unpooled.buffer())).a(this.getServer().getServerModName())));
+ playerconnection.sendPacket(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.a, (new PacketDataSerializer(Unpooled.buffer())).a(net.yatopia.server.YatopiaConfig.brandName))); // Yatopia
playerconnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
playerconnection.sendPacket(new PacketPlayOutAbilities(entityplayer.abilities));
playerconnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex));
2020-09-01 08:38:17 +02:00
diff --git a/src/main/java/net/yatopia/server/YatopiaConfig.java b/src/main/java/net/yatopia/server/YatopiaConfig.java
2020-06-27 17:23:21 +02:00
new file mode 100644
2020-09-15 07:43:13 +02:00
index 0000000000000000000000000000000000000000..c4dd521d18dd60ec07bdcf0d367b5135710dca58
2020-06-27 17:23:21 +02:00
--- /dev/null
2020-09-01 08:38:17 +02:00
+++ b/src/main/java/net/yatopia/server/YatopiaConfig.java
2020-09-15 07:43:13 +02:00
@@ -0,0 +1,193 @@
2020-09-01 08:38:17 +02:00
+package net.yatopia.server;
2020-08-15 18:18:36 +02:00
+
+import com.google.common.base.Throwables;
+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.logging.Level;
+import java.util.regex.Pattern;
+import net.minecraft.server.MinecraftServer;
+import org.bukkit.Bukkit;
+import org.bukkit.configuration.InvalidConfigurationException;
+import org.bukkit.configuration.file.YamlConfiguration;
+
+public class YatopiaConfig {
+
+ public static File CONFIG_FILE;
+ private static final String HEADER = "This is the main configuration file for Yatopia.\n"
+ + "Yatopia contains many breaking changes and settings, so know what you are doing!\n"
+ + "You have been warned!\n";
+ /*========================================================================*/
+ public static YamlConfiguration config;
+ public static int version; // since we're remapping sidestreams' configs we need this public
+ public static boolean verbose; // since we're remapping sidestreams' configs we need this public
+ /*========================================================================*/
+
+ public static void init(File configFile) {
+ CONFIG_FILE = configFile;
+ config = new YamlConfiguration();
+ try {
+ config.load(CONFIG_FILE);
+ } catch (IOException ex) {
+ } catch (InvalidConfigurationException ex) {
+ Bukkit.getLogger().log(Level.SEVERE, "Could not load yatopia.yml, please correct your syntax errors", ex);
+ throw Throwables.propagate(ex);
+ }
+ config.options().header(HEADER);
+ config.options().copyDefaults(true);
+ verbose = getBoolean("verbose", false);
+
+ version = getInt("config-version", 1);
+ set("config-version", 1);
+ removeLeftovers();
+ readConfig(YatopiaConfig.class, null);
+ }
+
+ private static void removeLeftovers() {
+ // this method is only to remove non-used values in the config
+
2020-09-13 09:00:43 +02:00
+ // leftover from rainforest
2020-08-15 18:18:36 +02:00
+ if (config.get("world-settings") != null) {
+ set("world-settings", null);
+ }
2020-09-13 09:00:43 +02:00
+ if (config.get("allow-player-item-duplication") != null) {
+ set("allow-player-item-duplication", null);
2020-08-15 18:18:36 +02:00
+ }
2020-09-13 09:00:43 +02:00
+ if (config.get("allow-ridable-chestable-duping") != null) {
+ set("allow-ridable-chestable-duping", null);
2020-08-15 18:18:36 +02:00
+ }
2020-09-13 09:00:43 +02:00
+ if (config.get("allow-sand-duping") != null) {
+ set("allow-sand-duping", null);
2020-08-22 21:11:04 +02:00
+ }
2020-08-15 18:18:36 +02:00
+ }
+
+ protected static void logError(String s) {
+ Bukkit.getLogger().severe(s);
+ }
+
+ protected static void log(String s) {
+ if (verbose) {
+ Bukkit.getLogger().info(s);
+ }
+ }
+
+ 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) {
+ Bukkit.getLogger().log(Level.SEVERE, "Error invoking " + method, ex);
+ }
+ }
+ }
+ }
+
+ try {
+ config.save(CONFIG_FILE);
+ } catch (IOException ex) {
+ Bukkit.getLogger().log(Level.SEVERE, "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;
+ }
+
+ private 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, (double) def);
+ }
+
+ private static int getInt(String path, int def) {
+ config.addDefault(path, def);
+ return config.getInt(path, config.getInt(path));
+ }
+
+ private static <T> List<T> getList(String path, List<T> def) {
+ config.addDefault(path, def);
+ return (List<T>) 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 disableEntityStuckChecks = false;
+ private static void disableEntityStuckChecks() {
+ disableEntityStuckChecks = getBoolean("settings.disableEntityStuckChecks", false);
+ }
+
2020-09-13 09:00:43 +02:00
+ public static String brandName = "Yatopia";
+ private static void brandName() {
+ brandName = getString("brand-name", brandName);
+ }
2020-08-15 18:18:36 +02:00
+}
2020-08-11 17:38:17 +02:00
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
2020-09-27 18:05:16 +02:00
index 4bae0e82bc25b576a23b5f05af7c3ad944a54bcf..78d7fc805a1aeb0d31e51a5aa68e92d9ffd7ba73 100644
2020-08-11 17:38:17 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
2020-09-15 07:23:39 +02:00
@@ -845,6 +845,7 @@ public final class CraftServer implements Server {
2020-09-13 09:00:43 +02:00
com.tuinity.tuinity.config.TuinityConfig.init((File) console.options.valueOf("tuinity-settings")); // Tuinity - Server Config
2020-08-11 17:38:17 +02:00
net.pl3x.purpur.PurpurConfig.init((File) console.options.valueOf("purpur-settings")); // Purpur
2020-08-15 11:43:24 +02:00
de.minebench.origami.OrigamiConfig.init((File) console.options.valueOf("origami-settings")); // Origami
2020-09-01 08:38:17 +02:00
+ net.yatopia.server.YatopiaConfig.init((File) console.options.valueOf("yatopia-settings")); // Yatopia
2020-08-11 17:38:17 +02:00
for (WorldServer world : console.getWorlds()) {
world.worldDataServer.setDifficulty(config.difficulty);
world.setSpawnFlags(config.spawnMonsters, config.spawnAnimals);
2020-09-15 07:23:39 +02:00
@@ -2274,6 +2275,13 @@ public final class CraftServer implements Server {
2020-08-13 17:53:32 +02:00
}
// Origami end
2020-08-15 18:18:36 +02:00
2020-08-13 17:53:32 +02:00
+ // Yatopia start
2020-08-15 18:18:36 +02:00
+ @Override
2020-08-13 17:53:32 +02:00
+ public YamlConfiguration getYatopiaConfig() {
2020-09-01 08:38:17 +02:00
+ return net.yatopia.server.YatopiaConfig.config;
2020-08-13 17:53:32 +02:00
+ }
+ // Yatopia end
2020-08-15 18:18:36 +02:00
+
2020-08-13 17:53:32 +02:00
@Override
public void restart() {
2020-08-15 18:18:36 +02:00
org.spigotmc.RestartCommand.restart();
2020-08-11 17:38:17 +02:00
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
2020-10-03 09:16:41 +02:00
index 2e0dcd78a1ec5d817c44831c279c47dc98902681..a14ae29b1c248b208adfc9eb22048ba76b09502f 100644
2020-08-11 17:38:17 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
2020-09-13 09:00:43 +02:00
@@ -162,6 +162,14 @@ public class Main {
2020-08-11 17:38:17 +02:00
.describedAs("Yml file");
2020-08-15 11:43:24 +02:00
// Origami end
2020-08-11 17:38:17 +02:00
+ // Yatopia start
+ acceptsAll(asList("yatopia", "yatopia-settings"), "File for yatopia settings")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("yatopia.yml"))
+ .describedAs("Yml file");
+ // Yatopia end
+
// Paper start
acceptsAll(asList("server-name"), "Name of the server")
.withRequiredArg()