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;
|
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 org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public final class NoThankYouMicrosoft extends JavaPlugin {
|
public final class NoThankYouMicrosoft extends JavaPlugin {
|
||||||
|
|
||||||
private static JavaPlugin instance;
|
private static JavaPlugin instance;
|
||||||
|
private File databaseFile;
|
||||||
|
private FileConfiguration databaseFileConfig;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
instance = this;
|
instance = this;
|
||||||
this.saveDefaultConfig();
|
this.saveDefaultConfig();
|
||||||
|
createDatabaseConfig();
|
||||||
this.getServer().getPluginManager().registerEvents(new messageListener(), this);
|
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() {
|
public static JavaPlugin getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
public FileConfiguration getDatabase() {
|
||||||
|
return this.databaseFileConfig;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
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