Changed grace period time from 200 to 400 (5s to 10s). Added function to ProtectedPlayers.java to remove a player from the list, updated the updateGracePeriods method. Updated C2SKeyPress.java. Made OnKeyPressEventHandler.java check for mouse clicks as well, also made sure it only fires on client-side. Added an event for when a player leaves the server to remove them from the list.

This commit is contained in:
micle
2021-06-03 19:58:21 +01:00
parent 532a49744b
commit 6022797e04
9 changed files with 84 additions and 24 deletions

View File

@ -1,13 +1,28 @@
package com.micle.loginprotection.events;
import com.micle.loginprotection.LoginProtection;
import com.micle.loginprotection.network.C2SKeyPress;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
public class OnKeyPressEventHandler {
@SubscribeEvent
@OnlyIn(Dist.CLIENT)
public void KeyPressEvent(InputEvent.KeyInputEvent event) {
if (LoginProtection.has_pressed_key) { return; }
ServerData server = Minecraft.getInstance().getCurrentServer();
if (server == null) { return; }
LoginProtection.INSTANCE.sendToServer(new C2SKeyPress());
}
@SubscribeEvent
@OnlyIn(Dist.CLIENT)
public void MouseClickEvent(InputEvent.ClickInputEvent event) {
ServerData server = Minecraft.getInstance().getCurrentServer();
if (server == null) { return; }
LoginProtection.INSTANCE.sendToServer(new C2SKeyPress());
}
}