diff --git a/src/main/kotlin/net/trivernis/superutils/EventListener.kt b/src/main/kotlin/net/trivernis/superutils/EventListener.kt index e3f2386..fcf32c1 100644 --- a/src/main/kotlin/net/trivernis/superutils/EventListener.kt +++ b/src/main/kotlin/net/trivernis/superutils/EventListener.kt @@ -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.") + } + } } \ No newline at end of file diff --git a/src/main/kotlin/net/trivernis/superutils/SuperUtils.kt b/src/main/kotlin/net/trivernis/superutils/SuperUtils.kt index c72a0b4..eaad8fa 100644 --- a/src/main/kotlin/net/trivernis/superutils/SuperUtils.kt +++ b/src/main/kotlin/net/trivernis/superutils/SuperUtils.kt @@ -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) } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 2b96130..834d32e 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -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!