Skip to content

Commit

Permalink
add unrestrictAdminCommands config option to enable admin commands to…
Browse files Browse the repository at this point in the history
… non-op
  • Loading branch information
bertcardinaels authored and Dream-Master committed Jan 12, 2024
1 parent 02470f2 commit b8f148b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/main/java/betterquesting/commands/BQ_CommandAdmin.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import betterquesting.commands.admin.QuestCommandPurge;
import betterquesting.commands.admin.QuestCommandReportAllProgress;
import betterquesting.commands.admin.QuestCommandReset;
import drethic.questbook.config.QBConfig;

import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
Expand Down Expand Up @@ -104,6 +106,13 @@ public int getRequiredPermissionLevel()
return 2;
}

@Override
public boolean canCommandSenderUseCommand(ICommandSender sender)
{
if(QBConfig.unrestrictAdminCommands) return true;
else return super.canCommandSenderUseCommand(sender);
}

@Override
public void processCommand(ICommandSender sender, String[] args)
{
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/drethic/questbook/config/QBConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class QBConfig {
public static boolean spawnWithBook;
public static boolean disablePartyNotifications;
public static boolean disableQuestNotifications;
public static boolean unrestrictAdminCommands;

public static final void init(FMLPreInitializationEvent e) {
QBLogger.logger.info("Loading config file.");
Expand All @@ -29,7 +30,8 @@ public static final void init(FMLPreInitializationEvent e) {
"[NYI]Disable party notifications. Default: false");
disableQuestNotifications = configBoolOption(Configuration.CATEGORY_GENERAL, "disableQuestNotifications", false,
"[NYI]Disable quest notifications. Default: false");

unrestrictAdminCommands = configBoolOption(Configuration.CATEGORY_GENERAL, "unrestrictAdminCommands", false,
"Enable this option to let non-op players use /bq_admin commands. Useful for single-player without cheats enabled. Default: false");
qbconfig.save();
}

Expand Down

0 comments on commit b8f148b

Please sign in to comment.