Check is regions cross..

Discussion in 'Plugin Development' started by MrRoboMan, Jul 19, 2016.

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

    MrRoboMan

    Hello. I writing my plugin for privating regions!
    I need to check (before privating region) is region cross with any other privated region..
    Region = 2 location (min,max).
    What i have now:
    Code (open)

    Code:
        public boolean checkIsRegionFree(Selection newRegion) {
            for (String region : config.getConfigurationSection("REGION").getKeys(false)) {
                Selection privatedRegion = new Selection(
                        TextLocation.parse(config.getString("REGION." + region + ".FIRST")),
                        TextLocation.parse(config.getString("REGION." + region + ".SECOND")));
                //return false if regions cross... But how to check it?! :-(
            }
            return true;
        }
    
    Code:
        public class Selection {
    
            private Location first;
            private Location second;
    
            public Selection() {
            }
    
            public Selection(Location first, Location second) {
                this.first = first;
                this.second = second;
            }
    
            public Location getFirst() {
                return first;
            }
    
            public void setFirst(Location first) {
                this.first = first;
            }
    
            public Location getSecond() {
                return second;
            }
    
            public void setSecond(Location second) {
                this.second = second;
            }
    
            public boolean hasFirst() {
                return first != null;
            }
    
            public boolean hasSecond() {
                return second != null;
            }
    
            public boolean hasSelection() {
                return first != null && second != null;
            }
    
            public boolean isValid() {
                return first.getWorld().getName().equals(second.getWorld().getName());
            }
        }
    
     
    Last edited: Jul 19, 2016
  2. Offline

    mine-care

    And what is the problem?
     
  3. Offline

    MrRoboMan

    @mine-care
    I dont know how to check it..
    Is regions cross..

    Up..
     
    Last edited by a moderator: Jul 19, 2016
Thread Status:
Not open for further replies.

Share This Page