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


Java EnchantItemEvent.setCancelled方法代码示例

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


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

示例1: onEnchant

import org.bukkit.event.enchantment.EnchantItemEvent; //导入方法依赖的package包/类
@HookHandler(priority = Priority.CRITICAL, ignoreCanceled = true)
public void onEnchant(final EnchantHook hook) {
    EnchantItemEvent event = new EnchantItemEvent(new CanaryPlayer(hook.getPlayer()), null, new CanaryBlock(hook
            .getEnchantmentTable().getBlock()), null, 0, null, 0) {
        @Override
        public void setExpLevelCost(int level) {
            super.setExpLevelCost(level);
            // How can you do this in Canary?
        }
    };
    event.setCancelled(hook.isCanceled());
    server.getPluginManager().callEvent(event);
    if (event.isCancelled()) {
        hook.setCanceled();
    }
    // TODO: Fill in.
}
 
开发者ID:CanaryBukkitTeam,项目名称:CanaryBukkit,代码行数:18,代码来源:CanaryPlayerListener.java

示例2: onEnchant

import org.bukkit.event.enchantment.EnchantItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEnchant(final EnchantItemEvent event) {
    final ItemStack item = getItem(event.getItem(), event.getEnchanter());
    final long seed = enchantSeeds.get(event.getEnchanter().getUniqueId());
    final EnchantResult result = mechanics.generateEnchantments(
            event.getEnchanter(), item, event.getExpLevelCost(), true, seed);

    placeholders.remove(event.getEnchanter().getUniqueId());
    event.getEnchantsToAdd().clear();
    result.getEnchantments().forEach((enchant, level) -> enchant.addToItem(item, level));
    GlowEffects.finalize(item);
    enchantSeeds.put(event.getEnchanter().getUniqueId(), random.nextLong());
    event.getInventory().setItem(0, item);
    event.setCancelled(true);

    if (event.getEnchanter().getGameMode() != GameMode.CREATIVE) {
        int cost = 0;
        final int[] tiers = offers.get(event.getEnchanter().getUniqueId());
        for (int i = 0; i < 6; i += 2) {
            if (tiers[i] == event.getExpLevelCost()) cost = tiers[i + 1];
        }
        event.getEnchanter().setLevel(event.getEnchanter().getLevel() - cost);
        event.getInventory().removeItem(new ItemStack(Material.INK_SACK, cost, (short) 4));
    }
}
 
开发者ID:Eniripsa96,项目名称:EnchantmentAPI,代码行数:26,代码来源:EnchantListener.java

示例3: canEnchant

import org.bukkit.event.enchantment.EnchantItemEvent; //导入方法依赖的package包/类
@EventHandler(priority= EventPriority.LOW, ignoreCancelled=true)
public void canEnchant(EnchantItemEvent event)
{
    ItemStack item = event.getItem();
    if (!PowerUtils.isPowerTool(item)) {
        return;
    }
    if (!PowerUtils.checkEnchantPermission(event.getEnchanter(), item.getType())) {
        event.setCancelled(true);
    }
}
 
开发者ID:OmniWorldMC,项目名称:OmniWorldMCPlugin,代码行数:12,代码来源:EnchantItemListener.java

示例4: onEnchantItem

import org.bukkit.event.enchantment.EnchantItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onEnchantItem(EnchantItemEvent event) {
    if (behaviorOfList) {
        Material item = event.getItem().getType();
        if (!allowed.contains(item)) {
            event.setCancelled(true);
            event.getEnchanter().sendMessage(ChatColor.DARK_RED + "You are not allowed to enchant non-tool items.");
        }
    } else {
        if (!canEnchant(event.getEnchanter())) {
            event.setCancelled(true);
            event.getEnchanter().sendMessage(ChatColor.DARK_RED + "You must vote for the server if you wish to enchant items.");
        }
    }
}
 
开发者ID:CoderMonkeys,项目名称:TerraCraftTools,代码行数:16,代码来源:LimitEnchants.java

示例5: onEnchantItemEvent

import org.bukkit.event.enchantment.EnchantItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onEnchantItemEvent(EnchantItemEvent event) {
	CivMessage.sendError(event.getEnchanter(), "Items cannot be enchanted with enchantment tables.");
	event.setCancelled(true);
}
 
开发者ID:netizen539,项目名称:civcraft,代码行数:6,代码来源:CustomItemManager.java

示例6: onEnchantItem

import org.bukkit.event.enchantment.EnchantItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onEnchantItem(EnchantItemEvent event) {
    event.setCancelled(true);
}
 
开发者ID:WaywardRealms,项目名称:Wayward,代码行数:5,代码来源:EnchantItemListener.java

示例7: onEnchantEvent

import org.bukkit.event.enchantment.EnchantItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onEnchantEvent(EnchantItemEvent event) {
    if (Demigods.getMythos().itemHasFlag(event.getItem(), DivineItem.Flag.UNENCHANTABLE)) event.setCancelled(true);
}
 
开发者ID:DemigodsRPG,项目名称:Demigods3,代码行数:5,代码来源:FlagListener.java

示例8: e

import org.bukkit.event.enchantment.EnchantItemEvent; //导入方法依赖的package包/类
@EventHandler public void e(EnchantItemEvent event) { event.setCancelled(true); } 
开发者ID:Limeth,项目名称:Breakpoint,代码行数:2,代码来源:BanListener.java


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