Search in sources :

Example 36 with LanternPlayer

use of org.lanternpowered.server.entity.living.player.LanternPlayer in project LanternServer by LanternPowered.

the class HandlerPlayInPlayerBlockPlacement method handle.

@Override
public void handle(NetworkContext context, MessagePlayInPlayerBlockPlacement message) {
    final LanternPlayer player = context.getSession().getPlayer();
    player.resetIdleTimeoutCounter();
    player.getInteractionHandler().handleBlockPlacing(message);
}
Also used : LanternPlayer(org.lanternpowered.server.entity.living.player.LanternPlayer)

Example 37 with LanternPlayer

use of org.lanternpowered.server.entity.living.player.LanternPlayer in project LanternServer by LanternPowered.

the class HandlerPlayInPlayerDigging method handle.

@Override
public void handle(NetworkContext context, MessagePlayInPlayerDigging message) {
    final LanternPlayer player = context.getSession().getPlayer();
    player.resetIdleTimeoutCounter();
    player.getInteractionHandler().handleDigging(message);
}
Also used : LanternPlayer(org.lanternpowered.server.entity.living.player.LanternPlayer)

Example 38 with LanternPlayer

use of org.lanternpowered.server.entity.living.player.LanternPlayer in project LanternServer by LanternPowered.

the class HandlerPlayInPlayerLook method handle.

@Override
public void handle(NetworkContext context, MessagePlayInPlayerLook message) {
    final LanternPlayer player = context.getSession().getPlayer();
    player.setRawRotation(toRotation(message.getPitch(), message.getYaw()));
    player.handleOnGroundState(message.isOnGround());
}
Also used : LanternPlayer(org.lanternpowered.server.entity.living.player.LanternPlayer)

Example 39 with LanternPlayer

use of org.lanternpowered.server.entity.living.player.LanternPlayer in project LanternServer by LanternPowered.

the class HandlerPlayInPlayerSwingArm method handle.

@Override
public void handle(NetworkContext context, MessagePlayInPlayerSwingArm message) {
    final LanternPlayer player = context.getSession().getPlayer();
    player.resetIdleTimeoutCounter();
    player.getInteractionHandler().handleSwingArm(message);
}
Also used : LanternPlayer(org.lanternpowered.server.entity.living.player.LanternPlayer)

Example 40 with LanternPlayer

use of org.lanternpowered.server.entity.living.player.LanternPlayer in project LanternServer by LanternPowered.

the class HandlerPlayInResourcePackStatus method handle.

@Override
public void handle(NetworkContext context, MessagePlayInResourcePackStatus message) {
    final Optional<ResourcePack> resourcePack = context.getSession().getPlayer().getResourcePackSendQueue().poll(message.getStatus());
    final LanternPlayer player = context.getSession().getPlayer();
    if (!resourcePack.isPresent()) {
        Lantern.getLogger().warn("{} received a unexpected resource pack status message ({}), no resource pack was pending", player.getName(), message.getStatus());
        return;
    }
    final CauseStack causeStack = CauseStack.current();
    try (CauseStack.Frame frame = causeStack.pushCauseFrame()) {
        frame.addContext(EventContextKeys.PLAYER, player);
        Sponge.getEventManager().post(SpongeEventFactory.createResourcePackStatusEvent(frame.getCurrentCause(), resourcePack.get(), player, message.getStatus()));
    }
}
Also used : CauseStack(org.lanternpowered.server.event.CauseStack) ResourcePack(org.spongepowered.api.resourcepack.ResourcePack) LanternPlayer(org.lanternpowered.server.entity.living.player.LanternPlayer)

Aggregations

LanternPlayer (org.lanternpowered.server.entity.living.player.LanternPlayer)48 ArrayList (java.util.ArrayList)13 CauseStack (org.lanternpowered.server.event.CauseStack)12 AbstractSlot (org.lanternpowered.server.inventory.AbstractSlot)11 ItemStack (org.spongepowered.api.item.inventory.ItemStack)11 World (org.spongepowered.api.world.World)11 Optional (java.util.Optional)10 Vector3d (com.flowpowered.math.vector.Vector3d)9 List (java.util.List)9 Collectors (java.util.stream.Collectors)9 Nullable (javax.annotation.Nullable)9 Sponge (org.spongepowered.api.Sponge)9 SlotTransaction (org.spongepowered.api.item.inventory.transaction.SlotTransaction)9 Lantern (org.lanternpowered.server.game.Lantern)8 LanternItemStack (org.lanternpowered.server.inventory.LanternItemStack)8 Player (org.spongepowered.api.entity.living.player.Player)8 ChangeInventoryEvent (org.spongepowered.api.event.item.inventory.ChangeInventoryEvent)8 AbstractInventory (org.lanternpowered.server.inventory.AbstractInventory)7 PlayerInventoryContainer (org.lanternpowered.server.inventory.PlayerInventoryContainer)7 ClientContainer (org.lanternpowered.server.inventory.client.ClientContainer)7