it works. commands are broken.
This commit is contained in:
108
build.gradle
108
build.gradle
@@ -1,6 +1,9 @@
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
|
||||
plugins {
|
||||
id 'java'
|
||||
id("xyz.jpenilla.run-paper") version "2.3.1"
|
||||
id "com.gradleup.shadow" version "9.2.2"
|
||||
}
|
||||
|
||||
group = 'hdvtdev'
|
||||
@@ -8,6 +11,7 @@ version = '0.0.1-a'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'https://storehouse.okaeri.eu/repository/maven-releases/'}
|
||||
maven { url 'https://repo.md-5.net/content/groups/public/' }
|
||||
maven { url 'https://jitpack.io' }
|
||||
maven {
|
||||
@@ -21,15 +25,24 @@ repositories {
|
||||
maven { url 'https://libraries.minecraft.net/' }
|
||||
}
|
||||
|
||||
def okaeriConfigsVersion = '5.0.13'
|
||||
|
||||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
|
||||
implementation group: 'me.libraryaddict.disguises', name: 'libsdisguises', version: '11.0.6'
|
||||
//TODO implementation 'me.lucko:commodore:2.2'
|
||||
compileOnly group: 'me.libraryaddict.disguises', name: 'libsdisguises', version: '11.0.6'
|
||||
compileOnly 'org.projectlombok:lombok:1.18.42'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.42'
|
||||
|
||||
implementation "eu.okaeri:okaeri-configs-validator-okaeri:$okaeriConfigsVersion"
|
||||
implementation "eu.okaeri:okaeri-configs-yaml-bukkit:$okaeriConfigsVersion"
|
||||
implementation "eu.okaeri:okaeri-configs-serdes-bukkit:$okaeriConfigsVersion"
|
||||
implementation "eu.okaeri:okaeri-configs-serdes-commons:$okaeriConfigsVersion"
|
||||
|
||||
implementation "org.incendo:cloud-paper:2.0.0-beta.13"
|
||||
}
|
||||
|
||||
|
||||
def targetJavaVersion = 21
|
||||
def targetJavaVersion = 17
|
||||
java {
|
||||
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
|
||||
sourceCompatibility = javaVersion
|
||||
@@ -56,14 +69,83 @@ processResources {
|
||||
}
|
||||
}
|
||||
|
||||
jar {
|
||||
//destinationDirectory.set(file("/home/hadvart/Documents/Minecraft/Pufferfish 1.20.4/plugins"))
|
||||
from sourceSets.main.output
|
||||
from {
|
||||
configurations.runtimeClasspath.findAll {
|
||||
it.name.startsWith('Java-Probability-Collection') || it.name.startsWith('commodore') || it.name.startsWith('brigadier')
|
||||
}.collect { zipTree(it) }
|
||||
}
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
tasks.shadowJar {
|
||||
archiveClassifier.set("")
|
||||
relocate("eu.okaeri", "hdvtdev.blockandseek.libs.okaeri")
|
||||
relocate("org.incendo", "hdvtdev.blockandseek.libs.cloud")
|
||||
}
|
||||
|
||||
tasks.build {
|
||||
dependsOn(tasks.shadowJar)
|
||||
}
|
||||
|
||||
tasks.register('deploy') {
|
||||
dependsOn build
|
||||
|
||||
|
||||
doLast {
|
||||
def targetDir = project.property('server.plugins.dir')
|
||||
def rconHost = project.property('rcon.host')
|
||||
def rconPort = project.property('rcon.port') as int
|
||||
def rconPass = project.property('rcon.password')
|
||||
|
||||
|
||||
def jarFile = tasks.jar.archiveFile.get().asFile
|
||||
|
||||
if (!file(targetDir).exists()) {
|
||||
println "Err folder not found : $targetDir"
|
||||
return
|
||||
}
|
||||
|
||||
copy {
|
||||
from jarFile
|
||||
into targetDir
|
||||
}
|
||||
|
||||
try {
|
||||
sendRconCommand(rconHost, rconPort, rconPass, "plugman reload BlockAndSeek")
|
||||
sendRconCommand(rconHost, rconPort, rconPass, "reload")
|
||||
println "Plugin reloaded"
|
||||
} catch (Exception e) {
|
||||
println "RCON: ${e.message}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def sendRconCommand(String host, int port, String password, String command) {
|
||||
new Socket(host, port).withCloseable { socket ->
|
||||
def out = socket.outputStream
|
||||
def inp = socket.inputStream
|
||||
|
||||
def sendPacket = { int id, int type, String body ->
|
||||
byte[] bodyBytes = body.getBytes("UTF-8")
|
||||
int length = 4 + 4 + bodyBytes.length + 2 // id + type + body + 2 nulls
|
||||
ByteBuffer buffer = ByteBuffer.allocate(4 + length)
|
||||
buffer.order(ByteOrder.LITTLE_ENDIAN)
|
||||
|
||||
buffer.putInt(length)
|
||||
buffer.putInt(id)
|
||||
buffer.putInt(type)
|
||||
buffer.put(bodyBytes)
|
||||
buffer.put((byte) 0)
|
||||
buffer.put((byte) 0)
|
||||
|
||||
out.write(buffer.array())
|
||||
out.flush()
|
||||
}
|
||||
|
||||
|
||||
sendPacket(1, 3, password)
|
||||
|
||||
inp.read(new byte[4096])
|
||||
|
||||
sendPacket(2, 2, command)
|
||||
|
||||
byte[] buffer = new byte[4096]
|
||||
int read = inp.read(buffer)
|
||||
if (read > 12) {
|
||||
String response = new String(buffer, 12, read - 12 - 2, "UTF-8")
|
||||
println "Server response: $response"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user