mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
API Breaking
Removed LoggingChangeSet since it wasn't functional and the majority of it was commented out. Migrated a lot of RunnableVal implementations to Suppliers for improved readability and a very small speed improvement.
This commit is contained in:
@ -13,7 +13,6 @@ import com.boydti.fawe.beta.implementation.queue.ParallelQueueExtent;
|
||||
import com.sk89q.worldedit.util.Identifiable;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.logging.LoggingChangeSet;
|
||||
import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory;
|
||||
import com.boydti.fawe.object.FaweLimit;
|
||||
import com.boydti.fawe.object.HistoryExtent;
|
||||
@ -80,7 +79,7 @@ public class EditSessionBuilder {
|
||||
public EditSessionBuilder(@Nonnull World world) {
|
||||
checkNotNull(world);
|
||||
this.world = world;
|
||||
this.worldName = Fawe.imp().getWorldName(world);
|
||||
this.worldName = world.getName();
|
||||
}
|
||||
|
||||
public EditSessionBuilder(World world, String worldName) {
|
||||
@ -389,13 +388,7 @@ public class EditSessionBuilder {
|
||||
if (command != null && changeSet instanceof RollbackOptimizedHistory) {
|
||||
((RollbackOptimizedHistory) changeSet).setCommand(this.command);
|
||||
}
|
||||
if (changeSet instanceof NullChangeSet && Fawe.imp().getBlocksHubApi() != null && player != null) {
|
||||
changeSet = LoggingChangeSet.wrap(player, changeSet);
|
||||
}
|
||||
if (!(changeSet instanceof NullChangeSet)) {
|
||||
if (!(changeSet instanceof LoggingChangeSet) && player != null && Fawe.imp().getBlocksHubApi() != null) {
|
||||
changeSet = LoggingChangeSet.wrap(player, changeSet);
|
||||
}
|
||||
if (this.blockBag != null) {
|
||||
System.out.println("TODO implement block bag as IBatchProcessor");
|
||||
changeSet = new BlockBagChangeSet(changeSet, blockBag, limit.INVENTORY_MODE == 1);
|
||||
|
@ -89,6 +89,7 @@ import net.jpountz.lz4.LZ4Factory;
|
||||
import net.jpountz.lz4.LZ4FastDecompressor;
|
||||
import net.jpountz.lz4.LZ4InputStream;
|
||||
import net.jpountz.lz4.LZ4Utils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MainUtil {
|
||||
|
||||
@ -371,15 +372,11 @@ public class MainUtil {
|
||||
return new FaweInputStream(new FastBufferedInputStream(is));
|
||||
}
|
||||
|
||||
public static URL upload(UUID uuid, String file, String extension, final RunnableVal<OutputStream> writeTask) {
|
||||
public static URL upload(UUID uuid, String file, String extension, @NotNull final RunnableVal<OutputStream> writeTask) {
|
||||
return upload(Settings.IMP.WEB.URL, uuid != null, uuid != null ? uuid.toString() : null, file, extension, writeTask);
|
||||
}
|
||||
|
||||
public static URL upload(String urlStr, boolean save, String uuid, String file, String extension, final RunnableVal<OutputStream> writeTask) {
|
||||
if (writeTask == null) {
|
||||
getLogger(MainUtil.class).debug("Write task cannot be null");
|
||||
return null;
|
||||
}
|
||||
public static URL upload(String urlStr, boolean save, String uuid, String file, String extension, @NotNull final RunnableVal<OutputStream> writeTask) {
|
||||
String filename = (file == null ? "plot" : file) + (extension != null ? "." + extension : "");
|
||||
uuid = uuid == null ? UUID.randomUUID().toString() : uuid;
|
||||
final String website;
|
||||
|
@ -22,7 +22,7 @@ public abstract class TaskManager {
|
||||
|
||||
public static TaskManager IMP;
|
||||
|
||||
private ForkJoinPool pool = new ForkJoinPool();
|
||||
private final ForkJoinPool pool = new ForkJoinPool();
|
||||
|
||||
/**
|
||||
* Run a repeating task on the main thread
|
||||
@ -307,6 +307,22 @@ public abstract class TaskManager {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a task on the main thread when the TPS is high enough, and wait for execution to finish:<br>
|
||||
* - Useful if you need to access something from the Bukkit API from another thread<br>
|
||||
* - Usually wait time is around 25ms<br>
|
||||
*/
|
||||
public <T> T syncWhenFree(@NotNull final Supplier<T> supplier) {
|
||||
if (Fawe.isMainThread()) {
|
||||
return supplier.get();
|
||||
}
|
||||
try {
|
||||
return Fawe.get().getQueueHandler().sync(supplier).get();
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Quickly run a task on the main thread, and wait for execution to finish:<br>
|
||||
|
Reference in New Issue
Block a user