Mirror von
https://github.com/TheSilentPro/HeadDB.git
synchronisiert 2024-12-26 19:02:39 +01:00
use impl of set
Dieser Commit ist enthalten in:
Ursprung
796652ed95
Commit
6f415e58ca
@ -104,6 +104,8 @@ public class CommandMain extends HeadDBCommand implements CommandExecutor, TabCo
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
main.open(player);
|
||||
}));
|
||||
|
||||
pane.setButton(getInstance().getConfig().getInt("gui.main.meta.search.slot"), new Button(Utils.getItemFromConfig("gui.main.meta.search.item", Material.DARK_OAK_SIGN), e -> {
|
||||
|
@ -4,19 +4,19 @@ import tsp.headdb.HeadDB;
|
||||
import tsp.warehouse.storage.file.SerializableFileDataManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerStorage extends SerializableFileDataManager<Collection<PlayerData>> {
|
||||
public class PlayerStorage extends SerializableFileDataManager<HashSet<PlayerData>> {
|
||||
|
||||
private final Map<UUID, PlayerData> players = new HashMap<>();
|
||||
|
||||
public PlayerStorage(Storage storage) {
|
||||
super(new File("data/players.data"), storage.getExecutor());
|
||||
public PlayerStorage(HeadDB instance, Storage storage) {
|
||||
super(new File(instance.getDataFolder(), "data/players.data"), storage.getExecutor());
|
||||
}
|
||||
|
||||
public void set(PlayerData data) {
|
||||
@ -42,11 +42,11 @@ public class PlayerStorage extends SerializableFileDataManager<Collection<Player
|
||||
}
|
||||
|
||||
public void backup() {
|
||||
save(players.values()).whenComplete((success, ex) -> HeadDB.getInstance().getLog().debug("Saved " + players.values().size() + " player data!"));
|
||||
save(new HashSet<>(players.values())).whenComplete((success, ex) -> HeadDB.getInstance().getLog().debug("Saved " + players.values().size() + " player data!"));
|
||||
}
|
||||
|
||||
public void suspend() {
|
||||
Boolean saved = save(players.values())
|
||||
Boolean saved = save(new HashSet<>(players.values()))
|
||||
.exceptionally(ex -> {
|
||||
HeadDB.getInstance().getLog().error("Failed to save player data! | Stack Trace: ");
|
||||
ex.printStackTrace();
|
||||
|
@ -1,5 +1,8 @@
|
||||
package tsp.headdb.core.storage;
|
||||
|
||||
import tsp.headdb.HeadDB;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
@ -10,7 +13,8 @@ public class Storage {
|
||||
|
||||
public Storage(int threads) {
|
||||
executor = Executors.newFixedThreadPool(threads, HeadDBThreadFactory.FACTORY);
|
||||
playerStorage = new PlayerStorage(this);
|
||||
validateDataDirectory();
|
||||
playerStorage = new PlayerStorage(HeadDB.getInstance(), this);
|
||||
}
|
||||
|
||||
public PlayerStorage getPlayerStorage() {
|
||||
@ -21,4 +25,9 @@ public class Storage {
|
||||
return executor;
|
||||
}
|
||||
|
||||
private void validateDataDirectory() {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
new File(HeadDB.getInstance().getDataFolder(), "data").mkdir();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public class UpdateTask implements Task {
|
||||
@Override
|
||||
public void run() {
|
||||
HeadAPI.getDatabase().update((time, heads) -> HeadDB.getInstance().getLog().debug("Fetched: " + heads.size() + " Heads | Provider: " + HeadAPI.getDatabase().getRequester().getProvider().name() + " | Time: " + time + "ms (" + TimeUnit.MILLISECONDS.toSeconds(time) + "s)"));
|
||||
//HeadDB.getInstance().getStorage().save();
|
||||
HeadDB.getInstance().getStorage().getPlayerStorage().backup();
|
||||
HeadDB.getInstance().getLog().debug("UpdateTask finished!");
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren