Ejemplo n.º 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);
      }
    }
Ejemplo n.º 2
0
 @Override
 public boolean pushData(int playerId) {
   return Query.table(PlacedBlocks.TableName)
       .value(PlacedBlocks.PlayerId, playerId)
       .value(PlacedBlocks.MaterialId, MaterialCache.parse(block))
       .value(PlacedBlocks.World, location.getWorld().getName())
       .value(PlacedBlocks.XCoord, location.getBlockX())
       .value(PlacedBlocks.YCoord, location.getBlockY())
       .value(PlacedBlocks.ZCoord, location.getBlockZ())
       .value(PlacedBlocks.Timestamp, timestamp)
       .insert();
 }
Ejemplo n.º 3
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;
 }