mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
commanding-pipeline diff
This commit is contained in:
@ -1,40 +1,50 @@
|
||||
package com.boydti.fawe.util;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.beta.IQueueExtent;
|
||||
import com.boydti.fawe.beta.implementation.ParallelQueueExtent;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
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;
|
||||
import com.boydti.fawe.object.NullChangeSet;
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.object.brush.visualization.VirtualWorld;
|
||||
import com.boydti.fawe.object.changeset.BlockBagChangeSet;
|
||||
import com.boydti.fawe.object.changeset.DiskStorageHistory;
|
||||
import com.boydti.fawe.object.changeset.FaweChangeSet;
|
||||
import com.boydti.fawe.object.changeset.MemoryOptimizedHistory;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.boydti.fawe.object.extent.FaweRegionExtent;
|
||||
import com.boydti.fawe.object.extent.MultiRegionExtent;
|
||||
import com.boydti.fawe.object.extent.NullExtent;
|
||||
import com.boydti.fawe.object.extent.SingleRegionExtent;
|
||||
import com.boydti.fawe.object.extent.SlowExtent;
|
||||
import com.boydti.fawe.object.extent.StripNBTExtent;
|
||||
import com.boydti.fawe.wrappers.WorldWrapper;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.eventbus.EventBus;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import java.util.UUID;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class EditSessionBuilder {
|
||||
private World world;
|
||||
private String worldName;
|
||||
private Extent extent;
|
||||
private Player player;
|
||||
private FaweLimit limit;
|
||||
private FaweChangeSet changeSet;
|
||||
@ -45,6 +55,7 @@ public class EditSessionBuilder {
|
||||
private Boolean combineStages;
|
||||
private EventBus eventBus;
|
||||
private BlockBag blockBag;
|
||||
private boolean threaded = true;
|
||||
private EditSessionEvent event;
|
||||
|
||||
/**
|
||||
@ -65,14 +76,12 @@ public class EditSessionBuilder {
|
||||
public EditSessionBuilder(@Nonnull World world) {
|
||||
checkNotNull(world);
|
||||
this.world = world;
|
||||
this.extent = world;
|
||||
this.worldName = Fawe.imp().getWorldName(world);
|
||||
}
|
||||
|
||||
public EditSessionBuilder(World world, String worldName) {
|
||||
if (world == null && worldName == null) throw new NullPointerException("Both world and worldname cannot be null");
|
||||
this.world = world;
|
||||
this.extent = world;
|
||||
this.worldName = worldName;
|
||||
}
|
||||
|
||||
@ -84,12 +93,12 @@ public class EditSessionBuilder {
|
||||
|
||||
public EditSessionBuilder player(@Nullable Player player) {
|
||||
this.player = player;
|
||||
return this;
|
||||
return setDirty();
|
||||
}
|
||||
|
||||
public EditSessionBuilder limit(@Nullable FaweLimit limit) {
|
||||
this.limit = limit;
|
||||
return this;
|
||||
return setDirty();
|
||||
}
|
||||
|
||||
public EditSessionBuilder limitUnlimited() {
|
||||
@ -101,12 +110,12 @@ public class EditSessionBuilder {
|
||||
limitUnlimited();
|
||||
FaweLimit tmp = fp.getLimit();
|
||||
limit.INVENTORY_MODE = tmp.INVENTORY_MODE;
|
||||
return this;
|
||||
return setDirty();
|
||||
}
|
||||
|
||||
public EditSessionBuilder changeSet(@Nullable FaweChangeSet changeSet) {
|
||||
this.changeSet = changeSet;
|
||||
return this;
|
||||
return setDirty();
|
||||
}
|
||||
|
||||
public EditSessionBuilder changeSetNull() {
|
||||
@ -117,7 +126,7 @@ public class EditSessionBuilder {
|
||||
checkNotNull(world);
|
||||
this.world = world;
|
||||
this.worldName = world.getName();
|
||||
return this;
|
||||
return setDirty();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -146,23 +155,23 @@ public class EditSessionBuilder {
|
||||
} else {
|
||||
this.changeSet = new MemoryOptimizedHistory(world);
|
||||
}
|
||||
return this;
|
||||
return setDirty();
|
||||
}
|
||||
|
||||
public EditSessionBuilder allowedRegions(@Nullable Region[] allowedRegions) {
|
||||
this.allowedRegions = allowedRegions;
|
||||
return this;
|
||||
return setDirty();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public EditSessionBuilder allowedRegions(@Nullable RegionWrapper[] allowedRegions) {
|
||||
this.allowedRegions = allowedRegions;
|
||||
return this;
|
||||
return setDirty();
|
||||
}
|
||||
|
||||
public EditSessionBuilder allowedRegions(@Nullable RegionWrapper allowedRegion) {
|
||||
this.allowedRegions = allowedRegion == null ? null : allowedRegion.toArray();
|
||||
return this;
|
||||
return setDirty();
|
||||
}
|
||||
|
||||
public EditSessionBuilder allowedRegionsEverywhere() {
|
||||
@ -171,47 +180,45 @@ public class EditSessionBuilder {
|
||||
|
||||
public EditSessionBuilder autoQueue(@Nullable Boolean autoQueue) {
|
||||
this.autoQueue = autoQueue;
|
||||
return this;
|
||||
return setDirty();
|
||||
}
|
||||
|
||||
public EditSessionBuilder fastmode(@Nullable Boolean fastmode) {
|
||||
this.fastmode = fastmode;
|
||||
return this;
|
||||
return setDirty();
|
||||
}
|
||||
|
||||
public EditSessionBuilder checkMemory(@Nullable Boolean checkMemory) {
|
||||
this.checkMemory = checkMemory;
|
||||
return this;
|
||||
return setDirty();
|
||||
}
|
||||
|
||||
public EditSessionBuilder combineStages(@Nullable Boolean combineStages) {
|
||||
this.combineStages = combineStages;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EditSessionBuilder extent(@Nullable Extent extent) {
|
||||
this.extent = extent;
|
||||
return this;
|
||||
return setDirty();
|
||||
}
|
||||
|
||||
public EditSessionBuilder blockBag(@Nullable BlockBag blockBag) {
|
||||
this.blockBag = blockBag;
|
||||
return this;
|
||||
return setDirty();
|
||||
}
|
||||
|
||||
public EditSessionBuilder eventBus(@Nullable EventBus eventBus) {
|
||||
this.eventBus = eventBus;
|
||||
return this;
|
||||
return setDirty();
|
||||
}
|
||||
|
||||
public EditSessionBuilder event(@Nullable EditSessionEvent event) {
|
||||
this.event = event;
|
||||
return setDirty();
|
||||
}
|
||||
|
||||
private EditSessionBuilder setDirty() {
|
||||
compiled = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
private boolean wrapped;
|
||||
|
||||
private AbstractDelegateExtent wrapExtent(final AbstractDelegateExtent extent, final EventBus eventBus, EditSessionEvent event, final EditSession.Stage stage) {
|
||||
private Extent wrapExtent(final Extent extent, final EventBus eventBus, EditSessionEvent event, final EditSession.Stage stage) {
|
||||
event = event.clone(stage);
|
||||
event.setExtent(extent);
|
||||
eventBus.post(event);
|
||||
@ -222,16 +229,16 @@ public class EditSessionBuilder {
|
||||
if(toReturn instanceof com.sk89q.worldedit.extent.NullExtent) {
|
||||
return new NullExtent(toReturn, FaweException.MANUAL);
|
||||
}
|
||||
if (!(toReturn instanceof AbstractDelegateExtent)) {
|
||||
Fawe.debug("Extent " + toReturn + " must be AbstractDelegateExtent");
|
||||
return extent;
|
||||
}
|
||||
// if (!(toReturn instanceof AbstractDelegateExtent)) {
|
||||
// Fawe.debug("Extent " + toReturn + " must be AbstractDelegateExtent");
|
||||
// return extent;
|
||||
// }
|
||||
if (toReturn != extent) {
|
||||
String className = toReturn.getClass().getName().toLowerCase();
|
||||
for (String allowed : Settings.IMP.EXTENT.ALLOWED_PLUGINS) {
|
||||
if (className.contains(allowed.toLowerCase())) {
|
||||
this.wrapped = true;
|
||||
return (AbstractDelegateExtent) toReturn;
|
||||
return toReturn;
|
||||
}
|
||||
}
|
||||
if (Settings.IMP.EXTENT.DEBUG) {
|
||||
@ -252,13 +259,16 @@ public class EditSessionBuilder {
|
||||
|
||||
private FaweChangeSet changeTask;
|
||||
private int maxY;
|
||||
private HistoryExtent history;
|
||||
private AbstractDelegateExtent bypassHistory;
|
||||
private AbstractDelegateExtent bypassAll;
|
||||
private Extent bypassHistory;
|
||||
private Extent bypassAll;
|
||||
private Extent extent;
|
||||
private boolean compiled;
|
||||
private boolean wrapped;
|
||||
|
||||
public EditSessionBuilder compile() {
|
||||
if (extent != null) return this;
|
||||
if (compiled) return this;
|
||||
|
||||
compiled = true;
|
||||
wrapped = false;
|
||||
if (world == null && !this.worldName.isEmpty()) {
|
||||
world = FaweAPI.getWorld(this.worldName);
|
||||
@ -302,109 +312,126 @@ public class EditSessionBuilder {
|
||||
}
|
||||
// this.originalLimit = limit;
|
||||
this.blockBag = limit.INVENTORY_MODE != 0 ? blockBag : null;
|
||||
// this.limit = limit.copy();
|
||||
this.limit = limit.copy();
|
||||
|
||||
// if (queue == null) {
|
||||
// boolean placeChunks = this.fastmode || this.limit.FAST_PLACEMENT;
|
||||
// World unwrapped = WorldWrapper.unwrap(world);
|
||||
// if (unwrapped instanceof IQueueExtent) {
|
||||
// queue = (IQueueExtent) unwrapped;
|
||||
// } else if (unwrapped instanceof MCAWorld) {
|
||||
// queue = ((MCAWorld) unwrapped).getQueue();
|
||||
// } else if (player != null && world.equals(player.getWorld())) {
|
||||
// queue = player.getIQueueExtent(placeChunks, autoQueue);
|
||||
// } else {
|
||||
// queue = SetQueue.IMP.getNewQueue(world, placeChunks, autoQueue);
|
||||
// }
|
||||
// }
|
||||
// if (combineStages == null) {
|
||||
// combineStages =
|
||||
// // If it's enabled in the settings
|
||||
// Settings.IMP.HISTORY.COMBINE_STAGES
|
||||
// // If fast placement is disabled, it's slower to perform a copy on each chunk
|
||||
// && this.limit.FAST_PLACEMENT
|
||||
// // If the specific queue doesn't support it
|
||||
// && queue.supports(IQueueExtent.Capability.CHANGE_TASKS)
|
||||
// // If the edit uses items from the inventory we can't use a delayed task
|
||||
// && this.blockBag == null;
|
||||
// }
|
||||
// if (!Settings.IMP.QUEUE.PROGRESS.DISPLAY.equalsIgnoreCase("false") && player != null) {
|
||||
// switch (Settings.IMP.QUEUE.PROGRESS.DISPLAY.toLowerCase()) {
|
||||
// case "chat":
|
||||
// this.queue.setProgressTask(new ChatProgressTracker(player));
|
||||
// break;
|
||||
// case "title":
|
||||
// case "true":
|
||||
// default:
|
||||
// this.queue.setProgressTask(new DefaultProgressTracker(player));
|
||||
// }
|
||||
// }
|
||||
// this.bypassAll = wrapExtent(new FastWorldEditExtent(world, queue), eventBus, event, EditSession.Stage.BEFORE_CHANGE);
|
||||
// this.bypassHistory = (this.extent = wrapExtent(bypassAll, eventBus, event, EditSession.Stage.BEFORE_REORDER));
|
||||
// if (!this.fastmode || changeSet != null) {
|
||||
// if (changeSet == null) {
|
||||
// if (Settings.IMP.HISTORY.USE_DISK) {
|
||||
// UUID uuid = player == null ? EditSession.CONSOLE : player.getUUID();
|
||||
// if (Settings.IMP.HISTORY.USE_DATABASE) {
|
||||
// changeSet = new RollbackOptimizedHistory(world, uuid);
|
||||
// } else {
|
||||
// changeSet = new DiskStorageHistory(world, uuid);
|
||||
// }
|
||||
// } else if (combineStages && Settings.IMP.HISTORY.COMPRESSION_LEVEL == 0 && !(queue instanceof MCAQueue)) {
|
||||
// changeSet = new CPUOptimizedChangeSet(world);
|
||||
// } else {
|
||||
// changeSet = new MemoryOptimizedHistory(world);
|
||||
if (extent == null) {
|
||||
IQueueExtent queue = null;
|
||||
World unwrapped = WorldWrapper.unwrap(world);
|
||||
boolean placeChunks = this.fastmode || this.limit.FAST_PLACEMENT;
|
||||
|
||||
if (placeChunks) {
|
||||
if (unwrapped instanceof IQueueExtent) {
|
||||
extent = queue = (IQueueExtent) unwrapped;
|
||||
} else if (Settings.IMP.QUEUE.PARALLEL_THREADS > 1 && threaded) {
|
||||
ParallelQueueExtent parallel = new ParallelQueueExtent(Fawe.get().getQueueHandler(), world);
|
||||
queue = parallel.getExtent();
|
||||
extent = parallel;
|
||||
} else {
|
||||
System.out.println("FAWE is in single threaded mode (performance reduced)");
|
||||
extent = queue = Fawe.get().getQueueHandler().getQueue(world);
|
||||
}
|
||||
} else {
|
||||
extent = world;
|
||||
}
|
||||
Extent root = extent;
|
||||
if (combineStages == null) {
|
||||
combineStages =
|
||||
// If it's enabled in the settings
|
||||
Settings.IMP.HISTORY.COMBINE_STAGES
|
||||
// If fast placement is disabled, it's slower to perform a copy on each chunk
|
||||
&& this.limit.FAST_PLACEMENT
|
||||
// If the edit uses items from the inventory we can't use a delayed task
|
||||
&& this.blockBag == null;
|
||||
}
|
||||
if (!Settings.IMP.QUEUE.PROGRESS.DISPLAY.equalsIgnoreCase("false") && player != null) {
|
||||
System.out.println("TODO add progress display");
|
||||
// switch (Settings.IMP.QUEUE.PROGRESS.DISPLAY.toLowerCase()) {
|
||||
// case "chat":
|
||||
// this.queue.setProgressTask(new ChatProgressTracker(player));
|
||||
// break;
|
||||
// case "title":
|
||||
// case "true":
|
||||
// default:
|
||||
// this.queue.setProgressTask(new DefaultProgressTracker(player));
|
||||
// }
|
||||
// }
|
||||
// if (this.limit.SPEED_REDUCTION > 0) {
|
||||
// this.bypassHistory = new SlowExtent(this.bypassHistory, this.limit.SPEED_REDUCTION);
|
||||
// }
|
||||
// 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) {
|
||||
// changeSet = new BlockBagChangeSet(changeSet, blockBag, limit.INVENTORY_MODE == 1);
|
||||
// }
|
||||
// if (combineStages) {
|
||||
// changeTask = changeSet;
|
||||
// changeSet.addChangeTask(queue);
|
||||
// } else {
|
||||
// this.extent = (history = new HistoryExtent(bypassHistory, changeSet, queue));
|
||||
//// if (this.blockBag != null) {
|
||||
//// this.extent = new BlockBagExtent(this.extent, blockBag, limit.INVENTORY_MODE == 1);
|
||||
//// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (allowedRegions == null) {
|
||||
// if (player != null && !player.hasPermission("fawe.bypass") && !player.hasPermission("fawe.bypass.regions") && !(queue instanceof VirtualWorld)) {
|
||||
// allowedRegions = player.getCurrentRegions();
|
||||
// }
|
||||
// }
|
||||
// this.maxY = world == null ? 255 : world.getMaxY();
|
||||
// if (allowedRegions != null) {
|
||||
// if (allowedRegions.length == 0) {
|
||||
// this.extent = new NullExtent(this.extent, FaweException.NO_REGION);
|
||||
// } else {
|
||||
// this.extent = new ProcessedWEExtent(this.extent, this.limit);
|
||||
// if (allowedRegions.length == 1) {
|
||||
// this.extent = new SingleRegionExtent(this.extent, this.limit, allowedRegions[0]);
|
||||
// } else {
|
||||
// this.extent = new MultiRegionExtent(this.extent, this.limit, allowedRegions);
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// this.extent = new HeightBoundExtent(this.extent, this.limit, 0, maxY);
|
||||
// }
|
||||
// if (this.limit.STRIP_NBT != null && !this.limit.STRIP_NBT.isEmpty()) {
|
||||
// this.extent = new StripNBTExtent(this.extent, this.limit.STRIP_NBT);
|
||||
// }
|
||||
// this.extent = wrapExtent(this.extent, eventBus, event, EditSession.Stage.BEFORE_HISTORY);
|
||||
// return this;
|
||||
}
|
||||
extent = this.bypassAll = wrapExtent(extent, eventBus, event, EditSession.Stage.BEFORE_CHANGE);
|
||||
this.bypassHistory = (this.extent = wrapExtent(bypassAll, eventBus, event, EditSession.Stage.BEFORE_REORDER));
|
||||
if (!this.fastmode || changeSet != null) {
|
||||
if (changeSet == null) {
|
||||
if (Settings.IMP.HISTORY.USE_DISK) {
|
||||
UUID uuid = player == null ? EditSession.CONSOLE : player.getUniqueId();
|
||||
if (Settings.IMP.HISTORY.USE_DATABASE) {
|
||||
changeSet = new RollbackOptimizedHistory(world, uuid);
|
||||
} else {
|
||||
changeSet = new DiskStorageHistory(world, uuid);
|
||||
}
|
||||
// } else if (combineStages && Settings.IMP.HISTORY.COMPRESSION_LEVEL == 0) {
|
||||
// changeSet = new CPUOptimizedChangeSet(world);
|
||||
} else {
|
||||
if (combineStages && Settings.IMP.HISTORY.COMPRESSION_LEVEL == 0) {
|
||||
System.out.println("TODO add CPUOptimizedChangeSet");
|
||||
}
|
||||
changeSet = new MemoryOptimizedHistory(world);
|
||||
}
|
||||
}
|
||||
if (this.limit.SPEED_REDUCTION > 0) {
|
||||
this.extent = this.bypassHistory = new SlowExtent(this.bypassHistory, this.limit.SPEED_REDUCTION);
|
||||
}
|
||||
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);
|
||||
}
|
||||
if (combineStages) {
|
||||
changeTask = changeSet;
|
||||
this.extent = extent.enableHistory(changeSet);
|
||||
} else {
|
||||
this.extent = (new HistoryExtent(extent, changeSet));
|
||||
// if (this.blockBag != null) {
|
||||
// this.extent = new BlockBagExtent(this.extent, blockBag, limit.INVENTORY_MODE == 1);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
if (allowedRegions == null) {
|
||||
if (player != null && !player.hasPermission("fawe.bypass") && !player.hasPermission("fawe.bypass.regions") && !(root instanceof VirtualWorld)) {
|
||||
allowedRegions = player.getCurrentRegions();
|
||||
}
|
||||
}
|
||||
this.maxY = world == null ? 255 : world.getMaxY();
|
||||
FaweRegionExtent regionExtent = null;
|
||||
if (allowedRegions != null) {
|
||||
if (allowedRegions.length == 0) {
|
||||
regionExtent = new NullExtent(this.extent, FaweException.NO_REGION);
|
||||
} else {
|
||||
// this.extent = new ProcessedWEExtent(this.extent, this.limit);
|
||||
if (allowedRegions.length == 1) {
|
||||
regionExtent = new SingleRegionExtent(this.extent, this.limit, allowedRegions[0]);
|
||||
} else {
|
||||
regionExtent = new MultiRegionExtent(this.extent, this.limit, allowedRegions);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// this.extent = new HeightBoundExtent(this.extent, this.limit, 0, maxY);
|
||||
}
|
||||
if (regionExtent != null && queue != null && combineStages) {
|
||||
queue.addProcessor(regionExtent);
|
||||
} else if (regionExtent != null) {
|
||||
this.extent = regionExtent;
|
||||
}
|
||||
if (this.limit.STRIP_NBT != null && !this.limit.STRIP_NBT.isEmpty()) {
|
||||
System.out.println("TODO add batch processor for strip nbt");
|
||||
this.extent = new StripNBTExtent(this.extent, this.limit.STRIP_NBT);
|
||||
}
|
||||
this.extent = wrapExtent(this.extent, eventBus, event, EditSession.Stage.BEFORE_HISTORY);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -415,10 +442,6 @@ public class EditSessionBuilder {
|
||||
return new EditSession(this);
|
||||
}
|
||||
|
||||
public Extent getExtent() {
|
||||
return extent;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
@ -427,6 +450,10 @@ public class EditSessionBuilder {
|
||||
return worldName;
|
||||
}
|
||||
|
||||
public Extent getExtent() {
|
||||
return extent != null ? extent : world;
|
||||
}
|
||||
|
||||
public boolean isWrapped() {
|
||||
return wrapped;
|
||||
}
|
||||
@ -435,23 +462,16 @@ public class EditSessionBuilder {
|
||||
return fastmode;
|
||||
}
|
||||
|
||||
public HistoryExtent getHistory() {
|
||||
return history;
|
||||
}
|
||||
|
||||
public AbstractDelegateExtent getBypassHistory() {
|
||||
public Extent getBypassHistory() {
|
||||
return bypassHistory;
|
||||
}
|
||||
|
||||
public AbstractDelegateExtent getBypassAll() {
|
||||
public Extent getBypassAll() {
|
||||
return bypassAll;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public FaweLimit getLimit() {
|
||||
if (limit == null) {
|
||||
return FaweLimit.MAX;
|
||||
}
|
||||
return limit;
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,8 @@ public class FaweTimer implements Runnable {
|
||||
if (tick < lastGetTPSTick + tickInterval) {
|
||||
return lastGetTPSValue;
|
||||
}
|
||||
double total = Arrays.stream(history).sum();
|
||||
double total = 0;
|
||||
for (double v : history) total += v;
|
||||
lastGetTPSValue = total / history.length;
|
||||
lastGetTPSTick = tick;
|
||||
return lastGetTPSValue;
|
||||
|
@ -1,5 +1,9 @@
|
||||
package com.boydti.fawe.util;
|
||||
|
||||
import com.boydti.fawe.object.io.FastByteArrayOutputStream;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
@ -10,6 +14,33 @@ import java.util.stream.Collectors;
|
||||
public class ImgurUtility {
|
||||
public static final String CLIENT_ID = "50e34b65351eb07";
|
||||
|
||||
public static URL uploadImage(File file) throws IOException {
|
||||
// was used until a merge deleted all the CFI/schematics functionality TODO NOT IMPLEMENTED
|
||||
return uploadImage(new FileInputStream(file));
|
||||
}
|
||||
|
||||
public static URL uploadImage(InputStream inputStream) throws IOException {
|
||||
// was used until a merge deleted all the CFI/schematics functionality TODO NOT IMPLEMENTED
|
||||
inputStream = new BufferedInputStream(inputStream);
|
||||
FastByteArrayOutputStream baos = new FastByteArrayOutputStream(Short.MAX_VALUE);
|
||||
int i;
|
||||
while ((i = inputStream.read()) != -1) {
|
||||
baos.write(i);
|
||||
}
|
||||
baos.flush();
|
||||
return uploadImage(baos.toByteArray());
|
||||
}
|
||||
|
||||
public static URL uploadImage(byte[] image) throws IOException {
|
||||
// was used until a merge deleted all the CFI/schematics functionality TODO NOT IMPLEMENTED
|
||||
String json = getImgurContent(CLIENT_ID, image);
|
||||
Gson gson = new Gson();
|
||||
JsonObject obj = gson.fromJson(json, JsonObject.class);
|
||||
JsonObject data = obj.get("data").getAsJsonObject();
|
||||
String link = data.get("link").getAsString();
|
||||
return new URL(link);
|
||||
}
|
||||
|
||||
public static String getImgurContent(String clientID, byte[] image) throws IOException {
|
||||
String imageString = Base64.getEncoder().encodeToString(image);
|
||||
URL url = new URL("https://api.imgur.com/3/image");
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.boydti.fawe.util;
|
||||
|
||||
import static java.lang.System.arraycopy;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
@ -26,7 +24,17 @@ import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import java.awt.Graphics2D;
|
||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||
import net.jpountz.lz4.LZ4BlockOutputStream;
|
||||
import net.jpountz.lz4.LZ4Compressor;
|
||||
import net.jpountz.lz4.LZ4Factory;
|
||||
import net.jpountz.lz4.LZ4FastDecompressor;
|
||||
import net.jpountz.lz4.LZ4InputStream;
|
||||
import net.jpountz.lz4.LZ4Utils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
@ -75,27 +83,11 @@ import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.Inflater;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.imageio.ImageIO;
|
||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||
import net.jpountz.lz4.LZ4BlockOutputStream;
|
||||
import net.jpountz.lz4.LZ4Compressor;
|
||||
import net.jpountz.lz4.LZ4Factory;
|
||||
import net.jpountz.lz4.LZ4FastDecompressor;
|
||||
import net.jpountz.lz4.LZ4InputStream;
|
||||
import net.jpountz.lz4.LZ4Utils;
|
||||
|
||||
import static java.lang.System.arraycopy;
|
||||
|
||||
public class MainUtil {
|
||||
|
||||
public static void sendAdmin(final String s) {
|
||||
for (final Player player : Fawe.get().getCachedPlayers()) {
|
||||
if (player.hasPermission("fawe.admin")) {
|
||||
player.print(s);
|
||||
}
|
||||
}
|
||||
Fawe.debug(s);
|
||||
}
|
||||
|
||||
public static List<String> filter(String prefix, List<String> suggestions) {
|
||||
if (prefix.isEmpty()) {
|
||||
return suggestions;
|
||||
@ -754,7 +746,6 @@ public class MainUtil {
|
||||
if (time >= 33868800) {
|
||||
int years = (int) (time / 33868800);
|
||||
int time1 = years * 33868800;
|
||||
System.out.println(time1);
|
||||
time -= time1;
|
||||
toreturn.append(years + "y ");
|
||||
}
|
||||
|
@ -69,10 +69,10 @@ public class TextureUtil implements TextureHolder {
|
||||
private BiomeColor[] biomes = new BiomeColor[]{
|
||||
// ID Name Temperature, rainfall, grass, foliage colors
|
||||
// - note: the colors here are just placeholders, they are computed in the program
|
||||
new BiomeColor(0, "ocean", 0.5f, 0.5f, 0x92BD59, 7842607),
|
||||
new BiomeColor(0, "ocean", 0.5f, 0.5f, 0x92BD59, 0x77AB2F),
|
||||
// default values of temp and rain
|
||||
new BiomeColor(1, "plains", 0.8f, 0.4f, 0x92BD59, 7842607),
|
||||
new BiomeColor(2, "desert", 2.0f, 0.0f, 0x92BD59, 7842607),
|
||||
new BiomeColor(1, "plains", 0.8f, 0.4f, 0x92BD59, 0x77AB2F),
|
||||
new BiomeColor(2, "desert", 2.0f, 0.0f, 0x92BD59, 0x77AB2F),
|
||||
new BiomeColor(3, "mountains", 0.2f, 0.3f, 0x92BD59, 0x77AB2F),
|
||||
new BiomeColor(4, "forest", 0.7f, 0.8f, 0x92BD59, 0x77AB2F),
|
||||
new BiomeColor(5, "taiga", 0.25f, 0.8f, 0x92BD59, 0x77AB2F),
|
||||
@ -97,7 +97,7 @@ public class TextureUtil implements TextureHolder {
|
||||
new BiomeColor(22, "jungle_hills", 0.95f, 0.9f, 0x92BD59, 0x77AB2F),
|
||||
new BiomeColor(23, "jungle_edge", 0.95f, 0.8f, 0x92BD59, 0x77AB2F),
|
||||
new BiomeColor(24, "deep_ocean", 0.5f, 0.5f, 0x92BD59, 0x77AB2F),
|
||||
new BiomeColor(25, "stone_shore", 0.2f, 0.3f, 9616729, 0x77AB2F),
|
||||
new BiomeColor(25, "stone_shore", 0.2f, 0.3f, 0x92BD59, 0x77AB2F),
|
||||
new BiomeColor(26, "snowy_beach", 0.05f, 0.3f, 0x92BD59, 0x77AB2F),
|
||||
new BiomeColor(27, "birch_forest", 0.6f, 0.6f, 0x92BD59, 0x77AB2F),
|
||||
new BiomeColor(28, "birch_forest_hills", 0.6f, 0.6f, 0x92BD59, 0x77AB2F),
|
||||
|
Reference in New Issue
Block a user