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


Java EventPriority类代码示例

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


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

示例1: onPlayerInteract

import org.bukkit.event.EventPriority; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
        return;

    Player player = event.getPlayer();
    if (player.getGameMode() == GameMode.CREATIVE && player.hasPermission(ProtectionListener.PROTECTION_BYPASS_PERMISSION)) {
        return;
    }

    if (plugin.getEotwHandler().isEndOfTheWorld()) {
        return;
    }

    Block block = event.getClickedBlock();
    if (!this.isSubclaimable(block)) {
        return;
    }

    if (!this.checkSubclaimIntegrity(player, block)) {
        event.setCancelled(true);
        player.sendMessage(ChatColor.RED + "You do not have access to this subclaimed " + block.getType().toString() + '.');
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:25,代码来源:SignSubclaimListener.java

示例2: onPlayerDeath

import org.bukkit.event.EventPriority; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerDeath(PlayerDeathEvent event) {
    Faction currentEventFac = plugin.getTimerManager().getEventTimer().getEventFaction();
    if (currentEventFac instanceof ConquestFaction) {
        Player player = event.getEntity();
        PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);
        if (playerFaction != null && SettingsYML.CONQUEST_POINT_LOSS_PER_DEATH > 0) {
            int oldPoints = getPoints(playerFaction);
            if (oldPoints == 0) return;

            int newPoints = takePoints(playerFaction, SettingsYML.CONQUEST_POINT_LOSS_PER_DEATH);
            event.setDeathMessage(null); // for some reason if it isn't handled manually, weird colour coding happens
            Bukkit.broadcastMessage(ChatColor.YELLOW + "[" + currentEventFac.getName() + "] " +
                    ChatColor.GOLD + playerFaction.getName() + " lost " +
                    SettingsYML.CONQUEST_POINT_LOSS_PER_DEATH + " points because " + player.getName() + " died." +
                    ChatColor.AQUA + " (" + newPoints + '/' + SettingsYML.CONQUEST_REQUIRED_WIN_POINTS + ')' + ChatColor.YELLOW + '.');
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:20,代码来源:ConquestTracker.java

示例3: onLingeringPotionSplash

import org.bukkit.event.EventPriority; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onLingeringPotionSplash(final LingeringPotionSplashEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("1.9 " + e.getEventName());
        plugin.getLogger().info("1.9 entity = " + e.getEntity());
        plugin.getLogger().info("1.9 entity type = " + e.getEntityType());
        plugin.getLogger().info("1.9 radius = " + e.getAreaEffectCloud().getRadius());
        plugin.getLogger().info("1.9 id = " + e.getAreaEffectCloud().getEntityId());
        plugin.getLogger().info("1.9 hit entity = " + e.getHitEntity());
    }
    if (!Util.inWorld(e.getEntity().getLocation())) {
        return;
    }
    // Try to get the shooter
    Projectile projectile = e.getEntity();
    plugin.getLogger().info("shooter = " + projectile.getShooter());
    if (projectile.getShooter() != null && projectile.getShooter() instanceof Player) {
        UUID uuid = ((Player)projectile.getShooter()).getUniqueId();
        // Store it and remove it when the effect is gone
        thrownPotions.put(e.getAreaEffectCloud().getEntityId(), uuid);
        plugin.getServer().getScheduler().runTaskLater(plugin, () -> thrownPotions.remove(e.getAreaEffectCloud().getEntityId()), e.getAreaEffectCloud().getDuration());
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:24,代码来源:IslandGuard1_9.java

示例4: onInventoryClick

import org.bukkit.event.EventPriority; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onInventoryClick(InventoryClickEvent event) {
    HumanEntity humanEntity = event.getWhoClicked();
    if (humanEntity instanceof Player) {
        Player player = (Player) humanEntity;
        PearlNameFaker pearlNameFaker = itemNameFakes.get(player.getUniqueId());
        if (pearlNameFaker == null)
            return;

        // Required to prevent ghost items.
        int heldSlot = player.getInventory().getHeldItemSlot();
        if (event.getSlot() == heldSlot) {
            pearlNameFaker.setFakeItem(CraftItemStack.asNMSCopy(player.getItemInHand()), heldSlot);
        } else if (event.getHotbarButton() == heldSlot) {
            pearlNameFaker.setFakeItem(CraftItemStack.asNMSCopy(event.getCurrentItem()), event.getSlot());
            new BukkitRunnable() {
                @Override
                public void run() {
                    player.updateInventory();
                }
            }.runTask(plugin);
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:25,代码来源:EnderPearlTimer.java

示例5: onPearlClip

import org.bukkit.event.EventPriority; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPearlClip(PlayerTeleportEvent event) {
	if (event.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL) {
		Location to = event.getTo();
		if (blockedPearlTypes.contains(to.getBlock().getType())) {
			Player player = event.getPlayer();
			player.sendMessage(ChatColor.RED + "You cannot pearl there.");
			removeCooldown(player);
			event.setCancelled(true);

			return;
		}
		to.setX(to.getBlockX() + 0.5D);
		to.setZ(to.getBlockZ() + 0.5D);
		event.setTo(to);

	}
}
 
开发者ID:HuliPvP,项目名称:Chambers,代码行数:19,代码来源:EnderpearlListener.java

示例6: onPlayerMove

import org.bukkit.event.EventPriority; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerMove(final PlayerMoveEvent event) {
    final Location from = event.getFrom();
    final Location to = event.getTo();
    if (from.getBlockX() == to.getBlockX() && from.getBlockZ() == to.getBlockZ()) {
        return;
    }
    if (!isWithinBorder(to) && isWithinBorder(from)) {
        final Player player = event.getPlayer();
        player.sendMessage(ChatColor.RED + "You cannot go past the border.");
        event.setTo(from);
        final Entity vehicle = player.getVehicle();
        if (vehicle != null) {
            vehicle.eject();
            vehicle.teleport(from);
            vehicle.setPassenger((Entity)player);
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:20,代码来源:BorderListener.java

示例7: onBlockBreak

import org.bukkit.event.EventPriority; //导入依赖的package包/类
@EventHandler(ignoreCancelled=true, priority=EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent event)
{
  Block block = event.getBlock();
  if (isEventSign(block))
  {
    BlockState state = block.getState();
    Sign sign = (Sign)state;
    ItemStack stack = new ItemStack(Material.SIGN, 1);
    ItemMeta meta = stack.getItemMeta();
    meta.setDisplayName(EVENT_SIGN_ITEM_NAME);
    meta.setLore(Arrays.asList(sign.getLines()));
    stack.setItemMeta(meta);
    
    Player player = event.getPlayer();
    World world = player.getWorld();
    Location blockLocation = block.getLocation();
    if ((player.getGameMode() != GameMode.CREATIVE) && (world.isGameRule("doTileDrops"))) {
      world.dropItemNaturally(blockLocation, stack);
    }
    event.setCancelled(true);
    block.setType(Material.AIR);
    state.update();
  }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:26,代码来源:EventSignListener.java

示例8: onPlaceHopper

import org.bukkit.event.EventPriority; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlaceHopper(final BlockPlaceEvent e) {
	if (!cm.tileLimitEnabled) {
		return;
	}
	if (e.getBlock().getType() == Material.HOPPER) {
		Player p = e.getPlayer();
		if (p.isOp()) {
			return;
		}
		int limit = NeverLagUtils.getMaxPermission(p, "neverlag.limit.hopper.");
		if (limit <= 0) {
			limit = cm.tileLimitDefaultHopper;
		}
		if (isLimit(e.getBlock().getLocation(), Material.HOPPER, limit)) {
			e.setCancelled(true);
			p.sendMessage(i18n.tr("message", limit));
		}
	}
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:21,代码来源:TilesLimiter.java

示例9: kill

import org.bukkit.event.EventPriority; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void kill(final MatchPlayerDeathEvent event) {
    if(!event.isChallengeKill()) return;

    // Death raindrops are given by the backend, to reduce API usage

    final int raindrops = calculateRaindrops(
        event.getKiller(),
        RaindropConstants.KILL_REWARD,
        false,
        1
    );

    event.setRaindrops(raindrops);

    final MatchPlayer killer = event.getOnlineKiller();
    if(killer != null) {
        RaindropUtil.showRaindrops(
            killer.getBukkit(),
            raindrops,
            RaindropUtil.calculateMultiplier(event.getKiller().getPlayerId()),
            new TranslatableComponent("match.kill.killed", event.getVictim().getComponentName())
        );
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:26,代码来源:RaindropListener.java

示例10: onCreatureSpawn

import org.bukkit.event.EventPriority; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onCreatureSpawn(CreatureSpawnEvent event) {
    if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.SLIME_SPLIT) { // allow slimes to always split
        return;
    }

    switch (event.getSpawnReason()) {
    case NATURAL:
        if (event.getLocation().getChunk().getEntities().length > MAX_NATURAL_CHUNK_ENTITIES) {
            event.setCancelled(true);
        }
        break;
    case CHUNK_GEN:
        if (event.getLocation().getChunk().getEntities().length > MAX_CHUNK_GENERATED_ENTITIES) {
            event.setCancelled(true);
        }
        break;
    default:
        break;
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:22,代码来源:EntityLimitListener.java

示例11: onPlace

import org.bukkit.event.EventPriority; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlace(BlockPlaceEvent e) {
	if (!cm.isAntiPlaceDoorDupe) {
		return;
	}
	// 判断手里的物品是否为门
	if (e.getItemInHand().getType() == Material.WOOD_DOOR || e.getItemInHand().getType() == Material.IRON_DOOR) {
		// 清理所在区块的甘蔗掉落物
		for (Entity entity : e.getPlayer().getLocation().getChunk().getEntities()) {
			if (entity instanceof Item) {
				Material itemType = ((Item) entity).getItemStack().getType();
				if (itemType == Material.SUGAR_CANE || itemType == Material.CACTUS) {
					entity.remove();
				}
			}
		}
	}
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:19,代码来源:AntiPlaceDoorDupe.java

示例12: onPlayerDeath

import org.bukkit.event.EventPriority; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerDeath(PlayerDeathEvent event) {
    Player player = event.getEntity();
    World world = player.getWorld();
    Location location = player.getLocation();
    Collection<ItemStack> drops = event.getDrops();
    if (!drops.isEmpty()) {
        Iterator<ItemStack> iterator = drops.iterator();

        // Drop the items manually so we can add meta to prevent
        // PVP Protected players from collecting them.
        long stamp = System.currentTimeMillis() + +ITEM_PICKUP_DELAY;
        while (iterator.hasNext()) {
            itemUUIDPickupDelays.put(world.dropItemNaturally(location, iterator.next()).getUniqueId(), stamp);
            iterator.remove();
        }
    }

    clearCooldown(player);
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:21,代码来源:InvincibilityTimer.java

示例13: onPlayerFish

import org.bukkit.event.EventPriority; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerFish(PlayerFishEvent event) {
    double amount = event.getExpToDrop();
    if (amount > 0) {
        amount = Math.ceil(amount * SettingsYML.EXP_MULTIPLIER_FISHING);
        ProjectileSource projectileSource = event.getHook().getShooter();
        if (projectileSource instanceof Player) {
            ItemStack stack = ((Player) projectileSource).getItemInHand();
            int enchantmentLevel = stack.getEnchantmentLevel(Enchantment.LUCK);
            if (enchantmentLevel > 0L) {
                amount = Math.ceil(amount * (enchantmentLevel * SettingsYML.EXP_MULTIPLIER_LUCK_PER_LEVEL));
            }
        }

        event.setExpToDrop((int) amount);
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:18,代码来源:ExpMultiplierListener.java

示例14: onItemSpawn

import org.bukkit.event.EventPriority; //导入依赖的package包/类
/**
 * Add ore to chest on drop
 *
 * @param event Item spawn event instance
 */
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onItemSpawn(ItemSpawnEvent event)
{
    if (event.getEntityType() != EntityType.DROPPED_ITEM
            || Meta.hasMeta(event.getEntity().getItemStack())
            || event.getEntity().hasMetadata("playerDrop"))
        return;

    for (int i = 0; i < MATERIALS.length; i++)
    {
        ItemStack stack = event.getEntity().getItemStack();

        if (MATERIALS[i] != stack.getType())
            continue;

        ItemStack newStack = stack.clone();
        this.inventory.addItem(Meta.addMeta(newStack));
        event.getEntity().setItemStack(Meta.addMeta(event.getEntity().getItemStack()));
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:26,代码来源:RiskyRetrievalModule.java

示例15: onPlayerInteract

import org.bukkit.event.EventPriority; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerInteract(PlayerInteractEvent e) {
	if (!cm.isDisableChangeSpawnerType) {
		return;
	}
	if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
		if (e.getClickedBlock().getType() == Material.MOB_SPAWNER) {
			if (e.getItem() == null) {
				return;
			}
			if (e.getPlayer().isOp()) {
				return;
			}
			if (e.getItem().getType() == Material.MONSTER_EGG || e.getItem().getType() == Material.MONSTER_EGGS) {
				e.setCancelled(true);
			}
		}
	}
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:20,代码来源:AntiUseEggsChangeSpawnerType.java


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