SpoutDev/Spout — Issue #1120: getScreen() in onScreenOpen is "null"
Author: Hoeze
Created: 2011-12-03 17:57:27+00:00
State: open

I wrote the following code:

The ScreenListener class:
public void onScreenOpen(ScreenOpenEvent event)
{
System.out.println("Screen opened");
if (event.getPlayer().isSpoutCraftEnabled() && event.getScreenType() == ScreenType.CHEST_INVENTORY)
{
new GUIChestInv(event.getScreen(),event.getPlayer());
System.out.println("GUIChestInv created" );
}else System.out.println("no GUI created");
}

The GUIChestInv class:
public GUIChestInv (Screen screen, SpoutPlayer splayer)
{
this.splayer = splayer;
this.invScreen = screen;
System.out.println("ChestInv initialised, Screen: "+ screen + ", Player: " + splayer);

createScreen(splayer);
}

But I always get null for the screen:
[INFORMATION] ChestInv initialised, Screen: null, Player: CraftPlayer{name=******}
and an error in my createScreen()-method...