@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()));
}
java类org.bukkit.event.player.PlayerBedEnterEvent的实例源码
EnteredBedsListener.java 文件源码
项目:Statz
阅读 32
收藏 0
点赞 0
评论 0
PlayerListener.java 文件源码
项目:BedwarsRel
阅读 31
收藏 0
点赞 0
评论 0
@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);
}
HomeCommand.java 文件源码
项目:vanillacraft
阅读 32
收藏 0
点赞 0
评论 0
@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());
}
}
}
}
BlockListener.java 文件源码
项目:civcraft
阅读 23
收藏 0
点赞 0
评论 0
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;
}
}
}
PlayerListener.java 文件源码
项目:Factoid
阅读 32
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
}
PlayerEvent.java 文件源码
项目:SleepingPlus
阅读 24
收藏 0
点赞 0
评论 0
@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);
}
}
}
}
IslandGuard.java 文件源码
项目:bskyblock
阅读 26
收藏 0
点赞 0
评论 0
@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);
}
}
SleepEvent.java 文件源码
项目:RealSurvival
阅读 25
收藏 0
点赞 0
评论 0
@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;
}
SleepMechanics.java 文件源码
项目:Kineticraft
阅读 33
收藏 0
点赞 0
评论 0
@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.");
}
MonsterSpawnListener.java 文件源码
项目:world-of-icerealm
阅读 25
收藏 0
点赞 0
评论 0
@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!");
}
}
Blockode.java 文件源码
项目:CraftPlugins
阅读 32
收藏 0
点赞 0
评论 0
@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;
}
}
Blockode.java 文件源码
项目:CraftPlugins
阅读 31
收藏 0
点赞 0
评论 0
@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;
}
}
Blockode.java 文件源码
项目:CraftPlugins
阅读 24
收藏 0
点赞 0
评论 0
@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;
}
}
Blockode.java 文件源码
项目:CraftPlugins
阅读 30
收藏 0
点赞 0
评论 0
@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;
}
}
PluginBase.java 文件源码
项目:SinglePlayerSleep
阅读 27
收藏 0
点赞 0
评论 0
@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 + ""));
}
}
SpawnOnSleepListener.java 文件源码
项目:BloodMoon
阅读 26
收藏 0
点赞 0
评论 0
@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);
}
}
}
CanaryPlayerListener.java 文件源码
项目:CanaryBukkit
阅读 28
收藏 0
点赞 0
评论 0
@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();
}
}
AchieveBedListener.java 文件源码
项目:AdvancedAchievements
阅读 27
收藏 0
点赞 0
评论 0
@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);
}
ToolBox.java 文件源码
项目:libelula
阅读 37
收藏 0
点赞 0
评论 0
@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);
}
}
}
IslandGuard.java 文件源码
项目:acidisland
阅读 29
收藏 0
点赞 0
评论 0
@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);
}
}
IslandGuard.java 文件源码
项目:askyblock
阅读 35
收藏 0
点赞 0
评论 0
@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);
}
}
Running.java 文件源码
项目:Scapegoat
阅读 29
收藏 0
点赞 0
评论 0
/**
* 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);
}
SSGPlayerListener.java 文件源码
项目:simple-survival-games
阅读 37
收藏 0
点赞 0
评论 0
@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!");
}
}
}
PlayerEvent.java 文件源码
项目:SleepingPlus
阅读 24
收藏 0
点赞 0
评论 0
@EventHandler
public void onPlayerEnterBed(PlayerBedEnterEvent event)
{
Player player = event.getPlayer();
SleepPlayer sleepPlayer = manData.getSleepPlayer(player);
if(sleepPlayer != null){
sleepPlayer.inBed();
sleepPlayer.desactiver();
}
}
PlayerListenerTest.java 文件源码
项目:AuthMeReloaded
阅读 28
收藏 0
点赞 0
评论 0
@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);
}
EventFilterMatchModule.java 文件源码
项目:ProjectAres
阅读 25
收藏 0
点赞 0
评论 0
@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"));
}
PlayerInteractListener.java 文件源码
项目:Breakpoint
阅读 25
收藏 0
点赞 0
评论 0
@EventHandler
public void onPlayerBedEnter(PlayerBedEnterEvent event)
{
event.setCancelled(true);
}
ExileListener.java 文件源码
项目:ExilePearl
阅读 36
收藏 0
点赞 0
评论 0
/**
* 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());
}
PlayerInteractListener.java 文件源码
项目:Breakpoint
阅读 23
收藏 0
点赞 0
评论 0
@EventHandler
public void onPlayerBedEnter(PlayerBedEnterEvent event)
{
event.setCancelled(true);
}
FreezeComponent.java 文件源码
项目:CraftoPlugin
阅读 35
收藏 0
点赞 0
评论 0
@EventHandler
public void onBedEnter(final PlayerBedEnterEvent event) {
if (!this.frozenPlayers.isEmpty() && !event.isCancelled() && this.frozenPlayers.containsKey(event.getPlayer().getUniqueId())) {
event.setCancelled(true);
}
}