Update to Minecraft 1.19

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot
2022-06-08 02:00:00 +10:00
parent 9bfa9ca85b
commit ec575f5252
88 changed files with 1339 additions and 375 deletions

View File

@@ -1,8 +1,8 @@
package org.bukkit.event.enchantment;
import com.google.common.base.Preconditions;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang.Validate;
import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
@@ -85,7 +85,7 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable {
* @param level - cost in levels
*/
public void setExpLevelCost(int level) {
Validate.isTrue(level > 0, "The cost must be greater than 0!");
Preconditions.checkArgument(level > 0, "The cost must be greater than 0!");
this.level = level;
}

View File

@@ -1,6 +1,6 @@
package org.bukkit.event.entity;
import org.apache.commons.lang.Validate;
import com.google.common.base.Preconditions;
import org.bukkit.entity.EnderDragon;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@@ -56,7 +56,7 @@ public class EnderDragonChangePhaseEvent extends EntityEvent implements Cancella
* @param newPhase the new dragon phase
*/
public void setNewPhase(@NotNull EnderDragon.Phase newPhase) {
Validate.notNull(newPhase, "New dragon phase cannot be null");
Preconditions.checkArgument(newPhase != null, "New dragon phase cannot be null");
this.newPhase = newPhase;
}

View File

@@ -1,6 +1,6 @@
package org.bukkit.event.entity;
import org.apache.commons.lang.Validate;
import com.google.common.base.Preconditions;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@@ -26,9 +26,9 @@ public class EntityBreedEvent extends EntityEvent implements Cancellable {
public EntityBreedEvent(@NotNull LivingEntity child, @NotNull LivingEntity mother, @NotNull LivingEntity father, @Nullable LivingEntity breeder, @Nullable ItemStack bredWith, int experience) {
super(child);
Validate.notNull(child, "Cannot have null child");
Validate.notNull(mother, "Cannot have null mother");
Validate.notNull(father, "Cannot have null father");
Preconditions.checkArgument(child != null, "Cannot have null child");
Preconditions.checkArgument(mother != null, "Cannot have null mother");
Preconditions.checkArgument(father != null, "Cannot have null father");
// Breeder can be null in the case of spontaneous conception
this.mother = mother;
@@ -101,7 +101,7 @@ public class EntityBreedEvent extends EntityEvent implements Cancellable {
* @param experience experience amount
*/
public void setExperience(int experience) {
Validate.isTrue(experience >= 0, "Experience cannot be negative");
Preconditions.checkArgument(experience >= 0, "Experience cannot be negative");
this.experience = experience;
}

View File

@@ -2,10 +2,11 @@ package org.bukkit.event.entity;
import com.google.common.base.Function;
import com.google.common.base.Functions;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import java.util.EnumMap;
import java.util.Map;
import org.apache.commons.lang.Validate;
import java.util.Objects;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@@ -32,11 +33,11 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable {
public EntityDamageEvent(@NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers, @NotNull final Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions) {
super(damagee);
Validate.isTrue(modifiers.containsKey(DamageModifier.BASE), "BASE DamageModifier missing");
Validate.isTrue(!modifiers.containsKey(null), "Cannot have null DamageModifier");
Validate.noNullElements(modifiers.values(), "Cannot have null modifier values");
Validate.isTrue(modifiers.keySet().equals(modifierFunctions.keySet()), "Must have a modifier function for each DamageModifier");
Validate.noNullElements(modifierFunctions.values(), "Cannot have null modifier function");
Preconditions.checkArgument(modifiers.containsKey(DamageModifier.BASE), "BASE DamageModifier missing");
Preconditions.checkArgument(!modifiers.containsKey(null), "Cannot have null DamageModifier");
Preconditions.checkArgument(modifiers.values().stream().allMatch(Objects::nonNull), "Cannot have null modifier values");
Preconditions.checkArgument(modifiers.keySet().equals(modifierFunctions.keySet()), "Must have a modifier function for each DamageModifier");
Preconditions.checkArgument(modifierFunctions.values().stream().allMatch(Objects::nonNull), "Cannot have null modifier function");
this.originals = new EnumMap<DamageModifier, Double>(modifiers);
this.cause = cause;
this.modifiers = modifiers;
@@ -99,7 +100,7 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable {
* @see DamageModifier#BASE
*/
public double getDamage(@NotNull DamageModifier type) throws IllegalArgumentException {
Validate.notNull(type, "Cannot have null DamageModifier");
Preconditions.checkArgument(type != null, "Cannot have null DamageModifier");
final Double damage = modifiers.get(type);
return damage == null ? 0 : damage;
}
@@ -116,7 +117,7 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable {
* @throws IllegalArgumentException if type is null
*/
public boolean isApplicable(@NotNull DamageModifier type) throws IllegalArgumentException {
Validate.notNull(type, "Cannot have null DamageModifier");
Preconditions.checkArgument(type != null, "Cannot have null DamageModifier");
return modifiers.containsKey(type);
}

View File

@@ -1,9 +1,9 @@
package org.bukkit.event.entity;
import com.google.common.base.Preconditions;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import org.apache.commons.lang.Validate;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.event.Cancellable;
@@ -70,7 +70,7 @@ public class PotionSplashEvent extends ProjectileHitEvent implements Cancellable
* @param intensity relative to maximum effect
*/
public void setIntensity(@NotNull LivingEntity entity, double intensity) {
Validate.notNull(entity, "You must specify a valid entity.");
Preconditions.checkArgument(entity != null, "You must specify a valid entity.");
if (intensity <= 0.0) {
affectedEntities.remove(entity);
} else {

View File

@@ -1,10 +1,10 @@
package org.bukkit.event.inventory;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.Validate;
import org.bukkit.Location;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
@@ -65,8 +65,8 @@ public class InventoryDragEvent extends InventoryInteractEvent {
public InventoryDragEvent(@NotNull InventoryView what, @Nullable ItemStack newCursor, @NotNull ItemStack oldCursor, boolean right, @NotNull Map<Integer, ItemStack> slots) {
super(what);
Validate.notNull(oldCursor);
Validate.notNull(slots);
Preconditions.checkArgument(oldCursor != null);
Preconditions.checkArgument(slots != null);
type = right ? DragType.SINGLE : DragType.EVEN;
this.newCursor = newCursor;

View File

@@ -1,6 +1,6 @@
package org.bukkit.event.inventory;
import org.apache.commons.lang.Validate;
import com.google.common.base.Preconditions;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@@ -33,7 +33,7 @@ public class InventoryMoveItemEvent extends Event implements Cancellable {
private final boolean didSourceInitiate;
public InventoryMoveItemEvent(@NotNull final Inventory sourceInventory, @NotNull final ItemStack itemStack, @NotNull final Inventory destinationInventory, final boolean didSourceInitiate) {
Validate.notNull(itemStack, "ItemStack cannot be null");
Preconditions.checkArgument(itemStack != null, "ItemStack cannot be null");
this.sourceInventory = sourceInventory;
this.itemStack = itemStack;
this.destinationInventory = destinationInventory;
@@ -69,7 +69,7 @@ public class InventoryMoveItemEvent extends Event implements Cancellable {
* @param itemStack The ItemStack
*/
public void setItem(@NotNull ItemStack itemStack) {
Validate.notNull(itemStack, "ItemStack cannot be null. Cancel the event if you want nothing to be transferred.");
Preconditions.checkArgument(itemStack != null, "ItemStack cannot be null. Cancel the event if you want nothing to be transferred.");
this.itemStack = itemStack.clone();
}

View File

@@ -1,8 +1,8 @@
package org.bukkit.event.player;
import com.google.common.base.Preconditions;
import java.util.HashSet;
import java.util.Set;
import org.apache.commons.lang.Validate;
import org.bukkit.Warning;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
@@ -78,7 +78,7 @@ public class PlayerChatEvent extends PlayerEvent implements Cancellable {
* @param player New player which this event will execute as
*/
public void setPlayer(@NotNull final Player player) {
Validate.notNull(player, "Player cannot be null");
Preconditions.checkArgument(player != null, "Player cannot be null");
this.player = player;
}

View File

@@ -1,7 +1,7 @@
package org.bukkit.event.player;
import com.google.common.base.Preconditions;
import java.util.Collection;
import org.apache.commons.lang.Validate;
import org.bukkit.Warning;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
@@ -22,8 +22,8 @@ public class PlayerChatTabCompleteEvent extends PlayerEvent {
public PlayerChatTabCompleteEvent(@NotNull final Player who, @NotNull final String message, @NotNull final Collection<String> completions) {
super(who);
Validate.notNull(message, "Message cannot be null");
Validate.notNull(completions, "Completions cannot be null");
Preconditions.checkArgument(message != null, "Message cannot be null");
Preconditions.checkArgument(completions != null, "Completions cannot be null");
this.message = message;
int i = message.lastIndexOf(' ');
if (i < 0) {

View File

@@ -1,8 +1,8 @@
package org.bukkit.event.player;
import com.google.common.base.Preconditions;
import java.util.HashSet;
import java.util.Set;
import org.apache.commons.lang.Validate;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@@ -96,8 +96,8 @@ public class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancell
* @throws IllegalArgumentException if command is null or empty
*/
public void setMessage(@NotNull String command) throws IllegalArgumentException {
Validate.notNull(command, "Command cannot be null");
Validate.notEmpty(command, "Command cannot be empty");
Preconditions.checkArgument(command != null, "Command cannot be null");
Preconditions.checkArgument(!command.isEmpty(), "Command cannot be empty");
this.message = command;
}
@@ -108,7 +108,7 @@ public class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancell
* @throws IllegalArgumentException if the player provided is null
*/
public void setPlayer(@NotNull final Player player) throws IllegalArgumentException {
Validate.notNull(player, "Player cannot be null");
Preconditions.checkArgument(player != null, "Player cannot be null");
this.player = player;
}

View File

@@ -1,6 +1,6 @@
package org.bukkit.event.player;
import org.apache.commons.lang.Validate;
import com.google.common.base.Preconditions;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
@@ -24,9 +24,9 @@ public class PlayerEditBookEvent extends PlayerEvent implements Cancellable {
public PlayerEditBookEvent(@NotNull Player who, int slot, @NotNull BookMeta previousBookMeta, @NotNull BookMeta newBookMeta, boolean isSigning) {
super(who);
Validate.isTrue(slot >= -1 && slot <= 8, "Slot must be in range (-1)-8 inclusive");
Validate.notNull(previousBookMeta, "Previous book meta must not be null");
Validate.notNull(newBookMeta, "New book meta must not be null");
Preconditions.checkArgument(slot >= -1 && slot <= 8, "Slot must be in range (-1)-8 inclusive");
Preconditions.checkArgument(previousBookMeta != null, "Previous book meta must not be null");
Preconditions.checkArgument(newBookMeta != null, "New book meta must not be null");
Bukkit.getItemFactory().equals(previousBookMeta, newBookMeta);
@@ -86,7 +86,7 @@ public class PlayerEditBookEvent extends PlayerEvent implements Cancellable {
* @throws IllegalArgumentException if the new book meta is null
*/
public void setNewBookMeta(@NotNull BookMeta newBookMeta) throws IllegalArgumentException {
Validate.notNull(newBookMeta, "New book meta must not be null");
Preconditions.checkArgument(newBookMeta != null, "New book meta must not be null");
Bukkit.getItemFactory().equals(newBookMeta, null);
this.newBookMeta = newBookMeta.clone();
}

View File

@@ -1,6 +1,6 @@
package org.bukkit.event.player;
import org.apache.commons.lang.Validate;
import com.google.common.base.Preconditions;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
@@ -43,8 +43,8 @@ public class PlayerRespawnEvent extends PlayerEvent {
* @param respawnLocation new location for the respawn
*/
public void setRespawnLocation(@NotNull Location respawnLocation) {
Validate.notNull(respawnLocation, "Respawn location can not be null");
Validate.notNull(respawnLocation.getWorld(), "Respawn world can not be null");
Preconditions.checkArgument(respawnLocation != null, "Respawn location can not be null");
Preconditions.checkArgument(respawnLocation.getWorld() != null, "Respawn world can not be null");
this.respawnLocation = respawnLocation;
}

View File

@@ -1,8 +1,8 @@
package org.bukkit.event.server;
import com.google.common.base.Preconditions;
import java.net.InetAddress;
import java.util.Iterator;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.UndefinedNullability;
import org.bukkit.entity.Player;
@@ -27,7 +27,7 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
public ServerListPingEvent(@NotNull final InetAddress address, @NotNull final String motd, final int numPlayers, final int maxPlayers) {
super(true);
Validate.isTrue(numPlayers >= 0, "Cannot have negative number of players online", numPlayers);
Preconditions.checkArgument(numPlayers >= 0, "Cannot have negative number of players online", numPlayers);
this.address = address;
this.motd = motd;
this.numPlayers = numPlayers;

View File

@@ -1,7 +1,7 @@
package org.bukkit.event.server;
import com.google.common.base.Preconditions;
import java.util.List;
import org.apache.commons.lang.Validate;
import org.bukkit.command.CommandSender;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
@@ -29,9 +29,9 @@ public class TabCompleteEvent extends Event implements Cancellable {
private boolean cancelled;
public TabCompleteEvent(@NotNull CommandSender sender, @NotNull String buffer, @NotNull List<String> completions) {
Validate.notNull(sender, "sender");
Validate.notNull(buffer, "buffer");
Validate.notNull(completions, "completions");
Preconditions.checkArgument(sender != null, "sender");
Preconditions.checkArgument(buffer != null, "buffer");
Preconditions.checkArgument(completions != null, "completions");
this.sender = sender;
this.buffer = buffer;
@@ -75,7 +75,7 @@ public class TabCompleteEvent extends Event implements Cancellable {
* @param completions the new completions
*/
public void setCompletions(@NotNull List<String> completions) {
Validate.notNull(completions);
Preconditions.checkArgument(completions != null);
this.completions = completions;
}

View File

@@ -24,8 +24,8 @@ public class GenericGameEvent extends WorldEvent implements Cancellable {
private int radius;
private boolean cancelled;
public GenericGameEvent(@NotNull GameEvent event, @NotNull Location location, @Nullable Entity entity, int radius) {
super(location.getWorld());
public GenericGameEvent(@NotNull GameEvent event, @NotNull Location location, @Nullable Entity entity, int radius, boolean isAsync) {
super(location.getWorld(), isAsync);
this.event = event;
this.location = location;
this.entity = entity;

View File

@@ -11,6 +11,11 @@ public abstract class WorldEvent extends Event {
private final World world;
public WorldEvent(@NotNull final World world) {
this(world, false);
}
public WorldEvent(@NotNull World world, boolean isAsync) {
super(isAsync);
this.world = world;
}