f41b0279a6
Added back in the small and medium sized Alchemical Chest aludel recipes Added a recipe to make a chalk block from 4 pieces of chalk Created an EE test suite to test EE specific energy values Re-registered several EE items Removed a duplicate Gson type adapter registration Changed the ItemStackSerializer to return JsonNull in the event that there is no registered name for the item (the item would never deserialize as it wouldn't have a name to lookup) Changed the EnergyValueMapSerializer to allow serializing of null energy values (as JsonNull). Used for energy value testing.
92 lines
3.3 KiB
Java
92 lines
3.3 KiB
Java
package com.pahimar.ee3.command;
|
|
|
|
import com.pahimar.ee3.reference.Files;
|
|
import com.pahimar.ee3.reference.Messages;
|
|
import com.pahimar.ee3.reference.Names;
|
|
import com.pahimar.ee3.reference.Reference;
|
|
import com.pahimar.ee3.test.EnergyValueTestSuite;
|
|
import com.pahimar.ee3.util.LogHelper;
|
|
import cpw.mods.fml.common.FMLCommonHandler;
|
|
import net.minecraft.command.ICommandSender;
|
|
import net.minecraft.command.WrongUsageException;
|
|
import net.minecraft.util.ChatComponentTranslation;
|
|
|
|
import java.io.File;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
public class CommandRunTest extends CommandEE {
|
|
|
|
@Override
|
|
public String getCommandName() {
|
|
return Names.Commands.RUN_TEST;
|
|
}
|
|
|
|
@Override
|
|
public int getRequiredPermissionLevel() {
|
|
return 2;
|
|
}
|
|
|
|
@Override
|
|
public String getCommandUsage(ICommandSender commandSender) {
|
|
return Messages.Commands.RUN_TEST_USAGE;
|
|
}
|
|
|
|
@Override
|
|
public void processCommand(ICommandSender commandSender, String[] args) {
|
|
|
|
if (args.length == 2) {
|
|
|
|
boolean testFound = false;
|
|
|
|
if (Files.globalTestDirectory != null) {
|
|
for (File testCaseFile : Files.globalTestDirectory.listFiles()) {
|
|
if (testCaseFile.isFile() && testCaseFile.getName().equalsIgnoreCase(args[1])) {
|
|
testFound = true;
|
|
EnergyValueTestSuite energyValueTestSuite = new EnergyValueTestSuite(testCaseFile);
|
|
LogHelper.info(EnergyValueTestSuite.TEST_MARKER, "BEGIN TEST ({})", testCaseFile.getName());
|
|
energyValueTestSuite.run();
|
|
LogHelper.info(EnergyValueTestSuite.TEST_MARKER, "END TEST ({})", testCaseFile.getName());
|
|
}
|
|
}
|
|
|
|
if (testFound) {
|
|
commandSender.addChatMessage(new ChatComponentTranslation(Messages.Commands.RUN_TESTS_SUCCESS, args[1]));
|
|
}
|
|
else {
|
|
commandSender.addChatMessage(new ChatComponentTranslation(Messages.Commands.RUN_TESTS_NOT_FOUND, args[1]));
|
|
}
|
|
}
|
|
else {
|
|
throw new WrongUsageException(Messages.Commands.RUN_TEST_USAGE);
|
|
}
|
|
}
|
|
else {
|
|
throw new WrongUsageException(Messages.Commands.RUN_TEST_USAGE);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public List addTabCompletionOptions(ICommandSender commandSender, String[] args) {
|
|
|
|
if (args.length == 2) {
|
|
|
|
File testCaseDirectory = new File(FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getSaveHandler().getWorldDirectory(), "data" + File.separator + Reference.LOWERCASE_MOD_ID + File.separator + "energyvalues" + File.separator + "testcases");
|
|
testCaseDirectory.mkdirs();
|
|
|
|
ArrayList<String> fileNames = new ArrayList<>();
|
|
|
|
if (Files.globalTestDirectory != null) {
|
|
for (File testCaseFile : Files.globalTestDirectory.listFiles()) {
|
|
if (testCaseFile.isFile() && testCaseFile.getAbsolutePath().endsWith(".json")) {
|
|
fileNames.add(testCaseFile.getName());
|
|
}
|
|
}
|
|
}
|
|
|
|
return getListOfStringsMatchingLastWord(args, fileNames.toArray(new String[0]));
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|