player.getTargetBlock won't work!

Discussion in 'Spigot Plugin Development' started by BroodRooster, May 24, 2016.

  1. So Hi,

    I'm developing a plugin. But the player.getTargetBlock won't work. Here is my code:
    Code (Text):
                    if (args[1].equalsIgnoreCase("Frame")) {
                        Player player = (Player)sender;
                        int maxDistance = 50;
                        Block target = player.getTargetBlock((HashSet<Byte>)null, 100);
                        if (args.length != 4) {
                            sender.sendMessage("Too many arguments!");
                            return true;
                        }
                        if (target.getType() != Material.AIR) {
                            FrameCommands.plugin.FrameConfig.set("Frame." + args[2] + args[3] + ".world", target.getWorld().getName());
                            FrameCommands.plugin.FrameConfig.set("Frame." + args[2] + args[3] + ".x", target.getLocation().getX());
                            FrameCommands.plugin.FrameConfig.set("Frame." + args[2] + args[3] + ".y", target.getLocation().getY());
                            FrameCommands.plugin.FrameConfig.set("Frame." + args[2] + args[3] + ".z", target.getLocation().getZ());
                            FrameCommands.plugin.FrameConfig.saveConfig();
                            sender.sendMessage("Succesfully create: + args[2] + "for: " + args[3]");
                            return true;
                        }
                    }
    Hopefully somebody can help me.

    Greats,
    BroodRooster
     
  2. Can you tell us which error is thrown... or no error?
     
  3. This isn't an error, it is crossed out because the method is depreciated. The replacement for this method is one with the same signature but with the HashSet<Byte> replaced with a Set<Material>. Change your cast to Set<Material> and you will be using the new method.