本文整理汇总了Java中org.bukkit.event.EventPriority.HIGH属性的典型用法代码示例。如果您正苦于以下问题:Java EventPriority.HIGH属性的具体用法?Java EventPriority.HIGH怎么用?Java EventPriority.HIGH使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.event.EventPriority
的用法示例。
在下文中一共展示了EventPriority.HIGH属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: equipWeaponEvent
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void equipWeaponEvent(InventoryDragEvent event) {
if (!enabled) return;
HumanEntity human = event.getWhoClicked();
boolean alreadyHasGun = hasGun(human);
Inventory inv = event.getInventory();
ItemStack prior = event.getOldCursor();
// Don't really care what sort of drag, if we have a gun in inv and this was a gun, deny.
if (alreadyHasGun && (inv != null && !InventoryType.PLAYER.equals(inv.getType()))
&& (prior != null && isGun(prior))) {
event.setResult(Result.DENY);
// yes this will prevent drag style of weapon in chest invs. Oh well.
}
}
示例2: onPlayerDamage
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerDamage(EntityDamageEvent event) {
if (event.getCause() == EntityDamageEvent.DamageCause.VOID) {
Entity entity = event.getEntity();
if (entity instanceof Player) {
// Allow players to die by VOID in the END
if (entity.getWorld().getEnvironment() == World.Environment.THE_END) {
return;
}
Location destination = BukkitUtils.getHighestLocation(entity.getLocation());
if (destination == null)
return;
if (entity.teleport(destination, PlayerTeleportEvent.TeleportCause.PLUGIN)) {
event.setCancelled(true);
((Player) entity).sendMessage(ChatColor.YELLOW + "You were saved from the void.");
}
}
}
}
示例3: onArcherSpeedClick
@EventHandler(ignoreCancelled=false, priority=EventPriority.HIGH)
public void onArcherSpeedClick(PlayerInteractEvent event)
{
Action action = event.getAction();
if (((action == Action.RIGHT_CLICK_AIR) || (action == Action.RIGHT_CLICK_BLOCK)) &&
(event.hasItem()) && (event.getItem().getType() == Material.SUGAR))
{
if (this.plugin.getPvpClassManager().getEquippedClass(event.getPlayer()) != this) {
return;
}
Player player = event.getPlayer();
UUID uuid = player.getUniqueId();
long timestamp = this.archerSpeedCooldowns.get(uuid);
long millis = System.currentTimeMillis();
long remaining = timestamp == this.archerSpeedCooldowns.getNoEntryValue() ? -1L : timestamp - millis;
if (remaining > 0L)
{
player.sendMessage(ChatColor.RED + "Cannot use Speed Boost for another " + DurationFormatUtils.formatDurationWords(remaining, true, true) + ".");
}
else
{
ItemStack stack = player.getItemInHand();
if (stack.getAmount() == 1) {
player.setItemInHand(new ItemStack(Material.AIR, 1));
} else {
stack.setAmount(stack.getAmount() - 1);
}
player.sendMessage(ChatColor.GREEN + "Speed 4 activated for 7 seconds.");
this.plugin.getEffectRestorer().setRestoreEffect(player, ARCHER_SPEED_EFFECT);
this.archerSpeedCooldowns.put(event.getPlayer().getUniqueId(), System.currentTimeMillis() + ARCHER_SPEED_COOLDOWN_DELAY);
}
}
}
示例4: onBlockPlace
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onBlockPlace(BlockPlaceEvent event) {
Key key = plugin.getKeyManager().getKey(event.getItemInHand());
if (key != null) {
event.setCancelled(true);
}
}
示例5: onBlockBreak
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onBlockBreak(final BlockBreakEvent event) {
if (!isWithinBorder(event.getBlock().getLocation())) {
event.setCancelled(true);
event.getPlayer().sendMessage(ChatColor.RED + "You cannot break blocks past the border.");
}
}
示例6: onPlayerTeleport
/**
* Prevent teleporting outside the map
*/
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerTeleport(final PlayerTeleportEvent event) {
if(event.getCause() == PlayerTeleportEvent.TeleportCause.PLUGIN) {
double fromY = event.getFrom().getY();
double toY = event.getTo().getY();
if((fromY >= 0.0D && fromY < 255.0D) && (toY < 0.0D || toY >= 255.0D)) {
event.setCancelled(true);
}
}
}
示例7: onCommand
@EventHandler(priority = EventPriority.HIGH)
public void onCommand(PlayerCommandPreprocessEvent e){
Player p = e.getPlayer();
if(manager.isInPvP(p)){
e.setCancelled(true);
p.sendMessage(Utils.colorize(PAData.SURVIVAL.getPrefix() + ChatColor.DARK_RED + " ¡No puedes ejecutar comandos en pvp!"));
}
}
示例8: onChannelMessage
@EventHandler (priority = EventPriority.HIGH)
public void onChannelMessage(ChannelMessageEvent event) {
ChatChannel channel = event.getChannel();
KingdomFactionsPlayer player = event.getByWho();
int cooldownSeconds = channel.getRank(player).getCooldown();
if (cooldownSeconds != 0 && !player.hasPermission(ChatModule.CHAT_ALWAYS_PERMISSION)) {
return;
}
}
示例9: toggleSneakEvent
/**
* Keeps track of player sneaking; if they are sneaking, we track when the
* snuck, or, clear if unsnuck.
*
* @param event
* the sneak toggle event
*/
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void toggleSneakEvent(PlayerToggleSneakEvent event) {
if (event.isSneaking()) {
sneakingSince.computeIfAbsent(event.getPlayer().getUniqueId(), u -> {
if (event.getPlayer().hasPermission("addgun.data")) { event.getPlayer().sendMessage(ChatColor.GOLD + " sneak started"); }
return System.currentTimeMillis();
});
} else {
if (sneakingSince.containsKey(event.getPlayer().getUniqueId()) && event.getPlayer().hasPermission("addgun.data")) {
event.getPlayer().sendMessage(ChatColor.GOLD + " sneak cleared");
}
sneakingSince.remove(event.getPlayer().getUniqueId());
}
}
示例10: onMatchCycle
@EventHandler(priority = EventPriority.HIGH)
public void onMatchCycle(CycleEvent event) {
tourney.setState(TourneyState.ENABLED_WAITING_FOR_TEAMS);
teamManager.assignTeams(vote.getParticipatingTeams());
clearCurrentVote();
}
示例11: onEntityDamage
@EventHandler(priority = EventPriority.HIGH)
public void onEntityDamage(EntityDamageEvent event)
{
//cancel if on periscope
if( event.getEntity() instanceof Player )
{
Player player = (Player)event.getEntity();
for( Periscope p: NavyCraft.allPeriscopes )
{
if( p.user == player )
{
event.setCancelled(true);
return;
}
}
if( event.getCause() == DamageCause.SUFFOCATION )
{
Craft c = Craft.getCraft(player.getLocation().getBlockX(),player.getLocation().getBlockY(), player.getLocation().getBlockZ());
if( c != null )
{
event.setCancelled(true);
return;
}
}
}
if ( event instanceof EntityDamageByEntityEvent )
{
Entity attacker = ((EntityDamageByEntityEvent) event).getDamager();
if( attacker instanceof Egg )
{
if( NavyCraft.explosiveEggsList.contains((Egg)attacker) )
{
event.setDamage(5);
}
}
}
}
示例12: noFire
@EventHandler(priority = EventPriority.HIGH)
public void noFire(final BlockBurnEvent event) {
event.setCancelled(true);
}
示例13: pickupItem
@EventHandler(priority = EventPriority.HIGH)
public void pickupItem(PlayerPickupItemEvent event) {
event.setCancelled(true);
}
示例14: onBlockIgnite
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onBlockIgnite(BlockIgniteEvent event) {
if (event.getCause() == BlockIgniteEvent.IgniteCause.SPREAD) {
event.setCancelled(true);
}
}
示例15: onEntityDamage
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onEntityDamage(EntityDamageEvent event) {
Entity entity = event.getEntity();
if (entity instanceof Player) {
Player player = (Player) entity;
Faction playerFactionAt = plugin.getFactionManager().getFactionAt(player.getLocation());
EntityDamageEvent.DamageCause cause = event.getCause();
if (playerFactionAt.isSafezone() && cause != EntityDamageEvent.DamageCause.SUICIDE && cause != EntityDamageEvent.DamageCause.VOID) {
event.setCancelled(true);
}
Player attacker = BukkitUtils.getFinalAttacker(event, true);
if (attacker != null) {
Faction attackerFactionAt = plugin.getFactionManager().getFactionAt(attacker.getLocation());
if (attackerFactionAt.isSafezone()) {
event.setCancelled(true);
attacker.sendMessage(ChatColor.RED + "You cannot attack players when in safe-zones.");
return;
} else if (playerFactionAt.isSafezone()) {
// it's already cancelled above.
attacker.sendMessage(ChatColor.RED + "You cannot attack players that are in safe-zones.");
return;
}
PlayerFaction attackerFaction;
PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);
if (playerFaction != null && ((attackerFaction = plugin.getFactionManager().getPlayerFaction(attacker)) != null)) {
Role role = playerFaction.getMember(player).getRole();
String hiddenAstrixedName = role.getAstrix() + (player.hasPotionEffect(PotionEffectType.INVISIBILITY) ? "???" : player.getName());
if (attackerFaction == playerFaction) {
event.setCancelled(true);
} else if (attackerFaction.getAllied().contains(playerFaction.getUniqueID())) {
if (true) { // TODO: prevent ally damage.
event.setCancelled(true);
attacker.sendMessage(SettingsYML.ALLY_COLOUR + hiddenAstrixedName + ChatColor.YELLOW + " is an ally.");
} else {
attacker.sendMessage(ChatColor.YELLOW + "Careful! " + SettingsYML.ALLY_COLOUR + hiddenAstrixedName + ChatColor.YELLOW + " is an ally.");
}
}
}
}
}
}