Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
Florian CUNY 2019-04-27 21:05:03 +02:00
commit c2659b8d12
3 changed files with 20 additions and 19 deletions

View File

@ -37,6 +37,7 @@ import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Attachable;
import org.bukkit.material.Colorable;
import org.bukkit.util.BoundingBox;
import org.bukkit.util.Vector;
import world.bentobox.bentobox.BentoBox;
@ -131,35 +132,24 @@ public class Clipboard {
blockConfig = new YamlConfiguration();
int count = 0;
int minX = Math.max(pos1.getBlockX(),pos2.getBlockX());
int maxX = Math.min(pos1.getBlockX(), pos2.getBlockX());
int minY = Math.max(pos1.getBlockY(),pos2.getBlockY());
int maxY = Math.min(pos1.getBlockY(), pos2.getBlockY());
int minZ = Math.max(pos1.getBlockZ(),pos2.getBlockZ());
int maxZ = Math.min(pos1.getBlockZ(), pos2.getBlockZ());
BoundingBox toCopy = BoundingBox.of(pos1, pos2);
for (int x = Math.min(pos1.getBlockX(), pos2.getBlockX()); x <= Math.max(pos1.getBlockX(),pos2.getBlockX()); x++) {
for (int y = Math.min(pos1.getBlockY(), pos2.getBlockY()); y <= Math.max(pos1.getBlockY(),pos2.getBlockY()); y++) {
for (int z = Math.min(pos1.getBlockZ(), pos2.getBlockZ()); z <= Math.max(pos1.getBlockZ(),pos2.getBlockZ()); z++) {
for (int x = (int)toCopy.getMinX(); x <= toCopy.getMaxX(); x++) {
for (int y = (int)toCopy.getMinY(); y <= toCopy.getMaxY(); y++) {
for (int z = (int)toCopy.getMinZ(); z <= toCopy.getMaxZ(); z++) {
Block block = world.getBlockAt(x, y, z);
if (copyBlock(block, origin == null ? user.getLocation() : origin, copyAir, world.getLivingEntities().stream()
.filter(Objects::nonNull)
.filter(e -> !(e instanceof Player) && e.getLocation().getBlock().equals(block))
.collect(Collectors.toList()))) {
minX = Math.min(minX, x);
maxX = Math.max(maxX, x);
minY = Math.min(minY, y);
maxY = Math.max(maxY, y);
minZ = Math.min(minZ, z);
maxZ = Math.max(maxZ, z);
count ++;
}
}
}
}
blockConfig.set("size.xsize", maxX - minX + 1);
blockConfig.set("size.ysize", maxY - minY + 1);
blockConfig.set("size.zsize", maxZ - minZ + 1);
blockConfig.set("size.xsize", toCopy.getWidthX());
blockConfig.set("size.ysize", toCopy.getHeight());
blockConfig.set("size.zsize", toCopy.getWidthZ());
user.sendMessage("commands.admin.schem.copied-blocks", TextVariables.NUMBER, String.valueOf(count));
copied = true;
return true;

View File

@ -94,7 +94,11 @@ public class ServerCompatibility {
public enum ServerVersion {
V1_13(Compatibility.NOT_SUPPORTED),
V1_13_1(Compatibility.NOT_SUPPORTED),
V1_13_2(Compatibility.COMPATIBLE);
V1_13_2(Compatibility.COMPATIBLE),
/*
* @since 1.5.0
*/
V1_14(Compatibility.INCOMPATIBLE);
private Compatibility compatibility;

View File

@ -90,6 +90,9 @@ public class ClipboardTest {
when(loc.getBlockZ()).thenReturn(3);
when(loc.getBlock()).thenReturn(block);
when(loc.toVector()).thenReturn(new Vector(1,2,3));
when(loc.getX()).thenReturn(1D);
when(loc.getY()).thenReturn(2D);
when(loc.getZ()).thenReturn(3D);
loc2 = mock(Location.class);
when(loc2.getWorld()).thenReturn(world);
@ -97,6 +100,10 @@ public class ClipboardTest {
when(loc2.getBlockY()).thenReturn(3);
when(loc2.getBlockZ()).thenReturn(4);
when(loc2.getBlock()).thenReturn(block);
when(loc2.toVector()).thenReturn(new Vector(2,3,4));
when(loc2.getX()).thenReturn(2D);
when(loc2.getY()).thenReturn(3D);
when(loc2.getZ()).thenReturn(4D);
// Living entities
List<LivingEntity> ents = new ArrayList<>();