Java 类org.bukkit.event.inventory.InventoryCreativeEvent 实例源码

项目:ProjectAres    文件:ItemSharingAndLockingListener.java   
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onInventoryClick(final InventoryClickEvent event) {
    if(event instanceof InventoryCreativeEvent) return;;

    // Ensure the player is clicking in their own inventory
    // TODO: should we allow items to be locked into other types of inventories?
    if(!Objects.equals(event.getWhoClicked(), event.getInventory().getHolder())) return;

    // Break out of the switch if the action will move a locked item, otherwise return
    switch(event.getAction()) {
        case HOTBAR_SWAP:
        case HOTBAR_MOVE_AND_READD:
            // These actions can move up to two stacks. Check the hotbar stack,
            // and then fall through to check the stack under the cursor.
            if(isLocked(Slot.Hotbar.forPosition(event.getHotbarButton())
                                   .getItem(event.getWhoClicked().getInventory()))) break;
            // fall through

        case PICKUP_ALL:
        case PICKUP_HALF:
        case PICKUP_SOME:
        case PICKUP_ONE:
        case SWAP_WITH_CURSOR:
        case MOVE_TO_OTHER_INVENTORY:
        case DROP_ONE_SLOT:
        case DROP_ALL_SLOT:
        case COLLECT_TO_CURSOR:
            // All these actions move only a single stack, except COLLECT_TO_CURSOR,
            // which can only move items that are stackable with the one under the cursor,
            // and locked items are only stackable with other locked items.
            if(isLocked(event.getCurrentItem())) break;

            // fall through

        default: return;
    }

    event.setCancelled(true);
    sendLockWarning(event.getWhoClicked());
}
项目:HCFCore    文件:CreativeClickListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInventoryCreative(InventoryCreativeEvent event) {
    HumanEntity humanEntity = event.getWhoClicked();
    if (humanEntity instanceof Player && !humanEntity.hasPermission("base.command.gamemode")) {
        event.setCancelled(true);
       // humanEntity.sendMessage(ChatColor.RED + "You are not allowed to be in gamemode! Setting you to default gamemode!");
        humanEntity.setGameMode(GameMode.SURVIVAL);
    }
}
项目:HCFCore    文件:CreativeClickListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInventoryCreative(InventoryCreativeEvent event) {
    HumanEntity humanEntity = event.getWhoClicked();
    if (humanEntity instanceof Player && !humanEntity.hasPermission("base.command.gamemode")) {
        event.setCancelled(true);
        // humanEntity.sendMessage(ChatColor.RED + "You are not allowed to be in gamemode! Setting you to default gamemode!");
        humanEntity.setGameMode(GameMode.SURVIVAL);
    }
}
项目:HCFCore    文件:CreativeClickListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInventoryCreative(InventoryCreativeEvent event) {
    HumanEntity humanEntity = event.getWhoClicked();
    if (humanEntity instanceof Player && !humanEntity.hasPermission("base.command.gamemode")) {
        event.setCancelled(true);
       // humanEntity.sendMessage(ChatColor.RED + "You are not allowed to be in gamemode! Setting you to default gamemode!");
        humanEntity.setGameMode(GameMode.SURVIVAL);
    }
}
项目:PerWorldInventory    文件:WorldInventoriesDupingPatch.java   
@EventHandler(priority = EventPriority.LOWEST)
public void onCreativeSlotChange(InventoryCreativeEvent event) {
    if (timeouts.isEmpty()) {
        return; // Saves performance for most common case
    }
    InventoryHolder holder = event.getInventory().getHolder();
    if (holder instanceof Player && timeouts.containsKey(((Player) holder).getUniqueId())) {
        event.setResult(Event.Result.DENY);
    }
}
项目:Transformer    文件:PickBlockListener.java   
@EventHandler
public void onPick(InventoryCreativeEvent event){
    if(locked_players.containsKey(event.getWhoClicked())) {
        if (event.getClick().equals(ClickType.CREATIVE)) {
            if (event.getAction().equals(InventoryAction.PLACE_ALL)) {
                if (event.getCursor() != null) {
                    if (!event.getCursor().getType().equals(Material.AIR)) {
                        event.setCancelled(true);
                        locked_players.get(event.getWhoClicked()).changeBlock(new VirtualBlock(event.getCursor().getType()), (Player) event.getWhoClicked());
                    }
                }
            }
        }
    }
}
项目:PerWorldInventory    文件:WorldInventoriesDupingPatch.java   
@EventHandler(priority = EventPriority.LOWEST)
public void onCreativeSlotChange(InventoryCreativeEvent event) {
    if (timeouts.isEmpty()) {
        return; // Saves performance for most common case
    }
    InventoryHolder holder = event.getInventory().getHolder();
    if (holder instanceof Player && timeouts.containsKey(((Player) holder).getUniqueId())) {
        event.setResult(Event.Result.DENY);
    }
}
项目:StarQuestCode    文件:SQDuties.java   
@EventHandler
public void creativeInventory(InventoryCreativeEvent e) {

    if (e.getWhoClicked().hasPermission("commandspy.track")) {
        Runnable task = new CommandSpyFile(((Player) e.getWhoClicked()).getName(), "Inventory", "Own Inventory" + e.getAction() + "|" + e.getCurrentItem());
        new Thread(task, "CommandSpy").start();
    }
}
项目:StarQuestCode    文件:SQDuties.java   
@EventHandler
public void creativeInventory(InventoryCreativeEvent e) {

    if (e.getWhoClicked().hasPermission("commandspy.track")) {
        Runnable task = new CommandSpyFile(((Player) e.getWhoClicked()).getName(), "Inventory", "Own Inventory" + e.getAction() + "|" + e.getCurrentItem());
        new Thread(task, "CommandSpy").start();
    }
}
项目:TheSurvivalGames    文件:ItemDropListener.java   
@EventHandler(priority = EventPriority.HIGH)
public void onCreative(InventoryCreativeEvent event) {
    try {
        Player p = (Player) event.getWhoClicked();
        if (SGApi.getArenaManager().getArena(p).spectators.contains(p.getName()))
            event.setCancelled(true);
    } catch (ArenaNotFoundException ignored) {}
}
项目:StarQuestCode    文件:Events.java   
@EventHandler
public void creativeInventory(InventoryCreativeEvent e) {

    if (e.getWhoClicked().hasPermission("commandspy.track")) {

        final String name = e.getWhoClicked().getName();
        final InventoryAction invAction = e.getAction();
        final ItemStack item = e.getCurrentItem();

        BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
        scheduler.scheduleAsyncDelayedTask(SQDuties.getPluginMain(), new Runnable() {

            @Override
            public void run() {

                (new CommandSpyFile(name, "Inventory", ("Own Inventory " + invAction + "|" + item))).run();

            }

        },1);

    }

}
项目:ce    文件:CEListener.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void inventoryMenuPrevention(InventoryCreativeEvent event) {
    if (event.getView().getTopInventory().getTitle().startsWith("CE"))
        event.setCancelled(true);
}
项目:CardinalPGM    文件:ObserverModule.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onViewingInventoryClick(InventoryCreativeEvent event) {
    updateNextTick(event.getActor());
}
项目:RemoveGodItems    文件:BlanketOnCreativeListener.java   
@EventHandler
public void onCreative(InventoryCreativeEvent evt) {
    ItemStack itemStack = evt.getCurrentItem();
    ItemStack newStack = new ItemStack(itemStack.getType(), itemStack.getAmount());
    evt.setCurrentItem(newStack);
}
项目:RemoveGodItems    文件:BlanketOnCreativeListener.java   
public void unregister() {
    InventoryCreativeEvent.getHandlerList().unregister(this);
}
项目:RemoveGodItems    文件:CreativeInventoryListener.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onCreativeInventory(InventoryCreativeEvent evt) {
    plugin.getChecker().checkItem(evt.getCursor(), evt.getWhoClicked());
}
项目:RemoveGodItems    文件:CreativeInventoryListener.java   
@Override
public void unregister() {
    InventoryCreativeEvent.getHandlerList().unregister(this);
}