Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main.dartanman.fpvp.game;
- import java.util.ArrayList;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.block.Sign;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.Action;
- import org.bukkit.event.player.PlayerInteractEvent;
- import main.dartanman.fpvp.Main;
- import net.md_5.bungee.api.ChatColor;
- public class Game implements CommandExecutor,Listener{
- private Main plugin;
- public Game(Main pl)
- {
- this.plugin = pl;
- }
- ArrayList<Player> red = new ArrayList<Player>();
- ArrayList<Player> blue = new ArrayList<Player>();
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- FileConfiguration config = plugin.getConfig();
- Player player = (Player) sender;
- if(!(sender instanceof Player)){
- sender.sendMessage("Only players can use this command!");
- return false;
- }
- if(args.length == 0){
- player.sendMessage(ChatColor.BLUE + "FrostGame Help Menu:");
- player.sendMessage(ChatColor.GREEN + "/fg setlobby" + ChatColor.GOLD + " - " + ChatColor.BLUE + "Set the minigame lobby");
- return true;
- }
- if(args.length == 1){
- if(args[0].equalsIgnoreCase("setlobby")){
- Location loc = player.getLocation();
- config.set("location.World" , loc.getWorld().getName());
- config.set("location.X" , loc.getX());
- config.set("location.Y" , loc.getY());
- config.set("location.Z" , loc.getZ());
- player.sendMessage(ChatColor.GREEN + "Lobby set!");
- return true;
- }
- if(args[0].equalsIgnoreCase("setquit")){
- Location loc = player.getLocation();
- config.set("location2.World" , loc.getWorld().getName());
- config.set("location2.X" , loc.getX());
- config.set("location2.Y" , loc.getY());
- config.set("location2.Z" , loc.getZ());
- player.sendMessage(ChatColor.GREEN + "Quit spot set!");
- return true;
- }
- if(args[0].equalsIgnoreCase("setspawn1")){
- Location loc = player.getLocation();
- config.set("location3.World" , loc.getWorld().getName());
- config.set("location3.X" , loc.getX());
- config.set("location3.Y" , loc.getY());
- config.set("location3.Z" , loc.getZ());
- player.sendMessage(ChatColor.GREEN + "Spawn 1 set!");
- return true;
- }
- if(args[0].equalsIgnoreCase("setspawn2")){
- Location loc = player.getLocation();
- config.set("location4.World" , loc.getWorld().getName());
- config.set("location4.X" , loc.getX());
- config.set("location4.Y" , loc.getY());
- config.set("location4.Z" , loc.getZ());
- player.sendMessage(ChatColor.GREEN + "Spawn 2 set!");
- return true;
- }
- if(args[0].equalsIgnoreCase("join")){
- Location newLoc = new Location(Bukkit.getWorld((String) config.get("location.World")), config.getDouble("location.X"), config.getDouble("location.Y"), config.getDouble("location.Z"));
- player.teleport(newLoc);
- if(blue.size() == 0){
- blue.add(player);
- red.remove(player);
- player.sendMessage(ChatColor.BLUE + "You were added to the blue team");
- }else if(red.size() == 0){
- red.add(player);
- blue.remove(player);
- player.sendMessage(ChatColor.RED + "You were added to the red team");
- }
- }else if(red.size() == 1 && blue.size() == 1){
- player.sendMessage("Please wait til the current battle is over");
- }
- player.sendMessage(ChatColor.GREEN + "You have joined the game!");
- return true;
- }
- if(args[0].equalsIgnoreCase("quit") || args[0].equalsIgnoreCase("leave")){
- Location newLoc = new Location(Bukkit.getWorld((String) config.get("location2.World")), config.getDouble("location2.X"), config.getDouble("location2.Y"), config.getDouble("location2.Z"));
- player.teleport(newLoc);
- player.sendMessage(ChatColor.GREEN + "You have joined the game!");
- return true;
- }
- player.sendMessage(ChatColor.RED + "Improper args! Try again!");
- return true;
- }
- @EventHandler
- public void onInteract(PlayerInteractEvent event){
- FileConfiguration config = plugin.getConfig();
- Player player = (Player) event.getPlayer();
- if(event.getAction() == Action.RIGHT_CLICK_BLOCK) {
- if(event.getClickedBlock().getType() == Material.SIGN ||
- event.getClickedBlock().getType() == Material.WALL_SIGN ||
- event.getClickedBlock().getType() == Material.SIGN_POST){
- Sign sign = (Sign) event.getClickedBlock().getState();
- if(sign.getLine(0).equalsIgnoreCase("[FrostPvP]") && sign.getLine(1).equalsIgnoreCase("[Start]")){
- if(red.contains(player)){
- Location newLoc = new Location(Bukkit.getWorld((String) config.get("location3.World")), config.getDouble("location3.X"), config.getDouble("location3.Y"), config.getDouble("location3.Z"));
- player.teleport(newLoc);
- player.sendMessage(ChatColor.GREEN + "The game is starting");
- }
- if(blue.contains(player)){
- Location newLoc = new Location(Bukkit.getWorld((String) config.get("location4.World")), config.getDouble("location4.X"), config.getDouble("location4.Y"), config.getDouble("location4.Z"));
- player.teleport(newLoc);
- player.sendMessage(ChatColor.GREEN + "The game is starting");
- } else{
- player.sendMessage(ChatColor.RED + "You are not in a game!");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement