3
0
Mirror von https://github.com/TheSilentPro/HeadDB.git synchronisiert 2024-12-27 11:20:05 +01:00

Add AsyncHeadsFetchedEvent

Dieser Commit ist enthalten in:
BuildTools 2023-06-27 20:46:05 +02:00
Ursprung 106d26f23c
Commit d8d428947a
2 geänderte Dateien mit 56 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,45 @@
package tsp.headdb.core.api.events;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
public class AsyncHeadsFetchedEvent extends Event {
private static final HandlerList HANDLER_LIST = new HandlerList();
private final int headsCount;
private final String providerName;
private final long timeTook;
public AsyncHeadsFetchedEvent(int headsCount, String providerName, long timeTook) {
this.headsCount = headsCount;
this.providerName = providerName;
this.timeTook = timeTook;
}
@NotNull
@SuppressWarnings("unused")
public static HandlerList getHandlerList() {
return HANDLER_LIST;
}
@NotNull
@Override
public HandlerList getHandlers() {
return new HandlerList();
}
@SuppressWarnings("unused")
public int getHeadsCount() {
return headsCount;
}
@SuppressWarnings("unused")
public String getProviderName() {
return providerName;
}
@SuppressWarnings("unused")
public long getTimeTook() {
return timeTook;
}
}

Datei anzeigen

@ -1,7 +1,9 @@
package tsp.headdb.core.task;
import org.bukkit.Bukkit;
import tsp.headdb.HeadDB;
import tsp.headdb.core.api.HeadAPI;
import tsp.headdb.core.api.events.AsyncHeadsFetchedEvent;
import tsp.headdb.implementation.head.Head;
import tsp.nexuslib.task.Task;
@ -25,7 +27,15 @@ public class UpdateTask implements Task {
size++;
}
}
HeadDB.getInstance().getLog().debug("Fetched: " + size + " Heads | Provider: " + HeadAPI.getDatabase().getRequester().getProvider().name() + " | Time: " + time + "ms (" + TimeUnit.MILLISECONDS.toSeconds(time) + "s)");
String providerName = HeadAPI.getDatabase().getRequester().getProvider().name();
HeadDB.getInstance().getLog().debug("Fetched: " + size + " Heads | Provider: " + providerName + " | Time: " + time + "ms (" + TimeUnit.MILLISECONDS.toSeconds(time) + "s)");
Bukkit.getPluginManager().callEvent(
new AsyncHeadsFetchedEvent(
size,
providerName,
time));
});
HeadDB.getInstance().getStorage().getPlayerStorage().backup();
HeadDB.getInstance().getLog().debug("UpdateTask finished!");