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();
}
Aggregations