• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IsCancelled类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: onClientAuthMonitor

import org.spongepowered.api.event.filter.IsCancelled; //导入依赖的package包/类
@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);
        }
    }
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:17,代码来源:SpongeConnectionListener.java


示例2: onClientLogin

import org.spongepowered.api.event.filter.IsCancelled; //导入依赖的package包/类
@Listener(order = Order.FIRST)
@IsCancelled(Tristate.UNDEFINED)
public void onClientLogin(ClientConnectionEvent.Login e) {
    /* Called when the player starts logging into the server.
       At this point, the users data should be present and loaded.
       Listening on LOW priority to allow plugins to further modify data here. (auth plugins, etc.) */

    final GameProfile player = e.getProfile();

    if (this.plugin.getConfiguration().get(ConfigKeys.DEBUG_LOGINS)) {
        this.plugin.getLog().info("Processing login event for " + player.getUniqueId() + " - " + player.getName());
    }

    final User user = this.plugin.getUserManager().getIfLoaded(this.plugin.getUuidCache().getUUID(player.getUniqueId()));

    /* User instance is null for whatever reason. Could be that it was unloaded between asyncpre and now. */
    if (user == null) {
        this.deniedLogin.add(player.getUniqueId());

        this.plugin.getLog().warn("User " + player.getUniqueId() + " - " + player.getName() + " doesn't have data pre-loaded. - denying login.");
        e.setCancelled(true);
        e.setMessageCancelled(false);
        //noinspection deprecation
        e.setMessage(TextSerializers.LEGACY_FORMATTING_CODE.deserialize(Message.LOADING_ERROR.asString(this.plugin.getLocaleManager())));
    }
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:27,代码来源:SpongeConnectionListener.java


示例3: onChangeBlock

import org.spongepowered.api.event.filter.IsCancelled; //导入依赖的package包/类
@Listener(order=Order.FIRST)
@IsCancelled(Tristate.UNDEFINED)
public void onChangeBlock(ChangeBlockEvent.Place event) {
	Optional<Player> optPlayer = event.getCause().get(NamedCause.SOURCE, Player.class);
	if (!optPlayer.isPresent()) return;
	
	Player player = optPlayer.get();
	if (!this.players.contains(player.getUniqueId())) return;
	
	event.setCancelled(true);
	
	event.getTransactions().forEach(transaction -> {
		player.sendMessage(Text.of(TextColors.GRAY, TextStyles.BOLD, "============================================"));
		player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Type: ", TextColors.BLUE, TextStyles.RESET, transaction.getOriginal().getState().getId()));
		player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Owner: ", TextColors.BLUE, TextStyles.RESET, transaction.getOriginal().getCreator()));
		player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Notifier: ", TextColors.BLUE, TextStyles.RESET, transaction.getOriginal().getNotifier()));
	});
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:19,代码来源:EAInfo.java


示例4: onInteractBlock

import org.spongepowered.api.event.filter.IsCancelled; //导入依赖的package包/类
@Listener(order=Order.FIRST)
@IsCancelled(Tristate.UNDEFINED)
public void onInteractBlock(InteractBlockEvent.Primary event) {
	Optional<Player> optPlayer = event.getCause().get(NamedCause.SOURCE, Player.class);
	if (!optPlayer.isPresent()) return;
	
	Player player = optPlayer.get();
	if (!this.players.contains(player.getUniqueId())) return;
	
	event.setCancelled(true);
	
	player.sendMessage(Text.of(TextColors.GRAY, TextStyles.BOLD, "============================================"));
	player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Type: ", TextColors.BLUE, TextStyles.RESET, event.getTargetBlock().getState().getId()));
	player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Owner: ", TextColors.BLUE, TextStyles.RESET, event.getTargetBlock().getCreator()));
	player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Block Notifier: ", TextColors.BLUE, TextStyles.RESET, event.getTargetBlock().getNotifier()));
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:17,代码来源:EAInfo.java


示例5: onInteractEntity

import org.spongepowered.api.event.filter.IsCancelled; //导入依赖的package包/类
@Listener(order=Order.FIRST)
@IsCancelled(Tristate.UNDEFINED)
public void onInteractEntity(InteractEntityEvent.Primary event) {
	Optional<Player> optPlayer = event.getCause().get(NamedCause.SOURCE, Player.class);
	if (!optPlayer.isPresent()) return;
	
	Player player = optPlayer.get();
	if (!this.players.contains(player.getUniqueId())) return;
	
	event.setCancelled(true);
	
	player.sendMessage(Text.of(TextColors.GRAY, TextStyles.BOLD, "============================================"));
	player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Entity Type: ", TextColors.BLUE, TextStyles.RESET, event.getTargetEntity().getType().getId()));
	player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Entity Owner: ", TextColors.BLUE, TextStyles.RESET, event.getTargetEntity().getCreator()));
	player.sendMessage(Text.of(TextColors.DARK_GREEN, TextStyles.BOLD, "Entity Notifier: ", TextColors.BLUE, TextStyles.RESET, event.getTargetEntity().getNotifier()));
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:17,代码来源:EAInfo.java


示例6: onMoveEntityEventTeleport

import org.spongepowered.api.event.filter.IsCancelled; //导入依赖的package包/类
@Listener
@IsCancelled(Tristate.FALSE)
public void onMoveEntityEventTeleport(MoveEntityEvent.Teleport event, @Root Player player) {
    if (event.getFromTransform().getExtent().equals(event.getToTransform().getExtent())) {
        return;
    }

    World world = event.getToTransform().getExtent();
    Vector3d rotation = null;
    for (SpawnEntity spawnEntity : SpawnCache.instance.get()) {
        if (spawnEntity.getWorld().getIdentifier().equals(world.getUniqueId().toString())) {
            rotation = spawnEntity.getRotation();
        }
    }

    if (rotation != null) {
        Transform<World> to = new Transform<>(world.getSpawnLocation());
        event.setToTransform(to.setRotation(rotation));
    }
}
 
开发者ID:mmonkey,项目名称:Destinations,代码行数:21,代码来源:PlayerListeners.java


示例7: onPlayerTeleportPreEvent

import org.spongepowered.api.event.filter.IsCancelled; //导入依赖的package包/类
@Listener(order = Order.LATE)
@IsCancelled(Tristate.FALSE)
@Include(PlayerTeleportEvent.Pre.class)
public void onPlayerTeleportPreEvent(PlayerTeleportEvent event) {
    Player player = event.getTargetEntity();
    PlayerEntity playerEntity = PlayerCache.instance.get(player);

    for (BackEntity backEntity : playerEntity.getBacks()) {
        if (backEntity.getLocation().getWorld().getIdentifier().equals(event.getLocation().getExtent().getUniqueId().toString())) {
            playerEntity.getBacks().remove(backEntity);
        }
    }

    playerEntity.getBacks().add(new BackEntity(new LocationEntity(event.getLocation(), event.getRotation())));
    playerEntity = PlayerRepository.instance.save(playerEntity);
    PlayerCache.instance.set(player, playerEntity);
}
 
开发者ID:mmonkey,项目名称:Destinations,代码行数:18,代码来源:TeleportListeners.java


示例8: onPlayerTeleportEvent

import org.spongepowered.api.event.filter.IsCancelled; //导入依赖的package包/类
@Listener(order = Order.LATE)
@IsCancelled(Tristate.FALSE)
@Exclude(PlayerTeleportEvent.Pre.class)
public void onPlayerTeleportEvent(PlayerTeleportEvent event) {
    Optional<SleepingData> optional = event.getTargetEntity().get(SleepingData.class);
    if (optional.isPresent() && optional.get().asImmutable().sleeping().get()) {
        event.getTargetEntity().sendMessage(MessagesUtil.get(event.getTargetEntity(), "teleport.sleep"));
        return;
    }

    if (event.getRotation() == null) {
        event.getTargetEntity().setLocationSafely(event.getLocation());
    } else {
        event.getTargetEntity().setLocationAndRotationSafely(event.getLocation(), event.getRotation());
    }
}
 
开发者ID:mmonkey,项目名称:Destinations,代码行数:17,代码来源:TeleportListeners.java


示例9: onIncomingMessage

import org.spongepowered.api.event.filter.IsCancelled; //导入依赖的package包/类
@Listener(order = Order.PRE, beforeModifications = true)
@IsCancelled(Tristate.UNDEFINED)
public void onIncomingMessage(MessageChannelEvent.Chat event, @Root Player player) {
    if (getView(player).handleIncoming(event.getRawMessage())) {
        // No plugins should interpret this as chat
        event.setCancelled(true);
        event.setChannel(MessageChannel.TO_NONE);
    }
}
 
开发者ID:simon816,项目名称:ChatUI,代码行数:10,代码来源:ChatUILib.java


示例10: onClientAuth

import org.spongepowered.api.event.filter.IsCancelled; //导入依赖的package包/类
@Listener(order = Order.EARLY)
@IsCancelled(Tristate.UNDEFINED)
public void onClientAuth(ClientConnectionEvent.Auth e) {
    /* Called when the player first attempts a connection with the server.
       Listening on AFTER_PRE priority to allow plugins to modify username / UUID data here. (auth plugins) */

    final GameProfile p = e.getProfile();
    final String username = p.getName().orElseThrow(() -> new RuntimeException("No username present for user " + p.getUniqueId()));

    if (this.plugin.getConfiguration().get(ConfigKeys.DEBUG_LOGINS)) {
        this.plugin.getLog().info("Processing auth event for " + p.getUniqueId() + " - " + p.getName());
    }

    this.plugin.getUniqueConnections().add(p.getUniqueId());

    /* Actually process the login for the connection.
       We do this here to delay the login until the data is ready.
       If the login gets cancelled later on, then this will be cleaned up.

       This includes:
       - loading uuid data
       - loading permissions
       - creating a user instance in the UserManager for this connection.
       - setting up cached data. */
    try {
        User user = loadUser(p.getUniqueId(), username);
        this.plugin.getEventFactory().handleUserLoginProcess(p.getUniqueId(), username, user);
    } catch (Exception ex) {
        this.plugin.getLog().severe("Exception occured whilst loading data for " + p.getUniqueId() + " - " + p.getName());
        ex.printStackTrace();

        this.deniedAsyncLogin.add(p.getUniqueId());

        e.setCancelled(true);
        e.setMessageCancelled(false);
        //noinspection deprecation
        e.setMessage(TextSerializers.LEGACY_FORMATTING_CODE.deserialize(Message.LOADING_ERROR.asString(this.plugin.getLocaleManager())));
    }
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:40,代码来源:SpongeConnectionListener.java


示例11: onClientLoginMonitor

import org.spongepowered.api.event.filter.IsCancelled; //导入依赖的package包/类
@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);
        }
    }
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:16,代码来源:SpongeConnectionListener.java


示例12: onClientConnectionEventLogin

import org.spongepowered.api.event.filter.IsCancelled; //导入依赖的package包/类
@Listener
@IsCancelled(Tristate.FALSE)
public void onClientConnectionEventLogin(ClientConnectionEvent.Login event) {
    Optional<Player> optionalPlayer = event.getTargetUser().getPlayer();
    if (optionalPlayer.isPresent()) {
        Player player = optionalPlayer.get();
        PlayerEntity playerEntity = PlayerCache.instance.get(player);
        if (!playerEntity.getName().equals(player.getName())) {
            playerEntity.setName(player.getName());
            playerEntity = PlayerRepository.instance.save(playerEntity);
            PlayerCache.instance.set(player, playerEntity);
        }
    }
}
 
开发者ID:mmonkey,项目名称:Destinations,代码行数:15,代码来源:PlayerListeners.java


示例13: onSleepingEvent

import org.spongepowered.api.event.filter.IsCancelled; //导入依赖的package包/类
@Listener
@IsCancelled(Tristate.FALSE)
public void onSleepingEvent(SleepingEvent.Pre event) {
    if (!(event.getTargetEntity() instanceof Player)) {
        return;
    }

    Player player = (Player) event.getTargetEntity();
    PlayerEntity playerEntity = PlayerCache.instance.get(player);
    BlockSnapshot blockSnapshot = event.getBed();
    Optional<Location<World>> optional = blockSnapshot.getLocation();
    if (!optional.isPresent()) {
        return;
    }

    Location<World> location = optional.get();
    for (BedEntity bed : playerEntity.getBeds()) {
        if (bed.getLocation().getWorld().getIdentifier().equals(player.getWorld().getUniqueId().toString())) {
            Location<World> bedLocation = bed.getLocation().getLocation();
            if (location.getBlockPosition().equals(bedLocation.getBlockPosition())) {
                bed.setLastUse(new Timestamp(new Date().getTime()));
                playerEntity = PlayerRepository.instance.save(playerEntity);
                PlayerCache.instance.set(player, playerEntity);
                return;
            }
        }
    }

    playerEntity.getBeds().add(new BedEntity(new LocationEntity(location)));
    playerEntity = PlayerRepository.instance.save(playerEntity);
    PlayerCache.instance.set(player, playerEntity);
}
 
开发者ID:mmonkey,项目名称:Destinations,代码行数:33,代码来源:PlayerListeners.java


示例14: onCriticalStrike

import org.spongepowered.api.event.filter.IsCancelled; //导入依赖的package包/类
@Listener(order = Order.LATE)
@IsCancelled(Tristate.UNDEFINED)
public void onCriticalStrike(CriticalStrikeEvent event) {
	if (event.isCancelled()) {
		if (event.getSource().hasEffect(ResoluteTechniqueEffect.name)) {
			event.setCancelled(false);
		}
	}
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:10,代码来源:SkillListener.java


示例15: onDodge

import org.spongepowered.api.event.filter.IsCancelled; //导入依赖的package包/类
@Listener(order = Order.LATE)
@IsCancelled(Tristate.UNDEFINED)
public void onDodge(DamageDodgedEvent event) {
	if (event.isCancelled()) {
		if (event.getSource().hasEffect(ResoluteTechniqueEffect.name)) {
			event.setCancelled(false);
		}
	}
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:10,代码来源:SkillListener.java


示例16: onManaDrain

import org.spongepowered.api.event.filter.IsCancelled; //导入依赖的package包/类
@Listener(order = Order.LAST)
@IsCancelled(Tristate.FALSE)
public void onManaDrain(ManaDrainEvent mde) {
	IReservable mana = mde.getTarget().getMana();
	double k = mana.getValue() - mde.getAmountDrained() <= 0 ? 0 : mana.getValue() - mde.getAmountDrained();
	mana.setValue(k);
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:8,代码来源:SkillListener.java


示例17: onBlockPlace

import org.spongepowered.api.event.filter.IsCancelled; //导入依赖的package包/类
@Listener(order = Order.POST)
@IsCancelled(value = Tristate.TRUE)
public void onBlockPlace(ChangeBlockEvent.Place event, @Root Player player) {
  final Location<World> playerLoc = player.getLocation();

  for (Transaction<BlockSnapshot> transaction : event.getTransactions()) {
    Optional<Location<World>> optLoc = transaction.getOriginal().getLocation();
    if (!optLoc.isPresent()) {
      continue;
    }

    Location<World> blockLoc = optLoc.get();

    final int blockY = blockLoc.getBlockY();

    if (Math.abs(player.getVelocity().getY()) > UPWARDS_VELOCITY && playerLoc.getY() > blockY) {
      Task.builder().execute(() -> {
        Vector3d position = player.getLocation().getPosition();
        if (position.getY() >= (blockY + LEAP_DISTANCE)) {

          if (playerLoc.getPosition().distanceSquared(blockLoc.getPosition()) > Math.pow(RADIUS, 2)) {
            return;
          }

          player.sendMessage(Text.of(TextColors.RED, "Hack jumping detected."));
          player.setLocation(playerLoc.setPosition(new Vector3d(position.getX(), blockY, position.getZ())));
        }
      }).delayTicks(4).submit(SkreePlugin.inst());
    }
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:32,代码来源:AntiJumpListener.java


示例18: onMemberJoin

import org.spongepowered.api.event.filter.IsCancelled; //导入依赖的package包/类
@IsCancelled(Tristate.FALSE)
@Listener(order = Order.POST)
public void onMemberJoin(ClanMemberJoinEvent event) {
    updateClanTagCache();
}
 
开发者ID:iLefty,项目名称:mcClans,代码行数:6,代码来源:ClansImpl.java


示例19: onMemberLeave

import org.spongepowered.api.event.filter.IsCancelled; //导入依赖的package包/类
@IsCancelled(Tristate.FALSE)
@Listener(order = Order.POST)
public void onMemberLeave(ClanMemberLeaveEvent event) {
    updateClanTagCache();
}
 
开发者ID:iLefty,项目名称:mcClans,代码行数:6,代码来源:ClansImpl.java


示例20: getDelegate

import org.spongepowered.api.event.filter.IsCancelled; //导入依赖的package包/类
public FilterDelegate getDelegate(Annotation anno) {
    if (this == CANCELLATION) {
        return new CancellationEventFilterDelegate(((IsCancelled) anno).value());
    }
    throw new UnsupportedOperationException();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:7,代码来源:FilterGenerator.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OneSignal类代码示例发布时间:2022-05-22
下一篇:
Java QQToken类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap