added exporter
This commit is contained in:
parent
55739cdb98
commit
8de90e6209
7 changed files with 184 additions and 6 deletions
20
build.gradle
20
build.gradle
|
@ -45,8 +45,12 @@ repositories {
|
||||||
configurations {
|
configurations {
|
||||||
shade
|
shade
|
||||||
compile.extendsFrom shade
|
compile.extendsFrom shade
|
||||||
|
|
||||||
|
designershade
|
||||||
|
compile.extendsFrom designershade
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
version = "1.0.5"
|
version = "1.0.5"
|
||||||
|
|
||||||
def ENV = System.getenv()
|
def ENV = System.getenv()
|
||||||
|
@ -82,6 +86,12 @@ dependencies {
|
||||||
compile 'RebornCore:RebornCore-1.9:2.0.5.+:dev'
|
compile 'RebornCore:RebornCore-1.9:2.0.5.+:dev'
|
||||||
deobfCompile "mezz.jei:jei_1.9:+"
|
deobfCompile "mezz.jei:jei_1.9:+"
|
||||||
deobfCompile 'MCMultiPart:MCMultiPart-experimental:1.1.0_55:universal'
|
deobfCompile 'MCMultiPart:MCMultiPart-experimental:1.1.0_55:universal'
|
||||||
|
|
||||||
|
//For manual designer!
|
||||||
|
designershade 'org.zeroturnaround:zt-zip:1.9'
|
||||||
|
designershade 'org.slf4j:slf4j-api:1.7.21'
|
||||||
|
designershade 'org.slf4j:slf4j-simple:1.7.21'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,7 +129,17 @@ task designerJar(type: Jar) {
|
||||||
include "techreborn/manual/saveFormat/**"
|
include "techreborn/manual/saveFormat/**"
|
||||||
include "assets/techreborn/designer/**"
|
include "assets/techreborn/designer/**"
|
||||||
include "assets/techreborn/textures/manual/**"
|
include "assets/techreborn/textures/manual/**"
|
||||||
|
|
||||||
|
//Deps
|
||||||
|
include "org/slf4j/**"
|
||||||
|
include "org/zeroturnaround/zip/**"
|
||||||
|
|
||||||
manifest { attributes 'Main-Class': 'techreborn.manual.designer.ManualDesigner' }
|
manifest { attributes 'Main-Class': 'techreborn.manual.designer.ManualDesigner' }
|
||||||
|
configurations.designershade.each { dep ->
|
||||||
|
from(project.zipTree(dep)){
|
||||||
|
exclude 'META-INF', 'META-INF/**', '**/*.java'
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
|
|
|
@ -16,6 +16,7 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.TextComponentString;
|
import net.minecraft.util.text.TextComponentString;
|
||||||
import net.minecraftforge.fluids.Fluid;
|
import net.minecraftforge.fluids.Fluid;
|
||||||
import net.minecraftforge.fml.common.registry.GameData;
|
import net.minecraftforge.fml.common.registry.GameData;
|
||||||
|
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||||
import reborncore.api.fuel.FluidPowerManager;
|
import reborncore.api.fuel.FluidPowerManager;
|
||||||
import reborncore.api.recipe.RecipeHandler;
|
import reborncore.api.recipe.RecipeHandler;
|
||||||
|
|
||||||
|
@ -91,11 +92,13 @@ public class TechRebornDevCommand extends CommandBase
|
||||||
} else if ("getname".equals(args[0])) {
|
} else if ("getname".equals(args[0])) {
|
||||||
EntityPlayer player = (EntityPlayer) sender;
|
EntityPlayer player = (EntityPlayer) sender;
|
||||||
if (player.getHeldItem(EnumHand.MAIN_HAND) != null) {
|
if (player.getHeldItem(EnumHand.MAIN_HAND) != null) {
|
||||||
Block block = Block.getBlockFromItem(player.getHeldItem(EnumHand.MAIN_HAND).getItem());
|
if(GameData.getItemRegistry().containsValue(player.getHeldItem(EnumHand.MAIN_HAND).getItem())){
|
||||||
if (block != null && block != Blocks.air) {
|
sender.addChatMessage(new TextComponentString(GameData.getItemRegistry().getNameForObject(player.getHeldItem(EnumHand.MAIN_HAND).getItem()) + ":" + player.getHeldItem(EnumHand.MAIN_HAND).getItemDamage()));
|
||||||
sender.addChatMessage(new TextComponentString(GameData.getBlockRegistry().getNameForObject(block) + " with a meta of " + player.getHeldItem(EnumHand.MAIN_HAND).getItemDamage()));
|
|
||||||
} else {
|
} else {
|
||||||
((EntityPlayer) sender).addChatComponentMessage(new TextComponentString("hold a Block!"));
|
Block block = Block.getBlockFromItem(player.getHeldItem(EnumHand.MAIN_HAND).getItem());
|
||||||
|
if (block != null && block != Blocks.air) {
|
||||||
|
sender.addChatMessage(new TextComponentString(GameData.getBlockRegistry().getNameForObject(block) + ":" + player.getHeldItem(EnumHand.MAIN_HAND).getItemDamage()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
((EntityPlayer) sender).addChatComponentMessage(new TextComponentString("hold an item!"));
|
((EntityPlayer) sender).addChatComponentMessage(new TextComponentString("hold an item!"));
|
||||||
|
|
|
@ -11,11 +11,14 @@ import javafx.scene.control.Alert;
|
||||||
import javafx.scene.control.TreeItem;
|
import javafx.scene.control.TreeItem;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
import techreborn.manual.designer.exporter.Exporter;
|
||||||
import techreborn.manual.designer.fileUtils.SaveSystem;
|
import techreborn.manual.designer.fileUtils.SaveSystem;
|
||||||
import techreborn.manual.designer.windows.MainWindowController;
|
import techreborn.manual.designer.windows.MainWindowController;
|
||||||
import techreborn.manual.saveFormat.Entry;
|
import techreborn.manual.saveFormat.Entry;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,8 +28,12 @@ public class ManualDesigner extends Application {
|
||||||
|
|
||||||
public static Stage stage;
|
public static Stage stage;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) throws Exception {
|
||||||
launch(args);
|
if(args.length > 0 && args[0].equals("-export")){
|
||||||
|
Exporter.run(args);
|
||||||
|
} else {
|
||||||
|
launch(args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -70,6 +77,7 @@ public class ManualDesigner extends Application {
|
||||||
if(!isValid){
|
if(!isValid){
|
||||||
if(SaveSystem.entries.containsKey(selectedItem)){
|
if(SaveSystem.entries.containsKey(selectedItem)){
|
||||||
Entry entry = SaveSystem.entries.get(selectedItem);
|
Entry entry = SaveSystem.entries.get(selectedItem);
|
||||||
|
controller.pageimage.setVisible(false);
|
||||||
if(entry.data != null && entry.data.data != null){
|
if(entry.data != null && entry.data.data != null){
|
||||||
if(entry.data.data.containsKey("text")){
|
if(entry.data.data.containsKey("text")){
|
||||||
controller.textInput.setText(entry.data.data.get("text"));
|
controller.textInput.setText(entry.data.data.get("text"));
|
||||||
|
@ -82,6 +90,7 @@ public class ManualDesigner extends Application {
|
||||||
File image = new File(imagesDir, entry.data.data.get("image") + ".png");
|
File image = new File(imagesDir, entry.data.data.get("image") + ".png");
|
||||||
if(image.exists()){
|
if(image.exists()){
|
||||||
controller.pageimage.setImage(new Image(image.toURI().toString()));
|
controller.pageimage.setImage(new Image(image.toURI().toString()));
|
||||||
|
controller.pageimage.setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,6 +100,7 @@ public class ManualDesigner extends Application {
|
||||||
//TODO Improve this
|
//TODO Improve this
|
||||||
} else {
|
} else {
|
||||||
controller.textInput.setText("");
|
controller.textInput.setText("");
|
||||||
|
controller.imageTextArea.setText("");
|
||||||
}
|
}
|
||||||
if(entry.type.equalsIgnoreCase("image")){
|
if(entry.type.equalsIgnoreCase("image")){
|
||||||
controller.imageTextArea.setDisable(false);
|
controller.imageTextArea.setDisable(false);
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package techreborn.manual.designer.exporter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Mark on 16/04/2016.
|
||||||
|
*/
|
||||||
|
public class DownloadablePackageInfo {
|
||||||
|
|
||||||
|
PackageInfo packageInfo;
|
||||||
|
|
||||||
|
String md5;
|
||||||
|
|
||||||
|
String fileName;
|
||||||
|
|
||||||
|
}
|
101
src/main/java/techreborn/manual/designer/exporter/Exporter.java
Normal file
101
src/main/java/techreborn/manual/designer/exporter/Exporter.java
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
package techreborn.manual.designer.exporter;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.apache.commons.lang3.time.DateUtils;
|
||||||
|
import org.zeroturnaround.zip.ZipUtil;
|
||||||
|
import reborncore.shields.json.ShieldJsonLoader;
|
||||||
|
import techreborn.manual.saveFormat.ManualFormat;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Mark on 16/04/2016.
|
||||||
|
*/
|
||||||
|
public class Exporter {
|
||||||
|
|
||||||
|
public static void run(String[] arg) throws Exception {
|
||||||
|
if(arg.length < 3){
|
||||||
|
System.out.println("Error incorrect arguments!");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
File input = new File(arg[1]);
|
||||||
|
File output = new File(arg[2]);
|
||||||
|
if(!input.exists()){
|
||||||
|
System.out.println("that input file does not exist!");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
if(!output.exists()){
|
||||||
|
System.out.println("that output file does not exist!");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
File inputMaster = new File(input, "master.json");
|
||||||
|
if(!inputMaster.exists()){
|
||||||
|
System.out.println("That input is not valid! no master.json file found");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
File inputData = new File(input, "data.json");
|
||||||
|
if(!inputData.exists()){
|
||||||
|
System.out.println("That input is not valid! no data.json file found");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||||
|
File webJson = new File(output, "versions.json");
|
||||||
|
VersionsInfo versions = null;
|
||||||
|
if(webJson.exists()){
|
||||||
|
BufferedReader reader = new BufferedReader(new FileReader(webJson));
|
||||||
|
versions = gson.fromJson(reader, VersionsInfo.class);
|
||||||
|
} else {
|
||||||
|
versions = new VersionsInfo();
|
||||||
|
versions.versions = new ArrayList<>();
|
||||||
|
versions.name = "TechReborn";
|
||||||
|
}
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss.SSS");
|
||||||
|
versions.lastUpdated = dateFormat.format(new Date());
|
||||||
|
|
||||||
|
BufferedReader reader = new BufferedReader(new FileReader(inputData));
|
||||||
|
PackageInfo info = gson.fromJson(reader, PackageInfo.class);
|
||||||
|
|
||||||
|
DownloadablePackageInfo downloadablePackageInfo = new DownloadablePackageInfo();
|
||||||
|
downloadablePackageInfo.packageInfo = info;
|
||||||
|
File packages = new File(output, "packages");
|
||||||
|
if(!packages.exists()){
|
||||||
|
packages.mkdir();
|
||||||
|
}
|
||||||
|
dateFormat = new SimpleDateFormat("dd-MM-yyyy-HH-mm-ss-SSS");
|
||||||
|
|
||||||
|
File outputFile = new File(packages, versions.name + dateFormat.format(new Date()) + ".zip");
|
||||||
|
|
||||||
|
ZipUtil.pack(input, outputFile);
|
||||||
|
downloadablePackageInfo.fileName = outputFile.getName();
|
||||||
|
downloadablePackageInfo.md5 = ShieldJsonLoader.getMD5(outputFile);
|
||||||
|
|
||||||
|
List<DownloadablePackageInfo> savedVersions = versions.versions;
|
||||||
|
versions.versions = new ArrayList<>();
|
||||||
|
versions.versions.add(downloadablePackageInfo);
|
||||||
|
versions.versions.addAll(savedVersions);
|
||||||
|
|
||||||
|
String json = gson.toJson(versions);
|
||||||
|
FileWriter writer = new FileWriter(webJson);
|
||||||
|
writer.write(json);
|
||||||
|
writer.close();
|
||||||
|
|
||||||
|
System.out.println("Done!");
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package techreborn.manual.designer.exporter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Mark on 16/04/2016.
|
||||||
|
*/
|
||||||
|
public class PackageInfo {
|
||||||
|
|
||||||
|
public String name;
|
||||||
|
|
||||||
|
public String version;
|
||||||
|
|
||||||
|
public String language;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package techreborn.manual.designer.exporter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Mark on 16/04/2016.
|
||||||
|
*/
|
||||||
|
public class VersionsInfo {
|
||||||
|
|
||||||
|
String name;
|
||||||
|
|
||||||
|
String lastUpdated;
|
||||||
|
|
||||||
|
List<DownloadablePackageInfo> versions;
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue