13
0

Merge remote-tracking branch 'origin/master'
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
yoyosource 2023-07-15 21:50:46 +02:00
Commit fad9c082bd
4 geänderte Dateien mit 29 neuen und 194 gelöschten Zeilen

Datei anzeigen

@ -25,18 +25,7 @@ plugins {
id 'application' id 'application'
id 'com.github.johnrengelman.shadow' version '5.0.0' id 'com.github.johnrengelman.shadow' version '5.0.0'
} id 'de.steamwar.gradle' version 'RELEASE'
ext.swdep = { s ->
if (file("${rootDir}/lib/${s}.jar").exists()) {
return files("${rootDir}/lib/${s}.jar")
} else {
if (s.contains("-")) {
return "de.steamwar:${s.toLowerCase().replace('-', ':')}"
} else {
return "de.steamwar:${s.toLowerCase()}:RELEASE"
}
}
} }
group 'de.steamwar' group 'de.steamwar'
@ -44,26 +33,6 @@ version ''
mainClassName = '' mainClassName = ''
Properties steamwarProperties = new Properties()
if (file("steamwar.properties").exists()) {
steamwarProperties.load(file("steamwar.properties").newDataInputStream())
}
ext {
buildName = 'LobbySystem2.0'
artifactName = 'lobbysystem2.0'
uberJarName = "${buildName}-all.jar"
jarName = "${artifactName}.jar"
libs = "${buildDir}/libs"
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
operatingSystem = "windows"
} else {
operatingSystem = "unix"
}
}
compileJava.options.encoding = 'UTF-8' compileJava.options.encoding = 'UTF-8'
sourceCompatibility = 1.8 sourceCompatibility = 1.8
@ -87,14 +56,6 @@ repositories {
maven { maven {
url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/') url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/')
} }
maven {
url = uri('https://steamwar.de/maven/')
credentials {
username = steamwarProperties.getProperty("maven.username")
password = steamwarProperties.getProperty("maven.password")
}
}
} }
dependencies { dependencies {
@ -109,151 +70,3 @@ dependencies {
annotationProcessor 'org.projectlombok:lombok:1.18.22' annotationProcessor 'org.projectlombok:lombok:1.18.22'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22' testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
} }
task buildProject {
description 'Build this project'
group "Steamwar"
dependsOn build
}
task finalizeProject {
description 'Finalize this project'
group "Steamwar"
doLast {
if ("${buildDir}" == null) {
return
}
delete fileTree("${libs}").matching {
exclude("${uberJarName}")
}
file(libs + "/" + uberJarName).renameTo(file(libs + "/" + jarName))
}
}
build.finalizedBy(finalizeProject)
if (steamwarProperties.containsKey("hostname")) {
String hostname = steamwarProperties.get("hostname")
String uploadPath = steamwarProperties.getOrDefault("uploadPath", "~")
String server = steamwarProperties.getOrDefault("server", "Dev1.15")
String serverStartFlags = steamwarProperties.getOrDefault("serverStartFlags", "")
task uploadProject {
description 'Upload this project'
group "Steamwar"
doLast {
await(shell("scp ${libs}/${jarName} ${hostname}:${uploadPath}/${server}/plugins"))
if (steamwarProperties.getOrDefault("directStart", "false") == "false" && !answer("Start ${server} server?")) {
return
}
serverStart(server, serverStartFlags, hostname)
}
}
uploadProject.dependsOn(buildProject)
task startDevServer {
description 'Start the DevServer'
group "Steamwar"
doLast {
serverStart(server, serverStartFlags, hostname)
}
}
}
private def await(Process proc) {
def out = new StringBuilder()
def err = new StringBuilder()
proc.waitForProcessOutput(out, err)
return [out, err, proc.exitValue()]
}
private def shell(String command) {
if (operatingSystem == "unix") {
return ['bash', '-c', command].execute()
} else {
return ["cmd", "/c", command].execute()
}
}
private def serverStart(String serverName, String serverFlags, String hostname) {
def proc = shell("ssh -t ${hostname} \"./mc ${serverFlags} ${serverName}\"")
Set<String> strings = new HashSet<>()
File file = new File("${projectDir}/ignoredlog");
if (file.exists()) {
new BufferedReader(new InputStreamReader(new FileInputStream(file))).readLines().forEach({ s ->
strings.add(s)
})
}
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 (strings.stream().anyMatch({check -> s.contains(check)})) {
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 = proc.getOutputStream().newWriter()
try {
while (proc.alive) {
String s = reader.readLine()
writer.write(s + "\n")
writer.flush()
}
} catch (IOException e) {
// Ignored
}
})
inputThread.setName("${serverName} - InputThread")
inputThread.start()
gradle.buildFinished { buildResult ->
if (!proc.alive) {
return
}
writer = proc.getOutputStream().newWriter()
writer.write("stop\n")
writer.flush()
awaitClose(proc, outputThread, inputThread)
}
awaitClose(proc, outputThread, inputThread)
};
private static def awaitClose(Process proc, Thread outputThread, Thread inputThread) {
while (proc.alive) {
Thread.sleep(10)
}
proc.closeStreams()
outputThread.interrupt()
inputThread.interrupt()
}
private def answer(String question) {
while (System.in.available() > 0) System.in.read()
println(question)
boolean valid = "Yy".contains(((char) System.in.read()).toString())
while (System.in.available() > 0) System.in.read()
return valid
}

Datei anzeigen

@ -17,4 +17,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
pluginManagement {
repositories {
gradlePluginPortal()
maven {
url = uri("https://steamwar.de/maven/")
}
}
}
rootProject.name = 'LobbySystem2.0' rootProject.name = 'LobbySystem2.0'

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.lobby.command;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.listener.PlayerSpawn;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -52,15 +53,26 @@ public class ModifyCommand extends SWCommand implements Listener {
if(!user.getUserGroup().isTeamGroup() && !user.getUserName().equals("joschi1")) if(!user.getUserGroup().isTeamGroup() && !user.getUserName().equals("joschi1"))
return; return;
modifying.add(player); if(modifying(player)) {
LobbySystem.getEntityServer(true).addPlayer(player); modifying.remove(player);
player.setGameMode(GameMode.CREATIVE); LobbySystem.getEntityServer(true).removePlayer(player);
player.setOp(true); player.setGameMode(GameMode.ADVENTURE);
player.setOp(false);
PlayerSpawn.giveItems(player);
}else {
modifying.add(player);
LobbySystem.getEntityServer(true).addPlayer(player);
player.setGameMode(GameMode.CREATIVE);
player.setOp(true);
}
} }
@EventHandler @EventHandler
public void onLeave(PlayerQuitEvent event) { public void onLeave(PlayerQuitEvent event) {
modifying.remove(event.getPlayer()); Player player = event.getPlayer();
modifying.remove(player);
player.setOp(false);
} }
@Register("waitinghallspawn") @Register("waitinghallspawn")

Datei anzeigen

@ -50,7 +50,6 @@ public class PlayerSpawn extends BasicListener {
public void onJoin(PlayerJoinEvent e) { public void onJoin(PlayerJoinEvent e) {
Player player = e.getPlayer(); Player player = e.getPlayer();
e.setJoinMessage(null); e.setJoinMessage(null);
player.getInventory().clear();
player.setGameMode(GameMode.ADVENTURE); player.setGameMode(GameMode.ADVENTURE);
player.setWalkSpeed(0.5f); player.setWalkSpeed(0.5f);
@ -68,6 +67,8 @@ public class PlayerSpawn extends BasicListener {
public static void giveItems(Player player) { public static void giveItems(Player player) {
PlayerInventory inventory = player.getInventory(); PlayerInventory inventory = player.getInventory();
inventory.clear();
inventory.setItem(EquipmentSlot.CHEST, ELYTRA); inventory.setItem(EquipmentSlot.CHEST, ELYTRA);
player.getInventory().setItem(FIREWORK_SLOT, FIREWORK); player.getInventory().setItem(FIREWORK_SLOT, FIREWORK);