mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Fixes #997 for 1.8
This commit is contained in:
parent
30d57d8642
commit
f74e7bb4cb
@ -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;
|
||||||
@ -16,12 +14,6 @@ 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.intellectualcrafters.plot.util.TaskManager;
|
||||||
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;
|
||||||
@ -32,6 +24,14 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
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_8_3 extends SlowQueue {
|
public class FastQueue_1_8_3 extends SlowQueue {
|
||||||
|
|
||||||
@ -46,6 +46,8 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
|||||||
private final RefField fieldSections;
|
private final RefField fieldSections;
|
||||||
private final RefField fieldWorld;
|
private final RefField fieldWorld;
|
||||||
private final RefMethod methodGetIdArray;
|
private final RefMethod methodGetIdArray;
|
||||||
|
private final RefMethod methodGetWorld;
|
||||||
|
private final RefField tileEntityUnload;
|
||||||
|
|
||||||
public FastQueue_1_8_3() throws RuntimeException {
|
public FastQueue_1_8_3() throws RuntimeException {
|
||||||
RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
||||||
@ -62,6 +64,8 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
|||||||
this.methodGetIdArray = classChunkSection.getMethod("getIdArray");
|
this.methodGetIdArray = classChunkSection.getMethod("getIdArray");
|
||||||
this.methodAreNeighborsLoaded = classChunk.getMethod("areNeighborsLoaded", int.class);
|
this.methodAreNeighborsLoaded = classChunk.getMethod("areNeighborsLoaded", int.class);
|
||||||
this.classChunkSectionConstructor = classChunkSection.getConstructor(int.class, boolean.class, char[].class);
|
this.classChunkSectionConstructor = classChunkSection.getConstructor(int.class, boolean.class, char[].class);
|
||||||
|
this.tileEntityUnload = classWorld.getField("c");
|
||||||
|
this.methodGetWorld = classChunk.getMethod("getWorld");
|
||||||
this.chunksender = new SendChunk();
|
this.chunksender = new SendChunk();
|
||||||
TaskManager.runTaskRepeat(new Runnable() {
|
TaskManager.runTaskRepeat(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -126,6 +130,7 @@ public class FastQueue_1_8_3 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 sections1 = clazz.getDeclaredField("sections");
|
Field sections1 = clazz.getDeclaredField("sections");
|
||||||
sections1.setAccessible(true);
|
sections1.setAccessible(true);
|
||||||
@ -134,6 +139,7 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
|||||||
|
|
||||||
Object[] sections = (Object[]) sections1.get(c);
|
Object[] sections = (Object[]) sections1.get(c);
|
||||||
HashMap<?, ?> tiles = (HashMap<?, ?>) tileEntities.get(c);
|
HashMap<?, ?> tiles = (HashMap<?, ?>) tileEntities.get(c);
|
||||||
|
List<Object> tilesUnload = (List<Object>) tileEntityUnload.of(w).get();
|
||||||
List<?>[] entities = (List<?>[]) entitySlices.get(c);
|
List<?>[] entities = (List<?>[]) entitySlices.get(c);
|
||||||
|
|
||||||
Method getX = null;
|
Method getX = null;
|
||||||
@ -162,6 +168,7 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (array[k] != 0) {
|
if (array[k] != 0) {
|
||||||
|
tilesUnload.add(tile.getValue());
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,12 +60,12 @@ public class FastQueue_1_9 extends SlowQueue {
|
|||||||
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.tileEntityUnload = classWorld.getField("tileEntityListUnload");
|
||||||
|
this.methodGetWorld = classChunk.getMethod("getWorld");
|
||||||
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");
|
||||||
|
@ -14,6 +14,6 @@ public class Chat extends SubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(PlotPlayer player, String... args) {
|
public boolean onCommand(PlotPlayer player, String... args) {
|
||||||
return MainCommand.onCommand(player, "plot", "toggle", "chat");
|
return MainCommand.onCommand(player, "toggle", "chat");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user