Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.korex.setspawn;
- import java.io.File;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.entity.Player;
- import me.korex.main.Main;
- public class newspawncmd implements CommandExecutor{
- int high = 4;
- int countdown;
- private Main plugin;
- public newspawncmd(Main pl) {
- this.plugin = pl;
- }
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- final Player p = (Player)sender;
- int x = (int) p.getLocation().getX();
- int y = (int) p.getLocation().getY();
- double z = (int) p.getLocation().getZ();
- final Location loc1 = new Location(p.getWorld(), x, y, z);
- p.sendMessage(Main.pr + "In §a3 §6Sekunden wirst du zum Spawn teleportiert!");
- countdown = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin,new Runnable() {
- public void run() {
- int x2 = (int) p.getLocation().getX();
- int y2= (int) p.getLocation().getY();
- double z2 = (int) p.getLocation().getZ();
- Location loc2 = new Location(p.getWorld(), x2, y2, z2);
- if(loc1.equals(loc2)) {
- if(high != 1) {
- high--;
- p.sendMessage(" §a" + high + "§6Sekunden...");
- } else {
- p.sendMessage(Main.pr + "Du wurdest zum §aSpawn §6teleportiert!");
- Bukkit.getScheduler().cancelTask(countdown);
- high=4;
- File file = new File("plugins/Spawn","Spawn.yml");
- YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
- String world = cfg.getString("spawn.world");
- double x = cfg.getDouble("spawn.x");
- double y = cfg.getDouble("spawn.y");
- double z = cfg.getDouble("spawn.z");
- float yaw = (float) cfg.getDouble("spawn.yaw");
- float pitch = (float) cfg.getDouble("spawn.pitch");
- Location loc = new Location(Bukkit.getWorld(world), x, y, z, yaw, pitch);
- p.teleport(loc);
- }
- } else {
- p.sendMessage(Main.pr + "Teleportation abgebrochen, du darfst dich §cnicht §6bewegen!");
- Bukkit.getScheduler().cancelTask(countdown);
- high=4;
- }
- }
- }, 0, 20);
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement