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:
1 parent
c3fe5d685b
commit
0cb20e0795
3 files changed
+21
-5
No files matched your search
@@ -472,6 +472,9 @@ public class CarpetSettings
|
||||
@Rule(desc = "Enables /player command to control/spawn players", category = COMMAND)
|
||||
public static String commandPlayer = "ops";
|
||||
|
||||
@Rule(desc = "Spawn offline players in online mode if online-mode player with specified name does not exist", category = COMMAND)
|
||||
public static boolean allowSpawningOfflinePlayers = true;
|
||||
|
||||
@Rule(desc = "Allows to track mobs AI via /track command", category = COMMAND)
|
||||
public static String commandTrackAI = "ops";
|
||||
|
||||
|
||||
@@ -192,9 +192,14 @@ public class PlayerCommand
|
||||
GameProfile profile = server.getUserCache().findByName(playerName);
|
||||
if (profile == null)
|
||||
{
|
||||
Messenger.m(context.getSource(), "r Player "+playerName+" is either banned by Mojang, or auth servers are down. " +
|
||||
"Banned players can only be summoned in Singleplayer and in servers in off-line mode.");
|
||||
return true;
|
||||
if (!CarpetSettings.allowSpawningOfflinePlayers)
|
||||
{
|
||||
Messenger.m(context.getSource(), "r Player "+playerName+" is either banned by Mojang, or auth servers are down. " +
|
||||
"Banned players can only be summoned in Singleplayer and in servers in off-line mode.");
|
||||
return true;
|
||||
} else {
|
||||
profile = new GameProfile(PlayerEntity.getOfflinePlayerUuid(playerName), playerName);
|
||||
}
|
||||
}
|
||||
if (manager.getUserBanList().contains(profile))
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user