Java Language: Why our theses lines of code not working??

Discussion in 'Programming' started by Jbot_James, May 4, 2015.

  1. Hello, I am new to the programming world but I know how helpful spigot can be with anything so I came here. The plugin I am trying to make is that if you Right click a blaze rod you will get SPEED effect. Here is my code

    package me.RegularMoments;

    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.potion.Potion;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    import org.bukkit.potion.PotionType;

    public class SpeedStick extends JavaPlugin {

    public void onEnable() {
    getLogger().info("Plugin Enabled");
    public void onDisable() {


    public void onPlayerInteract(PlayerInteractEvent e) {
    Player p = e.getPlayer();
    if (e.getAction() == Action.RIGHT_CLICK_AIR)
    if (p.getItemInHand().getType() == Material.BLAZE_ROD) {
    p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 10000, 1));




    I tried it out and after a few days of trying to make it work it dident. If you can tell me what I need to do that would be great. Thank you
    • Funny Funny x 1
    • Agree Agree x 2
    • Funny Funny x 1
    • Winner Winner x 1
  2. Register your event
  3. Wow that means nothing to me LOL. Thanks for trying to help. I dont know what you mean by Wrong section and I dont know what pastebin is AND were should I put the curly brackets. Thanks. If possible copy my code and paste it in your answer with it fixed. Thanks :)
    • Funny Funny x 2
  4. | A website to store text online and make it more "readable".
    For wrong section i mean you should ask for this type of questions here.
    And lol, i'm not going to fix your code for you; you must learn.. , i already told you what's wrong and i think i was very specific.
    • Agree Agree x 1
  5. Okay well thanks anyways. So what I should do at the end of if (e.getAction() == Action.RIGHT_CLICK_AIR) is change it to if (e.getAction() == Action.RIGHT_CLICK_AIR) { Please tell me if this is current or not. BTW Thanks for giving me a challenge to figure it out :)
  6. no.

    1) wrong forum section on the forums, this should be in the "Spigot Plugin Development" section.
    3) if you really do not know the answer to this question then please, go back to the books and learn the basics as that is barebone's basic java programming.
    • Agree Agree x 1
  7. I dident get books I use the internet to my advantage and I have only been learning JAVA for a week now. I do know Objective-C and Swift quite well though. Thanks anyway though. BTW when you were once me (a learning dev) How would you like it if I made fun of you. Thanks though for..... well nothing. :cool:
  8. Look through the Oracle tutorials/documentation.

    He's not making fun of you. He's just advising that you should go learn more basic java structure.
    • Agree Agree x 2
  9. Thank you for help.
  10. not trying to make fun of you.

    and I am also guessing you don't actually know Obj-C or Swift either.

    You see, the curly bracket programming syntax all started back with C, the curly brackets were than picked up by some other languages, such as Swift and Objective-C oh and, Java.
    curly bracket syntax is a big part in many different programming languages.

    So if you don't understand the use of curly bracket syntax in Java, I don't see how you could in Swift or Obj-C.

    Please, learn some more java before starting with the Bukkit/Spigot API.

    I really mean no disrespect and am generally a nice and helpful person, but asking a question like that ticks certain nerves.

    I would feel bad if someone treated me similarly while I was new to Java programming but what I am calling you out on is bare basic java knowledge.
    • Agree Agree x 2
  11. "Objective-C and Swift quite well" ... are you sure? According to what you have presented, it looks like you still need to understand what the "flow control" is...

    I would strongly advise learning "basic programming" before you learn any programming language. It's good that you are self-teaching, but you should probably get good understanding of the fundamental of programming.
    • Like Like x 1
  12. I know how to fix this. Learn Java.
  13. I disagree (politely)... he needs to learn "programming"'s not just a matter of knowing programming language..
    • Optimistic Optimistic x 1
  14. I do know Objective-C, Im making a game for IOS Called MiniGame Mashup.
  15. Phoenix616

    Resource Staff

    That is wrong, he has no ; behind his statement so it just affects the next line (which is another if-statement and has some curly brackets. One should use just one if-statement and &&'s but it works, it's just a bad coding style.
  16. konsolas


    In onEnable:
    Code (Text):
    Bukkit.getServer().getPluginManager().registerEvents(this, this);
  17. Yes! Finally! After so many posts!

    I really thought nobody would spoonfeed the TO, and only replying unnecessary things like what the problems is and where a solution is *explained*. Thanks.

    (don't want to offend you, but spoonfeeding is just bad)
  18. At the begining of your thread you have clearly stated that you are new to programming world. But now you are telling that you know Objective-C and swift. Wtf!
  19. konsolas


    I thought it better just to get this thread over with.