Allow /player spawn spawn offline-mode player in online server; Code clean-up in /player spawn command (#872)

* Clean up code in PlayerCommand.spawn and EntityPlayerMPFake.createFake.

* Update src/main/java/carpet/CarpetSettings.java

* Update src/main/java/carpet/commands/PlayerCommand.java

* Update src/main/java/carpet/patches/EntityPlayerMPFake.java

Co-authored-by: gnembon <41132274+gnembon@users.noreply.github.com>
This commit is contained in:
Keuinandgnembon authored and GitHub committed 2021-05-25 13:21:59 -03:00
1 parent c3fe5d685b
commit 0cb20e0795
3 files changed
+21 -5

No files matched your search

@@ -1,5 +1,6 @@
package carpet.patches;
import carpet.CarpetSettings;
import com.mojang.authlib.GameProfile;
import net.minecraft.block.entity.SkullBlockEntity;
import net.minecraft.entity.Entity;
@@ -22,7 +23,6 @@ import net.minecraft.util.UserCache;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.GameMode;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import carpet.fakes.ServerPlayerEntityInterface;
import carpet.utils.Messenger;
@@ -45,7 +45,15 @@ public class EntityPlayerMPFake extends ServerPlayerEntity
finally {
UserCache.setUseRemote(server.isDedicated() && server.isOnlineMode());
}
if (gameprofile == null) return null;
if (gameprofile == null)
{
if (!CarpetSettings.allowSpawningOfflinePlayers)
{
return null;
} else {
gameprofile = new GameProfile(PlayerEntity.getOfflinePlayerUuid(username), username);
}
}
if (gameprofile.getProperties().containsKey("textures"))
{
gameprofile = SkullBlockEntity.loadProperties(gameprofile);