public void setEntitys(ArrayList<Entity> realEntities) { for (Entity e : realEntities) { JsonEntity JE = new JsonEntity(e.getX(), e.getY(), e.isSolid(), e.getClass().getName()); if (e.isSign()) { JE.setSignText(e.getSignText()); } entities.add(JE); } }
ArrayList<Entity> getEntities() { ArrayList<Entity> realEntities = new ArrayList<Entity>(); for (JsonEntity je : this.entities) { Entity xyz = null; Class<?> cl; try { cl = Class.forName(je.getName()); Constructor<?> con = cl.getConstructor(float.class, float.class, boolean.class); xyz = (Entity) con.newInstance(je.getX(), je.getY(), je.getSolid()); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } if (xyz.isSign()) { xyz.setSignText(je.getSignText()); System.out.println("Sign Text = " + je.getSignText()); } realEntities.add(xyz); } return realEntities; }