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


Java EntityInventoryChangeEvent.isCancelled方法代码示例

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


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

示例1: setItem

import cn.nukkit.event.entity.EntityInventoryChangeEvent; //导入方法依赖的package包/类
@Override
public boolean setItem(int index, Item item, boolean send) {
    item = item.clone();
    if (index < 0 || index >= this.size) {
        return false;
    } else if (item.getId() == 0 || item.getCount() <= 0) {
        return this.clear(index);
    }

    InventoryHolder holder = this.getHolder();
    if (holder instanceof Entity) {
        EntityInventoryChangeEvent ev = new EntityInventoryChangeEvent((Entity) holder, this.getItem(index), item, index);
        Server.getInstance().getPluginManager().callEvent(ev);
        if (ev.isCancelled()) {
            this.sendSlot(index, this.getViewers());
            return false;
        }

        item = ev.getNewItem();
    }

    Item old = this.getItem(index);
    this.slots.put(index, item.clone());
    this.onSlotChange(index, old, send);

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

示例2: clear

import cn.nukkit.event.entity.EntityInventoryChangeEvent; //导入方法依赖的package包/类
@Override
public boolean clear(int index, boolean send) {
    if (this.slots.containsKey(index)) {
        Item item = new ItemBlock(new BlockAir(), null, 0);
        Item old = this.slots.get(index);
        InventoryHolder holder = this.getHolder();
        if (holder instanceof Entity) {
            EntityInventoryChangeEvent ev = new EntityInventoryChangeEvent((Entity) holder, old, item, index);
            Server.getInstance().getPluginManager().callEvent(ev);
            if (ev.isCancelled()) {
                this.sendSlot(index, this.getViewers());
                return false;
            }
            item = ev.getNewItem();
        }

        if (item.getId() != Item.AIR) {
            this.slots.put(index, item.clone());
        } else {
            this.slots.remove(index);
        }

        this.onSlotChange(index, old, send);
    }

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

示例3: setItem

import cn.nukkit.event.entity.EntityInventoryChangeEvent; //导入方法依赖的package包/类
@Override
public boolean setItem(int index, Item item, boolean send) {
    item = item.clone();
    if (index < 0 || index >= this.size) {
        return false;
    } else if (item.getId() == 0 || item.getCount() <= 0) {
        return this.clear(index, send);
    }

    InventoryHolder holder = this.getHolder();
    if (holder instanceof Entity) {
        EntityInventoryChangeEvent ev = new EntityInventoryChangeEvent((Entity) holder, this, this.getItem(index), item, index);
        Server.getInstance().getPluginManager().callEvent(ev);
        if (ev.isCancelled()) {
            this.sendSlot(index, this.getViewers());
            return false;
        }

        item = ev.getNewItem();
    }

    Item old = this.getItem(index);
    this.slots.put(index, item.clone());
    this.onSlotChange(index, old, send);

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

示例4: clear

import cn.nukkit.event.entity.EntityInventoryChangeEvent; //导入方法依赖的package包/类
@Override
public boolean clear(int index, boolean send) {
    if (this.slots.containsKey(index)) {
        Item item = new ItemBlock(new BlockAir(), null, 0);
        Item old = this.slots.get(index);
        InventoryHolder holder = this.getHolder();
        if (holder instanceof Entity) {
            EntityInventoryChangeEvent ev = new EntityInventoryChangeEvent((Entity) holder, this, old, item, index);
            Server.getInstance().getPluginManager().callEvent(ev);
            if (ev.isCancelled()) {
                this.sendSlot(index, this.getViewers());
                return false;
            }
            item = ev.getNewItem();
        }

        if (item.getId() != Item.AIR) {
            this.slots.put(index, item.clone());
        } else {
            this.slots.remove(index);
        }

        this.onSlotChange(index, old, send);
    }

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

示例5: setItem

import cn.nukkit.event.entity.EntityInventoryChangeEvent; //导入方法依赖的package包/类
@Override
public boolean setItem(int index, Item item) {
    item = item.clone();
    if (index < 0 || index >= this.size) {
        return false;
    } else if (item.getId() == 0 || item.getCount() <= 0) {
        return this.clear(index);
    }

    InventoryHolder holder = this.getHolder();
    if (holder instanceof Entity) {
        EntityInventoryChangeEvent ev = new EntityInventoryChangeEvent((Entity) holder, this.getItem(index), item, index);
        Server.getInstance().getPluginManager().callEvent(ev);
        if (ev.isCancelled()) {
            this.sendSlot(index, this.getViewers());
            return false;
        }

        item = ev.getNewItem();
    }

    Item old = this.getItem(index);
    this.slots.put(index, item.clone());
    this.onSlotChange(index, old);

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

示例6: clear

import cn.nukkit.event.entity.EntityInventoryChangeEvent; //导入方法依赖的package包/类
@Override
public boolean clear(int index) {
    if (this.slots.containsKey(index)) {
        Item item = new ItemBlock(new BlockAir(), null, 0);
        Item old = this.slots.get(index);
        InventoryHolder holder = this.getHolder();
        if (holder instanceof Entity) {
            EntityInventoryChangeEvent ev = new EntityInventoryChangeEvent((Entity) holder, old, item, index);
            Server.getInstance().getPluginManager().callEvent(ev);
            if (ev.isCancelled()) {
                this.sendSlot(index, this.getViewers());
                return false;
            }
            item = ev.getNewItem();
        }

        if (item.getId() != Item.AIR) {
            this.slots.put(index, item.clone());
        } else {
            this.slots.remove(index);
        }

        this.onSlotChange(index, old);
    }

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


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