Advertisement
Guest User

T_Config

a guest
May 5th, 2016
2,549
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. package com.tke.aula9;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.util.List;
  6.  
  7. import org.bukkit.configuration.file.YamlConfiguration;
  8. import org.bukkit.plugin.java.JavaPlugin;
  9.  
  10. public class T_Config {
  11. public T_Config(JavaPlugin plugin, String nome) {
  12. this.plugin = plugin;
  13. setName(nome);
  14. reloadConfig();
  15. }
  16.  
  17. private JavaPlugin plugin;
  18. private String name;
  19. private File file;
  20. public JavaPlugin getPlugin() {
  21. return plugin;
  22. }
  23. public void setPlugin(JavaPlugin plugin) {
  24. this.plugin = plugin;
  25. }
  26. public String getName() {
  27. return name;
  28. }
  29. public void setName(String name) {
  30. this.name = name;
  31. }
  32. public File getFile() {
  33. return file;
  34. }
  35. public YamlConfiguration getConfig() {
  36. return config;
  37. }
  38. private YamlConfiguration config;
  39. public void saveConfig() {
  40. try {
  41. getConfig().save(getFile());
  42. } catch (IOException e) {
  43. e.printStackTrace();
  44. }
  45. }
  46. public void saveDefault() {
  47. getConfig().options().copyDefaults(true);
  48. }
  49. public void saveDefaultConfig() {
  50. getPlugin().saveResource(getName(), false);
  51. }
  52. public void reloadConfig() {
  53. file = new File(getPlugin().getDataFolder(),getName());
  54. config = YamlConfiguration.loadConfiguration(getFile());
  55.  
  56. }
  57. public void deleteConfig() {
  58. getFile().delete();
  59. }
  60. public boolean existeConfig() {
  61. return getFile().exists();
  62. }
  63.  
  64. public String getString(String path) {
  65. return getConfig().getString(path);
  66. }
  67.  
  68. public int getInt(String path) {
  69. return getConfig().getInt(path);
  70. }
  71.  
  72. public boolean getBoolean(String path) {
  73. return getConfig().getBoolean(path);
  74. }
  75.  
  76. public double getDouble(String path) {
  77. return getConfig().getDouble(path);
  78. }
  79.  
  80. public List<?> getList(String path){
  81. return getConfig().getList(path);
  82. }
  83. public boolean contains(String path) {
  84. return getConfig().contains(path);
  85. }
  86.  
  87. public void set(String path, Object value) {
  88. getConfig().set(path, value);
  89. }
  90.  
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement