本文整理汇总了Java中org.bukkit.event.inventory.InventoryType.SlotType.OUTSIDE属性的典型用法代码示例。如果您正苦于以下问题:Java SlotType.OUTSIDE属性的具体用法?Java SlotType.OUTSIDE怎么用?Java SlotType.OUTSIDE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.event.inventory.InventoryType.SlotType
的用法示例。
在下文中一共展示了SlotType.OUTSIDE属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCurrentItem
/**
* Gets the ItemStack currently in the clicked slot.
*
* @return the item in the clicked
*/
public ItemStack getCurrentItem() {
if (slot_type == SlotType.OUTSIDE) {
return current;
}
return getView().getItem(rawSlot);
}
示例2: setCurrentItem
/**
* Sets the ItemStack currently in the clicked slot.
*
* @param stack the item to be placed in the current slot
*/
public void setCurrentItem(ItemStack stack) {
if (slot_type == SlotType.OUTSIDE) {
current = stack;
} else {
getView().setItem(rawSlot, stack);
}
}
示例3: getCurrentItem
/**
* Gets the ItemStack currently in the clicked slot. Returns air for empty
* slots and null for clicking outside the inventory.
*
* @return the item in the clicked slot
*/
public ItemStack getCurrentItem() {
if (slot_type == SlotType.OUTSIDE) {
return current;
}
return getView().getItem(rawSlot);
}
示例4: 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;
}
示例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) {
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: onInventoryClick
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
// TODO : this needs optimization
Player player = (Player) event.getWhoClicked(); // The player that
// clicked the item
ItemStack clicked = event.getCurrentItem(); // The item that was clicked
Inventory inventory = event.getInventory(); // The inventory that was
// clicked in
int slot = event.getRawSlot();
// Challenges
if (inventory.getName().equals(plugin.myLocale(player.getUniqueId()).challengesguiTitle)) {
event.setCancelled(true);
if (event.getSlotType() == SlotType.OUTSIDE) {
player.closeInventory();
return;
}
// Get the list of items in this inventory
// plugin.getLogger().info("DEBUG: You clicked on slot " + slot);
List<CPItem> challenges = plugin.getChallenges().getCP(player);
if (challenges == null) {
plugin.getLogger().warning("Player was accessing Challenge Inventory, but it had lost state - was server restarted?");
player.closeInventory();
player.performCommand(Settings.CHALLENGECOMMAND);
return;
}
// plugin.getLogger().info("DEBUG: Challenges size = " +
// challenges.size());
if (slot >= 0 && slot < challenges.size()) {
CPItem item = challenges.get(slot);
// Check that it is the top items that are being clicked on
// These two should be identical because it is made before
if (clicked.equals(item.getItem())) {
// Next section indicates the level of panel to open
if (item.getNextSection() != null) {
player.closeInventory();
player.openInventory(plugin.getChallenges().challengePanel(player, item.getNextSection()));
} else if (item.getCommand() != null) {
player.performCommand(item.getCommand());
player.closeInventory();
player.openInventory(plugin.getChallenges().challengePanel(player));
}
}
}
}
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: runInventoryChecks
public int runInventoryChecks(Player p, Inventory inv, InventoryAction ia, InventoryClickEvent event) {
if (p.isBlocking() || p.isSneaking() || p.isSprinting() || p.isSleeping()) {
if (this.vars.issueViolation(p, CheckType.IMPOSSIBLE_CLICK)) {
return 1;
}
}
long rdif = (System.currentTimeMillis() - this.getLastViolation(p.getName()));
if (rdif <= 2000) {
return 1;//Prevent abuse to bypass check
}
if (ia == InventoryAction.NOTHING) {//Who was the idiot that added this -_-
return 0;
}
if (p.getGameMode() == GameMode.CREATIVE) {
if (inv.getType() == InventoryType.PLAYER || inv.getType() == InventoryType.CREATIVE) {
if (event.getSlotType() != SlotType.OUTSIDE) {//We want to check for fastdrops which in turn = lag
this.lastviolation.put(p.getName(), System.currentTimeMillis());
return 0;
}
}
}
if (Settings.debug) {
Bukkit.broadcastMessage("Type: " + inv.getType() + "; Action: " + ia.toString().toLowerCase());
}
long diff = (System.currentTimeMillis() - this.getLastClicked(p.getName()));
if (diff <= Settings.fcs) {
if (this.vars.issueViolation(p, CheckType.SPEED_CLICK)) {
return 1;
}
}
this.lastclick.put(p.getName(), System.currentTimeMillis());
return 0;
}