public void run(int playerId) {
try {
if (allWidgets.containsKey(widgetId)) {
widget = allWidgets.get(widgetId);
if (widget.getVersion() == version) {
widget.readData(new SpoutInputStream(widgetData));
}
} else {
widget = widgetType.getWidgetClass().newInstance();
// Hackish way to set the ID without a setter
((GenericWidget) widget).setId(widgetId);
if (widget.getVersion() == version) {
widget.readData(new SpoutInputStream(widgetData));
} else {
if (nags[widgetType.getId()]-- > 0) {
System.out.println("Received invalid widget: " + widgetType.getWidgetClass().getSimpleName() + " v: " + version + " current v: " + widget.getVersion());
}
widget = null;