Mirror von
https://github.com/TheSilentPro/HeadDB.git
synchronisiert 2024-12-27 11:20:05 +01:00
Add AsyncHeadsFetchedEvent
Dieser Commit ist enthalten in:
Ursprung
106d26f23c
Commit
d8d428947a
45
src/main/java/tsp/headdb/core/api/events/AsyncHeadsFetchedEvent.java
Normale Datei
45
src/main/java/tsp/headdb/core/api/events/AsyncHeadsFetchedEvent.java
Normale Datei
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,9 @@
|
|||||||
package tsp.headdb.core.task;
|
package tsp.headdb.core.task;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import tsp.headdb.HeadDB;
|
import tsp.headdb.HeadDB;
|
||||||
import tsp.headdb.core.api.HeadAPI;
|
import tsp.headdb.core.api.HeadAPI;
|
||||||
|
import tsp.headdb.core.api.events.AsyncHeadsFetchedEvent;
|
||||||
import tsp.headdb.implementation.head.Head;
|
import tsp.headdb.implementation.head.Head;
|
||||||
import tsp.nexuslib.task.Task;
|
import tsp.nexuslib.task.Task;
|
||||||
|
|
||||||
@ -25,7 +27,15 @@ public class UpdateTask implements Task {
|
|||||||
size++;
|
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().getStorage().getPlayerStorage().backup();
|
||||||
HeadDB.getInstance().getLog().debug("UpdateTask finished!");
|
HeadDB.getInstance().getLog().debug("UpdateTask finished!");
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren