Java Code Examples for org.bukkit.event.player.PlayerBedEnterEvent#setCancelled()

The following examples show how to use org.bukkit.event.player.PlayerBedEnterEvent#setCancelled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlayerListener.java    From BedwarsRel with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onSleep(PlayerBedEnterEvent bee) {

  Player p = bee.getPlayer();

  Game g = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(p);
  if (g == null) {
    return;
  }

  if (g.getState() == GameState.STOPPED) {
    return;
  }

  bee.setCancelled(true);
}
 
Example 2
Source File: BlockListener.java    From civcraft with GNU General Public License v2.0 6 votes vote down vote up
public void OnPlayerBedEnterEvent(PlayerBedEnterEvent event) {
	
	Resident resident = CivGlobal.getResident(event.getPlayer().getName());

	if (resident == null) {
		event.setCancelled(true);
		return;
	}
			
	coord.setFromLocation(event.getPlayer().getLocation());
	Camp camp = CivGlobal.getCampFromChunk(coord);
	if (camp != null) {
		if (!camp.hasMember(event.getPlayer().getName())) {
			CivMessage.sendError(event.getPlayer(), "You cannot sleep in a camp you do not belong to.");
			event.setCancelled(true);
			return;
		}
	}		
}
 
Example 3
Source File: IslandGuard.java    From askyblock with GNU General Public License v2.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOW)
public void onPlayerBedEnter(final PlayerBedEnterEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    // Check world
    if (inWorld(e.getPlayer())) {
        if (actionAllowed(e.getPlayer(),e.getBed().getLocation(), SettingsFlag.BED)) {
            return;
        }
        // Not allowed
        Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected);
        e.setCancelled(true);
    }
}
 
Example 4
Source File: PlayerListener.java    From AuthMeReloaded with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerBedEnter(PlayerBedEnterEvent event) {
    if (listenerService.shouldCancelEvent(event)) {
        event.setCancelled(true);
    }
}