mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-25 02:27:42 +01:00
Fixed ProtectedRegion.compareTo.
It properly implements the Comparable interface now. In particular, it now fulfills the criterion "sgn(x.compareTo(y)) == -sgn(y.compareTo(x))".
This commit is contained in:
parent
46a2510e85
commit
9d848e222b
@ -414,21 +414,22 @@ public boolean containsAny(List<BlockVector2D> pts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares to another region.
|
* Compares to another region.<br>
|
||||||
|
*<br>
|
||||||
|
* Orders primarily by the priority, descending<br>
|
||||||
|
* Orders secondarily by the id, ascending
|
||||||
*
|
*
|
||||||
* @param other
|
* @param other
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int compareTo(ProtectedRegion other) {
|
public int compareTo(ProtectedRegion other) {
|
||||||
if (id.equals(other.id)) {
|
if (priority > other.priority) {
|
||||||
return 0;
|
|
||||||
} else if (priority == other.priority) {
|
|
||||||
return 1;
|
|
||||||
} else if (priority > other.priority) {
|
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else if (priority < other.priority) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return id.compareTo(other.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user