AstralLiteratureClub / Fluffy

Fluffy is a combat manager for the latest PaperMC server software. This is not designed to work with normal spigot.
0 stars 0 forks source link

Statistics counted / database #3

Open Antritus opened 9 months ago

Antritus commented 9 months ago

Create statistics for kills (global, crystal, anchor, bed, tnt) , deaths (global, crystal, anchor, bed, tnt), streaks (kills, deaths)

Add a way to have custom statistics


public interface Account {
  Map<Statistic, Integer> getAllStatistics();
  int getStatistic(Statistic statistic);
  void increment(Statistic statistic);
  void decrement(Statistic statistic);
  void reset(Statistic statistic);
  void set(Statistic statistic, @Range(from = 0, to = Integer.MAX_VALUE) int amount);
  CompletableFuture<Void> delete(Statistic statistic);
  CompletableFuture<Void> save();
}

public interface Statistic {
  String getName();

  static Statistic of(String name){
    return new StatisticImpl(name);
  }

  protected class StatisticImpl implements Statistic {
    private final String name;
    protected Statisticimpl(String name){
      this.name = name;
    }

    @Override
    public StatisticImpl() {
      return name;
    }
  }
}

public final class Statistics {
  public static final Statistic KILLS_GLOBAL = Statistic.of("kills.global");
  public static final Statistic KILLS_ANCHOR = Statistic.of("kills.anchor");
  public static final Statistic KILLS_CRYSTAL= Statistic.of("kills.crystal");
  public static final Statistic KILLS_TNT = Statistic.of("kills.tnt");
  public static final Statistic KILLS_BED = Statistic.of("kills.bed");

  public static final Statistic DEATHS_GLOBAL = Statistic.of("deaths.global");
  public static final Statistic DEATHS_ANCHOR = Statistic.of("deaths.anchor");
  public static final Statistic DEATHS_CRYSTAL= Statistic.of("deaths.crystal");
  public static final Statistic DEATHS_TNT = Statistic.of("deaths.tnt");
  public static final Statistic DEATHS_BED = Statistic.of("deaths.bed");

  public static final Statistic STREAK_KILLS= Statistic.of("streaks.kills");
  public static final Statistic STREAK_DEATHS= Statistic.of("streaks.deaths");
}
Antritus commented 9 months ago

Won't add other explosions adding TNT instead

Antritus commented 8 months ago

18 added the default database system. Still need to make the updating of the database

Antritus commented 8 months ago

All time statistics which would be stored in a different database or using a different table

Antritus commented 8 months ago

Split databases to

Kills, Deaths, Streaks

Antritus commented 7 months ago

A way to add custom statistics and way to automatically store them. This would be useful in other private plugins of my so I wouldn't need to each time create a new database instance