properly throw

This commit is contained in:
xGinko 2023-09-30 12:21:19 +02:00
parent 56bec235c9
commit 3109adb472

View File

@ -26,10 +26,10 @@ public class VillagerOptimizeEvent extends Event implements Cancellable {
public VillagerOptimizeEvent(@NotNull WrappedVillager wrappedVillager, @NotNull OptimizationType type) throws IllegalArgumentException { public VillagerOptimizeEvent(@NotNull WrappedVillager wrappedVillager, @NotNull OptimizationType type) throws IllegalArgumentException {
this.wrappedVillager = wrappedVillager; this.wrappedVillager = wrappedVillager;
this.type = type;
if (type.equals(OptimizationType.NONE)) { if (type.equals(OptimizationType.NONE)) {
throw new IllegalArgumentException("Type can't be NONE."); throw new IllegalArgumentException("Type can't be NONE.");
} else {
this.type = type;
} }
} }
@ -41,9 +41,13 @@ public class VillagerOptimizeEvent extends Event implements Cancellable {
return type; return type;
} }
public void setOptimizationType(@NotNull OptimizationType type) { public void setOptimizationType(@NotNull OptimizationType type) throws IllegalArgumentException {
if (type.equals(OptimizationType.NONE)) {
throw new IllegalArgumentException("Type can't be NONE.");
} else {
this.type = type; this.type = type;
} }
}
@Override @Override
public void setCancelled(boolean cancel) { public void setCancelled(boolean cancel) {