/src/main/scala/com/pneumaticraft/scalamc/ScalaMC.scala

http://github.com/PneumatiCraft/ScalaMC · Scala · 51 lines · 35 code · 16 blank · 0 comment · 0 complexity · fbac05a2e140ddf866e49494ea6373d7 MD5 · raw file

  1. package com.pneumaticraft.scalamc {
  2. import java.util.logging.Logger
  3. import scala.collection.JavaConversions._
  4. import org.bukkit.command.{Command, CommandSender}
  5. import org.bukkit.plugin.java.JavaPlugin
  6. import com.pneumaticraft.scalamc.commands._
  7. import com.pneumaticraft.commandhandler.CommandHandler
  8. object ScalaMC {
  9. val LOG_PREFIX = "[ScalaMC] "
  10. val LOG = Logger.getLogger("Minecraft")
  11. def Info(s:String) = LOG.info(LOG_PREFIX + s)
  12. }
  13. class ScalaMC extends JavaPlugin {
  14. private var permissionsHandler:SMPermissionsHandler = _
  15. private var commandHandler:CommandHandler = _
  16. override def onEnable() = {
  17. ScalaMC.Info("Enabled!")
  18. this.initializePermissions()
  19. this.loadCommands()
  20. }
  21. private def initializePermissions() = {
  22. this.permissionsHandler = new SMPermissionsHandler(this)
  23. }
  24. private def loadCommands() = {
  25. this.commandHandler = new CommandHandler(this, this.permissionsHandler)
  26. this.commandHandler.registerCommand(new SMHelloCommand(this))
  27. }
  28. override def onDisable() = ScalaMC.Info("Disabled!")
  29. override def onCommand(sender:CommandSender, command:Command, commandLabel:String, args:Array[String]):Boolean = {
  30. var keyPath = List(command.getLabel().toLowerCase()) ++ args
  31. this.commandHandler.locateAndRunCommand(sender, keyPath)
  32. }
  33. def getPermissionsHandler() = this.permissionsHandler
  34. }
  35. }