Example #1
0
    @Override
    public void fetchData(int playerId) {
      if (!LocalConfiguration.Standalone.asBoolean()) {
        clearData(playerId);
        return;
      }

      QueryResult result =
          Query.table(TotalBlocksTable.TableName)
              .column(TotalBlocksTable.Destroyed)
              .column(TotalBlocksTable.Placed)
              .condition(TotalBlocksTable.PlayerId, playerId)
              .condition(TotalBlocksTable.MaterialId, MaterialCache.parse(block))
              .select();

      if (result == null) {
        Query.table(TotalBlocksTable.TableName)
            .value(TotalBlocksTable.PlayerId, playerId)
            .value(TotalBlocksTable.MaterialId, MaterialCache.parse(block))
            .value(TotalBlocksTable.Destroyed, broken)
            .value(TotalBlocksTable.Placed, placed)
            .insert();
      } else {
        broken = result.asInt(TotalBlocksTable.Destroyed);
        placed = result.asInt(TotalBlocksTable.Placed);
      }
    }
Example #2
0
 @Override
 public boolean pushData(int playerId) {
   boolean result =
       Query.table(TotalBlocksTable.TableName)
           .value(TotalBlocksTable.Destroyed, broken)
           .value(TotalBlocksTable.Placed, placed)
           .condition(TotalBlocksTable.PlayerId, playerId)
           .condition(TotalBlocksTable.MaterialId, MaterialCache.parse(block))
           .update(LocalConfiguration.Standalone.asBoolean());
   fetchData(playerId);
   return result;
 }