Prevent players with essentials.sleepingignored permission from going to bed. Prevents a bug in bukkit.

This commit is contained in:
snowleo 2011-10-09 20:10:21 +02:00
parent 81994160e8
commit f3dc846b1b
2 changed files with 14 additions and 0 deletions

View File

@ -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_EGG_THROW, playerListener, Priority.High, this);
pm.registerEvent(Type.PLAYER_BUCKET_EMPTY, 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_ANIMATION, playerListener, Priority.High, this);
pm.registerEvent(Type.PLAYER_BED_ENTER, playerListener, Priority.High, this);
final EssentialsBlockListener blockListener = new EssentialsBlockListener(this); final EssentialsBlockListener blockListener = new EssentialsBlockListener(this);
pm.registerEvent(Type.BLOCK_PLACE, blockListener, Priority.Lowest, this); pm.registerEvent(Type.BLOCK_PLACE, blockListener, Priority.Lowest, this);

View File

@ -14,6 +14,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerAnimationEvent; import org.bukkit.event.player.PlayerAnimationEvent;
import org.bukkit.event.player.PlayerAnimationType; import org.bukkit.event.player.PlayerAnimationType;
import org.bukkit.event.player.PlayerBedEnterEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
@ -380,4 +381,16 @@ public class EssentialsPlayerListener extends PlayerListener
user.updateActivity(true); 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.");
}
}
} }