Changed setLastInputTick method in Client Proxy to a simpler updateLastInputTick method which doesn't need a parameter since it was only ever passed one value.
This commit is contained in:
@ -81,149 +81,149 @@ public class OnClientInputEventHandler {
|
|||||||
if (key == GLFW.GLFW_KEY_ESCAPE) {
|
if (key == GLFW.GLFW_KEY_ESCAPE) {
|
||||||
isPausePressed = isPressed;
|
isPausePressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.PAUSE.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.PAUSE.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == GLFW.GLFW_KEY_F3) {
|
} else if (key == GLFW.GLFW_KEY_F3) {
|
||||||
isDebugPressed = isPressed;
|
isDebugPressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.DEBUG.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.DEBUG.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == keyBinds.keyFullscreen.getKey().getValue()) {
|
} else if (key == keyBinds.keyFullscreen.getKey().getValue()) {
|
||||||
isFullscreenPressed = isPressed;
|
isFullscreenPressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.FULLSCREEN.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.FULLSCREEN.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == keyBinds.keyTogglePerspective.getKey().getValue()) {
|
} else if (key == keyBinds.keyTogglePerspective.getKey().getValue()) {
|
||||||
isTogglePerspectivePressed = isPressed;
|
isTogglePerspectivePressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.PERSPECTIVE.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.PERSPECTIVE.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == keyBinds.keySmoothCamera.getKey().getValue()) {
|
} else if (key == keyBinds.keySmoothCamera.getKey().getValue()) {
|
||||||
isSmoothCameraPressed = isPressed;
|
isSmoothCameraPressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.SMOOTH_CAMERA.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.SMOOTH_CAMERA.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == keyBinds.keyScreenshot.getKey().getValue()) {
|
} else if (key == keyBinds.keyScreenshot.getKey().getValue()) {
|
||||||
isScreenshotPressed = isPressed;
|
isScreenshotPressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.SCREENSHOT.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.SCREENSHOT.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == keyBinds.keySpectatorOutlines.getKey().getValue()) {
|
} else if (key == keyBinds.keySpectatorOutlines.getKey().getValue()) {
|
||||||
isSpectatorOutlinesPressed = isPressed;
|
isSpectatorOutlinesPressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.SPECTATOR_OUTLINES.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.SPECTATOR_OUTLINES.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == keyBinds.keyAdvancements.getKey().getValue()) {
|
} else if (key == keyBinds.keyAdvancements.getKey().getValue()) {
|
||||||
isAdvancementsPressed = isPressed;
|
isAdvancementsPressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.ADVANCEMENTS.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.ADVANCEMENTS.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == keyBinds.keyPlayerList.getKey().getValue()) {
|
} else if (key == keyBinds.keyPlayerList.getKey().getValue()) {
|
||||||
isPlayerListPressed = isPressed;
|
isPlayerListPressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.PLAYER_LIST.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.PLAYER_LIST.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == keyBinds.keyChat.getKey().getValue()) {
|
} else if (key == keyBinds.keyChat.getKey().getValue()) {
|
||||||
isChatPressed = isPressed;
|
isChatPressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.CHAT.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.CHAT.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == keyBinds.keyCommand.getKey().getValue()) {
|
} else if (key == keyBinds.keyCommand.getKey().getValue()) {
|
||||||
isChatCommandPressed = isPressed;
|
isChatCommandPressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.CHAT.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.CHAT.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == GLFW.GLFW_KEY_ENTER) {
|
} else if (key == GLFW.GLFW_KEY_ENTER) {
|
||||||
isChatEnterPressed = isPressed;
|
isChatEnterPressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.CHAT.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.CHAT.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == keyBinds.keySocialInteractions.getKey().getValue()) {
|
} else if (key == keyBinds.keySocialInteractions.getKey().getValue()) {
|
||||||
isSocialInteractionsPressed = isPressed;
|
isSocialInteractionsPressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.SOCIAL_INTERACTIONS.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.SOCIAL_INTERACTIONS.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == keyBinds.keyLoadHotbarActivator.getKey().getValue()) {
|
} else if (key == keyBinds.keyLoadHotbarActivator.getKey().getValue()) {
|
||||||
isLoadHotbarActivatorPressed = isPressed;
|
isLoadHotbarActivatorPressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.LOAD_HOTBAR_ACTIVATOR.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.LOAD_HOTBAR_ACTIVATOR.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == keyBinds.keySaveHotbarActivator.getKey().getValue()) {
|
} else if (key == keyBinds.keySaveHotbarActivator.getKey().getValue()) {
|
||||||
isSaveHotbarActivatorPressed = isPressed;
|
isSaveHotbarActivatorPressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.SAVE_HOTBAR_ACTIVATOR.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.SAVE_HOTBAR_ACTIVATOR.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == keyBinds.keySwapOffhand.getKey().getValue()) {
|
} else if (key == keyBinds.keySwapOffhand.getKey().getValue()) {
|
||||||
isSwapOffhandPressed = isPressed;
|
isSwapOffhandPressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.SWAP_ITEM.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.SWAP_ITEM.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == keyBinds.keyInventory.getKey().getValue()) {
|
} else if (key == keyBinds.keyInventory.getKey().getValue()) {
|
||||||
isInventoryPressed = isPressed;
|
isInventoryPressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.INVENTORY.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.INVENTORY.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == keyBinds.keyDrop.getKey().getValue()) {
|
} else if (key == keyBinds.keyDrop.getKey().getValue()) {
|
||||||
isDropItemPressed = isPressed;
|
isDropItemPressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.DROP_ITEM.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.DROP_ITEM.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == keyBinds.keyUse.getKey().getValue()) {
|
} else if (key == keyBinds.keyUse.getKey().getValue()) {
|
||||||
isUseItemPressed = isPressed;
|
isUseItemPressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.USE_ITEM.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.USE_ITEM.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == keyBinds.keyPickItem.getKey().getValue()) {
|
} else if (key == keyBinds.keyPickItem.getKey().getValue()) {
|
||||||
isPickBlockPressed = isPressed;
|
isPickBlockPressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.PICK_BLOCK.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.PICK_BLOCK.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == keyBinds.keyAttack.getKey().getValue()) {
|
} else if (key == keyBinds.keyAttack.getKey().getValue()) {
|
||||||
isAttackPressed = isPressed;
|
isAttackPressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.ATTACK.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.ATTACK.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == keyBinds.keyUp.getKey().getValue()) {
|
} else if (key == keyBinds.keyUp.getKey().getValue()) {
|
||||||
isMoveUpPressed = isPressed;
|
isMoveUpPressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.MOVE.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.MOVE.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == keyBinds.keyRight.getKey().getValue()) {
|
} else if (key == keyBinds.keyRight.getKey().getValue()) {
|
||||||
isMoveRightPressed = isPressed;
|
isMoveRightPressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.MOVE.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.MOVE.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == keyBinds.keyDown.getKey().getValue()) {
|
} else if (key == keyBinds.keyDown.getKey().getValue()) {
|
||||||
isMoveDownPressed = isPressed;
|
isMoveDownPressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.MOVE.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.MOVE.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == keyBinds.keyLeft.getKey().getValue()) {
|
} else if (key == keyBinds.keyLeft.getKey().getValue()) {
|
||||||
isMoveLeftPressed = isPressed;
|
isMoveLeftPressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.MOVE.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.MOVE.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == keyBinds.keySprint.getKey().getValue()) {
|
} else if (key == keyBinds.keySprint.getKey().getValue()) {
|
||||||
isMoveSprintPressed = isPressed;
|
isMoveSprintPressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.MOVE.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.MOVE.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == keyBinds.keyShift.getKey().getValue()) {
|
} else if (key == keyBinds.keyShift.getKey().getValue()) {
|
||||||
isSneakPressed = isPressed;
|
isSneakPressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.SNEAK.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.SNEAK.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else if (key == keyBinds.keyJump.getKey().getValue()) {
|
} else if (key == keyBinds.keyJump.getKey().getValue()) {
|
||||||
isJumpPressed = isPressed;
|
isJumpPressed = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.JUMP.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.JUMP.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < isHotbarPressed.length; i++) {
|
for (int i = 0; i < isHotbarPressed.length; i++) {
|
||||||
if (key == keyBinds.keyHotbarSlots[i].getKey().getValue()) {
|
if (key == keyBinds.keyHotbarSlots[i].getKey().getValue()) {
|
||||||
isHotbarPressed[i] = isPressed;
|
isHotbarPressed[i] = isPressed;
|
||||||
if (!allowedKeys.contains(Config.Server.KEYS.HOTBAR.toString())) {
|
if (!allowedKeys.contains(Config.Server.KEYS.HOTBAR.toString())) {
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -265,7 +265,7 @@ public class OnClientInputEventHandler {
|
|||||||
(isJumpPressed && !allowedKeys.contains(Config.Server.KEYS.JUMP.toString())) ||
|
(isJumpPressed && !allowedKeys.contains(Config.Server.KEYS.JUMP.toString())) ||
|
||||||
(Arrays.stream(isHotbarPressed).anyMatch(b -> b) && !allowedKeys.contains(Config.Server.KEYS.HOTBAR.toString()))) {
|
(Arrays.stream(isHotbarPressed).anyMatch(b -> b) && !allowedKeys.contains(Config.Server.KEYS.HOTBAR.toString()))) {
|
||||||
// Assign new last input tick
|
// Assign new last input tick
|
||||||
Proxy.Client.setLastInputTick(LoginProtection.getProxy().getClientPlayer().tickCount);
|
Proxy.Client.updateLastInputTick();
|
||||||
|
|
||||||
// If player is not active send an input packet
|
// If player is not active send an input packet
|
||||||
if (!Proxy.Client.getPlayerState().equals(ProtectedPlayer.State.ACTIVE)) {
|
if (!Proxy.Client.getPlayerState().equals(ProtectedPlayer.State.ACTIVE)) {
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package dev.micle.loginprotection.proxy;
|
package dev.micle.loginprotection.proxy;
|
||||||
|
|
||||||
|
import dev.micle.loginprotection.LoginProtection;
|
||||||
import dev.micle.loginprotection.data.ProtectedPlayer;
|
import dev.micle.loginprotection.data.ProtectedPlayer;
|
||||||
import dev.micle.loginprotection.data.ProtectedPlayerManager;
|
import dev.micle.loginprotection.data.ProtectedPlayerManager;
|
||||||
import dev.micle.loginprotection.events.*;
|
import dev.micle.loginprotection.events.*;
|
||||||
@ -110,8 +111,8 @@ public class Proxy implements IProxy {
|
|||||||
return lastInputTick;
|
return lastInputTick;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setLastInputTick(int newLastInputTick) {
|
public static void updateLastInputTick() {
|
||||||
lastInputTick = newLastInputTick;
|
lastInputTick = LoginProtection.getProxy().getClientPlayer().tickCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user