Paper/patches/api/0484-Initialisation-improvements.patch
2024-08-11 18:24:35 +02:00

60 Zeilen
2.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Lixfel <agga-games@gmx.de>
Date: Sat, 27 Aug 2022 09:00:08 +0200
Subject: [PATCH] Initialisation improvements
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
index 7e4f7cb2afbc145e532285c793573ad107bc3033..d5931454d3022b2e55e2e0f4f66edd470d24a3ee 100644
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
@@ -205,47 +205,7 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
Class<?> result = classes.get(name);
if (result == null) {
- String path = name.replace('.', '/').concat(".class");
- JarEntry entry = jar.getJarEntry(path);
-
- if (entry != null) {
- byte[] classBytes;
-
- try (InputStream is = jar.getInputStream(entry)) {
- classBytes = ByteStreams.toByteArray(is);
- } catch (IOException ex) {
- throw new ClassNotFoundException(name, ex);
- }
-
- classBytes = org.bukkit.Bukkit.getServer().getUnsafe().processClass(description, path, classBytes); // Paper
-
- int dot = name.lastIndexOf('.');
- if (dot != -1) {
- String pkgName = name.substring(0, dot);
- if (getPackage(pkgName) == null) {
- try {
- if (manifest != null) {
- definePackage(pkgName, manifest, url);
- } else {
- definePackage(pkgName, null, null, null, null, null, null, null);
- }
- } catch (IllegalArgumentException ex) {
- if (getPackage(pkgName) == null) {
- throw new IllegalStateException("Cannot find package " + pkgName);
- }
- }
- }
- }
-
- CodeSigner[] signers = entry.getCodeSigners();
- CodeSource source = new CodeSource(url, signers);
-
- result = defineClass(name, classBytes, 0, classBytes.length, source);
- }
-
- if (result == null) {
- result = super.findClass(name);
- }
+ result = super.findClass(name);
classes.put(name, result);
this.setClass(name, result); // Paper