Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ru.lisenochek.bls;
- 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.entity.Player;
- import java.io.IOException;
- public class CommandAPI implements CommandExecutor {
- private static World w = Bukkit.getWorld(CoordsConfig.y.getString("Coords.world"));
- private static double x = CoordsConfig.y.getDouble("Coords.x");
- private static double y = CoordsConfig.y.getDouble("Coords.y");
- private static double z = CoordsConfig.y.getDouble("Coords.z");
- private static float pitch = CoordsConfig.y.getInt("Coords.pitch");
- private static float yaw = CoordsConfig.y.getInt("Coords.yaw");
- @Override
- public boolean onCommand(CommandSender s, Command cmd, String str, String[] args) {
- Player p = (Player) s;
- if (str.equalsIgnoreCase("spawn")) {
- Location loc = new Location(w, x, y, z, yaw, pitch);
- if (p.getWorld() != loc.getWorld()) return true;
- p.teleport(loc);
- p.sendMessage(C.c(Config.getSuccessTeleport));
- }
- if (str.equalsIgnoreCase("setspawn")) {
- if (!p.isOp()) return true;
- Location loc = p.getLocation();
- CoordsConfig.y.set("Coords.world", p.getWorld().getName());
- CoordsConfig.y.set("Coords.x", loc.getX());
- CoordsConfig.y.set("Coords.y", loc.getY());
- CoordsConfig.y.set("Coords.z", loc.getZ());
- CoordsConfig.y.set("Coords.pitch", loc.getPitch());
- CoordsConfig.y.set("Coords.yaw", loc.getYaw());
- try {
- CoordsConfig.y.save(CoordsConfig.f);
- } catch (IOException e) {
- e.printStackTrace();
- }
- w = Bukkit.getWorld(CoordsConfig.y.getString("Coords.world"));
- x = CoordsConfig.y.getDouble("Coords.x");
- y = CoordsConfig.y.getDouble("Coords.y");
- z = CoordsConfig.y.getDouble("Coords.z");
- pitch = CoordsConfig.y.getInt("Coords.pitch");
- yaw = CoordsConfig.y.getInt("Coords.yaw");
- p.sendMessage(C.c(Config.getSuccessSetTeleport));
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement