Added @DontExport annotation for telling Bukkit not to share a class with another plugin

By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
Bukkit/Spigot 2011-05-12 23:09:24 +01:00
parent 2282eb15a5
commit 11804b78a5
3 changed files with 19 additions and 2 deletions

View file

@ -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);
}
}

View file

@ -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);
}

View file

@ -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 {
}