Fixed casting issue in FastQueue_1_9

This commit is contained in:
Matt 2016-03-16 19:18:09 -04:00
parent 7bbd359be8
commit 75bf01c13f

View File

@ -1,14 +1,20 @@
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.*; import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.PlotChunk;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass; import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor; import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefField; import com.intellectualcrafters.plot.util.ReflectionUtils.RefField;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod; import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod.RefExecutor; import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod.RefExecutor;
import com.intellectualcrafters.plot.util.SetQueue;
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper; import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
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.Chunk;
@ -20,13 +26,17 @@ 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;
import java.util.*; import java.util.AbstractSet;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
public class FastQueue_1_9 extends SlowQueue { public class FastQueue_1_9 extends SlowQueue {
final Object air;
private final SendChunk chunksender; private final SendChunk chunksender;
private final RefClass classEntityPlayer = getRefClass("{nms}.EntityPlayer"); private final RefClass classEntityPlayer = getRefClass("{nms}.EntityPlayer");
private final RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk"); private final RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk");
@ -41,25 +51,24 @@ public class FastQueue_1_9 extends SlowQueue {
private final RefClass classChunkSection = getRefClass("{nms}.ChunkSection"); private final RefClass classChunkSection = getRefClass("{nms}.ChunkSection");
private final RefClass classBlock = getRefClass("{nms}.Block"); private final RefClass classBlock = getRefClass("{nms}.Block");
private final RefClass classIBlockData = getRefClass("{nms}.IBlockData"); private final RefClass classIBlockData = getRefClass("{nms}.IBlockData");
private HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>(); private final HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
private RefMethod methodGetHandleChunk; private final RefMethod methodGetHandleChunk;
private RefConstructor MapChunk; private final RefConstructor MapChunk;
private RefMethod methodInitLighting; private final RefMethod methodInitLighting;
private RefConstructor classBlockPositionConstructor; private final RefConstructor classBlockPositionConstructor;
private RefConstructor classChunkSectionConstructor; private final RefConstructor classChunkSectionConstructor;
private RefMethod methodW; private final RefMethod methodW;
private RefMethod methodAreNeighborsLoaded; private final RefMethod methodAreNeighborsLoaded;
private RefField fieldSections; private final RefField fieldSections;
private RefField fieldWorld; private final RefField fieldWorld;
private RefMethod methodGetBlocks; private final RefMethod methodGetBlocks;
private RefMethod methodGetType; private final RefMethod methodGetType;
private RefMethod methodSetType; private final RefMethod methodSetType;
private RefMethod methodGetCombinedId; private final RefMethod methodGetCombinedId;
private RefMethod methodGetByCombinedId; private final RefMethod methodGetByCombinedId;
final Object air;
public FastQueue_1_9() throws NoSuchMethodException, RuntimeException { public FastQueue_1_9() throws RuntimeException {
methodGetHandleChunk = classCraftChunk.getMethod("getHandle"); methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
methodInitLighting = classChunk.getMethod("initLighting"); methodInitLighting = classChunk.getMethod("initLighting");
MapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), boolean.class, int.class); MapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), boolean.class, int.class);
@ -143,11 +152,11 @@ public class FastQueue_1_9 extends SlowQueue {
final Field sf = clazz.getDeclaredField("sections"); final Field sf = clazz.getDeclaredField("sections");
sf.setAccessible(true); sf.setAccessible(true);
final Field tf = clazz.getDeclaredField("tileEntities"); final Field tf = clazz.getDeclaredField("tileEntities");
final Field ef = clazz.getDeclaredField("entitySlices"); final Field entitySlices = clazz.getDeclaredField("entitySlices");
final Object[] sections = (Object[]) sf.get(c); final Object[] sections = (Object[]) sf.get(c);
final HashMap<?, ?> tiles = (HashMap<?, ?>) tf.get(c); final HashMap<?, ?> tiles = (HashMap<?, ?>) tf.get(c);
final List<?>[] entities = (List<?>[]) ef.get(c); final AbstractSet<?>[] entities = (AbstractSet<?>[]) entitySlices.get(c);
Method xm = null; Method xm = null;
Method ym = null; Method ym = null;
@ -228,7 +237,7 @@ public class FastQueue_1_9 extends SlowQueue {
int x = MainUtil.x_loc[j][k]; int x = MainUtil.x_loc[j][k];
int y = MainUtil.y_loc[j][k]; int y = MainUtil.y_loc[j][k];
int z = MainUtil.z_loc[j][k]; int z = MainUtil.z_loc[j][k];
int id = (int) n; int id = n;
Object iblock = methodGetByCombinedId.call((int) n); Object iblock = methodGetByCombinedId.call((int) n);
setType.call(x, y & 15, z, iblock); setType.call(x, y & 15, z, iblock);
continue; continue;