-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix&feat: 添加更多Lua类型与Java类型转换方法,添加网络请求方法
- Loading branch information
Showing
17 changed files
with
948 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
|
||
### getClass | ||
+ **Description**: 通过全类名去获取java类类型. | ||
+ **Return Type**: **Class<?>** | ||
+ **Return Desc**: 如果类存在则返回对应的类 | ||
+ **Usage**: `getClass(name:String)` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|name|**String**|全类名| | ||
### toIntArray | ||
+ **Description**: 将Lua中只含整形的表转换为java中的整形数组. | ||
+ **Return Type**: **int[]** | ||
+ **Return Desc**: 转换成Java中的整形数组. | ||
+ **Usage**: `toIntArray(table:LuaObject)` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|table|**LuaObject**|只含整形的表(数组).| | ||
### toIntArray | ||
+ **Description**: 将Lua中只含整形的表转换为java中的整形数组. | ||
+ **Return Type**: **int[]** | ||
+ **Return Desc**: 转换成Java中的整形数组. | ||
+ **Usage**: `toIntArray(table:LuaTable)` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|table|**LuaTable**|只含整形的表(数组).| | ||
### toDoubleArray | ||
+ **Description**: 将Lua中只含浮点数的表转换为java中的double类型数组. | ||
+ **Return Type**: **double[]** | ||
+ **Return Desc**: 转换成Java中的double类型数组. | ||
+ **Usage**: `toDoubleArray(table:LuaObject)` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|table|**LuaObject**|只含小数的表(数组).| | ||
### toDoubleArray | ||
+ **Description**: 将Lua中只含浮点数的表转换为java中的double类型数组. | ||
+ **Return Type**: **double[]** | ||
+ **Return Desc**: 转换成Java中的double类型数组. | ||
+ **Usage**: `toDoubleArray(table:LuaTable)` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|table|**LuaTable**|只含小数的表(数组).| | ||
### toFloatArray | ||
+ **Description**: 将Lua中只含浮点数的表转换为java中的float类型数组. | ||
+ **Return Type**: **float[]** | ||
+ **Return Desc**: 转换成Java中的float类型数组. | ||
+ **Usage**: `toFloatArray(table:LuaObject)` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|table|**LuaObject**|只含小数的表(数组).| | ||
### toFloatArray | ||
+ **Description**: 将Lua中只含浮点数的表转换为java中的float类型数组. | ||
+ **Return Type**: **float[]** | ||
+ **Return Desc**: 转换成Java中的float类型数组. | ||
+ **Usage**: `toFloatArray(table:LuaTable)` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|table|**LuaTable**|只含小数的表(数组).| | ||
### toStringArray | ||
+ **Description**: 将Lua中只含字符串的表转换为java中的String类型数组. | ||
+ **Return Type**: **String[]** | ||
+ **Return Desc**: 转换成Java中的String类型数组. | ||
+ **Usage**: `toStringArray(table:LuaObject)` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|table|**LuaObject**|只含字符串的表(数组).| | ||
### toStringArray | ||
+ **Description**: 将Lua中只含字符串的表转换为java中的String类型数组. | ||
+ **Return Type**: **String[]** | ||
+ **Return Desc**: 转换成Java中的String类型数组. | ||
+ **Usage**: `toStringArray(table:LuaTable)` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|table|**LuaTable**|只含字符串的表(数组).| | ||
### toArray | ||
+ **Description**: 将Lua中只含指定类型的表转换为java中的指定类型数组. | ||
+ **Return Type**: **T[]** | ||
+ **Return Desc**: 转换成Java中的指定类型数组. | ||
+ **Usage**: `toArray(t:T, table:LuaObject)` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|t|**T**|需要转换成的Java类型实例.| | ||
|table|**LuaObject**|只含指定类型的表(数组).| | ||
### toArray | ||
+ **Description**: 将Lua中只含指定类型的表转换为java中的指定类型数组. | ||
+ **Return Type**: **T[]** | ||
+ **Return Desc**: 转换成Java中的指定类型数组. | ||
+ **Usage**: `toArray(t:T, table:LuaTable)` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|t|**T**|需要转换成的Java类型实例.| | ||
|table|**LuaTable**|只含指定类型的表(数组).| | ||
### toObjectArray | ||
+ **Description**: 将Lua中的表(数组)转换为java中的Object类型数组. | ||
+ **Return Type**: **Object[]** | ||
+ **Return Desc**: @return | ||
+ **Usage**: `toObjectArray(table:LuaObject)` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|table|**LuaObject**|表(数组)| | ||
### toObjectArray | ||
+ **Description**: 将Lua中的表(数组)转换为java中的Object类型数组. | ||
+ **Return Type**: **Object[]** | ||
+ **Return Desc**: @return | ||
+ **Usage**: `toObjectArray(table:LuaTable)` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|table|**LuaTable**|表(数组)| | ||
### toStringStringMap | ||
+ **Description**: 将Lua中的只包含字符串的数组(下标为数字且未显式指定数字下标的Table)(如{"a", "b"}而非{2 = "b"})转换为Java中的Map类型. | ||
+ **Return Type**: **String>** | ||
+ **Return Desc**: Map<String, String>类型HashMap. | ||
+ **Usage**: `toStringStringMap(table:LuaObject)` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|table|**LuaObject**|Lua中的表| | ||
### toStringStringMap | ||
+ **Description**: 将Lua中的只包含字符串的数组(下标为数字且未显式指定数字下标的Table)(如{"a", "b"}而非{2 = "b"})转换为Java中的Map类型. | ||
+ **Return Type**: **String>** | ||
+ **Return Desc**: Map<String, String>类型HashMap. | ||
+ **Usage**: `toStringStringMap(table:LuaTable)` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|table|**LuaTable**|Lua中的表| | ||
### toObjectObjectMap | ||
+ **Description**: 将Lua中的数组(下标为数字且未显式指定数字下标的Table)(如{"a", "b"}而非{2 = "b"})转换为Java中的Map类型. | ||
+ **Return Type**: **Object>** | ||
+ **Return Desc**: Map<Object, Object>类型HashMap. | ||
+ **Usage**: `toObjectObjectMap(table:LuaObject)` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|table|**LuaObject**|Lua中的表| | ||
### toObjectObjectMap | ||
+ **Description**: 将Lua中的数组(下标为数字且未显式指定数字下标的Table)(如{"a", "b"}而非{2 = "b"})转换为Java中的Map类型. | ||
+ **Return Type**: **Object>** | ||
+ **Return Desc**: Map<Object, Object>类型HashMap. | ||
+ **Usage**: `toObjectObjectMap(table:LuaTable)` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|table|**LuaTable**|Lua中的表| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,136 @@ | ||
|
||
### luaBukkit.helper:isLoadPlugin | ||
### isLoadPlugin | ||
+ **Description**: 指定脚本插件是否加载. | ||
+ **Return Type**: **boolean** | ||
+ **Return Desc**: 如果已经加载则返回true. | ||
+ **Usage**: `luaBukkit.helper:isLoadPlugin(id:String)` | ||
+ **Usage**: `isLoadPlugin(id:String)` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|id|**String**|脚本插件id| | ||
### luaBukkit.helper:newLuaRunnable | ||
### newLuaRunnable | ||
+ **Description**: 以指定id对应的函数为run方法主体创建一个Runnable子类实例 | ||
+ **Return Type**: **LuaRunnable** | ||
+ **Return Desc**: LuaRunnable实例 | ||
+ **Usage**: `luaBukkit.helper:newLuaRunnable(id:String)` | ||
+ **Usage**: `newLuaRunnable(id:String)` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|id|**String**|函数路径| | ||
### luaBukkit.helper:newLuaRunnable | ||
### newLuaRunnable | ||
+ **Description**: 以指定id对应的函数为run方法主体创建一个Runnable子类实例 | ||
+ **Return Type**: **LuaRunnable** | ||
+ **Return Desc**: LuaRunnable实例 | ||
+ **Usage**: `luaBukkit.helper:newLuaRunnable(id:String, obj:Object)` | ||
+ **Usage**: `newLuaRunnable(id:String, obj:Object)` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|id|**String**|函数路径| | ||
|obj|**Object**|带入的参数.| | ||
### luaBukkit.helper:getPlugin | ||
### getPlugin | ||
+ **Description**: 获取本插件实例对象. | ||
+ **Return Type**: **Plugin** | ||
+ **Return Desc**: 本插件的实例对象. | ||
+ **Usage**: `luaBukkit.helper:getPlugin()` | ||
+ **Usage**: `getPlugin()` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|
||
### luaBukkit.helper:getClass | ||
+ **Description**: 通过全类名去获取java类类型. | ||
+ **Return Type**: **Class<?>** | ||
+ **Return Desc**: 如果类存在则返回对应的类 | ||
+ **Usage**: `luaBukkit.helper:getClass(name:String)` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|name|**String**|全类名| | ||
### luaBukkit.helper:isNativeMode | ||
### isNativeMode | ||
+ **Description**: 插件是否在Native模式下运行. | ||
+ **Return Type**: **boolean** | ||
+ **Return Desc**: 如果是在Native模式下运行则返回true. | ||
+ **Usage**: `luaBukkit.helper:isNativeMode()` | ||
+ **Usage**: `isNativeMode()` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|
||
### httpAction | ||
+ **Description**: 以插件身份发送一个HTTP请求. | ||
+ **Return Type**: **void** | ||
+ **Return Desc**: | ||
+ **Usage**: `httpAction(plugin:LuaPlugin, urlString:String, body:byte[], preOperation:Object, callback:Object, errorCallback:Object)` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|plugin|**LuaPlugin**|Lua插件实例.| | ||
|urlString|**String**|链接字符串| | ||
|body|**byte[]**|请求体,如果传入null则代表不需要请求体.| | ||
|preOperation|**Object**|前置操作Lua函数闭包,将会传入一个HttpURLConnection实例给闭包.| | ||
|callback|**Object**|一个Lua函数闭包,会将ResponseCode以及HTTP请求的文本结果作为字符串传递给闭包.| | ||
|errorCallback|**Object**|一个Lua函数闭包,其只在运行过程中出现错误时调用,会将Exception实例传给闭包.| | ||
### httpAction | ||
+ **Description**: 以插件身份发送一个HTTP请求. | ||
+ **Return Type**: **void** | ||
+ **Return Desc**: | ||
+ **Usage**: `httpAction(plugin:LuaPlugin, urlString:String, method:String, body:byte[], connectTimeout:int, readTimeout:int, instanceFollowRedirects:boolean, Map<String:, header:String>, useCaches:boolean, callback:Object, errorCallback:Object)` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|plugin|**LuaPlugin**|Lua插件实例.| | ||
|urlString|**String**|链接字符串| | ||
|method|**String**|请求方法| | ||
|body|**byte[]**|请求体,如果传入null则代表不需要请求体.| | ||
|connectTimeout|**int**|连接等待时间(毫秒).| | ||
|readTimeout|**int**|读取等待时间(毫秒).| | ||
|instanceFollowRedirects|**boolean**|是否跟随重定向.| | ||
|Map<String|****|null| | ||
|header|**String>**|需要添加的请求头,为null则代表不需要添加.| | ||
|useCaches|**boolean**|是否使用缓存.| | ||
|callback|**Object**|一个Lua函数闭包,会将ResponseCode以及HTTP请求的文本结果作为字符串传递给闭包.| | ||
|errorCallback|**Object**|一个Lua函数闭包,其只在运行过程中出现错误时调用,会将Exception实例传给闭包.| | ||
### httpAction | ||
+ **Description**: 以插件身份发送一个HTTP请求. | ||
+ **Return Type**: **void** | ||
+ **Return Desc**: | ||
+ **Usage**: `httpAction(plugin:LuaPlugin, urlString:String, method:String, body:String, bodyEncode:String, connectTimeout:int, readTimeout:int, instanceFollowRedirects:boolean, Map<String:, header:String>, useCaches:boolean, callback:Object, errorCallback:Object)` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|plugin|**LuaPlugin**|Lua插件实例.| | ||
|urlString|**String**|链接字符串| | ||
|method|**String**|请求方法| | ||
|body|**String**|字符串请求体,如果传入null则代表不需要请求体.| | ||
|bodyEncode|**String**|字符串请求体编码格式.| | ||
|connectTimeout|**int**|连接等待时间(毫秒).| | ||
|readTimeout|**int**|读取等待时间(毫秒).| | ||
|instanceFollowRedirects|**boolean**|是否跟随重定向.| | ||
|Map<String|****|null| | ||
|header|**String>**|需要添加的请求头,为null则代表不需要添加.| | ||
|useCaches|**boolean**|是否使用缓存.| | ||
|callback|**Object**|一个Lua函数闭包,会将ResponseCode以及HTTP请求的文本结果作为字符串传递给闭包.| | ||
|errorCallback|**Object**|一个Lua函数闭包,其只在运行过程中出现错误时调用,会将Exception实例传给闭包.| | ||
### httpGet | ||
+ **Description**: 以插件身份发送一个HTTP的GET请求. | ||
+ **Return Type**: **void** | ||
+ **Return Desc**: | ||
+ **Usage**: `httpGet(plugin:LuaPlugin, urlString:String, connectTimeout:int, readTimeout:int, instanceFollowRedirects:boolean, Map<String:, header:String>, useCaches:boolean, callback:Object, errorCallback:Object)` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|plugin|**LuaPlugin**|Lua插件实例.| | ||
|urlString|**String**|链接字符串| | ||
|connectTimeout|**int**|连接等待时间(毫秒).| | ||
|readTimeout|**int**|读取等待时间(毫秒).| | ||
|instanceFollowRedirects|**boolean**|是否跟随重定向.| | ||
|Map<String|****|null| | ||
|header|**String>**|需要添加的请求头,为null则代表不需要添加.| | ||
|useCaches|**boolean**|是否使用缓存.| | ||
|callback|**Object**|一个Lua函数闭包,会将ResponseCode以及HTTP请求的文本结果作为字符串传递给闭包.| | ||
|errorCallback|**Object**|一个Lua函数闭包,其只在运行过程中出现错误时调用,会将Exception实例传给闭包.| | ||
### httpGet | ||
+ **Description**: 以插件身份发送一个HTTP的GET请求. | ||
+ **Return Type**: **void** | ||
+ **Return Desc**: | ||
+ **Usage**: `httpGet(plugin:LuaPlugin, urlString:String, connectTimeout:int, readTimeout:int, instanceFollowRedirects:boolean, useCaches:boolean, callback:Object, errorCallback:Object)` | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|plugin|**LuaPlugin**|Lua插件实例.| | ||
|urlString|**String**|链接字符串| | ||
|connectTimeout|**int**|连接等待时间(毫秒).| | ||
|readTimeout|**int**|读取等待时间(毫秒).| | ||
|instanceFollowRedirects|**boolean**|是否跟随重定向.| | ||
|useCaches|**boolean**|是否使用缓存.| | ||
|callback|**Object**|一个Lua函数闭包,会将ResponseCode以及HTTP请求的文本结果作为字符串传递给闭包.| | ||
|errorCallback|**Object**|一个Lua函数闭包,其只在运行过程中出现错误时调用,会将Exception实例传给闭包.| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module LuaInMinecraftBukkit.main { | ||
requires java.base; | ||
requires org.luaj; | ||
requires org.bukkit; | ||
requires java.logging; | ||
requires java.net.http; | ||
|
||
opens org.keplerproject.luajava to java.base; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.