#How to make a Bukkit minigame This is a tutorial on how to make a Bukkit minigame plugin for 1.7/1.8. You should have some basic knowledge of Java, OOP, and Bukkit.
##Arenas
Arenas are the base to any minigame (unless you only want one instance of the game). These can be implemented in many different ways, but my favorite is to have an Arena
class with a static ArrayList<Arena>
inside it.
public class Arena {
//global list
private static ArrayList<Arena> arenaList = new ArrayList<Arena>();
//local variables
private String name;
private Location spawn;
private Location lobby;
private ArrayList<UUID> players;
public Arena(String name, Location spawn, Location lobby){
this.name = name;
this.spawn = spawn;
this.lobby = lobby;
this.players = new ArrayList<UUID>();
arenaList.add(this);
}
//Getters for variables and arenaList
}
You'll want different variables, such as Locations, for different games. Here I have a main game spawn and a lobby for in between games. We also use UUID
s to store Players instead of the Player object due to memory leaks.
Now for some methods which we can use in Listeners (put these in your Arena class).
public static getArena(String name){
for(Arena a : arenaList){
//put .equalsIgnoreCase() if you want to ignore case in commands and such
if(a.getName().equals(name)){
return a;
}
}
return null;
}
public static getArena(Player p){
for(Arena a : arenaList){
if(a.getPlayers().contains(p.getUniqueId)){
return a;
}
}
return null;
}
public static isInGame(Player p){
return getArena(p) != null;
}