From 2b8dfad33732b5bc68f2e599ec65c891d82a9e83 Mon Sep 17 00:00:00 2001 From: Louis Vallat Date: Thu, 16 Apr 2020 12:28:27 +0200 Subject: [PATCH] added proof of concept --- .../louisvallat/sweetdreams/SweetDreams.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main/java/xyz/louisvallat/sweetdreams/SweetDreams.java b/src/main/java/xyz/louisvallat/sweetdreams/SweetDreams.java index 9a7e0b5..d8806c4 100644 --- a/src/main/java/xyz/louisvallat/sweetdreams/SweetDreams.java +++ b/src/main/java/xyz/louisvallat/sweetdreams/SweetDreams.java @@ -1,9 +1,16 @@ package xyz.louisvallat.sweetdreams; import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerBedEnterEvent; +import org.bukkit.event.player.PlayerBedLeaveEvent; import org.bukkit.plugin.java.JavaPlugin; +import javax.swing.*; + public final class SweetDreams extends JavaPlugin implements Listener { @Override @@ -18,4 +25,18 @@ public final class SweetDreams extends JavaPlugin implements Listener { getLogger().info("Disabling plugin..."); getLogger().info("Done disabling."); } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onSleepEvent(PlayerBedEnterEvent event) { + Player player = event.getPlayer(); + player.sendMessage("You are sleeping"); + getServer().broadcastMessage(player.getName() + " is sleeping!"); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onWakeEvent(PlayerBedLeaveEvent event) { + Player player = event.getPlayer(); + player.sendMessage("You are awoken"); + getServer().broadcastMessage(player.getName() + " has awoken!"); + } }