Skip to content

Commit

Permalink
Added more functions, and final update/release for 1.13
Browse files Browse the repository at this point in the history
  • Loading branch information
JTK222 committed Jul 19, 2018
1 parent 02196a6 commit 40271d4
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 39 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ bin/ResourcePackUpdater.class
bin/UpdateJson.class
libs/gson-2.8.2.jar
test.bat
/.metadata/
/target/
1 change: 1 addition & 0 deletions bin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/net/
51 changes: 19 additions & 32 deletions src/net/dark_roleplay/rpupdater/ResourcePackUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,44 +16,31 @@ public class ResourcePackUpdater {
JsonObject updateJson;
public static PrintStream OUT;


//G:\Coding\Resource Pack Updater\TestPack\assets\minecraft
//G:\Coding\Resource Pack Updater\ResourcePackUpdater\changes.json
public static void main(String[] args) throws FileNotFoundException{
// try {
// UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
// }catch(Exception ex) {
// ex.printStackTrace();
// }
// MainScreen screen = new MainScreen();
// return;
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}catch(Exception ex) {
ex.printStackTrace();
}
MainScreen screen = new MainScreen();
return;
}

public static void update(String pathUpdateFile, String pathAssets) {
OUT = System.out;
String pathUpdateFile = "";
String pathAssets = "";
if(args.length == 1){
pathUpdateFile = args[0];
while(pathAssets.isEmpty()){
OUT.println("Please enter the path to your assets folder:");
pathAssets = inputString();
}
}else if(args.length == 0){
while(pathUpdateFile.isEmpty()){
OUT.println("Please enter the path to a update json:");
pathUpdateFile = inputString();
}
while(pathAssets.isEmpty()){
OUT.println("Please enter the path to your assets folder:");
pathAssets = inputString();
}
}else{
pathUpdateFile = args[0];
pathAssets = args[1];
}

UpdateJson uJson = new UpdateJson(pathUpdateFile);
uJson.renameFiles(pathAssets);
uJson.renameContent(pathAssets);
uJson.moveBlockStates(pathAssets);
System.out.println("Renamed " + uJson.renames + " Files!");
System.out.println("Changed " + uJson.changes + " Lines!");
System.out.println("Moved " + uJson.moves + " Blockstates!");
uJson.renameFiles(pathAssets);
uJson.renameFolders(pathAssets);
System.out.println("Update Stats:");
System.out.println(String.format("Renamed %d Files", uJson.renames));
System.out.println(String.format("Changed %d Files", uJson.changes));
System.out.println(String.format("Moved %d Files", uJson.moves));
}

private static String inputString(){
Expand Down
15 changes: 15 additions & 0 deletions src/net/dark_roleplay/rpupdater/UpdateJson.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ public void renameContent(String path2) {
Path path = Paths.get(file.getPath());
try {
String content = new String(Files.readAllBytes(path), charset);
if(content.contains("blocks/")) {
content = content.replaceAll("blocks/", "block/");
changes++;
}
if(content.contains("items/")) {
content = content.replaceAll("items/", "item/");
changes++;
}
for (String key : renameTextures.keySet()) {
if(content.contains(renameTextures.get(key)))
changes++;
Expand Down Expand Up @@ -192,4 +200,11 @@ private JsonObject getJson(String path) {
}
return null;
}

public void renameFolders(String path) {
File rename = new File(path + "/textures/blocks");
rename.renameTo(new File(path + "/textures/block"));
File rename2 = new File(path + "/textures/items");
rename2.renameTo(new File(path + "/textures/item"));
}
}
39 changes: 34 additions & 5 deletions src/net/dark_roleplay/rpupdater/gui/MainPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,46 @@
import javax.swing.JLabel;
import javax.swing.JTabbedPane;

import net.dark_roleplay.rpupdater.ResourcePackUpdater;
import net.dark_roleplay.rpupdater.gui.components.JMultilineLabel;
import net.dark_roleplay.rpupdater.gui.panels.ChangesSelectionPanel;
import net.dark_roleplay.rpupdater.gui.panels.ResourcePackSelectionPanel;
import javax.swing.JPanel;
import javax.swing.Box;
import javax.swing.JButton;
import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.io.PrintStream;
import java.awt.event.ActionEvent;
import javax.swing.BoxLayout;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;

public class MainPane extends JTabbedPane{
public class MainPane extends JPanel{

private static final long serialVersionUID = 1L;

public MainPane(){
this.setTabPlacement(TOP);
this.addTab("Resource Pack", null, new ResourcePackSelectionPanel(), "Select the location of your resourcepack");
this.addTab("Changes Json", null, new ChangesSelectionPanel(), "Select the location of changes.json");

Box verticalBox = Box.createVerticalBox();
ResourcePackSelectionPanel resourcePackSelectionPanel = new ResourcePackSelectionPanel();
verticalBox.add(resourcePackSelectionPanel);
ChangesSelectionPanel changesSelectionPanel = new ChangesSelectionPanel();
verticalBox.add(changesSelectionPanel);

JButton btnNewButton = new JButton("Update Pack");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ResourcePackUpdater.update(ChangesSelectionPanel.folderLocation.getText(), ResourcePackSelectionPanel.folderLocation.getText());
}
});
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
verticalBox.add(btnNewButton);
add(verticalBox);
}

}
7 changes: 5 additions & 2 deletions src/net/dark_roleplay/rpupdater/gui/MainScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ public class MainScreen extends JFrame{
private static final long serialVersionUID = 1L;

public MainScreen (){
setTitle("Dark Roleplay Resource Pack Updater");
this.setSize(600, 400);
this.setLocationRelativeTo(null);
this.add(new MainPane());
this.setContentPane(new MainPane());
// this.pack();
this.setVisible(true);
this.setResizable(false);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}

}
Binary file not shown.
Binary file modified target/classes/net/dark_roleplay/rpupdater/UpdateJson.class
Binary file not shown.
Binary file modified target/classes/net/dark_roleplay/rpupdater/gui/MainPane.class
Binary file not shown.
Binary file modified target/classes/net/dark_roleplay/rpupdater/gui/MainScreen.class
Binary file not shown.

0 comments on commit 40271d4

Please sign in to comment.