cleanup
This commit is contained in:
parent
c2749bc3af
commit
74a03b2b19
@ -43,7 +43,7 @@ public class Fawe {
|
|||||||
* The FAWE instance;
|
* The FAWE instance;
|
||||||
*/
|
*/
|
||||||
private static Fawe INSTANCE;
|
private static Fawe INSTANCE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the implementation specific class
|
* Get the implementation specific class
|
||||||
* @return
|
* @return
|
||||||
@ -52,7 +52,7 @@ public class Fawe {
|
|||||||
public static <T extends IFawe> T imp() {
|
public static <T extends IFawe> T imp() {
|
||||||
return INSTANCE != null ? (T) INSTANCE.IMP : null;
|
return INSTANCE != null ? (T) INSTANCE.IMP : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the implementation independent class
|
* Get the implementation independent class
|
||||||
* @return
|
* @return
|
||||||
@ -60,7 +60,7 @@ public class Fawe {
|
|||||||
public static Fawe get() {
|
public static Fawe get() {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup Fawe
|
* Setup Fawe
|
||||||
* @param implementation
|
* @param implementation
|
||||||
@ -75,7 +75,7 @@ public class Fawe {
|
|||||||
}
|
}
|
||||||
INSTANCE = new Fawe(implementation);
|
INSTANCE = new Fawe(implementation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write something to the console
|
* Write something to the console
|
||||||
* @param s
|
* @param s
|
||||||
@ -87,79 +87,79 @@ public class Fawe {
|
|||||||
System.out.print(s);
|
System.out.print(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The platform specific implementation
|
* The platform specific implementation
|
||||||
*/
|
*/
|
||||||
private final IFawe IMP;
|
private final IFawe IMP;
|
||||||
private Thread thread = Thread.currentThread();
|
private Thread thread = Thread.currentThread();
|
||||||
|
|
||||||
private Fawe(final IFawe implementation) {
|
private Fawe(final IFawe implementation) {
|
||||||
IMP = implementation;
|
this.IMP = implementation;
|
||||||
|
|
||||||
this.thread = Thread.currentThread();
|
this.thread = Thread.currentThread();
|
||||||
/*
|
/*
|
||||||
* Implementation dependent stuff
|
* Implementation dependent stuff
|
||||||
*/
|
*/
|
||||||
setupConfigs();
|
this.setupConfigs();
|
||||||
setupCommands();
|
this.setupCommands();
|
||||||
|
|
||||||
// TODO command event - queue?
|
// TODO command event - queue?
|
||||||
|
|
||||||
TaskManager.IMP = IMP.getTaskManager();
|
TaskManager.IMP = this.IMP.getTaskManager();
|
||||||
SetQueue.IMP.queue = IMP.getQueue();
|
SetQueue.IMP.queue = this.IMP.getQueue();
|
||||||
|
|
||||||
// Delayed setup
|
// Delayed setup
|
||||||
TaskManager.IMP.later(new Runnable() {
|
TaskManager.IMP.later(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// worldedit
|
// worldedit
|
||||||
WEManager.IMP.managers.addAll(IMP.getMaskManagers());
|
WEManager.IMP.managers.addAll(Fawe.this.IMP.getMaskManagers());
|
||||||
worldedit = WorldEdit.getInstance();
|
Fawe.this.worldedit = WorldEdit.getInstance();
|
||||||
// Events
|
// Events
|
||||||
setupEvents();
|
Fawe.this.setupEvents();
|
||||||
IMP.setupVault();
|
Fawe.this.IMP.setupVault();
|
||||||
}
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Instance independent stuff
|
* Instance independent stuff
|
||||||
*/
|
*/
|
||||||
setupInjector();
|
this.setupInjector();
|
||||||
setupMemoryListener();
|
this.setupMemoryListener();
|
||||||
|
|
||||||
// Lag
|
// Lag
|
||||||
final Lag lag = new Lag();
|
final Lag lag = new Lag();
|
||||||
TaskManager.IMP.repeat(lag, 100);
|
TaskManager.IMP.repeat(lag, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupEvents() {
|
private void setupEvents() {
|
||||||
WorldEdit.getInstance().getEventBus().register(new WESubscriber());
|
WorldEdit.getInstance().getEventBus().register(new WESubscriber());
|
||||||
if (Settings.COMMAND_PROCESSOR) {
|
if (Settings.COMMAND_PROCESSOR) {
|
||||||
IMP.setupWEListener();
|
this.IMP.setupWEListener();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupCommands() {
|
private void setupCommands() {
|
||||||
IMP.setupCommand("wea", new Wea());
|
this.IMP.setupCommand("wea", new Wea());
|
||||||
IMP.setupCommand("fixlighting", new FixLighting());
|
this.IMP.setupCommand("fixlighting", new FixLighting());
|
||||||
IMP.setupCommand("stream", new Stream());
|
this.IMP.setupCommand("stream", new Stream());
|
||||||
IMP.setupCommand("wrg", new WorldEditRegion());
|
this.IMP.setupCommand("wrg", new WorldEditRegion());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupConfigs() {
|
private void setupConfigs() {
|
||||||
// Setting up config.yml
|
// Setting up config.yml
|
||||||
Settings.setup(new File(IMP.getDirectory(), "config.yml"));
|
Settings.setup(new File(this.IMP.getDirectory(), "config.yml"));
|
||||||
// Setting up message.yml
|
// Setting up message.yml
|
||||||
BBC.load(new File(IMP.getDirectory(), "message.yml"));
|
BBC.load(new File(this.IMP.getDirectory(), "message.yml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private WorldEdit worldedit;
|
private WorldEdit worldedit;
|
||||||
|
|
||||||
public WorldEdit getWorldEdit() {
|
public WorldEdit getWorldEdit() {
|
||||||
return worldedit;
|
return this.worldedit;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupInjector() {
|
private void setupInjector() {
|
||||||
EditSession.inject();
|
EditSession.inject();
|
||||||
Operations.inject();
|
Operations.inject();
|
||||||
@ -174,7 +174,7 @@ public class Fawe {
|
|||||||
RecursiveVisitor.inject();
|
RecursiveVisitor.inject();
|
||||||
RegionVisitor.inject();
|
RegionVisitor.inject();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupMemoryListener() {
|
private void setupMemoryListener() {
|
||||||
final MemoryMXBean memBean = ManagementFactory.getMemoryMXBean();
|
final MemoryMXBean memBean = ManagementFactory.getMemoryMXBean();
|
||||||
final NotificationEmitter ne = (NotificationEmitter) memBean;
|
final NotificationEmitter ne = (NotificationEmitter) memBean;
|
||||||
@ -196,20 +196,20 @@ public class Fawe {
|
|||||||
}
|
}
|
||||||
final long alert = (max * Settings.MEM_FREE) / 100;
|
final long alert = (max * Settings.MEM_FREE) / 100;
|
||||||
mp.setUsageThreshold(alert);
|
mp.setUsageThreshold(alert);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Thread getMainThread() {
|
public Thread getMainThread() {
|
||||||
return thread;
|
return this.thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO FIXME
|
* TODO FIXME
|
||||||
* - Async packet sending
|
* - Async packet sending
|
||||||
* - Redo WEManager delay / command queue
|
* - Redo WEManager delay / command queue
|
||||||
* - Support older versions of bukkit
|
* - Support older versions of bukkit
|
||||||
* - Optimize lighting updates / chunk sending
|
* - Optimize lighting updates / chunk sending
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ import com.sk89q.worldedit.world.biome.BaseBiome;
|
|||||||
* FaweAPI.[some method]
|
* FaweAPI.[some method]
|
||||||
*/
|
*/
|
||||||
public class FaweAPI {
|
public class FaweAPI {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare two versions
|
* Compare two versions
|
||||||
* @param version
|
* @param version
|
||||||
@ -45,7 +45,7 @@ public class FaweAPI {
|
|||||||
public static boolean checkVersion(final int[] version, final int major, final int minor, final int minor2) {
|
public static boolean checkVersion(final int[] version, final int major, final int minor, final int minor2) {
|
||||||
return (version[0] > major) || ((version[0] == major) && (version[1] > minor)) || ((version[0] == major) && (version[1] == minor) && (version[2] >= minor2));
|
return (version[0] > major) || ((version[0] == major) && (version[1] > minor)) || ((version[0] == major) && (version[1] == minor) && (version[2] >= minor2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a block at a location asynchronously
|
* Set a block at a location asynchronously
|
||||||
* @param loc
|
* @param loc
|
||||||
@ -54,7 +54,7 @@ public class FaweAPI {
|
|||||||
public static void setBlockAsync(final Location loc, final Material m) {
|
public static void setBlockAsync(final Location loc, final Material m) {
|
||||||
SetQueue.IMP.setBlock(loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), (short) m.getId());
|
SetQueue.IMP.setBlock(loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), (short) m.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a block at a location asynchronously
|
* Set a block at a location asynchronously
|
||||||
* @param world
|
* @param world
|
||||||
@ -67,7 +67,7 @@ public class FaweAPI {
|
|||||||
public static void setBlockAsync(final String world, final int x, final int y, final int z, final short id, final byte data) {
|
public static void setBlockAsync(final String world, final int x, final int y, final int z, final short id, final byte data) {
|
||||||
SetQueue.IMP.setBlock(world, x, y, z, id, data);
|
SetQueue.IMP.setBlock(world, x, y, z, id, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a biome at a location asynchronously
|
* Set a biome at a location asynchronously
|
||||||
* @param world
|
* @param world
|
||||||
@ -76,7 +76,7 @@ public class FaweAPI {
|
|||||||
* @param id
|
* @param id
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
public static void setBiomeAsync(final String world, final int x, final int z, BaseBiome biome) {
|
public static void setBiomeAsync(final String world, final int x, final int z, final BaseBiome biome) {
|
||||||
SetQueue.IMP.setBiome(world, x, z, biome);
|
SetQueue.IMP.setBiome(world, x, z, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,10 +85,10 @@ public class FaweAPI {
|
|||||||
* @param loc
|
* @param loc
|
||||||
* @param biome
|
* @param biome
|
||||||
*/
|
*/
|
||||||
public static void setBiomeAsync(Location loc, BaseBiome biome) {
|
public static void setBiomeAsync(final Location loc, final BaseBiome biome) {
|
||||||
SetQueue.IMP.setBiome(loc.getWorld().getName(), loc.getBlockX(), loc.getBlockZ(), biome);
|
SetQueue.IMP.setBiome(loc.getWorld().getName(), loc.getBlockX(), loc.getBlockZ(), biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This will return a FaweChunk object that can be modified.<br>
|
* This will return a FaweChunk object that can be modified.<br>
|
||||||
* - The FaweChunk object can be reused if you want identical changes across chunks<br>
|
* - The FaweChunk object can be reused if you want identical changes across chunks<br>
|
||||||
@ -100,47 +100,47 @@ public class FaweAPI {
|
|||||||
public static FaweChunk<?> createChunk() {
|
public static FaweChunk<?> createChunk() {
|
||||||
return SetQueue.IMP.queue.getChunk(new ChunkLoc(null, 0, 0));
|
return SetQueue.IMP.queue.getChunk(new ChunkLoc(null, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see #createChunk()
|
* @see #createChunk()
|
||||||
* @param data
|
* @param data
|
||||||
* @param location
|
* @param location
|
||||||
*/
|
*/
|
||||||
public static void setChunkAsync(FaweChunk<?> data, ChunkLoc location) {
|
public static void setChunkAsync(final FaweChunk<?> data, final ChunkLoc location) {
|
||||||
data.setChunkLoc(location);
|
data.setChunkLoc(location);
|
||||||
data.addToQueue();
|
data.addToQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see #createChunk()
|
* @see #createChunk()
|
||||||
* @param data
|
* @param data
|
||||||
* @param chunk
|
* @param chunk
|
||||||
*/
|
*/
|
||||||
public static void setChunkAsync(FaweChunk<?> data, Chunk chunk) {
|
public static void setChunkAsync(final FaweChunk<?> data, final Chunk chunk) {
|
||||||
ChunkLoc loc = new ChunkLoc(chunk.getWorld().getName(), chunk.getX(), chunk.getZ());
|
final ChunkLoc loc = new ChunkLoc(chunk.getWorld().getName(), chunk.getX(), chunk.getZ());
|
||||||
data.setChunkLoc(loc);
|
data.setChunkLoc(loc);
|
||||||
data.addToQueue();
|
data.addToQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fix the lighting at a chunk location.<br>
|
* Fix the lighting at a chunk location.<br>
|
||||||
* - The fixAll parameter determines if extensive relighting should occur (slow)
|
* - The fixAll parameter determines if extensive relighting should occur (slow)
|
||||||
* @param loc
|
* @param loc
|
||||||
*/
|
*/
|
||||||
public static void fixLighting(ChunkLoc loc, boolean fixAll) {
|
public static void fixLighting(final ChunkLoc loc, final boolean fixAll) {
|
||||||
SetQueue.IMP.queue.fixLighting(SetQueue.IMP.queue.getChunk(loc), fixAll);
|
SetQueue.IMP.queue.fixLighting(SetQueue.IMP.queue.getChunk(loc), fixAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fix the lighting at a chunk.<br>
|
* Fix the lighting at a chunk.<br>
|
||||||
* - The fixAll parameter determines if extensive relighting should occur (slow)
|
* - The fixAll parameter determines if extensive relighting should occur (slow)
|
||||||
* @param chunk
|
* @param chunk
|
||||||
*/
|
*/
|
||||||
public static void fixLighting(Chunk chunk, boolean fixAll) {
|
public static void fixLighting(final Chunk chunk, final boolean fixAll) {
|
||||||
ChunkLoc loc = new ChunkLoc(chunk.getWorld().getName(), chunk.getX(), chunk.getZ());
|
final ChunkLoc loc = new ChunkLoc(chunk.getWorld().getName(), chunk.getX(), chunk.getZ());
|
||||||
SetQueue.IMP.queue.fixLighting(SetQueue.IMP.queue.getChunk(loc), fixAll);
|
SetQueue.IMP.queue.fixLighting(SetQueue.IMP.queue.getChunk(loc), fixAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If a schematic is too large to be pasted normally<br>
|
* If a schematic is too large to be pasted normally<br>
|
||||||
* - Skips any block history
|
* - Skips any block history
|
||||||
@ -150,10 +150,10 @@ public class FaweAPI {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static void streamSchematicAsync(final File file, final Location loc) {
|
public static void streamSchematicAsync(final File file, final Location loc) {
|
||||||
FaweLocation fl = new FaweLocation(loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
final FaweLocation fl = new FaweLocation(loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||||
streamSchematicAsync(file, fl);
|
streamSchematicAsync(file, fl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If a schematic is too large to be pasted normally<br>
|
* If a schematic is too large to be pasted normally<br>
|
||||||
* - Skips any block history
|
* - Skips any block history
|
||||||
@ -167,15 +167,15 @@ public class FaweAPI {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
FileInputStream is = new FileInputStream(file);
|
final FileInputStream is = new FileInputStream(file);
|
||||||
streamSchematic(is, loc);
|
streamSchematic(is, loc);
|
||||||
} catch (IOException e) {
|
} catch (final IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If a schematic is too large to be pasted normally<br>
|
* If a schematic is too large to be pasted normally<br>
|
||||||
* - Skips any block history
|
* - Skips any block history
|
||||||
@ -188,16 +188,16 @@ public class FaweAPI {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
ReadableByteChannel rbc = Channels.newChannel(url.openStream());
|
final ReadableByteChannel rbc = Channels.newChannel(url.openStream());
|
||||||
final InputStream is = Channels.newInputStream(rbc);
|
final InputStream is = Channels.newInputStream(rbc);
|
||||||
streamSchematic(is, loc);
|
streamSchematic(is, loc);
|
||||||
} catch (IOException e) {
|
} catch (final IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If a schematic is too large to be pasted normally<br>
|
* If a schematic is too large to be pasted normally<br>
|
||||||
* - Skips any block history
|
* - Skips any block history
|
||||||
@ -206,25 +206,25 @@ public class FaweAPI {
|
|||||||
* @param loc
|
* @param loc
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public static void streamSchematic(InputStream is, FaweLocation loc) throws IOException {
|
public static void streamSchematic(final InputStream is, final FaweLocation loc) throws IOException {
|
||||||
NBTInputStream stream = new NBTInputStream(new GZIPInputStream(is));
|
final NBTInputStream stream = new NBTInputStream(new GZIPInputStream(is));
|
||||||
Tag tag = stream.readNamedTag().getTag();
|
Tag tag = stream.readNamedTag().getTag();
|
||||||
stream.close();
|
stream.close();
|
||||||
|
|
||||||
Map<String, Tag> tagMap = (Map<String, Tag>) tag.getValue();
|
Map<String, Tag> tagMap = (Map<String, Tag>) tag.getValue();
|
||||||
|
|
||||||
short width = ShortTag.class.cast(tagMap.get("Width")).getValue();
|
final short width = ShortTag.class.cast(tagMap.get("Width")).getValue();
|
||||||
short length = ShortTag.class.cast(tagMap.get("Length")).getValue();
|
final short length = ShortTag.class.cast(tagMap.get("Length")).getValue();
|
||||||
short height = ShortTag.class.cast(tagMap.get("Height")).getValue();
|
final short height = ShortTag.class.cast(tagMap.get("Height")).getValue();
|
||||||
byte[] ids = ByteArrayTag.class.cast(tagMap.get("Blocks")).getValue();
|
byte[] ids = ByteArrayTag.class.cast(tagMap.get("Blocks")).getValue();
|
||||||
byte[] datas = ByteArrayTag.class.cast(tagMap.get("Data")).getValue();
|
byte[] datas = ByteArrayTag.class.cast(tagMap.get("Data")).getValue();
|
||||||
|
|
||||||
String world = loc.world;
|
final String world = loc.world;
|
||||||
|
|
||||||
int x_offset = loc.x + IntTag.class.cast(tagMap.get("WEOffsetX")).getValue();
|
final int x_offset = loc.x + IntTag.class.cast(tagMap.get("WEOffsetX")).getValue();
|
||||||
int y_offset = loc.y + IntTag.class.cast(tagMap.get("WEOffsetY")).getValue();
|
final int y_offset = loc.y + IntTag.class.cast(tagMap.get("WEOffsetY")).getValue();
|
||||||
int z_offset = loc.z + IntTag.class.cast(tagMap.get("WEOffsetZ")).getValue();
|
final int z_offset = loc.z + IntTag.class.cast(tagMap.get("WEOffsetZ")).getValue();
|
||||||
|
|
||||||
tagMap = null;
|
tagMap = null;
|
||||||
tag = null;
|
tag = null;
|
||||||
|
|
||||||
@ -236,11 +236,11 @@ public class FaweAPI {
|
|||||||
final int i1 = y * width * length;
|
final int i1 = y * width * length;
|
||||||
for (int z = 0; z < length; z++) {
|
for (int z = 0; z < length; z++) {
|
||||||
final int i2 = (z * width) + i1;
|
final int i2 = (z * width) + i1;
|
||||||
int zz = z_offset + z;
|
final int zz = z_offset + z;
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
final int i = i2 + x;
|
final int i = i2 + x;
|
||||||
int xx = x_offset + x;
|
final int xx = x_offset + x;
|
||||||
short id = (short) (ids[i] & 0xFF);
|
final short id = (short) (ids[i] & 0xFF);
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 0:
|
case 0:
|
||||||
case 2:
|
case 2:
|
||||||
@ -318,7 +318,7 @@ public class FaweAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ids = null;
|
ids = null;
|
||||||
datas = null;
|
datas = null;
|
||||||
System.gc();
|
System.gc();
|
||||||
|
@ -5,16 +5,16 @@ import com.boydti.fawe.object.PseudoRandom;
|
|||||||
public class FaweCache {
|
public class FaweCache {
|
||||||
public final static short[][][] CACHE_I = new short[256][16][16];
|
public final static short[][][] CACHE_I = new short[256][16][16];
|
||||||
public final static short[][][] CACHE_J = new short[256][16][16];
|
public final static short[][][] CACHE_J = new short[256][16][16];
|
||||||
|
|
||||||
public final static byte[][] CACHE_X = new byte[16][4096];
|
public final static byte[][] CACHE_X = new byte[16][4096];
|
||||||
public final static short[][] CACHE_Y = new short[16][4096];
|
public final static short[][] CACHE_Y = new short[16][4096];
|
||||||
public final static byte[][] CACHE_Z = new byte[16][4096];
|
public final static byte[][] CACHE_Z = new byte[16][4096];
|
||||||
|
|
||||||
public final static short[] CACHE_ID = new short[65535];
|
public final static short[] CACHE_ID = new short[65535];
|
||||||
public final static byte[] CACHE_DATA = new byte[65535];
|
public final static byte[] CACHE_DATA = new byte[65535];
|
||||||
|
|
||||||
public final static PseudoRandom RANDOM = new PseudoRandom();
|
public final static PseudoRandom RANDOM = new PseudoRandom();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
for (int x = 0; x < 16; x++) {
|
for (int x = 0; x < 16; x++) {
|
||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; z++) {
|
||||||
@ -31,9 +31,9 @@ public class FaweCache {
|
|||||||
}
|
}
|
||||||
for (int i = 0; i < 65535; i++) {
|
for (int i = 0; i < 65535; i++) {
|
||||||
final int j = i >> 4;
|
final int j = i >> 4;
|
||||||
final int k = i & 0xF;
|
final int k = i & 0xF;
|
||||||
CACHE_ID[i] = (short) j;
|
CACHE_ID[i] = (short) j;
|
||||||
CACHE_DATA[i] = (byte) k;
|
CACHE_DATA[i] = (byte) k;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,24 +13,24 @@ import com.sk89q.worldedit.EditSession;
|
|||||||
|
|
||||||
public interface IFawe {
|
public interface IFawe {
|
||||||
public void debug(final String s);
|
public void debug(final String s);
|
||||||
|
|
||||||
public File getDirectory();
|
public File getDirectory();
|
||||||
|
|
||||||
public void setupCommand(final String label, final FaweCommand cmd);
|
public void setupCommand(final String label, final FaweCommand cmd);
|
||||||
|
|
||||||
public FawePlayer wrap(final Object obj);
|
public FawePlayer wrap(final Object obj);
|
||||||
|
|
||||||
public void setupWEListener();
|
public void setupWEListener();
|
||||||
|
|
||||||
public void setupVault();
|
public void setupVault();
|
||||||
|
|
||||||
public TaskManager getTaskManager();
|
public TaskManager getTaskManager();
|
||||||
|
|
||||||
public int[] getVersion();
|
public int[] getVersion();
|
||||||
|
|
||||||
public FaweQueue getQueue();
|
public FaweQueue getQueue();
|
||||||
|
|
||||||
public EditSessionWrapper getEditSessionWrapper(final EditSession session);
|
public EditSessionWrapper getEditSessionWrapper(final EditSession session);
|
||||||
|
|
||||||
public Collection<FaweMaskManager> getMaskManagers();
|
public Collection<FaweMaskManager> getMaskManagers();
|
||||||
}
|
}
|
||||||
|
@ -10,16 +10,16 @@ import com.boydti.fawe.object.FaweCommand;
|
|||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
|
|
||||||
public class BukkitCommand implements CommandExecutor {
|
public class BukkitCommand implements CommandExecutor {
|
||||||
|
|
||||||
private final FaweCommand cmd;
|
private final FaweCommand cmd;
|
||||||
|
|
||||||
public BukkitCommand(final FaweCommand cmd) {
|
public BukkitCommand(final FaweCommand cmd) {
|
||||||
this.cmd = cmd;
|
this.cmd = cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
|
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
|
||||||
FawePlayer plr = Fawe.imp().wrap(sender);
|
final FawePlayer plr = Fawe.imp().wrap(sender);
|
||||||
if (!sender.hasPermission(this.cmd.getPerm())) {
|
if (!sender.hasPermission(this.cmd.getPerm())) {
|
||||||
BBC.NO_PERM.send(plr, this.cmd.getPerm());
|
BBC.NO_PERM.send(plr, this.cmd.getPerm());
|
||||||
return true;
|
return true;
|
||||||
@ -27,5 +27,5 @@ public class BukkitCommand implements CommandExecutor {
|
|||||||
this.cmd.execute(plr, args);
|
this.cmd.execute(plr, args);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,56 +12,56 @@ import com.boydti.fawe.object.FaweLocation;
|
|||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
|
|
||||||
public class BukkitPlayer extends FawePlayer<Player> {
|
public class BukkitPlayer extends FawePlayer<Player> {
|
||||||
|
|
||||||
public BukkitPlayer(final Player parent) {
|
public BukkitPlayer(final Player parent) {
|
||||||
super(parent);
|
super(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return parent.getName();
|
return this.parent.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UUID getUUID() {
|
public UUID getUUID() {
|
||||||
return parent.getUniqueId();
|
return this.parent.getUniqueId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(final String perm) {
|
public boolean hasPermission(final String perm) {
|
||||||
return parent.hasPermission(perm);
|
return this.parent.hasPermission(perm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPermission(final String perm, final boolean flag) {
|
public void setPermission(final String perm, final boolean flag) {
|
||||||
if (Fawe.<FaweBukkit> imp().getVault() == null) {
|
if (Fawe.<FaweBukkit> imp().getVault() == null) {
|
||||||
parent.addAttachment(Fawe.<FaweBukkit> imp()).setPermission("fawe.bypass", flag);
|
this.parent.addAttachment(Fawe.<FaweBukkit> imp()).setPermission("fawe.bypass", flag);
|
||||||
} else if (flag) {
|
} else if (flag) {
|
||||||
Fawe.<FaweBukkit> imp().getVault().permission.playerAdd(parent, perm);
|
Fawe.<FaweBukkit> imp().getVault().permission.playerAdd(this.parent, perm);
|
||||||
} else {
|
} else {
|
||||||
Fawe.<FaweBukkit> imp().getVault().permission.playerRemove(parent, perm);
|
Fawe.<FaweBukkit> imp().getVault().permission.playerRemove(this.parent, perm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(final String message) {
|
public void sendMessage(final String message) {
|
||||||
parent.sendMessage(ChatColor.translateAlternateColorCodes('&', message));
|
this.parent.sendMessage(ChatColor.translateAlternateColorCodes('&', message));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void executeCommand(final String cmd) {
|
public void executeCommand(final String cmd) {
|
||||||
Bukkit.getServer().dispatchCommand(parent, cmd);
|
Bukkit.getServer().dispatchCommand(this.parent, cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FaweLocation getLocation() {
|
public FaweLocation getLocation() {
|
||||||
Location loc = parent.getLocation();
|
final Location loc = this.parent.getLocation();
|
||||||
return new FaweLocation(loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
return new FaweLocation(loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public com.sk89q.worldedit.entity.Player getPlayer() {
|
public com.sk89q.worldedit.entity.Player getPlayer() {
|
||||||
return Fawe.<FaweBukkit> imp().getWorldEditPlugin().wrapPlayer(parent);
|
return Fawe.<FaweBukkit> imp().getWorldEditPlugin().wrapPlayer(this.parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,55 +9,55 @@ import org.bukkit.plugin.Plugin;
|
|||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
|
|
||||||
public class BukkitTaskMan extends TaskManager {
|
public class BukkitTaskMan extends TaskManager {
|
||||||
|
|
||||||
private final Plugin plugin;
|
private final Plugin plugin;
|
||||||
|
|
||||||
public BukkitTaskMan(Plugin plugin) {
|
public BukkitTaskMan(final Plugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int repeat(final Runnable r, final int interval) {
|
public int repeat(final Runnable r, final int interval) {
|
||||||
return plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, r, interval, interval);
|
return this.plugin.getServer().getScheduler().scheduleSyncRepeatingTask(this.plugin, r, interval, interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int repeatAsync(final Runnable r, final int interval) {
|
public int repeatAsync(final Runnable r, final int interval) {
|
||||||
return plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(plugin, r, interval, interval);
|
return this.plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(this.plugin, r, interval, interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableInt index = new MutableInt(0);
|
public MutableInt index = new MutableInt(0);
|
||||||
public HashMap<Integer, Integer> tasks = new HashMap<>();
|
public HashMap<Integer, Integer> tasks = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void async(final Runnable r) {
|
public void async(final Runnable r) {
|
||||||
if (r == null) {
|
if (r == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, r).getTaskId();
|
this.plugin.getServer().getScheduler().runTaskAsynchronously(this.plugin, r).getTaskId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void task(final Runnable r) {
|
public void task(final Runnable r) {
|
||||||
if (r == null) {
|
if (r == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
plugin.getServer().getScheduler().runTask(plugin, r).getTaskId();
|
this.plugin.getServer().getScheduler().runTask(this.plugin, r).getTaskId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void later(final Runnable r, final int delay) {
|
public void later(final Runnable r, final int delay) {
|
||||||
if (r == null) {
|
if (r == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
plugin.getServer().getScheduler().runTaskLater(plugin, r, delay).getTaskId();
|
this.plugin.getServer().getScheduler().runTaskLater(this.plugin, r, delay).getTaskId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void laterAsync(final Runnable r, final int delay) {
|
public void laterAsync(final Runnable r, final int delay) {
|
||||||
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, r, delay);
|
this.plugin.getServer().getScheduler().runTaskLaterAsynchronously(this.plugin, r, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancel(final int task) {
|
public void cancel(final int task) {
|
||||||
if (task != -1) {
|
if (task != -1) {
|
||||||
|
@ -37,53 +37,53 @@ import com.sk89q.worldedit.EditSession;
|
|||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
|
|
||||||
public class FaweBukkit extends JavaPlugin implements IFawe {
|
public class FaweBukkit extends JavaPlugin implements IFawe {
|
||||||
|
|
||||||
private VaultUtil vault;
|
private VaultUtil vault;
|
||||||
private WorldEditPlugin worldedit;
|
private WorldEditPlugin worldedit;
|
||||||
|
|
||||||
public VaultUtil getVault() {
|
public VaultUtil getVault() {
|
||||||
return vault;
|
return this.vault;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorldEditPlugin getWorldEditPlugin() {
|
public WorldEditPlugin getWorldEditPlugin() {
|
||||||
if (worldedit == null) {
|
if (this.worldedit == null) {
|
||||||
worldedit = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
|
this.worldedit = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
|
||||||
}
|
}
|
||||||
return worldedit;
|
return this.worldedit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
try {
|
try {
|
||||||
Fawe.set(this);
|
Fawe.set(this);
|
||||||
try {
|
try {
|
||||||
Class<?> clazz = Class.forName("org.spigotmc.AsyncCatcher");
|
final Class<?> clazz = Class.forName("org.spigotmc.AsyncCatcher");
|
||||||
Field field = clazz.getDeclaredField("enabled");
|
final Field field = clazz.getDeclaredField("enabled");
|
||||||
field.set(null, false);
|
field.set(null, false);
|
||||||
} catch (Throwable e) {
|
} catch (final Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
getServer().shutdown();
|
this.getServer().shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void debug(final String s) {
|
public void debug(final String s) {
|
||||||
getLogger().info(ChatColor.translateAlternateColorCodes('&', s));
|
this.getLogger().info(ChatColor.translateAlternateColorCodes('&', s));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File getDirectory() {
|
public File getDirectory() {
|
||||||
return getDataFolder();
|
return this.getDataFolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setupCommand(final String label, final FaweCommand cmd) {
|
public void setupCommand(final String label, final FaweCommand cmd) {
|
||||||
getCommand(label).setExecutor(new BukkitCommand(cmd));
|
this.getCommand(label).setExecutor(new BukkitCommand(cmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FawePlayer<Player> wrap(final Object obj) {
|
public FawePlayer<Player> wrap(final Object obj) {
|
||||||
if (obj.getClass() == String.class) {
|
if (obj.getClass() == String.class) {
|
||||||
@ -94,26 +94,26 @@ public class FaweBukkit extends JavaPlugin implements IFawe {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setupWEListener() {
|
public void setupWEListener() {
|
||||||
getServer().getPluginManager().registerEvents(new WEListener(), this);
|
this.getServer().getPluginManager().registerEvents(new WEListener(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setupVault() {
|
public void setupVault() {
|
||||||
try {
|
try {
|
||||||
vault = new VaultUtil();
|
this.vault = new VaultUtil();
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
debug("&cPlease install vault!");
|
this.debug("&cPlease install vault!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TaskManager getTaskManager() {
|
public TaskManager getTaskManager() {
|
||||||
return new BukkitTaskMan(this);
|
return new BukkitTaskMan(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getVersion() {
|
public int[] getVersion() {
|
||||||
try {
|
try {
|
||||||
@ -127,51 +127,51 @@ public class FaweBukkit extends JavaPlugin implements IFawe {
|
|||||||
return version;
|
return version;
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
debug(StringMan.getString(Bukkit.getBukkitVersion()));
|
this.debug(StringMan.getString(Bukkit.getBukkitVersion()));
|
||||||
debug(StringMan.getString(Bukkit.getBukkitVersion().split("-")[0].split("\\.")));
|
this.debug(StringMan.getString(Bukkit.getBukkitVersion().split("-")[0].split("\\.")));
|
||||||
return new int[] { Integer.MAX_VALUE, 0, 0 };
|
return new int[] { Integer.MAX_VALUE, 0, 0 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FaweQueue getQueue() {
|
public FaweQueue getQueue() {
|
||||||
if (FaweAPI.checkVersion(getServerVersion(), 1, 9, 0)) {
|
if (FaweAPI.checkVersion(this.getServerVersion(), 1, 9, 0)) {
|
||||||
try {
|
try {
|
||||||
return new BukkitQueue_1_9();
|
return new BukkitQueue_1_9();
|
||||||
} catch (Throwable e) {
|
} catch (final Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new BukkitQueue_1_8();
|
return new BukkitQueue_1_8();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int[] version;
|
private int[] version;
|
||||||
|
|
||||||
public int[] getServerVersion() {
|
public int[] getServerVersion() {
|
||||||
if (version == null) {
|
if (this.version == null) {
|
||||||
try {
|
try {
|
||||||
version = new int[3];
|
this.version = new int[3];
|
||||||
final String[] split = Bukkit.getBukkitVersion().split("-")[0].split("\\.");
|
final String[] split = Bukkit.getBukkitVersion().split("-")[0].split("\\.");
|
||||||
version[0] = Integer.parseInt(split[0]);
|
this.version[0] = Integer.parseInt(split[0]);
|
||||||
version[1] = Integer.parseInt(split[1]);
|
this.version[1] = Integer.parseInt(split[1]);
|
||||||
if (split.length == 3) {
|
if (split.length == 3) {
|
||||||
version[2] = Integer.parseInt(split[2]);
|
this.version[2] = Integer.parseInt(split[2]);
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (final NumberFormatException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Fawe.debug(StringMan.getString(Bukkit.getBukkitVersion()));
|
Fawe.debug(StringMan.getString(Bukkit.getBukkitVersion()));
|
||||||
Fawe.debug(StringMan.getString(Bukkit.getBukkitVersion().split("-")[0].split("\\.")));
|
Fawe.debug(StringMan.getString(Bukkit.getBukkitVersion().split("-")[0].split("\\.")));
|
||||||
return new int[] { Integer.MAX_VALUE, 0, 0 };
|
return new int[] { Integer.MAX_VALUE, 0, 0 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return version;
|
return this.version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditSessionWrapper getEditSessionWrapper(final EditSession session) {
|
public EditSessionWrapper getEditSessionWrapper(final EditSession session) {
|
||||||
return new BukkitEditSessionWrapper_1_8(session);
|
return new BukkitEditSessionWrapper_1_8(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<FaweMaskManager> getMaskManagers() {
|
public Collection<FaweMaskManager> getMaskManagers() {
|
||||||
final Plugin worldguardPlugin = Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
|
final Plugin worldguardPlugin = Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
|
||||||
@ -180,7 +180,7 @@ public class FaweBukkit extends JavaPlugin implements IFawe {
|
|||||||
try {
|
try {
|
||||||
managers.add(new Worldguard(worldguardPlugin, this));
|
managers.add(new Worldguard(worldguardPlugin, this));
|
||||||
Fawe.debug("Plugin 'WorldGuard' found. Using it now.");
|
Fawe.debug("Plugin 'WorldGuard' found. Using it now.");
|
||||||
} catch (Throwable e) {
|
} catch (final Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -191,7 +191,7 @@ public class FaweBukkit extends JavaPlugin implements IFawe {
|
|||||||
try {
|
try {
|
||||||
managers.add(new PlotMeFeature(plotmePlugin, this));
|
managers.add(new PlotMeFeature(plotmePlugin, this));
|
||||||
Fawe.debug("Plugin 'PlotMe' found. Using it now.");
|
Fawe.debug("Plugin 'PlotMe' found. Using it now.");
|
||||||
} catch (Throwable e) {
|
} catch (final Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -202,7 +202,7 @@ public class FaweBukkit extends JavaPlugin implements IFawe {
|
|||||||
try {
|
try {
|
||||||
managers.add(new TownyFeature(townyPlugin, this));
|
managers.add(new TownyFeature(townyPlugin, this));
|
||||||
Fawe.debug("Plugin 'Towny' found. Using it now.");
|
Fawe.debug("Plugin 'Towny' found. Using it now.");
|
||||||
} catch (Throwable e) {
|
} catch (final Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -225,7 +225,7 @@ public class FaweBukkit extends JavaPlugin implements IFawe {
|
|||||||
try {
|
try {
|
||||||
managers.add(new ResidenceFeature(residencePlugin, this));
|
managers.add(new ResidenceFeature(residencePlugin, this));
|
||||||
Fawe.debug("Plugin 'Residence' found. Using it now.");
|
Fawe.debug("Plugin 'Residence' found. Using it now.");
|
||||||
} catch (Throwable e) {
|
} catch (final Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -236,7 +236,7 @@ public class FaweBukkit extends JavaPlugin implements IFawe {
|
|||||||
try {
|
try {
|
||||||
managers.add(new GriefPreventionFeature(griefpreventionPlugin, this));
|
managers.add(new GriefPreventionFeature(griefpreventionPlugin, this));
|
||||||
Fawe.debug("Plugin 'GriefPrevention' found. Using it now.");
|
Fawe.debug("Plugin 'GriefPrevention' found. Using it now.");
|
||||||
} catch (Throwable e) {
|
} catch (final Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -247,7 +247,7 @@ public class FaweBukkit extends JavaPlugin implements IFawe {
|
|||||||
try {
|
try {
|
||||||
managers.add(new PlotSquaredFeature(plotsquaredPlugin, this));
|
managers.add(new PlotSquaredFeature(plotsquaredPlugin, this));
|
||||||
Fawe.debug("Plugin 'PlotSquared' found. Using it now.");
|
Fawe.debug("Plugin 'PlotSquared' found. Using it now.");
|
||||||
} catch (Throwable e) {
|
} catch (final Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -258,7 +258,7 @@ public class FaweBukkit extends JavaPlugin implements IFawe {
|
|||||||
try {
|
try {
|
||||||
managers.add(new PreciousStonesFeature(preciousstonesPlugin, this));
|
managers.add(new PreciousStonesFeature(preciousstonesPlugin, this));
|
||||||
Fawe.debug("Plugin 'PreciousStones' found. Using it now.");
|
Fawe.debug("Plugin 'PreciousStones' found. Using it now.");
|
||||||
} catch (Throwable e) {
|
} catch (final Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -7,13 +7,13 @@ import org.bukkit.plugin.RegisteredServiceProvider;
|
|||||||
|
|
||||||
public class VaultUtil {
|
public class VaultUtil {
|
||||||
public final Permission permission;
|
public final Permission permission;
|
||||||
|
|
||||||
public VaultUtil() {
|
public VaultUtil() {
|
||||||
final RegisteredServiceProvider<Permission> permissionProvider = Bukkit.getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
|
final RegisteredServiceProvider<Permission> permissionProvider = Bukkit.getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
|
||||||
if (permissionProvider != null) {
|
if (permissionProvider != null) {
|
||||||
permission = permissionProvider.getProvider();
|
this.permission = permissionProvider.getProvider();
|
||||||
} else {
|
} else {
|
||||||
permission = null;
|
this.permission = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ import com.sk89q.worldedit.regions.Region;
|
|||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class WEListener implements Listener {
|
public class WEListener implements Listener {
|
||||||
|
|
||||||
public final HashSet<String> rad1 = new HashSet<>(Arrays.asList("forestgen", "pumpkins", "drain", "fixwater", "fixlava", "replacenear", "snow", "thaw", "ex", "butcher", "size"));
|
public final HashSet<String> rad1 = new HashSet<>(Arrays.asList("forestgen", "pumpkins", "drain", "fixwater", "fixlava", "replacenear", "snow", "thaw", "ex", "butcher", "size"));
|
||||||
public final HashSet<String> rad2 = new HashSet<>(Arrays.asList("fill", "fillr", "removenear", "remove"));
|
public final HashSet<String> rad2 = new HashSet<>(Arrays.asList("fill", "fillr", "removenear", "remove"));
|
||||||
public final HashSet<String> rad2_1 = new HashSet<>(Arrays.asList("hcyl", "cyl"));
|
public final HashSet<String> rad2_1 = new HashSet<>(Arrays.asList("hcyl", "cyl"));
|
||||||
@ -37,7 +37,7 @@ public class WEListener implements Listener {
|
|||||||
public final HashSet<String> rad2_3 = new HashSet<>(Arrays.asList("brush smooth"));
|
public final HashSet<String> rad2_3 = new HashSet<>(Arrays.asList("brush smooth"));
|
||||||
public final HashSet<String> rad3_1 = new HashSet<>(Arrays.asList("brush gravity"));
|
public final HashSet<String> rad3_1 = new HashSet<>(Arrays.asList("brush gravity"));
|
||||||
public final HashSet<String> rad3_2 = new HashSet<>(Arrays.asList("brush sphere", "brush cylinder"));
|
public final HashSet<String> rad3_2 = new HashSet<>(Arrays.asList("brush sphere", "brush cylinder"));
|
||||||
|
|
||||||
public final HashSet<String> region = new HashSet<>(Arrays.asList("move", "set", "replace", "overlay", "walls", "outline", "deform", "hollow", "smooth", "naturalize", "paste", "count", "distr",
|
public final HashSet<String> region = new HashSet<>(Arrays.asList("move", "set", "replace", "overlay", "walls", "outline", "deform", "hollow", "smooth", "naturalize", "paste", "count", "distr",
|
||||||
"copy", "cut", "green", "setbiome"));
|
"copy", "cut", "green", "setbiome"));
|
||||||
public final HashSet<String> regionExtend = new HashSet<>(Arrays.asList("stack"));
|
public final HashSet<String> regionExtend = new HashSet<>(Arrays.asList("stack"));
|
||||||
@ -45,7 +45,7 @@ public class WEListener implements Listener {
|
|||||||
public final HashSet<String> unsafe1 = new HashSet<>(Arrays.asList("cs", ".s", "restore", "snapshot", "delchunks", "listchunks"));
|
public final HashSet<String> unsafe1 = new HashSet<>(Arrays.asList("cs", ".s", "restore", "snapshot", "delchunks", "listchunks"));
|
||||||
public final HashSet<String> restricted = new HashSet<>(Arrays.asList("up"));
|
public final HashSet<String> restricted = new HashSet<>(Arrays.asList("up"));
|
||||||
public final HashSet<String> other = new HashSet<>(Arrays.asList("undo", "redo", "schematic", "schem", "count"));
|
public final HashSet<String> other = new HashSet<>(Arrays.asList("undo", "redo", "schematic", "schem", "count"));
|
||||||
|
|
||||||
public boolean checkCommand(final List<String> list, final String cmd) {
|
public boolean checkCommand(final List<String> list, final String cmd) {
|
||||||
for (final String identifier : list) {
|
for (final String identifier : list) {
|
||||||
if (("/" + identifier).equals(cmd) || ("//" + identifier).equals(cmd) || ("/worldedit:/" + identifier).equals(cmd) || ("/worldedit:" + identifier).equals(cmd)) {
|
if (("/" + identifier).equals(cmd) || ("//" + identifier).equals(cmd) || ("/worldedit:/" + identifier).equals(cmd) || ("/worldedit:" + identifier).equals(cmd)) {
|
||||||
@ -54,7 +54,7 @@ public class WEListener implements Listener {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String reduceCmd(final String cmd, final boolean single) {
|
public String reduceCmd(final String cmd, final boolean single) {
|
||||||
if (cmd.startsWith("/worldedit:/")) {
|
if (cmd.startsWith("/worldedit:/")) {
|
||||||
return cmd.substring(12);
|
return cmd.substring(12);
|
||||||
@ -70,7 +70,7 @@ public class WEListener implements Listener {
|
|||||||
}
|
}
|
||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getInt(final String s) {
|
public int getInt(final String s) {
|
||||||
try {
|
try {
|
||||||
int max = 0;
|
int max = 0;
|
||||||
@ -86,7 +86,7 @@ public class WEListener implements Listener {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkVolume(final FawePlayer<Player> player, final long volume, final long max, final Cancellable e) {
|
public boolean checkVolume(final FawePlayer<Player> player, final long volume, final long max, final Cancellable e) {
|
||||||
if (volume > max) {
|
if (volume > max) {
|
||||||
MainUtil.sendMessage(FawePlayer.wrap(player.getName()), BBC.WORLDEDIT_VOLUME.s().replaceAll("%current%", volume + "").replaceAll("%max%", max + ""));
|
MainUtil.sendMessage(FawePlayer.wrap(player.getName()), BBC.WORLDEDIT_VOLUME.s().replaceAll("%current%", volume + "").replaceAll("%max%", max + ""));
|
||||||
@ -97,14 +97,14 @@ public class WEListener implements Listener {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkSelection(final FawePlayer<Player> player, final int modifier, final long max, final Cancellable e) {
|
public boolean checkSelection(final FawePlayer<Player> player, final int modifier, final long max, final Cancellable e) {
|
||||||
LocalSession session = Fawe.get().getWorldEdit().getSession(player.getName());
|
final LocalSession session = Fawe.get().getWorldEdit().getSession(player.getName());
|
||||||
LocalWorld w = BukkitUtil.getLocalWorld(player.parent.getWorld());
|
final LocalWorld w = BukkitUtil.getLocalWorld(player.parent.getWorld());
|
||||||
Region selection = null;
|
Region selection = null;
|
||||||
try {
|
try {
|
||||||
selection = session.getSelection(w);
|
selection = session.getSelection(w);
|
||||||
} catch (IncompleteRegionException e2) {}
|
} catch (final IncompleteRegionException e2) {}
|
||||||
if (selection == null) {
|
if (selection == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -139,9 +139,9 @@ public class WEListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
final long volume = Math.abs((pos1.getBlockX() - pos2.getBlockX()) * (pos1.getBlockY() - pos2.getBlockY()) * (pos1.getBlockZ() - pos2.getBlockZ())) * modifier;
|
final long volume = Math.abs((pos1.getBlockX() - pos2.getBlockX()) * (pos1.getBlockY() - pos2.getBlockY()) * (pos1.getBlockZ() - pos2.getBlockZ())) * modifier;
|
||||||
return checkVolume(player, volume, max, e);
|
return this.checkVolume(player, volume, max, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public boolean onPlayerCommand(final PlayerCommandPreprocessEvent e) {
|
public boolean onPlayerCommand(final PlayerCommandPreprocessEvent e) {
|
||||||
final FawePlayer<Player> player = FawePlayer.wrap(e.getPlayer());
|
final FawePlayer<Player> player = FawePlayer.wrap(e.getPlayer());
|
||||||
@ -149,65 +149,65 @@ public class WEListener implements Listener {
|
|||||||
final String cmd = message.toLowerCase();
|
final String cmd = message.toLowerCase();
|
||||||
final boolean single = true;
|
final boolean single = true;
|
||||||
final String[] split = cmd.split(" ");
|
final String[] split = cmd.split(" ");
|
||||||
|
|
||||||
final long maxVolume = Settings.WE_MAX_VOLUME;
|
final long maxVolume = Settings.WE_MAX_VOLUME;
|
||||||
final long maxIterations = Settings.WE_MAX_ITERATIONS;
|
final long maxIterations = Settings.WE_MAX_ITERATIONS;
|
||||||
// if (player.hasPermission("fawe.bypass")) {
|
// if (player.hasPermission("fawe.bypass")) {
|
||||||
// return true;
|
// return true;
|
||||||
// }
|
// }
|
||||||
if (split.length >= 2) {
|
if (split.length >= 2) {
|
||||||
final String reduced = reduceCmd(split[0], single);
|
final String reduced = this.reduceCmd(split[0], single);
|
||||||
final String reduced2 = reduceCmd(split[0] + " " + split[1], single);
|
final String reduced2 = this.reduceCmd(split[0] + " " + split[1], single);
|
||||||
if (rad1.contains(reduced)) {
|
if (this.rad1.contains(reduced)) {
|
||||||
if (WEManager.IMP.delay(player, message)) {
|
if (WEManager.IMP.delay(player, message)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
final long volume = getInt(split[1]) * 256;
|
final long volume = this.getInt(split[1]) * 256;
|
||||||
return checkVolume(player, volume, maxVolume, e);
|
return this.checkVolume(player, volume, maxVolume, e);
|
||||||
}
|
}
|
||||||
if (rad2.contains(reduced)) {
|
if (this.rad2.contains(reduced)) {
|
||||||
if (WEManager.IMP.delay(player, message)) {
|
if (WEManager.IMP.delay(player, message)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (split.length >= 3) {
|
if (split.length >= 3) {
|
||||||
final long volume = getInt(split[2]) * 256;
|
final long volume = this.getInt(split[2]) * 256;
|
||||||
return checkVolume(player, volume, maxVolume, e);
|
return this.checkVolume(player, volume, maxVolume, e);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (rad2_1.contains(reduced)) {
|
if (this.rad2_1.contains(reduced)) {
|
||||||
if (WEManager.IMP.delay(player, message)) {
|
if (WEManager.IMP.delay(player, message)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (split.length >= 4) {
|
if (split.length >= 4) {
|
||||||
final long volume = getInt(split[2]) * getInt(split[3]);
|
final long volume = this.getInt(split[2]) * this.getInt(split[3]);
|
||||||
return checkVolume(player, volume, maxVolume, e);
|
return this.checkVolume(player, volume, maxVolume, e);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (rad2_2.contains(reduced)) {
|
if (this.rad2_2.contains(reduced)) {
|
||||||
if (WEManager.IMP.delay(player, message)) {
|
if (WEManager.IMP.delay(player, message)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (split.length >= 3) {
|
if (split.length >= 3) {
|
||||||
final long radius = getInt(split[2]);
|
final long radius = this.getInt(split[2]);
|
||||||
final long volume = radius * radius;
|
final long volume = radius * radius;
|
||||||
return checkVolume(player, volume, maxVolume, e);
|
return this.checkVolume(player, volume, maxVolume, e);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (rad2_3.contains(reduced2)) {
|
if (this.rad2_3.contains(reduced2)) {
|
||||||
if (WEManager.IMP.delay(player, message)) {
|
if (WEManager.IMP.delay(player, message)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (split.length >= 3) {
|
if (split.length >= 3) {
|
||||||
if (split.length == 4) {
|
if (split.length == 4) {
|
||||||
final int iterations = getInt(split[3]);
|
final int iterations = this.getInt(split[3]);
|
||||||
if (iterations > maxIterations) {
|
if (iterations > maxIterations) {
|
||||||
MainUtil.sendMessage(player, BBC.WORLDEDIT_ITERATIONS.s().replaceAll("%current%", iterations + "").replaceAll("%max%", maxIterations + ""));
|
MainUtil.sendMessage(player, BBC.WORLDEDIT_ITERATIONS.s().replaceAll("%current%", iterations + "").replaceAll("%max%", maxIterations + ""));
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
@ -217,13 +217,13 @@ public class WEListener implements Listener {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final long radius = getInt(split[2]);
|
final long radius = this.getInt(split[2]);
|
||||||
final long volume = radius * radius;
|
final long volume = radius * radius;
|
||||||
return checkVolume(player, volume, maxVolume, e);
|
return this.checkVolume(player, volume, maxVolume, e);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (rad3_1.contains(reduced2)) {
|
if (this.rad3_1.contains(reduced2)) {
|
||||||
if (WEManager.IMP.delay(player, message)) {
|
if (WEManager.IMP.delay(player, message)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return true;
|
return true;
|
||||||
@ -233,13 +233,13 @@ public class WEListener implements Listener {
|
|||||||
if (split[i].equalsIgnoreCase("-h")) {
|
if (split[i].equalsIgnoreCase("-h")) {
|
||||||
i = 3;
|
i = 3;
|
||||||
}
|
}
|
||||||
final long radius = getInt(split[i]);
|
final long radius = this.getInt(split[i]);
|
||||||
final long volume = radius * radius;
|
final long volume = radius * radius;
|
||||||
return checkVolume(player, volume, maxVolume, e);
|
return this.checkVolume(player, volume, maxVolume, e);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (rad3_2.contains(reduced2)) {
|
if (this.rad3_2.contains(reduced2)) {
|
||||||
if (WEManager.IMP.delay(player, message)) {
|
if (WEManager.IMP.delay(player, message)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return true;
|
return true;
|
||||||
@ -249,21 +249,21 @@ public class WEListener implements Listener {
|
|||||||
if (split[i].equalsIgnoreCase("-h")) {
|
if (split[i].equalsIgnoreCase("-h")) {
|
||||||
i = 4;
|
i = 4;
|
||||||
}
|
}
|
||||||
final long radius = getInt(split[i]);
|
final long radius = this.getInt(split[i]);
|
||||||
final long volume = radius * radius;
|
final long volume = radius * radius;
|
||||||
return checkVolume(player, volume, maxVolume, e);
|
return this.checkVolume(player, volume, maxVolume, e);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (regionExtend.contains(reduced)) {
|
if (this.regionExtend.contains(reduced)) {
|
||||||
if (WEManager.IMP.delay(player, message)) {
|
if (WEManager.IMP.delay(player, message)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return checkSelection(player, getInt(split[1]), maxVolume, e);
|
return this.checkSelection(player, this.getInt(split[1]), maxVolume, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final String reduced = reduceCmd(split[0], single);
|
final String reduced = this.reduceCmd(split[0], single);
|
||||||
if (Settings.WE_BLACKLIST.contains(reduced)) {
|
if (Settings.WE_BLACKLIST.contains(reduced)) {
|
||||||
BBC.WORLDEDIT_UNSAFE.send(player);
|
BBC.WORLDEDIT_UNSAFE.send(player);
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
@ -271,9 +271,9 @@ public class WEListener implements Listener {
|
|||||||
BBC.WORLDEDIT_BYPASS.send(player);
|
BBC.WORLDEDIT_BYPASS.send(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (restricted.contains(reduced)) {
|
if (this.restricted.contains(reduced)) {
|
||||||
final HashSet<RegionWrapper> mask = WEManager.IMP.getMask(player);
|
final HashSet<RegionWrapper> mask = WEManager.IMP.getMask(player);
|
||||||
Location loc = player.parent.getLocation();
|
final Location loc = player.parent.getLocation();
|
||||||
for (final RegionWrapper region : mask) {
|
for (final RegionWrapper region : mask) {
|
||||||
if (region.isIn(loc.getBlockX(), loc.getBlockZ())) {
|
if (region.isIn(loc.getBlockX(), loc.getBlockZ())) {
|
||||||
if (WEManager.IMP.delay(player, message)) {
|
if (WEManager.IMP.delay(player, message)) {
|
||||||
@ -287,20 +287,20 @@ public class WEListener implements Listener {
|
|||||||
BBC.REQUIRE_SELECTION_IN_MASK.send(player);
|
BBC.REQUIRE_SELECTION_IN_MASK.send(player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (region.contains(reduced)) {
|
if (this.region.contains(reduced)) {
|
||||||
if (WEManager.IMP.delay(player, message)) {
|
if (WEManager.IMP.delay(player, message)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return checkSelection(player, 1, maxVolume, e);
|
return this.checkSelection(player, 1, maxVolume, e);
|
||||||
}
|
}
|
||||||
if (unregioned.contains(reduced)) {
|
if (this.unregioned.contains(reduced)) {
|
||||||
if (WEManager.IMP.delay(player, message)) {
|
if (WEManager.IMP.delay(player, message)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (other.contains(reduced)) {
|
if (this.other.contains(reduced)) {
|
||||||
if (WEManager.IMP.delay(player, message)) {
|
if (WEManager.IMP.delay(player, message)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return true;
|
return true;
|
||||||
|
@ -5,7 +5,7 @@ import org.bukkit.entity.Player;
|
|||||||
import com.boydti.fawe.regions.FaweMaskManager;
|
import com.boydti.fawe.regions.FaweMaskManager;
|
||||||
|
|
||||||
public abstract class BukkitMaskManager extends FaweMaskManager<Player> {
|
public abstract class BukkitMaskManager extends FaweMaskManager<Player> {
|
||||||
|
|
||||||
public BukkitMaskManager(final String plugin) {
|
public BukkitMaskManager(final String plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
}
|
}
|
||||||
|
@ -15,19 +15,19 @@ import com.massivecraft.massivecore.ps.PS;
|
|||||||
public class FactionsFeature extends BukkitMaskManager implements Listener {
|
public class FactionsFeature extends BukkitMaskManager implements Listener {
|
||||||
FaweBukkit plugin;
|
FaweBukkit plugin;
|
||||||
Plugin factions;
|
Plugin factions;
|
||||||
|
|
||||||
public FactionsFeature(final Plugin factionsPlugin, final FaweBukkit p3) {
|
public FactionsFeature(final Plugin factionsPlugin, final FaweBukkit p3) {
|
||||||
super(factionsPlugin.getName());
|
super(factionsPlugin.getName());
|
||||||
factions = factionsPlugin;
|
this.factions = factionsPlugin;
|
||||||
plugin = p3;
|
this.plugin = p3;
|
||||||
BoardColl.get();
|
BoardColl.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||||
final Player player = fp.parent;
|
final Player player = fp.parent;
|
||||||
final Location loc = player.getLocation();
|
final Location loc = player.getLocation();
|
||||||
PS ps = PS.valueOf(loc);
|
final PS ps = PS.valueOf(loc);
|
||||||
final Faction fac = BoardColl.get().getFactionAt(ps);
|
final Faction fac = BoardColl.get().getFactionAt(ps);
|
||||||
if (fac != null) {
|
if (fac != null) {
|
||||||
if (fac.getOnlinePlayers().contains(player)) {
|
if (fac.getOnlinePlayers().contains(player)) {
|
||||||
|
@ -17,12 +17,12 @@ import com.massivecraft.factions.Faction;
|
|||||||
|
|
||||||
public class FactionsUUIDFeature extends BukkitMaskManager implements Listener {
|
public class FactionsUUIDFeature extends BukkitMaskManager implements Listener {
|
||||||
private final Board instance;
|
private final Board instance;
|
||||||
|
|
||||||
public FactionsUUIDFeature(final Plugin factionsPlugin, final FaweBukkit p3) {
|
public FactionsUUIDFeature(final Plugin factionsPlugin, final FaweBukkit p3) {
|
||||||
super(factionsPlugin.getName());
|
super(factionsPlugin.getName());
|
||||||
instance = Board.getInstance();
|
this.instance = Board.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||||
final Player player = fp.parent;
|
final Player player = fp.parent;
|
||||||
@ -30,47 +30,47 @@ public class FactionsUUIDFeature extends BukkitMaskManager implements Listener {
|
|||||||
final boolean perm = Perm.hasPermission(FawePlayer.wrap(player), "fawe.factions.wilderness");
|
final boolean perm = Perm.hasPermission(FawePlayer.wrap(player), "fawe.factions.wilderness");
|
||||||
final RegionWrapper locs = new RegionWrapper(chunk.getX(), chunk.getX(), chunk.getZ(), chunk.getZ());
|
final RegionWrapper locs = new RegionWrapper(chunk.getX(), chunk.getX(), chunk.getZ(), chunk.getZ());
|
||||||
final World world = player.getWorld();
|
final World world = player.getWorld();
|
||||||
|
|
||||||
int count = 32;
|
int count = 32;
|
||||||
|
|
||||||
if (isAdded(locs, world, player, perm)) {
|
if (this.isAdded(locs, world, player, perm)) {
|
||||||
boolean hasPerm = true;
|
boolean hasPerm = true;
|
||||||
|
|
||||||
RegionWrapper chunkSelection;
|
RegionWrapper chunkSelection;
|
||||||
while (hasPerm && (count > 0)) {
|
while (hasPerm && (count > 0)) {
|
||||||
count--;
|
count--;
|
||||||
|
|
||||||
hasPerm = false;
|
hasPerm = false;
|
||||||
|
|
||||||
chunkSelection = new RegionWrapper(locs.maxX + 1, locs.maxX + 1, locs.minZ, locs.maxZ);
|
chunkSelection = new RegionWrapper(locs.maxX + 1, locs.maxX + 1, locs.minZ, locs.maxZ);
|
||||||
|
|
||||||
if (isAdded(chunkSelection, world, player, perm)) {
|
if (this.isAdded(chunkSelection, world, player, perm)) {
|
||||||
locs.maxX += 1;
|
locs.maxX += 1;
|
||||||
hasPerm = true;
|
hasPerm = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
chunkSelection = new RegionWrapper(locs.minX - 1, locs.minX - 1, locs.minZ, locs.maxZ);
|
chunkSelection = new RegionWrapper(locs.minX - 1, locs.minX - 1, locs.minZ, locs.maxZ);
|
||||||
|
|
||||||
if (isAdded(chunkSelection, world, player, perm)) {
|
if (this.isAdded(chunkSelection, world, player, perm)) {
|
||||||
locs.minX -= 1;
|
locs.minX -= 1;
|
||||||
hasPerm = true;
|
hasPerm = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
chunkSelection = new RegionWrapper(locs.minX, locs.maxX, locs.maxZ + 1, locs.maxZ + 1);
|
chunkSelection = new RegionWrapper(locs.minX, locs.maxX, locs.maxZ + 1, locs.maxZ + 1);
|
||||||
|
|
||||||
if (isAdded(chunkSelection, world, player, perm)) {
|
if (this.isAdded(chunkSelection, world, player, perm)) {
|
||||||
locs.maxZ += 1;
|
locs.maxZ += 1;
|
||||||
hasPerm = true;
|
hasPerm = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
chunkSelection = new RegionWrapper(locs.minX, locs.maxX, locs.minZ - 1, locs.minZ - 1);
|
chunkSelection = new RegionWrapper(locs.minX, locs.maxX, locs.minZ - 1, locs.minZ - 1);
|
||||||
|
|
||||||
if (isAdded(chunkSelection, world, player, perm)) {
|
if (this.isAdded(chunkSelection, world, player, perm)) {
|
||||||
locs.minZ -= 1;
|
locs.minZ -= 1;
|
||||||
hasPerm = true;
|
hasPerm = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final Location pos1 = new Location(world, locs.minX << 4, 1, locs.minZ << 4);
|
final Location pos1 = new Location(world, locs.minX << 4, 1, locs.minZ << 4);
|
||||||
final Location pos2 = new Location(world, 15 + (locs.maxX << 4), 256, 15 + (locs.maxZ << 4));
|
final Location pos2 = new Location(world, 15 + (locs.maxX << 4), 256, 15 + (locs.maxZ << 4));
|
||||||
return new FaweMask(pos1, pos2) {
|
return new FaweMask(pos1, pos2) {
|
||||||
@ -82,11 +82,11 @@ public class FactionsUUIDFeature extends BukkitMaskManager implements Listener {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAdded(final RegionWrapper locs, final World world, final Player player, final boolean perm) {
|
public boolean isAdded(final RegionWrapper locs, final World world, final Player player, final boolean perm) {
|
||||||
for (int x = locs.minX; x <= locs.maxX; x++) {
|
for (int x = locs.minX; x <= locs.maxX; x++) {
|
||||||
for (int z = locs.minZ; z <= locs.maxZ; z++) {
|
for (int z = locs.minZ; z <= locs.maxZ; z++) {
|
||||||
final Faction fac = instance.getFactionAt(new FLocation(world.getName(), x, z));
|
final Faction fac = this.instance.getFactionAt(new FLocation(world.getName(), x, z));
|
||||||
if (fac == null) {
|
if (fac == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ public class FaweMask {
|
|||||||
private String description = null;
|
private String description = null;
|
||||||
private Location position1;
|
private Location position1;
|
||||||
private Location position2;
|
private Location position2;
|
||||||
|
|
||||||
public FaweMask(final Location pos1, final Location pos2, final String id) {
|
public FaweMask(final Location pos1, final Location pos2, final String id) {
|
||||||
if ((pos1 == null) || (pos2 == null)) {
|
if ((pos1 == null) || (pos2 == null)) {
|
||||||
throw new IllegalArgumentException("Locations cannot be null!");
|
throw new IllegalArgumentException("Locations cannot be null!");
|
||||||
@ -19,11 +19,11 @@ public class FaweMask {
|
|||||||
if (pos1.getWorld().equals(pos2.getWorld()) == false) {
|
if (pos1.getWorld().equals(pos2.getWorld()) == false) {
|
||||||
throw new IllegalArgumentException("Locations must be in the same world!");
|
throw new IllegalArgumentException("Locations must be in the same world!");
|
||||||
}
|
}
|
||||||
description = id;
|
this.description = id;
|
||||||
position1 = new Location(pos1.getWorld(), Math.min(pos1.getBlockX(), pos2.getBlockX()), 0, Math.min(pos1.getBlockZ(), pos2.getBlockZ()));
|
this.position1 = new Location(pos1.getWorld(), Math.min(pos1.getBlockX(), pos2.getBlockX()), 0, Math.min(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||||
position2 = new Location(pos1.getWorld(), Math.max(pos1.getBlockX(), pos2.getBlockX()), 256, Math.max(pos1.getBlockZ(), pos2.getBlockZ()));
|
this.position2 = new Location(pos1.getWorld(), Math.max(pos1.getBlockX(), pos2.getBlockX()), 256, Math.max(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public FaweMask(final Location pos1, final Location pos2) {
|
public FaweMask(final Location pos1, final Location pos2) {
|
||||||
if ((pos1 == null) || (pos2 == null)) {
|
if ((pos1 == null) || (pos2 == null)) {
|
||||||
throw new IllegalArgumentException("Locations cannot be null!");
|
throw new IllegalArgumentException("Locations cannot be null!");
|
||||||
@ -31,28 +31,28 @@ public class FaweMask {
|
|||||||
if (pos1.getWorld().equals(pos2.getWorld()) == false) {
|
if (pos1.getWorld().equals(pos2.getWorld()) == false) {
|
||||||
throw new IllegalArgumentException("Locations must be in the same world!");
|
throw new IllegalArgumentException("Locations must be in the same world!");
|
||||||
}
|
}
|
||||||
position1 = new Location(pos1.getWorld(), Math.min(pos1.getBlockX(), pos2.getBlockX()), 0, Math.min(pos1.getBlockZ(), pos2.getBlockZ()));
|
this.position1 = new Location(pos1.getWorld(), Math.min(pos1.getBlockX(), pos2.getBlockX()), 0, Math.min(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||||
position2 = new Location(pos1.getWorld(), Math.max(pos1.getBlockX(), pos2.getBlockX()), 256, Math.max(pos1.getBlockZ(), pos2.getBlockZ()));
|
this.position2 = new Location(pos1.getWorld(), Math.max(pos1.getBlockX(), pos2.getBlockX()), 256, Math.max(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashSet<RegionWrapper> getRegions() {
|
public HashSet<RegionWrapper> getRegions() {
|
||||||
final Location lower = getLowerBound();
|
final Location lower = this.getLowerBound();
|
||||||
final Location upper = getUpperBound();
|
final Location upper = this.getUpperBound();
|
||||||
return new HashSet<>(Arrays.asList(new RegionWrapper(lower.getBlockX(), upper.getBlockX(), lower.getBlockZ(), upper.getBlockZ())));
|
return new HashSet<>(Arrays.asList(new RegionWrapper(lower.getBlockX(), upper.getBlockX(), lower.getBlockZ(), upper.getBlockZ())));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return description;
|
return this.description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getLowerBound() {
|
public Location getLowerBound() {
|
||||||
return position1;
|
return this.position1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getUpperBound() {
|
public Location getUpperBound() {
|
||||||
return position2;
|
return this.position2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBounds(final Location pos1, final Location pos2) {
|
public void setBounds(final Location pos1, final Location pos2) {
|
||||||
if ((pos1 == null) || (pos2 == null)) {
|
if ((pos1 == null) || (pos2 == null)) {
|
||||||
throw new IllegalArgumentException("Locations cannot be null!");
|
throw new IllegalArgumentException("Locations cannot be null!");
|
||||||
@ -60,33 +60,33 @@ public class FaweMask {
|
|||||||
if (pos1.getWorld().equals(pos2.getWorld()) == false) {
|
if (pos1.getWorld().equals(pos2.getWorld()) == false) {
|
||||||
throw new IllegalArgumentException("Locations must be in the same world!");
|
throw new IllegalArgumentException("Locations must be in the same world!");
|
||||||
}
|
}
|
||||||
position1 = new Location(pos1.getWorld(), Math.min(pos1.getBlockX(), pos2.getBlockX()), 0, Math.min(pos1.getBlockZ(), pos2.getBlockZ()));
|
this.position1 = new Location(pos1.getWorld(), Math.min(pos1.getBlockX(), pos2.getBlockX()), 0, Math.min(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||||
position2 = new Location(pos1.getWorld(), Math.max(pos1.getBlockX(), pos2.getBlockX()), 256, Math.max(pos1.getBlockZ(), pos2.getBlockZ()));
|
this.position2 = new Location(pos1.getWorld(), Math.max(pos1.getBlockX(), pos2.getBlockX()), 256, Math.max(pos1.getBlockZ(), pos2.getBlockZ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location[] getBounds() {
|
public Location[] getBounds() {
|
||||||
final Location[] locations = { position1, position2 };
|
final Location[] locations = { this.position1, this.position2 };
|
||||||
return locations;
|
return locations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(final Location loc) {
|
public boolean contains(final Location loc) {
|
||||||
if (position1.getWorld().equals(loc.getWorld())) {
|
if (this.position1.getWorld().equals(loc.getWorld())) {
|
||||||
if (loc.getBlockX() < position1.getBlockX()) {
|
if (loc.getBlockX() < this.position1.getBlockX()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (loc.getBlockX() > position2.getBlockX()) {
|
if (loc.getBlockX() > this.position2.getBlockX()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (loc.getBlockZ() < position1.getBlockZ()) {
|
if (loc.getBlockZ() < this.position1.getBlockZ()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (loc.getBlockZ() > position2.getBlockZ()) {
|
if (loc.getBlockZ() > this.position2.getBlockZ()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (loc.getBlockY() < position1.getBlockY()) {
|
if (loc.getBlockY() < this.position1.getBlockY()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (loc.getBlockY() > position2.getBlockY()) {
|
if (loc.getBlockY() > this.position2.getBlockY()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -14,13 +14,13 @@ import com.boydti.fawe.object.FawePlayer;
|
|||||||
public class GriefPreventionFeature extends BukkitMaskManager implements Listener {
|
public class GriefPreventionFeature extends BukkitMaskManager implements Listener {
|
||||||
FaweBukkit plugin;
|
FaweBukkit plugin;
|
||||||
Plugin griefprevention;
|
Plugin griefprevention;
|
||||||
|
|
||||||
public GriefPreventionFeature(final Plugin griefpreventionPlugin, final FaweBukkit p3) {
|
public GriefPreventionFeature(final Plugin griefpreventionPlugin, final FaweBukkit p3) {
|
||||||
super(griefpreventionPlugin.getName());
|
super(griefpreventionPlugin.getName());
|
||||||
griefprevention = griefpreventionPlugin;
|
this.griefprevention = griefpreventionPlugin;
|
||||||
plugin = p3;
|
this.plugin = p3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||||
final Player player = fp.parent;
|
final Player player = fp.parent;
|
||||||
@ -41,6 +41,6 @@ public class GriefPreventionFeature extends BukkitMaskManager implements Listene
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,27 +16,27 @@ import com.worldcretornica.plotme_core.bukkit.api.BukkitWorld;
|
|||||||
public class PlotMeFeature extends BukkitMaskManager implements Listener {
|
public class PlotMeFeature extends BukkitMaskManager implements Listener {
|
||||||
FaweBukkit plugin;
|
FaweBukkit plugin;
|
||||||
PlotMe_Core plotme;
|
PlotMe_Core plotme;
|
||||||
|
|
||||||
public PlotMeFeature(final Plugin plotmePlugin, final FaweBukkit p3) {
|
public PlotMeFeature(final Plugin plotmePlugin, final FaweBukkit p3) {
|
||||||
super(plotmePlugin.getName());
|
super(plotmePlugin.getName());
|
||||||
plotme = ((PlotMe_CorePlugin) plotmePlugin).getAPI();
|
this.plotme = ((PlotMe_CorePlugin) plotmePlugin).getAPI();
|
||||||
plugin = p3;
|
this.plugin = p3;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||||
final Player player = fp.parent;
|
final Player player = fp.parent;
|
||||||
final Location location = player.getLocation();
|
final Location location = player.getLocation();
|
||||||
final Plot plot = plotme.getPlotMeCoreManager().getPlotById(new BukkitPlayer(player));
|
final Plot plot = this.plotme.getPlotMeCoreManager().getPlotById(new BukkitPlayer(player));
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final boolean isallowed = plot.isAllowed(player.getUniqueId());
|
final boolean isallowed = plot.isAllowed(player.getUniqueId());
|
||||||
if (isallowed) {
|
if (isallowed) {
|
||||||
final Location pos1 = new Location(location.getWorld(), plotme.getGenManager(player.getWorld().getName()).bottomX(plot.getId(), new BukkitWorld(player.getWorld())), 0, plotme
|
final Location pos1 = new Location(location.getWorld(), this.plotme.getGenManager(player.getWorld().getName()).bottomX(plot.getId(), new BukkitWorld(player.getWorld())), 0, this.plotme
|
||||||
.getGenManager(player.getWorld().getName()).bottomZ(plot.getId(), new BukkitWorld(player.getWorld())));
|
.getGenManager(player.getWorld().getName()).bottomZ(plot.getId(), new BukkitWorld(player.getWorld())));
|
||||||
final Location pos2 = new Location(location.getWorld(), plotme.getGenManager(player.getWorld().getName()).topX(plot.getId(), new BukkitWorld(player.getWorld())), 256, plotme
|
final Location pos2 = new Location(location.getWorld(), this.plotme.getGenManager(player.getWorld().getName()).topX(plot.getId(), new BukkitWorld(player.getWorld())), 256, this.plotme
|
||||||
.getGenManager(player.getWorld().getName()).topZ(plot.getId(), new BukkitWorld(player.getWorld())));
|
.getGenManager(player.getWorld().getName()).topZ(plot.getId(), new BukkitWorld(player.getWorld())));
|
||||||
return new FaweMask(pos1, pos2) {
|
return new FaweMask(pos1, pos2) {
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,14 +19,14 @@ import com.plotsquared.bukkit.BukkitMain;
|
|||||||
|
|
||||||
public class PlotSquaredFeature extends BukkitMaskManager implements Listener {
|
public class PlotSquaredFeature extends BukkitMaskManager implements Listener {
|
||||||
FaweBukkit plugin;
|
FaweBukkit plugin;
|
||||||
|
|
||||||
public PlotSquaredFeature(final Plugin plotPlugin, final FaweBukkit p3) {
|
public PlotSquaredFeature(final Plugin plotPlugin, final FaweBukkit p3) {
|
||||||
super(plotPlugin.getName());
|
super(plotPlugin.getName());
|
||||||
plugin = p3;
|
this.plugin = p3;
|
||||||
BukkitMain.worldEdit = null;
|
BukkitMain.worldEdit = null;
|
||||||
PS.get().worldedit = null;
|
PS.get().worldedit = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||||
final PlotPlayer pp = PlotPlayer.wrap(fp.parent);
|
final PlotPlayer pp = PlotPlayer.wrap(fp.parent);
|
||||||
@ -58,10 +58,10 @@ public class PlotSquaredFeature extends BukkitMaskManager implements Listener {
|
|||||||
final World world = fp.parent.getWorld();
|
final World world = fp.parent.getWorld();
|
||||||
final com.intellectualcrafters.plot.object.RegionWrapper region = plot.getLargestRegion();
|
final com.intellectualcrafters.plot.object.RegionWrapper region = plot.getLargestRegion();
|
||||||
final HashSet<com.intellectualcrafters.plot.object.RegionWrapper> regions = plot.getRegions();
|
final HashSet<com.intellectualcrafters.plot.object.RegionWrapper> regions = plot.getRegions();
|
||||||
|
|
||||||
final Location pos1 = new Location(world, region.minX, 0, region.minZ);
|
final Location pos1 = new Location(world, region.minX, 0, region.minZ);
|
||||||
final Location pos2 = new Location(world, region.maxX, 256, region.maxZ);
|
final Location pos2 = new Location(world, region.maxX, 256, region.maxZ);
|
||||||
|
|
||||||
final HashSet<RegionWrapper> faweRegions = new HashSet<RegionWrapper>();
|
final HashSet<RegionWrapper> faweRegions = new HashSet<RegionWrapper>();
|
||||||
for (final com.intellectualcrafters.plot.object.RegionWrapper current : regions) {
|
for (final com.intellectualcrafters.plot.object.RegionWrapper current : regions) {
|
||||||
faweRegions.add(new RegionWrapper(current.minX, current.maxX, current.minZ, current.maxZ));
|
faweRegions.add(new RegionWrapper(current.minX, current.maxX, current.minZ, current.maxZ));
|
||||||
@ -71,7 +71,7 @@ public class PlotSquaredFeature extends BukkitMaskManager implements Listener {
|
|||||||
public String getName() {
|
public String getName() {
|
||||||
return "PLOT^2:" + id;
|
return "PLOT^2:" + id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HashSet<RegionWrapper> getRegions() {
|
public HashSet<RegionWrapper> getRegions() {
|
||||||
return faweRegions;
|
return faweRegions;
|
||||||
|
@ -17,14 +17,14 @@ import com.boydti.fawe.object.FawePlayer;
|
|||||||
public class PreciousStonesFeature extends BukkitMaskManager implements Listener {
|
public class PreciousStonesFeature extends BukkitMaskManager implements Listener {
|
||||||
FaweBukkit plugin;
|
FaweBukkit plugin;
|
||||||
Plugin preciousstones;
|
Plugin preciousstones;
|
||||||
|
|
||||||
public PreciousStonesFeature(final Plugin preciousstonesPlugin, final FaweBukkit p3) {
|
public PreciousStonesFeature(final Plugin preciousstonesPlugin, final FaweBukkit p3) {
|
||||||
super(preciousstonesPlugin.getName());
|
super(preciousstonesPlugin.getName());
|
||||||
preciousstones = preciousstonesPlugin;
|
this.preciousstones = preciousstonesPlugin;
|
||||||
plugin = p3;
|
this.plugin = p3;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||||
final Player player = fp.parent;
|
final Player player = fp.parent;
|
||||||
|
@ -14,14 +14,14 @@ import com.boydti.fawe.object.FawePlayer;
|
|||||||
public class ResidenceFeature extends BukkitMaskManager implements Listener {
|
public class ResidenceFeature extends BukkitMaskManager implements Listener {
|
||||||
FaweBukkit plugin;
|
FaweBukkit plugin;
|
||||||
Plugin residence;
|
Plugin residence;
|
||||||
|
|
||||||
public ResidenceFeature(final Plugin residencePlugin, final FaweBukkit p3) {
|
public ResidenceFeature(final Plugin residencePlugin, final FaweBukkit p3) {
|
||||||
super(residencePlugin.getName());
|
super(residencePlugin.getName());
|
||||||
residence = residencePlugin;
|
this.residence = residencePlugin;
|
||||||
plugin = p3;
|
this.plugin = p3;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||||
final Player player = fp.parent;
|
final Player player = fp.parent;
|
||||||
|
@ -17,19 +17,19 @@ import com.palmergames.bukkit.towny.object.WorldCoord;
|
|||||||
public class TownyFeature extends BukkitMaskManager implements Listener {
|
public class TownyFeature extends BukkitMaskManager implements Listener {
|
||||||
FaweBukkit plugin;
|
FaweBukkit plugin;
|
||||||
Plugin towny;
|
Plugin towny;
|
||||||
|
|
||||||
public TownyFeature(final Plugin townyPlugin, final FaweBukkit p3) {
|
public TownyFeature(final Plugin townyPlugin, final FaweBukkit p3) {
|
||||||
super(townyPlugin.getName());
|
super(townyPlugin.getName());
|
||||||
towny = townyPlugin;
|
this.towny = townyPlugin;
|
||||||
plugin = p3;
|
this.plugin = p3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||||
final Player player = fp.parent;
|
final Player player = fp.parent;
|
||||||
final Location location = player.getLocation();
|
final Location location = player.getLocation();
|
||||||
try {
|
try {
|
||||||
final PlayerCache cache = ((Towny) towny).getCache(player);
|
final PlayerCache cache = ((Towny) this.towny).getCache(player);
|
||||||
final WorldCoord mycoord = cache.getLastTownBlock();
|
final WorldCoord mycoord = cache.getLastTownBlock();
|
||||||
if (mycoord == null) {
|
if (mycoord == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -44,7 +44,7 @@ public class TownyFeature extends BukkitMaskManager implements Listener {
|
|||||||
isMember = true;
|
isMember = true;
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!isMember) {
|
if (!isMember) {
|
||||||
if (player.hasPermission("fawe.towny.*")) {
|
if (player.hasPermission("fawe.towny.*")) {
|
||||||
|
@ -17,28 +17,28 @@ import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
|||||||
public class Worldguard extends BukkitMaskManager implements Listener {
|
public class Worldguard extends BukkitMaskManager implements Listener {
|
||||||
WorldGuardPlugin worldguard;
|
WorldGuardPlugin worldguard;
|
||||||
FaweBukkit plugin;
|
FaweBukkit plugin;
|
||||||
|
|
||||||
private WorldGuardPlugin getWorldGuard() {
|
private WorldGuardPlugin getWorldGuard() {
|
||||||
final Plugin plugin = Bukkit.getPluginManager().getPlugin("WorldGuard");
|
final Plugin plugin = Bukkit.getPluginManager().getPlugin("WorldGuard");
|
||||||
|
|
||||||
// WorldGuard may not be loaded
|
// WorldGuard may not be loaded
|
||||||
if ((plugin == null) || !(plugin instanceof WorldGuardPlugin)) {
|
if ((plugin == null) || !(plugin instanceof WorldGuardPlugin)) {
|
||||||
return null; // Maybe you want throw an exception instead
|
return null; // Maybe you want throw an exception instead
|
||||||
}
|
}
|
||||||
|
|
||||||
return (WorldGuardPlugin) plugin;
|
return (WorldGuardPlugin) plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Worldguard(final Plugin p2, final FaweBukkit p3) {
|
public Worldguard(final Plugin p2, final FaweBukkit p3) {
|
||||||
super(p2.getName());
|
super(p2.getName());
|
||||||
worldguard = getWorldGuard();
|
this.worldguard = this.getWorldGuard();
|
||||||
plugin = p3;
|
this.plugin = p3;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtectedRegion isowner(final Player player, final Location location) {
|
public ProtectedRegion isowner(final Player player, final Location location) {
|
||||||
final com.sk89q.worldguard.LocalPlayer localplayer = worldguard.wrapPlayer(player);
|
final com.sk89q.worldguard.LocalPlayer localplayer = this.worldguard.wrapPlayer(player);
|
||||||
final RegionManager manager = worldguard.getRegionManager(player.getWorld());
|
final RegionManager manager = this.worldguard.getRegionManager(player.getWorld());
|
||||||
final ApplicableRegionSet regions = manager.getApplicableRegions(player.getLocation());
|
final ApplicableRegionSet regions = manager.getApplicableRegions(player.getLocation());
|
||||||
for (final ProtectedRegion region : regions) {
|
for (final ProtectedRegion region : regions) {
|
||||||
if (region.isOwner(localplayer)) {
|
if (region.isOwner(localplayer)) {
|
||||||
@ -53,10 +53,10 @@ public class Worldguard extends BukkitMaskManager implements Listener {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtectedRegion getregion(final Player player, final BlockVector location) {
|
public ProtectedRegion getregion(final Player player, final BlockVector location) {
|
||||||
final com.sk89q.worldguard.LocalPlayer localplayer = worldguard.wrapPlayer(player);
|
final com.sk89q.worldguard.LocalPlayer localplayer = this.worldguard.wrapPlayer(player);
|
||||||
final ApplicableRegionSet regions = worldguard.getRegionManager(player.getWorld()).getApplicableRegions(location);
|
final ApplicableRegionSet regions = this.worldguard.getRegionManager(player.getWorld()).getApplicableRegions(location);
|
||||||
for (final ProtectedRegion region : regions) {
|
for (final ProtectedRegion region : regions) {
|
||||||
if (region.isOwner(localplayer)) {
|
if (region.isOwner(localplayer)) {
|
||||||
return region;
|
return region;
|
||||||
@ -70,12 +70,12 @@ public class Worldguard extends BukkitMaskManager implements Listener {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||||
final Player player = fp.parent;
|
final Player player = fp.parent;
|
||||||
final Location location = player.getLocation();
|
final Location location = player.getLocation();
|
||||||
final ProtectedRegion myregion = isowner(player, location);
|
final ProtectedRegion myregion = this.isowner(player, location);
|
||||||
if (myregion != null) {
|
if (myregion != null) {
|
||||||
final Location pos1 = new Location(location.getWorld(), myregion.getMinimumPoint().getBlockX(), myregion.getMinimumPoint().getBlockY(), myregion.getMinimumPoint().getBlockZ());
|
final Location pos1 = new Location(location.getWorld(), myregion.getMinimumPoint().getBlockX(), myregion.getMinimumPoint().getBlockY(), myregion.getMinimumPoint().getBlockZ());
|
||||||
final Location pos2 = new Location(location.getWorld(), myregion.getMaximumPoint().getBlockX(), myregion.getMaximumPoint().getBlockY(), myregion.getMaximumPoint().getBlockZ());
|
final Location pos2 = new Location(location.getWorld(), myregion.getMaximumPoint().getBlockX(), myregion.getMaximumPoint().getBlockY(), myregion.getMaximumPoint().getBlockZ());
|
||||||
@ -88,6 +88,6 @@ public class Worldguard extends BukkitMaskManager implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,24 +8,24 @@ import com.sk89q.worldedit.extent.Extent;
|
|||||||
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
||||||
|
|
||||||
public class BukkitEditSessionWrapper_0 extends EditSessionWrapper {
|
public class BukkitEditSessionWrapper_0 extends EditSessionWrapper {
|
||||||
|
|
||||||
private BlocksHubHook hook;
|
private BlocksHubHook hook;
|
||||||
|
|
||||||
public BukkitEditSessionWrapper_0(EditSession session) {
|
public BukkitEditSessionWrapper_0(final EditSession session) {
|
||||||
super(session);
|
super(session);
|
||||||
try {
|
try {
|
||||||
this.hook = new BlocksHubHook();
|
this.hook = new BlocksHubHook();
|
||||||
} catch (Throwable e) {
|
} catch (final Throwable e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Extent getHistoryExtent(Extent parent, ChangeSet set, FawePlayer<?> player) {
|
public Extent getHistoryExtent(final Extent parent, final ChangeSet set, final FawePlayer<?> player) {
|
||||||
if (hook != null) {
|
if (this.hook != null) {
|
||||||
return hook.getLoggingExtent(parent, set, player);
|
return this.hook.getLoggingExtent(parent, set, player);
|
||||||
}
|
}
|
||||||
return super.getHistoryExtent(parent, set, player);
|
return super.getHistoryExtent(parent, set, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ import com.boydti.fawe.util.TaskManager;
|
|||||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||||
|
|
||||||
public abstract class BukkitQueue_0 extends FaweQueue implements Listener {
|
public abstract class BukkitQueue_0 extends FaweQueue implements Listener {
|
||||||
|
|
||||||
private final HashMap<String, HashSet<Long>> loaded = new HashMap<>();
|
private final HashMap<String, HashSet<Long>> loaded = new HashMap<>();
|
||||||
|
|
||||||
public BukkitQueue_0() {
|
public BukkitQueue_0() {
|
||||||
@ -41,77 +41,77 @@ public abstract class BukkitQueue_0 extends FaweQueue implements Listener {
|
|||||||
Bukkit.getPluginManager().registerEvents(BukkitQueue_0.this, (Plugin) Fawe.imp());
|
Bukkit.getPluginManager().registerEvents(BukkitQueue_0.this, (Plugin) Fawe.imp());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
for (World world : Bukkit.getWorlds()) {
|
for (final World world : Bukkit.getWorlds()) {
|
||||||
for (Chunk chunk : world.getLoadedChunks()) {
|
for (final Chunk chunk : world.getLoadedChunks()) {
|
||||||
addLoaded(chunk);
|
this.addLoaded(chunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||||
public void onWorldLoad(WorldLoadEvent event) {
|
public void onWorldLoad(final WorldLoadEvent event) {
|
||||||
World world = event.getWorld();
|
final World world = event.getWorld();
|
||||||
for (Chunk chunk : world.getLoadedChunks()) {
|
for (final Chunk chunk : world.getLoadedChunks()) {
|
||||||
addLoaded(chunk);
|
this.addLoaded(chunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||||
public void onWorldUnload(WorldUnloadEvent event) {
|
public void onWorldUnload(final WorldUnloadEvent event) {
|
||||||
loaded.remove(event.getWorld().getName());
|
this.loaded.remove(event.getWorld().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addLoaded(Chunk chunk) {
|
public void addLoaded(final Chunk chunk) {
|
||||||
String world = chunk.getWorld().getName();
|
final String world = chunk.getWorld().getName();
|
||||||
long x = chunk.getX();
|
final long x = chunk.getX();
|
||||||
long z = chunk.getZ();
|
final long z = chunk.getZ();
|
||||||
long id = x << 32 | z & 0xFFFFFFFFL;
|
final long id = (x << 32) | (z & 0xFFFFFFFFL);
|
||||||
HashSet<Long> map = loaded.get(world);
|
HashSet<Long> map = this.loaded.get(world);
|
||||||
if (map != null) {
|
if (map != null) {
|
||||||
map.add(id);
|
map.add(id);
|
||||||
} else {
|
} else {
|
||||||
map = new HashSet<>(Arrays.asList(id));
|
map = new HashSet<>(Arrays.asList(id));
|
||||||
loaded.put(world, map);
|
this.loaded.put(world, map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeLoaded(Chunk chunk) {
|
public void removeLoaded(final Chunk chunk) {
|
||||||
String world = chunk.getWorld().getName();
|
final String world = chunk.getWorld().getName();
|
||||||
long x = chunk.getX();
|
final long x = chunk.getX();
|
||||||
long z = chunk.getZ();
|
final long z = chunk.getZ();
|
||||||
long id = x << 32 | z & 0xFFFFFFFFL;
|
final long id = (x << 32) | (z & 0xFFFFFFFFL);
|
||||||
HashSet<Long> map = loaded.get(world);
|
final HashSet<Long> map = this.loaded.get(world);
|
||||||
if (map != null) {
|
if (map != null) {
|
||||||
map.remove(id);
|
map.remove(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isChunkLoaded(String world, int x, int z) {
|
public boolean isChunkLoaded(final String world, final int x, final int z) {
|
||||||
long id = (long) x << 32 | z & 0xFFFFFFFFL;
|
final long id = ((long) x << 32) | (z & 0xFFFFFFFFL);
|
||||||
HashSet<Long> map = loaded.get(world);
|
final HashSet<Long> map = this.loaded.get(world);
|
||||||
if (map != null) {
|
if (map != null) {
|
||||||
return map.contains(id);
|
return map.contains(id);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||||
public void onChunkLoad(ChunkLoadEvent event) {
|
public void onChunkLoad(final ChunkLoadEvent event) {
|
||||||
Chunk chunk = event.getChunk();
|
final Chunk chunk = event.getChunk();
|
||||||
addLoaded(chunk);
|
this.addLoaded(chunk);
|
||||||
if (Settings.FIX_ALL_LIGHTING) {
|
if (Settings.FIX_ALL_LIGHTING) {
|
||||||
fixLighting(getChunk(new ChunkLoc(chunk.getWorld().getName(), chunk.getX(), chunk.getZ())), false);
|
this.fixLighting(this.getChunk(new ChunkLoc(chunk.getWorld().getName(), chunk.getX(), chunk.getZ())), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||||
public void onChunkUnload(ChunkUnloadEvent event) {
|
public void onChunkUnload(final ChunkUnloadEvent event) {
|
||||||
removeLoaded(event.getChunk());
|
this.removeLoaded(event.getChunk());
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ConcurrentHashMap<ChunkLoc, FaweChunk<Chunk>> blocks = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<ChunkLoc, FaweChunk<Chunk>> blocks = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(final String world, int x, final int y, int z, final short id, final byte data) {
|
public boolean setBlock(final String world, int x, final int y, int z, final short id, final byte data) {
|
||||||
if ((y > 255) || (y < 0)) {
|
if ((y > 255) || (y < 0)) {
|
||||||
@ -120,61 +120,61 @@ public abstract class BukkitQueue_0 extends FaweQueue implements Listener {
|
|||||||
final ChunkLoc wrap = new ChunkLoc(world, x >> 4, z >> 4);
|
final ChunkLoc wrap = new ChunkLoc(world, x >> 4, z >> 4);
|
||||||
x = x & 15;
|
x = x & 15;
|
||||||
z = z & 15;
|
z = z & 15;
|
||||||
FaweChunk<Chunk> result = blocks.get(wrap);
|
FaweChunk<Chunk> result = this.blocks.get(wrap);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
result = getChunk(wrap);
|
result = this.getChunk(wrap);
|
||||||
result.setBlock(x, y, z, id, data);
|
result.setBlock(x, y, z, id, data);
|
||||||
final FaweChunk<Chunk> previous = blocks.put(wrap, result);
|
final FaweChunk<Chunk> previous = this.blocks.put(wrap, result);
|
||||||
if (previous == null) {
|
if (previous == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
blocks.put(wrap, previous);
|
this.blocks.put(wrap, previous);
|
||||||
result = previous;
|
result = previous;
|
||||||
}
|
}
|
||||||
result.setBlock(x, y, z, id, data);
|
result.setBlock(x, y, z, id, data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(String world, int x, int z, BaseBiome biome) {
|
public boolean setBiome(final String world, int x, int z, final BaseBiome biome) {
|
||||||
final ChunkLoc wrap = new ChunkLoc(world, x >> 4, z >> 4);
|
final ChunkLoc wrap = new ChunkLoc(world, x >> 4, z >> 4);
|
||||||
x = x & 15;
|
x = x & 15;
|
||||||
z = z & 15;
|
z = z & 15;
|
||||||
FaweChunk<Chunk> result = blocks.get(wrap);
|
FaweChunk<Chunk> result = this.blocks.get(wrap);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
result = getChunk(wrap);
|
result = this.getChunk(wrap);
|
||||||
final FaweChunk<Chunk> previous = blocks.put(wrap, result);
|
final FaweChunk<Chunk> previous = this.blocks.put(wrap, result);
|
||||||
if (previous != null) {
|
if (previous != null) {
|
||||||
blocks.put(wrap, previous);
|
this.blocks.put(wrap, previous);
|
||||||
result = previous;
|
result = previous;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result.setBiome(x, z, biome);
|
result.setBiome(x, z, biome);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FaweChunk<Chunk> next() {
|
public FaweChunk<Chunk> next() {
|
||||||
try {
|
try {
|
||||||
if (blocks.size() == 0) {
|
if (this.blocks.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final Iterator<Entry<ChunkLoc, FaweChunk<Chunk>>> iter = blocks.entrySet().iterator();
|
final Iterator<Entry<ChunkLoc, FaweChunk<Chunk>>> iter = this.blocks.entrySet().iterator();
|
||||||
final FaweChunk<Chunk> toReturn = iter.next().getValue();
|
final FaweChunk<Chunk> toReturn = iter.next().getValue();
|
||||||
if (SetQueue.IMP.isWaiting()) {
|
if (SetQueue.IMP.isWaiting()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
iter.remove();
|
iter.remove();
|
||||||
execute(toReturn);
|
this.execute(toReturn);
|
||||||
return toReturn;
|
return toReturn;
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ArrayDeque<FaweChunk<Chunk>> toUpdate = new ArrayDeque<>();
|
private final ArrayDeque<FaweChunk<Chunk>> toUpdate = new ArrayDeque<>();
|
||||||
|
|
||||||
public boolean execute(final FaweChunk<Chunk> fc) {
|
public boolean execute(final FaweChunk<Chunk> fc) {
|
||||||
if (fc == null) {
|
if (fc == null) {
|
||||||
return false;
|
return false;
|
||||||
@ -183,29 +183,29 @@ public abstract class BukkitQueue_0 extends FaweQueue implements Listener {
|
|||||||
final Chunk chunk = fc.getChunk();
|
final Chunk chunk = fc.getChunk();
|
||||||
chunk.load(true);
|
chunk.load(true);
|
||||||
// Set blocks / entities / biome
|
// Set blocks / entities / biome
|
||||||
if (!setComponents(fc)) {
|
if (!this.setComponents(fc)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
blocks.clear();
|
this.blocks.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setChunk(FaweChunk<?> chunk) {
|
public void setChunk(final FaweChunk<?> chunk) {
|
||||||
blocks.put(chunk.getChunkLoc(), (FaweChunk<Chunk>) chunk);
|
this.blocks.put(chunk.getChunkLoc(), (FaweChunk<Chunk>) chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Collection<FaweChunk<Chunk>> sendChunk(final Collection<FaweChunk<Chunk>> fcs);
|
public abstract Collection<FaweChunk<Chunk>> sendChunk(final Collection<FaweChunk<Chunk>> fcs);
|
||||||
|
|
||||||
public abstract boolean setComponents(final FaweChunk<Chunk> fc);
|
public abstract boolean setComponents(final FaweChunk<Chunk> fc);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract FaweChunk<Chunk> getChunk(final ChunkLoc wrap);
|
public abstract FaweChunk<Chunk> getChunk(final ChunkLoc wrap);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract boolean fixLighting(FaweChunk<?> fc, boolean fixAll);
|
public abstract boolean fixLighting(final FaweChunk<?> fc, final boolean fixAll);
|
||||||
}
|
}
|
||||||
|
@ -11,57 +11,57 @@ import com.boydti.fawe.object.FaweChunk;
|
|||||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||||
|
|
||||||
public class BukkitChunk_1_8 extends FaweChunk<Chunk> {
|
public class BukkitChunk_1_8 extends FaweChunk<Chunk> {
|
||||||
|
|
||||||
private char[][] ids;
|
private char[][] ids;
|
||||||
|
|
||||||
private final short[] count;
|
private final short[] count;
|
||||||
private final short[] air;
|
private final short[] air;
|
||||||
private final short[] relight;
|
private final short[] relight;
|
||||||
private int[][] biomes;
|
private int[][] biomes;
|
||||||
|
|
||||||
public Chunk chunk;
|
public Chunk chunk;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A FaweSections object represents a chunk and the blocks that you wish to change in it.
|
* A FaweSections object represents a chunk and the blocks that you wish to change in it.
|
||||||
*/
|
*/
|
||||||
protected BukkitChunk_1_8(final ChunkLoc chunk) {
|
protected BukkitChunk_1_8(final ChunkLoc chunk) {
|
||||||
super(chunk);
|
super(chunk);
|
||||||
ids = new char[16][];
|
this.ids = new char[16][];
|
||||||
count = new short[16];
|
this.count = new short[16];
|
||||||
air = new short[16];
|
this.air = new short[16];
|
||||||
relight = new short[16];
|
this.relight = new short[16];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Chunk getChunk() {
|
public Chunk getChunk() {
|
||||||
if (chunk == null) {
|
if (this.chunk == null) {
|
||||||
final ChunkLoc cl = getChunkLoc();
|
final ChunkLoc cl = this.getChunkLoc();
|
||||||
chunk = Bukkit.getWorld(cl.world).getChunkAt(cl.x, cl.z);
|
this.chunk = Bukkit.getWorld(cl.world).getChunkAt(cl.x, cl.z);
|
||||||
}
|
}
|
||||||
return chunk;
|
return this.chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setChunkLoc(final ChunkLoc loc) {
|
public void setChunkLoc(final ChunkLoc loc) {
|
||||||
super.setChunkLoc(loc);
|
super.setChunkLoc(loc);
|
||||||
chunk = null;
|
this.chunk = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of block changes in a specified section
|
* Get the number of block changes in a specified section
|
||||||
* @param i
|
* @param i
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int getCount(final int i) {
|
public int getCount(final int i) {
|
||||||
return count[i];
|
return this.count[i];
|
||||||
}
|
|
||||||
|
|
||||||
public int getAir(final int i) {
|
|
||||||
return air[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCount(int i, short value) {
|
public int getAir(final int i) {
|
||||||
count[i] = value;
|
return this.air[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCount(final int i, final short value) {
|
||||||
|
this.count[i] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -70,61 +70,62 @@ public class BukkitChunk_1_8 extends FaweChunk<Chunk> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int getRelight(final int i) {
|
public int getRelight(final int i) {
|
||||||
return relight[i];
|
return this.relight[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTotalCount() {
|
public int getTotalCount() {
|
||||||
int total = 0;
|
int total = 0;
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
total += count[i];
|
total += this.count[i];
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTotalRelight() {
|
public int getTotalRelight() {
|
||||||
if (getTotalCount() == 0 && biomes == null) {
|
if ((this.getTotalCount() == 0) && (this.biomes == null)) {
|
||||||
Arrays.fill(count, (short) 1);
|
Arrays.fill(this.count, (short) 1);
|
||||||
Arrays.fill(relight, Short.MAX_VALUE);
|
Arrays.fill(this.relight, Short.MAX_VALUE);
|
||||||
return Short.MAX_VALUE;
|
return Short.MAX_VALUE;
|
||||||
}
|
}
|
||||||
int total = 0;
|
int total = 0;
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
total += relight[i];
|
total += this.relight[i];
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the raw data for a section
|
* Get the raw data for a section
|
||||||
* @param i
|
* @param i
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public char[] getIdArray(final int i) {
|
public char[] getIdArray(final int i) {
|
||||||
return ids[i];
|
return this.ids[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
ids = null;
|
this.ids = null;
|
||||||
biomes = null;
|
this.biomes = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[][] getBiomeArray() {
|
public int[][] getBiomeArray() {
|
||||||
return biomes;
|
return this.biomes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBlock(final int x, final int y, final int z, final int id, byte data) {
|
public void setBlock(final int x, final int y, final int z, final int id, byte data) {
|
||||||
final int i = FaweCache.CACHE_I[y][x][z];
|
final int i = FaweCache.CACHE_I[y][x][z];
|
||||||
final int j = FaweCache.CACHE_J[y][x][z];
|
final int j = FaweCache.CACHE_J[y][x][z];
|
||||||
char[] vs = ids[i];
|
char[] vs = this.ids[i];
|
||||||
if (vs == null) {
|
if (vs == null) {
|
||||||
vs = ids[i] = new char[4096];
|
vs = this.ids[i] = new char[4096];
|
||||||
count[i]++;
|
this.count[i]++;
|
||||||
} else if (vs[j] == 0) {
|
} else if (vs[j] == 0) {
|
||||||
count[i]++;
|
this.count[i]++;
|
||||||
}
|
}
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 0:
|
case 0:
|
||||||
air[i]++;
|
this.air[i]++;
|
||||||
vs[j] = (char) 1;
|
vs[j] = (char) 1;
|
||||||
return;
|
return;
|
||||||
case 10:
|
case 10:
|
||||||
@ -138,7 +139,7 @@ public class BukkitChunk_1_8 extends FaweChunk<Chunk> {
|
|||||||
case 124:
|
case 124:
|
||||||
case 138:
|
case 138:
|
||||||
case 169:
|
case 169:
|
||||||
relight[i]++;
|
this.relight[i]++;
|
||||||
case 2:
|
case 2:
|
||||||
case 4:
|
case 4:
|
||||||
case 13:
|
case 13:
|
||||||
@ -201,7 +202,7 @@ public class BukkitChunk_1_8 extends FaweChunk<Chunk> {
|
|||||||
case 130:
|
case 130:
|
||||||
case 76:
|
case 76:
|
||||||
case 62:
|
case 62:
|
||||||
relight[i]++;
|
this.relight[i]++;
|
||||||
case 54:
|
case 54:
|
||||||
case 146:
|
case 146:
|
||||||
case 61:
|
case 61:
|
||||||
@ -216,15 +217,15 @@ public class BukkitChunk_1_8 extends FaweChunk<Chunk> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBiome(int x, int z, BaseBiome biome) {
|
public void setBiome(final int x, final int z, final BaseBiome biome) {
|
||||||
if (biomes == null) {
|
if (this.biomes == null) {
|
||||||
biomes = new int[16][];
|
this.biomes = new int[16][];
|
||||||
}
|
}
|
||||||
int[] index = biomes[x];
|
int[] index = this.biomes[x];
|
||||||
if (index == null) {
|
if (index == null) {
|
||||||
index = biomes[x] = new int[16];
|
index = this.biomes[x] = new int[16];
|
||||||
}
|
}
|
||||||
index[z] = biome.getId();
|
index[z] = biome.getId();
|
||||||
}
|
}
|
||||||
|
@ -13,50 +13,50 @@ import com.sk89q.worldedit.Vector;
|
|||||||
import com.sk89q.worldedit.blocks.BlockType;
|
import com.sk89q.worldedit.blocks.BlockType;
|
||||||
|
|
||||||
public class BukkitEditSessionWrapper_1_8 extends BukkitEditSessionWrapper_0 {
|
public class BukkitEditSessionWrapper_1_8 extends BukkitEditSessionWrapper_0 {
|
||||||
|
|
||||||
private final RefClass classCraftWorld = getRefClass("{cb}.CraftWorld");
|
private final RefClass classCraftWorld = getRefClass("{cb}.CraftWorld");
|
||||||
private final RefClass classChunk = getRefClass("{nms}.Chunk");
|
private final RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||||
private final RefClass classWorld = getRefClass("{nms}.World");
|
private final RefClass classWorld = getRefClass("{nms}.World");
|
||||||
|
|
||||||
private RefMethod worldGetHandle;
|
private RefMethod worldGetHandle;
|
||||||
private RefMethod methodGetChunkAt;
|
private RefMethod methodGetChunkAt;
|
||||||
private RefField heightMap;
|
private RefField heightMap;
|
||||||
private Object nmsWorld;
|
private Object nmsWorld;
|
||||||
|
|
||||||
private int lastXMin;
|
private int lastXMin;
|
||||||
private int lastZMin;
|
private int lastZMin;
|
||||||
private Object lastChunk;
|
private Object lastChunk;
|
||||||
|
|
||||||
public BukkitEditSessionWrapper_1_8(final EditSession session) {
|
public BukkitEditSessionWrapper_1_8(final EditSession session) {
|
||||||
super(session);
|
super(session);
|
||||||
try {
|
try {
|
||||||
worldGetHandle = classCraftWorld.getMethod("getHandle");
|
this.worldGetHandle = this.classCraftWorld.getMethod("getHandle");
|
||||||
methodGetChunkAt = classWorld.getMethod("getChunkAt", int.class, int.class);
|
this.methodGetChunkAt = this.classWorld.getMethod("getChunkAt", int.class, int.class);
|
||||||
heightMap = classChunk.getField("heightMap");
|
this.heightMap = this.classChunk.getField("heightMap");
|
||||||
nmsWorld = worldGetHandle.of(Bukkit.getWorld(session.getWorld().getName())).call();
|
this.nmsWorld = this.worldGetHandle.of(Bukkit.getWorld(session.getWorld().getName())).call();
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHighestTerrainBlock(final int x, final int z, final int minY, final int maxY, final boolean naturalOnly) {
|
public int getHighestTerrainBlock(final int x, final int z, final int minY, final int maxY, final boolean naturalOnly) {
|
||||||
final int bx = x >> 4;
|
final int bx = x >> 4;
|
||||||
final int bz = z >> 4;
|
final int bz = z >> 4;
|
||||||
int[] heights;
|
int[] heights;
|
||||||
if ((lastChunk == null) || (bx != lastXMin) || (bz != lastZMin)) {
|
if ((this.lastChunk == null) || (bx != this.lastXMin) || (bz != this.lastZMin)) {
|
||||||
lastXMin = bx;
|
this.lastXMin = bx;
|
||||||
lastZMin = bz;
|
this.lastZMin = bz;
|
||||||
lastChunk = methodGetChunkAt.of(nmsWorld).call(bx, bz);
|
this.lastChunk = this.methodGetChunkAt.of(this.nmsWorld).call(bx, bz);
|
||||||
}
|
}
|
||||||
if (lastChunk != null) {
|
if (this.lastChunk != null) {
|
||||||
heights = (int[]) heightMap.of(lastChunk).get();
|
heights = (int[]) this.heightMap.of(this.lastChunk).get();
|
||||||
final int lx = x & 15;
|
final int lx = x & 15;
|
||||||
final int lz = z & 15;
|
final int lz = z & 15;
|
||||||
final int height = heights[((lz << 4) | lx)];
|
final int height = heights[((lz << 4) | lx)];
|
||||||
if ((height <= maxY) && (height >= minY)) {
|
if ((height <= maxY) && (height >= minY)) {
|
||||||
final Vector pt = new Vector(x, height, z);
|
final Vector pt = new Vector(x, height, z);
|
||||||
final int id = session.getBlockType(pt);
|
final int id = this.session.getBlockType(pt);
|
||||||
if (naturalOnly ? BlockType.isNaturalTerrainBlock(id, 0) : !BlockType.canPassThrough(id, 0)) {
|
if (naturalOnly ? BlockType.isNaturalTerrainBlock(id, 0) : !BlockType.canPassThrough(id, 0)) {
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ public class BukkitEditSessionWrapper_1_8 extends BukkitEditSessionWrapper_0 {
|
|||||||
}
|
}
|
||||||
for (int y = maxY; y >= minY; --y) {
|
for (int y = maxY; y >= minY; --y) {
|
||||||
final Vector pt = new Vector(x, y, z);
|
final Vector pt = new Vector(x, y, z);
|
||||||
final int id = session.getBlockType(pt);
|
final int id = this.session.getBlockType(pt);
|
||||||
int data;
|
int data;
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 0: {
|
case 0: {
|
||||||
@ -160,5 +160,5 @@ public class BukkitEditSessionWrapper_1_8 extends BukkitEditSessionWrapper_0 {
|
|||||||
}
|
}
|
||||||
return minY;
|
return minY;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ import com.sk89q.worldedit.bukkit.BukkitUtil;
|
|||||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||||
|
|
||||||
public class BukkitQueue_1_8 extends BukkitQueue_0 {
|
public class BukkitQueue_1_8 extends BukkitQueue_0 {
|
||||||
|
|
||||||
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");
|
||||||
private final RefClass classPacket = getRefClass("{nms}.Packet");
|
private final RefClass classPacket = getRefClass("{nms}.Packet");
|
||||||
@ -56,10 +56,10 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
|
|||||||
private final RefClass classCraftPlayer = getRefClass("{cb}.entity.CraftPlayer");
|
private final RefClass classCraftPlayer = getRefClass("{cb}.entity.CraftPlayer");
|
||||||
private final RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
private final RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
||||||
private final RefClass classWorld = getRefClass("{nms}.World");
|
private final RefClass classWorld = getRefClass("{nms}.World");
|
||||||
private final RefField mustSave = classChunk.getField("mustSave");
|
private final RefField mustSave = this.classChunk.getField("mustSave");
|
||||||
private final RefClass classBlockPosition = getRefClass("{nms}.BlockPosition");
|
private final RefClass classBlockPosition = getRefClass("{nms}.BlockPosition");
|
||||||
private final RefClass classChunkSection = getRefClass("{nms}.ChunkSection");
|
private final RefClass classChunkSection = getRefClass("{nms}.ChunkSection");
|
||||||
|
|
||||||
private RefMethod methodGetHandlePlayer;
|
private RefMethod methodGetHandlePlayer;
|
||||||
private RefMethod methodGetHandleChunk;
|
private RefMethod methodGetHandleChunk;
|
||||||
private RefConstructor MapChunk;
|
private RefConstructor MapChunk;
|
||||||
@ -75,52 +75,52 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
|
|||||||
private RefMethod methodGetIdArray;
|
private RefMethod methodGetIdArray;
|
||||||
private RefMethod methodGetWorld;
|
private RefMethod methodGetWorld;
|
||||||
private RefField tileEntityListTick;
|
private RefField tileEntityListTick;
|
||||||
|
|
||||||
private final HashMap<String, FaweGenerator_1_8> worldMap = new HashMap<>();
|
private final HashMap<String, FaweGenerator_1_8> worldMap = new HashMap<>();
|
||||||
|
|
||||||
public BukkitQueue_1_8() {
|
public BukkitQueue_1_8() {
|
||||||
try {
|
try {
|
||||||
methodGetHandlePlayer = classCraftPlayer.getMethod("getHandle");
|
this.methodGetHandlePlayer = this.classCraftPlayer.getMethod("getHandle");
|
||||||
methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
|
this.methodGetHandleChunk = this.classCraftChunk.getMethod("getHandle");
|
||||||
methodInitLighting = classChunk.getMethod("initLighting");
|
this.methodInitLighting = this.classChunk.getMethod("initLighting");
|
||||||
MapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), boolean.class, int.class);
|
this.MapChunk = this.classMapChunk.getConstructor(this.classChunk.getRealClass(), boolean.class, int.class);
|
||||||
connection = classEntityPlayer.getField("playerConnection");
|
this.connection = this.classEntityPlayer.getField("playerConnection");
|
||||||
send = classConnection.getMethod("sendPacket", classPacket.getRealClass());
|
this.send = this.classConnection.getMethod("sendPacket", this.classPacket.getRealClass());
|
||||||
classBlockPositionConstructor = classBlockPosition.getConstructor(int.class, int.class, int.class);
|
this.classBlockPositionConstructor = this.classBlockPosition.getConstructor(int.class, int.class, int.class);
|
||||||
methodX = classWorld.getMethod("x", classBlockPosition.getRealClass());
|
this.methodX = this.classWorld.getMethod("x", this.classBlockPosition.getRealClass());
|
||||||
fieldSections = classChunk.getField("sections");
|
this.fieldSections = this.classChunk.getField("sections");
|
||||||
fieldWorld = classChunk.getField("world");
|
this.fieldWorld = this.classChunk.getField("world");
|
||||||
methodGetIdArray = classChunkSection.getMethod("getIdArray");
|
this.methodGetIdArray = this.classChunkSection.getMethod("getIdArray");
|
||||||
methodAreNeighborsLoaded = classChunk.getMethod("areNeighborsLoaded", int.class);
|
this.methodAreNeighborsLoaded = this.classChunk.getMethod("areNeighborsLoaded", int.class);
|
||||||
classChunkSectionConstructor = classChunkSection.getConstructor(int.class, boolean.class, char[].class);
|
this.classChunkSectionConstructor = this.classChunkSection.getConstructor(int.class, boolean.class, char[].class);
|
||||||
this.tileEntityListTick = classWorld.getField("tileEntityList");
|
this.tileEntityListTick = this.classWorld.getField("tileEntityList");
|
||||||
this.methodGetWorld = classChunk.getMethod("getWorld");
|
this.methodGetWorld = this.classChunk.getMethod("getWorld");
|
||||||
} catch (final NoSuchMethodException e) {
|
} catch (final NoSuchMethodException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public FaweGenerator_1_8 getFaweGenerator(final World world) {
|
public FaweGenerator_1_8 getFaweGenerator(final World world) {
|
||||||
final ChunkGenerator gen = world.getGenerator();
|
final ChunkGenerator gen = world.getGenerator();
|
||||||
if ((gen != null) && (gen instanceof FaweGenerator_1_8)) {
|
if ((gen != null) && (gen instanceof FaweGenerator_1_8)) {
|
||||||
return (FaweGenerator_1_8) gen;
|
return (FaweGenerator_1_8) gen;
|
||||||
}
|
}
|
||||||
FaweGenerator_1_8 faweGen = worldMap.get(world.getName());
|
FaweGenerator_1_8 faweGen = this.worldMap.get(world.getName());
|
||||||
if (faweGen != null) {
|
if (faweGen != null) {
|
||||||
return faweGen;
|
return faweGen;
|
||||||
}
|
}
|
||||||
faweGen = new FaweGenerator_1_8(this, world);
|
faweGen = new FaweGenerator_1_8(this, world);
|
||||||
worldMap.put(world.getName(), faweGen);
|
this.worldMap.put(world.getName(), faweGen);
|
||||||
return faweGen;
|
return faweGen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<FaweChunk<Chunk>> sendChunk(final Collection<FaweChunk<Chunk>> fcs) {
|
public Collection<FaweChunk<Chunk>> sendChunk(final Collection<FaweChunk<Chunk>> fcs) {
|
||||||
final HashMap<FaweChunk<Chunk>, Object> packets = new HashMap<>();
|
final HashMap<FaweChunk<Chunk>, Object> packets = new HashMap<>();
|
||||||
final HashMap<String, ArrayList<FaweChunk<Chunk>>> map = new HashMap<>();
|
final HashMap<String, ArrayList<FaweChunk<Chunk>>> map = new HashMap<>();
|
||||||
|
|
||||||
for (final FaweChunk<Chunk> fc : fcs) {
|
for (final FaweChunk<Chunk> fc : fcs) {
|
||||||
String world = fc.getChunkLoc().world;
|
final String world = fc.getChunkLoc().world;
|
||||||
ArrayList<FaweChunk<Chunk>> list = map.get(world);
|
ArrayList<FaweChunk<Chunk>> list = map.get(world);
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
list = new ArrayList<>();
|
list = new ArrayList<>();
|
||||||
@ -138,19 +138,19 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
|
|||||||
final Location loc = player.getLocation();
|
final Location loc = player.getLocation();
|
||||||
final int cx = loc.getBlockX() >> 4;
|
final int cx = loc.getBlockX() >> 4;
|
||||||
final int cz = loc.getBlockZ() >> 4;
|
final int cz = loc.getBlockZ() >> 4;
|
||||||
final Object entity = methodGetHandlePlayer.of(player).call();
|
final Object entity = this.methodGetHandlePlayer.of(player).call();
|
||||||
|
|
||||||
for (final FaweChunk<Chunk> fc : list) {
|
for (final FaweChunk<Chunk> fc : list) {
|
||||||
final int dx = Math.abs(cx - fc.getChunkLoc().x);
|
final int dx = Math.abs(cx - fc.getChunkLoc().x);
|
||||||
final int dz = Math.abs(cz - fc.getChunkLoc().z);
|
final int dz = Math.abs(cz - fc.getChunkLoc().z);
|
||||||
if ((dx > view) || (dz > view)) {
|
if ((dx > view) || (dz > view)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
RefExecutor con = send.of(connection.of(entity).get());
|
final RefExecutor con = this.send.of(this.connection.of(entity).get());
|
||||||
Object packet = packets.get(fc);
|
Object packet = packets.get(fc);
|
||||||
if (packet == null) {
|
if (packet == null) {
|
||||||
final Object c = methodGetHandleChunk.of(fc.getChunk()).call();
|
final Object c = this.methodGetHandleChunk.of(fc.getChunk()).call();
|
||||||
packet = MapChunk.create(c, true, 65535);
|
packet = this.MapChunk.create(c, true, 65535);
|
||||||
packets.put(fc, packet);
|
packets.put(fc, packet);
|
||||||
con.call(packet);
|
con.call(packet);
|
||||||
} else {
|
} else {
|
||||||
@ -159,53 +159,53 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
final HashSet<FaweChunk<Chunk>> chunks = new HashSet<FaweChunk<Chunk>>();
|
final HashSet<FaweChunk<Chunk>> chunks = new HashSet<FaweChunk<Chunk>>();
|
||||||
for (FaweChunk<Chunk> fc : fcs) {
|
for (final FaweChunk<Chunk> fc : fcs) {
|
||||||
Chunk chunk = fc.getChunk();
|
final Chunk chunk = fc.getChunk();
|
||||||
chunk.unload(true, false);
|
chunk.unload(true, false);
|
||||||
chunk.load();
|
chunk.load();
|
||||||
ChunkLoc loc = fc.getChunkLoc();
|
final ChunkLoc loc = fc.getChunkLoc();
|
||||||
chunk.getWorld().refreshChunk(loc.x, loc.z);
|
chunk.getWorld().refreshChunk(loc.x, loc.z);
|
||||||
if (!fixLighting(fc, Settings.FIX_ALL_LIGHTING)) {
|
if (!this.fixLighting(fc, Settings.FIX_ALL_LIGHTING)) {
|
||||||
chunks.add(fc);
|
chunks.add(fc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return chunks;
|
return chunks;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean fixLighting(final FaweChunk<?> fc, boolean fixAll) {
|
public boolean fixLighting(final FaweChunk<?> fc, final boolean fixAll) {
|
||||||
try {
|
try {
|
||||||
BukkitChunk_1_8 bc = (BukkitChunk_1_8) fc;
|
final BukkitChunk_1_8 bc = (BukkitChunk_1_8) fc;
|
||||||
final Chunk chunk = bc.getChunk();
|
final Chunk chunk = bc.getChunk();
|
||||||
if (!chunk.isLoaded()) {
|
if (!chunk.isLoaded()) {
|
||||||
chunk.load(false);
|
chunk.load(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize lighting
|
|
||||||
final Object c = methodGetHandleChunk.of(chunk).call();
|
|
||||||
|
|
||||||
methodInitLighting.of(c).call();
|
|
||||||
|
|
||||||
if ((bc.getTotalRelight() == 0 && !fixAll)) {
|
// Initialize lighting
|
||||||
|
final Object c = this.methodGetHandleChunk.of(chunk).call();
|
||||||
|
|
||||||
|
this.methodInitLighting.of(c).call();
|
||||||
|
|
||||||
|
if (((bc.getTotalRelight() == 0) && !fixAll)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Object[] sections = (Object[]) fieldSections.of(c).get();
|
final Object[] sections = (Object[]) this.fieldSections.of(c).get();
|
||||||
final Object w = fieldWorld.of(c).get();
|
final Object w = this.fieldWorld.of(c).get();
|
||||||
|
|
||||||
final int X = chunk.getX() << 4;
|
final int X = chunk.getX() << 4;
|
||||||
final int Z = chunk.getZ() << 4;
|
final int Z = chunk.getZ() << 4;
|
||||||
|
|
||||||
RefExecutor relight = methodX.of(w);
|
final RefExecutor relight = this.methodX.of(w);
|
||||||
for (int j = 0; j < sections.length; j++) {
|
for (int j = 0; j < sections.length; j++) {
|
||||||
final Object section = sections[j];
|
final Object section = sections[j];
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ((bc.getRelight(j) == 0 && !fixAll) || bc.getCount(j) == 0 || (bc.getCount(j) >= 4096 && bc.getAir(j) == 0)) {
|
if (((bc.getRelight(j) == 0) && !fixAll) || (bc.getCount(j) == 0) || ((bc.getCount(j) >= 4096) && (bc.getAir(j) == 0))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final char[] array = getIdArray(section);
|
final char[] array = this.getIdArray(section);
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -243,10 +243,10 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
|
|||||||
final int x = FaweCache.CACHE_X[j][k];
|
final int x = FaweCache.CACHE_X[j][k];
|
||||||
final int y = FaweCache.CACHE_Y[j][k];
|
final int y = FaweCache.CACHE_Y[j][k];
|
||||||
final int z = FaweCache.CACHE_Z[j][k];
|
final int z = FaweCache.CACHE_Z[j][k];
|
||||||
if (isSurrounded(sections, x, y, z)) {
|
if (this.isSurrounded(sections, x, y, z)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final Object pos = classBlockPositionConstructor.create(X + x, y, Z + z);
|
final Object pos = this.classBlockPositionConstructor.create(X + x, y, Z + z);
|
||||||
relight.call(pos);
|
relight.call(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -257,36 +257,36 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSurrounded(Object[] sections, int x, int y, int z) {
|
public boolean isSurrounded(final Object[] sections, final int x, final int y, final int z) {
|
||||||
return isSolid(getId(sections, x, y + 1, z))
|
return this.isSolid(this.getId(sections, x, y + 1, z))
|
||||||
&& isSolid(getId(sections, x + 1, y - 1, z))
|
&& this.isSolid(this.getId(sections, x + 1, y - 1, z))
|
||||||
&& isSolid(getId(sections, x - 1, y, z))
|
&& this.isSolid(this.getId(sections, x - 1, y, z))
|
||||||
&& isSolid(getId(sections, x, y, z + 1))
|
&& this.isSolid(this.getId(sections, x, y, z + 1))
|
||||||
&& isSolid(getId(sections, x, y, z - 1));
|
&& this.isSolid(this.getId(sections, x, y, z - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSolid(int i) {
|
public boolean isSolid(final int i) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return Material.getMaterial(i).isOccluding();
|
return Material.getMaterial(i).isOccluding();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId(Object[] sections, int x, int y, int z) {
|
public int getId(final Object[] sections, final int x, final int y, final int z) {
|
||||||
if (x < 0 || x > 15 || z < 0 || z > 15) {
|
if ((x < 0) || (x > 15) || (z < 0) || (z > 15)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (y < 0 || y > 255) {
|
if ((y < 0) || (y > 255)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
int i = FaweCache.CACHE_I[y][x][z];
|
final int i = FaweCache.CACHE_I[y][x][z];
|
||||||
Object section = sections[i];
|
final Object section = sections[i];
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
char[] array = getIdArray(section);
|
final char[] array = this.getIdArray(section);
|
||||||
int j = FaweCache.CACHE_J[y][x][z];
|
final int j = FaweCache.CACHE_J[y][x][z];
|
||||||
return array[j] >> 4;
|
return array[j] >> 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,27 +296,27 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
|
|||||||
final BukkitChunk_1_8 fs = ((BukkitChunk_1_8) fc);
|
final BukkitChunk_1_8 fs = ((BukkitChunk_1_8) fc);
|
||||||
final Chunk chunk = fs.getChunk();
|
final Chunk chunk = fs.getChunk();
|
||||||
final World world = chunk.getWorld();
|
final World world = chunk.getWorld();
|
||||||
|
|
||||||
final boolean flag = world.getEnvironment() == Environment.NORMAL;
|
final boolean flag = world.getEnvironment() == Environment.NORMAL;
|
||||||
|
|
||||||
// Sections
|
// Sections
|
||||||
final Method getHandele = chunk.getClass().getDeclaredMethod("getHandle");
|
final Method getHandele = chunk.getClass().getDeclaredMethod("getHandle");
|
||||||
final Object c = getHandele.invoke(chunk);
|
final Object c = getHandele.invoke(chunk);
|
||||||
Object w = methodGetWorld.of(c).call();
|
final Object w = this.methodGetWorld.of(c).call();
|
||||||
final Class<? extends Object> clazz = c.getClass();
|
final Class<? extends Object> clazz = c.getClass();
|
||||||
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 ef = 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 Collection<?>[] entities = (Collection<?>[]) ef.get(c);
|
final Collection<?>[] entities = (Collection<?>[]) ef.get(c);
|
||||||
|
|
||||||
Method xm = null;
|
Method xm = null;
|
||||||
Method ym = null;
|
Method ym = null;
|
||||||
Method zm = null;
|
Method zm = null;
|
||||||
|
|
||||||
// Trim tiles
|
// Trim tiles
|
||||||
boolean removed = false;
|
boolean removed = false;
|
||||||
final Set<Entry<?, ?>> entryset = (Set<Entry<?, ?>>) (Set<?>) tiles.entrySet();
|
final Set<Entry<?, ?>> entryset = (Set<Entry<?, ?>>) (Set<?>) tiles.entrySet();
|
||||||
@ -347,14 +347,14 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
|
|||||||
if (removed) {
|
if (removed) {
|
||||||
((Collection) this.tileEntityListTick.of(w).get()).clear();
|
((Collection) this.tileEntityListTick.of(w).get()).clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trim entities
|
// Trim entities
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
if ((entities[i] != null) && (fs.getCount(i) >= 4096)) {
|
if ((entities[i] != null) && (fs.getCount(i) >= 4096)) {
|
||||||
entities[i].clear();
|
entities[i].clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Efficiently merge sections
|
// Efficiently merge sections
|
||||||
for (int j = 0; j < sections.length; j++) {
|
for (int j = 0; j < sections.length; j++) {
|
||||||
if (fs.getCount(j) == 0) {
|
if (fs.getCount(j) == 0) {
|
||||||
@ -366,10 +366,10 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
|
|||||||
}
|
}
|
||||||
Object section = sections[j];
|
Object section = sections[j];
|
||||||
if ((section == null) || (fs.getCount(j) >= 4096)) {
|
if ((section == null) || (fs.getCount(j) >= 4096)) {
|
||||||
section = sections[j] = newChunkSection(j << 4, flag, newArray);
|
section = sections[j] = this.newChunkSection(j << 4, flag, newArray);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final char[] currentArray = getIdArray(section);
|
final char[] currentArray = this.getIdArray(section);
|
||||||
boolean fill = true;
|
boolean fill = true;
|
||||||
for (int k = 0; k < newArray.length; k++) {
|
for (int k = 0; k < newArray.length; k++) {
|
||||||
final char n = newArray[k];
|
final char n = newArray[k];
|
||||||
@ -394,22 +394,22 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
|
|||||||
fs.setCount(j, Short.MAX_VALUE);
|
fs.setCount(j, Short.MAX_VALUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Biomes
|
// Biomes
|
||||||
int[][] biomes = fs.getBiomeArray();
|
final int[][] biomes = fs.getBiomeArray();
|
||||||
if (biomes != null) {
|
if (biomes != null) {
|
||||||
LocalWorld lw = BukkitUtil.getLocalWorld(world);
|
final LocalWorld lw = BukkitUtil.getLocalWorld(world);
|
||||||
int X = fs.getChunkLoc().x << 4;
|
final int X = fs.getChunkLoc().x << 4;
|
||||||
int Z = fs.getChunkLoc().z << 4;
|
final int Z = fs.getChunkLoc().z << 4;
|
||||||
BaseBiome bb = new BaseBiome(0);
|
final BaseBiome bb = new BaseBiome(0);
|
||||||
int last = 0;
|
int last = 0;
|
||||||
for (int x = 0; x < 16; x++) {
|
for (int x = 0; x < 16; x++) {
|
||||||
int[] array = biomes[x];
|
final int[] array = biomes[x];
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; z++) {
|
||||||
int biome = array[z];
|
final int biome = array[z];
|
||||||
if (biome == 0) {
|
if (biome == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -421,7 +421,7 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear
|
// Clear
|
||||||
fs.clear();
|
fs.clear();
|
||||||
return true;
|
return true;
|
||||||
@ -430,7 +430,7 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
super.clear();
|
super.clear();
|
||||||
@ -439,8 +439,8 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
|
|||||||
HashMap<String, HashMap<IntegerPair, Integer>> players = new HashMap<>();
|
HashMap<String, HashMap<IntegerPair, Integer>> players = new HashMap<>();
|
||||||
for (final Player player : Bukkit.getOnlinePlayers()) {
|
for (final Player player : Bukkit.getOnlinePlayers()) {
|
||||||
// Clear history
|
// Clear history
|
||||||
FawePlayer<Object> fp = FawePlayer.wrap(player);
|
final FawePlayer<Object> fp = FawePlayer.wrap(player);
|
||||||
LocalSession s = fp.getSession();
|
final LocalSession s = fp.getSession();
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
s.clearHistory();
|
s.clearHistory();
|
||||||
s.setClipboard(null);
|
s.setClipboard(null);
|
||||||
@ -490,7 +490,7 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
|
|||||||
final boolean save = world.isAutoSave();
|
final boolean save = world.isAutoSave();
|
||||||
world.setAutoSave(false);
|
world.setAutoSave(false);
|
||||||
for (final Chunk chunk : world.getLoadedChunks()) {
|
for (final Chunk chunk : world.getLoadedChunks()) {
|
||||||
unloadChunk(name, chunk);
|
this.unloadChunk(name, chunk);
|
||||||
}
|
}
|
||||||
world.setAutoSave(save);
|
world.setAutoSave(save);
|
||||||
continue;
|
continue;
|
||||||
@ -515,7 +515,7 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
|
|||||||
int free = MemUtil.calculateMemory();
|
int free = MemUtil.calculateMemory();
|
||||||
if (free <= 1) {
|
if (free <= 1) {
|
||||||
for (final Chunk chunk : toUnload) {
|
for (final Chunk chunk : toUnload) {
|
||||||
unloadChunk(chunk.getWorld().getName(), chunk);
|
this.unloadChunk(chunk.getWorld().getName(), chunk);
|
||||||
}
|
}
|
||||||
} else if (free == Integer.MAX_VALUE) {
|
} else if (free == Integer.MAX_VALUE) {
|
||||||
for (final Chunk chunk : toUnload) {
|
for (final Chunk chunk : toUnload) {
|
||||||
@ -546,35 +546,35 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
|
|||||||
for (final World world : Bukkit.getWorlds()) {
|
for (final World world : Bukkit.getWorlds()) {
|
||||||
final String name = world.getName();
|
final String name = world.getName();
|
||||||
for (final Chunk chunk : world.getLoadedChunks()) {
|
for (final Chunk chunk : world.getLoadedChunks()) {
|
||||||
unloadChunk(name, chunk);
|
this.unloadChunk(name, chunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.gc();
|
System.gc();
|
||||||
System.gc();
|
System.gc();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object newChunkSection(final int i, final boolean flag, final char[] ids) {
|
public Object newChunkSection(final int i, final boolean flag, final char[] ids) {
|
||||||
return classChunkSectionConstructor.create(i, flag, ids);
|
return this.classChunkSectionConstructor.create(i, flag, ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
public char[] getIdArray(final Object obj) {
|
public char[] getIdArray(final Object obj) {
|
||||||
return (char[]) methodGetIdArray.of(obj).call();
|
return (char[]) this.methodGetIdArray.of(obj).call();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FaweChunk<Chunk> getChunk(final ChunkLoc wrap) {
|
public FaweChunk<Chunk> getChunk(final ChunkLoc wrap) {
|
||||||
return new BukkitChunk_1_8(wrap);
|
return new BukkitChunk_1_8(wrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean unloadChunk(final String world, final Chunk chunk) {
|
public boolean unloadChunk(final String world, final Chunk chunk) {
|
||||||
final Object c = methodGetHandleChunk.of(chunk).call();
|
final Object c = this.methodGetHandleChunk.of(chunk).call();
|
||||||
mustSave.of(c).set(false);
|
this.mustSave.of(c).set(false);
|
||||||
if (chunk.isLoaded()) {
|
if (chunk.isLoaded()) {
|
||||||
chunk.unload(false, false);
|
chunk.unload(false, false);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChunkGenerator setGenerator(final World world, final ChunkGenerator newGen) {
|
public ChunkGenerator setGenerator(final World world, final ChunkGenerator newGen) {
|
||||||
try {
|
try {
|
||||||
final ChunkGenerator gen = world.getGenerator();
|
final ChunkGenerator gen = world.getGenerator();
|
||||||
@ -582,21 +582,21 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
|
|||||||
final Field generator = clazz.getDeclaredField("generator");
|
final Field generator = clazz.getDeclaredField("generator");
|
||||||
generator.setAccessible(true);
|
generator.setAccessible(true);
|
||||||
generator.set(world, newGen);
|
generator.set(world, newGen);
|
||||||
|
|
||||||
final Field wf = clazz.getDeclaredField("world");
|
final Field wf = clazz.getDeclaredField("world");
|
||||||
wf.setAccessible(true);
|
wf.setAccessible(true);
|
||||||
final Object w = wf.get(world);
|
final Object w = wf.get(world);
|
||||||
final Class<?> clazz2 = w.getClass().getSuperclass();
|
final Class<?> clazz2 = w.getClass().getSuperclass();
|
||||||
final Field generator2 = clazz2.getDeclaredField("generator");
|
final Field generator2 = clazz2.getDeclaredField("generator");
|
||||||
generator2.set(w, newGen);
|
generator2.set(w, newGen);
|
||||||
|
|
||||||
return gen;
|
return gen;
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BlockPopulator> setPopulator(final World world, final List<BlockPopulator> newPop) {
|
public List<BlockPopulator> setPopulator(final World world, final List<BlockPopulator> newPop) {
|
||||||
try {
|
try {
|
||||||
final List<BlockPopulator> pop = world.getPopulators();
|
final List<BlockPopulator> pop = world.getPopulators();
|
||||||
@ -609,21 +609,21 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEntitiesAndTiles(final Chunk chunk, final List<?>[] entities, final Map<?, ?> tiles) {
|
public void setEntitiesAndTiles(final Chunk chunk, final List<?>[] entities, final Map<?, ?> tiles) {
|
||||||
try {
|
try {
|
||||||
final Class<? extends Chunk> clazz = chunk.getClass();
|
final Class<? extends Chunk> clazz = chunk.getClass();
|
||||||
final Method handle = clazz.getMethod("getHandle");
|
final Method handle = clazz.getMethod("getHandle");
|
||||||
final Object c = handle.invoke(chunk);
|
final Object c = handle.invoke(chunk);
|
||||||
final Class<? extends Object> clazz2 = c.getClass();
|
final Class<? extends Object> clazz2 = c.getClass();
|
||||||
|
|
||||||
if (tiles.size() > 0) {
|
if (tiles.size() > 0) {
|
||||||
final Field tef = clazz2.getDeclaredField("tileEntities");
|
final Field tef = clazz2.getDeclaredField("tileEntities");
|
||||||
final Map<?, ?> te = (Map<?, ?>) tef.get(c);
|
final Map<?, ?> te = (Map<?, ?>) tef.get(c);
|
||||||
final Method put = te.getClass().getMethod("putAll", Map.class);
|
final Method put = te.getClass().getMethod("putAll", Map.class);
|
||||||
put.invoke(te, tiles);
|
put.invoke(te, tiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Field esf = clazz2.getDeclaredField("entitySlices");
|
final Field esf = clazz2.getDeclaredField("entitySlices");
|
||||||
esf.setAccessible(true);
|
esf.setAccessible(true);
|
||||||
esf.set(c, entities);
|
esf.set(c, entities);
|
||||||
@ -631,7 +631,7 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getProvider(final World world) {
|
public Object getProvider(final World world) {
|
||||||
try {
|
try {
|
||||||
// Provider 1
|
// Provider 1
|
||||||
@ -654,7 +654,7 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object setProvider(final World world, Object newProvider) {
|
public Object setProvider(final World world, Object newProvider) {
|
||||||
try {
|
try {
|
||||||
// Provider 1
|
// Provider 1
|
||||||
|
@ -30,28 +30,28 @@ import com.boydti.fawe.object.ChunkLoc;
|
|||||||
|
|
||||||
public class FaweGenerator_1_8 extends ChunkGenerator implements Listener {
|
public class FaweGenerator_1_8 extends ChunkGenerator implements Listener {
|
||||||
private boolean events;
|
private boolean events;
|
||||||
|
|
||||||
private final ChunkGenerator parent;
|
private final ChunkGenerator parent;
|
||||||
private final List<BlockPopulator> pops;
|
private final List<BlockPopulator> pops;
|
||||||
private final Object provider;
|
private final Object provider;
|
||||||
|
|
||||||
private short[][] ids;
|
private short[][] ids;
|
||||||
private byte[][] data;
|
private byte[][] data;
|
||||||
private Map<?, ?> tiles;
|
private Map<?, ?> tiles;
|
||||||
private List<?>[] entities;
|
private List<?>[] entities;
|
||||||
private Biome[][] biomes;
|
private Biome[][] biomes;
|
||||||
|
|
||||||
private final World world;
|
private final World world;
|
||||||
|
|
||||||
private final BukkitQueue_1_8 queue;
|
private final BukkitQueue_1_8 queue;
|
||||||
|
|
||||||
private void registerEvents() {
|
private void registerEvents() {
|
||||||
if (events) {
|
if (this.events) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Bukkit.getPluginManager().registerEvents(this, Fawe.<FaweBukkit> imp());
|
Bukkit.getPluginManager().registerEvents(this, Fawe.<FaweBukkit> imp());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
private void onPopulate(final ChunkPopulateEvent event) {
|
private void onPopulate(final ChunkPopulateEvent event) {
|
||||||
final World world = event.getWorld();
|
final World world = event.getWorld();
|
||||||
@ -62,20 +62,20 @@ public class FaweGenerator_1_8 extends ChunkGenerator implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fawe.populate(event.getChunk());
|
fawe.populate(event.getChunk());
|
||||||
decouple((FaweGenerator_1_8) gen, world);
|
this.decouple((FaweGenerator_1_8) gen, world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlock(final short[][] result, final int x, final int y, final int z, final short blkid) {
|
public void setBlock(final short[][] result, final int x, final int y, final int z, final short blkid) {
|
||||||
if (result[FaweCache.CACHE_I[y][x][z]] == null) {
|
if (result[FaweCache.CACHE_I[y][x][z]] == null) {
|
||||||
result[FaweCache.CACHE_I[y][x][z]] = new short[4096];
|
result[FaweCache.CACHE_I[y][x][z]] = new short[4096];
|
||||||
}
|
}
|
||||||
result[FaweCache.CACHE_I[y][x][z]][FaweCache.CACHE_J[y][x][z]] = blkid;
|
result[FaweCache.CACHE_I[y][x][z]][FaweCache.CACHE_J[y][x][z]] = blkid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlock(final short[][] result, final int x, final int y, final int z, final short[] blkid) {
|
public void setBlock(final short[][] result, final int x, final int y, final int z, final short[] blkid) {
|
||||||
if (blkid.length == 1) {
|
if (blkid.length == 1) {
|
||||||
setBlock(result, x, y, z, blkid[0]);
|
this.setBlock(result, x, y, z, blkid[0]);
|
||||||
}
|
}
|
||||||
final short id = blkid[FaweCache.RANDOM.random(blkid.length)];
|
final short id = blkid[FaweCache.RANDOM.random(blkid.length)];
|
||||||
if (result[FaweCache.CACHE_I[y][x][z]] == null) {
|
if (result[FaweCache.CACHE_I[y][x][z]] == null) {
|
||||||
@ -83,16 +83,16 @@ public class FaweGenerator_1_8 extends ChunkGenerator implements Listener {
|
|||||||
}
|
}
|
||||||
result[FaweCache.CACHE_I[y][x][z]][FaweCache.CACHE_J[y][x][z]] = id;
|
result[FaweCache.CACHE_I[y][x][z]][FaweCache.CACHE_J[y][x][z]] = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlocks(final short[][] ids, final byte[][] data, final int x, final int z) {
|
public void setBlocks(final short[][] ids, final byte[][] data, final int x, final int z) {
|
||||||
this.ids = ids;
|
this.ids = ids;
|
||||||
this.data = data == null ? new byte[16][] : data;
|
this.data = data == null ? new byte[16][] : data;
|
||||||
if (parent == null) {
|
if (this.parent == null) {
|
||||||
inject(this, world);
|
this.inject(this, this.world);
|
||||||
}
|
}
|
||||||
world.regenerateChunk(x, z);
|
this.world.regenerateChunk(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Regenerate chunk with the provided id / data / block count<br>
|
* Regenerate chunk with the provided id / data / block count<br>
|
||||||
* - You can provide null for datas / count but it will be marginally slower
|
* - You can provide null for datas / count but it will be marginally slower
|
||||||
@ -111,7 +111,7 @@ public class FaweGenerator_1_8 extends ChunkGenerator implements Listener {
|
|||||||
}
|
}
|
||||||
final int x = chunk.getX();
|
final int x = chunk.getX();
|
||||||
final int z = chunk.getZ();
|
final int z = chunk.getZ();
|
||||||
|
|
||||||
boolean skip = true;
|
boolean skip = true;
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
if (count[i] < 4096) {
|
if (count[i] < 4096) {
|
||||||
@ -119,18 +119,18 @@ public class FaweGenerator_1_8 extends ChunkGenerator implements Listener {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!skip) {
|
if (!skip) {
|
||||||
try {
|
try {
|
||||||
chunk.load(true);
|
chunk.load(true);
|
||||||
biomes = new Biome[16][16];
|
this.biomes = new Biome[16][16];
|
||||||
final int X = x << 4;
|
final int X = x << 4;
|
||||||
final int Z = z << 4;
|
final int Z = z << 4;
|
||||||
for (int xx = 0; xx < 16; xx++) {
|
for (int xx = 0; xx < 16; xx++) {
|
||||||
final int xxx = X + x;
|
final int xxx = X + x;
|
||||||
for (int zz = 0; zz < 16; zz++) {
|
for (int zz = 0; zz < 16; zz++) {
|
||||||
final int zzz = Z + zz;
|
final int zzz = Z + zz;
|
||||||
biomes[xx][zz] = world.getBiome(xxx, zzz);
|
this.biomes[xx][zz] = this.world.getBiome(xxx, zzz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final Method getHandele = chunk.getClass().getDeclaredMethod("getHandle");
|
final Method getHandele = chunk.getClass().getDeclaredMethod("getHandle");
|
||||||
@ -140,15 +140,15 @@ public class FaweGenerator_1_8 extends ChunkGenerator implements Listener {
|
|||||||
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 ef = 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 List<?>[] entities = (List<?>[]) ef.get(c);
|
||||||
|
|
||||||
Method xm = null;
|
Method xm = null;
|
||||||
Method ym = null;
|
Method ym = null;
|
||||||
Method zm = null;
|
Method zm = null;
|
||||||
|
|
||||||
// Copy entities / blockstates
|
// Copy entities / blockstates
|
||||||
final Set<Entry<?, ?>> entryset = (Set<Entry<?, ?>>) (Set<?>) tiles.entrySet();
|
final Set<Entry<?, ?>> entryset = (Set<Entry<?, ?>>) (Set<?>) tiles.entrySet();
|
||||||
final Iterator<Entry<?, ?>> iter = entryset.iterator();
|
final Iterator<Entry<?, ?>> iter = entryset.iterator();
|
||||||
@ -173,7 +173,7 @@ public class FaweGenerator_1_8 extends ChunkGenerator implements Listener {
|
|||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.tiles = tiles;
|
this.tiles = tiles;
|
||||||
// Trim entities
|
// Trim entities
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
@ -182,7 +182,7 @@ public class FaweGenerator_1_8 extends ChunkGenerator implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.entities = entities;
|
this.entities = entities;
|
||||||
|
|
||||||
// Efficiently merge sections
|
// Efficiently merge sections
|
||||||
Method getIdArray = null;
|
Method getIdArray = null;
|
||||||
for (int j = 0; j < sections.length; j++) {
|
for (int j = 0; j < sections.length; j++) {
|
||||||
@ -315,7 +315,7 @@ public class FaweGenerator_1_8 extends ChunkGenerator implements Listener {
|
|||||||
datas[j][k] = db;
|
datas[j][k] = db;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return;
|
return;
|
||||||
@ -323,19 +323,19 @@ public class FaweGenerator_1_8 extends ChunkGenerator implements Listener {
|
|||||||
}
|
}
|
||||||
// Execute
|
// Execute
|
||||||
this.ids = ids;
|
this.ids = ids;
|
||||||
data = datas;
|
this.data = datas;
|
||||||
if (parent == null) {
|
if (this.parent == null) {
|
||||||
inject(this, world);
|
this.inject(this, this.world);
|
||||||
}
|
}
|
||||||
world.regenerateChunk(x, z);
|
this.world.regenerateChunk(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void inject(final FaweGenerator_1_8 gen, final World world) {
|
public void inject(final FaweGenerator_1_8 gen, final World world) {
|
||||||
queue.setGenerator(world, gen);
|
this.queue.setGenerator(world, gen);
|
||||||
queue.setPopulator(world, new ArrayList<BlockPopulator>());
|
this.queue.setPopulator(world, new ArrayList<BlockPopulator>());
|
||||||
queue.setProvider(world, null);
|
this.queue.setProvider(world, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void decouple(final FaweGenerator_1_8 gen, final World world) {
|
public void decouple(final FaweGenerator_1_8 gen, final World world) {
|
||||||
gen.data = null;
|
gen.data = null;
|
||||||
gen.ids = null;
|
gen.ids = null;
|
||||||
@ -343,32 +343,32 @@ public class FaweGenerator_1_8 extends ChunkGenerator implements Listener {
|
|||||||
gen.entities = null;
|
gen.entities = null;
|
||||||
gen.biomes = null;
|
gen.biomes = null;
|
||||||
if (gen.parent == null) {
|
if (gen.parent == null) {
|
||||||
queue.setGenerator(world, gen.parent);
|
this.queue.setGenerator(world, gen.parent);
|
||||||
queue.setPopulator(world, gen.pops);
|
this.queue.setPopulator(world, gen.pops);
|
||||||
if (gen.provider != null) {
|
if (gen.provider != null) {
|
||||||
queue.setProvider(world, gen.provider);
|
this.queue.setProvider(world, gen.provider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public FaweGenerator_1_8(final BukkitQueue_1_8 queue, final World world) {
|
public FaweGenerator_1_8(final BukkitQueue_1_8 queue, final World world) {
|
||||||
this.queue = queue;
|
this.queue = queue;
|
||||||
this.world = world;
|
this.world = world;
|
||||||
parent = world.getGenerator();
|
this.parent = world.getGenerator();
|
||||||
pops = world.getPopulators();
|
this.pops = world.getPopulators();
|
||||||
if (parent == null) {
|
if (this.parent == null) {
|
||||||
provider = queue.getProvider(world);
|
this.provider = queue.getProvider(world);
|
||||||
} else {
|
} else {
|
||||||
provider = null;
|
this.provider = null;
|
||||||
}
|
}
|
||||||
registerEvents();
|
this.registerEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public short[][] generateExtBlockSections(final World world, final Random random, final int x, final int z, final BiomeGrid biomes) {
|
public short[][] generateExtBlockSections(final World world, final Random random, final int x, final int z, final BiomeGrid biomes) {
|
||||||
short[][] result;
|
short[][] result;
|
||||||
if (ids != null) {
|
if (this.ids != null) {
|
||||||
result = ids;
|
result = this.ids;
|
||||||
if ((biomes != null) && (this.biomes != null)) {
|
if ((biomes != null) && (this.biomes != null)) {
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
for (int j = 0; j < 16; j++) {
|
for (int j = 0; j < 16; j++) {
|
||||||
@ -376,17 +376,17 @@ public class FaweGenerator_1_8 extends ChunkGenerator implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (parent != null) {
|
} else if (this.parent != null) {
|
||||||
result = parent.generateExtBlockSections(world, random, x, z, biomes);
|
result = this.parent.generateExtBlockSections(world, random, x, z, biomes);
|
||||||
} else {
|
} else {
|
||||||
result = null;
|
result = null;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void populate(final Chunk chunk) {
|
public void populate(final Chunk chunk) {
|
||||||
for (int i = 0; i < data.length; i++) {
|
for (int i = 0; i < this.data.length; i++) {
|
||||||
final byte[] section = data[i];
|
final byte[] section = this.data[i];
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -401,54 +401,54 @@ public class FaweGenerator_1_8 extends ChunkGenerator implements Listener {
|
|||||||
chunk.getBlock(x, y, z).setData(v != -1 ? v : 0, false);
|
chunk.getBlock(x, y, z).setData(v != -1 ? v : 0, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((tiles != null) || (entities != null)) {
|
if ((this.tiles != null) || (this.entities != null)) {
|
||||||
queue.setEntitiesAndTiles(chunk, entities, tiles);
|
this.queue.setEntitiesAndTiles(chunk, this.entities, this.tiles);
|
||||||
}
|
}
|
||||||
final BukkitChunk_1_8 fc = new BukkitChunk_1_8(new ChunkLoc(chunk.getWorld().getName(), chunk.getX(), chunk.getZ()));
|
final BukkitChunk_1_8 fc = new BukkitChunk_1_8(new ChunkLoc(chunk.getWorld().getName(), chunk.getX(), chunk.getZ()));
|
||||||
fc.chunk = chunk;
|
fc.chunk = chunk;
|
||||||
queue.fixLighting(fc, Settings.FIX_ALL_LIGHTING);
|
this.queue.fixLighting(fc, Settings.FIX_ALL_LIGHTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] generate(final World world, final Random random, final int x, final int z) {
|
public byte[] generate(final World world, final Random random, final int x, final int z) {
|
||||||
if (ids == null) {
|
if (this.ids == null) {
|
||||||
try {
|
try {
|
||||||
parent.generate(world, random, x, z);
|
this.parent.generate(world, random, x, z);
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[][] generateBlockSections(final World world, final Random random, final int x, final int z, final BiomeGrid biomes) {
|
public byte[][] generateBlockSections(final World world, final Random random, final int x, final int z, final BiomeGrid biomes) {
|
||||||
if ((ids == null) && (parent != null)) {
|
if ((this.ids == null) && (this.parent != null)) {
|
||||||
return parent.generateBlockSections(world, random, x, z, biomes);
|
return this.parent.generateBlockSections(world, random, x, z, biomes);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canSpawn(final World world, final int x, final int z) {
|
public boolean canSpawn(final World world, final int x, final int z) {
|
||||||
if (parent != null) {
|
if (this.parent != null) {
|
||||||
return parent.canSpawn(world, x, z);
|
return this.parent.canSpawn(world, x, z);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BlockPopulator> getDefaultPopulators(final World world) {
|
public List<BlockPopulator> getDefaultPopulators(final World world) {
|
||||||
if ((ids == null) && (parent != null)) {
|
if ((this.ids == null) && (this.parent != null)) {
|
||||||
return parent.getDefaultPopulators(world);
|
return this.parent.getDefaultPopulators(world);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getFixedSpawnLocation(final World world, final Random random) {
|
public Location getFixedSpawnLocation(final World world, final Random random) {
|
||||||
if ((ids == null) && (parent != null)) {
|
if ((this.ids == null) && (this.parent != null)) {
|
||||||
return parent.getFixedSpawnLocation(world, random);
|
return this.parent.getFixedSpawnLocation(world, random);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -11,57 +11,57 @@ import com.boydti.fawe.object.FaweChunk;
|
|||||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||||
|
|
||||||
public class BukkitChunk_1_9 extends FaweChunk<Chunk> {
|
public class BukkitChunk_1_9 extends FaweChunk<Chunk> {
|
||||||
|
|
||||||
private int[][] ids;
|
private int[][] ids;
|
||||||
|
|
||||||
private final short[] count;
|
private final short[] count;
|
||||||
private final short[] air;
|
private final short[] air;
|
||||||
private final short[] relight;
|
private final short[] relight;
|
||||||
public int[][] biomes;
|
public int[][] biomes;
|
||||||
|
|
||||||
public Chunk chunk;
|
public Chunk chunk;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A FaweSections object represents a chunk and the blocks that you wish to change in it.
|
* A FaweSections object represents a chunk and the blocks that you wish to change in it.
|
||||||
*/
|
*/
|
||||||
protected BukkitChunk_1_9(final ChunkLoc chunk) {
|
protected BukkitChunk_1_9(final ChunkLoc chunk) {
|
||||||
super(chunk);
|
super(chunk);
|
||||||
ids = new int[16][];
|
this.ids = new int[16][];
|
||||||
count = new short[16];
|
this.count = new short[16];
|
||||||
air = new short[16];
|
this.air = new short[16];
|
||||||
relight = new short[16];
|
this.relight = new short[16];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Chunk getChunk() {
|
public Chunk getChunk() {
|
||||||
if (chunk == null) {
|
if (this.chunk == null) {
|
||||||
final ChunkLoc cl = getChunkLoc();
|
final ChunkLoc cl = this.getChunkLoc();
|
||||||
chunk = Bukkit.getWorld(cl.world).getChunkAt(cl.x, cl.z);
|
this.chunk = Bukkit.getWorld(cl.world).getChunkAt(cl.x, cl.z);
|
||||||
}
|
}
|
||||||
return chunk;
|
return this.chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setChunkLoc(final ChunkLoc loc) {
|
public void setChunkLoc(final ChunkLoc loc) {
|
||||||
super.setChunkLoc(loc);
|
super.setChunkLoc(loc);
|
||||||
chunk = null;
|
this.chunk = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of block changes in a specified section
|
* Get the number of block changes in a specified section
|
||||||
* @param i
|
* @param i
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int getCount(final int i) {
|
public int getCount(final int i) {
|
||||||
return count[i];
|
return this.count[i];
|
||||||
}
|
|
||||||
|
|
||||||
public int getAir(final int i) {
|
|
||||||
return air[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCount(int i, short value) {
|
public int getAir(final int i) {
|
||||||
count[i] = value;
|
return this.air[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCount(final int i, final short value) {
|
||||||
|
this.count[i] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -70,65 +70,66 @@ public class BukkitChunk_1_9 extends FaweChunk<Chunk> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int getRelight(final int i) {
|
public int getRelight(final int i) {
|
||||||
return relight[i];
|
return this.relight[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTotalCount() {
|
public int getTotalCount() {
|
||||||
int total = 0;
|
int total = 0;
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
total += count[i];
|
total += this.count[i];
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTotalRelight() {
|
public int getTotalRelight() {
|
||||||
if (getTotalCount() == 0 && biomes == null) {
|
if ((this.getTotalCount() == 0) && (this.biomes == null)) {
|
||||||
Arrays.fill(count, (short) 1);
|
Arrays.fill(this.count, (short) 1);
|
||||||
Arrays.fill(relight, Short.MAX_VALUE);
|
Arrays.fill(this.relight, Short.MAX_VALUE);
|
||||||
return Short.MAX_VALUE;
|
return Short.MAX_VALUE;
|
||||||
}
|
}
|
||||||
int total = 0;
|
int total = 0;
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
total += relight[i];
|
total += this.relight[i];
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the raw data for a section
|
* Get the raw data for a section
|
||||||
* @param i
|
* @param i
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int[] getIdArray(final int i) {
|
public int[] getIdArray(final int i) {
|
||||||
return ids[i];
|
return this.ids[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[][] getIdArrays() {
|
public int[][] getIdArrays() {
|
||||||
return ids;
|
return this.ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
ids = null;
|
this.ids = null;
|
||||||
biomes = null;
|
this.biomes = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[][] getBiomeArray() {
|
public int[][] getBiomeArray() {
|
||||||
return biomes;
|
return this.biomes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBlock(final int x, final int y, final int z, final int id, byte data) {
|
public void setBlock(final int x, final int y, final int z, final int id, byte data) {
|
||||||
final int i = FaweCache.CACHE_I[y][x][z];
|
final int i = FaweCache.CACHE_I[y][x][z];
|
||||||
final int j = FaweCache.CACHE_J[y][x][z];
|
final int j = FaweCache.CACHE_J[y][x][z];
|
||||||
int[] vs = ids[i];
|
int[] vs = this.ids[i];
|
||||||
if (vs == null) {
|
if (vs == null) {
|
||||||
vs = ids[i] = new int[4096];
|
vs = this.ids[i] = new int[4096];
|
||||||
count[i]++;
|
this.count[i]++;
|
||||||
} else if (vs[j] == 0) {
|
} else if (vs[j] == 0) {
|
||||||
count[i]++;
|
this.count[i]++;
|
||||||
}
|
}
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 0:
|
case 0:
|
||||||
air[i]++;
|
this.air[i]++;
|
||||||
vs[j] = -1;
|
vs[j] = -1;
|
||||||
return;
|
return;
|
||||||
case 10:
|
case 10:
|
||||||
@ -142,7 +143,7 @@ public class BukkitChunk_1_9 extends FaweChunk<Chunk> {
|
|||||||
case 124:
|
case 124:
|
||||||
case 138:
|
case 138:
|
||||||
case 169:
|
case 169:
|
||||||
relight[i]++;
|
this.relight[i]++;
|
||||||
case 2:
|
case 2:
|
||||||
case 4:
|
case 4:
|
||||||
case 13:
|
case 13:
|
||||||
@ -205,7 +206,7 @@ public class BukkitChunk_1_9 extends FaweChunk<Chunk> {
|
|||||||
case 130:
|
case 130:
|
||||||
case 76:
|
case 76:
|
||||||
case 62:
|
case 62:
|
||||||
relight[i]++;
|
this.relight[i]++;
|
||||||
case 54:
|
case 54:
|
||||||
case 146:
|
case 146:
|
||||||
case 61:
|
case 61:
|
||||||
@ -220,15 +221,15 @@ public class BukkitChunk_1_9 extends FaweChunk<Chunk> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBiome(int x, int z, BaseBiome biome) {
|
public void setBiome(final int x, final int z, final BaseBiome biome) {
|
||||||
if (biomes == null) {
|
if (this.biomes == null) {
|
||||||
biomes = new int[16][];
|
this.biomes = new int[16][];
|
||||||
}
|
}
|
||||||
int[] index = biomes[x];
|
int[] index = this.biomes[x];
|
||||||
if (index == null) {
|
if (index == null) {
|
||||||
index = biomes[x] = new int[16];
|
index = this.biomes[x] = new int[16];
|
||||||
}
|
}
|
||||||
index[z] = biome.getId();
|
index[z] = biome.getId();
|
||||||
}
|
}
|
||||||
|
@ -45,12 +45,12 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
|||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
|
|
||||||
public class BukkitQueue_1_9 extends BukkitQueue_0 {
|
public class BukkitQueue_1_9 extends BukkitQueue_0 {
|
||||||
|
|
||||||
private final RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk");
|
private final RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk");
|
||||||
private final RefClass classChunk = getRefClass("{nms}.Chunk");
|
private final RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||||
private final RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
private final RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
||||||
private final RefClass classWorld = getRefClass("{nms}.World");
|
private final RefClass classWorld = getRefClass("{nms}.World");
|
||||||
private final RefField mustSave = classChunk.getField("mustSave");
|
private final RefField mustSave = this.classChunk.getField("mustSave");
|
||||||
private final RefClass classBlockPosition = getRefClass("{nms}.BlockPosition");
|
private final RefClass classBlockPosition = getRefClass("{nms}.BlockPosition");
|
||||||
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");
|
||||||
@ -70,65 +70,65 @@ public class BukkitQueue_1_9 extends BukkitQueue_0 {
|
|||||||
private final Object air;
|
private final Object air;
|
||||||
private final RefMethod methodGetWorld;
|
private final RefMethod methodGetWorld;
|
||||||
private final RefField tileEntityListTick;
|
private final RefField tileEntityListTick;
|
||||||
|
|
||||||
public BukkitQueue_1_9() throws NoSuchMethodException, RuntimeException {
|
public BukkitQueue_1_9() throws NoSuchMethodException, RuntimeException {
|
||||||
methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
|
this.methodGetHandleChunk = this.classCraftChunk.getMethod("getHandle");
|
||||||
methodInitLighting = classChunk.getMethod("initLighting");
|
this.methodInitLighting = this.classChunk.getMethod("initLighting");
|
||||||
MapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), boolean.class, int.class);
|
this.MapChunk = this.classMapChunk.getConstructor(this.classChunk.getRealClass(), boolean.class, int.class);
|
||||||
classBlockPositionConstructor = classBlockPosition.getConstructor(int.class, int.class, int.class);
|
this.classBlockPositionConstructor = this.classBlockPosition.getConstructor(int.class, int.class, int.class);
|
||||||
methodW = classWorld.getMethod("w", classBlockPosition.getRealClass());
|
this.methodW = this.classWorld.getMethod("w", this.classBlockPosition.getRealClass());
|
||||||
fieldSections = classChunk.getField("sections");
|
this.fieldSections = this.classChunk.getField("sections");
|
||||||
fieldWorld = classChunk.getField("world");
|
this.fieldWorld = this.classChunk.getField("world");
|
||||||
methodGetByCombinedId = classBlock.getMethod("getByCombinedId", int.class);
|
this.methodGetByCombinedId = this.classBlock.getMethod("getByCombinedId", int.class);
|
||||||
methodGetBlocks = classChunkSection.getMethod("getBlocks");
|
this.methodGetBlocks = this.classChunkSection.getMethod("getBlocks");
|
||||||
methodSetType = classChunkSection.getMethod("setType", int.class, int.class, int.class, classIBlockData.getRealClass());
|
this.methodSetType = this.classChunkSection.getMethod("setType", int.class, int.class, int.class, this.classIBlockData.getRealClass());
|
||||||
methodAreNeighborsLoaded = classChunk.getMethod("areNeighborsLoaded", int.class);
|
this.methodAreNeighborsLoaded = this.classChunk.getMethod("areNeighborsLoaded", int.class);
|
||||||
classChunkSectionConstructor = classChunkSection.getConstructor(int.class, boolean.class, char[].class);
|
this.classChunkSectionConstructor = this.classChunkSection.getConstructor(int.class, boolean.class, char[].class);
|
||||||
air = methodGetByCombinedId.call(0);
|
this.air = this.methodGetByCombinedId.call(0);
|
||||||
this.tileEntityListTick = classWorld.getField("tileEntityListTick");
|
this.tileEntityListTick = this.classWorld.getField("tileEntityListTick");
|
||||||
this.methodGetWorld = classChunk.getMethod("getWorld");
|
this.methodGetWorld = this.classChunk.getMethod("getWorld");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<FaweChunk<Chunk>> sendChunk(final Collection<FaweChunk<Chunk>> fcs) {
|
public Collection<FaweChunk<Chunk>> sendChunk(final Collection<FaweChunk<Chunk>> fcs) {
|
||||||
for (FaweChunk<Chunk> fc : fcs) {
|
for (final FaweChunk<Chunk> fc : fcs) {
|
||||||
Chunk chunk = fc.getChunk();
|
final Chunk chunk = fc.getChunk();
|
||||||
ChunkLoc loc = fc.getChunkLoc();
|
final ChunkLoc loc = fc.getChunkLoc();
|
||||||
chunk.getWorld().refreshChunk(loc.x, loc.z);
|
chunk.getWorld().refreshChunk(loc.x, loc.z);
|
||||||
}
|
}
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean fixLighting(final FaweChunk<?> pc, boolean fixAll) {
|
public boolean fixLighting(final FaweChunk<?> pc, final boolean fixAll) {
|
||||||
try {
|
try {
|
||||||
BukkitChunk_1_9 bc = (BukkitChunk_1_9) pc;
|
final BukkitChunk_1_9 bc = (BukkitChunk_1_9) pc;
|
||||||
final Chunk chunk = bc.getChunk();
|
final Chunk chunk = bc.getChunk();
|
||||||
if (!chunk.isLoaded()) {
|
if (!chunk.isLoaded()) {
|
||||||
chunk.load(false);
|
chunk.load(false);
|
||||||
}
|
}
|
||||||
// Initialize lighting
|
// Initialize lighting
|
||||||
final Object c = methodGetHandleChunk.of(chunk).call();
|
final Object c = this.methodGetHandleChunk.of(chunk).call();
|
||||||
|
|
||||||
methodInitLighting.of(c).call();
|
|
||||||
|
|
||||||
if ((bc.getTotalRelight() == 0 && !fixAll)) {
|
this.methodInitLighting.of(c).call();
|
||||||
|
|
||||||
|
if (((bc.getTotalRelight() == 0) && !fixAll)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Object[] sections = (Object[]) fieldSections.of(c).get();
|
final Object[] sections = (Object[]) this.fieldSections.of(c).get();
|
||||||
final Object w = fieldWorld.of(c).get();
|
final Object w = this.fieldWorld.of(c).get();
|
||||||
|
|
||||||
final int X = chunk.getX() << 4;
|
final int X = chunk.getX() << 4;
|
||||||
final int Z = chunk.getZ() << 4;
|
final int Z = chunk.getZ() << 4;
|
||||||
|
|
||||||
RefExecutor relight = methodW.of(w);
|
final RefExecutor relight = this.methodW.of(w);
|
||||||
for (int j = 0; j < sections.length; j++) {
|
for (int j = 0; j < sections.length; j++) {
|
||||||
final Object section = sections[j];
|
final Object section = sections[j];
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ((bc.getRelight(j) == 0 && !fixAll) || bc.getCount(j) == 0 || (bc.getCount(j) >= 4096 && bc.getAir(j) == 0)) {
|
if (((bc.getRelight(j) == 0) && !fixAll) || (bc.getCount(j) == 0) || ((bc.getCount(j) >= 4096) && (bc.getAir(j) == 0))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final int[] array = bc.getIdArray(j);
|
final int[] array = bc.getIdArray(j);
|
||||||
@ -169,10 +169,10 @@ public class BukkitQueue_1_9 extends BukkitQueue_0 {
|
|||||||
final int x = FaweCache.CACHE_X[j][k];
|
final int x = FaweCache.CACHE_X[j][k];
|
||||||
final int y = FaweCache.CACHE_Y[j][k];
|
final int y = FaweCache.CACHE_Y[j][k];
|
||||||
final int z = FaweCache.CACHE_Z[j][k];
|
final int z = FaweCache.CACHE_Z[j][k];
|
||||||
if (isSurrounded(bc.getIdArrays(), x, y, z)) {
|
if (this.isSurrounded(bc.getIdArrays(), x, y, z)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final Object pos = classBlockPositionConstructor.create(X + x, y, Z + z);
|
final Object pos = this.classBlockPositionConstructor.create(X + x, y, Z + z);
|
||||||
relight.call(pos);
|
relight.call(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -183,47 +183,47 @@ public class BukkitQueue_1_9 extends BukkitQueue_0 {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSurrounded(int[][] sections, int x, int y, int z) {
|
public boolean isSurrounded(final int[][] sections, final int x, final int y, final int z) {
|
||||||
return isSolid(getId(sections, x, y + 1, z))
|
return this.isSolid(this.getId(sections, x, y + 1, z))
|
||||||
&& isSolid(getId(sections, x + 1, y - 1, z))
|
&& this.isSolid(this.getId(sections, x + 1, y - 1, z))
|
||||||
&& isSolid(getId(sections, x - 1, y, z))
|
&& this.isSolid(this.getId(sections, x - 1, y, z))
|
||||||
&& isSolid(getId(sections, x, y, z + 1))
|
&& this.isSolid(this.getId(sections, x, y, z + 1))
|
||||||
&& isSolid(getId(sections, x, y, z - 1));
|
&& this.isSolid(this.getId(sections, x, y, z - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSolid(int i) {
|
public boolean isSolid(final int i) {
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
Material material = Material.getMaterial(i);
|
final Material material = Material.getMaterial(i);
|
||||||
return material != null && Material.getMaterial(i).isOccluding();
|
return (material != null) && Material.getMaterial(i).isOccluding();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId(int[][] sections, int x, int y, int z) {
|
public int getId(final int[][] sections, final int x, final int y, final int z) {
|
||||||
if (x < 0 || x > 15 || z < 0 || z > 15) {
|
if ((x < 0) || (x > 15) || (z < 0) || (z > 15)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (y < 0 || y > 255) {
|
if ((y < 0) || (y > 255)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
int i = FaweCache.CACHE_I[y][x][z];
|
final int i = FaweCache.CACHE_I[y][x][z];
|
||||||
int[] section = sections[i];
|
final int[] section = sections[i];
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int j = FaweCache.CACHE_J[y][x][z];
|
final int j = FaweCache.CACHE_J[y][x][z];
|
||||||
return section[j];
|
return section[j];
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getBlocks(final Object obj) {
|
public Object getBlocks(final Object obj) {
|
||||||
return methodGetBlocks.of(obj).call();
|
return this.methodGetBlocks.of(obj).call();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setComponents(final FaweChunk<Chunk> pc) {
|
public boolean setComponents(final FaweChunk<Chunk> pc) {
|
||||||
final BukkitChunk_1_9 fs = (BukkitChunk_1_9) pc;
|
final BukkitChunk_1_9 fs = (BukkitChunk_1_9) pc;
|
||||||
Chunk chunk = pc.getChunk();
|
final Chunk chunk = pc.getChunk();
|
||||||
final World world = chunk.getWorld();
|
final World world = chunk.getWorld();
|
||||||
chunk.load(true);
|
chunk.load(true);
|
||||||
try {
|
try {
|
||||||
@ -232,7 +232,7 @@ public class BukkitQueue_1_9 extends BukkitQueue_0 {
|
|||||||
// Sections
|
// Sections
|
||||||
final Method getHandele = chunk.getClass().getDeclaredMethod("getHandle");
|
final Method getHandele = chunk.getClass().getDeclaredMethod("getHandle");
|
||||||
final Object c = getHandele.invoke(chunk);
|
final Object c = getHandele.invoke(chunk);
|
||||||
Object w = methodGetWorld.of(c).call();
|
final Object w = this.methodGetWorld.of(c).call();
|
||||||
final Class<? extends Object> clazz = c.getClass();
|
final Class<? extends Object> clazz = c.getClass();
|
||||||
final Field sf = clazz.getDeclaredField("sections");
|
final Field sf = clazz.getDeclaredField("sections");
|
||||||
sf.setAccessible(true);
|
sf.setAccessible(true);
|
||||||
@ -296,18 +296,18 @@ public class BukkitQueue_1_9 extends BukkitQueue_0 {
|
|||||||
}
|
}
|
||||||
Object section = sections[j];
|
Object section = sections[j];
|
||||||
if ((section == null) || (fs.getCount(j) >= 4096)) {
|
if ((section == null) || (fs.getCount(j) >= 4096)) {
|
||||||
char[] array = new char[4096];
|
final char[] array = new char[4096];
|
||||||
for (int i = 0; i < newArray.length; i++) {
|
for (int i = 0; i < newArray.length; i++) {
|
||||||
int combined = newArray[i];
|
final int combined = newArray[i];
|
||||||
int id = combined & 4095;
|
final int id = combined & 4095;
|
||||||
int data = combined >> 12;
|
final int data = combined >> 12;
|
||||||
array[i] = (char) ((id << 4) + data);
|
array[i] = (char) ((id << 4) + data);
|
||||||
}
|
}
|
||||||
section = sections[j] = newChunkSection(j << 4, flag, array);
|
section = sections[j] = this.newChunkSection(j << 4, flag, array);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final Object currentArray = getBlocks(section);
|
this.getBlocks(section);
|
||||||
RefExecutor setType = methodSetType.of(section);
|
final RefExecutor setType = this.methodSetType.of(section);
|
||||||
boolean fill = true;
|
boolean fill = true;
|
||||||
for (int k = 0; k < newArray.length; k++) {
|
for (int k = 0; k < newArray.length; k++) {
|
||||||
final int n = newArray[k];
|
final int n = newArray[k];
|
||||||
@ -317,18 +317,17 @@ public class BukkitQueue_1_9 extends BukkitQueue_0 {
|
|||||||
continue;
|
continue;
|
||||||
case -1: {
|
case -1: {
|
||||||
fill = false;
|
fill = false;
|
||||||
int x = FaweCache.CACHE_X[j][k];
|
final int x = FaweCache.CACHE_X[j][k];
|
||||||
int y = FaweCache.CACHE_Y[j][k];
|
final int y = FaweCache.CACHE_Y[j][k];
|
||||||
int z = FaweCache.CACHE_Z[j][k];
|
final int z = FaweCache.CACHE_Z[j][k];
|
||||||
setType.call(x, y & 15, z, air);
|
setType.call(x, y & 15, z, this.air);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
int x = FaweCache.CACHE_X[j][k];
|
final int x = FaweCache.CACHE_X[j][k];
|
||||||
int y = FaweCache.CACHE_Y[j][k];
|
final int y = FaweCache.CACHE_Y[j][k];
|
||||||
int z = FaweCache.CACHE_Z[j][k];
|
final int z = FaweCache.CACHE_Z[j][k];
|
||||||
int id = n;
|
final Object iblock = this.methodGetByCombinedId.call(n);
|
||||||
Object iblock = methodGetByCombinedId.call(n);
|
|
||||||
setType.call(x, y & 15, z, iblock);
|
setType.call(x, y & 15, z, iblock);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -342,16 +341,16 @@ public class BukkitQueue_1_9 extends BukkitQueue_0 {
|
|||||||
} catch (IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException | InvocationTargetException | NoSuchFieldException e) {
|
} catch (IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException | InvocationTargetException | NoSuchFieldException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
int[][] biomes = fs.biomes;
|
final int[][] biomes = fs.biomes;
|
||||||
Biome[] values = Biome.values();
|
final Biome[] values = Biome.values();
|
||||||
if (biomes != null) {
|
if (biomes != null) {
|
||||||
for (int x = 0; x < 16; x++) {
|
for (int x = 0; x < 16; x++) {
|
||||||
int[] array = biomes[x];
|
final int[] array = biomes[x];
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; z++) {
|
||||||
int biome = array[z];
|
final int biome = array[z];
|
||||||
if (biome == 0) {
|
if (biome == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -362,13 +361,13 @@ public class BukkitQueue_1_9 extends BukkitQueue_0 {
|
|||||||
TaskManager.runTaskLater(new Runnable() {
|
TaskManager.runTaskLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
ChunkLoc loc = fs.getChunkLoc();
|
final ChunkLoc loc = fs.getChunkLoc();
|
||||||
world.refreshChunk(loc.x, loc.z);
|
world.refreshChunk(loc.x, loc.z);
|
||||||
}
|
}
|
||||||
}, 1);
|
}, 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
super.clear();
|
super.clear();
|
||||||
@ -377,8 +376,8 @@ public class BukkitQueue_1_9 extends BukkitQueue_0 {
|
|||||||
HashMap<String, HashMap<IntegerPair, Integer>> players = new HashMap<>();
|
HashMap<String, HashMap<IntegerPair, Integer>> players = new HashMap<>();
|
||||||
for (final Player player : Bukkit.getOnlinePlayers()) {
|
for (final Player player : Bukkit.getOnlinePlayers()) {
|
||||||
// Clear history
|
// Clear history
|
||||||
FawePlayer<Object> fp = FawePlayer.wrap(player);
|
final FawePlayer<Object> fp = FawePlayer.wrap(player);
|
||||||
LocalSession s = fp.getSession();
|
final LocalSession s = fp.getSession();
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
s.clearHistory();
|
s.clearHistory();
|
||||||
s.setClipboard(null);
|
s.setClipboard(null);
|
||||||
@ -428,7 +427,7 @@ public class BukkitQueue_1_9 extends BukkitQueue_0 {
|
|||||||
final boolean save = world.isAutoSave();
|
final boolean save = world.isAutoSave();
|
||||||
world.setAutoSave(false);
|
world.setAutoSave(false);
|
||||||
for (final Chunk chunk : world.getLoadedChunks()) {
|
for (final Chunk chunk : world.getLoadedChunks()) {
|
||||||
unloadChunk(name, chunk);
|
this.unloadChunk(name, chunk);
|
||||||
}
|
}
|
||||||
world.setAutoSave(save);
|
world.setAutoSave(save);
|
||||||
continue;
|
continue;
|
||||||
@ -453,7 +452,7 @@ public class BukkitQueue_1_9 extends BukkitQueue_0 {
|
|||||||
int free = MemUtil.calculateMemory();
|
int free = MemUtil.calculateMemory();
|
||||||
if (free <= 1) {
|
if (free <= 1) {
|
||||||
for (final Chunk chunk : toUnload) {
|
for (final Chunk chunk : toUnload) {
|
||||||
unloadChunk(chunk.getWorld().getName(), chunk);
|
this.unloadChunk(chunk.getWorld().getName(), chunk);
|
||||||
}
|
}
|
||||||
} else if (free == Integer.MAX_VALUE) {
|
} else if (free == Integer.MAX_VALUE) {
|
||||||
for (final Chunk chunk : toUnload) {
|
for (final Chunk chunk : toUnload) {
|
||||||
@ -484,31 +483,31 @@ public class BukkitQueue_1_9 extends BukkitQueue_0 {
|
|||||||
for (final World world : Bukkit.getWorlds()) {
|
for (final World world : Bukkit.getWorlds()) {
|
||||||
final String name = world.getName();
|
final String name = world.getName();
|
||||||
for (final Chunk chunk : world.getLoadedChunks()) {
|
for (final Chunk chunk : world.getLoadedChunks()) {
|
||||||
unloadChunk(name, chunk);
|
this.unloadChunk(name, chunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.gc();
|
System.gc();
|
||||||
System.gc();
|
System.gc();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object newChunkSection(final int i, final boolean flag, final char[] ids) {
|
public Object newChunkSection(final int i, final boolean flag, final char[] ids) {
|
||||||
return classChunkSectionConstructor.create(i, flag, ids);
|
return this.classChunkSectionConstructor.create(i, flag, ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FaweChunk<Chunk> getChunk(final ChunkLoc wrap) {
|
public FaweChunk<Chunk> getChunk(final ChunkLoc wrap) {
|
||||||
return new BukkitChunk_1_9(wrap);
|
return new BukkitChunk_1_9(wrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean unloadChunk(final String world, final Chunk chunk) {
|
public boolean unloadChunk(final String world, final Chunk chunk) {
|
||||||
final Object c = methodGetHandleChunk.of(chunk).call();
|
final Object c = this.methodGetHandleChunk.of(chunk).call();
|
||||||
mustSave.of(c).set(false);
|
this.mustSave.of(c).set(false);
|
||||||
if (chunk.isLoaded()) {
|
if (chunk.isLoaded()) {
|
||||||
chunk.unload(false, false);
|
chunk.unload(false, false);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChunkGenerator setGenerator(final World world, final ChunkGenerator newGen) {
|
public ChunkGenerator setGenerator(final World world, final ChunkGenerator newGen) {
|
||||||
try {
|
try {
|
||||||
final ChunkGenerator gen = world.getGenerator();
|
final ChunkGenerator gen = world.getGenerator();
|
||||||
@ -516,21 +515,21 @@ public class BukkitQueue_1_9 extends BukkitQueue_0 {
|
|||||||
final Field generator = clazz.getDeclaredField("generator");
|
final Field generator = clazz.getDeclaredField("generator");
|
||||||
generator.setAccessible(true);
|
generator.setAccessible(true);
|
||||||
generator.set(world, newGen);
|
generator.set(world, newGen);
|
||||||
|
|
||||||
final Field wf = clazz.getDeclaredField("world");
|
final Field wf = clazz.getDeclaredField("world");
|
||||||
wf.setAccessible(true);
|
wf.setAccessible(true);
|
||||||
final Object w = wf.get(world);
|
final Object w = wf.get(world);
|
||||||
final Class<?> clazz2 = w.getClass().getSuperclass();
|
final Class<?> clazz2 = w.getClass().getSuperclass();
|
||||||
final Field generator2 = clazz2.getDeclaredField("generator");
|
final Field generator2 = clazz2.getDeclaredField("generator");
|
||||||
generator2.set(w, newGen);
|
generator2.set(w, newGen);
|
||||||
|
|
||||||
return gen;
|
return gen;
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BlockPopulator> setPopulator(final World world, final List<BlockPopulator> newPop) {
|
public List<BlockPopulator> setPopulator(final World world, final List<BlockPopulator> newPop) {
|
||||||
try {
|
try {
|
||||||
final List<BlockPopulator> pop = world.getPopulators();
|
final List<BlockPopulator> pop = world.getPopulators();
|
||||||
@ -543,21 +542,21 @@ public class BukkitQueue_1_9 extends BukkitQueue_0 {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEntitiesAndTiles(final Chunk chunk, final List<?>[] entities, final Map<?, ?> tiles) {
|
public void setEntitiesAndTiles(final Chunk chunk, final List<?>[] entities, final Map<?, ?> tiles) {
|
||||||
try {
|
try {
|
||||||
final Class<? extends Chunk> clazz = chunk.getClass();
|
final Class<? extends Chunk> clazz = chunk.getClass();
|
||||||
final Method handle = clazz.getMethod("getHandle");
|
final Method handle = clazz.getMethod("getHandle");
|
||||||
final Object c = handle.invoke(chunk);
|
final Object c = handle.invoke(chunk);
|
||||||
final Class<? extends Object> clazz2 = c.getClass();
|
final Class<? extends Object> clazz2 = c.getClass();
|
||||||
|
|
||||||
if (tiles.size() > 0) {
|
if (tiles.size() > 0) {
|
||||||
final Field tef = clazz2.getDeclaredField("tileEntities");
|
final Field tef = clazz2.getDeclaredField("tileEntities");
|
||||||
final Map<?, ?> te = (Map<?, ?>) tef.get(c);
|
final Map<?, ?> te = (Map<?, ?>) tef.get(c);
|
||||||
final Method put = te.getClass().getMethod("putAll", Map.class);
|
final Method put = te.getClass().getMethod("putAll", Map.class);
|
||||||
put.invoke(te, tiles);
|
put.invoke(te, tiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Field esf = clazz2.getDeclaredField("entitySlices");
|
final Field esf = clazz2.getDeclaredField("entitySlices");
|
||||||
esf.setAccessible(true);
|
esf.setAccessible(true);
|
||||||
esf.set(c, entities);
|
esf.set(c, entities);
|
||||||
@ -565,7 +564,7 @@ public class BukkitQueue_1_9 extends BukkitQueue_0 {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getProvider(final World world) {
|
public Object getProvider(final World world) {
|
||||||
try {
|
try {
|
||||||
// Provider 1
|
// Provider 1
|
||||||
@ -588,7 +587,7 @@ public class BukkitQueue_1_9 extends BukkitQueue_0 {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object setProvider(final World world, Object newProvider) {
|
public Object setProvider(final World world, Object newProvider) {
|
||||||
try {
|
try {
|
||||||
// Provider 1
|
// Provider 1
|
||||||
|
@ -11,38 +11,38 @@ import com.sk89q.worldedit.Vector;
|
|||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
|
||||||
public class FixLighting extends FaweCommand {
|
public class FixLighting extends FaweCommand {
|
||||||
|
|
||||||
public FixLighting() {
|
public FixLighting() {
|
||||||
super("fawe.fixlighting");
|
super("fawe.fixlighting");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final FawePlayer player, final String... args) {
|
public boolean execute(final FawePlayer player, final String... args) {
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
FaweLocation loc = player.getLocation();
|
final FaweLocation loc = player.getLocation();
|
||||||
Region selection = player.getSelection();
|
final Region selection = player.getSelection();
|
||||||
if (selection == null) {
|
if (selection == null) {
|
||||||
FaweAPI.fixLighting(new ChunkLoc(loc.world, loc.x >> 4, loc.z >> 4), Settings.FIX_ALL_LIGHTING);
|
FaweAPI.fixLighting(new ChunkLoc(loc.world, loc.x >> 4, loc.z >> 4), Settings.FIX_ALL_LIGHTING);
|
||||||
BBC.FIX_LIGHTING_CHUNK.send(player);
|
BBC.FIX_LIGHTING_CHUNK.send(player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
int cx = loc.x >> 4;
|
final int cx = loc.x >> 4;
|
||||||
int cz = loc.z >> 4;
|
final int cz = loc.z >> 4;
|
||||||
Vector bot = selection.getMinimumPoint();
|
final Vector bot = selection.getMinimumPoint();
|
||||||
Vector top = selection.getMaximumPoint();
|
final Vector top = selection.getMaximumPoint();
|
||||||
|
|
||||||
int minX = Math.max(cx - 8, bot.getBlockX() >> 4);
|
final int minX = Math.max(cx - 8, bot.getBlockX() >> 4);
|
||||||
int minZ = Math.max(cz - 8, bot.getBlockZ() >> 4);
|
final int minZ = Math.max(cz - 8, bot.getBlockZ() >> 4);
|
||||||
|
|
||||||
int maxX = Math.min(cx + 8, top.getBlockX() >> 4);
|
final int maxX = Math.min(cx + 8, top.getBlockX() >> 4);
|
||||||
int maxZ = Math.min(cz + 8, top.getBlockZ() >> 4);
|
final int maxZ = Math.min(cz + 8, top.getBlockZ() >> 4);
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int x = minX; x <= maxX; x++) {
|
for (int x = minX; x <= maxX; x++) {
|
||||||
for (int z = minZ; z <= maxZ; z++) {
|
for (int z = minZ; z <= maxZ; z++) {
|
||||||
ChunkLoc cl = new ChunkLoc(loc.world, x, z);
|
final ChunkLoc cl = new ChunkLoc(loc.world, x, z);
|
||||||
FaweAPI.fixLighting(cl, Settings.FIX_ALL_LIGHTING);
|
FaweAPI.fixLighting(cl, Settings.FIX_ALL_LIGHTING);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,11 @@ import com.boydti.fawe.object.FaweCommand;
|
|||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
|
|
||||||
public class Stream extends FaweCommand {
|
public class Stream extends FaweCommand {
|
||||||
|
|
||||||
public Stream() {
|
public Stream() {
|
||||||
super("fawe.stream");
|
super("fawe.stream");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final FawePlayer player, final String... args) {
|
public boolean execute(final FawePlayer player, final String... args) {
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
@ -26,7 +26,7 @@ public class Stream extends FaweCommand {
|
|||||||
if (!args[0].endsWith(".schematic")) {
|
if (!args[0].endsWith(".schematic")) {
|
||||||
args[0] += ".schematic";
|
args[0] += ".schematic";
|
||||||
}
|
}
|
||||||
File file = Fawe.get().getWorldEdit().getWorkingDirectoryFile(Fawe.get().getWorldEdit().getConfiguration().saveDir + File.separator + args[0]);
|
final File file = Fawe.get().getWorldEdit().getWorkingDirectoryFile(Fawe.get().getWorldEdit().getConfiguration().saveDir + File.separator + args[0]);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
BBC.SCHEMATIC_NOT_FOUND.send(player, args);
|
BBC.SCHEMATIC_NOT_FOUND.send(player, args);
|
||||||
return false;
|
return false;
|
||||||
|
@ -5,25 +5,25 @@ import com.boydti.fawe.object.FaweCommand;
|
|||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
|
|
||||||
public class Wea extends FaweCommand {
|
public class Wea extends FaweCommand {
|
||||||
|
|
||||||
public Wea() {
|
public Wea() {
|
||||||
super("fawe.admin");
|
super("fawe.admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final FawePlayer player, final String... args) {
|
public boolean execute(final FawePlayer player, final String... args) {
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (toggle(player)) {
|
if (this.toggle(player)) {
|
||||||
BBC.WORLDEDIT_BYPASSED.send(player);
|
BBC.WORLDEDIT_BYPASSED.send(player);
|
||||||
} else {
|
} else {
|
||||||
BBC.WORLDEDIT_RESTRICTED.send(player);
|
BBC.WORLDEDIT_RESTRICTED.send(player);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean toggle(FawePlayer player) {
|
private boolean toggle(final FawePlayer player) {
|
||||||
if (player.hasPermission("fawe.bypass")) {
|
if (player.hasPermission("fawe.bypass")) {
|
||||||
player.setPermission("fawe.bypass", false);
|
player.setPermission("fawe.bypass", false);
|
||||||
return false;
|
return false;
|
||||||
|
@ -6,17 +6,17 @@ import com.boydti.fawe.object.FawePlayer;
|
|||||||
import com.boydti.fawe.object.RegionWrapper;
|
import com.boydti.fawe.object.RegionWrapper;
|
||||||
|
|
||||||
public class WorldEditRegion extends FaweCommand {
|
public class WorldEditRegion extends FaweCommand {
|
||||||
|
|
||||||
public WorldEditRegion() {
|
public WorldEditRegion() {
|
||||||
super("fawe.worldeditregion");
|
super("fawe.worldeditregion");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final FawePlayer player, final String... args) {
|
public boolean execute(final FawePlayer player, final String... args) {
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
RegionWrapper region = player.getLargestRegion();
|
final RegionWrapper region = player.getLargestRegion();
|
||||||
if (region == null) {
|
if (region == null) {
|
||||||
BBC.NO_REGION.send(player);
|
BBC.NO_REGION.send(player);
|
||||||
return false;
|
return false;
|
||||||
@ -25,14 +25,4 @@ public class WorldEditRegion extends FaweCommand {
|
|||||||
BBC.SET_REGION.send(player);
|
BBC.SET_REGION.send(player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean toggle(FawePlayer player) {
|
|
||||||
if (player.hasPermission("fawe.bypass")) {
|
|
||||||
player.setPermission("fawe.bypass", false);
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
player.setPermission("fawe.bypass", true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ import com.boydti.fawe.object.FawePlayer;
|
|||||||
import com.boydti.fawe.util.StringMan;
|
import com.boydti.fawe.util.StringMan;
|
||||||
|
|
||||||
public enum BBC {
|
public enum BBC {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Things to note about this class:
|
* Things to note about this class:
|
||||||
* Can use multiple arguments %s, %s1, %s2, %s3 etc
|
* Can use multiple arguments %s, %s1, %s2, %s3 etc
|
||||||
@ -46,7 +46,7 @@ public enum BBC {
|
|||||||
OOM(
|
OOM(
|
||||||
"&8[&cCritical&8] &cDetected low memory i.e. < 1%. FAWE will take the following actions:\n&8 - &7Terminate WE block placement\n&8 - &7Clear WE history\n&8 - &7Unload non essential chunks\n&8 - &7Kill entities\n&8 - &7Garbage collect\n&cIgnore this if trying to crash server.\n&7Note: Low memory is likely (but not necessarily) caused by WE",
|
"&8[&cCritical&8] &cDetected low memory i.e. < 1%. FAWE will take the following actions:\n&8 - &7Terminate WE block placement\n&8 - &7Clear WE history\n&8 - &7Unload non essential chunks\n&8 - &7Kill entities\n&8 - &7Garbage collect\n&cIgnore this if trying to crash server.\n&7Note: Low memory is likely (but not necessarily) caused by WE",
|
||||||
"Error");
|
"Error");
|
||||||
|
|
||||||
private static final HashMap<String, String> replacements = new HashMap<>();
|
private static final HashMap<String, String> replacements = new HashMap<>();
|
||||||
/**
|
/**
|
||||||
* Translated
|
* Translated
|
||||||
@ -64,7 +64,7 @@ public enum BBC {
|
|||||||
* Should the string be prefixed?
|
* Should the string be prefixed?
|
||||||
*/
|
*/
|
||||||
private boolean prefix;
|
private boolean prefix;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for custom strings.
|
* Constructor for custom strings.
|
||||||
*/
|
*/
|
||||||
@ -73,7 +73,7 @@ public enum BBC {
|
|||||||
* use setCustomString();
|
* use setCustomString();
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -82,13 +82,13 @@ public enum BBC {
|
|||||||
*/
|
*/
|
||||||
BBC(final String d, final boolean prefix, final String cat) {
|
BBC(final String d, final boolean prefix, final String cat) {
|
||||||
this.d = d;
|
this.d = d;
|
||||||
if (s == null) {
|
if (this.s == null) {
|
||||||
s = d;
|
this.s = d;
|
||||||
}
|
}
|
||||||
this.prefix = prefix;
|
this.prefix = prefix;
|
||||||
this.cat = cat.toLowerCase();
|
this.cat = cat.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -97,9 +97,9 @@ public enum BBC {
|
|||||||
BBC(final String d, final String cat) {
|
BBC(final String d, final String cat) {
|
||||||
this(d, true, cat.toLowerCase());
|
this(d, true, cat.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String format(final Object... args) {
|
public String format(final Object... args) {
|
||||||
String m = s;
|
String m = this.s;
|
||||||
for (int i = args.length - 1; i >= 0; i--) {
|
for (int i = args.length - 1; i >= 0; i--) {
|
||||||
if (args[i] == null) {
|
if (args[i] == null) {
|
||||||
continue;
|
continue;
|
||||||
@ -111,7 +111,7 @@ public enum BBC {
|
|||||||
}
|
}
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void load(final File file) {
|
public static void load(final File file) {
|
||||||
try {
|
try {
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
@ -178,34 +178,34 @@ public enum BBC {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String s() {
|
public String s() {
|
||||||
return s;
|
return this.s;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean usePrefix() {
|
public boolean usePrefix() {
|
||||||
return prefix;
|
return this.prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return translated and color decoded
|
* @return translated and color decoded
|
||||||
*
|
*
|
||||||
* @see org.bukkit.ChatColor#translateAlternateColorCodes(char, String)
|
* @see org.bukkit.ChatColor#translateAlternateColorCodes(char, String)
|
||||||
*/
|
*/
|
||||||
public String translated() {
|
public String translated() {
|
||||||
return ChatColor.translateAlternateColorCodes('&', s());
|
return ChatColor.translateAlternateColorCodes('&', this.s());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCat() {
|
public String getCat() {
|
||||||
return cat;
|
return this.cat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send(final FawePlayer<?> player, final Object... args) {
|
public void send(final FawePlayer<?> player, final Object... args) {
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
Fawe.debug(format(args));
|
Fawe.debug(this.format(args));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(format(args));
|
player.sendMessage(this.format(args));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import java.util.Map.Entry;
|
|||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
public class Settings {
|
public class Settings {
|
||||||
|
|
||||||
public static int MAX_BLOCKSTATES = 1337;
|
public static int MAX_BLOCKSTATES = 1337;
|
||||||
public static int MAX_ENTITIES = 1337;
|
public static int MAX_ENTITIES = 1337;
|
||||||
public static long WE_MAX_ITERATIONS = 1000;
|
public static long WE_MAX_ITERATIONS = 1000;
|
||||||
@ -22,7 +22,7 @@ public class Settings {
|
|||||||
public static List<String> WE_BLACKLIST = Arrays.asList("cs", ".s", "restore", "snapshot", "delchunks", "listchunks");
|
public static List<String> WE_BLACKLIST = Arrays.asList("cs", ".s", "restore", "snapshot", "delchunks", "listchunks");
|
||||||
public static long MEM_FREE = 95;
|
public static long MEM_FREE = 95;
|
||||||
public static boolean ENABLE_HARD_LIMIT = true;
|
public static boolean ENABLE_HARD_LIMIT = true;
|
||||||
|
|
||||||
public static void setup(final File file) {
|
public static void setup(final File file) {
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
file.getParentFile().mkdirs();
|
file.getParentFile().mkdirs();
|
||||||
@ -33,7 +33,7 @@ public class Settings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
final YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
|
final YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
|
||||||
|
|
||||||
final Map<String, Object> options = new HashMap<>();
|
final Map<String, Object> options = new HashMap<>();
|
||||||
options.put("max-blockstates", MAX_BLOCKSTATES);
|
options.put("max-blockstates", MAX_BLOCKSTATES);
|
||||||
options.put("max-entities", MAX_ENTITIES);
|
options.put("max-entities", MAX_ENTITIES);
|
||||||
@ -45,7 +45,7 @@ public class Settings {
|
|||||||
options.put("max-memory-percent", MEM_FREE);
|
options.put("max-memory-percent", MEM_FREE);
|
||||||
options.put("crash-mitigation", ENABLE_HARD_LIMIT);
|
options.put("crash-mitigation", ENABLE_HARD_LIMIT);
|
||||||
options.put("fix-all-lighting", FIX_ALL_LIGHTING);
|
options.put("fix-all-lighting", FIX_ALL_LIGHTING);
|
||||||
|
|
||||||
for (final Entry<String, Object> node : options.entrySet()) {
|
for (final Entry<String, Object> node : options.entrySet()) {
|
||||||
if (!config.contains(node.getKey())) {
|
if (!config.contains(node.getKey())) {
|
||||||
config.set(node.getKey(), node.getValue());
|
config.set(node.getKey(), node.getValue());
|
||||||
@ -61,7 +61,6 @@ public class Settings {
|
|||||||
REQUIRE_SELECTION = config.getBoolean("require-selection-in-mask");
|
REQUIRE_SELECTION = config.getBoolean("require-selection-in-mask");
|
||||||
WE_BLACKLIST = config.getStringList("command-blacklist");
|
WE_BLACKLIST = config.getStringList("command-blacklist");
|
||||||
ENABLE_HARD_LIMIT = config.getBoolean("crash-mitigation");
|
ENABLE_HARD_LIMIT = config.getBoolean("crash-mitigation");
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
config.save(file);
|
config.save(file);
|
||||||
|
@ -15,10 +15,10 @@ public class BlocksHubHook {
|
|||||||
|
|
||||||
public BlocksHubHook() {
|
public BlocksHubHook() {
|
||||||
this.hub = (BlocksHub) Bukkit.getServer().getPluginManager().getPlugin("BlocksHub");
|
this.hub = (BlocksHub) Bukkit.getServer().getPluginManager().getPlugin("BlocksHub");
|
||||||
this.api = hub.getApi();
|
this.api = this.hub.getApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Extent getLoggingExtent(Extent parent, ChangeSet set, FawePlayer<?> player) {
|
public Extent getLoggingExtent(final Extent parent, final ChangeSet set, final FawePlayer<?> player) {
|
||||||
return new LoggingExtent(parent, set, (FawePlayer<Player>) player, api);
|
return new LoggingExtent(parent, set, (FawePlayer<Player>) player, this.api);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,40 +31,40 @@ import com.sk89q.worldedit.util.Location;
|
|||||||
* Logs changes to BlocksHub
|
* Logs changes to BlocksHub
|
||||||
*/
|
*/
|
||||||
public class LoggingExtent extends AbstractDelegateExtent {
|
public class LoggingExtent extends AbstractDelegateExtent {
|
||||||
|
|
||||||
private final ChangeSet changeSet;
|
private final ChangeSet changeSet;
|
||||||
private final IBlocksHubApi api;
|
private final IBlocksHubApi api;
|
||||||
private final String playerName;
|
private final String playerName;
|
||||||
private final World world;
|
private final World world;
|
||||||
private final org.bukkit.Location loc;
|
private final org.bukkit.Location loc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
*
|
*
|
||||||
* @param extent the extent
|
* @param extent the extent
|
||||||
* @param changeSet the change set
|
* @param changeSet the change set
|
||||||
* @param api
|
* @param api
|
||||||
* @param player
|
* @param player
|
||||||
* @param thread
|
* @param thread
|
||||||
*/
|
*/
|
||||||
public LoggingExtent(final Extent extent, final ChangeSet changeSet, FawePlayer<Player> player, IBlocksHubApi api) {
|
public LoggingExtent(final Extent extent, final ChangeSet changeSet, final FawePlayer<Player> player, final IBlocksHubApi api) {
|
||||||
super(extent);
|
super(extent);
|
||||||
checkNotNull(changeSet);
|
checkNotNull(changeSet);
|
||||||
this.changeSet = changeSet;
|
this.changeSet = changeSet;
|
||||||
this.api = api;
|
this.api = api;
|
||||||
this.playerName = player.getName();
|
this.playerName = player.getName();
|
||||||
this.world = player.parent.getWorld();
|
this.world = player.parent.getWorld();
|
||||||
this.loc = new org.bukkit.Location(world, 0, 0, 0);
|
this.loc = new org.bukkit.Location(this.world, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean setBlock(final Vector location, final BaseBlock block) throws WorldEditException {
|
public synchronized boolean setBlock(final Vector location, final BaseBlock block) throws WorldEditException {
|
||||||
if (super.setBlock(location, block)) {
|
if (super.setBlock(location, block)) {
|
||||||
BaseBlock previous;
|
BaseBlock previous;
|
||||||
try {
|
try {
|
||||||
previous = getBlock(location);
|
previous = this.getBlock(location);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
previous = getBlock(location);
|
previous = this.getBlock(location);
|
||||||
}
|
}
|
||||||
final int id_p = previous.getId();
|
final int id_p = previous.getId();
|
||||||
final int id_b = block.getId();
|
final int id_b = block.getId();
|
||||||
@ -152,47 +152,47 @@ public class LoggingExtent extends AbstractDelegateExtent {
|
|||||||
if (id_p == id_b) {
|
if (id_p == id_b) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
loc.setX(location.getX());
|
this.loc.setX(location.getX());
|
||||||
loc.setY(location.getY());
|
this.loc.setY(location.getY());
|
||||||
loc.setZ(location.getZ());
|
this.loc.setZ(location.getZ());
|
||||||
api.logBlock(playerName, world, loc, id_p, (byte) 0, id_b, (byte) 0);
|
this.api.logBlock(this.playerName, this.world, this.loc, id_p, (byte) 0, id_b, (byte) 0);
|
||||||
default:
|
default:
|
||||||
int data_p = previous.getData();
|
final int data_p = previous.getData();
|
||||||
int data_b = block.getData();
|
final int data_b = block.getData();
|
||||||
if (id_p == id_b && data_b == data_p) {
|
if ((id_p == id_b) && (data_b == data_p)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
loc.setX(location.getX());
|
this.loc.setX(location.getX());
|
||||||
loc.setY(location.getY());
|
this.loc.setY(location.getY());
|
||||||
loc.setZ(location.getZ());
|
this.loc.setZ(location.getZ());
|
||||||
api.logBlock(playerName, world, loc, id_p, (byte) data_p, id_b, (byte) data_b);
|
this.api.logBlock(this.playerName, this.world, this.loc, id_p, (byte) data_p, id_b, (byte) data_b);
|
||||||
}
|
}
|
||||||
changeSet.add(new BlockChange(location.toBlockVector(), previous, block));
|
this.changeSet.add(new BlockChange(location.toBlockVector(), previous, block));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Entity createEntity(final Location location, final BaseEntity state) {
|
public Entity createEntity(final Location location, final BaseEntity state) {
|
||||||
final Entity entity = super.createEntity(location, state);
|
final Entity entity = super.createEntity(location, state);
|
||||||
if (state != null) {
|
if (state != null) {
|
||||||
changeSet.add(new EntityCreate(location, state, entity));
|
this.changeSet.add(new EntityCreate(location, state, entity));
|
||||||
}
|
}
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Entity> getEntities() {
|
public List<? extends Entity> getEntities() {
|
||||||
return wrapEntities(super.getEntities());
|
return this.wrapEntities(super.getEntities());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Entity> getEntities(final Region region) {
|
public List<? extends Entity> getEntities(final Region region) {
|
||||||
return wrapEntities(super.getEntities(region));
|
return this.wrapEntities(super.getEntities(region));
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<? extends Entity> wrapEntities(final List<? extends Entity> entities) {
|
private List<? extends Entity> wrapEntities(final List<? extends Entity> entities) {
|
||||||
final List<Entity> newList = new ArrayList<Entity>(entities.size());
|
final List<Entity> newList = new ArrayList<Entity>(entities.size());
|
||||||
for (final Entity entity : entities) {
|
for (final Entity entity : entities) {
|
||||||
@ -200,44 +200,44 @@ public class LoggingExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
return newList;
|
return newList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TrackedEntity implements Entity {
|
private class TrackedEntity implements Entity {
|
||||||
private final Entity entity;
|
private final Entity entity;
|
||||||
|
|
||||||
private TrackedEntity(final Entity entity) {
|
private TrackedEntity(final Entity entity) {
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseEntity getState() {
|
public BaseEntity getState() {
|
||||||
return entity.getState();
|
return this.entity.getState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getLocation() {
|
public Location getLocation() {
|
||||||
return entity.getLocation();
|
return this.entity.getLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Extent getExtent() {
|
public Extent getExtent() {
|
||||||
return entity.getExtent();
|
return this.entity.getExtent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean remove() {
|
public boolean remove() {
|
||||||
final Location location = entity.getLocation();
|
final Location location = this.entity.getLocation();
|
||||||
final BaseEntity state = entity.getState();
|
final BaseEntity state = this.entity.getState();
|
||||||
final boolean success = entity.remove();
|
final boolean success = this.entity.remove();
|
||||||
if ((state != null) && success) {
|
if ((state != null) && success) {
|
||||||
changeSet.add(new EntityRemove(location, state));
|
LoggingExtent.this.changeSet.add(new EntityRemove(location, state));
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public <T> T getFacet(final Class<? extends T> cls) {
|
public <T> T getFacet(final Class<? extends T> cls) {
|
||||||
return entity.getFacet(cls);
|
return this.entity.getFacet(cls);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,36 +4,36 @@ public class ChunkLoc {
|
|||||||
public final int x;
|
public final int x;
|
||||||
public final int z;
|
public final int z;
|
||||||
public final String world;
|
public final String world;
|
||||||
|
|
||||||
public ChunkLoc(final String world, final int x, final int z) {
|
public ChunkLoc(final String world, final int x, final int z) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result;
|
int result;
|
||||||
if (x >= 0) {
|
if (this.x >= 0) {
|
||||||
if (z >= 0) {
|
if (this.z >= 0) {
|
||||||
result = (x * x) + (3 * x) + (2 * x * z) + z + (z * z);
|
result = (this.x * this.x) + (3 * this.x) + (2 * this.x * this.z) + this.z + (this.z * this.z);
|
||||||
} else {
|
} else {
|
||||||
final int y1 = -z;
|
final int y1 = -this.z;
|
||||||
result = (x * x) + (3 * x) + (2 * x * y1) + y1 + (y1 * y1) + 1;
|
result = (this.x * this.x) + (3 * this.x) + (2 * this.x * y1) + y1 + (y1 * y1) + 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final int x1 = -x;
|
final int x1 = -this.x;
|
||||||
if (z >= 0) {
|
if (this.z >= 0) {
|
||||||
result = -((x1 * x1) + (3 * x1) + (2 * x1 * z) + z + (z * z));
|
result = -((x1 * x1) + (3 * x1) + (2 * x1 * this.z) + this.z + (this.z * this.z));
|
||||||
} else {
|
} else {
|
||||||
final int y1 = -z;
|
final int y1 = -this.z;
|
||||||
result = -((x1 * x1) + (3 * x1) + (2 * x1 * y1) + y1 + (y1 * y1) + 1);
|
result = -((x1 * x1) + (3 * x1) + (2 * x1 * y1) + y1 + (y1 * y1) + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result = (result * 31) + world.hashCode();
|
result = (result * 31) + this.world.hashCode();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) {
|
public boolean equals(final Object obj) {
|
||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
@ -42,15 +42,15 @@ public class ChunkLoc {
|
|||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getClass() != obj.getClass()) {
|
if (this.getClass() != obj.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final ChunkLoc other = (ChunkLoc) obj;
|
final ChunkLoc other = (ChunkLoc) obj;
|
||||||
return ((x == other.x) && (z == other.z) && (world.equals(other.world)));
|
return ((this.x == other.x) && (this.z == other.z) && (this.world.equals(other.world)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return world + ":" + x + "," + z;
|
return this.world + ":" + this.x + "," + this.z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,26 +7,26 @@ import com.sk89q.worldedit.extent.Extent;
|
|||||||
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
||||||
|
|
||||||
public class EditSessionWrapper {
|
public class EditSessionWrapper {
|
||||||
|
|
||||||
public final EditSession session;
|
public final EditSession session;
|
||||||
|
|
||||||
public EditSessionWrapper(final EditSession session) {
|
public EditSessionWrapper(final EditSession session) {
|
||||||
this.session = session;
|
this.session = session;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getHighestTerrainBlock(final int x, final int z, final int minY, final int maxY, final boolean naturalOnly) {
|
public int getHighestTerrainBlock(final int x, final int z, final int minY, final int maxY, final boolean naturalOnly) {
|
||||||
for (int y = maxY; y >= minY; --y) {
|
for (int y = maxY; y >= minY; --y) {
|
||||||
final Vector pt = new Vector(x, y, z);
|
final Vector pt = new Vector(x, y, z);
|
||||||
final int id = session.getBlockType(pt);
|
final int id = this.session.getBlockType(pt);
|
||||||
final int data = session.getBlockData(pt);
|
final int data = this.session.getBlockData(pt);
|
||||||
if (naturalOnly ? BlockType.isNaturalTerrainBlock(id, data) : !BlockType.canPassThrough(id, data)) {
|
if (naturalOnly ? BlockType.isNaturalTerrainBlock(id, data) : !BlockType.canPassThrough(id, data)) {
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return minY;
|
return minY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Extent getHistoryExtent(Extent parent, ChangeSet set, FawePlayer<?> player) {
|
public Extent getHistoryExtent(final Extent parent, final ChangeSet set, final FawePlayer<?> player) {
|
||||||
return new HistoryExtent(parent, set);
|
return new HistoryExtent(parent, set);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,16 +19,16 @@ import com.sk89q.worldedit.world.World;
|
|||||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||||
|
|
||||||
public class FastWorldEditExtent extends AbstractDelegateExtent {
|
public class FastWorldEditExtent extends AbstractDelegateExtent {
|
||||||
|
|
||||||
private final String world;
|
private final String world;
|
||||||
private final Thread thread;
|
private final Thread thread;
|
||||||
|
|
||||||
public FastWorldEditExtent(World world, Thread thread) {
|
public FastWorldEditExtent(final World world, final Thread thread) {
|
||||||
super(world);
|
super(world);
|
||||||
this.thread = thread;
|
this.thread = thread;
|
||||||
this.world = world.getName();
|
this.world = world.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Entity createEntity(final Location location, final BaseEntity entity) {
|
public Entity createEntity(final Location location, final BaseEntity entity) {
|
||||||
TaskManager.IMP.task(new Runnable() {
|
TaskManager.IMP.task(new Runnable() {
|
||||||
@ -39,70 +39,70 @@ public class FastWorldEditExtent extends AbstractDelegateExtent {
|
|||||||
});
|
});
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBiome getBiome(Vector2D position) {
|
public BaseBiome getBiome(final Vector2D position) {
|
||||||
if (!SetQueue.IMP.isChunkLoaded(world, position.getBlockX() >> 4, position.getBlockZ() >> 4)) {
|
if (!SetQueue.IMP.isChunkLoaded(this.world, position.getBlockX() >> 4, position.getBlockZ() >> 4)) {
|
||||||
return EditSession.nullBiome;
|
return EditSession.nullBiome;
|
||||||
}
|
}
|
||||||
synchronized (thread) {
|
synchronized (this.thread) {
|
||||||
return super.getBiome(position);
|
return super.getBiome(position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private BaseBlock lastBlock;
|
private BaseBlock lastBlock;
|
||||||
private BlockVector lastVector;
|
private BlockVector lastVector;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getLazyBlock(Vector position) {
|
public BaseBlock getLazyBlock(final Vector position) {
|
||||||
if (lastBlock != null && lastVector.equals(position.toBlockVector())) {
|
if ((this.lastBlock != null) && this.lastVector.equals(position.toBlockVector())) {
|
||||||
return lastBlock;
|
return this.lastBlock;
|
||||||
}
|
}
|
||||||
if (!SetQueue.IMP.isChunkLoaded(world, position.getBlockX() >> 4, position.getBlockZ() >> 4)) {
|
if (!SetQueue.IMP.isChunkLoaded(this.world, position.getBlockX() >> 4, position.getBlockZ() >> 4)) {
|
||||||
try {
|
try {
|
||||||
lastVector = position.toBlockVector();
|
this.lastVector = position.toBlockVector();
|
||||||
return lastBlock = super.getBlock(position);
|
return this.lastBlock = super.getBlock(position);
|
||||||
} catch (Throwable e) {
|
} catch (final Throwable e) {
|
||||||
return EditSession.nullBlock;
|
return EditSession.nullBlock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
synchronized (thread) {
|
synchronized (this.thread) {
|
||||||
lastVector = position.toBlockVector();
|
this.lastVector = position.toBlockVector();
|
||||||
return lastBlock = super.getBlock(position);
|
return this.lastBlock = super.getBlock(position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Entity> getEntities() {
|
public List<? extends Entity> getEntities() {
|
||||||
synchronized (thread) {
|
synchronized (this.thread) {
|
||||||
return super.getEntities();
|
return super.getEntities();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Entity> getEntities(Region region) {
|
public List<? extends Entity> getEntities(final Region region) {
|
||||||
synchronized (thread) {
|
synchronized (this.thread) {
|
||||||
return super.getEntities(region);
|
return super.getEntities(region);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getBlock(Vector position) {
|
public BaseBlock getBlock(final Vector position) {
|
||||||
return getLazyBlock(position);
|
return this.getLazyBlock(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(Vector2D position, BaseBiome biome) {
|
public boolean setBiome(final Vector2D position, final BaseBiome biome) {
|
||||||
SetQueue.IMP.setBiome(world, position.getBlockX(), position.getBlockZ(), biome);
|
SetQueue.IMP.setBiome(this.world, position.getBlockX(), position.getBlockZ(), biome);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
|
public boolean setBlock(final Vector location, final BaseBlock block) throws WorldEditException {
|
||||||
short id = (short) block.getId();
|
final short id = (short) block.getId();
|
||||||
int x = location.getBlockX();
|
final int x = location.getBlockX();
|
||||||
int y = location.getBlockY();
|
final int y = location.getBlockY();
|
||||||
int z = location.getBlockZ();
|
final int z = location.getBlockZ();
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 0:
|
case 0:
|
||||||
case 2:
|
case 2:
|
||||||
@ -183,14 +183,14 @@ public class FastWorldEditExtent extends AbstractDelegateExtent {
|
|||||||
case 190:
|
case 190:
|
||||||
case 191:
|
case 191:
|
||||||
case 192: {
|
case 192: {
|
||||||
SetQueue.IMP.setBlock(world, x, y, z, id);
|
SetQueue.IMP.setBlock(this.world, x, y, z, id);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
SetQueue.IMP.setBlock(world, x, y, z, id, (byte) block.getData());
|
SetQueue.IMP.setBlock(this.world, x, y, z, id, (byte) block.getData());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,9 @@ import com.sk89q.worldedit.history.change.Change;
|
|||||||
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
||||||
|
|
||||||
public class FaweChangeSet implements ChangeSet {
|
public class FaweChangeSet implements ChangeSet {
|
||||||
|
|
||||||
private final ArrayDeque<Change> changes = new ArrayDeque<>();
|
private final ArrayDeque<Change> changes = new ArrayDeque<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(final Change change) {
|
public void add(final Change change) {
|
||||||
if (change.getClass() == BlockChange.class) {
|
if (change.getClass() == BlockChange.class) {
|
||||||
@ -21,24 +21,24 @@ public class FaweChangeSet implements ChangeSet {
|
|||||||
// int x = pos.getBlockX();
|
// int x = pos.getBlockX();
|
||||||
// int y = pos.getBlockY();
|
// int y = pos.getBlockY();
|
||||||
// int z = pos.getBlockZ();
|
// int z = pos.getBlockZ();
|
||||||
changes.add(bc);
|
this.changes.add(bc);
|
||||||
} else {
|
} else {
|
||||||
changes.add(change);
|
this.changes.add(change);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Change> backwardIterator() {
|
public Iterator<Change> backwardIterator() {
|
||||||
return changes.descendingIterator();
|
return this.changes.descendingIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Change> forwardIterator() {
|
public Iterator<Change> forwardIterator() {
|
||||||
return changes.iterator();
|
return this.changes.iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
return changes.size();
|
return this.changes.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,61 +5,61 @@ import com.boydti.fawe.util.SetQueue;
|
|||||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||||
|
|
||||||
public abstract class FaweChunk<T> {
|
public abstract class FaweChunk<T> {
|
||||||
|
|
||||||
private ChunkLoc chunk;
|
private ChunkLoc chunk;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A FaweSections object represents a chunk and the blocks that you wish to change in it.
|
* A FaweSections object represents a chunk and the blocks that you wish to change in it.
|
||||||
*/
|
*/
|
||||||
public FaweChunk(final ChunkLoc chunk) {
|
public FaweChunk(final ChunkLoc chunk) {
|
||||||
this.chunk = chunk;
|
this.chunk = chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChunkLoc(final ChunkLoc loc) {
|
public void setChunkLoc(final ChunkLoc loc) {
|
||||||
this.chunk = loc;
|
this.chunk = loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChunkLoc getChunkLoc() {
|
public ChunkLoc getChunkLoc() {
|
||||||
return this.chunk;
|
return this.chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addToQueue() {
|
public void addToQueue() {
|
||||||
if (chunk == null) {
|
if (this.chunk == null) {
|
||||||
throw new IllegalArgumentException("Chunk location cannot be null!");
|
throw new IllegalArgumentException("Chunk location cannot be null!");
|
||||||
}
|
}
|
||||||
SetQueue.IMP.queue.setChunk(this);
|
SetQueue.IMP.queue.setChunk(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fixLighting() {
|
public void fixLighting() {
|
||||||
SetQueue.IMP.queue.fixLighting(this, Settings.FIX_ALL_LIGHTING);
|
SetQueue.IMP.queue.fixLighting(this, Settings.FIX_ALL_LIGHTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fill(int id, byte data) {
|
public void fill(final int id, final byte data) {
|
||||||
for (int x = 0; x < 16; x++) {
|
for (int x = 0; x < 16; x++) {
|
||||||
for (int y = 0; y < 256; y++) {
|
for (int y = 0; y < 256; y++) {
|
||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; z++) {
|
||||||
setBlock(x, y, z, id, data);
|
this.setBlock(x, y, z, id, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract T getChunk();
|
public abstract T getChunk();
|
||||||
|
|
||||||
public abstract void setBlock(final int x, final int y, final int z, final int id, final byte data);
|
public abstract void setBlock(final int x, final int y, final int z, final int id, final byte data);
|
||||||
|
|
||||||
public abstract void setBiome(int x, int z, BaseBiome biome);
|
public abstract void setBiome(final int x, final int z, final BaseBiome biome);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return chunk.hashCode();
|
return this.chunk.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(final Object obj) {
|
||||||
if (obj == null || !(obj instanceof FaweChunk)) {
|
if ((obj == null) || !(obj instanceof FaweChunk)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return chunk.equals(((FaweChunk) obj).chunk);
|
return this.chunk.equals(((FaweChunk) obj).chunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,14 +2,14 @@ package com.boydti.fawe.object;
|
|||||||
|
|
||||||
public abstract class FaweCommand<T> {
|
public abstract class FaweCommand<T> {
|
||||||
public final String perm;
|
public final String perm;
|
||||||
|
|
||||||
public FaweCommand(final String perm) {
|
public FaweCommand(final String perm) {
|
||||||
this.perm = perm;
|
this.perm = perm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPerm() {
|
public String getPerm() {
|
||||||
return perm;
|
return this.perm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract boolean execute(final FawePlayer<T> player, final String... args);
|
public abstract boolean execute(final FawePlayer<T> player, final String... args);
|
||||||
}
|
}
|
||||||
|
@ -5,20 +5,19 @@ import com.boydti.fawe.util.SetQueue;
|
|||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class FaweLocation {
|
public class FaweLocation {
|
||||||
|
|
||||||
|
|
||||||
public final int x;
|
public final int x;
|
||||||
public final int y;
|
public final int y;
|
||||||
public final int z;
|
public final int z;
|
||||||
public final String world;
|
public final String world;
|
||||||
|
|
||||||
public FaweLocation(String world, int x, int y, int z) {
|
public FaweLocation(final String world, final int x, final int y, final int z) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) {
|
public boolean equals(final Object obj) {
|
||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
@ -27,19 +26,19 @@ public class FaweLocation {
|
|||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getClass() != obj.getClass()) {
|
if (this.getClass() != obj.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final FaweLocation other = (FaweLocation) obj;
|
final FaweLocation other = (FaweLocation) obj;
|
||||||
return ((x == other.x) && (y == other.y) && (z == other.z) && (world.equals(other.world)));
|
return ((this.x == other.x) && (this.y == other.y) && (this.z == other.z) && (this.world.equals(other.world)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return x << 8 + z << 4 + y;
|
return this.x << (8 + this.z) << (4 + this.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlockAsync(short id, byte data) {
|
public void setBlockAsync(final short id, final byte data) {
|
||||||
SetQueue.IMP.setBlock(world, x, y, z, id, data);
|
SetQueue.IMP.setBlock(this.world, this.x, this.y, this.z, id, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,61 +13,61 @@ import com.sk89q.worldedit.regions.RegionSelector;
|
|||||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||||
|
|
||||||
public abstract class FawePlayer<T> {
|
public abstract class FawePlayer<T> {
|
||||||
|
|
||||||
public final T parent;
|
public final T parent;
|
||||||
private LocalSession session;
|
private LocalSession session;
|
||||||
|
|
||||||
public static <T> FawePlayer<T> wrap(final Object obj) {
|
public static <T> FawePlayer<T> wrap(final Object obj) {
|
||||||
return Fawe.imp().wrap(obj);
|
return Fawe.imp().wrap(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FawePlayer(final T parent) {
|
public FawePlayer(final T parent) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String getName();
|
public abstract String getName();
|
||||||
|
|
||||||
public abstract UUID getUUID();
|
public abstract UUID getUUID();
|
||||||
|
|
||||||
public abstract boolean hasPermission(final String perm);
|
public abstract boolean hasPermission(final String perm);
|
||||||
|
|
||||||
public abstract void setPermission(final String perm, final boolean flag);
|
public abstract void setPermission(final String perm, final boolean flag);
|
||||||
|
|
||||||
public abstract void sendMessage(final String message);
|
public abstract void sendMessage(final String message);
|
||||||
|
|
||||||
public abstract void executeCommand(final String substring);
|
public abstract void executeCommand(final String substring);
|
||||||
|
|
||||||
public abstract FaweLocation getLocation();
|
public abstract FaweLocation getLocation();
|
||||||
|
|
||||||
public abstract Player getPlayer();
|
public abstract Player getPlayer();
|
||||||
|
|
||||||
public Region getSelection() {
|
public Region getSelection() {
|
||||||
try {
|
try {
|
||||||
return getSession().getSelection(getPlayer().getWorld());
|
return this.getSession().getSelection(this.getPlayer().getWorld());
|
||||||
} catch (IncompleteRegionException e) {
|
} catch (final IncompleteRegionException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalSession getSession() {
|
public LocalSession getSession() {
|
||||||
return session != null ? session : Fawe.get().getWorldEdit().getSession(getPlayer());
|
return this.session != null ? this.session : Fawe.get().getWorldEdit().getSession(this.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashSet<RegionWrapper> getCurrentRegions() {
|
public HashSet<RegionWrapper> getCurrentRegions() {
|
||||||
return WEManager.IMP.getMask(this);
|
return WEManager.IMP.getMask(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelection(RegionWrapper region) {
|
public void setSelection(final RegionWrapper region) {
|
||||||
Player player = getPlayer();
|
final Player player = this.getPlayer();
|
||||||
RegionSelector selector = new CuboidRegionSelector(player.getWorld(), region.getBottomVector(), region.getTopVector());
|
final RegionSelector selector = new CuboidRegionSelector(player.getWorld(), region.getBottomVector(), region.getTopVector());
|
||||||
getSession().setRegionSelector(player.getWorld(), selector);
|
this.getSession().setRegionSelector(player.getWorld(), selector);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RegionWrapper getLargestRegion() {
|
public RegionWrapper getLargestRegion() {
|
||||||
int area = 0;
|
int area = 0;
|
||||||
RegionWrapper max = null;
|
RegionWrapper max = null;
|
||||||
for (RegionWrapper region : getCurrentRegions()) {
|
for (final RegionWrapper region : this.getCurrentRegions()) {
|
||||||
int tmp = (region.maxX - region.minX) * (region.maxZ - region.minZ);
|
final int tmp = (region.maxX - region.minX) * (region.maxZ - region.minZ);
|
||||||
if (tmp > area) {
|
if (tmp > area) {
|
||||||
area = tmp;
|
area = tmp;
|
||||||
max = region;
|
max = region;
|
||||||
@ -75,13 +75,13 @@ public abstract class FawePlayer<T> {
|
|||||||
}
|
}
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getName();
|
return this.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasWorldEditBypass() {
|
public boolean hasWorldEditBypass() {
|
||||||
return hasPermission("fawe.bypass");
|
return this.hasPermission("fawe.bypass");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,9 @@ import com.sk89q.worldedit.util.Location;
|
|||||||
* Stores changes to a {@link ChangeSet}.
|
* Stores changes to a {@link ChangeSet}.
|
||||||
*/
|
*/
|
||||||
public class HistoryExtent extends AbstractDelegateExtent {
|
public class HistoryExtent extends AbstractDelegateExtent {
|
||||||
|
|
||||||
private final ChangeSet changeSet;
|
private final ChangeSet changeSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
*
|
*
|
||||||
@ -40,15 +40,15 @@ public class HistoryExtent extends AbstractDelegateExtent {
|
|||||||
checkNotNull(changeSet);
|
checkNotNull(changeSet);
|
||||||
this.changeSet = changeSet;
|
this.changeSet = changeSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean setBlock(final Vector location, final BaseBlock block) throws WorldEditException {
|
public synchronized boolean setBlock(final Vector location, final BaseBlock block) throws WorldEditException {
|
||||||
if (super.setBlock(location, block)) {
|
if (super.setBlock(location, block)) {
|
||||||
BaseBlock previous;
|
BaseBlock previous;
|
||||||
try {
|
try {
|
||||||
previous = getBlock(location);
|
previous = this.getBlock(location);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
previous = getBlock(location);
|
previous = this.getBlock(location);
|
||||||
}
|
}
|
||||||
final int id_p = previous.getId();
|
final int id_p = previous.getId();
|
||||||
final int id_b = block.getId();
|
final int id_b = block.getId();
|
||||||
@ -141,32 +141,32 @@ public class HistoryExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
changeSet.add(new BlockChange(location.toBlockVector(), previous, block));
|
this.changeSet.add(new BlockChange(location.toBlockVector(), previous, block));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Entity createEntity(final Location location, final BaseEntity state) {
|
public Entity createEntity(final Location location, final BaseEntity state) {
|
||||||
final Entity entity = super.createEntity(location, state);
|
final Entity entity = super.createEntity(location, state);
|
||||||
if (state != null && entity != null) {
|
if ((state != null) && (entity != null)) {
|
||||||
changeSet.add(new EntityCreate(location, state, entity));
|
this.changeSet.add(new EntityCreate(location, state, entity));
|
||||||
}
|
}
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Entity> getEntities() {
|
public List<? extends Entity> getEntities() {
|
||||||
return wrapEntities(super.getEntities());
|
return this.wrapEntities(super.getEntities());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Entity> getEntities(final Region region) {
|
public List<? extends Entity> getEntities(final Region region) {
|
||||||
return wrapEntities(super.getEntities(region));
|
return this.wrapEntities(super.getEntities(region));
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<? extends Entity> wrapEntities(final List<? extends Entity> entities) {
|
private List<? extends Entity> wrapEntities(final List<? extends Entity> entities) {
|
||||||
final List<Entity> newList = new ArrayList<Entity>(entities.size());
|
final List<Entity> newList = new ArrayList<Entity>(entities.size());
|
||||||
for (final Entity entity : entities) {
|
for (final Entity entity : entities) {
|
||||||
@ -174,44 +174,44 @@ public class HistoryExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
return newList;
|
return newList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TrackedEntity implements Entity {
|
private class TrackedEntity implements Entity {
|
||||||
private final Entity entity;
|
private final Entity entity;
|
||||||
|
|
||||||
private TrackedEntity(final Entity entity) {
|
private TrackedEntity(final Entity entity) {
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseEntity getState() {
|
public BaseEntity getState() {
|
||||||
return entity.getState();
|
return this.entity.getState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getLocation() {
|
public Location getLocation() {
|
||||||
return entity.getLocation();
|
return this.entity.getLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Extent getExtent() {
|
public Extent getExtent() {
|
||||||
return entity.getExtent();
|
return this.entity.getExtent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean remove() {
|
public boolean remove() {
|
||||||
final Location location = entity.getLocation();
|
final Location location = this.entity.getLocation();
|
||||||
final BaseEntity state = entity.getState();
|
final BaseEntity state = this.entity.getState();
|
||||||
final boolean success = entity.remove();
|
final boolean success = this.entity.remove();
|
||||||
if ((state != null) && success) {
|
if ((state != null) && success) {
|
||||||
changeSet.add(new EntityRemove(location, state));
|
HistoryExtent.this.changeSet.add(new EntityRemove(location, state));
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public <T> T getFacet(final Class<? extends T> cls) {
|
public <T> T getFacet(final Class<? extends T> cls) {
|
||||||
return entity.getFacet(cls);
|
return this.entity.getFacet(cls);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,48 +3,48 @@ package com.boydti.fawe.object;
|
|||||||
public class IntegerPair {
|
public class IntegerPair {
|
||||||
public int x;
|
public int x;
|
||||||
public int z;
|
public int z;
|
||||||
|
|
||||||
public IntegerPair(final int x, final int z) {
|
public IntegerPair(final int x, final int z) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
int hash;
|
int hash;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
if (hash == 0) {
|
if (this.hash == 0) {
|
||||||
long val = 0;
|
long val = 0;
|
||||||
if (x >= 0) {
|
if (this.x >= 0) {
|
||||||
if (z >= 0) {
|
if (this.z >= 0) {
|
||||||
val = (x * x) + (3 * x) + (2 * x * z) + z + (z * z);
|
val = (this.x * this.x) + (3 * this.x) + (2 * this.x * this.z) + this.z + (this.z * this.z);
|
||||||
} else {
|
} else {
|
||||||
final int z1 = -z;
|
final int z1 = -this.z;
|
||||||
val = (x * x) + (3 * x) + (2 * x * z1) + z1 + (z1 * z1) + 1;
|
val = (this.x * this.x) + (3 * this.x) + (2 * this.x * z1) + z1 + (z1 * z1) + 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final int x1 = -x;
|
final int x1 = -this.x;
|
||||||
if (z >= 0) {
|
if (this.z >= 0) {
|
||||||
val = -((x1 * x1) + (3 * x1) + (2 * x1 * z) + z + (z * z));
|
val = -((x1 * x1) + (3 * x1) + (2 * x1 * this.z) + this.z + (this.z * this.z));
|
||||||
} else {
|
} else {
|
||||||
final int z1 = -z;
|
final int z1 = -this.z;
|
||||||
val = -((x1 * x1) + (3 * x1) + (2 * x1 * z1) + z1 + (z1 * z1) + 1);
|
val = -((x1 * x1) + (3 * x1) + (2 * x1 * z1) + z1 + (z1 * z1) + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hash = (int) (val % Integer.MAX_VALUE);
|
this.hash = (int) (val % Integer.MAX_VALUE);
|
||||||
}
|
}
|
||||||
return hash;
|
return this.hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) {
|
public boolean equals(final Object obj) {
|
||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ((obj == null) || (hashCode() != obj.hashCode()) || (getClass() != obj.getClass())) {
|
if ((obj == null) || (this.hashCode() != obj.hashCode()) || (this.getClass() != obj.getClass())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final IntegerPair other = (IntegerPair) obj;
|
final IntegerPair other = (IntegerPair) obj;
|
||||||
return ((x == other.x) && (z == other.z));
|
return ((this.x == other.x) && (this.z == other.z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,60 +17,60 @@ import com.sk89q.worldedit.util.Location;
|
|||||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||||
|
|
||||||
public class NullExtent implements Extent {
|
public class NullExtent implements Extent {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBiome getBiome(final Vector2D arg0) {
|
public BaseBiome getBiome(final Vector2D arg0) {
|
||||||
return EditSession.nullBiome;
|
return EditSession.nullBiome;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getBlock(final Vector arg0) {
|
public BaseBlock getBlock(final Vector arg0) {
|
||||||
return EditSession.nullBlock;
|
return EditSession.nullBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getLazyBlock(final Vector arg0) {
|
public BaseBlock getLazyBlock(final Vector arg0) {
|
||||||
return EditSession.nullBlock;
|
return EditSession.nullBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Operation commit() {
|
public Operation commit() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(final Vector2D arg0, final BaseBiome arg1) {
|
public boolean setBiome(final Vector2D arg0, final BaseBiome arg1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(final Vector arg0, final BaseBlock arg1) throws WorldEditException {
|
public boolean setBlock(final Vector arg0, final BaseBlock arg1) throws WorldEditException {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Entity createEntity(final Location arg0, final BaseEntity arg1) {
|
public Entity createEntity(final Location arg0, final BaseEntity arg1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Entity> getEntities() {
|
public List<? extends Entity> getEntities() {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Entity> getEntities(final Region arg0) {
|
public List<? extends Entity> getEntities(final Region arg0) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector getMaximumPoint() {
|
public Vector getMaximumPoint() {
|
||||||
return new Vector(0, 0, 0);
|
return new Vector(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector getMinimumPoint() {
|
public Vector getMinimumPoint() {
|
||||||
return new Vector(0, 0, 0);
|
return new Vector(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ import com.sk89q.worldedit.world.biome.BaseBiome;
|
|||||||
|
|
||||||
public class ProcessedWEExtent extends AbstractDelegateExtent {
|
public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||||
private Extent parent;
|
private Extent parent;
|
||||||
|
|
||||||
private boolean BSblocked = false;
|
private boolean BSblocked = false;
|
||||||
private boolean Eblocked = false;
|
private boolean Eblocked = false;
|
||||||
private int BScount = 0;
|
private int BScount = 0;
|
||||||
@ -38,8 +38,8 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
private final String world;
|
private final String world;
|
||||||
private final HashSet<RegionWrapper> mask;
|
private final HashSet<RegionWrapper> mask;
|
||||||
private final Thread thread;
|
private final Thread thread;
|
||||||
|
|
||||||
public ProcessedWEExtent(World world, Thread thread, FawePlayer<?> player, HashSet<RegionWrapper> mask, int max) {
|
public ProcessedWEExtent(final World world, final Thread thread, final FawePlayer<?> player, final HashSet<RegionWrapper> mask, final int max) {
|
||||||
super(world);
|
super(world);
|
||||||
this.user = player;
|
this.user = player;
|
||||||
this.world = world.getName();
|
this.world = world.getName();
|
||||||
@ -47,26 +47,26 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
this.mask = mask;
|
this.mask = mask;
|
||||||
this.thread = thread;
|
this.thread = thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMax(int max) {
|
public void setMax(final int max) {
|
||||||
this.max = max != -1 ? max : Integer.MAX_VALUE;
|
this.max = max != -1 ? max : Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParent(Extent parent) {
|
public void setParent(final Extent parent) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Entity createEntity(final Location location, final BaseEntity entity) {
|
public Entity createEntity(final Location location, final BaseEntity entity) {
|
||||||
if (Eblocked) {
|
if (this.Eblocked) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Ecount++;
|
this.Ecount++;
|
||||||
if (Ecount > Settings.MAX_ENTITIES) {
|
if (this.Ecount > Settings.MAX_ENTITIES) {
|
||||||
Eblocked = true;
|
this.Eblocked = true;
|
||||||
MainUtil.sendAdmin(BBC.WORLDEDIT_DANGEROUS_WORLDEDIT.format(world + ": " + location.getBlockX() + "," + location.getBlockY() + "," + location.getBlockZ(), user));
|
MainUtil.sendAdmin(BBC.WORLDEDIT_DANGEROUS_WORLDEDIT.format(this.world + ": " + location.getBlockX() + "," + location.getBlockY() + "," + location.getBlockZ(), this.user));
|
||||||
}
|
}
|
||||||
if (WEManager.IMP.maskContains(mask, location.getBlockX(), location.getBlockZ())) {
|
if (WEManager.IMP.maskContains(this.mask, location.getBlockX(), location.getBlockZ())) {
|
||||||
TaskManager.IMP.task(new Runnable() {
|
TaskManager.IMP.task(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -76,56 +76,56 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBiome getBiome(Vector2D position) {
|
public BaseBiome getBiome(final Vector2D position) {
|
||||||
if (!SetQueue.IMP.isChunkLoaded(world, position.getBlockX() >> 4, position.getBlockZ() >> 4)) {
|
if (!SetQueue.IMP.isChunkLoaded(this.world, position.getBlockX() >> 4, position.getBlockZ() >> 4)) {
|
||||||
return EditSession.nullBiome;
|
return EditSession.nullBiome;
|
||||||
}
|
}
|
||||||
synchronized (thread) {
|
synchronized (this.thread) {
|
||||||
return super.getBiome(position);
|
return super.getBiome(position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private BaseBlock lastBlock;
|
private BaseBlock lastBlock;
|
||||||
private BlockVector lastVector;
|
private BlockVector lastVector;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getLazyBlock(Vector position) {
|
public BaseBlock getLazyBlock(final Vector position) {
|
||||||
if (lastBlock != null && lastVector.equals(position.toBlockVector())) {
|
if ((this.lastBlock != null) && this.lastVector.equals(position.toBlockVector())) {
|
||||||
return lastBlock;
|
return this.lastBlock;
|
||||||
}
|
}
|
||||||
if (!SetQueue.IMP.isChunkLoaded(world, position.getBlockX() >> 4, position.getBlockZ() >> 4)) {
|
if (!SetQueue.IMP.isChunkLoaded(this.world, position.getBlockX() >> 4, position.getBlockZ() >> 4)) {
|
||||||
try {
|
try {
|
||||||
lastVector = position.toBlockVector();
|
this.lastVector = position.toBlockVector();
|
||||||
return lastBlock = super.getBlock(position);
|
return this.lastBlock = super.getBlock(position);
|
||||||
} catch (Throwable e) {
|
} catch (final Throwable e) {
|
||||||
return EditSession.nullBlock;
|
return EditSession.nullBlock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
synchronized (thread) {
|
synchronized (this.thread) {
|
||||||
lastVector = position.toBlockVector();
|
this.lastVector = position.toBlockVector();
|
||||||
return lastBlock = super.getLazyBlock(position);
|
return this.lastBlock = super.getLazyBlock(position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Entity> getEntities() {
|
public List<? extends Entity> getEntities() {
|
||||||
synchronized (thread) {
|
synchronized (this.thread) {
|
||||||
return super.getEntities();
|
return super.getEntities();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Entity> getEntities(Region region) {
|
public List<? extends Entity> getEntities(final Region region) {
|
||||||
synchronized (thread) {
|
synchronized (this.thread) {
|
||||||
return super.getEntities(region);
|
return super.getEntities(region);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getBlock(Vector position) {
|
public BaseBlock getBlock(final Vector position) {
|
||||||
return getLazyBlock(position);
|
return this.getLazyBlock(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -168,25 +168,25 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
case 33:
|
case 33:
|
||||||
case 151:
|
case 151:
|
||||||
case 178: {
|
case 178: {
|
||||||
if (BSblocked) {
|
if (this.BSblocked) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
BScount++;
|
this.BScount++;
|
||||||
if (BScount > Settings.MAX_BLOCKSTATES) {
|
if (this.BScount > Settings.MAX_BLOCKSTATES) {
|
||||||
BSblocked = true;
|
this.BSblocked = true;
|
||||||
MainUtil.sendAdmin(BBC.WORLDEDIT_DANGEROUS_WORLDEDIT.format(world + ": " + location.getBlockX() + "," + location.getBlockY() + "," + location.getBlockZ(), user));
|
MainUtil.sendAdmin(BBC.WORLDEDIT_DANGEROUS_WORLDEDIT.format(this.world + ": " + location.getBlockX() + "," + location.getBlockY() + "," + location.getBlockZ(), this.user));
|
||||||
}
|
}
|
||||||
final int x = location.getBlockX();
|
final int x = location.getBlockX();
|
||||||
final int z = location.getBlockZ();
|
final int z = location.getBlockZ();
|
||||||
if (WEManager.IMP.maskContains(mask, x, z)) {
|
if (WEManager.IMP.maskContains(this.mask, x, z)) {
|
||||||
if (count++ > max) {
|
if (this.count++ > this.max) {
|
||||||
if (parent != null) {
|
if (this.parent != null) {
|
||||||
WEManager.IMP.cancelEdit(parent);
|
WEManager.IMP.cancelEdit(this.parent);
|
||||||
parent = null;
|
this.parent = null;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SetQueue.IMP.setBlock(world, x, location.getBlockY(), z, id, (byte) block.getData());
|
SetQueue.IMP.setBlock(this.world, x, location.getBlockY(), z, id, (byte) block.getData());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -194,10 +194,10 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
final int x = location.getBlockX();
|
final int x = location.getBlockX();
|
||||||
final int y = location.getBlockY();
|
final int y = location.getBlockY();
|
||||||
final int z = location.getBlockZ();
|
final int z = location.getBlockZ();
|
||||||
if (WEManager.IMP.maskContains(mask, location.getBlockX(), location.getBlockZ())) {
|
if (WEManager.IMP.maskContains(this.mask, location.getBlockX(), location.getBlockZ())) {
|
||||||
if (count++ > max) {
|
if (this.count++ > this.max) {
|
||||||
WEManager.IMP.cancelEdit(parent);
|
WEManager.IMP.cancelEdit(this.parent);
|
||||||
parent = null;
|
this.parent = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch (id) {
|
switch (id) {
|
||||||
@ -281,26 +281,26 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
case 190:
|
case 190:
|
||||||
case 191:
|
case 191:
|
||||||
case 192: {
|
case 192: {
|
||||||
SetQueue.IMP.setBlock(world, x, y, z, id);
|
SetQueue.IMP.setBlock(this.world, x, y, z, id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
SetQueue.IMP.setBlock(world, x, y, z, id, (byte) block.getData());
|
SetQueue.IMP.setBlock(this.world, x, y, z, id, (byte) block.getData());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(final Vector2D position, final BaseBiome biome) {
|
public boolean setBiome(final Vector2D position, final BaseBiome biome) {
|
||||||
if (WEManager.IMP.maskContains(mask, position.getBlockX(), position.getBlockZ())) {
|
if (WEManager.IMP.maskContains(this.mask, position.getBlockX(), position.getBlockZ())) {
|
||||||
SetQueue.IMP.setBiome(world, position.getBlockX(), position.getBlockZ(), biome);
|
SetQueue.IMP.setBiome(this.world, position.getBlockX(), position.getBlockZ(), biome);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,37 +1,37 @@
|
|||||||
package com.boydti.fawe.object;
|
package com.boydti.fawe.object;
|
||||||
|
|
||||||
public class PseudoRandom {
|
public class PseudoRandom {
|
||||||
|
|
||||||
public static PseudoRandom random = new PseudoRandom();
|
public static PseudoRandom random = new PseudoRandom();
|
||||||
|
|
||||||
private long state;
|
private long state;
|
||||||
|
|
||||||
public PseudoRandom() {
|
public PseudoRandom() {
|
||||||
state = System.nanoTime();
|
this.state = System.nanoTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PseudoRandom(final long state) {
|
public PseudoRandom(final long state) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long nextLong() {
|
public long nextLong() {
|
||||||
final long a = state;
|
final long a = this.state;
|
||||||
state = xorShift64(a);
|
this.state = this.xorShift64(a);
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long xorShift64(long a) {
|
public long xorShift64(long a) {
|
||||||
a ^= (a << 21);
|
a ^= (a << 21);
|
||||||
a ^= (a >>> 35);
|
a ^= (a >>> 35);
|
||||||
a ^= (a << 4);
|
a ^= (a << 4);
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int random(final int n) {
|
public int random(final int n) {
|
||||||
if (n == 1) {
|
if (n == 1) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
final long r = ((nextLong() >>> 32) * n) >> 32;
|
final long r = ((this.nextLong() >>> 32) * n) >> 32;
|
||||||
return (int) r;
|
return (int) r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,15 +7,15 @@ public class RegionWrapper {
|
|||||||
public int maxX;
|
public int maxX;
|
||||||
public int minZ;
|
public int minZ;
|
||||||
public int maxZ;
|
public int maxZ;
|
||||||
|
|
||||||
public RegionWrapper(final int minX, final int maxX, final int minZ, final int maxZ) {
|
public RegionWrapper(final int minX, final int maxX, final int minZ, final int maxZ) {
|
||||||
this.maxX = maxX;
|
this.maxX = maxX;
|
||||||
this.minX = minX;
|
this.minX = minX;
|
||||||
this.maxZ = maxZ;
|
this.maxZ = maxZ;
|
||||||
this.minZ = minZ;
|
this.minZ = minZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RegionWrapper(Vector pos1, Vector pos2) {
|
public RegionWrapper(final Vector pos1, final Vector pos2) {
|
||||||
this.minX = Math.min(pos1.getBlockX(), pos2.getBlockX());
|
this.minX = Math.min(pos1.getBlockX(), pos2.getBlockX());
|
||||||
this.minZ = Math.min(pos1.getBlockZ(), pos2.getBlockZ());
|
this.minZ = Math.min(pos1.getBlockZ(), pos2.getBlockZ());
|
||||||
this.maxX = Math.max(pos1.getBlockX(), pos2.getBlockX());
|
this.maxX = Math.max(pos1.getBlockX(), pos2.getBlockX());
|
||||||
@ -23,19 +23,19 @@ public class RegionWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIn(final int x, final int z) {
|
public boolean isIn(final int x, final int z) {
|
||||||
return ((x >= minX) && (x <= maxX) && (z >= minZ) && (z <= maxZ));
|
return ((x >= this.minX) && (x <= this.maxX) && (z >= this.minZ) && (z <= this.maxZ));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return minX + "," + minZ + "->" + maxX + "," + maxZ;
|
return this.minX + "," + this.minZ + "->" + this.maxX + "," + this.maxZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector getBottomVector() {
|
public Vector getBottomVector() {
|
||||||
return new Vector(minX, 1, minZ);
|
return new Vector(this.minX, 1, this.minZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector getTopVector() {
|
public Vector getTopVector() {
|
||||||
return new Vector(maxX, 255, maxZ);
|
return new Vector(this.maxX, 255, this.maxZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@ package com.boydti.fawe.object;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
public abstract class SendChunk {
|
public abstract class SendChunk {
|
||||||
|
|
||||||
public abstract void fixLighting(final Collection<ChunkLoc> locs);
|
public abstract void fixLighting(final Collection<ChunkLoc> locs);
|
||||||
|
|
||||||
public abstract void update(final Collection<ChunkLoc> locs);
|
public abstract void update(final Collection<ChunkLoc> locs);
|
||||||
}
|
}
|
||||||
|
@ -5,19 +5,19 @@ import com.boydti.fawe.object.FawePlayer;
|
|||||||
|
|
||||||
public abstract class FaweMaskManager<T> {
|
public abstract class FaweMaskManager<T> {
|
||||||
private final String key;
|
private final String key;
|
||||||
|
|
||||||
public FaweMaskManager(String plugin) {
|
public FaweMaskManager(final String plugin) {
|
||||||
this.key = plugin.toLowerCase();
|
this.key = plugin.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getKey() {
|
public String getKey() {
|
||||||
return this.key;
|
return this.key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.key;
|
return this.key;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract FaweMask getMask(final FawePlayer<T> player);
|
public abstract FaweMask getMask(final FawePlayer<T> player);
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
|||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
|
||||||
public class ExtentWrapper extends AbstractDelegateExtent {
|
public class ExtentWrapper extends AbstractDelegateExtent {
|
||||||
|
|
||||||
public ExtentWrapper(final Extent extent) {
|
public ExtentWrapper(final Extent extent) {
|
||||||
super(extent);
|
super(extent);
|
||||||
}
|
}
|
||||||
|
@ -8,23 +8,23 @@ import com.sk89q.worldedit.world.biome.BaseBiome;
|
|||||||
|
|
||||||
public abstract class FaweQueue {
|
public abstract class FaweQueue {
|
||||||
public abstract boolean setBlock(final String world, final int x, final int y, final int z, final short id, final byte data);
|
public abstract boolean setBlock(final String world, final int x, final int y, final int z, final short id, final byte data);
|
||||||
|
|
||||||
public abstract boolean setBiome(final String world, final int x, final int z, final BaseBiome biome);
|
public abstract boolean setBiome(final String world, final int x, final int z, final BaseBiome biome);
|
||||||
|
|
||||||
public abstract FaweChunk<?> getChunk(ChunkLoc wrap);
|
public abstract FaweChunk<?> getChunk(final ChunkLoc wrap);
|
||||||
|
|
||||||
public abstract void setChunk(FaweChunk<?> chunk);
|
public abstract void setChunk(final FaweChunk<?> chunk);
|
||||||
|
|
||||||
public abstract boolean fixLighting(FaweChunk<?> chunk, boolean fixAll);
|
public abstract boolean fixLighting(final FaweChunk<?> chunk, final boolean fixAll);
|
||||||
|
|
||||||
public abstract boolean isChunkLoaded(String world, int x, int z);
|
public abstract boolean isChunkLoaded(final String world, final int x, final int z);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the FaweChunk and sets the requested blocks
|
* Gets the FaweChunk and sets the requested blocks
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public abstract FaweChunk next();
|
public abstract FaweChunk next();
|
||||||
|
|
||||||
public void saveMemory() {
|
public void saveMemory() {
|
||||||
MainUtil.sendAdmin(BBC.OOM.s());
|
MainUtil.sendAdmin(BBC.OOM.s());
|
||||||
// Set memory limited
|
// Set memory limited
|
||||||
@ -37,6 +37,6 @@ public abstract class FaweQueue {
|
|||||||
System.gc();
|
System.gc();
|
||||||
// Unload chunks
|
// Unload chunks
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void clear();
|
protected abstract void clear();
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ public class Lag implements Runnable {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public static long LT = 0L;
|
public static long LT = 0L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the server TPS
|
* Get the server TPS
|
||||||
*
|
*
|
||||||
@ -26,7 +26,7 @@ public class Lag implements Runnable {
|
|||||||
public static double getTPS() {
|
public static double getTPS() {
|
||||||
return Math.round(getTPS(100)) > 20.0D ? 20.0D : Math.round(getTPS(100));
|
return Math.round(getTPS(100)) > 20.0D ? 20.0D : Math.round(getTPS(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the tick per second (measured in $ticks)
|
* Return the tick per second (measured in $ticks)
|
||||||
*
|
*
|
||||||
@ -42,7 +42,7 @@ public class Lag implements Runnable {
|
|||||||
final long e = System.currentTimeMillis() - T[t];
|
final long e = System.currentTimeMillis() - T[t];
|
||||||
return ticks / (e / 1000.0D);
|
return ticks / (e / 1000.0D);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get number of ticks since
|
* Get number of ticks since
|
||||||
*
|
*
|
||||||
@ -54,7 +54,7 @@ public class Lag implements Runnable {
|
|||||||
final long t = T[tI % T.length];
|
final long t = T[tI % T.length];
|
||||||
return System.currentTimeMillis() - t;
|
return System.currentTimeMillis() - t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get lag percentage
|
* Get lag percentage
|
||||||
*
|
*
|
||||||
@ -63,7 +63,7 @@ public class Lag implements Runnable {
|
|||||||
public static double getPercentage() {
|
public static double getPercentage() {
|
||||||
return Math.round((1.0D - (Lag.getTPS() / 20.0D)) * 100.0D);
|
return Math.round((1.0D - (Lag.getTPS() / 20.0D)) * 100.0D);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get TPS percentage (of 20)
|
* Get TPS percentage (of 20)
|
||||||
*
|
*
|
||||||
@ -72,7 +72,7 @@ public class Lag implements Runnable {
|
|||||||
public static double getFullPercentage() {
|
public static double getFullPercentage() {
|
||||||
return getTPS() * 5.0D;
|
return getTPS() * 5.0D;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
T[TC % T.length] = System.currentTimeMillis();
|
T[TC % T.length] = System.currentTimeMillis();
|
||||||
|
@ -20,7 +20,7 @@ public class MainUtil {
|
|||||||
player.sendMessage(message);
|
player.sendMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendAdmin(final String s) {
|
public static void sendAdmin(final String s) {
|
||||||
for (final Player player : Bukkit.getOnlinePlayers()) {
|
for (final Player player : Bukkit.getOnlinePlayers()) {
|
||||||
if (player.hasPermission("fawe.admin")) {
|
if (player.hasPermission("fawe.admin")) {
|
||||||
|
@ -5,17 +5,17 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
|
|
||||||
public class MemUtil {
|
public class MemUtil {
|
||||||
|
|
||||||
private static AtomicBoolean memory = new AtomicBoolean(false);
|
private static AtomicBoolean memory = new AtomicBoolean(false);
|
||||||
|
|
||||||
public static boolean isMemoryFree() {
|
public static boolean isMemoryFree() {
|
||||||
return !memory.get();
|
return !memory.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isMemoryLimited() {
|
public static boolean isMemoryLimited() {
|
||||||
return memory.get();
|
return memory.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int calculateMemory() {
|
public static int calculateMemory() {
|
||||||
final long heapSize = Runtime.getRuntime().totalMemory();
|
final long heapSize = Runtime.getRuntime().totalMemory();
|
||||||
final long heapMaxSize = Runtime.getRuntime().maxMemory();
|
final long heapMaxSize = Runtime.getRuntime().maxMemory();
|
||||||
@ -30,11 +30,11 @@ public class MemUtil {
|
|||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void memoryLimitedTask() {
|
public static void memoryLimitedTask() {
|
||||||
memory.set(true);
|
memory.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void memoryPlentifulTask() {
|
public static void memoryPlentifulTask() {
|
||||||
memory.set(false);
|
memory.set(false);
|
||||||
}
|
}
|
||||||
|
@ -7,23 +7,23 @@ public enum Perm {
|
|||||||
* Permission related functions
|
* Permission related functions
|
||||||
*/
|
*/
|
||||||
ADMIN("fawe.admin", "admin");
|
ADMIN("fawe.admin", "admin");
|
||||||
|
|
||||||
public String s;
|
public String s;
|
||||||
public String cat;
|
public String cat;
|
||||||
|
|
||||||
Perm(final String perm, final String cat) {
|
Perm(final String perm, final String cat) {
|
||||||
s = perm;
|
this.s = perm;
|
||||||
this.cat = cat;
|
this.cat = cat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean has(final FawePlayer<?> player) {
|
public boolean has(final FawePlayer<?> player) {
|
||||||
return hasPermission(player, this);
|
return this.hasPermission(player, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPermission(final FawePlayer<?> player, final Perm perm) {
|
public boolean hasPermission(final FawePlayer<?> player, final Perm perm) {
|
||||||
return hasPermission(player, perm.s);
|
return hasPermission(player, perm.s);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasPermission(final FawePlayer<?> player, final String perm) {
|
public static boolean hasPermission(final FawePlayer<?> player, final String perm) {
|
||||||
if ((player == null) || player.hasPermission(ADMIN.s)) {
|
if ((player == null) || player.hasPermission(ADMIN.s)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -55,17 +55,17 @@ public class ReflectionUtils {
|
|||||||
} catch (final Exception ignored) {}
|
} catch (final Exception ignored) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> getNmsClass(final String name) {
|
public static Class<?> getNmsClass(final String name) {
|
||||||
final String className = "net.minecraft.server." + getVersion() + "." + name;
|
final String className = "net.minecraft.server." + getVersion() + "." + name;
|
||||||
return getClass(className);
|
return getClass(className);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> getCbClass(final String name) {
|
public static Class<?> getCbClass(final String name) {
|
||||||
final String className = "org.bukkit.craftbukkit." + getVersion() + "." + name;
|
final String className = "org.bukkit.craftbukkit." + getVersion() + "." + name;
|
||||||
return getClass(className);
|
return getClass(className);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> getUtilClass(final String name) {
|
public static Class<?> getUtilClass(final String name) {
|
||||||
try {
|
try {
|
||||||
return Class.forName(name); //Try before 1.8 first
|
return Class.forName(name); //Try before 1.8 first
|
||||||
@ -77,17 +77,17 @@ public class ReflectionUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getVersion() {
|
public static String getVersion() {
|
||||||
final String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
final String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
||||||
return packageName.substring(packageName.lastIndexOf('.') + 1);
|
return packageName.substring(packageName.lastIndexOf('.') + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object getHandle(final Object wrapper) {
|
public static Object getHandle(final Object wrapper) {
|
||||||
final Method getHandle = makeMethod(wrapper.getClass(), "getHandle");
|
final Method getHandle = makeMethod(wrapper.getClass(), "getHandle");
|
||||||
return callMethod(getHandle, wrapper);
|
return callMethod(getHandle, wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Utils
|
//Utils
|
||||||
public static Method makeMethod(final Class<?> clazz, final String methodName, final Class<?>... paramaters) {
|
public static Method makeMethod(final Class<?> clazz, final String methodName, final Class<?>... paramaters) {
|
||||||
try {
|
try {
|
||||||
@ -98,7 +98,7 @@ public class ReflectionUtils {
|
|||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> T callMethod(final Method method, final Object instance, final Object... paramaters) {
|
public static <T> T callMethod(final Method method, final Object instance, final Object... paramaters) {
|
||||||
if (method == null) {
|
if (method == null) {
|
||||||
@ -113,7 +113,7 @@ public class ReflectionUtils {
|
|||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> Constructor<T> makeConstructor(final Class<?> clazz, final Class<?>... paramaterTypes) {
|
public static <T> Constructor<T> makeConstructor(final Class<?> clazz, final Class<?>... paramaterTypes) {
|
||||||
try {
|
try {
|
||||||
@ -124,7 +124,7 @@ public class ReflectionUtils {
|
|||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T callConstructor(final Constructor<T> constructor, final Object... paramaters) {
|
public static <T> T callConstructor(final Constructor<T> constructor, final Object... paramaters) {
|
||||||
if (constructor == null) {
|
if (constructor == null) {
|
||||||
throw new RuntimeException("No such constructor");
|
throw new RuntimeException("No such constructor");
|
||||||
@ -138,7 +138,7 @@ public class ReflectionUtils {
|
|||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Field makeField(final Class<?> clazz, final String name) {
|
public static Field makeField(final Class<?> clazz, final String name) {
|
||||||
try {
|
try {
|
||||||
return clazz.getDeclaredField(name);
|
return clazz.getDeclaredField(name);
|
||||||
@ -148,7 +148,7 @@ public class ReflectionUtils {
|
|||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> T getField(final Field field, final Object instance) {
|
public static <T> T getField(final Field field, final Object instance) {
|
||||||
if (field == null) {
|
if (field == null) {
|
||||||
@ -161,7 +161,7 @@ public class ReflectionUtils {
|
|||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setField(final Field field, final Object instance, final Object value) {
|
public static void setField(final Field field, final Object instance, final Object value) {
|
||||||
if (field == null) {
|
if (field == null) {
|
||||||
throw new RuntimeException("No such field");
|
throw new RuntimeException("No such field");
|
||||||
@ -173,7 +173,7 @@ public class ReflectionUtils {
|
|||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> getClass(final String name) {
|
public static Class<?> getClass(final String name) {
|
||||||
try {
|
try {
|
||||||
return Class.forName(name);
|
return Class.forName(name);
|
||||||
@ -181,7 +181,7 @@ public class ReflectionUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> Class<? extends T> getClass(final String name, final Class<T> superClass) {
|
public static <T> Class<? extends T> getClass(final String name, final Class<T> superClass) {
|
||||||
try {
|
try {
|
||||||
return Class.forName(name).asSubclass(superClass);
|
return Class.forName(name).asSubclass(superClass);
|
||||||
@ -189,14 +189,14 @@ public class ReflectionUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if server has forge classes
|
* @return true if server has forge classes
|
||||||
*/
|
*/
|
||||||
public static boolean isForge() {
|
public static boolean isForge() {
|
||||||
return forge;
|
return forge;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get class for name. Replace {nms} to net.minecraft.server.V*. Replace {cb} to org.bukkit.craftbukkit.V*. Replace
|
* Get class for name. Replace {nms} to net.minecraft.server.V*. Replace {cb} to org.bukkit.craftbukkit.V*. Replace
|
||||||
* {nm} to net.minecraft
|
* {nm} to net.minecraft
|
||||||
@ -216,7 +216,7 @@ public class ReflectionUtils {
|
|||||||
}
|
}
|
||||||
throw new RuntimeException("no class found");
|
throw new RuntimeException("no class found");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get RefClass object by real class
|
* get RefClass object by real class
|
||||||
*
|
*
|
||||||
@ -227,26 +227,26 @@ public class ReflectionUtils {
|
|||||||
public static RefClass getRefClass(final Class clazz) {
|
public static RefClass getRefClass(final Class clazz) {
|
||||||
return new RefClass(clazz);
|
return new RefClass(clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RefClass - utility to simplify work with reflections.
|
* RefClass - utility to simplify work with reflections.
|
||||||
*/
|
*/
|
||||||
public static class RefClass {
|
public static class RefClass {
|
||||||
private final Class<?> clazz;
|
private final Class<?> clazz;
|
||||||
|
|
||||||
private RefClass(final Class<?> clazz) {
|
private RefClass(final Class<?> clazz) {
|
||||||
this.clazz = clazz;
|
this.clazz = clazz;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get passed class
|
* get passed class
|
||||||
*
|
*
|
||||||
* @return class
|
* @return class
|
||||||
*/
|
*/
|
||||||
public Class<?> getRealClass() {
|
public Class<?> getRealClass() {
|
||||||
return clazz;
|
return this.clazz;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* see {@link Class#isInstance(Object)}
|
* see {@link Class#isInstance(Object)}
|
||||||
*
|
*
|
||||||
@ -255,9 +255,9 @@ public class ReflectionUtils {
|
|||||||
* @return true if object is an instance of this class
|
* @return true if object is an instance of this class
|
||||||
*/
|
*/
|
||||||
public boolean isInstance(final Object object) {
|
public boolean isInstance(final Object object) {
|
||||||
return clazz.isInstance(object);
|
return this.clazz.isInstance(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get existing method by name and types
|
* get existing method by name and types
|
||||||
*
|
*
|
||||||
@ -282,15 +282,15 @@ public class ReflectionUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return new RefMethod(clazz.getMethod(name, classes));
|
return new RefMethod(this.clazz.getMethod(name, classes));
|
||||||
} catch (final NoSuchMethodException ignored) {
|
} catch (final NoSuchMethodException ignored) {
|
||||||
return new RefMethod(clazz.getDeclaredMethod(name, classes));
|
return new RefMethod(this.clazz.getDeclaredMethod(name, classes));
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get existing constructor by types
|
* get existing constructor by types
|
||||||
*
|
*
|
||||||
@ -314,15 +314,15 @@ public class ReflectionUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return new RefConstructor(clazz.getConstructor(classes));
|
return new RefConstructor(this.clazz.getConstructor(classes));
|
||||||
} catch (final NoSuchMethodException ignored) {
|
} catch (final NoSuchMethodException ignored) {
|
||||||
return new RefConstructor(clazz.getDeclaredConstructor(classes));
|
return new RefConstructor(this.clazz.getDeclaredConstructor(classes));
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* find method by type parameters
|
* find method by type parameters
|
||||||
*
|
*
|
||||||
@ -345,8 +345,8 @@ public class ReflectionUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
final List<Method> methods = new ArrayList<>();
|
final List<Method> methods = new ArrayList<>();
|
||||||
Collections.addAll(methods, clazz.getMethods());
|
Collections.addAll(methods, this.clazz.getMethods());
|
||||||
Collections.addAll(methods, clazz.getDeclaredMethods());
|
Collections.addAll(methods, this.clazz.getDeclaredMethods());
|
||||||
findMethod: for (final Method m : methods) {
|
findMethod: for (final Method m : methods) {
|
||||||
final Class<?>[] methodTypes = m.getParameterTypes();
|
final Class<?>[] methodTypes = m.getParameterTypes();
|
||||||
if (methodTypes.length != classes.length) {
|
if (methodTypes.length != classes.length) {
|
||||||
@ -361,7 +361,7 @@ public class ReflectionUtils {
|
|||||||
}
|
}
|
||||||
throw new RuntimeException("no such method");
|
throw new RuntimeException("no such method");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* find method by name
|
* find method by name
|
||||||
*
|
*
|
||||||
@ -373,8 +373,8 @@ public class ReflectionUtils {
|
|||||||
*/
|
*/
|
||||||
public RefMethod findMethodByName(final String... names) {
|
public RefMethod findMethodByName(final String... names) {
|
||||||
final List<Method> methods = new ArrayList<>();
|
final List<Method> methods = new ArrayList<>();
|
||||||
Collections.addAll(methods, clazz.getMethods());
|
Collections.addAll(methods, this.clazz.getMethods());
|
||||||
Collections.addAll(methods, clazz.getDeclaredMethods());
|
Collections.addAll(methods, this.clazz.getDeclaredMethods());
|
||||||
for (final Method m : methods) {
|
for (final Method m : methods) {
|
||||||
for (final String name : names) {
|
for (final String name : names) {
|
||||||
if (m.getName().equals(name)) {
|
if (m.getName().equals(name)) {
|
||||||
@ -384,7 +384,7 @@ public class ReflectionUtils {
|
|||||||
}
|
}
|
||||||
throw new RuntimeException("no such method");
|
throw new RuntimeException("no such method");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* find method by return value
|
* find method by return value
|
||||||
*
|
*
|
||||||
@ -395,9 +395,9 @@ public class ReflectionUtils {
|
|||||||
* @throws RuntimeException if method not found
|
* @throws RuntimeException if method not found
|
||||||
*/
|
*/
|
||||||
public RefMethod findMethodByReturnType(final RefClass type) {
|
public RefMethod findMethodByReturnType(final RefClass type) {
|
||||||
return findMethodByReturnType(type.clazz);
|
return this.findMethodByReturnType(type.clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* find method by return value
|
* find method by return value
|
||||||
*
|
*
|
||||||
@ -412,8 +412,8 @@ public class ReflectionUtils {
|
|||||||
type = void.class;
|
type = void.class;
|
||||||
}
|
}
|
||||||
final List<Method> methods = new ArrayList<>();
|
final List<Method> methods = new ArrayList<>();
|
||||||
Collections.addAll(methods, clazz.getMethods());
|
Collections.addAll(methods, this.clazz.getMethods());
|
||||||
Collections.addAll(methods, clazz.getDeclaredMethods());
|
Collections.addAll(methods, this.clazz.getDeclaredMethods());
|
||||||
for (final Method m : methods) {
|
for (final Method m : methods) {
|
||||||
if (type.equals(m.getReturnType())) {
|
if (type.equals(m.getReturnType())) {
|
||||||
return new RefMethod(m);
|
return new RefMethod(m);
|
||||||
@ -421,7 +421,7 @@ public class ReflectionUtils {
|
|||||||
}
|
}
|
||||||
throw new RuntimeException("no such method");
|
throw new RuntimeException("no such method");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* find constructor by number of arguments
|
* find constructor by number of arguments
|
||||||
*
|
*
|
||||||
@ -433,8 +433,8 @@ public class ReflectionUtils {
|
|||||||
*/
|
*/
|
||||||
public RefConstructor findConstructor(final int number) {
|
public RefConstructor findConstructor(final int number) {
|
||||||
final List<Constructor> constructors = new ArrayList<>();
|
final List<Constructor> constructors = new ArrayList<>();
|
||||||
Collections.addAll(constructors, clazz.getConstructors());
|
Collections.addAll(constructors, this.clazz.getConstructors());
|
||||||
Collections.addAll(constructors, clazz.getDeclaredConstructors());
|
Collections.addAll(constructors, this.clazz.getDeclaredConstructors());
|
||||||
for (final Constructor m : constructors) {
|
for (final Constructor m : constructors) {
|
||||||
if (m.getParameterTypes().length == number) {
|
if (m.getParameterTypes().length == number) {
|
||||||
return new RefConstructor(m);
|
return new RefConstructor(m);
|
||||||
@ -442,7 +442,7 @@ public class ReflectionUtils {
|
|||||||
}
|
}
|
||||||
throw new RuntimeException("no such constructor");
|
throw new RuntimeException("no such constructor");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get field by name
|
* get field by name
|
||||||
*
|
*
|
||||||
@ -455,15 +455,15 @@ public class ReflectionUtils {
|
|||||||
public RefField getField(final String name) {
|
public RefField getField(final String name) {
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
return new RefField(clazz.getField(name));
|
return new RefField(this.clazz.getField(name));
|
||||||
} catch (final NoSuchFieldException ignored) {
|
} catch (final NoSuchFieldException ignored) {
|
||||||
return new RefField(clazz.getDeclaredField(name));
|
return new RefField(this.clazz.getDeclaredField(name));
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* find field by type
|
* find field by type
|
||||||
*
|
*
|
||||||
@ -474,9 +474,9 @@ public class ReflectionUtils {
|
|||||||
* @throws RuntimeException if field not found
|
* @throws RuntimeException if field not found
|
||||||
*/
|
*/
|
||||||
public RefField findField(final RefClass type) {
|
public RefField findField(final RefClass type) {
|
||||||
return findField(type.clazz);
|
return this.findField(type.clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* find field by type
|
* find field by type
|
||||||
*
|
*
|
||||||
@ -491,8 +491,8 @@ public class ReflectionUtils {
|
|||||||
type = void.class;
|
type = void.class;
|
||||||
}
|
}
|
||||||
final List<Field> fields = new ArrayList<>();
|
final List<Field> fields = new ArrayList<>();
|
||||||
Collections.addAll(fields, clazz.getFields());
|
Collections.addAll(fields, this.clazz.getFields());
|
||||||
Collections.addAll(fields, clazz.getDeclaredFields());
|
Collections.addAll(fields, this.clazz.getDeclaredFields());
|
||||||
for (final Field f : fields) {
|
for (final Field f : fields) {
|
||||||
if (type.equals(f.getType())) {
|
if (type.equals(f.getType())) {
|
||||||
return new RefField(f);
|
return new RefField(f);
|
||||||
@ -501,39 +501,39 @@ public class ReflectionUtils {
|
|||||||
throw new RuntimeException("no such field");
|
throw new RuntimeException("no such field");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method wrapper
|
* Method wrapper
|
||||||
*/
|
*/
|
||||||
public static class RefMethod {
|
public static class RefMethod {
|
||||||
private final Method method;
|
private final Method method;
|
||||||
|
|
||||||
private RefMethod(final Method method) {
|
private RefMethod(final Method method) {
|
||||||
this.method = method;
|
this.method = method;
|
||||||
method.setAccessible(true);
|
method.setAccessible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return passed method
|
* @return passed method
|
||||||
*/
|
*/
|
||||||
public Method getRealMethod() {
|
public Method getRealMethod() {
|
||||||
return method;
|
return this.method;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return owner class of method
|
* @return owner class of method
|
||||||
*/
|
*/
|
||||||
public RefClass getRefClass() {
|
public RefClass getRefClass() {
|
||||||
return new RefClass(method.getDeclaringClass());
|
return new RefClass(this.method.getDeclaringClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return class of method return type
|
* @return class of method return type
|
||||||
*/
|
*/
|
||||||
public RefClass getReturnRefClass() {
|
public RefClass getReturnRefClass() {
|
||||||
return new RefClass(method.getReturnType());
|
return new RefClass(this.method.getReturnType());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* apply method to object
|
* apply method to object
|
||||||
*
|
*
|
||||||
@ -544,7 +544,7 @@ public class ReflectionUtils {
|
|||||||
public RefExecutor of(final Object e) {
|
public RefExecutor of(final Object e) {
|
||||||
return new RefExecutor(e);
|
return new RefExecutor(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* call static method
|
* call static method
|
||||||
*
|
*
|
||||||
@ -554,19 +554,19 @@ public class ReflectionUtils {
|
|||||||
*/
|
*/
|
||||||
public Object call(final Object... params) {
|
public Object call(final Object... params) {
|
||||||
try {
|
try {
|
||||||
return method.invoke(null, params);
|
return this.method.invoke(null, params);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RefExecutor {
|
public class RefExecutor {
|
||||||
final Object e;
|
final Object e;
|
||||||
|
|
||||||
public RefExecutor(final Object e) {
|
public RefExecutor(final Object e) {
|
||||||
this.e = e;
|
this.e = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* apply method for selected object
|
* apply method for selected object
|
||||||
*
|
*
|
||||||
@ -578,39 +578,39 @@ public class ReflectionUtils {
|
|||||||
*/
|
*/
|
||||||
public Object call(final Object... params) {
|
public Object call(final Object... params) {
|
||||||
try {
|
try {
|
||||||
return method.invoke(e, params);
|
return RefMethod.this.method.invoke(this.e, params);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor wrapper
|
* Constructor wrapper
|
||||||
*/
|
*/
|
||||||
public static class RefConstructor {
|
public static class RefConstructor {
|
||||||
private final Constructor constructor;
|
private final Constructor constructor;
|
||||||
|
|
||||||
private RefConstructor(final Constructor constructor) {
|
private RefConstructor(final Constructor constructor) {
|
||||||
this.constructor = constructor;
|
this.constructor = constructor;
|
||||||
constructor.setAccessible(true);
|
constructor.setAccessible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return passed constructor
|
* @return passed constructor
|
||||||
*/
|
*/
|
||||||
public Constructor getRealConstructor() {
|
public Constructor getRealConstructor() {
|
||||||
return constructor;
|
return this.constructor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return owner class of method
|
* @return owner class of method
|
||||||
*/
|
*/
|
||||||
public RefClass getRefClass() {
|
public RefClass getRefClass() {
|
||||||
return new RefClass(constructor.getDeclaringClass());
|
return new RefClass(this.constructor.getDeclaringClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create new instance with constructor
|
* create new instance with constructor
|
||||||
*
|
*
|
||||||
@ -622,42 +622,42 @@ public class ReflectionUtils {
|
|||||||
*/
|
*/
|
||||||
public Object create(final Object... params) {
|
public Object create(final Object... params) {
|
||||||
try {
|
try {
|
||||||
return constructor.newInstance(params);
|
return this.constructor.newInstance(params);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RefField {
|
public static class RefField {
|
||||||
private final Field field;
|
private final Field field;
|
||||||
|
|
||||||
private RefField(final Field field) {
|
private RefField(final Field field) {
|
||||||
this.field = field;
|
this.field = field;
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return passed field
|
* @return passed field
|
||||||
*/
|
*/
|
||||||
public Field getRealField() {
|
public Field getRealField() {
|
||||||
return field;
|
return this.field;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return owner class of field
|
* @return owner class of field
|
||||||
*/
|
*/
|
||||||
public RefClass getRefClass() {
|
public RefClass getRefClass() {
|
||||||
return new RefClass(field.getDeclaringClass());
|
return new RefClass(this.field.getDeclaringClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return type of field
|
* @return type of field
|
||||||
*/
|
*/
|
||||||
public RefClass getFieldRefClass() {
|
public RefClass getFieldRefClass() {
|
||||||
return new RefClass(field.getType());
|
return new RefClass(this.field.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* apply fiend for object
|
* apply fiend for object
|
||||||
*
|
*
|
||||||
@ -668,14 +668,14 @@ public class ReflectionUtils {
|
|||||||
public RefExecutor of(final Object e) {
|
public RefExecutor of(final Object e) {
|
||||||
return new RefExecutor(e);
|
return new RefExecutor(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RefExecutor {
|
public class RefExecutor {
|
||||||
final Object e;
|
final Object e;
|
||||||
|
|
||||||
public RefExecutor(final Object e) {
|
public RefExecutor(final Object e) {
|
||||||
this.e = e;
|
this.e = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set field value for applied object
|
* set field value for applied object
|
||||||
*
|
*
|
||||||
@ -683,12 +683,12 @@ public class ReflectionUtils {
|
|||||||
*/
|
*/
|
||||||
public void set(final Object param) {
|
public void set(final Object param) {
|
||||||
try {
|
try {
|
||||||
field.set(e, param);
|
RefField.this.field.set(this.e, param);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get field value for applied object
|
* get field value for applied object
|
||||||
*
|
*
|
||||||
@ -696,7 +696,7 @@ public class ReflectionUtils {
|
|||||||
*/
|
*/
|
||||||
public Object get() {
|
public Object get() {
|
||||||
try {
|
try {
|
||||||
return field.get(e);
|
return RefField.this.field.get(this.e);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -10,20 +10,20 @@ import com.sk89q.worldedit.extent.Extent;
|
|||||||
|
|
||||||
public class SafeExtentWrapper extends AbstractDelegateExtent {
|
public class SafeExtentWrapper extends AbstractDelegateExtent {
|
||||||
private final FawePlayer<?> player;
|
private final FawePlayer<?> player;
|
||||||
|
|
||||||
public SafeExtentWrapper(final FawePlayer<?> player, final Extent extent) {
|
public SafeExtentWrapper(final FawePlayer<?> player, final Extent extent) {
|
||||||
super(extent);
|
super(extent);
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(final Vector location, final BaseBlock block) throws WorldEditException {
|
public boolean setBlock(final Vector location, final BaseBlock block) throws WorldEditException {
|
||||||
if (super.setBlock(location, block)) {
|
if (super.setBlock(location, block)) {
|
||||||
if (MemUtil.isMemoryLimited()) {
|
if (MemUtil.isMemoryLimited()) {
|
||||||
if (player != null) {
|
if (this.player != null) {
|
||||||
BBC.WORLDEDIT_OOM.send(player);
|
BBC.WORLDEDIT_OOM.send(this.player);
|
||||||
if (Perm.hasPermission(player, "worldedit.fast")) {
|
if (Perm.hasPermission(this.player, "worldedit.fast")) {
|
||||||
BBC.WORLDEDIT_OOM_ADMIN.send(player);
|
BBC.WORLDEDIT_OOM_ADMIN.send(this.player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WEManager.IMP.cancelEdit(this);
|
WEManager.IMP.cancelEdit(this);
|
||||||
|
@ -8,11 +8,11 @@ import com.boydti.fawe.object.FaweChunk;
|
|||||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||||
|
|
||||||
public class SetQueue {
|
public class SetQueue {
|
||||||
|
|
||||||
public static final SetQueue IMP = new SetQueue();
|
public static final SetQueue IMP = new SetQueue();
|
||||||
|
|
||||||
public FaweQueue queue;
|
public FaweQueue queue;
|
||||||
|
|
||||||
private final AtomicInteger time_waiting = new AtomicInteger(2);
|
private final AtomicInteger time_waiting = new AtomicInteger(2);
|
||||||
private final AtomicInteger time_current = new AtomicInteger(0);
|
private final AtomicInteger time_current = new AtomicInteger(0);
|
||||||
private final ArrayDeque<Runnable> runnables = new ArrayDeque<>();
|
private final ArrayDeque<Runnable> runnables = new ArrayDeque<>();
|
||||||
@ -26,81 +26,81 @@ public class SetQueue {
|
|||||||
if (!MemUtil.isMemoryFree()) {
|
if (!MemUtil.isMemoryFree()) {
|
||||||
final int mem = MemUtil.calculateMemory();
|
final int mem = MemUtil.calculateMemory();
|
||||||
if (mem != Integer.MAX_VALUE) {
|
if (mem != Integer.MAX_VALUE) {
|
||||||
if (mem <= 1 && Settings.ENABLE_HARD_LIMIT) {
|
if ((mem <= 1) && Settings.ENABLE_HARD_LIMIT) {
|
||||||
queue.saveMemory();
|
SetQueue.this.queue.saveMemory();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (forceChunkSet()) {
|
if (SetQueue.this.forceChunkSet()) {
|
||||||
System.gc();
|
System.gc();
|
||||||
} else {
|
} else {
|
||||||
time_current.incrementAndGet();
|
SetQueue.this.time_current.incrementAndGet();
|
||||||
tasks();
|
SetQueue.this.tasks();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
long free = 50 + Math.min(50 + last - (last = System.currentTimeMillis()), last2 - System.currentTimeMillis());
|
final long free = 50 + Math.min((50 + SetQueue.this.last) - (SetQueue.this.last = System.currentTimeMillis()), SetQueue.this.last2 - System.currentTimeMillis());
|
||||||
time_current.incrementAndGet();
|
SetQueue.this.time_current.incrementAndGet();
|
||||||
do {
|
do {
|
||||||
if (isWaiting()) {
|
if (SetQueue.this.isWaiting()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final FaweChunk<?> current = queue.next();
|
final FaweChunk<?> current = SetQueue.this.queue.next();
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
time_waiting.set(Math.max(time_waiting.get(), time_current.get() - 2));
|
SetQueue.this.time_waiting.set(Math.max(SetQueue.this.time_waiting.get(), SetQueue.this.time_current.get() - 2));
|
||||||
tasks();
|
SetQueue.this.tasks();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} while ((last2 = System.currentTimeMillis()) - last < free);
|
} while (((SetQueue.this.last2 = System.currentTimeMillis()) - SetQueue.this.last) < free);
|
||||||
time_waiting.set(time_current.get() - 1);
|
SetQueue.this.time_waiting.set(SetQueue.this.time_current.get() - 1);
|
||||||
}
|
}
|
||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean forceChunkSet() {
|
public boolean forceChunkSet() {
|
||||||
final FaweChunk<?> set = queue.next();
|
final FaweChunk<?> set = this.queue.next();
|
||||||
return set != null;
|
return set != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWaiting() {
|
public boolean isWaiting() {
|
||||||
return time_waiting.get() >= time_current.get();
|
return this.time_waiting.get() >= this.time_current.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDone() {
|
public boolean isDone() {
|
||||||
return (time_waiting.get() + 1) < time_current.get();
|
return (this.time_waiting.get() + 1) < this.time_current.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWaiting() {
|
public void setWaiting() {
|
||||||
time_waiting.set(time_current.get() + 1);
|
this.time_waiting.set(this.time_current.get() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addTask(final Runnable whenDone) {
|
public boolean addTask(final Runnable whenDone) {
|
||||||
if (isDone()) {
|
if (this.isDone()) {
|
||||||
// Run
|
// Run
|
||||||
tasks();
|
this.tasks();
|
||||||
if (whenDone != null) {
|
if (whenDone != null) {
|
||||||
whenDone.run();
|
whenDone.run();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (whenDone != null) {
|
if (whenDone != null) {
|
||||||
runnables.add(whenDone);
|
this.runnables.add(whenDone);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean tasks() {
|
public boolean tasks() {
|
||||||
if (runnables.size() == 0) {
|
if (this.runnables.size() == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final ArrayDeque<Runnable> tmp = runnables.clone();
|
final ArrayDeque<Runnable> tmp = this.runnables.clone();
|
||||||
runnables.clear();
|
this.runnables.clear();
|
||||||
for (final Runnable runnable : tmp) {
|
for (final Runnable runnable : tmp) {
|
||||||
runnable.run();
|
runnable.run();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param world
|
* @param world
|
||||||
* @param x
|
* @param x
|
||||||
@ -112,9 +112,9 @@ public class SetQueue {
|
|||||||
*/
|
*/
|
||||||
public boolean setBlock(final String world, final int x, final int y, final int z, final short id, final byte data) {
|
public boolean setBlock(final String world, final int x, final int y, final int z, final short id, final byte data) {
|
||||||
SetQueue.IMP.setWaiting();
|
SetQueue.IMP.setWaiting();
|
||||||
return queue.setBlock(world, x, y, z, id, data);
|
return this.queue.setBlock(world, x, y, z, id, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param world
|
* @param world
|
||||||
* @param x
|
* @param x
|
||||||
@ -125,9 +125,9 @@ public class SetQueue {
|
|||||||
*/
|
*/
|
||||||
public boolean setBlock(final String world, final int x, final int y, final int z, final short id) {
|
public boolean setBlock(final String world, final int x, final int y, final int z, final short id) {
|
||||||
SetQueue.IMP.setWaiting();
|
SetQueue.IMP.setWaiting();
|
||||||
return queue.setBlock(world, x, y, z, id, (byte) 0);
|
return this.queue.setBlock(world, x, y, z, id, (byte) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param world
|
* @param world
|
||||||
* @param x
|
* @param x
|
||||||
@ -137,12 +137,12 @@ public class SetQueue {
|
|||||||
* @param data
|
* @param data
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean setBiome(final String world, final int x, final int z, BaseBiome biome) {
|
public boolean setBiome(final String world, final int x, final int z, final BaseBiome biome) {
|
||||||
SetQueue.IMP.setWaiting();
|
SetQueue.IMP.setWaiting();
|
||||||
return queue.setBiome(world, x, z, biome);
|
return this.queue.setBiome(world, x, z, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isChunkLoaded(String world, int x, int z) {
|
public boolean isChunkLoaded(final String world, final int x, final int z) {
|
||||||
return queue.isChunkLoaded(world, x, z);
|
return this.queue.isChunkLoaded(world, x, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,17 +29,17 @@ public class StringMan {
|
|||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int intersection(Set<String> options, String[] toCheck) {
|
public static int intersection(final Set<String> options, final String[] toCheck) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (String check : toCheck) {
|
for (final String check : toCheck) {
|
||||||
if (options.contains(check)) {
|
if (options.contains(check)) {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getString(final Object obj) {
|
public static String getString(final Object obj) {
|
||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
return "null";
|
return "null";
|
||||||
@ -50,7 +50,7 @@ public class StringMan {
|
|||||||
if (obj.getClass().isArray()) {
|
if (obj.getClass().isArray()) {
|
||||||
String result = "";
|
String result = "";
|
||||||
String prefix = "";
|
String prefix = "";
|
||||||
|
|
||||||
for (int i = 0; i < Array.getLength(obj); i++) {
|
for (int i = 0; i < Array.getLength(obj); i++) {
|
||||||
result += prefix + getString(Array.get(obj, i));
|
result += prefix + getString(Array.get(obj, i));
|
||||||
prefix = ",";
|
prefix = ",";
|
||||||
@ -68,7 +68,7 @@ public class StringMan {
|
|||||||
return obj.toString();
|
return obj.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String replaceFirst(final char c, final String s) {
|
public static String replaceFirst(final char c, final String s) {
|
||||||
if (s == null) {
|
if (s == null) {
|
||||||
return "";
|
return "";
|
||||||
@ -94,7 +94,7 @@ public class StringMan {
|
|||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String replaceAll(final String string, final Object... pairs) {
|
public static String replaceAll(final String string, final Object... pairs) {
|
||||||
final StringBuilder sb = new StringBuilder(string);
|
final StringBuilder sb = new StringBuilder(string);
|
||||||
for (int i = 0; i < pairs.length; i += 2) {
|
for (int i = 0; i < pairs.length; i += 2) {
|
||||||
@ -110,7 +110,7 @@ public class StringMan {
|
|||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAlphanumeric(final String str) {
|
public static boolean isAlphanumeric(final String str) {
|
||||||
for (int i = 0; i < str.length(); i++) {
|
for (int i = 0; i < str.length(); i++) {
|
||||||
final char c = str.charAt(i);
|
final char c = str.charAt(i);
|
||||||
@ -120,7 +120,7 @@ public class StringMan {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAlphanumericUnd(final String str) {
|
public static boolean isAlphanumericUnd(final String str) {
|
||||||
for (int i = 0; i < str.length(); i++) {
|
for (int i = 0; i < str.length(); i++) {
|
||||||
final char c = str.charAt(i);
|
final char c = str.charAt(i);
|
||||||
@ -130,7 +130,7 @@ public class StringMan {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAlpha(final String str) {
|
public static boolean isAlpha(final String str) {
|
||||||
for (int i = 0; i < str.length(); i++) {
|
for (int i = 0; i < str.length(); i++) {
|
||||||
final char c = str.charAt(i);
|
final char c = str.charAt(i);
|
||||||
@ -140,11 +140,11 @@ public class StringMan {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String join(final Collection<?> collection, final String delimiter) {
|
public static String join(final Collection<?> collection, final String delimiter) {
|
||||||
return join(collection.toArray(), delimiter);
|
return join(collection.toArray(), delimiter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String joinOrdered(final Collection<?> collection, final String delimiter) {
|
public static String joinOrdered(final Collection<?> collection, final String delimiter) {
|
||||||
final Object[] array = collection.toArray();
|
final Object[] array = collection.toArray();
|
||||||
Arrays.sort(array, new Comparator<Object>() {
|
Arrays.sort(array, new Comparator<Object>() {
|
||||||
@ -152,19 +152,19 @@ public class StringMan {
|
|||||||
public int compare(final Object a, final Object b) {
|
public int compare(final Object a, final Object b) {
|
||||||
return a.hashCode() - b.hashCode();
|
return a.hashCode() - b.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
return join(array, delimiter);
|
return join(array, delimiter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String join(final Collection<?> collection, final char delimiter) {
|
public static String join(final Collection<?> collection, final char delimiter) {
|
||||||
return join(collection.toArray(), delimiter + "");
|
return join(collection.toArray(), delimiter + "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAsciiPrintable(final char c) {
|
public static boolean isAsciiPrintable(final char c) {
|
||||||
return (c >= ' ') && (c < '');
|
return (c >= ' ') && (c < '');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAsciiPrintable(final String s) {
|
public static boolean isAsciiPrintable(final String s) {
|
||||||
for (final char c : s.toCharArray()) {
|
for (final char c : s.toCharArray()) {
|
||||||
if (!isAsciiPrintable(c)) {
|
if (!isAsciiPrintable(c)) {
|
||||||
@ -173,7 +173,7 @@ public class StringMan {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getLevenshteinDistance(String s, String t) {
|
public static int getLevenshteinDistance(String s, String t) {
|
||||||
int n = s.length();
|
int n = s.length();
|
||||||
int m = t.length();
|
int m = t.length();
|
||||||
@ -202,7 +202,7 @@ public class StringMan {
|
|||||||
for (j = 1; j <= m; j++) {
|
for (j = 1; j <= m; j++) {
|
||||||
t_j = t.charAt(j - 1);
|
t_j = t.charAt(j - 1);
|
||||||
d[0] = j;
|
d[0] = j;
|
||||||
|
|
||||||
for (i = 1; i <= n; i++) {
|
for (i = 1; i <= n; i++) {
|
||||||
cost = s.charAt(i - 1) == t_j ? 0 : 1;
|
cost = s.charAt(i - 1) == t_j ? 0 : 1;
|
||||||
d[i] = Math.min(Math.min(d[i - 1] + 1, p[i] + 1), p[i - 1] + cost);
|
d[i] = Math.min(Math.min(d[i - 1] + 1, p[i] + 1), p[i - 1] + cost);
|
||||||
@ -213,7 +213,7 @@ public class StringMan {
|
|||||||
}
|
}
|
||||||
return p[n];
|
return p[n];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String join(final Object[] array, final String delimiter) {
|
public static String join(final Object[] array, final String delimiter) {
|
||||||
final StringBuilder result = new StringBuilder();
|
final StringBuilder result = new StringBuilder();
|
||||||
for (int i = 0, j = array.length; i < j; i++) {
|
for (int i = 0, j = array.length; i < j; i++) {
|
||||||
@ -224,7 +224,7 @@ public class StringMan {
|
|||||||
}
|
}
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String join(final int[] array, final String delimiter) {
|
public static String join(final int[] array, final String delimiter) {
|
||||||
final Integer[] wrapped = new Integer[array.length];
|
final Integer[] wrapped = new Integer[array.length];
|
||||||
for (int i = 0; i < array.length; i++) {
|
for (int i = 0; i < array.length; i++) {
|
||||||
@ -232,7 +232,7 @@ public class StringMan {
|
|||||||
}
|
}
|
||||||
return join(wrapped, delimiter);
|
return join(wrapped, delimiter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isEqualToAny(final String a, final String... args) {
|
public static boolean isEqualToAny(final String a, final String... args) {
|
||||||
for (final String arg : args) {
|
for (final String arg : args) {
|
||||||
if (StringMan.isEqual(a, arg)) {
|
if (StringMan.isEqual(a, arg)) {
|
||||||
@ -241,7 +241,7 @@ public class StringMan {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isEqualIgnoreCaseToAny(final String a, final String... args) {
|
public static boolean isEqualIgnoreCaseToAny(final String a, final String... args) {
|
||||||
for (final String arg : args) {
|
for (final String arg : args) {
|
||||||
if (StringMan.isEqualIgnoreCase(a, arg)) {
|
if (StringMan.isEqualIgnoreCase(a, arg)) {
|
||||||
@ -250,15 +250,15 @@ public class StringMan {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isEqual(final String a, final String b) {
|
public static boolean isEqual(final String a, final String b) {
|
||||||
return ((a == b) || ((a != null) && (b != null) && (a.length() == b.length()) && (a.hashCode() == b.hashCode()) && a.equals(b)));
|
return ((a == b) || ((a != null) && (b != null) && (a.length() == b.length()) && (a.hashCode() == b.hashCode()) && a.equals(b)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isEqualIgnoreCase(final String a, final String b) {
|
public static boolean isEqualIgnoreCase(final String a, final String b) {
|
||||||
return ((a == b) || ((a != null) && (b != null) && (a.length() == b.length()) && a.equalsIgnoreCase(b)));
|
return ((a == b) || ((a != null) && (b != null) && (a.length() == b.length()) && a.equalsIgnoreCase(b)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String repeat(final String s, final int n) {
|
public static String repeat(final String s, final int n) {
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
package com.boydti.fawe.util;
|
package com.boydti.fawe.util;
|
||||||
|
|
||||||
public abstract class TaskManager {
|
public abstract class TaskManager {
|
||||||
|
|
||||||
public static TaskManager IMP;
|
public static TaskManager IMP;
|
||||||
|
|
||||||
public abstract int repeat(final Runnable r, final int interval);
|
public abstract int repeat(final Runnable r, final int interval);
|
||||||
|
|
||||||
public abstract int repeatAsync(final Runnable r, final int interval);
|
public abstract int repeatAsync(final Runnable r, final int interval);
|
||||||
|
|
||||||
public abstract void async(final Runnable r);
|
public abstract void async(final Runnable r);
|
||||||
|
|
||||||
public abstract void task(final Runnable r);
|
public abstract void task(final Runnable r);
|
||||||
|
|
||||||
public abstract void later(final Runnable r, final int delay);
|
public abstract void later(final Runnable r, final int delay);
|
||||||
|
|
||||||
public abstract void laterAsync(final Runnable r, final int delay);
|
public abstract void laterAsync(final Runnable r, final int delay);
|
||||||
|
|
||||||
public abstract void cancel(final int task);
|
public abstract void cancel(final int task);
|
||||||
}
|
}
|
||||||
|
@ -14,11 +14,11 @@ import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
|||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
|
||||||
public class WEManager {
|
public class WEManager {
|
||||||
|
|
||||||
public final static WEManager IMP = new WEManager();
|
public final static WEManager IMP = new WEManager();
|
||||||
|
|
||||||
public final ArrayDeque<FaweMaskManager> managers = new ArrayDeque<>();
|
public final ArrayDeque<FaweMaskManager> managers = new ArrayDeque<>();
|
||||||
|
|
||||||
public void cancelEdit(Extent parent) {
|
public void cancelEdit(Extent parent) {
|
||||||
try {
|
try {
|
||||||
final Field field = AbstractDelegateExtent.class.getDeclaredField("extent");
|
final Field field = AbstractDelegateExtent.class.getDeclaredField("extent");
|
||||||
@ -29,7 +29,7 @@ public class WEManager {
|
|||||||
}
|
}
|
||||||
parent = null;
|
parent = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean maskContains(final HashSet<RegionWrapper> mask, final int x, final int z) {
|
public boolean maskContains(final HashSet<RegionWrapper> mask, final int x, final int z) {
|
||||||
for (final RegionWrapper region : mask) {
|
for (final RegionWrapper region : mask) {
|
||||||
if ((x >= region.minX) && (x <= region.maxX) && (z >= region.minZ) && (z <= region.maxZ)) {
|
if ((x >= region.minX) && (x <= region.maxX) && (z >= region.minZ) && (z <= region.maxZ)) {
|
||||||
@ -38,14 +38,14 @@ public class WEManager {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashSet<RegionWrapper> getMask(final FawePlayer<?> player) {
|
public HashSet<RegionWrapper> getMask(final FawePlayer<?> player) {
|
||||||
final HashSet<RegionWrapper> regions = new HashSet<>();
|
final HashSet<RegionWrapper> regions = new HashSet<>();
|
||||||
if (player.hasPermission("fawe.bypass")) {
|
if (player.hasPermission("fawe.bypass")) {
|
||||||
regions.add(new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE));
|
regions.add(new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE));
|
||||||
return regions;
|
return regions;
|
||||||
}
|
}
|
||||||
for (final FaweMaskManager manager : managers) {
|
for (final FaweMaskManager manager : this.managers) {
|
||||||
if (player.hasPermission("fawe." + manager.getKey())) {
|
if (player.hasPermission("fawe." + manager.getKey())) {
|
||||||
final FaweMask mask = manager.getMask(player);
|
final FaweMask mask = manager.getMask(player);
|
||||||
if (mask != null) {
|
if (mask != null) {
|
||||||
@ -55,23 +55,23 @@ public class WEManager {
|
|||||||
}
|
}
|
||||||
return regions;
|
return regions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean intersects(final RegionWrapper region1, final RegionWrapper region2) {
|
public boolean intersects(final RegionWrapper region1, final RegionWrapper region2) {
|
||||||
return (region1.minX <= region2.maxX) && (region1.maxX >= region2.minX) && (region1.minZ <= region2.maxZ) && (region1.maxZ >= region2.minZ);
|
return (region1.minX <= region2.maxX) && (region1.maxX >= region2.minX) && (region1.minZ <= region2.maxZ) && (region1.maxZ >= region2.minZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean regionContains(final RegionWrapper selection, final HashSet<RegionWrapper> mask) {
|
public boolean regionContains(final RegionWrapper selection, final HashSet<RegionWrapper> mask) {
|
||||||
for (final RegionWrapper region : mask) {
|
for (final RegionWrapper region : mask) {
|
||||||
if (intersects(region, selection)) {
|
if (this.intersects(region, selection)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean delay(final FawePlayer<?> player, final String command) {
|
public boolean delay(final FawePlayer<?> player, final String command) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
return delay(player, new Runnable() {
|
return this.delay(player, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@ -104,7 +104,7 @@ public class WEManager {
|
|||||||
}
|
}
|
||||||
}, false, false);
|
}, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean delay(final FawePlayer<?> player, final Runnable whenDone, final boolean delayed, final boolean onlyDelayedExecution) {
|
public boolean delay(final FawePlayer<?> player, final Runnable whenDone, final boolean delayed, final boolean onlyDelayedExecution) {
|
||||||
final boolean free = SetQueue.IMP.addTask(null);
|
final boolean free = SetQueue.IMP.addTask(null);
|
||||||
if (free) {
|
if (free) {
|
||||||
|
@ -5,8 +5,7 @@ import com.sk89q.worldedit.util.eventbus.EventHandler.Priority;
|
|||||||
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
||||||
|
|
||||||
public class WESubscriber {
|
public class WESubscriber {
|
||||||
|
|
||||||
@Subscribe(priority = Priority.VERY_EARLY)
|
@Subscribe(priority = Priority.VERY_EARLY)
|
||||||
public void onEditSession(final EditSessionEvent event) {
|
public void onEditSession(final EditSessionEvent event) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -18,96 +18,94 @@ import com.sk89q.worldedit.util.command.Dispatcher;
|
|||||||
|
|
||||||
public class DispatcherWrapper implements Dispatcher {
|
public class DispatcherWrapper implements Dispatcher {
|
||||||
private final Dispatcher parent;
|
private final Dispatcher parent;
|
||||||
|
|
||||||
public final Dispatcher getParent() {
|
public final Dispatcher getParent() {
|
||||||
return parent;
|
return this.parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DispatcherWrapper(Dispatcher parent) {
|
public DispatcherWrapper(final Dispatcher parent) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerCommand(CommandCallable callable, String... alias) {
|
public void registerCommand(final CommandCallable callable, final String... alias) {
|
||||||
parent.registerCommand(callable, alias);
|
this.parent.registerCommand(callable, alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<CommandMapping> getCommands() {
|
public Set<CommandMapping> getCommands() {
|
||||||
return parent.getCommands();
|
return this.parent.getCommands();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> getPrimaryAliases() {
|
public Collection<String> getPrimaryAliases() {
|
||||||
return parent.getPrimaryAliases();
|
return this.parent.getPrimaryAliases();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> getAliases() {
|
public Collection<String> getAliases() {
|
||||||
return parent.getAliases();
|
return this.parent.getAliases();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandMapping get(String alias) {
|
public CommandMapping get(final String alias) {
|
||||||
return parent.get(alias);
|
return this.parent.get(alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(String alias) {
|
public boolean contains(final String alias) {
|
||||||
return parent.contains(alias);
|
return this.parent.contains(alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object call(final String arguments, final CommandLocals locals, final String[] parentCommands) throws CommandException {
|
public Object call(final String arguments, final CommandLocals locals, final String[] parentCommands) throws CommandException {
|
||||||
TaskManager.IMP.async(new Runnable() {
|
TaskManager.IMP.async(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
parent.call(arguments, locals, parentCommands);
|
DispatcherWrapper.this.parent.call(arguments, locals, parentCommands);
|
||||||
} catch (CommandException e) {
|
} catch (final CommandException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Description getDescription() {
|
public Description getDescription() {
|
||||||
return parent.getDescription();
|
return this.parent.getDescription();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean testPermission(CommandLocals locals) {
|
|
||||||
return parent.testPermission(locals);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getSuggestions(String arguments, CommandLocals locals) throws CommandException {
|
public boolean testPermission(final CommandLocals locals) {
|
||||||
return parent.getSuggestions(arguments, locals);
|
return this.parent.testPermission(locals);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getSuggestions(final String arguments, final CommandLocals locals) throws CommandException {
|
||||||
|
return this.parent.getSuggestions(arguments, locals);
|
||||||
|
}
|
||||||
|
|
||||||
public static void inject() {
|
public static void inject() {
|
||||||
// Delayed injection
|
// Delayed injection
|
||||||
TaskManager.IMP.task(new Runnable() {
|
TaskManager.IMP.task(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
PlatformManager platform = WorldEdit.getInstance().getPlatformManager();
|
final PlatformManager platform = WorldEdit.getInstance().getPlatformManager();
|
||||||
CommandManager command = platform.getCommandManager();
|
final CommandManager command = platform.getCommandManager();
|
||||||
Class<? extends CommandManager> clazz = command.getClass();
|
final Class<? extends CommandManager> clazz = command.getClass();
|
||||||
Field field = clazz.getDeclaredField("dispatcher");
|
final Field field = clazz.getDeclaredField("dispatcher");
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
Dispatcher parent = (Dispatcher) field.get(command);
|
final Dispatcher parent = (Dispatcher) field.get(command);
|
||||||
DispatcherWrapper dispatcher = new DispatcherWrapper(parent);
|
final DispatcherWrapper dispatcher = new DispatcherWrapper(parent);
|
||||||
field.set(command, dispatcher);
|
field.set(command, dispatcher);
|
||||||
} catch (Throwable e) {
|
} catch (final Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,11 +43,11 @@ import com.sk89q.worldedit.world.registry.WorldData;
|
|||||||
* @see Transform
|
* @see Transform
|
||||||
*/
|
*/
|
||||||
public class FlattenedClipboardTransform {
|
public class FlattenedClipboardTransform {
|
||||||
|
|
||||||
private final Clipboard original;
|
private final Clipboard original;
|
||||||
private final Transform transform;
|
private final Transform transform;
|
||||||
private final WorldData worldData;
|
private final WorldData worldData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
*
|
*
|
||||||
@ -63,19 +63,20 @@ public class FlattenedClipboardTransform {
|
|||||||
this.transform = transform;
|
this.transform = transform;
|
||||||
this.worldData = worldData;
|
this.worldData = worldData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the transformed region.
|
* Get the transformed region.
|
||||||
*
|
*
|
||||||
* @return the transformed region
|
* @return the transformed region
|
||||||
*/
|
*/
|
||||||
public Region getTransformedRegion() {
|
public Region getTransformedRegion() {
|
||||||
final Region region = original.getRegion();
|
final Region region = this.original.getRegion();
|
||||||
final Vector minimum = region.getMinimumPoint();
|
final Vector minimum = region.getMinimumPoint();
|
||||||
final Vector maximum = region.getMaximumPoint();
|
final Vector maximum = region.getMaximumPoint();
|
||||||
|
|
||||||
final Transform transformAround = new CombinedTransform(new AffineTransform().translate(original.getOrigin().multiply(-1)), transform, new AffineTransform().translate(original.getOrigin()));
|
final Transform transformAround = new CombinedTransform(new AffineTransform().translate(this.original.getOrigin().multiply(-1)), this.transform, new AffineTransform().translate(this.original
|
||||||
|
.getOrigin()));
|
||||||
|
|
||||||
final Vector[] corners = new Vector[] {
|
final Vector[] corners = new Vector[] {
|
||||||
minimum,
|
minimum,
|
||||||
maximum,
|
maximum,
|
||||||
@ -85,32 +86,32 @@ public class FlattenedClipboardTransform {
|
|||||||
maximum.setX(minimum.getX()),
|
maximum.setX(minimum.getX()),
|
||||||
maximum.setY(minimum.getY()),
|
maximum.setY(minimum.getY()),
|
||||||
maximum.setZ(minimum.getZ()) };
|
maximum.setZ(minimum.getZ()) };
|
||||||
|
|
||||||
for (int i = 0; i < corners.length; i++) {
|
for (int i = 0; i < corners.length; i++) {
|
||||||
corners[i] = transformAround.apply(corners[i]);
|
corners[i] = transformAround.apply(corners[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector newMinimum = corners[0];
|
Vector newMinimum = corners[0];
|
||||||
Vector newMaximum = corners[0];
|
Vector newMaximum = corners[0];
|
||||||
|
|
||||||
for (int i = 1; i < corners.length; i++) {
|
for (int i = 1; i < corners.length; i++) {
|
||||||
newMinimum = Vector.getMinimum(newMinimum, corners[i]);
|
newMinimum = Vector.getMinimum(newMinimum, corners[i]);
|
||||||
newMaximum = Vector.getMaximum(newMaximum, corners[i]);
|
newMaximum = Vector.getMaximum(newMaximum, corners[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// After transformation, the points may not really sit on a block,
|
// After transformation, the points may not really sit on a block,
|
||||||
// so we should expand the region for edge cases
|
// so we should expand the region for edge cases
|
||||||
newMinimum = newMinimum.setX(Math.floor(newMinimum.getX()));
|
newMinimum = newMinimum.setX(Math.floor(newMinimum.getX()));
|
||||||
newMinimum = newMinimum.setY(Math.floor(newMinimum.getY()));
|
newMinimum = newMinimum.setY(Math.floor(newMinimum.getY()));
|
||||||
newMinimum = newMinimum.setZ(Math.floor(newMinimum.getZ()));
|
newMinimum = newMinimum.setZ(Math.floor(newMinimum.getZ()));
|
||||||
|
|
||||||
newMaximum = newMaximum.setX(Math.ceil(newMaximum.getX()));
|
newMaximum = newMaximum.setX(Math.ceil(newMaximum.getX()));
|
||||||
newMaximum = newMaximum.setY(Math.ceil(newMaximum.getY()));
|
newMaximum = newMaximum.setY(Math.ceil(newMaximum.getY()));
|
||||||
newMaximum = newMaximum.setZ(Math.ceil(newMaximum.getZ()));
|
newMaximum = newMaximum.setZ(Math.ceil(newMaximum.getZ()));
|
||||||
|
|
||||||
return new CuboidRegion(newMinimum, newMaximum);
|
return new CuboidRegion(newMinimum, newMaximum);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an operation to copy from the original clipboard to the given extent.
|
* Create an operation to copy from the original clipboard to the given extent.
|
||||||
*
|
*
|
||||||
@ -118,12 +119,12 @@ public class FlattenedClipboardTransform {
|
|||||||
* @return the operation
|
* @return the operation
|
||||||
*/
|
*/
|
||||||
public Operation copyTo(final Extent target) {
|
public Operation copyTo(final Extent target) {
|
||||||
final BlockTransformExtent extent = new BlockTransformExtent(original, transform, worldData.getBlockRegistry());
|
final BlockTransformExtent extent = new BlockTransformExtent(this.original, this.transform, this.worldData.getBlockRegistry());
|
||||||
final ForwardExtentCopy copy = new ForwardExtentCopy(extent, original.getRegion(), original.getOrigin(), target, original.getOrigin());
|
final ForwardExtentCopy copy = new ForwardExtentCopy(extent, this.original.getRegion(), this.original.getOrigin(), target, this.original.getOrigin());
|
||||||
copy.setTransform(transform);
|
copy.setTransform(this.transform);
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance to bake the transform with.
|
* Create a new instance to bake the transform with.
|
||||||
*
|
*
|
||||||
@ -135,5 +136,5 @@ public class FlattenedClipboardTransform {
|
|||||||
public static FlattenedClipboardTransform transform(final Clipboard original, final Transform transform, final WorldData worldData) {
|
public static FlattenedClipboardTransform transform(final Clipboard original, final Transform transform, final WorldData worldData) {
|
||||||
return new FlattenedClipboardTransform(original, transform, worldData);
|
return new FlattenedClipboardTransform(original, transform, worldData);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -64,10 +64,10 @@ import com.sk89q.worldedit.world.registry.WorldData;
|
|||||||
* Commands that work with schematic files.
|
* Commands that work with schematic files.
|
||||||
*/
|
*/
|
||||||
public class SchematicCommands {
|
public class SchematicCommands {
|
||||||
|
|
||||||
private static final Logger log = Logger.getLogger(SchematicCommands.class.getCanonicalName());
|
private static final Logger log = Logger.getLogger(SchematicCommands.class.getCanonicalName());
|
||||||
private final WorldEdit worldEdit;
|
private final WorldEdit worldEdit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
*
|
*
|
||||||
@ -77,27 +77,27 @@ public class SchematicCommands {
|
|||||||
checkNotNull(worldEdit);
|
checkNotNull(worldEdit);
|
||||||
this.worldEdit = worldEdit;
|
this.worldEdit = worldEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = { "load" }, usage = "[<format>] <filename>", desc = "Load a schematic into your clipboard")
|
@Command(aliases = { "load" }, usage = "[<format>] <filename>", desc = "Load a schematic into your clipboard")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@CommandPermissions({ "worldedit.clipboard.load", "worldedit.schematic.load" })
|
@CommandPermissions({ "worldedit.clipboard.load", "worldedit.schematic.load" })
|
||||||
public void load(final Player player, final LocalSession session, @Optional("schematic") final String formatName, final String filename) throws FilenameException {
|
public void load(final Player player, final LocalSession session, @Optional("schematic") final String formatName, final String filename) throws FilenameException {
|
||||||
final LocalConfiguration config = worldEdit.getConfiguration();
|
final LocalConfiguration config = this.worldEdit.getConfiguration();
|
||||||
|
|
||||||
final File dir = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
final File dir = this.worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||||
final File f = worldEdit.getSafeOpenFile(player, dir, filename, "schematic", "schematic");
|
final File f = this.worldEdit.getSafeOpenFile(player, dir, filename, "schematic", "schematic");
|
||||||
|
|
||||||
if (!f.exists()) {
|
if (!f.exists()) {
|
||||||
player.printError("Schematic " + filename + " does not exist!");
|
player.printError("Schematic " + filename + " does not exist!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final ClipboardFormat format = ClipboardFormat.findByAlias(formatName);
|
final ClipboardFormat format = ClipboardFormat.findByAlias(formatName);
|
||||||
if (format == null) {
|
if (format == null) {
|
||||||
player.printError("Unknown schematic format: " + formatName);
|
player.printError("Unknown schematic format: " + formatName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetQueue.IMP.addTask(new Runnable() {
|
SetQueue.IMP.addTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -108,18 +108,18 @@ public class SchematicCommands {
|
|||||||
try {
|
try {
|
||||||
final String filePath = f.getCanonicalPath();
|
final String filePath = f.getCanonicalPath();
|
||||||
final String dirPath = dir.getCanonicalPath();
|
final String dirPath = dir.getCanonicalPath();
|
||||||
|
|
||||||
if (!filePath.substring(0, dirPath.length()).equals(dirPath)) {
|
if (!filePath.substring(0, dirPath.length()).equals(dirPath)) {
|
||||||
player.printError("Clipboard file could not read or it does not exist.");
|
player.printError("Clipboard file could not read or it does not exist.");
|
||||||
} else {
|
} else {
|
||||||
final FileInputStream fis = closer.register(new FileInputStream(f));
|
final FileInputStream fis = closer.register(new FileInputStream(f));
|
||||||
final BufferedInputStream bis = closer.register(new BufferedInputStream(fis));
|
final BufferedInputStream bis = closer.register(new BufferedInputStream(fis));
|
||||||
final ClipboardReader reader = format.getReader(bis);
|
final ClipboardReader reader = format.getReader(bis);
|
||||||
|
|
||||||
final WorldData worldData = player.getWorld().getWorldData();
|
final WorldData worldData = player.getWorld().getWorldData();
|
||||||
final Clipboard clipboard = reader.read(player.getWorld().getWorldData());
|
final Clipboard clipboard = reader.read(player.getWorld().getWorldData());
|
||||||
session.setClipboard(new ClipboardHolder(clipboard, worldData));
|
session.setClipboard(new ClipboardHolder(clipboard, worldData));
|
||||||
|
|
||||||
log.info(player.getName() + " loaded " + filePath);
|
log.info(player.getName() + " loaded " + filePath);
|
||||||
player.print(filename + " loaded. Paste it with //paste");
|
player.print(filename + " loaded. Paste it with //paste");
|
||||||
}
|
}
|
||||||
@ -136,27 +136,27 @@ public class SchematicCommands {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = { "save" }, usage = "[<format>] <filename>", desc = "Save a schematic into your clipboard")
|
@Command(aliases = { "save" }, usage = "[<format>] <filename>", desc = "Save a schematic into your clipboard")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@CommandPermissions({ "worldedit.clipboard.save", "worldedit.schematic.save" })
|
@CommandPermissions({ "worldedit.clipboard.save", "worldedit.schematic.save" })
|
||||||
public void save(final Player player, final LocalSession session, @Optional("schematic") final String formatName, final String filename) throws CommandException, WorldEditException {
|
public void save(final Player player, final LocalSession session, @Optional("schematic") final String formatName, final String filename) throws CommandException, WorldEditException {
|
||||||
final LocalConfiguration config = worldEdit.getConfiguration();
|
final LocalConfiguration config = this.worldEdit.getConfiguration();
|
||||||
|
|
||||||
final File dir = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
final File dir = this.worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||||
final File f = worldEdit.getSafeSaveFile(player, dir, filename, "schematic", "schematic");
|
final File f = this.worldEdit.getSafeSaveFile(player, dir, filename, "schematic", "schematic");
|
||||||
|
|
||||||
final ClipboardFormat format = ClipboardFormat.findByAlias(formatName);
|
final ClipboardFormat format = ClipboardFormat.findByAlias(formatName);
|
||||||
if (format == null) {
|
if (format == null) {
|
||||||
player.printError("Unknown schematic format: " + formatName);
|
player.printError("Unknown schematic format: " + formatName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final ClipboardHolder holder = session.getClipboard();
|
final ClipboardHolder holder = session.getClipboard();
|
||||||
final Clipboard clipboard = holder.getClipboard();
|
final Clipboard clipboard = holder.getClipboard();
|
||||||
final Transform transform = holder.getTransform();
|
final Transform transform = holder.getTransform();
|
||||||
final Clipboard target;
|
final Clipboard target;
|
||||||
|
|
||||||
// If we have a transform, bake it into the copy
|
// If we have a transform, bake it into the copy
|
||||||
if (!transform.isIdentity()) {
|
if (!transform.isIdentity()) {
|
||||||
final FlattenedClipboardTransform result = FlattenedClipboardTransform.transform(clipboard, transform, holder.getWorldData());
|
final FlattenedClipboardTransform result = FlattenedClipboardTransform.transform(clipboard, transform, holder.getWorldData());
|
||||||
@ -166,7 +166,7 @@ public class SchematicCommands {
|
|||||||
} else {
|
} else {
|
||||||
target = clipboard;
|
target = clipboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetQueue.IMP.addTask(new Runnable() {
|
SetQueue.IMP.addTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -183,7 +183,7 @@ public class SchematicCommands {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final FileOutputStream fos = closer.register(new FileOutputStream(f));
|
final FileOutputStream fos = closer.register(new FileOutputStream(f));
|
||||||
final BufferedOutputStream bos = closer.register(new BufferedOutputStream(fos));
|
final BufferedOutputStream bos = closer.register(new BufferedOutputStream(fos));
|
||||||
final ClipboardWriter writer = closer.register(format.getWriter(bos));
|
final ClipboardWriter writer = closer.register(format.getWriter(bos));
|
||||||
@ -203,15 +203,15 @@ public class SchematicCommands {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = { "delete", "d" }, usage = "<filename>", desc = "Delete a saved schematic", help = "Delete a schematic from the schematic list", min = 1, max = 1)
|
@Command(aliases = { "delete", "d" }, usage = "<filename>", desc = "Delete a saved schematic", help = "Delete a schematic from the schematic list", min = 1, max = 1)
|
||||||
@CommandPermissions("worldedit.schematic.delete")
|
@CommandPermissions("worldedit.schematic.delete")
|
||||||
public void delete(final Player player, final LocalSession session, final EditSession editSession, final CommandContext args) throws WorldEditException {
|
public void delete(final Player player, final LocalSession session, final EditSession editSession, final CommandContext args) throws WorldEditException {
|
||||||
final LocalConfiguration config = worldEdit.getConfiguration();
|
final LocalConfiguration config = this.worldEdit.getConfiguration();
|
||||||
final String filename = args.getString(0);
|
final String filename = args.getString(0);
|
||||||
|
|
||||||
final File dir = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
final File dir = this.worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||||
final File f = worldEdit.getSafeSaveFile(player, dir, filename, "schematic", "schematic");
|
final File f = this.worldEdit.getSafeSaveFile(player, dir, filename, "schematic", "schematic");
|
||||||
TaskManager.IMP.async(new Runnable() {
|
TaskManager.IMP.async(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -219,17 +219,17 @@ public class SchematicCommands {
|
|||||||
player.printError("Schematic " + filename + " does not exist!");
|
player.printError("Schematic " + filename + " does not exist!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!f.delete()) {
|
if (!f.delete()) {
|
||||||
player.printError("Deletion of " + filename + " failed! Maybe it is read-only.");
|
player.printError("Deletion of " + filename + " failed! Maybe it is read-only.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.print(filename + " has been deleted.");
|
player.print(filename + " has been deleted.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = { "formats", "listformats", "f" }, desc = "List available formats", max = 0)
|
@Command(aliases = { "formats", "listformats", "f" }, desc = "List available formats", max = 0)
|
||||||
@CommandPermissions("worldedit.schematic.formats")
|
@CommandPermissions("worldedit.schematic.formats")
|
||||||
public void formats(final Actor actor) throws WorldEditException {
|
public void formats(final Actor actor) throws WorldEditException {
|
||||||
@ -250,13 +250,13 @@ public class SchematicCommands {
|
|||||||
actor.print(builder.toString());
|
actor.print(builder.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = { "list", "all", "ls" }, desc = "List saved schematics", max = 0, flags = "dn", help = "List all schematics in the schematics directory\n"
|
@Command(aliases = { "list", "all", "ls" }, desc = "List saved schematics", max = 0, flags = "dn", help = "List all schematics in the schematics directory\n"
|
||||||
+ " -d sorts by date, oldest first\n"
|
+ " -d sorts by date, oldest first\n"
|
||||||
+ " -n sorts by date, newest first\n")
|
+ " -n sorts by date, newest first\n")
|
||||||
@CommandPermissions("worldedit.schematic.list")
|
@CommandPermissions("worldedit.schematic.list")
|
||||||
public void list(final Actor actor, final CommandContext args) throws WorldEditException {
|
public void list(final Actor actor, final CommandContext args) throws WorldEditException {
|
||||||
final File dir = worldEdit.getWorkingDirectoryFile(worldEdit.getConfiguration().saveDir);
|
final File dir = this.worldEdit.getWorkingDirectoryFile(this.worldEdit.getConfiguration().saveDir);
|
||||||
final File[] files = dir.listFiles(new FileFilter() {
|
final File[] files = dir.listFiles(new FileFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(final File file) {
|
public boolean accept(final File file) {
|
||||||
@ -269,7 +269,7 @@ public class SchematicCommands {
|
|||||||
if (files == null) {
|
if (files == null) {
|
||||||
throw new FilenameResolutionException(dir.getPath(), "Schematics directory invalid or not found.");
|
throw new FilenameResolutionException(dir.getPath(), "Schematics directory invalid or not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
final int sortType = args.hasFlag('d') ? -1 : args.hasFlag('n') ? 1 : 0;
|
final int sortType = args.hasFlag('d') ? -1 : args.hasFlag('n') ? 1 : 0;
|
||||||
// cleanup file list
|
// cleanup file list
|
||||||
Arrays.sort(files, new Comparator<File>() {
|
Arrays.sort(files, new Comparator<File>() {
|
||||||
@ -283,37 +283,37 @@ public class SchematicCommands {
|
|||||||
}
|
}
|
||||||
// http://stackoverflow.com/questions/203030/best-way-to-list-files-in-java-sorted-by-date-modified
|
// http://stackoverflow.com/questions/203030/best-way-to-list-files-in-java-sorted-by-date-modified
|
||||||
int result = sortType == 0 ? f1.getName().compareToIgnoreCase(f2.getName()) : // use name by default
|
int result = sortType == 0 ? f1.getName().compareToIgnoreCase(f2.getName()) : // use name by default
|
||||||
Long.valueOf(f1.lastModified()).compareTo(f2.lastModified()); // use date if there is a flag
|
Long.valueOf(f1.lastModified()).compareTo(f2.lastModified()); // use date if there is a flag
|
||||||
if (sortType == 1) {
|
if (sortType == 1) {
|
||||||
result = -result; // flip date for newest first instead of oldest first
|
result = -result; // flip date for newest first instead of oldest first
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
actor.print("Available schematics (Filename (Format)):");
|
actor.print("Available schematics (Filename (Format)):");
|
||||||
actor.print(listFiles("", files));
|
actor.print(this.listFiles("", files));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String listFiles(final String prefix, final File[] files) {
|
private String listFiles(final String prefix, final File[] files) {
|
||||||
final StringBuilder build = new StringBuilder();
|
final StringBuilder build = new StringBuilder();
|
||||||
for (final File file : files) {
|
for (final File file : files) {
|
||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
build.append(listFiles(prefix + file.getName() + "/", file.listFiles()));
|
build.append(this.listFiles(prefix + file.getName() + "/", file.listFiles()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file.isFile()) {
|
if (!file.isFile()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
build.append("\n\u00a79");
|
build.append("\n\u00a79");
|
||||||
final ClipboardFormat format = ClipboardFormat.findByFile(file);
|
final ClipboardFormat format = ClipboardFormat.findByFile(file);
|
||||||
build.append(prefix).append(file.getName()).append(": ").append(format == null ? "Unknown" : format.name());
|
build.append(prefix).append(file.getName()).append(": ").append(format == null ? "Unknown" : format.name());
|
||||||
}
|
}
|
||||||
return build.toString();
|
return build.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> inject() {
|
public static Class<?> inject() {
|
||||||
return SchematicCommands.class;
|
return SchematicCommands.class;
|
||||||
}
|
}
|
||||||
|
@ -40,9 +40,9 @@ import com.sk89q.worldedit.entity.Player;
|
|||||||
* Commands related to scripting.
|
* Commands related to scripting.
|
||||||
*/
|
*/
|
||||||
public class ScriptingCommands {
|
public class ScriptingCommands {
|
||||||
|
|
||||||
private final WorldEdit worldEdit;
|
private final WorldEdit worldEdit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
*
|
*
|
||||||
@ -52,23 +52,23 @@ public class ScriptingCommands {
|
|||||||
checkNotNull(worldEdit);
|
checkNotNull(worldEdit);
|
||||||
this.worldEdit = worldEdit;
|
this.worldEdit = worldEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = { "cs" }, usage = "<filename> [args...]", desc = "Execute a CraftScript", min = 1, max = -1)
|
@Command(aliases = { "cs" }, usage = "<filename> [args...]", desc = "Execute a CraftScript", min = 1, max = -1)
|
||||||
@CommandPermissions("worldedit.scripting.execute")
|
@CommandPermissions("worldedit.scripting.execute")
|
||||||
@Logging(ALL)
|
@Logging(ALL)
|
||||||
public void execute(final Player player, final LocalSession session, final EditSession editSession, final CommandContext args) throws WorldEditException {
|
public void execute(final Player player, final LocalSession session, final EditSession editSession, final CommandContext args) throws WorldEditException {
|
||||||
final String[] scriptArgs = args.getSlice(1);
|
final String[] scriptArgs = args.getSlice(1);
|
||||||
final String name = args.getString(0);
|
final String name = args.getString(0);
|
||||||
|
|
||||||
if (!player.hasPermission("worldedit.scripting.execute." + name)) {
|
if (!player.hasPermission("worldedit.scripting.execute." + name)) {
|
||||||
player.printError("You don't have permission to use that script.");
|
player.printError("You don't have permission to use that script.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
session.setLastScript(name);
|
session.setLastScript(name);
|
||||||
|
|
||||||
final File dir = worldEdit.getWorkingDirectoryFile(worldEdit.getConfiguration().scriptsDir);
|
final File dir = this.worldEdit.getWorkingDirectoryFile(this.worldEdit.getConfiguration().scriptsDir);
|
||||||
final File f = worldEdit.getSafeOpenFile(player, dir, name, "js", "js");
|
final File f = this.worldEdit.getSafeOpenFile(player, dir, name, "js", "js");
|
||||||
SetQueue.IMP.addTask(new Runnable() {
|
SetQueue.IMP.addTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -76,7 +76,7 @@ public class ScriptingCommands {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
worldEdit.runScript(player, f, scriptArgs);
|
ScriptingCommands.this.worldEdit.runScript(player, f, scriptArgs);
|
||||||
} catch (final WorldEditException ex) {
|
} catch (final WorldEditException ex) {
|
||||||
player.printError("Error while executing CraftScript.");
|
player.printError("Error while executing CraftScript.");
|
||||||
}
|
}
|
||||||
@ -85,28 +85,28 @@ public class ScriptingCommands {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = { ".s" }, usage = "[args...]", desc = "Execute last CraftScript", min = 0, max = -1)
|
@Command(aliases = { ".s" }, usage = "[args...]", desc = "Execute last CraftScript", min = 0, max = -1)
|
||||||
@CommandPermissions("worldedit.scripting.execute")
|
@CommandPermissions("worldedit.scripting.execute")
|
||||||
@Logging(ALL)
|
@Logging(ALL)
|
||||||
public void executeLast(final Player player, final LocalSession session, final EditSession editSession, final CommandContext args) throws WorldEditException {
|
public void executeLast(final Player player, final LocalSession session, final EditSession editSession, final CommandContext args) throws WorldEditException {
|
||||||
final String lastScript = session.getLastScript();
|
final String lastScript = session.getLastScript();
|
||||||
|
|
||||||
if (!player.hasPermission("worldedit.scripting.execute." + lastScript)) {
|
if (!player.hasPermission("worldedit.scripting.execute." + lastScript)) {
|
||||||
player.printError("You don't have permission to use that script.");
|
player.printError("You don't have permission to use that script.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastScript == null) {
|
if (lastScript == null) {
|
||||||
player.printError("Use /cs with a script name first.");
|
player.printError("Use /cs with a script name first.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String[] scriptArgs = args.getSlice(0);
|
final String[] scriptArgs = args.getSlice(0);
|
||||||
|
|
||||||
final File dir = worldEdit.getWorkingDirectoryFile(worldEdit.getConfiguration().scriptsDir);
|
final File dir = this.worldEdit.getWorkingDirectoryFile(this.worldEdit.getConfiguration().scriptsDir);
|
||||||
final File f = worldEdit.getSafeOpenFile(player, dir, lastScript, "js", "js");
|
final File f = this.worldEdit.getSafeOpenFile(player, dir, lastScript, "js", "js");
|
||||||
|
|
||||||
SetQueue.IMP.addTask(new Runnable() {
|
SetQueue.IMP.addTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -114,7 +114,7 @@ public class ScriptingCommands {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
worldEdit.runScript(player, f, scriptArgs);
|
ScriptingCommands.this.worldEdit.runScript(player, f, scriptArgs);
|
||||||
} catch (final WorldEditException ex) {
|
} catch (final WorldEditException ex) {
|
||||||
player.printError("Error while executing CraftScript.");
|
player.printError("Error while executing CraftScript.");
|
||||||
}
|
}
|
||||||
@ -123,7 +123,7 @@ public class ScriptingCommands {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> inject() {
|
public static Class<?> inject() {
|
||||||
return ScriptingCommands.class;
|
return ScriptingCommands.class;
|
||||||
}
|
}
|
||||||
|
@ -28,9 +28,9 @@ import com.sk89q.worldedit.WorldEditException;
|
|||||||
* Operation helper methods.
|
* Operation helper methods.
|
||||||
*/
|
*/
|
||||||
public final class Operations {
|
public final class Operations {
|
||||||
|
|
||||||
private Operations() {}
|
private Operations() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Complete a given operation synchronously until it completes.
|
* Complete a given operation synchronously until it completes.
|
||||||
*
|
*
|
||||||
@ -42,7 +42,7 @@ public final class Operations {
|
|||||||
operation = operation.resume(new RunContext());
|
operation = operation.resume(new RunContext());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Complete a given operation synchronously until it completes. Catch all
|
* Complete a given operation synchronously until it completes. Catch all
|
||||||
* errors that is not {@link MaxChangedBlocksException} for legacy reasons.
|
* errors that is not {@link MaxChangedBlocksException} for legacy reasons.
|
||||||
@ -59,7 +59,7 @@ public final class Operations {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Complete a given operation synchronously until it completes. Re-throw all
|
* Complete a given operation synchronously until it completes. Re-throw all
|
||||||
* {@link com.sk89q.worldedit.WorldEditException} exceptions as
|
* {@link com.sk89q.worldedit.WorldEditException} exceptions as
|
||||||
@ -76,7 +76,7 @@ public final class Operations {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void completeSmart(final Operation op, final Runnable whenDone, final boolean threadsafe) {
|
public static void completeSmart(final Operation op, final Runnable whenDone, final boolean threadsafe) {
|
||||||
if (!threadsafe) {
|
if (!threadsafe) {
|
||||||
completeBlindly(op);
|
completeBlindly(op);
|
||||||
@ -105,7 +105,7 @@ public final class Operations {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> inject() {
|
public static Class<?> inject() {
|
||||||
return Operations.class;
|
return Operations.class;
|
||||||
}
|
}
|
||||||
|
@ -49,13 +49,13 @@ import com.sk89q.worldedit.function.operation.RunContext;
|
|||||||
* those points.</p>
|
* those points.</p>
|
||||||
*/
|
*/
|
||||||
public abstract class BreadthFirstSearch implements Operation {
|
public abstract class BreadthFirstSearch implements Operation {
|
||||||
|
|
||||||
private final RegionFunction function;
|
private final RegionFunction function;
|
||||||
private final Queue<BlockVector> queue = new ArrayDeque<BlockVector>();
|
private final Queue<BlockVector> queue = new ArrayDeque<BlockVector>();
|
||||||
private final Set<BlockVector> visited = new HashSet<BlockVector>();
|
private final Set<BlockVector> visited = new HashSet<BlockVector>();
|
||||||
private final List<Vector> directions = new ArrayList<Vector>();
|
private final List<Vector> directions = new ArrayList<Vector>();
|
||||||
private int affected = 0;
|
private int affected = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
*
|
*
|
||||||
@ -64,9 +64,9 @@ public abstract class BreadthFirstSearch implements Operation {
|
|||||||
protected BreadthFirstSearch(final RegionFunction function) {
|
protected BreadthFirstSearch(final RegionFunction function) {
|
||||||
checkNotNull(function);
|
checkNotNull(function);
|
||||||
this.function = function;
|
this.function = function;
|
||||||
addAxes();
|
this.addAxes();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the list of directions will be visited.
|
* Get the list of directions will be visited.
|
||||||
*
|
*
|
||||||
@ -80,31 +80,31 @@ public abstract class BreadthFirstSearch implements Operation {
|
|||||||
* @return the list of directions
|
* @return the list of directions
|
||||||
*/
|
*/
|
||||||
protected Collection<Vector> getDirections() {
|
protected Collection<Vector> getDirections() {
|
||||||
return directions;
|
return this.directions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the directions along the axes as directions to visit.
|
* Add the directions along the axes as directions to visit.
|
||||||
*/
|
*/
|
||||||
protected void addAxes() {
|
protected void addAxes() {
|
||||||
directions.add(new Vector(0, -1, 0));
|
this.directions.add(new Vector(0, -1, 0));
|
||||||
directions.add(new Vector(0, 1, 0));
|
this.directions.add(new Vector(0, 1, 0));
|
||||||
directions.add(new Vector(-1, 0, 0));
|
this.directions.add(new Vector(-1, 0, 0));
|
||||||
directions.add(new Vector(1, 0, 0));
|
this.directions.add(new Vector(1, 0, 0));
|
||||||
directions.add(new Vector(0, 0, -1));
|
this.directions.add(new Vector(0, 0, -1));
|
||||||
directions.add(new Vector(0, 0, 1));
|
this.directions.add(new Vector(0, 0, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the diagonal directions as directions to visit.
|
* Add the diagonal directions as directions to visit.
|
||||||
*/
|
*/
|
||||||
protected void addDiagonal() {
|
protected void addDiagonal() {
|
||||||
directions.add(new Vector(1, 0, 1));
|
this.directions.add(new Vector(1, 0, 1));
|
||||||
directions.add(new Vector(-1, 0, -1));
|
this.directions.add(new Vector(-1, 0, -1));
|
||||||
directions.add(new Vector(1, 0, -1));
|
this.directions.add(new Vector(1, 0, -1));
|
||||||
directions.add(new Vector(-1, 0, 1));
|
this.directions.add(new Vector(-1, 0, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the given location to the list of locations to visit, provided
|
* Add the given location to the list of locations to visit, provided
|
||||||
* that it has not been visited. The position passed to this method
|
* that it has not been visited. The position passed to this method
|
||||||
@ -121,12 +121,12 @@ public abstract class BreadthFirstSearch implements Operation {
|
|||||||
*/
|
*/
|
||||||
public void visit(final Vector position) {
|
public void visit(final Vector position) {
|
||||||
final BlockVector blockVector = position.toBlockVector();
|
final BlockVector blockVector = position.toBlockVector();
|
||||||
if (!visited.contains(blockVector)) {
|
if (!this.visited.contains(blockVector)) {
|
||||||
queue.add(blockVector);
|
this.queue.add(blockVector);
|
||||||
visited.add(blockVector);
|
this.visited.add(blockVector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to visit the given 'to' location.
|
* Try to visit the given 'to' location.
|
||||||
*
|
*
|
||||||
@ -135,14 +135,14 @@ public abstract class BreadthFirstSearch implements Operation {
|
|||||||
*/
|
*/
|
||||||
private void visit(final Vector from, final Vector to) {
|
private void visit(final Vector from, final Vector to) {
|
||||||
final BlockVector blockVector = to.toBlockVector();
|
final BlockVector blockVector = to.toBlockVector();
|
||||||
if (!visited.contains(blockVector)) {
|
if (!this.visited.contains(blockVector)) {
|
||||||
visited.add(blockVector);
|
this.visited.add(blockVector);
|
||||||
if (isVisitable(from, to)) {
|
if (this.isVisitable(from, to)) {
|
||||||
queue.add(blockVector);
|
this.queue.add(blockVector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return whether the given 'to' block should be visited, starting from the
|
* Return whether the given 'to' block should be visited, starting from the
|
||||||
* 'from' block.
|
* 'from' block.
|
||||||
@ -152,40 +152,40 @@ public abstract class BreadthFirstSearch implements Operation {
|
|||||||
* @return true if the 'to' block should be visited
|
* @return true if the 'to' block should be visited
|
||||||
*/
|
*/
|
||||||
protected abstract boolean isVisitable(final Vector from, final Vector to);
|
protected abstract boolean isVisitable(final Vector from, final Vector to);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of affected objects.
|
* Get the number of affected objects.
|
||||||
*
|
*
|
||||||
* @return the number of affected
|
* @return the number of affected
|
||||||
*/
|
*/
|
||||||
public int getAffected() {
|
public int getAffected() {
|
||||||
return affected;
|
return this.affected;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Operation resume(final RunContext run) throws WorldEditException {
|
public Operation resume(final RunContext run) throws WorldEditException {
|
||||||
Vector position;
|
Vector position;
|
||||||
while ((position = queue.poll()) != null) {
|
while ((position = this.queue.poll()) != null) {
|
||||||
if (function.apply(position)) {
|
if (this.function.apply(position)) {
|
||||||
affected++;
|
this.affected++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final Vector dir : directions) {
|
for (final Vector dir : this.directions) {
|
||||||
visit(position, position.add(dir));
|
this.visit(position, position.add(dir));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancel() {}
|
public void cancel() {}
|
||||||
|
|
||||||
public static Class<?> inject() {
|
public static Class<?> inject() {
|
||||||
return Operations.class;
|
return Operations.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addStatusMessages(List<String> messages) {
|
public void addStatusMessages(final List<String> messages) {
|
||||||
messages.add(getAffected() + " blocks affected");
|
messages.add(this.getAffected() + " blocks affected");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,9 +36,9 @@ import com.sk89q.worldedit.function.operation.Operations;
|
|||||||
* <p>This is used by {@code //fill}.</p>
|
* <p>This is used by {@code //fill}.</p>
|
||||||
*/
|
*/
|
||||||
public class DownwardVisitor extends RecursiveVisitor {
|
public class DownwardVisitor extends RecursiveVisitor {
|
||||||
|
|
||||||
private final int baseY;
|
private final int baseY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new visitor.
|
* Create a new visitor.
|
||||||
*
|
*
|
||||||
@ -49,10 +49,10 @@ public class DownwardVisitor extends RecursiveVisitor {
|
|||||||
public DownwardVisitor(final Mask mask, final RegionFunction function, final int baseY) {
|
public DownwardVisitor(final Mask mask, final RegionFunction function, final int baseY) {
|
||||||
super(mask, function);
|
super(mask, function);
|
||||||
checkNotNull(mask);
|
checkNotNull(mask);
|
||||||
|
|
||||||
this.baseY = baseY;
|
this.baseY = baseY;
|
||||||
|
|
||||||
final Collection<Vector> directions = getDirections();
|
final Collection<Vector> directions = this.getDirections();
|
||||||
directions.clear();
|
directions.clear();
|
||||||
directions.add(new Vector(1, 0, 0));
|
directions.add(new Vector(1, 0, 0));
|
||||||
directions.add(new Vector(-1, 0, 0));
|
directions.add(new Vector(-1, 0, 0));
|
||||||
@ -60,13 +60,13 @@ public class DownwardVisitor extends RecursiveVisitor {
|
|||||||
directions.add(new Vector(0, 0, -1));
|
directions.add(new Vector(0, 0, -1));
|
||||||
directions.add(new Vector(0, -1, 0));
|
directions.add(new Vector(0, -1, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isVisitable(final Vector from, final Vector to) {
|
protected boolean isVisitable(final Vector from, final Vector to) {
|
||||||
final int fromY = from.getBlockY();
|
final int fromY = from.getBlockY();
|
||||||
return ((fromY == baseY) || (to.subtract(from).getBlockY() < 0)) && super.isVisitable(from, to);
|
return ((fromY == this.baseY) || (to.subtract(from).getBlockY() < 0)) && super.isVisitable(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> inject() {
|
public static Class<?> inject() {
|
||||||
return Operations.class;
|
return Operations.class;
|
||||||
}
|
}
|
||||||
|
@ -35,11 +35,11 @@ import com.sk89q.worldedit.function.operation.RunContext;
|
|||||||
* Visits entities as provided by an {@code Iterator}.
|
* Visits entities as provided by an {@code Iterator}.
|
||||||
*/
|
*/
|
||||||
public class EntityVisitor implements Operation {
|
public class EntityVisitor implements Operation {
|
||||||
|
|
||||||
private final EntityFunction function;
|
private final EntityFunction function;
|
||||||
private final int affected = 0;
|
private final int affected = 0;
|
||||||
private final Iterator<? extends Entity> iterator;
|
private final Iterator<? extends Entity> iterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
*
|
*
|
||||||
@ -49,36 +49,36 @@ public class EntityVisitor implements Operation {
|
|||||||
public EntityVisitor(final Iterator<? extends Entity> iterator, final EntityFunction function) {
|
public EntityVisitor(final Iterator<? extends Entity> iterator, final EntityFunction function) {
|
||||||
checkNotNull(iterator);
|
checkNotNull(iterator);
|
||||||
checkNotNull(function);
|
checkNotNull(function);
|
||||||
|
|
||||||
this.function = function;
|
this.function = function;
|
||||||
this.iterator = iterator;
|
this.iterator = iterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of affected objects.
|
* Get the number of affected objects.
|
||||||
*
|
*
|
||||||
* @return the number of affected
|
* @return the number of affected
|
||||||
*/
|
*/
|
||||||
public int getAffected() {
|
public int getAffected() {
|
||||||
return affected;
|
return this.affected;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Operation resume(final RunContext run) throws WorldEditException {
|
public Operation resume(final RunContext run) throws WorldEditException {
|
||||||
while (iterator.hasNext()) {
|
while (this.iterator.hasNext()) {
|
||||||
function.apply(iterator.next());
|
this.function.apply(this.iterator.next());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancel() {}
|
public void cancel() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addStatusMessages(List<String> messages) {
|
public void addStatusMessages(final List<String> messages) {
|
||||||
messages.add(getAffected() + " blocks affected");
|
messages.add(this.getAffected() + " blocks affected");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> inject() {
|
public static Class<?> inject() {
|
||||||
return Operations.class;
|
return Operations.class;
|
||||||
}
|
}
|
||||||
|
@ -35,11 +35,11 @@ import com.sk89q.worldedit.regions.FlatRegion;
|
|||||||
* Applies region functions to columns in a {@link FlatRegion}.
|
* Applies region functions to columns in a {@link FlatRegion}.
|
||||||
*/
|
*/
|
||||||
public class FlatRegionVisitor implements Operation {
|
public class FlatRegionVisitor implements Operation {
|
||||||
|
|
||||||
private final FlatRegionFunction function;
|
private final FlatRegionFunction function;
|
||||||
private final int affected = 0;
|
private final int affected = 0;
|
||||||
private final Iterable<Vector2D> iterator;
|
private final Iterable<Vector2D> iterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new visitor.
|
* Create a new visitor.
|
||||||
*
|
*
|
||||||
@ -50,36 +50,36 @@ public class FlatRegionVisitor implements Operation {
|
|||||||
checkNotNull(flatRegion);
|
checkNotNull(flatRegion);
|
||||||
checkNotNull(function);
|
checkNotNull(function);
|
||||||
this.function = function;
|
this.function = function;
|
||||||
iterator = flatRegion.asFlatRegion();
|
this.iterator = flatRegion.asFlatRegion();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of affected objects.
|
* Get the number of affected objects.
|
||||||
*
|
*
|
||||||
* @return the number of affected
|
* @return the number of affected
|
||||||
*/
|
*/
|
||||||
public int getAffected() {
|
public int getAffected() {
|
||||||
return affected;
|
return this.affected;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Operation resume(final RunContext run) throws WorldEditException {
|
public Operation resume(final RunContext run) throws WorldEditException {
|
||||||
for (final Vector2D pt : iterator) {
|
for (final Vector2D pt : this.iterator) {
|
||||||
function.apply(pt);
|
this.function.apply(pt);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancel() {}
|
public void cancel() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addStatusMessages(List<String> messages) {
|
public void addStatusMessages(final List<String> messages) {
|
||||||
messages.add(getAffected() + " columns affected");
|
messages.add(this.getAffected() + " columns affected");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> inject() {
|
public static Class<?> inject() {
|
||||||
return Operations.class;
|
return Operations.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -44,13 +44,13 @@ import com.sk89q.worldedit.regions.FlatRegion;
|
|||||||
* each layer.</p>
|
* each layer.</p>
|
||||||
*/
|
*/
|
||||||
public class LayerVisitor implements Operation {
|
public class LayerVisitor implements Operation {
|
||||||
|
|
||||||
private final LayerFunction function;
|
private final LayerFunction function;
|
||||||
private Mask2D mask = Masks.alwaysTrue2D();
|
private Mask2D mask = Masks.alwaysTrue2D();
|
||||||
private final int minY;
|
private final int minY;
|
||||||
private final int maxY;
|
private final int maxY;
|
||||||
private final Iterable<Vector2D> iterator;
|
private final Iterable<Vector2D> iterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new visitor.
|
* Create a new visitor.
|
||||||
*
|
*
|
||||||
@ -66,9 +66,9 @@ public class LayerVisitor implements Operation {
|
|||||||
this.minY = minY;
|
this.minY = minY;
|
||||||
this.maxY = maxY;
|
this.maxY = maxY;
|
||||||
this.function = function;
|
this.function = function;
|
||||||
iterator = flatRegion.asFlatRegion();
|
this.iterator = flatRegion.asFlatRegion();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the mask that determines which columns within the flat region
|
* Get the mask that determines which columns within the flat region
|
||||||
* will be visited.
|
* will be visited.
|
||||||
@ -76,9 +76,9 @@ public class LayerVisitor implements Operation {
|
|||||||
* @return a 2D mask
|
* @return a 2D mask
|
||||||
*/
|
*/
|
||||||
public Mask2D getMask() {
|
public Mask2D getMask() {
|
||||||
return mask;
|
return this.mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the mask that determines which columns within the flat region
|
* Set the mask that determines which columns within the flat region
|
||||||
* will be visited.
|
* will be visited.
|
||||||
@ -89,32 +89,32 @@ public class LayerVisitor implements Operation {
|
|||||||
checkNotNull(mask);
|
checkNotNull(mask);
|
||||||
this.mask = mask;
|
this.mask = mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Operation resume(final RunContext run) throws WorldEditException {
|
public Operation resume(final RunContext run) throws WorldEditException {
|
||||||
for (final Vector2D column : iterator) {
|
for (final Vector2D column : this.iterator) {
|
||||||
if (!mask.test(column)) {
|
if (!this.mask.test(column)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Abort if we are underground
|
// Abort if we are underground
|
||||||
if (function.isGround(column.toVector(maxY + 1))) {
|
if (this.function.isGround(column.toVector(this.maxY + 1))) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
int groundY = 0;
|
int groundY = 0;
|
||||||
for (int y = maxY; y >= minY; --y) {
|
for (int y = this.maxY; y >= this.minY; --y) {
|
||||||
final Vector test = column.toVector(y);
|
final Vector test = column.toVector(y);
|
||||||
if (!found) {
|
if (!found) {
|
||||||
if (function.isGround(test)) {
|
if (this.function.isGround(test)) {
|
||||||
found = true;
|
found = true;
|
||||||
groundY = y;
|
groundY = y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
if (!function.apply(test, groundY - y)) {
|
if (!this.function.apply(test, groundY - y)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -122,12 +122,12 @@ public class LayerVisitor implements Operation {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancel() {}
|
public void cancel() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addStatusMessages(List<String> messages) {}
|
public void addStatusMessages(final List<String> messages) {}
|
||||||
|
|
||||||
public static Class<?> inject() {
|
public static Class<?> inject() {
|
||||||
return Operations.class;
|
return Operations.class;
|
||||||
|
@ -30,7 +30,7 @@ import com.sk89q.worldedit.function.operation.Operations;
|
|||||||
* A {@link RecursiveVisitor} that goes orthogonally to the side and down, but never up.
|
* A {@link RecursiveVisitor} that goes orthogonally to the side and down, but never up.
|
||||||
*/
|
*/
|
||||||
public class NonRisingVisitor extends RecursiveVisitor {
|
public class NonRisingVisitor extends RecursiveVisitor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new recursive visitor.
|
* Create a new recursive visitor.
|
||||||
*
|
*
|
||||||
@ -39,7 +39,7 @@ public class NonRisingVisitor extends RecursiveVisitor {
|
|||||||
*/
|
*/
|
||||||
public NonRisingVisitor(final Mask mask, final RegionFunction function) {
|
public NonRisingVisitor(final Mask mask, final RegionFunction function) {
|
||||||
super(mask, function);
|
super(mask, function);
|
||||||
final Collection<Vector> directions = getDirections();
|
final Collection<Vector> directions = this.getDirections();
|
||||||
directions.clear();
|
directions.clear();
|
||||||
directions.add(new Vector(1, 0, 0));
|
directions.add(new Vector(1, 0, 0));
|
||||||
directions.add(new Vector(-1, 0, 0));
|
directions.add(new Vector(-1, 0, 0));
|
||||||
@ -47,9 +47,9 @@ public class NonRisingVisitor extends RecursiveVisitor {
|
|||||||
directions.add(new Vector(0, 0, -1));
|
directions.add(new Vector(0, 0, -1));
|
||||||
directions.add(new Vector(0, -1, 0));
|
directions.add(new Vector(0, -1, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> inject() {
|
public static Class<?> inject() {
|
||||||
return Operations.class;
|
return Operations.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,9 +31,9 @@ import com.sk89q.worldedit.function.operation.Operations;
|
|||||||
* determine where a block should be visited.
|
* determine where a block should be visited.
|
||||||
*/
|
*/
|
||||||
public class RecursiveVisitor extends BreadthFirstSearch {
|
public class RecursiveVisitor extends BreadthFirstSearch {
|
||||||
|
|
||||||
private final Mask mask;
|
private final Mask mask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new recursive visitor.
|
* Create a new recursive visitor.
|
||||||
*
|
*
|
||||||
@ -45,12 +45,12 @@ public class RecursiveVisitor extends BreadthFirstSearch {
|
|||||||
checkNotNull(mask);
|
checkNotNull(mask);
|
||||||
this.mask = mask;
|
this.mask = mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isVisitable(final Vector from, final Vector to) {
|
protected boolean isVisitable(final Vector from, final Vector to) {
|
||||||
return mask.test(to);
|
return this.mask.test(to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> inject() {
|
public static Class<?> inject() {
|
||||||
return Operations.class;
|
return Operations.class;
|
||||||
}
|
}
|
||||||
|
@ -34,45 +34,45 @@ import com.sk89q.worldedit.regions.Region;
|
|||||||
* Utility class to apply region functions to {@link com.sk89q.worldedit.regions.Region}.
|
* Utility class to apply region functions to {@link com.sk89q.worldedit.regions.Region}.
|
||||||
*/
|
*/
|
||||||
public class RegionVisitor implements Operation {
|
public class RegionVisitor implements Operation {
|
||||||
|
|
||||||
private final RegionFunction function;
|
private final RegionFunction function;
|
||||||
private final int affected = 0;
|
private final int affected = 0;
|
||||||
|
|
||||||
private final Iterator<BlockVector> iterator;
|
private final Iterator<BlockVector> iterator;
|
||||||
|
|
||||||
public RegionVisitor(final Region region, final RegionFunction function) {
|
public RegionVisitor(final Region region, final RegionFunction function) {
|
||||||
this.function = function;
|
this.function = function;
|
||||||
iterator = region.iterator();
|
this.iterator = region.iterator();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of affected objects.
|
* Get the number of affected objects.
|
||||||
*
|
*
|
||||||
* @return the number of affected
|
* @return the number of affected
|
||||||
*/
|
*/
|
||||||
public int getAffected() {
|
public int getAffected() {
|
||||||
return affected;
|
return this.affected;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Operation resume(final RunContext run) throws WorldEditException {
|
public Operation resume(final RunContext run) throws WorldEditException {
|
||||||
while (iterator.hasNext()) {
|
while (this.iterator.hasNext()) {
|
||||||
function.apply(iterator.next());
|
this.function.apply(this.iterator.next());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancel() {}
|
public void cancel() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addStatusMessages(List<String> messages) {
|
public void addStatusMessages(final List<String> messages) {
|
||||||
messages.add(getAffected() + " blocks affected");
|
messages.add(this.getAffected() + " blocks affected");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<?> inject() {
|
public static Class<?> inject() {
|
||||||
return Operations.class;
|
return Operations.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user