better death messages for fake players and handling idling. Fixes #619
This commit is contained in:
1 parent
6dc6a42bda
commit
97971322e5
3 files changed
+14
-3
No files matched your search
@@ -69,7 +69,7 @@ public abstract class PlayerManager_fakePlayersMixin
|
||||
ServerPlayerEntity serverPlayerEntity_3 = (ServerPlayerEntity) var5.next();
|
||||
if(serverPlayerEntity_3 instanceof EntityPlayerMPFake)
|
||||
{
|
||||
serverPlayerEntity_3.kill();
|
||||
((EntityPlayerMPFake)serverPlayerEntity_3).kill(new TranslatableText("multiplayer.disconnect.duplicate_login"));
|
||||
continue;
|
||||
}
|
||||
serverPlayerEntity_3.networkHandler.disconnect(new TranslatableText("multiplayer.disconnect.duplicate_login"));
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.network.packet.s2c.play.PlayerListS2CPacket;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.entity.player.HungerManager;
|
||||
import net.minecraft.network.NetworkSide;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.ServerTask;
|
||||
@@ -95,9 +96,14 @@ public class EntityPlayerMPFake extends ServerPlayerEntity
|
||||
|
||||
@Override
|
||||
public void kill()
|
||||
{
|
||||
kill(Messenger.s("Killed"));
|
||||
}
|
||||
|
||||
public void kill(Text reason)
|
||||
{
|
||||
this.server.send(new ServerTask(this.server.getTicks(), () -> {
|
||||
this.networkHandler.onDisconnected(Messenger.s("Killed"));
|
||||
this.networkHandler.onDisconnected(reason);
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -120,7 +126,7 @@ public class EntityPlayerMPFake extends ServerPlayerEntity
|
||||
super.onDeath(cause);
|
||||
setHealth(20);
|
||||
this.hungerManager = new HungerManager();
|
||||
kill();
|
||||
kill(this.getDamageTracker().getDeathMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
|
||||
public class NetHandlerPlayServerFake extends ServerPlayNetworkHandler
|
||||
{
|
||||
@@ -22,6 +23,10 @@ public class NetHandlerPlayServerFake extends ServerPlayNetworkHandler
|
||||
@Override
|
||||
public void disconnect(Text message)
|
||||
{
|
||||
if (player instanceof EntityPlayerMPFake && message instanceof TranslatableText && ((TranslatableText) message).getKey().equals("multiplayer.disconnect.idling"))
|
||||
{
|
||||
((EntityPlayerMPFake) player).kill(new TranslatableText(((TranslatableText) message).getKey()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user