mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 17:57:38 +00:00
A lot of removals, upstream merges, and maybe more.
This commit is contained in:
parent
3169592332
commit
7f3c4c4828
@ -24,7 +24,6 @@ import com.boydti.fawe.bukkit.util.BukkitReflectionUtils;
|
|||||||
import com.boydti.fawe.bukkit.util.BukkitTaskMan;
|
import com.boydti.fawe.bukkit.util.BukkitTaskMan;
|
||||||
import com.boydti.fawe.bukkit.util.ItemUtil;
|
import com.boydti.fawe.bukkit.util.ItemUtil;
|
||||||
import com.boydti.fawe.bukkit.util.VaultUtil;
|
import com.boydti.fawe.bukkit.util.VaultUtil;
|
||||||
import com.boydti.fawe.bukkit.util.cui.CUIListener;
|
|
||||||
import com.boydti.fawe.bukkit.util.image.BukkitImageViewer;
|
import com.boydti.fawe.bukkit.util.image.BukkitImageViewer;
|
||||||
import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
|
import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
|
||||||
import com.boydti.fawe.bukkit.v0.BukkitQueue_All;
|
import com.boydti.fawe.bukkit.v0.BukkitQueue_All;
|
||||||
@ -73,10 +72,10 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
|
|
||||||
private boolean listeningImages;
|
private boolean listeningImages;
|
||||||
private BukkitImageListener imageListener;
|
private BukkitImageListener imageListener;
|
||||||
private CFIPacketListener packetListener;
|
//private CFIPacketListener packetListener;
|
||||||
|
|
||||||
private boolean listeningCui;
|
//private boolean listeningCui;
|
||||||
private CUIListener cuiListener;
|
//private CUIListener cuiListener;
|
||||||
|
|
||||||
public VaultUtil getVault() {
|
public VaultUtil getVault() {
|
||||||
return this.vault;
|
return this.vault;
|
||||||
@ -151,7 +150,7 @@ public class FaweBukkit implements IFawe, Listener {
|
|||||||
if (listeningImages && imageListener == null) return null;
|
if (listeningImages && imageListener == null) return null;
|
||||||
try {
|
try {
|
||||||
listeningImages = true;
|
listeningImages = true;
|
||||||
registerPacketListener();
|
//registerPacketListener();
|
||||||
PluginManager manager = Bukkit.getPluginManager();
|
PluginManager manager = Bukkit.getPluginManager();
|
||||||
|
|
||||||
if (manager.getPlugin("PacketListenerApi") == null) {
|
if (manager.getPlugin("PacketListenerApi") == null) {
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
package com.boydti.fawe.bukkit.util.cui;
|
|
||||||
|
|
||||||
import com.boydti.fawe.object.FawePlayer;
|
|
||||||
import com.boydti.fawe.util.cui.CUI;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
public class CUIListener implements Listener {
|
|
||||||
|
|
||||||
public CUIListener(Plugin plugin) {
|
|
||||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
|
||||||
Location from = event.getFrom();
|
|
||||||
Location to = event.getTo();
|
|
||||||
if ((int) from.getX() >> 2 != (int) to.getX() >> 2 || (int) from.getZ() >> 2 != (int) to.getZ() >> 2 || (int) from.getY() >> 2 != (int) to.getY() >> 2) {
|
|
||||||
FawePlayer<Object> player = FawePlayer.wrap(event.getPlayer());
|
|
||||||
CUI cui = player.getMeta("CUI");
|
|
||||||
if (cui instanceof StructureCUI) {
|
|
||||||
StructureCUI sCui = (StructureCUI) cui;
|
|
||||||
sCui.update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,201 +0,0 @@
|
|||||||
package com.boydti.fawe.bukkit.util.cui;
|
|
||||||
|
|
||||||
import com.boydti.fawe.FaweCache;
|
|
||||||
import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
|
|
||||||
import com.boydti.fawe.object.FawePlayer;
|
|
||||||
import com.boydti.fawe.util.cui.CUI;
|
|
||||||
import com.comphenix.protocol.PacketType;
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
|
||||||
import com.comphenix.protocol.ProtocolManager;
|
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
|
||||||
import com.comphenix.protocol.injector.PacketConstructor;
|
|
||||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtBase;
|
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
|
||||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
|
||||||
import com.sk89q.worldedit.internal.cui.SelectionPointEvent;
|
|
||||||
import com.sk89q.worldedit.internal.cui.SelectionShapeEvent;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class StructureCUI extends CUI {
|
|
||||||
private boolean cuboid = true;
|
|
||||||
|
|
||||||
private BlockVector3 pos1;
|
|
||||||
private BlockVector3 pos2;
|
|
||||||
|
|
||||||
private BlockVector3 remove;
|
|
||||||
private NbtCompound removeTag;
|
|
||||||
private BlockState state;
|
|
||||||
|
|
||||||
public StructureCUI(FawePlayer player) {
|
|
||||||
super(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispatchCUIEvent(CUIEvent event) {
|
|
||||||
if (event instanceof SelectionShapeEvent) {
|
|
||||||
clear();
|
|
||||||
this.cuboid = event.getParameters()[0].equalsIgnoreCase("cuboid");
|
|
||||||
} else if (cuboid && event instanceof SelectionPointEvent) {
|
|
||||||
SelectionPointEvent spe = (SelectionPointEvent) event;
|
|
||||||
String[] param = spe.getParameters();
|
|
||||||
int id = Integer.parseInt(param[0]);
|
|
||||||
int x = Integer.parseInt(param[1]);
|
|
||||||
int y = Integer.parseInt(param[2]);
|
|
||||||
int z = Integer.parseInt(param[3]);
|
|
||||||
BlockVector3 pos = BlockVector3.at(x, y, z);
|
|
||||||
if (id == 0) {
|
|
||||||
pos1 = pos;
|
|
||||||
} else {
|
|
||||||
pos2 = pos;
|
|
||||||
}
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int viewDistance() {
|
|
||||||
Player player = this.<Player>getPlayer().parent;
|
|
||||||
//todo replace with PaperLib.isPaper()
|
|
||||||
if (Bukkit.getVersion().contains("paper")) {
|
|
||||||
return player.getViewDistance();
|
|
||||||
} else {
|
|
||||||
return Bukkit.getViewDistance();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clear() {
|
|
||||||
pos1 = null;
|
|
||||||
pos2 = null;
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
private NbtCompound constructStructureNbt(int x, int y, int z, int posX, int posY, int posZ, int sizeX, int sizeY, int sizeZ) {
|
|
||||||
HashMap<String, Object> tag = new HashMap<>();
|
|
||||||
tag.put("name", UUID.randomUUID().toString());
|
|
||||||
tag.put("author", "Empire92"); // :D
|
|
||||||
tag.put("metadata", "");
|
|
||||||
tag.put("x", x);
|
|
||||||
tag.put("y", y);
|
|
||||||
tag.put("z", z);
|
|
||||||
tag.put("posX", posX);
|
|
||||||
tag.put("posY", posY);
|
|
||||||
tag.put("posZ", posZ);
|
|
||||||
tag.put("sizeX", sizeX);
|
|
||||||
tag.put("sizeY", sizeY);
|
|
||||||
tag.put("sizeZ", sizeZ);
|
|
||||||
tag.put("rotation", "NONE");
|
|
||||||
tag.put("mirror", "NONE");
|
|
||||||
tag.put("mode", "SAVE");
|
|
||||||
tag.put("ignoreEntities", true);
|
|
||||||
tag.put("powered", false);
|
|
||||||
tag.put("showair", false);
|
|
||||||
tag.put("showboundingbox", true);
|
|
||||||
tag.put("integrity", 1.0f);
|
|
||||||
tag.put("seed", 0);
|
|
||||||
tag.put("id", "minecraft:structure_block");
|
|
||||||
Object nmsTag = BukkitQueue_0.fromNative(FaweCache.asTag(tag));
|
|
||||||
return NbtFactory.fromNMSCompound(nmsTag);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendOp() {
|
|
||||||
Player player = this.<Player>getPlayer().parent;
|
|
||||||
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
|
|
||||||
|
|
||||||
PacketConstructor statusCtr = manager.createPacketConstructor(PacketType.Play.Server.ENTITY_STATUS, player, (byte) 28);
|
|
||||||
PacketContainer status = statusCtr.createPacket(player, (byte) 28);
|
|
||||||
|
|
||||||
try {
|
|
||||||
manager.sendServerPacket(player, status);
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendNbt(BlockVector3 pos, NbtCompound compound) {
|
|
||||||
Player player = this.<Player>getPlayer().parent;
|
|
||||||
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
|
|
||||||
|
|
||||||
PacketContainer blockNbt = new PacketContainer(PacketType.Play.Server.TILE_ENTITY_DATA);
|
|
||||||
blockNbt.getBlockPositionModifier().write(0, new BlockPosition(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()));
|
|
||||||
blockNbt.getIntegers().write(0, 7);
|
|
||||||
blockNbt.getNbtModifier().write(0, compound);
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
manager.sendServerPacket(player, blockNbt);
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void update() {
|
|
||||||
Player player = this.<Player>getPlayer().parent;
|
|
||||||
Location playerLoc = player.getLocation();
|
|
||||||
boolean setOp = remove == null && !player.isOp();
|
|
||||||
if (remove != null) {
|
|
||||||
int cx = playerLoc.getBlockX() >> 4;
|
|
||||||
int cz = playerLoc.getBlockZ() >> 4;
|
|
||||||
int viewDistance = viewDistance();
|
|
||||||
if (Math.abs(cx - (remove.getBlockX() >> 4)) <= viewDistance && Math.abs(cz - (remove.getBlockZ() >> 4)) <= viewDistance) {
|
|
||||||
Map<String, NbtBase<?>> map = removeTag.getValue();
|
|
||||||
map.put("sizeX", NbtFactory.of("sizeX", 0));
|
|
||||||
sendNbt(remove, removeTag);
|
|
||||||
Location removeLoc = new Location(player.getWorld(), remove.getX(), remove.getY(), remove.getZ());
|
|
||||||
player.sendBlockChange(removeLoc, BukkitAdapter.adapt(state));
|
|
||||||
}
|
|
||||||
remove = null;
|
|
||||||
}
|
|
||||||
if (pos1 == null || pos2 == null) return;
|
|
||||||
BlockVector3 min = pos1.getMinimum(pos2);
|
|
||||||
BlockVector3 max = pos1.getMaximum(pos2);
|
|
||||||
|
|
||||||
// Position
|
|
||||||
double rotX = playerLoc.getYaw();
|
|
||||||
double rotY = playerLoc.getPitch();
|
|
||||||
double xz = Math.cos(Math.toRadians(rotY));
|
|
||||||
int x = (int) (playerLoc.getX() - (-xz * Math.sin(Math.toRadians(rotX))) * 12);
|
|
||||||
int z = (int) (playerLoc.getZ() - (xz * Math.cos(Math.toRadians(rotX))) * 12);
|
|
||||||
int y = Math.max(0, Math.min(Math.min(255, max.getBlockY() + 32), playerLoc.getBlockY() + 3));
|
|
||||||
int minX = Math.max(Math.min(32, min.getBlockX() - x), -32);
|
|
||||||
int maxX = Math.max(Math.min(32, max.getBlockX() - x + 1), -32);
|
|
||||||
int minY = Math.max(Math.min(32, min.getBlockY() - y), -32);
|
|
||||||
int maxY = Math.max(Math.min(32, max.getBlockY() - y + 1), -32);
|
|
||||||
int minZ = Math.max(Math.min(32, min.getBlockZ() - z), -32);
|
|
||||||
int maxZ = Math.max(Math.min(32, max.getBlockZ() - z + 1), -32);
|
|
||||||
int sizeX = Math.min(32, maxX - minX);
|
|
||||||
int sizeY = Math.min(32, maxY - minY);
|
|
||||||
int sizeZ = Math.min(32, maxZ - minZ);
|
|
||||||
if (sizeX == 0 || sizeY == 0 || sizeZ == 0) return;
|
|
||||||
// maxX - 32;
|
|
||||||
int posX = Math.max(minX, Math.min(16, maxX) - 32);
|
|
||||||
int posY = Math.max(minY, Math.min(16, maxY) - 32);
|
|
||||||
int posZ = Math.max(minZ, Math.min(16, maxZ) - 32);
|
|
||||||
|
|
||||||
// NBT
|
|
||||||
NbtCompound compound = constructStructureNbt(x, y, z, posX, posY, posZ, sizeX, sizeY, sizeZ);
|
|
||||||
|
|
||||||
Block block = player.getWorld().getBlockAt(x, y, z);
|
|
||||||
remove = BlockVector3.at(x, y, z);
|
|
||||||
state = BukkitAdapter.adapt(block.getBlockData());
|
|
||||||
removeTag = compound;
|
|
||||||
|
|
||||||
Location blockLoc = new Location(player.getWorld(), x, y, z);
|
|
||||||
player.sendBlockChange(blockLoc, Material.STRUCTURE_BLOCK, (byte) 0);
|
|
||||||
if (setOp) sendOp();
|
|
||||||
sendNbt(remove, compound);
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,7 +7,6 @@ import com.boydti.fawe.example.NMSRelighter;
|
|||||||
import com.boydti.fawe.object.FaweLocation;
|
import com.boydti.fawe.object.FaweLocation;
|
||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
import com.boydti.fawe.object.FaweQueue;
|
import com.boydti.fawe.object.FaweQueue;
|
||||||
import com.boydti.fawe.object.PseudoRandom;
|
|
||||||
import com.boydti.fawe.object.RegionWrapper;
|
import com.boydti.fawe.object.RegionWrapper;
|
||||||
import com.boydti.fawe.object.changeset.DiskStorageHistory;
|
import com.boydti.fawe.object.changeset.DiskStorageHistory;
|
||||||
import com.boydti.fawe.object.schematic.Schematic;
|
import com.boydti.fawe.object.schematic.Schematic;
|
||||||
@ -245,15 +244,6 @@ public class FaweAPI {
|
|||||||
return MemUtil.isMemoryLimited();
|
return MemUtil.isMemoryLimited();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Use ThreadLocalRandom instead
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static PseudoRandom getFastRandom() {
|
|
||||||
throw new UnsupportedOperationException("Please Use ThreadLocalRandom instead.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a player's allowed WorldEdit region
|
* Get a player's allowed WorldEdit region
|
||||||
*
|
*
|
||||||
|
@ -4,13 +4,14 @@ import com.boydti.fawe.Fawe;
|
|||||||
import com.boydti.fawe.configuration.MemorySection;
|
import com.boydti.fawe.configuration.MemorySection;
|
||||||
import com.boydti.fawe.configuration.file.YamlConfiguration;
|
import com.boydti.fawe.configuration.file.YamlConfiguration;
|
||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
import com.boydti.fawe.object.PseudoRandom;
|
|
||||||
import com.boydti.fawe.object.RunnableVal3;
|
import com.boydti.fawe.object.RunnableVal3;
|
||||||
import com.boydti.fawe.util.MainUtil;
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.StringMan;
|
import com.boydti.fawe.util.StringMan;
|
||||||
import com.boydti.fawe.util.chat.Message;
|
import com.boydti.fawe.util.chat.Message;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import com.sk89q.worldedit.entity.Player;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
@ -595,11 +595,11 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
placed.add(x, z);
|
placed.add(x, z);
|
||||||
ClipboardHolder holder = clipboards.get(PseudoRandom.random.random(clipboards.size()));
|
ClipboardHolder holder = clipboards.get(ThreadLocalRandom.current().nextInt(clipboards.size()));
|
||||||
if (randomRotate) {
|
if (randomRotate) {
|
||||||
int rotate = PseudoRandom.random.random(4) * 90;
|
int rotate = ThreadLocalRandom.current().nextInt(4) * 90;
|
||||||
if (rotate != 0) {
|
if (rotate != 0) {
|
||||||
holder.setTransform(new AffineTransform().rotateY(PseudoRandom.random.random(4) * 90));
|
holder.setTransform(new AffineTransform().rotateY(ThreadLocalRandom.current().nextInt(4) * 90));
|
||||||
} else {
|
} else {
|
||||||
holder.setTransform(identity);
|
holder.setTransform(identity);
|
||||||
}
|
}
|
||||||
@ -644,11 +644,11 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
|||||||
}
|
}
|
||||||
mutable.mutY(y + 1);
|
mutable.mutY(y + 1);
|
||||||
placed.add(x, z);
|
placed.add(x, z);
|
||||||
ClipboardHolder holder = clipboards.get(PseudoRandom.random.random(clipboards.size()));
|
ClipboardHolder holder = clipboards.get(ThreadLocalRandom.current().nextInt(clipboards.size()));
|
||||||
if (randomRotate) {
|
if (randomRotate) {
|
||||||
int rotate = PseudoRandom.random.random(4) * 90;
|
int rotate = ThreadLocalRandom.current().nextInt(4) * 90;
|
||||||
if (rotate != 0) {
|
if (rotate != 0) {
|
||||||
holder.setTransform(new AffineTransform().rotateY(PseudoRandom.random.random(4) * 90));
|
holder.setTransform(new AffineTransform().rotateY(ThreadLocalRandom.current().nextInt(4) * 90));
|
||||||
} else {
|
} else {
|
||||||
holder.setTransform(identity);
|
holder.setTransform(identity);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.boydti.fawe.jnbt.anvil.generator;
|
package com.boydti.fawe.jnbt.anvil.generator;
|
||||||
|
|
||||||
import com.boydti.fawe.object.PseudoRandom;
|
|
||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.boydti.fawe.jnbt.anvil.generator;
|
package com.boydti.fawe.jnbt.anvil.generator;
|
||||||
|
|
||||||
import com.boydti.fawe.object.PseudoRandom;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
@ -10,12 +9,10 @@ import java.util.concurrent.ThreadLocalRandom;
|
|||||||
public abstract class GenBase {
|
public abstract class GenBase {
|
||||||
|
|
||||||
private final int checkAreaSize;
|
private final int checkAreaSize;
|
||||||
private final PseudoRandom random;
|
|
||||||
private final long seed;
|
private final long seed;
|
||||||
private final long worldSeed1, worldSeed2;
|
private final long worldSeed1, worldSeed2;
|
||||||
|
|
||||||
public GenBase(int area) {
|
public GenBase(int area) {
|
||||||
this.random = new PseudoRandom();
|
|
||||||
this.checkAreaSize = area;
|
this.checkAreaSize = area;
|
||||||
this.seed = ThreadLocalRandom.current().nextLong();
|
this.seed = ThreadLocalRandom.current().nextLong();
|
||||||
this.worldSeed1 = ThreadLocalRandom.current().nextLong();
|
this.worldSeed1 = ThreadLocalRandom.current().nextLong();
|
||||||
@ -26,10 +23,6 @@ public abstract class GenBase {
|
|||||||
return checkAreaSize;
|
return checkAreaSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PseudoRandom getRandom() {
|
|
||||||
return random;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void generate(BlockVector2 chunkPos, Extent chunk) throws WorldEditException {
|
public void generate(BlockVector2 chunkPos, Extent chunk) throws WorldEditException {
|
||||||
int i = this.checkAreaSize;
|
int i = this.checkAreaSize;
|
||||||
int chunkX = chunkPos.getBlockX();
|
int chunkX = chunkPos.getBlockX();
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package com.boydti.fawe.jnbt.anvil.generator;
|
package com.boydti.fawe.jnbt.anvil.generator;
|
||||||
|
|
||||||
import com.boydti.fawe.object.PseudoRandom;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
|
||||||
|
|
||||||
public abstract class Resource {
|
public abstract class Resource {
|
||||||
public Resource() {}
|
public Resource() {}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.boydti.fawe.jnbt.anvil.generator;
|
package com.boydti.fawe.jnbt.anvil.generator;
|
||||||
|
|
||||||
import com.boydti.fawe.object.PseudoRandom;
|
|
||||||
import com.boydti.fawe.object.schematic.Schematic;
|
import com.boydti.fawe.object.schematic.Schematic;
|
||||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
@ -12,6 +11,7 @@ import com.sk89q.worldedit.math.transform.Transform;
|
|||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
public class SchemGen extends Resource {
|
public class SchemGen extends Resource {
|
||||||
|
|
||||||
@ -40,9 +40,9 @@ public class SchemGen extends Resource {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mutable.mutY(y + 1);
|
mutable.mutY(y + 1);
|
||||||
ClipboardHolder holder = clipboards.get(PseudoRandom.random.random(clipboards.size()));
|
ClipboardHolder holder = clipboards.get(ThreadLocalRandom.current().nextInt(clipboards.size()));
|
||||||
if (randomRotate) {
|
if (randomRotate) {
|
||||||
holder.setTransform(new AffineTransform().rotateY(PseudoRandom.random.random(4) * 90));
|
holder.setTransform(new AffineTransform().rotateY(ThreadLocalRandom.current().nextInt(4) * 90));
|
||||||
}
|
}
|
||||||
Clipboard clipboard = holder.getClipboard();
|
Clipboard clipboard = holder.getClipboard();
|
||||||
Schematic schematic = new Schematic(clipboard);
|
Schematic schematic = new Schematic(clipboard);
|
||||||
|
@ -506,7 +506,8 @@ public abstract class FawePlayer<T> extends Metadatable {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public LocalSession getSession() {
|
public LocalSession getSession() {
|
||||||
return (this.session != null || this.getPlayer() == null || Fawe.get() == null) ? this.session : (session = Fawe.get().getWorldEdit().getSessionManager().get(this.getPlayer()));
|
if (this.session != null || this.getPlayer() == null || Fawe.get() == null) return this.session;
|
||||||
|
else return session = Fawe.get().getWorldEdit().getSessionManager().get(this.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -662,7 +663,8 @@ public abstract class FawePlayer<T> extends Metadatable {
|
|||||||
|
|
||||||
PlayerProxy proxy = new PlayerProxy(player, permActor, cuiActor, world);
|
PlayerProxy proxy = new PlayerProxy(player, permActor, cuiActor, world);
|
||||||
if (world instanceof VirtualWorld) {
|
if (world instanceof VirtualWorld) {
|
||||||
proxy.setOffset(Vector3.ZERO.subtract(((VirtualWorld) world).getOrigin()));
|
//todo fix this
|
||||||
|
//proxy.setOffset(Vector3.ZERO.subtract(((VirtualWorld) world).getOrigin()));
|
||||||
}
|
}
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
|
@ -33,11 +33,8 @@ public class Metadatable {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public <V> V getMeta(String key) {
|
public <V> V getMeta(String key) {
|
||||||
if (this.meta != null) {
|
|
||||||
return (V) this.meta.get(key);
|
return (V) this.meta.get(key);
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the metadata for a specific key (or return the default provided)
|
* Get the metadata for a specific key (or return the default provided)
|
||||||
@ -48,12 +45,9 @@ public class Metadatable {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public <V> V getMeta(String key, V def) {
|
public <V> V getMeta(String key, V def) {
|
||||||
if (this.meta != null) {
|
|
||||||
V value = (V) this.meta.get(key);
|
V value = (V) this.meta.get(key);
|
||||||
return value == null ? def : value;
|
return value == null ? def : value;
|
||||||
}
|
}
|
||||||
return def;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete the metadata for a key.
|
* Delete the metadata for a key.
|
||||||
@ -63,6 +57,6 @@ public class Metadatable {
|
|||||||
* @param key
|
* @param key
|
||||||
*/
|
*/
|
||||||
public <V> V deleteMeta(String key) {
|
public <V> V deleteMeta(String key) {
|
||||||
return this.meta == null ? null : (V) this.meta.remove(key);
|
return (V) this.meta.remove(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
package com.boydti.fawe.object;
|
|
||||||
|
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
/**
|
|
||||||
* @Deprecated use ThreadLocalRandom instead
|
|
||||||
*/
|
|
||||||
public class PseudoRandom {
|
|
||||||
public static PseudoRandom random = new PseudoRandom();
|
|
||||||
|
|
||||||
public PseudoRandom() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public int random(final int n) {
|
|
||||||
if (n == 1) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
final long r = ((ThreadLocalRandom.current().nextLong() >>> 32) * n) >> 32;
|
|
||||||
return (int) r;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,27 +1,20 @@
|
|||||||
package com.boydti.fawe.object.brush;
|
package com.boydti.fawe.object.brush;
|
||||||
|
|
||||||
import com.boydti.fawe.FaweCache;
|
|
||||||
import com.boydti.fawe.object.PseudoRandom;
|
|
||||||
import com.boydti.fawe.object.clipboard.CPUOptimizedClipboard;
|
import com.boydti.fawe.object.clipboard.CPUOptimizedClipboard;
|
||||||
import com.boydti.fawe.object.clipboard.FaweClipboard;
|
import com.boydti.fawe.object.clipboard.FaweClipboard;
|
||||||
import com.boydti.fawe.object.clipboard.OffsetFaweClipboard;
|
import com.boydti.fawe.object.clipboard.OffsetFaweClipboard;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.blocks.Blocks;
|
|
||||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
import com.sk89q.worldedit.command.tool.brush.Brush;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class ErodeBrush implements Brush {
|
public class ErodeBrush implements Brush {
|
||||||
|
|
||||||
private PseudoRandom rand = new PseudoRandom();
|
|
||||||
|
|
||||||
private static final BlockVector3[] FACES_TO_CHECK = {BlockVector3.at(0, 0, 1), BlockVector3.at(0, 0, -1), BlockVector3.at(0, 1, 0), BlockVector3.at(0, -1, 0), BlockVector3.at(1, 0, 0), BlockVector3.at(-1, 0, 0)};
|
private static final BlockVector3[] FACES_TO_CHECK = {BlockVector3.at(0, 0, 1), BlockVector3.at(0, 0, -1), BlockVector3.at(0, 1, 0), BlockVector3.at(0, -1, 0), BlockVector3.at(1, 0, 0), BlockVector3.at(-1, 0, 0)};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.boydti.fawe.object.brush;
|
package com.boydti.fawe.object.brush;
|
||||||
|
|
||||||
import com.boydti.fawe.object.PseudoRandom;
|
|
||||||
import com.boydti.fawe.object.collection.LocalBlockVectorSet;
|
import com.boydti.fawe.object.collection.LocalBlockVectorSet;
|
||||||
import com.boydti.fawe.object.mask.SurfaceMask;
|
import com.boydti.fawe.object.mask.SurfaceMask;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
@ -12,6 +11,8 @@ import com.sk89q.worldedit.function.visitor.BreadthFirstSearch;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||||
|
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
public class ShatterBrush extends ScatterBrush {
|
public class ShatterBrush extends ScatterBrush {
|
||||||
private final MutableBlockVector3 mutable = new MutableBlockVector3();
|
private final MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||||
|
|
||||||
@ -61,7 +62,7 @@ public class ShatterBrush extends ScatterBrush {
|
|||||||
frontier.forEach(new LocalBlockVectorSet.BlockVectorSetVisitor() {
|
frontier.forEach(new LocalBlockVectorSet.BlockVectorSetVisitor() {
|
||||||
@Override
|
@Override
|
||||||
public void run(int x, int y, int z, int index) {
|
public void run(int x, int y, int z, int index) {
|
||||||
if (PseudoRandom.random.random(2) == 0) {
|
if (ThreadLocalRandom.current().nextInt(2) == 0) {
|
||||||
finalTmp.add(x, y, z);
|
finalTmp.add(x, y, z);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,20 @@
|
|||||||
package com.boydti.fawe.object.brush;
|
package com.boydti.fawe.object.brush;
|
||||||
|
|
||||||
import com.boydti.fawe.object.PseudoRandom;
|
|
||||||
import com.boydti.fawe.object.collection.LocalBlockVectorSet;
|
import com.boydti.fawe.object.collection.LocalBlockVectorSet;
|
||||||
import com.boydti.fawe.object.mask.SurfaceMask;
|
import com.boydti.fawe.object.mask.SurfaceMask;
|
||||||
import com.boydti.fawe.object.pattern.BiomePattern;
|
import com.boydti.fawe.object.pattern.BiomePattern;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
|
||||||
import com.sk89q.worldedit.function.RegionFunction;
|
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
||||||
import com.sk89q.worldedit.function.operation.Operations;
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.function.visitor.BreadthFirstSearch;
|
||||||
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
|
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
public class SplatterBrush extends ScatterBrush {
|
public class SplatterBrush extends ScatterBrush {
|
||||||
private final boolean solid;
|
private final boolean solid;
|
||||||
@ -45,24 +44,16 @@ public class SplatterBrush extends ScatterBrush {
|
|||||||
SurfaceMask surface = new SurfaceMask(editSession);
|
SurfaceMask surface = new SurfaceMask(editSession);
|
||||||
final SolidBlockMask solid = new SolidBlockMask(editSession);
|
final SolidBlockMask solid = new SolidBlockMask(editSession);
|
||||||
|
|
||||||
RecursiveVisitor visitor = new RecursiveVisitor(new Mask() {
|
RecursiveVisitor visitor = new RecursiveVisitor(vector -> {
|
||||||
@Override
|
|
||||||
public boolean test(BlockVector3 vector) {
|
|
||||||
double dist = vector.distanceSq(position);
|
double dist = vector.distanceSq(position);
|
||||||
if (dist < size2 && !placed.contains(vector) && (PseudoRandom.random.random(5) < 2) && surface.test(vector)) {
|
if (dist < size2 && !placed.contains(vector) && (ThreadLocalRandom.current().nextInt(5) < 2) && surface.test(vector)) {
|
||||||
placed.add(vector);
|
placed.add(vector);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}, vector -> editSession.setBlock(vector, finalPattern), recursion, editSession);
|
||||||
}, new RegionFunction() {
|
|
||||||
@Override
|
|
||||||
public boolean apply(BlockVector3 vector) throws WorldEditException {
|
|
||||||
return editSession.setBlock(vector, finalPattern);
|
|
||||||
}
|
|
||||||
}, recursion, editSession);
|
|
||||||
visitor.setMaxBranch(2);
|
visitor.setMaxBranch(2);
|
||||||
visitor.setDirections(Arrays.asList(visitor.DIAGONAL_DIRECTIONS));
|
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
|
||||||
visitor.visit(position);
|
visitor.visit(position);
|
||||||
Operations.completeBlindly(visitor);
|
Operations.completeBlindly(visitor);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.boydti.fawe.object.brush;
|
package com.boydti.fawe.object.brush;
|
||||||
|
|
||||||
import com.boydti.fawe.object.PseudoRandom;
|
|
||||||
import com.boydti.fawe.object.brush.heightmap.HeightMap;
|
import com.boydti.fawe.object.brush.heightmap.HeightMap;
|
||||||
import com.boydti.fawe.object.mask.AdjacentAnyMask;
|
import com.boydti.fawe.object.mask.AdjacentAnyMask;
|
||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
@ -13,14 +12,17 @@ import com.sk89q.worldedit.function.mask.Masks;
|
|||||||
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
||||||
import com.sk89q.worldedit.function.operation.Operations;
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.function.visitor.BreadthFirstSearch;
|
||||||
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
|
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.MutableVector3;
|
import com.sk89q.worldedit.math.MutableVector3;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
public class StencilBrush extends HeightBrush {
|
public class StencilBrush extends HeightBrush {
|
||||||
private final boolean onlyWhite;
|
private final boolean onlyWhite;
|
||||||
@ -84,7 +86,7 @@ public class StencilBrush extends HeightBrush {
|
|||||||
if (val < cutoff) {
|
if (val < cutoff) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (val >= 255 || PseudoRandom.random.random(maxY) < val) {
|
if (val >= 255 || ThreadLocalRandom.current().nextInt(maxY) < val) {
|
||||||
editSession.setBlock(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ(), pattern);
|
editSession.setBlock(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ(), pattern);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -92,7 +94,7 @@ public class StencilBrush extends HeightBrush {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}, vector -> true, Integer.MAX_VALUE, editSession);
|
}, vector -> true, Integer.MAX_VALUE, editSession);
|
||||||
visitor.setDirections(Arrays.asList(visitor.DIAGONAL_DIRECTIONS));
|
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
|
||||||
visitor.visit(position);
|
visitor.visit(position);
|
||||||
Operations.completeBlindly(visitor);
|
Operations.completeBlindly(visitor);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.boydti.fawe.object.brush.heightmap;
|
package com.boydti.fawe.object.brush.heightmap;
|
||||||
|
|
||||||
import com.boydti.fawe.object.PseudoRandom;
|
|
||||||
import com.boydti.fawe.util.MainUtil;
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
@ -12,6 +11,8 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
|||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
public interface HeightMap {
|
public interface HeightMap {
|
||||||
public double getHeight(int x, int z);
|
public double getHeight(int x, int z);
|
||||||
|
|
||||||
@ -108,7 +109,7 @@ public interface HeightMap {
|
|||||||
int diff = targetY - height;
|
int diff = targetY - height;
|
||||||
double raiseScaled = diff * (raisePow * sizePowInv);
|
double raiseScaled = diff * (raisePow * sizePowInv);
|
||||||
double raiseScaledAbs = Math.abs(raiseScaled);
|
double raiseScaledAbs = Math.abs(raiseScaled);
|
||||||
int random = PseudoRandom.random.random(256) < (int) ((Math.ceil(raiseScaledAbs) - Math.floor(raiseScaledAbs)) * 256) ? (diff > 0 ? 1 : -1) : 0;
|
int random = ThreadLocalRandom.current().nextInt(256) < (int) ((Math.ceil(raiseScaledAbs) - Math.floor(raiseScaledAbs)) * 256) ? (diff > 0 ? 1 : -1) : 0;
|
||||||
int raiseScaledInt = (int) raiseScaled + random;
|
int raiseScaledInt = (int) raiseScaled + random;
|
||||||
newData[index] = height + raiseScaledInt;
|
newData[index] = height + raiseScaledInt;
|
||||||
}
|
}
|
||||||
@ -148,7 +149,7 @@ public interface HeightMap {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
raise = (yscale * raise);
|
raise = (yscale * raise);
|
||||||
int random = PseudoRandom.random.random(256) < (int) ((raise - (int) raise) * (256)) ? 1 : 0;
|
int random = ThreadLocalRandom.current().nextInt(256) < (int) ((raise - (int) raise) * (256)) ? 1 : 0;
|
||||||
int newHeight = height + (int) raise + random;
|
int newHeight = height + (int) raise + random;
|
||||||
newData[index] = newHeight;
|
newData[index] = newHeight;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import java.util.List;
|
|||||||
public class ScrollClipboard extends ScrollAction {
|
public class ScrollClipboard extends ScrollAction {
|
||||||
private final List<ClipboardHolder> clipboards;
|
private final List<ClipboardHolder> clipboards;
|
||||||
private final LocalSession session;
|
private final LocalSession session;
|
||||||
int index = 0;
|
private int index = 0;
|
||||||
|
|
||||||
public ScrollClipboard(BrushTool tool, LocalSession session, List<ClipboardHolder> clipboards) {
|
public ScrollClipboard(BrushTool tool, LocalSession session, List<ClipboardHolder> clipboards) {
|
||||||
super(tool);
|
super(tool);
|
||||||
|
@ -20,7 +20,6 @@ public class VisualQueue extends SingleThreadIntervalQueue<FawePlayer> {
|
|||||||
LocalSession session = fp.getSession();
|
LocalSession session = fp.getSession();
|
||||||
Player player = fp.getPlayer();
|
Player player = fp.getPlayer();
|
||||||
Tool tool = session.getTool(player);
|
Tool tool = session.getTool(player);
|
||||||
Brush brush;
|
|
||||||
if (tool instanceof BrushTool) {
|
if (tool instanceof BrushTool) {
|
||||||
BrushTool brushTool = (BrushTool) tool;
|
BrushTool brushTool = (BrushTool) tool;
|
||||||
if (brushTool.getVisualMode() != VisualMode.NONE) {
|
if (brushTool.getVisualMode() != VisualMode.NONE) {
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package com.boydti.fawe.object.mask;
|
package com.boydti.fawe.object.mask;
|
||||||
|
|
||||||
import com.boydti.fawe.FaweCache;
|
|
||||||
import com.boydti.fawe.object.PseudoRandom;
|
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
// TODO FIXME
|
// TODO FIXME
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
import com.boydti.fawe.object.PseudoRandom;
|
|
||||||
import com.boydti.fawe.object.schematic.Schematic;
|
import com.boydti.fawe.object.schematic.Schematic;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
||||||
@ -17,6 +15,7 @@ import com.sk89q.worldedit.session.ClipboardHolder;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.NotSerializableException;
|
import java.io.NotSerializableException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
@ -37,11 +36,11 @@ public class RandomFullClipboardPattern extends AbstractPattern {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
||||||
ClipboardHolder holder = clipboards.get(PseudoRandom.random.random(clipboards.size()));
|
ClipboardHolder holder = clipboards.get(ThreadLocalRandom.current().nextInt(clipboards.size()));
|
||||||
AffineTransform transform = new AffineTransform();
|
AffineTransform transform = new AffineTransform();
|
||||||
if (randomRotate) {
|
if (randomRotate) {
|
||||||
transform = transform.rotateY(PseudoRandom.random.random(4) * 90);
|
transform = transform.rotateY(ThreadLocalRandom.current().nextInt(4) * 90);
|
||||||
holder.setTransform(new AffineTransform().rotateY(PseudoRandom.random.random(4) * 90));
|
holder.setTransform(new AffineTransform().rotateY(ThreadLocalRandom.current().nextInt(4) * 90));
|
||||||
}
|
}
|
||||||
if (randomFlip) {
|
if (randomFlip) {
|
||||||
transform = transform.scale(Vector3.at(1, 0, 0).multiply(-2).add(1, 1, 1));
|
transform = transform.scale(Vector3.at(1, 0, 0).multiply(-2).add(1, 1, 1));
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -89,7 +89,7 @@ public final class BrushCache {
|
|||||||
String json = tool.toString(gson);
|
String json = tool.toString(gson);
|
||||||
map.put("weBrushJson", new StringTag(json));
|
map.put("weBrushJson", new StringTag(json));
|
||||||
if (display == null) {
|
if (display == null) {
|
||||||
map.put("display", new CompoundTag(displayMap = new HashMap()));
|
map.put("display", new CompoundTag(displayMap = new HashMap<>()));
|
||||||
} else {
|
} else {
|
||||||
displayMap = ReflectionUtils.getMap(display.getValue());
|
displayMap = ReflectionUtils.getMap(display.getValue());
|
||||||
}
|
}
|
||||||
|
@ -49,16 +49,16 @@ public class ImgurUtility {
|
|||||||
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||||
conn.connect();
|
conn.connect();
|
||||||
StringBuilder stb = new StringBuilder();
|
StringBuilder stb = new StringBuilder();
|
||||||
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
|
try (OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream())) {
|
||||||
wr.write(data);
|
wr.write(data);
|
||||||
wr.flush();
|
wr.flush();
|
||||||
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
try (BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()))) {
|
||||||
String line;
|
String line;
|
||||||
while ((line = rd.readLine()) != null) {
|
while ((line = rd.readLine()) != null) {
|
||||||
stb.append(line).append("\n");
|
stb.append(line).append("\n");
|
||||||
}
|
}
|
||||||
wr.close();
|
}
|
||||||
rd.close();
|
}
|
||||||
return stb.toString();
|
return stb.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,6 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
|
|
||||||
public enum Jars {
|
public enum Jars {
|
||||||
WE_B_6_1_7_2("https://addons.cursecdn.com/files/2431/372/worldedit-bukkit-6.1.7.2.jar",
|
|
||||||
"CRVJCWGJJ6UK40CTGHXQVK2/3C9BBTOS25FWI0ZHD4S=", 1726340),
|
|
||||||
|
|
||||||
VS_B_5_171_0("https://media.forgecdn.net/files/2488/589/VoxelSniper-5.172.0-SNAPSHOT.jar",
|
|
||||||
"4CTEDDEKCAN/M6R0DHS925++HBSJ/TUYAAKAR4CUWC4=", 3615020),
|
|
||||||
|
|
||||||
MM_v1_4_0("https://github.com/InventivetalentDev/MapManager/releases/download/1.4.0-SNAPSHOT/MapManager_v1.4.0-SNAPSHOT.jar",
|
MM_v1_4_0("https://github.com/InventivetalentDev/MapManager/releases/download/1.4.0-SNAPSHOT/MapManager_v1.4.0-SNAPSHOT.jar",
|
||||||
"AEO5SKBUGN4YJRS8XGGNLBM2QRZPTI1KF0/1W1URTGA=", 163279),
|
"AEO5SKBUGN4YJRS8XGGNLBM2QRZPTI1KF0/1W1URTGA=", 163279),
|
||||||
@ -45,7 +40,7 @@ public enum Jars {
|
|||||||
public byte[] download() throws IOException {
|
public byte[] download() throws IOException {
|
||||||
byte[] jarBytes = new byte[this.filesize];
|
byte[] jarBytes = new byte[this.filesize];
|
||||||
URL url = new URL(this.url);
|
URL url = new URL(this.url);
|
||||||
try (DataInputStream dis = new DataInputStream(url.openConnection().getInputStream());) {
|
try (DataInputStream dis = new DataInputStream(url.openConnection().getInputStream())) {
|
||||||
dis.readFully(jarBytes);
|
dis.readFully(jarBytes);
|
||||||
if (dis.read() != -1) { // assert that we've read everything
|
if (dis.read() != -1) { // assert that we've read everything
|
||||||
throw new IllegalStateException("downloaded jar is longer than expected");
|
throw new IllegalStateException("downloaded jar is longer than expected");
|
||||||
|
@ -15,12 +15,15 @@ import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
|||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||||
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import java.awt.Graphics2D;
|
import net.jpountz.lz4.*;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Parameter;
|
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
import java.nio.channels.Channels;
|
import java.nio.channels.Channels;
|
||||||
import java.nio.channels.FileChannel;
|
import java.nio.channels.FileChannel;
|
||||||
@ -28,6 +31,7 @@ import java.nio.channels.ReadableByteChannel;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.*;
|
import java.nio.file.*;
|
||||||
import java.nio.file.attribute.BasicFileAttributes;
|
import java.nio.file.attribute.BasicFileAttributes;
|
||||||
|
import java.util.List;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ForkJoinPool;
|
import java.util.concurrent.ForkJoinPool;
|
||||||
@ -37,9 +41,8 @@ import java.util.function.BiConsumer;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.zip.*;
|
import java.util.zip.*;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.imageio.ImageIO;
|
import static java.lang.System.arraycopy;
|
||||||
import net.jpountz.lz4.*;
|
|
||||||
|
|
||||||
public class MainUtil {
|
public class MainUtil {
|
||||||
/*
|
/*
|
||||||
@ -75,35 +78,6 @@ public class MainUtil {
|
|||||||
return suggestions;
|
return suggestions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> prepend(String start, List<String> suggestions) {
|
|
||||||
if (start.isEmpty()) {
|
|
||||||
return suggestions;
|
|
||||||
}
|
|
||||||
suggestions = new ArrayList<>(suggestions);
|
|
||||||
for (int i = 0; i < suggestions.size(); i++) {
|
|
||||||
suggestions.set(i, start + suggestions.get(i));
|
|
||||||
}
|
|
||||||
return suggestions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> T[] joinArrayGeneric(T[]... arrays) {
|
|
||||||
int length = 0;
|
|
||||||
for (T[] array : arrays) {
|
|
||||||
length += array.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
//T[] result = new T[length];
|
|
||||||
final T[] result = (T[]) Array.newInstance(arrays[0].getClass().getComponentType(), length);
|
|
||||||
|
|
||||||
int offset = 0;
|
|
||||||
for (T[] array : arrays) {
|
|
||||||
System.arraycopy(array, 0, result, offset, array.length);
|
|
||||||
offset += array.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> T getOf(Object[] arr, Class<T> ofType) {
|
public static <T> T getOf(Object[] arr, Class<T> ofType) {
|
||||||
for (Object a : arr) {
|
for (Object a : arr) {
|
||||||
if (a != null && a.getClass() == ofType) {
|
if (a != null && a.getClass() == ofType) {
|
||||||
@ -113,22 +87,6 @@ public class MainUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getParameterNames(Method method) {
|
|
||||||
Parameter[] parameters = method.getParameters();
|
|
||||||
List<String> parameterNames = new ArrayList<>();
|
|
||||||
|
|
||||||
for (Parameter parameter : parameters) {
|
|
||||||
if(!parameter.isNamePresent()) {
|
|
||||||
throw new IllegalArgumentException("Parameter names are not present!");
|
|
||||||
}
|
|
||||||
|
|
||||||
String parameterName = parameter.getName();
|
|
||||||
parameterNames.add(parameterName);
|
|
||||||
}
|
|
||||||
|
|
||||||
return parameterNames.toArray(new String[parameterNames.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static long getTotalSize(Path path) {
|
public static long getTotalSize(Path path) {
|
||||||
final AtomicLong size = new AtomicLong(0);
|
final AtomicLong size = new AtomicLong(0);
|
||||||
traverse(path, new RunnableVal2<Path, BasicFileAttributes>() {
|
traverse(path, new RunnableVal2<Path, BasicFileAttributes>() {
|
||||||
@ -217,9 +175,7 @@ public class MainUtil {
|
|||||||
|
|
||||||
public static int getMaxFileId(File folder) {
|
public static int getMaxFileId(File folder) {
|
||||||
final int[] max = new int[1];
|
final int[] max = new int[1];
|
||||||
folder.listFiles(new FileFilter() {
|
folder.listFiles(pathname -> {
|
||||||
@Override
|
|
||||||
public boolean accept(File pathname) {
|
|
||||||
String name = pathname.getName();
|
String name = pathname.getName();
|
||||||
Integer val = null;
|
Integer val = null;
|
||||||
if (pathname.isDirectory()) {
|
if (pathname.isDirectory()) {
|
||||||
@ -230,7 +186,6 @@ public class MainUtil {
|
|||||||
}
|
}
|
||||||
if (val != null && val > max[0]) max[0] = val;
|
if (val != null && val > max[0]) max[0] = val;
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return max[0] + 1;
|
return max[0] + 1;
|
||||||
}
|
}
|
||||||
@ -294,7 +249,7 @@ public class MainUtil {
|
|||||||
return baos.toByteArray();
|
return baos.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] decompress(byte[] bytes, byte[] buffer, Inflater inflater) throws IOException, DataFormatException {
|
public static byte[] decompress(byte[] bytes, byte[] buffer, Inflater inflater) throws DataFormatException {
|
||||||
if (buffer == null) {
|
if (buffer == null) {
|
||||||
buffer = new byte[8192];
|
buffer = new byte[8192];
|
||||||
}
|
}
|
||||||
@ -452,10 +407,11 @@ public class MainUtil {
|
|||||||
writer.append("--" + boundary + "--").append(CRLF).flush();
|
writer.append("--" + boundary + "--").append(CRLF).flush();
|
||||||
}
|
}
|
||||||
int responseCode = ((HttpURLConnection) con).getResponseCode();
|
int responseCode = ((HttpURLConnection) con).getResponseCode();
|
||||||
java.util.Scanner scanner = new java.util.Scanner(con.getInputStream()).useDelimiter("\\A");
|
String content;
|
||||||
String content = scanner.next().trim();
|
try (Scanner scanner = new Scanner(con.getInputStream()).useDelimiter("\\A")) {
|
||||||
scanner.close();
|
content = scanner.next().trim();
|
||||||
if (content != null && !content.startsWith("<")) {
|
}
|
||||||
|
if (!content.startsWith("<")) {
|
||||||
Fawe.debug(content);
|
Fawe.debug(content);
|
||||||
}
|
}
|
||||||
if (responseCode == 200) {
|
if (responseCode == 200) {
|
||||||
@ -512,8 +468,8 @@ public class MainUtil {
|
|||||||
return loader;
|
return loader;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable ignore) {
|
} catch (Throwable throwable) {
|
||||||
ignore.printStackTrace();
|
throwable.printStackTrace();
|
||||||
}
|
}
|
||||||
return sysloader;
|
return sysloader;
|
||||||
}
|
}
|
||||||
@ -527,12 +483,13 @@ public class MainUtil {
|
|||||||
public static void download(URL url, File out) throws IOException {
|
public static void download(URL url, File out) throws IOException {
|
||||||
File parent = out.getParentFile();
|
File parent = out.getParentFile();
|
||||||
if (!out.exists()) {
|
if (!out.exists()) {
|
||||||
if (parent != null) parent.mkdirs();
|
if (parent != null) {
|
||||||
|
parent.mkdirs();
|
||||||
|
}
|
||||||
File tempFile = File.createTempFile(UUID.randomUUID().toString(), ".tmp", parent);
|
File tempFile = File.createTempFile(UUID.randomUUID().toString(), ".tmp", parent);
|
||||||
tempFile.deleteOnExit();
|
tempFile.deleteOnExit();
|
||||||
try (InputStream is = url.openStream()) {
|
try (InputStream is = url.openStream(); ReadableByteChannel rbc = Channels.newChannel(is);
|
||||||
ReadableByteChannel rbc = Channels.newChannel(is);
|
FileOutputStream fos = new FileOutputStream(tempFile)) {
|
||||||
FileOutputStream fos = new FileOutputStream(tempFile);
|
|
||||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||||
}
|
}
|
||||||
Files.copy(tempFile.toPath(), out.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(tempFile.toPath(), out.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||||
@ -616,32 +573,14 @@ public class MainUtil {
|
|||||||
}
|
}
|
||||||
destFile.createNewFile();
|
destFile.createNewFile();
|
||||||
}
|
}
|
||||||
FileInputStream fIn = null;
|
try (FileInputStream fIn = new FileInputStream(sourceFile); FileChannel source = fIn.getChannel();
|
||||||
FileOutputStream fOut = null;
|
FileOutputStream fOut = new FileOutputStream(destFile); FileChannel destination = fOut.getChannel()) {
|
||||||
FileChannel source = null;
|
|
||||||
FileChannel destination = null;
|
|
||||||
try {
|
|
||||||
fIn = new FileInputStream(sourceFile);
|
|
||||||
source = fIn.getChannel();
|
|
||||||
fOut = new FileOutputStream(destFile);
|
|
||||||
destination = fOut.getChannel();
|
|
||||||
long transfered = 0;
|
long transfered = 0;
|
||||||
long bytes = source.size();
|
long bytes = source.size();
|
||||||
while (transfered < bytes) {
|
while (transfered < bytes) {
|
||||||
transfered += destination.transferFrom(source, 0, source.size());
|
transfered += destination.transferFrom(source, 0, source.size());
|
||||||
destination.position(transfered);
|
destination.position(transfered);
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
if (source != null) {
|
|
||||||
source.close();
|
|
||||||
} else if (fIn != null) {
|
|
||||||
fIn.close();
|
|
||||||
}
|
|
||||||
if (destination != null) {
|
|
||||||
destination.close();
|
|
||||||
} else if (fOut != null) {
|
|
||||||
fOut.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return destFile;
|
return destFile;
|
||||||
}
|
}
|
||||||
@ -793,31 +732,6 @@ public class MainUtil {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void smoothArray(int[] data, int width, int radius, int weight) {
|
|
||||||
int[] copy = data.clone();
|
|
||||||
int length = data.length / width;
|
|
||||||
int diameter = 2 * radius + 1;
|
|
||||||
weight += diameter * diameter - 1;
|
|
||||||
for (int x = 0; x < width; x++) {
|
|
||||||
for (int y = 0; y < length; y++) {
|
|
||||||
int index = x + width * y;
|
|
||||||
int value = 0;
|
|
||||||
int count = 0;
|
|
||||||
for (int x2 = Math.max(0, x - radius); x2 <= Math.min(width - 1, x + radius); x2++) {
|
|
||||||
for (int y2 = Math.max(0, y - radius); y2 <= Math.min(length - 1, y + radius); y2++) {
|
|
||||||
count++;
|
|
||||||
int index2 = x2 + width * y2;
|
|
||||||
value += data[index2];
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
value += data[index] * (weight - count);
|
|
||||||
value = value / (weight);
|
|
||||||
data[index] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void warnDeprecated(Class... alternatives) {
|
public static void warnDeprecated(Class... alternatives) {
|
||||||
StackTraceElement[] stacktrace = new RuntimeException().getStackTrace();
|
StackTraceElement[] stacktrace = new RuntimeException().getStackTrace();
|
||||||
if (stacktrace.length > 1) {
|
if (stacktrace.length > 1) {
|
||||||
@ -838,8 +752,8 @@ public class MainUtil {
|
|||||||
String myName = Class.forName(deprecatedElement.getClassName()).getSimpleName();
|
String myName = Class.forName(deprecatedElement.getClassName()).getSimpleName();
|
||||||
Fawe.debug("@" + creator + " used by " + myName + "." + deprecatedElement.getMethodName() + "():" + deprecatedElement.getLineNumber() + " is deprecated.");
|
Fawe.debug("@" + creator + " used by " + myName + "." + deprecatedElement.getMethodName() + "():" + deprecatedElement.getLineNumber() + " is deprecated.");
|
||||||
Fawe.debug(" - Alternatives: " + StringMan.getString(alternatives));
|
Fawe.debug(" - Alternatives: " + StringMan.getString(alternatives));
|
||||||
} catch (Throwable ignore) {
|
} catch (Throwable throwable) {
|
||||||
ignore.printStackTrace();
|
throwable.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -972,7 +886,7 @@ public class MainUtil {
|
|||||||
Class component = arr.getClass().getComponentType();
|
Class component = arr.getClass().getComponentType();
|
||||||
Object newInnerArray = Array.newInstance(component, innerArrayLength);
|
Object newInnerArray = Array.newInstance(component, innerArrayLength);
|
||||||
if (component.isPrimitive()) {
|
if (component.isPrimitive()) {
|
||||||
System.arraycopy(arr, 0, newInnerArray, 0, innerArrayLength);
|
arraycopy(arr, 0, newInnerArray, 0, innerArrayLength);
|
||||||
} else {
|
} else {
|
||||||
//copy each elem of the array
|
//copy each elem of the array
|
||||||
for (int i = 0; i < innerArrayLength; i++) {
|
for (int i = 0; i < innerArrayLength; i++) {
|
||||||
@ -1073,15 +987,12 @@ public class MainUtil {
|
|||||||
public static void deleteOlder(File directory, final long timeDiff, boolean printDebug) {
|
public static void deleteOlder(File directory, final long timeDiff, boolean printDebug) {
|
||||||
final long now = System.currentTimeMillis();
|
final long now = System.currentTimeMillis();
|
||||||
ForkJoinPool pool = new ForkJoinPool();
|
ForkJoinPool pool = new ForkJoinPool();
|
||||||
iterateFiles(directory, new Consumer<File>() {
|
iterateFiles(directory, file -> {
|
||||||
@Override
|
|
||||||
public void accept(File file) {
|
|
||||||
long age = now - file.lastModified();
|
long age = now - file.lastModified();
|
||||||
if (age > timeDiff) {
|
if (age > timeDiff) {
|
||||||
pool.submit(() -> file.delete());
|
pool.submit(file::delete);
|
||||||
if (printDebug) BBC.FILE_DELETED.send(null, file);
|
if (printDebug) BBC.FILE_DELETED.send(null, file);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
pool.shutdown();
|
pool.shutdown();
|
||||||
try {
|
try {
|
||||||
@ -1099,10 +1010,9 @@ public class MainUtil {
|
|||||||
if (directory.exists()) {
|
if (directory.exists()) {
|
||||||
File[] files = directory.listFiles();
|
File[] files = directory.listFiles();
|
||||||
if (null != files) {
|
if (null != files) {
|
||||||
for (int i = 0; i < files.length; i++) {
|
for (File file : files) {
|
||||||
File file = files[i];
|
|
||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
deleteDirectory(files[i], printDebug);
|
deleteDirectory(file, printDebug);
|
||||||
} else {
|
} else {
|
||||||
file.delete();
|
file.delete();
|
||||||
if (printDebug) BBC.FILE_DELETED.send(null, file);
|
if (printDebug) BBC.FILE_DELETED.send(null, file);
|
||||||
@ -1131,26 +1041,15 @@ public class MainUtil {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isValidSign(CompoundTag tag) {
|
|
||||||
Map<String, Tag> values = tag.getValue();
|
|
||||||
if (values.size() > 4 && values.containsKey("Text1")) {
|
|
||||||
Tag text1 = values.get("Text1");
|
|
||||||
Object value = text1.getValue();
|
|
||||||
return value != null && value instanceof String && ((String) value).length() > 0;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum OS {
|
public enum OS {
|
||||||
LINUX, SOLARIS, WINDOWS, MACOS, UNKNOWN;
|
LINUX, WINDOWS, MACOS, UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File getWorkingDirectory(String applicationName) {
|
public static File getWorkingDirectory(String applicationName) {
|
||||||
String userHome = System.getProperty("user.home", ".");
|
String userHome = System.getProperty("user.home", ".");
|
||||||
File workingDirectory = null;
|
File workingDirectory;
|
||||||
switch (getPlatform()) {
|
switch (getPlatform()) {
|
||||||
case LINUX:
|
case LINUX:
|
||||||
case SOLARIS:
|
|
||||||
workingDirectory = new File(userHome, '.' + applicationName + '/');
|
workingDirectory = new File(userHome, '.' + applicationName + '/');
|
||||||
break;
|
break;
|
||||||
case WINDOWS:
|
case WINDOWS:
|
||||||
@ -1181,12 +1080,6 @@ public class MainUtil {
|
|||||||
if (osName.contains("mac")) {
|
if (osName.contains("mac")) {
|
||||||
return OS.MACOS;
|
return OS.MACOS;
|
||||||
}
|
}
|
||||||
if (osName.contains("solaris")) {
|
|
||||||
return OS.SOLARIS;
|
|
||||||
}
|
|
||||||
if (osName.contains("sunos")) {
|
|
||||||
return OS.SOLARIS;
|
|
||||||
}
|
|
||||||
if (osName.contains("linux")) {
|
if (osName.contains("linux")) {
|
||||||
return OS.LINUX;
|
return OS.LINUX;
|
||||||
}
|
}
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
package com.boydti.fawe.util.cui;
|
|
||||||
|
|
||||||
import com.boydti.fawe.object.FawePlayer;
|
|
||||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
|
||||||
|
|
||||||
public abstract class CUI {
|
|
||||||
private final FawePlayer player;
|
|
||||||
|
|
||||||
public CUI(FawePlayer player) {
|
|
||||||
this.player = player;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> FawePlayer<T> getPlayer() {
|
|
||||||
return player;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void dispatchCUIEvent(CUIEvent event);
|
|
||||||
}
|
|
@ -230,9 +230,7 @@ public class ImageUtil {
|
|||||||
} else {
|
} else {
|
||||||
throw new ParameterException("Invalid image " + arg);
|
throw new ParameterException("Invalid image " + arg);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException | URISyntaxException e) {
|
||||||
throw new ParameterException(e);
|
|
||||||
} catch (URISyntaxException e) {
|
|
||||||
throw new ParameterException(e);
|
throw new ParameterException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
|
|||||||
import com.boydti.fawe.object.collection.SparseBitSet;
|
import com.boydti.fawe.object.collection.SparseBitSet;
|
||||||
import com.boydti.fawe.object.extent.ResettableExtent;
|
import com.boydti.fawe.object.extent.ResettableExtent;
|
||||||
import com.boydti.fawe.util.*;
|
import com.boydti.fawe.util.*;
|
||||||
import com.boydti.fawe.util.cui.CUI;
|
|
||||||
import com.boydti.fawe.wrappers.WorldWrapper;
|
import com.boydti.fawe.wrappers.WorldWrapper;
|
||||||
import com.sk89q.jchronic.Chronic;
|
import com.sk89q.jchronic.Chronic;
|
||||||
import com.sk89q.jchronic.Options;
|
import com.sk89q.jchronic.Options;
|
||||||
@ -127,10 +126,8 @@ public class LocalSession implements TextureHolder {
|
|||||||
private transient boolean toolControl = true;
|
private transient boolean toolControl = true;
|
||||||
private transient boolean superPickaxe = false;
|
private transient boolean superPickaxe = false;
|
||||||
private transient BlockTool pickaxeMode = new SinglePickaxe();
|
private transient BlockTool pickaxeMode = new SinglePickaxe();
|
||||||
|
|
||||||
private transient boolean hasTool = false;
|
private transient boolean hasTool = false;
|
||||||
private transient Tool[] tools = new Tool[ItemTypes.size()];
|
private transient Map<ItemType, Tool> tools = new HashMap<>();
|
||||||
|
|
||||||
private transient int maxBlocksChanged = -1;
|
private transient int maxBlocksChanged = -1;
|
||||||
private transient int maxTimeoutTime;
|
private transient int maxTimeoutTime;
|
||||||
private transient boolean useInventory;
|
private transient boolean useInventory;
|
||||||
@ -379,6 +376,11 @@ public class LocalSession implements TextureHolder {
|
|||||||
* @param editSession the edit session
|
* @param editSession the edit session
|
||||||
*/
|
*/
|
||||||
public void remember(EditSession editSession) {
|
public void remember(EditSession editSession) {
|
||||||
|
checkNotNull(editSession);
|
||||||
|
|
||||||
|
// Don't store anything if no changes were made
|
||||||
|
if (editSession.size() == 0) return;
|
||||||
|
|
||||||
FawePlayer fp = editSession.getPlayer();
|
FawePlayer fp = editSession.getPlayer();
|
||||||
int limit = fp == null ? Integer.MAX_VALUE : fp.getLimit().MAX_HISTORY;
|
int limit = fp == null ? Integer.MAX_VALUE : fp.getLimit().MAX_HISTORY;
|
||||||
remember(editSession, true, limit);
|
remember(editSession, true, limit);
|
||||||
@ -452,7 +454,7 @@ public class LocalSession implements TextureHolder {
|
|||||||
}
|
}
|
||||||
// It should have already been flushed, but just in case!
|
// It should have already been flushed, but just in case!
|
||||||
editSession.flushQueue();
|
editSession.flushQueue();
|
||||||
if (editSession == null || editSession.getChangeSet() == null || limitMb == 0 || ((historySize >> 20) > limitMb && !append)) {
|
if (editSession.getChangeSet() == null || limitMb == 0 || historySize >> 20 > limitMb && !append) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Don't store anything if no changes were made
|
// Don't store anything if no changes were made
|
||||||
@ -575,7 +577,7 @@ public class LocalSession implements TextureHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void unregisterTools(Player player) {
|
public void unregisterTools(Player player) {
|
||||||
for (Tool tool : tools) {
|
for (Tool tool : tools.values()) {
|
||||||
if (tool instanceof BrushTool) {
|
if (tool instanceof BrushTool) {
|
||||||
((BrushTool) tool).clear(player);
|
((BrushTool) tool).clear(player);
|
||||||
}
|
}
|
||||||
@ -691,7 +693,7 @@ public class LocalSession implements TextureHolder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (world != null) {
|
if (world != null) {
|
||||||
Fawe.imp().registerPacketListener();
|
//Fawe.imp().registerPacketListener();
|
||||||
world.update();
|
world.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -959,7 +961,7 @@ public class LocalSession implements TextureHolder {
|
|||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public Tool getTool(ItemType item) {
|
public Tool getTool(ItemType item) {
|
||||||
return tools[item.getInternalId()];
|
return tools.get(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@ -988,7 +990,6 @@ public class LocalSession implements TextureHolder {
|
|||||||
* @return the tool, or {@code null}
|
* @return the tool, or {@code null}
|
||||||
* @throws InvalidToolBindException if the item can't be bound to that item
|
* @throws InvalidToolBindException if the item can't be bound to that item
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
public BrushTool getBrushTool(ItemType item) throws InvalidToolBindException {
|
public BrushTool getBrushTool(ItemType item) throws InvalidToolBindException {
|
||||||
return getBrushTool(item.getDefaultState(), null, true);
|
return getBrushTool(item.getDefaultState(), null, true);
|
||||||
}
|
}
|
||||||
@ -1005,9 +1006,9 @@ public class LocalSession implements TextureHolder {
|
|||||||
|
|
||||||
public BrushTool getBrushTool(BaseItem item, Player player, boolean create) throws InvalidToolBindException {
|
public BrushTool getBrushTool(BaseItem item, Player player, boolean create) throws InvalidToolBindException {
|
||||||
Tool tool = getTool(item, player);
|
Tool tool = getTool(item, player);
|
||||||
if ((tool == null || !(tool instanceof BrushTool))) {
|
if (!(tool instanceof BrushTool)) {
|
||||||
if (create) {
|
if (create) {
|
||||||
tool = new BrushTool();
|
tool = new BrushTool("worldedit.brush.sphere");
|
||||||
setTool(item, tool, player);
|
setTool(item, tool, player);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
@ -1025,6 +1026,13 @@ public class LocalSession implements TextureHolder {
|
|||||||
* @throws InvalidToolBindException if the item can't be bound to that item
|
* @throws InvalidToolBindException if the item can't be bound to that item
|
||||||
*/
|
*/
|
||||||
public void setTool(ItemType item, @Nullable Tool tool) throws InvalidToolBindException {
|
public void setTool(ItemType item, @Nullable Tool tool) throws InvalidToolBindException {
|
||||||
|
if (item.hasBlockType()) {
|
||||||
|
throw new InvalidToolBindException(item, "Blocks can't be used");
|
||||||
|
} else if (item.getId().equalsIgnoreCase(config.wandItem)) {
|
||||||
|
throw new InvalidToolBindException(item, "Already used for the wand");
|
||||||
|
} else if (item.getId().equalsIgnoreCase(config.navigationWand)) {
|
||||||
|
throw new InvalidToolBindException(item, "Already used for the navigation wand");
|
||||||
|
}
|
||||||
setTool(item.getDefaultState(), tool, null);
|
setTool(item.getDefaultState(), tool, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1035,7 +1043,7 @@ public class LocalSession implements TextureHolder {
|
|||||||
|
|
||||||
public void setTool(BaseItem item, @Nullable Tool tool, Player player) throws InvalidToolBindException {
|
public void setTool(BaseItem item, @Nullable Tool tool, Player player) throws InvalidToolBindException {
|
||||||
ItemType type = item.getType();
|
ItemType type = item.getType();
|
||||||
if (type.hasBlockType() && type.getBlockType().getMaterial().isAir()) {
|
if (type.hasBlockType()) {
|
||||||
throw new InvalidToolBindException(type, "Blocks can't be used");
|
throw new InvalidToolBindException(type, "Blocks can't be used");
|
||||||
} else if (type.getId().equalsIgnoreCase(config.wandItem)) {
|
} else if (type.getId().equalsIgnoreCase(config.wandItem)) {
|
||||||
throw new InvalidToolBindException(type, "Already used for the wand");
|
throw new InvalidToolBindException(type, "Already used for the wand");
|
||||||
@ -1049,21 +1057,23 @@ public class LocalSession implements TextureHolder {
|
|||||||
if (tool != null) {
|
if (tool != null) {
|
||||||
((BrushTool) tool).setHolder(item);
|
((BrushTool) tool).setHolder(item);
|
||||||
} else {
|
} else {
|
||||||
this.tools[type.getInternalId()] = null;
|
this.tools.remove(type);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
previous = this.tools[type.getInternalId()];
|
previous = this.tools.get(type);
|
||||||
this.tools[type.getInternalId()] = tool;
|
this.tools.put(type, tool);
|
||||||
if (tool != null) {
|
if (tool != null) {
|
||||||
hasTool = true;
|
hasTool = true;
|
||||||
} else {
|
} else {
|
||||||
hasTool = false;
|
hasTool = false;
|
||||||
for (Tool i : this.tools) if (i != null) {
|
for (Tool i : this.tools.values()) {
|
||||||
|
if (i != null) {
|
||||||
hasTool = true;
|
hasTool = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (previous != null && player != null && previous instanceof BrushTool) {
|
if (previous != null && player != null && previous instanceof BrushTool) {
|
||||||
BrushTool brushTool = (BrushTool) previous;
|
BrushTool brushTool = (BrushTool) previous;
|
||||||
brushTool.clear(player);
|
brushTool.clear(player);
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
|
||||||
import com.boydti.fawe.config.BBC;
|
import com.boydti.fawe.config.BBC;
|
||||||
import com.boydti.fawe.config.Commands;
|
import com.boydti.fawe.config.Commands;
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
@ -29,10 +28,9 @@ import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
|
|||||||
import com.boydti.fawe.object.clipboard.URIClipboardHolder;
|
import com.boydti.fawe.object.clipboard.URIClipboardHolder;
|
||||||
import com.boydti.fawe.object.clipboard.remap.ClipboardRemapper;
|
import com.boydti.fawe.object.clipboard.remap.ClipboardRemapper;
|
||||||
import com.boydti.fawe.object.schematic.StructureFormat;
|
import com.boydti.fawe.object.schematic.StructureFormat;
|
||||||
import com.boydti.fawe.object.schematic.visualizer.SchemVis;
|
//import com.boydti.fawe.object.schematic.visualizer.SchemVis;
|
||||||
import com.boydti.fawe.util.MainUtil;
|
import com.boydti.fawe.util.MainUtil;
|
||||||
import com.boydti.fawe.util.chat.Message;
|
import com.boydti.fawe.util.chat.Message;
|
||||||
import com.google.common.collect.Multimap;
|
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandException;
|
import com.sk89q.minecraft.util.commands.CommandException;
|
||||||
@ -49,42 +47,28 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
|||||||
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
|
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
||||||
import com.sk89q.worldedit.function.operation.Operations;
|
import com.sk89q.worldedit.function.operation.Operations;
|
||||||
import com.sk89q.worldedit.math.transform.Transform;
|
import com.sk89q.worldedit.math.transform.Transform;
|
||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||||
import com.sk89q.worldedit.util.io.Closer;
|
|
||||||
import com.sk89q.worldedit.util.io.file.FilenameException;
|
import com.sk89q.worldedit.util.io.file.FilenameException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.*;
|
||||||
import java.io.BufferedOutputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.channels.Channels;
|
import java.nio.channels.Channels;
|
||||||
import java.nio.channels.ReadableByteChannel;
|
import java.nio.channels.ReadableByteChannel;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.atomic.LongAdder;
|
import java.util.concurrent.atomic.LongAdder;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import static com.boydti.fawe.util.ReflectionUtils.as;
|
import static com.boydti.fawe.util.ReflectionUtils.as;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commands that work with schematic files.
|
* Commands that work with schematic files.
|
||||||
@ -135,9 +119,7 @@ public class SchematicCommands extends MethodCommands {
|
|||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = {"clear"},
|
aliases = {"clear"},
|
||||||
usage = "",
|
|
||||||
desc = "Clear your clipboard",
|
desc = "Clear your clipboard",
|
||||||
min = 0,
|
|
||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions({"worldedit.clipboard.clear", "worldedit.schematic.clear"})
|
@CommandPermissions({"worldedit.clipboard.clear", "worldedit.schematic.clear"})
|
||||||
@ -165,7 +147,6 @@ public class SchematicCommands extends MethodCommands {
|
|||||||
uri = new File(root, fileName).toURI();
|
uri = new File(root, fileName).toURI();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean removed = false;
|
|
||||||
ClipboardHolder clipboard = session.getClipboard();
|
ClipboardHolder clipboard = session.getClipboard();
|
||||||
if (clipboard instanceof URIClipboardHolder) {
|
if (clipboard instanceof URIClipboardHolder) {
|
||||||
URIClipboardHolder identifiable = (URIClipboardHolder) clipboard;
|
URIClipboardHolder identifiable = (URIClipboardHolder) clipboard;
|
||||||
@ -205,11 +186,15 @@ public class SchematicCommands extends MethodCommands {
|
|||||||
player.print(BBC.getPrefix() + "Remapped schematic");
|
player.print(BBC.getPrefix() + "Remapped schematic");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"load"}, usage = "[<format>] <filename>", desc = "Load a schematic into your clipboard")
|
@Command(
|
||||||
|
aliases = {"load"},
|
||||||
|
usage = "[<format>] <filename>",
|
||||||
|
desc = "Load a schematic into your clipboard"
|
||||||
|
)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@CommandPermissions({"worldedit.clipboard.load", "worldedit.schematic.load", "worldedit.schematic.load.asset", "worldedit.schematic.load.web", "worldedit.schematic.load.other"})
|
@CommandPermissions({"worldedit.clipboard.load", "worldedit.schematic.load", "worldedit.schematic.load.asset", "worldedit.schematic.load.web", "worldedit.schematic.load.other"})
|
||||||
public void load(final Player player, final LocalSession session, @Optional() final String formatName, String filename) throws FilenameException {
|
public void load(Player player, LocalSession session, @Optional() String formatName, String filename) throws FilenameException {
|
||||||
final LocalConfiguration config = this.worldEdit.getConfiguration();
|
LocalConfiguration config = worldEdit.getConfiguration();
|
||||||
ClipboardFormat format = formatName == null ? null : ClipboardFormats.findByAlias(formatName);
|
ClipboardFormat format = formatName == null ? null : ClipboardFormats.findByAlias(formatName);
|
||||||
InputStream in = null;
|
InputStream in = null;
|
||||||
try {
|
try {
|
||||||
@ -225,13 +210,12 @@ public class SchematicCommands extends MethodCommands {
|
|||||||
ReadableByteChannel rbc = Channels.newChannel(url.openStream());
|
ReadableByteChannel rbc = Channels.newChannel(url.openStream());
|
||||||
in = Channels.newInputStream(rbc);
|
in = Channels.newInputStream(rbc);
|
||||||
uri = url.toURI();
|
uri = url.toURI();
|
||||||
if (format == null) format = BuiltInClipboardFormat.MCEDIT_SCHEMATIC;
|
|
||||||
} else {
|
} else {
|
||||||
if (!player.hasPermission("worldedit.schematic.load") && !player.hasPermission("worldedit.clipboard.load")) {
|
if (!player.hasPermission("worldedit.schematic.load") && !player.hasPermission("worldedit.clipboard.load")) {
|
||||||
BBC.NO_PERM.send(player, "worldedit.clipboard.load");
|
BBC.NO_PERM.send(player, "worldedit.clipboard.load");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
File working = this.worldEdit.getWorkingDirectoryFile(config.saveDir);
|
File working = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||||
File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, player.getUniqueId().toString()) : working;
|
File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, player.getUniqueId().toString()) : working;
|
||||||
File f;
|
File f;
|
||||||
if (filename.startsWith("#")) {
|
if (filename.startsWith("#")) {
|
||||||
@ -264,7 +248,7 @@ public class SchematicCommands extends MethodCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (f == null || !f.exists() || !MainUtil.isInSubDirectory(working, f)) {
|
if (f == null || !f.exists() || !MainUtil.isInSubDirectory(working, f)) {
|
||||||
player.printError(BBC.getPrefix() + "Schematic " + filename + " does not exist! (" + ((f == null) ? false : f.exists()) + "|" + f + "|" + (f == null ? false : !MainUtil.isInSubDirectory(working, f)) + ")");
|
player.printError(BBC.getPrefix() + "Schematic " + filename + " does not exist! (" + ((f != null) && f.exists()) + "|" + f + "|" + (f != null && !MainUtil.isInSubDirectory(working, f)) + ")");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (format == null) {
|
if (format == null) {
|
||||||
@ -294,17 +278,22 @@ public class SchematicCommands extends MethodCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"save"}, usage = "[format] <filename>", desc = "Save a schematic into your clipboard", help = "The default format for 1.13 is schem")
|
@Command(
|
||||||
|
aliases = {"save"},
|
||||||
|
usage = "[format] <filename>",
|
||||||
|
desc = "Save a schematic into your clipboard",
|
||||||
|
help = "The default format for 1.13 is schem"
|
||||||
|
)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@CommandPermissions({"worldedit.clipboard.save", "worldedit.schematic.save", "worldedit.schematic.save.other"})
|
@CommandPermissions({"worldedit.clipboard.save", "worldedit.schematic.save", "worldedit.schematic.save.other"})
|
||||||
public void save(final Player player, final LocalSession session, @Optional("schem") final String formatName, String filename, @Switch('g') boolean global, @Switch('f') boolean allowOverwrite) throws CommandException, WorldEditException {
|
public void save(Player player, LocalSession session, @Optional("schem") String formatName, String filename, @Switch('g') boolean global, @Switch('f') boolean allowOverwrite) throws CommandException, WorldEditException {
|
||||||
final LocalConfiguration config = this.worldEdit.getConfiguration();
|
LocalConfiguration config = worldEdit.getConfiguration();
|
||||||
final ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
|
ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
|
||||||
if (format == null) {
|
if (format == null) {
|
||||||
player.printError(BBC.getPrefix() + "Unknown schematic format: " + formatName);
|
player.printError(BBC.getPrefix() + "Unknown schematic format: " + formatName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
File working = this.worldEdit.getWorkingDirectoryFile(config.saveDir);
|
File working = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||||
File dir = !global && Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, player.getUniqueId().toString()) : working;
|
File dir = !global && Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, player.getUniqueId().toString()) : working;
|
||||||
if (filename.contains("../")) {
|
if (filename.contains("../")) {
|
||||||
if (!player.hasPermission("worldedit.schematic.save.other")) {
|
if (!player.hasPermission("worldedit.schematic.save.other")) {
|
||||||
@ -316,7 +305,7 @@ public class SchematicCommands extends MethodCommands {
|
|||||||
filename = filename.substring(3);
|
filename = filename.substring(3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File f = this.worldEdit.getSafeSaveFile(player, dir, filename, format.getPrimaryFileExtension(), format.getPrimaryFileExtension());
|
File f = worldEdit.getSafeSaveFile(player, dir, filename, format.getPrimaryFileExtension(), format.getPrimaryFileExtension());
|
||||||
if (f.getName().replaceAll("." + format.getPrimaryFileExtension(), "").isEmpty()) {
|
if (f.getName().replaceAll("." + format.getPrimaryFileExtension(), "").isEmpty()) {
|
||||||
File directory = f.getParentFile();
|
File directory = f.getParentFile();
|
||||||
if (directory.exists()) {
|
if (directory.exists()) {
|
||||||
@ -345,14 +334,14 @@ public class SchematicCommands extends MethodCommands {
|
|||||||
BBC.SCHEMATIC_MOVE_EXISTS.send(player, f.getName());
|
BBC.SCHEMATIC_MOVE_EXISTS.send(player, f.getName());
|
||||||
}
|
}
|
||||||
try (FileOutputStream fos = new FileOutputStream(f)) {
|
try (FileOutputStream fos = new FileOutputStream(f)) {
|
||||||
final ClipboardHolder holder = session.getClipboard();
|
ClipboardHolder holder = session.getClipboard();
|
||||||
final Clipboard clipboard = holder.getClipboard();
|
Clipboard clipboard = holder.getClipboard();
|
||||||
final Transform transform = holder.getTransform();
|
Transform transform = holder.getTransform();
|
||||||
final Clipboard target;
|
Clipboard target;
|
||||||
|
|
||||||
// If we have a transform, bake it into the copy
|
// If we have a transform, bake it into the copy
|
||||||
if (!transform.isIdentity()) {
|
if (!transform.isIdentity()) {
|
||||||
final FlattenedClipboardTransform result = FlattenedClipboardTransform.transform(clipboard, transform);
|
FlattenedClipboardTransform result = FlattenedClipboardTransform.transform(clipboard, transform);
|
||||||
target = new BlockArrayClipboard(result.getTransformedRegion(), UUID.randomUUID());
|
target = new BlockArrayClipboard(result.getTransformedRegion(), UUID.randomUUID());
|
||||||
target.setOrigin(clipboard.getOrigin());
|
target.setOrigin(clipboard.getOrigin());
|
||||||
Operations.completeLegacy(result.copyTo(target));
|
Operations.completeLegacy(result.copyTo(target));
|
||||||
@ -386,12 +375,19 @@ public class SchematicCommands extends MethodCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"move", "m"}, usage = "<directory>", desc = "Move your loaded schematic", help = "Move your currently loaded schematics", min = 1, max = 1)
|
@Command(
|
||||||
|
aliases = {"move", "m"},
|
||||||
|
usage = "<directory>",
|
||||||
|
desc = "Move your loaded schematic",
|
||||||
|
help = "Move your currently loaded schematics",
|
||||||
|
min = 1,
|
||||||
|
max = 1
|
||||||
|
)
|
||||||
@CommandPermissions({"worldedit.schematic.move", "worldedit.schematic.move.other"})
|
@CommandPermissions({"worldedit.schematic.move", "worldedit.schematic.move.other"})
|
||||||
public void move(final Player player, final LocalSession session, String directory) throws WorldEditException, IOException {
|
public void move(Player player, LocalSession session, String directory) throws WorldEditException, IOException {
|
||||||
final LocalConfiguration config = this.worldEdit.getConfiguration();
|
LocalConfiguration config = worldEdit.getConfiguration();
|
||||||
final File working = this.worldEdit.getWorkingDirectoryFile(config.saveDir);
|
File working = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||||
final File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, player.getUniqueId().toString()) : working;
|
File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, player.getUniqueId().toString()) : working;
|
||||||
File destDir = new File(dir, directory);
|
File destDir = new File(dir, directory);
|
||||||
if (!MainUtil.isInSubDirectory(working, destDir)) {
|
if (!MainUtil.isInSubDirectory(working, destDir)) {
|
||||||
player.printError(BBC.getPrefix() + "Directory " + destDir + " does not exist!");
|
player.printError(BBC.getPrefix() + "Directory " + destDir + " does not exist!");
|
||||||
@ -432,7 +428,14 @@ public class SchematicCommands extends MethodCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"delete", "d"}, usage = "<filename|*>", desc = "Delete a saved schematic", help = "Delete a schematic from the schematic list", min = 1, max = 1)
|
@Command(
|
||||||
|
aliases = {"delete", "d"},
|
||||||
|
usage = "<filename|*>",
|
||||||
|
desc = "Delete a saved schematic",
|
||||||
|
help = "Delete a schematic from the schematic list",
|
||||||
|
min = 1,
|
||||||
|
max = 1
|
||||||
|
)
|
||||||
@CommandPermissions({"worldedit.schematic.delete", "worldedit.schematic.delete.other"})
|
@CommandPermissions({"worldedit.schematic.delete", "worldedit.schematic.delete.other"})
|
||||||
public void delete(final Player player, final LocalSession session, final CommandContext args) throws WorldEditException, IOException {
|
public void delete(final Player player, final LocalSession session, final CommandContext args) throws WorldEditException, IOException {
|
||||||
final LocalConfiguration config = this.worldEdit.getConfiguration();
|
final LocalConfiguration config = this.worldEdit.getConfiguration();
|
||||||
@ -490,7 +493,11 @@ public class SchematicCommands extends MethodCommands {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = {"formats", "listformats", "f"}, desc = "List available formats", max = 0)
|
@Command(
|
||||||
|
aliases = {"formats", "listformats", "f"},
|
||||||
|
desc = "List available formats",
|
||||||
|
max = 0
|
||||||
|
)
|
||||||
@CommandPermissions("worldedit.schematic.formats")
|
@CommandPermissions("worldedit.schematic.formats")
|
||||||
public void formats(final Actor actor) throws WorldEditException {
|
public void formats(final Actor actor) throws WorldEditException {
|
||||||
BBC.SCHEMATIC_FORMAT.send(actor);
|
BBC.SCHEMATIC_FORMAT.send(actor);
|
||||||
@ -515,12 +522,11 @@ public class SchematicCommands extends MethodCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
@Command(
|
@Command(
|
||||||
aliases = {"show"},
|
aliases = {"show"},
|
||||||
desc = "Show a schematic",
|
desc = "Show a schematic",
|
||||||
usage = "[global|mine|<filter>]",
|
usage = "[global|mine|<filter>]",
|
||||||
min = 0,
|
|
||||||
max = -1,
|
|
||||||
flags = "dnp",
|
flags = "dnp",
|
||||||
help = "List all schematics in the schematics directory\n" +
|
help = "List all schematics in the schematics directory\n" +
|
||||||
" -f <format> restricts by format\n"
|
" -f <format> restricts by format\n"
|
||||||
@ -578,13 +584,12 @@ public class SchematicCommands extends MethodCommands {
|
|||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = {"list", "ls", "all"},
|
aliases = {"list", "ls", "all"},
|
||||||
desc = "List saved schematics",
|
desc = "List saved schematics",
|
||||||
usage = "[global|mine|<filter>] [page=1]",
|
usage = "[global|mine|<filter>] [page=1]",
|
||||||
min = 0,
|
|
||||||
max = -1,
|
|
||||||
flags = "dnp",
|
flags = "dnp",
|
||||||
help = "List all schematics in the schematics directory\n" +
|
help = "List all schematics in the schematics directory\n" +
|
||||||
" -p <page> prints the requested page\n" +
|
" -p <page> prints the requested page\n" +
|
||||||
|
@ -183,8 +183,8 @@ public class UtilityCommands extends MethodCommands {
|
|||||||
desc = "Generate the heightmap interface: https://github.com/boy0001/HeightMap"
|
desc = "Generate the heightmap interface: https://github.com/boy0001/HeightMap"
|
||||||
)
|
)
|
||||||
@CommandPermissions("fawe.admin")
|
@CommandPermissions("fawe.admin")
|
||||||
public void heightmapInterface(FawePlayer player, @Optional("100") int min, @Optional("200") int max) throws IOException {
|
public void heightmapInterface(Player player, @Optional("100") int min, @Optional("200") int max) throws IOException {
|
||||||
player.sendMessage("Please wait while we generate the minified heightmaps.");
|
player.print("Please wait while we generate the minified heightmaps.");
|
||||||
File srcFolder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HEIGHTMAP);
|
File srcFolder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HEIGHTMAP);
|
||||||
|
|
||||||
File webSrc = new File(Fawe.imp().getDirectory(), "web" + File.separator + "heightmap");
|
File webSrc = new File(Fawe.imp().getDirectory(), "web" + File.separator + "heightmap");
|
||||||
@ -206,7 +206,7 @@ public class UtilityCommands extends MethodCommands {
|
|||||||
BufferedImage img = MainUtil.readImage(file);
|
BufferedImage img = MainUtil.readImage(file);
|
||||||
BufferedImage minImg = ImageUtil.getScaledInstance(img, min, min, RenderingHints.VALUE_INTERPOLATION_BILINEAR, true);
|
BufferedImage minImg = ImageUtil.getScaledInstance(img, min, min, RenderingHints.VALUE_INTERPOLATION_BILINEAR, true);
|
||||||
BufferedImage maxImg = max == -1 ? img : ImageUtil.getScaledInstance(img, max, max, RenderingHints.VALUE_INTERPOLATION_BILINEAR, true);
|
BufferedImage maxImg = max == -1 ? img : ImageUtil.getScaledInstance(img, max, max, RenderingHints.VALUE_INTERPOLATION_BILINEAR, true);
|
||||||
player.sendMessage("Writing " + name);
|
player.print("Writing " + name);
|
||||||
File minFile = new File(minImages, name);
|
File minFile = new File(minImages, name);
|
||||||
File maxFile = new File(maxImages, name);
|
File maxFile = new File(maxImages, name);
|
||||||
minFile.getParentFile().mkdirs();
|
minFile.getParentFile().mkdirs();
|
||||||
@ -231,9 +231,9 @@ public class UtilityCommands extends MethodCommands {
|
|||||||
config.append("// The local source for the image (used in commands)\n");
|
config.append("// The local source for the image (used in commands)\n");
|
||||||
config.append("var src_local = \"file://\";\n");
|
config.append("var src_local = \"file://\";\n");
|
||||||
File configFile = new File(webSrc, "config.js");
|
File configFile = new File(webSrc, "config.js");
|
||||||
player.sendMessage("Writing " + configFile);
|
player.print("Writing " + configFile);
|
||||||
Files.write(configFile.toPath(), config.toString().getBytes());
|
Files.write(configFile.toPath(), config.toString().getBytes());
|
||||||
player.sendMessage("Done! See: `FastAsyncWorldEdit/web/heightmap`");
|
player.print("Done! See: `FastAsyncWorldEdit/web/heightmap`");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
|
@ -98,7 +98,6 @@ public class SelectionCommand extends SimpleCommand<Operation> {
|
|||||||
CuboidRegion cuboid = (CuboidRegion) selection;
|
CuboidRegion cuboid = (CuboidRegion) selection;
|
||||||
RegionFunction function = ((RegionVisitor) operation).function;
|
RegionFunction function = ((RegionVisitor) operation).function;
|
||||||
RegionWrapper current = new RegionWrapper(cuboid.getMinimumPoint(), cuboid.getMaximumPoint());
|
RegionWrapper current = new RegionWrapper(cuboid.getMinimumPoint(), cuboid.getMaximumPoint());
|
||||||
FawePlayer fp = FawePlayer.wrap(player);
|
|
||||||
FaweRegionExtent regionExtent = editSession.getRegionExtent();
|
FaweRegionExtent regionExtent = editSession.getRegionExtent();
|
||||||
|
|
||||||
if (function instanceof BlockReplace && regionExtent == null || regionExtent.isGlobal()) {
|
if (function instanceof BlockReplace && regionExtent == null || regionExtent.isGlobal()) {
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
package com.sk89q.worldedit.extent;
|
package com.sk89q.worldedit.extent;
|
||||||
|
|
||||||
import com.boydti.fawe.jnbt.anvil.generator.*;
|
import com.boydti.fawe.jnbt.anvil.generator.*;
|
||||||
import com.boydti.fawe.object.PseudoRandom;
|
|
||||||
import com.boydti.fawe.object.clipboard.WorldCopyClipboard;
|
import com.boydti.fawe.object.clipboard.WorldCopyClipboard;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
@ -32,7 +31,6 @@ import com.sk89q.worldedit.function.pattern.Pattern;
|
|||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||||
import com.sk89q.worldedit.math.MutableVector3;
|
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.registry.state.PropertyGroup;
|
import com.sk89q.worldedit.registry.state.PropertyGroup;
|
||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
|
@ -19,9 +19,19 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extent.clipboard.io;
|
package com.sk89q.worldedit.extent.clipboard.io;
|
||||||
|
|
||||||
|
import com.boydti.fawe.object.io.PGZIPOutputStream;
|
||||||
|
import com.boydti.fawe.object.io.ResettableFileInputStream;
|
||||||
|
import com.boydti.fawe.object.schematic.PNGWriter;
|
||||||
|
import com.boydti.fawe.object.schematic.StructureFormat;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import com.sk89q.jnbt.NBTInputStream;
|
||||||
|
import com.sk89q.jnbt.NBTOutputStream;
|
||||||
|
import com.sk89q.jnbt.NamedTag;
|
||||||
|
import com.sk89q.jnbt.Tag;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -32,28 +42,21 @@ import java.util.Set;
|
|||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
import java.util.zip.GZIPOutputStream;
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
import com.boydti.fawe.object.clipboard.AbstractClipboardFormat;
|
|
||||||
import com.boydti.fawe.object.io.PGZIPOutputStream;
|
|
||||||
import com.boydti.fawe.object.io.ResettableFileInputStream;
|
|
||||||
import com.boydti.fawe.object.schematic.PNGWriter;
|
|
||||||
import com.boydti.fawe.object.schematic.StructureFormat;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
|
||||||
import com.sk89q.jnbt.NBTConstants;
|
|
||||||
import com.sk89q.jnbt.NBTInputStream;
|
|
||||||
import com.sk89q.jnbt.NBTOutputStream;
|
|
||||||
import com.sk89q.jnbt.NamedTag;
|
|
||||||
import com.sk89q.jnbt.Tag;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A collection of supported clipboard formats.
|
* A collection of supported clipboard formats.
|
||||||
*/
|
*/
|
||||||
public enum BuiltInClipboardFormat implements ClipboardFormat {
|
public enum BuiltInClipboardFormat implements ClipboardFormat {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Schematic format used by MCEdit.
|
* The Schematic format used by MCEdit.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
MCEDIT_SCHEMATIC("mcedit", "mce", "schematic") {
|
MCEDIT_SCHEMATIC("mcedit", "mce", "schematic") {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPrimaryFileExtension() {
|
||||||
|
return "schematic";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClipboardReader getReader(InputStream inputStream) throws IOException {
|
public ClipboardReader getReader(InputStream inputStream) throws IOException {
|
||||||
if (inputStream instanceof FileInputStream) {
|
if (inputStream instanceof FileInputStream) {
|
||||||
@ -90,15 +93,14 @@ public enum BuiltInClipboardFormat implements ClipboardFormat{
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
SPONGE_SCHEMATIC("sponge", "schem") {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPrimaryFileExtension() {
|
public String getPrimaryFileExtension() {
|
||||||
return "schematic";
|
return "schem";
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
SPONGE_SCHEMATIC("sponge", "schem") {
|
|
||||||
@Override
|
@Override
|
||||||
public ClipboardReader getReader(InputStream inputStream) throws IOException {
|
public ClipboardReader getReader(InputStream inputStream) throws IOException {
|
||||||
if (inputStream instanceof FileInputStream) {
|
if (inputStream instanceof FileInputStream) {
|
||||||
@ -106,8 +108,7 @@ public enum BuiltInClipboardFormat implements ClipboardFormat{
|
|||||||
}
|
}
|
||||||
BufferedInputStream buffered = new BufferedInputStream(inputStream);
|
BufferedInputStream buffered = new BufferedInputStream(inputStream);
|
||||||
NBTInputStream nbtStream = new NBTInputStream(new BufferedInputStream(new GZIPInputStream(buffered)));
|
NBTInputStream nbtStream = new NBTInputStream(new BufferedInputStream(new GZIPInputStream(buffered)));
|
||||||
SpongeSchematicReader input = new SpongeSchematicReader(nbtStream);
|
return new SpongeSchematicReader(nbtStream);
|
||||||
return input;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -117,8 +118,7 @@ public enum BuiltInClipboardFormat implements ClipboardFormat{
|
|||||||
gzip = outputStream;
|
gzip = outputStream;
|
||||||
} else {
|
} else {
|
||||||
outputStream = new BufferedOutputStream(outputStream);
|
outputStream = new BufferedOutputStream(outputStream);
|
||||||
PGZIPOutputStream pigz = new PGZIPOutputStream(outputStream);
|
gzip = new PGZIPOutputStream(outputStream);
|
||||||
gzip = pigz;
|
|
||||||
}
|
}
|
||||||
NBTOutputStream nbtStream = new NBTOutputStream(new BufferedOutputStream(gzip));
|
NBTOutputStream nbtStream = new NBTOutputStream(new BufferedOutputStream(gzip));
|
||||||
return new SpongeSchematicWriter(nbtStream);
|
return new SpongeSchematicWriter(nbtStream);
|
||||||
@ -145,10 +145,6 @@ public enum BuiltInClipboardFormat implements ClipboardFormat{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPrimaryFileExtension() {
|
|
||||||
return "schem";
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -166,13 +162,7 @@ public enum BuiltInClipboardFormat implements ClipboardFormat{
|
|||||||
@Override
|
@Override
|
||||||
public ClipboardWriter getWriter(OutputStream outputStream) throws IOException {
|
public ClipboardWriter getWriter(OutputStream outputStream) throws IOException {
|
||||||
outputStream = new BufferedOutputStream(outputStream);
|
outputStream = new BufferedOutputStream(outputStream);
|
||||||
OutputStream gzip;
|
OutputStream gzip = new PGZIPOutputStream(outputStream);
|
||||||
if (outputStream instanceof PGZIPOutputStream || outputStream instanceof GZIPOutputStream) {
|
|
||||||
gzip = outputStream;
|
|
||||||
} else {
|
|
||||||
PGZIPOutputStream pigz = new PGZIPOutputStream(outputStream);
|
|
||||||
gzip = pigz;
|
|
||||||
}
|
|
||||||
NBTOutputStream nbtStream = new NBTOutputStream(new BufferedOutputStream(gzip));
|
NBTOutputStream nbtStream = new NBTOutputStream(new BufferedOutputStream(gzip));
|
||||||
return new StructureFormat(nbtStream);
|
return new StructureFormat(nbtStream);
|
||||||
}
|
}
|
||||||
@ -194,7 +184,7 @@ public enum BuiltInClipboardFormat implements ClipboardFormat{
|
|||||||
PNG("png", "image") {
|
PNG("png", "image") {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClipboardReader getReader(InputStream inputStream) throws IOException {
|
public ClipboardReader getReader(InputStream inputStream) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.internal.command;
|
package com.sk89q.worldedit.internal.command;
|
||||||
|
|
||||||
import com.boydti.fawe.object.FawePlayer;
|
|
||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.IncompleteRegionException;
|
import com.sk89q.worldedit.IncompleteRegionException;
|
||||||
@ -89,7 +88,7 @@ public class WorldEditBinding {
|
|||||||
public Object getSelection(ArgumentStack context) throws IncompleteRegionException, ParameterException {
|
public Object getSelection(ArgumentStack context) throws IncompleteRegionException, ParameterException {
|
||||||
Player sender = getPlayer(context);
|
Player sender = getPlayer(context);
|
||||||
LocalSession session = worldEdit.getSessionManager().get(sender);
|
LocalSession session = worldEdit.getSessionManager().get(sender);
|
||||||
return session.getSelection(FawePlayer.wrap(sender).getWorldForEditing());
|
return session.getSelection(sender.getWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,6 +46,7 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* An abstract implementation of {@link World}.
|
* An abstract implementation of {@link World}.
|
||||||
|
* Added by FAWE.
|
||||||
*/
|
*/
|
||||||
public interface SimpleWorld extends World {
|
public interface SimpleWorld extends World {
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user