Issues wth sub-classing Area?

  • I am facing unexpected results (at least unexpected by me!) when using a sub-class of the net.risingworld.api.utils.Area class:


    1) The PlayerEnterAreaEvent fires repeatedly while the player moves within the area without leaving it


    2) The PlayerLeaveAreaEvent never fires


    3) The Area.equals() methods returns false even when the two objects involved in the test are physically the same object.


    The attached, small, sample plug-in defines a sub-class of the Area class, uses an instance of it to test several events and shows the issues described above.


    Am I wrong in expecting that an instance of a sub-class of Area should behave as an instance of Area itself for the common, non-overriden methods?

  • Well, actually the Areas are causing some problems. There is still some debug code left which causes various issues in certain cases, that will be fixed with the next update.
    However, this isn't related to your problem. Using sub-classes of Area causes trouble, since the "equals()" method in Area doesn't check if the other object is an instance of Area (it only compares the classes, so the sub-class isn't considered to be an Area). This will be changed with the next update ;)

  • Thanks for the reply. I understand the point about .equals() and I hope the causes for the oddities with events can be found too.


    The whole is not OVERLY important, as it is always possible to achieve the same results with a non-sub-classed class which hosts an Area field in itself. Sub-classing is surely cleaner and possibly lighter, though.

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!