#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

@@ -2,6 +2,7 @@ package org.bukkit.craftbukkit.event;
import com.google.common.base.Function;
import com.google.common.base.Functions;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.mojang.datafixers.util.Either;
import java.net.InetAddress;
@@ -1610,9 +1611,8 @@ public class CraftEventFactory {
PotionEffect bukkitOldEffect = (oldEffect == null) ? null : CraftPotionUtil.toBukkit(oldEffect);
PotionEffect bukkitNewEffect = (newEffect == null) ? null : CraftPotionUtil.toBukkit(newEffect);
if (bukkitOldEffect == null && bukkitNewEffect == null) {
throw new IllegalStateException("Old and new potion effect are both null");
}
Preconditions.checkState(bukkitOldEffect != null, "Old and new potion is null");
Preconditions.checkState(bukkitNewEffect != null, "New potion effect is null");
EntityPotionEffectEvent event = new EntityPotionEffectEvent((LivingEntity) entity.getBukkitEntity(), bukkitOldEffect, bukkitNewEffect, cause, action, willOverride);
Bukkit.getPluginManager().callEvent(event);