diff options
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Essentials.java | 1 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index fe0c3560c..0da255685 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -164,6 +164,7 @@ public class Essentials extends JavaPlugin implements IEssentials pm.registerEvent(Type.PLAYER_EGG_THROW, playerListener, Priority.High, this); pm.registerEvent(Type.PLAYER_BUCKET_EMPTY, playerListener, Priority.High, this); pm.registerEvent(Type.PLAYER_ANIMATION, playerListener, Priority.High, this); + pm.registerEvent(Type.PLAYER_BED_ENTER, playerListener, Priority.High, this); final EssentialsBlockListener blockListener = new EssentialsBlockListener(this); pm.registerEvent(Type.BLOCK_PLACE, blockListener, Priority.Lowest, this); diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 026e4632b..5d121b82e 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -14,6 +14,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerAnimationEvent; import org.bukkit.event.player.PlayerAnimationType; +import org.bukkit.event.player.PlayerBedEnterEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; @@ -380,4 +381,16 @@ public class EssentialsPlayerListener extends PlayerListener user.updateActivity(true); } } + + @Override + public void onPlayerBedEnter(PlayerBedEnterEvent event) + { + if (event.isCancelled()) { + return; + } + if (event.getPlayer().isSleepingIgnored()) { + event.setCancelled(true); + event.getPlayer().sendMessage("You can't go to bed, your sleep is ignored."); + } + } } |