Advertisement
TheReturningVoid

Untitled

Sep 16th, 2015
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 2.52 KB | None | 0 0
  1. class PackageType(path: String) {
  2.     def this(parent: PackageType, path: String) {
  3.       this (parent.path + "." + path)
  4.     }
  5.   }
  6.   /**
  7.     * Represents an enumeration of dynamic packages of NMS and CraftBukkit
  8.     *
  9.     * This class is part of the '''ReflectionUtils''' and follows the same usage conditions
  10.     *
  11.     * ''Rewritten in Scala by TheReturningVoid''
  12.     *
  13.     * @author DarkBlade12, TheReturningVoid
  14.     * @since 1.0
  15.     */
  16.   object PackageType {
  17.     val MINECRAFT_SERVER = new PackageType("net.minecraft.server." + getServerVersion)
  18.     val CRAFTBUKKIT = new PackageType("org.bukkit.craftbukkit." + getServerVersion)
  19.     val CRAFTBUKKIT_BLOCK = new PackageType(CRAFTBUKKIT, "block")
  20.     val CRAFTBUKKIT_CHUNKIO = new PackageType(CRAFTBUKKIT, "chunkio")
  21.     val CRAFTBUKKIT_COMMAND = new PackageType(CRAFTBUKKIT, "command")
  22.     val CRAFTBUKKIT_CONVERSATIONS = new PackageType(CRAFTBUKKIT, "conversations")
  23.     val CRAFTBUKKIT_ENCHANTMENTS = new PackageType(CRAFTBUKKIT, "enchantments")
  24.     val CRAFTBUKKIT_ENTITY = new PackageType(CRAFTBUKKIT, "entity")
  25.     val CRAFTBUKKIT_EVENT = new PackageType(CRAFTBUKKIT, "event")
  26.     val CRAFTBUKKIT_GENERATOR = new PackageType(CRAFTBUKKIT, "generator")
  27.     val CRAFTBUKKIT_HELP = new PackageType(CRAFTBUKKIT, "help")
  28.     val CRAFTBUKKIT_INVENTORY = new PackageType(CRAFTBUKKIT, "inventory")
  29.     val CRAFTBUKKIT_MAP = new PackageType(CRAFTBUKKIT, "map")
  30.     val CRAFTBUKKIT_METADATA = new PackageType(CRAFTBUKKIT, "metadata")
  31.     val CRAFTBUKKIT_POTION = new PackageType(CRAFTBUKKIT, "potion")
  32.     val CRAFTBUKKIT_PROJECTILES = new PackageType(CRAFTBUKKIT, "projectiles")
  33.     val CRAFTBUKKIT_SCHEDULER = new PackageType(CRAFTBUKKIT, "scheduler")
  34.     val CRAFTBUKKIT_SCOREBOARD = new PackageType(CRAFTBUKKIT, "scoreboard")
  35.     val CRAFTBUKKIT_UPDATER = new PackageType(CRAFTBUKKIT, "updater")
  36.     val CRAFTBUKKIT_UTIL = new PackageType(CRAFTBUKKIT, "util")
  37.  
  38.     /**
  39.       * Returns the class of the given name
  40.       *
  41.       * @param classname Name of the desired class
  42.       * @throws java.lang.ClassNotFoundException If the desired class with the specified name and package cannot be found
  43.       * @return The class with the specified name
  44.       */
  45.     @throws(classOf[ClassNotFoundException])
  46.     def getClass(classname: String): Class[_] = Class.forName(this + "." + classname)
  47.  
  48.     /**
  49.       * Returns the version of your server
  50.       *
  51.       * @return The server version
  52.       */
  53.     def getServerVersion = Bukkit.getServer.getClass.getPackage.getName substring 23
  54.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement