mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2024-11-25 19:45:54 +01:00
Saving enhancements.
This commit is contained in:
parent
d0dc9be979
commit
135b0d7f08
@ -396,8 +396,7 @@ public final class PurpleBot {
|
||||
} else {
|
||||
sender.sendMessage("User '" + user + "' is now muted.");
|
||||
muteList.get(channelName).add(user);
|
||||
config.set("channels." + encodeChannel(getConfigChannelName(channelName)) + ".muted", muteList.get(channelName));
|
||||
saveConfig();
|
||||
saveConfig("channels." + encodeChannel(getConfigChannelName(channelName)) + ".muted", muteList.get(channelName));
|
||||
}
|
||||
}
|
||||
|
||||
@ -412,7 +411,6 @@ public final class PurpleBot {
|
||||
} else {
|
||||
sender.sendMessage("Muted users for " + channelName
|
||||
+ ": " + Joiner.on(", ").join(muteList.get(channelName)));
|
||||
saveConfig();
|
||||
}
|
||||
}
|
||||
|
||||
@ -426,8 +424,7 @@ public final class PurpleBot {
|
||||
if (muteList.get(channelName).contains(user)) {
|
||||
sender.sendMessage("User '" + user + "' is no longer muted.");
|
||||
muteList.get(channelName).remove(user);
|
||||
config.set("channels." + encodeChannel(getConfigChannelName(channelName)) + ".muted", muteList.get(channelName));
|
||||
saveConfig();
|
||||
saveConfig("channels." + encodeChannel(getConfigChannelName(channelName)) + ".muted", muteList.get(channelName));
|
||||
} else {
|
||||
sender.sendMessage("User '" + user + "' is not muted.");
|
||||
}
|
||||
@ -549,6 +546,17 @@ public final class PurpleBot {
|
||||
plugin.logError(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param section
|
||||
* @param obj
|
||||
*/
|
||||
public void saveConfig(String section, Object obj) {
|
||||
plugin.logDebug("Saving [" + section + "]: " + obj.toString());
|
||||
config.set(section, obj);
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
@ -567,8 +575,8 @@ public final class PurpleBot {
|
||||
}
|
||||
});
|
||||
sender.sendMessage("Setting nickname to " + newNick);
|
||||
config.set("nick", newNick);
|
||||
saveConfig();
|
||||
saveConfig("nick", newNick);
|
||||
|
||||
}
|
||||
|
||||
public void asyncJoinChannel(final String channelName, final String password) {
|
||||
@ -626,15 +634,13 @@ public final class PurpleBot {
|
||||
+ "Login set to " + ChatColor.WHITE
|
||||
+ newLogin + ChatColor.DARK_PURPLE
|
||||
+ ". Reload the bot for the change to take effect.");
|
||||
config.set("login", newLogin);
|
||||
saveConfig();
|
||||
saveConfig("login", newLogin);
|
||||
}
|
||||
|
||||
private void sanitizeServerName() {
|
||||
botServer = botServer.replace("^.*\\/\\/", "");
|
||||
botServer = botServer.replace(":\\d+$", "");
|
||||
config.set("server", botServer);
|
||||
saveConfig();
|
||||
saveConfig("server", botServer);
|
||||
}
|
||||
|
||||
private boolean loadConfig() {
|
||||
@ -971,8 +977,7 @@ public final class PurpleBot {
|
||||
* @param delay
|
||||
*/
|
||||
public void setIRCDelay(CommandSender sender, long delay) {
|
||||
config.set("message-delay", delay);
|
||||
saveConfig();
|
||||
saveConfig("message-delay", delay);
|
||||
sender.sendMessage(ChatColor.DARK_PURPLE
|
||||
+ "IRC message delay changed to "
|
||||
+ ChatColor.WHITE + delay + ChatColor.DARK_PURPLE + " ms. "
|
||||
@ -1680,9 +1685,8 @@ public final class PurpleBot {
|
||||
String tTopic = tokenizedTopic(topic);
|
||||
if (channel != null) {
|
||||
setTheTopic(channel, tTopic);
|
||||
config.set("channels." + encodeChannel(getConfigChannelName(channelName)) + ".topic", topic);
|
||||
channelTopic.put(channelName, topic);
|
||||
saveConfig();
|
||||
saveConfig("channels." + encodeChannel(getConfigChannelName(channelName)) + ".topic", topic);
|
||||
channelTopic.put(channelName, topic);
|
||||
sender.sendMessage("IRC topic for " + channelName + " changed to \"" + topic + "\"");
|
||||
} else {
|
||||
sender.sendMessage("Invalid channel: " + channelName);
|
||||
@ -1733,9 +1737,9 @@ public final class PurpleBot {
|
||||
}
|
||||
sanitizeServerName();
|
||||
autoConnect = auto;
|
||||
config.set("server", botServer);
|
||||
config.set("port", botServerPort);
|
||||
config.set("autoconnect", autoConnect);
|
||||
saveConfig("server", botServer);
|
||||
saveConfig("port", botServerPort);
|
||||
saveConfig("autoconnect", autoConnect);
|
||||
|
||||
sender.sendMessage("IRC server changed to \"" + botServer + ":"
|
||||
+ botServerPort + "\". (AutoConnect: "
|
||||
@ -1757,8 +1761,7 @@ public final class PurpleBot {
|
||||
+ ChatColor.RESET + " has been added to the ops list.");
|
||||
opsList.get(channelName).add(userMask);
|
||||
}
|
||||
config.set("channels." + encodeChannel(getConfigChannelName(channelName)) + ".ops", opsList.get(channelName));
|
||||
saveConfig();
|
||||
saveConfig("channels." + encodeChannel(getConfigChannelName(channelName)) + ".ops", opsList.get(channelName));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1776,8 +1779,7 @@ public final class PurpleBot {
|
||||
+ ChatColor.RESET + " has been added to the voices list.");
|
||||
voicesList.get(channelName).add(userMask);
|
||||
}
|
||||
config.set("channels." + encodeChannel(getConfigChannelName(channelName)) + ".voices", voicesList.get(channelName));
|
||||
saveConfig();
|
||||
saveConfig("channels." + encodeChannel(getConfigChannelName(channelName)) + ".voices", voicesList.get(channelName));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1795,8 +1797,7 @@ public final class PurpleBot {
|
||||
sender.sendMessage("User mask " + ChatColor.WHITE + userMask
|
||||
+ ChatColor.RESET + " is not in the ops list.");
|
||||
}
|
||||
config.set("channels." + encodeChannel(getConfigChannelName(channelName)) + ".ops", opsList.get(channelName));
|
||||
saveConfig();
|
||||
saveConfig("channels." + encodeChannel(getConfigChannelName(channelName)) + ".ops", opsList.get(channelName));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1814,8 +1815,8 @@ public final class PurpleBot {
|
||||
sender.sendMessage("User mask " + ChatColor.WHITE + userMask
|
||||
+ ChatColor.RESET + " is not in the voices list.");
|
||||
}
|
||||
config.set("channels." + encodeChannel(getConfigChannelName(channelName)) + ".voices", voicesList.get(channelName));
|
||||
saveConfig();
|
||||
saveConfig("channels." + encodeChannel(getConfigChannelName(channelName)) + ".voices", voicesList.get(channelName));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1926,8 +1927,6 @@ public final class PurpleBot {
|
||||
String channelName = channel.getName();
|
||||
String tTopic = tokenizedTopic(topic);
|
||||
if (setBy.equals(botNick)) {
|
||||
//config.set("channels." + encodeChannel(channelName) + ".topic", topic);
|
||||
//saveConfig();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -3160,4 +3159,5 @@ public final class PurpleBot {
|
||||
plugin.logInfo("Trying alternate nick " + botNick);
|
||||
bot.sendIRC().changeNick(botNick);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user