blob: 4f39bbe9d9a7ac52a53816faac205348d5595beb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
package com.baitinq.primalmc.utils;
import com.baitinq.primalmc.Main;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOError;
import java.io.IOException;
public class ConfigurationManager {
private Main plugin = Main.getPlugin(Main.class);
public FileConfiguration playerscfg;
public File playersfile;
public void setup(){
if(!plugin.getDataFolder().exists()){
plugin.getDataFolder().mkdir();
}
playersfile = new File(plugin.getDataFolder(),"players.yml");
if(!playersfile.exists()){
try{
playersfile.createNewFile();
}catch (IOException e){
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.RED+"Could not create players.yml");
}
}
playerscfg = YamlConfiguration.loadConfiguration(playersfile);
}
public FileConfiguration getPlayers() {
return playerscfg;
}
public void SavePlayers(){
try{
playerscfg.save(playersfile);
}catch (IOException e){
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.RED+"Could not save players.yml");
}
}
public void ReloadPlayers(){
try{
playerscfg = YamlConfiguration.loadConfiguration(playersfile);
}catch(IOError e){
playerscfg = YamlConfiguration.loadConfiguration(playersfile);
}
}
}
|