2012-10-31 21:36:16 +05:00
|
|
|
package de.diddiz.worldedit;
|
|
|
|
|
|
|
|
|
|
import com.sk89q.worldedit.EditSession;
|
2013-01-12 12:37:45 +05:00
|
|
|
import com.sk89q.worldedit.LocalPlayer;
|
2012-10-31 21:36:16 +05:00
|
|
|
import com.sk89q.worldedit.LocalWorld;
|
|
|
|
|
import com.sk89q.worldedit.Vector;
|
|
|
|
|
import com.sk89q.worldedit.bags.BlockBag;
|
|
|
|
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
2013-01-12 12:37:45 +05:00
|
|
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
|
|
|
|
import de.diddiz.LogBlock.LogBlock;
|
|
|
|
|
import de.diddiz.LogBlock.Logging;
|
|
|
|
|
import de.diddiz.LogBlock.config.Config;
|
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
|
import org.bukkit.Location;
|
2012-10-31 21:36:16 +05:00
|
|
|
|
2013-01-12 12:37:45 +05:00
|
|
|
public class LogBlockEditSession extends EditSession {
|
|
|
|
|
|
|
|
|
|
private LocalPlayer player;
|
2012-10-31 21:36:16 +05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*/
|
2013-01-12 12:37:45 +05:00
|
|
|
public LogBlockEditSession(LocalWorld world, int maxBlocks, LocalPlayer player) {
|
2012-10-31 21:36:16 +05:00
|
|
|
super(world, maxBlocks);
|
2013-01-12 12:37:45 +05:00
|
|
|
this.player = player;
|
2012-10-31 21:36:16 +05:00
|
|
|
}
|
2013-01-12 12:37:45 +05:00
|
|
|
|
2012-10-31 21:36:16 +05:00
|
|
|
/**
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*/
|
2013-01-12 12:37:45 +05:00
|
|
|
public LogBlockEditSession(LocalWorld world, int maxBlocks, BlockBag blockBag, LocalPlayer player) {
|
2012-10-31 21:36:16 +05:00
|
|
|
super(world, maxBlocks, blockBag);
|
2013-01-12 12:37:45 +05:00
|
|
|
this.player = player;
|
2012-10-31 21:36:16 +05:00
|
|
|
}
|
2013-01-12 12:37:45 +05:00
|
|
|
|
2012-10-31 21:36:16 +05:00
|
|
|
@Override
|
|
|
|
|
public boolean rawSetBlock(Vector pt, BaseBlock block) {
|
2013-01-12 12:37:45 +05:00
|
|
|
if (!(player.getWorld() instanceof BukkitWorld)) {
|
|
|
|
|
return super.rawSetBlock(pt, block);
|
|
|
|
|
}
|
|
|
|
|
int typeBefore = ((BukkitWorld) player.getWorld()).getWorld().getBlockTypeIdAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
|
|
|
|
boolean success = super.rawSetBlock(pt, block);
|
|
|
|
|
if (success && Config.isLogging(player.getWorld().getName(), Logging.WORLDEDIT)) {
|
|
|
|
|
Location location = new Location(Bukkit.getWorld(player.getWorld().getName()), pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
|
|
|
|
LogBlock.getInstance().getConsumer().queueBlock(player.getName(), location, typeBefore, location.getBlock().getTypeId(), location.getBlock().getData());
|
|
|
|
|
}
|
|
|
|
|
return success;
|
2012-10-31 21:36:16 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|