Saves command rank settings to bentobox config.yml

https://github.com/BentoBoxWorld/BentoBox/issues/657
This commit is contained in:
tastybento 2019-05-03 22:29:03 -07:00
parent 4e0e283ace
commit 2b2ee7e42c
4 changed files with 16 additions and 8 deletions

View File

@ -110,7 +110,7 @@ public class BentoBox extends JavaPlugin {
return; return;
} }
// Saving the config now. // Saving the config now.
new Config<>(this, Settings.class).saveConfigObject(settings); saveConfig();
// Start Database managers // Start Database managers
playersManager = new PlayersManager(this); playersManager = new PlayersManager(this);
@ -154,7 +154,7 @@ public class BentoBox extends JavaPlugin {
addonsManager.loadAddons(); addonsManager.loadAddons();
// Enable addons // Enable addons
addonsManager.enableAddons(); addonsManager.enableAddons();
// Register default gamemode placeholders // Register default gamemode placeholders
addonsManager.getGameModeAddons().forEach(placeholdersManager::registerDefaultPlaceholders); addonsManager.getGameModeAddons().forEach(placeholdersManager::registerDefaultPlaceholders);
@ -333,6 +333,11 @@ public class BentoBox extends JavaPlugin {
return true; return true;
} }
@Override
public void saveConfig() {
if (settings != null) new Config<>(this, Settings.class).saveConfigObject(settings);
}
/** /**
* @return the notifier * @return the notifier
*/ */

View File

@ -74,7 +74,7 @@ public class Settings implements DataObject {
private Set<String> fakePlayers = new HashSet<>(); private Set<String> fakePlayers = new HashSet<>();
@ConfigComment("Rank required to use a command. e.g., use the invite command. Default is owner rank is required.") @ConfigComment("Rank required to use a command. e.g., use the invite command. Default is owner rank is required.")
@ConfigEntry(path = "general.rank-command", experimental = true) @ConfigEntry(path = "general.rank-command")
private Map<String, Integer> rankCommand = new HashMap<>(); private Map<String, Integer> rankCommand = new HashMap<>();
@ConfigEntry(path = "panel.close-on-click-outside") @ConfigEntry(path = "panel.close-on-click-outside")

View File

@ -1,5 +1,5 @@
/** /**
* *
*/ */
package world.bentobox.bentobox.listeners.flags.clicklisteners; package world.bentobox.bentobox.listeners.flags.clicklisteners;
@ -57,6 +57,9 @@ public class CommandCycleClick implements ClickHandler {
} }
// Apply change to panel // Apply change to panel
panel.getInventory().setItem(slot, commandRankClickListener.getPanelItem(command, user).getItem()); panel.getInventory().setItem(slot, commandRankClickListener.getPanelItem(command, user).getItem());
// Save config
plugin.saveConfig();
} else { } else {
user.getPlayer().playSound(user.getLocation(), Sound.BLOCK_METAL_HIT, 1F, 1F); user.getPlayer().playSound(user.getLocation(), Sound.BLOCK_METAL_HIT, 1F, 1F);
} }

View File

@ -1,5 +1,5 @@
/** /**
* *
*/ */
package world.bentobox.bentobox.listeners.flags.clicklisteners; package world.bentobox.bentobox.listeners.flags.clicklisteners;
@ -30,7 +30,7 @@ import world.bentobox.bentobox.util.Util;
* *
*/ */
public class CommandRankClickListener implements ClickHandler { public class CommandRankClickListener implements ClickHandler {
private BentoBox plugin = BentoBox.getInstance(); private BentoBox plugin = BentoBox.getInstance();
/* (non-Javadoc) /* (non-Javadoc)
@ -107,7 +107,7 @@ public class CommandRankClickListener implements ClickHandler {
List<String> result = new ArrayList<>(); List<String> result = new ArrayList<>();
plugin.getCommandsManager().getCommands().values().stream() plugin.getCommandsManager().getCommands().values().stream()
.filter(c -> c.getWorld() != null && c.getWorld().equals(world)) .filter(c -> c.getWorld() != null && c.getWorld().equals(world))
.forEach(c -> result.addAll(getCmdRecursively("/", c))); .forEach(c -> result.addAll(getCmdRecursively("/", c)));
if (result.size() > 49) { if (result.size() > 49) {
Bukkit.getLogger().severe("Number of rank setting commands is too big for GUI"); Bukkit.getLogger().severe("Number of rank setting commands is too big for GUI");
result.subList(49, result.size()).clear(); result.subList(49, result.size()).clear();
@ -127,7 +127,7 @@ public class CommandRankClickListener implements ClickHandler {
if (cc.isConfigurableRankCommand()) { if (cc.isConfigurableRankCommand()) {
result.add(newLabel); result.add(newLabel);
} }
cc.getSubCommands().values().forEach(s -> result.addAll(getCmdRecursively(newLabel + " ", s))); cc.getSubCommands().values().forEach(s -> result.addAll(getCmdRecursively(newLabel + " ", s)));
return result; return result;
} }