From 65ea162ce2d40480648d48b70eb54e9fca41a151 Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 22 Jul 2019 12:34:03 +1000 Subject: [PATCH] Ensure Bukkit data pack is always up to date --- nms-patches/MinecraftServer.patch | 60 +++++++++++++++---------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/nms-patches/MinecraftServer.patch b/nms-patches/MinecraftServer.patch index 28fc468dbc..ba09fd9cc1 100644 --- a/nms-patches/MinecraftServer.patch +++ b/nms-patches/MinecraftServer.patch @@ -307,7 +307,7 @@ private void a(WorldData worlddata) { worlddata.f(false); -@@ -353,6 +495,25 @@ +@@ -353,6 +495,23 @@ protected void a(File file, WorldData worlddata) { this.resourcePackRepository.a((ResourcePackSource) (new ResourcePackSourceVanilla())); this.resourcePackFolder = new ResourcePackSourceFolder(new File(file, "datapacks")); @@ -317,23 +317,21 @@ + bukkitDataPackFolder.mkdirs(); + } + File mcMeta = new File(bukkitDataPackFolder, "pack.mcmeta"); -+ if (!mcMeta.exists()) { -+ try { -+ com.google.common.io.Files.write("{\n" -+ + " \"pack\": {\n" -+ + " \"description\": \"Data pack for resources provided by Bukkit plugins\",\n" -+ + " \"pack_format\": 1\n" -+ + " }\n" -+ + "}", mcMeta, com.google.common.base.Charsets.UTF_8); -+ } catch (IOException ex) { -+ throw new RuntimeException("Could not initialize Bukkit datapack", ex); -+ } ++ try { ++ com.google.common.io.Files.write("{\n" ++ + " \"pack\": {\n" ++ + " \"description\": \"Data pack for resources provided by Bukkit plugins\",\n" ++ + " \"pack_format\": " + SharedConstants.a().getPackVersion() + "\n" ++ + " }\n" ++ + "}\n", mcMeta, com.google.common.base.Charsets.UTF_8); ++ } catch (IOException ex) { ++ throw new RuntimeException("Could not initialize Bukkit datapack", ex); + } + // CraftBukkit end this.resourcePackRepository.a((ResourcePackSource) this.resourcePackFolder); this.resourcePackRepository.a(); List list = Lists.newArrayList(); -@@ -373,11 +534,18 @@ +@@ -373,11 +532,18 @@ this.b(worlddata); } @@ -355,7 +353,7 @@ BlockPosition blockposition = worldserver.getSpawn(); worldloadlistener.a(new ChunkCoordIntPair(blockposition)); -@@ -388,17 +556,21 @@ +@@ -388,17 +554,21 @@ chunkproviderserver.addTicket(TicketType.START, new ChunkCoordIntPair(blockposition), 11, Unit.INSTANCE); while (chunkproviderserver.b() != 441) { @@ -386,7 +384,7 @@ if (forcedchunk != null) { WorldServer worldserver1 = this.getWorldServer(dimensionmanager); -@@ -413,10 +585,16 @@ +@@ -413,10 +583,16 @@ } } @@ -405,7 +403,7 @@ } protected void a(String s, WorldNBTStorage worldnbtstorage) { -@@ -463,12 +641,16 @@ +@@ -463,12 +639,16 @@ } } @@ -422,7 +420,7 @@ return flag3; } -@@ -477,8 +659,29 @@ +@@ -477,8 +657,29 @@ this.stop(); } @@ -452,7 +450,7 @@ if (this.getServerConnection() != null) { this.getServerConnection().b(); } -@@ -487,6 +690,7 @@ +@@ -487,6 +688,7 @@ MinecraftServer.LOGGER.info("Saving players"); this.playerList.savePlayers(); this.playerList.shutdown(); @@ -460,7 +458,7 @@ } MinecraftServer.LOGGER.info("Saving worlds"); -@@ -556,14 +760,16 @@ +@@ -556,14 +758,16 @@ while (this.isRunning) { long i = SystemUtils.getMonotonicMillis() - this.nextTick; @@ -478,7 +476,7 @@ this.nextTick += 50L; if (this.T) { this.T = false; -@@ -610,6 +816,12 @@ +@@ -610,6 +814,12 @@ } catch (Throwable throwable1) { MinecraftServer.LOGGER.error("Exception stopping the server", throwable1); } finally { @@ -491,7 +489,7 @@ this.exit(); } -@@ -618,8 +830,15 @@ +@@ -618,8 +828,15 @@ } private boolean canSleepForTick() { @@ -508,7 +506,7 @@ protected void sleepForTick() { this.executeAll(); -@@ -720,7 +939,7 @@ +@@ -720,7 +937,7 @@ this.serverPing.b().a(agameprofile); } @@ -517,7 +515,7 @@ MinecraftServer.LOGGER.debug("Autosave started"); this.methodProfiler.enter("save"); this.playerList.savePlayers(); -@@ -750,23 +969,40 @@ +@@ -750,23 +967,40 @@ } protected void b(BooleanSupplier booleansupplier) { @@ -559,7 +557,7 @@ this.methodProfiler.enter("tick"); -@@ -805,7 +1041,8 @@ +@@ -805,7 +1039,8 @@ this.tickables.add(runnable); } @@ -569,7 +567,7 @@ OptionParser optionparser = new OptionParser(); OptionSpec optionspec = optionparser.accepts("nogui"); OptionSpec optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits"); -@@ -828,15 +1065,17 @@ +@@ -828,15 +1063,17 @@ optionparser.printHelpOn(System.err); return; } @@ -589,7 +587,7 @@ MinecraftServer.LOGGER.info("Initialized '" + java_nio_file_path.toAbsolutePath().toString() + "' and '" + java_nio_file_path1.toAbsolutePath().toString() + "'"); return; } -@@ -848,14 +1087,15 @@ +@@ -848,14 +1085,15 @@ DispenserRegistry.init(); DispenserRegistry.c(); @@ -608,7 +606,7 @@ dedicatedserver.i((String) optionset.valueOf(optionspec7)); dedicatedserver.setPort((Integer) optionset.valueOf(optionspec10)); dedicatedserver.e(optionset.has(optionspec2)); -@@ -878,6 +1118,29 @@ +@@ -878,6 +1116,29 @@ thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(MinecraftServer.LOGGER)); Runtime.getRuntime().addShutdownHook(thread); @@ -638,7 +636,7 @@ } catch (Exception exception) { MinecraftServer.LOGGER.fatal("Failed to start the minecraft server", exception); } -@@ -897,7 +1160,9 @@ +@@ -897,7 +1158,9 @@ } public void startServerThread() { @@ -648,7 +646,7 @@ } public File d(String s) { -@@ -952,7 +1217,7 @@ +@@ -952,7 +1215,7 @@ } public String getServerModName() { @@ -657,7 +655,7 @@ } public CrashReport b(CrashReport crashreport) { -@@ -991,7 +1256,7 @@ +@@ -991,7 +1254,7 @@ } public boolean F() { @@ -666,7 +664,7 @@ } @Override -@@ -1690,4 +1955,16 @@ +@@ -1690,4 +1953,16 @@ } }