本文整理汇总了Java中org.spongepowered.api.event.filter.IsCancelled类的典型用法代码示例。如果您正苦于以下问题:Java IsCancelled类的具体用法?Java IsCancelled怎么用?Java IsCancelled使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IsCancelled类属于org.spongepowered.api.event.filter包,在下文中一共展示了IsCancelled类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
}
示例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())));
}
}
示例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()));
});
}
示例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()));
}
示例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()));
}
示例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));
}
}
示例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);
}
示例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());
}
}
示例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);
}
}
示例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())));
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
示例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);
}
}
}
示例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);
}
}
}