mirror of
https://github.com/darksaid98/TownyChat.git
synced 2026-12-01 14:38:57 +00:00
Merge remote-tracking branch 'upstream/master' into feat/adventure
This commit is contained in:
3 files changed
+21
-18
No files matched your search
@@ -7,7 +7,7 @@
|
||||
<groupId>com.palmergames.bukkit</groupId>
|
||||
<artifactId>TownyChat</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>0.111</version>
|
||||
<version>0.112</version>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
|
||||
@@ -478,4 +478,7 @@ v0.110:
|
||||
- Update min. Towny version to 0.100.0.0.
|
||||
- Add CommentedConfiguration support to the channels.yml.
|
||||
- The Comments in the file have been updated to include missing channel flags.
|
||||
- It is now possible to update the file comments as new flags are added.
|
||||
- It is now possible to update the file comments as new flags are added.
|
||||
v0.111:
|
||||
- Fix creation of channels.yml, opting to make channels into proper ConfigurationSections rather than Maps which aren't easily read on their first creation and then subsequent load.
|
||||
- It is no longer recommended to delete your channels.yml when updating from TownyChat 0.109 or earlier.
|
||||
@@ -19,7 +19,6 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -39,7 +38,7 @@ public class ChannelsSettings {
|
||||
if (FileMgmt.checkOrCreateFile(filepath)) {
|
||||
File file = new File(filepath);
|
||||
|
||||
// read the config.yml into memory
|
||||
// read the channels.yml into memory
|
||||
channelConfig = new CommentedConfiguration(file.toPath());
|
||||
if (!channelConfig.load()) {
|
||||
Bukkit.getLogger().severe("[TownyChat] Failed to load Channels.yml!");
|
||||
@@ -93,7 +92,6 @@ public class ChannelsSettings {
|
||||
}
|
||||
|
||||
private static void tryAndSetDefaultChannels() {
|
||||
|
||||
if (channelConfig.contains(CHANNELS_ROOT)) {
|
||||
// There is already a root channels present, not our first run.
|
||||
newChannelConfig.set(CHANNELS_ROOT, channelConfig.get(CHANNELS_ROOT));
|
||||
@@ -102,20 +100,23 @@ public class ChannelsSettings {
|
||||
Chat.getTownyChat().getLogger().info("TownyChat creating default channels.yml file.");
|
||||
|
||||
newChannelConfig.createSection(CHANNELS_ROOT);
|
||||
for (String channel : DEFAULT_CHANNELS)
|
||||
newChannelConfig.createSection(CHANNELS_ROOT + "." + channel);
|
||||
DEFAULT_CHANNELS.forEach(channel -> newChannelConfig.createSection(CHANNELS_ROOT + "." + channel));
|
||||
|
||||
ConfigurationSection configurationSection = newChannelConfig.getConfigurationSection(CHANNELS_ROOT);
|
||||
configurationSection.set("general", generalDefaults());
|
||||
configurationSection.set("town", townDefaults());
|
||||
configurationSection.set("nation", nationDefaults());
|
||||
configurationSection.set("alliance", allianceDefaults());
|
||||
configurationSection.set("admin", adminDefaults());
|
||||
configurationSection.set("mod", modDefaults());
|
||||
configurationSection.set("local", localDefaults());
|
||||
setConfigSection("general", generalDefaults());
|
||||
setConfigSection("town", townDefaults());
|
||||
setConfigSection("nation", nationDefaults());
|
||||
setConfigSection("alliance", allianceDefaults());
|
||||
setConfigSection("admin", adminDefaults());
|
||||
setConfigSection("mod", modDefaults());
|
||||
setConfigSection("local", localDefaults());
|
||||
}
|
||||
}
|
||||
|
||||
private static void setConfigSection(String section, Map<String,Object> settings) {
|
||||
ConfigurationSection configurationSection = newChannelConfig.getConfigurationSection(CHANNELS_ROOT + "." + section);
|
||||
settings.entrySet().stream().forEach(entry -> configurationSection.set(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
|
||||
private static Map<String, Object> generalDefaults() {
|
||||
Map<String, Object> channelMap = new LinkedHashMap<>();
|
||||
channelMap.put("commands", "g");
|
||||
@@ -208,7 +209,6 @@ public class ChannelsSettings {
|
||||
channelMap.put("channelTag", "&f[local]");
|
||||
channelMap.put("messagecolour", "&f");
|
||||
channelMap.put("permission", "towny.chat.local");
|
||||
channelMap.put("default", "true");
|
||||
channelMap.put("range", "100");
|
||||
return channelMap;
|
||||
}
|
||||
@@ -234,7 +234,7 @@ public class ChannelsSettings {
|
||||
Chat plugin = Chat.getTownyChat();
|
||||
|
||||
channelsKeys.forEach((channelName)-> {
|
||||
Channel channel = new StandardChannel(plugin, channelName.toLowerCase(Locale.ROOT));
|
||||
Channel channel = new StandardChannel(plugin, channelName);
|
||||
loadChannelSettings(channelName, channel);
|
||||
plugin.getChannelsHandler().addChannel(channel);
|
||||
});
|
||||
@@ -291,7 +291,7 @@ public class ChannelsSettings {
|
||||
*/
|
||||
public ChannelDetails(CommentedConfiguration channelsConfig, String name) {
|
||||
super();
|
||||
this.name = name.toLowerCase(Locale.ROOT);
|
||||
this.name = name;
|
||||
String path = CHANNELS_ROOT + "." + this.name;
|
||||
for (String key : channelsConfig.getConfigurationSection(path).getKeys(true)) {
|
||||
String innerPath = path + "." + key;
|
||||
|
||||
Reference in new issue
Block a user