Skip to content

Commit 2ef5c91

Browse files
committed
a bunch of fixes
1 parent b720d36 commit 2ef5c91

File tree

6 files changed

+68
-60
lines changed

6 files changed

+68
-60
lines changed

commands.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ order: 98
44
---
55

66
# Commands
7-
List of commands provided by LuaLink.
7+
List of all commands and permissions provided by LuaLink.
88

99
| Command | Permission | Description |
1010
| -------------------------- | ------------------------------------------------------ |
11-
| `/lualink load <script>` | lualink.command.load | Loads specified Lua script. |
12-
| `/lualink unload <script>` | lualink.command.unload | Unloads specified Lua script. |
13-
| `/lualink reload <script>` | lualink.command.reload | Reloads specified Lua script. |
14-
| `/lualink list` | lualink.command.list | Lists all loaded Lua scripts. |
11+
| `/lualink load (script)` | lualink.command.load | Loads specified Lua script. |
12+
| `/lualink unload (script)` | lualink.command.unload | Unloads specified Lua script. |
13+
| `/lualink reload (script)` | lualink.command.reload | Reloads specified Lua script. |
14+
| `/lualink list` | lualink.command.list | Lists all loaded Lua scripts. |
15+
16+
Please be cautious and give access to these commands only to people you trust.

dependencies.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
icon: package-dependencies
3-
order: 98
3+
order: 97
44
---
55

66
# Dependencies
7+
TO-DO

getting-started.md

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Basic **Lua** knowledge is an obvious prerequisite, but it should be relatively
2121
| ------------------------------------------------------------ |
2222
| [1. Creating Scripts](#creating-scripts) |
2323
| [2. Script Life-cycle](#script-life-cycle) |
24-
| [3. Importing](#importing) |
24+
| [3. Importing and Requiring](#importing-and-requiring) |
2525
| [4. Constructors and Instances](#constructors-and-instances) |
2626
| [5. Commands](#commands) |
2727
| [6. Events](#events) |
@@ -31,12 +31,12 @@ Basic **Lua** knowledge is an obvious prerequisite, but it should be relatively
3131

3232
### Creating Scripts
3333
There are a couple of things to keep in mind when using LuaLink.
34-
- Each script is stored in a separate folder inside the `plugins/LuaLink/scripts` directory, and libraries are stored in the `plugins/LuaLink/libs` directory.
35-
<sup>More about libraries can be found on the **[Libraries](libraries.md)** page.</sup>
36-
- Entry point of the script (or library) is a file named `main.lua` or `init.lua`.
37-
<sup>It doesn't matter which file you choose as the entry point, but you should be consistent with your naming convention.</sup>
3834
- Script life-cycle can be managed using `/lualink load`, `/lualink unload` and `/lualink reload` commands.
3935
<sup>More on this can be found on the **[Commands](commands.md)** page.</sup>
36+
- Each script is stored in a separate folder inside the `plugins/LuaLink/scripts` directory, and libraries are stored in the `plugins/LuaLink/libs` directory.
37+
<sup>More about libraries can be found on the **[Libraries](libraries.md)** page.</sup>
38+
- Entry point of the script (or library) is a file named `main.lua`.
39+
<sup>More files can be created and loaded using the `require` keyword.</sup>
4040

4141
<br />
4242

@@ -45,12 +45,12 @@ Scripts are automatically loaded after server has been fully started. They can a
4545
```lua
4646
-- Called after the script has been successfully loaded.
4747
script:onLoad(function()
48-
script:logger:info("Script has been loaded.")
48+
script.logger:info("Script has been loaded.")
4949
end)
5050

5151
-- Called before the script is attempted to be unloaded.
5252
script:onUnload(function()
53-
script:logger:info("Script is about to be unloaded.")
53+
script.logger:info("Script is about to be unloaded.")
5454
end)
5555
```
5656

@@ -81,17 +81,18 @@ script:onLoad(function()
8181
counter:increment()
8282
counter:increment()
8383
-- Printing current value of the counter to the console.
84-
script.logger.info(counter:get() ..
84+
script.logger:info(counter:get() .. " is the current value of the counter.")
85+
end)
8586
```
8687

8788
<br />
8889

8990
### Constructors and Instances
9091
New instances of Java classes can be created as follows.
9192
```lua
92-
local Bukkit = import "org.bukkit.Bukkit"
93-
local Keyed = import "net.kyori.adventure.key.Keyed"
94-
local NamespacedKey = import "org.bukkit.NamespacedKey"
93+
local Bukkit = import("org.bukkit.Bukkit")
94+
local Keyed = import("net.kyori.adventure.key.Keyed")
95+
local NamespacedKey = import("org.bukkit.NamespacedKey")
9596

9697
script.onLoad(function()
9798
-- Creating new instance of NamespacedKey class.
@@ -101,7 +102,7 @@ script.onLoad(function()
101102
-- Checking if World is instance of Keyed. (SPOILER: IT IS)
102103
if (Keyed.class:isInstance(world) == true) then
103104
-- Sending loaded chunks count to the console.
104-
script.logger.info("World " .. world:key():asString() .. " has " .. world:getChunkCount() .. " chunks loaded.")
105+
script.logger:info("World " .. world:key():asString() .. " has " .. world:getChunkCount() .. " chunks loaded.")
105106
end
106107
end)
107108
```
@@ -111,7 +112,7 @@ end)
111112
### Commands
112113
Non-complex commands can be created with little effort using built-in API.
113114
```lua
114-
local Bukkit = import "org.bukkit.Bukkit"
115+
local Bukkit = import("org.bukkit.Bukkit")
115116

116117
-- Function to handle command tab-completion.
117118
function onTabComplete(sender, alias, args)
@@ -157,28 +158,28 @@ end)
157158
### Scheduler
158159
Scheduler can be used to register single-use, delayed or repeating tasks.
159160
```lua
160-
-- Schedules task to be run on the next tick.
161-
script.run(function()
161+
-- Schedules a task to be run on the next tick.
162+
scheduler:run(function()
162163
-- Whatever belongs to the task goes here.
163164
end)
164165

165-
-- Schedules task to be run after 20 ticks has passed. Task function parameter can be omitted if not used.
166-
script.runDelayed(function(task)
166+
-- Schedules a task to be run after 20 ticks has passed.
167+
scheduler:runLater(function()
167168
-- Whatever belongs to the task goes here.
168169
end, 20)
169170

170-
-- Schedules task to be run after 20 ticks has passed, and repeated every 160 ticks. Task function parameter can be omitted if not used.
171-
script.runRepeating(function(task)
171+
-- Schedules a task to be run after 20 ticks has passed, and repeated every 160 ticks.
172+
scheduler:runRepeating(function()
172173
-- Whatever belongs to the task goes here.
173174
end, 20, 160)
174175
```
175176

176177
Tasks can also be run asynchronously, but please note that neither the Bukkit API nor the LuaLink API is guaranteed to be thread-safe.
177178
```lua
178179
-- Schedules asynchronous task to be run on the next tick.
179-
script.runAsync(callback: () -> void): void
180-
-- Schedules asynchronous task to be run after {delay} ticks has passed. Task function parameter can be omitted if not used.
181-
script.runDelayedAsync(callback: (task: BukkitTask) -> void, delay: number): BukkitTask
182-
-- Schedules task to be run after {delay} ticks has passed, and repeated every {period} ticks. Task function parameter can be omitted if not used.
183-
script.runRepeatingAsync(callback: (task: BukkitTask) -> void, delay: number, period: number): BukkitTask
180+
scheduler:runAsync(handler: () -> void): BukkitTask
181+
-- Schedules asynchronous task to be run after {delay} ticks has passed.
182+
scheduler:runLaterAsync(handler: () -> void, delay: number): BukkitTask
183+
-- Schedules task to be run after {delay} ticks has passed, and repeated every {period} ticks.
184+
scheduler:runRepeatingAsync(handler: () -> void, delay: number, period: number): BukkitTask
184185
```

index.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ This documentation page is still a work in progress and may contain outdated inf
88
!!!
99

1010
# LuaLink v2
11-
LuaLink is an experimental plugin that provides a basic Lua scripting runtime for Paper-based Minecraft servers. It is designed for small and simple tasks and serves as an alternative to Skript and other scripting plugins.
11+
**LuaLink** is an experimental plugin that provides a basic Lua scripting runtime for **Paper-based** Minecraft servers. It is designed for small and simple tasks and serves as a much more powerful alternative to **Skript** and other scripting plugins.
1212

13-
Scripting runtime is based on [LuaJava](https://github.com/gudzpoz/luajava) with [LuaJIT](https://github.com/LuaJIT/LuaJIT). For more details on implementation specifics or differences, please refer to their respective documentation.
13+
Scripting runtime is based on **[LuaJava](https://github.com/gudzpoz/luajava)** with **[LuaJIT](https://github.com/LuaJIT/LuaJIT)**. For more details on implementation specifics or differences, please refer to their respective documentation.
1414

1515
<br />
1616

@@ -41,26 +41,26 @@ Plugin can be downloaded from following sources:
4141
## Quick Start
4242
After you have installed the plugin, you can start writing your first script.
4343

44-
- Each script is stored in a separate folder inside the `plugins/LuaLink/scripts` directory.
45-
- Entry point of the script is a file named `main.lua` or `init.lua`.
4644
- Script life-cycle can be managed using `/lualink load`, `/lualink unload` and `/lualink reload` commands.
45+
- Each script is stored in a separate folder inside the `plugins/LuaLink/scripts` directory.
46+
- Entry point of the script is a file named `main.lua`.
4747

48-
```lua plugins/LuaLink/scripts/my_script/init.lua
49-
local Bukkit = import "org.bukkit.Bukkit"
48+
```lua plugins/LuaLink/scripts/my_script/main.lua
49+
local Bukkit = import("org.bukkit.Bukkit")
5050

5151
-- Called after the script has been successfully loaded.
5252
script:onLoad(function()
5353
-- Logging message to the console.
54-
script:logger:info("Hello, World!")
54+
script.logger:info("Hello, World!")
5555
end)
5656

5757
```
5858
It's quite simple, isn't it? For this particular case, we can simplify it even further by extracting the logic away from the `onLoad` block.
5959

60-
```lua plugins/LuaLink/scripts/my_script/init.lua
61-
local Bukkit = import "org.bukkit.Bukkit"
60+
```lua plugins/LuaLink/scripts/my_script/main.lua
61+
local Bukkit = import("org.bukkit.Bukkit")
6262

6363
-- Logging message to the console.
64-
script:logger:info("Hello, World!")
64+
script.logger:info("Hello, World!")
6565
```
6666
Want to do something more complex? More information on how to write scripts can be found on the **[Getting Started](getting-started.md)** page.

libraries.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
icon: package-dependents
3-
order: 97
3+
order: 96
44
---
55

66
# Libraries
@@ -9,10 +9,10 @@ LuaLink provides a way to load external **Java** libraries for use in your scrip
99
<br />
1010

1111
## Lua Libraries
12-
External Lua libraries can be added by copying files to the `/plugins/LuaLink/libs/` folder.
12+
External Lua libraries can be added by creating or copying files to the `/plugins/LuaLink/libs/` folder.
1313

1414
==- Example Lua Library
15-
```lua **/plugins/LuaLink/libs/example_library/init.lua**
15+
```lua **/plugins/LuaLink/libs/example_library/main.lua**
1616
local Counter = {}
1717
Counter.__index = Counter
1818

@@ -46,18 +46,18 @@ This is an example of a Counter class that allows you to increment, decrement, a
4646

4747
Now, if you want to use this class in your script, you can import it using the `require` keyword.
4848

49-
```lua /plugins/LuaLink/scripts/example_script/init.lua
49+
```lua /plugins/LuaLink/scripts/example_script/main.lua
5050
local Counter = require("example_library")
5151

5252
script:onLoad(function()
5353
-- Creating a new instance of the Counter class.
54-
local counter = Counter.new()
54+
local counter = Counter()
5555
-- Incrementing the counter three times.
5656
counter:increment()
5757
counter:increment()
5858
counter:increment()
5959
-- Printing current value of the counter to the console.
60-
script.logger.info(counter:get() .. " is the current value of the counter.")
60+
script.logger:info(counter:get() .. " is the current value of the counter.")
6161
end)
6262
```
6363

@@ -88,7 +88,7 @@ External Java/Kotlin libraries can be added by configuring the `/plugins/LuaLink
8888
}
8989
```
9090

91-
In this example, we are adding stefvanschie's [IF](https://github.com/stefvanschie/IF) library of version `0.10.11` from [Maven Central](https://repo.maven.apache.org/maven2/) repository. You can also see how to add and authenticate with a private repository using credentials, which might be essential when working with closed-source projects or [GitHub Packages](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry).
91+
In this example, we are adding stefvanschie's [IF](https://github.com/stefvanschie/IF) library of version `0.10.11` from [Maven Central](https://repo.maven.apache.org/maven2/) repository. You can also see how and authenticate with a private repository using credentials, which might be essential when working with closed-source projects or [GitHub Packages](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry).
9292

9393
After restarting the server, we should be able to import and access any class that belongs to specified library(-ies).
9494

reference.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
icon: code
3-
order: 96
3+
order: 95
44
---
55

66
# Reference
@@ -10,32 +10,36 @@ Provides methods to schedule and manage tasks. It supports both synchronous and
1010

1111
```lua
1212
--- Schedules a task to run on the next tick.
13-
-- @param callback The task function to execute
14-
scheduler:run(callback: () -> void): void
13+
-- @param handler The task function to execute
14+
scheduler:run(handler: () -> void): BukkitTask
1515

1616
--- Schedules an asynchronous task to run on the next tick.
17-
-- @param callback The task function to execute
18-
scheduler:runAsync(callback: () -> void): void
17+
-- @param handler The task function to execute
18+
scheduler:runAsync(handler: () -> void): BukkitTask
1919

2020
--- Schedules a task to run after a delay (in ticks).
21-
-- @param callback The task function to execute
21+
-- @param handler The task function to execute
2222
-- @param delay Delay in ticks before execution
23-
scheduler:runDelayed(callback: (task: BukkitTask) -> void, delay: number): BukkitTask
23+
scheduler:runLater(handler: () -> void, delay: number): BukkitTask
2424

2525
--- Schedules an asynchronous task to run after a delay (in ticks).
26-
-- @param callback The task function to execute
26+
-- @param handler The task function to execute
2727
-- @param delay Delay in ticks before execution
28-
scheduler:runDelayedAsync(callback: (task: BukkitTask) -> void, delay: number): BukkitTask
28+
scheduler:runLaterAsync(handler: () -> void, delay: number): BukkitTask
2929

3030
--- Schedules a repeating task.
31-
-- @param callback The task function to execute
31+
-- @param handler The task function to execute
3232
-- @param delay Delay in ticks before first execution
3333
-- @param period Interval in ticks between executions
34-
scheduler:runRepeating(callback: (task: BukkitTask) -> void, delay: number, period: number): BukkitTask
34+
scheduler:runRepeating(handler: () -> void, delay: number, period: number): BukkitTask
3535

3636
--- Schedules an asynchronous repeating task.
37-
-- @param callback The task function to execute
37+
-- @param handler The task function to execute
3838
-- @param delay Delay in ticks before first execution
3939
-- @param period Interval in ticks between executions
40-
scheduler:runRepeatingAsync(callback: (task: BukkitTask) -> void, delay: number, period: number): BukkitTask
40+
scheduler:runRepeatingAsync(handler: () -> void, delay: number, period: number): BukkitTask
41+
42+
--- Cancels a task with the specified identifier.
43+
-- @param task The task to cancel
44+
scheduler:cancel(task: number): void
4145
```

0 commit comments

Comments
 (0)