Java Code Examples for org.bukkit.event.EventPriority#MONITOR

The following examples show how to use org.bukkit.event.EventPriority#MONITOR . 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: CommandEventHandler.java    From GriefDefender with MIT License 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerChatPost(AsyncPlayerChatEvent event) {
    final Player player = event.getPlayer();
    final Iterator<Player> iterator = event.getRecipients().iterator();

    while (iterator.hasNext()) {
        final Player receiver = iterator.next();
        if (receiver == player) {
            continue;
        }

        final GDPlayerData receiverData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(receiver.getWorld(), receiver.getUniqueId());
        if (receiverData.isRecordingChat()) {
            iterator.remove();
            final String s = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage());
            final Component message = LegacyComponentSerializer.legacy().deserialize(s, '&');
            final Component component = TextComponent.builder()
                    .append(TextComponent.builder()
                            .append(message)
                            .hoverEvent(HoverEvent.showText(TextComponent.of(formatter.format(Instant.now()))))
                            .build())
                    .build();
            receiverData.chatLines.add(component);
        }
    }
}
 
Example 2
Source File: FillListener.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 onInventoryOpen(InventoryOpenEvent event) {
    final MatchPlayer opener = playerFinder.getParticipant(event.getActor());
    if(opener == null) return;

    final Inventory inventory = event.getInventory();
    final Predicate<Filter> passesFilter = passesFilter(inventory.getHolder());
    if(passesFilter == null) return;

    logger.fine(() -> opener.getName() + " opened a " + inventory.getHolder().getClass().getSimpleName());

    // Find all Fillers that apply to the holder of the opened inventory
    final List<Filler> fillers = this.fillers.stream()
                                             .filter(filler -> passesFilter.test(filler.filter()))
                                             .collect(Collectors.toImmutableList());
    if(fillers.isEmpty()) return;

    logger.fine(() -> "Found fillers " + fillers.stream()
                                                .map(Filler::identify)
                                                .collect(java.util.stream.Collectors.joining(", ")));

    // Find all Caches that the opened inventory is part of
    final List<Fillable> fillables = new ArrayList<>();
    for(Cache cache : caches) {
        if(passesFilter.test(cache.region()) && passesFilter.test(cache.filter())) {
            fillables.add(new FillableCache(cache));
        }
    }
    // If the inventory is not in any Cache, just fill it directly
    if(fillables.isEmpty()) {
        fillables.add(new FillableInventory(inventory));
    }

    fillables.forEach(fillable -> fillable.fill(opener, fillers));
}
 
Example 3
Source File: PlayerEventListener.java    From Hawk with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void abilitiesServerSide(HawkAsyncPlayerAbilitiesEvent e) {
    HawkPlayer pp = hawk.getHawkPlayer(e.getPlayer());
    pp.sendSimulatedAction(new Runnable() {
        @Override
        public void run() {
            pp.setAllowedToFly(e.isAllowedToFly());
            pp.setFlying(e.isFlying());
            pp.setInCreative(e.isCreativeMode());
        }
    });
}
 
Example 4
Source File: FireworkMatchModule.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onFlagCapture(final FlagCaptureEvent event) {
  if (PGM.get().getConfiguration().showFireworks() && event.getGoal().isVisible()) {
    this.spawnFireworkDisplay(
        event.getMatch().getWorld(),
        event.getNet().getRegion(),
        event.getGoal().getDyeColor().getColor(),
        FLAG_CAPTURE_COUNT,
        FLAG_CAPTURE_RADIUS,
        ROCKET_POWER);
  }
}
 
Example 5
Source File: KitMatchModule.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 onPlayerQuit(final PlayerQuitEvent event) {
  MatchPlayer player = this.match.getPlayer(event.getPlayer());
  if (player != null) {
    this.lockedArmorSlots.removeAll(player);
  }
}
 
Example 6
Source File: ReadyListener.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 onPartyRemove(PartyRemoveEvent event) {
    ReadyManager readyManager = readyManagerProvider.get().orElse(null);
    if(readyManager == null) return;

    readyManager.remove(event.getParty());
    checkMatchStart(event.getMatch());
}
 
Example 7
Source File: ViewInventoryMatchModule.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void updateMonitoredTransform(final PlayerBlockTransformEvent event) {
  MatchPlayer player = event.getPlayer();
  if (player != null) this.scheduleCheck(player.getBukkit());
}
 
Example 8
Source File: GeneralizingListener.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerMoveMonitor(final PlayerMoveEvent event) {
  this.handleMovementMonitor(event);
}
 
Example 9
Source File: StatsPlayerFacet.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@TargetedEventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerDeath(final MatchPlayerDeathEvent event) {
    if (event.isVictim(this.player) || event.isKiller(this.player)) update();
}
 
Example 10
Source File: FormattingListener.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void destroyableDestroyed(final DestroyableDestroyedEvent event) {
    Destroyable destroyable = event.getDestroyable();

    if (destroyable.isVisible()) {
        List<DestroyableContribution> sorted = new ArrayList<>(event.getDestroyable().getContributions());
        Collections.sort(sorted, new Comparator<DestroyableContribution>() {
            @Override
            public int compare(DestroyableContribution o1, DestroyableContribution o2) {
                return Double.compare(o2.getPercentage(), o1.getPercentage()); // reverse
            }
        });

        List<BaseComponent> contributors = new ArrayList<>();
        boolean someExcluded = false;
        for(DestroyableContribution entry : sorted) {
            if(entry.getPercentage() > 0.2) { // 20% necessary to be included
                contributors.add(new TranslatableComponent(
                    "objective.credit.player.percentage",
                    entry.getPlayerState().getStyledName(NameStyle.COLOR),
                    new Component(String.valueOf(Math.round(entry.getPercentage() * 100)), net.md_5.bungee.api.ChatColor.AQUA)
                ));
            } else {
                someExcluded = true;
            }
        }

        BaseComponent credit;
        if(contributors.isEmpty()) {
            credit = someExcluded ? new TranslatableComponent("objective.credit.many") // All contributors < 20%
                                  : new TranslatableComponent("objective.credit.unknown"); // No contributors
        } else {
            if(someExcluded) {
                contributors.add(new TranslatableComponent("objective.credit.etc")); // Some contributors < 20%
            }
            credit = new ListComponent(contributors);
        }

        event.getMatch().sendMessage(new TranslatableComponent(
            "match.complete.destroyable",
            credit,
            destroyable.getComponentName(),
            destroyable.getOwner().getComponentName()
        ));
    }
}
 
Example 11
Source File: FallTracker.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerDespawn(final ParticipantDespawnEvent event) {
    endFall(event.getPlayer());
}
 
Example 12
Source File: TPContainerListener.java    From Transport-Pipes with MIT License 4 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onChunkLoad(ChunkLoadEvent e) {
    handleChunkLoadSync(e.getChunk(), false);
}
 
Example 13
Source File: ScoreboardMatchModule.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onPartyRemove(PartyRemoveEvent event) {
  removePartyScoreboard(event.getParty());
}
 
Example 14
Source File: OwnedMobTracker.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onSlimeSplit(SlimeSplitEvent event) {
    if(event.getCount() > 0 && resolveEntity(event.getEntity()) != null) {
        splitter = new WeakReference<>(event.getEntity());
    }
}
 
Example 15
Source File: ViewInventoryMatchModule.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void updateMonitoredDamage(final EntityDamageEvent event) {
  if (event.getEntity() instanceof Player) {
    this.scheduleCheck((Player) event.getEntity());
  }
}
 
Example 16
Source File: TabManager.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onRespawn(PlayerRespawnEvent event) {
    TabView view = this.getViewOrNull(event.getPlayer());
    if(view != null) view.onRespawn(event);
}
 
Example 17
Source File: CombatLogTracker.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerDeath(PlayerDeathEvent event) {
  // Clear last damage when a player dies
  this.recentDamage.remove(event.getEntity());
}
 
Example 18
Source File: Flag.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
private void onFlagCapture(FlagCaptureEvent event) {
    this.state.onEvent(event);
}
 
Example 19
Source File: ArmorListener.java    From MineTinker with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void expCalculation(MTEntityDamageByEntityEvent event) {
	expCalculation(event.isBlocking(), event.getTool(), event.getEvent(), event.getPlayer());
}
 
Example 20
Source File: Flag.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
private void onPlayerMove(CoarsePlayerMoveEvent event) {
    this.state.onEvent(event);
}