Skip to content

Varaibles. Too varied for my liking.📎

If you're running a Minecraft server, you should know what a variable is. If not, that's okay! It's time to learn! In simpler terms, a variable is something that stores a value. Variables would normally come in types, which would all be used in order to store what the program needs to store. Take a look below for a small example:

a: 100 
# a is a variable as it is holding a value. The variable type here is an Integer, which is a whole number.

b: "Hello there!" 
# b is also a variable as it is holding a value. The variable type here is a String, which is what is normally used for letters, characters and text in general.

c: true
# c is also a variable as it is holding a value. The variable type here is a Boolean, which is a true or a false statement. An easier way of thinking of this would be a "yes" or a "no".

d:
  - "Hello"
  - "There!"
# d is also a variable as it is holding a value. The variable type here is a StringList, which, as you can see, is the same as a String, but many of them in a list. 
Both A and B are variables, as they both hold a value. If you've configured a plugin before, there's no doubt that you've already seen how useful this can be. You are able to use this to customise multiple features of your plugin, however, you should be careful that you don't mix up variable types. You'll come across many issues if you put a String where an Integer should be, for example. More on this later.

Variable Types📎

As said before, variables come as different types, each type can be used for a different purpose, but they'll all work together in the end, in order to give you the desired result. It could be very useful for you to learn up on these the best you can, as each variable type will come in handy somewhere down the line. You've probably used them before! Take a look at some of the more commonly used YAML variables here:

  • String: It's normally used in text. Letters, numbers, sentences, words, paragraphs, you name it. If it's got to do with text, it would be a form of String.
  • Number: These would be used to define any number you wanted. In Java, these would be split up into multiple variables, but you don't need to know that.
  • StringList: This would be the same as a String but in a list format. There are many uses for this, but the most common is where you would use it to customise your /help command.
  • List: A set of variables of the same data type, stored in one location. A list of variables. Many forms of lists are derived from here, including String Lists.
  • Boolean: Probably one of the simplest variables to use. It's simply a "true" or a "false"! Think of it like a "yes" or a "no". Used for virtually anything. You probably used it when ordering food at a restaurant! Booleans are used every day, everywhere.

These are some of the more common variable types you would see when configuring your server. You won't need to identify these, but it's useful information to have, no?

I choose you! ... Wait, what are you?📎

Want to test what you've just learned? Take a look at the challenge below.

Below this paragraph, I have written out eight different variables. It's okay if you don't know what you're looking at yet, I haven't shown you how to identify which variable is which, although, give it a try if you feel like challenging yourself!

Identify the variables below:

a: true
b: "Goodbye my friend..."
c: 66.2
d:
  - "A"
  - "B"
e: "Huh?"
f: 'What''s going on here?'
g: 75
h: true
i:
  - 1
  - 2
  - 3
  - 4

Please note that some information may be wrong in this wiki, and I have done my best to ensure whatever has been written is correct. This was written in British English (with the odd oxford comma). If you believe there is a spelling, grammatical, or technical error, please contact me immediately through Discord: longbow122#1576