Skip to content

Instantly share code, notes, and snippets.

@Neverboosted
Created June 12, 2019 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Neverboosted/f58d9dd4c9f25b6ce1365a31fb1f9254 to your computer and use it in GitHub Desktop.
Save Neverboosted/f58d9dd4c9f25b6ce1365a31fb1f9254 to your computer and use it in GitHub Desktop.
HomeCommand
package de.fly.main.commands;
import de.fly.main.Main;
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;
public class HomeCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(label.equalsIgnoreCase("home")){
if(sender instanceof Player){
Player p = (Player) sender;
if(args.length == 0) {
p.sendMessage("§b[REDz] §cFalscher Syntax : §7/home (Name)");
return false;
}
if(args.length == 1) {
if(Main.getInstance().getConfig().contains("home" + p.getUniqueId().toString() + "." + args[0])){
World w = Bukkit.getServer().getWorld(Main.getInstance().getConfig().getString("home" + p.getUniqueId().toString() + "." + args[0] + ".world"));
double x = Main.getInstance().getConfig().getDouble("home" + p.getUniqueId().toString() + "." + args[0] + ".x");
double y = Main.getInstance().getConfig().getDouble("home" + p.getUniqueId().toString() + "." + args[0] + ".y");
double z = Main.getInstance().getConfig().getDouble("home" + p.getUniqueId().toString() + "." + args[0] + ".z" );
double pitch = Main.getInstance().getConfig().getDouble("home" + p.getUniqueId().toString() + "." + args[0] + ".pitch");
double yaw = Main.getInstance().getConfig().getDouble("home" + p.getUniqueId().toString() + "." + args[0] + ".yaw");
p.teleport(new Location(w, x, y, z , (float) yaw, (float) pitch));
p.sendMessage("§b[REDz] §7Du hast dich zu deinen §e" + args[0] + "§7teleportiert");
return false;
} else {
p.sendMessage("§b[REDz] §7 Der Home mit dem Namen §e " + args[0] + " §7 exsistiert nicht!");
return false;
}
}
if(args.length >= 2) {
p.sendMessage("§b[REDz] §cFalscher Syntax : §7/home (Name)");
return false;
}
}
}
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment