Jump to content

DefaultModelList > Looting method()


Recommended Posts

Posted

I'd say convert your model to an array by copying contents over while iterating the model, using the enumeration returned by the DefaultListModel#elements method.

 

Then pass that array using getGroundItems().closest(array) to get the closest desired item on the ground; or getGroundItems().filter(array) to get them all.

Posted

I'd say convert your model to an array by copying contents over while iterating the model, using the enumeration returned by the DefaultListModel#elements method.

 

Then pass that array using getGroundItems().closest(array) to get the closest desired item on the ground; or getGroundItems().filter(array) to get them all.

Posted (edited)

toArray doesn't make use of generics, and will always return Object[], so he'd have to convert it regardless to use it with the EntityAPI

 

He could actually use copyInto, which is backed by System.arraycopy. But seeing how DefaultListModel is backed by Vector, it would be wiser to use your own ListModel implementation, allowing you to add this support while potentionally increasing performance.

Edited by fixthissite
  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...