@@ -52,7 +52,8 @@ class LuaManager() {
5252 " libs/" ,
5353 " lib/" ,
5454 configDir.resolve(" hypixelcry/scripts/libs/" ).toString() + " /" ,
55- configDir.resolve(" hypixelcry/scripts/lib/" ).toString() + " /"
55+ configDir.resolve(" hypixelcry/scripts/lib/" ).toString() + " /" ,
56+ configDir.resolve(" hypixelcry/scripts/" ).toString() + " /"
5657 )
5758
5859 private val moduleSearchPaths = CopyOnWriteArrayList <String >().apply {
@@ -206,17 +207,6 @@ class LuaManager() {
206207 return file
207208 }
208209 }
209-
210- // Check module/init.* structure
211- val moduleDir = File (" $path$baseName /" )
212- if (moduleDir.exists() && moduleDir.isDirectory) {
213- for (ext in luaExtensions) {
214- val initFile = File (moduleDir, " init$ext " )
215- if (initFile.exists() && initFile.isFile) {
216- return initFile
217- }
218- }
219- }
220210 }
221211 return null
222212 }
@@ -225,17 +215,15 @@ class LuaManager() {
225215 fun addClientTickCallback (callback : LuaValue ): Boolean {
226216 if (! callback.isfunction()) return false
227217 synchronized(callbacksLock) {
228- clientTickCallbacks.add(callback)
218+ return clientTickCallbacks.add(callback)
229219 }
230- return true
231220 }
232221
233222 fun addWorldRendererCallback (callback : LuaValue ): Boolean {
234223 if (! callback.isfunction()) return false
235224 synchronized(callbacksLock) {
236- renderWorldCallbacks.add(callback)
225+ return renderWorldCallbacks.add(callback)
237226 }
238- return false
239227 }
240228
241229 fun addKeyEventCallback (callback : LuaValue ): Boolean {
@@ -252,18 +240,24 @@ class LuaManager() {
252240 }
253241 }
254242 fun removeWorldRendererCallback (callback : LuaValue ): Boolean {
255- return renderWorldCallbacks.remove(callback)
243+ synchronized(callbacksLock) {
244+ return renderWorldCallbacks.remove(callback)
245+ }
256246 }
257247
258248 fun removeKeyEventCallback (callback : LuaValue ): Boolean {
259- return keyEventCallbacks.remove(callback)
249+ synchronized(callbacksLock) {
250+ return keyEventCallbacks.remove(callback)
251+ }
260252 }
261253
262254 // Methods to clear all callbacks
263255 fun clearAllCallbacks () {
264- clientTickCallbacks.clear()
265- renderWorldCallbacks.clear()
266- keyEventCallbacks.clear()
256+ synchronized(callbacksLock) {
257+ clientTickCallbacks.clear()
258+ renderWorldCallbacks.clear()
259+ keyEventCallbacks.clear()
260+ }
267261 }
268262
269263 // Callback methods
@@ -311,20 +305,6 @@ class LuaManager() {
311305 }
312306 }
313307
314- fun addModuleSearchPath (path : String ) {
315- val normalizedPath = if (path.endsWith(" /" )) path else " $path /"
316- moduleSearchPaths.add(normalizedPath)
317- }
318-
319- fun removeModuleSearchPath (path : String ) {
320- val normalizedPath = if (path.endsWith(" /" )) path else " $path /"
321- moduleSearchPaths.remove(normalizedPath)
322- }
323-
324- fun getModuleSearchPaths (): List <String > {
325- return moduleSearchPaths.toList()
326- }
327-
328308 fun executeScript (file : File ): Any {
329309 if (! file.exists() || ! file.isFile) {
330310 throw FileNotFoundException (" Script file not found: ${file.path} " )
@@ -416,7 +396,7 @@ class LuaManager() {
416396 return scriptCallbacks.keys.toList()
417397 }
418398
419- public fun restoreGlobals () {
399+ fun restoreGlobals () {
420400 persistentGlobals.forEach { (name, value) ->
421401 globals.set(name, value)
422402 }
0 commit comments