added commandScriptACE setting and custom permissions for scarpet.
This commit is contained in:
1 parent
8f32354606
commit
493cea2c13
4 files changed
+27
-10
No files matched your search
@@ -28,6 +28,7 @@ import static carpet.settings.RuleCategory.OPTIMIZATION;
|
|||||||
import static carpet.settings.RuleCategory.SURVIVAL;
|
import static carpet.settings.RuleCategory.SURVIVAL;
|
||||||
import static carpet.settings.RuleCategory.TNT;
|
import static carpet.settings.RuleCategory.TNT;
|
||||||
import static carpet.settings.RuleCategory.DISPENSER;
|
import static carpet.settings.RuleCategory.DISPENSER;
|
||||||
|
import static carpet.settings.RuleCategory.SCARPET;
|
||||||
|
|
||||||
@SuppressWarnings("CanBeFinal")
|
@SuppressWarnings("CanBeFinal")
|
||||||
public class CarpetSettings
|
public class CarpetSettings
|
||||||
@@ -303,13 +304,27 @@ public class CarpetSettings
|
|||||||
@Rule(desc = "Enables /draw commands", extra = "... allows for drawing simple shapes", category = COMMAND)
|
@Rule(desc = "Enables /draw commands", extra = "... allows for drawing simple shapes", category = COMMAND)
|
||||||
public static String commandDraw = "true";
|
public static String commandDraw = "true";
|
||||||
|
|
||||||
@Rule(desc = "Enables /script command", extra = "An in-game scripting API for Scarpet programming language", category = COMMAND)
|
@Rule(
|
||||||
public static boolean commandScript = true;
|
desc = "Enables /script command",
|
||||||
|
extra = "An in-game scripting API for Scarpet programming language",
|
||||||
|
category = {COMMAND, SCARPET}
|
||||||
|
)
|
||||||
|
public static String commandScript = "true";
|
||||||
|
|
||||||
|
@Rule(
|
||||||
|
desc = "Enables restrictions for arbitrary code execution with scarpet",
|
||||||
|
extra = {
|
||||||
|
"Users that don't have this permission level",
|
||||||
|
"won't be able to load apps or /script run"
|
||||||
|
},
|
||||||
|
category = {COMMAND, SCARPET}
|
||||||
|
)
|
||||||
|
public static String commandScriptACE = "ops";
|
||||||
|
|
||||||
@Rule(
|
@Rule(
|
||||||
desc = "Scarpet script from world files will autoload on server/world start ",
|
desc = "Scarpet script from world files will autoload on server/world start ",
|
||||||
extra = "if /script is enabled",
|
extra = "if /script is enabled",
|
||||||
category = CREATIVE
|
category = SCARPET
|
||||||
)
|
)
|
||||||
public static boolean scriptsAutoload = false;
|
public static boolean scriptsAutoload = false;
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import carpet.script.LazyValue;
|
|||||||
import carpet.script.Tokenizer;
|
import carpet.script.Tokenizer;
|
||||||
import carpet.script.exception.CarpetExpressionException;
|
import carpet.script.exception.CarpetExpressionException;
|
||||||
import carpet.script.value.FunctionValue;
|
import carpet.script.value.FunctionValue;
|
||||||
|
import carpet.settings.SettingsManager;
|
||||||
import carpet.utils.Messenger;
|
import carpet.utils.Messenger;
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
@@ -79,7 +80,7 @@ public class ScriptCommand
|
|||||||
LiteralArgumentBuilder<ServerCommandSource> u = literal("resume").
|
LiteralArgumentBuilder<ServerCommandSource> u = literal("resume").
|
||||||
executes( (cc) -> { CarpetServer.scriptServer.stopAll = false; return 1;});
|
executes( (cc) -> { CarpetServer.scriptServer.stopAll = false; return 1;});
|
||||||
LiteralArgumentBuilder<ServerCommandSource> l = literal("run").
|
LiteralArgumentBuilder<ServerCommandSource> l = literal("run").
|
||||||
requires((player) -> player.hasPermissionLevel(2)).
|
requires((player) -> SettingsManager.canUseCommand(player, CarpetSettings.commandScriptACE)).
|
||||||
then(argument("expr", StringArgumentType.greedyString()).suggests(ScriptCommand::suggestCode).
|
then(argument("expr", StringArgumentType.greedyString()).suggests(ScriptCommand::suggestCode).
|
||||||
executes((cc) -> compute(
|
executes((cc) -> compute(
|
||||||
cc,
|
cc,
|
||||||
@@ -205,7 +206,7 @@ public class ScriptCommand
|
|||||||
BlockPredicateArgumentType.getBlockPredicate(cc, "filter"),
|
BlockPredicateArgumentType.getBlockPredicate(cc, "filter"),
|
||||||
"outline"
|
"outline"
|
||||||
)))))))));
|
)))))))));
|
||||||
LiteralArgumentBuilder<ServerCommandSource> a = literal("load").requires( (player) -> player.hasPermissionLevel(2) ).
|
LiteralArgumentBuilder<ServerCommandSource> a = literal("load").requires( (player) -> SettingsManager.canUseCommand(player, CarpetSettings.commandScriptACE) ).
|
||||||
then(argument("app", StringArgumentType.word()).
|
then(argument("app", StringArgumentType.word()).
|
||||||
suggests( (cc, bb) -> suggestMatching(CarpetServer.scriptServer.listAvailableModules(true),bb)).
|
suggests( (cc, bb) -> suggestMatching(CarpetServer.scriptServer.listAvailableModules(true),bb)).
|
||||||
executes((cc) ->
|
executes((cc) ->
|
||||||
@@ -222,7 +223,7 @@ public class ScriptCommand
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
LiteralArgumentBuilder<ServerCommandSource> f = literal("unload").requires( (player) -> player.hasPermissionLevel(2) ).
|
LiteralArgumentBuilder<ServerCommandSource> f = literal("unload").requires( (player) -> SettingsManager.canUseCommand(player, CarpetSettings.commandScriptACE) ).
|
||||||
then(argument("app", StringArgumentType.word()).
|
then(argument("app", StringArgumentType.word()).
|
||||||
suggests( (cc, bb) -> suggestMatching(CarpetServer.scriptServer.modules.keySet(),bb)).
|
suggests( (cc, bb) -> suggestMatching(CarpetServer.scriptServer.modules.keySet(),bb)).
|
||||||
executes((cc) ->
|
executes((cc) ->
|
||||||
@@ -231,7 +232,7 @@ public class ScriptCommand
|
|||||||
return success?1:0;
|
return success?1:0;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
LiteralArgumentBuilder<ServerCommandSource> q = literal("event").requires( (player) -> player.hasPermissionLevel(2) ).
|
LiteralArgumentBuilder<ServerCommandSource> q = literal("event").requires( (player) -> SettingsManager.canUseCommand(player, CarpetSettings.commandScriptACE) ).
|
||||||
executes( (cc) -> listEvents(cc.getSource())).
|
executes( (cc) -> listEvents(cc.getSource())).
|
||||||
then(literal("add_to").
|
then(literal("add_to").
|
||||||
then(argument("event", StringArgumentType.word()).
|
then(argument("event", StringArgumentType.word()).
|
||||||
@@ -268,10 +269,10 @@ public class ScriptCommand
|
|||||||
|
|
||||||
|
|
||||||
dispatcher.register(literal("script").
|
dispatcher.register(literal("script").
|
||||||
requires((player) -> CarpetSettings.commandScript).
|
requires((player) -> SettingsManager.canUseCommand(player, CarpetSettings.commandScript)).
|
||||||
then(b).then(u).then(o).then(l).then(s).then(c).then(h).then(i).then(e).then(t).then(a).then(f).then(q));
|
then(b).then(u).then(o).then(l).then(s).then(c).then(h).then(i).then(e).then(t).then(a).then(f).then(q));
|
||||||
dispatcher.register(literal("script").
|
dispatcher.register(literal("script").
|
||||||
requires((player) -> CarpetSettings.commandScript).
|
requires((player) -> SettingsManager.canUseCommand(player, CarpetSettings.commandScript)).
|
||||||
then(literal("in").
|
then(literal("in").
|
||||||
then(argument("app", StringArgumentType.word()).
|
then(argument("app", StringArgumentType.word()).
|
||||||
suggests( (cc, bb) -> suggestMatching(CarpetServer.scriptServer.modules.keySet(), bb)).
|
suggests( (cc, bb) -> suggestMatching(CarpetServer.scriptServer.modules.keySet(), bb)).
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public abstract class ArmorStandEntity_scarpetMarkerMixin extends LivingEntity
|
|||||||
@Inject(method = "readCustomDataFromTag", at = @At("HEAD"))
|
@Inject(method = "readCustomDataFromTag", at = @At("HEAD"))
|
||||||
private void checkScarpetMarkerUnloaded(CallbackInfo ci)
|
private void checkScarpetMarkerUnloaded(CallbackInfo ci)
|
||||||
{
|
{
|
||||||
if ((CarpetSettings.scriptsAutoload || CarpetSettings.commandScript) && !world.isClient)
|
if ((CarpetSettings.scriptsAutoload || !CarpetSettings.commandScript.equals("false")) && !world.isClient)
|
||||||
{
|
{
|
||||||
if (getScoreboardTags().contains(ExpressionInspector.MARKER_STRING))
|
if (getScoreboardTags().contains(ExpressionInspector.MARKER_STRING))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,5 +11,6 @@ public class RuleCategory
|
|||||||
public static final String COMMAND = "command";
|
public static final String COMMAND = "command";
|
||||||
public static final String TNT = "tnt";
|
public static final String TNT = "tnt";
|
||||||
public static final String DISPENSER = "dispenser";
|
public static final String DISPENSER = "dispenser";
|
||||||
|
public static final String SCARPET = "scarpet";
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user