Add playtime update

This commit is contained in:
2026-05-31 20:20:14 +02:00
parent 5dbf3638d0
commit 559cae2b6d
2 changed files with 13 additions and 0 deletions
@@ -36,6 +36,9 @@ public class Advancements {
@Getter @Getter
static final List<Advancement> all = new ArrayList<>(); static final List<Advancement> all = new ArrayList<>();
@Getter
private static final List<Advancement> playtime = new ArrayList<>();
public static final Advancement ROOT = new Advancement( public static final Advancement ROOT = new Advancement(
"steamwar:advancements/root", "steamwar:advancements/root",
Optional.empty(), Optional.empty(),
@@ -80,6 +83,7 @@ public class Advancements {
return (int) (playtime / (neededPlayTime / 100)); return (int) (playtime / (neededPlayTime / 100));
} }
); );
playtime.add(previous);
} }
} }
} }
@@ -28,6 +28,7 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.ProtocolUtils; import com.velocitypowered.proxy.protocol.ProtocolUtils;
import com.velocitypowered.proxy.protocol.StateRegistry; import com.velocitypowered.proxy.protocol.StateRegistry;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import de.steamwar.messages.Chatter;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.velocitycore.VelocityCore; import de.steamwar.velocitycore.VelocityCore;
import de.steamwar.velocitycore.listeners.BasicListener; import de.steamwar.velocitycore.listeners.BasicListener;
@@ -55,6 +56,14 @@ public class AdvancementsManager extends BasicListener {
} catch (Exception e) { } catch (Exception e) {
// Ignore // Ignore
} }
VelocityCore.schedule(() -> {
for (Advancement advancement : Advancements.getPlaytime()) {
Chatter.allPlayers().forEach(player -> {
advancement.get(SteamwarUser.get(player.getUniqueId())).update();
});
}
}).repeat(10, TimeUnit.MINUTES).schedule();
} }
@Subscribe(priority = -1000) @Subscribe(priority = -1000)