diff --git a/PATCHES.md b/PATCHES.md index 6315d2eb..7c578177 100644 --- a/PATCHES.md +++ b/PATCHES.md @@ -14,7 +14,6 @@ # Patches | server | Add GameProfileLookupEvent | tr7zw | | | api | Add NBT API as a first-class lib | tr7zw | | | server | Add NBT API as a first-class lib | tr7zw | | -| server | Add config Yatopia command and basic settings | tr7zw | | | api | Add getLastTickMs api | tr7zw | | | server | Add getLastTickMs api | tr7zw | | | server | Add no-tick block list | William Blake Galbreath | | @@ -116,6 +115,7 @@ # Patches | server | Use offline uuids if we need to | Ivan Pekov | | | server | Villagers follow emerald blocks | William Blake Galbreath | | | api | Yatopia API Bundle | Bud Gidiere | | +| server | Yatopia configuration | tr7zw | | | server | Yatopia-Server-Fixes | Bud Gidiere | | | server | Zombie horse naturally spawn | William Blake Galbreath | | | server | dont load chunks for physics | Aikar | | diff --git a/patches/server/0006-Add-config-Yatopia-command-and-basic-settings.patch b/patches/server/0006-Yatopia-configuration.patch similarity index 67% rename from patches/server/0006-Add-config-Yatopia-command-and-basic-settings.patch rename to patches/server/0006-Yatopia-configuration.patch index 472aed59..2be2247b 100644 --- a/patches/server/0006-Add-config-Yatopia-command-and-basic-settings.patch +++ b/patches/server/0006-Yatopia-configuration.patch @@ -1,8 +1,9 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +rom 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: tr7zw Date: Wed, 5 Aug 2020 08:05:10 -0500 -Subject: [PATCH] Add config Yatopia command and basic settings +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 @@ -26,10 +27,10 @@ index dae2e5d70756c5b61163d57099b65f7e415b288c..21712a6691e00ffaf523f084da6ce565 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 050e0d7ec29755590dde2f35090b96f6f2457952..dde91498e773cc6744612f780ce82bd35ad79637 100644 +index 050e0d7ec29755590dde2f35090b96f6f2457952..72d7a017f2aa7f2fde3b5de437e7fd2e051edd24 100644 --- a/src/main/java/net/minecraft/server/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/DedicatedServer.java -@@ -177,6 +177,15 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer +@@ -177,6 +177,14 @@ 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 @@ -40,7 +41,6 @@ index 050e0d7ec29755590dde2f35090b96f6f2457952..dde91498e773cc6744612f780ce82bd3 + DedicatedServer.LOGGER.error("Unable to load server configuration", e); + return false; + } -+ net.yatopia.server.YatopiaConfig.registerCommands(); + // Yatopia end this.setPVP(dedicatedserverproperties.pvp); this.setAllowFlight(dedicatedserverproperties.allowFlight); @@ -78,159 +78,12 @@ index c944b407df03fca1153978d0763313d44d6461c8..66d0cf7d4b0bbffbd5eff64bfc46806c 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/net/yatopia/server/YatopiaCommand.java b/src/main/java/net/yatopia/server/YatopiaCommand.java -new file mode 100644 -index 0000000000000000000000000000000000000000..3a3cda53b253e42556268506e2c32b65be84bedb ---- /dev/null -+++ b/src/main/java/net/yatopia/server/YatopiaCommand.java -@@ -0,0 +1,141 @@ -+package net.yatopia.server; -+ -+import com.google.common.base.Preconditions; -+import com.google.common.collect.Lists; -+import java.io.File; -+import java.util.Arrays; -+import java.util.Collection; -+import java.util.Collections; -+import java.util.List; -+import java.util.Locale; -+import java.util.function.Function; -+import net.minecraft.server.MinecraftKey; -+import net.minecraft.server.MinecraftServer; -+import net.minecraft.server.World; -+import net.minecraft.server.WorldDataServer; -+import org.bukkit.Bukkit; -+import org.bukkit.ChatColor; -+import org.bukkit.Location; -+import org.bukkit.command.Command; -+import org.bukkit.command.CommandSender; -+import org.spigotmc.TicksPerSecondCommand; -+ -+public class YatopiaCommand extends Command { -+ -+ public YatopiaCommand(String name) { -+ super(name); -+ this.description = "Yatopia related commands"; -+ this.usageMessage = "/yatopia [help | reload | info | version]"; -+ this.setPermission("bukkit.command.yatopia"); -+ } -+ -+ @Override -+ public List tabComplete(CommandSender sender, String alias, String[] args, Location location) throws IllegalArgumentException { -+ if (args.length <= 1) { -+ return getListMatchingLast(args, "help", "info", "reload", "version"); -+ } -+ return Collections.emptyList(); -+ } -+ -+ // Code from Mojang - copyright them -+ public static List getListMatchingLast(String[] args, String... matches) { -+ return getListMatchingLast(args, Arrays.asList(matches)); -+ } -+ -+ public static boolean matches(String s, String s1) { -+ return s1.regionMatches(true, 0, s, 0, s.length()); -+ } -+ -+ public static List getListMatchingLast(String[] strings, Collection collection) { -+ String last = strings[strings.length - 1]; -+ List results = Lists.newArrayList(); -+ -+ if (!collection.isEmpty()) { -+ Function toStringFunction = (o) -> { -+ Preconditions.checkNotNull(o); -+ return o.toString(); -+ }; -+ for (Object c : collection) { -+ String value = toStringFunction.apply(c); -+ if (matches(last, value)) { -+ results.add(value); -+ } -+ } -+ -+ if (results.isEmpty()) { -+ for (Object c : collection) { -+ if (c instanceof MinecraftKey) { -+ MinecraftKey key = (MinecraftKey) c; -+ if (matches(last, key.getKey())) { -+ results.add(key.toString()); -+ } -+ } -+ } -+ } -+ } -+ -+ return results; -+ } -+ // end copy stuff -+ -+ @Override -+ public boolean execute(CommandSender sender, String commandLabel, String[] args) { -+ if (!testPermission(sender)) return true; -+ -+ if (args.length == 0) { -+ sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); -+ return false; -+ } -+ -+ switch (args[0].toLowerCase(Locale.ENGLISH)) { -+ case "info": -+ doInfo(sender); -+ break; -+ case "reload": -+ doReload(sender); -+ break; -+ case "ver": -+ case "version": -+ Command ver = org.bukkit.Bukkit.getServer().getCommandMap().getCommand("version"); -+ if (ver != null) { -+ ver.execute(sender, commandLabel, new String[0]); -+ break; -+ } -+ // else - fall through to default -+ default: -+ sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); -+ return false; -+ } -+ -+ return true; -+ } -+ -+ private void doInfo(CommandSender sender) { -+ broadcastMessage(sender, ChatColor.GOLD + "Last tick took " + TicksPerSecondCommand.format(Bukkit.getLastTickMs())); -+ for (World world : MinecraftServer.getServer().getWorlds()) { -+ String name = ((WorldDataServer) world.worldData).getName(); -+ broadcastMessage(sender, ChatColor.GOLD + "Entities in world " + -+ ChatColor.YELLOW + "\"" + name + "\"" + -+ ChatColor.GOLD + ": " + ChatColor.YELLOW + world.getWorld().getEntityCount()); -+ broadcastMessage(sender, ChatColor.GOLD + "Chunks loaded in world " + -+ ChatColor.YELLOW + "\"" + name + "\"" + -+ ChatColor.GOLD + ": " + ChatColor.YELLOW + world.getWorld().getChunkCount()); -+ } -+ } -+ -+ private void doReload(CommandSender sender) { -+ broadcastMessage(sender, ChatColor.RED + "Please note that this command is not supported and may cause issues."); -+ broadcastMessage(sender, ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server."); -+ -+ MinecraftServer console = MinecraftServer.getServer(); -+ YatopiaConfig.init((File) console.options.valueOf("yatopia-settings")); -+ console.server.reloadCount++; -+ -+ broadcastMessage(sender, ChatColor.GREEN + "Yatopia config reload complete."); -+ } -+ -+ // utility method -+ private void broadcastMessage(CommandSender sender, String message) { -+ Command.broadcastCommandMessage(sender, message); -+ } -+} diff --git a/src/main/java/net/yatopia/server/YatopiaConfig.java b/src/main/java/net/yatopia/server/YatopiaConfig.java new file mode 100644 -index 0000000000000000000000000000000000000000..f69be0c7eef07727028c14e5ad9c859363aa19c0 +index 0000000000000000000000000000000000000000..c4dd521d18dd60ec07bdcf0d367b5135710dca58 --- /dev/null +++ b/src/main/java/net/yatopia/server/YatopiaConfig.java -@@ -0,0 +1,213 @@ +@@ -0,0 +1,193 @@ +package net.yatopia.server; + +import com.google.common.base.Throwables; @@ -239,15 +92,12 @@ index 0000000000000000000000000000000000000000..f69be0c7eef07727028c14e5ad9c8593 +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; -+import java.util.HashMap; +import java.util.List; -+import java.util.Map; +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.command.Command; +import org.bukkit.configuration.InvalidConfigurationException; +import org.bukkit.configuration.file.YamlConfiguration; + @@ -260,11 +110,8 @@ index 0000000000000000000000000000000000000000..f69be0c7eef07727028c14e5ad9c8593 + /*========================================================================*/ + public static YamlConfiguration config; + public static int version; // since we're remapping sidestreams' configs we need this public -+ static Map commands; + public static boolean verbose; // since we're remapping sidestreams' configs we need this public -+ private static boolean fatalError; + /*========================================================================*/ -+ private static boolean metricsStarted; + + public static void init(File configFile) { + CONFIG_FILE = configFile; @@ -280,9 +127,6 @@ index 0000000000000000000000000000000000000000..f69be0c7eef07727028c14e5ad9c8593 + config.options().copyDefaults(true); + verbose = getBoolean("verbose", false); + -+ commands = new HashMap(); -+ commands.put("yatopia", new YatopiaCommand("yatopia")); -+ + version = getInt("config-version", 1); + set("config-version", 1); + removeLeftovers(); @@ -311,23 +155,12 @@ index 0000000000000000000000000000000000000000..f69be0c7eef07727028c14e5ad9c8593 + Bukkit.getLogger().severe(s); + } + -+ protected static void fatal(String s) { -+ fatalError = true; -+ throw new RuntimeException("Fatal yatopia.yml config error: " + s); -+ } -+ + protected static void log(String s) { + if (verbose) { + Bukkit.getLogger().info(s); + } + } + -+ public static void registerCommands() { -+ for (Map.Entry entry : commands.entrySet()) { -+ MinecraftServer.getServer().server.getCommandMap().register(entry.getKey(), "Yatopia", entry.getValue()); -+ } -+ } -+ + static void readConfig(Class clazz, Object instance) { + for (Method method : clazz.getDeclaredMethods()) { + if (Modifier.isPrivate(method.getModifiers())) { diff --git a/patches/server/0008-Allow-to-change-the-piston-push-limit.patch b/patches/server/0008-Allow-to-change-the-piston-push-limit.patch index 1ecda1e3..b915b1b9 100644 --- a/patches/server/0008-Allow-to-change-the-piston-push-limit.patch +++ b/patches/server/0008-Allow-to-change-the-piston-push-limit.patch @@ -36,10 +36,10 @@ index 95aeaaf0bb07c5ecf7117dae3382b0f0aac6426f..71636ce642efcd3453b6c5bfb2b2ef0e } diff --git a/src/main/java/net/yatopia/server/YatopiaConfig.java b/src/main/java/net/yatopia/server/YatopiaConfig.java -index f69be0c7eef07727028c14e5ad9c859363aa19c0..b918247b14c712f48eb0c55d2750c49fc86256df 100644 +index c4dd521d18dd60ec07bdcf0d367b5135710dca58..d69001b126046070abfa96dd3d1e6f95a24af536 100644 --- a/src/main/java/net/yatopia/server/YatopiaConfig.java +++ b/src/main/java/net/yatopia/server/YatopiaConfig.java -@@ -210,4 +210,9 @@ public class YatopiaConfig { +@@ -190,4 +190,9 @@ public class YatopiaConfig { private static void brandName() { brandName = getString("brand-name", brandName); } diff --git a/patches/server/0018-Item-stuck-sleep-config.patch b/patches/server/0018-Item-stuck-sleep-config.patch index d3ee5570..6a291eb6 100644 --- a/patches/server/0018-Item-stuck-sleep-config.patch +++ b/patches/server/0018-Item-stuck-sleep-config.patch @@ -18,10 +18,10 @@ index 9110491fb4cf4424d737b47602a85abaa7f30bea..13a712f1c75a1d6d3a5cedb4a11b2768 if (this.noclip) { this.l(this.locX(), (this.getBoundingBox().minY + this.getBoundingBox().maxY) / 2.0D, this.locZ()); diff --git a/src/main/java/net/yatopia/server/YatopiaConfig.java b/src/main/java/net/yatopia/server/YatopiaConfig.java -index b918247b14c712f48eb0c55d2750c49fc86256df..88ec22d8211276aeaadc14c5c13dc8a6fbedb382 100644 +index d69001b126046070abfa96dd3d1e6f95a24af536..9357d12cd623cd3ea92e39bd9d70ee89330ad1b3 100644 --- a/src/main/java/net/yatopia/server/YatopiaConfig.java +++ b/src/main/java/net/yatopia/server/YatopiaConfig.java -@@ -215,4 +215,9 @@ public class YatopiaConfig { +@@ -195,4 +195,9 @@ public class YatopiaConfig { private static void pistonPushLimit() { pistonPushLimit = getInt("settings.pistonPushLimit", 12); } diff --git a/patches/server/0019-Option-for-simpler-Villagers.patch b/patches/server/0019-Option-for-simpler-Villagers.patch index f179cea1..2e3f6217 100644 --- a/patches/server/0019-Option-for-simpler-Villagers.patch +++ b/patches/server/0019-Option-for-simpler-Villagers.patch @@ -151,10 +151,10 @@ index 1104196cf6dc448dada2e190e5e9e27c9f18d2dc..da2bd7c597a3f691ec13ff37dd2ef87d MinecraftServer minecraftserver = ((WorldServer) this.world).getMinecraftServer(); diff --git a/src/main/java/net/yatopia/server/YatopiaConfig.java b/src/main/java/net/yatopia/server/YatopiaConfig.java -index 88ec22d8211276aeaadc14c5c13dc8a6fbedb382..c60c3c4b730fe299e62c277cdd644b6afd3841e5 100644 +index 9357d12cd623cd3ea92e39bd9d70ee89330ad1b3..eb53176099103172961d544c0dab17cc19ef2e7f 100644 --- a/src/main/java/net/yatopia/server/YatopiaConfig.java +++ b/src/main/java/net/yatopia/server/YatopiaConfig.java -@@ -220,4 +220,11 @@ public class YatopiaConfig { +@@ -200,4 +200,11 @@ public class YatopiaConfig { private static void itemStuckSleepTicks() { itemStuckSleepTicks = getInt("settings.itemStuckSleepTicks", 1); } diff --git a/patches/server/0023-Redirect-Configs.patch b/patches/server/0023-Redirect-Configs.patch index 951c6800..4661a760 100644 --- a/patches/server/0023-Redirect-Configs.patch +++ b/patches/server/0023-Redirect-Configs.patch @@ -46,13 +46,13 @@ index bbf09800b7b72bdfb75c91e4c6c77fe00e3ad436..1d98bfdee95fb1052fcd9f141a2ab82b for (final Method method : clazz.getDeclaredMethods()) { if (method.getReturnType() != void.class || method.getParameterCount() != 0 || diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java -index dde91498e773cc6744612f780ce82bd35ad79637..15ccdad0f46297c30ed603879db467608c410df4 100644 +index 72d7a017f2aa7f2fde3b5de437e7fd2e051edd24..6c280d64bb069fba0d52a7d8b4eb6a0816354cc1 100644 --- a/src/main/java/net/minecraft/server/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/DedicatedServer.java -@@ -185,6 +185,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer +@@ -184,6 +184,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer + DedicatedServer.LOGGER.error("Unable to load server configuration", e); return false; } - net.yatopia.server.YatopiaConfig.registerCommands(); + de.minebench.origami.OrigamiConfig.init((java.io.File) options.valueOf("origami-settings")); // Yatopia end this.setPVP(dedicatedserverproperties.pvp); diff --git a/patches/server/0027-Fix-lead-fall-dmg-config.patch b/patches/server/0027-Fix-lead-fall-dmg-config.patch index 6fff3279..e651f51d 100644 --- a/patches/server/0027-Fix-lead-fall-dmg-config.patch +++ b/patches/server/0027-Fix-lead-fall-dmg-config.patch @@ -18,10 +18,10 @@ index 26306687857100173e762578eb2c509370279207..c6bbc620e163acea757b610e95169e8f } diff --git a/src/main/java/net/yatopia/server/YatopiaConfig.java b/src/main/java/net/yatopia/server/YatopiaConfig.java -index c60c3c4b730fe299e62c277cdd644b6afd3841e5..c1aa37a91aef1bd2a2cafa32cb6028831f0f8c1d 100644 +index eb53176099103172961d544c0dab17cc19ef2e7f..b0dac509dddd576742308b687048e432fcf0484f 100644 --- a/src/main/java/net/yatopia/server/YatopiaConfig.java +++ b/src/main/java/net/yatopia/server/YatopiaConfig.java -@@ -227,4 +227,9 @@ public class YatopiaConfig { +@@ -207,4 +207,9 @@ public class YatopiaConfig { simplerVillagerBehavior = getBoolean("settings.villager.simplerVillagerBehavior", false); villagersHideAtNight = getBoolean("settings.villager.villagersHideAtNight", false); } diff --git a/patches/server/0033-Use-offline-uuids-if-we-need-to.patch b/patches/server/0033-Use-offline-uuids-if-we-need-to.patch index 75eb4ac6..6e5266c4 100644 --- a/patches/server/0033-Use-offline-uuids-if-we-need-to.patch +++ b/patches/server/0033-Use-offline-uuids-if-we-need-to.patch @@ -65,10 +65,10 @@ index 1496c43fc9487caf6ddb3782a9d1c79ef6ca1e94..7e486c0f326449a10700efcec7ed3d9d } diff --git a/src/main/java/net/yatopia/server/YatopiaConfig.java b/src/main/java/net/yatopia/server/YatopiaConfig.java -index c1aa37a91aef1bd2a2cafa32cb6028831f0f8c1d..256a713df5ed27fbe926ab0a124ffcd438fa431c 100644 +index b0dac509dddd576742308b687048e432fcf0484f..0237e91512dd15dae1597f1cbb37b0fb178ae35e 100644 --- a/src/main/java/net/yatopia/server/YatopiaConfig.java +++ b/src/main/java/net/yatopia/server/YatopiaConfig.java -@@ -232,4 +232,26 @@ public class YatopiaConfig { +@@ -212,4 +212,26 @@ public class YatopiaConfig { private static void fixFallDistance() { fixFallDistance = getBoolean("settings.fixFallDistance", false); }