1515
1616public class Main {
1717
18- public static final String TITLE = "Sourcecraft - Minecraft to Source converter" ;
19- public static final String VERSION = "3.0 " ;
18+ public static final String TITLE = "Sourcecraft - Minecraft to VMF converter" ;
19+ public static final String VERSION = "3.1 " ;
2020 public static final String AUTHOR = "garten" ;
2121 public static final String LICENSE = "GNU General Public License v3.0" ;
2222 public static final String LICENSE_INFO = "https://www.gnu.org/licenses/gpl-3.0.html" ;
@@ -54,12 +54,29 @@ public Main() {
5454
5555 File output = new File (this .gui .getOutputFile ());
5656 ConverterData data = this .getConverterData ();
57+ if (data == null ) {
58+ return ;
59+ }
5760 this .converter .convert (data , output );
5861 if (data .getUpdateTextures ()) {
5962 final TexturePack pack = data .getTexturePack ();
6063 if (!Steam .areTexturesUpToDate (data .getGame (), pack )) {
61- TextureFolderMover .copyFolder (pack .getFolder (), data .getGame ()
62- .getMatriealPath (pack ));
64+ File targetDirectory = data .getGame ()
65+ .getMatriealPath (pack );
66+ if (targetDirectory .exists ()) {
67+ TextureFolderMover .copyFolder (pack .getFolder (), data .getGame ()
68+ .getMatriealPath (pack ));
69+ } else if (targetDirectory .getParentFile ()
70+ .getParentFile ()
71+ .exists ()) {
72+ targetDirectory .getParentFile ()
73+ .mkdir (); // Garrysmod comes without material folder
74+ TextureFolderMover .copyFolder (pack .getFolder (), data .getGame ()
75+ .getMatriealPath (pack ));
76+ } else {
77+ Loggger .log ("Not copying textures. The directory " + targetDirectory + " does not exist. Have you launched " + data .getGame ()
78+ .getLongName () + " at least once?" );
79+ }
6380 }
6481 }
6582
@@ -80,6 +97,9 @@ public Main() {
8097 });
8198 }
8299
100+ /**
101+ * returns true if place has been found.
102+ */
83103 private void saveNewPlace () {
84104 if (this .gui .getRememberPlaceSelected ()) {
85105 String name = this .gui .getSaveLocation ();
@@ -113,8 +133,11 @@ public ConverterData getConverterData() {
113133 ConverterData converterData = new ConverterData ();
114134
115135 Place place = this .gui .getPlaceFromCoordinates ();
116- String worldName = this .gui .getWorld ()
117- .toString ();
136+ World world = this .gui .getWorld ();
137+ if (world == null ) {
138+ return null ;
139+ }
140+ String worldName = world .toString ();
118141 Loggger .log ("world = " + worldName );
119142 if (place == null ) {
120143 Loggger .warn ("Place not found" );
0 commit comments