Repackage NMS

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2021-03-16 09:00:00 +11:00
parent 18496e998f
commit 9da047989c
968 changed files with 5448 additions and 5050 deletions

View File

@@ -1,10 +1,11 @@
--- a/net/minecraft/server/DedicatedServer.java
+++ b/net/minecraft/server/DedicatedServer.java
@@ -22,6 +22,14 @@
--- a/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
@@ -60,6 +60,15 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import net.minecraft.world.level.DataPackConfiguration;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.io.IoBuilder;
+import org.bukkit.command.CommandSender;
@@ -15,7 +16,7 @@
public class DedicatedServer extends MinecraftServer implements IMinecraftServer {
private static final Logger LOGGER = LogManager.getLogger();
@@ -36,8 +44,10 @@
@@ -74,8 +83,10 @@
@Nullable
private final TextFilter r;
@@ -28,7 +29,7 @@
this.propertyManager = dedicatedserversettings;
this.remoteControlCommandListener = new RemoteControlCommandListener(this);
this.r = null;
@@ -47,13 +57,44 @@
@@ -85,13 +96,44 @@
public boolean init() throws IOException {
Thread thread = new Thread("Server console handler") {
public void run() {
@@ -76,7 +77,7 @@
}
} catch (IOException ioexception) {
DedicatedServer.LOGGER.error("Exception handling console input", ioexception);
@@ -62,6 +103,27 @@
@@ -100,6 +142,27 @@
}
};
@@ -104,7 +105,7 @@
thread.setDaemon(true);
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER));
thread.start();
@@ -88,7 +150,7 @@
@@ -126,7 +189,7 @@
this.setForceGamemode(dedicatedserverproperties.forceGamemode);
super.setIdleTimeout((Integer) dedicatedserverproperties.playerIdleTimeout.get());
this.i(dedicatedserverproperties.enforceWhitelist);
@@ -113,7 +114,7 @@
DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode);
InetAddress inetaddress = null;
@@ -112,6 +174,12 @@
@@ -150,6 +213,12 @@
return false;
}
@@ -126,7 +127,7 @@
if (!this.getOnlineMode()) {
DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware.");
@@ -126,7 +194,7 @@
@@ -164,7 +233,7 @@
if (!NameReferencingFileConverter.e(this)) {
return false;
} else {
@@ -135,7 +136,7 @@
long i = SystemUtils.getMonotonicNanos();
this.c(dedicatedserverproperties.maxBuildHeight);
@@ -134,7 +202,7 @@
@@ -172,7 +241,7 @@
TileEntitySkull.a(this.getMinecraftSessionService());
UserCache.a(this.getOnlineMode());
DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getWorld());
@@ -144,7 +145,7 @@
long j = SystemUtils.getMonotonicNanos() - i;
String s = String.format(Locale.ROOT, "%.3fs", (double) j / 1.0E9D);
@@ -151,6 +219,7 @@
@@ -189,6 +258,7 @@
if (dedicatedserverproperties.enableRcon) {
DedicatedServer.LOGGER.info("Starting remote control listener");
this.remoteControlListener = RemoteControlListener.a((IMinecraftServer) this);
@@ -152,7 +153,7 @@
}
if (this.getMaxTickTime() > 0L) {
@@ -265,6 +334,7 @@
@@ -303,6 +373,7 @@
this.remoteStatusListener.b();
}
@@ -160,7 +161,7 @@
}
@Override
@@ -293,7 +363,15 @@
@@ -331,7 +402,15 @@
while (!this.serverCommandQueue.isEmpty()) {
ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0);
@@ -177,7 +178,7 @@
}
}
@@ -503,14 +581,45 @@
@@ -541,14 +620,45 @@
@Override
public String getPlugins() {
@@ -225,7 +226,7 @@
});
return this.remoteControlCommandListener.getMessages();
}
@@ -552,4 +661,15 @@
@@ -590,4 +700,15 @@
public ITextFilter a(EntityPlayer entityplayer) {
return this.r != null ? this.r.a(entityplayer.getProfile()) : null;
}

View File

@@ -1,12 +1,12 @@
--- a/net/minecraft/server/DedicatedServerProperties.java
+++ b/net/minecraft/server/DedicatedServerProperties.java
@@ -3,8 +3,14 @@
import java.util.Properties;
import java.util.concurrent.TimeUnit;
--- a/net/minecraft/server/dedicated/DedicatedServerProperties.java
+++ b/net/minecraft/server/dedicated/DedicatedServerProperties.java
@@ -9,8 +9,14 @@
import net.minecraft.world.level.EnumGamemode;
import net.minecraft.world.level.levelgen.GeneratorSettings;
+// CraftBukkit start
+import joptsimple.OptionSet;
+import net.minecraft.server.PropertyManager.EditableProperty;
+import net.minecraft.server.dedicated.PropertyManager.EditableProperty;
+// CraftBukkit end
+
public class DedicatedServerProperties extends PropertyManager<DedicatedServerProperties> {
@@ -15,7 +15,7 @@
public final boolean onlineMode = this.getBoolean("online-mode", true);
public final boolean preventProxyConnections = this.getBoolean("prevent-proxy-connections", false);
public final String serverIp = this.getString("server-ip", "");
@@ -55,8 +61,10 @@
@@ -61,8 +67,10 @@
public final PropertyManager<DedicatedServerProperties>.EditableProperty<Boolean> whiteList;
public final GeneratorSettings generatorSettings;
@@ -28,15 +28,15 @@
this.difficulty = (EnumDifficulty) this.a("difficulty", a(EnumDifficulty::getById, EnumDifficulty::a), EnumDifficulty::c, EnumDifficulty.EASY);
this.gamemode = (EnumGamemode) this.a("gamemode", a(EnumGamemode::getById, EnumGamemode::a), EnumGamemode::b, EnumGamemode.SURVIVAL);
this.levelName = this.getString("level-name", "world");
@@ -107,12 +115,14 @@
@@ -113,12 +121,14 @@
this.generatorSettings = GeneratorSettings.a(iregistrycustom, properties);
}
- public static DedicatedServerProperties load(IRegistryCustom iregistrycustom, java.nio.file.Path java_nio_file_path) {
- return new DedicatedServerProperties(loadPropertiesFile(java_nio_file_path), iregistrycustom);
- public static DedicatedServerProperties load(IRegistryCustom iregistrycustom, Path path) {
- return new DedicatedServerProperties(loadPropertiesFile(path), iregistrycustom);
+ // CraftBukkit start
+ public static DedicatedServerProperties load(IRegistryCustom iregistrycustom, java.nio.file.Path java_nio_file_path, OptionSet optionset) {
+ return new DedicatedServerProperties(loadPropertiesFile(java_nio_file_path), iregistrycustom, optionset);
+ public static DedicatedServerProperties load(IRegistryCustom iregistrycustom, Path path, OptionSet optionset) {
+ return new DedicatedServerProperties(loadPropertiesFile(path), iregistrycustom, optionset);
}
@Override

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/server/DedicatedServerSettings.java
+++ b/net/minecraft/server/DedicatedServerSettings.java
@@ -2,14 +2,21 @@
--- a/net/minecraft/server/dedicated/DedicatedServerSettings.java
+++ b/net/minecraft/server/dedicated/DedicatedServerSettings.java
@@ -4,14 +4,21 @@
import java.util.function.UnaryOperator;
import net.minecraft.core.IRegistryCustom;
+// CraftBukkit start
+import java.io.File;
@@ -11,12 +11,12 @@
+
public class DedicatedServerSettings {
private final java.nio.file.Path path;
private final Path path;
private DedicatedServerProperties properties;
- public DedicatedServerSettings(IRegistryCustom iregistrycustom, java.nio.file.Path java_nio_file_path) {
- this.path = java_nio_file_path;
- this.properties = DedicatedServerProperties.load(iregistrycustom, java_nio_file_path);
- public DedicatedServerSettings(IRegistryCustom iregistrycustom, Path path) {
- this.path = path;
- this.properties = DedicatedServerProperties.load(iregistrycustom, path);
+ // CraftBukkit start
+ public DedicatedServerSettings(IRegistryCustom iregistrycustom, OptionSet optionset) {
+ this.path = ((File) optionset.valueOf("config")).toPath();

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/PropertyManager.java
+++ b/net/minecraft/server/PropertyManager.java
@@ -15,15 +15,30 @@
--- a/net/minecraft/server/dedicated/PropertyManager.java
+++ b/net/minecraft/server/dedicated/PropertyManager.java
@@ -17,15 +17,30 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -29,22 +29,22 @@
+ }
+ // CraftBukkit end
+
public static Properties loadPropertiesFile(java.nio.file.Path java_nio_file_path) {
public static Properties loadPropertiesFile(Path path) {
Properties properties = new Properties();
@@ -59,6 +74,11 @@
@@ -61,6 +76,11 @@
public void savePropertiesFile(java.nio.file.Path java_nio_file_path) {
public void savePropertiesFile(Path path) {
try {
+ // CraftBukkit start - Don't attempt writing to file if it's read only
+ if (java_nio_file_path.toFile().exists() && !java_nio_file_path.toFile().canWrite()) {
+ if (path.toFile().exists() && !path.toFile().canWrite()) {
+ return;
+ }
+ // CraftBukkit end
OutputStream outputstream = Files.newOutputStream(java_nio_file_path);
OutputStream outputstream = Files.newOutputStream(path);
Throwable throwable = null;
@@ -90,7 +110,7 @@
@@ -92,7 +112,7 @@
private static <V extends Number> Function<String, V> a(Function<String, V> function) {
return (s) -> {
try {
@@ -53,7 +53,7 @@
} catch (NumberFormatException numberformatexception) {
return null;
}
@@ -109,7 +129,7 @@
@@ -111,7 +131,7 @@
@Nullable
private String c(String s) {
@@ -62,7 +62,7 @@
}
@Nullable
@@ -137,7 +157,7 @@
@@ -139,7 +159,7 @@
V v1 = MoreObjects.firstNonNull(s1 != null ? function.apply(s1) : null, v0);
this.properties.put(s, function1.apply(v1));
@@ -71,7 +71,7 @@
}
protected <V> V a(String s, Function<String, V> function, UnaryOperator<V> unaryoperator, Function<V, String> function1, V v0) {
@@ -166,7 +186,7 @@
@@ -168,7 +188,7 @@
}
protected int getInt(String s, int i) {
@@ -80,7 +80,7 @@
}
protected PropertyManager<T>.EditableProperty<Integer> b(String s, int i) {
@@ -178,7 +198,7 @@
@@ -180,7 +200,7 @@
}
protected long getLong(String s, long i) {
@@ -89,7 +89,7 @@
}
protected boolean getBoolean(String s, boolean flag) {
@@ -201,7 +221,7 @@
@@ -203,7 +223,7 @@
return properties;
}
@@ -98,7 +98,7 @@
public class EditableProperty<V> implements Supplier<V> {
@@ -209,7 +229,7 @@
@@ -211,7 +231,7 @@
private final V c;
private final Function<V, String> d;
@@ -107,7 +107,7 @@
this.b = s;
this.c = object;
this.d = function;
@@ -223,7 +243,7 @@
@@ -225,7 +245,7 @@
Properties properties = PropertyManager.this.a();
properties.put(this.b, this.d.apply(v0));