Don't use getPlayerOrException in CarpetScriptHost

This commit is contained in:
altrisi committed 2023-06-26 18:33:20 +02:00
1 parent a8fedc37e4
commit 177179b70a
1 file changed
+3 -11
@@ -675,12 +675,8 @@ public class CarpetScriptHost extends ScriptHost
return this;
}
// user based
ServerPlayer player;
try
{
player = source.getPlayerOrException();
}
catch (CommandSyntaxException ignored)
ServerPlayer player = source.getPlayer();
if (player == null)
{
throw new SimpleCommandExceptionType(Component.literal("Cannot run player based apps without the player context")).create();
}
@@ -1057,11 +1053,7 @@ public class CarpetScriptHost extends ScriptHost
responsibleSource = source;
errorSnooper = (expr, /*Nullable*/ token, ctx, message) ->
{
try
{
source.getPlayerOrException();
}
catch (CommandSyntaxException e)
if (!source.isPlayer())
{
return null;
}