mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-18 00:25:39 +01:00
Re-add default bukkit datapack
This commit is contained in:
parent
d1fb662ec5
commit
709b003fee
@ -34,7 +34,7 @@
|
|||||||
Main.LOGGER.info("Initialized '{}' and '{}'", java_nio_file_path.toAbsolutePath(), java_nio_file_path1.toAbsolutePath());
|
Main.LOGGER.info("Initialized '{}' and '{}'", java_nio_file_path.toAbsolutePath(), java_nio_file_path1.toAbsolutePath());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -74,18 +77,19 @@
|
@@ -74,24 +77,42 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +58,30 @@
|
|||||||
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
Main.LOGGER.warn("Safe mode active, only vanilla datapack will be loaded");
|
Main.LOGGER.warn("Safe mode active, only vanilla datapack will be loaded");
|
||||||
@@ -107,6 +111,7 @@
|
}
|
||||||
|
|
||||||
|
ResourcePackRepository<ResourcePackLoader> resourcepackrepository = new ResourcePackRepository<>(ResourcePackLoader::new, new ResourcePackSource[]{new ResourcePackSourceVanilla(), new ResourcePackSourceFolder(convertable_conversionsession.getWorldFolder(SavedFile.DATAPACKS).toFile(), PackSource.c)});
|
||||||
|
+ // 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 @@
|
||||||
|
|
||||||
datapackresources.i();
|
datapackresources.i();
|
||||||
IRegistryCustom.Dimension iregistrycustom_dimension = IRegistryCustom.b();
|
IRegistryCustom.Dimension iregistrycustom_dimension = IRegistryCustom.b();
|
||||||
@ -66,7 +89,7 @@
|
|||||||
RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, datapackresources.h(), (IRegistryCustom) iregistrycustom_dimension);
|
RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, datapackresources.h(), (IRegistryCustom) iregistrycustom_dimension);
|
||||||
Object object = convertable_conversionsession.a((DynamicOps) registryreadops, datapackconfiguration1);
|
Object object = convertable_conversionsession.a((DynamicOps) registryreadops, datapackconfiguration1);
|
||||||
|
|
||||||
@@ -134,21 +139,32 @@
|
@@ -134,21 +156,32 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
convertable_conversionsession.a((IRegistryCustom) iregistrycustom_dimension, (SaveData) object);
|
convertable_conversionsession.a((IRegistryCustom) iregistrycustom_dimension, (SaveData) object);
|
||||||
@ -101,7 +124,7 @@
|
|||||||
Thread thread = new Thread("Server Shutdown Thread") {
|
Thread thread = new Thread("Server Shutdown Thread") {
|
||||||
public void run() {
|
public void run() {
|
||||||
dedicatedserver.safeShutdown(true);
|
dedicatedserver.safeShutdown(true);
|
||||||
@@ -157,14 +173,15 @@
|
@@ -157,14 +190,15 @@
|
||||||
|
|
||||||
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER));
|
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER));
|
||||||
Runtime.getRuntime().addShutdownHook(thread);
|
Runtime.getRuntime().addShutdownHook(thread);
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
public final Map<ResourceKey<World>, WorldServer> worldServer;
|
public final Map<ResourceKey<World>, WorldServer> worldServer;
|
||||||
private PlayerList playerList;
|
private PlayerList playerList;
|
||||||
private volatile boolean isRunning;
|
private volatile boolean isRunning;
|
||||||
@@ -124,6 +135,21 @@
|
@@ -124,6 +135,20 @@
|
||||||
private final DefinedStructureManager ak;
|
private final DefinedStructureManager ak;
|
||||||
protected SaveData saveData;
|
protected SaveData saveData;
|
||||||
|
|
||||||
@ -48,7 +48,6 @@
|
|||||||
+ public static int currentTick = (int) (System.currentTimeMillis() / 50);
|
+ public static int currentTick = (int) (System.currentTimeMillis() / 50);
|
||||||
+ public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
|
+ public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
|
||||||
+ public int autosavePeriod;
|
+ public int autosavePeriod;
|
||||||
+ public File bukkitDataPackFolder;
|
|
||||||
+ public CommandDispatcher vanillaCommandDispatcher;
|
+ public CommandDispatcher vanillaCommandDispatcher;
|
||||||
+ private boolean forceTicks;
|
+ private boolean forceTicks;
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
@ -56,7 +55,7 @@
|
|||||||
public static <S extends MinecraftServer> S a(Function<Thread, S> function) {
|
public static <S extends MinecraftServer> S a(Function<Thread, S> function) {
|
||||||
AtomicReference<S> atomicreference = new AtomicReference();
|
AtomicReference<S> atomicreference = new AtomicReference();
|
||||||
Thread thread = new Thread(() -> {
|
Thread thread = new Thread(() -> {
|
||||||
@@ -133,21 +159,21 @@
|
@@ -133,21 +158,21 @@
|
||||||
thread.setUncaughtExceptionHandler((thread1, throwable) -> {
|
thread.setUncaughtExceptionHandler((thread1, throwable) -> {
|
||||||
MinecraftServer.LOGGER.error(throwable);
|
MinecraftServer.LOGGER.error(throwable);
|
||||||
});
|
});
|
||||||
@ -81,7 +80,7 @@
|
|||||||
this.isRunning = true;
|
this.isRunning = true;
|
||||||
this.h = new long[100];
|
this.h = new long[100];
|
||||||
this.K = "";
|
this.K = "";
|
||||||
@@ -173,7 +199,34 @@
|
@@ -173,7 +198,34 @@
|
||||||
this.ak = new DefinedStructureManager(datapackresources.h(), convertable_conversionsession, datafixer);
|
this.ak = new DefinedStructureManager(datapackresources.h(), convertable_conversionsession, datafixer);
|
||||||
this.serverThread = thread;
|
this.serverThread = thread;
|
||||||
this.executorService = SystemUtils.f();
|
this.executorService = SystemUtils.f();
|
||||||
@ -116,7 +115,7 @@
|
|||||||
|
|
||||||
private void initializeScoreboards(WorldPersistentData worldpersistentdata) {
|
private void initializeScoreboards(WorldPersistentData worldpersistentdata) {
|
||||||
PersistentScoreboard persistentscoreboard = (PersistentScoreboard) worldpersistentdata.a(PersistentScoreboard::new, "scoreboard");
|
PersistentScoreboard persistentscoreboard = (PersistentScoreboard) worldpersistentdata.a(PersistentScoreboard::new, "scoreboard");
|
||||||
@@ -186,7 +239,7 @@
|
@@ -186,7 +238,7 @@
|
||||||
|
|
||||||
public static void convertWorld(Convertable.ConversionSession convertable_conversionsession) {
|
public static void convertWorld(Convertable.ConversionSession convertable_conversionsession) {
|
||||||
if (convertable_conversionsession.isConvertable()) {
|
if (convertable_conversionsession.isConvertable()) {
|
||||||
@ -125,7 +124,7 @@
|
|||||||
convertable_conversionsession.convert(new IProgressUpdate() {
|
convertable_conversionsession.convert(new IProgressUpdate() {
|
||||||
private long a = SystemUtils.getMonotonicMillis();
|
private long a = SystemUtils.getMonotonicMillis();
|
||||||
|
|
||||||
@@ -209,48 +262,187 @@
|
@@ -209,48 +261,187 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,7 +346,7 @@
|
|||||||
WorldBorder worldborder = worldserver.getWorldBorder();
|
WorldBorder worldborder = worldserver.getWorldBorder();
|
||||||
|
|
||||||
worldborder.a(iworlddataserver.q());
|
worldborder.a(iworlddataserver.q());
|
||||||
@@ -275,34 +467,8 @@
|
@@ -275,34 +466,8 @@
|
||||||
|
|
||||||
iworlddataserver.c(true);
|
iworlddataserver.c(true);
|
||||||
}
|
}
|
||||||
@ -383,7 +382,7 @@
|
|||||||
|
|
||||||
private static void a(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1, boolean flag2) {
|
private static void a(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1, boolean flag2) {
|
||||||
ChunkGenerator chunkgenerator = worldserver.getChunkProvider().getChunkGenerator();
|
ChunkGenerator chunkgenerator = worldserver.getChunkProvider().getChunkGenerator();
|
||||||
@@ -317,6 +483,21 @@
|
@@ -317,6 +482,21 @@
|
||||||
Random random = new Random(worldserver.getSeed());
|
Random random = new Random(worldserver.getSeed());
|
||||||
BlockPosition blockposition = worldchunkmanager.a(0, worldserver.getSeaLevel(), 0, 256, list, random);
|
BlockPosition blockposition = worldchunkmanager.a(0, worldserver.getSeaLevel(), 0, 256, list, random);
|
||||||
ChunkCoordIntPair chunkcoordintpair = blockposition == null ? new ChunkCoordIntPair(0, 0) : new ChunkCoordIntPair(blockposition);
|
ChunkCoordIntPair chunkcoordintpair = blockposition == null ? new ChunkCoordIntPair(0, 0) : new ChunkCoordIntPair(blockposition);
|
||||||
@ -405,7 +404,7 @@
|
|||||||
|
|
||||||
if (blockposition == null) {
|
if (blockposition == null) {
|
||||||
MinecraftServer.LOGGER.warn("Unable to find spawn biome");
|
MinecraftServer.LOGGER.warn("Unable to find spawn biome");
|
||||||
@@ -363,7 +544,7 @@
|
@@ -363,7 +543,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
@ -414,7 +413,7 @@
|
|||||||
|
|
||||||
worldgenfeatureconfigured.a(worldserver, worldserver.getStructureManager(), chunkgenerator, worldserver.random, new BlockPosition(iworlddataserver.a(), iworlddataserver.b(), iworlddataserver.c()));
|
worldgenfeatureconfigured.a(worldserver, worldserver.getStructureManager(), chunkgenerator, worldserver.random, new BlockPosition(iworlddataserver.a(), iworlddataserver.b(), iworlddataserver.c()));
|
||||||
}
|
}
|
||||||
@@ -383,8 +564,15 @@
|
@@ -383,8 +563,15 @@
|
||||||
iworlddataserver.setGameType(EnumGamemode.SPECTATOR);
|
iworlddataserver.setGameType(EnumGamemode.SPECTATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,7 +431,7 @@
|
|||||||
|
|
||||||
MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.getDimensionKey().a());
|
MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.getDimensionKey().a());
|
||||||
BlockPosition blockposition = worldserver.getSpawn();
|
BlockPosition blockposition = worldserver.getSpawn();
|
||||||
@@ -397,17 +585,21 @@
|
@@ -397,17 +584,21 @@
|
||||||
chunkproviderserver.addTicket(TicketType.START, new ChunkCoordIntPair(blockposition), 11, Unit.INSTANCE);
|
chunkproviderserver.addTicket(TicketType.START, new ChunkCoordIntPair(blockposition), 11, Unit.INSTANCE);
|
||||||
|
|
||||||
while (chunkproviderserver.b() != 441) {
|
while (chunkproviderserver.b() != 441) {
|
||||||
@ -463,7 +462,7 @@
|
|||||||
|
|
||||||
if (forcedchunk != null) {
|
if (forcedchunk != null) {
|
||||||
LongIterator longiterator = forcedchunk.a().iterator();
|
LongIterator longiterator = forcedchunk.a().iterator();
|
||||||
@@ -421,11 +613,17 @@
|
@@ -421,11 +612,17 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,7 +482,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void loadResourcesZip() {
|
protected void loadResourcesZip() {
|
||||||
@@ -470,12 +668,16 @@
|
@@ -470,12 +667,16 @@
|
||||||
worldserver.save((IProgressUpdate) null, flag1, worldserver.savingDisabled && !flag2);
|
worldserver.save((IProgressUpdate) null, flag1, worldserver.savingDisabled && !flag2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,7 +499,7 @@
|
|||||||
return flag3;
|
return flag3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -484,8 +686,29 @@
|
@@ -484,8 +685,29 @@
|
||||||
this.stop();
|
this.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,7 +529,7 @@
|
|||||||
if (this.getServerConnection() != null) {
|
if (this.getServerConnection() != null) {
|
||||||
this.getServerConnection().b();
|
this.getServerConnection().b();
|
||||||
}
|
}
|
||||||
@@ -494,6 +717,7 @@
|
@@ -494,6 +716,7 @@
|
||||||
MinecraftServer.LOGGER.info("Saving players");
|
MinecraftServer.LOGGER.info("Saving players");
|
||||||
this.playerList.savePlayers();
|
this.playerList.savePlayers();
|
||||||
this.playerList.shutdown();
|
this.playerList.shutdown();
|
||||||
@ -538,7 +537,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
MinecraftServer.LOGGER.info("Saving worlds");
|
MinecraftServer.LOGGER.info("Saving worlds");
|
||||||
@@ -571,14 +795,16 @@
|
@@ -571,14 +794,16 @@
|
||||||
while (this.isRunning) {
|
while (this.isRunning) {
|
||||||
long i = SystemUtils.getMonotonicMillis() - this.nextTick;
|
long i = SystemUtils.getMonotonicMillis() - this.nextTick;
|
||||||
|
|
||||||
@ -556,7 +555,7 @@
|
|||||||
this.nextTick += 50L;
|
this.nextTick += 50L;
|
||||||
GameProfilerTick gameprofilertick = GameProfilerTick.a("Server");
|
GameProfilerTick gameprofilertick = GameProfilerTick.a("Server");
|
||||||
|
|
||||||
@@ -624,6 +850,12 @@
|
@@ -624,6 +849,12 @@
|
||||||
} catch (Throwable throwable1) {
|
} catch (Throwable throwable1) {
|
||||||
MinecraftServer.LOGGER.error("Exception stopping the server", throwable1);
|
MinecraftServer.LOGGER.error("Exception stopping the server", throwable1);
|
||||||
} finally {
|
} finally {
|
||||||
@ -569,7 +568,7 @@
|
|||||||
this.exit();
|
this.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -632,8 +864,15 @@
|
@@ -632,8 +863,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canSleepForTick() {
|
private boolean canSleepForTick() {
|
||||||
@ -586,7 +585,7 @@
|
|||||||
|
|
||||||
protected void sleepForTick() {
|
protected void sleepForTick() {
|
||||||
this.executeAll();
|
this.executeAll();
|
||||||
@@ -739,7 +978,7 @@
|
@@ -739,7 +977,7 @@
|
||||||
this.serverPing.b().a(agameprofile);
|
this.serverPing.b().a(agameprofile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -595,7 +594,7 @@
|
|||||||
MinecraftServer.LOGGER.debug("Autosave started");
|
MinecraftServer.LOGGER.debug("Autosave started");
|
||||||
this.methodProfiler.enter("save");
|
this.methodProfiler.enter("save");
|
||||||
this.playerList.savePlayers();
|
this.playerList.savePlayers();
|
||||||
@@ -769,22 +1008,39 @@
|
@@ -769,22 +1007,39 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void b(BooleanSupplier booleansupplier) {
|
protected void b(BooleanSupplier booleansupplier) {
|
||||||
@ -635,7 +634,7 @@
|
|||||||
|
|
||||||
this.methodProfiler.enter("tick");
|
this.methodProfiler.enter("tick");
|
||||||
|
|
||||||
@@ -868,7 +1124,7 @@
|
@@ -868,7 +1123,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getServerModName() {
|
public String getServerModName() {
|
||||||
@ -644,7 +643,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CrashReport b(CrashReport crashreport) {
|
public CrashReport b(CrashReport crashreport) {
|
||||||
@@ -1217,11 +1473,11 @@
|
@@ -1217,11 +1472,11 @@
|
||||||
|
|
||||||
public CompletableFuture<Void> a(Collection<String> collection) {
|
public CompletableFuture<Void> a(Collection<String> collection) {
|
||||||
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
|
||||||
@ -658,7 +657,7 @@
|
|||||||
}, this).thenCompose((immutablelist) -> {
|
}, this).thenCompose((immutablelist) -> {
|
||||||
return DataPackResources.a(immutablelist, this.j() ? CommandDispatcher.ServerType.DEDICATED : CommandDispatcher.ServerType.INTEGRATED, this.h(), this.executorService, this);
|
return DataPackResources.a(immutablelist, this.j() ? CommandDispatcher.ServerType.DEDICATED : CommandDispatcher.ServerType.INTEGRATED, this.h(), this.executorService, this);
|
||||||
}).thenAcceptAsync((datapackresources) -> {
|
}).thenAcceptAsync((datapackresources) -> {
|
||||||
@@ -1592,6 +1848,22 @@
|
@@ -1592,6 +1847,22 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ import net.minecraft.server.MinecraftServer;
|
|||||||
import net.minecraft.server.MojangsonParser;
|
import net.minecraft.server.MojangsonParser;
|
||||||
import net.minecraft.server.NBTBase;
|
import net.minecraft.server.NBTBase;
|
||||||
import net.minecraft.server.NBTTagCompound;
|
import net.minecraft.server.NBTTagCompound;
|
||||||
|
import net.minecraft.server.SavedFile;
|
||||||
import net.minecraft.server.SharedConstants;
|
import net.minecraft.server.SharedConstants;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -220,6 +221,10 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
|||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static File getBukkitDataPackFolder() {
|
||||||
|
return new File(MinecraftServer.getServer().a(SavedFile.DATAPACKS).toFile(), "bukkit");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Advancement loadAdvancement(NamespacedKey key, String advancement) {
|
public Advancement loadAdvancement(NamespacedKey key, String advancement) {
|
||||||
if (Bukkit.getAdvancement(key) != null) {
|
if (Bukkit.getAdvancement(key) != null) {
|
||||||
@ -232,7 +237,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
|||||||
Advancement bukkit = Bukkit.getAdvancement(key);
|
Advancement bukkit = Bukkit.getAdvancement(key);
|
||||||
|
|
||||||
if (bukkit != null) {
|
if (bukkit != null) {
|
||||||
File file = new File(MinecraftServer.getServer().bukkitDataPackFolder, "data" + File.separator + key.getNamespace() + File.separator + "advancements" + File.separator + key.getKey() + ".json");
|
File file = new File(getBukkitDataPackFolder(), "data" + File.separator + key.getNamespace() + File.separator + "advancements" + File.separator + key.getKey() + ".json");
|
||||||
file.getParentFile().mkdirs();
|
file.getParentFile().mkdirs();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -252,7 +257,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeAdvancement(NamespacedKey key) {
|
public boolean removeAdvancement(NamespacedKey key) {
|
||||||
File file = new File(MinecraftServer.getServer().bukkitDataPackFolder, "data" + File.separator + key.getNamespace() + File.separator + "advancements" + File.separator + key.getKey() + ".json");
|
File file = new File(getBukkitDataPackFolder(), "data" + File.separator + key.getNamespace() + File.separator + "advancements" + File.separator + key.getKey() + ".json");
|
||||||
return file.delete();
|
return file.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user