Updated C2SKeyPress class.

This commit is contained in:
2021-09-29 18:45:10 +01:00
parent db787d46d1
commit 712ab92bc5

View File

@ -1,8 +1,11 @@
package com.micle.loginprotection.network;
import com.micle.loginprotection.LoginProtection;
import com.micle.loginprotection.setup.Config;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.network.PacketBuffer;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.fml.network.NetworkEvent;
@ -25,11 +28,26 @@ public class C2SKeyPress {
if (LoginProtection.protected_players.getPlayer(sender.getUUID()) == null) { return; }
if (!LoginProtection.protected_players.getPlayer(sender.getUUID()).isLoading()) { return; }
if (!Config.POST_GRACE_ENABLED.get()) {
LoginProtection.protected_players.removePlayer(sender.getUUID());
} else {
LoginProtection.protected_players.getPlayer(sender.getUUID()).setLoading(false);
sender.sendMessage(new StringTextComponent("Grace Period started!"), sender.getUUID());
}
if (sender.isInWater()) {
if (Config.POST_DROWN_ENABLED.get()) {
sender.setAirSupply(sender.getMaxAirSupply());
}
if (Config.POST_WATER_ENABLED.get()) {
sender.addEffect(new EffectInstance(Effects.WATER_BREATHING, Config.POST_WATER_DURATION.get()*20, 0));
}
}
if (sender.isInLava() && Config.POST_LAVA_ENABLED.get()) {
sender.addEffect(new EffectInstance(Effects.FIRE_RESISTANCE, Config.POST_LAVA_DURATION.get()*20, 0));
}
if (sender.isOnFire() && Config.POST_FIRE_ENABLED.get()) {
sender.addEffect(new EffectInstance(Effects.FIRE_RESISTANCE, Config.POST_FIRE_DURATION.get()*20, 0));
}
});
context.setPacketHandled(true);
}