diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index 448b297035..93eb0f2c04 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -27,6 +27,7 @@ import org.bukkit.event.vehicle.*; import org.bukkit.event.world.*; import org.bukkit.event.weather.*; import org.bukkit.plugin.*; +import org.bukkit.plugin.java.annotations.DontExport; import org.yaml.snakeyaml.error.YAMLException; /** @@ -217,7 +218,7 @@ public final class JavaPluginLoader implements PluginLoader { } public void setClass(final String name, final Class clazz) { - if(!classes.containsKey(name)) { + if ((!classes.containsKey(name)) && (clazz.getAnnotation(DontExport.class) != null)) { classes.put(name, clazz); } } diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/paper-api/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java index 91d4d6d3d6..f998e3098e 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java @@ -28,7 +28,7 @@ public class PluginClassLoader extends URLClassLoader { Class result = classes.get(name); if (result == null) { - if(checkGlobal) { + if (checkGlobal) { result = loader.getClassByName(name); } diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/annotations/DontExport.java b/paper-api/src/main/java/org/bukkit/plugin/java/annotations/DontExport.java new file mode 100644 index 0000000000..dd6efb9bea --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/plugin/java/annotations/DontExport.java @@ -0,0 +1,16 @@ + +package org.bukkit.plugin.java.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Flags a class as private and not to be exported with other plugins + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface DontExport { + +}