本文整理汇总了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.
}
示例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));
}
}
示例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);
}
}
示例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.");
}
}
}
示例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);
}
示例6: onEnchantItem
import org.bukkit.event.enchantment.EnchantItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onEnchantItem(EnchantItemEvent event) {
event.setCancelled(true);
}
示例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);
}
示例8: e
import org.bukkit.event.enchantment.EnchantItemEvent; //导入方法依赖的package包/类
@EventHandler public void e(EnchantItemEvent event) { event.setCancelled(true); }