diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java index e9c083b9..2e2998d9 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java @@ -210,10 +210,12 @@ public class FaweBukkit implements IFawe, Listener { Bukkit.getServicesManager().unregister(service, instance); try { Class clazz = instance.getClass(); - Field logFailedRequests = ReflectionUtils.setAccessible(clazz.getDeclaredField("logFailedRequests")); + Field logFailedRequests = ReflectionUtils.findField(clazz, boolean.class); logFailedRequests.set(null, false); Field url = null; - try { url = clazz.getDeclaredField("URL"); } catch (NoSuchFieldException ignore) { url = clazz.getDeclaredField("bStatsUrl"); } + try { url = clazz.getDeclaredField("URL"); } catch (NoSuchFieldException ignore) { + for (Field field : clazz.getDeclaredFields()) if (ReflectionUtils.setAccessible(field).get(null).toString().startsWith("http")) { url = field; break; } + } if (url != null) ReflectionUtils.setFailsafeFieldValue(url, null, null); } catch (NoSuchFieldError | IllegalAccessException ignore) {} catch (Throwable e) { diff --git a/core/src/main/java/com/boydti/fawe/command/FawePrimitiveBinding.java b/core/src/main/java/com/boydti/fawe/command/FawePrimitiveBinding.java index cae4a492..3f9aedd0 100644 --- a/core/src/main/java/com/boydti/fawe/command/FawePrimitiveBinding.java +++ b/core/src/main/java/com/boydti/fawe/command/FawePrimitiveBinding.java @@ -7,6 +7,7 @@ import com.boydti.fawe.object.extent.ResettableExtent; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.Vector; +import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Player; @@ -216,6 +217,38 @@ public class FawePrimitiveBinding extends BindingHelper { return new Vector(radiusX, radiusY, radiusZ); } + + /** + * Gets a type from a {@link ArgumentStack}. + * + * @param context the context + * @return the requested type + * @throws ParameterException on error + */ + @BindingMatch(type = Vector2D.class, + behavior = BindingBehavior.CONSUMES, + consumedCount = 1, + provideModifiers = true) + public Vector2D getVector2D(ArgumentStack context, Annotation[] modifiers) throws ParameterException { + String radiusString = context.next(); + String[] radii = radiusString.split(","); + final double radiusX, radiusZ; + switch (radii.length) { + case 1: + radiusX = radiusZ = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[0])); + break; + + case 2: + radiusX = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[0])); + radiusZ = Math.max(1, FawePrimitiveBinding.parseNumericInput(radii[2])); + break; + + default: + throw new ParameterException("You must either specify 1 or 2 radius values."); + } + return new Vector2D(radiusX, radiusZ); + } + /** * Try to parse numeric input as either a number or a mathematical expression. *