mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
Update changes from ver/1.21.4 branch
This commit is contained in:
@@ -0,0 +1,122 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
||||||
|
Date: Wed, 18 Jun 2025 10:47:21 -0700
|
||||||
|
Subject: [PATCH] Paper: Avoid and discourage use of Maven Central as a CDN
|
||||||
|
|
||||||
|
Original license: GPLv3
|
||||||
|
Original project: https://github.com/PaperMC/Paper
|
||||||
|
|
||||||
|
https://github.com/PaperMC/Paper/commit/62b7f86dae659deb2fc450285452d7c1439f92dc
|
||||||
|
|
||||||
|
Default LibraryLoader to Google's Maven Central mirror, add MavenLibraryResolver.MAVEN_CENTRAL_DEFAULT_MIRROR, and warn on use of Maven Central with MavenLibraryResolver
|
||||||
|
|
||||||
|
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..ebb52c2c8d5fe8ca25513aadae8168180a3d426e 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;
|
||||||
|
* MavenLibraryResolver resolver = new MavenLibraryResolver();
|
||||||
|
* resolver.addDependency(new Dependency(new DefaultArtifact("org.jooq:jooq:3.17.7"), null));
|
||||||
|
* resolver.addRepository(new RemoteRepository.Builder(
|
||||||
|
- * "central", "default", "https://repo1.maven.org/maven2/"
|
||||||
|
+ * "central", "default", MavenLibraryResolver.MAVEN_CENTRAL_DEFAULT_MIRROR // Paper - Avoid and discourage use of Maven Central as a CDN
|
||||||
|
* ).build());
|
||||||
|
* }</pre>
|
||||||
|
* <p>
|
||||||
|
@@ -50,6 +50,24 @@ import org.slf4j.LoggerFactory;
|
||||||
|
@NullMarked
|
||||||
|
public class MavenLibraryResolver implements ClassPathLibrary {
|
||||||
|
|
||||||
|
+ // Paper start - Avoid and discourage use of Maven Central as a CDN
|
||||||
|
+ /**
|
||||||
|
+ * The default Maven Central mirror, configurable through the {@code PAPER_DEFAULT_CENTRAL_REPOSITORY} environment
|
||||||
|
+ * variable. Use this instead of Maven Central directly when you do not have your own mirror, as using
|
||||||
|
+ * Maven Central as a CDN is against the Maven Central Terms of Service, and you will cause users to hit
|
||||||
|
+ * rate limits.
|
||||||
|
+ *
|
||||||
|
+ * <p>This repository is also used by the legacy {@link org.bukkit.plugin.java.LibraryLoader}.</p>
|
||||||
|
+ */
|
||||||
|
+ public static final String MAVEN_CENTRAL_DEFAULT_MIRROR = getDefaultMavenCentralMirror();
|
||||||
|
+ private static final List<String> MAVEN_CENTRAL_URLS = List.of(
|
||||||
|
+ "https://repo1.maven.org/maven2",
|
||||||
|
+ "http://repo1.maven.org/maven2",
|
||||||
|
+ "https://repo.maven.apache.org/maven2",
|
||||||
|
+ "http://repo.maven.apache.org/maven2"
|
||||||
|
+ );
|
||||||
|
+ // Paper end - Avoid and discourage use of Maven Central as a CDN
|
||||||
|
+
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger("MavenLibraryResolver");
|
||||||
|
|
||||||
|
private final RepositorySystem repository;
|
||||||
|
@@ -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)) {
|
||||||
|
+ LOGGER.warn(
|
||||||
|
+ "Use of Maven Central as a CDN is against the Maven Central Terms of Service. Use MavenLibraryResolver.MAVEN_CENTRAL_DEFAULT_MIRROR instead.",
|
||||||
|
+ 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 +156,17 @@ public class MavenLibraryResolver implements ClassPathLibrary {
|
||||||
|
store.addLibrary(file.toPath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ // Paper start - Avoid and discourage use of Maven Central as a CDN
|
||||||
|
+ private static String getDefaultMavenCentralMirror() {
|
||||||
|
+ String central = System.getenv("PAPER_DEFAULT_CENTRAL_REPOSITORY");
|
||||||
|
+ if (central == null) {
|
||||||
|
+ central = System.getProperty("org.bukkit.plugin.java.LibraryLoader.centralURL");
|
||||||
|
+ }
|
||||||
|
+ if (central == null) {
|
||||||
|
+ central = "https://maven-central.storage-download.googleapis.com/maven2";
|
||||||
|
+ }
|
||||||
|
+ return central;
|
||||||
|
+ }
|
||||||
|
+ // Paper end - Avoid and discourage use of Maven Central as a CDN
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/bukkit/plugin/java/LibraryLoader.java b/src/main/java/org/bukkit/plugin/java/LibraryLoader.java
|
||||||
|
index 7e4e702845f61703f0741add59f7cfc0afea1543..012ba8ee3d84a7bb09068e42fd1bae8ad221622e 100644
|
||||||
|
--- a/src/main/java/org/bukkit/plugin/java/LibraryLoader.java
|
||||||
|
+++ b/src/main/java/org/bukkit/plugin/java/LibraryLoader.java
|
||||||
|
@@ -47,19 +47,11 @@ public class LibraryLoader {
|
||||||
|
public static java.util.function.BiFunction<URL[], ClassLoader, URLClassLoader> LIBRARY_LOADER_FACTORY; // Paper - rewrite reflection in libraries
|
||||||
|
public static java.util.function.Function<List<java.nio.file.Path>, List<java.nio.file.Path>> REMAPPER; // Paper - remap libraries
|
||||||
|
|
||||||
|
- // TODO: Consider moving this and adding per plugin support for defining repositories
|
||||||
|
+ // Paper start - Avoid and discourage use of Maven Central as a CDN
|
||||||
|
private static List<RemoteRepository> getRepositories() {
|
||||||
|
- String central = System.getenv("PAPER_DEFAULT_CENTRAL_REPOSITORY");
|
||||||
|
- if (central == null) {
|
||||||
|
- central = System.getProperty("org.bukkit.plugin.java.LibraryLoader.centralURL");
|
||||||
|
- }
|
||||||
|
- if (central == null) {
|
||||||
|
- central = "https://repo.maven.apache.org/maven2";
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- return Arrays.asList(new RemoteRepository.Builder("central", "default", central).build());
|
||||||
|
-
|
||||||
|
+ return List.of(new RemoteRepository.Builder("central", "default", io.papermc.paper.plugin.loader.library.impl.MavenLibraryResolver.MAVEN_CENTRAL_DEFAULT_MIRROR).build());
|
||||||
|
}
|
||||||
|
+ // Paper end - Avoid and discourage use of Maven Central as a CDN
|
||||||
|
|
||||||
|
public LibraryLoader(@NotNull Logger logger) {
|
||||||
|
this.logger = logger;
|
||||||
|
@@ -87,7 +79,7 @@ public class LibraryLoader {
|
||||||
|
session.setSystemProperties(System.getProperties());
|
||||||
|
session.setReadOnly();
|
||||||
|
|
||||||
|
- this.repositories = repository.newResolutionRepositories(session, getRepositories());
|
||||||
|
+ this.repositories = repository.newResolutionRepositories(session, getRepositories()); // Paper - Avoid and discourage use of Maven Central as a CDN
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
@@ -55,10 +55,10 @@ index 163e9a0e179dc88be93614ff66ee2be3eccc694f..539786355ac89b5eb8ad876e65662e84
|
|||||||
* This class was not meant to be constructed explicitly
|
* This class was not meant to be constructed explicitly
|
||||||
*
|
*
|
||||||
diff --git a/src/main/java/org/bukkit/plugin/java/LibraryLoader.java b/src/main/java/org/bukkit/plugin/java/LibraryLoader.java
|
diff --git a/src/main/java/org/bukkit/plugin/java/LibraryLoader.java b/src/main/java/org/bukkit/plugin/java/LibraryLoader.java
|
||||||
index 7e4e702845f61703f0741add59f7cfc0afea1543..23e3fcc8c2d6e0555448295199eee186de619042 100644
|
index 012ba8ee3d84a7bb09068e42fd1bae8ad221622e..1f2e86e9a830b990bbba3704889671465816ea1c 100644
|
||||||
--- a/src/main/java/org/bukkit/plugin/java/LibraryLoader.java
|
--- a/src/main/java/org/bukkit/plugin/java/LibraryLoader.java
|
||||||
+++ b/src/main/java/org/bukkit/plugin/java/LibraryLoader.java
|
+++ b/src/main/java/org/bukkit/plugin/java/LibraryLoader.java
|
||||||
@@ -77,6 +77,7 @@ public class LibraryLoader {
|
@@ -69,6 +69,7 @@ public class LibraryLoader {
|
||||||
session.setTransferListener(new AbstractTransferListener() {
|
session.setTransferListener(new AbstractTransferListener() {
|
||||||
@Override
|
@Override
|
||||||
public void transferStarted(@NotNull TransferEvent event) {
|
public void transferStarted(@NotNull TransferEvent event) {
|
||||||
@@ -66,7 +66,7 @@ index 7e4e702845f61703f0741add59f7cfc0afea1543..23e3fcc8c2d6e0555448295199eee186
|
|||||||
logger.log(Level.INFO, "Downloading {0}", event.getResource().getRepositoryUrl() + event.getResource().getResourceName());
|
logger.log(Level.INFO, "Downloading {0}", event.getResource().getRepositoryUrl() + event.getResource().getResourceName());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -102,6 +103,7 @@ public class LibraryLoader {
|
@@ -94,6 +95,7 @@ public class LibraryLoader {
|
||||||
// Paper end - plugin loader api
|
// Paper end - plugin loader api
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,7 @@ index 7e4e702845f61703f0741add59f7cfc0afea1543..23e3fcc8c2d6e0555448295199eee186
|
|||||||
logger.log(Level.INFO, "[{0}] Loading {1} libraries... please wait", new Object[]
|
logger.log(Level.INFO, "[{0}] Loading {1} libraries... please wait", new Object[]
|
||||||
{
|
{
|
||||||
java.util.Objects.requireNonNullElseGet(desc.getPrefix(), desc::getName), desc.getLibraries().size() // Paper - use configured log prefix
|
java.util.Objects.requireNonNullElseGet(desc.getPrefix(), desc::getName), desc.getLibraries().size() // Paper - use configured log prefix
|
||||||
@@ -154,6 +156,7 @@ public class LibraryLoader {
|
@@ -146,6 +148,7 @@ public class LibraryLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
jarFiles.add(url);
|
jarFiles.add(url);
|
||||||
@@ -37,7 +37,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||||
index ac341838b6a2d2600eec8ae26791346f65ac93ae..28a3224c32e1890c95d540080fc5c04bc930a1e9 100644
|
index d34419693fc78b3f7e8f6bbf115f17f29e5e3377..c44453789834c544b0e78b52bb9b09ffbd5958fb 100644
|
||||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||||
@@ -2129,6 +2129,16 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
@@ -2129,6 +2129,16 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
|
||||||
Date: Sat, 3 Feb 2024 18:45:53 -0500
|
|
||||||
Subject: [PATCH] Configurable LibraryLoader maven repos
|
|
||||||
|
|
||||||
TODO - Dreeam: Support multi maven repos for lib downloading.
|
|
||||||
|
|
||||||
Add JVM flag `-DLeaf.library-download-repo=link` to choose library download repo link.
|
|
||||||
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 107705db2d82b7c191e5e625ec888e0bc3b03831..77a58fc7c173b1724d44b0eeaf23b4a1b22b5fcb 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
|
|
||||||
@@ -105,7 +105,7 @@ public class MavenLibraryResolver implements ClassPathLibrary {
|
|
||||||
* dependencies from
|
|
||||||
*/
|
|
||||||
public void addRepository(final RemoteRepository remoteRepository) {
|
|
||||||
- this.repositories.add(remoteRepository);
|
|
||||||
+ this.repositories.add(org.dreeam.leaf.plugin.loader.MavenCentralMirror.getCentralRepo(remoteRepository)); // Leaf - Configurable LibraryLoader maven repos
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
diff --git a/src/main/java/org/bukkit/plugin/java/LibraryLoader.java b/src/main/java/org/bukkit/plugin/java/LibraryLoader.java
|
|
||||||
index 23e3fcc8c2d6e0555448295199eee186de619042..502c51b3ae0a05569540c09b4c51dad1438da36e 100644
|
|
||||||
--- a/src/main/java/org/bukkit/plugin/java/LibraryLoader.java
|
|
||||||
+++ b/src/main/java/org/bukkit/plugin/java/LibraryLoader.java
|
|
||||||
@@ -88,7 +88,19 @@ public class LibraryLoader {
|
|
||||||
session.setSystemProperties(System.getProperties());
|
|
||||||
session.setReadOnly();
|
|
||||||
|
|
||||||
- this.repositories = repository.newResolutionRepositories(session, getRepositories());
|
|
||||||
+ // Leaf start - Configurable LibraryLoader maven repos
|
|
||||||
+ this.repositories = repository.newResolutionRepositories(
|
|
||||||
+ session,
|
|
||||||
+ List.of(org.dreeam.leaf.plugin.loader.MavenCentralMirror.getCentralRepo("https://repo.maven.apache.org/maven2"))
|
|
||||||
+ );
|
|
||||||
+ /* // Dreeam TODO
|
|
||||||
+ this.repositories = repository.newResolutionRepositories(session, List.of(
|
|
||||||
+ new RemoteRepository.Builder("central", "default", "https://repo.maven.apache.org/maven2").build(),
|
|
||||||
+ new RemoteRepository.Builder("aliyun", "default", "https://maven.aliyun.com/repository/public").build(),
|
|
||||||
+ new RemoteRepository.Builder("tencentclound", "default", "https://mirrors.cloud.tencent.com/nexus/repository/maven-public/").build(),
|
|
||||||
+ new RemoteRepository.Builder("huaweicloud", "default", "https://repo.huaweicloud.com/repository/maven/").build()
|
|
||||||
+ ));*/
|
|
||||||
+ // Leaf end - Configurable LibraryLoader maven repos
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
diff --git a/src/main/java/org/dreeam/leaf/plugin/loader/MavenCentralMirror.java b/src/main/java/org/dreeam/leaf/plugin/loader/MavenCentralMirror.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..95534cb6d771a0fe288e7c843c41b0036bdc7095
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/org/dreeam/leaf/plugin/loader/MavenCentralMirror.java
|
|
||||||
@@ -0,0 +1,24 @@
|
|
||||||
+package org.dreeam.leaf.plugin.loader;
|
|
||||||
+
|
|
||||||
+import org.eclipse.aether.repository.RemoteRepository;
|
|
||||||
+
|
|
||||||
+public class MavenCentralMirror {
|
|
||||||
+
|
|
||||||
+ public static final String MAVEN_CENTRAL_MIRROR_REPO = System.getProperty("Leaf.library-download-repo");
|
|
||||||
+
|
|
||||||
+ public static RemoteRepository getCentralRepo(RemoteRepository repo) {
|
|
||||||
+ if (MAVEN_CENTRAL_MIRROR_REPO != null && repo.getUrl().contains("repo.maven.apache.org/maven2")) {
|
|
||||||
+ repo = new RemoteRepository.Builder("central", "default", MAVEN_CENTRAL_MIRROR_REPO).build();
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return repo;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public static RemoteRepository getCentralRepo(String repo) {
|
|
||||||
+ if (MAVEN_CENTRAL_MIRROR_REPO != null) {
|
|
||||||
+ repo = MAVEN_CENTRAL_MIRROR_REPO;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return new RemoteRepository.Builder("central", "default", repo).build();
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||||
|
Date: Sat, 3 Feb 2024 18:45:53 -0500
|
||||||
|
Subject: [PATCH] Configurable LibraryLoader maven repos
|
||||||
|
|
||||||
|
Add JVM flag `-DLeaf.library-download-repo=link` to choose library download repo link.
|
||||||
|
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 ebb52c2c8d5fe8ca25513aadae8168180a3d426e..006a86da6afa1b7b80df5df073ebd236e27cd2b5 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,16 @@ public class MavenLibraryResolver implements ClassPathLibrary {
|
||||||
|
* <p>This repository is also used by the legacy {@link org.bukkit.plugin.java.LibraryLoader}.</p>
|
||||||
|
*/
|
||||||
|
public static final String MAVEN_CENTRAL_DEFAULT_MIRROR = getDefaultMavenCentralMirror();
|
||||||
|
- private static final List<String> MAVEN_CENTRAL_URLS = List.of(
|
||||||
|
+ // Leaf start - Configurable LibraryLoader maven repos
|
||||||
|
+ @org.jspecify.annotations.Nullable
|
||||||
|
+ public static final RemoteRepository MAVEN_CENTRAL_MIRROR_REPO = getCentralMirrorRepo();
|
||||||
|
+ private static final String[] MAVEN_CENTRAL_URLS = new String[]{
|
||||||
|
"https://repo1.maven.org/maven2",
|
||||||
|
"http://repo1.maven.org/maven2",
|
||||||
|
"https://repo.maven.apache.org/maven2",
|
||||||
|
"http://repo.maven.apache.org/maven2"
|
||||||
|
- );
|
||||||
|
+ };
|
||||||
|
+ // Leaf end - Configurable LibraryLoader maven repos
|
||||||
|
// Paper end - Avoid and discourage use of Maven Central as a CDN
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger("MavenLibraryResolver");
|
||||||
|
@@ -124,12 +128,21 @@ 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)) {
|
||||||
|
- LOGGER.warn(
|
||||||
|
- "Use of Maven Central as a CDN is against the Maven Central Terms of Service. Use MavenLibraryResolver.MAVEN_CENTRAL_DEFAULT_MIRROR instead.",
|
||||||
|
- new RuntimeException("Plugin used Maven Central for library resolution")
|
||||||
|
- );
|
||||||
|
+ // Leaf start - Configurable LibraryLoader maven repos
|
||||||
|
+ for (String url : MAVEN_CENTRAL_URLS) {
|
||||||
|
+ if (remoteRepository.getUrl().startsWith(url)) {
|
||||||
|
+ RemoteRepository mirrorRepo = MAVEN_CENTRAL_MIRROR_REPO;
|
||||||
|
+ if (mirrorRepo != null) {
|
||||||
|
+ this.repositories.add(mirrorRepo);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ LOGGER.warn(
|
||||||
|
+ "Use of Maven Central as a CDN is against the Maven Central Terms of Service. Use MavenLibraryResolver.MAVEN_CENTRAL_DEFAULT_MIRROR instead.",
|
||||||
|
+ new RuntimeException("Plugin used Maven Central for library resolution")
|
||||||
|
+ );
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
+ // Leaf end - Configurable LibraryLoader maven repos
|
||||||
|
// Paper end - Avoid and discourage use of Maven Central as a CDN
|
||||||
|
this.repositories.add(remoteRepository);
|
||||||
|
}
|
||||||
|
@@ -169,4 +182,15 @@ public class MavenLibraryResolver implements ClassPathLibrary {
|
||||||
|
return central;
|
||||||
|
}
|
||||||
|
// Paper end - Avoid and discourage use of Maven Central as a CDN
|
||||||
|
+
|
||||||
|
+ // Leaf start - Configurable LibraryLoader maven repos
|
||||||
|
+ @org.jspecify.annotations.Nullable
|
||||||
|
+ private static RemoteRepository getCentralMirrorRepo() {
|
||||||
|
+ String mirrorAddr = System.getProperty("Leaf.library-download-repo");
|
||||||
|
+ if (mirrorAddr != null) {
|
||||||
|
+ new RemoteRepository.Builder("central", "default", mirrorAddr).build();
|
||||||
|
+ }
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+ // Leaf end - Configurable LibraryLoader maven repos
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/bukkit/plugin/java/LibraryLoader.java b/src/main/java/org/bukkit/plugin/java/LibraryLoader.java
|
||||||
|
index 1f2e86e9a830b990bbba3704889671465816ea1c..a16da10e38889af3a5878a6273d2982c707e93d2 100644
|
||||||
|
--- a/src/main/java/org/bukkit/plugin/java/LibraryLoader.java
|
||||||
|
+++ b/src/main/java/org/bukkit/plugin/java/LibraryLoader.java
|
||||||
|
@@ -49,6 +49,7 @@ public class LibraryLoader {
|
||||||
|
|
||||||
|
// Paper start - Avoid and discourage use of Maven Central as a CDN
|
||||||
|
private static List<RemoteRepository> getRepositories() {
|
||||||
|
+ if (io.papermc.paper.plugin.loader.library.impl.MavenLibraryResolver.MAVEN_CENTRAL_MIRROR_REPO != null) return List.of(io.papermc.paper.plugin.loader.library.impl.MavenLibraryResolver.MAVEN_CENTRAL_MIRROR_REPO); // Leaf - Configurable LibraryLoader maven repos
|
||||||
|
return List.of(new RemoteRepository.Builder("central", "default", io.papermc.paper.plugin.loader.library.impl.MavenLibraryResolver.MAVEN_CENTRAL_DEFAULT_MIRROR).build());
|
||||||
|
}
|
||||||
|
// Paper end - Avoid and discourage use of Maven Central as a CDN
|
||||||
@@ -1,23 +1,16 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Leymooo <Vjatseslav.Maspanov@gmail.com>
|
From: AJ Ferguson <fergusonjva@gmail.com>
|
||||||
Date: Wed, 11 Jun 2025 05:30:39 +0300
|
Date: Mon, 6 Jan 2025 20:31:00 +1100
|
||||||
Subject: [PATCH] PaperPR: Fix excess slot updates / inventory state id desync
|
Subject: [PATCH] Paper: Fix excess slot updates
|
||||||
|
|
||||||
Original license: GPLv3
|
Original license: GPLv3
|
||||||
Original project: https://github.com/SparklyPower/SparklyPaper
|
Original project: https://github.com/PaperMC/Paper
|
||||||
Paper pull request: https://github.com/PaperMC/Paper/pull/12654
|
Paper pull request: https://github.com/PaperMC/Paper/pull/12654
|
||||||
|
|
||||||
Fixes inventory state id desync with high ping causing inventory to be "buggy" (ghost items, items jumping to/from cursor, etc)
|
https://github.com/PaperMC/Paper/commit/e714de636543d61fcd3682705484c8a15f4f3ca6
|
||||||
|
|
||||||
Without patch: https://youtu.be/hOXt3Rpkgtg
|
|
||||||
With patch: https://youtu.be/MtOYD7uieS4
|
|
||||||
|
|
||||||
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/df01cf867a2255024aacf9ac2ff6a56b2ffb7ce5#nms-patches/net/minecraft/world/inventory/Container.patch
|
|
||||||
|
|
||||||
https://discord.com/channels/289587909051416579/555462289851940864/1382165293308182699
|
|
||||||
|
|
||||||
diff --git a/net/minecraft/world/inventory/AbstractContainerMenu.java b/net/minecraft/world/inventory/AbstractContainerMenu.java
|
diff --git a/net/minecraft/world/inventory/AbstractContainerMenu.java b/net/minecraft/world/inventory/AbstractContainerMenu.java
|
||||||
index 9dd3187fd968ab95e9d55b4c8cc74e782cc0f241..c5ede24d00f444d04c835af3a7f0154227492be4 100644
|
index 9dd3187fd968ab95e9d55b4c8cc74e782cc0f241..46c3353a9722cb9c8073cadbad0ced57bab0c390 100644
|
||||||
--- a/net/minecraft/world/inventory/AbstractContainerMenu.java
|
--- a/net/minecraft/world/inventory/AbstractContainerMenu.java
|
||||||
+++ b/net/minecraft/world/inventory/AbstractContainerMenu.java
|
+++ b/net/minecraft/world/inventory/AbstractContainerMenu.java
|
||||||
@@ -559,7 +559,7 @@ public abstract class AbstractContainerMenu {
|
@@ -559,7 +559,7 @@ public abstract class AbstractContainerMenu {
|
||||||
@@ -25,7 +18,7 @@ index 9dd3187fd968ab95e9d55b4c8cc74e782cc0f241..c5ede24d00f444d04c835af3a7f01542
|
|||||||
slot.setChanged();
|
slot.setChanged();
|
||||||
// CraftBukkit start - Make sure the client has the right slot contents
|
// CraftBukkit start - Make sure the client has the right slot contents
|
||||||
- if (player instanceof ServerPlayer serverPlayer && slot.getMaxStackSize() != 64) {
|
- if (player instanceof ServerPlayer serverPlayer && slot.getMaxStackSize() != 64) {
|
||||||
+ if (player instanceof ServerPlayer serverPlayer && slot.getMaxStackSize() != net.minecraft.world.Container.MAX_STACK) { // Paper - Fix excess slot updates / inventory state id desync
|
+ if (player instanceof ServerPlayer serverPlayer && slot.getMaxStackSize() != Container.MAX_STACK) { // Paper - craftbukkkit - Fix excess slot updates
|
||||||
serverPlayer.connection.send(new net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket(this.containerId, this.incrementStateId(), slot.index, slot.getItem()));
|
serverPlayer.connection.send(new net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket(this.containerId, this.incrementStateId(), slot.index, slot.getItem()));
|
||||||
// Updating a crafting inventory makes the client reset the result slot, have to send it again
|
// Updating a crafting inventory makes the client reset the result slot, have to send it again
|
||||||
if (this.getBukkitView().getType() == org.bukkit.event.inventory.InventoryType.WORKBENCH || this.getBukkitView().getType() == org.bukkit.event.inventory.InventoryType.CRAFTING) {
|
if (this.getBukkitView().getType() == org.bukkit.event.inventory.InventoryType.WORKBENCH || this.getBukkitView().getType() == org.bukkit.event.inventory.InventoryType.CRAFTING) {
|
||||||
Reference in New Issue
Block a user