throw player out of bed

Discussion in 'Plugin Development' started by MCManager, Aug 6, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    MCManager

    how do i throw someone out of bed in the PlayerBedEnter event?
     
  2. Offline

    Baummann

    event.setCancelled(true);
     
  3. Offline

    MCManager

    doesn't work
     
  4. Offline

    Baummann

    Try to destroy the bed and place it again.

    Let me code something for you:

    Code:java
    1. private Map<Block, LinkedList<BlockState>> beds = new HashMap<Player, LinkedList<BlockState>>();
    2. public void putBlock(BlockState block) {
    3. LinkedList<BlockState> list = beds.get(block.getBlock());
    4. if (list.size() >= 2) {
    5. BlockState old = list.removeFirst();
    6. old.update(true);
    7. }
    8. list.add(block);
    9. }
    10.  
    11. public void onPlayerBedEnter(PlayerBedEnterEvent event) {
    12. Block b = event.getBed();
    13. Location loc = event.getBed().getLocation();
    14. b.setType(Material.AIR);
    15. putBlock(b.getState());
    16. }
    17.  
     
Thread Status:
Not open for further replies.

Share This Page