Discussion in 'Bukkit Discussion' started by AmoebaMan, Nov 1, 2012.

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


    I know this has probably been answered at some point before, but why are PotionEffectType and Enchantment defined as abstract classes with static variables rather than as enumerations?

    The way I see it, an enumeration would be the proper way to represent these things, and by not doing this you also lose two critical features of enum-constants:
    1. Serializability
    2. Safe usage of the equality operator
    So basically, just curious. There's undoubtedly some explanation, and I'd like to hear it for my own information. Of course, if there's not, then we have a problem.
    Canownueasy likes this.
  2. Offline


    Probably because it was a (bad) design choice a while back, but the Bukkit team just stuck with it (or forgot about it). The Bukkit team undoubtedly has bigger things on their minds (fixing critical crashes, adding to the API etc) to fix something reasonably minor as this. Its a pretty simple thing to submit a PR for, anyway. Since noone has so far, I guess they are fine with using .equals, and if you think about it, there really are only a few cases where potion effects need to be serialized. For the most part, storing their data value and effect ID is sufficient.

    So while your points are correct, the issue is small. You appear to know how to program well, why don't you submit a PR? You do have a completely valid point, and I'm sure that the corner-case people would enjoy PE's being serializable, and newbies would not have grief with finding that their code doesn't work because they compared objects with equality operators. Would lessen a bit of posts of the Plugin Development section.
  3. Offline


    Its because each potion static constant is actually different and is a wrapper class for a specific potion type.
  4. Offline


    Yes, but isn't this almost a coding non-sequitur? Wouldn't it be much easier and cleaner to represent these as enum constants, and have them linked to their respective classes behind the scenes?

    The enumeration EntityType does this perfectly well.
    Canownueasy likes this.
  5. Offline


    You're exactly right; I had always presumed that these issues were because of an initial poor design choice and Bukkit didn't want to break code built with legacy versions of their library... but we all know Bukkit doesn't give two cents about breaking legacy code. :rolleyes: So, really, I don't know why they haven't fixed this issue. There are numerous other issues including an enormous design flaw with the event system... and when I brought this up staff members used Thor's hammer on me. :confused:
Thread Status:
Not open for further replies.

Share This Page