当前位置: 首页>>代码示例>>Java>>正文


Java Player.sleepOn方法代码示例

本文整理汇总了Java中cn.nukkit.Player.sleepOn方法的典型用法代码示例。如果您正苦于以下问题:Java Player.sleepOn方法的具体用法?Java Player.sleepOn怎么用?Java Player.sleepOn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cn.nukkit.Player的用法示例。


在下文中一共展示了Player.sleepOn方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onActivate

import cn.nukkit.Player; //导入方法依赖的package包/类
@Override
public boolean onActivate(Item item, Player player) {
    int time = this.getLevel().getTime() % Level.TIME_FULL;

    boolean isNight = (time >= Level.TIME_NIGHT && time < Level.TIME_SUNRISE);

    if (player != null && !isNight) {
        player.sendMessage(new TranslationContainer("tile.bed.noSleep"));
        return true;
    }

    Block blockNorth = this.north();
    Block blockSouth = this.south();
    Block blockEast = this.east();
    Block blockWest = this.west();

    Block b;
    if ((this.meta & 0x08) == 0x08) {
        b = this;
    } else {
        if (blockNorth.getId() == this.getId() && (blockNorth.meta & 0x08) == 0x08) {
            b = blockNorth;
        } else if (blockSouth.getId() == this.getId() && (blockSouth.meta & 0x08) == 0x08) {
            b = blockSouth;
        } else if (blockEast.getId() == this.getId() && (blockEast.meta & 0x08) == 0x08) {
            b = blockEast;
        } else if (blockWest.getId() == this.getId() && (blockWest.meta & 0x08) == 0x08) {
            b = blockWest;
        } else {
            if (player != null) {
                player.sendMessage(new TranslationContainer("tile.bed.notValid"));
            }

            return true;
        }
    }

    if (player != null && !player.sleepOn(b)) {
        player.sendMessage(new TranslationContainer("tile.bed.occupied"));
    }


    return true;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:45,代码来源:BlockBed.java

示例2: onActivate

import cn.nukkit.Player; //导入方法依赖的package包/类
@Override
public boolean onActivate(Item item, Player player) {
    if (this.getLevel().getDimension() != Level.DIMENSION_OVERWORLD) {
        BedExplosionEvent event = new BedExplosionEvent(player, this, 4);
        Server.getInstance().getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            return true;
        }
        Explosion explosion = new Explosion(this, event.getForce(), this);
        explosion.explodeA();

        return false;
    } 

    int time = this.getLevel().getTime() % Level.TIME_FULL;

    boolean isNight = (time >= Level.TIME_NIGHT && time < Level.TIME_SUNRISE);

    if (player != null && !isNight) {
        player.sendMessage(TextFormat.GRAY + "You can only sleep at night");
        return true;
    }

    Block blockNorth = this.north();
    Block blockSouth = this.south();
    Block blockEast = this.east();
    Block blockWest = this.west();

    Block b;
    if ((this.meta & 0x08) == 0x08) {
        b = this;
    } else {
        if (blockNorth.getId() == this.getId() && (blockNorth.meta & 0x08) == 0x08) {
            b = blockNorth;
        } else if (blockSouth.getId() == this.getId() && (blockSouth.meta & 0x08) == 0x08) {
            b = blockSouth;
        } else if (blockEast.getId() == this.getId() && (blockEast.meta & 0x08) == 0x08) {
            b = blockEast;
        } else if (blockWest.getId() == this.getId() && (blockWest.meta & 0x08) == 0x08) {
            b = blockWest;
        } else {
            if (player != null) {
                player.sendMessage(TextFormat.GRAY + "This bed is incomplete");
            }

            return true;
        }
    }

    if (player != null && !player.sleepOn(b)) {
        player.sendMessage(TextFormat.GRAY + "This bed is occupied");
    }


    return true;
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:57,代码来源:BlockBed.java

示例3: onActivate

import cn.nukkit.Player; //导入方法依赖的package包/类
@Override
public boolean onActivate(Item item, Player player) {
    int time = this.getLevel().getTime() % Level.TIME_FULL;

    boolean isNight = (time >= Level.TIME_NIGHT && time < Level.TIME_SUNRISE);

    if (player != null && !isNight) {
        player.sendMessage(TextFormat.GRAY + "You can only sleep at night");
        return true;
    }

    Block blockNorth = this.north();
    Block blockSouth = this.south();
    Block blockEast = this.east();
    Block blockWest = this.west();

    Block b;
    if ((this.meta & 0x08) == 0x08) {
        b = this;
    } else {
        if (blockNorth.getId() == this.getId() && (blockNorth.meta & 0x08) == 0x08) {
            b = blockNorth;
        } else if (blockSouth.getId() == this.getId() && (blockSouth.meta & 0x08) == 0x08) {
            b = blockSouth;
        } else if (blockEast.getId() == this.getId() && (blockEast.meta & 0x08) == 0x08) {
            b = blockEast;
        } else if (blockWest.getId() == this.getId() && (blockWest.meta & 0x08) == 0x08) {
            b = blockWest;
        } else {
            if (player != null) {
                player.sendMessage(TextFormat.GRAY + "This bed is incomplete");
            }

            return true;
        }
    }

    if (player != null && !player.sleepOn(b)) {
        player.sendMessage(TextFormat.GRAY + "This bed is occupied");
    }


    return true;
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:45,代码来源:BlockBed.java


注:本文中的cn.nukkit.Player.sleepOn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。