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


Java InventoryCreativeEvent类代码示例

本文整理汇总了Java中org.bukkit.event.inventory.InventoryCreativeEvent的典型用法代码示例。如果您正苦于以下问题:Java InventoryCreativeEvent类的具体用法?Java InventoryCreativeEvent怎么用?Java InventoryCreativeEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: onInventoryClick

import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
@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());
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:41,代码来源:ItemSharingAndLockingListener.java

示例2: onInventoryCreative

import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:10,代码来源:CreativeClickListener.java

示例3: onInventoryCreative

import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
@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);
	}
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:10,代码来源:CreativeClickListener.java

示例4: onCreativeSlotChange

import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:Gnat008,项目名称:PerWorldInventory,代码行数:11,代码来源:WorldInventoriesDupingPatch.java

示例5: onPick

import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
@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());
                    }
                }
            }
        }
    }
}
 
开发者ID:Vilsol,项目名称:Transformer,代码行数:16,代码来源:PickBlockListener.java

示例6: creativeInventory

import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
@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();
	}
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:9,代码来源:SQDuties.java

示例7: onCreative

import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
@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) {}
}
 
开发者ID:SurvivalGamesDevTeam,项目名称:TheSurvivalGames,代码行数:9,代码来源:ItemDropListener.java

示例8: creativeInventory

import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
@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);
		
	}
	
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:25,代码来源:Events.java

示例9: inventoryMenuPrevention

import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void inventoryMenuPrevention(InventoryCreativeEvent event) {
    if (event.getView().getTopInventory().getTitle().startsWith("CE"))
        event.setCancelled(true);
}
 
开发者ID:Taiterio,项目名称:ce,代码行数:6,代码来源:CEListener.java

示例10: onViewingInventoryClick

import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onViewingInventoryClick(InventoryCreativeEvent event) {
    updateNextTick(event.getActor());
}
 
开发者ID:twizmwazin,项目名称:CardinalPGM,代码行数:5,代码来源:ObserverModule.java

示例11: onCreative

import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
@EventHandler
public void onCreative(InventoryCreativeEvent evt) {
    ItemStack itemStack = evt.getCurrentItem();
    ItemStack newStack = new ItemStack(itemStack.getType(), itemStack.getAmount());
    evt.setCurrentItem(newStack);
}
 
开发者ID:daboross,项目名称:RemoveGodItems,代码行数:7,代码来源:BlanketOnCreativeListener.java

示例12: unregister

import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
public void unregister() {
    InventoryCreativeEvent.getHandlerList().unregister(this);
}
 
开发者ID:daboross,项目名称:RemoveGodItems,代码行数:4,代码来源:BlanketOnCreativeListener.java

示例13: onCreativeInventory

import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onCreativeInventory(InventoryCreativeEvent evt) {
    plugin.getChecker().checkItem(evt.getCursor(), evt.getWhoClicked());
}
 
开发者ID:daboross,项目名称:RemoveGodItems,代码行数:5,代码来源:CreativeInventoryListener.java

示例14: unregister

import org.bukkit.event.inventory.InventoryCreativeEvent; //导入依赖的package包/类
@Override
public void unregister() {
    InventoryCreativeEvent.getHandlerList().unregister(this);
}
 
开发者ID:daboross,项目名称:RemoveGodItems,代码行数:5,代码来源:CreativeInventoryListener.java


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