Changed to class for every command
parent
cacca65d43
commit
b3bdcaa822
@ -0,0 +1,27 @@
|
|||||||
|
package net.trivernis.superutils.commands
|
||||||
|
|
||||||
|
import org.bukkit.GameMode
|
||||||
|
import org.bukkit.command.Command
|
||||||
|
import org.bukkit.command.CommandExecutor
|
||||||
|
import org.bukkit.command.CommandSender
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
import org.bukkit.potion.PotionEffectType
|
||||||
|
|
||||||
|
class CommandC: CommandExecutor {
|
||||||
|
/**
|
||||||
|
* Sets the users gamemode to spectator with nightvision or back to survival
|
||||||
|
*/
|
||||||
|
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<String>): Boolean {
|
||||||
|
if (sender is Player && command.testPermission(sender)) {
|
||||||
|
if (sender.gameMode != GameMode.SPECTATOR) {
|
||||||
|
sender.gameMode = GameMode.SPECTATOR
|
||||||
|
sender.addPotionEffect(PotionEffectType.NIGHT_VISION.createEffect(1000000, 255))
|
||||||
|
} else {
|
||||||
|
sender.removePotionEffect(PotionEffectType.NIGHT_VISION)
|
||||||
|
sender.gameMode = GameMode.SURVIVAL
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package net.trivernis.superutils.commands
|
||||||
|
|
||||||
|
import com.earth2me.essentials.Essentials
|
||||||
|
import com.earth2me.essentials.UserData
|
||||||
|
import org.bukkit.Location
|
||||||
|
import org.bukkit.command.Command
|
||||||
|
import org.bukkit.command.CommandExecutor
|
||||||
|
import org.bukkit.command.CommandSender
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent
|
||||||
|
|
||||||
|
class CommandH(private var essentials: Essentials) : CommandExecutor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Teleports the user to the default home or a specified one
|
||||||
|
*/
|
||||||
|
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean {
|
||||||
|
if (sender is Player && command.testPermission(sender)) {
|
||||||
|
val essUser = essentials.getUser(sender)
|
||||||
|
val userHome: Location
|
||||||
|
userHome = if (args.isNotEmpty()) {
|
||||||
|
essUser.getHome(args[0])
|
||||||
|
} else {
|
||||||
|
essUser.getHome("home")
|
||||||
|
}
|
||||||
|
essUser.teleport.teleport(userHome.block.location, null, PlayerTeleportEvent.TeleportCause.COMMAND)
|
||||||
|
essUser.sendMessage("You have been teleported home.")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue