I have created a quite basic plugin, however whatever i try, a Config file wont be created, and i don't know how to implement into my code, i need a solution, what could i add to make it create the config file, then read the config? Code: package me.n3wham.Ironman; import java.util.logging.Logger; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; public class Ironman extends JavaPlugin{ public final Logger logger= Logger.getLogger("Minecraft"); public static Ironman plugin; public void onDisable(){ PluginDescriptionFile pdffile = this.getDescription(); this.logger.info(pdffile.getName() + " Has Been Disabled"); } public void onEnable(){ PluginDescriptionFile pdffile = this.getDescription(); this.logger.info(pdffile.getName() + " Version " + pdffile.getVersion() + " Has Been Enabled!"); } public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){ Player player = (Player) sender; World world = player.getWorld(); if(commandLabel.equalsIgnoreCase("ironmode")) { ItemStack iron_chestplate = new ItemStack(Material.IRON_CHESTPLATE, 1); ItemStack iron_helmet = new ItemStack(Material.IRON_CHESTPLATE, 1); ItemStack iron_leggings = new ItemStack(Material.IRON_LEGGINGS, 1); ItemStack iron_boots = new ItemStack(Material.IRON_BOOTS, 1); PlayerInventory pi = player.getInventory(); pi.setChestplate(iron_chestplate); pi.setLeggings(iron_leggings); pi.setHelmet(iron_helmet); pi.setBoots(iron_boots); player.sendMessage(ChatColor.RED + "CRUSHING TIME!!"); } if(commandLabel.equalsIgnoreCase("ironmode")&& args[0].equalsIgnoreCase("off")) { PlayerInventory pi1 = player.getInventory(); pi1.setHelmet(null); pi1.setChestplate(null); pi1.setLeggings(null); pi1.setBoots(null); player.sendMessage(ChatColor.DARK_RED + "CRUSHING TIME OVER! - HAVE FUN?"); } if(commandLabel.equalsIgnoreCase("ironstrike")) { if(args.length ==0) { Block targetblock = player.getTargetBlock(null, 50); Location location = targetblock.getLocation(); world.strikeLightning(location); world.createExplosion(location, 4); } else if (args.length ==1) { if(player.getServer().getPlayer(args[0]) !=null) { Player targetplayer = player.getServer().getPlayer(args[0]); Location location = targetplayer.getLocation(); world.strikeLightning(location); player.sendMessage(ChatColor.GOLD + "Smiting player " + targetplayer.getDisplayName()); } else { player.sendMessage(ChatColor.RED + "Error: The player is offline"); } } else if (args.length >1) { player.sendMessage(ChatColor.RED + "Error: Too many arguments!"); } } return false; } { }} Code: world.createExplosion(location, 4); I would like to be able to set the explosion size? any help will be great!, thanks.
Have you tried: Code: public void loadConfiguration() { String path = "Settings.IronMan"; plugin.getConfig().addDefault(int, 4); plugin.getConfig().options().copyDefaults(true); plugin.saveConfig(); } That Should show: Code: settings: IronMan: 4 You need to add: Code: public void onEnable(){ loadConfiguration(); PluginDescriptionFile pdfFile = this.getDescription(); this.logger.info(pdfFile.getName () + " Has Been Enabled!"); } To your onEnable() so it creates a config if one isn't available. This is where I am stuck, as it wont seem to create the config.
[Tutorial/Beginner] Making configs | Bukkit Forums Introduction to the New Configuration - BukkitWiki [TUT] Bukkit's new FileConfiguration API! Create a YAML configuration! | Bukkit Forums
There are multiple ways to make a config. You can either have the plugin generate it, or create the file yourself. Let me know which one you want to make, and I'll tell you how to do it.