ChatConfig.java 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package com.gmail.nossr50.config;
  2. import com.gmail.nossr50.datatypes.chat.ChatChannel;
  3. import com.gmail.nossr50.util.text.StringUtils;
  4. import org.jetbrains.annotations.NotNull;
  5. public class ChatConfig extends AutoUpdateConfigLoader {
  6. private static ChatConfig instance;
  7. private ChatConfig() {
  8. super("chat.yml");
  9. validate();
  10. }
  11. public static ChatConfig getInstance() {
  12. if (instance == null) {
  13. instance = new ChatConfig();
  14. }
  15. return instance;
  16. }
  17. @Override
  18. protected void loadKeys() {
  19. //Sigh this old config system...
  20. }
  21. @Override
  22. protected boolean validateKeys() {
  23. return true;
  24. }
  25. public boolean isChatEnabled() {
  26. return config.getBoolean("Chat.Enable", true);
  27. }
  28. public boolean isChatChannelEnabled(@NotNull ChatChannel chatChannel) {
  29. String key = "Chat.Channels." + StringUtils.getCapitalized(chatChannel.toString()) + ".Enable";
  30. return config.getBoolean(key, true);
  31. }
  32. /**
  33. * Whether or not to use display names for players in target {@link ChatChannel}
  34. * @param chatChannel target chat channel
  35. * @return true if display names should be used
  36. */
  37. public boolean useDisplayNames(@NotNull ChatChannel chatChannel) {
  38. String key = "Chat.Channels." + StringUtils.getCapitalized(chatChannel.toString()) + ".Use_Display_Names";
  39. return config.getBoolean(key, true);
  40. }
  41. public boolean isSpyingAutomatic() {
  42. return config.getBoolean("Chat.Channels.Party.Spies.Automatically_Enable_Spying", false);
  43. }
  44. }