Hi guys, I'm currently making a party plugin, and I'm trying to make a new file to keep player's nicknames in it Code: Main.newConfig(PartyFile, PartyConfig, Main.getInstance().getDataFolder() + File.separator + "Party" + File.separator + player.getName() + "Party.yml"); and basically what is happening it that "PartyFile" and "PartyConfig" are not recognised, while I'm clearly telling him what they are in my main class (my main class: ) Code: public static void newConfig(File file, FileConfiguration config, String place) { file = new File(place); if(!file.exists()) { try { file.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } config = (YamlConfiguration.loadConfiguration(file)); try { config.save(file); } catch (IOException e) { e.printStackTrace(); } } If you have any ideas/questions please go ahead I'm sick of it (I'm not sure if I'm telling enough though)
@Praxounet 1. I would recommend the player's uuid and not name. (they could change name) 2. Not sure if this has anything to do with it but maybe try this instead: Code:Java public static void newConfig(String path) { File file = new File(path); if (!file.exists()) { try { file.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } //The following part isn't really needed if you don't write something to the file. FileConfiguration config = YamlConfiguration.loadConfiguration(file); try { config.save(file); } catch (IOException e) { e.printStackTrace(); }} Other than that you could print some messages to the console in between the code.
@Praxounet It might be a bad idea to use names as file names because it would contain characters that are not allowed as file names. (I don't know the minecraft naming rules, so I am not sure.) And like Karim said, you should not store the names of players, but their UUID. Could you post your entire main class so we can check what goes wrong exactly?
sure ! This is my main class : Code: package fr.praxounet.party; import java.io.File; import java.io.IOException; import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.plugin.java.JavaPlugin; import fr.praxounet.party.commands.party; import fr.praxounet.party.events.EventsClass; import net.md_5.bungee.api.ChatColor; public class Main extends JavaPlugin { private static Main instance; public static Main getInstance() { return instance; } fr.zeprof2code.core.core core = (fr.zeprof2code.core.core) Bukkit.getPluginManager().getPlugin("schaferrcore"); public void onEnable() { instance = this; getServer().getConsoleSender().sendMessage(ChatColor.DARK_GREEN + "\n\n[PARTY] plugin by Praxounet has been activated.\n"); getCommand("party").setExecutor(new party()); getServer().getPluginManager().registerEvents(new EventsClass(), this); getConfig().options().copyDefaults(true); saveConfig(); } public void onDisable() { getServer().getConsoleSender().sendMessage(ChatColor.RED + "\n\n[Hub] plugin by Praxounet has been desactived.\n"); } public static void newConfig(File file, FileConfiguration config, String place) { file = new File(place); if(!file.exists()) { try { file.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } config = (YamlConfiguration.loadConfiguration(file)); try { config.save(file); } catch (IOException e) { e.printStackTrace(); } } } (I will apply the necessary adjustments later ! )