Skip to content

Commit

Permalink
nuked more old code
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugobros3 committed Oct 21, 2019
1 parent 1022046 commit 4efee8a
Show file tree
Hide file tree
Showing 22 changed files with 212 additions and 245 deletions.
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ task("versionTxt") {
val file = File("${project.rootDir}/version.json")
file.writeText("""
{
version: "$version",
verboseVersion: "$verboseVersion",
commit: "${git.head().id}",
buildtime: "${Date()}"
"version": "$version",
"verboseVersion": "$verboseVersion",
"commit": "${git.head().id}",
"buildtime": "${Date()}"
}
""".trimIndent())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class ClientImplementation internal constructor(val arguments: Map<String, Strin

private fun printHelp() {
println("""
Chunk Stories Client version: ${VersionInfo.version}
Chunk Stories Client version: ${VersionInfo.versionJson.verboseVersion}
Available commandline options:
--core=... Specifies the folder/file to use as the base content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class GraphicsEngineImplementation(val client: ClientImplementation) : GraphicsE
// TODO check for MacOS first.
// System.setProperty("java.awt.headless", "true")

window = GLFWWindow(client, this, selectedGraphicsBackend, "Chunk Stories " + VersionInfo.version)
window = GLFWWindow(client, this, selectedGraphicsBackend, "Chunk Stories " + VersionInfo.versionJson.verboseVersion)

//TODO modify those to take the GraphicsEngine as param
backend = selectedGraphicsBackend.init(this, window)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import xyz.chunkstories.util.VersionInfo
fun printCopyrightNotice(drawer: GuiDrawer) {
// Notices
val noticeColor = Vector4f(1f)
val version = "Chunk Stories Client " + VersionInfo.version
val version = "Chunk Stories Client " + VersionInfo.versionJson.verboseVersion
drawer.fonts.defaultFont().getWidth(version)
drawer.drawStringWithShadow(drawer.fonts.defaultFont(), 4, 0, version, -1, noticeColor)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DebugInfoRendererHelper(ingameUI: IngameUI) {
val world = client.world as WorldImplementation
val graphicsBackend = window.graphicsEngine.backend

debugLine("Chunk Stories ${VersionInfo.version} running on the ${graphicsBackend.javaClass.simpleName}")
debugLine("Chunk Stories ${VersionInfo.versionJson.verboseVersion} running on the ${graphicsBackend.javaClass.simpleName}")

fun PerformanceCounter.print() {
debugLine("#FF0000Rendering: ${lastFrametimeNs/1000000}ms fps: ${avgFps.toInt()} (min ${minFps.toInt()}, max ${maxFps.toInt()}) #00FFFFSimulation performance : ${world.gameLogic.simulationFps}")
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/xyz/chunkstories/net/Connection.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ abstract class Connection(val remoteAddress: String, val port: Int) {
@Throws(IOException::class, PacketProcessingException::class, IllegalPacketException::class)
abstract fun handleDatagram(datagram: LogicalPacketDatagram)

abstract fun handleSystemRequest(msg: String): Boolean
abstract fun handleSystemRequest(message: String): Boolean

open fun sendTextMessage(string: String) {
val packet = PacketText()
Expand Down
22 changes: 0 additions & 22 deletions common/src/main/java/xyz/chunkstories/util/VersionInfo.java

This file was deleted.

28 changes: 28 additions & 0 deletions common/src/main/java/xyz/chunkstories/util/VersionInfo.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// This file is a part of the Chunk Stories Implementation codebase
// Check out README.md for more information
// Website: http://chunkstories.xyz
//

package xyz.chunkstories.util

import com.google.gson.Gson
import java.io.File

object VersionInfo {
val versionJson: VersionJson
val networkProtocolVersion = 37

init {
val file = File("version.json")

versionJson = if (file.exists()) {
val gson = Gson()
gson.fromJson(file.readText(), VersionJson::class.java)!!
} else {
VersionJson("unknown", "unknown(no version.json)", "unknown", "unknown")
}
}
}

data class VersionJson(val version: String, val verboseVersion: String, val commit: String, val buildtime: String)
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ fun loadOrDefaultPreLaunchOptions(): PreLaunchOptions {
properties.load(existingConfig.reader())
val dedicatedRam = (properties["client.performance.dedicatedRam"] as? String)?.toIntOrNull() ?: 2048

val vd = (properties["client.graphics.viewDistance"] as? String)?.toIntOrNull() ?: 2048
println("kek: $vd")

PreLaunchOptions(dedicatedRam)
} else {
PreLaunchOptions()
Expand Down
Binary file removed launcher/src/main/resources/gfx/bg.png
Binary file not shown.
Binary file removed launcher/src/main/resources/gfx/icon.png
Binary file not shown.
Binary file removed launcher/src/main/resources/gfx/icon128.png
Binary file not shown.
Binary file removed launcher/src/main/resources/gfx/icon16.png
Binary file not shown.
Binary file removed launcher/src/main/resources/gfx/logo.png
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class DedicatedServer internal constructor(coreContentLocation: File, modsString
val loggingFilename = "./serverlogs/$time.log"
LogbackSetupHelper(loggingFilename)

logger.info("Starting Chunkstories server " + VersionInfo.version + " network protocol version "
logger.info("Starting Chunkstories server " + VersionInfo.versionJson.verboseVersion + " network protocol version "
+ VersionInfo.networkProtocolVersion)

// Loads the mods/build filesystem
Expand Down Expand Up @@ -259,7 +259,7 @@ class DedicatedServer internal constructor(coreContentLocation: File, modsString
val freeRam = Runtime.getRuntime().freeMemory() / (1024 * 1024)
val usedRam = maxRam - freeRam

txt += "ChunkStories server " + VersionInfo.version
txt += "ChunkStories server " + VersionInfo.versionJson.verboseVersion
txt += " | fps:" + world.gameLogic.simulationFps
txt += " | ent:$ec"
txt += " | players:" + this.handler.playersNumber + "/" + this.handler.maxClients
Expand Down Expand Up @@ -312,7 +312,7 @@ class DedicatedServer internal constructor(coreContentLocation: File, modsString
}

override fun toString(): String {
return "[ChunkStories Server " + VersionInfo.version + "]"
return "[ChunkStories Server " + VersionInfo.versionJson.verboseVersion + "]"
}

override fun getPlayerByName(playerName: String): Player? = handler.getPlayerByName(playerName)
Expand Down Expand Up @@ -349,7 +349,7 @@ class DedicatedServer internal constructor(coreContentLocation: File, modsString
val coreContentLocationPath = s.replace("--core=", "")
coreContentLocation = File(coreContentLocationPath)
} else {
var helpText = "Chunk Stories server " + VersionInfo.version + "\n"
var helpText = "Chunk Stories server " + VersionInfo.versionJson.verboseVersion + "\n"

if (s == "-h" || s == "--help")
helpText += "Command line help: \n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

package xyz.chunkstories.server.commands.system

import xyz.chunkstories.api.content.mods.Mod
import xyz.chunkstories.api.plugin.ChunkStoriesPlugin
import xyz.chunkstories.api.plugin.commands.Command
import xyz.chunkstories.api.plugin.commands.CommandEmitter
import xyz.chunkstories.api.server.Server
Expand All @@ -18,61 +16,53 @@ import xyz.chunkstories.util.VersionInfo
class InfoCommands(serverConsole: Server) : ServerCommandBasic(serverConsole) {

init {

server.pluginManager.registerCommand("uptime", this)
server.pluginManager.registerCommand("info", this)
server.pluginManager.registerCommand("help", this)
server.pluginManager.registerCommand("plugins", this)
server.pluginManager.registerCommand("mods", this)
}

override fun handleCommand(emitter: CommandEmitter, cmd: Command, arguments: Array<String>): Boolean {
if (cmd.name == "uptime") {
emitter.sendMessage("#00FFD0The server has been running for " + server.uptime + " seconds.")
return true
} else if (cmd.name == "info") {
emitter.sendMessage("#00FFD0The server's ip is " + server.publicIp)
emitter.sendMessage("#00FFD0It's running version " + VersionInfo.version + " of the server software.")
emitter.sendMessage("#00FFD0" + server.world)
emitter.sendMessage("#00FFD0" + Runtime.getRuntime().freeMemory() / 1024 / 1024 + "Mb used out of "
+ Runtime.getRuntime().maxMemory() / 1024 / 1024 + "Mb allocated")
return true
} else if (cmd.name == "help") {
emitter.sendMessage("#00FFD0Avaible commands :")
emitter.sendMessage("#00FFD0" + " /plugins")
emitter.sendMessage("#00FFD0" + " /mods")
emitter.sendMessage("#00FFD0" + " /list")
emitter.sendMessage("#00FFD0" + " /info")
emitter.sendMessage("#00FFD0" + " /uptime")
for (command in server.pluginManager.commands()) {
emitter.sendMessage("#00FFD0 /" + command.name)
override fun handleCommand(emitter: CommandEmitter, command: Command, arguments: Array<String>): Boolean {
when {
command.name == "uptime" -> {
emitter.sendMessage("#00FFD0The server has been running for " + server.uptime + " seconds.")
return true
}
return true

} else if (cmd.name == "plugins") {
var list = ""

val i = server.pluginManager.activePlugins().iterator()
while (i.hasNext()) {
val plugin = i.next()
list += plugin.name + if (i.hasNext()) ", " else ""
command.name == "info" -> {
emitter.sendMessage("#00FFD0The server's ip is " + server.publicIp)
emitter.sendMessage("#00FFD0It's running version " + VersionInfo.versionJson.verboseVersion + " of the server software.")
emitter.sendMessage("#00FFD0" + server.world)
emitter.sendMessage("#00FFD0" + Runtime.getRuntime().freeMemory() / 1024 / 1024 + "Mb used out of " + Runtime.getRuntime().maxMemory() / 1024 / 1024 + "Mb allocated")
return true
}
command.name == "help" -> {
emitter.sendMessage("#00FFD0Avaible commands :")
emitter.sendMessage("#00FFD0" + " /plugins")
emitter.sendMessage("#00FFD0" + " /mods")
emitter.sendMessage("#00FFD0" + " /list")
emitter.sendMessage("#00FFD0" + " /info")
emitter.sendMessage("#00FFD0" + " /uptime")
for (availableCommand in server.pluginManager.commands()) {
emitter.sendMessage("#00FFD0 /" + availableCommand.name)
}
return true

emitter.sendMessage("#00FFD0$i active server plugins : $list")
return true
}
command.name == "plugins" -> {
val list = server.pluginManager.activePlugins().joinToString { it.name }
emitter.sendMessage("#00FFD0${list.length} active server plugins : $list")
return true

} else if (cmd.name == "mods") {
var list = ""
var i = 0
for (csp in server.content.modsManager.currentlyLoadedMods) {
i++
list += csp.modInfo.name + if (i == server.content.modsManager.currentlyLoadedMods.size) "" else ", "
}
emitter.sendMessage("#FF0000$i active server mods : $list")
return true
command.name == "mods" -> {
val list = server.content.modsManager.currentlyLoadedMods.joinToString { it.modInfo.name }
emitter.sendMessage("#FF0000${list.length} active server mods : $list")
return true

}
else -> return false
}
return false
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ abstract class ClientConnection(val context: Server, internal val clientsManager
private val loginHelper: PlayerAuthenticationHelper

abstract override var encoderDecoder: ClientPacketsContext protected set
protected var player: ServerPlayer? = null
var player: ServerPlayer? = null

init {
// This way we can tell the logs from one use to the next
Expand All @@ -48,7 +48,6 @@ abstract class ClientConnection(val context: Server, internal val clientsManager
}

override fun handleSystemRequest(message: String): Boolean {
var message = message
if (message.startsWith("info")) {
this.clientsManager.sendServerInfo(this)
return true
Expand All @@ -57,7 +56,7 @@ abstract class ClientConnection(val context: Server, internal val clientsManager
return loginHelper.handleLogin(message.substring(6, message.length))

} else if (message == "mods") {
sendTextMessage("info/mods:" + clientsManager.getServer().modsProvider.modsString)
sendTextMessage("info/mods:" + clientsManager.server.modsProvider.modsString)
this.flush()
return true

Expand All @@ -84,7 +83,7 @@ abstract class ClientConnection(val context: Server, internal val clientsManager
logger.info("$this asked to be sent mod $md5")

// Give him what he asked for.
val found = clientsManager.getServer().modsProvider.obtainModRedistribuable(md5)
val found = clientsManager.server.modsProvider.obtainModRedistribuable(md5)
if (found == null) {
logger.info("No such mod found.")
} else {
Expand All @@ -98,8 +97,8 @@ abstract class ClientConnection(val context: Server, internal val clientsManager
} else if (message.startsWith("world/")) {
// TODO this bit will obviously need to be rewritten when I get arround to doing
// multiworld support
val world = clientsManager.getServer().world
message = message.substring(6, message.length)
val world = clientsManager.server.world
val message = message.substring(6, message.length)

if (message == "enter") {
player.whenEnteringWorld(world)
Expand Down Expand Up @@ -142,12 +141,12 @@ abstract class ClientConnection(val context: Server, internal val clientsManager
args = chatMessage.substring(chatMessage.indexOf(" ") + 1, chatMessage.length).split(" ".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
}

clientsManager.getServer().console.dispatchCommand(player, cmdName, args)
clientsManager.server.console.dispatchCommand(player, cmdName, args)
return true
// The rest is just normal chat
} else if (chatMessage.length > 0) {
val event = PlayerChatEvent(player, chatMessage)
clientsManager.getServer().pluginManager.fireEvent(event)
clientsManager.server.pluginManager.fireEvent(event)

if (!event.isCancelled)
context.broadcastMessage(event.formattedMessage)
Expand Down Expand Up @@ -186,8 +185,8 @@ abstract class ClientConnection(val context: Server, internal val clientsManager

if (player != null) {
val playerDisconnectionEvent = PlayerLogoutEvent(player!!)
clientsManager.getServer().pluginManager.fireEvent(playerDisconnectionEvent)
clientsManager.getServer().broadcastMessage(playerDisconnectionEvent.logoutMessage!!)
clientsManager.server.pluginManager.fireEvent(playerDisconnectionEvent)
clientsManager.server.broadcastMessage(playerDisconnectionEvent.logoutMessage!!)

player!!.destroy()
}
Expand Down
Loading

0 comments on commit 4efee8a

Please sign in to comment.