Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package thom.plugin.hardcoresurvival.modules.survivalcommands.commands;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import thom.plugin.hardcoresurvival.Main;
- /**
- * Created by Thom on 24-7-2017.
- */
- public class Spawn implements CommandExecutor {
- @Override
- public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
- if (commandSender instanceof Player) {
- Player player = (Player) commandSender;
- if (command.getName().equalsIgnoreCase("spawn")) {
- if (strings.length == 0) {
- if (player.hasPermission("hardcoresurvival.spawn")) {
- if (Main.getPlugin().getDataManager().getConfig().
- getString("HardcoreSurvival.Data.Spawn.World") != null) {
- Location location = new Location(
- Bukkit.getWorld(Main.getPlugin().getDataManager().getConfig().
- getString("HardcoreSurvival.Data.Spawn.World")),
- Main.getPlugin().getDataManager().getConfig().
- getDouble("HardcoreSurvival.Data.Spawn.X"),
- Main.getPlugin().getDataManager().getConfig().
- getDouble("HardcoreSurvival.Data.Spawn.Y"),
- Main.getPlugin().getDataManager().getConfig().
- getDouble("HardcoreSurvival.Data.Spawn.Z"),
- (float) Main.getPlugin().getDataManager().getConfig().
- getDouble("HardcoreSurvival.Data.Spawn.Pitch"),
- (float) Main.getPlugin().getDataManager().getConfig().
- getDouble("HardcoreSurvival.Data.Spawn.Yaw"));
- if (location != null) {
- player.teleport(location);
- }
- }
- }
- } else if (strings.length == 1) {
- if (strings[0].equalsIgnoreCase("set")) {
- if (player.hasPermission("hardcoresurvival.setspawn")) {
- Location location = player.getLocation();
- Main.getPlugin().getDataManager().getConfig().set("HardcoreSurvival.Data.Spawn.World",
- location.getWorld().toString());
- Main.getPlugin().getDataManager().getConfig().set("HardcoreSurvival.Data.Spawn.X",
- location.getX());
- Main.getPlugin().getDataManager().getConfig().set("HardcoreSurvival.Data.Spawn.Y",
- location.getY());
- Main.getPlugin().getDataManager().getConfig().set("HardcoreSurvival.Data.Spawn.Z",
- location.getZ());
- Main.getPlugin().getDataManager().getConfig().set("HardcoreSurvival.Data.Spawn.Pitch",
- location.getPitch());
- Main.getPlugin().getDataManager().getConfig().set("HardcoreSurvival.Data.Spawn.Yaw",
- location.getYaw());
- player.sendMessage(Main.PREFIX + ChatColor.GRAY + "You have set the spawn!");
- }
- }
- }
- }
- } else {
- commandSender.sendMessage(ChatColor.RED + "Je moet een speler zijn om dit command te kunnen uitvoeren!");
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement