Fixed error message on success

master
Trivernis 5 years ago
parent 3de6072d3a
commit a478bbab78

@ -9,7 +9,7 @@ import org.bukkit.event.player.PlayerAdvancementDoneEvent
import org.bukkit.event.player.PlayerGameModeChangeEvent import org.bukkit.event.player.PlayerGameModeChangeEvent
import org.bukkit.potion.PotionEffectType import org.bukkit.potion.PotionEffectType
class EventListener(private val config: FileConfiguration, private val essentials: Essentials?, private val commandC: CommandC,): Listener { class EventListener(private val config: FileConfiguration, private val essentials: Essentials?, private val commandC: CommandC): Listener {
/** /**
* Removes the night vision effect from the player if given by /c command * Removes the night vision effect from the player if given by /c command
*/ */

@ -4,6 +4,7 @@ import com.earth2me.essentials.Essentials
import com.onarandombox.MultiverseCore.MultiverseCore import com.onarandombox.MultiverseCore.MultiverseCore
import net.trivernis.superutils.commands.CommandC import net.trivernis.superutils.commands.CommandC
import net.trivernis.superutils.commands.CommandH import net.trivernis.superutils.commands.CommandH
import net.trivernis.superutils.commands.CommandReload
import net.trivernis.superutils.commands.CommandWp import net.trivernis.superutils.commands.CommandWp
import org.bukkit.configuration.file.FileConfiguration import org.bukkit.configuration.file.FileConfiguration
import org.bukkit.entity.Minecart import org.bukkit.entity.Minecart
@ -19,6 +20,7 @@ class SuperUtils : JavaPlugin() {
val essentials = getEssentials() val essentials = getEssentials()
val commandC = CommandC(getMultiverseCore(), essentials) val commandC = CommandC(getMultiverseCore(), essentials)
server.pluginManager.registerEvents(EventListener(config, essentials, commandC), this) server.pluginManager.registerEvents(EventListener(config, essentials, commandC), this)
getCommand("reload")?.setExecutor(CommandReload(this))
getCommand("c")?.setExecutor(commandC) getCommand("c")?.setExecutor(commandC)
if (essentials != null) { if (essentials != null) {
@ -60,6 +62,5 @@ class SuperUtils : JavaPlugin() {
private fun configure() { private fun configure() {
config.addDefault("advancement-payout", 50) config.addDefault("advancement-payout", 50)
config.options().copyDefaults(true) config.options().copyDefaults(true)
saveConfig()
} }
} }

@ -17,11 +17,19 @@ class CommandC(private var multiverseCore: MultiverseCore?, private var essentia
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<String>): Boolean { override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<String>): Boolean {
if (sender is Player && command.testPermission(sender)) { if (sender is Player && command.testPermission(sender)) {
if (sender.gameMode != GameMode.SPECTATOR) { if (sender.gameMode != GameMode.SPECTATOR) {
sender.gameMode = GameMode.SPECTATOR
sender.addPotionEffect(PotionEffectType.NIGHT_VISION.createEffect(1000000, 255))
if (essentials != null) { if (essentials != null) {
val commandCost = essentials!!.settings.getCommandCost("c") val commandCost = essentials!!.settings.getCommandCost("c")
essentials!!.getUser(sender).takeMoney(commandCost) val essUser = essentials!!.getUser(sender)
if ((essUser.money - commandCost) > essentials!!.settings.minMoney) {
sender.gameMode = GameMode.SPECTATOR
sender.addPotionEffect(PotionEffectType.NIGHT_VISION.createEffect(1000000, 255))
essUser.takeMoney(commandCost)
} else {
sender.sendMessage("You do not have enough money for this command")
}
} else {
sender.gameMode = GameMode.SPECTATOR
sender.addPotionEffect(PotionEffectType.NIGHT_VISION.createEffect(1000000, 255))
} }
} else { } else {
sender.removePotionEffect(PotionEffectType.NIGHT_VISION) sender.removePotionEffect(PotionEffectType.NIGHT_VISION)

@ -0,0 +1,17 @@
package net.trivernis.superutils.commands
import net.trivernis.superutils.SuperUtils
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
import org.bukkit.command.CommandSender
class CommandReload(val superUtils: SuperUtils): CommandExecutor {
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean {
if (command.testPermission(sender)) {
superUtils.reloadConfig()
sender.sendMessage("Config for superutils reloaded.")
}
return true
}
}

@ -36,8 +36,13 @@ class CommandWp(private val essentials: Essentials): CommandExecutor, TabComplet
if (essentials.warps.list.find { it.equals(args[0], ignoreCase = true) }?.isNotEmpty() == true) { if (essentials.warps.list.find { it.equals(args[0], ignoreCase = true) }?.isNotEmpty() == true) {
val warp = essentials.warps.getWarp(args.first()) val warp = essentials.warps.getWarp(args.first())
val teleportCost = Trade(essentials.settings.getCommandCost("warp"), essentials) val teleportCost = Trade(essentials.settings.getCommandCost("warp"), essentials)
essUser.teleport.teleport(warp.block.location, teleportCost, PlayerTeleportEvent.TeleportCause.COMMAND) if ((essUser.money - teleportCost.money) > essentials.settings.minMoney) {
return true essUser.teleport.teleport(warp.block.location, teleportCost, PlayerTeleportEvent.TeleportCause.COMMAND)
return true
} else {
sender.sendMessage("You do not have enough money for this command.")
return true
}
} else { } else {
sender.sendMessage("Warp \"${args.first()}\" not found") sender.sendMessage("Warp \"${args.first()}\" not found")
} }

@ -5,6 +5,11 @@ description: Utility commands plugin.
author: Trivernis author: Trivernis
website: trivernis.net website: trivernis.net
commands: commands:
reload:
description: reloads the config of the plugin
permission: superutils.reload
permission-message: You do not have permission to reload the configuration!
usage: /reload
c: c:
description: spectator night vision description: spectator night vision
permission: superutils.c permission: superutils.c
@ -21,6 +26,9 @@ commands:
permission-message: You do not have permission! permission-message: You do not have permission!
usage: /wp {warp} usage: /wp {warp}
permissions: permissions:
superutils.reload:
description: Allows reload command
default: op
superutils.c: superutils.c:
description: Allows c command description: Allows c command
default: op default: op

Loading…
Cancel
Save