I can't use this String...

Discussion in 'Plugin Development' started by Hiddlebimpf TV [German], Oct 15, 2019.

Thread Status:
Not open for further replies.
  1. Hello I have a Problem...
    I need a String from a public boolean, but I need this String in void (Pictures)

    Code:
    public class Main extends JavaPlugin {
           
    
        public boolean onCommand(CommandSender sender, Command cmd, String cmdlabel, String[] args) {
            final Player p = (Player) sender;
       
            if (cmd.getName().equalsIgnoreCase("register")) {
            /*need */    String pname = p.getName();
            /*need */   String pip = p.getAddress().getHostName();
                p.sendMessage("Du hast dich erfolgreich regestiert!");
                File file = new File("");
               
    }
    }
    
        public static File folder = new File("plugins/HeyAntiAlts/userdata");
        public static File file = new File("plugins/HeyAntiAlts/userdata/" + /*Here  I need the String "pname"*/ pname + ".yml");
        public static YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
    Can Someone Help me Please?
    :D
     
  2. Offline

    CraftCreeper6

  3. Offline

    robertlit

    1) If this is your whole main class, you might need to read the docs a bit more
    2) The sender isn't of type Player for sure, what if the command is sent from console
    For your question, as mentioned above create the file inside the onCommand method.
     
Thread Status:
Not open for further replies.

Share This Page