Fixed "null" output for invalid worldedit selections

This commit is contained in:
JOO200 2020-08-01 16:55:37 +02:00
parent efe1e48bd4
commit c8bde17994
1 changed files with 8 additions and 5 deletions

View File

@ -245,14 +245,17 @@ class RegionCommandsBase {
* @throws CommandException thrown on an error
*/
protected static Region checkSelection(Actor actor) throws CommandException {
LocalSession localSession = WorldEdit.getInstance().getSessionManager().get(actor);
if (localSession == null || localSession.getSelectionWorld() == null)
throw new CommandException("Please select an area first. " +
"Use WorldEdit to make a selection! " +
"(see: https://worldedit.enginehub.org/en/latest/usage/regions/selections/).");
try {
LocalSession localSession = WorldEdit.getInstance().getSessionManager().get(actor);
return localSession.getRegionSelector(localSession.getSelectionWorld()).getRegion();
} catch (IncompleteRegionException e) {
throw new CommandException(
"Please select an area first. " +
"Use WorldEdit to make a selection! " +
"(see: https://worldedit.enginehub.org/en/latest/usage/regions/selections/).");
throw new CommandException("Please select an area first. " +
"Use WorldEdit to make a selection! " +
"(see: https://worldedit.enginehub.org/en/latest/usage/regions/selections/).");
}
}