Added some permissions and improved //schem list output

Dieser Commit ist enthalten in:
zml2008 2012-04-12 19:31:29 -07:00
Ursprung ff0f9073db
Commit 7dafb50999

Datei anzeigen

@ -22,6 +22,7 @@ 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.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalPlayer; import com.sk89q.worldedit.LocalPlayer;
@ -164,6 +165,7 @@ public class SchematicCommands {
desc = "List available schematic formats", desc = "List available schematic formats",
max = 0 max = 0
) )
@Console
@CommandPermissions("worldedit.schematic.formats") @CommandPermissions("worldedit.schematic.formats")
public void formats(CommandContext args, LocalSession session, LocalPlayer player, public void formats(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException { EditSession editSession) throws WorldEditException {
@ -190,18 +192,25 @@ public class SchematicCommands {
desc = "List available schematics", desc = "List available schematics",
max = 0 max = 0
) )
@Console
@CommandPermissions("worldedit.schematic.list") @CommandPermissions("worldedit.schematic.list")
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);
player.print("Available schematics (Filename - Format)"); StringBuilder build = new StringBuilder("Available schematics (Filename (Format)): ");
boolean first = true;
for (File file : dir.listFiles()) { for (File file : dir.listFiles()) {
if (!file.isFile()) { if (!file.isFile()) {
continue; continue;
} }
SchematicFormat format = SchematicFormat.getFormat(file); if (!first) {
player.print(file.getName() + ": " + (format == null ? "Unknown" : format.getName())); build.append(", ");
} }
SchematicFormat format = SchematicFormat.getFormat(file);
build.append(file.getName()).append(": ").append(format == null ? "Unknown" : format.getName());
first = false;
}
player.print(build.toString());
} }
} }