Fix schematic downloading
This commit is contained in:
parent
523f62787b
commit
b18e53e79f
@ -24,6 +24,7 @@ import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@ -136,6 +137,21 @@ public class BukkitQueue_1_10 extends BukkitQueue_0<Chunk, ChunkSection[], Chunk
|
||||
if (folder.exists() && !folder.isDirectory()) {
|
||||
throw new IllegalArgumentException("File exists with the name '" + name + "' and isn't a folder");
|
||||
}
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
try {
|
||||
Field field = CraftServer.class.getDeclaredField("worlds");
|
||||
field.setAccessible(true);
|
||||
Map<Object, Object> existing = (Map<Object, Object>) field.get(server);
|
||||
if (!existing.getClass().getName().contains("SynchronizedMap")) {
|
||||
field.set(server, Collections.synchronizedMap(existing));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (generator == null) {
|
||||
generator = server.getGenerator(name);
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@ -564,6 +565,21 @@ public class BukkitQueue17 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkSec
|
||||
if (folder.exists() && !folder.isDirectory()) {
|
||||
throw new IllegalArgumentException("File exists with the name '" + name + "' and isn't a folder");
|
||||
}
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
try {
|
||||
Field field = CraftServer.class.getDeclaredField("worlds");
|
||||
field.setAccessible(true);
|
||||
Map<Object, Object> existing = (Map<Object, Object>) field.get(server);
|
||||
if (!existing.getClass().getName().contains("SynchronizedMap")) {
|
||||
field.set(server, Collections.synchronizedMap(existing));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (generator == null) {
|
||||
generator = server.getGenerator(name);
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@ -540,6 +541,21 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkS
|
||||
if (folder.exists() && !folder.isDirectory()) {
|
||||
throw new IllegalArgumentException("File exists with the name '" + name + "' and isn't a folder");
|
||||
}
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
try {
|
||||
Field field = CraftServer.class.getDeclaredField("worlds");
|
||||
field.setAccessible(true);
|
||||
Map<Object, Object> existing = (Map<Object, Object>) field.get(server);
|
||||
if (!existing.getClass().getName().contains("SynchronizedMap")) {
|
||||
field.set(server, Collections.synchronizedMap(existing));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (generator == null) {
|
||||
generator = server.getGenerator(name);
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@ -186,6 +187,21 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Chu
|
||||
if (folder.exists() && !folder.isDirectory()) {
|
||||
throw new IllegalArgumentException("File exists with the name '" + name + "' and isn't a folder");
|
||||
}
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
try {
|
||||
Field field = CraftServer.class.getDeclaredField("worlds");
|
||||
field.setAccessible(true);
|
||||
Map<Object, Object> existing = (Map<Object, Object>) field.get(server);
|
||||
if (!existing.getClass().getName().contains("SynchronizedMap")) {
|
||||
field.set(server, Collections.synchronizedMap(existing));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (generator == null) {
|
||||
generator = server.getGenerator(name);
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.AbstractWorld;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
@ -54,8 +53,8 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* The FaweAPI class offers a few useful functions.<br>
|
||||
@ -137,10 +136,11 @@ public class FaweAPI {
|
||||
@Override
|
||||
public void run(OutputStream value) {
|
||||
try {
|
||||
GZIPOutputStream gzip = new GZIPOutputStream(value, true);
|
||||
ClipboardWriter writer = format.getWriter(gzip);
|
||||
writer.write(clipboard, null);
|
||||
gzip.flush();
|
||||
value.write(new String("test").getBytes());
|
||||
// GZIPOutputStream gzip = new GZIPOutputStream(value, true);
|
||||
// ClipboardWriter writer = format.getWriter(gzip);
|
||||
// writer.write(clipboard, null);
|
||||
// gzip.flush();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -390,6 +390,10 @@ public class FaweAPI {
|
||||
* @return
|
||||
*/
|
||||
public static int fixLighting(String world, Region selection, final FaweQueue.RelightMode mode) {
|
||||
return fixLighting(world, selection, null, mode);
|
||||
}
|
||||
|
||||
public static int fixLighting(String world, Region selection, @Nullable FaweQueue queue, final FaweQueue.RelightMode mode) {
|
||||
final Vector bot = selection.getMinimumPoint();
|
||||
final Vector top = selection.getMaximumPoint();
|
||||
|
||||
@ -400,7 +404,9 @@ public class FaweAPI {
|
||||
final int maxZ = top.getBlockZ() >> 4;
|
||||
|
||||
int count = 0;
|
||||
final FaweQueue queue = SetQueue.IMP.getNewQueue(world, true, false);
|
||||
if (queue == null) {
|
||||
queue = SetQueue.IMP.getNewQueue(world, true, false);
|
||||
}
|
||||
// Remove existing lighting first
|
||||
if (queue instanceof NMSMappedFaweQueue) {
|
||||
final NMSMappedFaweQueue nmsQueue = (NMSMappedFaweQueue) queue;
|
||||
|
@ -31,7 +31,6 @@ public class Commands {
|
||||
|
||||
public static Command translate(final Command command) {
|
||||
if (cmdConfig == null || command instanceof TranslatedCommand) {
|
||||
System.out.println("NO TRANSLATION FOR " + command.aliases()[0]);
|
||||
return command;
|
||||
}
|
||||
return new TranslatedCommand(command);
|
||||
|
@ -269,8 +269,7 @@ public class MainUtil {
|
||||
URLConnection con = new URL(website).openConnection();
|
||||
con.setDoOutput(true);
|
||||
con.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
|
||||
try (OutputStream output = con.getOutputStream();
|
||||
PrintWriter writer = new PrintWriter(new OutputStreamWriter(output, StandardCharsets.UTF_8), true)) {
|
||||
try (OutputStream output = con.getOutputStream(); PrintWriter writer = new PrintWriter(new OutputStreamWriter(output, StandardCharsets.UTF_8), true)) {
|
||||
String CRLF = "\r\n";
|
||||
writer.append("--" + boundary).append(CRLF);
|
||||
writer.append("Content-Disposition: form-data; name=\"param\"").append(CRLF);
|
||||
|
@ -43,15 +43,6 @@ public class MathMan {
|
||||
253, 254, 254, 255
|
||||
};
|
||||
|
||||
public static void main(String[] args) {
|
||||
double val;
|
||||
val = 10.2;
|
||||
System.out.println(inverseRound(10.2) + " " + 11);
|
||||
System.out.println(inverseRound(10.8) + " " + 10);
|
||||
System.out.println(inverseRound(-10.2) + " " + -11);
|
||||
System.out.println(inverseRound(-10.8) + " " + -10);
|
||||
}
|
||||
|
||||
public static long inverseRound(double val) {
|
||||
long round = Math.round(val);
|
||||
return (long) (round + Math.signum(val - round));
|
||||
|
@ -298,6 +298,14 @@ public final class NBTOutputStream implements Closeable {
|
||||
os.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush output.
|
||||
* @throws IOException
|
||||
*/
|
||||
public void flush() throws IOException {
|
||||
this.os.flush();
|
||||
}
|
||||
|
||||
public static Class<?> inject() {
|
||||
return NBTOutputStream.class;
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.internal.annotation.Direction;
|
||||
import com.sk89q.worldedit.internal.annotation.Selection;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
@ -223,6 +224,17 @@ public class ClipboardCommands {
|
||||
}
|
||||
ClipboardHolder holder = session.getClipboard();
|
||||
Clipboard clipboard = holder.getClipboard();
|
||||
final Transform transform = holder.getTransform();
|
||||
final Clipboard target;
|
||||
// If we have a transform, bake it into the copy
|
||||
if (!transform.isIdentity()) {
|
||||
final FlattenedClipboardTransform result = FlattenedClipboardTransform.transform(clipboard, transform, holder.getWorldData());
|
||||
target = new BlockArrayClipboard(result.getTransformedRegion(), player.getUniqueId());
|
||||
target.setOrigin(clipboard.getOrigin());
|
||||
Operations.completeLegacy(result.copyTo(target));
|
||||
} else {
|
||||
target = clipboard;
|
||||
}
|
||||
BBC.GENERATING_LINK.send(player, formatName);
|
||||
URL url;
|
||||
switch (format) {
|
||||
@ -230,7 +242,7 @@ public class ClipboardCommands {
|
||||
try {
|
||||
FastByteArrayOutputStream baos = new FastByteArrayOutputStream(Short.MAX_VALUE);
|
||||
ClipboardWriter writer = format.getWriter(baos);
|
||||
writer.write(clipboard, null);
|
||||
writer.write(target, null);
|
||||
baos.flush();
|
||||
url = ImgurUtility.uploadImage(baos.toByteArray());
|
||||
} catch (IOException e) {
|
||||
@ -239,7 +251,7 @@ public class ClipboardCommands {
|
||||
}
|
||||
break;
|
||||
case SCHEMATIC:
|
||||
url = FaweAPI.upload(clipboard, format);
|
||||
url = FaweAPI.upload(target, format);
|
||||
break;
|
||||
default:
|
||||
url = null;
|
||||
|
@ -103,11 +103,10 @@ public class RegionCommands {
|
||||
public void fixlighting(Player player, EditSession editSession) throws WorldEditException {
|
||||
FawePlayer fp = FawePlayer.wrap(player);
|
||||
final FaweLocation loc = fp.getLocation();
|
||||
final int cx = loc.x >> 4;
|
||||
final int cz = loc.z >> 4;
|
||||
|
||||
Region selection = fp.getSelection();
|
||||
if (selection == null) {
|
||||
final int cx = loc.x >> 4;
|
||||
final int cz = loc.z >> 4;
|
||||
selection = new CuboidRegion(new Vector(cx - 8, 0, cz - 8).multiply(16), new Vector(cx + 8, 0, cz + 8).multiply(16));
|
||||
}
|
||||
int count = FaweAPI.fixLighting(loc.world, selection, FaweQueue.RelightMode.ALL);
|
||||
@ -124,11 +123,10 @@ public class RegionCommands {
|
||||
public void removelighting(Player player, EditSession editSession) {
|
||||
FawePlayer fp = FawePlayer.wrap(player);
|
||||
final FaweLocation loc = fp.getLocation();
|
||||
final int cx = loc.x >> 4;
|
||||
final int cz = loc.z >> 4;
|
||||
|
||||
Region selection = fp.getSelection();
|
||||
if (selection == null) {
|
||||
final int cx = loc.x >> 4;
|
||||
final int cz = loc.z >> 4;
|
||||
selection = new CuboidRegion(new Vector(cx - 8, 0, cz - 8).multiply(16), new Vector(cx + 8, 0, cz + 8).multiply(16));
|
||||
}
|
||||
int count = FaweAPI.fixLighting(loc.world, selection, FaweQueue.RelightMode.NONE);
|
||||
@ -238,7 +236,7 @@ public class RegionCommands {
|
||||
@Optional("0") @Range(min = 0) int thickness,
|
||||
@Switch('h') boolean shell) throws WorldEditException {
|
||||
if (!(region instanceof ConvexPolyhedralRegion)) {
|
||||
player.printError("//line only works with convex polyhedral selections");
|
||||
player.printError("//curve only works with convex polyhedral selections");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -108,6 +108,7 @@ public class SchematicWriter implements ClipboardWriter {
|
||||
@Override
|
||||
public void write(Clipboard clipboard, WorldData data) throws IOException {
|
||||
outputStream.writeNamedTag("Schematic", writeTag(clipboard));
|
||||
outputStream.flush();
|
||||
}
|
||||
|
||||
public static CompoundTag writeTag(Clipboard clipboard) {
|
||||
|
Loading…
Reference in New Issue
Block a user