30.05.2015, 09:38
@dusk: The PlayerlifecycleObject will be created when the player connects, so it's not possible to create it when he enters the correct password. You could just add a boolean to your GameData class that indicates if the player is logged in or not. And if you want to add custom parameters to your constructor, you can do that by using a custom PlayerLifecycleObjectFactory, like this:
in short form, you can also use a lambda expression (I like it more):
@Kapersky™: Thank you
Код:
lifecycleHolder.registerClass(GameData.class, new PlayerLifecycleHolder.PlayerLifecycleObjectFactory<GameData>() { @Override public GameData create(EventManager eventManager, Player player) { return new GameData(eventManager, player); } });
Код:
lifecycleHolder.registerClass(GameData.class, (eventManager1, player) -> { return new GameData(eventManager1, player); });