Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package it.fw.smistamento;
- import java.io.File;
- import java.io.IOException;
- import java.io.InputStream;
- import java.util.logging.Level;
- import org.bukkit.ChatColor;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.plugin.java.JavaPlugin;
- public class main extends JavaPlugin{
- private FileConfiguration statistica = null;
- private File statisticaFile = null;
- public static main plugin;
- @Override
- public void onEnable(){
- getLogger().info("onEnable has been invoked!");
- this.saveDefaultConfig();
- }//end onEnable
- @Override
- public void onDisable(){
- getLogger().info("onDisable has been invoked!");
- }//end onDisable
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- if (cmd.getName().equalsIgnoreCase("smista")) {
- //comando help
- if (args.length > 0 && args[1].equalsIgnoreCase("help")) {
- sender.sendMessage("------ " + ChatColor.YELLOW + "Smista Help " + ChatColor.RESET +" ------");
- sender.sendMessage(ChatColor.RED + "/smista help:" + ChatColor.GRAY + " Ti da tutti i comandi disponibili di questo plugin.");
- sender.sendMessage(ChatColor.RED + "/smista squadre:" + ChatColor.GRAY + " Smista le squadre.");
- return true;
- }//end if
- //comando squadre
- if (args.length > 0 && args[1].equalsIgnoreCase("squadre")) {
- this.getServer().getOnlinePlayers();
- }//end if
- return true;
- }//end if
- return false;
- }//end onCommand
- public void reloadStatistica ( ) {
- if ( statisticaFile == null ) {
- statisticaFile = new File ( getDataFolder ( ) , "customConfig.yml" ) ;
- }
- statistica = YamlConfiguration. loadConfiguration ( statisticaFile ) ;
- // Cercare inadempienze nella jar
- InputStream defConfigStream = this.getResource("statisticaFile.yml");
- if ( defConfigStream != null ) {
- YamlConfiguration defConfig = YamlConfiguration. loadConfiguration ( defConfigStream ) ;
- statistica. setDefaults ( defConfig ) ;
- }
- }
- public FileConfiguration getCustomConfig() {
- if (statistica == null) {
- reloadStatistica();
- }
- return statistica;
- }
- public void saveCustomConfig() {
- if (statistica == null || statisticaFile == null) {
- return;
- }
- try {
- getCustomConfig().save(statisticaFile);
- } catch (IOException ex) {
- getLogger().log(Level.SEVERE, "Could not save config to " + statisticaFile, ex);
- }
- }
- public void saveDefaultConfig() {
- if (statisticaFile == null) {
- statisticaFile = new File(getDataFolder(), "customConfig.yml");
- }
- if (!statisticaFile.exists()) {
- plugin.saveResource("customConfig.yml", false);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement