Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.Dobbermann2.BowButton;
- import java.util.ArrayList;
- import java.util.HashMap;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.enchantments.Enchantment;
- import org.bukkit.entity.Player;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.meta.ItemMeta;
- import org.bukkit.plugin.java.JavaPlugin;
- public class Main extends JavaPlugin{
- public ArrayList<Player> jp = new ArrayList<Player>();
- public int a;
- public int startCountdownId;
- public HashMap<Player, Integer> points = new HashMap<Player, Integer>();
- public void onEnable() {
- Bukkit.getPluginManager().registerEvents(new Join(this), this);
- Bukkit.broadcastMessage(ChatColor.RED + "BowButton is now ENABLED");
- GameState.setState(GameState.IN_LOBBY);
- getConfig().addDefault("bowbutton.world", "bowbutton");
- getConfig().addDefault("bowbutton.x", 1);
- getConfig().addDefault("bowbutton.y", 1);
- getConfig().addDefault("bowbutton.z", 1);
- getConfig().addDefault("p1.x", 1);
- getConfig().addDefault("p1.y", 1);
- getConfig().addDefault("p1.z", 1);
- getConfig().addDefault("p2.x", 1);
- getConfig().addDefault("p2.y", 1);
- getConfig().addDefault("p2.z", 1);
- getConfig().addDefault("p3.x", 1);
- getConfig().addDefault("p3.y", 1);
- getConfig().addDefault("p3.z", 1);
- getConfig().addDefault("p4.x", 1);
- getConfig().addDefault("p4.y", 1);
- getConfig().addDefault("p4.z", 1);
- getConfig().addDefault("p5.x", 1);
- getConfig().addDefault("p5.y", 1);
- getConfig().addDefault("p5.z", 1);
- getConfig().addDefault("p1.world", "bowbutton");
- getConfig().addDefault("p2.world", "bowbutton");
- getConfig().addDefault("p3.world", "bowbutton");
- getConfig().addDefault("p4.world", "bowbutton");
- getConfig().addDefault("p5.world", "bowbutton");
- getConfig().options().copyDefaults(true);
- saveConfig();
- }
- public void onDisable() {
- }
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
- Player p = (Player) sender;
- if (cmd.getName().equalsIgnoreCase("bowbutton")) {
- if (args[0].equalsIgnoreCase("setlobby")) {
- if (p.isOp()) {
- }
- }
- if (args[0].equalsIgnoreCase("p1")) {
- if (p.isOp()) {
- getConfig().set("p1.world", p.getWorld().getName());
- getConfig().set("p1.x", p.getLocation().getX());
- getConfig().set("p1.y", p.getLocation().getY());
- getConfig().set("p1.z", p.getLocation().getZ());
- p.sendMessage(ChatColor.GREEN + "p1 has been set!");
- }
- }
- if (args[0].equalsIgnoreCase("p2")) {
- if (p.isOp()) {
- getConfig().set("p2.world", p.getWorld().getName());
- getConfig().set("p2.x", p.getLocation().getX());
- getConfig().set("p2.y", p.getLocation().getY());
- getConfig().set("p2.z", p.getLocation().getZ());
- p.sendMessage(ChatColor.GREEN + "p2 has been set!");
- }
- }
- if (args[0].equalsIgnoreCase("p3")) {
- if (p.isOp()) {
- getConfig().set("p3.world", p.getWorld().getName());
- getConfig().set("p3.x", p.getLocation().getX());
- getConfig().set("p3.y", p.getLocation().getY());
- getConfig().set("p3.z", p.getLocation().getZ());
- p.sendMessage(ChatColor.GREEN + "p3 has been set!");
- }
- }
- if (args[0].equalsIgnoreCase("p4")) {
- if (p.isOp()) {
- getConfig().set("p4.world", p.getWorld().getName());
- getConfig().set("p4.x", p.getLocation().getX());
- getConfig().set("p4.y", p.getLocation().getY());
- getConfig().set("p4.z", p.getLocation().getZ());
- p.sendMessage(ChatColor.GREEN + "p4 has been set!");
- }
- }
- if (args[0].equalsIgnoreCase("p5")) {
- if (p.isOp()) {
- getConfig().set("p5.world", p.getWorld().getName());
- getConfig().set("p5.x", p.getLocation().getX());
- getConfig().set("p5.y", p.getLocation().getY());
- getConfig().set("p5.z", p.getLocation().getZ());
- p.sendMessage(ChatColor.GREEN + "p5 has been set!");
- }
- }
- if (args[0] == null) {
- p.sendMessage(ChatColor.RED + "Invalid Arguments");
- }
- if (args.length == 0) {
- p.sendMessage(ChatColor.RED + "Invalid Arguments");
- }
- }
- return false;
- }
- public void Start() {
- if (GameState.isState(GameState.IN_LOBBY)) {
- Countdown.timeUntilStart = 60;
- startCountdownId = getServer().getScheduler().scheduleSyncRepeatingTask(this, new Countdown(this), 20L, 20L);
- }
- }
- public void StartGame() {
- stopCountdown();
- if (!(jp.get(0) == null)){
- jp.get(0).teleport(new Location(Bukkit.getWorld("bowbutton"), this.getConfig().getInt("p1.x"), this.getConfig().getInt("p1.y"), this.getConfig().getInt("p1.z")));
- }else {
- return;
- }
- if (!(jp.get(1) == null)){
- jp.get(1).teleport(new Location(Bukkit.getWorld("bowbutton"), this.getConfig().getInt("p2.x"), this.getConfig().getInt("p2.y"), this.getConfig().getInt("p2.z")));
- }else {
- return;
- }
- if (!(jp.get(2) == null)){
- jp.get(2).teleport(new Location(Bukkit.getWorld("bowbutton"), this.getConfig().getInt("p3.x"), this.getConfig().getInt("p3.y"), this.getConfig().getInt("p3.z")));
- }else {
- return;
- }
- if (!(jp.get(3) == null)){
- jp.get(3).teleport(new Location(Bukkit.getWorld("bowbutton"), this.getConfig().getInt("p4.x"), this.getConfig().getInt("p4.y"), this.getConfig().getInt("p4.z")));
- }else {
- return;
- }
- if (!(jp.get(4) == null )){
- jp.get(4).teleport(new Location(Bukkit.getWorld("bowbutton"), this.getConfig().getInt("p5.x"), this.getConfig().getInt("p5.y"), this.getConfig().getInt("p5.z")));
- }else {
- return;
- }
- GameState.setState(GameState.IN_GAME);
- ItemStack bow = new ItemStack(Material.BOW);
- ItemMeta bom = bow.getItemMeta();
- bom.addEnchant(Enchantment.ARROW_INFINITE, 1, true);
- bow.setAmount(1);
- bow.setItemMeta(bom);
- ItemStack arr = new ItemStack(Material.ARROW);
- arr.setAmount(1);
- jp.get(0).getInventory().addItem(bow);
- jp.get(0).getInventory().addItem(arr);
- jp.get(1).getInventory().addItem(bow);
- jp.get(1).getInventory().addItem(arr);
- jp.get(2).getInventory().addItem(bow);
- jp.get(2).getInventory().addItem(arr);
- jp.get(3).getInventory().addItem(bow);
- jp.get(3).getInventory().addItem(arr);
- jp.get(4).getInventory().addItem(bow);
- jp.get(4).getInventory().addItem(arr);
- jp.get(5).getInventory().addItem(bow);
- jp.get(5).getInventory().addItem(arr);
- return;
- }
- public void stopCountdown() {
- getServer().getScheduler().cancelTask(startCountdownId);
- }
- public void RestartCountdown() {
- stopCountdown();
- Start();
- }
- public void Ending() {
- jp.clear();
- points.clear();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement