9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00

Backport from ver/1.21.7

- Better warning message for discouraging Maven Central as CDN
- Fix infinite loop in dismount loc check
This commit is contained in:
Dreeam
2025-07-16 12:06:19 +08:00
parent dd196dd654
commit 61fb23646c
4 changed files with 48 additions and 33 deletions

View File

@@ -9,14 +9,10 @@ Original project: https://github.com/PaperMC/Paper
https://github.com/PaperMC/Paper/commit/62b7f86dae659deb2fc450285452d7c1439f92dc
Dreeam's Note:
We use soft warning which in Paper is directly exception throw,
Only print warning to avoid break plugins directly.
Also see `Configurable LibraryLoader maven repos` patch,
able to match googleapi mirror urls, to replace to repo url we custom defined.
This able to switch back to maven central repo, to prevent
situation that dependencies exist in maven central, but not in mirror.
---
Default LibraryLoader to Google's Maven Central mirror, add MavenLibraryResolver.MAVEN_CENTRAL_DEFAULT_MIRROR, and warn on use of Maven Central with MavenLibraryResolver
@@ -24,7 +20,7 @@ https://www.sonatype.com/blog/maven-central-and-the-tragedy-of-the-commons
https://www.sonatype.com/blog/beyond-ips-addressing-organizational-overconsumption-in-maven-central
diff --git a/src/main/java/io/papermc/paper/plugin/loader/library/impl/MavenLibraryResolver.java b/src/main/java/io/papermc/paper/plugin/loader/library/impl/MavenLibraryResolver.java
index 107705db2d82b7c191e5e625ec888e0bc3b03831..f12c25f35f3d26dc69e05c7965385e66a3d3d545 100644
index 107705db2d82b7c191e5e625ec888e0bc3b03831..0f26a192b709cbcda83fad0a0a78f87dbb9e701e 100644
--- a/src/main/java/io/papermc/paper/plugin/loader/library/impl/MavenLibraryResolver.java
+++ b/src/main/java/io/papermc/paper/plugin/loader/library/impl/MavenLibraryResolver.java
@@ -41,7 +41,7 @@ import org.slf4j.LoggerFactory;
@@ -61,23 +57,22 @@ index 107705db2d82b7c191e5e625ec888e0bc3b03831..f12c25f35f3d26dc69e05c7965385e66
private static final Logger LOGGER = LoggerFactory.getLogger("MavenLibraryResolver");
private final RepositorySystem repository;
@@ -105,6 +123,15 @@ public class MavenLibraryResolver implements ClassPathLibrary {
@@ -105,6 +123,14 @@ public class MavenLibraryResolver implements ClassPathLibrary {
* dependencies from
*/
public void addRepository(final RemoteRepository remoteRepository) {
+ // Paper start - Avoid and discourage use of Maven Central as a CDN
+ if (MAVEN_CENTRAL_URLS.stream().anyMatch(remoteRepository.getUrl()::startsWith)) {
+ try {
+ throw new RuntimeException("Plugin used Maven Central for library resolution");
+ } catch (RuntimeException e) {
+ LOGGER.error("Use of Maven Central as a CDN is against the Maven Central Terms of Service. Use MavenLibraryResolver.MAVEN_CENTRAL_DEFAULT_MIRROR instead.", e);
+ }
+ LOGGER.warn(
+ "Use of Maven Central as a CDN is against the Maven Central Terms of Service. Use MavenLibraryResolver.MAVEN_CENTRAL_DEFAULT_MIRROR instead. DO NOT report it to Paper or Leaf! Please contact plugin's support to adapt this change.", // Leaf - Better warning message for discouraging Maven Central as CDN
+ new RuntimeException("Plugin used Maven Central for library resolution")
+ );
+ }
+ // Paper end - Avoid and discourage use of Maven Central as a CDN
this.repositories.add(remoteRepository);
}
@@ -130,4 +157,17 @@ public class MavenLibraryResolver implements ClassPathLibrary {
@@ -130,4 +156,17 @@ public class MavenLibraryResolver implements ClassPathLibrary {
store.addLibrary(file.toPath());
}
}

View File

@@ -7,7 +7,7 @@ Add JVM flag `-DLeaf.library-download-repo=link` to choose library download repo
e.g. `-DLeaf.library-download-repo=https://maven.aliyun.com/repository/public`
diff --git a/src/main/java/io/papermc/paper/plugin/loader/library/impl/MavenLibraryResolver.java b/src/main/java/io/papermc/paper/plugin/loader/library/impl/MavenLibraryResolver.java
index f12c25f35f3d26dc69e05c7965385e66a3d3d545..768b60e13435dc8eca6fc343081a663a37a6d0e7 100644
index 0f26a192b709cbcda83fad0a0a78f87dbb9e701e..b0e20089283b2fb3fa0c65f96e1f6bd6634712e9 100644
--- a/src/main/java/io/papermc/paper/plugin/loader/library/impl/MavenLibraryResolver.java
+++ b/src/main/java/io/papermc/paper/plugin/loader/library/impl/MavenLibraryResolver.java
@@ -60,12 +60,25 @@ public class MavenLibraryResolver implements ClassPathLibrary {
@@ -38,29 +38,26 @@ index f12c25f35f3d26dc69e05c7965385e66a3d3d545..768b60e13435dc8eca6fc343081a663a
// Paper end - Avoid and discourage use of Maven Central as a CDN
private static final Logger LOGGER = LoggerFactory.getLogger("MavenLibraryResolver");
@@ -124,13 +137,32 @@ public class MavenLibraryResolver implements ClassPathLibrary {
@@ -124,12 +137,33 @@ public class MavenLibraryResolver implements ClassPathLibrary {
*/
public void addRepository(final RemoteRepository remoteRepository) {
// Paper start - Avoid and discourage use of Maven Central as a CDN
- if (MAVEN_CENTRAL_URLS.stream().anyMatch(remoteRepository.getUrl()::startsWith)) {
- try {
- throw new RuntimeException("Plugin used Maven Central for library resolution");
- } catch (RuntimeException e) {
- LOGGER.error("Use of Maven Central as a CDN is against the Maven Central Terms of Service. Use MavenLibraryResolver.MAVEN_CENTRAL_DEFAULT_MIRROR instead.", e);
+ // Leaf start - Configurable LibraryLoader maven repos
+ for (String url : MAVEN_CENTRAL_URLS) {
+ if (remoteRepository.getUrl().startsWith(url)) {
+ RemoteRepository mirrorRepo = CUSTOM_MAVEN_CENTRAL_MIRROR_REPO;
+ if (mirrorRepo != null) {
+ this.repositories.add(mirrorRepo);
+ return;
+ }
+ try {
+ throw new RuntimeException("Plugin used Maven Central for library resolution");
+ } catch (RuntimeException e) {
+ LOGGER.error("Use of Maven Central as a CDN is against the Maven Central Terms of Service. Use MavenLibraryResolver.MAVEN_CENTRAL_DEFAULT_MIRROR instead.", e);
+ }
+ }
+ for (String url : MAVEN_CENTRAL_URLS) {
+ if (remoteRepository.getUrl().startsWith(url)) {
+ RemoteRepository mirrorRepo = CUSTOM_MAVEN_CENTRAL_MIRROR_REPO;
+ if (mirrorRepo != null) {
+ this.repositories.add(mirrorRepo);
+ return;
+ }
+ // Leaf end - Configurable LibraryLoader maven repos
LOGGER.warn(
"Use of Maven Central as a CDN is against the Maven Central Terms of Service. Use MavenLibraryResolver.MAVEN_CENTRAL_DEFAULT_MIRROR instead. DO NOT report it to Paper or Leaf! Please contact plugin's support to adapt this change.", // Leaf - Better warning message for discouraging Maven Central as CDN
new RuntimeException("Plugin used Maven Central for library resolution")
);
+ // Leaf start - Configurable LibraryLoader maven repos
+ }
+ }
+ // Match google api maven central mirror urls
+ for (String url : MAVEN_CENTRAL_GOOGLE_MIRROR_URLS) {
@@ -70,13 +67,13 @@ index f12c25f35f3d26dc69e05c7965385e66a3d3d545..768b60e13435dc8eca6fc343081a663a
+ this.repositories.add(mirrorRepo);
+ return;
+ }
}
+ }
}
+ // Leaf end - Configurable LibraryLoader maven repos
// Paper end - Avoid and discourage use of Maven Central as a CDN
this.repositories.add(remoteRepository);
}
@@ -170,4 +202,15 @@ public class MavenLibraryResolver implements ClassPathLibrary {
@@ -169,4 +203,15 @@ public class MavenLibraryResolver implements ClassPathLibrary {
return central;
}
// Paper end - Avoid and discourage use of Maven Central as a CDN

View File

@@ -3,6 +3,7 @@ From: Taiyou06 <kaandindar21@gmail.com>
Date: Sun, 16 Feb 2025 01:13:04 +0100
Subject: [PATCH] count all chunks for ticking
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
index e07fdd22e08cb4e30cf606c055e85b5946e8c046..432c98b582ab40f893835a7a24ef9bbdacc49bd7 100644
--- a/net/minecraft/server/level/ServerChunkCache.java

View File

@@ -0,0 +1,22 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Date: Fri, 11 Jul 2025 06:10:41 +0800
Subject: [PATCH] Fix infinite loop in dismount loc check
Very fun VineFlower decompile issue.
Invert the condition to prevent infinite loop
diff --git a/net/minecraft/world/entity/animal/horse/AbstractHorse.java b/net/minecraft/world/entity/animal/horse/AbstractHorse.java
index 56dc7011ed07f0bd5870fbadde2b5c0c630c5edd..c2c14958254df77b9b18c6f4a0ea5e68fc79d44e 100644
--- a/net/minecraft/world/entity/animal/horse/AbstractHorse.java
+++ b/net/minecraft/world/entity/animal/horse/AbstractHorse.java
@@ -1223,7 +1223,7 @@ public abstract class AbstractHorse extends Animal implements ContainerListener,
}
mutableBlockPos.move(Direction.UP);
- } while (!(mutableBlockPos.getY() < d3));
+ } while (mutableBlockPos.getY() < d3); // Leaf - Fix infinite loop in dismount loc check
}
return null;