Skip to content

Commit

Permalink
fix: 二进制兼容 (#997)
Browse files Browse the repository at this point in the history
  • Loading branch information
StarWishsama committed Jan 15, 2025
1 parent 3e68e4a commit bf88afc
Showing 1 changed file with 38 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,15 @@ public static boolean isBlockPendingRemove(@Nonnull Block block) {
return false;
}

public static void requestLoad(ADataContainer data) {
public static void requestLoad(ASlimefunDataContainer data) {
if (data instanceof SlimefunBlockData blockData) {
requestLoad(blockData);
} else if (data instanceof SlimefunUniversalData uniData) {
requestLoad(uniData);
}
}

public static void requestLoad(SlimefunBlockData data) {
if (data.isDataLoaded()) {
return;
}
Expand All @@ -240,25 +248,36 @@ public static void requestLoad(ADataContainer data) {
loadingData.add(data);
}

if (data instanceof SlimefunBlockData blockData) {
Slimefun.getDatabaseManager()
.getBlockDataController()
.loadBlockDataAsync(blockData, new IAsyncReadCallback<>() {
@Override
public void onResult(SlimefunBlockData result) {
loadingData.remove(data);
}
});
} else if (data instanceof SlimefunUniversalData uniData) {
Slimefun.getDatabaseManager()
.getBlockDataController()
.loadUniversalDataAsync(uniData, new IAsyncReadCallback<>() {
@Override
public void onResult(SlimefunUniversalData result) {
loadingData.remove(data);
}
});
Slimefun.getDatabaseManager().getBlockDataController().loadBlockDataAsync(data, new IAsyncReadCallback<>() {
@Override
public void onResult(SlimefunBlockData result) {
loadingData.remove(data);
}
});
}

public static void requestLoad(SlimefunUniversalBlockData data) {
if (data.isDataLoaded()) {
return;
}

if (loadingData.contains(data)) {
return;
}

synchronized (loadingData) {
if (loadingData.contains(data)) {
return;
}
loadingData.add(data);
}

Slimefun.getDatabaseManager().getBlockDataController().loadUniversalDataAsync(data, new IAsyncReadCallback<>() {
@Override
public void onResult(SlimefunUniversalData result) {
loadingData.remove(data);
}
});
}

public static void executeAfterLoad(ASlimefunDataContainer data, Runnable execute, boolean runOnMainThread) {
Expand Down

0 comments on commit bf88afc

Please sign in to comment.