SHARE
TWEET

Untitled

TheReturningVoid Sep 16th, 2015 (edited) 99 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.   * Represents an enumeration of dynamic packages of NMS and CraftBukkit
  3.   *
  4.   * This class is part of the '''ReflectionUtils''' and follows the same usage conditions
  5.   *
  6.   * @constructor Construct a new package type
  7.   * @param path Path of the package
  8.   * @author DarkBlade12
  9.   * @since 1.0
  10.   */
  11. object PackageTypes extends Enumeration {
  12.   sealed abstract class PackageTypeBase
  13.   case class PackageType(parent: PackageTypePath, path: String) {
  14.     PackageTypes.path = path
  15.   }
  16.   case class PackageTypePath(path: String) {
  17.     PackageTypes.path = path
  18.   }
  19.  
  20.   object MINECRAFT_SERVER extends PackageTypePath("net.minecraft.server." + getServerVersion)
  21.   object CRAFTBUKKIT extends PackageTypePath("org.bukkit.craftbukkit." + getServerVersion)
  22.   object CRAFTBUKKIT_BLOCK extends PackageType(CRAFTBUKKIT, "block")
  23.   object CRAFTBUKKIT_BLOCK extends PackageType(CRAFTBUKKIT, "block")
  24.   object CRAFTBUKKIT_CHUNKIO extends PackageType(CRAFTBUKKIT, "chunkio")
  25.   object CRAFTBUKKIT_COMMAND extends PackageType(CRAFTBUKKIT, "command")
  26.   object CRAFTBUKKIT_CONVERSATIONS extends PackageType(CRAFTBUKKIT, "conversations")
  27.   object CRAFTBUKKIT_ENCHANTMENTS extends PackageType(CRAFTBUKKIT, "enchantments")
  28.   object CRAFTBUKKIT_ENTITY extends PackageType(CRAFTBUKKIT, "entity")
  29.   object CRAFTBUKKIT_EVENT extends PackageType(CRAFTBUKKIT, "event")
  30.   object CRAFTBUKKIT_GENERATOR extends PackageType(CRAFTBUKKIT, "generator")
  31.   object CRAFTBUKKIT_HELP extends PackageType(CRAFTBUKKIT, "help")
  32.   object CRAFTBUKKIT_INVENTORY extends PackageType(CRAFTBUKKIT, "inventory")
  33.   object CRAFTBUKKIT_MAP extends PackageType(CRAFTBUKKIT, "map")
  34.   object CRAFTBUKKIT_METADATA extends PackageType(CRAFTBUKKIT, "metadata")
  35.   object CRAFTBUKKIT_POTION extends PackageType(CRAFTBUKKIT, "potion")
  36.   object CRAFTBUKKIT_PROJECTILES extends PackageType(CRAFTBUKKIT, "projectiles")
  37.   object CRAFTBUKKIT_SCHEDULER extends PackageType(CRAFTBUKKIT, "scheduler")
  38.   object CRAFTBUKKIT_SCOREBOARD extends PackageType(CRAFTBUKKIT, "scoreboard")
  39.   object CRAFTBUKKIT_UPDATER extends PackageType(CRAFTBUKKIT, "updater")
  40.   object CRAFTBUKKIT_UTIL extends PackageType(CRAFTBUKKIT, "util")
  41.  
  42.   var path = "": String
  43.  
  44.   /**
  45.     * Returns the path of this package type
  46.     *
  47.     * @return The path
  48.     */
  49.   def getPath: String = path
  50.  
  51.   /**
  52.     * Returns the class of the given name
  53.     *
  54.     * @param classname Name of the desired class
  55.     * @throws java.lang.ClassNotFoundException If the desired class with the specified name and package cannot be found
  56.     * @return The class with the specified name
  57.     */
  58.   @throws(classOf[ClassNotFoundException])
  59.   def getClass(classname: String): Class[_] = Class.forName(this + "." + classname)
  60.  
  61.   // Override for convenience
  62.   override def toString(): String = path
  63.  
  64.   /**
  65.     * Returns the version of your server
  66.     *
  67.     * @return The server version
  68.     */
  69.   def getServerVersion = Bukkit.getServer.getClass.getPackage.getName substring 23
  70. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top