mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 19:15:11 +00:00
Added the repeatKey field to KeyEvent, distinguishing whether the event was triggered by the key being held down or the first press.
This commit is contained in:
1 parent
4c0ff9bf2e
commit
5c9424bac8
4 files changed
+13
-9
No files matched your search
@@ -68,19 +68,20 @@ public class ClientTickHandler{
|
||||
boolean isShiftPressed = Keyboard.isKeyDown(54) || Keyboard.isKeyDown(42);
|
||||
boolean isAltPressed = Keyboard.isKeyDown(184) || Keyboard.isKeyDown(56);
|
||||
boolean isMetaPressed = Keyboard.isKeyDown(220) || Keyboard.isKeyDown(219);
|
||||
boolean repeatKey = Keyboard.isRepeatEvent();
|
||||
boolean keyDown = Keyboard.isKeyDown(key);
|
||||
|
||||
StringBuilder keysDownString = new StringBuilder();
|
||||
for(int i = 0; i < Keyboard.getKeyCount(); i++){//Creates a comma separated string of the integer IDs of held keys
|
||||
if(Keyboard.isKeyDown(i)){
|
||||
for (int i = 0; i < Keyboard.getKeyCount(); i++) {//Creates a comma separated string of the integer IDs of held keys
|
||||
if (Keyboard.isKeyDown(i)) {
|
||||
keysDownString.append(Integer.valueOf(i)).append(",");
|
||||
}
|
||||
}
|
||||
if(keysDownString.length() > 0){//Removes last comma for later parsing
|
||||
keysDownString.deleteCharAt(keysDownString.length()-1);
|
||||
if (keysDownString.length() > 0) {//Removes last comma for later parsing
|
||||
keysDownString.deleteCharAt(keysDownString.length() - 1);
|
||||
}
|
||||
|
||||
NoppesUtilPlayer.sendData(EnumPlayerPacket.KeyPressed, new Object[]{Integer.valueOf(key), Boolean.valueOf(isCtrlPressed), Boolean.valueOf(isShiftPressed), Boolean.valueOf(isAltPressed), Boolean.valueOf(isMetaPressed), Boolean.valueOf(keyDown), keysDownString.toString()});
|
||||
NoppesUtilPlayer.sendData(EnumPlayerPacket.KeyPressed, new Object[]{Integer.valueOf(key), Boolean.valueOf(isCtrlPressed), Boolean.valueOf(isShiftPressed), Boolean.valueOf(isAltPressed), Boolean.valueOf(isMetaPressed), Boolean.valueOf(repeatKey), Boolean.valueOf(keyDown), keysDownString.toString()});
|
||||
}
|
||||
|
||||
private boolean isIgnoredKey(int key) {
|
||||
|
||||
Reference in new issue
Block a user