-
Notifications
You must be signed in to change notification settings - Fork 0
Developers
Anarchick edited this page Oct 24, 2024
·
4 revisions
Using ServerKeyboardBridge is very easy !
Download the plugin and put it to your libs folder.
dependencies {
compileOnly fileTree(include: ['*.jar'], dir: 'libs')
}softdepend: ['ServerKeyboardBridge'] // In your main class
@Override
public void onEnable() {
if (Bukkit.getPluginManager().isPluginEnabled("ServerKeyboardBridge")) {
// keyCode can be found here : https://www.glfw.org/docs/latest/group__keys.html and https://www.glfw.org/docs/latest/group__buttons.html
// Do not use null value, use empty string instead.
// name and category can't be blank
ServerKeyboardBridge.getInstance().registerKey(new KeyEntry(new NamespacedKey(plugin, id), name, description, category, defaultKeyCode));
}
} @EventHandler
public void skbJoinEvent(SkbJoinEventevent) {
Player player = event.getPlayer();
String version = event.getVersion();
}
// KeyPressedEvent, KeyReleasedEvent or KeyEvent for both
@EventHandler
public void keyPressed(KeyPressedEvent event) {
Player player = event.getPlayer();
NamespacedKey namespacedKey = event.getKey();
boolean isPressed = event.isPressed();
boolean isInGui = event.isInGUI();
}Q. Can I use translatable text ? A. Yes! Available for name, description and category
[CLIENT] connect to the server
sent packet HANDSHAKE containing his client mod version
[SERVER] if config option "IfNoModDetected.kickPlayer" is true:
kick player
else if received HANDSHAKE packet:
call BridgeJoinEvent
if client mod version is not supported by the plugin:
sent a message to client about not supported mod version
else:
sent all custom keys datas in a single packet
[CLIENT] if receive the custom keys data from packet:
register each custom keys
load configured keys from cache file
make the key binding button in game menu visible
when client press custom key:
sent a packet containing custom key id, is key pressed ? and is in gui ?
[SERVER] everytime received custom key packet:
call KeyPressedEvent or KeyReleaseEvent
[...]
[CLIENT] disconnect from server
unregister custom keys
hide the key binding button in game menu