plugin help/targetplayer help

Discussion in 'Plugin Development' started by johnf79, Feb 10, 2013.

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

    johnf79

    i am trying to make my plugin say [sender] had sex with [targetplayer] but i don't know the node/string thing, i am in desperate need of help as this is my 3rd plugin, but one not as simple as doing /hurt and take a heart of damage, i would love the help.
    thank you :)
     
  2. Offline

    johnf79

    Code:
    package me.Sex;
     
    import java.util.logging.Logger;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class Sex extends JavaPlugin{
        public final Logger logger = Logger.getLogger("minecraft");
        public static Sex sex;
       
        @Override
        public void onDisable() {
            PluginDescriptionFile pdfFile = this.getDescription();
            this.logger.info(pdfFile.getName() + " Has Been Disabled!");
        }
     
        @Override
        public void onEnable() {
            PluginDescriptionFile pdfFile = this.getDescription();
            this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion() + " Has Been Enabled!");
        }
       
        public boolean onCommand(CommandSender sender, Command cmd,  String commandLabel, String[] args){
            Player player = (Player) sender;
            player.getServer().getPlayer(args[0]);
        if(Bukkit.getPlayer(args[0]) != null){
            } else if(commandLabel.equalsIgnoreCase("Sex")){
                Player targetPlayer = player.getServer().getPlayer(args[0]);
                Bukkit.broadcastMessage(ChatColor.GOLD + player.getPlayer().getName() + " Had Sex With " + targetPlayer.getName());
                        return true;
                        }
                return false;
                }
    }
    
    this is the code from eclipse i'm using, help me out on EVERYTHING that is wrong with my codeing, and what i can shorten and things, or just reword the whole thing for me, thank you :)
     

    Attached Files:

  3. Offline

    johnf79

    can someone please comment and help me out :(, i've stared at this forum page for about 3 hours waiting for 1 response on help, i would love the help, thank you and please tell me what i should do :)
     
  4. Offline

    ImDeJay

    johnf79

    Code:
        @Override
        public void onDisable() {
     
        }
     
        @Override
        public void onEnable() {
     
        }
       
        public boolean onCommand(CommandSender sender, Command cmd,  String commandLabel, String[] args){
            
            if(sender instanceof Player){
           
           Player player = (Player) sender;
           
           
           if(commandLabel.equalsIgnoreCase("sex")){
           
           if(args.length == 1){
           
           Player targetPlayer = this.getServer().getPlayer(args[0]);
           
           if(targetPlayer != null){
           
           this.getServer().broadcastMessage(ChatColor.GOLD + player.getName() + " Had Sex With " + targetPlayer.getName());
           
           }
           
           }else{
           
           //args.lenth was <> to 1, u can do something here.
           }
           }
            }
            
            return false;
            
        }
     
  5. Offline

    gomeow

    Also, don't have a static reference to your plugin.
     
  6. Offline

    johnf79

    thanks for the help, but when i try adding another command it gives me an error:

    Code:
               
                  this.getServer().broadcastMessage(ChatColor.GOLD + player.getName() + " Gave a blowjob to " + targetPlayer.getName());
              }
    it has the part "targetPlayer.getName());" witha yellow bar under it, how do i fix that?
     
  7. Offline

    gomeow

    An error comes with an error message, read it
     
  8. Offline

    johnf79

    it just says it cannot be placed at this location, but what location would i put it?
    Code:
    public boolean onCommand(CommandSender sender, Command cmd,  String commandLabel, String[] args){
           
            if(sender instanceof Player){
         
          Player player = (Player) sender;
         
         
          if(commandLabel.equalsIgnoreCase("sex")){
         
          if(args.length == 1){
         
          Player targetPlayer = this.getServer().getPlayer(args[0]);
         
          if(targetPlayer != null){
         
          this.getServer().broadcastMessage(ChatColor.GOLD + player.getName() + " Had Sex With " + targetPlayer.getName());
         
          }else if (commandLabel.equalsIgnoreCase("BJ")){
             
          this.getServer().broadcastMessage(ChatColor.GOLD + player.getName() + " Gave a blowjob to " + targetPlayer.getName());
             
          }
         
          }else{
         
          //args.lenth was <> to 1, u can do something here.
          }
          }
            }
           
            return false;
           
        }
    }
    that is where i have it placed and it gives the error
     
  9. Offline

    gomeow

    Try Bukkit.broadcastMessage() & Bukkit.getPlayer()

    Also, can you point out exactly what has the error?
     
  10. Offline

    johnf79

    Code:
    public boolean onCommand(CommandSender sender, Command cmd,  String commandLabel, String[] args){
           
            if(sender instanceof Player){
         
          Player player = (Player) sender;
         
         
          if(commandLabel.equalsIgnoreCase("sex")){
         
          if(args.length == 1){
         
          Player targetPlayer = this.getServer().getPlayer(args[0]);
         
          if(targetPlayer != null){
         
          this.getServer().broadcastMessage(ChatColor.GOLD + player.getName() + " Had Sex With " + targetPlayer.getName());
         
          }else if (commandLabel.equalsIgnoreCase("BJ")){
             
          this.getServer().broadcastMessage(ChatColor.GOLD + player.getName() + " Gave a blowjob to " + [targetPlayer.getName]());
             
          }
         
          }else{
         
          //args.lenth was <> to 1, u can do something here.
          }
          }
            }
           
            return false;
           
        }
    }
    the part i put brackets on
     
  11. Offline

    TnT Retired Staff

    Moved to Plugin Development.
     
  12. Offline

    Tirelessly

    This is such a fucking stupid plugin.
     
    mastermustard likes this.
  13. Offline

    mastermustard

    why would you want a plugin that broadcasts wen u have sex.... on minecraft....
     
  14. Offline

    FTWin01Gurl

    This is really fucked up.
     
  15. Offline

    johnf79

    thanks for the help -.-
     
Thread Status:
Not open for further replies.

Share This Page