Chapter 7Use Piles of Variables: Arrays

Is your head full yet? I hope not, because you have a few fun things left to learn. In this chapter we’ll add these abilities to your toolbox:

  • Use local variables that exist only within a block

  • Use class-level global variables that can be accessed from anywhere in the class

  • Keep piles of data in arrays

Now that we can create a plugin command to do something, we need to take a look at how to remember stuff—in other words, how to better use Java variables to keep track of values. We’ll see when to use which kind of variable and how to work with piles of data in different ways (things like lists of Player objects), and we’ll build a couple of cool plugins along the way.

Get Learn to Program with Minecraft Plugins, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.