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 2688402c40
commit 6c30641919
9 changed files with 84 additions and 24 deletions

View File

@ -1,33 +1,24 @@
package com.micle.loginprotection.setup;
import com.micle.loginprotection.LoginProtection;
import com.micle.loginprotection.events.OnPlayerDamageEventHandler;
import com.micle.loginprotection.events.OnPlayerJoinEventHandler;
import com.micle.loginprotection.events.*;
import com.micle.loginprotection.network.C2SKeyPress;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.network.NetworkRegistry;
import net.minecraftforge.fml.network.simple.SimpleChannel;
public class Registration {
private static final String PROTOCOL_VERSION = "1";
public static final SimpleChannel INSTANCE = NetworkRegistry.newSimpleChannel(
new ResourceLocation(LoginProtection.MOD_ID, "main"),
() -> PROTOCOL_VERSION,
PROTOCOL_VERSION::equals,
PROTOCOL_VERSION::equals
);
public static void register() {
IEventBus mod_event_bus = FMLJavaModLoadingContext.get().getModEventBus();
MinecraftForge.EVENT_BUS.register(new OnPlayerJoinEventHandler());
MinecraftForge.EVENT_BUS.register(new OnPlayerDamageEventHandler());
MinecraftForge.EVENT_BUS.register(new OnServerTickEventHandler());
MinecraftForge.EVENT_BUS.register(new OnKeyPressEventHandler());
MinecraftForge.EVENT_BUS.register(new OnPlayerLeaveEventHandler());
int id = 0;
INSTANCE.registerMessage(id++,
LoginProtection.INSTANCE.registerMessage(id++,
C2SKeyPress.class,
C2SKeyPress::encode,
C2SKeyPress::decode,