Guest User

Untitled

a guest
Apr 19th, 2018
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. package Jamesst20.Minecraft;
  2.  
  3. import java.io.File;
  4.  
  5. import org.bukkit.configuration.file.FileConfiguration;
  6.  
  7. public class Configuration {
  8. static String Plugin = "[JamMinecraftUtility] ";
  9. static FileConfiguration config = JamMinecraftUtility.plugin.getConfig();
  10.  
  11. public static void start() {
  12. config.options().copyDefaults(true);
  13. JamMinecraftUtility.plugin.saveConfig();
  14.  
  15. JamMinecraftUtility.plugin
  16. .getConfig()
  17. .options()
  18. .header("###############################\n"
  19. + "JamMinecraftUtility was created by Jamesst20\n"
  20. + "You can change all the value below to what you want :)\n"
  21. + "Thanks to Jamesst20 :)\n"
  22. + "###############################\n");
  23.  
  24. if (JamMinecraftUtility.plugin.getConfig().getString(
  25. "settings.shutdownmessage", null) == null) {
  26. JamMinecraftUtility.plugin.getConfig().set("rights", "");
  27. System.out
  28. .println(Plugin
  29. + "[Config] Setting default rights, don't forget to add some admin.");
  30. JamMinecraftUtility.plugin.saveConfig();
  31. }
  32.  
  33. }
  34.  
  35. public static int senderHasRight(String playerName) {
  36. // return 0 if the user has no rights, 1 if the user is admin, 2 if the
  37. // user is a normal user.
  38. int right = 0;
  39. if (JamMinecraftUtility.plugin.getConfig()
  40. .getString("rights.normalUser").contains(playerName)) {
  41. right = 2;
  42. }
  43. if (JamMinecraftUtility.plugin.getConfig().getString("rights.admins")
  44. .contains(playerName)) {
  45. right = 1;
  46. }
  47. return right;
  48. }
  49.  
  50. public static void addAdmin(String adminName) {
  51. JamMinecraftUtility.plugin.getConfig().set("rights.admins", adminName);
  52. System.out.println(Plugin + "[Config] Adding new admin : " + adminName);
  53. JamMinecraftUtility.plugin.saveConfig();
  54. }
  55.  
  56. public static void addNormalUser(String adminName) {
  57. JamMinecraftUtility.plugin.getConfig().set("rights.normalUser",
  58. adminName);
  59. System.out.println(Plugin + "[Config] Adding new admin : " + adminName);
  60. JamMinecraftUtility.plugin.saveConfig();
  61. }
  62.  
  63. private static boolean fileExist(String pathPlusFileName) {
  64. File file = new File(pathPlusFileName);
  65. if (file.exists()) {
  66. return true;
  67. } else {
  68. return false;
  69. }
  70. }
  71. }
Add Comment
Please, Sign In to add comment