本文整理匯總了Java中org.spongepowered.api.event.Order.LAST屬性的典型用法代碼示例。如果您正苦於以下問題:Java Order.LAST屬性的具體用法?Java Order.LAST怎麽用?Java Order.LAST使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.spongepowered.api.event.Order
的用法示例。
在下文中一共展示了Order.LAST屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onClientAuthMonitor
@Listener(order = Order.LAST)
@IsCancelled(Tristate.UNDEFINED)
public void onClientAuthMonitor(ClientConnectionEvent.Auth e) {
/* Listen to see if the event was cancelled after we initially handled the connection
If the connection was cancelled here, we need to do something to clean up the data that was loaded. */
// Check to see if this connection was denied at LOW.
if (this.deniedAsyncLogin.remove(e.getProfile().getUniqueId())) {
// This is a problem, as they were denied at low priority, but are now being allowed.
if (e.isCancelled()) {
this.plugin.getLog().severe("Player connection was re-allowed for " + e.getProfile().getUniqueId());
e.setCancelled(true);
}
}
}
示例2: onMessageChannelEventChat
@Listener(order = Order.LAST)
public void onMessageChannelEventChat(MessageChannelEvent.Chat event, @First Player player) {
String mode = ConfigManager.get().getConfig().getNode("mode").getString();
Text tag;
if (mode.equalsIgnoreCase("default")) {
tag = defaultTag(player);
} else if (mode.equalsIgnoreCase("advanced")) {
tag = advancedTag(player);
} else {
return;
}
MessageFormatter formatter = event.getFormatter();
Text prefix = Text.join(tag, formatter.getHeader().toText());
formatter.setHeader(TextTemplate.of(prefix));
}
示例3: onEntityTeleport
@Listener(order = Order.LAST)
public void onEntityTeleport(MoveEntityEvent.Teleport event) {
if (event.getTargetEntity().getType() != EntityTypes.PLAYER) {
return; // not a player
}
if (event.getFromTransform().getPosition().equals(event.getToTransform().getPosition())) {
return; // player hasn't moved
}
Optional<Challenger> chal = CommonCore.getChallenger(event.getTargetEntity().getUniqueId());
if (chal.isPresent() && !((CommonChallenger) chal.get()).isLeaving()) {
Boundary bound = chal.get().getRound().getArena().getBoundary();
if (!bound.contains(LocationConverter.of(event.getToTransform().getPosition()))) {
if (chal.get().getRound().getConfigValue(ConfigNode.ALLOW_EXIT_BOUNDARY)) {
chal.get().removeFromRound();;
} else {
event.setCancelled(true);
}
}
}
}
示例4: onBlockBreak
@Listener(order = Order.LAST)
public void onBlockBreak(ChangeBlockEvent.Break event) {
for (Transaction<BlockSnapshot> blockSnapshotTransaction : event.getTransactions()) {
final BlockSnapshot original = blockSnapshotTransaction.getOriginal();
if (original.getState().getType() == BlockTypes.STANDING_SIGN
|| original.getState().getType() == BlockTypes.WALL_SIGN) {
if (original.getLocation().isPresent()) {
final Location3D location3D = WorldLocationConverter.of(original.getLocation().get());
// iterate all arenas of all minigames to see if sign is registered
//TODO: This is more expensive than it needs to be.
// We should maintain a global index of registered signs.
if (InfernoCore.getMinigames().values().stream()
.filter(minigame -> minigame.getArenas().stream()
.filter(arena -> arena.getLobbySignAt(location3D).isPresent()).count() > 0)
.count() > 0) {
event.setCancelled(true);
}
}
}
}
}
示例5: onPlayerInteractEntity
@Listener(order=Order.LAST)
public void onPlayerInteractEntity(InteractEntityEvent event, @First Player player_sponge) {
EPlayer player = this.plugin.getEServer().getEPlayer(player_sponge);
// GameMode : Painting
if (event instanceof InteractEntityEvent.Secondary && event.getTargetEntity() instanceof Painting) {
if (this.plugin.getConfigs().isGameModePaint() && player.isSneaking() && player.isCreative()) {
Painting paint = (Painting) event.getTargetEntity();
if (paint.get(Keys.ART).isPresent()) {
Art art = paint.get(Keys.ART).get();
Art next = UtilsPainting.next(art);
while (!paint.offer(Keys.ART, next).isSuccessful() && !art.equals(next)){
next = UtilsPainting.next(next);
}
}
}
}
// AFK
player.updateLastActivated();
// Freeze
if(player.isFreeze()) {
event.setCancelled(true);
}
}
示例6: onEntityDeath
@Listener(order = Order.LAST)
public void onEntityDeath(DestructEntityEvent.Death event) {
if (!GriefPreventionPlugin.instance.claimsEnabledForWorld(event.getTargetEntity().getWorld().getProperties())) {
return;
}
GPTimings.ENTITY_DEATH_EVENT.startTimingIfSync();
final Living entity = event.getTargetEntity();
if (!(entity instanceof Player) || !event.getCause().first(EntityDamageSource.class).isPresent()) {
GPTimings.ENTITY_DEATH_EVENT.stopTimingIfSync();
return;
}
// don't do the rest in worlds where claims are not enabled
if (!GriefPreventionPlugin.instance.claimsEnabledForWorld(entity.getWorld().getProperties())) {
GPTimings.ENTITY_DEATH_EVENT.stopTimingIfSync();
return;
}
GPTimings.ENTITY_DEATH_EVENT.stopTimingIfSync();
}
示例7: onPlayerRespawn
@Listener(order = Order.LAST)
public void onPlayerRespawn(RespawnPlayerEvent event) {
GPTimings.PLAYER_RESPAWN_EVENT.startTimingIfSync();
Player player = event.getTargetEntity();
if (!GriefPreventionPlugin.instance.claimsEnabledForWorld(player.getWorld().getProperties())) {
GPTimings.PLAYER_RESPAWN_EVENT.stopTimingIfSync();
return;
}
GPPlayerData playerData = GriefPreventionPlugin.instance.dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
playerData.lastSpawn = Calendar.getInstance().getTimeInMillis();
playerData.lastPvpTimestamp = 0; // no longer in pvp combat
// also send him any messaged from grief prevention he would have
// received while dead
if (playerData.messageOnRespawn != null) {
// color is already embedded inmessage in this case
GriefPreventionPlugin.sendMessage(player, Text.of(playerData.messageOnRespawn), 40L);
playerData.messageOnRespawn = null;
}
GriefPreventionPlugin.instance.checkPvpProtectionNeeded(player);
GPTimings.PLAYER_RESPAWN_EVENT.stopTimingIfSync();
}
示例8: onEntityDamage
@Listener(order = Order.LAST)
public void onEntityDamage(DamageEntityEvent event) {
if (event.isCancelled() || event.getFinalDamage() == 0) {
return;
}
if (event.getTargetEntity().getType() == EntityTypes.PLAYER) {
UUID id = event.getTargetEntity().getUniqueId();
IActiveCharacter character = characterService.getCharacter(id);
IEffectContainer container = character.getEffect(name);
if (container == null)
return;
if (!event.getCause().first(SoulBindEffect.class).isPresent()) {
event.setBaseDamage(event.getBaseDamage() * .5);
SoulBindEffect effect = (SoulBindEffect) container;
SkillDamageSourceBuilder builder = new SkillDamageSourceBuilder();
if (effect.getConsumer() == character) {
effect.getTarget().getEntity().damage(event.getBaseDamage(), builder.build());
} else {
effect.getConsumer().getEntity().damage(event.getBaseDamage(), builder.build());
}
}
}
}
示例9: onEntityDamageEvent
@Listener(order = Order.LAST)
public void onEntityDamageEvent(DamageEntityEvent event) {
Entity defender = event.getTargetEntity();
Optional<PatientXInstance> optInst = manager.getApplicableZone(defender);
if (!optInst.isPresent()) {
return;
}
PatientXInstance inst = optInst.get();
DamageSource dmgSource = event.getCause().first(DamageSource.class).get();
if (defender instanceof Player && manager.getBlockedDamage().contains(dmgSource.getType())) {
// Explosive damage formula: (1 × 1 + 1) × 8 × power + 1
// Use 49, snowball power is 3
double ratio = event.getBaseDamage() / 49;
// Nullify all modifiers
for (DamageFunction modifier : event.getModifiers()) {
event.setDamage(modifier.getModifier(), (a) -> 0D);
}
event.setBaseDamage(ratio * inst.getDifficulty());
}
}
示例10: onDeath
@Listener(order = Order.LAST)
public void onDeath(DestructEntityEvent.Death e) {
if (!(e.getTargetEntity() instanceof Player))
return;
Player p = (Player) e.getTargetEntity();
if (isOnPipe(p.getUniqueId()) && Via.getConfig().isShowNewDeathMessages() && checkGamerule(p.getWorld())) {
sendPacket(p, e.getMessage().toPlain());
}
}
示例11: onClientLoginMonitor
@Listener(order = Order.LAST)
@IsCancelled(Tristate.UNDEFINED)
public void onClientLoginMonitor(ClientConnectionEvent.Login e) {
/* Listen to see if the event was cancelled after we initially handled the login
If the connection was cancelled here, we need to do something to clean up the data that was loaded. */
// Check to see if this connection was denied at LOW. Even if it was denied at LOW, their data will still be present.
if (this.deniedLogin.remove(e.getProfile().getUniqueId())) {
// This is a problem, as they were denied at low priority, but are now being allowed.
if (!e.isCancelled()) {
this.plugin.getLog().severe("Player connection was re-allowed for " + e.getProfile().getUniqueId());
e.setCancelled(true);
}
}
}
示例12: onDamageEntity
@Listener(order = Order.LAST)
public void onDamageEntity(DamageEntityEvent event) {
java.util.Optional<Player> damager = event.getCause().first(Player.class);
if (!damager.isPresent()) {
return; // not a player, so return
}
Optional<Challenger> chal = CommonCore.getChallenger(event.getTargetEntity().getUniqueId());
Optional<Challenger> damChal = CommonCore.getChallenger(damager.get().getUniqueId());
// cancel if either of the players is spectating
if (chal.isPresent() && chal.get().isSpectating() || (damChal.isPresent() && damChal.get().isSpectating())) {
event.setCancelled(true);
return;
}
// check whether both are in a round
if (chal.isPresent() && damChal.isPresent()) {
// check whether they're in the same round
if (chal.get().getRound() == damChal.get().getRound()) {
// check whether damage is disabled entirely in the round, or if they're on the same team
if (!chal.get().getRound().getConfigValue(ConfigNode.ALLOW_DAMAGE)
|| (!chal.get().getRound().getConfigValue(ConfigNode.ALLOW_FRIENDLY_FIRE)
&& chal.get().getTeam().orNull() == damChal.get().getTeam().orNull())) {
event.setCancelled(true);
}
} else {
event.setCancelled(true);
}
} else if (chal.isPresent() != damChal.isPresent()) {
event.setCancelled(true); // one's in a round and one's not
}
}
示例13: onChangeBlock
@Listener(order = Order.LAST)
public void onChangeBlock(ChangeBlockEvent event) {
java.util.Optional<Player> player = event.getCause().first(Player.class);
if (player.isPresent()) {
doSpectatorCheck(event, player.get().getUniqueId());
}
}
示例14: onPlayerInteract
@Listener(order=Order.LAST)
public void onPlayerInteract(InteractItemEvent.Secondary event, @First Player player_sponge) {
EPlayer player = this.plugin.getEServer().getEPlayer(player_sponge);
if(player.getItemInMainHand().isPresent()){
ItemStack item = player.getItemInMainHand().get();
if(item.getType().equals(ItemTypes.COMPASS) && player.isCreative()){
Optional<Vector3i> block = player.getViewBlock();
if (block.isPresent()) {
player.teleport(player.getWorld().getLocation(block.get().add(0, 1, 0)), true);
}
}
}
}
示例15: onPlayerKicked
@Listener(order = Order.LAST)
public void onPlayerKicked(KickPlayerEvent event) {
GPTimings.PLAYER_KICK_EVENT.startTimingIfSync();
Player player = event.getTargetEntity();
GPPlayerData playerData = this.dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
playerData.wasKicked = true;
GPTimings.PLAYER_KICK_EVENT.stopTimingIfSync();
}