1.8.8 How do I send a multiline message to players?

Discussion in 'Spigot Plugin Development' started by CodingCyClone, Jun 29, 2021.

  1. I am creating a faction map (not a java map) that returns the chunk owners by sending the player a message (maybe 10 x 10 characters). Now I can do this by making a nested for loop and then have it check my faction hashmaps but how should I go about messaging the player? This would be really easy to do by printing to console in plain java but I dont know any good ways to do this when messaging a player in spigot. I am sure I could get it to work but it would be so messy and I am sure there must be a better way.
  2. Player has a #sendMessage method that excepts a varargs string. You can put as many messages as you want, separated by commas, or you can use an array.
    You can't send multi-line messages, but you can split the message where you want any new lines.
  3. You can create an 2D 5x11 int array to store the faction id if exist. Then you can make a function like:

    Code (Java):
    public void print(Player player) {
        int[][] array = new int[5][11];
        for(int[] line: array) {
          StringBuilder strLine = new StringBuilder();
          for(int id : line) {
            strLine.append(id != -1 ? "#" : "/");

            Map Example

    • Agree Agree x 1
  4. Get all your lines in an array or a list.
    Then do this:
    Code (Text):
    Player player;
    List<String> messages;
    // Or "String[] messages" - literally does not matter
    Minecraft supports sending multi-line messages with "\n".