-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
12 changed files
with
128 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ services: | |
volumes: | ||
- ./server:/data | ||
ports: | ||
- "25565:25565" | ||
- "25565:25565" | ||
- "4567:4567" |
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
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
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/io/github/toberocat/guiengine/webeditor/WebEditorServer.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,17 @@ | ||
package io.github.toberocat.guiengine.webeditor | ||
|
||
import io.github.toberocat.guiengine.webeditor.controller.GuiEngineApiController | ||
import spark.kotlin.port | ||
import spark.kotlin.staticFiles | ||
|
||
class WebEditorServer(port: Int) { | ||
init { | ||
port(port) | ||
staticFiles.location("/webeditor") | ||
GuiEngineApiController().register() | ||
} | ||
} | ||
|
||
fun main() { | ||
WebEditorServer(8080) | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/io/github/toberocat/guiengine/webeditor/controller/Controller.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,17 @@ | ||
package io.github.toberocat.guiengine.webeditor.controller | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import com.fasterxml.jackson.module.kotlin.registerKotlinModule | ||
import spark.Request | ||
import spark.Spark | ||
|
||
private val mapper = ObjectMapper().registerKotlinModule() | ||
|
||
interface Controller { | ||
fun <T> getRequest(route: String, callback: (req: Request) -> T) { | ||
Spark.get(route) { req, res -> | ||
res.type("application/json") | ||
return@get mapper.writeValueAsString(callback.invoke(req)) | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/kotlin/io/github/toberocat/guiengine/webeditor/controller/GuiEngineApiController.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,20 @@ | ||
package io.github.toberocat.guiengine.webeditor.controller | ||
|
||
import io.github.toberocat.guiengine.GuiEngineApi | ||
import spark.Spark | ||
|
||
class GuiEngineApiController : Controller { | ||
fun register() { | ||
getRequest("/apis") { GuiEngineApi.APIS.keys } | ||
getRequest("/guis/:api") { GuiEngineApi.APIS[it.params("api")]?.getAvailableGuis() ?: emptySet() } | ||
Spark.get("/guis/:api/:gui") { req, res -> | ||
res.type("application/xml") | ||
return@get """<?xml version="1.0" encoding="UTF-8"?>\n${getXmlGui(req.params("api"), req.params("gui"))}""" | ||
} | ||
} | ||
|
||
private fun getXmlGui(apiId: String, guiId: String): String { | ||
val api = GuiEngineApi.APIS[apiId] ?: return "" | ||
return api.xmlMapper.writeValueAsString(api.loadXmlGui(emptyMap(), guiId)) | ||
} | ||
} |
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 |
---|---|---|
|
@@ -12,4 +12,5 @@ items: | |
lore: | ||
- "" | ||
- "§7Click me! I can't get eaten" | ||
webeditor-port: 4657 | ||
update-checker: true |
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,28 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> | ||
|
||
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> | ||
<appender name="console" class="org.apache.log4j.ConsoleAppender"> | ||
<param name="Target" value="System.out"/> | ||
<layout class="org.apache.log4j.PatternLayout"> | ||
<param name="ConversionPattern" value="%-5p %c{1} - %m%n"/> | ||
</layout> | ||
</appender> | ||
|
||
<logger name="org.apache.spark"> | ||
<level value="error"/> | ||
</logger> | ||
|
||
<logger name="org.spark-project"> | ||
<level value="error"/> | ||
</logger> | ||
|
||
<logger name="org.spark-project"> | ||
<level value="error"/> | ||
</logger> | ||
|
||
<root> | ||
<priority value="debug"/> | ||
<appender-ref ref="console"/> | ||
</root> | ||
</log4j:configuration> |
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,3 @@ | ||
class SimpleItem { | ||
|
||
} |
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 @@ | ||
<h1>Hallo Welt!</h1> |