3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-25 02:20:07 +01:00
Dieser Commit ist enthalten in:
Jesse Boyd 2019-07-19 06:23:00 +10:00
Ursprung f500b5e056
Commit 1dcb18ae20
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
4 geänderte Dateien mit 48 neuen und 94 gelöschten Zeilen

Datei anzeigen

@ -1,20 +1,18 @@
package com.boydti.fawe;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.example.NMSMappedFaweQueue;
import com.boydti.fawe.example.NMSRelighter;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.changeset.DiskStorageHistory;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.extent.LightingExtent;
import com.boydti.fawe.object.schematic.Schematic;
import com.boydti.fawe.regions.FaweMaskManager;
import com.boydti.fawe.util.EditSessionBuilder;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MemUtil;
import com.boydti.fawe.util.SetQueue;
import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.util.WEManager;
import com.boydti.fawe.wrappers.WorldWrapper;
@ -148,7 +146,7 @@ public class FaweAPI {
* @param aliases The aliases to give the command (or none)
*/
public static void registerCommands(Object clazz, String... aliases) {
PlatformCommandManager.getInstance().registerCommands(clazz, aliases);
// PlatformCommandManager.getInstance().registerCommands(clazz, aliases); TODO NOT IMPLEMENTED
}
/**
@ -166,23 +164,23 @@ public class FaweAPI {
return FawePlayer.wrap(obj);
}
public static FaweQueue createQueue(String worldName, boolean autoqueue) {
return SetQueue.IMP.getNewQueue(worldName, true, autoqueue);
}
/**
* You can either use a FaweQueue or an EditSession to change blocks<br>
* - The FaweQueue skips a bit of overhead so it's faster<br>
* You can either use a IQueueExtent or an EditSession to change blocks<br>
* - The IQueueExtent skips a bit of overhead so it's marginally faster<br>
* - The WorldEdit EditSession can do a lot more<br>
* Remember to enqueue it when you're done!<br>
* Remember to commit when you're done!<br>
*
* @param world The name of the world
* @param autoqueue If it should start dispatching before you enqueue it.
* @return
* @see FaweQueue#enqueue()
*/
public static FaweQueue createQueue(World world, boolean autoqueue) {
return SetQueue.IMP.getNewQueue(world, true, autoqueue);
public static IQueueExtent createQueue(World world, boolean autoqueue) {
IQueueExtent queue = Fawe.get().getQueueHandler().getQueue(world);
if (!autoqueue) {
queue.disableQueue();
}
return queue;
}
public static World getWorld(String worldName) {
@ -416,19 +414,10 @@ public class FaweAPI {
return (version[0] > major) || ((version[0] == major) && (version[1] > minor)) || ((version[0] == major) && (version[1] == minor) && (version[2] >= minor2));
}
@Deprecated
public static int fixLighting(String world, Region selection) {
return fixLighting(world, selection, FaweQueue.RelightMode.ALL);
}
@Deprecated
public static int fixLighting(String world, Region selection, final FaweQueue.RelightMode mode) {
return fixLighting(world, selection, null, mode);
}
@Deprecated
public static int fixLighting(String world, Region selection, @Nullable FaweQueue queue, final FaweQueue.RelightMode mode) {
return fixLighting(getWorld(world), selection, queue, mode);
public static int fixLighting(World world, Region selection) {
return fixLighting(world, selection, null);
}
/**
@ -441,7 +430,7 @@ public class FaweAPI {
* @param selection (assumes cuboid)
* @return
*/
public static int fixLighting(World world, Region selection, @Nullable FaweQueue queue, final FaweQueue.RelightMode mode) {
public static int fixLighting(World world, Region selection, @Nullable IQueueExtent queue) {
final BlockVector3 bot = selection.getMinimumPoint();
final BlockVector3 top = selection.getMaximumPoint();
@ -452,42 +441,22 @@ public class FaweAPI {
final int maxZ = top.getBlockZ() >> 4;
int count = 0;
if (queue == null) {
queue = SetQueue.IMP.getNewQueue(world, true, false);
}
if (queue == null) queue = createQueue(world, false);
// Remove existing lighting first
if (queue instanceof NMSMappedFaweQueue) {
final NMSMappedFaweQueue nmsQueue = (NMSMappedFaweQueue) queue;
NMSRelighter relighter = new NMSRelighter(nmsQueue);
if (queue instanceof LightingExtent) {
LightingExtent relighter = (LightingExtent) queue;
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {
relighter.addChunk(x, z, null, 65535);
relighter.relightChunk(x, z);
count++;
}
}
if (mode != FaweQueue.RelightMode.NONE) {
boolean sky = nmsQueue.hasSky();
if (sky) {
relighter.fixSkyLighting();
}
relighter.fixBlockLighting();
} else {
relighter.removeLighting();
}
relighter.sendChunks();
} else {
throw new UnsupportedOperationException("Queue is not " + LightingExtent.class);
}
return count;
}
/**
* Set a task to run when the global queue (SetQueue class) is empty
*
* @param whenDone
*/
public static void addTask(final Runnable whenDone) {
SetQueue.IMP.addEmptyTask(whenDone);
}
/**
* Have a task run when the server is low on memory (configured threshold)
*

Datei anzeigen

@ -4,7 +4,6 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.object.FaweInputStream;
import com.boydti.fawe.object.FaweOutputStream;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.Metadatable;
import com.boydti.fawe.object.RunnableVal2;
import com.boydti.fawe.object.brush.visualization.VirtualWorld;
@ -21,7 +20,6 @@ import com.boydti.fawe.object.schematic.Schematic;
import com.boydti.fawe.util.CachedTextureUtil;
import com.boydti.fawe.util.RandomTextureUtil;
import com.boydti.fawe.util.ReflectionUtils;
import com.boydti.fawe.util.SetQueue;
import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.util.TextureUtil;
import com.boydti.fawe.util.image.Drawable;
@ -745,22 +743,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
@Override
public void setTile(int x, int y, int z, CompoundTag tag) {
// Not implemented
}
@Override
public void setEntity(int x, int y, int z, CompoundTag tag) {
// Not implemented
}
@Override
public void removeEntity(int x, int y, int z, UUID uuid) {
// Not implemented
}
@Override
public boolean setBiome(int x, int z, BiomeType biome) {
public boolean setBiome(int x, int y, int z, BiomeType biome) {
int index = z * getWidth() + x;
if (index < 0 || index >= getArea()) return false;
biomes.setByte(index, (byte) biome.getInternalId());

Datei anzeigen

@ -119,31 +119,31 @@ public abstract class FawePlayer<T> extends Metadatable {
}
public int cancel(boolean close) {
Collection<FaweQueue> queues = SetQueue.IMP.getAllQueues();
// Collection<FaweQueue> queues = SetQueue.IMP.getAllQueues(); TODO NOT IMPLEMENTED
int cancelled = 0;
clearActions();
for (FaweQueue queue : queues) {
Collection<EditSession> sessions = queue.getEditSessions();
for (EditSession session : sessions) {
FawePlayer currentPlayer = session.getPlayer();
if (currentPlayer == this) {
if (session.cancel()) {
cancelled++;
}
}
}
}
VirtualWorld world = getSession().getVirtualWorld();
if (world != null) {
if (close) {
try {
world.close(false);
} catch (IOException e) {
e.printStackTrace();
}
}
else world.clear();
}
// clearActions();
// for (FaweQueue queue : queues) {
// Collection<EditSession> sessions = queue.getEditSessions();
// for (EditSession session : sessions) {
// FawePlayer currentPlayer = session.getPlayer();
// if (currentPlayer == this) {
// if (session.cancel()) {
// cancelled++;
// }
// }
// }
// }
// VirtualWorld world = getSession().getVirtualWorld();
// if (world != null) {
// if (close) {
// try {
// world.close(false);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// else world.clear();
// }
return cancelled;
}

Datei anzeigen

@ -12,4 +12,6 @@ public interface LightingExtent extends Extent {
int getOpacity(int x, int y, int z);
int getBrightness(int x, int y, int z);
public void relightChunk(int chunkX, int chunkZ);
}