Solved Auto Variable Replacer

Discussion in 'Spigot Plugin Development' started by harveycat1, May 4, 2017.

  1. How could i make a private void Variable replace that will change all the variables in strings to actually variables with just like
    Code (Text):
            headl.addAll(plugin.getConfig().getStringList("GUI.Main.Info.Lore").Variables());
    i dont know what i would add from this
    Code (Text):
        private void variables() {


        }
     
  2. You can't. "Extension methods" exist in C#, but not in Java.
    You will have to create a method like this: private List<String> variables(List<String> input) { }
    And to use it: headl.addAll(variables(plugin.getConfig().getStringList("GUI.Main.Info.Lore")));
     
  3. i know that typed it wrong way sorry but how do i add lots of variables to it i dont want to have to put them in config i want them to be within the code
     
  4. i need a replace method that i can just make it replace any of the variables that i have chosen so if it was in the variables(test.test) it would replace 10 different variables with just that and would look something like variables.replace(%player%, Player.getName()) or something like that
     
  5. Okay, so make one? What's stopping you at this point? I believe you have everything you need (presuming you know how to iterate through a list), you just have to write the method.
     
  6. private List<String> variables(List<String> input) {

    variables(input.replaceAll("%Player%",
    }
    }
    Code (Text):
        private List<String> variables(List<String> input) {
           
            variables(input.replaceAll("%Player%",
        }
    }
    How can i setup something like
    Code (Text):
     Player p = Bukkit.getPlayer()
    as it doesnt allow for that method