Merge branch 'master' into 1.16
This commit is contained in:
commit
efbafdcf0b
5 files changed
+40
-3
No files matched your search
@@ -2,6 +2,7 @@ package carpet;
|
|||||||
|
|
||||||
import carpet.settings.ParsedRule;
|
import carpet.settings.ParsedRule;
|
||||||
import carpet.settings.Rule;
|
import carpet.settings.Rule;
|
||||||
|
import carpet.settings.SettingsManager;
|
||||||
import carpet.settings.Validator;
|
import carpet.settings.Validator;
|
||||||
import carpet.utils.Messenger;
|
import carpet.utils.Messenger;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
@@ -39,6 +40,7 @@ public class CarpetSettings
|
|||||||
public static boolean impendingFillSkipUpdates = false;
|
public static boolean impendingFillSkipUpdates = false;
|
||||||
public static Box currentTelepotingEntityBox = null;
|
public static Box currentTelepotingEntityBox = null;
|
||||||
public static Vec3d fixedPosition = null;
|
public static Vec3d fixedPosition = null;
|
||||||
|
public static int runPermissionLevel = 2;
|
||||||
|
|
||||||
@Rule(
|
@Rule(
|
||||||
desc = "Nether portals correctly place entities going through",
|
desc = "Nether portals correctly place entities going through",
|
||||||
@@ -311,13 +313,22 @@ public class CarpetSettings
|
|||||||
)
|
)
|
||||||
public static String commandScript = "true";
|
public static String commandScript = "true";
|
||||||
|
|
||||||
|
private static class ModulePermissionLevel extends Validator<String> {
|
||||||
|
@Override public String validate(ServerCommandSource source, ParsedRule<String> currentRule, String newValue, String string) {
|
||||||
|
CarpetSettings.runPermissionLevel = SettingsManager.getCommandLevel(newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String description() { return "Also controls permission level of commands executed via `run()`";}
|
||||||
|
}
|
||||||
@Rule(
|
@Rule(
|
||||||
desc = "Enables restrictions for arbitrary code execution with scarpet",
|
desc = "Enables restrictions for arbitrary code execution with scarpet",
|
||||||
extra = {
|
extra = {
|
||||||
"Users that don't have this permission level",
|
"Users that don't have this permission level",
|
||||||
"won't be able to load apps or /script run"
|
"won't be able to load apps or /script run"
|
||||||
},
|
},
|
||||||
category = {COMMAND, SCARPET}
|
category = {COMMAND, SCARPET},
|
||||||
|
validate = ModulePermissionLevel.class
|
||||||
)
|
)
|
||||||
public static String commandScriptACE = "ops";
|
public static String commandScriptACE = "ops";
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package carpet.mixins;
|
package carpet.mixins;
|
||||||
|
|
||||||
import carpet.fakes.EntityInterface;
|
import carpet.fakes.EntityInterface;
|
||||||
|
import carpet.script.EntityEventsGroup;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import net.minecraft.entity.damage.DamageSource;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
@@ -55,6 +57,12 @@ public abstract class ServerPlayerEntity_scarpetEventMixin extends PlayerEntity
|
|||||||
STATISTICS.onPlayerStatistic((ServerPlayerEntity) (Object)this, stat, amount);
|
STATISTICS.onPlayerStatistic((ServerPlayerEntity) (Object)this, stat, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "onDeath", at = @At("HEAD"))
|
||||||
|
private void onDeathEvent(DamageSource source, CallbackInfo ci)
|
||||||
|
{
|
||||||
|
((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.EntityEventType.ON_DEATH, this, source.name);
|
||||||
|
}
|
||||||
|
|
||||||
@Redirect(method = "method_14218", at = @At(
|
@Redirect(method = "method_14218", at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "Lnet/minecraft/server/network/ServerPlayerEntity;setSneaking(Z)V"
|
target = "Lnet/minecraft/server/network/ServerPlayerEntity;setSneaking(Z)V"
|
||||||
|
|||||||
@@ -3600,7 +3600,7 @@ public class CarpetExpression
|
|||||||
Vec3d posf = new Vec3d((double)target.getX()+0.5D,(double)target.getY(),(double)target.getZ()+0.5D);
|
Vec3d posf = new Vec3d((double)target.getX()+0.5D,(double)target.getY(),(double)target.getZ()+0.5D);
|
||||||
ServerCommandSource s = ((CarpetContext)c).s;
|
ServerCommandSource s = ((CarpetContext)c).s;
|
||||||
Value retval = new NumericValue(s.getMinecraftServer().getCommandManager().execute(
|
Value retval = new NumericValue(s.getMinecraftServer().getCommandManager().execute(
|
||||||
s.withPosition(posf).withSilent(), lv.get(0).evalValue(c).getString()));
|
s.withPosition(posf).withSilent().withLevel(CarpetSettings.runPermissionLevel), lv.get(0).evalValue(c).getString()));
|
||||||
return (c_, t_) -> retval;
|
return (c_, t_) -> retval;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public class EntityEventsGroup
|
|||||||
},
|
},
|
||||||
ON_REMOVED("on_removed", 0),
|
ON_REMOVED("on_removed", 0),
|
||||||
ON_TICK("on_tick", 0),
|
ON_TICK("on_tick", 0),
|
||||||
ON_DAMAGE("on_damaged", 2)
|
ON_DAMAGE("on_damaged", 3)
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public List<Value> makeArgs(Entity entity, Object... providedArgs)
|
public List<Value> makeArgs(Entity entity, Object... providedArgs)
|
||||||
|
|||||||
@@ -206,6 +206,24 @@ public class SettingsManager
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getCommandLevel(String commandLevel)
|
||||||
|
{
|
||||||
|
switch (commandLevel)
|
||||||
|
{
|
||||||
|
case "true": return 2;
|
||||||
|
case "false": return 0;
|
||||||
|
case "ops": return 2; // typical for other cheaty commands
|
||||||
|
case "0":
|
||||||
|
case "1":
|
||||||
|
case "2":
|
||||||
|
case "3":
|
||||||
|
case "4":
|
||||||
|
return Integer.parseInt(commandLevel);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void loadConfigurationFromConf()
|
private void loadConfigurationFromConf()
|
||||||
{
|
{
|
||||||
for (ParsedRule<?> rule : rules.values()) rule.resetToDefault(server.getCommandSource());
|
for (ParsedRule<?> rule : rules.values()) rule.resetToDefault(server.getCommandSource());
|
||||||
|
|||||||
Reference in new issue
Block a user