<commit_before>package org.royaldev.royalcommands.rcommands;

import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
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 org.royaldev.royalcommands.PConfManager;
import org.royaldev.royalcommands.RUtils;
import org.royaldev.royalcommands.RoyalCommands;

public class CmdHome implements CommandExecutor {

    private RoyalCommands plugin;

    public CmdHome(RoyalCommands plugin) {
        this.plugin = plugin;
    }

    @Override
    public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
        if (cmd.getName().equalsIgnoreCase("home")) {
            if (!plugin.isAuthorized(cs, "rcmds.home")) {
                RUtils.dispNoPerms(cs);
                return true;
            }

            if (!(cs instanceof Player)) {
                cs.sendMessage(ChatColor.RED + "This command is only available to players!");
                return true;
            }

            Player p = (Player) cs;

            boolean homeSet;
            Double homeX;
            Double homeY;
            Double homeZ;
            Float homeYaw;
            Float homePitch;
            World homeW;
            String name = "";
            if (args.length > 0) name = args[0];

            PConfManager pcm;
            if (name.contains(":") && plugin.isAuthorized(cs, "rcmds.others.home")) {
                if (!new PConfManager(name.split(":")[0]).exists()) {
                    cs.sendMessage(ChatColor.RED + "That player does not exist!");
                    return true;
                }
                OfflinePlayer op = plugin.getServer().getOfflinePlayer(name.split(":")[0]);
                if (plugin.isAuthorized(op, "rcmds.exempt.home")) {
                    cs.sendMessage(ChatColor.RED + "You cannot go to that player's house!");
                    return true;
                }
                pcm = new PConfManager(name.split(":")[0]);
                name = name.split(":")[1];
            } else {
                pcm = new PConfManager(cs.getName());
            }
            homeSet = (args.length > 0) ? pcm.getBoolean("home." + name + ".set") : pcm.getBoolean("home.home.set");
            if (homeSet) {
                if (args.length > 0) {
                    homeX = pcm.getDouble("home." + name + ".x");
                    homeY = pcm.getDouble("home." + name + ".y");
                    homeZ = pcm.getDouble("home." + name + ".z");
                    homeYaw = Float.parseFloat(pcm.getString("home." + name + ".yaw"));
                    homePitch = Float.parseFloat(pcm.getString("home." + name + ".pitch"));<commit_msg>Fixed: Possible exception in /home<commit_after>package org.royaldev.royalcommands.rcommands;

import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
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 org.royaldev.royalcommands.PConfManager;
import org.royaldev.royalcommands.RUtils;
import org.royaldev.royalcommands.RoyalCommands;

public class CmdHome implements CommandExecutor {

    private RoyalCommands plugin;

    public CmdHome(RoyalCommands plugin) {
        this.plugin = plugin;
    }

    @Override
    public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
        if (cmd.getName().equalsIgnoreCase("home")) {
            if (!plugin.isAuthorized(cs, "rcmds.home")) {
                RUtils.dispNoPerms(cs);
                return true;
            }

            if (!(cs instanceof Player)) {
                cs.sendMessage(ChatColor.RED + "This command is only available to players!");
                return true;
            }

            Player p = (Player) cs;

            boolean homeSet;
            Double homeX;
            Double homeY;
            Double homeZ;
            Float homeYaw;
            Float homePitch;
            World homeW;
            String name = "";
            if (args.length > 0) name = args[0];

            PConfManager pcm;
            if (name.contains(":") && plugin.isAuthorized(cs, "rcmds.others.home")) {
                if (!new PConfManager(name.split(":")[0]).exists()) {
                    cs.sendMessage(ChatColor.RED + "That player does not exist!");
                    return true;
                }
                OfflinePlayer op = plugin.getServer().getOfflinePlayer(name.split(":")[0]);
                if (plugin.isAuthorized(op, "rcmds.exempt.home")) {
                    cs.sendMessage(ChatColor.RED + "You cannot go to that player's house!");
                    return true;
                }
                String[] ss = name.split(":");
                if (ss.length < 2) {
                    cs.sendMessage(ChatColor.RED + "You must include the name of the player and home (player:home).");
                    return true;
                }
                pcm = new PConfManager(ss[0]);
                name = ss[1];
            } else {
                pcm = new PConfManager(cs.getName());
            }
            homeSet = (args.length > 0) ? pcm.getBoolean("home." + name + ".set") : pcm.getBoolean("home.home.set");
            if (homeSet) {
                if (args.length > 0) {
                    homeX = pcm.getDouble("home." + name + ".x");
                    homeY = pcm.getDouble("home." + name + ".y");
                    homeZ = pcm.getDouble("home." + name + ".z");
                    homeYaw = Float.parseFloat(pcm.getString("home." + name + ".yaw"));
                    homePitch = Float.parseFloat(pcm.getString("home." + name + ".pitch"));
{'fraction_non_alphanumeric': 0.12489350826375874, 'fraction_numerical': 0.002896575225762481, 'mean_word_length': 1.8166986564299423, 'pattern_counts': {'":': 9, '<': 4, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5216634', 'n_tokens_mistral': 1694, 'n_tokens_neox': 1600, 'n_words': 363}