@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onBedEnter(final PlayerBedEnterEvent event) { final PlayerStat stat = PlayerStat.ENTERED_BEDS; // Get player final Player player = (Player) event.getPlayer(); // Do general check if (!plugin.doGeneralCheck(player, stat)) return; // Update value to new stat. plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat, StatzUtil.makeQuery("uuid", player.getUniqueId().toString(), "value", 1, "world", player.getWorld().getName())); }
@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); }
@EventHandler public void onPlayerBedEnter(PlayerBedEnterEvent event) { Player player = event.getPlayer(); PlayerProfile profile = CoreData.getProfile(player); if (!event.isCancelled()) { if (profile.getData("Faction", Faction.class) != null) { Faction playerFaction = profile.getData("Faction", Faction.class); Faction targetFaction = plugin.getCoreMethods().getFaction(event.getBed().getLocation()); if (plugin.getCoreMethods().canSetHome(player, targetFaction, playerFaction)) { plugin.getCoreMethods().setHomeLocation(player); } else { plugin.getCoreErrors().timerNotDone(player, "set home", CoreData.getProfile(player).getRemainingDelay(Delay.SETHOME).getFormatted()); } } } }
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; } } }
/** * On player bed enter. * * @param event * the event */ @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPlayerBedEnter(PlayerBedEnterEvent event) { if (!playerConf.get(event.getPlayer()).isAdminMod()) { IDummyLand land = Factoid.getThisPlugin().iLands().getLandOrOutsideArea( event.getBed().getLocation()); if ((land instanceof ILand && ((ILand) land).isBanned(event .getPlayer())) || (!checkPermission(land, event.getPlayer(), PermissionList.SLEEP.getPermissionType()))) { messagePermission(event.getPlayer()); event.setCancelled(true); } } }
@EventHandler public void onPlayerInteractEvent(PlayerInteractEvent event) { Player p = event.getPlayer(); if(event.getClickedBlock() != null) { if(event.getClickedBlock().getType() == Material.BED_BLOCK && event.getAction() == Action.RIGHT_CLICK_BLOCK) { if(plugin.isActiveBedAtDay() && netminecraftclass != null) { Location loc = event.getClickedBlock().getLocation(); netminecraftclass.inBed(p, loc); Bukkit.getPluginManager().callEvent(new PlayerBedEnterEvent(p,event.getClickedBlock())); // bloc msg "You can sleep only at night" event.setCancelled(true); } } } }
@EventHandler(priority = EventPriority.LOW) public void onPlayerBedEnter(final PlayerBedEnterEvent e) { if (DEBUG) { plugin.getLogger().info(e.getEventName()); } // Check world if (Util.inWorld(e.getPlayer())) { if (actionAllowed(e.getPlayer(),e.getBed().getLocation(), SettingsFlag.BED)) { return; } // Not allowed Util.sendMessage(e.getPlayer(), plugin.getLocale(e.getPlayer().getUniqueId()).get("island.protected")); e.setCancelled(true); } }
@EventHandler public void Sleep(PlayerBedEnterEvent e){ if(rs.getPlayerData(e.getPlayer())==null)return; PlayerData pd=rs.getPlayerData(e.getPlayer()); pd.setSleep(true,1); pd.setBed(e.getBed()); e.setCancelled(false); return; }
@EventHandler public void onBedEnter(PlayerBedEnterEvent evt) { if (!evt.getBed().getWorld().equals(Core.getMainWorld())) return; updateBeds(); if (!MetadataManager.updateCooldownSilently(evt.getPlayer(), "bedSpam", 20 * 60 * 5)) Bukkit.broadcastMessage(ChatColor.GREEN.toString() + getLeftPlayers() + ChatColor.GRAY + " players need to enter a bed to skip the night."); }
@EventHandler(priority = EventPriority.NORMAL) public void onPlayerSleep(PlayerBedEnterEvent event) { if (_moon.isActive()) { event.setCancelled(true); event.getPlayer().sendMessage(ChatColor.YELLOW + "You cannot sleep during a " + ChatColor.DARK_RED + " BLOOD MOON!"); } }
@EventHandler(priority = EventPriority.NORMAL,ignoreCancelled = true) //这就是我说的那个监听器了,事件发生时会触发下面这个方法 public void onBedEnter(final PlayerBedEnterEvent e) { new BukkitRunnable(){//保证晚上 @Override public void run(){ gameworld.setTime(111111); }; }.runTaskTimer(Bukkit.getPluginManager().getPlugin("blockode"), 0L, 200L); if(isInList(e.getPlayer()) && e.getPlayer().getHealth()<e.getPlayer().getMaxHealth()){//回血 new BukkitRunnable(){ @Override public void run(){ if(e.getPlayer().getHealth()<e.getPlayer().getMaxHealth()&&e.getPlayer().isSleeping()){ e.getPlayer().setHealth(e.getPlayer().getHealth()+6); } else{ //e.getPlayer().teleport(e.getPlayer().getLocation()); ((CraftPlayer) e.getPlayer()).getHandle().a(true, false, false); e.getBed().setType(Material.AIR); cancel(); }; } }.runTaskTimer(Bukkit.getPluginManager().getPlugin("blockode"), 20L, 20L); } else{ return; } }
@EventHandler(priority = EventPriority.NORMAL,ignoreCancelled = true) //这就是我说的那个监听器了,事件发生时会触发下面这个方法 public void onBedEnter(final PlayerBedEnterEvent e) { /*new BukkitRunnable(){//保证晚上 @Override public void run(){ gameworld.setTime(111111); }; }.runTaskTimer(Bukkit.getPluginManager().getPlugin("blockode"), 0L, 200L);*/ final Damageable playerdg=(Damageable)e.getPlayer(); if(isInList(e.getPlayer()) && playerdg.getHealth()<playerdg.getMaxHealth()){//回血 new BukkitRunnable(){ @Override public void run(){ if(playerdg.getHealth()<playerdg.getMaxHealth()&&e.getPlayer().isSleeping()){ e.getPlayer().setHealth(playerdg.getHealth()+6); } else{ //e.getPlayer().teleport(e.getPlayer().getLocation()); ((CraftPlayer) e.getPlayer()).getHandle().a(true, false, false); e.getBed().setType(Material.AIR); cancel(); }; } }.runTaskTimer(Bukkit.getPluginManager().getPlugin("blockode"), 20L, 20L); } else{ return; } }
@EventHandler public void PlayerIsSleeping(PlayerBedEnterEvent event) throws InterruptedException{ final Player player = event.getPlayer(); final World world = player.getWorld(); //Broadcast to Server TextComponent message2 = new TextComponent(player.getDisplayName() + " " + lang.get("issleep." + daLang + "")); TextComponent message = new TextComponent(ChatColorUtils.setColors(getConfig().getString("cancelcolor")) + " [" + lang.get("cancel." + daLang + "") + "]"); message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,"/cancel")); message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("" + lang.get("clickcancel." + daLang + "")).create())); //this.broadcast(player.getDisplayName() + " is sleeping "); message2.addExtra(message); this.broadcast(message2); //this.broadcast(message); //player.sendMessage( message ); if(player.hasPermission("sps.hermits")||player.hasPermission("sps.op")){ //Thread.sleep(10000); if(!isCanceled){ transitionTask = this.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() { public void run() { //getLogger().info("runnable"); setDatime(player, world); } }, 10 * 20); }else{ isCanceled = false; } //player.sendMessage(ChatColor.RED + "isCanceled=" + isCanceled); }else if(!player.hasPermission("sps.hermits")||player.hasPermission("sps.op")){ player.sendMessage("" + lang.get("noperm." + daLang + "")); } }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerBedEnter(PlayerBedEnterEvent event) { World world = event.getPlayer().getWorld(); if (plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.SPAWN_ON_SLEEP)) { PluginConfig worldConfig = plugin.getConfig(world); String mobName = ListUtils.getRandom(worldConfig.getStringList(Config.FEATURE_SPAWN_ON_SLEEP_SPAWN)); EntityType creatureType = EntityType.fromName(mobName.toUpperCase()); if (creatureType != null) { //world.spawn(location, creatureType.getEntityClass(), SpawnReason.NATURAL); world.spawnEntity(event.getPlayer().getLocation(), creatureType); } } }
@HookHandler(priority = Priority.CRITICAL, ignoreCanceled = true) public void onEnteringBed(final BedEnterHook hook) { PlayerBedEnterEvent event = new PlayerBedEnterEvent(new CanaryPlayer(hook.getPlayer()), new CanaryBlock(hook.getBed())); event.setCancelled(hook.isCanceled()); server.getPluginManager().callEvent(event); if (event.isCancelled()) { hook.setCanceled(); } }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerBedEnter(PlayerBedEnterEvent event) { Player player = event.getPlayer(); NormalAchievements category = NormalAchievements.BEDS; if (!shouldIncreaseBeTakenIntoAccount(player, category) || isInCooldownPeriod(player, false, category)) { return; } updateStatisticAndAwardAchievementsIfAvailable(player, category, 1); }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) private void playerBedEnter(PlayerBedEnterEvent e) { Player player = e.getPlayer(); if (assignedTools.containsKey(player)) { Tool tool = assignedTools.get(player); if (tool.item.equals(player.getItemInHand())) { e.setCancelled(true); } } }
@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); } }
/** * Triggered everytime a player right clicks on a bed. * @param e */ @EventHandler public void onPlayerBedEnter(PlayerBedEnterEvent e) { e.getPlayer().sendMessage(ChatColor.DARK_PURPLE + "Pas le temps de dormir !"); e.setCancelled(true); }
@EventHandler public void onPlayerBedEnter(PlayerBedEnterEvent event) { Player p = event.getPlayer(); ArenaManager am = SimpleSurvivalGames.instance.getArenaManager(); // Is the current player playing if(am.isInArena(p)) { ArenaPlayer ap = am.getPlayer(p); // Is the player in the lobby of the arena if(ap.isInLobby()) { // Has the player a arena spawn assigned if(ap.hasAssignedAreanSpawn()) { // Cancel the event and send a status message event.setCancelled(true); p.sendMessage(ChatColor.DARK_RED + "You aren't tired enough to enter the bed inside the lobby of an arena!"); } } // The player may not sleep if(ap.isPlaying()) { event.setCancelled(true); p.sendMessage(ChatColor.DARK_RED + "You can't sleep while in the arena!"); } // Is the player an spectators if(ap.isSpectator()) { event.setCancelled(true); ap.sendMessage(ChatColor.DARK_RED + "You can't sleep while spectating!"); } } }
@EventHandler public void onPlayerEnterBed(PlayerBedEnterEvent event) { Player player = event.getPlayer(); SleepPlayer sleepPlayer = manData.getSleepPlayer(player); if(sleepPlayer != null){ sleepPlayer.inBed(); sleepPlayer.desactiver(); } }
@Test public void shouldHandleSimpleCancelableEvents() { withServiceMock(listenerService) .check(listener::onPlayerShear, PlayerShearEntityEvent.class) .check(listener::onPlayerFish, PlayerFishEvent.class) .check(listener::onPlayerBedEnter, PlayerBedEnterEvent.class) .check(listener::onPlayerDropItem, PlayerDropItemEvent.class) .check(listener::onPlayerHitPlayerEvent, EntityDamageByEntityEvent.class) .check(listener::onPlayerConsumeItem, PlayerItemConsumeEvent.class) .check(listener::onPlayerInteract, PlayerInteractEvent.class) .check(listener::onPlayerPickupItem, PlayerPickupItemEvent.class) .check(listener::onPlayerInteractEntity, PlayerInteractEntityEvent.class); }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onBedEnter(final PlayerBedEnterEvent event) { cancel(event, true, event.getPlayer().getWorld(), getMatch().getPlayer(event.getPlayer()), new TranslatableComponent("match.bed.disabled")); }
@EventHandler public void onPlayerBedEnter(PlayerBedEnterEvent event) { event.setCancelled(true); }
/** * Prevent exiled players from using a bed * @param e The event */ @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPlayerEnterBed(PlayerBedEnterEvent e) { checkAndCancelRule(ExileRule.USE_BED, e, e.getPlayer()); }
@EventHandler public void onBedEnter(final PlayerBedEnterEvent event) { if (!this.frozenPlayers.isEmpty() && !event.isCancelled() && this.frozenPlayers.containsKey(event.getPlayer().getUniqueId())) { event.setCancelled(true); } }
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW) public void PlayerBedEnter(final PlayerBedEnterEvent event) { if (!plugin.isLoggedIn(event.getPlayer())) event.setCancelled(true); }
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onPlayerBedEnter(PlayerBedEnterEvent event) { if (listenerService.shouldCancelEvent(event)) { event.setCancelled(true); } }
@EventHandler public void onBedEnter(final PlayerBedEnterEvent event) { if (!event.getBed().getWorld().getEnvironment().equals(Environment.NORMAL)) { return; } this.sleepingPlayers.add(event.getPlayer().getUniqueId()); if (Bukkit.getOnlinePlayers().size() == 1) { return; } // Vanilla will handle if only one player this.check(); }
@EventHandler public void e(PlayerBedEnterEvent event) { event.setCancelled(true); }