Use default bukkit block placer if NMS fails

The default block placer uses only the Bukkit API to perform changes.
- It's a bit laggy for larger changes
- Still a lot faster than normal WorldEdit
This commit is contained in:
Jesse Boyd 2016-04-22 01:41:41 +10:00
parent a7763cd8fd
commit 7e0964c118
7 changed files with 356 additions and 230 deletions

View File

@ -1,9 +1,7 @@
package com.boydti.fawe.bukkit.v0;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.object.FaweChunk;
import com.boydti.fawe.util.FaweQueue;
import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.world.biome.BaseBiome;
import java.util.Collection;
import java.util.concurrent.ConcurrentHashMap;
@ -12,7 +10,6 @@ import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
/**
* The base object for
@ -27,14 +24,8 @@ public abstract class BukkitQueue_0 extends FaweQueue implements Listener {
private ConcurrentHashMap<Long, FaweChunk<Chunk>> blocks = new ConcurrentHashMap<>();
private LinkedBlockingDeque<FaweChunk<Chunk>> chunks = new LinkedBlockingDeque<>();
public BukkitQueue_0(String world) {
public BukkitQueue_0(final String world) {
super(world);
TaskManager.IMP.task(new Runnable() {
@Override
public void run() {
Bukkit.getPluginManager().registerEvents(BukkitQueue_0.this, (Plugin) Fawe.imp());
}
});
}
@Override

View File

@ -0,0 +1,291 @@
package com.boydti.fawe.bukkit.v0;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.bukkit.v1_8.BukkitChunk_1_8;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweChunk;
import com.boydti.fawe.object.IntegerPair;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.bukkit.BukkitUtil;
import com.sk89q.worldedit.world.biome.BaseBiome;
import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.LinkedBlockingDeque;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.plugin.Plugin;
import org.spigotmc.AsyncCatcher;
public class BukkitQueue_All extends BukkitQueue_0 {
public final LinkedBlockingDeque<IntegerPair> loadQueue = new LinkedBlockingDeque<>();
public BukkitQueue_All(final String world) {
super(world);
TaskManager.IMP.repeat(new Runnable() {
@Override
public void run() {
synchronized (loadQueue) {
while (loadQueue.size() > 0) {
IntegerPair loc = loadQueue.poll();
if (bukkitWorld == null) {
bukkitWorld = Bukkit.getServer().getWorld(world);
}
if (!bukkitWorld.isChunkLoaded(loc.x, loc.z)) {
bukkitWorld.loadChunk(loc.x, loc.z, true);
}
}
loadQueue.notifyAll();
}
}
}, 1);
if (getClass() == BukkitQueue_All.class) {
TaskManager.IMP.task(new Runnable() {
@Override
public void run() {
Bukkit.getPluginManager().registerEvents(BukkitQueue_All.this, (Plugin) Fawe.imp());
}
});
}
}
private boolean physicsFreeze = false;
@EventHandler
public void onPhysics(BlockPhysicsEvent event) {
if (physicsFreeze) {
event.setCancelled(true);
}
}
@EventHandler
public void onItemSpawn(ItemSpawnEvent event) {
if (physicsFreeze) {
event.setCancelled(true);
}
}
@Override
public Collection<FaweChunk<Chunk>> sendChunk(Collection<FaweChunk<Chunk>> fcs) {
return new ArrayList<>();
}
@Override
public boolean setComponents(FaweChunk<Chunk> fc) {
try {
startSet();
final BukkitChunk_1_8 fs = ((BukkitChunk_1_8) fc);
final Chunk chunk = fs.getChunk();
final World world = chunk.getWorld();
char[][] sections = fs.getIdArrays();
boolean done = false;
boolean more = false;
// Efficiently merge sections
for (int j = 0; j < sections.length; j++) {
final int jf = j;
int changes = fs.getCount(j);
int lighting = fs.getRelight(j);
if (changes == 0) {
continue;
}
final char[] newArray = sections[j];
if (newArray == null) {
continue;
}
if (done) {
more = true;
break;
}
done = true;
sections[j] = null;
ArrayList<Thread> threads = new ArrayList<Thread>();
for (int k = 0; k < 16; k++) {
final int l = k << 8;
final int y = FaweCache.CACHE_Y[j][l];
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
for (int m = l; m < l + 256; m++) {
int combined = newArray[m];
switch (combined) {
case 0:
continue;
case 1:
int x = FaweCache.CACHE_X[jf][m];
int z = FaweCache.CACHE_Z[jf][m];
chunk.getBlock(x, y, z).setTypeId(0, false);
continue;
default:
x = FaweCache.CACHE_X[jf][m];
z = FaweCache.CACHE_Z[jf][m];
int id = combined >> 4;
int data = combined & 0xF;
Block block = chunk.getBlock(x, y, z);
if (data == 0) {
block.setTypeId(id, false);
} else {
block.setTypeIdAndData(id, (byte) data, false);
}
continue;
}
}
}
});
threads.add(thread);
thread.start();
}
for (Thread thread : threads) {
thread.join();
}
}
if (more) {
fc.addToQueue();
}
// Biomes
final int[][] biomes = fs.getBiomeArray();
if (biomes != null) {
final LocalWorld lw = BukkitUtil.getLocalWorld(world);
final int X = fs.getX() << 4;
final int Z = fs.getZ() << 4;
final BaseBiome bb = new BaseBiome(0);
int last = 0;
for (int x = 0; x < 16; x++) {
final int[] array = biomes[x];
if (array == null) {
continue;
}
for (int z = 0; z < 16; z++) {
final int biome = array[z];
if (biome == 0) {
continue;
}
if (last != biome) {
last = biome;
bb.setId(biome);
}
lw.setBiome(new Vector2D(X + x, Z + z), bb);
}
}
}
endSet();
return true;
} catch (final Throwable e) {
e.printStackTrace();
}
endSet();
return false;
}
public void startSet() {
physicsFreeze = true;
try {
// Need to temporarily disable the async catcher since it can't discern safe/unsafe async calls
// The main thread will be locked until it is enabled again (if anything fails it will be enabled again)
AsyncCatcher.enabled = false;
} catch (Throwable ignore) {}
}
public void endSet() {
physicsFreeze = false;
try {
AsyncCatcher.enabled = true;
} catch (Throwable ignore) {}
}
@Override
public FaweChunk<Chunk> getChunk(int x, int z) {
return new BukkitChunk_1_8(this, x, z);
}
@Override
public boolean fixLighting(FaweChunk<?> fc, boolean fixAll) {
return true;
}
public void loadChunk(IntegerPair chunk) {
loadQueue.add(chunk);
}
public int lastChunkX = Integer.MIN_VALUE;
public int lastChunkZ = Integer.MIN_VALUE;
public int lastChunkY = Integer.MIN_VALUE;
private Object lastChunk;
private Object lastSection;
public Object getCachedChunk(int cx, int cz) {
return bukkitWorld.getChunkAt(cx, cz);
}
public Object getCachedSection(Object chunk, int cy) {
return lastChunk;
}
public int getCombinedId4Data(Object section, int x, int y, int z) {
Block block = ((Chunk) lastChunk).getBlock(x & 15, y, z & 15);
int combined = block.getTypeId() << 4;
if (FaweCache.hasData(combined)) {
combined += block.getData();
}
return combined;
}
@Override
public int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
if (y < 0 || y > 255) {
return 0;
}
int cx = x >> 4;
int cz = z >> 4;
int cy = y >> 4;
if (cx != lastChunkX || cz != lastChunkZ) {
if (bukkitWorld == null) {
bukkitWorld = Bukkit.getServer().getWorld(world);
}
lastChunkX = cx;
lastChunkZ = cz;
if (!bukkitWorld.isChunkLoaded(cx, cz)) {
boolean sync = Thread.currentThread() == Fawe.get().getMainThread();
if (sync) {
bukkitWorld.loadChunk(cx, cz, true);
} else if (Settings.CHUNK_WAIT > 0) {
synchronized (loadQueue) {
loadQueue.add(new IntegerPair(cx, cz));
try {
loadQueue.wait(Settings.CHUNK_WAIT);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
if (!bukkitWorld.isChunkLoaded(cx, cz)) {
throw new FaweException.FaweChunkLoadException();
}
} else {
return 0;
}
}
lastChunk = getCachedChunk(cx, cz);
lastSection = getCachedSection(lastChunk, cy);
} else if (cy != lastChunkY) {
if (lastChunk == null) {
return 0;
}
lastSection = getCachedSection(lastChunk, cy);
}
if (lastChunk == null) {
return 0;
}
return getCombinedId4Data(lastSection, x, y, z);
}
}

View File

@ -2,12 +2,11 @@ package com.boydti.fawe.bukkit.v1_8;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
import com.boydti.fawe.bukkit.v0.BukkitQueue_All;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweChunk;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.IntegerPair;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.MemUtil;
import com.boydti.fawe.util.ReflectionUtils.RefClass;
import com.boydti.fawe.util.ReflectionUtils.RefConstructor;
@ -31,7 +30,6 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.LinkedBlockingDeque;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
@ -46,7 +44,7 @@ import org.bukkit.generator.ChunkGenerator;
import static com.boydti.fawe.util.ReflectionUtils.getRefClass;
public class BukkitQueue_1_8 extends BukkitQueue_0 {
public class BukkitQueue_1_8 extends BukkitQueue_All {
private final RefClass classEntityPlayer = getRefClass("{nms}.EntityPlayer");
private final RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk");
@ -99,75 +97,23 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
} catch (final NoSuchMethodException e) {
e.printStackTrace();
}
TaskManager.IMP.repeat(new Runnable() {
@Override
public void run() {
synchronized (loadQueue) {
while (loadQueue.size() > 0) {
IntegerPair loc = loadQueue.poll();
if (bukkitWorld == null) {
bukkitWorld = Bukkit.getServer().getWorld(world);
}
if (!bukkitWorld.isChunkLoaded(loc.x, loc.z)) {
bukkitWorld.loadChunk(loc.x, loc.z, true);
}
}
loadQueue.notifyAll();
}
}
}, 1);
}
private LinkedBlockingDeque<IntegerPair> loadQueue = new LinkedBlockingDeque<>();
public Object getCachedChunk(int cx, int cz) {
return methodGetHandleChunk.of(bukkitWorld.getChunkAt(cx, cz)).call();
}
@Override
public int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
if (y < 0 || y > 255) {
return 0;
}
int cx = x >> 4;
int cz = z >> 4;
int cy = y >> 4;
if (cx != lcx || cz != lcz) {
if (bukkitWorld == null) {
bukkitWorld = Bukkit.getServer().getWorld(world);
}
lcx = cx;
lcz = cz;
if (!bukkitWorld.isChunkLoaded(cx, cz)) {
boolean sync = Thread.currentThread() == Fawe.get().getMainThread();
if (sync) {
bukkitWorld.loadChunk(cx, cz, true);
} else if (Settings.CHUNK_WAIT > 0) {
synchronized (loadQueue) {
loadQueue.add(new IntegerPair(cx, cz));
try {
loadQueue.wait(Settings.CHUNK_WAIT);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
if (!bukkitWorld.isChunkLoaded(cx, cz)) {
throw new FaweException.FaweChunkLoadException();
}
} else {
return 0;
}
}
lc = methodGetHandleChunk.of(bukkitWorld.getChunkAt(cx, cz)).call();
} else if (cy == lcy) {
return ls != null ? ls[FaweCache.CACHE_J[y][x & 15][z & 15]] : 0;
}
if (lc == null) {
return 0;
}
Object storage = ((Object[]) fieldSections.of(lc).get())[cy];
public Object getCachedSection(Object chunk, int cy) {
Object storage = ((Object[]) fieldSections.of(chunk).get())[cy];
if (storage == null) {
ls = null;
return 0;
return null;
}
ls = getIdArray(storage);
return ls[FaweCache.CACHE_J[y][x & 15][z & 15]];
return getIdArray(storage);
}
public int getCombinedId4Data(Object section, int x, int y, int z) {
char[] ls = (char[]) section;
return ls != null ? ls[FaweCache.CACHE_J[y][x & 15][z & 15]] : 0;
}
@Override
@ -337,12 +283,6 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
return array[j] >> 4;
}
private int lcx = Integer.MIN_VALUE;
private int lcz = Integer.MIN_VALUE;
private int lcy = Integer.MIN_VALUE;
private Object lc;
private char[] ls;
@Override
public boolean setComponents(final FaweChunk<Chunk> fc) {
try {

View File

@ -2,13 +2,12 @@ package com.boydti.fawe.bukkit.v1_9;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
import com.boydti.fawe.bukkit.v0.BukkitQueue_All;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweChunk;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.IntegerPair;
import com.boydti.fawe.object.PseudoRandom;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.MemUtil;
import com.boydti.fawe.util.ReflectionUtils.RefClass;
import com.boydti.fawe.util.ReflectionUtils.RefConstructor;
@ -29,7 +28,6 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.LinkedBlockingDeque;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
@ -45,7 +43,7 @@ import org.bukkit.generator.ChunkGenerator;
import static com.boydti.fawe.util.ReflectionUtils.getRefClass;
public class BukkitQueue_1_9 extends BukkitQueue_0 {
public class BukkitQueue_1_9 extends BukkitQueue_All {
private final RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk");
private final RefClass classChunk = getRefClass("{nms}.Chunk");
@ -89,67 +87,18 @@ public class BukkitQueue_1_9 extends BukkitQueue_0 {
this.tileEntityListTick = this.classWorld.getField("tileEntityListTick");
this.methodGetWorld = this.classChunk.getMethod("getWorld");
this.methodGetCombinedId = classBlock.getMethod("getCombinedId", classIBlockData.getRealClass());
TaskManager.IMP.repeat(new Runnable() {
@Override
public void run() {
synchronized (loadQueue) {
while (loadQueue.size() > 0) {
IntegerPair loc = loadQueue.poll();
if (bukkitWorld == null) {
bukkitWorld = Bukkit.getServer().getWorld(world);
}
if (!bukkitWorld.isChunkLoaded(loc.x, loc.z)) {
bukkitWorld.loadChunk(loc.x, loc.z, true);
}
}
loadQueue.notifyAll();
}
}
}, 1);
}
private LinkedBlockingDeque<IntegerPair> loadQueue = new LinkedBlockingDeque<>();
public Object getCachedChunk(int cx, int cz) {
return methodGetType.of(methodGetHandleChunk.of(bukkitWorld.getChunkAt(cx, cz)).call());
}
@Override
public int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
if (y < 0 || y > 255) {
return 0;
}
int cx = x >> 4;
int cz = z >> 4;
int cy = y >> 4;
if (cx != lcx || cz != lcz) {
if (bukkitWorld == null) {
bukkitWorld = Bukkit.getServer().getWorld(world);
}
lcx = cx;
lcz = cz;
if (!bukkitWorld.isChunkLoaded(cx, cz)) {
boolean sync = Thread.currentThread() == Fawe.get().getMainThread();
if (sync) {
bukkitWorld.loadChunk(cx, cz, true);
} else if (Settings.CHUNK_WAIT > 0) {
synchronized (loadQueue) {
loadQueue.add(new IntegerPair(cx, cz));
try {
loadQueue.wait(Settings.CHUNK_WAIT);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
if (!bukkitWorld.isChunkLoaded(cx, cz)) {
throw new FaweException.FaweChunkLoadException();
}
} else {
return 0;
}
}
lc = methodGetType.of(methodGetHandleChunk.of(bukkitWorld.getChunkAt(cx, cz)).call());
}
if (lc == null) {
return 0;
}
int combined = (int) methodGetCombinedId.call(lc.call(x & 15, y, z & 15));
public Object getCachedSection(Object chunk, int cy) {
return chunk;
}
public int getCombinedId4Data(Object section, int x, int y, int z) {
int combined = (int) methodGetCombinedId.call(((RefExecutor) section).call(x & 15, y, z & 15));
return ((combined & 4095) << 4) + (combined >> 12);
}
@ -304,12 +253,6 @@ public class BukkitQueue_1_9 extends BukkitQueue_0 {
return this.methodGetBlocks.of(obj).call();
}
private int lcx = Integer.MIN_VALUE;
private int lcz = Integer.MIN_VALUE;
private int lcy = Integer.MIN_VALUE;
private RefExecutor lc;
private World bukkitWorld;
@Override
public boolean setComponents(final FaweChunk<Chunk> pc) {
final BukkitChunk_1_9 fs = (BukkitChunk_1_9) pc;

View File

@ -2,14 +2,13 @@ package com.boydti.fawe.bukkit.v1_9;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
import com.boydti.fawe.bukkit.v0.BukkitQueue_All;
import com.boydti.fawe.bukkit.v1_8.BukkitChunk_1_8;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweChunk;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.IntegerPair;
import com.boydti.fawe.object.PseudoRandom;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.MemUtil;
import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.LocalSession;
@ -23,7 +22,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.LinkedBlockingDeque;
import net.minecraft.server.v1_9_R1.Block;
import net.minecraft.server.v1_9_R1.BlockPosition;
import net.minecraft.server.v1_9_R1.ChunkSection;
@ -45,87 +43,27 @@ import org.bukkit.entity.Player;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
public class BukkitQueue_1_9_R1 extends BukkitQueue_0 {
public class BukkitQueue_1_9_R1 extends BukkitQueue_All {
private IBlockData air = Block.getByCombinedId(0);
public BukkitQueue_1_9_R1(final String world) throws NoSuchMethodException, RuntimeException {
super(world);
TaskManager.IMP.repeat(new Runnable() {
@Override
public void run() {
synchronized (loadQueue) {
while (loadQueue.size() > 0) {
IntegerPair loc = loadQueue.poll();
if (bukkitWorld == null) {
bukkitWorld = Bukkit.getServer().getWorld(world);
}
if (!bukkitWorld.isChunkLoaded(loc.x, loc.z)) {
bukkitWorld.loadChunk(loc.x, loc.z, true);
}
}
loadQueue.notifyAll();
}
}
}, 1);
}
private LinkedBlockingDeque<IntegerPair> loadQueue = new LinkedBlockingDeque<>();
public Object getCachedChunk(int cx, int cz) {
CraftChunk chunk = (CraftChunk) bukkitWorld.getChunkAt(cx, cz);
return chunk.getHandle().getSections();
}
private int lcx = Integer.MIN_VALUE;
private int lcz = Integer.MIN_VALUE;
private int lcy = Integer.MIN_VALUE;
private ChunkSection[] chunkSections;
private DataPaletteBlock lastSection;
public Object getCachedSection(Object chunk, int cy) {
ChunkSection[] chunkSections = (ChunkSection[]) chunk;
ChunkSection nibble = chunkSections[cy];
return nibble != null ? nibble.getBlocks() : null;
}
@Override
public int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
if (y < 0 || y > 255) {
return 0;
}
int cx = x >> 4;
int cz = z >> 4;
int cy = y >> 4;
if (cx != lcx || cz != lcz) {
if (bukkitWorld == null) {
bukkitWorld = Bukkit.getServer().getWorld(world);
}
lcx = cx;
lcz = cz;
if (!bukkitWorld.isChunkLoaded(cx, cz)) {
boolean sync = Thread.currentThread() == Fawe.get().getMainThread();
if (sync) {
bukkitWorld.loadChunk(cx, cz, true);
} else if (Settings.CHUNK_WAIT > 0) {
synchronized (loadQueue) {
loadQueue.add(new IntegerPair(cx, cz));
try {
loadQueue.wait(Settings.CHUNK_WAIT);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
if (!bukkitWorld.isChunkLoaded(cx, cz)) {
throw new FaweException.FaweChunkLoadException();
}
} else {
return 0;
}
}
CraftChunk chunk = (CraftChunk) bukkitWorld.getChunkAt(cx, cz);
chunkSections = chunk.getHandle().getSections();
ChunkSection nibble = chunkSections[cy];
lastSection = nibble != null ? nibble.getBlocks() : null;
} else if (cy != lcy) {
if (chunkSections == null) {
return 0;
}
ChunkSection nibble = chunkSections[cy];
lastSection = nibble != null ? nibble.getBlocks() : null;
}
if (lastSection == null) {
return 0;
}
public int getCombinedId4Data(Object section, int x, int y, int z) {
DataPaletteBlock lastSection = (DataPaletteBlock) section;
IBlockData ibd = lastSection.a(x & 15, y & 15, z & 15);
Block block = ibd.getBlock();
int id = Block.getId(block);
@ -284,8 +222,6 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0 {
return section[j] >> 4;
}
private World bukkitWorld;
public void setCount(int tickingBlockCount, int nonEmptyBlockCount, ChunkSection section) throws NoSuchFieldException, IllegalAccessException {
Class<? extends ChunkSection> clazz = section.getClass();
Field fieldTickingBlockCount = clazz.getDeclaredField("tickingBlockCount");

View File

@ -48,7 +48,7 @@ public abstract class FaweChunk<T> {
return x << 16 | z & 0xFFFF;
}
public void addToQueue(String world) {
public void addToQueue() {
parent.setChunk(this);
}

View File

@ -19,8 +19,11 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.profile.GameProfile;
import org.spongepowered.api.profile.GameProfileManager;
import org.spongepowered.api.text.serializer.TextSerializers;
@ -149,4 +152,26 @@ public class FaweSponge implements IFawe {
public String getPlatform() {
return "sponge";
}
@Override
public UUID getUUID(String name) {
try {
GameProfileManager pm = Sponge.getServer().getGameProfileManager();
GameProfile profile = pm.get(name).get();
return profile != null ? profile.getUniqueId() : null;
} catch (Exception e) {
return null;
}
}
@Override
public String getName(UUID uuid) {
try {
GameProfileManager pm = Sponge.getServer().getGameProfileManager();
GameProfile profile = pm.get(uuid).get();
return profile != null ? profile.getName().orElse(null) : null;
} catch (Exception e) {
return null;
}
}
}