Kick plugin [HELP]

Discussion in 'Plugin Development' started by NB5921, Mar 8, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    NB5921

    Hello everyone. So, I am really new to plugin development and don't have a clue what to do here: http://prntscr.com/6e925n. can someone help me please? I want it so when people do the command "/nbkick <player> <reason>" it broadcasts to all the Staff Members "<player> has been kicked by <player> for <reason>". I will appreciate anyones help!
     
  2. Hello, what you are doing wrong is that the BukkitAPI doesn't have a player meathod "kickPlayer()".

    There is "kickPlayer("Reason");

    I will not spoonfeed you code also. Try learning the Bukkit API from decompiling other plugins, or learning Java from oracles website, instead of learning Java FROM Bukkit.
     
    Last edited: Mar 8, 2015
  3. Offline

    B3N909

    You can use:
    Player p;
    p.KickPlayer();
     
  4. Offline

    Abstract97

    The reason you are getting that error is because the method 'kickPlayer' requires a string parameter for a message the player will receive when they are kicked.

    E.G
    Code:
    p.kickPlayer("You have been kicked for " + reason);
    There are also many things you are doing wrong there, at the moment you are trying to kick the player who executes the command. Try getting the arguments and kicking a target player. You may want to use a StringBuilder to build a reason too, a sample piece of code is shown below:

    Code:
    StringBuilder sb = new StringBuilder();
    
    for(int i = 1; i < args.length; i++) {
    sb.append(args[i] + " ");
    }
    
    String reasonToKick = sb.toString().trim();
     
    Last edited: Mar 8, 2015
    OfficerDeveloper likes this.
Thread Status:
Not open for further replies.

Share This Page