2015-07-30 19:24:01 +02:00
|
|
|
package com.plotsquared.bukkit.util;
|
2015-02-11 16:37:52 +01:00
|
|
|
|
2015-07-30 16:25:16 +02:00
|
|
|
import java.util.Collection;
|
|
|
|
|
2015-02-11 16:37:52 +01:00
|
|
|
import org.bukkit.Chunk;
|
|
|
|
import org.bukkit.World;
|
|
|
|
import org.bukkit.block.Block;
|
|
|
|
|
2015-07-30 16:25:16 +02:00
|
|
|
import com.intellectualcrafters.plot.util.MainUtil;
|
2015-04-02 02:56:34 +02:00
|
|
|
|
2015-02-23 06:29:45 +01:00
|
|
|
public class SetBlockSlow extends BukkitSetBlockManager {
|
2015-02-19 04:24:05 +01:00
|
|
|
@Override
|
2015-02-20 07:34:19 +01:00
|
|
|
public void set(final World world, final int x, final int y, final int z, final int id, final byte data) {
|
|
|
|
final Block block = world.getBlockAt(x, y, z);
|
2015-06-07 21:37:40 +02:00
|
|
|
if (id == -1) {
|
|
|
|
block.setData(data, false);
|
|
|
|
return;
|
|
|
|
}
|
2015-02-11 16:37:52 +01:00
|
|
|
if (block.getData() == data) {
|
|
|
|
if (block.getTypeId() != id) {
|
|
|
|
block.setTypeId(id, false);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (block.getTypeId() == id) {
|
|
|
|
block.setData(data, false);
|
|
|
|
} else {
|
|
|
|
block.setTypeIdAndData(id, data, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-02-23 02:32:27 +01:00
|
|
|
|
2015-02-11 16:37:52 +01:00
|
|
|
@Override
|
2015-03-27 12:25:24 +01:00
|
|
|
public void update(final Collection<Chunk> chunks) {
|
2015-04-02 02:56:34 +02:00
|
|
|
if (MainUtil.canSendChunk) {
|
|
|
|
try {
|
|
|
|
SendChunk.sendChunk(chunks);
|
|
|
|
} catch (final Throwable e) {
|
|
|
|
MainUtil.canSendChunk = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (Chunk chunk : chunks) {
|
|
|
|
chunk.unload();
|
|
|
|
chunk.load(true);
|
|
|
|
}
|
|
|
|
}
|
2015-02-11 16:37:52 +01:00
|
|
|
}
|
|
|
|
}
|