Various unfinished

Start work on command GUI
Code cleanup
Add new lighting mode (see config)
Rename sponge -> sponge112
Fix sponge compile issues
Fix fuzzy region min/max not being set on first use
Fix clipboard on disk not closing on java 9
Start work on CFI chunk simplifier (for loading existing worlds)
Minor tile fixes for bukkit 1.12
This commit is contained in:
Jesse Boyd 2018-01-16 11:30:55 +11:00
parent d78d533acd
commit 134daefa24
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
69 changed files with 954 additions and 380 deletions

4
.gitignore vendored
View File

@ -20,6 +20,9 @@ gradle.log
/forge1710/build
/sponge/build
/sponge111/build
/nukkit/out
/sponge112/build
/core/out
/bukkit/build
/bukkit0/build
/bukkit19/build
@ -31,3 +34,4 @@ wiki_permissions.md
/textures
*.iml
/obj
*.jar

View File

@ -3,6 +3,7 @@ repositories {
}
dependencies {
compile project(':core')
compile 'com.sk89q:worldguard:6.0.0-SNAPSHOT'
compile('com.destroystokyo.paper:paper-api:1.12-R0.1-SNAPSHOT') {
exclude group: 'net.md-5'
}
@ -30,6 +31,7 @@ dependencies {
compile 'org.bukkit.craftbukkit:CraftBukkit:1.8.8'
compile 'com.comphenix.protocol:ProtocolLib-API:4.4.0-SNAPSHOT'
compile 'com.wasteofplastic:askyblock:3.0.8.2'
compile 'org.inventivetalent:mapmanager:1.4.0-SNAPSHOT'
}
processResources {

View File

@ -17,6 +17,7 @@ import com.boydti.fawe.bukkit.regions.PreciousStonesFeature;
import com.boydti.fawe.bukkit.regions.ResidenceFeature;
import com.boydti.fawe.bukkit.regions.TownyFeature;
import com.boydti.fawe.bukkit.regions.Worldguard;
import com.boydti.fawe.bukkit.util.BukkitReflectionUtils;
import com.boydti.fawe.bukkit.util.BukkitTaskMan;
import com.boydti.fawe.bukkit.util.ItemUtil;
import com.boydti.fawe.bukkit.util.VaultUtil;
@ -374,7 +375,7 @@ public class FaweBukkit implements IFawe, Listener {
public FaweQueue getNewQueue(String world, boolean fast) {
if (playerChunk != (playerChunk = true)) {
try {
Field fieldDirtyCount = ReflectionUtils.getRefClass("{nms}.PlayerChunk").getField("dirtyCount").getRealField();
Field fieldDirtyCount = BukkitReflectionUtils.getRefClass("{nms}.PlayerChunk").getField("dirtyCount").getRealField();
fieldDirtyCount.setAccessible(true);
int mod = fieldDirtyCount.getModifiers();
if ((mod & Modifier.VOLATILE) == 0) {
@ -427,7 +428,7 @@ public class FaweBukkit implements IFawe, Listener {
if (fast) {
if (playerChunk != (playerChunk = true)) {
try {
Field fieldDirtyCount = ReflectionUtils.getRefClass("{nms}.PlayerChunk").getField("dirtyCount").getRealField();
Field fieldDirtyCount = BukkitReflectionUtils.getRefClass("{nms}.PlayerChunk").getField("dirtyCount").getRealField();
fieldDirtyCount.setAccessible(true);
int mod = fieldDirtyCount.getModifiers();
if ((mod & Modifier.VOLATILE) == 0) {

View File

@ -0,0 +1,109 @@
package com.boydti.fawe.bukkit.util;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.ReflectionUtils;
import java.lang.reflect.Method;
import org.bukkit.Bukkit;
import org.bukkit.Server;
public class BukkitReflectionUtils {
/**
* prefix of bukkit classes
*/
private static volatile String preClassB = null;
/**
* prefix of minecraft classes
*/
private static volatile String preClassM = null;
/**
* boolean value, TRUE if server uses forge or MCPC+
*/
private static boolean forge = false;
/**
* check server version and class names
*/
public static void init() {
if (Bukkit.getServer() != null) {
if (Bukkit.getVersion().contains("MCPC") || Bukkit.getVersion().contains("Forge")) {
forge = true;
}
final Server server = Bukkit.getServer();
final Class<?> bukkitServerClass = server.getClass();
String[] pas = bukkitServerClass.getName().split("\\.");
if (pas.length == 5) {
final String verB = pas[3];
preClassB = "org.bukkit.craftbukkit." + verB;
}
try {
final Method getHandle = bukkitServerClass.getDeclaredMethod("getHandle");
final Object handle = getHandle.invoke(server);
final Class handleServerClass = handle.getClass();
pas = handleServerClass.getName().split("\\.");
if (pas.length == 5) {
final String verM = pas[3];
preClassM = "net.minecraft.server." + verM;
}
} catch (final Exception ignored) {
MainUtil.handleError(ignored);
}
}
}
/**
* @return true if server has forge classes
*/
public static boolean isForge() {
return forge;
}
/**
* Get class for name. Replace {nms} to net.minecraft.server.V*. Replace {cb} to org.bukkit.craftbukkit.V*. Replace
* {nm} to net.minecraft
*
* @param classes possible class paths
* @return RefClass object
* @throws RuntimeException if no class found
*/
public static ReflectionUtils.RefClass getRefClass(final String... classes) throws RuntimeException {
if (preClassM == null) {
init();
}
for (String className : classes) {
try {
className = className.replace("{cb}", preClassB).replace("{nms}", preClassM).replace("{nm}", "net.minecraft");
return ReflectionUtils.getRefClass(Class.forName(className));
} catch (final ClassNotFoundException ignored) {
}
}
throw new RuntimeException("no class found: " + classes[0].replace("{cb}", preClassB).replace("{nms}", preClassM).replace("{nm}", "net.minecraft"));
}
public static Class<?> getNmsClass(final String name) {
final String className = "net.minecraft.server." + getVersion() + "." + name;
return ReflectionUtils.getClass(className);
}
public static Class<?> getCbClass(final String name) {
final String className = "org.bukkit.craftbukkit." + getVersion() + "." + name;
return ReflectionUtils.getClass(className);
}
public static Class<?> getUtilClass(final String name) {
try {
return Class.forName(name); //Try before 1.8 first
} catch (final ClassNotFoundException ex) {
try {
return Class.forName("net.minecraft.util." + name); //Not 1.8
} catch (final ClassNotFoundException ex2) {
return null;
}
}
}
public static String getVersion() {
final String packageName = Bukkit.getServer().getClass().getPackage().getName();
return packageName.substring(packageName.lastIndexOf('.') + 1);
}
}

View File

@ -25,13 +25,13 @@ public class ItemUtil {
private SoftReference<Int2ObjectOpenHashMap<WeakReference<Tag>>> hashToNMSTag = new SoftReference(new Int2ObjectOpenHashMap<>());
public ItemUtil() throws Exception {
this.classCraftItemStack = ReflectionUtils.getCbClass("inventory.CraftItemStack");
this.classNMSItem = ReflectionUtils.getNmsClass("ItemStack");
this.classCraftItemStack = BukkitReflectionUtils.getCbClass("inventory.CraftItemStack");
this.classNMSItem = BukkitReflectionUtils.getNmsClass("ItemStack");
this.methodAsNMSCopy = ReflectionUtils.setAccessible(classCraftItemStack.getDeclaredMethod("asNMSCopy", ItemStack.class));
this.methodHasTag = ReflectionUtils.setAccessible(classNMSItem.getDeclaredMethod("hasTag"));
this.methodGetTag = ReflectionUtils.setAccessible(classNMSItem.getDeclaredMethod("getTag"));
this.fieldHandle = ReflectionUtils.setAccessible(classCraftItemStack.getDeclaredField("handle"));
Class<?> classNBTTagCompound = ReflectionUtils.getNmsClass("NBTTagCompound");
Class<?> classNBTTagCompound = BukkitReflectionUtils.getNmsClass("NBTTagCompound");
this.methodSetTag = ReflectionUtils.setAccessible(classNMSItem.getDeclaredMethod("setTag", classNBTTagCompound));
this.methodAsBukkitCopy = ReflectionUtils.setAccessible(classCraftItemStack.getDeclaredMethod("asBukkitCopy", classNMSItem));
}

View File

@ -4,6 +4,7 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.bukkit.BukkitPlayer;
import com.boydti.fawe.bukkit.FaweBukkit;
import com.boydti.fawe.bukkit.util.BukkitReflectionUtils;
import com.boydti.fawe.bukkit.v1_12.packet.FaweChunkPacket;
import com.boydti.fawe.bukkit.v1_12.packet.MCAChunkPacket;
import com.boydti.fawe.example.CharFaweChunk;
@ -36,7 +37,6 @@ import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.ChunkSnapshot;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldCreator;
@ -59,7 +59,7 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
private static Method methodGetHandle;
static {
Class<?> classCraftChunk = ReflectionUtils.getCbClass("CraftChunk");
Class<?> classCraftChunk = BukkitReflectionUtils.getCbClass("CraftChunk");
try {
methodGetHandle = ReflectionUtils.setAccessible(classCraftChunk.getDeclaredMethod("getHandle"));
} catch (NoSuchMethodException e) {
@ -221,6 +221,11 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
return false;
}
@Override
public boolean removeSectionLighting(SECTION sections, int layer, boolean hasSky) {
return false;
}
public static void checkVersion(String supported) {
String version = Bukkit.getServer().getClass().getPackage().getName();
if (!version.contains(supported)) {

View File

@ -1,6 +1,7 @@
package com.boydti.fawe.bukkit.v0;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.bukkit.util.BukkitReflectionUtils;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.example.NullRelighter;
import com.boydti.fawe.example.Relighter;
@ -101,17 +102,17 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
static {
try {
ReflectionUtils.init();
classRegionFileCache = ReflectionUtils.getNmsClass("RegionFileCache");
classRegionFile = ReflectionUtils.getNmsClass("RegionFile");
classCraftChunk = ReflectionUtils.getCbClass("CraftChunk");
classNMSChunk = ReflectionUtils.getNmsClass("Chunk");
classCraftWorld = ReflectionUtils.getCbClass("CraftWorld");
classNMSWorld = ReflectionUtils.getNmsClass("World");
classChunkProviderServer = ReflectionUtils.getNmsClass("ChunkProviderServer");
classIChunkProvider = ReflectionUtils.getNmsClass("IChunkProvider");
classIChunkLoader = ReflectionUtils.getNmsClass("IChunkLoader");
classChunkRegionLoader = ReflectionUtils.getNmsClass("ChunkRegionLoader");
BukkitReflectionUtils.init();
classRegionFileCache = BukkitReflectionUtils.getNmsClass("RegionFileCache");
classRegionFile = BukkitReflectionUtils.getNmsClass("RegionFile");
classCraftChunk = BukkitReflectionUtils.getCbClass("CraftChunk");
classNMSChunk = BukkitReflectionUtils.getNmsClass("Chunk");
classCraftWorld = BukkitReflectionUtils.getCbClass("CraftWorld");
classNMSWorld = BukkitReflectionUtils.getNmsClass("World");
classChunkProviderServer = BukkitReflectionUtils.getNmsClass("ChunkProviderServer");
classIChunkProvider = BukkitReflectionUtils.getNmsClass("IChunkProvider");
classIChunkLoader = BukkitReflectionUtils.getNmsClass("IChunkLoader");
classChunkRegionLoader = BukkitReflectionUtils.getNmsClass("ChunkRegionLoader");
methodGetHandleChunk = ReflectionUtils.setAccessible(classCraftChunk.getDeclaredMethod("getHandle"));
methodGetHandleWorld = ReflectionUtils.setAccessible(classCraftWorld.getDeclaredMethod("getHandle"));

View File

@ -1,6 +1,7 @@
package com.boydti.fawe.bukkit.v0;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.bukkit.util.BukkitReflectionUtils;
import com.boydti.fawe.util.ReflectionUtils;
import com.sk89q.jnbt.ByteArrayTag;
import com.sk89q.jnbt.ByteTag;
@ -82,13 +83,13 @@ public class FaweAdapter_All implements BukkitImplAdapter {
private Map<Class<? extends Tag>, Integer> TagToId = new ConcurrentHashMap<>();
public FaweAdapter_All() throws Throwable {
ReflectionUtils.init();
classCraftWorld = ReflectionUtils.getCbClass("CraftWorld");
classCraftBlock = ReflectionUtils.getCbClass("block.CraftBlock");
classCraftEntity = ReflectionUtils.getCbClass("entity.CraftEntity");
classBiomeBase = ReflectionUtils.getNmsClass("BiomeBase");
classWorld = ReflectionUtils.getNmsClass("World");
classTileEntity = ReflectionUtils.getNmsClass("TileEntity");
BukkitReflectionUtils.init();
classCraftWorld = BukkitReflectionUtils.getCbClass("CraftWorld");
classCraftBlock = BukkitReflectionUtils.getCbClass("block.CraftBlock");
classCraftEntity = BukkitReflectionUtils.getCbClass("entity.CraftEntity");
classBiomeBase = BukkitReflectionUtils.getNmsClass("BiomeBase");
classWorld = BukkitReflectionUtils.getNmsClass("World");
classTileEntity = BukkitReflectionUtils.getNmsClass("TileEntity");
biomeToBiomeBase = ReflectionUtils.setAccessible(classCraftBlock.getDeclaredMethod("biomeToBiomeBase", Biome.class));
biomeBaseToBiome = ReflectionUtils.setAccessible(classCraftBlock.getDeclaredMethod("biomeBaseToBiome", classBiomeBase));
@ -97,7 +98,7 @@ public class FaweAdapter_All implements BukkitImplAdapter {
getHandleWorld = ReflectionUtils.setAccessible(classCraftWorld.getDeclaredMethod("getHandle"));
getHandleEntity = ReflectionUtils.setAccessible(classCraftEntity.getDeclaredMethod("getHandle"));
try {
classBlockPosition = ReflectionUtils.getNmsClass("BlockPosition");
classBlockPosition = BukkitReflectionUtils.getNmsClass("BlockPosition");
} catch (Throwable ignore) {
}
if (classBlockPosition != null) {
@ -109,9 +110,9 @@ public class FaweAdapter_All implements BukkitImplAdapter {
getTileEntity2 = ReflectionUtils.setAccessible(classWorld.getDeclaredMethod("getTileEntity", int.class, int.class, int.class));
}
classNBTTagCompound = ReflectionUtils.getNmsClass("NBTTagCompound");
classNBTBase = ReflectionUtils.getNmsClass("NBTBase");
classNBTTagInt = ReflectionUtils.getNmsClass("NBTTagInt");
classNBTTagCompound = BukkitReflectionUtils.getNmsClass("NBTTagCompound");
classNBTBase = BukkitReflectionUtils.getNmsClass("NBTBase");
classNBTTagInt = BukkitReflectionUtils.getNmsClass("NBTTagInt");
newNBTTagInt = ReflectionUtils.setAccessible(classNBTTagInt.getConstructor(int.class));
setNBTTagCompound = ReflectionUtils.setAccessible(classNBTTagCompound.getDeclaredMethod("set", String.class, classNBTBase));
newNBTTagCompound = ReflectionUtils.setAccessible(classNBTTagCompound.getConstructor());
@ -139,7 +140,7 @@ public class FaweAdapter_All implements BukkitImplAdapter {
int noMods = Modifier.STATIC;
int hasMods = 0;
for (int i = 0; i < nmsClasses.size(); i++) {
Class<?> nmsClass = ReflectionUtils.getNmsClass(nmsClasses.get(i));
Class<?> nmsClass = BukkitReflectionUtils.getNmsClass(nmsClasses.get(i));
Class<? extends Tag> weClass = weClasses.get(i);
TagToId.put(weClass, ids[i]);
@ -217,15 +218,15 @@ public class FaweAdapter_All implements BukkitImplAdapter {
}
}
try {
classEntity = ReflectionUtils.getNmsClass("Entity");
classEntityTypes = ReflectionUtils.getNmsClass("EntityTypes");
classEntity = BukkitReflectionUtils.getNmsClass("Entity");
classEntityTypes = BukkitReflectionUtils.getNmsClass("EntityTypes");
getBukkitEntity = ReflectionUtils.setAccessible(classEntity.getDeclaredMethod("getBukkitEntity"));
addEntity = ReflectionUtils.setAccessible(classWorld.getDeclaredMethod("addEntity", classEntity, CreatureSpawnEvent.SpawnReason.class));
setLocation = ReflectionUtils.setAccessible(classEntity.getDeclaredMethod("setLocation", double.class, double.class, double.class, float.class, float.class));
try {
classMinecraftKey = ReflectionUtils.getNmsClass("MinecraftKey");
classMinecraftKey = BukkitReflectionUtils.getNmsClass("MinecraftKey");
newMinecraftKey = classMinecraftKey.getConstructor(String.class);
} catch (Throwable ignore) {
}

View File

@ -648,20 +648,16 @@ public class BukkitQueue_1_10 extends BukkitQueue_0<net.minecraft.server.v1_10_R
}
@Override
public boolean removeLighting(ChunkSection[] sections, RelightMode mode, boolean sky) {
if (mode != RelightMode.NONE) {
for (int i = 0; i < sections.length; i++) {
ChunkSection section = sections[i];
public boolean removeSectionLighting(ChunkSection section, int layer, boolean sky) {
if (section != null) {
section.a(new NibbleArray()); // Emitted
section.a(new NibbleArray());
if (sky) {
section.b(new NibbleArray()); // Skylight
}
}
}
section.b(new NibbleArray());
}
return true;
}
return false;
}
@Override
public void setFullbright(ChunkSection[] sections) {

View File

@ -650,20 +650,16 @@ public class BukkitQueue_1_11 extends BukkitQueue_0<net.minecraft.server.v1_11_R
}
@Override
public boolean removeLighting(ChunkSection[] sections, RelightMode mode, boolean sky) {
if (mode != RelightMode.NONE) {
for (int i = 0; i < sections.length; i++) {
ChunkSection section = sections[i];
public boolean removeSectionLighting(ChunkSection section, int layer, boolean sky) {
if (section != null) {
section.a(new NibbleArray()); // Emitted
section.a(new NibbleArray());
if (sky) {
section.b(new NibbleArray()); // Skylight
}
}
}
section.b(new NibbleArray());
}
return true;
}
return false;
}
@Override
public void setFullbright(ChunkSection[] sections) {

View File

@ -245,8 +245,10 @@ public class BukkitChunk_1_12 extends CharFaweChunk<Chunk, BukkitQueue_1_12> {
if (copy != null) {
copy.storeEntity(entity);
}
removeEntity(entity);
iter.remove();
synchronized (BukkitQueue_0.class) {
removeEntity(entity);
}
}
}
}
@ -290,12 +292,14 @@ public class BukkitChunk_1_12 extends CharFaweChunk<Chunk, BukkitQueue_1_12> {
copy.storeEntity(entity);
}
iter.remove();
synchronized (BukkitQueue_0.class) {
removeEntity(entity);
}
}
}
}
}
}
// Set entities
Set<CompoundTag> entitiesToSpawn = this.getEntities();
Set<UUID> createdEntities = new HashSet<>();
@ -340,7 +344,9 @@ public class BukkitChunk_1_12 extends CharFaweChunk<Chunk, BukkitQueue_1_12> {
entity.f(tag);
}
entity.setLocation(x, y, z, yaw, pitch);
synchronized (BukkitQueue_0.class) {
nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
}
createdEntities.add(entity.getUniqueID());
}
}
@ -373,6 +379,7 @@ public class BukkitChunk_1_12 extends CharFaweChunk<Chunk, BukkitQueue_1_12> {
}
}
if (toRemove != null) {
synchronized (BukkitQueue_0.class) {
for (Map.Entry<BlockPosition, TileEntity> entry : toRemove.entrySet()) {
BlockPosition bp = entry.getKey();
TileEntity tile = entry.getValue();
@ -381,7 +388,7 @@ public class BukkitChunk_1_12 extends CharFaweChunk<Chunk, BukkitQueue_1_12> {
nmsWorld.s(bp);
tile.invalidateBlockCache();
}
}
}
// Set blocks
for (int j = 0; j < sections.length; j++) {
@ -485,6 +492,7 @@ public class BukkitChunk_1_12 extends CharFaweChunk<Chunk, BukkitQueue_1_12> {
int y = (blockHash & 0xFF);
int z = (blockHash >> 8 & 0xF) + bz;
BlockPosition pos = new BlockPosition(x, y, z); // Set pos
synchronized (BukkitQueue_0.class) {
TileEntity tileEntity = nmsWorld.getTileEntity(pos);
if (tileEntity != null) {
NBTTagCompound tag = (NBTTagCompound) BukkitQueue_1_12.fromNative(nativeTag);
@ -498,6 +506,7 @@ public class BukkitChunk_1_12 extends CharFaweChunk<Chunk, BukkitQueue_1_12> {
}
}
}
}
// Change task
if (copy != null) {
getParent().getChangeTask().run(copy, this);

View File

@ -730,20 +730,16 @@ public class BukkitQueue_1_12 extends BukkitQueue_0<net.minecraft.server.v1_12_R
}
@Override
public boolean removeLighting(ChunkSection[] sections, RelightMode mode, boolean sky) {
if (mode != RelightMode.NONE) {
for (int i = 0; i < sections.length; i++) {
ChunkSection section = sections[i];
public boolean removeSectionLighting(ChunkSection section, int layer, boolean sky) {
if (section != null) {
section.a(new NibbleArray()); // Emitted
section.a(null);
if (sky) {
section.b(new NibbleArray()); // Skylight
}
}
}
section.b(null);
}
return true;
}
return false;
}
@Override
public void setFullbright(ChunkSection[] sections) {

View File

@ -549,20 +549,16 @@ public class BukkitQueue17 extends BukkitQueue_0<net.minecraft.server.v1_7_R4.Ch
}
@Override
public boolean removeLighting(ChunkSection[] sections, RelightMode mode, boolean sky) {
if (mode == RelightMode.ALL) {
for (int i = 0; i < sections.length; i++) {
ChunkSection section = sections[i];
public boolean removeSectionLighting(ChunkSection section, int layer, boolean sky) {
if (section != null) {
section.setEmittedLightArray(null);
if (sky) {
section.setSkyLightArray(null);
}
}
}
}
return true;
}
return false;
}
@Override
public World createWorld(final WorldCreator creator) {

View File

@ -542,20 +542,16 @@ public class BukkitQueue18R3 extends BukkitQueue_0<net.minecraft.server.v1_8_R3.
}
@Override
public boolean removeLighting(ChunkSection[] sections, RelightMode mode, boolean sky) {
if (mode == RelightMode.ALL) {
for (int i = 0; i < sections.length; i++) {
ChunkSection section = sections[i];
public boolean removeSectionLighting(ChunkSection section, int layer, boolean sky) {
if (section != null) {
section.a(new NibbleArray());
if (sky) {
section.b(new NibbleArray());
}
}
}
}
return true;
}
return false;
}
@Override
public World createWorld(final WorldCreator creator) {

View File

@ -593,20 +593,16 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<net.minecraft.server.v1_9_
}
@Override
public boolean removeLighting(ChunkSection[] sections, RelightMode mode, boolean sky) {
if (mode == RelightMode.ALL) {
for (int i = 0; i < sections.length; i++) {
ChunkSection section = sections[i];
public boolean removeSectionLighting(ChunkSection section, int layer, boolean sky) {
if (section != null) {
section.a(new NibbleArray());
if (sky) {
section.b(new NibbleArray());
}
}
}
}
return true;
}
return false;
}
@Override
public void relight(int x, int y, int z) {

View File

@ -6,7 +6,6 @@ dependencies {
compile 'org.yaml:snakeyaml:1.16'
compile 'com.google.code.gson:gson:2.2.4'
compile 'net.fabiozumbi12:redprotect:1.9.6'
compile 'com.sk89q:worldguard:6.0.0-SNAPSHOT'
compile group: "com.plotsquared", name: "plotsquared-api", version: "latest"
compile 'org.primesoft:BlocksHub:2.0'
compile 'com.github.luben:zstd-jni:1.1.1'
@ -15,7 +14,6 @@ dependencies {
compile(group: 'com.sk89q.worldedit', name: 'worldedit-core', version:'6.1.3-SNAPSHOT') {
exclude(module: 'bukkit-classloader-check')
}
compile 'org.inventivetalent:mapmanager:1.4.0-SNAPSHOT'
}
processResources {

View File

@ -6,6 +6,7 @@ import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.regions.FaweMaskManager;
import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.util.cui.CUI;
import com.boydti.fawe.util.gui.FormBuilder;
import com.boydti.fawe.util.image.ImageViewer;
import com.sk89q.worldedit.world.World;
import java.io.File;
@ -58,4 +59,8 @@ public interface IFawe {
public default String getDebugInfo() {
return "";
}
public default FormBuilder getFormBuilder() {
return null;
}
}

View File

@ -394,9 +394,11 @@ public class Settings extends Config {
"The relighting mode to use:",
" - 0 = None (Do no relighting)",
" - 1 = Optimal (Relight changed light sources and changed blocks)",
" - 2 = All (Slowly relight every blocks)"
" - 2 = All (Slowly relight every blocks)",
})
public int MODE = 1;
@Comment({"If existing lighting should be removed before relighting"})
public boolean REMOVE_FIRST = false;
}
public void reload(File file) {

View File

@ -42,8 +42,12 @@ public abstract class NMSMappedFaweQueue<WORLD, CHUNK, CHUNKSECTION, SECTION> ex
TaskManager.IMP.async(new Runnable() {
@Override
public void run() {
if (Settings.IMP.LIGHTING.REMOVE_FIRST) {
getRelighter().removeAndRelight(hasSky());
} else {
getRelighter().fixLightingSafe(hasSky());
}
}
});
}
}
@ -109,7 +113,18 @@ public abstract class NMSMappedFaweQueue<WORLD, CHUNK, CHUNKSECTION, SECTION> ex
public abstract void setFullbright(CHUNKSECTION sections);
public abstract boolean removeLighting(CHUNKSECTION sections, RelightMode mode, boolean hasSky);
public boolean removeLighting(CHUNKSECTION sections, RelightMode mode, boolean hasSky) {
boolean result = false;
for (int i = 0; i < 16; i++) {
SECTION section = getCachedSection(sections, i);
if (section != null) {
result |= removeSectionLighting(section, i, hasSky);
}
}
return result;
}
public abstract boolean removeSectionLighting(SECTION sections, int layer, boolean hasSky);
public boolean isSurrounded(final char[][] sections, final int x, final int y, final int z) {
return this.isSolid(this.getId(sections, x, y + 1, z))

View File

@ -40,6 +40,7 @@ public class NMSRelighter implements Relighter {
public final IntegerTrio mutableBlockPos = new IntegerTrio();
private static final int DISPATCH_SIZE = 64;
private boolean removeFirst;
public NMSRelighter(NMSMappedFaweQueue queue) {
this.queue = queue;
@ -55,6 +56,13 @@ public class NMSRelighter implements Relighter {
return skyToRelight.isEmpty() && lightQueue.isEmpty() && queuedSkyToRelight.isEmpty() && concurrentLightQueue.isEmpty();
}
@Override
public synchronized void removeAndRelight(boolean sky) {
removeFirst = true;
fixLightingSafe(true);
removeFirst = false;
}
private void set(int x, int y, int z, long[][][] map) {
long[][] m1 = map[z];
if (m1 == null) {
@ -392,6 +400,11 @@ public class NMSRelighter implements Relighter {
Object section = queue.getCachedSection(sections, layer);
if (section == null) continue;
chunk.smooth = false;
if (removeFirst && (y & 15) == 15) {
queue.removeSectionLighting(sections, y >> 4, true);
}
for (int j = 0; j <= maxY; j++) {
int x = cacheX[j];
int z = cacheZ[j];

View File

@ -22,6 +22,11 @@ public class NullRelighter implements Relighter {
}
@Override
public void removeLighting() {
}
@Override
public void fixBlockLighting() {

View File

@ -7,6 +7,13 @@ public interface Relighter {
void fixLightingSafe(boolean sky);
default void removeAndRelight(boolean sky) {
removeLighting();
fixLightingSafe(sky);
}
void removeLighting();
void fixBlockLighting();
void fixSkyLighting();

View File

@ -0,0 +1,19 @@
package com.boydti.fawe.jnbt.anvil;
public class ChunkSimplifier {
private final HeightMapMCAGenerator gen;
public ChunkSimplifier(HeightMapMCAGenerator gen) {
this.gen = gen;
}
public void simplify(MCAChunk chunk) {
// Copy biome
// Calculate water level
// Determine floor block
// Determine overlay block
// determine main block
// Copy bedrock
// copy anomalies to blocks
}
}

View File

@ -510,7 +510,6 @@ public class MCAChunk extends FaweChunk<Void> {
if (entities == null) {
entities = new HashMap<UUID, CompoundTag>();
}
long least = entityTag.getLong("UUIDLeast");
long most = entityTag.getLong("UUIDMost");
entities.put(new UUID(most, least), entityTag);
@ -733,15 +732,19 @@ public class MCAChunk extends FaweChunk<Void> {
public void removeLight() {
for (int i = 0; i < skyLight.length; i++) {
removeLight(i);
}
}
public void removeLight(int i) {
byte[] array1 = skyLight[i];
if (array1 == null) {
continue;
return;
}
byte[] array2 = blockLight[i];
Arrays.fill(array1, (byte) 0);
Arrays.fill(array2, (byte) 0);
}
}
public int getNibble(int index, byte[] array) {
int indexShift = index >> 1;

View File

@ -687,6 +687,22 @@ public class MCAQueue extends NMSMappedFaweQueue<FaweQueue, FaweChunk, FaweChunk
}
}
@Override
public boolean removeSectionLighting(FaweChunk sections, int layer, boolean hasSky) {
if (sections.getClass() == MCAChunk.class) {
((MCAChunk) sections).removeLight(layer);
} else if (parentNMS != null) {
int cx = sections.getX();
int cz = sections.getZ();
parentNMS.ensureChunkLoaded(cx, cz);
Object parentSections = parentNMS.getCachedSections(parentNMS.getWorld(), cx, cz);
if (parentSections != null) {
parentNMS.removeSectionLighting(sections, layer, hasSky);
}
}
return true;
}
@Override
public boolean removeLighting(FaweChunk sections, RelightMode mode, boolean hasSky) {
if (mode != RelightMode.NONE) {

View File

@ -6,7 +6,6 @@ import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.changeset.AbstractDelegateChangeSet;
import com.boydti.fawe.object.changeset.FaweChangeSet;
import java.lang.reflect.Constructor;
import org.bukkit.entity.Player;
import org.primesoft.blockshub.IBlocksHubApi;
import org.primesoft.blockshub.api.IPlayer;
import org.primesoft.blockshub.api.IWorld;
@ -15,7 +14,7 @@ public class LoggingChangeSet extends AbstractDelegateChangeSet {
private static boolean initialized = false;
public static FaweChangeSet wrap(FawePlayer<Player> player, FaweChangeSet parent) {
public static FaweChangeSet wrap(FawePlayer player, FaweChangeSet parent) {
if (!initialized) {
initialized = true;
api = (IBlocksHubApi) Fawe.imp().getBlocksHubApi();

View File

@ -23,6 +23,7 @@ import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
@ -273,6 +274,16 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
clean.setAccessible(true);
clean.invoke(cleaner.invoke(cb));
} catch (Exception ex) {
try {
final Class<?> unsafeClass = Class.forName("sun.misc.Unsafe");
final Field theUnsafeField = unsafeClass.getDeclaredField("theUnsafe");
theUnsafeField.setAccessible(true);
final Object theUnsafe = theUnsafeField.get(null);
final Method invokeCleanerMethod = unsafeClass.getMethod("invokeCleaner", ByteBuffer.class);
invokeCleanerMethod.invoke(theUnsafe, cb);
} catch (Exception e) {
System.gc();
}
}
cb = null;
}

View File

@ -39,7 +39,7 @@ import java.io.Serializable;
* <p>
* A <code>SparseBitSet</code> is not safe for multithreaded use without
* external synchronization.
*
* @see <a href="https://github.com/brettwooldridge/SparseBitSet">source</a>
* @author Bruce K. Haddon
* @author Arthur van Hoff
* @author Michael McCloskey

View File

@ -0,0 +1,214 @@
package com.boydti.fawe.object.queue;
import com.boydti.fawe.object.FaweChunk;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.RunnableVal2;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.SetQueue;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BaseBiome;
import java.io.File;
import java.util.Collection;
import java.util.Collections;
import java.util.UUID;
import javax.annotation.Nullable;
public class NullFaweQueue implements FaweQueue {
private final String worldName;
public NullFaweQueue(String worldName) {
this.worldName = worldName;
}
@Override
public boolean setBlock(int x, int y, int z, int id, int data) {
return false;
}
@Override
public void setTile(int x, int y, int z, CompoundTag tag) {
}
@Override
public void setEntity(int x, int y, int z, CompoundTag tag) {
}
@Override
public void removeEntity(int x, int y, int z, UUID uuid) {
}
@Override
public boolean setBiome(int x, int z, BaseBiome biome) {
return false;
}
@Override
public FaweChunk getFaweChunk(int x, int z) {
return null;
}
@Override
public Collection<FaweChunk> getFaweChunks() {
return Collections.emptyList();
}
@Override
public void setChunk(FaweChunk chunk) {
}
@Override
public File getSaveFolder() {
return null;
}
@Override
public void setWorld(String world) {
}
@Override
public World getWEWorld() {
return null;
}
@Override
public String getWorldName() {
return worldName;
}
@Override
public long getModified() {
return 0;
}
@Override
public void setModified(long modified) {
}
@Override
public RunnableVal2<ProgressType, Integer> getProgressTask() {
return null;
}
@Override
public void setProgressTask(RunnableVal2<ProgressType, Integer> progressTask) {
}
@Override
public void setChangeTask(RunnableVal2<FaweChunk, FaweChunk> changeTask) {
}
@Override
public RunnableVal2<FaweChunk, FaweChunk> getChangeTask() {
return null;
}
@Override
public SetQueue.QueueStage getStage() {
return SetQueue.QueueStage.NONE;
}
@Override
public void setStage(SetQueue.QueueStage stage) {
}
@Override
public void addNotifyTask(Runnable runnable) {
runnable.run();
}
@Override
public void runTasks() {
}
@Override
public void addTask(Runnable whenFree) {
whenFree.run();
}
@Override
public boolean regenerateChunk(int x, int z, @Nullable BaseBiome biome, @Nullable Long seed) {
return false;
}
@Override
public void sendBlockUpdate(FaweChunk chunk, FawePlayer... players) {
}
@Override
public boolean next(int amount, long time) {
return false;
}
@Override
public void sendChunk(FaweChunk chunk) {
}
@Override
public void sendChunk(int x, int z, int bitMask) {
}
@Override
public void clear() {
}
@Override
public void addNotifyTask(int x, int z, Runnable runnable) {
runnable.run();
}
@Override
public int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException {
return 0;
}
@Override
public int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
return 0;
}
@Override
public int getCachedCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
return 0;
}
@Override
public boolean hasSky() {
return true;
}
@Override
public int getSkyLight(int x, int y, int z) {
return 0;
}
@Override
public int getEmmittedLight(int x, int y, int z) {
return 0;
}
@Override
public CompoundTag getTileEntity(int x, int y, int z) throws FaweException.FaweChunkLoadException {
return null;
}
@Override
public int size() {
return 0;
}
}

View File

@ -48,7 +48,8 @@ public class FuzzyRegion extends AbstractRegion {
public void select(int x, int y, int z) {
RecursiveVisitor search = new RecursiveVisitor(mask, new RegionFunction() {
@Override
public boolean apply(Vector position) throws WorldEditException {
public boolean apply(Vector p) throws WorldEditException {
setMinMax(p.getBlockX(), p.getBlockY(), p.getBlockZ());
return true;
}
}, 256, extent instanceof HasFaweQueue ? (HasFaweQueue) extent : null);
@ -62,8 +63,7 @@ public class FuzzyRegion extends AbstractRegion {
return (Iterator) set.iterator();
}
public void set(int x, int y, int z) throws RegionOperationException {
set.add(x, y, z);
private final void setMinMax(int x, int y, int z) {
if (x > maxX) {
maxX = x;
}
@ -84,6 +84,11 @@ public class FuzzyRegion extends AbstractRegion {
}
}
public final void set(int x, int y, int z) throws RegionOperationException {
set.add(x, y, z);
setMinMax(x, y, z);
}
public boolean contains(int x, int y, int z) {
return set.contains(x, y, z);
}

View File

@ -7,8 +7,8 @@ import com.intellectualcrafters.plot.commands.SubCommand;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.general.commands.CommandDeclaration;
import org.bukkit.Bukkit;
@CommandDeclaration(
command = "trimchunks",
@ -32,7 +32,7 @@ public class FaweTrim extends SubCommand {
plotPlayer.sendMessage("use /plot trimall <world> <boolean-delete-unowned>");
return false;
}
if (Bukkit.getWorld(strings[0]) == null) {
if (!WorldUtil.IMP.isWorld(strings[0])) {
C.NOT_VALID_PLOT_WORLD.send(plotPlayer, strings[0]);
return false;
}

View File

@ -26,6 +26,7 @@ import com.intellectualcrafters.plot.object.RunnableVal2;
import com.intellectualcrafters.plot.object.RunnableVal3;
import com.intellectualcrafters.plot.object.SetupObject;
import com.intellectualcrafters.plot.util.SetupUtils;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.general.commands.Command;
import com.plotsquared.general.commands.CommandDeclaration;
import java.io.File;
@ -33,8 +34,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.World;
@CommandDeclaration(
command = "moveto512",
@ -160,9 +159,7 @@ public class MoveTo512 extends Command {
check(area, C.COMMAND_SYNTAX, getUsage());
checkTrue(area instanceof HybridPlotWorld, C.NOT_VALID_HYBRID_PLOT_WORLD);
for (World world : Bukkit.getWorlds()) {
world.save();
}
WorldUtil.IMP.saveWorld(area.worldname);
FaweQueue defaultQueue = SetQueue.IMP.getNewQueue(area.worldname, true, false);
MCAQueue queueFrom = new MCAQueue(area.worldname, defaultQueue.getSaveFolder(), defaultQueue.hasSky());

View File

@ -4,8 +4,10 @@ import com.boydti.fawe.jnbt.anvil.MCAChunk;
import com.boydti.fawe.jnbt.anvil.MCAFile;
import com.boydti.fawe.jnbt.anvil.MCAFilter;
import com.boydti.fawe.jnbt.anvil.MCAQueue;
import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.SetQueue;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
@ -21,14 +23,11 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import static com.google.common.base.Preconditions.checkNotNull;
public class PlotTrim implements Listener {
public class PlotTrim {
private final MCAQueue queue;
private final PlotArea area;
private final PlotPlayer player;
@ -39,8 +38,10 @@ public class PlotTrim implements Listener {
private boolean deleteUnowned = true;
public PlotTrim(PlotPlayer player, PlotArea area, String worldName, boolean deleteUnowned) {
this.root = new File(Bukkit.getWorldContainer(), worldName + "-Copy" + File.separator + "region");
this.originalRoot = new File(Bukkit.getWorldContainer(), worldName + File.separator + "region");
FaweQueue tmpQueue = SetQueue.IMP.getNewQueue(worldName, true, false);
File saveFolder = tmpQueue.getSaveFolder();
this.root = new File(saveFolder.getParentFile().getParentFile(), worldName + "-Copy" + File.separator + "region");
this.originalRoot = saveFolder;
this.originalQueue = new MCAQueue(worldName, originalRoot, true);
this.queue = new MCAQueue(worldName + "-Copy", root, true);
this.area = area;
@ -76,7 +77,6 @@ public class PlotTrim implements Listener {
}
public void run() {
Bukkit.getPluginManager().registerEvents(this, (Plugin) PS.get().IMP);
final Set<ChunkLoc> mcas = new HashSet<>();
if (deleteUnowned && area != null) {
originalQueue.filterWorld(new MCAFilter() {

View File

@ -12,8 +12,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import sun.reflect.ConstructorAccessor;
import sun.reflect.FieldAccessor;
import sun.reflect.ReflectionFactory;
@ -24,49 +22,6 @@ import sun.reflect.ReflectionFactory;
*/
@SuppressWarnings({"UnusedDeclaration", "rawtypes"})
public class ReflectionUtils {
/**
* prefix of bukkit classes
*/
private static volatile String preClassB = null;
/**
* prefix of minecraft classes
*/
private static volatile String preClassM = null;
/**
* boolean value, TRUE if server uses forge or MCPC+
*/
private static boolean forge = false;
/**
* check server version and class names
*/
public static void init() {
if (Bukkit.getServer() != null) {
if (Bukkit.getVersion().contains("MCPC") || Bukkit.getVersion().contains("Forge")) {
forge = true;
}
final Server server = Bukkit.getServer();
final Class<?> bukkitServerClass = server.getClass();
String[] pas = bukkitServerClass.getName().split("\\.");
if (pas.length == 5) {
final String verB = pas[3];
preClassB = "org.bukkit.craftbukkit." + verB;
}
try {
final Method getHandle = bukkitServerClass.getDeclaredMethod("getHandle");
final Object handle = getHandle.invoke(server);
final Class handleServerClass = handle.getClass();
pas = handleServerClass.getName().split("\\.");
if (pas.length == 5) {
final String verM = pas[3];
preClassM = "net.minecraft.server." + verM;
}
} catch (final Exception ignored) {
MainUtil.handleError(ignored);
}
}
}
public static <T> T as(Class<T> t, Object o) {
return t.isInstance(o) ? t.cast(o) : null;
}
@ -200,33 +155,6 @@ public class ReflectionUtils {
}
}
public static Class<?> getNmsClass(final String name) {
final String className = "net.minecraft.server." + getVersion() + "." + name;
return getClass(className);
}
public static Class<?> getCbClass(final String name) {
final String className = "org.bukkit.craftbukkit." + getVersion() + "." + name;
return getClass(className);
}
public static Class<?> getUtilClass(final String name) {
try {
return Class.forName(name); //Try before 1.8 first
} catch (final ClassNotFoundException ex) {
try {
return Class.forName("net.minecraft.util." + name); //Not 1.8
} catch (final ClassNotFoundException ex2) {
return null;
}
}
}
public static String getVersion() {
final String packageName = Bukkit.getServer().getClass().getPackage().getName();
return packageName.substring(packageName.lastIndexOf('.') + 1);
}
public static Object getHandle(final Object wrapper) {
final Method getHandle = makeMethod(wrapper.getClass(), "getHandle");
return callMethod(getHandle, wrapper);
@ -414,34 +342,6 @@ public class ReflectionUtils {
}
}
/**
* @return true if server has forge classes
*/
public static boolean isForge() {
return forge;
}
/**
* Get class for name. Replace {nms} to net.minecraft.server.V*. Replace {cb} to org.bukkit.craftbukkit.V*. Replace
* {nm} to net.minecraft
*
* @param classes possible class paths
* @return RefClass object
* @throws RuntimeException if no class found
*/
public static RefClass getRefClass(final String... classes) throws RuntimeException {
if (preClassM == null) {
init();
}
for (String className : classes) {
try {
className = className.replace("{cb}", preClassB).replace("{nms}", preClassM).replace("{nm}", "net.minecraft");
return getRefClass(Class.forName(className));
} catch (final ClassNotFoundException ignored) {
}
}
throw new RuntimeException("no class found: " + classes[0].replace("{cb}", preClassB).replace("{nms}", preClassM).replace("{nm}", "net.minecraft"));
}
/**
* get RefClass object by real class

View File

@ -0,0 +1,29 @@
package com.boydti.fawe.util.gui;
import com.boydti.fawe.object.FawePlayer;
import java.net.URL;
import java.util.List;
import java.util.function.Consumer;
import javax.annotation.Nullable;
public interface FormBuilder<T> {
FormBuilder setTitle(String text);
FormBuilder setIcon(URL icon);
FormBuilder addButton(String text, @Nullable URL image);
FormBuilder addDropdown(String text, int def, String... options);
FormBuilder addInput(String text, String placeholder, String def);
FormBuilder addLabel(String text);
FormBuilder addSlider(String text, double min, double max, int step, double def);
FormBuilder addStepSlider(String text, int def, String... options);
FormBuilder addToggle(String text, boolean def);
void display(FawePlayer<T> fp, Consumer<List<String>> response);
}

View File

@ -31,6 +31,7 @@ import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.StringMan;
import com.boydti.fawe.util.chat.Message;
import com.boydti.fawe.util.chat.UsageMessage;
import com.boydti.fawe.util.gui.FormBuilder;
import com.google.common.base.Joiner;
import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
@ -100,6 +101,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;
import java.util.stream.Collectors;
@ -889,6 +891,33 @@ public class UtilityCommands extends MethodCommands {
help(args, we, actor, "/", null);
}
@Command(
aliases = {"/gui"},
desc = "Open the GUI"
)
@Logging(PLACEMENT)
public void gui(FawePlayer fp, LocalSession session, CommandContext args) throws WorldEditException {
FormBuilder gui = Fawe.imp().getFormBuilder();
if (gui == null) throw new UnsupportedOperationException("Not implemented");
Dispatcher callable = worldEdit.getPlatformManager().getCommandManager().getDispatcher();
CommandLocals locals = args.getLocals();
// TODO build form
gui.display(fp, new Consumer<List<String>>() {
@Override
public void accept(List<String> strings) {
}
});
}
private void help(CommandCallable callable) {
}
public static void help(CommandContext args, WorldEdit we, Actor actor, String prefix, CommandCallable callable) {
try {
if (callable == null) {

View File

@ -473,19 +473,14 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
}
@Override
public boolean removeLighting(ExtendedBlockStorage[] sections, RelightMode mode, boolean sky) {
if (mode == RelightMode.ALL) {
for (int i = 0; i < sections.length; i++) {
ExtendedBlockStorage section = sections[i];
public boolean removeSectionLighting(ExtendedBlockStorage sections, int layer, boolean sky) {
if (section != null) {
section.setBlocklightArray(new NibbleArray());
if (sky) {
section.setSkylightArray(new NibbleArray());
}
}
}
}
return true;
return section != null;
}
@Override

View File

@ -549,19 +549,14 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
}
@Override
public boolean removeLighting(ExtendedBlockStorage[] sections, RelightMode mode, boolean sky) {
if (mode == RelightMode.ALL) {
for (int i = 0; i < sections.length; i++) {
ExtendedBlockStorage section = sections[i];
public boolean removeSectionLighting(ExtendedBlockStorage sections, int layer, boolean sky) {
if (section != null) {
section.setBlocklightArray(new NibbleArray());
if (sky) {
section.setSkylightArray(new NibbleArray());
}
}
}
}
return true;
return section != null;
}
@Override

View File

@ -674,19 +674,14 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
}
@Override
public boolean removeLighting(ExtendedBlockStorage[] sections, RelightMode mode, boolean sky) {
if (mode == RelightMode.ALL) {
for (int i = 0; i < sections.length; i++) {
ExtendedBlockStorage section = sections[i];
public boolean removeSectionLighting(ExtendedBlockStorage sections, int layer, boolean sky) {
if (section != null) {
section.setBlockLight(new NibbleArray());
if (sky) {
section.setSkyLight(new NibbleArray());
}
}
}
}
return true;
return section != null;
}
@Override

View File

@ -469,19 +469,14 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
}
@Override
public boolean removeLighting(ExtendedBlockStorage[] sections, RelightMode mode, boolean sky) {
if (mode == RelightMode.ALL) {
for (int i = 0; i < sections.length; i++) {
ExtendedBlockStorage section = sections[i];
public boolean removeSectionLighting(ExtendedBlockStorage sections, int layer, boolean sky) {
if (section != null) {
section.setBlocklightArray(new NibbleArray(4096, 4));
if (sky) {
section.setSkylightArray(new NibbleArray(4096, 4));
}
}
}
}
return true;
return section != null;
}
@Override

View File

@ -435,19 +435,14 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
}
@Override
public boolean removeLighting(ExtendedBlockStorage[] sections, RelightMode mode, boolean sky) {
if (mode == RelightMode.ALL) {
for (int i = 0; i < sections.length; i++) {
ExtendedBlockStorage section = sections[i];
public boolean removeSectionLighting(ExtendedBlockStorage sections, int layer, boolean sky) {
if (section != null) {
section.setBlocklightArray(new NibbleArray());
if (sky) {
section.setSkylightArray(new NibbleArray());
}
}
}
}
return true;
return section != null;
}
@Override

View File

@ -465,19 +465,14 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
}
@Override
public boolean removeLighting(ExtendedBlockStorage[] sections, RelightMode mode, boolean sky) {
if (mode == RelightMode.ALL) {
for (int i = 0; i < sections.length; i++) {
ExtendedBlockStorage section = sections[i];
public boolean removeSectionLighting(ExtendedBlockStorage sections, int layer, boolean sky) {
if (section != null) {
section.setBlocklightArray(new NibbleArray());
if (sky) {
section.setSkylightArray(new NibbleArray());
}
}
}
}
return true;
return section != null;
}
public void setPalette(ExtendedBlockStorage section, BlockStateContainer palette) throws NoSuchFieldException, IllegalAccessException {

Binary file not shown.

View File

@ -1,3 +1,4 @@
#Fri Jan 12 10:28:44 AEDT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

74
gradlew vendored
View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env sh
##############################################################################
##
@ -6,12 +6,30 @@
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
@ -30,6 +48,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
@ -40,31 +59,11 @@ case "`uname`" in
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@ -90,7 +89,7 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@ -114,6 +113,7 @@ fi
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
@ -154,11 +154,19 @@ if $cygwin ; then
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
# Escape application args
save ( ) {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
APP_ARGS=$(save "$@")
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

View File

@ -3,7 +3,7 @@ repositories {
}
dependencies {
compile project(':core')
compile group: "cn.nukkit", name: "nukkit", version: "1.0-20170704.231613-609"
compile group: "cn.nukkit", name: "nukkit", version: "1.0"
compile name: 'worldedit-core-6.1.4-SNAPSHOT-dist'
}

View File

@ -19,6 +19,7 @@
package com.boydti.fawe.nukkit.core;
import cn.nukkit.AdventureSettings;
import cn.nukkit.Player;
import cn.nukkit.inventory.PlayerInventory;
import cn.nukkit.item.Item;
@ -174,7 +175,8 @@ public class NukkitPlayer extends LocalPlayer {
}
setPosition(new Vector(x + 0.5, y, z + 0.5));
player.getAdventureSettings().setCanFly(true);
player.getAdventureSettings().set(AdventureSettings.Type.ALLOW_FLIGHT, true);
player.getAdventureSettings().set(AdventureSettings.Type.FLYING, true);
player.getAdventureSettings().update();
}

View File

@ -0,0 +1,26 @@
package com.boydti.fawe.nukkit.core.gui;
import cn.nukkit.form.response.FormResponse;
import cn.nukkit.form.window.FormWindow;
public class DelegateFormWindow extends FormWindow {
private final FormWindow parent;
public DelegateFormWindow(FormWindow parent) {
this.parent = parent;
}
@Override
public String getJSONData() {
return parent.getJSONData();
}
@Override
public void setResponse(String s) {
parent.setResponse(s);
}
@Override
public FormResponse getResponse() {
return parent.getResponse();
}
}

View File

@ -0,0 +1,147 @@
package com.boydti.fawe.nukkit.core.gui;
import cn.nukkit.Player;
import cn.nukkit.form.element.Element;
import cn.nukkit.form.element.ElementButton;
import cn.nukkit.form.element.ElementButtonImageData;
import cn.nukkit.form.element.ElementDropdown;
import cn.nukkit.form.element.ElementInput;
import cn.nukkit.form.element.ElementLabel;
import cn.nukkit.form.element.ElementSlider;
import cn.nukkit.form.element.ElementStepSlider;
import cn.nukkit.form.element.ElementToggle;
import cn.nukkit.form.window.FormWindow;
import cn.nukkit.form.window.FormWindowCustom;
import cn.nukkit.form.window.FormWindowSimple;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.util.gui.FormBuilder;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import static com.google.common.base.Preconditions.checkNotNull;
public class NukkitFormBuilder implements FormBuilder<Player> {
private final List<Element> elements;
private final List<ElementButton> buttons;
private String title = "";
private String icon;
public NukkitFormBuilder() {
this.elements = new ArrayList<>();
this.buttons = new ArrayList<>();
}
@Override
public FormBuilder setTitle(String text) {
checkNotNull(text);
this.title = text;
return this;
}
@Override
public FormBuilder setIcon(URL icon) {
checkNotNull(icon);
this.icon = icon.toString();
return this;
}
@Override
public FormBuilder addButton(String text, URL image) {
checkNotNull(text);
if (!elements.isEmpty()) throw new UnsupportedOperationException("GUI does not support mixed buttons / elements");
ElementButton button;
if (image != null) {
ElementButtonImageData imageData = new ElementButtonImageData("url", image.toString());
button = new ElementButton(text, imageData);
} else {
button = new ElementButton(text);
}
buttons.add(button);
return this;
}
@Override
public FormBuilder addDropdown(String text, int def, String... options) {
checkNotNull(text);
checkNotNull(options);
for (String option : options) checkNotNull(option);
if (!buttons.isEmpty()) throw new UnsupportedOperationException("GUI does not support mixed buttons / elements");
elements.add(new ElementDropdown(text, Arrays.asList(options), def));
return this;
}
@Override
public FormBuilder addInput(String text, String placeholder, String def) {
checkNotNull(text);
checkNotNull(placeholder);
checkNotNull(def);
if (!buttons.isEmpty()) throw new UnsupportedOperationException("GUI does not support mixed buttons / elements");
elements.add(new ElementInput(text, placeholder, def));
return this;
}
@Override
public FormBuilder addLabel(String text) {
checkNotNull(text);
if (!buttons.isEmpty()) throw new UnsupportedOperationException("GUI does not support mixed buttons / elements");
elements.add(new ElementLabel(text));
return this;
}
@Override
public FormBuilder addSlider(String text, double min, double max, int step, double def) {
checkNotNull(text);
if (!buttons.isEmpty()) throw new UnsupportedOperationException("GUI does not support mixed buttons / elements");
elements.add(new ElementSlider(text, (float) min, (float) max, step, (float) def));
return this;
}
@Override
public FormBuilder addStepSlider(String text, int def, String... options) {
checkNotNull(text);
checkNotNull(options);
for (String option : options) checkNotNull(option);
if (!buttons.isEmpty()) throw new UnsupportedOperationException("GUI does not support mixed buttons / elements");
elements.add(new ElementStepSlider(text, Arrays.asList(options), def));
return this;
}
@Override
public FormBuilder addToggle(String text, boolean def) {
checkNotNull(text);
if (!buttons.isEmpty()) throw new UnsupportedOperationException("GUI does not support mixed buttons / elements");
elements.add(new ElementToggle(text, def));
return this;
}
@Override
public void display(FawePlayer<Player> fp, Consumer<List<String>> response) {
FormWindow window;
if (buttons.isEmpty()) {
if (icon == null) {
window = new FormWindowCustom("Title", elements);
} else {
window = new FormWindowCustom("Title", elements, icon);
}
} else {
window = new FormWindowSimple("Title", "", buttons);
}
if (response != null) {
window = new ResponseFormWindow(window, response);
}
Player player = fp.parent;
player.showFormWindow(window);
}
}

View File

@ -0,0 +1,22 @@
package com.boydti.fawe.nukkit.core.gui;
import cn.nukkit.form.window.FormWindow;
import java.util.List;
import java.util.function.Consumer;
import static com.google.common.base.Preconditions.checkNotNull;
public class ResponseFormWindow extends DelegateFormWindow {
private final Consumer<List<String>> task;
public ResponseFormWindow(FormWindow parent, Consumer<List<String>> onResponse) {
super(parent);
checkNotNull(onResponse);
this.task = onResponse;
}
public void respond(List<String> response) {
task.accept(response);
}
}

View File

@ -4,12 +4,14 @@ import cn.nukkit.Nukkit;
import cn.nukkit.Player;
import cn.nukkit.event.EventHandler;
import cn.nukkit.event.Listener;
import cn.nukkit.event.player.PlayerFormRespondedEvent;
import cn.nukkit.event.player.PlayerQuitEvent;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.IFawe;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.nukkit.core.NukkitTaskManager;
import com.boydti.fawe.nukkit.core.NukkitWorldEdit;
import com.boydti.fawe.nukkit.core.gui.NukkitFormBuilder;
import com.boydti.fawe.nukkit.listener.BrushListener;
import com.boydti.fawe.nukkit.optimization.queue.NukkitQueue;
import com.boydti.fawe.object.FaweChunk;
@ -19,6 +21,7 @@ import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.brush.visualization.VisualChunk;
import com.boydti.fawe.regions.FaweMaskManager;
import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.util.gui.FormBuilder;
import com.sk89q.worldedit.world.World;
import java.io.File;
import java.util.ArrayList;
@ -34,6 +37,9 @@ public class FaweNukkit implements IFawe, Listener {
this.plugin = mod;
FaweChunk.HEIGHT = 256;
VisualChunk.VISUALIZE_BLOCK = 20 << 4;
plugin.getServer().getPluginManager().registerEvents(this, plugin);
try {
new BrushListener(mod);
@ -44,6 +50,11 @@ public class FaweNukkit implements IFawe, Listener {
}
}
@Override
public FormBuilder getFormBuilder() {
return new NukkitFormBuilder();
}
@Override
public int getPlayerCount() {
return plugin.getServer().getOnlinePlayers().size();
@ -59,6 +70,11 @@ public class FaweNukkit implements IFawe, Listener {
return Nukkit.VERSION;
}
@EventHandler
public void onFormSubmit(PlayerFormRespondedEvent event) {
// TODO
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
@ -86,6 +102,8 @@ public class FaweNukkit implements IFawe, Listener {
@Override
public void setupCommand(String label, final FaweCommand cmd) {
plugin.getServer().getCommandMap().register(label, new NukkitCommand(label, cmd));
}
@Override

View File

@ -193,6 +193,21 @@ public class NukkitQueue extends NMSMappedFaweQueue<Level, BaseFullChunk, BaseFu
}
}
@Override
public boolean removeSectionLighting(BaseFullChunk section, int layer, boolean hasSky) {
int minY = layer << 4;
int maxY = minY + 15;
for (int y = minY; y < maxY; y++) {
for (int z = 0; z < 16; z++) {
for (int x = 0; x < 16; x++) {
section.setBlockSkyLight(x, y, z, 0);
section.setBlockLight(x, y, z, 0);
}
}
}
return true;
}
@Override
public boolean removeLighting(BaseFullChunk sections, RelightMode mode, boolean hasSky) {
for (int y = 0; y < 256; y++) {

View File

@ -1,3 +1,3 @@
rootProject.name = 'FastAsyncWorldEdit'
include 'core', 'bukkit', 'favs', 'nukkit', 'forge1710', 'forge189', 'forge194', 'forge110', 'forge111', 'sponge', 'forge112', 'sponge111'
include 'core', 'bukkit', 'favs', 'nukkit', 'forge1710', 'forge189', 'forge194', 'forge110', 'forge111', 'sponge112', 'forge112', 'sponge111'

View File

@ -563,19 +563,14 @@ public class SpongeQueue_1_11 extends NMSMappedFaweQueue<World, net.minecraft.wo
}
@Override
public boolean removeLighting(ExtendedBlockStorage[] sections, RelightMode mode, boolean sky) {
if (mode == RelightMode.ALL) {
for (int i = 0; i < sections.length; i++) {
ExtendedBlockStorage section = sections[i];
public boolean removeSectionLighting(ExtendedBlockStorage section, int layer, boolean sky) {
if (section != null) {
section.setBlocklightArray(new NibbleArray());
if (sky) {
section.setSkylightArray(new NibbleArray());
}
}
}
}
return true;
return section != null;
}
@Override

View File

@ -70,8 +70,8 @@ shadowJar {
include(dependency('com.github.luben:zstd-jni:1.1.1'))
// include(dependency('org.javassist:javassist:3.22.0-CR1'))
include(dependency('co.aikar:fastutil-lite:1.0'))
include(dependency(name: 'worldedit-core-6.1.7-SNAPSHOT-dist'))
include(dependency('com.sk89q.worldedit:worldedit-sponge:6.1.7-SNAPSHOT'))
include(dependency(name: 'worldedit-core-6.1.9-SNAPSHOT-dist'))
include(dependency('com.sk89q.worldedit:worldedit-sponge:6.1.9-SNAPSHOT'))
include(dependency('org.yaml:snakeyaml:1.16'))
}
archiveName = "${parent.name}-${project.name}-${parent.version}.jar"

View File

@ -565,19 +565,14 @@ public class SpongeQueue_1_12 extends NMSMappedFaweQueue<World, net.minecraft.wo
}
@Override
public boolean removeLighting(ExtendedBlockStorage[] sections, RelightMode mode, boolean sky) {
if (mode == RelightMode.ALL) {
for (int i = 0; i < sections.length; i++) {
ExtendedBlockStorage section = sections[i];
public boolean removeSectionLighting(ExtendedBlockStorage section, int layer, boolean sky) {
if (section != null) {
section.setBlockLight(new NibbleArray());
if (sky) {
section.setSkyLight(new NibbleArray());
}
}
}
}
return true;
return section != null;
}
@Override