Damage Plugin problem

Discussion in 'Plugin Development' started by halojude3, Sep 23, 2014.

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

    halojude3

    hi,
    i have a plugin issue again...
    thanks to everyone
     

    Attached Files:

  2. Offline

    Panjab

    You ain't serious, do you?
     
  3. Offline

    halojude3

    i am and did you see my eclipse file?
     
  4. Offline

    Gerov

    halojude3 Ummm, good for you... If you were to post what the problem was and what you are trying to do we can help you.
     
  5. Offline

    halojude3

    package me.Yotam.Fromm;

    import java.util.logging.Logger;

    import org.bukkit.Bukkit;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;

    public class yotam extends JavaPlugin {

    Logger MaNigga = Bukkit.getLogger();
    int i;
    @Override
    public void onEnable(){


    }

    @Override
    public void onDisable(){


    }

    public boolean onCommand(CommandSender theSender, Command cmd, String CommandLabel, String[] args){

    if(theSender instanceof Player){
    Player player = (Player) theSender;

    if(CommandLabel.equalsIgnoreCase("hurt")){
    if(Bukkit.getPlayer(args[0]) !=null){
    Player playerToHurt = Bukkit.getPlayer(args[0]);
    playerToHurt.damage(Double.parseDouble(args[1]));
    }
    else player.sendMessage("cant find player " + args[0]);
    }





    }
    return true;
    }


    }

    and in the Bukkit.getPlayer it just puts a line on it

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

    Gerov

    halojude3 You have two instances of Bukkit.getPlayer() which one? And is it a Warning or an error line?

    P.S. Ehm, interesting Logger variable...
     
  7. Offline

    halojude3

    in both of them its a yellow warning line under it but there is also a black line that covers it
     
  8. Offline

    Gerov

    halojude3 That just means it is deprecated. It will still work, it is trying to tell you there may be a better way of doing it.
     
  9. Offline

    halojude3

    oh ok but in the tutorial i am watching the teacher dont have this error
     
  10. Offline

    Gerov

    halojude3 And also, just a tip because it seems you are new to this, you may want to check the length of args[] before you do anything to make sure the player is inputing the right amount of arguements.
     
  11. Offline

    halojude3

    what?? lol
     
  12. Offline

    Gerov

  13. Offline

    halojude3

    Gerov
    8 - 11 mounth ago
     
  14. Offline

    Gerov

    halojude3 Then the method probably wasn't deprecated back then.
     
  15. Offline

    halojude3

    Gerov
    thank you very much sorry i didnt understand......
    but realy thanx
     
  16. Offline

    mythbusterma

    halojude3 Gerov

    You can still use the method.

    Don't go with a YoutTube "teacher," more often than not they don't know what they're talking about, as evidenced by not even MENTIONING to check the argument length, or what that even MEANS.

    Use the official Java plugin tutorial published by Oracle.
     
  17. Offline

    halojude3

    can you explain me what is this to checl tour length i mean what does it means in this case
     
  18. Offline

    Gerov

    halojude3

    Pseudo code:

    Code:java
    1. if args length == 1 then
    2.  
    3. //do stuff


    Edit: I just noticed I accidentally made it closer to Lua then anything:eek: .
     
  19. Offline

    mythbusterma

  20. Offline

    halojude3

    Gerov lol i knew this
     
  21. halojude3 Making plugins before learning Java is wrong.
     
  22. Offline

    halojude3

    AdamQpzm
    i learned a bit
    Gerov
    package me.Yotam.Fromm;

    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.java.JavaPlugin;

    public class yotam extends JavaPlugin {

    Logger MaNigga = Bukkit.getLogger();
    int i;


    @Override
    public void onEnable(){


    }

    @Override
    public void onDisable(){


    }

    public boolean onCommand(CommandSender theSender, Command cmd, String CommandLabel, String[] args){

    if(theSender instanceof Player){
    Player player = (Player) theSender;

    if(CommandLabel.equalsIgnoreCase("hurt")){

    if(Bukkit.getPlayer(args[0]) != null){
    Player playerToHurt = Bukkit.getPlayer(args[0]);
    double damageAmount = Double.parseDouble(args[1]);
    playerToHurt.damage(damageAmount);
    playerToHurt.sendMessage(ChatColor.RED + "you were hurt by " + player.getName());
    }
    else player.sendMessage("cant find player " + args[0]);
    }





    }
    return true;
    }


    }
    it still gives me the yellow error on both of the Bukkit.getPlayer(args[0])
     
  23. Offline

    halojude3

    AdamQpzm
    can you help me with my problem?
    it says an internat error occured while tempting to prform this command
     
  24. halojude3 There's really not much I can do to help you if you don't know enough to make plugins. 'An error' also isn't helpful, I'd need to know what the error is, which appears in console.

    Some things you're doing that you shouldn't be:
    • Starting a class with a lower-case
    • Lack of encapsulation
    • Starting a variable with an uppercase
    • Using Bukkit.getLogger()
    • Declaring a variable you never initialise or use
    • Checking the command label rather than the command's name
    • Accessing an array index before checking if it can exist
    • Parsing to a double and not handling it if it isn't a valid double
     
  25. Offline

    Peter25715

    halojude3 You are not serious at all, and what is up with Logger Ma... the n word?
    I agree with all of the people above. Learning Java is better for you. Trust me.
     
  26. Offline

    halojude3

    AdamQpzm
    it seems you know java so can you seggest me a online lessons in youtube or a site?
     
  27. halojude3 Video tutorials are bad. I'd recommend the Oracle tutorials or buying a Java book.
     
  28. Offline

    halojude3

    orcale tutorials is what mythbuster sent?
    and what book do you suggest
     
Thread Status:
Not open for further replies.

Share This Page