Skip to content

Commit

Permalink
Added @DontExport annotation for telling Bukkit not to share a class …
Browse files Browse the repository at this point in the history
…with another plugin
  • Loading branch information
Dinnerbone committed May 12, 2011
1 parent 5e82e3b commit 1c4bde5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
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;

/**
Expand Down Expand Up @@ -217,7 +218,7 @@ public Class<?> getClassByName(final String name) {
}

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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected Class<?> findClass(String name, boolean checkGlobal) throws ClassNotFo
Class<?> result = classes.get(name);

if (result == null) {
if(checkGlobal) {
if (checkGlobal) {
result = loader.getClassByName(name);
}

Expand Down
16 changes: 16 additions & 0 deletions src/main/java/org/bukkit/plugin/java/annotations/DontExport.java
Original file line number Diff line number Diff line change
@@ -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 {

}

0 comments on commit 1c4bde5

Please sign in to comment.