kevinn

Untitled

Apr 18th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.77 KB | None | 0 0
  1. package skinsrestorer.shared.storage;
  2.  
  3. import skinsrestorer.shared.utils.C;
  4. import skinsrestorer.shared.utils.YamlConfig;
  5.  
  6. import java.io.File;
  7. import java.lang.reflect.Field;
  8. import java.util.Arrays;
  9.  
  10. public class Locale {
  11. public static String PREFIX = "&e[&2SkinsRestorer&e]";
  12.  
  13. public static String HELP_SKIN_CLEAR = "Clears your skin.";
  14. public static String HELP_SKIN_CLEAR_OTHER = "Clears the skin of another player.";
  15. public static String HELP_SKIN_UPDATE = "Updates your skin.";
  16. public static String HELP_SKIN_UPDATE_OTHER = "Updates the skin of another player.";
  17. public static String HELP_SKIN_SET = "Sets your skin.";
  18. public static String HELP_SKIN_SET_OTHER = "Sets the skin of another player.";
  19. public static String HELP_SR_RELOAD = "Reloads the configuration file.";
  20. public static String HELP_SR_STATUS = "Checks plugin needed API services";
  21. public static String HELP_SR_DROP = "Drops the players skin data.";
  22. public static String HELP_SR_PROPS = "Displays the players current skin as properties.";
  23.  
  24. public static String PLAYER_HAS_NO_PERMISSION_SKIN = "&4Error&8: &cYou don't have permission to set this skin.";
  25. public static String PLAYER_HAS_NO_PERMISSION_URL = "&4Error&8: &cYou don't have permission to set skins by URL.";
  26. public static String SKIN_DISABLED = "&4Error&8: &cThis skin is disabled by an administrator.";
  27. public static String NOT_PREMIUM = "&4Error&8: &cPremium player with that name does not exist.";
  28. public static String INVALID_PLAYER = "&4Error&8: &c%player is not a valid username or URL.";
  29. public static String SKIN_COOLDOWN_NEW = "&4Error&8: &cYou can change your skin again in &e%s &cseconds.";
  30.  
  31. public static String SKIN_CHANGE_SUCCESS = "&2Your skin has been changed.";
  32. public static String SKIN_CLEAR_SUCCESS = "&2Your skin has been cleared.";
  33. public static String SKIN_CLEAR_ISSUER = "&2Skin cleared for player %player.";
  34.  
  35. public static String MS_UPDATING_SKIN = "&2Uploading skin, please wait...";
  36. public static String SUCCESS_UPDATING_SKIN = "&2Your skin has been updated.";
  37. public static String SUCCESS_UPDATING_SKIN_OTHER = "&2Skin updated for player %player.";
  38.  
  39. public static String ERROR_UPDATING_SKIN = "&4Error&8: &cAn error occurred while updating your skin. Please try again later!";
  40. public static String ERROR_UPDATING_URL = "&4Error&8: &cYou can't update custom url skins! \n&cRequest again using /skin url";
  41. public static String ERROR_INVALID_URLSKIN = "&4Error&8: &cInvalid skin url or format, \n&c try uploading your skin to imgur and right click copy imgurl \n&cFor guide see: \n&c&n&o https://github.com/SkinsRestorer/SkinsRestorerX/wiki/SkinURL";
  42. public static String ERROR_MS_FULL = "&4MS Error&8: &cAPI timed out while uploading your skin. Please try again later. (MineSkin)";
  43. public static String ERROR_MS_GENERIC = "&4MS Error&8: &c%error%";
  44. public static String GENERIC_ERROR = "&4Error&8: &cAn error occurred while requesting skin data, please try again later!";
  45. public static String WAIT_A_MINUTE = "&4Error&8: &cPlease wait a minute before requesting that skin again. (Rate Limited)";
  46.  
  47. public static String MENU_OPEN = "&2Opening the skins menu...";
  48. public static String MENU_TITLE = "&9Skins Menu - Page ";
  49. public static String NEXT_PAGE = "&a&l»&7 Next Page&a&l »";
  50. public static String PREVIOUS_PAGE = "&e&l«&7 Previous Page&e&l «";
  51. public static String REMOVE_SKIN = "&c&l[ &7Remove Skin&c&l ]";
  52. public static String SELECT_SKIN = "&2Click to select this skin";
  53.  
  54. public static String ADMIN_SET_SKIN = "&2You set %player's skin.";
  55. public static String SKIN_DATA_DROPPED = "&2Skin data for player %player dropped.";
  56. public static String STATUS_OK = "&2Mojang API connection successful!";
  57. public static String ALT_API_FAILED = "&4Error&8: &cSkin Data API is overloaded, please try again later!";
  58. public static String MS_API_FAILED = "&4Error&8: &cMineSkin API is overloaded, please try again later!";
  59. public static String NO_SKIN_DATA = "&4Error&8: &cNo skin data acquired! Does this player have a skin?";
  60. public static String RELOAD = "&2Config and Locale has been reloaded!";
  61. public static String OUTDATED = "&4You are running an outdated version of SkinsRestorer!\n&cPlease update to the latest version on Spigot: \n&ehttps://www.spigotmc.org/resources/skinsrestorer.2124/";
  62.  
  63. public static String SR_LINE = "&7&m----------------------------------------";
  64. public static String HELP_PLAYER = " &2&lSkinsRestorer &7- &f&lv%ver%"
  65. + "\n &2/skin <skinname> &7-&f Changes your skin."
  66. + "\n &2/skin update &7-&f Updates your skin."
  67. + "\n &2/skin clear &7-&f Clears your skin.";
  68.  
  69. //private static YamlConfig locale = new YamlConfig("plugins" + File.separator + "SkinsRestorer" + File.separator + "", "messages", true);
  70. private static YamlConfig locale;
  71.  
  72. public static final String[] IGNORE_PREFIX = {
  73. "HELP_",
  74. "MENU_OPEN",
  75. "MENU_TITLE",
  76. "NEXT_PAGE",
  77. "PREVIOUS_PAGE",
  78. "REMOVE_SKIN",
  79. "SELECT_SKIN",
  80. "SR_LINE"
  81. };
  82.  
  83. public static void load(String path) {
  84. System.out.println(Arrays.toString(IGNORE_PREFIX)); //testing
  85. try {
  86. locale = new YamlConfig(path + File.separator, "messages", true);
  87. locale.saveDefaultConfig();
  88. locale.reload();
  89.  
  90. for (Field f : Locale.class.getFields()) {
  91.  
  92. if (f.getType() != String.class)
  93. continue;
  94.  
  95. String parsed = C.c(locale.getString(f.getName(), f.get(null)));
  96.  
  97.  
  98. for (String IGNORE_PREFIX : IGNORE_PREFIX) {
  99. if (f.toString().contains(IGNORE_PREFIX)) {
  100.  
  101.  
  102. //if(!f.toString().contains("HELP_") && !Arrays.asList(IGNORE_PREFIX).contains(f.toString())) // array not working
  103. parsed = C.c(locale.getString("PREFIX", null)) + " " + parsed;
  104.  
  105. //System.out.println("string" + f); //testing
  106. System.out.println("MATCH = " + f.toString()); //testing
  107. //System.out.println("help_= " + f.toString().contains("HELP_")); //testing
  108. //System.out.println("ingore_prefix= " + Arrays.asList(IGNORE_PREFIX).contains(f.toString())); //testing
  109.  
  110. //}
  111. //}
  112. f.set(null, parsed);
  113. }
  114. } catch (Exception e) {
  115. System.out.println("§e[§2SkinsRestorer§e] §cCan't read messages.yml! Try removing it and restart your server.");
  116. }
  117. }
  118. }
Advertisement
Add Comment
Please, Sign In to add comment