本文整理匯總了Java中org.bukkit.event.inventory.InventoryAction.NOTHING屬性的典型用法代碼示例。如果您正苦於以下問題:Java InventoryAction.NOTHING屬性的具體用法?Java InventoryAction.NOTHING怎麽用?Java InventoryAction.NOTHING使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.bukkit.event.inventory.InventoryAction
的用法示例。
在下文中一共展示了InventoryAction.NOTHING屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onBackpackClick
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onBackpackClick(final InventoryClickEvent event) {
final Inventory inventory = event.getInventory();
final Player player = (Player) event.getWhoClicked();
if (!InventoryManager.playerIsLoaded(player)) {
return;
}
if (inventory.getHolder() instanceof BackpackHolder) {
// Click inside backpack
if (BackpackManager.isBackpack(event.getCurrentItem())
|| BackpackManager.isBackpack(event.getCursor())
|| InventoryManager.isFilledSlot(event.getCurrentItem())
|| InventoryManager.isFilledSlot(event.getCursor())) {
event.setCancelled(true);
return;
}
// Save changes
if (event.getAction() == InventoryAction.NOTHING) {
return;
}
BackpackUpdater.update(inventory, InventoryManager.get(player).getBackpack());
} else if ((event.getRawSlot() >= event.getView().getTopInventory().getSize()
|| event.getSlot() == SlotManager.instance().getBackpackSlot().getSlotId()
&& InventoryAPI.isRPGInventory(event.getInventory()))
&& !BackpackManager.playerCanTakeBackpack(player)
&& BackpackManager.isBackpack(event.getCursor())
&& ActionType.getTypeOfAction(event.getAction()) == ActionType.SET) {
// Prevent placing new backpack in bottom inventory if player can't take backpack
int limit = BackpackManager.getLimit();
String message = RPGInventory.getLanguage().getMessage("backpack.limit", limit);
PlayerUtils.sendMessage(player, message);
event.setCancelled(true);
}
}
示例2: onInventoryClick
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryClick(InventoryClickEvent event) {
if (event.getRawSlot() < 0 || event.getRawSlot() > 2 || event.getCurrentItem() == null
|| event.getCurrentItem().getType() == Material.AIR || event.getAction() == InventoryAction.NOTHING
|| event.getClick() == ClickType.NUMBER_KEY
&& event.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD) {
return;
}
Player player = (Player) event.getWhoClicked();
NormalAchievements category;
InventoryType inventoryType = event.getInventory().getType();
if (event.getRawSlot() == 2 && inventoryType == InventoryType.MERCHANT) {
category = NormalAchievements.TRADES;
} else if (event.getRawSlot() == 2 && inventoryType == InventoryType.ANVIL) {
category = NormalAchievements.ANVILS;
} else if (inventoryType == InventoryType.BREWING
&& (event.getCurrentItem().getType() == Material.POTION
|| plugin.getServerVersion() >= 9 && event.getCurrentItem().getType() == Material.SPLASH_POTION)
&& !isWaterPotion(event.getCurrentItem())) {
category = NormalAchievements.BREWING;
} else if (event.getRawSlot() == 2 && inventoryType == InventoryType.FURNACE) {
category = NormalAchievements.SMELTING;
} else {
return;
}
if (plugin.getDisabledCategorySet().contains(category.toString())
|| !shouldIncreaseBeTakenIntoAccount(player, category) || category == NormalAchievements.BREWING
&& isInCooldownPeriod(player, Integer.toString(event.getRawSlot()), false, category)) {
return;
}
int eventAmount = event.getCurrentItem().getAmount();
if (event.isShiftClick()) {
eventAmount = Math.min(eventAmount, getInventoryAvailableSpace(player, event.getCurrentItem()));
if (eventAmount == 0) {
return;
}
}
updateStatisticAndAwardAchievementsIfAvailable(player, category, eventAmount);
}
示例3: onCraftItem
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCraftItem(CraftItemEvent event) {
if (!(event.getWhoClicked() instanceof Player) || event.getAction() == InventoryAction.NOTHING
|| event.getClick() == ClickType.NUMBER_KEY
&& event.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD) {
return;
}
Player player = (Player) event.getWhoClicked();
if (!shouldIncreaseBeTakenIntoAccountNoPermissions(player)) {
return;
}
MultipleAchievements category = MultipleAchievements.CRAFTS;
ItemStack item = event.getCurrentItem();
String craftName = item.getType().name().toLowerCase();
if (!player.hasPermission(category.toPermName() + '.' + craftName)) {
return;
}
if (plugin.getPluginConfig().isConfigurationSection(category + "." + craftName + ':' + item.getDurability())) {
craftName += ":" + item.getDurability();
} else if (!plugin.getPluginConfig().isConfigurationSection(category + "." + craftName)) {
return;
}
int eventAmount = event.getCurrentItem().getAmount();
if (event.isShiftClick()) {
int maxAmount = event.getInventory().getMaxStackSize();
ItemStack[] matrix = event.getInventory().getMatrix();
for (ItemStack itemStack : matrix) {
if (itemStack != null && itemStack.getType() != Material.AIR) {
int itemStackAmount = itemStack.getAmount();
if (itemStackAmount < maxAmount && itemStackAmount > 0) {
maxAmount = itemStackAmount;
}
}
}
eventAmount *= maxAmount;
eventAmount = Math.min(eventAmount, getInventoryAvailableSpace(player, event.getCurrentItem()));
if (eventAmount == 0) {
return;
}
}
updateStatisticAndAwardAchievementsIfAvailable(player, category, craftName, eventAmount);
}
示例4: 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;
}