Ejemplo n.º 1
0
 /**
  * Remove a Warp from the data source
  *
  * @param warp Warp instance to remove from the data source.
  */
 public void removeWarp(Warp warp) {
   try {
     HashMap<String, Object> filter = new HashMap<String, Object>();
     filter.put("name", warp.getName());
     // filter.put("location", warp.getLocation().toString()); // Location is a bad filter, mkay
     Database.get().remove(schema, filter);
   } catch (DatabaseWriteException e) {
     log.error(e.getMessage(), e);
   }
 }
Ejemplo n.º 2
0
  /**
   * Update a Warp
   *
   * @param warp Warp instance to update to the data source.
   */
  public void updateWarp(Warp warp) {
    WarpDataAccess data = schema.getInstance();

    data.groups = warp.getGroupsAsString();
    data.isPlayerHome = warp.isPlayerHome();
    // data.location = warp.getLocation().toString(); Deprecated
    data.location = "N/A";
    warp.getLocation().toDataAccess(data); // Replacing data.location
    data.name = warp.getName();
    data.owner = warp.getOwner();
    try {
      HashMap<String, Object> filter = new HashMap<String, Object>();
      filter.put("name", warp.getName());
      Database.get().update(data, filter);
    } catch (DatabaseWriteException e) {
      log.error(e.getMessage(), e);
    }
  }
Ejemplo n.º 3
0
  /**
   * Add a new Warp to the list of Warps.
   *
   * @param warp Warp instance to add to the data source.
   */
  public void addWarp(Warp warp) {
    if (warpExists(warp)) {
      updateWarp(warp);
      return;
    }
    WarpDataAccess data = schema.getInstance();

    data.groups = warp.getGroupsAsString();
    data.isPlayerHome = warp.isPlayerHome();

    // data.location = warp.getLocation().toString(); deprecated
    data.location = "N/A";
    warp.getLocation().toDataAccess(data); // Replacing data.location
    data.name = warp.getName();
    data.owner = warp.getOwner();

    try {
      Database.get().insert(data);
    } catch (DatabaseWriteException e) {
      log.error(e.getMessage(), e);
    }
  }