forked from LogBlock/LogBlock
Update to WorldEdit for 1.13
This commit is contained in:
12
pom.xml
12
pom.xml
@ -53,9 +53,15 @@
|
|||||||
<systemPath>${project.basedir}/LogBlockQuestioner.jar</systemPath>
|
<systemPath>${project.basedir}/LogBlockQuestioner.jar</systemPath>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sk89q</groupId>
|
<groupId>com.sk89q.worldedit</groupId>
|
||||||
<artifactId>worldedit</artifactId>
|
<artifactId>worldedit-core</artifactId>
|
||||||
<version>6.0.0-SNAPSHOT</version>
|
<version>7.0.0-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sk89q.worldedit</groupId>
|
||||||
|
<artifactId>worldedit-bukkit</artifactId>
|
||||||
|
<version>7.0.0-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -9,6 +9,8 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static de.diddiz.LogBlock.Session.getSession;
|
import static de.diddiz.LogBlock.Session.getSession;
|
||||||
@ -768,7 +770,7 @@ public final class QueryParams implements Cloneable {
|
|||||||
|
|
||||||
public void setSelection(RegionContainer container) {
|
public void setSelection(RegionContainer container) {
|
||||||
this.sel = container;
|
this.sel = container;
|
||||||
world = sel.getSelection().getWorld();
|
world = BukkitAdapter.adapt(sel.getSelection().getWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlayer(String playerName) {
|
public void setPlayer(String playerName) {
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
package de.diddiz.worldedit;
|
package de.diddiz.worldedit;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.IncompleteRegionException;
|
||||||
|
import com.sk89q.worldedit.LocalSession;
|
||||||
|
import com.sk89q.worldedit.Vector;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -10,32 +15,46 @@ import org.bukkit.plugin.Plugin;
|
|||||||
|
|
||||||
public class RegionContainer {
|
public class RegionContainer {
|
||||||
|
|
||||||
private Selection selection;
|
private Region selection;
|
||||||
|
|
||||||
public RegionContainer(Selection sel) {
|
public RegionContainer(Region sel) {
|
||||||
this.selection = sel;
|
this.selection = sel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RegionContainer fromPlayerSelection(Player player, Plugin plugin) {
|
public static RegionContainer fromPlayerSelection(Player player, Plugin plugin) {
|
||||||
final Selection selection = ((WorldEditPlugin) plugin).getSelection(player);
|
LocalSession session = ((WorldEditPlugin) plugin).getSession(player);
|
||||||
|
com.sk89q.worldedit.world.World weWorld = BukkitAdapter.adapt(player.getWorld());
|
||||||
|
if (!weWorld.equals(session.getSelectionWorld())) {
|
||||||
|
throw new IllegalArgumentException("No selection defined");
|
||||||
|
}
|
||||||
|
Region selection;
|
||||||
|
try {
|
||||||
|
selection = session.getSelection(weWorld);
|
||||||
|
} catch (IncompleteRegionException e) {
|
||||||
|
throw new IllegalArgumentException("No selection defined");
|
||||||
|
}
|
||||||
if (selection == null) {
|
if (selection == null) {
|
||||||
throw new IllegalArgumentException("No selection defined");
|
throw new IllegalArgumentException("No selection defined");
|
||||||
}
|
}
|
||||||
if (!(selection instanceof CuboidSelection)) {
|
if (!(selection instanceof CuboidRegion)) {
|
||||||
throw new IllegalArgumentException("You have to define a cuboid selection");
|
throw new IllegalArgumentException("You have to define a cuboid selection");
|
||||||
}
|
}
|
||||||
return new RegionContainer(selection);
|
return new RegionContainer(selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RegionContainer fromCorners(World world, Location first, Location second) {
|
public static RegionContainer fromCorners(World world, Location first, Location second) {
|
||||||
return new RegionContainer(new CuboidSelection(world, first, second));
|
com.sk89q.worldedit.world.World weWorld = BukkitAdapter.adapt(world);
|
||||||
|
Vector firstVector = BukkitAdapter.asVector(first);
|
||||||
|
Vector secondVector = BukkitAdapter.asVector(second);
|
||||||
|
|
||||||
|
return new RegionContainer(new CuboidRegion(weWorld, firstVector, secondVector));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Selection getSelection() {
|
public Region getSelection() {
|
||||||
return selection;
|
return selection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelection(Selection selection) {
|
public void setSelection(Region selection) {
|
||||||
this.selection = selection;
|
this.selection = selection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,17 +3,26 @@ package de.diddiz.worldedit;
|
|||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extent.logging.AbstractLoggingExtent;
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||||
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
import de.diddiz.LogBlock.LogBlock;
|
import de.diddiz.LogBlock.LogBlock;
|
||||||
import de.diddiz.LogBlock.Logging;
|
import de.diddiz.LogBlock.Logging;
|
||||||
import de.diddiz.LogBlock.config.Config;
|
import de.diddiz.LogBlock.config.Config;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
@ -75,41 +84,34 @@ public class WorldEditLoggingHook {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setExtent(new AbstractLoggingExtent(event.getExtent()) {
|
event.setExtent(new AbstractDelegateExtent(event.getExtent()) {
|
||||||
@Override
|
@Override
|
||||||
protected void onBlockChange(Vector pt, BaseBlock block) {
|
public final boolean setBlock(Vector position, @SuppressWarnings("rawtypes") BlockStateHolder block) throws WorldEditException {
|
||||||
|
onBlockChange(position, block);
|
||||||
|
return super.setBlock(position, block);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onBlockChange(Vector pt, BlockStateHolder<?> block) {
|
||||||
|
|
||||||
if (event.getStage() != EditSession.Stage.BEFORE_CHANGE) {
|
if (event.getStage() != EditSession.Stage.BEFORE_CHANGE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME wait for updated worldedit
|
Location location = new Location(world, pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
||||||
// Location location = new Location(world, pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
Block origin = location.getBlock();
|
||||||
// Block origin = location.getBlock();
|
Material typeBefore = origin.getType();
|
||||||
// Material typeBefore = origin.getType();
|
|
||||||
// byte dataBefore = origin.getData();
|
// Check to see if we've broken a sign
|
||||||
// // If we're dealing with a sign, store the block state to read the text off
|
if (Config.isLogging(location.getWorld().getName(), Logging.SIGNTEXT) && (typeBefore == Material.SIGN || typeBefore == Material.WALL_SIGN)) {
|
||||||
// BlockState stateBefore = null;
|
BlockState stateBefore = origin.getState();
|
||||||
// if (typeBefore == Material.SIGN || typeBefore == Material.WALL_SIGN) {
|
plugin.getConsumer().queueSignBreak(lbActor, (Sign) stateBefore);
|
||||||
// stateBefore = origin.getState();
|
} else if (!origin.isEmpty()) {
|
||||||
// }
|
plugin.getConsumer().queueBlockBreak(lbActor, location, origin.getBlockData());
|
||||||
//
|
}
|
||||||
// // Check to see if we've broken a sign
|
BlockData newBlock = BukkitAdapter.adapt(block);
|
||||||
// if (Config.isLogging(location.getWorld().getName(), Logging.SIGNTEXT) && (typeBefore == Material.SIGN || typeBefore == Material.WALL_SIGN)) {
|
if (newBlock != null && newBlock.getMaterial() != Material.AIR) {
|
||||||
// plugin.getConsumer().queueSignBreak(lbActor, (Sign) stateBefore);
|
plugin.getConsumer().queueBlockPlace(lbActor, location, newBlock);
|
||||||
// if (block.getType() != Material.AIR.getId()) {
|
}
|
||||||
// plugin.getConsumer().queueBlockPlace(lbActor, location, block.getType(), (byte) block.getData());
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// if (dataBefore != 0) {
|
|
||||||
// plugin.getConsumer().queueBlockBreak(lbActor, location, typeBefore, dataBefore);
|
|
||||||
// if (block.getType() != Material.AIR.getId()) {
|
|
||||||
// plugin.getConsumer().queueBlockPlace(lbActor, location, block.getType(), (byte) block.getData());
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// plugin.getConsumer().queueBlock(lbActor, location, typeBefore, block.getType(), (byte) block.getData());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user