Fixes #1958
This commit is contained in:
1 parent
a178129e95
commit
a83d04e912
2 files changed
+28
-1
No files matched your search
@@ -190,6 +190,11 @@ public class PlayerCommand
|
|||||||
MinecraftServer server = context.getSource().getServer();
|
MinecraftServer server = context.getSource().getServer();
|
||||||
PlayerList manager = server.getPlayerList();
|
PlayerList manager = server.getPlayerList();
|
||||||
|
|
||||||
|
if (EntityPlayerMPFake.isSpawningPlayer(playerName))
|
||||||
|
{
|
||||||
|
Messenger.m(context.getSource(), "r Player ", "rb " + playerName, "r is currently logging on");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (manager.getPlayerByName(playerName) != null)
|
if (manager.getPlayerByName(playerName) != null)
|
||||||
{
|
{
|
||||||
Messenger.m(context.getSource(), "r Player ", "rb " + playerName, "r is already logged on");
|
Messenger.m(context.getSource(), "r Player ", "rb " + playerName, "r is already logged on");
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import net.minecraft.world.phys.Vec3;
|
|||||||
import carpet.fakes.ServerPlayerInterface;
|
import carpet.fakes.ServerPlayerInterface;
|
||||||
import carpet.utils.Messenger;
|
import carpet.utils.Messenger;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@@ -43,6 +44,8 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
@SuppressWarnings("EntityConstructor")
|
@SuppressWarnings("EntityConstructor")
|
||||||
public class EntityPlayerMPFake extends ServerPlayer
|
public class EntityPlayerMPFake extends ServerPlayer
|
||||||
{
|
{
|
||||||
|
private static final Set<String> spawning = new HashSet<>();
|
||||||
|
|
||||||
public Runnable fixStartingPosition = () -> {};
|
public Runnable fixStartingPosition = () -> {};
|
||||||
public boolean isAShadow;
|
public boolean isAShadow;
|
||||||
|
|
||||||
@@ -69,7 +72,21 @@ public class EntityPlayerMPFake extends ServerPlayer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
GameProfile finalGP = gameprofile;
|
GameProfile finalGP = gameprofile;
|
||||||
fetchGameProfile(gameprofile.getName()).thenAcceptAsync(p -> {
|
|
||||||
|
// We need to mark this player as spawning so that we do not
|
||||||
|
// try to spawn another player with the name while the profile
|
||||||
|
// is being fetched - preventing multiple players spawning
|
||||||
|
String name = gameprofile.getName();
|
||||||
|
spawning.add(name);
|
||||||
|
|
||||||
|
fetchGameProfile(name).whenCompleteAsync((p, t) -> {
|
||||||
|
// Always remove the name, even if exception occurs
|
||||||
|
spawning.remove(name);
|
||||||
|
if (t != null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
GameProfile current = finalGP;
|
GameProfile current = finalGP;
|
||||||
if (p.isPresent())
|
if (p.isPresent())
|
||||||
{
|
{
|
||||||
@@ -127,6 +144,11 @@ public class EntityPlayerMPFake extends ServerPlayer
|
|||||||
return new EntityPlayerMPFake(server, level, profile, cli, false);
|
return new EntityPlayerMPFake(server, level, profile, cli, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isSpawningPlayer(String username)
|
||||||
|
{
|
||||||
|
return spawning.contains(username);
|
||||||
|
}
|
||||||
|
|
||||||
private EntityPlayerMPFake(MinecraftServer server, ServerLevel worldIn, GameProfile profile, ClientInformation cli, boolean shadow)
|
private EntityPlayerMPFake(MinecraftServer server, ServerLevel worldIn, GameProfile profile, ClientInformation cli, boolean shadow)
|
||||||
{
|
{
|
||||||
super(server, worldIn, profile, cli);
|
super(server, worldIn, profile, cli);
|
||||||
|
|||||||
Reference in new issue
Block a user