forked from fzorb/noThankYouMicrosoft
basic database config thing
This commit is contained in:
parent
3fd16f2957
commit
b6b80874c8
2 changed files with 30 additions and 0 deletions
|
@ -1,21 +1,48 @@
|
|||
package xyz.fzorb.noThankYouMicrosoft;
|
||||
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public final class NoThankYouMicrosoft extends JavaPlugin {
|
||||
|
||||
private static JavaPlugin instance;
|
||||
private File databaseFile;
|
||||
private FileConfiguration databaseFileConfig;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
this.saveDefaultConfig();
|
||||
createDatabaseConfig();
|
||||
this.getServer().getPluginManager().registerEvents(new messageListener(), this);
|
||||
}
|
||||
|
||||
private void createDatabaseConfig() {
|
||||
databaseFile = new File(getDataFolder(), "database.yml");
|
||||
if (!databaseFile.exists()) {
|
||||
databaseFile.getParentFile().mkdirs();
|
||||
saveResource("database.yml", false);
|
||||
}
|
||||
|
||||
databaseFileConfig = new YamlConfiguration();
|
||||
try {
|
||||
databaseFileConfig.load(databaseFile);
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static JavaPlugin getInstance() {
|
||||
return instance;
|
||||
}
|
||||
public FileConfiguration getDatabase() {
|
||||
return this.databaseFileConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
|
3
src/main/resources/database.yml
Normal file
3
src/main/resources/database.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
players:
|
||||
uuid:
|
||||
flag: pride
|
Loading…
Add table
Add a link
Reference in a new issue