org.bukkit.event.EventPriority Java Examples

The following examples show how to use org.bukkit.event.EventPriority. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlayerListener.java    From BedWars with GNU Lesser General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST)
public void onCommandExecuted(PlayerCommandPreprocessEvent event) {
    if (event.isCancelled()) {
        return;
    }

    final Player player = event.getPlayer();
    if (Main.isPlayerInGame(player)) {
        //Allow players with permissions to use all commands
        if (player.hasPermission(ADMIN_PERMISSION)) {
            return;
        }

        final String message = event.getMessage();
        if (Main.isCommandLeaveShortcut(message)) {
            event.setCancelled(true);
            Main.getPlayerGameProfile(event.getPlayer()).changeGame(null);
        } else if (!Main.isCommandAllowedInGame(message.split(" ")[0])) {
            event.setCancelled(true);
            event.getPlayer().sendMessage(i18n("command_is_not_allowed"));
        }
    }
}
 
Example #2
Source File: ScoreMatchModule.java    From PGM with GNU Affero General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void playerAcquireRedeemableInBox(final PlayerItemTransferEvent event) {
  if (!event.isAcquiring()) return;
  final MatchPlayer player = this.match.getPlayer(event.getPlayer());
  if (player == null || !player.canInteract() || player.getBukkit().isDead()) return;

  for (final ScoreBox box : this.scoreBoxes) {
    if (!box.getRedeemables().isEmpty()
        && box.getRegion().contains(player.getBukkit())
        && box.canScore(player.getParticipantState())) {
      match
          .getExecutor(MatchScope.RUNNING)
          .execute(
              () -> {
                if (player.getBukkit().isOnline()) {
                  double points = redeemItems(box, player.getInventory());
                  ScoreMatchModule.this.playerScore(box, player, points);
                }
              });
    }
  }
}
 
Example #3
Source File: WorldEventHandler.java    From GriefDefender with MIT License 6 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onChunkLoad(ChunkLoadEvent event) {
    if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(event.getWorld().getUID())) {
        return;
    }

    final GDClaimManager claimWorldManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(event.getWorld().getUID());
    final GDChunk gdChunk = claimWorldManager.getChunk(event.getChunk());
    if (gdChunk != null) {
        try {
            gdChunk.loadChunkTrackingData();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
Example #4
Source File: PickerMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void checkInventoryClick(InventoryClickEvent event) {
    if(event.getCurrentItem() == null ||
       event.getCurrentItem().getItemMeta() == null ||
       event.getCurrentItem().getItemMeta().getDisplayName() == null) return;

    match.player(event.getActor()).ifPresent(player -> {
        if(!this.picking.contains(player)) return;

        this.handleInventoryClick(
            player,
            ChatColor.stripColor(event.getCurrentItem().getItemMeta().getDisplayName()),
            event.getCurrentItem().getData()
        );
        event.setCancelled(true);
    });
}
 
Example #5
Source File: NameTagX.java    From TAB with Apache License 2.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void a(PlayerMoveEvent e) {
	if (e.getFrom().getX() == e.getTo().getX() && e.getFrom().getY() == e.getTo().getY() && e.getFrom().getZ() == e.getTo().getZ()) return; //player only moved head
	ITabPlayer p = Shared.getPlayer(e.getPlayer().getUniqueId());
	if (p == null) return;
	if (!p.disabledNametag) Shared.featureCpu.runMeasuredTask("processing PlayerMoveEvent", CPUFeature.NAMETAGX_EVENT_MOVE, new Runnable() {
		public void run() {
			for (ArmorStand as : p.getArmorStands()) {
				as.updateLocation(e.getTo());
				List<ITabPlayer> nearbyPlayers = as.getNearbyPlayers();
				synchronized (nearbyPlayers){
					for (ITabPlayer nearby : nearbyPlayers) {
						nearby.sendPacket(as.getTeleportPacket(nearby));
					}
				}
			}
		}
	});
}
 
Example #6
Source File: KitMatchModule.java    From PGM with GNU Affero General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onGrenadeLaunch(final ProjectileLaunchEvent event) {
  if (event.getEntity().getShooter() instanceof Player) {
    Player player = (Player) event.getEntity().getShooter();
    ItemStack stack = player.getItemInHand();

    if (stack != null) {
      // special case for grenade arrows
      if (stack.getType() == Material.BOW) {
        int arrows = player.getInventory().first(Material.ARROW);
        if (arrows == -1) return;
        stack = player.getInventory().getItem(arrows);
      }

      Grenade grenade = Grenade.ITEM_TAG.get(stack);
      if (grenade != null) {
        grenade.set(PGM.get(), event.getEntity());
      }
    }
  }
}
 
Example #7
Source File: PlayerListener.java    From QuickShop-Reremake with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onDyeing(PlayerInteractEvent e) {
    if (e.getAction() != Action.RIGHT_CLICK_BLOCK || e.getItem() == null || !Util.isDyes(e.getItem().getType())) {
        return;
    }
    final Block block = e.getClickedBlock();
    if (block == null || !Util.isWallSign(block.getType())) {
        return;
    }
    final Block attachedBlock = Util.getAttached(block);
    if (attachedBlock == null || plugin.getShopManager().getShopIncludeAttached(attachedBlock.getLocation()) == null) {
        return;
    }
    e.setCancelled(true);
    Util.debugLog("Disallow " + e.getPlayer().getName() + " dye the shop sign.");
}
 
Example #8
Source File: FallTracker.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Called when the player touches or leaves the ground
 */
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerOnGroundChanged(final PlayerOnGroundEvent event) {
    MatchPlayer player = match.getParticipant(event.getPlayer());
    if(player == null) return;

    FallState fall = this.falls.get(player);
    if(fall != null) {
        if(event.getOnGround()) {
            // Falling player landed on the ground, cancel the fall if they are still there after MAX_ON_GROUND_TIME
            fall.onGroundTick = match.getClock().now().tick;
            fall.groundTouchCount++;
            this.scheduleCheckFallTimeout(fall, FallState.MAX_ON_GROUND_TICKS + 1);
        } else {
            // Falling player left the ground, check if it was caused by the attack
            this.playerBecameUnsupported(fall);
        }
    }
}
 
Example #9
Source File: KineticPlating.java    From MineTinker with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void effect(EntityDamageEvent event) {
	if (!(event.getEntity() instanceof Player)) return;
	if (event.getCause() != EntityDamageEvent.DamageCause.FLY_INTO_WALL) return;

	Player player = (Player) event.getEntity();
	if (!player.hasPermission("minetinker.modifiers.kineticplating.use")) return;
	ItemStack elytra = player.getInventory().getChestplate();

	if (!modManager.hasMod(elytra, this)) return;

	int level = modManager.getModLevel(elytra, this);
	double damageMod = 1.0 - (this.amount * level);
	if (damageMod < 0.0) damageMod = 0.0;
	double oldDamage = event.getDamage();
	double newDamage = oldDamage * damageMod;
	event.setDamage(newDamage);
	ChatWriter.logModifier(player, event, this, elytra, String.format("Damage(%.2f -> %.2f [x%.2f])", oldDamage, newDamage, damageMod));
}
 
Example #10
Source File: CommandEventHandler.java    From GriefDefender with MIT License 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerCommandMonitor(PlayerCommandPreprocessEvent event) {
    String message = event.getMessage();
    String arguments = "";
    String command = "";
    if (!message.contains(" ")) {
        command = message.replace("/", "");
    } else {
        command = message.substring(0, message.indexOf(" ")).replace("/", "");
        arguments = message.substring(message.indexOf(" ") + 1, message.length());
    }
    if (command.equalsIgnoreCase("datapack") && (arguments.contains("enable") || arguments.contains("disable"))) {
        if (GriefDefenderPlugin.getInstance().getTagProvider() != null) {
            GriefDefenderPlugin.getInstance().getTagProvider().refresh();
        }
    }
}
 
Example #11
Source File: BlockEventHandler.java    From GriefDefender with MIT License 6 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onBlockDispense(BlockDispenseEvent event) {
    final Block block = event.getBlock();
    final World world = event.getBlock().getWorld();
    if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID())) {
        return;
    }

    final Location location = block.getLocation();
    final GDClaimManager claimWorldManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(world.getUID());
    final GDChunk gpChunk = claimWorldManager.getChunk(block.getChunk());
    final GDPermissionUser user = gpChunk.getBlockOwner(location);
    if (user != null) {
        final BlockFace face = NMSUtil.getInstance().getFacing(block);
        final Location faceLocation = BlockUtil.getInstance().getBlockRelative(location, face);
        final GDClaim targetClaim = this.storage.getClaimAt(faceLocation);
        final ItemStack activeItem = user != null && user.getOnlinePlayer() != null ? NMSUtil.getInstance().getActiveItem(user.getOnlinePlayer()) : null;
        final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.INTERACT_BLOCK_SECONDARY, activeItem, event.getBlock(), user, TrustTypes.BUILDER, true);
        if (result == Tristate.FALSE) {
            event.setCancelled(true);
        } else {
            GDCauseStackManager.getInstance().pushCause(user);
        }
    }
}
 
Example #12
Source File: NameTagX.java    From TAB with Apache License 2.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void a(PlayerTeleportEvent e) {
	ITabPlayer p = Shared.getPlayer(e.getPlayer().getUniqueId());
	if (p == null) return;
	if (!p.disabledNametag) Shared.featureCpu.runMeasuredTask("processing PlayerTeleportEvent", CPUFeature.NAMETAGX_EVENT_TELEPORT, new Runnable() {
		public void run() {
			synchronized (p.armorStands) {
				for (ArmorStand as : p.armorStands) {
					as.updateLocation(e.getTo());
					List<ITabPlayer> nearbyPlayers = as.getNearbyPlayers();
					synchronized (nearbyPlayers){
						for (ITabPlayer nearby : nearbyPlayers) {
							nearby.sendPacket(as.getTeleportPacket(nearby));
						}
					}
				}
			}
		}
	});
}
 
Example #13
Source File: ChannelMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void partyLeave(PlayerLeavePartyEvent event) {
    if(event.getOldParty() instanceof MultiPlayerParty) {
        PlayerManager playerManager = channelsPlugin.getPlayerManager();
        Player bukkitPlayer = event.getPlayer().getBukkit();
        PartyChannel channel = partyChannels.get(event.getOldParty());

        if(channel != null) {
            bukkitPlayer.removeAttachments(channel.getListeningPermission());
            bukkitPlayer.removeAttachments(matchListeningPermission);

            // Whenever the player leaves a party with its own channel, check if that is the player's current channel,
            // and if it's not, then set their team chat setting to false. This is the only way to find out when they
            // switch to global chat, because the Channels plugin doesn't provide any notifcation.
            if(playerManager.getMembershipChannel(bukkitPlayer) != channel) {
                teamChatters.put(bukkitPlayer, false);
            }
        }
    }
}
 
Example #14
Source File: PlayerCustomItemDamage.java    From AdditionsAPI with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void gamemodeCheck(PlayerCustomItemDamageEvent event) {
	GameMode gm = event.getPlayer().getGameMode();
	if (gm != GameMode.SURVIVAL && gm != GameMode.ADVENTURE) {
		event.setCancelled(true);
	}
	if (event.getDamage() == 0) {
		event.setCancelled(true);
	}
}
 
Example #15
Source File: CivilianListener.java    From Civs with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onAdvertisementPlace(SignChangeEvent event) {
    Town town = TownManager.getInstance().getTownAt(event.getBlock().getLocation());
    if (town == null) {
        return;
    }
    Government government = GovernmentManager.getInstance().getGovernment(town.getGovernmentType());
    if (government.getGovernmentType() != GovernmentType.IDIOCRACY) {
        return;
    }
    changeAdvertising(event.getBlock(), town, false);
    changeAdvertising(event.getLines(), town, true);
    Util.checkNoise(town, event.getPlayer());
}
 
Example #16
Source File: WalkingTaskType.java    From Quests with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onMove(PlayerMoveEvent event) {
    if (event.getFrom().getBlockX() == event.getTo().getBlockX() && event.getFrom().getBlockZ() == event.getTo().getBlockZ()) {
        return;
    }

    Player player = event.getPlayer();

    QPlayer qPlayer = QuestsAPI.getPlayerManager().getPlayer(player.getUniqueId(), true);
    QuestProgressFile questProgressFile = qPlayer.getQuestProgressFile();

    for (Quest quest : super.getRegisteredQuests()) {
        if (questProgressFile.hasStartedQuest(quest)) {
            QuestProgress questProgress = questProgressFile.getQuestProgress(quest);

            for (Task task : quest.getTasksOfType(super.getType())) {
                TaskProgress taskProgress = questProgress.getTaskProgress(task.getId());

                if (taskProgress.isCompleted()) {
                    continue;
                }

                int distanceNeeded = (int) task.getConfigValue("distance");

                int progressDistance;
                if (taskProgress.getProgress() == null) {
                    progressDistance = 0;
                } else {
                    progressDistance = (int) taskProgress.getProgress();
                }

                taskProgress.setProgress(progressDistance + 1);

                if (((int) taskProgress.getProgress()) >= distanceNeeded) {
                    taskProgress.setCompleted(true);
                }
            }
        }
    }
}
 
Example #17
Source File: DefuseListener.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void rightClickDefuse(final PlayerInteractEntityEvent event) {
    ItemStack hand = event.getPlayer().getItemInHand();
    if(hand == null || hand.getType() != DEFUSE_ITEM) return;

    this.participantDefuse(event.getPlayer(), event.getRightClicked());
}
 
Example #18
Source File: WorldEventHandler.java    From GriefDefender with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onWorldUnload(WorldUnloadEvent event) {
    if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(event.getWorld().getUID())) {
        return;
    }

    GriefDefenderPlugin.getInstance().dataStore.removeClaimWorldManager(event.getWorld().getUID());
}
 
Example #19
Source File: FreezeMatchModule.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerCommand(final PlayerCommandPreprocessEvent event) {
  if (freeze.isFrozen(event.getPlayer()) && !event.getPlayer().hasPermission(Permissions.STAFF)) {
    boolean allow =
        ALLOWED_CMDS.stream()
            .filter(cmd -> event.getMessage().startsWith(cmd))
            .findAny()
            .isPresent();

    if (!allow) {
      // Don't allow commands except for those related to chat.
      event.setCancelled(true);
    }
  }
}
 
Example #20
Source File: ProximityGoal.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
private void onPlayerKill(MatchPlayerDeathEvent event) {
    if(event.getKiller() != null &&
       event.isChallengeKill() &&
       getProximityMetricType(event.getKiller().getParty()) == ProximityMetric.Type.CLOSEST_KILL) {

        updateProximity(event.getKiller(), event.getKiller().getLocation());
    }
}
 
Example #21
Source File: FilterMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerMove(CoarsePlayerMoveEvent event) {
    // On movement events, check the player immediately instead of invalidating them.
    // We can't wait until the end of the tick because the player could move several
    // more times by then (i.e. if we received multiple packets from them in the same
    // tick) which would make region checks highly unreliable.
    match.player(event.getPlayer()).ifPresent(player -> {
        invalidate(player);
        match.getServer().postToMainThread(match.getPlugin(), true, this::tick);
    });
}
 
Example #22
Source File: GhostSquadronMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void trackerMelee(final EntityDamageByEntityEvent event) {
    if(event.getDamager() instanceof Player && event.getEntity() instanceof Player) {
        MatchPlayer damager = this.getMatch().getPlayer((Player) event.getDamager());
        MatchPlayer damaged = this.getMatch().getPlayer((Player) event.getEntity());

        if(damager != null && damaged != null && this.isClass(damager, this.trackerClass) && damager.getParty() != damaged.getParty()) {
            ItemStack hand = damager.getBukkit().getItemInHand();
            if(hand != null && hand.getType() == Material.COMPASS) {
                this.reveal(damaged.getBukkit(), GhostSquadron.TRACKER_REVEAL_DURATION);
            }
        }
    }
}
 
Example #23
Source File: TNTMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void dispenserNukes(BlockTransformEvent event) {
    BlockState oldState = event.getOldState();
    if(oldState instanceof Dispenser &&
       this.properties.dispenserNukeLimit > 0 &&
       this.properties.dispenserNukeMultiplier > 0 &&
       event.getCause() instanceof EntityExplodeEvent) {

        EntityExplodeEvent explodeEvent = (EntityExplodeEvent) event.getCause();
        Dispenser dispenser = (Dispenser) oldState;
        int tntLimit = Math.round(this.properties.dispenserNukeLimit / this.properties.dispenserNukeMultiplier);
        int tntCount = 0;

        for(ItemStack stack : dispenser.getInventory().contents()) {
            if(stack != null && stack.getType() == Material.TNT) {
                int transfer = Math.min(stack.getAmount(), tntLimit - tntCount);
                if(transfer > 0) {
                    stack.setAmount(stack.getAmount() - transfer);
                    tntCount += transfer;
                }
            }
        }

        tntCount = (int) Math.ceil(tntCount * this.properties.dispenserNukeMultiplier);

        for(int i = 0; i < tntCount; i++) {
            TNTPrimed tnt = this.getMatch().getWorld().spawn(BlockUtils.base(dispenser), TNTPrimed.class);

            tnt.setFuseTicks(10 + this.getMatch().getRandom().nextInt(10)); // between 0.5 and 1.0 seconds, same as vanilla TNT chaining

            Random random = this.getMatch().getRandom();
            Vector velocity = new Vector(random.nextGaussian(), random.nextGaussian(), random.nextGaussian()); // uniform random direction
            velocity.normalize().multiply(0.5 + 0.5 * random.nextDouble());
            tnt.setVelocity(velocity);

            callPrimeEvent(tnt, explodeEvent.getEntity(), false);
        }
    }
}
 
Example #24
Source File: FormattingListener.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void destroyableDestroyed(final DestroyableDestroyedEvent event) {
  Destroyable destroyable = event.getDestroyable();
  if (!destroyable.isVisible()) return;

  event
      .getMatch()
      .sendMessage(
          TranslatableComponent.of(
              "destroyable.complete.owned",
              formatContributions(event.getDestroyable().getContributions()),
              destroyable.getComponentName(),
              destroyable.getOwner().getName()));
}
 
Example #25
Source File: DisplayProtectionListener.java    From QuickShop-Reremake with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void item(PlayerItemHeldEvent e) {
    if (!useEnhanceProtection) {
        return;
    }
    if (DisplayItem.getNowUsing() != DisplayType.REALITEM) {
        return;
    }
    final ItemStack stack = e.getPlayer().getInventory().getItemInMainHand();
    final ItemStack stackOffHand = e.getPlayer().getInventory().getItemInOffHand();
    if (DisplayItem.checkIsGuardItemStack(stack)) {
        e.getPlayer().getInventory().setItemInMainHand(new ItemStack(Material.AIR, 0));
        // You shouldn't be able to pick up that...
        sendAlert(
                "[DisplayGuard] Player "
                        + e.getPlayer().getName()
                        + " helded the displayItem, QuickShop already cancelled and removed it.");
        e.setCancelled(true);
        Util.inventoryCheck(e.getPlayer().getInventory());
    }
    if (DisplayItem.checkIsGuardItemStack(stackOffHand)) {
        e.getPlayer().getInventory().setItemInOffHand(new ItemStack(Material.AIR, 0));
        // You shouldn't be able to pick up that...
        sendAlert(
                "[DisplayGuard] Player "
                        + e.getPlayer().getName()
                        + " helded the displayItem, QuickShop already cancelled and removed it.");
        e.setCancelled(true);
        Util.inventoryCheck(e.getPlayer().getInventory());
    }
}
 
Example #26
Source File: BlitzMatchModule.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void handleLeave(final PlayerPartyChangeEvent event) {
  int lives = this.lifeManager.getLives(event.getPlayer().getId());
  if (event.getOldParty() instanceof Competitor && lives > 0) {
    this.handleElimination(event.getPlayer(), (Competitor) event.getOldParty());
  }
}
 
Example #27
Source File: DeathTracker.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Must run after {@link tc.oc.pgm.spawns.SpawnMatchModule#onVanillaDeath}
 */
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerDeath(PlayerDeathEvent event) {
    logger.fine("Wrapping " + event);
    MatchPlayer victim = match.getParticipant(event.getEntity());
    if(victim == null || victim.isDead()) return;

    DamageInfo info = getLastDamage(victim);
    if(info == null) info = new GenericDamageInfo(EntityDamageEvent.DamageCause.CUSTOM);

    match.callEvent(new MatchPlayerDeathEvent(event, victim, info, CombatLogTracker.isCombatLog(event)));
}
 
Example #28
Source File: SpawnMatchModule.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * This handler must run after {@link EventFilterMatchModule#onInteract(PlayerInteractEvent)} and
 * before the event handler in WorldEdit for compass clicking.
 */
@EventHandler(priority = EventPriority.LOW)
public void onInteract(final PlayerInteractEvent event) {
  MatchPlayer player = match.getPlayer(event.getPlayer());
  if (player != null) {
    State state = states.get(player);
    if (state != null) state.onEvent(event);
  }
}
 
Example #29
Source File: BlitzMatchModule.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void handleJoin(final PlayerParticipationStartEvent event) {
  if (event.getMatch().isRunning()) {
    event.cancel(
        TranslatableComponent.of(
            "blitz.joinDenied", TranslatableComponent.of("gamemode.blitz.name", TextColor.AQUA)));
  }
}
 
Example #30
Source File: FreezeMatchModule.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onInventoryClick(final InventoryClickEvent event) {
  if (event.getWhoClicked() instanceof Player) {
    if (freeze.isFrozen(event.getWhoClicked())) {
      event.setCancelled(true);
    }
  }
}