mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Fixes #997 for 1.9 (TODO fix for 1.8 as well)
This commit is contained in:
parent
ce9ec20b59
commit
30d57d8642
@ -1,7 +1,5 @@
|
|||||||
package com.plotsquared.bukkit.util.block;
|
package com.plotsquared.bukkit.util.block;
|
||||||
|
|
||||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
@ -17,12 +15,6 @@ import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
|||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
import com.plotsquared.bukkit.util.SendChunk;
|
import com.plotsquared.bukkit.util.SendChunk;
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.World.Environment;
|
|
||||||
import org.bukkit.block.Biome;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@ -30,8 +22,17 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.World.Environment;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
|
|
||||||
|
|
||||||
|
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||||
|
|
||||||
public class FastQueue_1_9 extends SlowQueue {
|
public class FastQueue_1_9 extends SlowQueue {
|
||||||
|
|
||||||
@ -51,16 +52,20 @@ public class FastQueue_1_9 extends SlowQueue {
|
|||||||
private final RefMethod methodSetType;
|
private final RefMethod methodSetType;
|
||||||
private final RefMethod methodGetCombinedId;
|
private final RefMethod methodGetCombinedId;
|
||||||
private final RefMethod methodGetByCombinedId;
|
private final RefMethod methodGetByCombinedId;
|
||||||
|
private final RefMethod methodGetWorld;
|
||||||
|
private final RefField tileEntityUnload;
|
||||||
|
|
||||||
|
|
||||||
public FastQueue_1_9() throws RuntimeException {
|
public FastQueue_1_9() throws RuntimeException {
|
||||||
RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
||||||
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
|
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
|
||||||
RefClass classChunk = getRefClass("{nms}.Chunk");
|
RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||||
|
this.methodGetWorld = classChunk.getMethod("getWorld");
|
||||||
this.methodInitLighting = classChunk.getMethod("initLighting");
|
this.methodInitLighting = classChunk.getMethod("initLighting");
|
||||||
RefClass classBlockPosition = getRefClass("{nms}.BlockPosition");
|
RefClass classBlockPosition = getRefClass("{nms}.BlockPosition");
|
||||||
this.classBlockPositionConstructor = classBlockPosition.getConstructor(int.class, int.class, int.class);
|
this.classBlockPositionConstructor = classBlockPosition.getConstructor(int.class, int.class, int.class);
|
||||||
RefClass classWorld = getRefClass("{nms}.World");
|
RefClass classWorld = getRefClass("{nms}.World");
|
||||||
|
this.tileEntityUnload = classWorld.getField("tileEntityListUnload");
|
||||||
this.methodW = classWorld.getMethod("w", classBlockPosition.getRealClass());
|
this.methodW = classWorld.getMethod("w", classBlockPosition.getRealClass());
|
||||||
this.fieldSections = classChunk.getField("sections");
|
this.fieldSections = classChunk.getField("sections");
|
||||||
this.fieldWorld = classChunk.getField("world");
|
this.fieldWorld = classChunk.getField("world");
|
||||||
@ -139,6 +144,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
|||||||
// Sections
|
// Sections
|
||||||
Method getHandle = chunk.getClass().getDeclaredMethod("getHandle");
|
Method getHandle = chunk.getClass().getDeclaredMethod("getHandle");
|
||||||
Object c = getHandle.invoke(chunk);
|
Object c = getHandle.invoke(chunk);
|
||||||
|
Object w = methodGetWorld.of(c).call();
|
||||||
Class<? extends Object> clazz = c.getClass();
|
Class<? extends Object> clazz = c.getClass();
|
||||||
Field sf = clazz.getDeclaredField("sections");
|
Field sf = clazz.getDeclaredField("sections");
|
||||||
sf.setAccessible(true);
|
sf.setAccessible(true);
|
||||||
@ -147,6 +153,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
|||||||
|
|
||||||
Object[] sections = (Object[]) sf.get(c);
|
Object[] sections = (Object[]) sf.get(c);
|
||||||
HashMap<?, ?> tiles = (HashMap<?, ?>) tf.get(c);
|
HashMap<?, ?> tiles = (HashMap<?, ?>) tf.get(c);
|
||||||
|
List<Object> tilesUnload = (List<Object>) tileEntityUnload.of(w).get();
|
||||||
Collection<?>[] entities = (Collection<?>[]) entitySlices.get(c);
|
Collection<?>[] entities = (Collection<?>[]) entitySlices.get(c);
|
||||||
|
|
||||||
Method xm = null;
|
Method xm = null;
|
||||||
@ -174,6 +181,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (array[k] != 0) {
|
if (array[k] != 0) {
|
||||||
|
tilesUnload.add(tile.getValue());
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user