Files
OldSliceMC/patches/api/0012-Add-PlayerLoadStatsEvent.patch
2024-11-16 09:36:10 -06:00

66 lines
1.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Sat, 16 Nov 2024 09:34:15 -0600
Subject: [PATCH] Add PlayerLoadStatsEvent
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerLoadStatsEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerLoadStatsEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..8c74868a7445b478a80aff160a7a588a885aa889
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerLoadStatsEvent.java
@@ -0,0 +1,53 @@
+package com.destroystokyo.paper.event.player;
+
+import org.bukkit.Bukkit;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.UUID;
+
+/**
+ * Calls an event in which player stats can be provided. If null, will load from disk, otherwise will use provided data
+ */
+public class PlayerLoadStatsEvent extends Event {
+ private static final HandlerList handlers = new HandlerList();
+ private final UUID playerId;
+ private String json;
+
+ public PlayerLoadStatsEvent(@NotNull UUID playerId) {
+ super(!Bukkit.isPrimaryThread());
+ this.playerId = playerId;
+ }
+
+ /**
+ * Gets the player's unique ID.
+ *
+ * @return The unique ID
+ */
+ @NotNull
+ public UUID getUniqueId() {
+ return playerId;
+ }
+
+ @Nullable
+ public String getStatistics() {
+ return json;
+ }
+
+ public void setStatistics(@NotNull String json) {
+ this.json = json;
+ }
+
+ @NotNull
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}