Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.stefvanschie;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Random;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.World;
- import org.bukkit.entity.Player;
- public class Join
- {
- BuildingGame main = new BuildingGame();
- public void joinGame (Player player, String arena)
- {
- if (player.hasPermission("join"))
- {
- if (main.arenas.contains(arena))
- {
- if (!main.playersInArena.containsKey(arena))
- {
- main.playersInArena.put(arena, 0);
- }
- if (main.playersInArena.get(arena) < main.arenas.getInt(arena + ".maxplayers"))
- {
- player.sendMessage(ChatColor.GOLD + "You have joined the game");
- for (Player pl : main.players.keySet())
- {
- if (main.players.get(pl).equals(arena))
- {
- pl.sendMessage(ChatColor.GOLD + "" + player.getName() + " joined the game!");
- }
- }
- main.playersInArena.put(arena, main.playersInArena.get(arena) + 1);
- main.players.put(player, arena);
- main.votes.put(player, 0);
- if (main.playersInArena.get(arena) == main.arenas.getInt(arena + ".maxplayers"))
- {
- String subject = "";
- if (main.config.contains("subjects"))
- {
- List<String> subjects = new ArrayList<String>();
- subjects = main.config.getStringList("subjects");
- Random rndm = new Random();
- int subjectint = rndm.nextInt(subjects.size());
- subject = subjects.get(subjectint);
- }
- int places = 1;
- for (Player pl : main.players.keySet())
- {
- if (main.players.get(pl).equals(arena))
- {
- String worldstr = main.arenas.getString(arena + "." + places + ".world");
- World world = main.getServer().getWorld(worldstr);
- int x = main.arenas.getInt(arena + "." + places + ".x");
- int y = main.arenas.getInt(arena + "." + places + ".y");
- int z = main.arenas.getInt(arena + "." + places + ".z");
- Location location = new Location(world, x, y, z);
- pl.teleport(location);
- pl.sendMessage(ChatColor.GOLD + "The game has started!");
- if (main.config.contains("subjects"))
- {
- pl.sendMessage(ChatColor.GOLD + "The subject is " + subject);
- }
- main.playernumbers.put(places, player);
- places++;
- }
- }
- main.timer(arena);
- }
- }
- else if (main.playersInArena.get(arena) >= main.config.getInt(arena + ".maxplayers"))
- {
- player.sendMessage(ChatColor.RED + "This arena is currently full");
- }
- else
- {
- player.sendMessage(ChatColor.RED + "An unexpected error occured: Error: bg.join.playersingame");
- }
- }
- else if (!main.config.contains(arena))
- {
- player.sendMessage(ChatColor.RED + "This arena does not exists!");
- }
- else
- {
- player.sendMessage(ChatColor.RED + "An unexpected error occured. Error: bg.join.config.contains");
- }
- }
- else if (!player.hasPermission("join"))
- {
- player.sendMessage(ChatColor.RED + "You don't have the required permission for that!");
- }
- else
- {
- player.sendMessage(ChatColor.RED + "An unexpected error occured: Error: bg.join.permission");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement