本文整理匯總了Java中org.bukkit.event.inventory.InventoryDragEvent.getInventory方法的典型用法代碼示例。如果您正苦於以下問題:Java InventoryDragEvent.getInventory方法的具體用法?Java InventoryDragEvent.getInventory怎麽用?Java InventoryDragEvent.getInventory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.event.inventory.InventoryDragEvent
的用法示例。
在下文中一共展示了InventoryDragEvent.getInventory方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: equipWeaponEvent
import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void equipWeaponEvent(InventoryDragEvent event) {
if (Result.DENY.equals(event.getResult())) return;
HumanEntity human = event.getWhoClicked();
Inventory inv = event.getInventory();
ItemStack prior = event.getOldCursor();
StandardGun priorGun = findGun(prior);
// Don't really care what sort of drag, if we have a gun in inv and this was a gun, deny.
if (priorGun != null && inv != null && !InventoryType.PLAYER.equals(inv.getType()) && priorGun.isLimitToOne() && priorGun.hasGun(human)) {
event.setResult(Result.DENY);
// yes this will prevent drag style of weapon in chest invs. Oh well.
}
}
示例2: equipWeaponEvent
import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void equipWeaponEvent(InventoryDragEvent event) {
if (!enabled) return;
HumanEntity human = event.getWhoClicked();
boolean alreadyHasGun = hasGun(human);
Inventory inv = event.getInventory();
ItemStack prior = event.getOldCursor();
// Don't really care what sort of drag, if we have a gun in inv and this was a gun, deny.
if (alreadyHasGun && (inv != null && !InventoryType.PLAYER.equals(inv.getType()))
&& (prior != null && isGun(prior))) {
event.setResult(Result.DENY);
// yes this will prevent drag style of weapon in chest invs. Oh well.
}
}
示例3: onInventoryDrag
import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryDrag(InventoryDragEvent event)
{
if (event.getWhoClicked() instanceof Player)
{
if (!this.inventoryChanges.containsKey(event.getWhoClicked().getUniqueId()))
{
return;
}
Inventory inventory = event.getInventory();
int amount = 0;
for (Entry<Integer, ItemStack> entry : event.getNewItems().entrySet())
{
if (entry.getKey() < inventory.getSize())
{
amount += entry.getValue().getAmount();
}
}
this.prepareForLogging((Player)event.getWhoClicked(), new ItemData(event.getOldCursor()), amount);
}
}
示例4: onInventoryDrag
import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onInventoryDrag(InventoryDragEvent event) {
Player player = (Player) event.getWhoClicked();
if (!InventoryManager.playerIsLoaded(player)) {
return;
}
for (Integer rawSlotId : event.getRawSlots()) {
ItemStack cursor = event.getOldCursor();
Inventory inventory = event.getInventory();
if (PetManager.isPetItem(cursor)) {
event.setCancelled(true);
return;
}
if (inventory.getType() == InventoryType.CRAFTING) {
if (InventoryManager.get(player).isOpened()) {
return;
}
// Shield slot is QUICKBAR and has rawId - 45 o.O
if (rawSlotId >= 1 && rawSlotId <= 8 || rawSlotId == 45) {
event.setCancelled(true);
return;
}
} else if (InventoryAPI.isRPGInventory(inventory)) {
if (rawSlotId < 54) {
event.setCancelled(true);
return;
}
}
}
}
示例5: onInventoryDrag
import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onInventoryDrag(InventoryDragEvent event) {
Inventory inventory = event.getInventory();
Inventory topInventory = event.getView().getTopInventory();
if (inventory != null && topInventory != null && topInventory.equals(inventory) && topInventory.getTitle().endsWith(" Key Reward")) { // TODO: More reliable
event.setCancelled(true);
}
}
示例6: InventoryDrag
import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
public static void InventoryDrag(InventoryDragEvent event)
{
Inventory inventory = event.getInventory();
if ( inventory.getName().contains("SkullInventory"))
{
event.setCancelled(true);
return;
}
}
示例7: inventoryDragEvent
import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void inventoryDragEvent(InventoryDragEvent e) {
if (e.getInventory() == null)
return;
if (check(e.getInventory().getType(), e.getOldCursor()))
e.setCancelled(true);
}
示例8: onDrag
import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler
public void onDrag(InventoryDragEvent event) {
if (users.contains(event.getWhoClicked().getUniqueId())) {
event.getInventory().setItem(31, new ItemStack(Material.AIR));
final Inventory inv = event.getInventory();
plugin.getServer().getScheduler().runTaskLater(plugin, () -> updateEmeraldIcon(inv), 1L);
}
}
示例9: onInventoryDrag
import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler
public void onInventoryDrag(InventoryDragEvent e) {
if (e == null) return;
if (e.getInventory() == null) return;
if (e.getInventory().getTitle() == null) return;
if (e.getInventory().getTitle().equals(CC(Main.finalconfig.getString("atm_title")))) {
e.setResult(Result.DENY);
}
}
示例10: onInventoryDrag
import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onInventoryDrag(InventoryDragEvent event)
{
Inventory inventory = event.getInventory();
if(isInventoryGui(HiddenId.grabId(inventory.getTitle())))
{
event.setCancelled(true);
}
}
示例11: onInventoryDragEvent
import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onInventoryDragEvent(InventoryDragEvent event) {
Inventory inventory = event.getInventory();
if (!(inventory instanceof BrewerInventory)) {
return;
}
InventoryHolder holder = inventory.getHolder();
if (!(holder instanceof BrewingStand)) {
return;
}
HumanEntity whoClicked = event.getWhoClicked();
if (!UserManager.hasPlayerDataKey(event.getWhoClicked()) || !Permissions.secondaryAbilityEnabled(whoClicked, SecondaryAbility.CONCOCTIONS)) {
return;
}
if (!event.getInventorySlots().contains(Alchemy.INGREDIENT_SLOT)) {
return;
}
ItemStack cursor = event.getCursor();
ItemStack ingredient = ((BrewerInventory) inventory).getIngredient();
if (AlchemyPotionBrewer.isEmpty(ingredient) || ingredient.isSimilar(cursor)) {
Player player = (Player) whoClicked;
if (AlchemyPotionBrewer.isValidIngredient(player, cursor)) {
// Not handled: dragging custom ingredients over ingredient slot (does not trigger any event)
AlchemyPotionBrewer.scheduleCheck(player, (BrewingStand) holder);
return;
}
event.setCancelled(true);
AlchemyPotionBrewer.scheduleUpdate(inventory);
}
}
示例12: onInventoryDragEvent
import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
/**
* Prevent placing items in death chests if configured
* @param event
*/
@EventHandler
public void onInventoryDragEvent(InventoryDragEvent event) {
Inventory inventory = event.getInventory();
// if inventory is a death chest inventory
if (inventoryIsDeathChest(inventory)) {
// if prevent-item-placement is configured false, do nothing and return
if (!plugin.getConfig().getBoolean("prevent-item-placement")) {
return;
}
// get set of slots dragged over
Set<Integer> rawSlots = event.getRawSlots();
// if single chest set max slot to 27
int maxSlot = 27;
// if double chest set max slot to 54
if (inventory.getHolder() instanceof DoubleChest) {
maxSlot = 54;
}
// iterate over dragged slots and if any are above max slot, cancel event
for (int slot : rawSlots) {
if (slot < maxSlot) {
// if player does not have allow-place permission, cancel event
if (!event.getWhoClicked().hasPermission("deathchest.allow-place")) {
event.setCancelled(true);
}
break;
}
}
}
}
示例13: onItemDrag
import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler
public void onItemDrag(final InventoryDragEvent event) {
if (event.getInventory() != null && event.getInventory().equals(this.inventory) && event.getWhoClicked() instanceof Player) {
event.setCancelled(true);
event.setResult(Result.DENY);
}
}
示例14: onDrag
import org.bukkit.event.inventory.InventoryDragEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onDrag(InventoryDragEvent event) {
if (!(event.getWhoClicked() instanceof Player)) {
return;
}
Player player = (Player) event.getWhoClicked();
if (player.hasPermission("playervaults.bypassblockeditems")) {
return;
}
Inventory clickedInventory = event.getInventory();
if (clickedInventory != null) {
VaultViewInfo info = PlayerVaults.getInstance().getInVault().get(player.getUniqueId().toString());
if (info != null) {
int num = info.getNumber();
String inventoryTitle = clickedInventory.getTitle();
String title = Lang.VAULT_TITLE.toString().replace("%number", String.valueOf(num)).replace("%p", info.getHolder());
if ((inventoryTitle != null && inventoryTitle.equalsIgnoreCase(title)) && event.getNewItems() != null) {
for (ItemStack item : event.getNewItems().values()) {
if (PlayerVaults.getInstance().isBlockedMaterial(item.getType())) {
event.setCancelled(true);
player.sendMessage(Lang.TITLE.toString() + Lang.BLOCKED_ITEM.toString().replace("%m", item.getType().name()));
return;
}
}
}
}
}
}