
KeyboardListenerAPI
This plugin currently only acts as an API interface. Unless other plugins require this plugin as a dependency, the plugin itself will not perform any operations
About KeyboardListenerAPI
KeyboardListenerAPI is designed to simplify the listening method of the original key. Through a short registration statement, developers can easily listen what key the player presses. However, due to the limitations of the server, KBLAPI can only listen a few specific keys through the events associated with Bukkit keys.
If you are looking for an API that can listen the full keyboard, sorry, no plugin can currently implement this function, please look for Mod.
Import API to your project
Maven (pom.xml)
Code (Text):
<dependencies>
<dependency>
<groupId>io.github.hexsook</groupId>
<artifactId>kblapi-api</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
Gradle [Kotlin DSL] (build.gradle.kts)
Code (Text):
implementation("io.github.hexsook:kblapi-api:1.2")
Gradle [Groovy DSL] (build.gradle)
Code (Text):
implementation 'io.github.hexsook:kblapi-api:1.2'
API Usage
To register a key listener, you need to add following code to your plugin main class:
Code (Java):
package
your_package
;
import
io.github.hexsook.kblapi.api.Key
;
import
io.github.hexsook.kblapi.api.KeyboardListener
;
import
io.github.hexsook.kblapi.api.KeyboardListenerAPI
;
import
org.bukkit.entity.Player
;
import
org.bukkit.plugin.java.JavaPlugin
;
public
class YourPluginMain
extends JavaPlugin
{
@Override
public
void onEnable
(
)
{
KeyboardListenerAPI api
= KeyboardListenerAPI.
get
(
)
;
api.
addKeyListener
(
this,
Key.
Q,
new KeyboardListener
(
)
{
@Override
public
void pressed
(Player player
)
{
player.
sendMessage
(
"你按下了Q"
)
;
}
}
)
;
}
}
Supported keys:
Q,
F,
SHIFT,
SHIFT+Q,
SHIFT+F
NOTE: If a key is being listened to, the event that would have been associated with that key will be cancelled.
Get Support
If you like my plugin, please leave a 5-STAR rating.
If you encounter any problems using the plugin, please open an Issue on Github. Sending bugs in the reviews is not a good choice.