本文整理汇总了Java中org.bukkit.craftbukkit.inventory.CraftInventoryView类的典型用法代码示例。如果您正苦于以下问题:Java CraftInventoryView类的具体用法?Java CraftInventoryView怎么用?Java CraftInventoryView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CraftInventoryView类属于org.bukkit.craftbukkit.inventory包,在下文中一共展示了CraftInventoryView类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBukkitView
import org.bukkit.craftbukkit.inventory.CraftInventoryView; //导入依赖的package包/类
@Override
public InventoryView getBukkitView() {
if (bukkitEntity != null) {
return bukkitEntity;
}
CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryHorse(this.a);
return bukkitEntity = new CraftInventoryView(player.player.getBukkitEntity(), inventory, this);
}
示例2: a
import org.bukkit.craftbukkit.inventory.CraftInventoryView; //导入依赖的package包/类
public void a(Packet102WindowClick packet102windowclick) {
if (this.player.dead) return; // CraftBukkit
if (this.player.activeContainer.windowId == packet102windowclick.a && this.player.activeContainer.c(this.player)) {
// CraftBukkit start - Call InventoryClickEvent
if (packet102windowclick.slot == -1) {
// Vanilla doesn't do anything with this, neither should we
return;
}
InventoryView inventory = this.player.activeContainer.getBukkitView();
SlotType type = CraftInventoryView.getSlotType(inventory, packet102windowclick.slot);
InventoryClickEvent event = new InventoryClickEvent(inventory, type, packet102windowclick.slot, packet102windowclick.button != 0, packet102windowclick.shift == 1);
org.bukkit.inventory.Inventory top = inventory.getTopInventory();
if (packet102windowclick.slot == 0 && top instanceof CraftingInventory) {
org.bukkit.inventory.Recipe recipe = ((CraftingInventory) top).getRecipe();
if (recipe != null) {
event = new org.bukkit.event.inventory.CraftItemEvent(recipe, inventory, type, packet102windowclick.slot, packet102windowclick.button != 0, packet102windowclick.shift == 1);
}
}
server.getPluginManager().callEvent(event);
ItemStack itemstack = null;
boolean defaultBehaviour = false;
switch(event.getResult()) {
case DEFAULT:
itemstack = this.player.activeContainer.clickItem(packet102windowclick.slot, packet102windowclick.button, packet102windowclick.shift, this.player);
defaultBehaviour = true;
break;
case DENY: // Deny any change, including changes from the event
break;
case ALLOW: // Allow changes unconditionally
org.bukkit.inventory.ItemStack cursor = event.getCursor();
if (cursor == null) {
this.player.inventory.setCarried((ItemStack) null);
} else {
this.player.inventory.setCarried(CraftItemStack.asNMSCopy(cursor));
}
org.bukkit.inventory.ItemStack item = event.getCurrentItem();
if (item != null) {
itemstack = CraftItemStack.asNMSCopy(item);
if (packet102windowclick.slot == -999) {
this.player.drop(itemstack);
} else {
this.player.activeContainer.getSlot(packet102windowclick.slot).set(itemstack);
}
} else if (packet102windowclick.slot != -999) {
this.player.activeContainer.getSlot(packet102windowclick.slot).set((ItemStack) null);
}
break;
}
// CraftBukkit end
if (ItemStack.matches(packet102windowclick.item, itemstack)) {
this.player.playerConnection.sendPacket(new Packet106Transaction(packet102windowclick.a, packet102windowclick.d, true));
this.player.h = true;
this.player.activeContainer.b();
this.player.broadcastCarriedItem();
this.player.h = false;
} else {
this.r.a(this.player.activeContainer.windowId, Short.valueOf(packet102windowclick.d));
this.player.playerConnection.sendPacket(new Packet106Transaction(packet102windowclick.a, packet102windowclick.d, false));
this.player.activeContainer.a(this.player, false);
ArrayList arraylist = new ArrayList();
for (int i = 0; i < this.player.activeContainer.c.size(); ++i) {
arraylist.add(((Slot) this.player.activeContainer.c.get(i)).getItem());
}
this.player.a(this.player.activeContainer, arraylist);
// CraftBukkit start - Send a Set Slot to update the crafting result slot
if (type == SlotType.RESULT && itemstack != null) {
this.player.playerConnection.sendPacket((Packet) (new Packet103SetSlot(this.player.activeContainer.windowId, 0, itemstack)));
}
// CraftBukkit end
}
}
}