From 1fdc0a59ec388732bb6b3d89af9123739b6c2e5d Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Thu, 2 Feb 2017 10:33:07 +1100 Subject: [PATCH] *Use player limit rather than int max --- .../worldedit/command/ClipboardCommands.java | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java b/core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java index aecff967..d1327bad 100644 --- a/core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java +++ b/core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java @@ -22,6 +22,7 @@ package com.sk89q.worldedit.command; import com.boydti.fawe.FaweAPI; import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.Settings; +import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.RunnableVal2; import com.boydti.fawe.object.clipboard.ReadOnlyClipboard; @@ -109,7 +110,13 @@ public class ClipboardCommands { public void lazyCopy(Player player, LocalSession session, EditSession editSession, @Selection final Region region, @Switch('e') boolean copyEntities, @Switch('m') Mask mask) throws WorldEditException { - + Vector min = region.getMinimumPoint(); + Vector max = region.getMaximumPoint(); + long volume = (((long)max.getX() - (long)min.getX() + 1) * ((long)max.getY() - (long)min.getY() + 1) * ((long)max.getZ() - (long)min.getZ() + 1)); + FaweLimit limit = FawePlayer.wrap(player).getLimit(); + if (volume >= limit.MAX_CHECKS) { + throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS); + } final Vector origin = region.getMinimumPoint(); final int mx = origin.getBlockX(); final int my = origin.getBlockY(); @@ -143,7 +150,8 @@ public class ClipboardCommands { Vector min = region.getMinimumPoint(); Vector max = region.getMaximumPoint(); long volume = (((long)max.getX() - (long)min.getX() + 1) * ((long)max.getY() - (long)min.getY() + 1) * ((long)max.getZ() - (long)min.getZ() + 1)); - if (volume >= Integer.MAX_VALUE) { + FaweLimit limit = FawePlayer.wrap(player).getLimit(); + if (volume >= limit.MAX_CHECKS) { throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS); } @@ -182,6 +190,16 @@ public class ClipboardCommands { public void lazyCut(Player player, LocalSession session, EditSession editSession, @Selection final Region region, @Switch('e') boolean copyEntities, @Switch('m') Mask mask) throws WorldEditException { + Vector min = region.getMinimumPoint(); + Vector max = region.getMaximumPoint(); + long volume = (((long)max.getX() - (long)min.getX() + 1) * ((long)max.getY() - (long)min.getY() + 1) * ((long)max.getZ() - (long)min.getZ() + 1)); + FaweLimit limit = FawePlayer.wrap(player).getLimit(); + if (volume >= limit.MAX_CHECKS) { + throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS); + } + if (volume >= limit.MAX_CHANGES) { + throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES); + } final Vector origin = region.getMinimumPoint(); final int mx = origin.getBlockX(); final int my = origin.getBlockY(); @@ -214,9 +232,13 @@ public class ClipboardCommands { Vector min = region.getMinimumPoint(); Vector max = region.getMaximumPoint(); long volume = (((long)max.getX() - (long)min.getX() + 1) * ((long)max.getY() - (long)min.getY() + 1) * ((long)max.getZ() - (long)min.getZ() + 1)); - if (volume >= Integer.MAX_VALUE) { + FaweLimit limit = FawePlayer.wrap(player).getLimit(); + if (volume >= limit.MAX_CHECKS) { throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS); } + if (volume >= limit.MAX_CHANGES) { + throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES); + } BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId()); clipboard.setOrigin(session.getPlacementPosition(player)); ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());