Need help new to programming!

Discussion in 'Plugin Development' started by porrinialex, Aug 20, 2013.

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

    porrinialex

    How do i make this so a player can send another player a message i think i got most of the code right?



    Code:
    package me.porrini.chatA;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
     
    public class tp implements CommandExecutor {
        public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
            Player player = (Player) sender;
            if (command.getName().equalsIgnoreCase("sendme")) {
            player.sendMessage(ChatColor.BLUE + "Welcome to PvpPerfect the best surviv server out there!");
           
            } else if (command.getName().equalsIgnoreCase("hello")) {
            player.sendMessage("[LINK]");
            }
            else if(command.getName().equalsIgnoreCase("Go")) {
                if (args.length == 0) {
                    player.sendMessage("Please add a name");
                   
                    Player target = Bukkit.getPlayer(args[0]);
                  if (target == null) {
                      player.sendMessage("Player is not online"+ args [0]);
                  } else {
                      player.?????????HOW DO I SEND A MESSAGE???????????????????????
                  }
                }
            }
            return false;
           
            }
    }
    
    Code:java
    1. package me.porrini.chatA;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.command.Command;
    6. import org.bukkit.command.CommandExecutor;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.entity.Player;
    9.  
    10. public class tp implements CommandExecutor {
    11. public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
    12. Player player = (Player) sender;
    13. if (command.getName().equalsIgnoreCase("sendme")) {
    14. player.sendMessage(ChatColor.BLUE + "Welcome to PvpPerfect the best surviv server out there!");
    15.  
    16. } else if (command.getName().equalsIgnoreCase("hello")) {
    17. player.sendMessage("[LINK]");
    18. }
    19. else if(command.getName().equalsIgnoreCase("Go")) {
    20. if (args.length == 0) {
    21. player.sendMessage("Please add a name");
    22.  
    23. Player target = Bukkit.getPlayer(args[0]);
    24. if (target == null) {
    25. player.sendMessage("Player is not online"+ args [0]);
    26. } else {
    27. player.?????????HOW DO I SEND A MESSAGE???????????????????????
    28. }
    29. }
    30. }
    31. return false;
    32.  
    33. }
    34. }


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  2. Offline

    monkeymanboy

    you would do target.sendMessage("Message In Here")
     
  3. Offline

    JPG2000

  4. Please learn how to use the bukkit javadoc (jd.bukkit.org), I think you will find it most helpful!
     
Thread Status:
Not open for further replies.

Share This Page