1.15.2 Set "Ban Reason"

Discussion in 'Spigot Plugin Development' started by TheFischPlayz, Jan 30, 2020.

Thread Status:
Not open for further replies.
  1. Hello Guys.. again :D

    I try so set a kick/ban reason but 1 arg is only 1 word soo.. how can i set a banreason like "You are banned" with spaces between the words ?

    Thx :)
  2. nani?
    • Creative Creative x 1
  3. Go learn Java. Also, your code should look like this.
    Code (Java):
    player.kickPlayer("You have been kicked");
  4. No, i dont want a finished message, i want to make one ingame /kick <Player> <Reason>
    BUT the <Reason> has more than 1 Word
    at the moment when i kick a player i only can write 1 word for the reason
  5. Your arguments array will contain all the words in the command.

    So if I type /kick AvroVulcan Using fly hacks

    My arguments array will look something like this:

    ["AvroVulcan", "Using", "fly", "hacks"]

    So, you need to get all arguments beyond the name of the player and get them all into a single string. To do this you can use a String Builder or just basic string concatenation.
  6. You'll need to join your arguments, which can be done easily with String.join
    " " is the delimiter, meaning each element will be separated with a space
    Code (Java):
    String reason = String.join(" ", args);
    Assuming you need different arguments than just the ban reason though, you can use Arrays.copyOfRange to get only a certain range of elements from a different array, i.e.: your args array, from the index of the start of the reason to the end of the array
    #6 Escad, Jan 30, 2020
    Last edited: Jan 30, 2020
Thread Status:
Not open for further replies.