BigVoidDog
Minecrafter
Code:
package de.alexcra.warp;
import java.io.File;
import java.io.IOException;
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.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
public class WarpCommand implements CommandExecutor {
private File file = new File("plugins/Warp", "warps.yml");
private FileConfiguration cfg = YamlConfiguration.loadConfiguration(this.file);
private String err_need_Player ="§4Du musst ein Spieler sein!";
private String err_need_argument ="§4Du hast zu wenige argumente!";
@Override
public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
Player player = null;
if(cs instanceof Player) {
player = (Player)cs;
}
if(label.equalsIgnoreCase("warp")) {
if(player != null) {
if(args.length >= 1) {
String str = "warps." + args[0].toLowerCase() + ".";
try {
World w =Bukkit.getWorld(this.cfg.getString(str + "world"));
if(w == null) {
cs.sendMessage("§cDer Welt ist unbekannt!");
return true;
}
double x = this.cfg.getDouble(str + "x");
double y = this.cfg.getDouble(str + "y");
double z = this.cfg.getDouble(str + "z");
double yaw = this.cfg.getDouble(str + "yaw");
double pitch = this.cfg.getDouble(str + "pitch");
Location loc = new Location(w, x, y, z, (float) yaw, (float) pitch);
player.teleport(loc);
cs.sendMessage("§6Du wurdes zum Warp §e " + args[0].toLowerCase() + " §6Teleportiert");
} catch(NullPointerException exc) {
cs.sendMessage("§4Der Warp §6" + args[0].toLowerCase() + "§existiert nicht.");
}
} else {
cs.sendMessage(err_need_argument);
}
} else {
cs.sendMessage(err_need_Player);
}
} else if(label.equalsIgnoreCase("setwarp")) {
if(player != null) {
if(args.length == 1) {
Location loc = player.getLocation();
String str = "warps." + args[0].toLowerCase() + ".";
this.cfg.set(str +"world", loc.getWorld().getName());
this.cfg.set(str + "x", loc.getX());
this.cfg.set(str + "y", loc.getY());
this.cfg.set(str + "z", loc.getZ());
this.cfg.set(str + "yaw", loc.getYaw());
this.cfg.set(str + "pitch", loc.getPitch());
try {
this.cfg.save(this.file);
cs.sendMessage("§7[§6Warp§7] §e " + args[0].toLowerCase() + " §6Wurde gesetzt.");
} catch (IOException e) {
e.printStackTrace();
}
} else {
cs.sendMessage(err_need_argument);
}
} else {
cs.sendMessage(err_need_Player);
}
} else if(label.equalsIgnoreCase("delwarp")) {
if(args.length >= 1) {
this.cfg.set("warps." + args[0].toLowerCase(), null);
try {
this.cfg.save(file);
cs.sendMessage("§7[§6Warp§7] §e " + args[0].toLowerCase() + " §6Wurde gelöcht.");
} catch (IOException e) {
e.printStackTrace();
}
} else {
cs.sendMessage(err_need_argument);
}
} else if(label.equalsIgnoreCase("waprs")) {
String str = "Warps: ";
for(String warp: this.cfg.getConfigurationSection("warps").getKeys(false)) {
str += warp + " ";
}
cs.sendMessage(str);
}
return false;
}
}
da kommt ein andere fehrle meldung statt Warp existiert nicht, Hilfe was muss ich machen
Zuletzt bearbeitet: