-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
09fdcf9
commit 15e05e8
Showing
6 changed files
with
188 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
plugins { | ||
id 'java' | ||
id 'org.jetbrains.kotlin.jvm' version '2.0.0' | ||
id 'maven-publish' | ||
id 'signing' | ||
id 'org.jetbrains.dokka' version '1.9.10' | ||
} | ||
|
||
group = project.rootProject.maven_group | ||
version = project.rootProject.mod_version | ||
|
||
kotlin { | ||
jvmToolchain(rootProject.jvm_version.toInteger()) | ||
compilerOptions { | ||
verbose = true | ||
allWarningsAsErrors = true | ||
} | ||
} | ||
|
||
def targetJavaVersion = rootProject.jvm_version.toInteger() | ||
tasks.withType(JavaCompile).configureEach { | ||
it.options.encoding = "UTF-8" | ||
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { | ||
it.options.release = targetJavaVersion | ||
} | ||
it.options.compilerArgs.add("-Werror") | ||
} | ||
|
||
dependencies { | ||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${project.kotlin_coroutines_version}") | ||
implementation("org.jetbrains.kotlin:kotlin-reflect:${project.kotlin_version}") | ||
implementation("org.apache.logging.log4j:log4j-api:${project.log4j2_version}") | ||
implementation("org.apache.logging.log4j:log4j-core:${project.log4j2_version}") | ||
implementation("org.fusesource.jansi:jansi:${project.jansi_version}") | ||
implementation("org.jline:jline:${project.jline_version}") | ||
} | ||
|
||
test { | ||
|
||
} | ||
|
||
processResources { | ||
inputs.property "version", project.rootProject.version | ||
inputs.property "minecraft_version", project.rootProject.minecraft_version | ||
inputs.property "loader_version", project.rootProject.loader_version | ||
filteringCharset "UTF-8" | ||
|
||
filesMatching("fabric.mod.json") { | ||
expand "version": project.rootProject.version, | ||
"minecraft_version": project.rootProject.minecraft_version, | ||
"loader_version": project.rootProject.loader_version | ||
} | ||
} | ||
|
||
jar { | ||
archiveBaseName = "advancedfmk-chatserver" | ||
} | ||
|
||
task sourcesJar(type: Jar) { | ||
from sourceSets.main.allSource | ||
java.withSourcesJar() | ||
archiveClassifier = "sources" | ||
} | ||
|
||
task javadocJar(type: Jar) { | ||
dependsOn(javadoc) | ||
from("build/dokka/javadoc") | ||
archiveClassifier = "javadoc" | ||
} | ||
|
||
artifacts { | ||
archives sourcesJar, javadocJar | ||
} | ||
|
||
var publish = new Properties() | ||
rootProject.file('.gradle/publish.cfg').withInputStream { publish.load(it) } | ||
|
||
def ossrhUserName = publish.getProperty('ossrhUserName') | ||
def ossrhPassword = publish.getProperty('ossrhPassword') | ||
def signKey = new String(publish.getProperty('signing.key').decodeBase64()) | ||
def signPassword = publish.getProperty('signing.password') | ||
|
||
publishing { | ||
publications { | ||
maven(MavenPublication) { | ||
groupId = group | ||
artifactId = 'advancedfmk-chatserver' | ||
version = version | ||
|
||
from components.kotlin | ||
artifact sourcesJar | ||
artifact javadocJar | ||
|
||
pom { | ||
name = 'chatserver (Advanced Framework)' | ||
description = 'Binary files reading & writing for Advanced Framework' | ||
url = 'http://github.com/PrimogemStudio/Advanced-Framework' | ||
licenses { | ||
license { | ||
name = 'GNU GENERAL PUBLIC LICENSE Version 3' | ||
url = 'https://www.gnu.org/licenses/gpl-3.0.txt' | ||
} | ||
} | ||
developers { | ||
developer { | ||
id = 'hackermdch' | ||
name = 'hackermdch' | ||
} | ||
|
||
|
||
developer { | ||
id = 'Jack253-png' | ||
name = 'Coder 2' | ||
email = '[email protected]' | ||
} | ||
} | ||
scm { | ||
connection = 'scm:git:git://github.com/PrimogemStudio/Advanced-Framework.git' | ||
developerConnection = 'scm:git:ssh://github.com/PrimogemStudio/Advanced-Framework.git' | ||
url = 'https://github.com/PrimogemStudio/Advanced-Framework' | ||
} | ||
} | ||
} | ||
} | ||
|
||
repositories { | ||
maven { | ||
name = "LocalMaven" | ||
url = rootProject.layout.projectDirectory.dir("../maven") | ||
} | ||
|
||
maven { | ||
name = "MavenCentral" | ||
credentials { | ||
username = ossrhUserName | ||
password = ossrhPassword | ||
} | ||
url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" | ||
} | ||
} | ||
} | ||
|
||
signing { | ||
useInMemoryPgpKeys(signKey, signPassword) | ||
sign publishing.publications.maven | ||
} |
34 changes: 34 additions & 0 deletions
34
chatserver/src/main/kotlin/com/primogemstudio/advancedfmk/chat/ChatServerMain.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.primogemstudio.advancedfmk.chat | ||
|
||
import kotlinx.coroutines.DelicateCoroutinesApi | ||
import kotlinx.coroutines.GlobalScope | ||
import kotlinx.coroutines.launch | ||
import java.net.ServerSocket | ||
import java.net.Socket | ||
|
||
fun eventLoop(s: Socket) { | ||
while (true) { | ||
val r = s.getInputStream() | ||
val a = r.available() | ||
if (a != 0) { | ||
val data = r.readNBytes(a) | ||
println(String(data, Charsets.UTF_8)) | ||
s.getOutputStream().write(data) | ||
} | ||
Thread.sleep(1000) | ||
|
||
if (s.isClosed) break | ||
} | ||
} | ||
|
||
@OptIn(DelicateCoroutinesApi::class) | ||
fun main() { | ||
val server = ServerSocket(32767) | ||
val sockets = mutableListOf<Socket>() | ||
|
||
while (true) { | ||
val s = server.accept() | ||
sockets.add(s) | ||
GlobalScope.launch { eventLoop(s) } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters