Dieser Commit ist enthalten in:
Silent 2022-02-18 01:58:14 +01:00
Ursprung ce442b645f
Commit 6ea59a99ba
3 geänderte Dateien mit 57 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -6,7 +6,7 @@
<groupId>tsp.headdb</groupId>
<artifactId>HeadDB</artifactId>
<version>3.2.2</version>
<version>3.2.4</version>
<packaging>jar</packaging>
<name>HeadDB</name>

Datei anzeigen

@ -8,6 +8,7 @@ import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import tsp.headdb.api.Head;
import tsp.headdb.event.DatabaseUpdateEvent;
import tsp.headdb.util.Log;
import tsp.headdb.util.Utils;
@ -217,6 +218,7 @@ public class HeadDatabase {
HEADS.clear();
HEADS.putAll(heads);
result.accept(heads);
Bukkit.getPluginManager().callEvent(new DatabaseUpdateEvent(this, heads));
}));
}

Datei anzeigen

@ -0,0 +1,54 @@
package tsp.headdb.event;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import tsp.headdb.api.Head;
import tsp.headdb.database.Category;
import tsp.headdb.database.HeadDatabase;
import java.util.List;
import java.util.Map;
/**
* This event is called AFTER a {@link tsp.headdb.database.HeadDatabase} updates.
* The event is called asynchronously and can not be cancelled.
*
* @author TheSilentPro
*/
public class DatabaseUpdateEvent extends Event {
private final HandlerList handlerList = new HandlerList();
private final HeadDatabase database;
private final Map<Category, List<Head>> heads;
public DatabaseUpdateEvent(HeadDatabase database, Map<Category, List<Head>> heads) {
super(true);
this.database = database;
this.heads = heads;
}
/**
* Retrieve the {@link HeadDatabase} associated with this event
*
* @return The database
*/
public HeadDatabase getDatabase() {
return database;
}
/**
* Retrieve the result of the update
*
* @return The heads fetched from the update
*/
public Map<Category, List<Head>> getHeads() {
return heads;
}
@Override
public HandlerList getHandlers() {
return handlerList;
}
}