net.minecraft.server.packs(.repository)

This commit is contained in:
Noah van der Aa 2024-12-14 17:39:31 +01:00
parent 68961d9f5e
commit 3efd1caa64
No known key found for this signature in database
GPG key ID: 547D90BC6FF753CF
3 changed files with 14 additions and 14 deletions

View file

@ -1,11 +1,11 @@
--- a/net/minecraft/server/packs/PathPackResources.java
+++ b/net/minecraft/server/packs/PathPackResources.java
@@ -103,6 +103,12 @@
@@ -103,6 +_,12 @@
try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(path)) {
for (Path path2 : directoryStream) {
String string = path2.getFileName().toString();
for (Path path1 : directoryStream) {
String string = path1.getFileName().toString();
+ // Paper start - Improve logging and errors
+ if (!Files.isDirectory(path2)) {
+ if (!Files.isDirectory(path1)) {
+ LOGGER.error("Invalid directory entry: {} in {}.", string, this.root, new java.nio.file.NotDirectoryException(string));
+ continue;
+ }

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/server/packs/VanillaPackResourcesBuilder.java
+++ b/net/minecraft/server/packs/VanillaPackResourcesBuilder.java
@@ -138,6 +138,15 @@
@@ -137,6 +_,15 @@
public VanillaPackResourcesBuilder applyDevelopmentConfig() {
developmentConfig.accept(this);

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/server/packs/repository/ServerPacksSource.java
+++ b/net/minecraft/server/packs/repository/ServerPacksSource.java
@@ -48,7 +48,7 @@
@@ -48,7 +_,7 @@
public static VanillaPackResources createVanillaPackSource() {
return new VanillaPackResourcesBuilder()
.setMetadata(BUILT_IN_METADATA)
@ -9,23 +9,23 @@
.applyDevelopmentConfig()
.pushJarResources()
.build(VANILLA_PACK_INFO);
@@ -68,7 +68,18 @@
@@ -68,7 +_,18 @@
@Nullable
@Override
protected Pack createBuiltinPack(String fileName, Pack.ResourcesSupplier packFactory, Component displayName) {
- return Pack.readMetaAndCreate(createBuiltInPackLocation(fileName, displayName), packFactory, PackType.SERVER_DATA, FEATURE_SELECTION_CONFIG);
protected Pack createBuiltinPack(String id, Pack.ResourcesSupplier resources, Component title) {
- return Pack.readMetaAndCreate(createBuiltInPackLocation(id, title), resources, PackType.SERVER_DATA, FEATURE_SELECTION_CONFIG);
+ // Paper start - custom built-in pack
+ final PackLocationInfo info;
+ final PackSelectionConfig packConfig;
+ if ("paper".equals(fileName)) {
+ info = new PackLocationInfo(fileName, displayName, PackSource.BUILT_IN, Optional.empty());
+ if ("paper".equals(id)) {
+ info = new PackLocationInfo(id, title, PackSource.BUILT_IN, Optional.empty());
+ packConfig = new PackSelectionConfig(true, Pack.Position.TOP, true);
+ } else {
+ info = createBuiltInPackLocation(fileName, displayName);
+ info = createBuiltInPackLocation(id, title);
+ packConfig = FEATURE_SELECTION_CONFIG;
+ }
+ return Pack.readMetaAndCreate(info, packFactory, PackType.SERVER_DATA, packConfig);
+ return Pack.readMetaAndCreate(info, resources, PackType.SERVER_DATA, packConfig);
+ // Paper end - custom built-in pack
}
public static PackRepository createPackRepository(Path dataPacksPath, DirectoryValidator symlinkFinder) {
public static PackRepository createPackRepository(Path folder, DirectoryValidator validator) {