Rename RegionContainer to CuboidRegion

This commit is contained in:
Brokkonaut
2018-07-31 18:00:28 +02:00
parent b80777a9a0
commit 28aabd09c7
3 changed files with 15 additions and 16 deletions

View File

@@ -2,7 +2,7 @@ package de.diddiz.LogBlock;
import de.diddiz.LogBlock.config.Config; import de.diddiz.LogBlock.config.Config;
import de.diddiz.util.Utils; import de.diddiz.util.Utils;
import de.diddiz.worldedit.RegionContainer; import de.diddiz.worldedit.CuboidRegion;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
@@ -27,7 +27,7 @@ public final class QueryParams implements Cloneable {
public List<String> killers = new ArrayList<String>(); public List<String> killers = new ArrayList<String>();
public List<String> victims = new ArrayList<String>(); public List<String> victims = new ArrayList<String>();
public boolean excludePlayersMode = false, excludeKillersMode = false, excludeVictimsMode = false, excludeBlocksMode = false, prepareToolQuery = false, silent = false; public boolean excludePlayersMode = false, excludeKillersMode = false, excludeVictimsMode = false, excludeBlocksMode = false, prepareToolQuery = false, silent = false;
public RegionContainer sel = null; public CuboidRegion sel = null;
public SummarizationMode sum = SummarizationMode.NONE; public SummarizationMode sum = SummarizationMode.NONE;
public List<Material> types = new ArrayList<Material>(); public List<Material> types = new ArrayList<Material>();
public List<Integer> typeIds = new ArrayList<Integer>(); public List<Integer> typeIds = new ArrayList<Integer>();
@@ -653,7 +653,7 @@ public final class QueryParams implements Cloneable {
} }
final Plugin we = player.getServer().getPluginManager().getPlugin("WorldEdit"); final Plugin we = player.getServer().getPluginManager().getPlugin("WorldEdit");
if (we != null) { if (we != null) {
setSelection(RegionContainer.fromPlayerSelection(player, we)); setSelection(CuboidRegion.fromPlayerSelection(player, we));
} else { } else {
throw new IllegalArgumentException("WorldEdit not found!"); throw new IllegalArgumentException("WorldEdit not found!");
} }
@@ -770,7 +770,7 @@ public final class QueryParams implements Cloneable {
world = loc.getWorld(); world = loc.getWorld();
} }
public void setSelection(RegionContainer container) { public void setSelection(CuboidRegion container) {
this.sel = container; this.sel = container;
world = sel.getWorld(); world = sel.getWorld();
} }

View File

@@ -1,7 +1,7 @@
package de.diddiz.LogBlock.listeners; package de.diddiz.LogBlock.listeners;
import de.diddiz.LogBlock.*; import de.diddiz.LogBlock.*;
import de.diddiz.worldedit.RegionContainer; import de.diddiz.worldedit.CuboidRegion;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@@ -59,7 +59,7 @@ public class ToolListener implements Listener {
if (logblock.getServer().getPluginManager().isPluginEnabled("WorldEdit")) { if (logblock.getServer().getPluginManager().isPluginEnabled("WorldEdit")) {
for (final BlockFace face : new BlockFace[]{BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST}) { for (final BlockFace face : new BlockFace[]{BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST}) {
if (block.getRelative(face).getType() == block.getType()) { if (block.getRelative(face).getType() == block.getType()) {
params.setSelection(RegionContainer.fromCorners(event.getPlayer().getWorld(), params.setSelection(CuboidRegion.fromCorners(event.getPlayer().getWorld(),
block.getLocation(), block.getRelative(face).getLocation())); block.getLocation(), block.getRelative(face).getLocation()));
} }
} }

View File

@@ -4,7 +4,6 @@ import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import org.bukkit.Location; import org.bukkit.Location;
@@ -14,13 +13,13 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.util.BlockVector; import org.bukkit.util.BlockVector;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
public class RegionContainer implements Cloneable { public class CuboidRegion implements Cloneable {
private World world; private World world;
private BlockVector min = new BlockVector(); private BlockVector min = new BlockVector();
private BlockVector max = new BlockVector(); private BlockVector max = new BlockVector();
public RegionContainer(World world, Vector first, Vector second) { public CuboidRegion(World world, Vector first, Vector second) {
this.world = world; this.world = world;
this.min.setX(Math.min(first.getBlockX(),second.getBlockX())); this.min.setX(Math.min(first.getBlockX(),second.getBlockX()));
this.min.setY(Math.min(first.getBlockY(),second.getBlockY())); this.min.setY(Math.min(first.getBlockY(),second.getBlockY()));
@@ -30,7 +29,7 @@ public class RegionContainer implements Cloneable {
this.max.setZ(Math.max(first.getBlockZ(),second.getBlockZ())); this.max.setZ(Math.max(first.getBlockZ(),second.getBlockZ()));
} }
public static RegionContainer fromPlayerSelection(Player player, Plugin worldEditPlugin) { public static CuboidRegion fromPlayerSelection(Player player, Plugin worldEditPlugin) {
LocalSession session = ((WorldEditPlugin) worldEditPlugin).getSession(player); LocalSession session = ((WorldEditPlugin) worldEditPlugin).getSession(player);
World world = player.getWorld(); World world = player.getWorld();
com.sk89q.worldedit.world.World weWorld = BukkitAdapter.adapt(world); com.sk89q.worldedit.world.World weWorld = BukkitAdapter.adapt(world);
@@ -46,18 +45,18 @@ public class RegionContainer implements Cloneable {
if (selection == null) { if (selection == null) {
throw new IllegalArgumentException("No selection defined"); throw new IllegalArgumentException("No selection defined");
} }
if (!(selection instanceof CuboidRegion)) { if (!(selection instanceof com.sk89q.worldedit.regions.CuboidRegion)) {
throw new IllegalArgumentException("You have to define a cuboid selection"); throw new IllegalArgumentException("You have to define a cuboid selection");
} }
com.sk89q.worldedit.Vector weMin = selection.getMinimumPoint(); com.sk89q.worldedit.Vector weMin = selection.getMinimumPoint();
com.sk89q.worldedit.Vector weMax = selection.getMaximumPoint(); com.sk89q.worldedit.Vector weMax = selection.getMaximumPoint();
Vector min = new Vector(weMin.getBlockX(), weMin.getBlockY(), weMin.getBlockZ()); Vector min = new Vector(weMin.getBlockX(), weMin.getBlockY(), weMin.getBlockZ());
Vector max = new Vector(weMax.getBlockX(), weMax.getBlockY(), weMax.getBlockZ()); Vector max = new Vector(weMax.getBlockX(), weMax.getBlockY(), weMax.getBlockZ());
return new RegionContainer(world, min, max); return new CuboidRegion(world, min, max);
} }
public static RegionContainer fromCorners(World world, Location first, Location second) { public static CuboidRegion fromCorners(World world, Location first, Location second) {
return new RegionContainer(world, first.toVector(), second.toVector()); return new CuboidRegion(world, first.toVector(), second.toVector());
} }
public World getWorld() { public World getWorld() {
@@ -81,9 +80,9 @@ public class RegionContainer implements Cloneable {
} }
@Override @Override
public RegionContainer clone() { public CuboidRegion clone() {
try { try {
RegionContainer clone = (RegionContainer) super.clone(); CuboidRegion clone = (CuboidRegion) super.clone();
clone.min = min.clone(); clone.min = min.clone();
clone.max = max.clone(); clone.max = max.clone();
return clone; return clone;