added proof of concept

This commit is contained in:
Louis Vallat 2020-04-16 12:28:27 +02:00
parent 334cbc10c4
commit 2b8dfad337

View File

@ -1,9 +1,16 @@
package xyz.louisvallat.sweetdreams; package xyz.louisvallat.sweetdreams;
import org.bukkit.Bukkit; 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.Listener;
import org.bukkit.event.player.PlayerBedEnterEvent;
import org.bukkit.event.player.PlayerBedLeaveEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import javax.swing.*;
public final class SweetDreams extends JavaPlugin implements Listener { public final class SweetDreams extends JavaPlugin implements Listener {
@Override @Override
@ -18,4 +25,18 @@ public final class SweetDreams extends JavaPlugin implements Listener {
getLogger().info("Disabling plugin..."); getLogger().info("Disabling plugin...");
getLogger().info("Done disabling."); 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!");
}
} }