mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2024-12-27 05:00:08 +08:00
Fixes NPE when attempting to list schematics in an invalid directory.
This commit is contained in:
parent
3f1a2bfc39
commit
fcaafe009c
@ -18,12 +18,16 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.commands;
|
package com.sk89q.worldedit.commands;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandException;
|
import com.sk89q.minecraft.util.commands.CommandException;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.minecraft.util.commands.Console;
|
import com.sk89q.minecraft.util.commands.Console;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.FilenameResolutionException;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
import com.sk89q.worldedit.LocalPlayer;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
@ -32,9 +36,6 @@
|
|||||||
import com.sk89q.worldedit.data.DataException;
|
import com.sk89q.worldedit.data.DataException;
|
||||||
import com.sk89q.worldedit.schematic.SchematicFormat;
|
import com.sk89q.worldedit.schematic.SchematicFormat;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commands related to schematics
|
* Commands related to schematics
|
||||||
*
|
*
|
||||||
@ -213,9 +214,14 @@ public void formats(CommandContext args, LocalSession session, LocalPlayer playe
|
|||||||
public void list(CommandContext args, LocalSession session, LocalPlayer player,
|
public void list(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
File dir = we.getWorkingDirectoryFile(we.getConfiguration().saveDir);
|
File dir = we.getWorkingDirectoryFile(we.getConfiguration().saveDir);
|
||||||
|
File[] files = dir.listFiles();
|
||||||
|
if (files == null) {
|
||||||
|
throw new FilenameResolutionException(dir.getPath(), "Schematics directory invalid or not found.");
|
||||||
|
}
|
||||||
StringBuilder build = new StringBuilder("Available schematics (Filename (Format)): ");
|
StringBuilder build = new StringBuilder("Available schematics (Filename (Format)): ");
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (File file : dir.listFiles()) {
|
|
||||||
|
for (File file : files) {
|
||||||
if (!file.isFile()) {
|
if (!file.isFile()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user