Added world save event

master
Trivernis 5 years ago
parent a478bbab78
commit c2ba86b660

@ -2,14 +2,17 @@ package net.trivernis.superutils
import com.earth2me.essentials.Essentials
import net.trivernis.superutils.commands.CommandC
import org.bukkit.Server
import org.bukkit.configuration.file.FileConfiguration
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.event.player.PlayerAdvancementDoneEvent
import org.bukkit.event.player.PlayerGameModeChangeEvent
import org.bukkit.event.world.WorldSaveEvent
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, private val server: Server): Listener {
/**
* Removes the night vision effect from the player if given by /c command
*/
@ -31,4 +34,13 @@ class EventListener(private val config: FileConfiguration, private val essential
}
}
}
/**
* Broadcasts that the world has been saved
*/
@EventHandler fun onWorldSave(event: WorldSaveEvent) {
if (config.getBoolean("save-notification")) {
server.broadcastMessage("The world has been saved.")
}
}
}

@ -19,8 +19,8 @@ class SuperUtils : JavaPlugin() {
configure()
val essentials = getEssentials()
val commandC = CommandC(getMultiverseCore(), essentials)
server.pluginManager.registerEvents(EventListener(config, essentials, commandC), this)
getCommand("reload")?.setExecutor(CommandReload(this))
server.pluginManager.registerEvents(EventListener(config, essentials, commandC, server), this)
getCommand("superutils reload")?.setExecutor(CommandReload(this))
getCommand("c")?.setExecutor(commandC)
if (essentials != null) {
@ -61,6 +61,7 @@ class SuperUtils : JavaPlugin() {
private fun configure() {
config.addDefault("advancement-payout", 50)
config.addDefault("save-notification", false)
config.options().copyDefaults(true)
}
}

@ -5,7 +5,7 @@ description: Utility commands plugin.
author: Trivernis
website: trivernis.net
commands:
reload:
'superutils reload':
description: reloads the config of the plugin
permission: superutils.reload
permission-message: You do not have permission to reload the configuration!

Loading…
Cancel
Save