Lists

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

  1. How do i setup a private list for variables such as
    Code (Text):
        private List<String> variables(List<String> input) {
            input.replaceAll("{player}", player);
        }
    }
    how would i make that trace to the player who is using the gui/command which is in a different class and saved to a custom data file i need it for a ton of custom placeholders
     
  2. You could get the stream of the list, map the values to the values with the replacements, and collect the result using Collectors#toList(). Or, iterate over the list and replace the values one by one; or even better, use arrays instead of lists.
     
  3. Code (Text):
    private List<String> variables(List<String> input) {
            return input.stream().map(str -> str.replace("{player}", player)).collect(Collectors.toList());
        }