Update to Minecraft 1.18-pre5

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2021-11-22 09:00:00 +11:00
parent a852b81a69
commit 43702a9e10
700 changed files with 10286 additions and 10098 deletions

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
@@ -65,6 +65,15 @@
@@ -61,6 +61,15 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -16,7 +16,7 @@
public class DedicatedServer extends MinecraftServer implements IMinecraftServer {
static final Logger LOGGER = LogManager.getLogger();
@@ -83,8 +92,10 @@
@@ -81,8 +90,10 @@
@Nullable
private final IChatBaseComponent resourcePackPrompt;
@@ -28,9 +28,9 @@
+ // CraftBukkit end
this.settings = dedicatedserversettings;
this.rconConsoleSource = new RemoteControlCommandListener(this);
this.textFilterClient = TextFilter.a(dedicatedserversettings.getProperties().textFilteringConfig);
@@ -95,13 +106,44 @@
public boolean init() throws IOException {
this.textFilterClient = TextFilter.createFromConfig(dedicatedserversettings.getProperties().textFilteringConfig);
@@ -93,13 +104,44 @@
public boolean initServer() throws IOException {
Thread thread = new Thread("Server console handler") {
public void run() {
- BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8));
@@ -52,7 +52,7 @@
try {
- while (!DedicatedServer.this.isStopped() && DedicatedServer.this.isRunning() && (s = bufferedreader.readLine()) != null) {
- DedicatedServer.this.issueCommand(s, DedicatedServer.this.getServerCommandListener());
- DedicatedServer.this.handleConsoleInput(s, DedicatedServer.this.createCommandSourceStack());
+ // CraftBukkit start - JLine disabling compatibility
+ while (!DedicatedServer.this.isStopped() && DedicatedServer.this.isRunning()) {
+ if (org.bukkit.craftbukkit.Main.useJline) {
@@ -71,13 +71,13 @@
+ continue;
+ }
+ if (s.trim().length() > 0) { // Trim to filter lines which are just spaces
+ DedicatedServer.this.issueCommand(s, DedicatedServer.this.getServerCommandListener());
+ DedicatedServer.this.handleConsoleInput(s, DedicatedServer.this.createCommandSourceStack());
+ }
+ // CraftBukkit end
}
} catch (IOException ioexception) {
DedicatedServer.LOGGER.error("Exception handling console input", ioexception);
@@ -110,6 +152,27 @@
@@ -108,6 +150,27 @@
}
};
@@ -105,83 +105,81 @@
thread.setDaemon(true);
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER));
thread.start();
@@ -135,7 +198,7 @@
@@ -133,7 +196,7 @@
this.setMotd(dedicatedserverproperties.motd);
super.setIdleTimeout((Integer) dedicatedserverproperties.playerIdleTimeout.get());
super.setPlayerIdleTimeout((Integer) dedicatedserverproperties.playerIdleTimeout.get());
this.setEnforceWhitelist(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;
@@ -159,6 +222,12 @@
@@ -157,6 +220,12 @@
return false;
}
+ // CraftBukkit start
+ this.a((PlayerList) (new DedicatedPlayerList(this, this.registryHolder, this.playerDataStorage)));
+ this.setPlayerList(new DedicatedPlayerList(this, this.registryHolder, this.playerDataStorage));
+ server.loadPlugins();
+ server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP);
+ // CraftBukkit end
+
if (!this.getOnlineMode()) {
if (!this.usesAuthentication()) {
DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware.");
@@ -173,7 +242,7 @@
if (!NameReferencingFileConverter.e(this)) {
@@ -171,13 +240,13 @@
if (!NameReferencingFileConverter.serverReadyAfterUserconversion(this)) {
return false;
} else {
- 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.setPlayerList(new DedicatedPlayerList(this, this.registryHolder, this.playerDataStorage));
+ // this.setPlayerList(new DedicatedPlayerList(this, this.registryHolder, this.playerDataStorage)); // CraftBukkit - moved up
long i = SystemUtils.getNanos();
TileEntitySkull.a(this.getUserCache());
@@ -181,7 +250,7 @@
TileEntitySkull.a((Executor) this);
UserCache.a(this.getOnlineMode());
DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getWorld());
- this.loadWorld();
+ this.loadWorld(storageSource.getLevelName()); // CraftBukkit
long j = SystemUtils.getMonotonicNanos() - i;
TileEntitySkull.setup(this.getProfileCache(), this.getSessionService(), this);
UserCache.setUsesAuthentication(this.usesAuthentication());
DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getLevelIdName());
- this.loadLevel();
+ this.loadLevel(storageSource.getLevelId()); // CraftBukkit
long j = SystemUtils.getNanos() - i;
String s = String.format(Locale.ROOT, "%.3fs", (double) j / 1.0E9D);
@@ -198,6 +267,7 @@
@@ -194,6 +263,7 @@
if (dedicatedserverproperties.enableRcon) {
DedicatedServer.LOGGER.info("Starting remote control listener");
this.rconThread = RemoteControlListener.a((IMinecraftServer) this);
this.rconThread = RemoteControlListener.create(this);
+ this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(this.rconConsoleSource); // CraftBukkit
}
if (this.getMaxTickTime() > 0L) {
@@ -347,6 +417,7 @@
this.queryThreadGs4.b();
if (this.getMaxTickLength() > 0L) {
@@ -337,6 +407,7 @@
this.queryThreadGs4.stop();
}
+ System.exit(0); // CraftBukkit
}
@Override
@@ -380,7 +451,15 @@
@@ -358,7 +429,15 @@
while (!this.consoleInput.isEmpty()) {
ServerCommand servercommand = (ServerCommand) this.consoleInput.remove(0);
- this.getCommandDispatcher().a(servercommand.source, servercommand.msg);
- this.getCommands().performCommand(servercommand.source, servercommand.msg);
+ // CraftBukkit start - ServerCommand for preprocessing
+ ServerCommandEvent event = new ServerCommandEvent(console, servercommand.msg);
+ server.getPluginManager().callEvent(event);
+ if (event.isCancelled()) continue;
+ servercommand = new ServerCommand(event.getCommand(), servercommand.source);
+
+ // this.getCommandDispatcher().a(servercommand.source, servercommand.command); // Called in dispatchServerCommand
+ // this.getCommands().performCommand(servercommand.source, servercommand.msg); // Called in dispatchServerCommand
+ server.dispatchServerCommand(console, servercommand);
+ // CraftBukkit end
}
}
@@ -585,14 +664,45 @@
@@ -568,14 +647,45 @@
@Override
public String getPlugins() {
public String getPluginNames() {
- return "";
+ // CraftBukkit start - Whole method
+ StringBuilder result = new StringBuilder();
@@ -210,30 +208,30 @@
}
@Override
public String executeRemoteCommand(String s) {
this.rconConsoleSource.clearMessages();
this.executeSync(() -> {
- this.getCommandDispatcher().a(this.rconConsoleSource.getWrapper(), s);
public String runCommand(String s) {
this.rconConsoleSource.prepareForCommand();
this.executeBlocking(() -> {
- this.getCommands().performCommand(this.rconConsoleSource.createCommandSourceStack(), 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(), rconConsoleSource.getWrapper());
+ ServerCommand serverCommand = new ServerCommand(event.getCommand(), rconConsoleSource.createCommandSourceStack());
+ server.dispatchServerCommand(remoteConsole, serverCommand);
+ // CraftBukkit end
});
return this.rconConsoleSource.getMessages();
return this.rconConsoleSource.getCommandResponse();
}
@@ -665,4 +775,15 @@
public IChatBaseComponent ba() {
@@ -649,4 +759,15 @@
public IChatBaseComponent getResourcePackPrompt() {
return this.resourcePackPrompt;
}
+
+ // CraftBukkit start
+ public boolean isDebugging() {
+ return this.getDedicatedServerProperties().debug;
+ return this.getProperties().debug;
+ }
+
+ @Override

View File

@@ -11,11 +11,11 @@
+
public class DedicatedServerProperties extends PropertyManager<DedicatedServerProperties> {
+ public final boolean debug = this.getBoolean("debug", false); // CraftBukkit
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", "");
@@ -64,8 +70,10 @@
+ public final boolean debug = this.get("debug", false); // CraftBukkit
public final boolean onlineMode = this.get("online-mode", true);
public final boolean preventProxyConnections = this.get("prevent-proxy-connections", false);
public final String serverIp = this.get("server-ip", "");
@@ -67,8 +73,10 @@
@Nullable
private GeneratorSettings worldGenSettings;
@@ -25,18 +25,18 @@
+ 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");
this.difficulty = (EnumDifficulty) this.get("difficulty", dispatchNumberOrString(EnumDifficulty::byId, EnumDifficulty::byName), EnumDifficulty::getKey, EnumDifficulty.EASY);
this.gamemode = (EnumGamemode) this.get("gamemode", dispatchNumberOrString(EnumGamemode::byId, EnumGamemode::byName), EnumGamemode::getName, EnumGamemode.SURVIVAL);
this.levelName = this.get("level-name", "world");
@@ -112,13 +120,15 @@
this.whiteList = this.b("white-list", false);
this.whiteList = this.getMutable("white-list", false);
}
- public static DedicatedServerProperties load(Path path) {
- return new DedicatedServerProperties(loadPropertiesFile(path));
- public static DedicatedServerProperties fromFile(Path path) {
- return new DedicatedServerProperties(loadFromFile(path));
+ // CraftBukkit start
+ public static DedicatedServerProperties load(Path path, OptionSet optionset) {
+ return new DedicatedServerProperties(loadPropertiesFile(path), optionset);
+ public static DedicatedServerProperties fromFile(Path path, OptionSet optionset) {
+ return new DedicatedServerProperties(loadFromFile(path), optionset);
}
@Override
@@ -46,5 +46,5 @@
+ DedicatedServerProperties dedicatedserverproperties = new DedicatedServerProperties(properties, optionset);
+ // CraftBukkit end
dedicatedserverproperties.a(iregistrycustom);
dedicatedserverproperties.getWorldGenSettings(iregistrycustom);
return dedicatedserverproperties;

View File

@@ -16,11 +16,11 @@
- public DedicatedServerSettings(Path path) {
- this.source = path;
- this.properties = DedicatedServerProperties.load(path);
- this.properties = DedicatedServerProperties.fromFile(path);
+ // CraftBukkit start
+ public DedicatedServerSettings(OptionSet optionset) {
+ this.source = ((File) optionset.valueOf("config")).toPath();
+ this.properties = DedicatedServerProperties.load(source, optionset);
+ this.properties = DedicatedServerProperties.fromFile(source, optionset);
+ // CraftBukkit end
}

View File

@@ -29,12 +29,12 @@
+ }
+ // CraftBukkit end
+
public static Properties loadPropertiesFile(Path path) {
public static Properties loadFromFile(Path path) {
Properties properties = new Properties();
@@ -58,6 +73,11 @@
public void savePropertiesFile(Path path) {
public void store(Path path) {
try {
+ // CraftBukkit start - Don't attempt writing to file if it's read only
+ if (path.toFile().exists() && !path.toFile().canWrite()) {
@@ -45,7 +45,7 @@
try {
@@ -86,7 +106,7 @@
private static <V extends Number> Function<String, V> a(Function<String, V> function) {
private static <V extends Number> Function<String, V> wrapNumberDeserializer(Function<String, V> function) {
return (s) -> {
try {
- return (Number) function.apply(s);
@@ -56,7 +56,7 @@
@@ -105,7 +125,7 @@
@Nullable
private String c(String s) {
private String getStringRaw(String s) {
- return (String) this.properties.get(s);
+ return (String) getOverride(s, this.properties.getProperty(s)); // CraftBukkit
}
@@ -70,25 +70,7 @@
+ return new PropertyManager.EditableProperty(s, v1, function1); // CraftBukkit - decompile error
}
protected <V> V a(String s, Function<String, V> function, UnaryOperator<V> unaryoperator, Function<V, String> function1, V v0) {
@@ -162,7 +182,7 @@
}
protected int getInt(String s, int i) {
- return (Integer) this.a(s, a(Integer::parseInt), (Object) i);
+ return (Integer) this.a(s, a(Integer::parseInt), i); // CraftBukkit - decompile error
}
protected PropertyManager<T>.EditableProperty<Integer> b(String s, int i) {
@@ -174,7 +194,7 @@
}
protected long getLong(String s, long i) {
- return (Long) this.a(s, a(Long::parseLong), (Object) i);
+ return (Long) this.a(s, a(Long::parseLong), i); // CraftBukkit - decompile error
}
protected boolean getBoolean(String s, boolean flag) {
protected <V> V get(String s, Function<String, V> function, UnaryOperator<V> unaryoperator, Function<V, String> function1, V v0) {
@@ -197,7 +217,7 @@
return properties;
}
@@ -108,7 +90,7 @@
this.value = object;
this.serializer = function;
@@ -219,7 +239,7 @@
Properties properties = PropertyManager.this.a();
Properties properties = PropertyManager.this.cloneProperties();
properties.put(this.key, this.serializer.apply(v0));
- return PropertyManager.this.reload(iregistrycustom, properties);