#1182: Consolidate Preconditions use and minor cleanup

By: Doc <nachito94@msn.com>
This commit is contained in:
CraftBukkit/Spigot
2023-06-12 19:41:02 +10:00
parent 5ff68bfbcb
commit ff78bf30f6
72 changed files with 695 additions and 855 deletions

View File

@@ -348,17 +348,13 @@ public final class CraftLegacy {
IBlockState state = states.getProperty(dataKey);
if (state == null) {
if (whitelistedStates.contains(dataKey)) {
continue;
}
throw new IllegalStateException("No state for " + dataKey);
Preconditions.checkArgument(whitelistedStates.contains(dataKey), "No state for %s", dataKey);
continue;
}
Preconditions.checkState(!properties.getString(dataKey).isEmpty(), "Empty data string");
Optional opt = state.getValue(properties.getString(dataKey));
if (!opt.isPresent()) {
throw new IllegalStateException("No state value " + properties.getString(dataKey) + " for " + dataKey);
}
Preconditions.checkArgument(opt.isPresent(), "No state value %s for %s", properties.getString(dataKey), dataKey);
blockData = blockData.setValue(state, (Comparable) opt.get());
}