geforkt von Mirrors/FastAsyncWorldEdit
refactor: Also deprecated IMP
for DBHandler
Dieser Commit ist enthalten in:
Ursprung
ca5ad58f01
Commit
28079e8129
@ -67,7 +67,7 @@ public enum FaweCache implements Trimable {
|
||||
/**
|
||||
* @since 2.0.0
|
||||
*/
|
||||
INSTANCE;// singleton
|
||||
INSTANCE;
|
||||
|
||||
private static final Logger LOGGER = LogManagerCompat.getLogger();
|
||||
|
||||
|
@ -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++;
|
||||
|
@ -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) {
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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.
|
||||
*
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren