use of net.runelite.http.api.config.Configuration in project runelite by runelite.
the class ConfigManager method load.
public void load() {
if (client == null) {
loadFromFile();
return;
}
Configuration configuration;
try {
configuration = client.get();
} catch (IOException ex) {
log.debug("Unable to load configuration from client, using saved configuration from disk", ex);
loadFromFile();
return;
}
if (configuration.getConfig().isEmpty()) {
log.debug("No configuration from client, using saved configuration on disk");
loadFromFile();
return;
}
properties.clear();
for (ConfigEntry entry : configuration.getConfig()) {
log.debug("Loading configuration value from client {}: {}", entry.getKey(), entry.getValue());
final String[] split = entry.getKey().split("\\.");
final String groupName = split[0];
final String key = split[1];
final String value = entry.getValue();
final String oldValue = (String) properties.setProperty(entry.getKey(), value);
ConfigChanged configChanged = new ConfigChanged();
configChanged.setGroup(groupName);
configChanged.setKey(key);
configChanged.setOldValue(oldValue);
configChanged.setNewValue(value);
eventBus.post(configChanged);
}
try {
saveToFile();
log.debug("Updated configuration on disk with the latest version");
} catch (IOException ex) {
log.warn("Unable to update configuration on disk", ex);
}
}
use of net.runelite.http.api.config.Configuration in project runelite by runelite.
the class ConfigService method get.
@RequestMapping
public Configuration get(HttpServletRequest request, HttpServletResponse response) throws IOException {
SessionEntry session = auth.handle(request, response);
if (session == null) {
return null;
}
List<ConfigEntry> config;
try (Connection con = sql2o.open()) {
config = con.createQuery("select `key`, value from config where user = :user").addParameter("user", session.getUser()).executeAndFetch(ConfigEntry.class);
}
return new Configuration(config);
}
Aggregations