Solved BlockBreakEvent e.getBlock().getLocation() error

Discussion in 'Spigot Plugin Development' started by JustixDeveloper, Jun 4, 2017.

Thread Status:
Not open for further replies.
  1. Hello guys,
    I'm coding a BedWars-Plugin and I want do detect if a player breaks a bed

    My Code:
    Code (Text):
                        if(e.getBlock().getLocation() == Data.getBedLocation("Red")){
                            p.sendMessage(Main.prefix + "Du darfst dein eigenes Bett nicht abbauen");
    And the getBedLocation()-Method:
    Code (Text):
        public static Location getBedLocation(String teamName){
            double x = cfg.getDouble(teamName + ".Bed.X");
            double y = cfg.getDouble(teamName + ".Bed.Y");
            double z = cfg.getDouble(teamName + ".Bed.Z");
            String worldName = cfg.getString(teamName + ".Bed.worldName");
            Location loc = new Location(Bukkit.getWorld(worldName), x, y, z);
            return loc;
    There is no error in console, if I break the bed, so it must be the location.
    Please help.
  2. Compare locations with either .equals() or compare each X Y and Z value with == I would also recommend printing out to console if that doesn't work, each X Y and Z value for each location you compare, to see if they really are the same.
  3. I will try...

    Thanks for the comment.
  4. YEAH, IT WORKS! Thank you so much!
Thread Status:
Not open for further replies.