Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.xkev320x.info;
- 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.FileConfiguration;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.entity.Player;
- public class LocationPort implements CommandExecutor {
- @SuppressWarnings("unused")
- private Info plugin;
- File file = new File("plugins/Info", "homes.yml"); //File wird geladen,er existiert ja schon...
- FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
- public LocationPort(Info info) {
- this.plugin = info;
- }
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String cmdlabel, String[] args) {
- if(!(sender instanceof Player)){
- sender.sendMessage("§cDu musst ein Spieler sein!");
- } else {
- Player p = (Player) sender;
- if(args.length == 1){
- if(cfg.contains(args[0])){ //falls das Home existiert...
- String world = cfg.getString(p.getName() + "." + args[0] + ".world"); //String world wird als der Weltname definiert in der Datei..
- double x = cfg.getDouble(p.getName() + "." + args[0] + ".x"); //...
- double y = cfg.getDouble(p.getName() + "." + args[0] + ".y");
- double z = cfg.getDouble(p.getName() + "." + args[0] + ".z");
- double yaw = cfg.getDouble(p.getName() + "." + args[0] + ".yaw");
- double pitch = cfg.getDouble(p.getName() + "." + args[0] + ".pitch");
- Location loc = new Location(Bukkit.getWorld(world), x, y, z); //Die Location loc wird erstellt und die Koordinaten sind die aus der Datei...
- loc.setPitch((float) pitch); //Der pitch wird zur loc hinzugefügt
- loc.setYaw((float) yaw); //Der yaw wird zur loc hinzugefügt
- p.teleport(loc); //Player wird zu dieser loc geportet...
- p.sendMessage("§2Du wurdest zu deinem Home §6" + args[0] + " §2geportet");
- } else if(!(cfg.contains(args[0]))){
- p.sendMessage("§cDieses Home existiert nicht!");
- }
- } else {
- p.sendMessage("§4Nutze bitte /location <name>");
- }
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement