Skip to content

Commit

Permalink
Move event script list to settings.json
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewcell committed Aug 22, 2023
1 parent ed1d998 commit bffe5d5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions settings.json.sample
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"printReceivePacket": true,
"modifiedClient": true,
"autoRegister": true,
"events": ["Trains", "Boats", "Cabin", "elevator", "KerningPQ"],
"hashType": {
"hashType": "pbkdf2",
"shaType": "sha512",
Expand Down
1 change: 0 additions & 1 deletion src/main/kotlin/constants/ServerConstants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ class ServerConstants {
const val autoSaveInterval = 1800000
const val rankingInterval = 1800000
const val perfectPitch = true
const val events = "Trains Boats Cabin elevator KerningPQ"
}
}
3 changes: 1 addition & 2 deletions src/main/kotlin/net/server/channel/Channel.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package net.server.channel

import client.Character
import constants.ServerConstants
import io.netty.bootstrap.ServerBootstrap
import io.netty.channel.ChannelInitializer
import io.netty.channel.ChannelOption
Expand Down Expand Up @@ -44,7 +43,7 @@ class Channel(val world: Int, val channelId: Int) : KLoggable {
var event: Event? = null
var finishedShutdown = false
private val bootstrap = ServerBootstrap()
val eventSM = EventScriptManager(this, ServerConstants.events.split(" "))
val eventSM = EventScriptManager(this, settings.events)

init {
port = port + channelId - 1
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/scripting/event/EventScriptManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import javax.script.Invocable
import javax.script.ScriptContext.ENGINE_SCOPE
import javax.script.ScriptEngineManager

class EventScriptManager(channelServer: Channel, scripts: List<String>) : AbstractScriptManager() {
class EventScriptManager(channelServer: Channel, scripts: Array<String>) : AbstractScriptManager() {
data class EventEntry(val iv: Invocable, val em: EventManager)

val events = mutableMapOf<String, EventEntry>()
Expand Down
16 changes: 15 additions & 1 deletion src/main/kotlin/tools/settings/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ data class Settings(
val printReceivePacket: Boolean = false,
val modifiedClient: Boolean = false,
val autoRegister: Boolean = false,
val events: Array<String> = arrayOf(),
val hashType: HashType = HashType(),
val logging: LoggingOption = LoggingOption()
)
) {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

other as Settings

return events.contentEquals(other.events)
}

override fun hashCode(): Int {
return events.contentHashCode()
}
}

0 comments on commit bffe5d5

Please sign in to comment.