Bukkit Coding – (11) Lists

Lists are pretty important in Java and Bukkit. Although you may not know it, you’ve already used lists when you used arguments in the last lesson. args is in fact a list. In this section, I’ll be going over how to use and create lists, and then we’ll use lists to improve our plugin from the last section.

Lists are a good way to store lots of information. Lists are defined by using two brackets after the variable type. Here’s an example of defining a list.

We can give our list some data like so.

and then you can output items in the list like so.

Note: There is no way to add data to the list after the list has been created. To make dynamic lists, see the section on ArrayLists.

So now we can implement a List into our plugin that we created in the previous lesson.

Let’s implement Lists into our Admin Broadcast plugin.

and of course we can add a prefix like so.

We can finish our plugin by putting the prefix in a String variable LIKE SO!

Be the first to comment

Leave a Reply

Your email address will not be published.


*