Solved A glitch on my plugin

Discussion in 'Plugin Development' started by MeTim, Mar 4, 2013.

Thread Status:
Not open for further replies.
  1. lycano
    Your statements sounded like they were required, I wanted to make it clear that they were not, I didn't encourage anything.

    It would've been better if you'd instead comunicate that it's pointless to write code that prints duplicate messages :p And also not good to use Minecraft's logger since the plugin is not Minecraft, it's a plugin, this.getLogger() should be used.

    MeTim
    There is a pull request for adding a way to get the hook entity for PlayerFishEvent, if that gets pulled you can use that... but until then you could use the get nearby entities method but you'd have to check if the entity's shooter is the player in the event so you don't target other people's hooks.

    And like I said above, you should remove your messages from onEnable() and onDisable() and also remove that logger, use this/plugin.getLogger() when you need to log something.
     
  2. Offline

    lycano

    MeTim here is your plugin. https://github.com/lycano/PAFishingRod

    You can grab it from there and compile it with maven. If you want to change the copyright lines to your name it would be nice if you just add yourself above and leave me in it to give me some credit.

    Of course you can change author to your name in the plugin.yml without leaving me in.

    If there is any problem with it feel free to contact me.

    Digi enums are objects so checking with equals is the way to go. Sure there is no instance so it would work but well this is senseless to discuss with you as you clearly did not think about it why i said it. Google it you will find the answer why its not good to do as you suggested.

    Even if you did not "forced" someone you gave this information he would use it without question as most people dont know when to use equals or the comperator.

    Anyways do what you think its best.

    You are right about the part "How to get the fishing rod location correctly". As there is no reference to getShooter in PlayerFishEvent. I remember where the BlockDamage event would fire when the fishing rod would hit the ground but that changed too.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  3. lycano
    Enums are constants actually :p
    But anyway, about that code you posted, you might want to break the for loop once you find the entity.
    And it still sends duplicate messages, if you want to teach good practices you should do it fully :p

    I guess this is solved since you built the plugin for him xD
     
  4. Offline

    MeTim

  5. Offline

    lycano

    Digi why don't you make a pull request instead of trying to piss me off? This is not a game about "who is the better coder". You could have just written yourself the plugin for him as it was clearly not that big of a deal. Im only trying to teach good coding style and if needed give those upcoming coders a good head start as this is much easier as having to go through all specific problem solving.

    Also im intrested to know how you would have solved this. The break is a good addition as this would lower the stress on this. Would you have used class casting? How would you have done it?

    Also im curious to know where it would print duplicate messages as there is only one send message and it would only be send when the tp event would not fire as the output is limited to pulling back the string and when hitting an entity or fish.

    MeTim you're welcome!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  6. lycano
    I am not trying to annoy or be a smart ass here, I am just trying to help, but if I made it seem that way I am sorry.

    If you want to just write plugins for other people it's fine, you do that :p but I don't, I belive in people understanding what they write and write it themselves, that's how I belive they truly learn. And if the poster doesn't have an interest in learning I'm directing them to the requests section.

    About the duplicated messages, I belive you didn't know that Bukkit already sends a message when a plugin is getting loaded and when it gets enabled, adding a message in onEnable() and onDisable() would be extra messages.
    And if every plugin had that (and most do :( ) it's going to spam alot of the server console at startup, slowing it down for slower computers and more importantly scroll the text faster that the admin can not see if some plugin gives a warning or something.

    And yeah, I suggested the same method as you wrote, his initial code with a check for entity's shooter.
     
  7. Offline

    lycano

    Digi well you where getting to a point where it seems pointless to discuss any further cause you where riding on words like "enums are constants" and avoiding the true meaning of the sentence itself. As for "enums are constants" you are right about that in one way but what you may have forgotten is that everything is an object. There are different types of objects like constants and variables.

    Anyways usually i dont try to write stuff for others cause i have enough to do with my plugins but sometimes i want to share and if the task itself is a challenge then i might just try it out and publish it.

    I believe that sharing is better than just giving advices that do most likely end in just writing the class itself or the plugin even if it seems that the person would not learn from it in the first place i think that he will come to a point where he reviews the code and wants to understand it by himself.

    I learned in the same way. Looking at other codes and trying to understand it. And if there where more ppl who where helpful in that way i guess the learning curve may not be so steep as its not that easy for someone who did never have done stuff with java.

    About the double messages. Bukkit may print that but its only the loading information. That does not mean that the plugin is actually enabled. Plus by outputting those extra info messages it may help when problems occur as you can quickly see at what stage the plugin may crash "is it after the enable message", "is it in the database handler?" stuff like that. Also I dont see why a log output will slow down a computer. Sry but thats not even an argument.

    "Scroll text faster" well you may want to search for other ways to debug the log file. I hope you dont mean that you can scroll faster in the console by itself ...
     
  8. lycano
    Code:
    getLogger().fine("Succesfully enabled.");
    That's what I suggest instead, there's no point in explaining more and extending this thread even further.
     
Thread Status:
Not open for further replies.

Share This Page