Advertisement
TheReturningVoid

Untitled

Sep 16th, 2015
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.29 KB | None | 0 0
  1. public enum PackageType {
  2.         MINECRAFT_SERVER("net.minecraft.server." + getServerVersion()),
  3.         CRAFTBUKKIT("org.bukkit.craftbukkit." + getServerVersion()),
  4.         CRAFTBUKKIT_BLOCK(CRAFTBUKKIT, "block"),
  5.         CRAFTBUKKIT_CHUNKIO(CRAFTBUKKIT, "chunkio"),
  6.         CRAFTBUKKIT_COMMAND(CRAFTBUKKIT, "command"),
  7.         CRAFTBUKKIT_CONVERSATIONS(CRAFTBUKKIT, "conversations"),
  8.         CRAFTBUKKIT_ENCHANTMENS(CRAFTBUKKIT, "enchantments"),
  9.         CRAFTBUKKIT_ENTITY(CRAFTBUKKIT, "entity"),
  10.         CRAFTBUKKIT_EVENT(CRAFTBUKKIT, "event"),
  11.         CRAFTBUKKIT_GENERATOR(CRAFTBUKKIT, "generator"),
  12.         CRAFTBUKKIT_HELP(CRAFTBUKKIT, "help"),
  13.         CRAFTBUKKIT_INVENTORY(CRAFTBUKKIT, "inventory"),
  14.         CRAFTBUKKIT_MAP(CRAFTBUKKIT, "map"),
  15.         CRAFTBUKKIT_METADATA(CRAFTBUKKIT, "metadata"),
  16.         CRAFTBUKKIT_POTION(CRAFTBUKKIT, "potion"),
  17.         CRAFTBUKKIT_PROJECTILES(CRAFTBUKKIT, "projectiles"),
  18.         CRAFTBUKKIT_SCHEDULER(CRAFTBUKKIT, "scheduler"),
  19.         CRAFTBUKKIT_SCOREBOARD(CRAFTBUKKIT, "scoreboard"),
  20.         CRAFTBUKKIT_UPDATER(CRAFTBUKKIT, "updater"),
  21.         CRAFTBUKKIT_UTIL(CRAFTBUKKIT, "util");
  22.  
  23.         private final String path;
  24.  
  25.         /**
  26.          * Construct a new package type
  27.          *
  28.          * @param path Path of the package
  29.          */
  30.         private PackageType(String path) {
  31.             this.path = path;
  32.         }
  33.  
  34.         /**
  35.          * Construct a new package type
  36.          *
  37.          * @param parent Parent package of the package
  38.          * @param path Path of the package
  39.          */
  40.         private PackageType(PackageType parent, String path) {
  41.             this(parent + "." + path);
  42.         }
  43.  
  44.         /**
  45.          * Returns the path of this package type
  46.          *
  47.          * @return The path
  48.          */
  49.         public String getPath() {
  50.             return path;
  51.         }
  52.  
  53.         /**
  54.          * Returns the class with the given name
  55.          *
  56.          * @param className Name of the desired class
  57.          * @return The class with the specified name
  58.          * @throws ClassNotFoundException If the desired class with the specified name and package cannot be found
  59.          */
  60.         public Class<?> getClass(String className) throws ClassNotFoundException {
  61.             return Class.forName(this + "." + className);
  62.         }
  63.  
  64.         // Override for convenience
  65.         @Override
  66.         public String toString() {
  67.             return path;
  68.         }
  69.  
  70.         /**
  71.          * Returns the version of your server
  72.          *
  73.          * @return The server version
  74.          */
  75.         public static String getServerVersion() {
  76.             return Bukkit.getServer().getClass().getPackage().getName().substring(23);
  77.         }
  78.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement