Skip to content

Commit

Permalink
disable permissions for now
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysdh540 committed Nov 5, 2023
1 parent b47104e commit 82f6fcb
Showing 1 changed file with 27 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,33 +115,34 @@ else if (value instanceof DoubleValue dValue)
}

if(Util.isDevEnv()) {
base.then(literal("disableEverything").requires(CUCommands::perms).executes(context -> {
CUConfigs.server().placementChecks.set(CUServer.PlacementCheck.OFF);
CUConfigs.server().extendedDriving.set(0.01);
CUConfigs.server().maxTrainRelocationDistance.set(128d);
CUConfigs.server().maxAllowedStress.set(-1d);
CUConfigs.server().trainAssemblyChecks.set(false);
CUConfigs.server().maxGlueConnectionRange.set(128d);
//CUConfigs.server().physicalBlockConnection.set(false);
CUConfigs.server().singleExtendoGripRange.set(128);
CUConfigs.server().doubleExtendoGripRange.set(128);
CUConfigs.server().allowAllCopycatBlocks.set(true);
CUConfigs.server().singleExtendoGripRange.set(128);
CUConfigs.server().doubleExtendoGripRange.set(128);
return Command.SINGLE_SUCCESS;
}));
base.then(literal("disableEverything")//.requires(CUCommands::perms)
.executes(context -> {
CUConfigs.server().placementChecks.set(CUServer.PlacementCheck.OFF);
CUConfigs.server().extendedDriving.set(0.01);
CUConfigs.server().maxTrainRelocationDistance.set(128d);
CUConfigs.server().maxAllowedStress.set(-1d);
CUConfigs.server().trainAssemblyChecks.set(false);
CUConfigs.server().maxGlueConnectionRange.set(128d);
//CUConfigs.server().physicalBlockConnection.set(false);
CUConfigs.server().singleExtendoGripRange.set(128);
CUConfigs.server().doubleExtendoGripRange.set(128);
CUConfigs.server().allowAllCopycatBlocks.set(true);
CUConfigs.server().singleExtendoGripRange.set(128);
CUConfigs.server().doubleExtendoGripRange.set(128);
return Command.SINGLE_SUCCESS;
}));
}

if (category != null)
base.then(category);
Util.registerCommand(base);
}

private static boolean perms(Object o) {
if(!(o instanceof CommandSourceStack source)) return false;
Entity e = source.getEntity();
return e != null && e.hasPermissions(4);
}
// private static boolean perms(Object o) {
// if(!(o instanceof CommandSourceStack source)) return false;
// Entity e = source.getEntity();
// return e != null && e.hasPermissions(4);
// }

private static <T> void gdr(LiteralArgumentBuilder<CommandSourceStack> category, String name, ConfigValue<T> value) {
category.then(literal(name)
Expand All @@ -151,7 +152,7 @@ private static <T> void gdr(LiteralArgumentBuilder<CommandSourceStack> category,
context.message("Default value: " + value.getDefault());
return Command.SINGLE_SUCCESS;
})
.then(literal("reset").requires(CUCommands::perms)
.then(literal("reset")//.requires(CUCommands::perms)
.executes(context -> {
if(value.get().equals(value.getDefault())) {
context.error("Value is already default!");
Expand All @@ -167,7 +168,7 @@ private static <T> void gdr(LiteralArgumentBuilder<CommandSourceStack> category,

private static void setBoolean(LiteralArgumentBuilder<CommandSourceStack> category, String name, BooleanValue value) {
category.then(literal(name)
.then(argument("value", BoolArgumentType.bool()).requires(CUCommands::perms)
.then(argument("value", BoolArgumentType.bool())//.requires(CUCommands::perms)
.executes(context -> {
boolean set = BoolArgumentType.getBool(context, "value");
if(set == value.get()) {
Expand All @@ -184,7 +185,7 @@ private static void setBoolean(LiteralArgumentBuilder<CommandSourceStack> catego

private static void setInt(LiteralArgumentBuilder<CommandSourceStack> category, String name, IntValue value) {
category.then(literal(name)
.then(argument("value", IntegerArgumentType.integer()).requires(CUCommands::perms)
.then(argument("value", IntegerArgumentType.integer())//.requires(CUCommands::perms)
.executes(context -> {
int set = IntegerArgumentType.getInteger(context, "value");
if(set == value.get()) {
Expand All @@ -201,7 +202,7 @@ private static void setInt(LiteralArgumentBuilder<CommandSourceStack> category,

private static void setDouble(LiteralArgumentBuilder<CommandSourceStack> category, String name, DoubleValue value) {
category.then(literal(name)
.then(argument("value", DoubleArgumentType.doubleArg()).requires(CUCommands::perms)
.then(argument("value", DoubleArgumentType.doubleArg())//.requires(CUCommands::perms)
.executes(context -> {
double set = DoubleArgumentType.getDouble(context, "value");
if(set == value.get()) {
Expand All @@ -219,7 +220,8 @@ private static void setDouble(LiteralArgumentBuilder<CommandSourceStack> categor
@SuppressWarnings("unchecked")
private static <T extends Enum<T>> void setEnum(LiteralArgumentBuilder<CommandSourceStack> category, String name, EnumValue<T> value) {
category.then(literal(name)
.then(argument("value", EnumArgument.enumArg(value.getDefault().getClass(), true)).requires(CUCommands::perms)
.then(argument("value", EnumArgument.enumArg(value.getDefault().getClass(), true))
//.requires(CUCommands::perms)
.executes(context -> {
T set = EnumArgument.getEnum(context, "value", (Class<T>) value.getDefault().getClass());
if(set == value.get()) {
Expand Down

0 comments on commit 82f6fcb

Please sign in to comment.