Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/kotlin/dev/znci/rocket/Rocket.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import dev.znci.rocket.commands.RocketCommand
import dev.znci.rocket.i18n.LocaleManager
import dev.znci.rocket.scripting.AddonManager
import dev.znci.rocket.scripting.ScriptManager
import dev.znci.rocket.scripting.events.EventListener
import dev.znci.rocket.scripting.api.RocketAddon
import dev.znci.rocket.scripting.events.EventListener
import java.io.File

open class Rocket : RocketAddon() {
Expand Down
15 changes: 15 additions & 0 deletions src/main/kotlin/dev/znci/rocket/scripting/AddonManager.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* Copyright 2025 znci
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.znci.rocket.scripting

import dev.znci.rocket.scripting.api.RocketAddon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@
import dev.znci.twine.TwineTable
import dev.znci.twine.TwineValueBase
import org.bukkit.event.Event
import java.io.File
import org.luaj.vm2.Globals
import org.luaj.vm2.LuaError
import org.luaj.vm2.LuaValue
import org.luaj.vm2.lib.jse.JsePlatform
import java.util.ArrayList
import java.io.File

/**
* The `ScriptManager` object is responsible for managing Lua scripts, global values, and event handling in the plugin.
Expand Down Expand Up @@ -62,7 +61,7 @@
* A list of global values (properties and tables) that have been registered for Lua scripting.
* These globals are made available to Lua scripts during their execution.
*/
var enabledGlobals: MutableList<TwineValueBase> = mutableListOf()

Check notice on line 64 in src/main/kotlin/dev/znci/rocket/scripting/ScriptManager.kt

View workflow job for this annotation

GitHub Actions / qodana

Class member can have 'private' visibility

Property 'enabledGlobals' could be private

/**
* Sets the folder where scripts are located.
Expand Down
16 changes: 15 additions & 1 deletion src/main/kotlin/dev/znci/rocket/scripting/api/RocketAddon.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
/**
* Copyright 2025 znci
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.znci.rocket.scripting.api

import dev.znci.rocket.scripting.AddonManager
import dev.znci.rocket.scripting.ScriptManager
import dev.znci.rocket.scripting.annotations.Global
import dev.znci.twine.TwineValueBase
Expand All @@ -16,7 +30,7 @@
registerGlobals()
}

fun registerGlobals(): Int {

Check notice on line 33 in src/main/kotlin/dev/znci/rocket/scripting/api/RocketAddon.kt

View workflow job for this annotation

GitHub Actions / qodana

Class member can have 'private' visibility

Function 'registerGlobals' could be private
val classLoader = this::class.java.classLoader
val reflections = Reflections(
ConfigurationBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import org.bukkit.event.Event
import org.bukkit.event.EventPriority
import org.bukkit.event.Listener
import org.bukkit.plugin.Plugin
import org.luaj.vm2.LuaBoolean
import org.luaj.vm2.LuaTable
import org.luaj.vm2.LuaValue
import org.luaj.vm2.lib.ZeroArgFunction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@
import dev.znci.twine.TwineNative
import dev.znci.twine.annotations.TwineNativeFunction
import org.bukkit.Bukkit
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
import org.bukkit.command.CommandMap
import org.bukkit.command.CommandSender
import org.bukkit.command.TabCompleter
import org.bukkit.command.*
import org.bukkit.entity.Player
import org.luaj.vm2.LuaTable

Expand Down Expand Up @@ -150,7 +146,7 @@
@TwineNativeFunction
fun tabCompleter(callback: (sender: LuaPlayer, args: Array<String>) -> Any): LuaCommand {
commandReference.tabCompleter = TabCompleter { commandSender, _, _, commandArgs ->
val result = callback(LuaPlayer(commandSender as Player), commandArgs)

Check notice on line 149 in src/main/kotlin/dev/znci/rocket/scripting/globals/tables/Commands.kt

View workflow job for this annotation

GitHub Actions / qodana

Variable declaration could be moved inside 'when'

Variable declaration could be moved into 'when'
return@TabCompleter when (result) {
is LuaTable -> List(result.rawlen()) { i -> result.get(i + 1).tojstring() }
else -> emptyList()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* Copyright 2025 znci
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.znci.rocket.scripting.globals.tables

import dev.znci.rocket.scripting.annotations.Global
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import org.bukkit.GameMode
import org.bukkit.OfflinePlayer
import org.bukkit.entity.Player
import java.time.Duration
import java.util.UUID
import java.util.*

@Suppress("unused")
@Global
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* Copyright 2025 znci
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.znci.rocket.scripting.globals.tables

import dev.znci.rocket.Rocket
Expand Down Expand Up @@ -159,7 +174,4 @@ class LuaServer : TwineNative("server") {
@TwineNativeFunction
fun shutdown() = server.shutdown()

@TwineNativeFunction
fun restart() = server.restart()

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* Copyright 2025 znci
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.znci.rocket.scripting.globals.tables

import dev.znci.rocket.scripting.annotations.Global
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* Copyright 2025 znci
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.znci.rocket.scripting.globals.values

import dev.znci.twine.TwineProperty
Expand Down
15 changes: 15 additions & 0 deletions src/main/kotlin/dev/znci/rocket/util/MessageFormatter.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* Copyright 2025 znci
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dev.znci.rocket.util

import net.kyori.adventure.text.Component
Expand Down
Loading