Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.maschinenmc.lobby.commands;
- import java.io.File;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.World;
- 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 net.maschinenmc.lobby.main.Main;
- public class SpawnCommand implements CommandExecutor {
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- if(!(sender instanceof Player)) {
- System.out.println("Das darf nur ein Spieler!");
- return true;
- }
- Player p =(Player) sender;
- File file = new File("plugins//MaschinenMC-Lobby//spawn.yml");
- if(!file.exists()) {
- p.sendMessage(Main.prefix + " Es wurde kein Spawn gesetzt! Bitte kontaktiere einen Admin!");
- return true;
- }
- YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
- Location loc = p.getLocation();
- double x = cfg.getDouble("X");
- double y = cfg.getDouble("Y");
- double z = cfg.getDouble("Z");
- double yaw = cfg.getDouble("Yaw");
- double pitch = cfg.getDouble("Pitch");
- String worldname = cfg.getString("Worldname");
- World welt = Bukkit.getWorld(worldname);
- loc.setX(x);
- loc.setY(y);
- loc.setZ(z);
- loc.setYaw((float) yaw);
- loc.setPitch((float) pitch);
- loc.setWorld(welt);
- p.teleport(loc);
- p.sendMessage(Main.prefix + " Du bist nun am Spawn!");
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement