Yatopia/patches/server/0007-Yatopia-configuration.patch
Ivan Pekov 4da7b3aefc
Updated Upstream and Sidestream(s) (Tuinity/EMC/Origami/Purpur/AirplaneLite)
Upstream/An Sidestream has released updates that appears to apply and compile correctly
This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing.

Tuinity Changes:
3e77330 Updated Upstream (Paper)

EMC Changes:
e45a78e4 Update the API as well - setTargetRange to Double where null is default FOLLOW_RANGE
9fc6891d Default target range to the follow range
a1e2e2a3 Fix an issue with players in vehicles in vehicles desyncing
b6e2f202 Add a Dead vehicle reason to VehicleExitEvent
72b0da43 Use the correct entity local variable
ad32d0d6 Fix bug with entity passengers not executing entity tasks
194aaafb Updated Paper
cb3a7bb7 Always convert Lore/Name of an item to ensure consistency
6c63538d Revert "Updated Paper"
8837d5a9 Limit fortress spawns to the nether
005cdda9 Updated Paper
1476d693 Fix Lore comparisons to use legacy format
588f30f9 Quick fix the rcon log issue for now
475e626a Fix World Meta loading
3ad5f8a7 Remove RCON Thread Logs
7f3c4a25 Fix dismounting from vehicle when teleporting cross dimension
595bd307 Prevent NPE for PathfinderGoalMeleeAttack
0a64d9e9 Fix EntityDismountEvent reason
c25ef322 Updated Paper

Origami Changes:
36c0e05 Fix wrong circular dependency error if plugin depends on own provides
655fa5f Add option to disable legacy plugin support

Purpur Changes:
79d304f Updated Upstream (Paper)
bef678f [ci-skip] Simpler method of merging metadata files
3b18ff8 Updated Upstream (Paper)
25c7772 Apply the AppendingTransformer for `META-INF/services/java.sql.Driver`
faf0db9 Bump config version to 10
3d1926e More base attribute stuff
43d6dab Updated Upstream (Paper)
2fd92fe [ci-skip] Setup repo for api publishing
26b0736 Updated Upstream (Paper)
e704540 [ci-skip] Fix the remaining javadoc warnings
a541703 [ci-skip] Fix import mc-dev task
64f5f9d Fix dependency relocations
d7f1884 [ci-skip] Skip compiling tests as well as running them when using the `-Pfast` flag
3e08321 [ci-skip] Fix javadoc warnings (missing @param and @return)
1bfe697 [ci-skip] Remove paper's unsafe util
63b647c [ci-skip] Make it easier to fork Purpur using our scripts
c453170 Fix relocations
7e331c2 Fix #118 Phantom fire time not working
844337c Fix lag from villager lobotomize check
2ec0dba Updated Upstream (Paper)
69c6484 Build using Toothpick scripts (#122)

AirplaneLite Changes:
ff087b7 Changes from Purpur
7263c2f Fix maven subproject URL
819c731 Switch to Purpur's Toothpick
2020-12-22 16:01:31 +02:00

325 lines
15 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: tr7zw <tr7zw@live.de>
Date: Wed, 5 Aug 2020 08:05:10 -0500
Subject: [PATCH] Yatopia configuration
also some basic settings that dont deserve a patch
diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java
index dae2e5d70756c5b61163d57099b65f7e415b288c..21712a6691e00ffaf523f084da6ce5659fc98be9 100644
--- a/src/main/java/co/aikar/timings/TimingsExport.java
+++ b/src/main/java/co/aikar/timings/TimingsExport.java
@@ -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
));
@@ -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 {
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
index 3ee8d31c453105eca7b96bede39a9ebbf40e1c2c..0a9f03526abf0638ada15d9810b949887fca9f9a 100644
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
@@ -180,6 +180,15 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
// Paper end
com.tuinity.tuinity.config.TuinityConfig.init((java.io.File) options.valueOf("tuinity-settings")); // Tuinity - Server Config
+ // Yatopia start
+ try {
+ org.yatopiamc.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.ba());
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 1b646a7bb1588ebff5b4fdb12bd3016084041e77..d37143396cac0bc8980b03fe0e5e31cc4ecf08ff 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -266,6 +266,7 @@ public abstract class EntityLiving extends Entity {
this.world.getMethodProfiler().enter("livingEntityBaseTick");
boolean flag = this instanceof EntityHuman;
+ if (!org.yatopiamc.yatopia.server.YatopiaConfig.disableEntityStuckChecks) { // Yatopia
if (this.isAlive()) {
if (this.inBlock()) {
this.damageEntity(DamageSource.STUCK, 1.0F);
@@ -281,6 +282,7 @@ public abstract class EntityLiving extends Entity {
}
}
}
+ } // Yatopia
if (this.isFireProof() || this.world.isClientSide) {
this.extinguish();
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index d0fc49cb95bbebd5de9cec41dfb5b359c1724360..ce7724a1797a992561d074f85c7bdef71b4dbe78 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -188,7 +188,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(org.yatopiamc.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));
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 248605cc533e4cad4b75b92b1d88ef6aa03f4c5c..40aaa7c1fe0bf0a5031d5e1e15035a40cfedaa34 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -864,6 +864,7 @@ public final class CraftServer implements Server {
com.tuinity.tuinity.config.TuinityConfig.init((File) console.options.valueOf("tuinity-settings")); // Tuinity - Server Config
net.pl3x.purpur.PurpurConfig.init((File) console.options.valueOf("purpur-settings")); // Purpur
de.minebench.origami.OrigamiConfig.init((File) console.options.valueOf("origami-settings")); // Origami
+ org.yatopiamc.yatopia.server.YatopiaConfig.init((File) console.options.valueOf("yatopia-settings")); // Yatopia
for (WorldServer world : console.getWorlds()) {
world.worldDataServer.setDifficulty(config.difficulty);
world.setSpawnFlags(config.spawnMonsters, config.spawnAnimals);
@@ -2318,6 +2319,13 @@ public final class CraftServer implements Server {
}
// Origami end
+ // Yatopia start
+ @Override
+ public YamlConfiguration getYatopiaConfig() {
+ return org.yatopiamc.yatopia.server.YatopiaConfig.config;
+ }
+ // Yatopia end
+
@Override
public void restart() {
org.spigotmc.RestartCommand.restart();
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index 3c603e2358de71f534e88551b72f202d190f58fe..ce08abf2eabfdb606b806f4d6d374055f5e10168 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -162,6 +162,14 @@ public class Main {
.describedAs("Yml file");
// Origami end
+ // 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()
diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..f5a43e607f9c13e07a0f5e7e139eed93f159185b
--- /dev/null
+++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
@@ -0,0 +1,192 @@
+package org.yatopiamc.yatopia.server;
+
+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 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
+
+ // leftover from rainforest
+ if (config.get("world-settings") != null) {
+ set("world-settings", null);
+ }
+ if (config.get("allow-player-item-duplication") != null) {
+ set("allow-player-item-duplication", null);
+ }
+ if (config.get("allow-ridable-chestable-duping") != null) {
+ set("allow-ridable-chestable-duping", null);
+ }
+ if (config.get("allow-sand-duping") != null) {
+ set("allow-sand-duping", null);
+ }
+ }
+
+ 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);
+ }
+
+ public static String brandName = "Yatopia";
+ private static void brandName() {
+ brandName = getString("brand-name", brandName);
+ }
+}