Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.matthewgeek123.swap;
- import java.util.Random;
- import java.util.TimerTask;
- import javax.swing.Timer;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.java.JavaPlugin;
- public class Main extends JavaPlugin{
- public void onEnable(){
- getLogger().info("Enabled!");
- }
- public void onDisable(){
- getLogger().info("Disabled!");
- }
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
- //World pworld = getServer().getWorld("world");
- if(cmd.getName().equalsIgnoreCase("startswap")){
- Player player = (Player) sender;
- player.sendMessage("doing it");
- if(player.hasPermission("deathswap.start")){
- final int stop=0;
- Player player1 = Bukkit.getServer().getPlayer(args[0]);
- Player player2 = Bukkit.getServer().getPlayer(args[1]);
- loop(player1, player2, 0);
- }
- }else if(cmd.getName().equalsIgnoreCase("stopswap")){
- loop(null, null, 1);
- }
- return true;
- }
- public static void loop(final Player player1, final Player player2, int stop){
- //from here to next comment needs to be in a delay timer thing (that can stop).length from var randomNum
- Random rand = new Random();
- int max=120;
- int min=20;
- final int randomNum = rand.nextInt((max - min) + 1) + min;
- loop(player1, player2, 0);
- onswap(player1, player2);
- //stop here. The variable randomNum will keep changing so the timers length will too
- if(stop==1){
- //stop the timer here (that will fire on /stopswap)
- }
- }
- public static void onswap(Player p1, Player p2){
- //player 1 department
- double x1, y1, z1;
- Location xyz1 = p1.getLocation();
- x1 = (double)xyz1.getX();
- y1 = (double)xyz1.getY();
- z1 = (double)xyz1.getZ();
- p1.sendMessage("player 1 coords: "+x1+" "+y1+" "+z1);
- //player 2 department
- double x2, y2, z2;
- Location xyz2 = p2.getLocation();
- x2 = (double)xyz2.getX();
- y2 = (double)xyz2.getY();
- z2 = (double)xyz2.getZ();
- p1.sendMessage("player 2 coords: "+x2+" "+y2+" "+z2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement