Skip to content

Commit

Permalink
use ConfigHandler to work with server-side config
Browse files Browse the repository at this point in the history
  • Loading branch information
bertcardinaels authored and Dream-Master committed Jan 12, 2024
1 parent b8f148b commit c6b42ef
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/main/java/betterquesting/api/storage/BQ_Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ public class BQ_Settings
public static boolean alwaysDrawImplicit = false;
public static boolean urlDebug = false;
public static boolean loadDefaultsOnStartup = true;

public static boolean unrestrictAdminCommands = false;
}
5 changes: 3 additions & 2 deletions src/main/java/betterquesting/commands/BQ_CommandAdmin.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
import betterquesting.commands.admin.QuestCommandPurge;
import betterquesting.commands.admin.QuestCommandReportAllProgress;
import betterquesting.commands.admin.QuestCommandReset;
import drethic.questbook.config.QBConfig;

import betterquesting.handlers.ConfigHandler;
import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
import net.minecraftforge.common.config.Configuration;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -109,7 +110,7 @@ public int getRequiredPermissionLevel()
@Override
public boolean canCommandSenderUseCommand(ICommandSender sender)
{
if(QBConfig.unrestrictAdminCommands) return true;
if(ConfigHandler.config.get(Configuration.CATEGORY_GENERAL,"Unrestrict Admin Commands", false).getBoolean(false)) return true;
else return super.canCommandSenderUseCommand(sender);
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/betterquesting/handlers/ConfigHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public static void initConfigs()
BQ_Settings.alwaysDrawImplicit = config.getBoolean("Always draw implicit dependency", Configuration.CATEGORY_GENERAL, false, "If true, always draw implicit dependency. This property can be changed by the GUI");
BQ_Settings.urlDebug = config.getBoolean("Highlight detected clickable url hotzone.", Configuration.CATEGORY_GENERAL, false, "If true, render each hotzone using alternating color.");
BQ_Settings.loadDefaultsOnStartup = config.getBoolean("Load the default quest DB on world startup.", Configuration.CATEGORY_GENERAL, true, "Does an equivalent of '/bq_admin default load' on every world load");
BQ_Settings.unrestrictAdminCommands = config.getBoolean("Unrestrict Admin Commands", Configuration.CATEGORY_GENERAL, false, "If true, all users can use /bq_admin commands regardless of op-status. Useful for single-player without cheats.");

config.save();
}
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/drethic/questbook/config/QBConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ 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 @@ -30,8 +29,6 @@ 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 c6b42ef

Please sign in to comment.