Advertisement
Guest User

Untitled

a guest
Jul 17th, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 2.79 KB | None | 0 0
  1. package pw.bowser.hysteria.module.internal.hacks.world.fly
  2.  
  3. import pw.bowser.hysteria.commands.companion.{Flag, Command}
  4. import pw.bowser.hysteria.util.commands.ToggleFlag
  5. import pw.bowser.hysteria.commands.HysteriaCommand
  6. import pw.bowser.hysteria.chat.Formatting
  7. import pw.bowser.hysteria.config.ConfigurationFlag
  8. import pw.bowser.libhysteria.modules.ModuleManifest
  9. import pw.bowser.hysteria.module.internal.HysteriaModule
  10. import pw.bowser.libhysteria.toggles.TogglesMixin
  11.  
  12. /**
  13.  * Date: 2/27/14
  14.  * Time: 9:48 PM
  15.  */
  16. @ModuleManifest(
  17.   groupId = "pw.bowser",
  18.   name = "Fly",
  19.   version = "0.1",
  20.   commands = Array("fly"),
  21.   description = "Planar and Parabolic fly"
  22. )
  23. class ModFly extends HysteriaModule with TogglesMixin {
  24.  
  25.   private var command: HysteriaCommand = null
  26.  
  27.   override def initModule(): Unit = {
  28.     super.initModule()
  29.  
  30.     configuration.setPropertyIfNew("fly.mode",   "3d")
  31.     configuration.setPropertyIfNew("fly.wedge",  0.2D)
  32.  
  33.     command = Command(
  34.       Array("fly"),
  35.       ToggleFlag(Array("@if_none"), this),
  36.       Flag(Array("mode", "m"), {
  37.         args =>
  38.           if (args.length > 0) configuration.setProperty("fly.mode", args(0) match {
  39.             case "3d" | "look" => "3d"
  40.             case "planar" | "notch" | "flat" => "planar"
  41.             case _ =>
  42.               tellPlayer("Invalid Fly Mode")
  43.               configuration.getString("fly.mode")
  44.           })
  45.  
  46.           tellPlayer(s"Fly Mode is set to ${Formatting.italicize(configuration.getString("fly.mode"))}")
  47.       }),
  48.       ConfigurationFlag(Array("w", "wedge"), configuration, "fly.wedge", ConfigurationFlag.Transforms.DOUBLE)
  49.     )
  50.   }
  51.  
  52.   override def enableModule(): Unit = {
  53.  
  54.     toggleRegistry.enrollToggleable(this)
  55.     commandDispatcher.registerCommand(command)
  56.  
  57.     super.enableModule()
  58.   }
  59.  
  60.   override def disableModule(): Unit = {
  61.  
  62.     toggleRegistry.disenrollToggleable(this)
  63.     commandDispatcher.unRegisterCommand(command)
  64.  
  65.     super.disableModule()
  66.   }
  67.  
  68.   def flyImpl: FlyMode = configuration.getString("fly.mode") match {
  69.     case "3d" => Fly3D
  70.     case "planar" | _ => PlanarFly
  71.   }
  72.  
  73.   def flyWedge: Double = configuration.getDouble("fly.wedge")
  74.  
  75.   /**
  76.    * Get the name of the toggleable
  77.    *
  78.    * @return name
  79.    */
  80.   def displayName: String = "Fly"
  81.  
  82.   /**
  83.    * Should return the distinguished name of the toggles
  84.    * The distinguished name should be unique to the toggles, ie, `pw.bowser.mods.mod.distinguished_name_here`
  85.    * @return
  86.    */
  87.   override def distinguishedName: String = "pw.hysteria.fly"
  88.  
  89.   override def conflictingToggles: List[String] = List("pw.hysteria.sprint", "pw.hysteria.speed", "pw.hysteria.shusako.glide")
  90.  
  91.   override def statusText: Option[String] = Some(configuration.getString("fly.mode") + " " + configuration.getDouble("fly.wedge"))
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement