mirror of
https://github.com/darksaid98/TownyChat.git
synced 2026-12-03 06:28:57 +00:00
Finalized per-world system. Still not loading any settings from newly
made chatconfig.
This commit is contained in:
1 parent
094eab4ad4
commit
8535894e41
2 files changed
+28
-11
No files matched your search
@@ -153,7 +153,7 @@ public enum ChatConfigNodes {
|
|||||||
MODIFY_CHAT_PER_WORLD(
|
MODIFY_CHAT_PER_WORLD(
|
||||||
"modify_chat.per_world",
|
"modify_chat.per_world",
|
||||||
"false",
|
"false",
|
||||||
"# This is used for when you don't have another plugin to format chat.",
|
"# If true the chat formats will be read from below to allow per world formatting.",
|
||||||
"# These can then be altered individually."),
|
"# These can then be altered individually."),
|
||||||
MODIFY_CHAT_ALONE_MESSAGE(
|
MODIFY_CHAT_ALONE_MESSAGE(
|
||||||
"modify_chat.alone_message",
|
"modify_chat.alone_message",
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.palmergames.bukkit.TownyChat.util.FileMgmt;
|
|||||||
import com.palmergames.bukkit.config.ConfigNodes;
|
import com.palmergames.bukkit.config.ConfigNodes;
|
||||||
import com.palmergames.bukkit.towny.object.TownyUniverse;
|
import com.palmergames.bukkit.towny.object.TownyUniverse;
|
||||||
import com.palmergames.bukkit.towny.object.TownyWorld;
|
import com.palmergames.bukkit.towny.object.TownyWorld;
|
||||||
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -63,6 +64,7 @@ public class ChatSettings extends tag_formats {
|
|||||||
addComment(root.getRoot(), root.getComments());
|
addComment(root.getRoot(), root.getComments());
|
||||||
if (root.getRoot() == ChatConfigNodes.WORLDS.getRoot()) {
|
if (root.getRoot() == ChatConfigNodes.WORLDS.getRoot()) {
|
||||||
// Per-worlds section.
|
// Per-worlds section.
|
||||||
|
// setNewProperty(root.getRoot(), root.getDefault());
|
||||||
setWorldDefaults();
|
setWorldDefaults();
|
||||||
|
|
||||||
} else if (root.getRoot() == ChatConfigNodes.VERSION.getRoot()) {
|
} else if (root.getRoot() == ChatConfigNodes.VERSION.getRoot()) {
|
||||||
@@ -79,20 +81,25 @@ public class ChatSettings extends tag_formats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void setWorldDefaults() {
|
private static void setWorldDefaults() {
|
||||||
|
if (perWorld()) {
|
||||||
if (!chatConfig.contains(ChatConfigNodes.WORLDS.getRoot())) {
|
|
||||||
for (TownyWorld world : TownyUniverse.getDataSource().getWorlds()) {
|
for (TownyWorld world : TownyUniverse.getDataSource().getWorlds()) {
|
||||||
newChatConfig.createSection("worlds." + world);
|
if (!chatConfig.contains("worlds." + world )
|
||||||
ConfigurationSection worldsection = newChatConfig.getConfigurationSection("worlds." + world);
|
|| !chatConfig.contains("worlds." + world + ".global")
|
||||||
worldsection.set("global", "Object");
|
|| !chatConfig.contains("worlds." + world + ".town")
|
||||||
worldsection.set("town", "Object");
|
|| !chatConfig.contains("worlds." + world + ".nation")
|
||||||
worldsection.set("nation", "Object");
|
|| !chatConfig.contains("worlds." + world + ".default")) {
|
||||||
worldsection.set("default", "Object");
|
newChatConfig.createSection("worlds." + world);
|
||||||
|
ConfigurationSection worldsection = newChatConfig.getConfigurationSection("worlds." + world);
|
||||||
|
worldsection.set("global", (chatConfig.get("worlds." + world + ".global")!= null) ? chatConfig.get("worlds." + world + ".global") : ChatConfigNodes.CHANNEL_FORMATS_GLOBAL.getDefault());
|
||||||
|
worldsection.set("town", (chatConfig.get("worlds." + world + ".town")!= null) ? chatConfig.get("worlds." + world + ".town") : ChatConfigNodes.CHANNEL_FORMATS_TOWN.getDefault());
|
||||||
|
worldsection.set("nation", (chatConfig.get("worlds." + world + ".nation")!= null) ? chatConfig.get("worlds." + world + ".nation") : ChatConfigNodes.CHANNEL_FORMATS_NATION.getDefault());
|
||||||
|
worldsection.set("default", (chatConfig.get("worlds." + world + ".default")!= null) ? chatConfig.get("worlds." + world + ".default") : ChatConfigNodes.CHANNEL_FORMATS_DEFAULT.getDefault());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newChatConfig.set(ChatConfigNodes.WORLDS.getRoot(), chatConfig.get(ChatConfigNodes.WORLDS.getRoot()));
|
if (chatConfig.contains(ChatConfigNodes.WORLDS.getRoot()))
|
||||||
|
newChatConfig.set(ChatConfigNodes.WORLDS.getRoot(), chatConfig.get(ChatConfigNodes.WORLDS.getRoot()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addComment(String root, String... comments) {
|
public static void addComment(String root, String... comments) {
|
||||||
@@ -122,6 +129,16 @@ public class ChatSettings extends tag_formats {
|
|||||||
private static void sendError(String msg) {
|
private static void sendError(String msg) {
|
||||||
System.out.println("[TownyChat] Error could not read " + msg);
|
System.out.println("[TownyChat] Error could not read " + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean perWorld() {
|
||||||
|
|
||||||
|
return getBoolean(ChatConfigNodes.MODIFY_CHAT_PER_WORLD);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean getBoolean(ChatConfigNodes node) {
|
||||||
|
|
||||||
|
return Boolean.parseBoolean(chatConfig.getString(node.getRoot().toLowerCase(), node.getDefault()));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the formatGroups
|
* @return the formatGroups
|
||||||
|
|||||||
Reference in new issue
Block a user