@Override public void saveHome(Home home) { if (!homes.containsKey(home.getOwner().toLowerCase())) { homes.put(home.getOwner().toLowerCase(), new HashMap<String, Home>()); } homes.get(home.getOwner().toLowerCase()).put(home.getName().toLowerCase(), home); plugin.getDatabase().save(home); }
@Override public void delHome(Home home) { Home h = null; try { h = homes.get(home.getOwner().toLowerCase()).remove(home.getName().toLowerCase()); } catch (NullPointerException ex) { } if (h != null) { plugin.getDatabase().delete(h); } }
@Override public void reloadData() { try { int rowCount = plugin.getDatabase().find(Home.class).findRowCount(); } catch (PersistenceException ex) { plugin.initDB(); } for (Home home : plugin.getDatabase().find(Home.class).findList()) { if (!homes.containsKey(home.getOwner().toLowerCase())) { homes.put(home.getOwner().toLowerCase(), new HashMap<String, Home>()); } homes.get(home.getOwner().toLowerCase()).put(home.getName().toLowerCase(), home); } plugin.debug("Loaded " + homes.size() + " player homes."); }
@Override public Home createHome( String player, String name, String world, double x, double y, double z, float yaw, float pitch) { Home home = plugin.getDatabase().createEntityBean(Home.class); home.setPlayerHomeName(new PlayerHomeName(player, name)); home.setWorld(world); home.setX(x); home.setY(y); home.setZ(z); home.setYaw(yaw); home.setPitch(pitch); if (!homes.containsKey(home.getOwner().toLowerCase())) { homes.put(home.getOwner().toLowerCase(), new HashMap<String, Home>()); } homes.get(home.getOwner().toLowerCase()).put(home.getName().toLowerCase(), home); return home; }