Advertisement
Guest User

Untitled

a guest
Aug 13th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. package de.byToxoDev.main.File;
  2.  
  3. import de.byToxoDev.main.Main;
  4. import org.bukkit.configuration.file.YamlConfiguration;
  5.  
  6. import java.io.File;
  7. import java.util.List;
  8. public class ConfigHandler {
  9.  
  10. File f;
  11.  
  12. public ConfigHandler(File f){
  13.  
  14. this.f = f;
  15.  
  16. }
  17. public String getString(String path) {
  18.  
  19. YamlConfiguration cfg = YamlConfiguration.loadConfiguration(this.f);
  20. return cfg.getString(path).replace("&", "§");
  21. }
  22. public Integer getInt(String path) {
  23.  
  24. YamlConfiguration cfg = YamlConfiguration.loadConfiguration(this.f);
  25. return cfg.getInt(path);
  26. }
  27. public Double getDouble(String path) {
  28.  
  29. YamlConfiguration cfg = YamlConfiguration.loadConfiguration(this.f);
  30. return cfg.getDouble(path);
  31. }
  32. public List<String> getList(String path) {
  33.  
  34. YamlConfiguration cfg = YamlConfiguration.loadConfiguration(this.f);
  35. return cfg.getStringList(path);
  36.  
  37. }
  38.  
  39. public void set(String path, Object o){
  40.  
  41. YamlConfiguration cfg = YamlConfiguration.loadConfiguration(this.f);
  42. cfg.set(path, o);
  43.  
  44. try {
  45.  
  46. cfg.save(this.f);
  47.  
  48. } catch (Exception e){
  49.  
  50. Main.getInstane().log("&4Es ist ein Fehler unterlaufen!" + e.getMessage());
  51.  
  52. }
  53.  
  54. }
  55.  
  56. public File getFile() {
  57. return f;
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement