Solved Java wont cooperate with me anymore ^^

Discussion in 'Plugin Development' started by EvilKittyCat123, May 7, 2014.

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

    Garris0n

    Last edited by a moderator: Jun 8, 2016
  2. EvilKittyCat123 You certainly should worry about if statements that do nothing, especially if they're supposed to do something.
     
  3. Offline

    EvilKittyCat123

    Garris0n
    I typed the command /nodrop, and it does what it is suppose to do. How is that not working?
     
  4. Offline

    Necrodoom

    you did an if and ignore its result, not sure how its deemed working.

    If you tried to add another command, it will always print nodrop message.
     
    Garris0n and AdamQpzm like this.
  5. Offline

    EvilKittyCat123

    Necrodoom
    Okay, so, I'm gonna try something different. I deleted the class noDrop, and decided to put the event in my main class. But I get a red line under onPlayerDrop saying "void is an invalid type for the variable onPlayerDrop".

    Here's my main class:
    PS (Instead of yelling and screaming at me that I suck, just give me a copy of exactly how my class should look like.. please...)

    Code:java
    1. package me.stripa.NoDrop;
    2.  
    3. import java.util.logging.Logger;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.event.Listener;
    11. import org.bukkit.event.player.PlayerDropItemEvent;
    12. import org.bukkit.plugin.PluginDescriptionFile;
    13. import org.bukkit.plugin.java.JavaPlugin;
    14.  
    15. public class Main extends JavaPlugin implements Listener
    16. {
    17. public final Logger logger = Logger.getLogger("Minecraft");
    18. public static Main plugin;
    19.  
    20. public void onDisable()
    21. {
    22. PluginDescriptionFile pdfFile = getDescription();
    23. this.logger.info(pdfFile.getName() + " Has been disabled! ");
    24. }
    25.  
    26. public void onEnable()
    27. {
    28. PluginDescriptionFile pdfFile = getDescription();
    29. this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion() + " Has been enabled! ");
    30. getServer().getPluginManager().registerEvents(this, this);
    31. }
    32.  
    33. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    34. Player player = (Player) sender;
    35.  
    36.  
    37. {
    38.  
    39. if(cmd.getName().equalsIgnoreCase("nodrop"));
    40. if(player.hasPermission("nodrop.main")) {
    41. player.sendMessage(ChatColor.BLUE +"["
    42. + ChatColor.GRAY + "NoDrop"
    43. + ChatColor.BLUE + "] "
    44. + ChatColor.YELLOW + "============ "
    45. + ChatColor.GRAY + "NoDrop version "
    46. + ChatColor.GREEN + "1.0 "
    47. + ChatColor.YELLOW + "============ "
    48. + ChatColor.GRAY + "Bukkit version: "
    49. + ChatColor.GREEN + Bukkit.getVersion() + " "
    50. + ChatColor.GRAY + "Plugin Developer: "
    51. + ChatColor.GREEN + "EvilKittyCat123");
    52.  
    53.  
    54. } else {
    55. player.sendMessage(ChatColor.BLUE + "["
    56. + ChatColor.GRAY + "NoDrop"
    57. + ChatColor.BLUE + "] "
    58. + ChatColor.RED + "You do not have permission!");
    59.  
    60. }
    61.  
    62.  
    63.  
    64. {
    65.  
    66. @EventHandler
    67. public void onPlayerDrop(PlayerDropItemEvent evt);
    68.  
    69.  
    70. }
    71.  
    72.  
    73.  
    74.  
    75. return false;
    76.  
    77. }
    78. }
    79. }
    80.  
    81.  
    82.  
    83.  
    84.  
    85.  
    86.  
    87.  
    88.  
    89.  
    90.  
    91.  
    92.  
    93.  
    94.  
    95.  
    96.  
    97.  
     
  6. Offline

    RawCode

    You provided invalid code 4 times in row, it wont compile and wont work.

    look closely on line 37 of your paste one more time
     
  7. Offline

    Garris0n

    There is no other solution. I could go over a few other things you shouldn't be doing that you likely got from outdated tutorials (logger, enable/disable messages, other stuff), however there's no point. You do not know enough Java to continue with Bukkit yet. There's not much you're going to be able to do without copying other people's code, and if you do manage to get something to work it will probably be luck. I'm not trying to insult you, by the way, that's simply the truth. You must learn Java, at least basic Java, before doing this. You can't just learn Bukkit.
     
    L33m4n123 and AdamQpzm like this.
  8. Offline

    Necrodoom

    EvilKittyCat123 You now came back to the original error of the beginning of this thread.
    line 39: if statement doing nothing
    line 67: method inside another method (playerdropitemevent inside oncommand)
    line 67: empty method

    If you are unsure how to fix it i recommend looking up a java tutorial.
     
  9. Offline

    EvilKittyCat123

  10. Offline

    Garris0n

    This is exactly what I mean. You need to be able to write it for yourself.
     
  11. Offline

    Aqua

  12. Offline

    EvilKittyCat123

    Garris0n
    Oh, you mean like I did 4 times before and everything worked successfully? Good times, so fucking good times.

    Listen up everybody! I am just trying to make thus 1 simple bukkit plugin which I have successfully managed to make many times before! I do not want to spend 2-3 years learning java in order to make a bukkit plugin which should take minimum 2 minutes! Again, I'VE DONE THIS SO MANY TIMES!

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

    Necrodoom

  14. Offline

    Garris0n

    So what happened, exactly? You just magically forgot Java? It might have "hackily" worked, but I still remember perfectly what it was like to try to use Bukkit without knowing Java. Not actually knowing what you're doing and coming up with bizarre solutions to problems is not good. I remember doing some stupid things (like discovering the static keyword and thinking it was the solution to all my problems). Seriously, learn Java. I've told many people this because I speak from experience. Learn. Java.
     
    AdamQpzm likes this.
  15. Offline

    Aqua

    If you have done it so many times before and made it work, how come you make these obvious mistakes now?
    Like we said: Learn some java first.
     
  16. Offline

    EvilKittyCat123

    Necrodoom
    Mhm?
    Garris0n
    I am already learning java, 10-12 days ago I bought a few Java books..
    Aqua
    That's the whole reason I made this thread. I've made this sort of plugin so many times.
     
  17. Offline

    Garris0n

     
  18. Offline

    Necrodoom

  19. Offline

    EvilKittyCat123

    Necrodoom
    I really don't see it.
    Garris0n
    I do read and learn java by using the books. But at the same time I am trying to make a plugin that I have made before.
     
  20. Offline

    Necrodoom

    Agh.

    You do an if(something) then close it with ; instead of { }, which means you just did a line of code which checks a variable and does nothing. You asked the exact same question 4 months ago, but yet you dont see the problem in this code, despite being almost an identical duplicate of it.

    I highly recommend reading a basic java tutorial before proceeding.
     
  21. Offline

    EvilKittyCat123

    fuck this, I give up. Thanks a lot for the help!

    I could have learned if somebody just gave me the correct code. Because then I would be able to see how it's done, and then proceed doing it right. I still don't understand why it is not working, but all I know is that it worked before.

    - Cya

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

    DeluXeNationMC

  23. Offline

    EvilKittyCat123

    DeluXeNationMC
    I've already looked at it. But I just don't get it.. I am stupid. All I am asking for, is for somebody to tell me what to do step by step on how to make this shit work. But nobody wants to. So I just gave up.. Everything worked before..
     
  24. Offline

    Necrodoom

    If you need this plugin i suggest making a thread at plugin request section or looking up existing plugins.
     
  25. Offline

    DeluXeNationMC

    EvilKittyCat123 First of all could you stop cursing because it is not necessary.
    Code:java
    1. package me.stripa.NoDrop;
    2.  
    3. import java.util.logging.Logger;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.event.Listener;
    11. import org.bukkit.event.player.PlayerDropItemEvent;
    12. import org.bukkit.plugin.PluginDescriptionFile;
    13. import org.bukkit.plugin.java.JavaPlugin;
    14.  
    15. public class Main extends JavaPlugin implements Listener
    16. {
    17. public final Logger logger = Logger.getLogger("Minecraft");
    18. public static Main plugin;
    19.  
    20. public void onDisable()
    21. {
    22. PluginDescriptionFile pdfFile = getDescription();
    23. this.logger.info(pdfFile.getName() + " Has been disabled! ");
    24. }
    25.  
    26. public void onEnable()
    27. {
    28. PluginDescriptionFile pdfFile = getDescription();
    29. this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion() + " Has been enabled! ");
    30. getServer().getPluginManager().registerEvents(this, this);
    31. }
    32.  
    33. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    34. Player player = (Player) sender;
    35.  
    36.  
    37. {
    38.  
    39. if(cmd.getName().equalsIgnoreCase("nodrop"));
    40. if(player.hasPermission("nodrop.main")) {
    41. player.sendMessage(ChatColor.BLUE +"["
    42. + ChatColor.GRAY + "NoDrop"
    43. + ChatColor.BLUE + "] "
    44. + ChatColor.YELLOW + "============ "
    45. + ChatColor.GRAY + "NoDrop version "
    46. + ChatColor.GREEN + "1.0 "
    47. + ChatColor.YELLOW + "============ "
    48. + ChatColor.GRAY + "Bukkit version: "
    49. + ChatColor.GREEN + Bukkit.getVersion() + " "
    50. + ChatColor.GRAY + "Plugin Developer: "
    51. + ChatColor.GREEN + "EvilKittyCat123");
    52.  
    53.  
    54. } else {
    55. player.sendMessage(ChatColor.BLUE + "["
    56. + ChatColor.GRAY + "NoDrop"
    57. + ChatColor.BLUE + "] "
    58. + ChatColor.RED + "You do not have permission!");
    59.  
    60. }
    61.  
    62.  
    63.  
    64. {
    65.  
    66. @EventHandler
    67. public void onPlayerDrop(PlayerDropItemEvent evt); //The ; should be a {
    68.  
    69.  
    70. }
    71.  
    72.  
    73.  
    74.  
    75. return false;
    76.  
    77. }
    78. }
    79. }
    80.  
    81.  
    82.  
    83.  
    84.  
    85.  
    86.  
    87.  
    88.  
    89.  
    90.  
    91.  
    92.  
    93.  
    94.  
    95.  
    96.  
    97.  

    In this code the problem is the ; on the end of public void onPlayerDrop(PlayerDropItemEvent evt); should be a { braket
     
  26. Offline

    Necrodoom

  27. Offline

    thomasb454


    Let's not turn this into a hate thread...
    The OP doesn't seem to understand - we're here to help, not judge.
     
    EvilKittyCat123 likes this.
  28. Offline

    EvilKittyCat123

    Errm, it wont let me put event.SetCancelled(true);
     
  29. I'm not trying to hate on him. But I'll agree that the OP doesn't understand - but he doesn't seem to want to accept our help, he wants us to tell him what the correct version is. Insisting that he's ready or that what he's doing worked a while ago when we know for a fact it didn't, and then just giving up? Not the kind of attitude somebody we can help has.
     
    thomasb454, Mayoz and DeluXeNationMC like this.
Thread Status:
Not open for further replies.

Share This Page