Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-25 02:20:07 +01:00
refactor: Alter handling of errors in bindings (#1395)
* Alter handling of errors in bindings - Fixes #1384 * Arbitrarily use TextComponent#of for InputParseException
Dieser Commit ist enthalten in:
Ursprung
806ea14ad2
Commit
6df16cfe96
@ -101,11 +101,15 @@ public class Bindings {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConversionResult<Object> convert(String s, InjectedValueAccess access) {
|
public ConversionResult<Object> convert(String s, InjectedValueAccess access) {
|
||||||
Object o = invoke(s, argsFunc, access, method);
|
try {
|
||||||
if (o == null) {
|
Object o = invoke(s, argsFunc, access, method);
|
||||||
return FailedConversion.from(new NullPointerException());
|
if (o == null) {
|
||||||
|
return FailedConversion.from(new NullPointerException());
|
||||||
|
}
|
||||||
|
return SuccessfulConversion.fromSingle(o);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
return FailedConversion.from(t);
|
||||||
}
|
}
|
||||||
return SuccessfulConversion.fromSingle(o);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
|||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
import org.enginehub.piston.exception.StopExecutionException;
|
||||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -49,36 +50,76 @@ public class ConsumeBindings extends Bindings {
|
|||||||
@Binding
|
@Binding
|
||||||
@Confirm(Confirm.Processor.REGION)
|
@Confirm(Confirm.Processor.REGION)
|
||||||
public int regionMultiple(Actor actor, InjectedValueAccess context, @Selection Region region, String argument) {
|
public int regionMultiple(Actor actor, InjectedValueAccess context, @Selection Region region, String argument) {
|
||||||
int times = (int) Expression.compile(argument).evaluate();
|
try {
|
||||||
return Confirm.Processor.REGION.check(actor, context, times);
|
int times = (int) Expression.compile(argument).evaluate();
|
||||||
|
return Confirm.Processor.REGION.check(actor, context, times);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
if (t instanceof StopExecutionException) { // Maintain throw from Confirm#check
|
||||||
|
throw t;
|
||||||
|
} else {
|
||||||
|
throw new InputParseException(TextComponent.of(t.getMessage()), t);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Binding
|
@Binding
|
||||||
@Confirm(Confirm.Processor.RADIUS)
|
@Confirm(Confirm.Processor.RADIUS)
|
||||||
public Integer radiusInteger(Actor actor, InjectedValueAccess context, String argument) {
|
public Integer radiusInteger(Actor actor, InjectedValueAccess context, String argument) {
|
||||||
int times = (int) Expression.compile(argument).evaluate();
|
try {
|
||||||
return Confirm.Processor.RADIUS.check(actor, context, times);
|
int times = (int) Expression.compile(argument).evaluate();
|
||||||
|
return Confirm.Processor.RADIUS.check(actor, context, times);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
if (t instanceof StopExecutionException) { // Maintain throw from Confirm#check
|
||||||
|
throw t;
|
||||||
|
} else {
|
||||||
|
throw new InputParseException(TextComponent.of(t.getMessage()), t);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Binding
|
@Binding
|
||||||
@Confirm(Confirm.Processor.LIMIT)
|
@Confirm(Confirm.Processor.LIMIT)
|
||||||
public Integer limitInteger(Actor actor, InjectedValueAccess context, String argument) {
|
public Integer limitInteger(Actor actor, InjectedValueAccess context, String argument) {
|
||||||
int times = (int) Expression.compile(argument).evaluate();
|
try {
|
||||||
return Confirm.Processor.LIMIT.check(actor, context, times);
|
int times = (int) Expression.compile(argument).evaluate();
|
||||||
|
return Confirm.Processor.LIMIT.check(actor, context, times);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
if (t instanceof StopExecutionException) { // Maintain throw from Confirm#check
|
||||||
|
throw t;
|
||||||
|
} else {
|
||||||
|
throw new InputParseException(TextComponent.of(t.getMessage()), t);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Binding
|
@Binding
|
||||||
@Confirm(Confirm.Processor.RADIUS)
|
@Confirm(Confirm.Processor.RADIUS)
|
||||||
public Double radiusDouble(Actor actor, InjectedValueAccess context, String argument) {
|
public Double radiusDouble(Actor actor, InjectedValueAccess context, String argument) {
|
||||||
double times = Expression.compile(argument).evaluate();
|
try {
|
||||||
return Confirm.Processor.RADIUS.check(actor, context, times);
|
double times = Expression.compile(argument).evaluate();
|
||||||
|
return Confirm.Processor.RADIUS.check(actor, context, times);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
if (t instanceof StopExecutionException) { // Maintain throw from Confirm#check
|
||||||
|
throw t;
|
||||||
|
} else {
|
||||||
|
throw new InputParseException(TextComponent.of(t.getMessage()), t);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Binding
|
@Binding
|
||||||
@Confirm(Confirm.Processor.LIMIT)
|
@Confirm(Confirm.Processor.LIMIT)
|
||||||
public Double limitDouble(Actor actor, InjectedValueAccess context, String argument) {
|
public Double limitDouble(Actor actor, InjectedValueAccess context, String argument) {
|
||||||
double times = Expression.compile(argument).evaluate();
|
try {
|
||||||
return Confirm.Processor.LIMIT.check(actor, context, times);
|
double times = Expression.compile(argument).evaluate();
|
||||||
|
return Confirm.Processor.LIMIT.check(actor, context, times);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
if (t instanceof StopExecutionException) { // Maintain throw from Confirm#check
|
||||||
|
throw t;
|
||||||
|
} else {
|
||||||
|
throw new InputParseException(TextComponent.of(t.getMessage()), t);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Binding
|
@Binding
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren