mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-06 18:50:51 +01:00
Added @DontExport annotation for telling Bukkit not to share a class with another plugin
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
2282eb15a5
commit
11804b78a5
3 changed files with 19 additions and 2 deletions
|
@ -27,6 +27,7 @@ import org.bukkit.event.vehicle.*;
|
||||||
import org.bukkit.event.world.*;
|
import org.bukkit.event.world.*;
|
||||||
import org.bukkit.event.weather.*;
|
import org.bukkit.event.weather.*;
|
||||||
import org.bukkit.plugin.*;
|
import org.bukkit.plugin.*;
|
||||||
|
import org.bukkit.plugin.java.annotations.DontExport;
|
||||||
import org.yaml.snakeyaml.error.YAMLException;
|
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) {
|
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);
|
classes.put(name, clazz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class PluginClassLoader extends URLClassLoader {
|
||||||
Class<?> result = classes.get(name);
|
Class<?> result = classes.get(name);
|
||||||
|
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
if(checkGlobal) {
|
if (checkGlobal) {
|
||||||
result = loader.getClassByName(name);
|
result = loader.getClassByName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue