當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。