Convert region ID to lowercase when saving polygon points to MySQL database. Check number of points in polygonal region before registering it.

When saving the points of a polygonal region to a MySQL database, the region ID was not converted to lowercase. If a region ID contained a capital letter, upon reload no points would be found, causing an out-of-bounds exception and essentially leaving WorldGuard unuseable.
This commit is contained in:
eswick 2014-06-22 14:13:45 -04:00
parent c66adf0119
commit 3bfcd69fd9

View File

@ -433,6 +433,12 @@ private void loadPoly2d() {
poly2dVectorResultSet.getInt("z")
));
}
if (points.size() < 3) {
logger.warning(String.format("Invalid polygonal region '%s': region only has %d point(s). Ignoring.", id, points.size()));
continue;
}
ProtectedRegion region = new ProtectedPolygonalRegion(id, points, minY, maxY);
region.setPriority(poly2dResultSet.getInt("priority"));
@ -932,7 +938,7 @@ private void updatePoly2dPoints(ProtectedPolygonalRegion region) throws SQLExcep
") VALUES (null, ?, " + this.worldDbId + ", ?, ?)"
);
String lowerId = region.getId();
String lowerId = region.getId().toLowerCase();
for (BlockVector2D point : region.getPoints()) {
insertPoly2dPointStatement.setString(1, lowerId);
insertPoly2dPointStatement.setInt(2, point.getBlockZ());