Search in sources :

Example 1 with CauseStack

use of org.lanternpowered.server.event.CauseStack in project LanternServer by LanternPowered.

the class LanternCommandManager method process.

@Override
public CommandResult process(CommandSource source, String commandLine) {
    checkNotNull(source, "source");
    final String[] argSplit = commandLine.split(" ", 2);
    final CauseStack causeStack = CauseStack.currentOrEmpty();
    try (CauseStack.Frame frame = causeStack.pushCauseFrame()) {
        frame.pushCause(source);
        final SendCommandEvent event = SpongeEventFactory.createSendCommandEvent(frame.getCurrentCause(), argSplit.length > 1 ? argSplit[1] : "", argSplit[0], CommandResult.empty());
        Sponge.getGame().getEventManager().post(event);
        if (event.isCancelled()) {
            return event.getResult();
        }
        // Only the first part of argSplit is used at the moment, do the other in the future if needed.
        argSplit[0] = event.getCommand();
        commandLine = event.getCommand();
        if (!event.getArguments().isEmpty()) {
            commandLine = commandLine + ' ' + event.getArguments();
        }
        try {
            return this.dispatcher.process(source, commandLine);
        } catch (InvocationCommandException ex) {
            if (ex.getCause() != null) {
                throw ex.getCause();
            }
        } catch (CommandPermissionException ex) {
            Text text = ex.getText();
            if (text != null) {
                source.sendMessage(error(text));
            }
        } catch (CommandException ex) {
            Text text = ex.getText();
            if (text != null) {
                source.sendMessage(error(text));
            }
            if (ex.shouldIncludeUsage()) {
                final Optional<CommandMapping> mapping = this.dispatcher.get(argSplit[0], source);
                mapping.ifPresent(commandMapping -> source.sendMessage(error(t("commands.generic.usage", t("/%s %s", argSplit[0], commandMapping.getCallable().getUsage(source))))));
            }
        }
    } catch (Throwable thr) {
        final Text.Builder excBuilder;
        if (thr instanceof TextMessageException) {
            final Text text = ((TextMessageException) thr).getText();
            excBuilder = text == null ? Text.builder("null") : Text.builder().append(text);
        } else {
            excBuilder = Text.builder(String.valueOf(thr.getMessage()));
        }
        if (source.hasPermission("sponge.debug.hover-stacktrace")) {
            final StringWriter writer = new StringWriter();
            thr.printStackTrace(new PrintWriter(writer));
            excBuilder.onHover(TextActions.showText(Text.of(writer.toString().replace("\t", "    ").replace("\r\n", "\n").replace("\r", // I mean I guess somebody could be running this on like OS 9?
            "\n"))));
        }
        source.sendMessage(error(t("Error occurred while executing command: %s", excBuilder.build())));
        this.logger.error(LanternTexts.toLegacy(t("Error occurred while executing command '%s' for source %s: %s", commandLine, source.toString(), String.valueOf(thr.getMessage()))), thr);
    }
    return CommandResult.empty();
}
Also used : Arrays(java.util.Arrays) Inject(com.google.inject.Inject) CommandCallable(org.spongepowered.api.command.CommandCallable) CommandMapping(org.spongepowered.api.command.CommandMapping) Multimap(com.google.common.collect.Multimap) LanternTexts(org.lanternpowered.server.text.LanternTexts) Function(java.util.function.Function) InvocationCommandException(org.spongepowered.api.command.InvocationCommandException) ArrayList(java.util.ArrayList) SpongeApiTranslationHelper.t(org.spongepowered.api.util.SpongeApiTranslationHelper.t) HashMultimap(com.google.common.collect.HashMultimap) CauseStack(org.lanternpowered.server.event.CauseStack) CommandPermissionException(org.spongepowered.api.command.CommandPermissionException) ImmutableList(com.google.common.collect.ImmutableList) Text(org.spongepowered.api.text.Text) Map(java.util.Map) TabCompleteEvent(org.spongepowered.api.event.command.TabCompleteEvent) PluginContainer(org.spongepowered.api.plugin.PluginContainer) Nullable(javax.annotation.Nullable) PrintWriter(java.io.PrintWriter) CommandResult(org.spongepowered.api.command.CommandResult) TextActions(org.spongepowered.api.text.action.TextActions) Location(org.spongepowered.api.world.Location) ImmutableSet(com.google.common.collect.ImmutableSet) Logger(org.slf4j.Logger) SimpleDispatcher(org.spongepowered.api.command.dispatcher.SimpleDispatcher) Iterator(java.util.Iterator) CommandSource(org.spongepowered.api.command.CommandSource) TextMessageException(org.spongepowered.api.util.TextMessageException) SpongeEventFactory(org.spongepowered.api.event.SpongeEventFactory) StringWriter(java.io.StringWriter) Collection(java.util.Collection) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Sponge(org.spongepowered.api.Sponge) Set(java.util.Set) CommandException(org.spongepowered.api.command.CommandException) List(java.util.List) World(org.spongepowered.api.world.World) CommandManager(org.spongepowered.api.command.CommandManager) Optional(java.util.Optional) SendCommandEvent(org.spongepowered.api.event.command.SendCommandEvent) CommandMessageFormatting.error(org.spongepowered.api.command.CommandMessageFormatting.error) Singleton(com.google.inject.Singleton) Disambiguator(org.spongepowered.api.command.dispatcher.Disambiguator) CauseStack(org.lanternpowered.server.event.CauseStack) CommandPermissionException(org.spongepowered.api.command.CommandPermissionException) Optional(java.util.Optional) Text(org.spongepowered.api.text.Text) InvocationCommandException(org.spongepowered.api.command.InvocationCommandException) CommandException(org.spongepowered.api.command.CommandException) InvocationCommandException(org.spongepowered.api.command.InvocationCommandException) StringWriter(java.io.StringWriter) SendCommandEvent(org.spongepowered.api.event.command.SendCommandEvent) TextMessageException(org.spongepowered.api.util.TextMessageException) PrintWriter(java.io.PrintWriter)

Example 2 with CauseStack

use of org.lanternpowered.server.event.CauseStack in project LanternServer by LanternPowered.

the class BanConfig method removeBan.

@Override
public boolean removeBan(Ban ban) {
    checkNotNull(ban, "ban");
    if (this.entries0.remove(ban)) {
        final CauseStack causeStack = CauseStack.currentOrEmpty();
        // Post the pardon events
        final Event event;
        final Cause cause = causeStack.getCurrentCause();
        if (ban instanceof Ban.Ip) {
            event = SpongeEventFactory.createPardonIpEvent(cause, (Ban.Ip) ban);
        } else {
            final Ban.Profile profileBan = (Ban.Profile) ban;
            // Check if the pardoned player is online (not yet been kicked)
            final Optional<Player> optTarget = Sponge.getServer().getPlayer(profileBan.getProfile().getUniqueId());
            if (optTarget.isPresent()) {
                event = SpongeEventFactory.createPardonUserEventTargetPlayer(cause, profileBan, optTarget.get(), optTarget.get());
            } else {
                event = SpongeEventFactory.createPardonUserEvent(cause, profileBan, Lantern.getGame().getServiceManager().provideUnchecked(UserStorageService.class).getOrCreate(profileBan.getProfile()));
            }
        }
        // Just ignore for now the fact that they may be cancellable,
        // only the PardonIpEvent seems to be cancellable
        // TODO: Should they all be cancellable or none of them?
        Sponge.getEventManager().post(event);
        return true;
    }
    return false;
}
Also used : UserStorageService(org.spongepowered.api.service.user.UserStorageService) CauseStack(org.lanternpowered.server.event.CauseStack) Player(org.spongepowered.api.entity.living.player.Player) Cause(org.spongepowered.api.event.cause.Cause) Ip(org.spongepowered.api.util.ban.Ban.Ip) Event(org.spongepowered.api.event.Event) Ban(org.spongepowered.api.util.ban.Ban) GameProfile(org.spongepowered.api.profile.GameProfile)

Example 3 with CauseStack

use of org.lanternpowered.server.event.CauseStack in project LanternServer by LanternPowered.

the class HandlerPlayInChatMessage method handle.

@Override
public void handle(NetworkContext context, MessagePlayInChatMessage message) {
    final NetworkSession session = context.getSession();
    final LanternPlayer player = session.getPlayer();
    player.resetIdleTimeoutCounter();
    final String message0 = message.getMessage();
    // Check for a valid click action callback
    final Matcher matcher = LanternClickActionCallbacks.COMMAND_PATTERN.matcher(message0);
    if (matcher.matches()) {
        final UUID uniqueId = UUID.fromString(matcher.group(1));
        final Optional<Consumer<CommandSource>> callback = LanternClickActionCallbacks.get().getCallbackForUUID(uniqueId);
        if (callback.isPresent()) {
            callback.get().accept(player);
        } else {
            player.sendMessage(error(t("The callback you provided was not valid. Keep in mind that callbacks will expire " + "after 10 minutes, so you might want to consider clicking faster next time!")));
        }
        return;
    }
    String message1 = StringUtils.normalizeSpace(message0);
    if (!isAllowedString(message0)) {
        session.disconnect(t("multiplayer.disconnect.illegal_characters"));
        return;
    }
    if (message1.startsWith("/")) {
        Lantern.getSyncExecutorService().submit(() -> Sponge.getCommandManager().process(player, message1.substring(1)));
    } else {
        final Text nameText = player.get(Keys.DISPLAY_NAME).get();
        final Text rawMessageText = Text.of(message0);
        final GlobalConfig.Chat.Urls urls = Lantern.getGame().getGlobalConfig().getChat().getUrls();
        final Text messageText;
        if (urls.isEnabled() && player.hasPermission(Permissions.Chat.FORMAT_URLS)) {
            messageText = newTextWithLinks(message0, urls.getTemplate(), false);
        } else {
            messageText = rawMessageText;
        }
        final MessageChannel channel = player.getMessageChannel();
        final CauseStack causeStack = CauseStack.current();
        try (CauseStack.Frame frame = causeStack.pushCauseFrame()) {
            frame.addContext(EventContextKeys.PLAYER, player);
            final MessageChannelEvent.Chat event = SpongeEventFactory.createMessageChannelEventChat(causeStack.getCurrentCause(), channel, Optional.of(channel), new MessageEvent.MessageFormatter(nameText, messageText), rawMessageText, false);
            if (!Sponge.getEventManager().post(event) && !event.isMessageCancelled()) {
                event.getChannel().ifPresent(c -> c.send(player, event.getMessage(), ChatTypes.CHAT));
            }
        }
    }
    final Attribute<ChatData> attr = context.getChannel().attr(CHAT_DATA);
    ChatData chatData = attr.get();
    if (chatData == null) {
        chatData = new ChatData();
        final ChatData chatData1 = attr.setIfAbsent(chatData);
        if (chatData1 != null) {
            chatData = chatData1;
        }
    }
    // noinspection SynchronizationOnLocalVariableOrMethodParameter
    synchronized (chatData) {
        final long currentTime = LanternGame.currentTimeTicks();
        if (chatData.lastChatTime != -1L) {
            chatData.chatThrottle = (int) Math.max(0, chatData.chatThrottle - (currentTime - chatData.lastChatTime));
        }
        chatData.lastChatTime = currentTime;
        chatData.chatThrottle += 20;
        if (chatData.chatThrottle > Lantern.getGame().getGlobalConfig().getChatSpamThreshold()) {
            session.disconnect(t("disconnect.spam"));
        }
    }
}
Also used : CauseStack(org.lanternpowered.server.event.CauseStack) NetworkSession(org.lanternpowered.server.network.NetworkSession) Matcher(java.util.regex.Matcher) MessageChannelEvent(org.spongepowered.api.event.message.MessageChannelEvent) MessageEvent(org.spongepowered.api.event.message.MessageEvent) Text(org.spongepowered.api.text.Text) Consumer(java.util.function.Consumer) MessageChannel(org.spongepowered.api.text.channel.MessageChannel) UUID(java.util.UUID) LanternPlayer(org.lanternpowered.server.entity.living.player.LanternPlayer)

Example 4 with CauseStack

use of org.lanternpowered.server.event.CauseStack in project LanternServer by LanternPowered.

the class KeyRegistryModule method registerDefaults.

@Override
public void registerDefaults() {
    final CauseStack causeStack = CauseStack.current();
    causeStack.pushCause(Lantern.getSpongePlugin());
    register(makeMutableBoundedValueKey(Double.class, DataQuery.of("Absorption"), "absorption"));
    register(makeValueKey(Boolean.class, of("AffectsSpawning"), "affects_spawning"));
    register(makeMutableBoundedValueKey(Integer.class, of("Age"), "age"));
    register(makeValueKey(Boolean.class, of("AIEnabled"), "ai_enabled"));
    register(makeMutableBoundedValueKey(Integer.class, of("Anger"), "anger"));
    register(makeMutableBoundedValueKey(Integer.class, DataQuery.of("AreaEffectCloudAge"), "area_effect_cloud_age"));
    register(makeValueKey(Color.class, DataQuery.of("AreaEffectCloudColor"), "area_effect_cloud_color"));
    register(makeMutableBoundedValueKey(Integer.class, DataQuery.of("AreaEffectCloudDuration"), "area_effect_cloud_duration"));
    register(makeMutableBoundedValueKey(Integer.class, DataQuery.of("AreaEffectCloudDurationOnUse"), "area_effect_cloud_duration_on_use"));
    register(makeValueKey(Color.class, DataQuery.of("AreaEffectCloudParticleType"), "area_effect_cloud_particle_type"));
    register(makeMutableBoundedValueKey(Double.class, DataQuery.of("AreaEffectCloudRadius"), "area_effect_cloud_radius"));
    register(makeMutableBoundedValueKey(Double.class, DataQuery.of("AreaEffectCloudRadiusOnUse"), "area_effect_cloud_radius_on_use"));
    register(makeMutableBoundedValueKey(Double.class, DataQuery.of("AreaEffectCloudRadiusPerTick"), "area_effect_cloud_radius_per_tick"));
    register(makeMutableBoundedValueKey(Integer.class, DataQuery.of("AreaEffectCloudRadiusReapplicationDelay"), "area_effect_cloud_reapplication_delay"));
    register(makeMutableBoundedValueKey(Integer.class, DataQuery.of("AreaEffectCloudWaitTime"), "area_effect_cloud_wait_time"));
    register(makeValueKey(Boolean.class, of("ArmorStandHasArms"), "armor_stand_has_arms"));
    register(makeValueKey(Boolean.class, of("ArmorStandHasBasePlate"), "armor_stand_has_base_plate"));
    register(makeValueKey(Boolean.class, of("ArmorStandIsSmall"), "armor_stand_is_small"));
    register(makeValueKey(Boolean.class, of("ArmorStandMarker"), "armor_stand_marker"));
    register(makeValueKey(Boolean.class, of("Angry"), "angry"));
    register(makeValueKey(Art.class, of("Art"), "art"));
    register(makeValueKey(Boolean.class, of("Attached"), "attached"));
    register(makeMutableBoundedValueKey(Double.class, of("AttackDamage"), "attack_damage"));
    register(makeValueKey(Axis.class, of("Axis"), "axis"));
    register(makeValueKey(DyeColor.class, of("BannerBaseColor"), "banner_base_color"));
    register(makePatternListKey(of("BannerPatterns"), "banner_patterns"));
    register(makeMutableBoundedValueKey(Float.class, of("BaseSize"), "base_size"));
    register(makeValueKey(EntitySnapshot.class, of("BaseVehicle"), "base_vehicle"));
    register(makeOptionalKey(PotionEffectType.class, of("BeaconPrimaryEffect"), "beacon_primary_effect"));
    register(makeOptionalKey(PotionEffectType.class, of("BeaconSecondaryEffect"), "beacon_secondary_effect"));
    register(makeValueKey(BigMushroomType.class, of("BigMushroomType"), "big_mushroom_type"));
    register(makeMapKeyWithKeyAndValue(BodyPart.class, Vector3d.class, of("BodyRotations"), "body_rotations"));
    register(makeValueKey(Text.class, of("BookAuthor"), "book_author"));
    register(makeListKey(Text.class, of("BookPages"), "book_pages"));
    register(makeSetKey(BlockType.class, of("BreakableBlockTypes"), "breakable_block_types"));
    register(makeValueKey(BrickType.class, of("BrickType"), "brick_type"));
    register(makeValueKey(Boolean.class, of("CanBreed"), "can_breed"));
    register(makeValueKey(Boolean.class, of("CanDropAsItem"), "can_drop_as_item"));
    register(makeValueKey(Boolean.class, of("CanFly"), "can_fly"));
    register(makeValueKey(Boolean.class, of("CanGrief"), "can_grief"));
    register(makeValueKey(Boolean.class, of("CanPlaceAsBlock"), "can_place_as_block"));
    register(makeValueKey(Career.class, of("Career"), "career"));
    register(makeValueKey(Vector3d.class, of("ChestRotation"), "chest_rotation"));
    register(makeValueKey(CoalType.class, of("CoalType"), "coal_type"));
    register(makeValueKey(Color.class, of("Color"), "color"));
    register(makeValueKey(String.class, of("Command"), "command"));
    register(makeValueKey(ComparatorType.class, of("ComparatorType"), "comparator_type"));
    register(makeSetKey(Direction.class, of("ConnectedDirections"), "connected_directions"));
    register(makeValueKey(Boolean.class, of("ConnectedEast"), "connected_east"));
    register(makeValueKey(Boolean.class, of("ConnectedNorth"), "connected_north"));
    register(makeValueKey(Boolean.class, of("ConnectedSouth"), "connected_south"));
    register(makeValueKey(Boolean.class, of("ConnectedWest"), "connected_west"));
    register(makeMutableBoundedValueKey(Integer.class, of("ContainedExperience"), "contained_experience"));
    register(makeValueKey(CookedFish.class, of("CookedFish"), "cooked_fish"));
    register(makeMutableBoundedValueKey(Integer.class, of("Cooldown"), "cooldown"));
    register(makeValueKey(Boolean.class, of("CreeperCharged"), "creeper_charged"));
    register(makeValueKey(Boolean.class, of("CriticalHit"), "critical_hit"));
    register(makeValueKey(Boolean.class, of("CustomNameVisible"), "custom_name_visible"));
    register(makeMapKeyWithKeyAndValue(EntityType.class, Double.class, of("EntityDamageMap"), "damage_entity_map"));
    register(makeValueKey(Boolean.class, of("Decayable"), "decayable"));
    register(makeMutableBoundedValueKey(Integer.class, of("Delay"), "delay"));
    register(makeMutableBoundedValueKey(Integer.class, of("DespawnDelay"), "despawn_delay"));
    register(makeValueKey(Direction.class, of("Direction"), "direction"));
    register(makeValueKey(DirtType.class, of("DirtType"), "dirt_type"));
    register(makeValueKey(Boolean.class, of("Disarmed"), "disarmed"));
    register(makeValueKey(DisguisedBlockType.class, of("DisguisedBlockType"), "disguised_block_type"));
    register(makeValueKey(Text.class, of("DisplayName"), "display_name"));
    register(makeValueKey(HandPreference.class, of("DominantHand"), "dominant_hand"));
    register(makeValueKey(DoublePlantType.class, of("DoublePlantType"), "double_plant_type"));
    register(makeValueKey(DyeColor.class, of("DyeColor"), "dye_color"));
    register(makeValueKey(Boolean.class, of("ElderGuardian"), "elder_guardian"));
    register(makeValueKey(Boolean.class, of("EndGatewayAge"), "end_gateway_age"));
    register(makeValueKey(Boolean.class, of("EndGatewayTeleportCooldown"), "end_gateway_teleport_cooldown"));
    register(makeMutableBoundedValueKey(Double.class, of("Exhaustion"), "exhaustion"));
    register(makeValueKey(Boolean.class, of("ExactTeleport"), "exact_teleport"));
    register(makeValueKey(Vector3i.class, of("ExitPosition"), "exit_position"));
    register(makeImmutableBoundedValueKey(Integer.class, of("ExperienceFromStartOfLevel"), "experience_from_start_of_level"));
    register(makeMutableBoundedValueKey(Integer.class, of("ExperienceLevel"), "experience_level"));
    register(makeMutableBoundedValueKey(Integer.class, of("ExperienceSinceLevel"), "experience_since_level"));
    register(makeMutableBoundedValueKey(Integer.class, of("ExpirationTicks"), "expiration_ticks"));
    register(makeOptionalKey(Integer.class, of("ExplosionRadius"), "explosion_radius"));
    register(makeValueKey(Boolean.class, of("Extended"), "extended"));
    register(makeValueKey(Boolean.class, of("FallingBlockCanHurtEntities"), "falling_block_can_hurt_entities"));
    register(makeValueKey(BlockState.class, of("FallingBlockState"), "falling_block_state"));
    register(makeMutableBoundedValueKey(Double.class, of("FallDamagePerBlock"), "fall_damage_per_block"));
    register(makeMutableBoundedValueKey(Float.class, of("FallDistance"), "fall_distance"));
    register(makeValueKey(Integer.class, of("FallTime"), "fall_time"));
    register(makeValueKey(Boolean.class, of("Filled"), "filled"));
    register(makeListKey(FireworkEffect.class, of("FireworkEffects"), "firework_effects"));
    register(makeMutableBoundedValueKey(Integer.class, of("FireworkFlightModifier"), "firework_flight_modifier"));
    register(makeMutableBoundedValueKey(Integer.class, of("FireDamageDelay"), "fire_damage_delay"));
    register(makeMutableBoundedValueKey(Integer.class, of("FireTicks"), "fire_ticks"));
    register(makeValueKey(Instant.class, of("FirstDatePlayed"), "first_date_played"));
    register(makeValueKey(Fish.class, of("FishType"), "fish_type"));
    register(makeValueKey(FluidStackSnapshot.class, of("FluidItemStack"), "fluid_item_stack"));
    register(makeMutableBoundedValueKey(Integer.class, of("FluidLevel"), "fluid_level"));
    register(makeMapKeyWithKeyAndValue(Direction.class, List.class, of("FluidTankContents"), "fluid_tank_contents"));
    register(makeValueKey(Double.class, of("FlyingSpeed"), "flying_speed"));
    register(makeMutableBoundedValueKey(Integer.class, of("FoodLevel"), "food_level"));
    register(makeValueKey(Integer.class, of("FuseDuration"), "fuse_duration"));
    register(makeValueKey(GameMode.class, of("GameMode"), "game_mode"));
    register(makeMutableBoundedValueKey(Integer.class, of("Generation"), "generation"));
    register(makeValueKey(Boolean.class, of("Glowing"), "glowing"));
    register(makeValueKey(GoldenApple.class, of("GoldenAppleType"), "golden_apple_type"));
    register(makeMutableBoundedValueKey(Integer.class, of("GrowthStage"), "growth_stage"));
    register(makeValueKey(Boolean.class, of("HasGravity"), "has_gravity"));
    register(makeValueKey(Vector3d.class, of("HeadRotation"), "head_rotation"));
    register(makeMutableBoundedValueKey(Double.class, of("Health"), "health"));
    register(makeMutableBoundedValueKey(Double.class, of("HealthScale"), "health_scale"));
    register(makeMutableBoundedValueKey(Float.class, of("Height"), "height"));
    register(makeValueKey(Boolean.class, of("HideAttributes"), "hide_attributes"));
    register(makeValueKey(Boolean.class, of("HideCanDestroy"), "hide_can_destroy"));
    register(makeValueKey(Boolean.class, of("HideCanPlace"), "hide_can_place"));
    register(makeValueKey(Boolean.class, of("HideEnchantments"), "hide_enchantments"));
    register(makeValueKey(Boolean.class, of("HideMiscellaneous"), "hide_miscellaneous"));
    register(makeValueKey(Boolean.class, of("HideUnbreakable"), "hide_unbreakable"));
    register(makeValueKey(Hinge.class, of("HingePosition"), "hinge_position"));
    register(makeValueKey(HorseColor.class, of("HorseColor"), "horse_color"));
    register(makeValueKey(HorseStyle.class, of("HorseStyle"), "horse_style"));
    register(makeValueKey(Boolean.class, of("InfiniteDespawnDelay"), "infinite_despawn_delay"));
    register(makeValueKey(Boolean.class, of("InfinitePickupDelay"), "infinite_pickup_delay"));
    register(makeValueKey(Boolean.class, of("InvisibilityIgnoresCollision"), "invisibility_ignores_collision"));
    register(makeValueKey(Boolean.class, of("InvisibilityPreventsTargeting"), "invisibility_prevents_targeting"));
    register(makeValueKey(Boolean.class, of("Invisible"), "invisible"));
    register(makeMutableBoundedValueKey(Integer.class, of("InvulnerabilityTicks"), "invulnerability_ticks"));
    register(makeValueKey(Boolean.class, of("Invulnerable"), "invulnerable"));
    register(makeValueKey(Boolean.class, of("InWall"), "in_wall"));
    register(makeValueKey(Boolean.class, of("IsAdult"), "is_adult"));
    register(makeValueKey(Boolean.class, of("IsAflame"), "is_aflame"));
    register(makeValueKey(Boolean.class, of("IsFlying"), "is_flying"));
    register(makeValueKey(Boolean.class, of("IsJohnny"), "is_johnny"));
    register(makeValueKey(Boolean.class, of("IsPlaying"), "is_playing"));
    register(makeValueKey(Boolean.class, of("IsScreaming"), "is_screaming"));
    register(makeValueKey(Boolean.class, of("IsSheared"), "is_sheared"));
    register(makeValueKey(Boolean.class, of("IsSilent"), "is_silent"));
    register(makeValueKey(Boolean.class, of("IsSitting"), "is_sitting"));
    register(makeValueKey(Boolean.class, of("IsSleeping"), "is_sleeping"));
    register(makeValueKey(Boolean.class, of("IsSneaking"), "is_sneaking"));
    register(makeValueKey(Boolean.class, of("IsSprinting"), "is_sprinting"));
    register(makeValueKey(Boolean.class, of("IsWet"), "is_wet"));
    register(makeValueKey(BlockState.class, of("ItemBlockState"), "item_blockstate"));
    register(makeMutableBoundedValueKey(Integer.class, of("ItemDurability"), "item_durability"));
    register(makeListKey(Enchantment.class, of("ItemEnchantments"), "item_enchantments"));
    register(makeListKey(Text.class, of("ItemLore"), "item_lore"));
    register(makeValueKey(Boolean.class, of("JohnnyVindicator"), "johnny_vindicator"));
    register(makeMutableBoundedValueKey(Integer.class, of("KnockbackStrength"), "knockback_strength"));
    register(makeOptionalKey(EntitySnapshot.class, of("LastAttacker"), "last_attacker"));
    register(makeOptionalKey(Text.class, of("LastCommandOutput"), "last_command_output"));
    register(makeOptionalKey(Double.class, of("LastDamage"), "last_damage"));
    register(makeValueKey(Instant.class, of("LastDatePlayed"), "last_date_played"));
    register(makeValueKey(Integer.class, of("Layer"), "layer"));
    register(makeValueKey(EntitySnapshot.class, of("LeashHolder"), "leash_holder"));
    register(makeValueKey(Vector3d.class, of("LeftArmRotation"), "left_arm_rotation"));
    register(makeValueKey(Vector3d.class, of("LeftLegRotation"), "left_leg_rotation"));
    register(makeMutableBoundedValueKey(Integer.class, of("LlamaStrength"), "llama_strength"));
    register(makeValueKey(LlamaVariant.class, of("LlamaVariant"), "llama_variant"));
    register(makeValueKey(String.class, of("LockToken"), "lock_token"));
    register(makeValueKey(LogAxis.class, of("LogAxis"), "log_axis"));
    register(makeMutableBoundedValueKey(Integer.class, of("MaxAir"), "max_air"));
    register(makeMutableBoundedValueKey(Integer.class, of("MaxBurnTime"), "max_burn_time"));
    register(makeMutableBoundedValueKey(Integer.class, of("MaxCookTime"), "max_cook_time"));
    register(makeMutableBoundedValueKey(Double.class, of("MaxFallDamage"), "max_fall_damage"));
    register(makeMutableBoundedValueKey(Double.class, of("MaxHealth"), "max_health"));
    register(makeMutableBoundedValueKey(Integer.class, of("Moisture"), "moisture"));
    register(makeValueKey(NotePitch.class, of("NotePitch"), "note_pitch"));
    register(makeValueKey(Boolean.class, of("Occupied"), "occupied"));
    register(makeValueKey(OcelotType.class, of("OcelotType"), "ocelot_type"));
    register(makeValueKey(Integer.class, of("Offset"), "offset"));
    register(makeValueKey(Boolean.class, of("Open"), "open"));
    register(makeMutableBoundedValueKey(Integer.class, of("PassedBurnTime"), "passed_burn_time"));
    register(makeMutableBoundedValueKey(Integer.class, of("PassedCookTime"), "passed_cook_time"));
    register(makeListKey(UUID.class, of("Passengers"), "passengers"));
    register(makeValueKey(Boolean.class, of("Persists"), "persists"));
    register(makeMutableBoundedValueKey(Integer.class, of("PickupDelay"), "pickup_delay"));
    register(makeValueKey(PickupRule.class, of("PickupRule"), "pickup_rule"));
    register(makeValueKey(Boolean.class, of("PigSaddle"), "pig_saddle"));
    register(makeValueKey(PistonType.class, of("PistonType"), "piston_type"));
    register(makeSetKey(BlockType.class, of("PlaceableBlocks"), "placeable_blocks"));
    register(makeValueKey(PlantType.class, of("PlantType"), "plant_type"));
    register(makeValueKey(Boolean.class, of("PlayerCreated"), "player_created"));
    register(makeValueKey(PortionType.class, of("PortionType"), "portion_type"));
    register(makeListKey(PotionEffect.class, of("PotionEffects"), "potion_effects"));
    register(makeValueKey(Integer.class, of("Power"), "power"));
    register(makeValueKey(Boolean.class, of("Powered"), "powered"));
    register(makeValueKey(PrismarineType.class, of("PrismarineType"), "prismarine_type"));
    register(makeValueKey(QuartzType.class, of("QuartzType"), "quartz_type"));
    register(makeValueKey(RabbitType.class, of("RabbitType"), "rabbit_type"));
    register(makeValueKey(RailDirection.class, of("RailDirection"), "rail_direction"));
    register(makeMutableBoundedValueKey(Integer.class, of("RemainingAir"), "remaining_air"));
    register(makeMutableBoundedValueKey(Integer.class, of("RemainingBrewTime"), "remaining_brew_time"));
    register(makeValueKey(BlockState.class, of("RepresentedBlock"), "represented_block"));
    register(makeValueKey(ItemStackSnapshot.class, of("RepresentedItem"), "represented_item"));
    register(makeValueKey(GameProfile.class, of("RepresentedPlayer"), "represented_player"));
    register(makeMapKeyWithKeyAndValue(UUID.class, RespawnLocation.class, of("RespawnLocations"), "respawn_locations"));
    register(makeValueKey(Vector3d.class, of("RightArmRotation"), "right_arm_rotation"));
    register(makeValueKey(Vector3d.class, of("RightLegRotation"), "right_leg_rotation"));
    register(makeValueKey(Rotation.class, of("Rotation"), "rotation"));
    register(makeValueKey(SandstoneType.class, of("SandstoneType"), "sandstone_type"));
    register(makeValueKey(SandType.class, of("SandType"), "sand_type"));
    register(makeMutableBoundedValueKey(Double.class, of("Saturation"), "saturation"));
    register(makeMutableBoundedValueKey(Float.class, of("Scale"), "scale"));
    register(makeValueKey(Boolean.class, of("Seamless"), "seamless"));
    register(makeValueKey(Boolean.class, of("ShouldDrop"), "should_drop"));
    register(makeValueKey(ShrubType.class, of("ShrubType"), "shrub_type"));
    register(makeListKey(Text.class, of("SignLines"), "sign_lines"));
    register(makeValueKey(UUID.class, of("SkinUniqueId"), "skin_unique_id"));
    register(makeValueKey(SkullType.class, of("SkullType"), "skull_type"));
    register(makeValueKey(SlabType.class, of("SlabType"), "slab_type"));
    register(makeMutableBoundedValueKey(Integer.class, of("SlimeSize"), "slime_size"));
    register(makeValueKey(Boolean.class, of("Snowed"), "snowed"));
    register(makeValueKey(EntityType.class, of("SpawnableEntityType"), "spawnable_entity_type"));
    register(makeWeightedCollectionKey(EntityArchetype.class, of("SpawnerEntities"), "spawner_entities"));
    register(makeMutableBoundedValueKey(Short.class, of("SpawnerMaximumDelay"), "spawner_maximum_delay"));
    register(makeMutableBoundedValueKey(Short.class, of("SpawnerMaximumNearbyEntities"), "spawner_maximum_nearby_entities"));
    register(makeMutableBoundedValueKey(Short.class, of("SpawnerMinimumDelay"), "spawner_minimum_delay"));
    register(makeValueKey(new TypeToken<WeightedSerializableObject<EntityArchetype>>() {
    }, of("SpawnerNextEntityToSpawn"), "spawner_next_entity_to_spawn"));
    register(makeMutableBoundedValueKey(Short.class, of("SpawnerRemainingDelay"), "spawner_remaining_delay"));
    register(makeMutableBoundedValueKey(Short.class, of("SpawnerRequiredPlayerRange"), "spawner_required_player_range"));
    register(makeMutableBoundedValueKey(Short.class, of("SpawnerSpawnCount"), "spawner_spawn_count"));
    register(makeMutableBoundedValueKey(Short.class, of("SpawnerSpawnRange"), "spawner_spawn_range"));
    register(makeValueKey(StairShape.class, of("StairShape"), "stair_shape"));
    register(makeMapKeyWithKeyAndValue(Statistic.class, Long.class, of("Statistics"), "statistics"));
    register(makeValueKey(StoneType.class, of("StoneType"), "stone_type"));
    register(makeListKey(Enchantment.class, of("StoredEnchantments"), "stored_enchantments"));
    register(makeValueKey(String.class, of("StructureAuthor"), "structure_author"));
    register(makeValueKey(Boolean.class, of("StructureIgnoreEntities"), "structure_ignore_entities"));
    register(makeValueKey(Float.class, of("StructureIntegrity"), "structure_integrity"));
    register(makeValueKey(StructureMode.class, of("StructureMode"), "structure_mode"));
    register(makeValueKey(Vector3i.class, of("StructurePosition"), "structure_position"));
    register(makeValueKey(Boolean.class, of("StructurePowered"), "structure_powered"));
    register(makeValueKey(Long.class, of("StructureSeed"), "structure_seed"));
    register(makeValueKey(Boolean.class, of("StructureShowAir"), "structure_show_air"));
    register(makeValueKey(Boolean.class, of("StructureShowBoundingBox"), "structure_show_bounding_box"));
    register(makeValueKey(Vector3i.class, of("StructureSize"), "structure_size"));
    register(makeMutableBoundedValueKey(Integer.class, of("StuckArrows"), "stuck_arrows"));
    register(makeMutableBoundedValueKey(Integer.class, of("SuccessCount"), "success_count"));
    register(makeValueKey(Boolean.class, of("Suspended"), "suspended"));
    register(makeOptionalKey(UUID.class, of("TamedOwner"), "tamed_owner"));
    register(makeValueKey(Vector3d.class, of("TargetedLocation"), "targeted_location"));
    register(makeValueKey(Integer.class, of("TicksRemaining"), "ticks_remaining"));
    register(makeMutableBoundedValueKey(Integer.class, of("TotalExperience"), "total_experience"));
    register(makeValueKey(Boolean.class, of("TracksOutput"), "tracks_output"));
    register(makeListKey(TradeOffer.class, of("TradeOffers"), "trade_offers"));
    register(makeValueKey(TreeType.class, of("TreeType"), "tree_type"));
    register(makeValueKey(Boolean.class, of("Unbreakable"), "unbreakable"));
    register(makeValueKey(Boolean.class, of("Vanish"), "vanish"));
    register(makeValueKey(Boolean.class, of("VanishIgnoresCollision"), "vanish_ignores_collision"));
    register(makeValueKey(Boolean.class, of("VanishPreventsTargeting"), "vanish_prevents_targeting"));
    register(makeValueKey(EntitySnapshot.class, of("Vehicle"), "vehicle"));
    register(makeValueKey(Vector3d.class, of("Velocity"), "velocity"));
    register(makeOptionalKey(Profession.class, of("VillagerZombieProfession"), "villager_zombie_profession"));
    register(makeValueKey(Double.class, of("WalkingSpeed"), "walking_speed"));
    register(makeValueKey(WallType.class, of("WallType"), "wall_type"));
    register(makeValueKey(Boolean.class, of("WillShatter"), "will_shatter"));
    register(makeMapKeyWithKeyAndValue(Direction.class, WireAttachmentType.class, of("WireAttachments"), "wire_attachments"));
    register(makeValueKey(WireAttachmentType.class, of("WireAttachmentEast"), "wire_attachment_east"));
    register(makeValueKey(WireAttachmentType.class, of("WireAttachmentNorth"), "wire_attachment_north"));
    register(makeValueKey(WireAttachmentType.class, of("WireAttachmentSouth"), "wire_attachment_south"));
    register(makeValueKey(WireAttachmentType.class, of("WireAttachmentWest"), "wire_attachment_west"));
    causeStack.popCause();
    causeStack.pushCause(Lantern.getImplementationPlugin());
    // Register the lantern keys
    for (Field field : LanternKeys.class.getFields()) {
        if (Modifier.isStatic(field.getModifiers())) {
            final Object object;
            try {
                object = field.get(null);
            } catch (IllegalAccessException e) {
                throw new RuntimeException(e);
            }
            if (object instanceof Key) {
                register((Key) object);
            }
        }
    }
    causeStack.popCause();
}
Also used : BodyPart(org.spongepowered.api.data.type.BodyPart) SlabType(org.spongepowered.api.data.type.SlabType) PotionEffect(org.spongepowered.api.effect.potion.PotionEffect) ComparatorType(org.spongepowered.api.data.type.ComparatorType) NotePitch(org.spongepowered.api.data.type.NotePitch) RabbitType(org.spongepowered.api.data.type.RabbitType) OcelotType(org.spongepowered.api.data.type.OcelotType) BigMushroomType(org.spongepowered.api.data.type.BigMushroomType) List(java.util.List) UUID(java.util.UUID) ShrubType(org.spongepowered.api.data.type.ShrubType) CauseStack(org.lanternpowered.server.event.CauseStack) Hinge(org.spongepowered.api.data.type.Hinge) StairShape(org.spongepowered.api.data.type.StairShape) PotionEffectType(org.spongepowered.api.effect.potion.PotionEffectType) HorseColor(org.spongepowered.api.data.type.HorseColor) DyeColor(org.spongepowered.api.data.type.DyeColor) Color(org.spongepowered.api.util.Color) Instant(java.time.Instant) DyeColor(org.spongepowered.api.data.type.DyeColor) BrickType(org.spongepowered.api.data.type.BrickType) EntityType(org.spongepowered.api.entity.EntityType) GameMode(org.spongepowered.api.entity.living.player.gamemode.GameMode) EntitySnapshot(org.spongepowered.api.entity.EntitySnapshot) Profession(org.spongepowered.api.data.type.Profession) FluidStackSnapshot(org.spongepowered.api.extra.fluid.FluidStackSnapshot) Vector3d(com.flowpowered.math.vector.Vector3d) BlockType(org.spongepowered.api.block.BlockType) DisguisedBlockType(org.spongepowered.api.data.type.DisguisedBlockType) HandPreference(org.spongepowered.api.data.type.HandPreference) GameProfile(org.spongepowered.api.profile.GameProfile) EntityArchetype(org.spongepowered.api.entity.EntityArchetype) Vector3i(com.flowpowered.math.vector.Vector3i) QuartzType(org.spongepowered.api.data.type.QuartzType) WeightedSerializableObject(org.spongepowered.api.util.weighted.WeightedSerializableObject) Enchantment(org.spongepowered.api.item.enchantment.Enchantment) LanternKeyFactory.makeImmutableBoundedValueKey(org.lanternpowered.server.data.key.LanternKeyFactory.makeImmutableBoundedValueKey) LanternKeyFactory.makeOptionalKey(org.lanternpowered.server.data.key.LanternKeyFactory.makeOptionalKey) LanternKeyFactory.makeSetKey(org.lanternpowered.server.data.key.LanternKeyFactory.makeSetKey) LanternKeyFactory.makeMutableBoundedValueKey(org.lanternpowered.server.data.key.LanternKeyFactory.makeMutableBoundedValueKey) Key(org.spongepowered.api.data.key.Key) LanternKeyFactory.makeListKey(org.lanternpowered.server.data.key.LanternKeyFactory.makeListKey) LanternKeyFactory.makeWeightedCollectionKey(org.lanternpowered.server.data.key.LanternKeyFactory.makeWeightedCollectionKey) LanternKeyFactory.makePatternListKey(org.lanternpowered.server.data.key.LanternKeyFactory.makePatternListKey) LanternKeyFactory.makeValueKey(org.lanternpowered.server.data.key.LanternKeyFactory.makeValueKey) CookedFish(org.spongepowered.api.data.type.CookedFish) PortionType(org.spongepowered.api.data.type.PortionType) StructureMode(org.spongepowered.api.data.type.StructureMode) Art(org.spongepowered.api.data.type.Art) DisguisedBlockType(org.spongepowered.api.data.type.DisguisedBlockType) WireAttachmentType(org.spongepowered.api.data.type.WireAttachmentType) RailDirection(org.spongepowered.api.data.type.RailDirection) Direction(org.spongepowered.api.util.Direction) FireworkEffect(org.spongepowered.api.item.FireworkEffect) TradeOffer(org.spongepowered.api.item.merchant.TradeOffer) RailDirection(org.spongepowered.api.data.type.RailDirection) DirtType(org.spongepowered.api.data.type.DirtType) Field(java.lang.reflect.Field) Statistic(org.spongepowered.api.statistic.Statistic) CookedFish(org.spongepowered.api.data.type.CookedFish) Fish(org.spongepowered.api.data.type.Fish) GoldenApple(org.spongepowered.api.data.type.GoldenApple) HorseStyle(org.spongepowered.api.data.type.HorseStyle) SandstoneType(org.spongepowered.api.data.type.SandstoneType) Axis(org.spongepowered.api.util.Axis) LogAxis(org.spongepowered.api.data.type.LogAxis) TreeType(org.spongepowered.api.data.type.TreeType) HorseColor(org.spongepowered.api.data.type.HorseColor) SandType(org.spongepowered.api.data.type.SandType) RespawnLocation(org.spongepowered.api.util.RespawnLocation) LlamaVariant(org.spongepowered.api.data.type.LlamaVariant) StoneType(org.spongepowered.api.data.type.StoneType) Text(org.spongepowered.api.text.Text) LogAxis(org.spongepowered.api.data.type.LogAxis) WallType(org.spongepowered.api.data.type.WallType) PistonType(org.spongepowered.api.data.type.PistonType) Rotation(org.spongepowered.api.util.rotation.Rotation) CoalType(org.spongepowered.api.data.type.CoalType) BlockState(org.spongepowered.api.block.BlockState) PickupRule(org.spongepowered.api.data.type.PickupRule) TypeToken(com.google.common.reflect.TypeToken) PlantType(org.spongepowered.api.data.type.PlantType) DoublePlantType(org.spongepowered.api.data.type.DoublePlantType) ItemStackSnapshot(org.spongepowered.api.item.inventory.ItemStackSnapshot) SkullType(org.spongepowered.api.data.type.SkullType) DoublePlantType(org.spongepowered.api.data.type.DoublePlantType) PrismarineType(org.spongepowered.api.data.type.PrismarineType) Career(org.spongepowered.api.data.type.Career)

Example 5 with CauseStack

use of org.lanternpowered.server.event.CauseStack in project LanternServer by LanternPowered.

the class LanternPlayer method handleDeath.

@Override
protected void handleDeath(CauseStack causeStack) {
    // Call the harvest event
    final boolean keepsInventory = getWorld().getOrCreateRule(RuleTypes.KEEP_INVENTORY).getValue();
    final int exp = keepsInventory ? 0 : Math.min(100, get(Keys.EXPERIENCE_LEVEL).orElse(0) * 7);
    // Humanoids get their own sub-interface for the event
    final HarvestEntityEvent.TargetPlayer harvestEvent = SpongeEventFactory.createHarvestEntityEventTargetPlayer(causeStack.getCurrentCause(), exp, exp, this, keepsInventory, keepsInventory, 0);
    Sponge.getEventManager().post(harvestEvent);
    if (!harvestEvent.isCancelled()) {
        final List<ItemStackSnapshot> drops = new ArrayList<>();
        if (!harvestEvent.keepsInventory()) {
            // Make a copy of all the items in the players inventory, and put them in the drops
            getInventory().<AbstractSlot>slots().forEach(slot -> slot.peek().ifPresent(itemStack -> drops.add(LanternItemStackSnapshot.wrap(itemStack))));
        }
        if (!harvestEvent.keepsLevel()) {
            offer(Keys.EXPERIENCE_LEVEL, harvestEvent.getLevel());
        }
        // Finalize the harvest event
        finalizeHarvestEvent(causeStack, harvestEvent, drops);
    }
    // Ban the player if the world is hardcode
    if (getWorld().getProperties().isHardcore()) {
        final BanService banService = Sponge.getServiceManager().provideUnchecked(BanService.class);
        // Add a permanent ban
        banService.addBan(Ban.of(getProfile(), t("gameMode.hardcore.banMessage")));
        // Bye, bye!
        kick(t("deathScreen.title.hardcore"));
    }
}
Also used : LanternPlayerAdvancements(org.lanternpowered.server.advancement.LanternPlayerAdvancements) LanternPlayerInventory(org.lanternpowered.server.inventory.vanilla.LanternPlayerInventory) LanternItemStackSnapshot(org.lanternpowered.server.inventory.LanternItemStackSnapshot) WorldConfig(org.lanternpowered.server.config.world.WorldConfig) ValueCollection(org.lanternpowered.server.data.ValueCollection) SoundCategory(org.spongepowered.api.effect.sound.SoundCategory) BookView(org.spongepowered.api.text.BookView) ItemStack(org.spongepowered.api.item.inventory.ItemStack) BlockRegistryModule(org.lanternpowered.server.game.registry.type.block.BlockRegistryModule) VanillaInventoryArchetypes(org.lanternpowered.server.inventory.vanilla.VanillaInventoryArchetypes) GameProfile(org.spongepowered.api.profile.GameProfile) LanternSoundType(org.lanternpowered.server.effect.sound.LanternSoundType) AdvancementProgress(org.spongepowered.api.advancement.AdvancementProgress) MessagePlayOutParticleEffect(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutParticleEffect) EnumSet(java.util.EnumSet) GlobalTabListEntry(org.lanternpowered.server.entity.living.player.tab.GlobalTabListEntry) MessagePlayOutSetReducedDebug(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutSetReducedDebug) LanternBossBar(org.lanternpowered.server.boss.LanternBossBar) Location(org.spongepowered.api.world.Location) AbstractViewer(org.lanternpowered.server.effect.AbstractViewer) TranslationHelper.t(org.lanternpowered.server.text.translation.TranslationHelper.t) LanternWeatherUniverse(org.lanternpowered.server.world.LanternWeatherUniverse) DataContainer(org.spongepowered.api.data.DataContainer) Set(java.util.Set) WorldBorder(org.spongepowered.api.world.WorldBorder) BlockState(org.spongepowered.api.block.BlockState) MessageChannelEvent(org.spongepowered.api.event.message.MessageChannelEvent) World(org.spongepowered.api.world.World) MessagePlayOutRecord(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutRecord) HandTypes(org.spongepowered.api.data.type.HandTypes) AbstractOrderedInventory(org.lanternpowered.server.inventory.AbstractOrderedInventory) Player(org.spongepowered.api.entity.living.player.Player) RespawnPlayerEvent(org.spongepowered.api.event.entity.living.humanoid.player.RespawnPlayerEvent) MessagePlayInOutBrand(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayInOutBrand) ChangeWorldBorderEvent(org.spongepowered.api.event.world.ChangeWorldBorderEvent) LanternKeys(org.lanternpowered.server.data.key.LanternKeys) ItemTypes(org.spongepowered.api.item.ItemTypes) GuiIdProperty(org.spongepowered.api.item.inventory.property.GuiIdProperty) Vector3d(com.flowpowered.math.vector.Vector3d) LanternCooldownTracker(org.lanternpowered.server.item.LanternCooldownTracker) AABB(org.spongepowered.api.util.AABB) LanternDifficulty(org.lanternpowered.server.world.difficulty.LanternDifficulty) ArrayList(java.util.ArrayList) Vector2i(com.flowpowered.math.vector.Vector2i) SpectateEntityEvent(org.lanternpowered.server.entity.event.SpectateEntityEvent) LanternTabListEntryBuilder(org.lanternpowered.server.entity.living.player.tab.LanternTabListEntryBuilder) LanternTitles(org.lanternpowered.server.text.title.LanternTitles) LanternTabList(org.lanternpowered.server.entity.living.player.tab.LanternTabList) CauseStack(org.lanternpowered.server.event.CauseStack) Text(org.spongepowered.api.text.Text) PlayerInventoryContainer(org.lanternpowered.server.inventory.PlayerInventoryContainer) LanternWorld(org.lanternpowered.server.world.LanternWorld) GlobalTabList(org.lanternpowered.server.entity.living.player.tab.GlobalTabList) LanternTabListEntry(org.lanternpowered.server.entity.living.player.tab.LanternTabListEntry) DimensionTypes(org.spongepowered.api.world.DimensionTypes) Nullable(javax.annotation.Nullable) MessagePlayOutPlayerRespawn(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutPlayerRespawn) MessagePlayOutStopSounds(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutStopSounds) WrittenBookItemTypeObjectSerializer(org.lanternpowered.server.data.io.store.item.WrittenBookItemTypeObjectSerializer) MessagePlayOutBlockChange(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutBlockChange) SpongeEventFactory(org.spongepowered.api.event.SpongeEventFactory) MessagePlayOutOpenBook(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutOpenBook) Scoreboard(org.spongepowered.api.scoreboard.Scoreboard) Entity(org.spongepowered.api.entity.Entity) LanternGameMode(org.lanternpowered.server.entity.living.player.gamemode.LanternGameMode) DataView(org.spongepowered.api.data.DataView) MessagePlayOutUnlockRecipes(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutUnlockRecipes) Vector3i(com.flowpowered.math.vector.Vector3i) ChatVisibilities(org.spongepowered.api.text.chat.ChatVisibilities) ChatVisibility(org.spongepowered.api.text.chat.ChatVisibility) MessageEvent(org.spongepowered.api.event.message.MessageEvent) AdvancementTree(org.spongepowered.api.advancement.AdvancementTree) BanService(org.spongepowered.api.service.ban.BanService) EventContextKeys(org.spongepowered.api.event.cause.EventContextKeys) NetworkIdHolder(org.lanternpowered.server.network.entity.NetworkIdHolder) ChunkTicketManager(org.spongepowered.api.world.ChunkTicketManager) ItemStackSnapshot(org.spongepowered.api.item.inventory.ItemStackSnapshot) Ban(org.spongepowered.api.util.ban.Ban) ChatType(org.spongepowered.api.text.chat.ChatType) RawItemStack(org.lanternpowered.server.network.objects.RawItemStack) UserStorageService(org.spongepowered.api.service.user.UserStorageService) ParticleEffect(org.spongepowered.api.effect.particle.ParticleEffect) ElementKeyRegistration(org.lanternpowered.server.data.element.ElementKeyRegistration) MessagePlayOutSetWindowSlot(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutSetWindowSlot) Locale(java.util.Locale) RuleTypes(org.lanternpowered.server.world.rules.RuleTypes) Title(org.spongepowered.api.text.title.Title) AbstractSlot(org.lanternpowered.server.inventory.AbstractSlot) SoundType(org.spongepowered.api.effect.sound.SoundType) Collection(java.util.Collection) ChunkLoadingTicket(org.lanternpowered.server.world.chunk.ChunkLoadingTicket) Sponge(org.spongepowered.api.Sponge) ResourcePack(org.spongepowered.api.resourcepack.ResourcePack) Sets(com.google.common.collect.Sets) Cause(org.spongepowered.api.event.cause.Cause) List(java.util.List) Lantern(org.lanternpowered.server.game.Lantern) Transform(org.spongepowered.api.entity.Transform) MessagePlayOutPlayerJoinGame(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutPlayerJoinGame) RelativePositions(org.spongepowered.api.util.RelativePositions) Optional(java.util.Optional) RecordType(org.spongepowered.api.effect.sound.record.RecordType) MessagePlayOutPlayerPositionAndLook(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutPlayerPositionAndLook) HarvestEntityEvent(org.spongepowered.api.event.entity.HarvestEntityEvent) IntArrayList(it.unimi.dsi.fastutil.ints.IntArrayList) LanternChatType(org.lanternpowered.server.text.chat.LanternChatType) Inventory(org.spongepowered.api.item.inventory.Inventory) ChatTypes(org.spongepowered.api.text.chat.ChatTypes) Keys(org.spongepowered.api.data.key.Keys) PlayerContainerSession(org.lanternpowered.server.inventory.PlayerContainerSession) HashSet(java.util.HashSet) LanternContainer(org.lanternpowered.server.inventory.LanternContainer) NetworkSession(org.lanternpowered.server.network.NetworkSession) SkinPart(org.spongepowered.api.data.type.SkinPart) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) LanternGameProfile(org.lanternpowered.server.profile.LanternGameProfile) Container(org.spongepowered.api.item.inventory.Container) MessagePlayOutSelectAdvancementTree(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutSelectAdvancementTree) LanternDimensionType(org.lanternpowered.server.world.dimension.LanternDimensionType) MessageChannel(org.spongepowered.api.text.channel.MessageChannel) Advancement(org.spongepowered.api.advancement.Advancement) EquipmentTypes(org.spongepowered.api.item.inventory.equipment.EquipmentTypes) Collections(java.util.Collections) LanternScoreboard(org.lanternpowered.server.scoreboard.LanternScoreboard) PlayerInventoryShiftClickBehavior(org.lanternpowered.server.inventory.vanilla.PlayerInventoryShiftClickBehavior) LanternWorldBorder(org.lanternpowered.server.world.LanternWorldBorder) HarvestEntityEvent(org.spongepowered.api.event.entity.HarvestEntityEvent) ArrayList(java.util.ArrayList) IntArrayList(it.unimi.dsi.fastutil.ints.IntArrayList) LanternItemStackSnapshot(org.lanternpowered.server.inventory.LanternItemStackSnapshot) ItemStackSnapshot(org.spongepowered.api.item.inventory.ItemStackSnapshot) BanService(org.spongepowered.api.service.ban.BanService)

Aggregations

CauseStack (org.lanternpowered.server.event.CauseStack)54 ItemStack (org.spongepowered.api.item.inventory.ItemStack)18 Entity (org.spongepowered.api.entity.Entity)16 ArrayList (java.util.ArrayList)15 Nullable (javax.annotation.Nullable)15 World (org.spongepowered.api.world.World)15 Optional (java.util.Optional)14 Lantern (org.lanternpowered.server.game.Lantern)13 AbstractSlot (org.lanternpowered.server.inventory.AbstractSlot)13 LanternWorld (org.lanternpowered.server.world.LanternWorld)13 SpawnEntityEvent (org.spongepowered.api.event.entity.SpawnEntityEvent)13 Vector3i (com.flowpowered.math.vector.Vector3i)12 List (java.util.List)12 LanternPlayer (org.lanternpowered.server.entity.living.player.LanternPlayer)12 Keys (org.spongepowered.api.data.key.Keys)12 EventContextKeys (org.spongepowered.api.event.cause.EventContextKeys)12 Sponge (org.spongepowered.api.Sponge)11 Transform (org.spongepowered.api.entity.Transform)11 Player (org.spongepowered.api.entity.living.player.Player)11 SpongeEventFactory (org.spongepowered.api.event.SpongeEventFactory)11