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


Java Player.getId方法代码示例

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


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

示例1: sendHeldItem

import cn.nukkit.Player; //导入方法依赖的package包/类
public void sendHeldItem(Player... players) {
    Item item = this.getItemInHand();

    MobEquipmentPacket pk = new MobEquipmentPacket();
    pk.item = item;
    pk.inventorySlot = pk.hotbarSlot = this.getHeldItemIndex();

    for (Player player : players) {
        pk.eid = this.getHolder().getId();
        if (player.equals(this.getHolder())) {
            pk.eid = player.getId();
            this.sendSlot(this.getHeldItemIndex(), player);
        }

        player.dataPacket(pk);
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:18,代码来源:PlayerInventory.java

示例2: onOpen

import cn.nukkit.Player; //导入方法依赖的package包/类
@Override
public void onOpen(Player who) {
    CompoundTag nbt = this.getHolder().getOffers();
    if (nbt != null) {
        super.onOpen(who);

        UpdateTradePacket pk1 = new UpdateTradePacket();
        pk1.windowId = (byte) who.getWindowId(this);
        pk1.windowType = 15;
        pk1.unknownVarInt1 = 0;
        pk1.unknownVarInt2 = 0;
        pk1.isWilling = false;
        pk1.trader = this.getHolder().getId();
        pk1.player = who.getId();
        pk1.displayName = this.getHolder().getName();
        try {
            pk1.offers = NBTIO.write(nbt, ByteOrder.LITTLE_ENDIAN, true);
        } catch (IOException e) {
            e.printStackTrace();
        }
        who.dataPacket(pk1);
    } else {
        super.onClose(who);
    }
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:26,代码来源:TradingInventory.java

示例3: sendHeldItem

import cn.nukkit.Player; //导入方法依赖的package包/类
public void sendHeldItem(Player... players) {
    Item item = this.getItemInHand();

    MobEquipmentPacket pk = new MobEquipmentPacket();
    pk.item = item;
    pk.inventorySlot = pk.hotbarSlot = this.getHeldItemIndex();

    for (Player player : players) {
        pk.entityRuntimeId = this.getHolder().getId();
        if (player.equals(this.getHolder())) {
            pk.entityRuntimeId = player.getId();
            this.sendSlot(this.getHeldItemIndex(), player);
        }

        player.dataPacket(pk);
    }
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:18,代码来源:PlayerInventory.java

示例4: sendHeldItem

import cn.nukkit.Player; //导入方法依赖的package包/类
public void sendHeldItem(Player[] players) {
    Item item = this.getItemInHand();

    MobEquipmentPacket pk = new MobEquipmentPacket();
    pk.item = item;
    pk.slot = (byte) this.getHeldItemSlot();
    pk.selectedSlot = (byte) this.getHeldItemIndex();

    for (Player player : players) {
        pk.eid = this.getHolder().getId();
        if (player.equals(this.getHolder())) {
            pk.eid = player.getId();
            this.sendSlot(this.getHeldItemSlot(), player);
        }

        player.dataPacket(pk);
    }
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:19,代码来源:PlayerInventory.java

示例5: sendArmorContents

import cn.nukkit.Player; //导入方法依赖的package包/类
public void sendArmorContents(Player[] players) {
    Item[] armor = this.getArmorContents();

    MobArmorEquipmentPacket pk = new MobArmorEquipmentPacket();
    pk.eid = this.getHolder().getId();
    pk.slots = armor;
    pk.encode();
    pk.isEncoded = true;

    for (Player player : players) {
        if (player.equals(this.getHolder())) {
            ContainerSetContentPacket pk2 = new ContainerSetContentPacket();
            pk2.windowid = ContainerSetContentPacket.SPECIAL_ARMOR;
            pk2.eid = player.getId();
            pk2.slots = armor;
            player.dataPacket(pk2);
        } else {
            player.dataPacket(pk);
        }
    }
}
 
开发者ID:CoreXDevelopment,项目名称:CoreX,代码行数:22,代码来源:PlayerInventory.java

示例6: sendContents

import cn.nukkit.Player; //导入方法依赖的package包/类
@Override
public void sendContents(Player[] players) {
    ContainerSetContentPacket pk = new ContainerSetContentPacket();
    pk.slots = new Item[this.getSize()];
    for (int i = 0; i < this.getSize(); ++i) {
        pk.slots[i] = this.getItem(i);
    }

    for (Player player : players) {
        pk.eid = player.getId();
        int id = player.getWindowId(this);
        if (id == -1 || !player.spawned) {
            this.close(player);
            continue;
        }
        pk.windowid = (byte) id;
        player.dataPacket(pk);
    }
}
 
开发者ID:CoreXDevelopment,项目名称:CoreX,代码行数:20,代码来源:BaseInventory.java

示例7: onCollideWithPlayer

import cn.nukkit.Player; //导入方法依赖的package包/类
@Override
public void onCollideWithPlayer(Player player) {
    if(this.getPickupDelay() > 0) {
        return;
    }

    Item item = this.getItem();
    PlayerInventory playerInventory = player.getInventory();

    if(!(item instanceof Item) || (player.isSurvival() && !playerInventory.canAddItem(item))) {
        return;
    }

    InventoryPickupItemEvent ev;
    this.server.getPluginManager().callEvent(ev = new InventoryPickupItemEvent(playerInventory, this));
    if(ev.isCancelled()) {
        return;
    }

    TakeItemEntityPacket pk = new TakeItemEntityPacket();
    pk.entityRuntimeId = player.getId();
    pk.target = this.getId();
    Server.broadcastPacket(this.getViewers().values(), pk);

    playerInventory.addItem(item);
    this.kill();
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:28,代码来源:EntityItem.java

示例8: onCollideWithPlayer

import cn.nukkit.Player; //导入方法依赖的package包/类
@Override
public void onCollideWithPlayer(Player player) {
    if(!this.hadCollision) {
        return;
    }

    Item item = new Item(Item.ARROW, 0, 1);
    PlayerInventory playerInventory = player.getInventory();

    if(player.isSurvival() && playerInventory.canAddItem(item)) {
        return;
    }

    InventoryPickupArrowEvent ev;
    this.server.getPluginManager().callEvent(ev = new InventoryPickupArrowEvent(playerInventory, this));
    if(ev.isCancelled()) {
        return;
    }

    TakeItemEntityPacket pk = new TakeItemEntityPacket();
    pk.entityRuntimeId = player.getId();
    pk.target = this.getId();
    Server.broadcastPacket(this.getViewers().values(), pk);

    playerInventory.addItem(item);
    this.kill();
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:28,代码来源:EntityArrow.java

示例9: sendPotionEffects

import cn.nukkit.Player; //导入方法依赖的package包/类
public void sendPotionEffects(Player player) {
    for (Effect effect : this.effects.values()) {
        MobEffectPacket pk = new MobEffectPacket();
        pk.eid = player.getId();
        pk.effectId = effect.getId();
        pk.amplifier = effect.getAmplifier();
        pk.particles = effect.isVisible();
        pk.duration = effect.getDuration();
        pk.eventId = MobEffectPacket.EVENT_ADD;

        player.dataPacket(pk);
    }
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:14,代码来源:Entity.java

示例10: sendContents

import cn.nukkit.Player; //导入方法依赖的package包/类
@Override
public void sendContents(Player[] players) {
    ContainerSetContentPacket pk = new ContainerSetContentPacket();
    pk.slots = new Item[this.getSize() +  + this.getHotbarSize()];
    for (int i = 0; i < this.getSize(); ++i) {
        pk.slots[i] = this.getItem(i);
    }

    //Because PE is stupid and shows 9 less slots than you send it, give it 9 dummy slots so it shows all the REAL slots.
    for(int i = this.getSize(); i < this.getSize() + this.getHotbarSize(); ++i){
        pk.slots[i] = new ItemBlock(new BlockAir());
    }

    for (Player player : players) {
        if (player.equals(this.getHolder())) {
            pk.hotbar = new int[this.getHotbarSize()];
            for (int i = 0; i < this.getHotbarSize(); ++i) {
                int index = this.getHotbarSlotIndex(i);
                pk.hotbar[i] = index <= -1 ? -1 : index + 9;
            }
        }
        int id = player.getWindowId(this);
        if (id == -1 || !player.spawned) {
            this.close(player);
            continue;
        }
        pk.eid = player.getId();
        pk.windowid = (byte) id;
        player.dataPacket(pk.clone());
    }
}
 
开发者ID:CoreXDevelopment,项目名称:CoreX,代码行数:32,代码来源:PlayerInventory.java


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