refactor: Also deprecated IMP for DBHandler

Dieser Commit ist enthalten in:
NotMyFault 2021-12-23 15:59:05 +01:00
Ursprung ca5ad58f01
Commit 28079e8129
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 158F5701A6AAD00C
7 geänderte Dateien mit 24 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -67,7 +67,7 @@ public enum FaweCache implements Trimable {
/**
* @since 2.0.0
*/
INSTANCE;// singleton
INSTANCE;
private static final Logger LOGGER = LogManagerCompat.getLogger();

Datei anzeigen

@ -81,7 +81,7 @@ public class InspectBrush extends BrushTool {
final int y = target.getBlockY();
final int z = target.getBlockZ();
World world = player.getWorld();
RollbackDatabase db = DBHandler.IMP.getDatabase(world);
RollbackDatabase db = DBHandler.dbHandler().getDatabase(world);
int count = 0;
for (Supplier<RollbackOptimizedHistory> supplier : db.getEdits(target, false)) {
count++;

Datei anzeigen

@ -9,12 +9,28 @@ import java.util.concurrent.ConcurrentHashMap;
public class DBHandler {
private static final Logger LOGGER = LogManagerCompat.getLogger();
/**
* @deprecated Use {@link #dbHandler()} instead.
*/
@Deprecated(forRemoval = true, since = "2.0.0")
public static final DBHandler IMP = new DBHandler();
private static final Logger LOGGER = LogManagerCompat.getLogger();
private static DBHandler INSTANCE;
private final Map<World, RollbackDatabase> databases = new ConcurrentHashMap<>(8, 0.9f, 1);
/**
* Get an instance of the DBHandler.
*
* @return an instance of the DBHandler.
* @since 2.0.0
*/
public static DBHandler dbHandler() {
if (INSTANCE == null) {
INSTANCE = new DBHandler();
}
return INSTANCE;
}
public RollbackDatabase getDatabase(World world) {
RollbackDatabase database = databases.get(world);
if (database != null) {

Datei anzeigen

@ -68,7 +68,7 @@ public class ProvideBindings extends Bindings {
@Binding
public RollbackDatabase database(World world) {
return DBHandler.IMP.getDatabase(world);
return DBHandler.dbHandler().getDatabase(world);
}
@AllowedRegion(FaweMaskManager.MaskType.OWNER)

Datei anzeigen

@ -121,7 +121,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
public void delete() {
deleteFiles();
if (Settings.settings().HISTORY.USE_DATABASE) {
RollbackDatabase db = DBHandler.IMP.getDatabase(getWorld());
RollbackDatabase db = DBHandler.dbHandler().getDatabase(getWorld());
db.delete(uuid, index);
}
}

Datei anzeigen

@ -99,7 +99,7 @@ public class RollbackOptimizedHistory extends DiskStorageHistory {
public void close() throws IOException {
super.close();
// Save to DB
RollbackDatabase db = DBHandler.IMP.getDatabase(getWorld());
RollbackDatabase db = DBHandler.dbHandler().getDatabase(getWorld());
if (db != null) {
db.logEdit(this);
}

Datei anzeigen

@ -35,10 +35,6 @@ public class WEManager {
public static WEManager IMP = new WEManager();
private final ArrayDeque<FaweMaskManager> managers = new ArrayDeque<>();
private WEManager() {
INSTANCE = this;
}
/**
* Get an instance of the WEManager.
*