Need help with interface implementation and objected oriented programming

Discussion in 'Plugin Development' started by ZeusAllMighty11, Apr 7, 2013.

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

    ZeusAllMighty11 Retired Staff

    Interface:
    https://github.com/YourAverageCampe.../me/zeus/MoarStuff/Interfaces/FishMethod.java

    Main class and loading method:
    https://github.com/YourAverageCamper/MoarStuff/blob/master/MoarStuff/src/me/zeus/MoarStuff/Main.java

    FishEvent class
    https://github.com/YourAverageCampe.../MoarStuff/Events/PlayerFishEventHandler.java

    Object I am currently having issues with
    https://github.com/YourAverageCampe...uff/src/me/zeus/MoarStuff/Resource/MSRod.java

    FishEffect enumeration
    https://github.com/YourAverageCampe...rc/me/zeus/MoarStuff/Resource/FishEffect.java



    Okay, so the issue is... It works with only one MSRod object. When there are two, they are loaded and saved correctly, but the problem is that if I use, for example, one of the MSRods that gives EXP, it will also give the perks of the other saved objects.

    So like I have 2 files right now. One is test.yml and one is test2.yml
    test.yml allows you to pick up 100 exp from fishing - works fine
    test2.yml allows you to pick up golden apples from fishing - works fine

    When both the files are existent in the file path, and I am only fishing with test.yml, it will give me test.yml AND test2.yml's stuff.


    Sorry if this is confusing, I am super confused because I've never used Interfaces before. Thanks!!!
     
  2. Offline

    RainoBoy97

    Do you have permission from @ZeusAllMighty11 to edit his project?
    //edit: derp
     
  3. Offline

    ZeusAllMighty11 Retired Staff

  4. Offline

    RainoBoy97

    This is not your plugin, you didnt make this from ground up.

    //Edit: fufufufu, you are Zeus >.<
     
  5. Offline

    ZeusAllMighty11 Retired Staff

    I am confused... and why did you edit your 1st post 5 times... :eek:
     
  6. Offline

    RainoBoy97

    I derped with the tagging, then realised the old ZeusAllmighty11 is now TheGreenGamerHD (?)
     
  7. Offline

    ZeusAllMighty11 Retired Staff

    Topic = derailed lol

    [​IMG] <--------
     
  8. Offline

    spywhere

    I don't know if I understand it correct.
    But what I understand is...

    You have 2 MSRod objects (let's say it's Rod1 and Rod2) but if you're using Rod1 and it's give you some exp, Rod2 will also give you some exp too...

    If that's the case, I think in the PlayerFishEventHandler class in onFish method, you called it for every rods.
    If player1 caught a fish, the event will belong to player1 and that event is send to every rods.
    Code:
    for (FishMethod fm : list)
    {
          fm.execute(e);
    }
     
  9. Offline

    ZeusAllMighty11 Retired Staff

    spywhere

    Hmm. I'm not really sure how to fix that, as I'd have to move the execution method out of the MSRod class and into another class which would implement FishMethod
     
  10. Offline

    spywhere

    What you should do is try to make each rods unique or identical. When player caught a fish, you check which rods is the one that player holding. When you can identify the rods then that's the time you can execute the command.
     
  11. Offline

    ZeusAllMighty11 Retired Staff

    spywhere
    That completely defeats the purpose of this, because then I have to run it through another method
     
Thread Status:
Not open for further replies.

Share This Page