diff options
author | snowleo <schneeleo@gmail.com> | 2011-10-09 20:10:21 +0200 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2011-10-09 20:10:21 +0200 |
commit | f3dc846b1b9b980bd3ceca8f1dc02c9135702927 (patch) | |
tree | da4e5bcdf45aa792209a67a277cbc9266fdb4e04 | |
parent | 81994160e89c30aa870bc196e8ac38185e2b9974 (diff) | |
download | Essentials-f3dc846b1b9b980bd3ceca8f1dc02c9135702927.tar Essentials-f3dc846b1b9b980bd3ceca8f1dc02c9135702927.tar.gz Essentials-f3dc846b1b9b980bd3ceca8f1dc02c9135702927.tar.lz Essentials-f3dc846b1b9b980bd3ceca8f1dc02c9135702927.tar.xz Essentials-f3dc846b1b9b980bd3ceca8f1dc02c9135702927.zip |
Prevent players with essentials.sleepingignored permission from going to bed. Prevents a bug in bukkit.
-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."); + } + } } |