[Solved] Need help with my plugin! Having trouble!

Discussion in 'Plugin Development' started by HotelManager24, Nov 24, 2011.

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

    HotelManager24

    Lately, I have been devloping this plugin. For a portion of it, I need to find out a portion of a command.

    Example:
    Code:
    /kick PLAYER REASON
    (I need to find out the player's name.)
    What I have been doing is:
    Code:
    for (int a = 5; a < 21; a++) {
    namefinder[c] = cmd.getName().valueOf(a);
    c++;
    }
    The thing is, valueOf is for characters and the name of a player is a String. Can anyone help with this? Is there an easier way to do this? Please help!!
     
  2. Offline

    Sagacious_Zed Bukkit Docs

    In the command executor class

    If you want to get the player object for a given player
    Code:
    Bukkit.getPlayer("partial player name");
    the onCommand method you are implementing must have an argument that is an array of strings.
    where you have the name should be the first element of the array.
     
  3. Offline

    HotelManager24

    The thing is, I would like to find two thing when a player runs this command.

    Example:
    Code:
    /kick PLAYER REASON
    I would like to find out who runs the command to kick a player, and who is being kicked.
     
  4. Offline

    Sagacious_Zed Bukkit Docs

  5. Offline

    HotelManager24

    Uhh... Sorry, I'm a bit lost. How should I be checking if it is an instance of another player? I understand how to find the name of the player sending the command. I'm just a bit "confuzzled" on how to find the player being kicked.
     
  6. Offline

    Sagacious_Zed Bukkit Docs

    no, that bit about casting is needed if you need the player object of the person doing the kicking.

    You can find the name of the player player being kicked from what i discussed before.
     
  7. Offline

    Jaker232

    If you want to find a target's name and kick them, and also with a string, please refer to my Player Catching Argument tutorial in the Resources section.
     
  8. Offline

    HotelManager24

  9. Offline

    Jaker232

  10. Offline

    HotelManager24

    Ok, so I checked it out.. I came out with this bit of code:
    Code:
    if (cmd.getName().startsWith("ban")) {
    
    			Player bannedPlayer = server.getPlayer(args[0]);
    			String admin = cmd.getName();
    
    			log.info("Player " + bannedPlayer + " was banned by " + admin + ".");
    
    }
    If I understood correctly, this checks if a player is executing the /ban command and if they do, it prints out to the console "Player PLAYER was banned by ADMIN." If I am correct, please say so. All this help is highly appreciated.
     
  11. Offline

    Jaker232

    You need to do
    Code:java
    1.  
    2. bannedPlayer.setBanned(true);
    3. bannedPlayer.kick("You have been banned by " + admin + ".");
    4.  


    Then you're all set.
     
  12. Offline

    HotelManager24

    Alrighty! Thanks! One other thing, in this plugin, I just want to log the bans, not have them activate. So do I really need those two lines of code? Wouldn't the already coded bukkit/minecraft_server.jar ban commands work fine?
     
  13. Offline

    Jaker232

    It bans them, then kicks them.

    I'm not sure about the banning, but send a message to the console.
     
  14. Offline

    HotelManager24

    I don't believe you understood what I meant. I was trying to say:

    Do I really need to put those two lines of code in the plugin? Since Notch and Bukkit have already coded in the ban command, and all I want to do is log it.
     
  15. Offline

    Jaker232

    Probably send it to console.
     
  16. Offline

    HotelManager24

    Ok, thanks!
     
Thread Status:
Not open for further replies.

Share This Page