Correct value replacement for server.properties

This commit is contained in:
ME1312 2018-11-21 17:33:52 -05:00
parent d877e80b9f
commit a12ff22645
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
3 changed files with 3 additions and 3 deletions

View File

@ -432,7 +432,7 @@ public class InternalSubCreator extends SubCreator {
File file = new File(dir, "server.properties");
if (!file.exists()) file.createNewFile();
InputStream stream = new FileInputStream(file);
String content = Util.readAll(new BufferedReader(new InputStreamReader(stream))).replace("server-port=", "server-port=" + port).replace("server-ip=", "server-ip=" + host.getAddress().getHostAddress());
String content = Util.readAll(new BufferedReader(new InputStreamReader(stream))).replaceAll("server-port=.*(\r?\n)", "server-port=" + port + "$1").replaceAll("server-ip=.*(\r?\n)", "server-ip=" + host.getAddress().getHostAddress() + "$1");
stream.close();
file.delete();
PrintWriter writer = new PrintWriter(file, "UTF-8");

View File

@ -7,4 +7,4 @@ Template:
Shell-Location: 'build.sh'
Permission: '+x'
Settings:
Executable: 'java -Xmx1024M -Dorg.bukkit.craftbukkit.libs.jline.terminal=unix -Djansi.passthrough=true -jar Spigot.jar'
Executable: 'java -Xmx1024M -Dorg.bukkit.craftbukkit.libs.jline.terminal=unix -Djansi.passthrough=true -jar Spigot.jar -p $port$'

View File

@ -429,7 +429,7 @@ public class SubCreator {
File file = new File(dir, "server.properties");
if (!file.exists()) file.createNewFile();
FileInputStream is = new FileInputStream(file);
String content = Util.readAll(new BufferedReader(new InputStreamReader(is))).replace("server-port=", "server-port=" + port).replace("server-ip=", "server-ip=" + host.config.get().getSection("Settings").getRawString("Server-Bind"));
String content = Util.readAll(new BufferedReader(new InputStreamReader(is))).replaceAll("server-port=.*(\r?\n)", "server-port=" + port + "$1").replaceAll("server-ip=.*(\r?\n)", "server-ip=" + host.config.get().getSection("Settings").getRawString("Server-Bind") + "$1");
is.close();
file.delete();
PrintWriter writer = new PrintWriter(file, "UTF-8");