当前位置: 首页>>代码示例>>Java>>正文


Java InventoryClickEvent.setCurrentItem方法代码示例

本文整理汇总了Java中org.bukkit.event.inventory.InventoryClickEvent.setCurrentItem方法的典型用法代码示例。如果您正苦于以下问题:Java InventoryClickEvent.setCurrentItem方法的具体用法?Java InventoryClickEvent.setCurrentItem怎么用?Java InventoryClickEvent.setCurrentItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.inventory.InventoryClickEvent的用法示例。


在下文中一共展示了InventoryClickEvent.setCurrentItem方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ClickCheckItem

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void ClickCheckItem(InventoryClickEvent evt){
    if(ConfigPatch.AntiLongStringCrashenable == true){
        if(evt.getWhoClicked().getType() != EntityType.PLAYER){
            return;
        }
        Player player = (Player) evt.getWhoClicked();
        ItemStack item = evt.getCursor();
        if(item != null){
            if(item.hasItemMeta() && item.getItemMeta().getDisplayName() != null){
                if(item.getItemMeta().getDisplayName().length() >= 127){
                    evt.setCancelled(true);
                    evt.setCurrentItem(null);
                    AzureAPI.log(player, ConfigPatch.AntiLongStringCrashWarnMessage);
                }
            }
        }
    }
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:20,代码来源:AntiLongStringCrash.java

示例2: onInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onInventoryClick(InventoryClickEvent event){
    if(event.getSlot() == 8){
        event.setCurrentItem(null);
        try {
            if(plugin.getConfig().getString("valeitemininv").equals("true")) {
                ValeUtil.setVale((Player) event.getWhoClicked(), ValeUtil.getVale((Player) event.getWhoClicked()));
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        event.setCancelled(true);
    }
}
 
开发者ID:Warvale,项目名称:NetworkCore,代码行数:15,代码来源:PlayerListener.java

示例3: onEvent

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@Override
public void onEvent(InventoryClickEvent event) {
    super.onEvent(event);
    if(this.isCarrier(event.getWhoClicked()) && event.getSlot() == ArmorType.HELMET.inventorySlot()) {
        event.setCancelled(true);
        event.getView().setCursor(null);
        event.setCurrentItem(null);
        this.flag.getMatch().getScheduler(MatchScope.RUNNING).createTask(() -> {
            if(isCurrent()) {
                dropFlag();
            }
        });
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:15,代码来源:Carried.java

示例4: onInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
    Player player = (Player) event.getWhoClicked();
    ItemStack currentItem = event.getCurrentItem();

    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    if (!ItemUtils.isEmpty(currentItem) && InventoryLocker.isLockedSlot(currentItem)) {
        int slot = event.getSlot();
        int line = InventoryLocker.getLine(slot);
        if (InventoryLocker.isBuyableSlot(currentItem, line)) {
            if (InventoryLocker.canBuySlot((Player) event.getWhoClicked(), line) && InventoryLocker.buySlot(player, line)) {
                player.getInventory().setItem(slot, null);
                event.setCurrentItem(null);

                if (slot < 35) {
                    player.getInventory().setItem(slot + 1, InventoryLocker.getBuyableSlotForLine(InventoryLocker.getLine(slot + 1)));
                }

                InventoryManager.get(player).setBuyedSlots(InventoryManager.get(player).getBuyedGenericSlots() + 1);
            } else {
                event.setCancelled(true);
            }
        } else {
            PlayerUtils.sendMessage(player, RPGInventory.getLanguage().getMessage("error.previous"));
            event.setCancelled(true);
        }
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:32,代码来源:LockerListener.java

示例5: onInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
    if (event.getSlot() == 8) {
        event.setCurrentItem(null);
        try {
            ScrapsUtil.setScraps((Player) event.getWhoClicked(), ScrapsUtil.getScraps((Player) event.getWhoClicked()));
        } catch (SQLException e) {
            e.printStackTrace();
        }
        event.setCancelled(true);
    }
}
 
开发者ID:Warvale,项目名称:Locked,代码行数:13,代码来源:PlayerListener.java


注:本文中的org.bukkit.event.inventory.InventoryClickEvent.setCurrentItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。