1.8.8 Debugging a old code

Discussion in 'Spigot Plugin Development' started by Wilsoon, Feb 1, 2020.

  1. Just don't bully me for this, thanks.
    So basically, I have an attacker and a defender, I actually tried challenging myself and everything worked except for the /kit (name) (player) part when I tried to do it with Bukkit#dispatchCommand.

    However, whenever I challenge someone else, the code where it says: "You are required to challenge before..." triggers, and it never works. Even after they press Accepted. How would I fix both of these issues? I have only one class and here it is.
    as for the multiple codes where getServer().getPluginManager().getPlugin("Essentials") and EssentialsX separately, I tried it with "||" operator and it ended up only triggering that part whether Essentials was inside my plugins or not. So I did it separately.
    It's also my first time using a HashMap and I found it a little confusing, so if there's anything wrong with the map that someone taught me. Just bear with my very horribly written code.

    Main class:
    Code (Java):

    package com.gmail.calorious.start;

    import java.io.File;
    import java.io.IOException;
    import java.util.HashMap;
    import java.util.Map;
    import java.util.Random;
    import java.util.UUID;

    import org.bukkit.Bukkit;
    import org.bukkit.Location;
    import org.bukkit.Material;

    import net.minecraft.server.v1_8_R3.PacketPlayOutTitle;
    import net.minecraft.server.v1_8_R3.PacketPlayOutTitle.EnumTitleAction;
    import net.md_5.bungee.api.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.command.ConsoleCommandSender;
    import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;

    import net.md_5.bungee.api.chat.ClickEvent;
    import net.md_5.bungee.api.chat.ComponentBuilder;
    import net.md_5.bungee.api.chat.HoverEvent;
    import net.md_5.bungee.api.chat.TextComponent;
    import org.bukkit.block.Block;
    import net.minecraft.server.v1_8_R3.IChatBaseComponent.ChatSerializer;
    public class Main extends JavaPlugin {
        private final Map<UUID, UUID> map = new HashMap<>();
        private final Map<String, String> playermap = new HashMap<>();
                    private static Main instance;
                    public static Main getInstance() { return instance; }
           @Override
           public void onEnable() {
               File config;
               try {
                config = File.createTempFile("config", ".yml");
                boolean exists = config.exists();
                if(exists == true) {
                    getLogger().info("Config found!");
                    getLogger().info("Saving Config...");
                    saveDefaultConfig();
                 
                    if(getServer().getPluginManager().getPlugin("Essentials") == null) {
                        getLogger().info(ChatColor.RED + "Essentials was not found.");
                    } else {
                        getLogger().info(ChatColor.GREEN + "Found Essentials, kit names are as follows:");
                        getLogger().info(ChatColor.GOLD + "Defender's kit name: " + getConfig().getString("kits.defender"));
                        getLogger().info(ChatColor.GOLD + "Attacker's kit name: " + getConfig().getString("kits.attacker"));
                    }
                    if(getServer().getPluginManager().getPlugin("EssentialsX") == null) {
                        getLogger().info(ChatColor.RED + "EssentialsX was not found.");
                    } else {
                        getLogger().info(ChatColor.GREEN + "Found EssentialsX, kit names are as follows:");
                        getLogger().info(ChatColor.GOLD + "Defender's kit name: " + getConfig().getString("kits.defender"));
                        getLogger().info(ChatColor.GOLD + "Attacker's kit name: " + getConfig().getString("kits.attacker"));
                    }

                } else {
                    getLogger().info("Creating Config...");
                    saveDefaultConfig();
                    getLogger().info(ChatColor.GREEN + "SafeHouse Plugin has been enabled.");
                    if(getServer().getPluginManager().getPlugin("Essentials") == null) {
                        getLogger().info(ChatColor.RED + "Essentials was not found.");
                    } else {
                        getLogger().info(ChatColor.GREEN + "Found Essentials, kit names are as follows:");
                        getLogger().info(ChatColor.GOLD + "Defender's kit name: " + getConfig().getString("kits.defender"));
                        getLogger().info(ChatColor.GOLD + "Attacker's kit name: " + getConfig().getString("kits.attacker"));
                    }
                    if(getServer().getPluginManager().getPlugin("EssentialsX") == null) {
                        getLogger().info(ChatColor.RED + "EssentialsX was not found.");
                    } else {
                        getLogger().info(ChatColor.GREEN + "Found EssentialsX, kit names are as follows:");
                        getLogger().info(ChatColor.GOLD + "Defender's kit name: " + getConfig().getString("kits.defender"));
                        getLogger().info(ChatColor.GOLD + "Attacker's kit name: " + getConfig().getString("kits.attacker"));
                    }

                    getLogger().info(ChatColor.GREEN + "SafeHouse Plugin has been enabled.");  
                }
            } catch (IOException e) {
                getLogger().info(ChatColor.GOLD + "An exception has occurred while loading the config");
                e.printStackTrace();
            }
             
           
           }
         
           @Override
           public void onDisable() {
               getLogger().info(ChatColor.RED + "SafeHouse Plugin has been disabled.");
           }
        @Override
           public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {              
                   if(cmd.getName().equalsIgnoreCase("safehouse")) {
                     if(args.length == 0) {
                         sender.sendMessage(ChatColor.GOLD + "                 SAFEHOUSE                       ");
                         sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.BOLD + "-----------------------------------");
                         sender.sendMessage(ChatColor.GREEN + "    /safehouse - Base Command for SafeHouse Plugin");
                         sender.sendMessage(ChatColor.GREEN + "    /safehouse (player) - Challenge someone to SafeHouse");
                         sender.sendMessage(ChatColor.GREEN + "    /safehouse reload - Reload SafeHouse plugin");
                         sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.BOLD + "-----------------------------------");
                         sender.sendMessage(ChatColor.GOLD + "                 SAFEHOUSE                       ");
                   }
                     if(args.length == 1 && args[0].equalsIgnoreCase("reload")) {
                        reloadConfig();
                        sender.sendMessage(ChatColor.GREEN + "Plugin has been reloaded!");
                        return true;
                   }
                     if(args.length == 1 && !(args[0].equalsIgnoreCase("reload"))) {
                         Player defender = Bukkit.getPlayer(args[0]);
                         if(defender == null) {
                            sender.sendMessage(ChatColor.RED + "This player is not online!");
                         } else if(!(sender instanceof Player)){
                            sender.sendMessage(ChatColor.RED + "You are not a player!");
                         } else {
                            TextComponent acceptmessage = new TextComponent("[Accept]");
                            TextComponent denymessage = new TextComponent("[Deny]");
                            TextComponent spacemessage = new TextComponent(" ");
                            acceptmessage.setColor(ChatColor.GREEN);
                            acceptmessage.setBold(true);
                            acceptmessage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/accepted" )); //Insert command after ,
                            acceptmessage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Click to accept.").create()));
                            denymessage.setColor(ChatColor.RED);
                            denymessage.setBold(true);
                            denymessage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/declined" )); //Insert command after ,
                            denymessage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Click to decline.").create()));
                            defender.sendMessage(ChatColor.GOLD + "You have received a SafeHouse challenge from " + sender.getName());
                            defender.sendMessage(ChatColor.GOLD + " Press the respective buttons to accept/deny.");
                            defender.spigot().sendMessage(acceptmessage, spacemessage, denymessage);
                            playermap.put(sender.getName(), defender.getName());
                            map.put(((Player) sender).getUniqueId(), defender.getUniqueId());
                          //COMPLETE
                        }
                     }
            }      
            if(cmd.getName().equalsIgnoreCase("accepted")) {
                Player defender = (Player) sender; // Renamed 'defender' from `attacker` (because 'defender' is who uses this command)
                UUID attackerId = map.remove(defender.getUniqueId()); // Get the attacker's id from the defender's id. I use #remove here to clean up your map while you can still get the wanted value
                Player attacker = Bukkit.getPlayer(attackerId); // get the Player from his id
                // do whatever u want here
                     if(attacker == null) {
                        sender.sendMessage(ChatColor.RED + "The person you are attempting to challenge is offline!");
                        return false;
                     }
                    attacker.sendMessage(ChatColor.GREEN + "Your challenge to " + sender.getName() + "has been accepted.");
                    Random random = new Random();
                    if (random.nextBoolean()) {
                            defender = (Player) sender;
                            attacker = defender;
                        }
                    attacker.sendMessage(ChatColor.GOLD + "Your inventory will be cleared as you enter the challenge.");
                    sender.sendMessage(ChatColor.GREEN + "You have accepted the challenge.");
                    sender.sendMessage(ChatColor.GOLD + "Your inventory will be cleared as you enter the challenge.");
                    Location tplocattacker = attacker.getLocation();
                    Location tplocdefender = ((Player) sender).getLocation();
                    tplocattacker.setX(getConfig().getDouble("startloc.attacker.x"));
                    tplocattacker.setY(getConfig().getDouble("startloc.attacker.y"));
                    tplocattacker.setZ(getConfig().getDouble("startloc.attacker.z"));
                    tplocdefender.setX(getConfig().getDouble("startloc.defender.x"));
                    tplocdefender.setY(getConfig().getDouble("startloc.defender.y"));
                    tplocdefender.setZ(getConfig().getDouble("startloc.defender.z"));
                    defender.teleport(tplocdefender);
                    attacker.teleport(tplocattacker);
                     Player defender_ = defender;
                    PacketPlayOutTitle countdown3 = new PacketPlayOutTitle(EnumTitleAction.TITLE, ChatSerializer.a("[\"\",{\"text\":\"3\",\"bold\":true,\"color\":\"green\"}]"));
                    PacketPlayOutTitle countdown2 = new PacketPlayOutTitle(EnumTitleAction.TITLE, ChatSerializer.a("[\"\",{\"text\":\"2\",\"bold\":true,\"color\":\"gold\"}]"));
                    PacketPlayOutTitle countdown1 = new PacketPlayOutTitle(EnumTitleAction.TITLE, ChatSerializer.a("[\"\",{\"text\":\"1\",\"bold\":true,\"color\":\"red\"}]"));
                    PacketPlayOutTitle countdownstart = new PacketPlayOutTitle(EnumTitleAction.TITLE, ChatSerializer.a("[\"\",{\"text\":\"Start!\",\"bold\":true,\"color\":\"green\"}]"));
                   
                    ((CraftPlayer) defender_).getHandle().playerConnection.sendPacket(countdown3);
                    ((CraftPlayer) sender).getHandle().playerConnection.sendPacket(countdown3);
                    Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> {
                       ((CraftPlayer) defender_).getHandle().playerConnection.sendPacket(countdown2);
                       ((CraftPlayer) sender).getHandle().playerConnection.sendPacket(countdown2);
                        }, 40L);
                   
                    Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> {
                            ((CraftPlayer) defender_).getHandle().playerConnection.sendPacket(countdown1);
                    ((CraftPlayer) sender).getHandle().playerConnection.sendPacket(countdown1);
                        }, 40L);
                    Location attackerdoor = new Location(Bukkit.getWorld("world"), getConfig().getDouble("blockloc.attacker.x"), getConfig().getDouble("blockloc.attacker.y"), getConfig().getDouble("blockloc.attacker.z"));
                    Block attackdoorblock = attackerdoor.getBlock();
                    Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> {
                           ((CraftPlayer) defender_).getHandle().playerConnection.sendPacket(countdownstart);
                    ((CraftPlayer) sender).getHandle().playerConnection.sendPacket(countdownstart);
                    attackdoorblock.setType(Material.AIR);
                    defender_.sendMessage(ChatColor.DARK_RED + "You are now able to leave the box, the box will be locked in 30 seconds.");
                        }, 40L);
                    ConsoleCommandSender console = getServer().getConsoleSender();
                    defender.sendMessage(ChatColor.AQUA + "Clearing inventories...");
                    attacker.sendMessage(ChatColor.AQUA + "Clearing inventories...");
                     defender.getInventory().clear();
                     attacker.getInventory().clear();
                     Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> {
                        defender_.sendMessage(ChatColor.AQUA + "Attempting to issue kits...");
                    sender.sendMessage(ChatColor.AQUA + "Attempting to issue kits...");
                    Bukkit.dispatchCommand(console, "kit " + getConfig().getString("kits.defender") + sender.getName());
                     Bukkit.dispatchCommand(console, "kit " + getConfig().getString("kits.attacker") + attacker.getName());
                     getLogger().info(ChatColor.AQUA + "SafeHouse Plugin has successfully issued kits!");
                     sender.sendMessage(ChatColor.AQUA + "Kits have successfully been issued.");
                     attacker.sendMessage(ChatColor.AQUA + "Kits have successfully been issued.");
                      }, 60L);
                       
                    }
                   
                    if(getConfig().getString("kits.defender") == null) {
                        getLogger().info(ChatColor.RED + "Failed to issue defender kit due to no kit name set in config.");
                        sender.sendMessage(ChatColor.DARK_RED + "Failed to issue defender kit, no kit name was set.");
                        attacker.sendMessage(ChatColor.DARK_RED + "Failed to issue defender kit, no kit name was set.");
                        return true;
                    }
                     if(getConfig().getString("kits.attacker") == null) {
                        getLogger().info(ChatColor.RED + "Failed to issue attacker kit due to no kit name set in config.");
                        sender.sendMessage(ChatColor.DARK_RED + "Failed to issue attacker kit, no kit name was set.");
                        defender_.sendMessage(ChatColor.DARK_RED + "Failed to issue attacker kit, no kit name was set.");
                        return true;
                    }
                   
                   
                    Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> {
                          defender_.sendMessage(ChatColor.GREEN + "The box has been locked.");
                          attackdoorblock.setType(Material.OBSIDIAN);
                          sender.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "This plugin is no longer managing the game.");
                          defender_.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "This plugin is no longer managing the game.");
                        }, 600L);
                    return true;
            }
            if(cmd.getName().equalsIgnoreCase("declined")) {
                Player defender = (Player) sender; // Renamed 'defender' from `attacker` (because 'defender' is who uses this command)
                UUID attackerId = map.remove(defender.getUniqueId()); // Get the attacker's id from the defender's id. I use #remove here to clean up your map while you can still get the wanted value
                Player attacker = Bukkit.getPlayer(attackerId); // get the Player from his id
                sender.sendMessage(ChatColor.RED + "You declined the challenge.");
                return true;
            }
            return true;
           }
    }
     
     
  2. Essentials & EssentialsX both use Essentials as the pluginname.
     
    • Agree Agree x 1
  3. Strahan

    Benefactor

    How are you even able to compile this? Copying and pasting it into my IDE and it has a bunch of errors due to an extraneous closing bracket after your scheduler for the kit command. Also what is the point of randomly flipping attacker and defender? You should not use generic names like "map" for your variables, they should be meaningful. I see in your code you are using playermap to store attacker/defender names then map to store attacker/defender UUID. That's pointless; just store UUID and get the names from that when needed then you don't have two maps to manage state on. Which, BTW, I do not see you ever removing players from playermap. Also you should read up on abstraction. Having all this in the onCommand is not best practices.
     
  4. To add on to that, your indentation is a bit out of whack... Even though most of the time it doesn't affect anything, sometimes with if-else statements it can cause the wrong else to trigger on an if. It would also help you find misplaced brackets easier.
     
  5. I fixed it back, but it probably still wouldn't work:
    Code (Java):

    package com.gmail.calorious.start;

    import java.io.File;
    import java.io.IOException;
    import java.util.HashMap;
    import java.util.Map;
    import java.util.Random;
    import java.util.UUID;

    import org.bukkit.Bukkit;
    import org.bukkit.Location;
    import org.bukkit.Material;

    import net.minecraft.server.v1_8_R3.PacketPlayOutTitle;
    import net.minecraft.server.v1_8_R3.PacketPlayOutTitle.EnumTitleAction;
    import net.md_5.bungee.api.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.command.ConsoleCommandSender;
    import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;

    import net.md_5.bungee.api.chat.ClickEvent;
    import net.md_5.bungee.api.chat.ComponentBuilder;
    import net.md_5.bungee.api.chat.HoverEvent;
    import net.md_5.bungee.api.chat.TextComponent;
    import org.bukkit.block.Block;
    import net.minecraft.server.v1_8_R3.IChatBaseComponent.ChatSerializer;
    public class Main extends JavaPlugin {
        private final Map<UUID, UUID> uuidmap = new HashMap<>();
                    private static Main instance;
                    public static Main getInstance() { return instance; }
           @Override
           public void onEnable() {
               File config;
               try {
                config = File.createTempFile("config", ".yml");
                boolean exists = config.exists();
                if(exists == true) {
                    getLogger().info("Config found!");
                    getLogger().info("Saving Config...");
                    saveDefaultConfig();
                   
                    if(getServer().getPluginManager().getPlugin("Essentials") == null) {
                        getLogger().info(ChatColor.RED + "Essentials was not found.");
                    } else {
                        getLogger().info(ChatColor.GREEN + "Found Essentials, kit names are as follows:");
                        getLogger().info(ChatColor.GOLD + "Defender's kit name: " + getConfig().getString("kits.defender"));
                        getLogger().info(ChatColor.GOLD + "Attacker's kit name: " + getConfig().getString("kits.attacker"));
                    }
                    if(getServer().getPluginManager().getPlugin("EssentialsX") == null) {
                        getLogger().info(ChatColor.RED + "EssentialsX was not found, .");
                    } else {
                        getLogger().info(ChatColor.GREEN + "Found EssentialsX, kit names are as follows:");
                        getLogger().info(ChatColor.GOLD + "Defender's kit name: " + getConfig().getString("kits.defender"));
                        getLogger().info(ChatColor.GOLD + "Attacker's kit name: " + getConfig().getString("kits.attacker"));
                    }

                } else {
                    getLogger().info("Creating Config...");
                    saveDefaultConfig();
                    getLogger().info(ChatColor.GREEN + "SafeHouse Plugin has been enabled.");
                    if(getServer().getPluginManager().getPlugin("Essentials") == null) {
                        getLogger().info(ChatColor.RED + "Essentials was not found.");
                    } else {
                        getLogger().info(ChatColor.GREEN + "Found Essentials, kit names are as follows:");
                        getLogger().info(ChatColor.GOLD + "Defender's kit name: " + getConfig().getString("kits.defender"));
                        getLogger().info(ChatColor.GOLD + "Attacker's kit name: " + getConfig().getString("kits.attacker"));
                    }
                    if(getServer().getPluginManager().getPlugin("EssentialsX") == null) {
                        getLogger().info(ChatColor.RED + "EssentialsX was not found.");
                    } else {
                        getLogger().info(ChatColor.GREEN + "Found EssentialsX, kit names are as follows:");
                        getLogger().info(ChatColor.GOLD + "Defender's kit name: " + getConfig().getString("kits.defender"));
                        getLogger().info(ChatColor.GOLD + "Attacker's kit name: " + getConfig().getString("kits.attacker"));
                    }

                    getLogger().info(ChatColor.GREEN + "SafeHouse Plugin has been enabled.");  
                }
            } catch (IOException e) {
                getLogger().info(ChatColor.GOLD + "An exception has occurred while loading the config");
                e.printStackTrace();
            }
               
             
           }
           
           @Override
           public void onDisable() {
               getLogger().info(ChatColor.RED + "SafeHouse Plugin has been disabled.");
           }
        @Override
           public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {              
                   if(cmd.getName().equalsIgnoreCase("safehouse")) {
                     if(args.length == 0) {
                         sender.sendMessage(ChatColor.GOLD + "                 SAFEHOUSE                       ");
                         sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.BOLD + "-----------------------------------");
                         sender.sendMessage(ChatColor.GREEN + "    /safehouse - Base Command for SafeHouse Plugin");
                         sender.sendMessage(ChatColor.GREEN + "    /safehouse (player) - Challenge someone to SafeHouse");
                         sender.sendMessage(ChatColor.GREEN + "    /safehouse reload - Reload SafeHouse plugin");
                         sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.BOLD + "-----------------------------------");
                         sender.sendMessage(ChatColor.GOLD + "                 SAFEHOUSE                       ");
                   }
                     if(args.length == 1 && args[0].equalsIgnoreCase("reload")) {
                        reloadConfig();
                        sender.sendMessage(ChatColor.GREEN + "Plugin has been reloaded!");
                        return true;
                   }
                     if(args.length == 1 && !(args[0].equalsIgnoreCase("reload"))) {
                         Player defender = Bukkit.getPlayer(args[0]);
                         if(defender == null) {
                            sender.sendMessage(ChatColor.RED + "This player is not online!");
                         } else if(!(sender instanceof Player)){
                            sender.sendMessage(ChatColor.RED + "You are not a player!");
                         } else {
                            TextComponent acceptmessage = new TextComponent("[Accept]");
                            TextComponent denymessage = new TextComponent("[Deny]");
                            TextComponent spacemessage = new TextComponent(" ");
                            acceptmessage.setColor(ChatColor.GREEN);
                            acceptmessage.setBold(true);
                            acceptmessage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/accepted" )); //Insert command after ,
                            acceptmessage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Click to accept.").create()));
                            denymessage.setColor(ChatColor.RED);
                            denymessage.setBold(true);
                            denymessage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/declined" )); //Insert command after ,
                            denymessage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Click to decline.").create()));
                            defender.sendMessage(ChatColor.GOLD + "You have received a SafeHouse challenge from " + sender.getName());
                            defender.sendMessage(ChatColor.GOLD + " Press the respective buttons to accept/deny.");
                            defender.spigot().sendMessage(acceptmessage, spacemessage, denymessage);
                            uuidmap.put(((Player) sender).getUniqueId(), defender.getUniqueId());
                          //COMPLETE
                        }
                     }
            }      
            if(cmd.getName().equalsIgnoreCase("accepted")) {
                Player defender = (Player) sender; // Renamed 'defender' from `attacker` (because 'defender' is who uses this command)
                UUID attackerId = uuidmap.remove(defender.getUniqueId()); // Get the attacker's id from the defender's id. I use #remove here to clean up your map while you can still get the wanted value
                Player attacker = Bukkit.getPlayer(attackerId); // get the Player from his id
                // do whatever u want here
                     if(attacker == null) {
                        sender.sendMessage(ChatColor.RED + "The person you are attempting to challenge is offline!");
                        return false;
                     }
                    attacker.sendMessage(ChatColor.GREEN + "Your challenge to " + sender.getName() + "has been accepted.");
                    Random random = new Random();
                    if (random.nextBoolean()) {
                            defender = (Player) sender;
                            attacker = defender;
                        }
                    attacker.sendMessage(ChatColor.GOLD + "Your inventory will be cleared as you enter the challenge.");
                    sender.sendMessage(ChatColor.GREEN + "You have accepted the challenge.");
                    sender.sendMessage(ChatColor.GOLD + "Your inventory will be cleared as you enter the challenge.");
                    Location tplocattacker = attacker.getLocation();
                    Location tplocdefender = ((Player) sender).getLocation();
                    tplocattacker.setX(getConfig().getDouble("startloc.attacker.x"));
                    tplocattacker.setY(getConfig().getDouble("startloc.attacker.y"));
                    tplocattacker.setZ(getConfig().getDouble("startloc.attacker.z"));
                    tplocdefender.setX(getConfig().getDouble("startloc.defender.x"));
                    tplocdefender.setY(getConfig().getDouble("startloc.defender.y"));
                    tplocdefender.setZ(getConfig().getDouble("startloc.defender.z"));
                    defender.teleport(tplocdefender);
                    attacker.teleport(tplocattacker);
                     Player defender_ = defender;
                    PacketPlayOutTitle countdown3 = new PacketPlayOutTitle(EnumTitleAction.TITLE, ChatSerializer.a("[\"\",{\"text\":\"3\",\"bold\":true,\"color\":\"green\"}]"));
                    PacketPlayOutTitle countdown2 = new PacketPlayOutTitle(EnumTitleAction.TITLE, ChatSerializer.a("[\"\",{\"text\":\"2\",\"bold\":true,\"color\":\"gold\"}]"));
                    PacketPlayOutTitle countdown1 = new PacketPlayOutTitle(EnumTitleAction.TITLE, ChatSerializer.a("[\"\",{\"text\":\"1\",\"bold\":true,\"color\":\"red\"}]"));
                    PacketPlayOutTitle countdownstart = new PacketPlayOutTitle(EnumTitleAction.TITLE, ChatSerializer.a("[\"\",{\"text\":\"Start!\",\"bold\":true,\"color\":\"green\"}]"));
                     
                    ((CraftPlayer) defender_).getHandle().playerConnection.sendPacket(countdown3);
                    ((CraftPlayer) sender).getHandle().playerConnection.sendPacket(countdown3);
                    Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> {
                       ((CraftPlayer) defender_).getHandle().playerConnection.sendPacket(countdown2);
                       ((CraftPlayer) sender).getHandle().playerConnection.sendPacket(countdown2);
                        }, 40L);
                     
                    Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> {
                            ((CraftPlayer) defender_).getHandle().playerConnection.sendPacket(countdown1);
                    ((CraftPlayer) sender).getHandle().playerConnection.sendPacket(countdown1);
                        }, 40L);
                    Location attackerdoor = new Location(Bukkit.getWorld("world"), getConfig().getDouble("blockloc.attacker.x"), getConfig().getDouble("blockloc.attacker.y"), getConfig().getDouble("blockloc.attacker.z"));
                    Block attackdoorblock = attackerdoor.getBlock();
                    Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> {
                           ((CraftPlayer) defender_).getHandle().playerConnection.sendPacket(countdownstart);
                    ((CraftPlayer) sender).getHandle().playerConnection.sendPacket(countdownstart);
                    attackdoorblock.setType(Material.AIR);
                    defender_.sendMessage(ChatColor.DARK_RED + "You are now able to leave the box, the box will be locked in 30 seconds.");
                        }, 40L);
                    ConsoleCommandSender console = getServer().getConsoleSender();
                    defender.sendMessage(ChatColor.AQUA + "Clearing inventories...");
                    attacker.sendMessage(ChatColor.AQUA + "Clearing inventories...");
                     defender.getInventory().clear();
                     attacker.getInventory().clear();
                     Player attacker_ = attacker;
                     Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> {
                        defender_.sendMessage(ChatColor.AQUA + "Attempting to issue kits...");
                    sender.sendMessage(ChatColor.AQUA + "Attempting to issue kits...");
                    Bukkit.dispatchCommand(console, "kit " + getConfig().getString("kits.defender") + sender.getName());
                     Bukkit.dispatchCommand(console, "kit " + getConfig().getString("kits.attacker") + attacker_.getName());
                     getLogger().info(ChatColor.AQUA + "SafeHouse Plugin has successfully issued kits!");
                     sender.sendMessage(ChatColor.AQUA + "Kits have successfully been issued.");
                     attacker_.sendMessage(ChatColor.AQUA + "Kits have successfully been issued.");
                      }, 60L);
                         
                     
                    if(getConfig().getString("kits.defender") == null) {
                        getLogger().info(ChatColor.RED + "Failed to issue defender kit due to no kit name set in config.");
                        sender.sendMessage(ChatColor.DARK_RED + "Failed to issue defender kit, no kit name was set.");
                        attacker.sendMessage(ChatColor.DARK_RED + "Failed to issue defender kit, no kit name was set.");
                        return true;
                    }
                     if(getConfig().getString("kits.attacker") == null) {
                        getLogger().info(ChatColor.RED + "Failed to issue attacker kit due to no kit name set in config.");
                        sender.sendMessage(ChatColor.DARK_RED + "Failed to issue attacker kit, no kit name was set.");
                        defender_.sendMessage(ChatColor.DARK_RED + "Failed to issue attacker kit, no kit name was set.");
                        return true;
                    }
                     
                     
                    Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> {
                          defender_.sendMessage(ChatColor.GREEN + "The box has been locked.");
                          attackdoorblock.setType(Material.OBSIDIAN);
                          sender.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "This plugin is no longer managing the game.");
                          defender_.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "This plugin is no longer managing the game.");
                        }, 600L);
                    return true;
            }
            if(cmd.getName().equalsIgnoreCase("declined")) {
                sender.sendMessage(ChatColor.RED + "You declined the challenge.");
                return true;
            }
            return true;
           }
    }
     
     
  6. Yep, I've got this point already, it's because I made this code before the other plugin you took a look at.