本文整理汇总了Java中org.bukkit.event.inventory.InventoryType.SlotType.RESULT属性的典型用法代码示例。如果您正苦于以下问题:Java SlotType.RESULT属性的具体用法?Java SlotType.RESULT怎么用?Java SlotType.RESULT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.event.inventory.InventoryType.SlotType
的用法示例。
在下文中一共展示了SlotType.RESULT属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onShiftCrafting
@EventHandler(priority=EventPriority.LOW)
public void onShiftCrafting(InventoryClickEvent event) {
if (event.getSlotType() == SlotType.RESULT
&& event.getClick().equals(ClickType.SHIFT_LEFT)
&& event.getWhoClicked() instanceof Player) {
Player player = (Player) event.getWhoClicked();
String playerID = PlayerConverter.getID(player);
if (containsPlayer(playerID)) {
event.setCancelled(true);
}
}
}
示例2: getSlotType
public static SlotType getSlotType(InventoryView inventory, int slot) {
SlotType type = SlotType.CONTAINER;
if (inventory == null) return type; // Cauldron - modded inventories with no Bukkit wrapper
if (slot >= 0 && slot < inventory.getTopInventory().getSize()) {
switch(inventory.getType()) {
case FURNACE:
if (slot == 2) {
type = SlotType.RESULT;
} else if(slot == 1) {
type = SlotType.FUEL;
} else {
type = SlotType.CRAFTING;
}
break;
case BREWING:
if (slot == 3) {
type = SlotType.FUEL;
} else {
type = SlotType.CRAFTING;
}
break;
case ENCHANTING:
type = SlotType.CRAFTING;
break;
case WORKBENCH:
case CRAFTING:
if (slot == 0) {
type = SlotType.RESULT;
} else {
type = SlotType.CRAFTING;
}
break;
case MERCHANT:
if (slot == 2) {
type = SlotType.RESULT;
} else {
type = SlotType.CRAFTING;
}
break;
case BEACON:
type = SlotType.CRAFTING;
break;
case ANVIL:
if (slot == 2) {
type = SlotType.RESULT;
} else {
type = SlotType.CRAFTING;
}
break;
default:
// Nothing to do, it's a CONTAINER slot
}
} else {
if (slot == -999) {
type = SlotType.OUTSIDE;
} else if (inventory.getType() == InventoryType.CRAFTING) {
if (slot < 9) {
type = SlotType.ARMOR;
} else if (slot > 35) {
type = SlotType.QUICKBAR;
}
} else if (slot >= (inventory.countSlots() - 9)) {
type = SlotType.QUICKBAR;
}
}
return type;
}
示例3: getSlotType
public static SlotType getSlotType(InventoryView inventory, int slot) {
SlotType type = SlotType.CONTAINER;
if (slot >= 0 && slot < inventory.getTopInventory().getSize()) {
switch(inventory.getType()) {
case FURNACE:
if (slot == 2) {
type = SlotType.RESULT;
} else if(slot == 1) {
type = SlotType.FUEL;
} else {
type = SlotType.CRAFTING;
}
break;
case BREWING:
if (slot == 3) {
type = SlotType.FUEL;
} else {
type = SlotType.CRAFTING;
}
break;
case ENCHANTING:
type = SlotType.CRAFTING;
break;
case WORKBENCH:
case CRAFTING:
if (slot == 0) {
type = SlotType.RESULT;
} else {
type = SlotType.CRAFTING;
}
break;
case MERCHANT:
if (slot == 2) {
type = SlotType.RESULT;
} else {
type = SlotType.CRAFTING;
}
break;
case BEACON:
type = SlotType.CRAFTING;
break;
case ANVIL:
if (slot == 2) {
type = SlotType.RESULT;
} else {
type = SlotType.CRAFTING;
}
break;
default:
// Nothing to do, it's a CONTAINER slot
}
} else {
if (slot == -999) {
type = SlotType.OUTSIDE;
} else if (inventory.getType() == InventoryType.CRAFTING) {
if (slot < 9) {
type = SlotType.ARMOR;
} else if (slot > 35) {
type = SlotType.QUICKBAR;
}
} else if (slot >= (inventory.countSlots() - 9)) {
type = SlotType.QUICKBAR;
}
}
return type;
}
示例4: getSlotType
public static SlotType getSlotType(InventoryView inventory, int slot) {
SlotType type = SlotType.CONTAINER;
if (slot >= 0 && slot < inventory.getTopInventory().getSize()) {
switch(inventory.getType()) {
case FURNACE:
if (slot == 2) {
type = SlotType.RESULT;
} else if(slot == 1) {
type = SlotType.FUEL;
}
break;
case BREWING:
if (slot == 3) {
type = SlotType.FUEL;
} else {
type = SlotType.CRAFTING;
}
break;
case ENCHANTING:
type = SlotType.CRAFTING;
break;
case WORKBENCH:
case CRAFTING:
if (slot == 0) {
type = SlotType.RESULT;
} else {
type = SlotType.CRAFTING;
}
break;
case MERCHANT:
if (slot == 2) {
type = SlotType.RESULT;
} else {
type = SlotType.CRAFTING;
}
break;
case BEACON:
type = SlotType.CRAFTING;
break;
case ANVIL:
if (slot == 2) {
type = SlotType.RESULT;
} else {
type = SlotType.CRAFTING;
}
break;
default:
// Nothing to do, it's a CONTAINER slot
}
} else {
if (slot == -999) {
type = SlotType.OUTSIDE;
} else if (inventory.getType() == InventoryType.CRAFTING && slot < 9) {
type = SlotType.ARMOR;
} else if (slot >= (inventory.countSlots() - 9)) {
type = SlotType.QUICKBAR;
}
}
return type;
}
示例5: getSlotType
public static SlotType getSlotType(InventoryView inventory, int slot) {
SlotType type = SlotType.CONTAINER;
if (slot >= 0 && slot < inventory.getTopInventory().getSize()) {
switch(inventory.getType()) {
case FURNACE:
if (slot == 2) {
type = SlotType.RESULT;
} else if(slot == 1) {
type = SlotType.FUEL;
} else {
type = SlotType.CRAFTING;
}
break;
case BREWING:
if (slot == 3) {
type = SlotType.FUEL;
} else {
type = SlotType.CRAFTING;
}
break;
case ENCHANTING:
type = SlotType.CRAFTING;
break;
case WORKBENCH:
case CRAFTING:
if (slot == 0) {
type = SlotType.RESULT;
} else {
type = SlotType.CRAFTING;
}
break;
case MERCHANT:
if (slot == 2) {
type = SlotType.RESULT;
} else {
type = SlotType.CRAFTING;
}
break;
case BEACON:
type = SlotType.CRAFTING;
break;
case ANVIL:
if (slot == 2) {
type = SlotType.RESULT;
} else {
type = SlotType.CRAFTING;
}
break;
default:
// Nothing to do, it's a CONTAINER slot
}
} else {
if (slot == -999 || slot == -1) {
type = SlotType.OUTSIDE;
} else if (inventory.getType() == InventoryType.CRAFTING) {
if (slot < 9) {
type = SlotType.ARMOR;
} else if (slot > 35) {
type = SlotType.QUICKBAR;
}
} else if (slot >= (inventory.countSlots() - 9)) {
type = SlotType.QUICKBAR;
}
}
return type;
}
示例6: a
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
}
}
}
示例7: getSlotType
public static SlotType getSlotType(InventoryView inventory, int slot) {
SlotType type = SlotType.CONTAINER;
if (slot < inventory.getTopInventory().getSize()) {
switch(inventory.getType()) {
case FURNACE:
if (slot == 2) {
type = SlotType.RESULT;
} else if(slot == 1) {
type = SlotType.FUEL;
}
break;
case BREWING:
if (slot == 0) {
type = SlotType.FUEL;
} else {
type = SlotType.CRAFTING;
}
break;
case ENCHANTING:
type = SlotType.CRAFTING;
break;
case WORKBENCH:
case CRAFTING:
if (slot == 0) {
type = SlotType.RESULT;
} else {
type = SlotType.CRAFTING;
}
break;
case MERCHANT:
if (slot == 2) {
type = SlotType.RESULT;
} else {
type = SlotType.CRAFTING;
}
break;
case BEACON:
type = SlotType.CRAFTING;
break;
case ANVIL:
if (slot == 2) {
type = SlotType.RESULT;
} else {
type = SlotType.CRAFTING;
}
break;
default:
// Nothing to do, it's a CONTAINER slot
}
} else {
if (slot == -999) {
type = SlotType.OUTSIDE;
} else if (inventory.getType() == InventoryType.CRAFTING && slot < 9) {
type = SlotType.ARMOR;
} else if (slot >= (inventory.countSlots() - 9)) {
type = SlotType.QUICKBAR;
}
}
return type;
}
示例8: onInventoryClick
public void onInventoryClick(InventoryClickEvent event) {
if (event.getInventory().getType() == InventoryType.ANVIL && event.getSlotType() == SlotType.RESULT) {
Inventory anvil = event.getInventory();
ItemStack anvilResult = anvil.getItem(event.getSlot());
}
}