gradle #252
45
build.gradle
45
build.gradle
@ -93,13 +93,14 @@ task finalizeProject {
|
||||
build.finalizedBy(finalizeProject)
|
||||
|
||||
if (project.hasProperty("hostname")) {
|
||||
def server = "Dev1.15"
|
||||
// def server = "Developer"
|
||||
|
||||
task uploadProject {
|
||||
description 'Upload this project'
|
||||
group "Steamwar"
|
||||
|
||||
doLast {
|
||||
def server = "Dev1.15"
|
||||
// def server = "Developer"
|
||||
await(shell("scp ${libs}/${jarName} ${hostname}:~/${server}/plugins"))
|
||||
if (!answer("Start ${server} server?")) {
|
||||
return
|
||||
@ -107,6 +108,15 @@ if (project.hasProperty("hostname")) {
|
||||
serverStart(server)
|
||||
}
|
||||
}
|
||||
|
||||
task startDevServer {
|
||||
description 'Start the DevServer'
|
||||
group "Steamwar"
|
||||
|
||||
doLast {
|
||||
serverStart(server)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def await(Process proc) {
|
||||
@ -127,12 +137,32 @@ def shell(String command) {
|
||||
def serverStart(String serverName) {
|
||||
def proc = shell("ssh -t ${hostname} \"./mc ${serverName}\"")
|
||||
|
||||
Thread outputThread = proc.consumeProcessOutputStream(System.out)
|
||||
Thread outputThread = new Thread({
|
||||
Reader reader = proc.getInputStream().newReader();
|
||||
Writer writer = System.out.newWriter();
|
||||
try {
|
||||
while (proc.alive) {
|
||||
String s = reader.readLine()
|
||||
if (s == null) {
|
||||
return
|
||||
}
|
||||
if (s.contains("SteamWar? Unbekannter Befehl.")) {
|
||||
continue
|
||||
}
|
||||
writer.write(s + "\n")
|
||||
writer.flush()
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// Ignored
|
||||
}
|
||||
})
|
||||
outputThread.setName("${serverName} - OutputThread")
|
||||
outputThread.start()
|
||||
|
||||
Writer writer
|
||||
Thread inputThread = new Thread({
|
||||
Reader reader = System.in.newReader()
|
||||
Writer writer = proc.getOutputStream().newWriter()
|
||||
writer = proc.getOutputStream().newWriter()
|
||||
try {
|
||||
while (proc.alive) {
|
||||
String s = reader.readLine()
|
||||
@ -150,11 +180,14 @@ def serverStart(String serverName) {
|
||||
if (!proc.alive) {
|
||||
return
|
||||
}
|
||||
Writer writer = proc.getOutputStream().newWriter()
|
||||
writer = proc.getOutputStream().newWriter()
|
||||
writer.write("stop\n")
|
||||
writer.flush()
|
||||
|
||||
proc.getInputStream().close()
|
||||
while (proc.alive) {
|
||||
Thread.sleep(10)
|
||||
}
|
||||
proc.closeStreams()
|
||||
outputThread.interrupt()
|
||||
inputThread.interrupt()
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren