[Methods] Need help creating a method

Discussion in 'Plugin Development' started by ko47374737, Jun 28, 2014.

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

    ko47374737

  2. Offline

    dsouzamatt

    ko47374737 What exactly are you trying to do? This?

    Because earlier on, in response to my first post you said:

    Which is what Traks and I were giving examples of. You have a method which returns something, then use it again in another method and so on.
     
  3. Offline

    Rocoty

    Jeez man. Dude was only trying to help. He didn't see the point of trying to accomplish what you want. So he asked in order to maybe try and find a better way to achieve your goal. That's what I would have done at least.
     
  4. Offline

    ZodiacTheories

    dsouzamatt Rocoty ko47374737

    Correct me if I am mistaken, can't ko just edit the Player class or whatever class he wants and add his new methods?
     
  5. Offline

    Gater12

    ZodiacTheories
    Sure.

    But it applies if it's only for his personal use. (ONLY)
     
  6. Offline

    Traks

    ZodiacTheories And how would he do that? Get all Bukkit's source code, edit the Player and CraftPlayer classes, compile it and this way have his own version of bukkit, just to add 1 method to those classes?

    If he wants to create an API, he would be the only one able to use it...
     
    Rocoty likes this.
  7. Offline

    Rocoty

    Edit how exactly? He could edit the bytecode maybe. But it's tedious and probably not worth the effort. ZodiacTheories
     
  8. Offline

    Gater12

    Rocoty likes this.
  9. Offline

    Rocoty

    Gater12 Oh yeah. But still probably not worth the effort
     
    dsouzamatt, Traks and Gater12 like this.
  10. Offline

    ZodiacTheories

    Rocoty

    Can't he just copy and paste the code from the class he wants, and override that class with his new methods?
     
  11. Offline

    Traks

    ZodiacTheories There is no way to override classes in Java... You can only override superclass behaviour, but the superclass itself won't be affected. Only when getting a new instance of the subclass would you use the overridden methods

    Edit: You could use the same package names as the ones used for Player and CraftPlayer, but since Bukkit's classes will be loaded earlier than the plugins', they won't override it
     
  12. Offline

    Rocoty

    ZodiacTheories If you meant to extend the class. Yes, he could do that. But he would have use reflection to infer the right object in the right places and he would have to cast every time he wanted to use his own methods.
     
  13. Offline

    ZodiacTheories

    Rocoty Traks

    Sorry, explained badly, I meant to say what Rocoty said about extending it, and using Reflection.
     
  14. Offline

    dsouzamatt

    And so we get back to the question, is it really worth the effort?
     
  15. Offline

    Rocoty

    ZodiacTheories dsouzamatt Definitely not worth it. Casting every time he wants to use his own methods there would just slow down the process, make the code look ugly and achieve the opposite of what he wants to achieve.

    Basically OP should not want to chain those methods in the way we think he wants. And instead try to find a much cleaner way of accomplishing what he really wants...If that made any sense...
     
    Traks, dsouzamatt and ZodiacTheories like this.
  16. Offline

    ko47374737

  17. Offline

    xTigerRebornx

    ko47374737 Its not that you can't (people with a proper knowledge can do it easily), its that its redundant and unneeded, and from what I can tell, has no point to it other then the fact that you want it to use your methods (which just calls Bukkit's methods anyway)
     
  18. Offline

    Rocoty

    ko47374737
    So...what do you really want to accomplish in the end with this? There is probably a very good way to do it.
     
  19. Offline

    dsouzamatt

    If you really wanted to you could probably try it. The general consensus though is that for the effort you'd need to put in it would be a waste of time when there are, as Rocoty said, better, more efficient ways to accomplish the same thing.


    Edit: I apologise for the tahg spam, Rocoty

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

    ko47374737

    xTigerRebornx Rocoty
    Im not using bukkit methods for my new plugin but I just don't wanna say what the method is and also im making it for a java game

    Java program**. Its for bukkit

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

    xTigerRebornx

    ko47374737 Not to be harsh, but this is a help section for developing plugins using the Bukkit API. Java questions are generally answered on here, but they lean more towards the Bukkit API. If you are looking for answers for Java-specific questions, then a place like StackOverflow will get actual answers rather then the answers you've gotten here.
     
  22. Offline

    ko47374737

    I just want to know but all you guys are saying well theres no point bla bla bla... for me there is so yeh... pweese please please help:'(
     
  23. Offline

    xTigerRebornx

    ko47374737
    Read this, and post your "problem" again.
     
  24. Offline

    1Rogue


    Not without breaking the security contracts that the JVM establishes and treading into the territory of sun.misc.Unsafe.

    http://docs.oracle.com/javase/tutorial/java/javaOO/methods.html
     
  25. Offline

    ZodiacTheories

  26. Offline

    ko47374737

    1Rogue Have you started video tutorials?
     
  27. ko47374737 It's not that there's no point, it's that you don't know how Java works. It's been explained already what a method actually is, so please just learn Java before trying to create a plugin and certainly before trying to create a tutorial :) It'll definitely work out better for you in the long run.
     
  28. Offline

    ko47374737

    • This is completely unacceptable behavior
    AdamQpzm I FUCKING KNOW JAVA OTHER WISE I WOULDNT BE MAKING A FUCKING PROGRAM FOR A PLUGIN THAT USES BUKKIT API.. I KNOW HOW THAT METHOD WORKS I JUST WANT TO LEARN ABOUT LIKE RETURNING THE INSTANCE OR SOMETHING!
     
  29. ko47374737 There's no need to be so rude. I was only trying to say what you should do. :)



    Uh huh.
     
    nlthijs48 and TGRHavoc like this.
  30. Offline

    ko47374737

    AdamQpzm
    Could you give an example of how you would do it then?
    If you know "java"
     
Thread Status:
Not open for further replies.

Share This Page