Dieser Commit ist enthalten in:
IronApollo 2020-02-26 09:35:47 -05:00
Commit 12431e7b7a
15 geänderte Dateien mit 82 neuen und 522 gelöschten Zeilen

Datei anzeigen

@ -13,15 +13,16 @@ repositories {
maven { url = uri("https://papermc.io/repo/repository/maven-public/") } maven { url = uri("https://papermc.io/repo/repository/maven-public/") }
maven { url = uri("http://empcraft.com/maven2") } maven { url = uri("http://empcraft.com/maven2") }
maven { url = uri("https://maven.enginehub.org/repo/") } maven { url = uri("https://maven.enginehub.org/repo/") }
maven { url = uri("http://ci.frostcast.net/plugin/repository/everything") }
maven { url = uri("http://dl.bintray.com/tastybento/maven-repo") }
maven { url = uri("http://ci.emc.gs/nexus/content/groups/aikar/") } maven { url = uri("http://ci.emc.gs/nexus/content/groups/aikar/") }
maven(fun MavenArtifactRepository.() { maven {
this.name = "JitPack" this.name = "JitPack"
this.url = uri("https://jitpack.io") this.url = uri("https://jitpack.io")
}) }
maven { url = uri("https://repo.destroystokyo.com/repository/maven-public//") } maven { url = uri("https://repo.destroystokyo.com/repository/maven-public/") }
maven { url = uri("http://repo.dmulloy2.net/content/groups/public/") } maven {
name = "ProtocolLib Repo"
url = uri("https://repo.dmulloy2.net/nexus/repository/public/")
}
maven { url = uri("https://repo.inventivetalent.org/content/groups/public/")} maven { url = uri("https://repo.inventivetalent.org/content/groups/public/")}
flatDir {dir(File("src/main/resources"))} flatDir {dir(File("src/main/resources"))}
} }
@ -64,7 +65,7 @@ dependencies {
"implementation"("com.bekvon.bukkit.residence:Residence:4.5._13.1") { isTransitive = false } "implementation"("com.bekvon.bukkit.residence:Residence:4.5._13.1") { isTransitive = false }
"implementation"("com.palmergames.bukkit:towny:0.84.0.9") { isTransitive = false } "implementation"("com.palmergames.bukkit:towny:0.84.0.9") { isTransitive = false }
"implementation"("com.thevoxelbox.voxelsniper:voxelsniper:5.171.0") { isTransitive = false } "implementation"("com.thevoxelbox.voxelsniper:voxelsniper:5.171.0") { isTransitive = false }
"implementation"("com.comphenix.protocol:ProtocolLib-API:4.4.0-SNAPSHOT") { isTransitive = false } "implementation"("com.comphenix.protocol:ProtocolLib:4.5.0") { isTransitive = false }
} }
tasks.named<Copy>("processResources") { tasks.named<Copy>("processResources") {

Datei anzeigen

@ -27,7 +27,6 @@ import com.boydti.fawe.util.Jars;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.util.WEManager; import com.boydti.fawe.util.WEManager;
import com.boydti.fawe.util.image.ImageViewer; import com.boydti.fawe.util.image.ImageViewer;
import com.boydti.fawe.util.task.Task;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.BukkitPlayer; import com.sk89q.worldedit.bukkit.BukkitPlayer;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
@ -38,7 +37,6 @@ import java.util.Collection;
import java.util.UUID; import java.util.UUID;
import java.util.function.Supplier; import java.util.function.Supplier;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -159,24 +157,6 @@ public class FaweBukkit implements IFawe, Listener {
} }
@Override
public com.sk89q.worldedit.entity.Player wrap(final Object obj) {
Player player = null;
if (obj.getClass() == Player.class) {
player = (Player) obj;
} else if (obj.getClass() == String.class) {
String name = (String) obj;
player = Bukkit.getPlayer(name);
} else if (obj.getClass() == UUID.class) {
UUID uuid = (UUID) obj;
player = Bukkit.getPlayer(uuid);
}
if (player == null) {
throw new IllegalArgumentException("Unknown player type: " + obj);
}
return BukkitAdapter.adapt(player);
}
public ItemUtil getItemUtil() { public ItemUtil getItemUtil() {
ItemUtil tmp = itemUtil; ItemUtil tmp = itemUtil;
if (tmp == null) { if (tmp == null) {

Datei anzeigen

@ -1,453 +0,0 @@
//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;
//import com.sk89q.jnbt.CompoundTag;
//import com.sk89q.jnbt.DoubleTag;
//import com.sk89q.jnbt.EndTag;
//import com.sk89q.jnbt.FloatTag;
//import com.sk89q.jnbt.IntArrayTag;
//import com.sk89q.jnbt.IntTag;
//import com.sk89q.jnbt.ListTag;
//import com.sk89q.jnbt.LongTag;
//import com.sk89q.jnbt.NBTConstants;
//import com.sk89q.jnbt.ShortTag;
//import com.sk89q.jnbt.StringTag;
//import com.sk89q.jnbt.Tag;
//import com.sk89q.worldedit.blocks.BaseBlock;
//import com.sk89q.worldedit.world.block.BlockState;
//import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
//import com.sk89q.worldedit.entity.BaseEntity;
//import com.sk89q.worldedit.internal.Constants;
//import java.lang.reflect.Constructor;
//import java.lang.reflect.Field;
//import java.lang.reflect.InvocationTargetException;
//import java.lang.reflect.Method;
//import java.lang.reflect.Modifier;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//import java.util.concurrent.ConcurrentHashMap;
//import javax.annotation.Nullable;
//import org.bukkit.Location;
//import org.bukkit.Material;
//import org.bukkit.World;
//import org.bukkit.block.Biome;
//import org.bukkit.entity.Entity;
//import org.bukkit.event.entity.CreatureSpawnEvent;
//
//public class FaweAdapter_All implements BukkitImplAdapter {
//
// private final Class<?> classCraftBlock;
// private final Method biomeToBiomeBase;
// private final Class<?> classBiomeBase;
// private final Method biomeBaseToTypeId;
// private final Method getBiome;
// private final Method biomeBaseToBiome;
// private final Class<?> classCraftWorld;
// private final Method getHandleWorld;
// private final Class<?> classWorld;
// private final Method getTileEntity1;
// private final Method getTileEntity2;
// private final Class<?> classNBTTagCompound;
// private final Constructor<?> newNBTTagCompound;
// private final Class<?> classTileEntity;
// private final Class<?> classCraftEntity;
// private final Method getHandleEntity;
// private final Class<?> classNBTTagInt;
// private final Class<?> classNBTBase;
// private final Constructor<?> newNBTTagInt;
// private final Method setNBTTagCompound;
// private Class<?> classEntity;
// private Method getBukkitEntity;
// private Method addEntity;
// private Method setLocation;
// private Class<?> classEntityTypes;
// private Method getEntityId;
// private Method createEntityFromId;
// private Method readTagIntoEntity;
// private Method readEntityIntoTag;
// private Constructor<?> newMinecraftKey;
// private Class<?> classMinecraftKey;
// private Method readTagIntoTileEntity;
// private Method readTileEntityIntoTag;
// private Class<?> classBlockPosition;
// private Constructor<?> newBlockPosition;
//
// private Map<Class<? extends Tag>, NMSTagConstructor> WEToNMS = new ConcurrentHashMap<>();
// private Map<Class, WETagConstructor> NMSToWE = new ConcurrentHashMap<>();
// private Map<Class<? extends Tag>, Integer> TagToId = new ConcurrentHashMap<>();
//
// public FaweAdapter_All() throws Throwable {
// 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));
// getBiome = ReflectionUtils.setAccessible(classBiomeBase.getDeclaredMethod("getBiome", int.class));
// biomeBaseToTypeId = ReflectionUtils.findMethod(classBiomeBase, int.class, classBiomeBase);
// getHandleWorld = ReflectionUtils.setAccessible(classCraftWorld.getDeclaredMethod("getHandle"));
// getHandleEntity = ReflectionUtils.setAccessible(classCraftEntity.getDeclaredMethod("getHandle"));
// try {
// classBlockPosition = BukkitReflectionUtils.getNmsClass("BlockPosition");
// } catch (Throwable ignore) {
// }
// if (classBlockPosition != null) {
// getTileEntity1 = classWorld.getDeclaredMethod("getTileEntity", classBlockPosition);
// getTileEntity2 = null;
// newBlockPosition = ReflectionUtils.setAccessible(classBlockPosition.getConstructor(int.class, int.class, int.class));
// } else {
// getTileEntity1 = null;
// getTileEntity2 = ReflectionUtils.setAccessible(classWorld.getDeclaredMethod("getTileEntity", int.class, int.class, int.class));
// }
//
// 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());
// try {
// readTileEntityIntoTag = ReflectionUtils.setAccessible(classTileEntity.getDeclaredMethod("save", classNBTTagCompound));
// } catch (Throwable ignore) {
// readTileEntityIntoTag = ReflectionUtils.findMethod(classTileEntity, classNBTTagCompound, classNBTTagCompound);
// if (readTileEntityIntoTag == null) {
// readTileEntityIntoTag = ReflectionUtils.findMethod(classTileEntity, 1, Void.TYPE, classNBTTagCompound);
// }
// }
//
//
// try {
// readTagIntoTileEntity = ReflectionUtils.setAccessible(classTileEntity.getDeclaredMethod("load", classNBTTagCompound));
// } catch (Throwable ignore) {
// readTagIntoTileEntity = ReflectionUtils.findMethod(classTileEntity, 0, Void.TYPE, classNBTTagCompound);
// }
//
//
// List<String> nmsClasses = Arrays.asList("NBTTagCompound", "NBTTagByte", "NBTTagByteArray", "NBTTagDouble", "NBTTagFloat", "NBTTagInt", "NBTTagIntArray", "NBTTagList", "NBTTagEnd", "NBTTagString", "NBTTagShort", "NBTTagLong");
// List<Class<? extends Tag>> weClasses = Arrays.asList(CompoundTag.class, ByteTag.class, ByteArrayTag.class, DoubleTag.class, FloatTag.class, IntTag.class, IntArrayTag.class, ListTag.class, EndTag.class, StringTag.class, ShortTag.class, LongTag.class);
// int[] ids = new int[]{10, 1, 7, 6, 5, 3, 11, 9, 0, 8, 2, 4};
//
// int noMods = Modifier.STATIC;
// int hasMods = 0;
// for (int i = 0; i < nmsClasses.size(); i++) {
// Class<?> nmsClass = BukkitReflectionUtils.getNmsClass(nmsClasses.get(i));
// Class<? extends Tag> weClass = weClasses.get(i);
// TagToId.put(weClass, ids[i]);
//
// Constructor nmsConstructor = ReflectionUtils.setAccessible(nmsClass.getDeclaredConstructor());
//
// if (weClass == EndTag.class) {
// NMSToWE.put(nmsClass, value -> new EndTag());
// WEToNMS.put(weClass, value -> nmsConstructor.newInstance());
// } else if (weClass == CompoundTag.class) {
// Field mapField = ReflectionUtils.findField(nmsClass, Map.class, hasMods, noMods);
// Constructor<? extends Tag> weConstructor = ReflectionUtils.setAccessible(CompoundTag.class.getConstructor(Map.class));
//
// NMSToWE.put(nmsClass, value -> {
// Map<String, Object> map = (Map) mapField.get(value);
// Map<String, Tag> weMap = new HashMap<String, Tag>();
// for (Map.Entry<String, Object> entry : map.entrySet()) {
// weMap.put(entry.getKey(), toNative(entry.getValue()));
// }
// return new CompoundTag(weMap);
// });
//
// WEToNMS.put(weClass, value -> {
// Map<String, Tag> map = ReflectionUtils.getMap(((CompoundTag) value).getValue());
// Object nmsTag = nmsConstructor.newInstance();
// Map<String, Object> nmsMap = (Map<String, Object>) mapField.get(nmsTag);
// for (Map.Entry<String, Tag> entry : map.entrySet()) {
// nmsMap.put(entry.getKey(), fromNative(entry.getValue()));
// }
// return nmsTag;
// });
// } else if (weClass == ListTag.class) {
// Field listField = ReflectionUtils.findField(nmsClass, List.class, hasMods, noMods);
// Field typeField = ReflectionUtils.findField(nmsClass, byte.class, hasMods, noMods);
// Constructor<? extends Tag> weConstructor = ReflectionUtils.setAccessible(ListTag.class.getConstructor(Class.class, List.class));
//
// NMSToWE.put(nmsClass, tag -> {
// int type = ((Number) typeField.get(tag)).intValue();
// List list = (List) listField.get(tag);
//
// Class<? extends Tag> weType = NBTConstants.getClassFromType(type);
// ArrayList<Tag> weList = new ArrayList<>();
// for (Object nmsTag : list) {
// weList.add(toNative(nmsTag));
// }
// return new ListTag(weType, weList);
// });
// WEToNMS.put(weClass, tag -> {
// ListTag lt = (ListTag) tag;
// List<Tag> list = ReflectionUtils.getList(lt.getValue());
// Class<? extends Tag> type = lt.getType();
//
// int typeId = TagToId.get(type);
// Object nmsTagList = nmsConstructor.newInstance();
// typeField.set(nmsTagList, (byte) typeId);
// ArrayList<Object> nmsList = (ArrayList<Object>) listField.get(nmsTagList);
// for (Tag weTag : list) {
// nmsList.add(fromNative(weTag));
// }
// return nmsTagList;
// });
// } else {
// Field typeField = ReflectionUtils.findField(nmsClass, null, hasMods, noMods);
// Constructor<? extends Tag> weConstructor = ReflectionUtils.setAccessible(weClass.getConstructor(typeField.getType()));
//
// NMSToWE.put(nmsClass, tag -> {
// Object value = typeField.get(tag);
// return weConstructor.newInstance(value);
// });
//
// WEToNMS.put(weClass, tag -> {
// Object nmsTag = nmsConstructor.newInstance();
// typeField.set(nmsTag, tag.getValue());
// return nmsTag;
// });
// }
// }
// try {
// 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 = BukkitReflectionUtils.getNmsClass("MinecraftKey");
// newMinecraftKey = classMinecraftKey.getConstructor(String.class);
// } catch (Throwable ignore) {
// }
// if (classMinecraftKey != null) {
// getEntityId = ReflectionUtils.findMethod(classEntityTypes, classMinecraftKey, classEntity);
// createEntityFromId = ReflectionUtils.findMethod(classEntityTypes, classEntity, classMinecraftKey, classWorld);
// } else {
// getEntityId = ReflectionUtils.findMethod(classEntityTypes, String.class, classEntity);
// createEntityFromId = ReflectionUtils.findMethod(classEntityTypes, classEntity, String.class, classWorld);
// }
//
// noMods = Modifier.ABSTRACT | Modifier.PROTECTED | Modifier.PRIVATE;
// try {
// readEntityIntoTag = classEntity.getDeclaredMethod("save", classNBTTagCompound);
// } catch (Throwable ignore) {
// readEntityIntoTag = ReflectionUtils.findMethod(classEntity, classNBTTagCompound, classNBTTagCompound);
// if (readEntityIntoTag == null) {
// readEntityIntoTag = ReflectionUtils.findMethod(classEntity, 0, 0, noMods, Void.TYPE, classNBTTagCompound);
// }
// }
// ReflectionUtils.setAccessible(readEntityIntoTag);
// readTagIntoEntity = ReflectionUtils.findMethod(classEntity, 1, 0, noMods, Void.TYPE, classNBTTagCompound);
// if (readTagIntoEntity == null) {
// readTagIntoEntity = ReflectionUtils.findMethod(classEntity, 0, 0, noMods, Void.TYPE, classNBTTagCompound);
// }
// } catch (Throwable e) {
// e.printStackTrace();
// classEntity = null;
// }
// }
//
// @Nullable
// @Override
// public BaseEntity getEntity(Entity entity) {
// try {
// if (classEntity == null) return null;
// Object nmsEntity = getHandleEntity.invoke(entity);
//
// String id = getEntityId(nmsEntity);
//
// if (id != null) {
// Object tag = newNBTTagCompound.newInstance();
// readEntityIntoTag.invoke(nmsEntity, tag);
// return new BaseEntity(id, (CompoundTag) toNative(tag));
// }
// } catch (Throwable e) {
// throw new RuntimeException(e);
// }
// return null;
// }
//
// private String getEntityId(Object entity) throws InvocationTargetException, IllegalAccessException {
// Object res = getEntityId.invoke(null, entity);
// return res == null ? null : res.toString();
// }
//
// private Object createEntityFromId(String id, Object world) throws InvocationTargetException, IllegalAccessException, InstantiationException {
// if (classMinecraftKey != null) {
// Object key = newMinecraftKey.newInstance(id);
// return createEntityFromId.invoke(null, key, world);
// } else {
// return createEntityFromId.invoke(null, id, world);
// }
// }
//
// @Nullable
// @Override
// public Entity createEntity(Location location, BaseEntity state) {
// try {
// if (classEntity == null) return null;
// World world = location.getWorld();
// Object nmsWorld = getHandleWorld.invoke(world);
//
// Object createdEntity = createEntityFromId(state.getTypeId(), nmsWorld);
//
// if (createdEntity != null) {
// CompoundTag nativeTag = state.getNbtData();
// Map<String, Tag> rawMap = ReflectionUtils.getMap(nativeTag.getValue());
// for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
// rawMap.remove(name);
// }
// if (nativeTag != null) {
// Object tag = fromNative(nativeTag);
// readTagIntoEntity.invoke(createdEntity, tag);
// }
//
// setLocation.invoke(createdEntity, location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
//
// addEntity.invoke(nmsWorld, createdEntity, CreatureSpawnEvent.SpawnReason.CUSTOM);
// return (Entity) getBukkitEntity.invoke(createdEntity);
// }
// } catch (Throwable e) {
// throw new RuntimeException(e);
// }
// return null;
// }
//
// public Tag toNative(Object nmsTag) {
// try {
// return NMSToWE.get(nmsTag.getClass()).construct(nmsTag);
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
//
// public Object fromNative(Tag tag) {
// try {
// return WEToNMS.get(tag.getClass()).construct(tag);
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
//
// @Override
// public int getBlockId(Material material) {
// return material.getId();
// }
//
// @Override
// public Material getMaterial(int id) {
// return Material.getMaterial(id);
// }
//
// @Override
// public BiomeType getBiomeType(Biome biome) {
// try {
// Object biomeBase = biomeToBiomeBase.invoke(null, biome);
// if (biomeBase != null) return (int) biomeBaseToTypeId.invoke(null, biomeBase);
// } catch (Throwable e) {
// throw new RuntimeException(e);
// }
// return 0;
// }
//
// @Override
// public Biome getBiome(int id) {
// try {
// Object biomeBase = getBiome.invoke(null, id);
// if (biomeBase != null) return (Biome) biomeBaseToBiome.invoke(null, biomeBase);
// } catch (Throwable e) {
// throw new RuntimeException(e);
// }
// return Biome.OCEAN;
// }
//
// @Override
// public BaseBlock getBlock(Location location) {
// try {
// World craftWorld = location.getWorld();
// int x = location.getBlockX();
// int y = location.getBlockY();
// int z = location.getBlockZ();
//
// org.bukkit.block.Block bukkitBlock = location.getBlock();
// BaseBlock block = FaweCache.IMP.getBlock(bukkitBlock.getTypeId(), bukkitBlock.getData());
//
// // Read the NBT data
// Object nmsWorld = getHandleWorld.invoke(craftWorld);
// Object tileEntity = getTileEntity(nmsWorld, x, y, z);
//
// if (tileEntity != null) {
// block = new BaseBlock(block);
// Object tag = newNBTTagCompound.newInstance();
// readTileEntityIntoTag.invoke(tileEntity, tag);
// block.setNbtData((CompoundTag) toNative(tag));
// }
// return block;
// } catch (Throwable e) {
// throw new RuntimeException(e);
// }
// }
//
// public Object getTileEntity(Object nmsWorld, int x, int y, int z) {
// try {
// if (getTileEntity1 != null) {
// Object pos = newBlockPosition.newInstance(x, y, z);
// return getTileEntity1.invoke(nmsWorld, pos);
// } else {
// return getTileEntity2.invoke(nmsWorld, x, y, z);
// }
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
//
// @Override
// public boolean setBlock(Location location, BaseBlock block, boolean notifyAndLight) {
// World craftWorld = location.getWorld();
// int x = location.getBlockX();
// int y = location.getBlockY();
// int z = location.getBlockZ();
//
// boolean changed = location.getBlock().setTypeIdAndData(block.getId(), (byte) block.getData(), notifyAndLight);
//
// CompoundTag nativeTag = block.getNbtData();
// if (nativeTag != null) {
// try {
// Object nmsWorld = getHandleWorld.invoke(craftWorld);
// Object tileEntity = getTileEntity(nmsWorld, x, y, z);
// if (tileEntity != null) {
// Object tag = fromNative(nativeTag);
//
// setNBTTagCompound.invoke(tag, "x", newNBTTagInt.newInstance(x));
// setNBTTagCompound.invoke(tag, "y", newNBTTagInt.newInstance(y));
// setNBTTagCompound.invoke(tag, "z", newNBTTagInt.newInstance(z));
// readTagIntoTileEntity.invoke(tileEntity, tag); // Load data
// }
// } catch (Throwable e) {
// throw new RuntimeException(e);
// }
// }
//
// return changed;
// }
//
// private interface NMSTagConstructor {
// Object construct(Tag value) throws Exception;
// }
//
// private interface WETagConstructor {
// Tag construct(Object value) throws Exception;
// }
//}

Datei anzeigen

@ -12,6 +12,9 @@ import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypesCache; import com.sk89q.worldedit.world.block.BlockTypesCache;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Method;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import net.jpountz.util.UnsafeUtils; import net.jpountz.util.UnsafeUtils;
import net.minecraft.server.v1_14_R1.Block; import net.minecraft.server.v1_14_R1.Block;
@ -52,6 +55,8 @@ public final class BukkitAdapter_1_14 extends NMSAdapter {
private final static Field fieldDirtyCount; private final static Field fieldDirtyCount;
private final static Field fieldDirtyBits; private final static Field fieldDirtyBits;
private final static MethodHandle methodGetVisibleChunk;
private static final int CHUNKSECTION_BASE; private static final int CHUNKSECTION_BASE;
private static final int CHUNKSECTION_SHIFT; private static final int CHUNKSECTION_SHIFT;
@ -78,6 +83,10 @@ public final class BukkitAdapter_1_14 extends NMSAdapter {
fieldDirtyBits = PlayerChunk.class.getDeclaredField("r"); fieldDirtyBits = PlayerChunk.class.getDeclaredField("r");
fieldDirtyBits.setAccessible(true); fieldDirtyBits.setAccessible(true);
Method declaredGetVisibleChunk = PlayerChunkMap.class.getDeclaredMethod("getVisibleChunk", long.class);
declaredGetVisibleChunk.setAccessible(true);
methodGetVisibleChunk = MethodHandles.lookup().unreflect(declaredGetVisibleChunk);
{ {
Field tmp; Field tmp;
try { try {
@ -154,11 +163,11 @@ public final class BukkitAdapter_1_14 extends NMSAdapter {
public static PlayerChunk getPlayerChunk(net.minecraft.server.v1_14_R1.WorldServer nmsWorld, final int cx, final int cz) { public static PlayerChunk getPlayerChunk(net.minecraft.server.v1_14_R1.WorldServer nmsWorld, final int cx, final int cz) {
PlayerChunkMap chunkMap = nmsWorld.getChunkProvider().playerChunkMap; PlayerChunkMap chunkMap = nmsWorld.getChunkProvider().playerChunkMap;
PlayerChunk playerChunk = chunkMap.visibleChunks.get(ChunkCoordIntPair.pair(cx, cz)); try {
if (playerChunk == null) { return (PlayerChunk)methodGetVisibleChunk.invoke(chunkMap, ChunkCoordIntPair.pair(cx, cz));
return null; } catch (Throwable thr) {
throw new RuntimeException(thr);
} }
return playerChunk;
} }
public static void sendChunk(net.minecraft.server.v1_14_R1.WorldServer nmsWorld, int X, int Z, int mask) { public static void sendChunk(net.minecraft.server.v1_14_R1.WorldServer nmsWorld, int X, int Z, int mask) {

Datei anzeigen

@ -12,6 +12,9 @@ import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypesCache; import com.sk89q.worldedit.world.block.BlockTypesCache;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Method;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import net.jpountz.util.UnsafeUtils; import net.jpountz.util.UnsafeUtils;
import net.minecraft.server.v1_15_R1.*; import net.minecraft.server.v1_15_R1.*;
@ -40,6 +43,8 @@ public final class BukkitAdapter_1_15 extends NMSAdapter {
private final static Field fieldDirtyCount; private final static Field fieldDirtyCount;
private final static Field fieldDirtyBits; private final static Field fieldDirtyBits;
private final static MethodHandle methodGetVisibleChunk;
private static final int CHUNKSECTION_BASE; private static final int CHUNKSECTION_BASE;
private static final int CHUNKSECTION_SHIFT; private static final int CHUNKSECTION_SHIFT;
@ -66,6 +71,10 @@ public final class BukkitAdapter_1_15 extends NMSAdapter {
fieldDirtyBits = PlayerChunk.class.getDeclaredField("r"); fieldDirtyBits = PlayerChunk.class.getDeclaredField("r");
fieldDirtyBits.setAccessible(true); fieldDirtyBits.setAccessible(true);
Method declaredGetVisibleChunk = PlayerChunkMap.class.getDeclaredMethod("getVisibleChunk", long.class);
declaredGetVisibleChunk.setAccessible(true);
methodGetVisibleChunk = MethodHandles.lookup().unreflect(declaredGetVisibleChunk);
Field tmp = DataPaletteBlock.class.getDeclaredField("j"); Field tmp = DataPaletteBlock.class.getDeclaredField("j");
ReflectionUtils.setAccessibleNonFinal(tmp); ReflectionUtils.setAccessibleNonFinal(tmp);
fieldLock = tmp; fieldLock = tmp;
@ -135,8 +144,11 @@ public final class BukkitAdapter_1_15 extends NMSAdapter {
public static PlayerChunk getPlayerChunk(net.minecraft.server.v1_15_R1.WorldServer nmsWorld, final int cx, final int cz) { public static PlayerChunk getPlayerChunk(net.minecraft.server.v1_15_R1.WorldServer nmsWorld, final int cx, final int cz) {
PlayerChunkMap chunkMap = nmsWorld.getChunkProvider().playerChunkMap; PlayerChunkMap chunkMap = nmsWorld.getChunkProvider().playerChunkMap;
PlayerChunk playerChunk = chunkMap.visibleChunks.get(ChunkCoordIntPair.pair(cx, cz)); try {
return playerChunk; return (PlayerChunk)methodGetVisibleChunk.invoke(chunkMap, ChunkCoordIntPair.pair(cx, cz));
} catch (Throwable thr) {
throw new RuntimeException(thr);
}
} }
public static void sendChunk(net.minecraft.server.v1_15_R1.WorldServer nmsWorld, int X, int Z, int mask) { public static void sendChunk(net.minecraft.server.v1_15_R1.WorldServer nmsWorld, int X, int Z, int mask) {

Datei anzeigen

@ -12,6 +12,10 @@ import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypesCache; import com.sk89q.worldedit.world.block.BlockTypesCache;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.reflect.Method;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import net.jpountz.util.UnsafeUtils; import net.jpountz.util.UnsafeUtils;
import net.minecraft.server.v1_15_R1.*; import net.minecraft.server.v1_15_R1.*;
@ -40,6 +44,8 @@ public final class BukkitAdapter_1_15_2 extends NMSAdapter {
private final static Field fieldDirtyCount; private final static Field fieldDirtyCount;
private final static Field fieldDirtyBits; private final static Field fieldDirtyBits;
private final static MethodHandle methodGetVisibleChunk;
private static final int CHUNKSECTION_BASE; private static final int CHUNKSECTION_BASE;
private static final int CHUNKSECTION_SHIFT; private static final int CHUNKSECTION_SHIFT;
@ -66,6 +72,10 @@ public final class BukkitAdapter_1_15_2 extends NMSAdapter {
fieldDirtyBits = PlayerChunk.class.getDeclaredField("r"); fieldDirtyBits = PlayerChunk.class.getDeclaredField("r");
fieldDirtyBits.setAccessible(true); fieldDirtyBits.setAccessible(true);
Method declaredGetVisibleChunk = PlayerChunkMap.class.getDeclaredMethod("getVisibleChunk", long.class);
declaredGetVisibleChunk.setAccessible(true);
methodGetVisibleChunk = MethodHandles.lookup().unreflect(declaredGetVisibleChunk);
Field tmp = DataPaletteBlock.class.getDeclaredField("j"); Field tmp = DataPaletteBlock.class.getDeclaredField("j");
ReflectionUtils.setAccessibleNonFinal(tmp); ReflectionUtils.setAccessibleNonFinal(tmp);
fieldLock = tmp; fieldLock = tmp;
@ -136,8 +146,11 @@ public final class BukkitAdapter_1_15_2 extends NMSAdapter {
public static PlayerChunk getPlayerChunk(WorldServer nmsWorld, final int cx, final int cz) { public static PlayerChunk getPlayerChunk(WorldServer nmsWorld, final int cx, final int cz) {
PlayerChunkMap chunkMap = nmsWorld.getChunkProvider().playerChunkMap; PlayerChunkMap chunkMap = nmsWorld.getChunkProvider().playerChunkMap;
PlayerChunk playerChunk = chunkMap.visibleChunks.get(ChunkCoordIntPair.pair(cx, cz)); try {
return playerChunk; return (PlayerChunk)methodGetVisibleChunk.invoke(chunkMap, ChunkCoordIntPair.pair(cx, cz));
} catch (Throwable thr) {
throw new RuntimeException(thr);
}
} }
public static void sendChunk(WorldServer nmsWorld, int X, int Z, int mask) { public static void sendChunk(WorldServer nmsWorld, int X, int Z, int mask) {

Datei anzeigen

@ -18,21 +18,21 @@ import com.sk89q.worldedit.world.block.BlockState;
// TODO FIXME // TODO FIXME
public class FaweLocalBlockQueue extends LocalBlockQueue { public class FaweLocalBlockQueue extends LocalBlockQueue {
public final IQueueExtent<IQueueChunk> IMP; public final IQueueExtent<IQueueChunk> instance;
private final World world; private final World world;
private BlockVector3 mutable = new MutableBlockVector3(); private BlockVector3 mutable = new MutableBlockVector3();
public FaweLocalBlockQueue(String worldName) { public FaweLocalBlockQueue(String worldName) {
super(worldName); super(worldName);
this.world = FaweAPI.getWorld(worldName); this.world = FaweAPI.getWorld(worldName);
IMP = Fawe.get().getQueueHandler().getQueue(world); instance = Fawe.get().getQueueHandler().getQueue(world);
Fawe.get().getQueueHandler().unCache(); Fawe.get().getQueueHandler().unCache();
} }
@Override @Override
public boolean next() { public boolean next() {
if (!IMP.isEmpty()) { if (!instance.isEmpty()) {
IMP.flush(); instance.flush();
} }
return false; return false;
} }
@ -49,7 +49,7 @@ public class FaweLocalBlockQueue extends LocalBlockQueue {
@Override @Override
public int size() { public int size() {
return IMP.isEmpty() ? 0 : 1; return instance.isEmpty() ? 0 : 1;
} }
@Override @Override
@ -62,33 +62,33 @@ public class FaweLocalBlockQueue extends LocalBlockQueue {
@Override @Override
public long getModified() { public long getModified() {
return IMP.size(); return instance.size();
} }
@Override @Override
public boolean setBlock(final int x, final int y, final int z, final BlockState id) { public boolean setBlock(final int x, final int y, final int z, final BlockState id) {
return IMP.setBlock(x, y, z, id); return instance.setBlock(x, y, z, id);
} }
@Override @Override
public boolean setBlock(int x, int y, int z, Pattern pattern) { public boolean setBlock(int x, int y, int z, Pattern pattern) {
mutable.setComponents(x, y, z); mutable.setComponents(x, y, z);
return pattern.apply(IMP, mutable, mutable); return pattern.apply(instance, mutable, mutable);
} }
@Override @Override
public boolean setBlock(final int x, final int y, final int z, final BaseBlock id) { public boolean setBlock(final int x, final int y, final int z, final BaseBlock id) {
return IMP.setBlock(x, y, z, id); return instance.setBlock(x, y, z, id);
} }
@Override @Override
public BlockState getBlock(int x, int y, int z) { public BlockState getBlock(int x, int y, int z) {
return IMP.getBlock(x, y, z); return instance.getBlock(x, y, z);
} }
@Override @Override
public boolean setBiome(int x, int z, BiomeType biomeType) { public boolean setBiome(int x, int z, BiomeType biomeType) {
return IMP.setBiome(x, 0, z, biomeType); return instance.setBiome(x, 0, z, biomeType);
} }
@Override @Override
@ -98,13 +98,13 @@ public class FaweLocalBlockQueue extends LocalBlockQueue {
@Override @Override
public void flush() { public void flush() {
IMP.flush(); instance.flush();
} }
@Override @Override
public boolean enqueue() { public boolean enqueue() {
boolean val = super.enqueue(); boolean val = super.enqueue();
IMP.enableQueue(); instance.enableQueue();
return val; return val;
} }
@ -119,12 +119,12 @@ public class FaweLocalBlockQueue extends LocalBlockQueue {
@Override @Override
public void regenChunk(int x, int z) { public void regenChunk(int x, int z) {
IMP.regenerateChunk(x, z, null, null); instance.regenerateChunk(x, z, null, null);
} }
@Override @Override
public boolean setTile(int x, int y, int z, CompoundTag tag) { public boolean setTile(int x, int y, int z, CompoundTag tag) {
IMP.setTile(x, y, z, (com.sk89q.jnbt.CompoundTag) FaweCache.IMP.asTag(tag)); instance.setTile(x, y, z, (com.sk89q.jnbt.CompoundTag) FaweCache.IMP.asTag(tag));
return true; return true;
} }
} }

Datei anzeigen

@ -19,6 +19,7 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
@ -29,6 +30,7 @@ import java.util.Collection;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
import org.bukkit.Bukkit;
@CommandDeclaration( @CommandDeclaration(
command = "generatebiome", command = "generatebiome",
@ -71,11 +73,11 @@ public class PlotSetBiome extends Command {
} }
plot.addRunning(); plot.addRunning();
TaskManager.IMP.async(() -> { TaskManager.IMP.async(() -> {
EditSession session = new EditSessionBuilder(FaweAPI.getWorld(plot.getArea().worldname)) EditSession session = new EditSessionBuilder(BukkitAdapter.adapt(Bukkit.getWorld(plot.getArea().worldname)))
.autoQueue(false) .autoQueue(false)
.checkMemory(false) .checkMemory(false)
.allowedRegionsEverywhere() .allowedRegionsEverywhere()
.player(Fawe.imp().wrap(player.getUUID())) .player(BukkitAdapter.adapt(Bukkit.getPlayer(player.getUUID())))
.limitUnlimited() .limitUnlimited()
.build(); .build();
long seed = ThreadLocalRandom.current().nextLong(); long seed = ThreadLocalRandom.current().nextLong();

Datei anzeigen

@ -292,11 +292,11 @@ public class Fawe {
} }
public void setupConfigs() { public void setupConfigs() {
MainUtil.copyFile(MainUtil.getJarFile(), "lang/strings.json", null); MainUtil.copyFile(MainUtil.getJarFile(), "lang" + File.separator + "strings.json", null);
// Setting up config.yml // Setting up config.yml
File file = new File(this.IMP.getDirectory(), "config.yml"); File file = new File(this.IMP.getDirectory(), "config.yml");
Settings.IMP.PLATFORM = IMP.getPlatform().replace("\"", ""); Settings.IMP.PLATFORM = IMP.getPlatform().replace("\"", "");
try (InputStream stream = getClass().getResourceAsStream("/fawe.properties"); try (InputStream stream = getClass().getResourceAsStream(File.separator + "fawe.properties");
BufferedReader br = new BufferedReader(new InputStreamReader(stream))) { BufferedReader br = new BufferedReader(new InputStreamReader(stream))) {
String versionString = br.readLine(); String versionString = br.readLine();
String commitString = br.readLine(); String commitString = br.readLine();

Datei anzeigen

@ -17,8 +17,6 @@ public interface IFawe {
File getDirectory(); File getDirectory();
Player wrap(final Object obj);
TaskManager getTaskManager(); TaskManager getTaskManager();
Collection<FaweMaskManager> getMaskManagers(); Collection<FaweMaskManager> getMaskManagers();

Datei anzeigen

@ -1,5 +1,6 @@
package com.boydti.fawe.beta.implementation.queue; package com.boydti.fawe.beta.implementation.queue;
@FunctionalInterface
public interface Pool<T> { public interface Pool<T> {
T poll(); T poll();
default boolean offer(T recycle) { default boolean offer(T recycle) {

Datei anzeigen

@ -188,13 +188,13 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
* Get a new IChunk from either the pool, or create a new one<br> + Initialize it at the * Get a new IChunk from either the pool, or create a new one<br> + Initialize it at the
* coordinates * coordinates
* *
* @param X * @param chunkX
* @param Z * @param chunkZ
* @return IChunk * @return IChunk
*/ */
private ChunkHolder poolOrCreate(int X, int Z) { private ChunkHolder poolOrCreate(int chunkX, int chunkZ) {
ChunkHolder next = create(false); ChunkHolder next = create(false);
next.init(this, X, Z); next.init(this, chunkX, chunkZ);
return next; return next;
} }

Datei anzeigen

@ -93,7 +93,7 @@ public class Settings extends Config {
" - Use a shared directory or NFS/Samba" " - Use a shared directory or NFS/Samba"
}) })
public String CLIPBOARD = "clipboard"; public String CLIPBOARD = "clipboard";
@Comment("Each player has their own sub directory for schematics") @Comment("Each player has his or her own sub directory for schematics")
public boolean PER_PLAYER_SCHEMATICS = true; public boolean PER_PLAYER_SCHEMATICS = true;
public String COMMANDS = "commands"; public String COMMANDS = "commands";
} }
@ -288,7 +288,7 @@ public class Settings extends Config {
"Increase or decrease queue intensity (ms) [-50,50]:", "Increase or decrease queue intensity (ms) [-50,50]:",
" 0 = balance of performance / stability", " 0 = balance of performance / stability",
" -10 = Allocate 10ms less for chunk placement", " -10 = Allocate 10ms less for chunk placement",
"Too high will can cause lag spikes (you might be okay with this)", "Too high can cause lag spikes (you might be okay with this)",
"Too low will result in slow edits", "Too low will result in slow edits",
}) })
public int EXTRA_TIME_MS = 0; public int EXTRA_TIME_MS = 0;

Datei anzeigen

@ -31,7 +31,7 @@ import java.util.Iterator;
import java.util.UUID; import java.util.UUID;
import java.util.function.Supplier; import java.util.function.Supplier;
public class InspectBrush extends BrushTool implements DoubleActionTraceTool { public class InspectBrush extends BrushTool {
/** /**
* Construct the tool. * Construct the tool.
@ -61,13 +61,14 @@ public class InspectBrush extends BrushTool implements DoubleActionTraceTool {
} }
public boolean perform(final Player player, LocalSession session, boolean rightClick) { public boolean perform(final Player player, LocalSession session, boolean rightClick) {
if (!session.isToolControlEnabled() || !player.hasPermission("worldedit.tool.inspect")) { if (!player.hasPermission("worldedit.tool.inspect")) {
player.print(Caption.of("", "worldedit.tool.inspect")); player.print(Caption.of("", "worldedit.tool.inspect"));
System.out.println("No tool control"); System.out.println("No tool control");
return false; return false;
} }
if (!Settings.IMP.HISTORY.USE_DATABASE) { if (!Settings.IMP.HISTORY.USE_DATABASE) {
player.print(Caption.of("fawe.error.setting.disable", ("history.use-database (Import with /history import )"))); player.print(Caption.of("fawe.error.setting.disable",
"history.use-database (Import with /history import )"));
System.out.println("No db"); System.out.println("No db");
return false; return false;
} }

Datei anzeigen

@ -1493,9 +1493,7 @@ public class LocalSession implements TextureHolder {
private void prepareEditingExtents(EditSession editSession, Actor actor) { private void prepareEditingExtents(EditSession editSession, Actor actor) {
editSession.setFastMode(fastMode); editSession.setFastMode(fastMode);
/*
editSession.setReorderMode(reorderMode); editSession.setReorderMode(reorderMode);
*/
if (editSession.getSurvivalExtent() != null) { if (editSession.getSurvivalExtent() != null) {
editSession.getSurvivalExtent().setStripNbt(!actor.hasPermission("worldedit.setnbt")); editSession.getSurvivalExtent().setStripNbt(!actor.hasPermission("worldedit.setnbt"));
} }
@ -1526,7 +1524,6 @@ public class LocalSession implements TextureHolder {
* @return The reorder mode * @return The reorder mode
*/ */
public EditSession.ReorderMode getReorderMode() { public EditSession.ReorderMode getReorderMode() {
// return reorderMode;
return EditSession.ReorderMode.FAST; return EditSession.ReorderMode.FAST;
} }
@ -1536,7 +1533,6 @@ public class LocalSession implements TextureHolder {
* @param reorderMode The reorder mode * @param reorderMode The reorder mode
*/ */
public void setReorderMode(EditSession.ReorderMode reorderMode) { public void setReorderMode(EditSession.ReorderMode reorderMode) {
// this.reorderMode = reorderMode;
} }
/** /**