Fixed grace period updating when it shouldn't. Fixed singleplayer making player invulnerable.

This commit is contained in:
micle
2021-06-03 20:56:04 +01:00
parent 47b27d67c8
commit 58634ef30e
2 changed files with 6 additions and 0 deletions

View File

@ -44,6 +44,8 @@ public class ProtectedPlayers {
public void updateGracePeriod(UUID player_uuid) { public void updateGracePeriod(UUID player_uuid) {
ProtectedPlayer protected_player = getPlayer(player_uuid); ProtectedPlayer protected_player = getPlayer(player_uuid);
if (protected_player.isLoading()) { return; }
int grace_period = protected_player.getGracePeriod()-1; int grace_period = protected_player.getGracePeriod()-1;
protected_player.setGracePeriod(grace_period); protected_player.setGracePeriod(grace_period);
if (grace_period <= 0) { if (grace_period <= 0) {

View File

@ -1,12 +1,16 @@
package com.micle.loginprotection.events; package com.micle.loginprotection.events;
import com.micle.loginprotection.LoginProtection; import com.micle.loginprotection.LoginProtection;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
public class OnPlayerJoinEventHandler { public class OnPlayerJoinEventHandler {
@SubscribeEvent @SubscribeEvent
@OnlyIn(Dist.DEDICATED_SERVER)
public void EntityJoinWorldEvent(PlayerEvent.PlayerLoggedInEvent event) { public void EntityJoinWorldEvent(PlayerEvent.PlayerLoggedInEvent event) {
if (!(event.getEntity() instanceof PlayerEntity)) { return; } if (!(event.getEntity() instanceof PlayerEntity)) { return; }
PlayerEntity player = (PlayerEntity) event.getEntity(); PlayerEntity player = (PlayerEntity) event.getEntity();