Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tk.challangesmp.toxicmine;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import java.util.Scanner;
- import java.util.Timer;
- import java.util.TimerTask;
- import static tk.challangesmp.toxicmine.Main.*;
- public class Start implements CommandExecutor {
- private Main plugin;
- static Timer timer = new Timer();
- static TimerTask timerTask = new ChallengeTimer();
- public Start(Main plugin) {
- this.plugin = plugin;
- plugin.getCommand("challenge").setExecutor(this);
- }
- @Override
- public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) {
- if(args.length == 0) {
- if(label.equalsIgnoreCase("challenge"))
- commandSender.sendMessage(ChatColor.RED + "Invalid parameter. do /challenge help!");
- return true;
- }
- if (!(commandSender instanceof Player)) {
- if(args.length > 0)
- if (args[0].equals("reload")) {
- //Seconds for a week is 604800000
- //TIMER DOES NOTHING BUT JUST COUNT 1 WEEK IN TICKS! ALL OPS WILL GET NOTIFIED WHEN TIMER FINISHED!!
- timer.schedule(timerTask, 604800000);
- timerIsOngoing = true;
- Main.getPlugin(Main.class).reloadConfig();
- commandSender.sendMessage("Challenge successfully reloaded");
- return true;
- }
- if(args.length > 0) {
- if (args[0].equals("stop"))
- timerTask.cancel();
- timer.purge();
- commandSender.sendMessage("Cancelled timer.");
- return true;
- }
- return true;
- }
- Player player = (Player) commandSender;
- if(args.length > 0) {
- if (args[0].equals("join"))
- if (competent.contains(player)) {
- player.sendMessage("You are already there in the challenge!");
- return true;
- }
- if (timerIsOngoing){
- competent.add(player);
- player.sendMessage("Successfully added you to the challenge!");
- } else {
- player.sendMessage("The challenge timer is not ongoing.");
- }
- return true;
- }
- if(args.length > 0) {
- if (args[0].equals("quit"))
- if (!competent.contains(player)) {
- player.sendMessage("You are not there in the challenge.");
- return true;
- }
- if (timerIsOngoing){
- Scanner scanner = new Scanner(System.in);
- player.sendMessage("Are you sure to remove yourself from the challenge? [Yes/No]");
- String opinion = scanner.nextLine();
- if (opinion.equalsIgnoreCase("yes")) {
- competent.remove(player);
- player.sendMessage("Successfully removed you from the challenge.");
- }else {
- player.sendMessage("Aborted removal.");
- }
- } else {
- competent.remove(player);
- player.sendMessage("Successfully removed you from the challenge.");
- }
- return true;
- }
- if(args.length > 0) {
- if (args[0].equals("tp"))
- if (player.isOp()) {
- Location location = player.getLocation();
- for (Player value : competent) {
- value.teleport(location);
- }
- player.sendMessage("Finished teleporting competent(s) to you!");
- }
- return true;
- }
- if(args.length > 0) {
- if (args[0].equals("help"))
- if(player.isOp());
- player.sendMessage(ChatColor.YELLOW + "Command List");
- player.sendMessage(ChatColor.BLUE + "/challenge join " + ChatColor.GRAY + "- " + ChatColor.YELLOW + "Adds player to waiting state");
- player.sendMessage(ChatColor.BLUE + "/challenge quit " + ChatColor.GRAY + "- " +ChatColor.YELLOW + "Removes player to waiting state");
- player.sendMessage(ChatColor.BLUE + "/challenge reload(CONSOLE ONLY) " + ChatColor.GRAY + "- " + ChatColor.YELLOW + "Starts the Timer");
- player.sendMessage(ChatColor.BLUE + "/challenge stop(CONSOLE ONLY) " + ChatColor.GRAY + "- " + ChatColor.YELLOW + "Stops the Timer");
- player.sendMessage(ChatColor.BLUE + "/challenge tp(OP ONLY) " + ChatColor.GRAY + "- " + ChatColor.YELLOW + "Tps everyone in waiting stage to the current location of the command executor");
- player.sendMessage(ChatColor.BLUE + "/challenge help " + ChatColor.GRAY + "- " + ChatColor.YELLOW + "Shows the command list");
- }else if(!player.isOp()) {
- player.sendMessage(ChatColor.YELLOW + "Command List");
- player.sendMessage(ChatColor.BLUE + "/challenge join " + ChatColor.GRAY + "- " + ChatColor.YELLOW + "Adds player to waiting state");
- player.sendMessage(ChatColor.BLUE + "/challenge quit " + ChatColor.GRAY + "- " +ChatColor.YELLOW + "Removes player to waiting state");
- player.sendMessage(ChatColor.BLUE + "/challenge help " + ChatColor.GRAY + "- " + ChatColor.YELLOW + "Shows the command list");
- }
- return true;
- }
- }
- class ChallengeTimer extends TimerTask {
- @Override
- public void run() {
- oneWeekOver = true;
- }
- public void AlarmOps() {
- if(oneWeekOver = true) {
- Player operators = (Player) Bukkit.getServer().getOperators();
- operators.sendMessage("" + ChatColor.YELLOW + ChatColor.BOLD + "THE TIMER HAS ENDED! YOU CAN NOW START THE EVENT!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement