/** * Creates a new {@link GameStateEvent} of the given type. * * @param type The type of the state event * @param game The game instance for this {@link Event} * @param <T> The type of the state event * @return A new instance of the event */ public static <T extends GameStateEvent> T createState(Class<T> type, Game game) { Map<String, Object> values = Maps.newHashMapWithExpectedSize(2); values.put("state", game.getState()); values.put("cause", Cause.source(game).build()); return SpongeEventFactoryUtils.createEventImpl(type, values); }