Checking a player in cuboid area.

Discussion in 'Plugin Development' started by PlayFriik, Dec 28, 2014.

Thread Status:
Not open for further replies.
  1. Offline


    I was thinking, how I would check when player is in certain cuboid area and I found this:
    I just renamed minX, maxX, minY etc > X1, X2, Y1 etc.

    But the problem is that I can't figure out how I would check for the world?

    My code at the moment:
                            // Getting game world name for config.
                            String gameName2 = plugin.gameName1.get(1);
                            // Getting the game world name for checking later.
                            World w1 = Bukkit.getWorld(gameName2);
                            // X1, X2 etc in config.
                            double X1 = plugin.getConfig().getDouble("Maps." + gameName2 + ".GreenTeam.base.X1");
                            double X2 = plugin.getConfig().getDouble("Maps." + gameName2 + ".GreenTeam.base.X2");
                            double Y1 = plugin.getConfig().getDouble("Maps." + gameName2 + ".GreenTeam.base.Y1");
                            double Y2 = plugin.getConfig().getDouble("Maps." + gameName2 + ".GreenTeam.base.Y2");
                            double Z1 = plugin.getConfig().getDouble("Maps." + gameName2 + ".GreenTeam.base.Z1");
                            double Z2 = plugin.getConfig().getDouble("Maps." + gameName2 + ".GreenTeam.base.Z2");
                            // Getting player's world name and cords.
                            World w = player.getWorld();
                            double x = player.getLocation().getX();
                            double y = player.getLocation().getY();
                            double z = player.getLocation().getZ();
                            // Checking....
                            if(x >= X1 && x <= X2 && y >= Y1 && y <= Y2 && z >= Z1 && z <= Z2 && w == w1) {
                                // Removing 1 score from green team.
  2. Offline



    Does that work? If not I might need more details.
  3. Offline


  4. Offline


    Ok then, I'll need more detail if that didn't work. Post a stack trace if it's throwing an exception.
  5. Offline


    Sorry, but I can't understand that last sentence.. (I feel really stupid right now)

    // FIXED!
    Last edited: Dec 28, 2014
  6. Offline


    For this, I use the Cuboid API that someone made. (I believe it was KingFarris or something).
    You create a cuboid with two locations as the corners, and then you can do
    It will return true if the player is inside the region.
  7. Offline


    @nuclearmissile if w1 is a string it should be if(p.getWorld.getName().equals(string here));
  8. Offline


Thread Status:
Not open for further replies.

Share This Page