2020-06-25 02:00:00 +02:00
--- a/net/minecraft/server/Main.java
+++ b/net/minecraft/server/Main.java
@@ -28,7 +28,8 @@
public Main() {}
- public static void main(String[] astring) {
+ public static void main(final OptionSet optionset) { // CraftBukkit - replaces main(String[] astring)
+ /* CraftBukkit start - Replace everything
OptionParser optionparser = new OptionParser();
OptionSpec<Void> optionspec = optionparser.accepts("nogui");
OptionSpec<Void> optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits");
2020-08-11 23:00:00 +02:00
@@ -52,20 +53,22 @@
2020-06-25 02:00:00 +02:00
optionparser.printHelpOn(System.err);
return;
}
+ */ // CraftBukkit end
+ try {
CrashReport.h();
DispenserRegistry.init();
DispenserRegistry.c();
SystemUtils.l();
2020-08-11 23:00:00 +02:00
IRegistryCustom.Dimension iregistrycustom_dimension = IRegistryCustom.b();
2020-06-25 02:00:00 +02:00
java.nio.file.Path java_nio_file_path = Paths.get("server.properties");
2020-08-11 23:00:00 +02:00
- DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(iregistrycustom_dimension, java_nio_file_path);
+ DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(iregistrycustom_dimension, optionset); // CraftBukkit - CLI argument support
2020-06-25 02:00:00 +02:00
dedicatedserversettings.save();
java.nio.file.Path java_nio_file_path1 = Paths.get("eula.txt");
EULA eula = new EULA(java_nio_file_path1);
- if (optionset.has(optionspec1)) {
+ if (optionset.has("initSettings")) { // CraftBukkit
Main.LOGGER.info("Initialized '{}' and '{}'", java_nio_file_path.toAbsolutePath(), java_nio_file_path1.toAbsolutePath());
return;
}
2020-08-11 23:00:00 +02:00
@@ -75,24 +78,42 @@
2020-06-25 02:00:00 +02:00
return;
}
- File file = new File((String) optionset.valueOf(optionspec9));
+ File file = (File) optionset.valueOf("universe"); // CraftBukkit
YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(Proxy.NO_PROXY, UUID.randomUUID().toString());
MinecraftSessionService minecraftsessionservice = yggdrasilauthenticationservice.createMinecraftSessionService();
GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository();
UserCache usercache = new UserCache(gameprofilerepository, new File(file, MinecraftServer.b.getName()));
- String s = (String) Optional.ofNullable(optionset.valueOf(optionspec10)).orElse(dedicatedserversettings.getProperties().levelName);
+ // CraftBukkit start
+ String s = (String) Optional.ofNullable(optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName);
Convertable convertable = Convertable.a(file.toPath());
- Convertable.ConversionSession convertable_conversionsession = convertable.c(s);
+ Convertable.ConversionSession convertable_conversionsession = convertable.c(s, WorldDimension.OVERWORLD);
MinecraftServer.convertWorld(convertable_conversionsession);
DataPackConfiguration datapackconfiguration = convertable_conversionsession.e();
- boolean flag = optionset.has(optionspec6);
+ boolean flag = optionset.has("safeMode");
if (flag) {
Main.LOGGER.warn("Safe mode active, only vanilla datapack will be loaded");
2020-06-26 04:24:35 +02:00
}
2020-08-11 23:00:00 +02:00
ResourcePackRepository resourcepackrepository = new ResourcePackRepository(new ResourcePackSource[]{new ResourcePackSourceVanilla(), new ResourcePackSourceFolder(convertable_conversionsession.getWorldFolder(SavedFile.DATAPACKS).toFile(), PackSource.c)});
2020-06-26 04:24:35 +02:00
+ // CraftBukkit start
+ File bukkitDataPackFolder = new File(convertable_conversionsession.getWorldFolder(SavedFile.DATAPACKS).toFile(), "bukkit");
+ if (!bukkitDataPackFolder.exists()) {
+ bukkitDataPackFolder.mkdirs();
+ }
+ File mcMeta = new File(bukkitDataPackFolder, "pack.mcmeta");
+ try {
+ com.google.common.io.Files.write("{\n"
+ + " \"pack\": {\n"
+ + " \"description\": \"Data pack for resources provided by Bukkit plugins\",\n"
+ + " \"pack_format\": " + SharedConstants.getGameVersion().getPackVersion() + "\n"
+ + " }\n"
+ + "}\n", mcMeta, com.google.common.base.Charsets.UTF_8);
+ } catch (java.io.IOException ex) {
+ throw new RuntimeException("Could not initialize Bukkit datapack", ex);
+ }
+ // CraftBukkit end
DataPackConfiguration datapackconfiguration1 = MinecraftServer.a(resourcepackrepository, datapackconfiguration == null ? DataPackConfiguration.a : datapackconfiguration, flag);
CompletableFuture completablefuture = DataPackResources.a(resourcepackrepository.f(), CommandDispatcher.ServerType.DEDICATED, dedicatedserversettings.getProperties().functionPermissionLevel, SystemUtils.f(), Runnable::run);
@@ -107,6 +128,7 @@
2020-08-11 23:00:00 +02:00
}
2020-06-25 02:00:00 +02:00
datapackresources.i();
+ /*
2020-08-11 23:00:00 +02:00
RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, datapackresources.h(), iregistrycustom_dimension);
2020-06-25 02:00:00 +02:00
Object object = convertable_conversionsession.a((DynamicOps) registryreadops, datapackconfiguration1);
2020-06-26 04:24:35 +02:00
@@ -134,21 +156,32 @@
2020-06-25 02:00:00 +02:00
}
convertable_conversionsession.a((IRegistryCustom) iregistrycustom_dimension, (SaveData) object);
+ */
final DedicatedServer dedicatedserver = (DedicatedServer) MinecraftServer.a((thread) -> {
- DedicatedServer dedicatedserver1 = new DedicatedServer(thread, iregistrycustom_dimension, convertable_conversionsession, resourcepackrepository, datapackresources, object, dedicatedserversettings, DataConverterRegistry.a(), minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new);
+ DedicatedServer dedicatedserver1 = new DedicatedServer(optionset, datapackconfiguration1, thread, iregistrycustom_dimension, convertable_conversionsession, resourcepackrepository, datapackresources, null, dedicatedserversettings, DataConverterRegistry.a(), minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new);
+ /*
dedicatedserver1.d((String) optionset.valueOf(optionspec8));
dedicatedserver1.setPort((Integer) optionset.valueOf(optionspec11));
dedicatedserver1.c(optionset.has(optionspec2));
dedicatedserver1.b((String) optionset.valueOf(optionspec12));
- boolean flag1 = !optionset.has(optionspec) && !optionset.valuesOf(nonoptionargumentspec).contains("nogui");
+ */
+ boolean flag1 = !optionset.has("nogui") && !optionset.nonOptionArguments().contains("nogui");
if (flag1 && !GraphicsEnvironment.isHeadless()) {
2020-08-11 23:00:00 +02:00
dedicatedserver1.bc();
2020-06-25 02:00:00 +02:00
}
+ if (optionset.has("port")) {
+ int port = (Integer) optionset.valueOf("port");
+ if (port > 0) {
+ dedicatedserver1.setPort(port);
+ }
+ }
+
return dedicatedserver1;
});
+ /* CraftBukkit start
Thread thread = new Thread("Server Shutdown Thread") {
public void run() {
dedicatedserver.safeShutdown(true);
2020-06-26 04:24:35 +02:00
@@ -157,14 +190,15 @@
2020-06-25 02:00:00 +02:00
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER));
Runtime.getRuntime().addShutdownHook(thread);
+ */ // CraftBukkit end
} catch (Exception exception1) {
Main.LOGGER.fatal("Failed to start the minecraft server", exception1);
}
2020-06-25 09:58:10 +02:00
2020-06-25 02:00:00 +02:00
}
2020-06-25 09:58:10 +02:00
- public static void convertWorld(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, ImmutableSet<ResourceKey<World>> immutableset) {
2020-06-25 02:00:00 +02:00
- Main.LOGGER.info("Forcing world upgrade!");
2020-06-25 09:58:10 +02:00
+ public static void convertWorld(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, ImmutableSet<ResourceKey<DimensionManager>> immutableset) { // CraftBukkit
2020-06-25 02:00:00 +02:00
+ Main.LOGGER.info("Forcing world upgrade! {}", convertable_conversionsession.getLevelName()); // CraftBukkit
WorldUpgrader worldupgrader = new WorldUpgrader(convertable_conversionsession, datafixer, immutableset, flag);
IChatBaseComponent ichatbasecomponent = null;