本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}