Search in sources :

Example 1 with OpenWindowMessage

use of net.glowstone.net.message.play.inv.OpenWindowMessage in project Glowstone by GlowstoneMC.

the class GlowPlayer method openInventory.

@Override
public void openInventory(InventoryView view) {
    session.send(new CloseWindowMessage(invMonitor.getId()));
    super.openInventory(view);
    invMonitor = new InventoryMonitor(getOpenInventory());
    int viewId = invMonitor.getId();
    if (viewId != 0) {
        InventoryOpenEvent event = EventFactory.getInstance().callEvent(new InventoryOpenEvent(view));
        if (event.isCancelled()) {
            // close the inventory but don't fire the InventoryCloseEvent
            resetInventoryView();
            return;
        }
        String title = view.getTitle();
        boolean defaultTitle = Objects.equals(view.getType().getDefaultTitle(), title);
        if (view.getTopInventory() instanceof PlayerInventory && defaultTitle) {
            title = ((PlayerInventory) view.getTopInventory()).getHolder().getName();
        }
        Message open = new OpenWindowMessage(viewId, invMonitor.getType(), title, ((GlowInventory) view.getTopInventory()).getRawSlots());
        session.send(open);
    }
    updateInventory();
}
Also used : InventoryOpenEvent(org.bukkit.event.inventory.InventoryOpenEvent) CloseWindowMessage(net.glowstone.net.message.play.inv.CloseWindowMessage) OpenWindowMessage(net.glowstone.net.message.play.inv.OpenWindowMessage) TitleMessage(net.glowstone.net.message.play.game.TitleMessage) EntityMetadataMessage(net.glowstone.net.message.play.entity.EntityMetadataMessage) OpenWindowMessage(net.glowstone.net.message.play.inv.OpenWindowMessage) BlockBreakAnimationMessage(net.glowstone.net.message.play.game.BlockBreakAnimationMessage) WindowPropertyMessage(net.glowstone.net.message.play.inv.WindowPropertyMessage) UpdateBlockEntityMessage(net.glowstone.net.message.play.game.UpdateBlockEntityMessage) RespawnMessage(net.glowstone.net.message.play.game.RespawnMessage) EntityVelocityMessage(net.glowstone.net.message.play.entity.EntityVelocityMessage) PositionRotationMessage(net.glowstone.net.message.play.game.PositionRotationMessage) HealthMessage(net.glowstone.net.message.play.game.HealthMessage) PluginMessage(net.glowstone.net.message.play.game.PluginMessage) SetWindowSlotMessage(net.glowstone.net.message.play.inv.SetWindowSlotMessage) PlayEffectMessage(net.glowstone.net.message.play.game.PlayEffectMessage) BlockChangeMessage(net.glowstone.net.message.play.game.BlockChangeMessage) MultiBlockChangeMessage(net.glowstone.net.message.play.game.MultiBlockChangeMessage) UnloadChunkMessage(net.glowstone.net.message.play.game.UnloadChunkMessage) StateChangeMessage(net.glowstone.net.message.play.game.StateChangeMessage) SpawnPositionMessage(net.glowstone.net.message.play.game.SpawnPositionMessage) ExperienceMessage(net.glowstone.net.message.play.game.ExperienceMessage) NamedSoundEffectMessage(net.glowstone.net.message.play.game.NamedSoundEffectMessage) UserListHeaderFooterMessage(net.glowstone.net.message.play.game.UserListHeaderFooterMessage) HeldItemMessage(net.glowstone.net.message.play.inv.HeldItemMessage) MapDataMessage(net.glowstone.net.message.play.game.MapDataMessage) StopSoundMessage(net.glowstone.net.message.play.game.StopSoundMessage) CloseWindowMessage(net.glowstone.net.message.play.inv.CloseWindowMessage) ChunkDataMessage(net.glowstone.net.message.play.game.ChunkDataMessage) TimeMessage(net.glowstone.net.message.play.game.TimeMessage) Message(com.flowpowered.network.Message) SetWindowContentsMessage(net.glowstone.net.message.play.inv.SetWindowContentsMessage) PlayParticleMessage(net.glowstone.net.message.play.game.PlayParticleMessage) ResourcePackSendMessage(net.glowstone.net.message.play.player.ResourcePackSendMessage) DestroyEntitiesMessage(net.glowstone.net.message.play.entity.DestroyEntitiesMessage) JoinGameMessage(net.glowstone.net.message.play.game.JoinGameMessage) SignEditorMessage(net.glowstone.net.message.play.game.SignEditorMessage) SetPassengerMessage(net.glowstone.net.message.play.entity.SetPassengerMessage) EntityAnimationMessage(net.glowstone.net.message.play.entity.EntityAnimationMessage) TextMessage(net.glowstone.util.TextMessage) UpdateSignMessage(net.glowstone.net.message.play.game.UpdateSignMessage) UserListItemMessage(net.glowstone.net.message.play.game.UserListItemMessage) ChatMessage(net.glowstone.net.message.play.game.ChatMessage) InventoryMonitor(net.glowstone.inventory.InventoryMonitor) PlayerInventory(org.bukkit.inventory.PlayerInventory)

Aggregations

Message (com.flowpowered.network.Message)1 InventoryMonitor (net.glowstone.inventory.InventoryMonitor)1 DestroyEntitiesMessage (net.glowstone.net.message.play.entity.DestroyEntitiesMessage)1 EntityAnimationMessage (net.glowstone.net.message.play.entity.EntityAnimationMessage)1 EntityMetadataMessage (net.glowstone.net.message.play.entity.EntityMetadataMessage)1 EntityVelocityMessage (net.glowstone.net.message.play.entity.EntityVelocityMessage)1 SetPassengerMessage (net.glowstone.net.message.play.entity.SetPassengerMessage)1 BlockBreakAnimationMessage (net.glowstone.net.message.play.game.BlockBreakAnimationMessage)1 BlockChangeMessage (net.glowstone.net.message.play.game.BlockChangeMessage)1 ChatMessage (net.glowstone.net.message.play.game.ChatMessage)1 ChunkDataMessage (net.glowstone.net.message.play.game.ChunkDataMessage)1 ExperienceMessage (net.glowstone.net.message.play.game.ExperienceMessage)1 HealthMessage (net.glowstone.net.message.play.game.HealthMessage)1 JoinGameMessage (net.glowstone.net.message.play.game.JoinGameMessage)1 MapDataMessage (net.glowstone.net.message.play.game.MapDataMessage)1 MultiBlockChangeMessage (net.glowstone.net.message.play.game.MultiBlockChangeMessage)1 NamedSoundEffectMessage (net.glowstone.net.message.play.game.NamedSoundEffectMessage)1 PlayEffectMessage (net.glowstone.net.message.play.game.PlayEffectMessage)1 PlayParticleMessage (net.glowstone.net.message.play.game.PlayParticleMessage)1 PluginMessage (net.glowstone.net.message.play.game.PluginMessage)1