mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-27 09:56:41 +00:00
Removed the CLI program from WorldEdit.
This commit is contained in:
@ -1,94 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.cli;
|
||||
|
||||
import static java.util.Arrays.*;
|
||||
import java.util.List;
|
||||
import joptsimple.OptionParser;
|
||||
import joptsimple.OptionSet;
|
||||
import joptsimple.OptionSpec;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class Main {
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] _args) throws Throwable {
|
||||
OptionParser parser = new OptionParser();
|
||||
OptionSpec<String> world =
|
||||
parser.accepts("world").withRequiredArg().ofType(String.class)
|
||||
.describedAs("world directory").defaultsTo("world");
|
||||
parser.acceptsAll(asList("?", "h"), "show help");
|
||||
|
||||
OptionSet options = parser.parse(_args);
|
||||
List<String> args = options.nonOptionArguments();
|
||||
|
||||
if (args.size() != 1 || options.has("?")) {
|
||||
System.err.println("worldedit <action>");
|
||||
System.err.println();
|
||||
parser.printHelpOn(System.err);
|
||||
return;
|
||||
}
|
||||
|
||||
System.err.println("WorldEdit v" + getVersion());
|
||||
System.err.println("Copyright (c) 2010-2011 sk89q <http://www.sk89q.com>");
|
||||
System.err.println();
|
||||
|
||||
String act = args.get(0);
|
||||
String worldPath = options.valueOf(world);
|
||||
|
||||
if (act.equalsIgnoreCase("check")) {
|
||||
new WorldChecker(worldPath);
|
||||
} else {
|
||||
System.err.println("Only valid action is 'check'.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the version.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getVersion() {
|
||||
Package p = com.sk89q.worldedit.cli.Main.class.getPackage();
|
||||
|
||||
if (p == null) {
|
||||
p = Package.getPackage("com.sk89q.worldedit");
|
||||
}
|
||||
|
||||
String version;
|
||||
|
||||
if (p == null) {
|
||||
return "(unknown)";
|
||||
} else {
|
||||
version = p.getImplementationVersion();
|
||||
|
||||
if (version == null) {
|
||||
return "(unknown)";
|
||||
}
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.cli;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.jnbt.NBTInputStream;
|
||||
import org.jnbt.Tag;
|
||||
|
||||
public class WorldChecker {
|
||||
private File worldPath;
|
||||
|
||||
public WorldChecker(String path) {
|
||||
worldPath = new File(path);
|
||||
|
||||
checkLevelDat();
|
||||
checkFiles();
|
||||
|
||||
System.out.println("Done.");
|
||||
}
|
||||
|
||||
public void checkLevelDat() {
|
||||
try {
|
||||
checkNBT(new File(worldPath, "level.dat"));
|
||||
} catch (IOException e) {
|
||||
System.out.println("BAD: level.dat: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void checkFiles() {
|
||||
final Pattern chunkFilePattern = Pattern.compile("^c\\..*\\.dat$");
|
||||
|
||||
FileFilter folderFilter = new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
return f.isDirectory();
|
||||
}
|
||||
};
|
||||
|
||||
FileFilter chunkFilter = new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
return f.isFile()
|
||||
&& chunkFilePattern.matcher(f.getName()).matches();
|
||||
}
|
||||
};
|
||||
|
||||
for (File l1 : worldPath.listFiles(folderFilter)) {
|
||||
for (File l2 : l1.listFiles(folderFilter)) {
|
||||
for (File chunkFile : l2.listFiles(chunkFilter)) {
|
||||
checkChunkFile(chunkFile,
|
||||
l1.getName(), l2.getName(), chunkFile.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkChunkFile(File f, String a, String b, String c) {
|
||||
String id = a + "/" + b + "/" + c;
|
||||
|
||||
try {
|
||||
checkNBT(f);
|
||||
} catch (IOException e) {
|
||||
System.out.println("BAD: " + id);
|
||||
}
|
||||
}
|
||||
|
||||
public void checkNBT(File file) throws IOException {
|
||||
FileInputStream stream = new FileInputStream(file);
|
||||
NBTInputStream nbt = new NBTInputStream(stream);
|
||||
Tag tag = nbt.readTag();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user