Update to Minecraft 1.17

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2021-06-11 15:00:00 +10:00
parent 75faba7fde
commit b3a8254758
619 changed files with 10708 additions and 8451 deletions

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
@@ -60,6 +60,15 @@
@@ -64,6 +64,15 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -15,10 +15,10 @@
+
public class DedicatedServer extends MinecraftServer implements IMinecraftServer {
private static final Logger LOGGER = LogManager.getLogger();
@@ -74,8 +83,10 @@
static final Logger LOGGER = LogManager.getLogger();
@@ -82,8 +91,10 @@
@Nullable
private final TextFilter r;
private final IChatBaseComponent resourcePackPrompt;
- public DedicatedServer(Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, DataPackResources datapackresources, SaveData savedata, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) {
- super(thread, iregistrycustom_dimension, convertable_conversionsession, savedata, resourcepackrepository, Proxy.NO_PROXY, datafixer, datapackresources, minecraftsessionservice, gameprofilerepository, usercache, worldloadlistenerfactory);
@@ -26,10 +26,10 @@
+ public DedicatedServer(joptsimple.OptionSet options, DataPackConfiguration datapackconfiguration, Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, DataPackResources datapackresources, SaveData savedata, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) {
+ super(options, datapackconfiguration, thread, iregistrycustom_dimension, convertable_conversionsession, savedata, resourcepackrepository, Proxy.NO_PROXY, datafixer, datapackresources, minecraftsessionservice, gameprofilerepository, usercache, worldloadlistenerfactory);
+ // CraftBukkit end
this.propertyManager = dedicatedserversettings;
this.remoteControlCommandListener = new RemoteControlCommandListener(this);
this.r = null;
@@ -85,13 +96,44 @@
this.settings = dedicatedserversettings;
this.rconConsoleSource = new RemoteControlCommandListener(this);
this.textFilterClient = TextFilter.a(dedicatedserversettings.getProperties().textFilteringConfig);
@@ -94,13 +105,44 @@
public boolean init() throws IOException {
Thread thread = new Thread("Server console handler") {
public void run() {
@@ -77,7 +77,7 @@
}
} catch (IOException ioexception) {
DedicatedServer.LOGGER.error("Exception handling console input", ioexception);
@@ -100,6 +142,27 @@
@@ -109,6 +151,27 @@
}
};
@@ -105,21 +105,21 @@
thread.setDaemon(true);
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER));
thread.start();
@@ -126,7 +189,7 @@
this.setForceGamemode(dedicatedserverproperties.forceGamemode);
@@ -134,7 +197,7 @@
this.setMotd(dedicatedserverproperties.motd);
super.setIdleTimeout((Integer) dedicatedserverproperties.playerIdleTimeout.get());
this.i(dedicatedserverproperties.enforceWhitelist);
- this.saveData.setGameType(dedicatedserverproperties.gamemode);
+ // this.saveData.setGameType(dedicatedserverproperties.gamemode); // CraftBukkit - moved to world loading
this.h(dedicatedserverproperties.enforceWhitelist);
- this.worldData.setGameType(dedicatedserverproperties.gamemode);
+ // this.worldData.setGameType(dedicatedserverproperties.gamemode); // CraftBukkit - moved to world loading
DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode);
InetAddress inetaddress = null;
@@ -150,6 +213,12 @@
@@ -158,6 +221,12 @@
return false;
}
+ // CraftBukkit start
+ this.a((PlayerList) (new DedicatedPlayerList(this, this.customRegistry, this.worldNBTStorage)));
+ this.a((PlayerList) (new DedicatedPlayerList(this, this.registryHolder, this.playerDataStorage)));
+ server.loadPlugins();
+ server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP);
+ // CraftBukkit end
@@ -127,47 +127,46 @@
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.");
@@ -164,7 +233,7 @@
@@ -172,14 +241,14 @@
if (!NameReferencingFileConverter.e(this)) {
return false;
} else {
- this.a((PlayerList) (new DedicatedPlayerList(this, this.customRegistry, this.worldNBTStorage)));
- this.a((PlayerList) (new DedicatedPlayerList(this, this.registryHolder, this.playerDataStorage)));
+ // this.a((PlayerList) (new DedicatedPlayerList(this, this.customRegistry, this.worldNBTStorage))); // CraftBukkit - moved up
long i = SystemUtils.getMonotonicNanos();
this.c(dedicatedserverproperties.maxBuildHeight);
@@ -172,7 +241,7 @@
TileEntitySkull.a(this.getUserCache());
TileEntitySkull.a(this.getMinecraftSessionService());
UserCache.a(this.getOnlineMode());
DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getWorld());
- this.loadWorld();
+ this.loadWorld(convertable.getLevelName()); // CraftBukkit
+ this.loadWorld(storageSource.getLevelName()); // CraftBukkit
long j = SystemUtils.getMonotonicNanos() - i;
String s = String.format(Locale.ROOT, "%.3fs", (double) j / 1.0E9D);
@@ -189,6 +258,7 @@
@@ -196,6 +265,7 @@
if (dedicatedserverproperties.enableRcon) {
DedicatedServer.LOGGER.info("Starting remote control listener");
this.remoteControlListener = RemoteControlListener.a((IMinecraftServer) this);
+ this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(this.remoteControlCommandListener); // CraftBukkit
this.rconThread = RemoteControlListener.a((IMinecraftServer) this);
+ this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(this.rconConsoleSource); // CraftBukkit
}
if (this.getMaxTickTime() > 0L) {
@@ -303,6 +373,7 @@
this.remoteStatusListener.b();
@@ -345,6 +415,7 @@
this.queryThreadGs4.b();
}
+ System.exit(0); // CraftBukkit
}
@Override
@@ -331,7 +402,15 @@
while (!this.serverCommandQueue.isEmpty()) {
ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0);
@@ -378,7 +449,15 @@
while (!this.consoleInput.isEmpty()) {
ServerCommand servercommand = (ServerCommand) this.consoleInput.remove(0);
- this.getCommandDispatcher().a(servercommand.source, servercommand.command);
- this.getCommandDispatcher().a(servercommand.source, servercommand.msg);
+ // CraftBukkit start - ServerCommand for preprocessing
+ ServerCommandEvent event = new ServerCommandEvent(console, servercommand.command);
+ ServerCommandEvent event = new ServerCommandEvent(console, servercommand.msg);
+ server.getPluginManager().callEvent(event);
+ if (event.isCancelled()) continue;
+ servercommand = new ServerCommand(event.getCommand(), servercommand.source);
@@ -178,7 +177,7 @@
}
}
@@ -541,14 +620,45 @@
@@ -583,14 +662,45 @@
@Override
public String getPlugins() {
@@ -211,24 +210,24 @@
@Override
public String executeRemoteCommand(String s) {
this.remoteControlCommandListener.clearMessages();
this.rconConsoleSource.clearMessages();
this.executeSync(() -> {
- this.getCommandDispatcher().a(this.remoteControlCommandListener.getWrapper(), s);
- this.getCommandDispatcher().a(this.rconConsoleSource.getWrapper(), s);
+ // CraftBukkit start - fire RemoteServerCommandEvent
+ RemoteServerCommandEvent event = new RemoteServerCommandEvent(remoteConsole, s);
+ server.getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;
+ }
+ ServerCommand serverCommand = new ServerCommand(event.getCommand(), remoteControlCommandListener.getWrapper());
+ ServerCommand serverCommand = new ServerCommand(event.getCommand(), rconConsoleSource.getWrapper());
+ server.dispatchServerCommand(remoteConsole, serverCommand);
+ // CraftBukkit end
});
return this.remoteControlCommandListener.getMessages();
return this.rconConsoleSource.getMessages();
}
@@ -590,4 +700,15 @@
public ITextFilter a(EntityPlayer entityplayer) {
return this.r != null ? this.r.a(entityplayer.getProfile()) : null;
@@ -663,4 +773,15 @@
public IChatBaseComponent bb() {
return this.resourcePackPrompt;
}
+
+ // CraftBukkit start

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/dedicated/DedicatedServerProperties.java
+++ b/net/minecraft/server/dedicated/DedicatedServerProperties.java
@@ -9,8 +9,14 @@
@@ -10,8 +10,14 @@
import net.minecraft.world.level.EnumGamemode;
import net.minecraft.world.level.levelgen.GeneratorSettings;
@@ -15,35 +15,36 @@
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", "");
@@ -61,8 +67,10 @@
public final PropertyManager<DedicatedServerProperties>.EditableProperty<Boolean> whiteList;
public final GeneratorSettings generatorSettings;
@@ -64,8 +70,10 @@
@Nullable
public GeneratorSettings worldGenSettings;
- public DedicatedServerProperties(Properties properties, IRegistryCustom iregistrycustom) {
- public DedicatedServerProperties(Properties properties) {
- super(properties);
+ // CraftBukkit start
+ public DedicatedServerProperties(Properties properties, IRegistryCustom iregistrycustom, OptionSet optionset) {
+ public DedicatedServerProperties(Properties properties, OptionSet optionset) {
+ super(properties, optionset);
+ // CraftBukkit end
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");
@@ -113,12 +121,14 @@
this.generatorSettings = GeneratorSettings.a(iregistrycustom, properties);
@@ -112,13 +120,15 @@
this.whiteList = this.b("white-list", false);
}
- public static DedicatedServerProperties load(IRegistryCustom iregistrycustom, Path path) {
- return new DedicatedServerProperties(loadPropertiesFile(path), iregistrycustom);
- public static DedicatedServerProperties load(Path path) {
- return new DedicatedServerProperties(loadPropertiesFile(path));
+ // CraftBukkit start
+ public static DedicatedServerProperties load(IRegistryCustom iregistrycustom, Path path, OptionSet optionset) {
+ return new DedicatedServerProperties(loadPropertiesFile(path), iregistrycustom, optionset);
+ public static DedicatedServerProperties load(Path path, OptionSet optionset) {
+ return new DedicatedServerProperties(loadPropertiesFile(path), optionset);
}
@Override
- protected DedicatedServerProperties reload(IRegistryCustom iregistrycustom, Properties properties) {
- return new DedicatedServerProperties(properties, iregistrycustom);
- DedicatedServerProperties dedicatedserverproperties = new DedicatedServerProperties(properties);
+ protected DedicatedServerProperties reload(IRegistryCustom iregistrycustom, Properties properties, OptionSet optionset) {
+ return new DedicatedServerProperties(properties, iregistrycustom, optionset);
+ DedicatedServerProperties dedicatedserverproperties = new DedicatedServerProperties(properties, optionset);
+ // CraftBukkit end
}
}
dedicatedserverproperties.a(iregistrycustom);
return dedicatedserverproperties;

View File

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

View File

@@ -32,7 +32,7 @@
public static Properties loadPropertiesFile(Path path) {
Properties properties = new Properties();
@@ -61,6 +76,11 @@
@@ -58,6 +73,11 @@
public void savePropertiesFile(Path path) {
try {
@@ -42,9 +42,9 @@
+ }
+ // CraftBukkit end
OutputStream outputstream = Files.newOutputStream(path);
Throwable throwable = null;
@@ -92,7 +112,7 @@
try {
@@ -86,7 +106,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;
}
@@ -111,7 +131,7 @@
@@ -105,7 +125,7 @@
@Nullable
private String c(String s) {
@@ -62,7 +62,7 @@
}
@Nullable
@@ -139,7 +159,7 @@
@@ -133,7 +153,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) {
@@ -168,7 +188,7 @@
@@ -162,7 +182,7 @@
}
protected int getInt(String s, int i) {
@@ -80,7 +80,7 @@
}
protected PropertyManager<T>.EditableProperty<Integer> b(String s, int i) {
@@ -180,7 +200,7 @@
@@ -174,7 +194,7 @@
}
protected long getLong(String s, long i) {
@@ -89,7 +89,7 @@
}
protected boolean getBoolean(String s, boolean flag) {
@@ -203,7 +223,7 @@
@@ -197,7 +217,7 @@
return properties;
}
@@ -98,19 +98,19 @@
public class EditableProperty<V> implements Supplier<V> {
@@ -211,7 +231,7 @@
private final V c;
private final Function<V, String> d;
@@ -205,7 +225,7 @@
private final V value;
private final Function<V, String> serializer;
- private EditableProperty(String s, Object object, Function function) {
+ private EditableProperty(String s, V object, Function function) { // CraftBukkit - decompile error
this.b = s;
this.c = object;
this.d = function;
@@ -225,7 +245,7 @@
- EditableProperty(String s, Object object, Function function) {
+ EditableProperty(String s, V object, Function function) { // CraftBukkit - decompile error
this.key = s;
this.value = object;
this.serializer = function;
@@ -219,7 +239,7 @@
Properties properties = PropertyManager.this.a();
properties.put(this.b, this.d.apply(v0));
properties.put(this.key, this.serializer.apply(v0));
- return PropertyManager.this.reload(iregistrycustom, properties);
+ return PropertyManager.this.reload(iregistrycustom, properties, PropertyManager.this.options); // CraftBukkit
}