How to use FishHookMock class of be.seeseemelk.mockbukkit.entity package

Best MockBukkit code snippet using be.seeseemelk.mockbukkit.entity.FishHookMock

Source:WorldMock.java Github

copy

Full Screen

...17import be.seeseemelk.mockbukkit.entity.EndermanMock;18import be.seeseemelk.mockbukkit.entity.EntityMock;19import be.seeseemelk.mockbukkit.entity.ExperienceOrbMock;20import be.seeseemelk.mockbukkit.entity.FireworkMock;21import be.seeseemelk.mockbukkit.entity.FishHookMock;22import be.seeseemelk.mockbukkit.entity.FoxMock;23import be.seeseemelk.mockbukkit.entity.FrogMock;24import be.seeseemelk.mockbukkit.entity.GhastMock;25import be.seeseemelk.mockbukkit.entity.GiantMock;26import be.seeseemelk.mockbukkit.entity.GoatMock;27import be.seeseemelk.mockbukkit.entity.HorseMock;28import be.seeseemelk.mockbukkit.entity.ItemEntityMock;29import be.seeseemelk.mockbukkit.entity.LlamaMock;30import be.seeseemelk.mockbukkit.entity.MobMock;31import be.seeseemelk.mockbukkit.entity.MuleMock;32import be.seeseemelk.mockbukkit.entity.MushroomCowMock;33import be.seeseemelk.mockbukkit.entity.PigMock;34import be.seeseemelk.mockbukkit.entity.PufferFishMock;35import be.seeseemelk.mockbukkit.entity.SalmonMock;36import be.seeseemelk.mockbukkit.entity.SheepMock;37import be.seeseemelk.mockbukkit.entity.SkeletonHorseMock;38import be.seeseemelk.mockbukkit.entity.SkeletonMock;39import be.seeseemelk.mockbukkit.entity.SpiderMock;40import be.seeseemelk.mockbukkit.entity.StrayMock;41import be.seeseemelk.mockbukkit.entity.TadpoleMock;42import be.seeseemelk.mockbukkit.entity.TropicalFishMock;43import be.seeseemelk.mockbukkit.entity.WardenMock;44import be.seeseemelk.mockbukkit.entity.WitherSkeletonMock;45import be.seeseemelk.mockbukkit.entity.WolfMock;46import be.seeseemelk.mockbukkit.entity.ZombieHorseMock;47import be.seeseemelk.mockbukkit.entity.ZombieMock;48import be.seeseemelk.mockbukkit.generator.BiomeProviderMock;49import be.seeseemelk.mockbukkit.metadata.MetadataTable;50import be.seeseemelk.mockbukkit.persistence.PersistentDataContainerMock;51import com.destroystokyo.paper.HeightmapType;52import com.google.common.base.Preconditions;53import io.papermc.paper.world.MoonPhase;54import org.bukkit.BlockChangeDelegate;55import org.bukkit.Bukkit;56import org.bukkit.Chunk;57import org.bukkit.ChunkSnapshot;58import org.bukkit.Difficulty;59import org.bukkit.Effect;60import org.bukkit.FluidCollisionMode;61import org.bukkit.GameEvent;62import org.bukkit.GameRule;63import org.bukkit.HeightMap;64import org.bukkit.Location;65import org.bukkit.Material;66import org.bukkit.NamespacedKey;67import org.bukkit.Particle;68import org.bukkit.Raid;69import org.bukkit.Sound;70import org.bukkit.SoundCategory;71import org.bukkit.StructureType;72import org.bukkit.TreeType;73import org.bukkit.World;74import org.bukkit.WorldCreator;75import org.bukkit.WorldType;76import org.bukkit.block.Biome;77import org.bukkit.block.Block;78import org.bukkit.block.BlockFace;79import org.bukkit.block.BlockState;80import org.bukkit.block.data.BlockData;81import org.bukkit.boss.DragonBattle;82import org.bukkit.entity.AbstractArrow;83import org.bukkit.entity.Allay;84import org.bukkit.entity.Animals;85import org.bukkit.entity.ArmorStand;86import org.bukkit.entity.Arrow;87import org.bukkit.entity.Axolotl;88import org.bukkit.entity.Bat;89import org.bukkit.entity.Bee;90import org.bukkit.entity.Blaze;91import org.bukkit.entity.Cat;92import org.bukkit.entity.CaveSpider;93import org.bukkit.entity.Chicken;94import org.bukkit.entity.Cod;95import org.bukkit.entity.Cow;96import org.bukkit.entity.Creeper;97import org.bukkit.entity.Donkey;98import org.bukkit.entity.Egg;99import org.bukkit.entity.Enderman;100import org.bukkit.entity.Entity;101import org.bukkit.entity.EntityType;102import org.bukkit.entity.ExperienceOrb;103import org.bukkit.entity.FallingBlock;104import org.bukkit.entity.Firework;105import org.bukkit.entity.FishHook;106import org.bukkit.entity.Fox;107import org.bukkit.entity.Frog;108import org.bukkit.entity.Ghast;109import org.bukkit.entity.Giant;110import org.bukkit.entity.Goat;111import org.bukkit.entity.Golem;112import org.bukkit.entity.Hanging;113import org.bukkit.entity.Horse;114import org.bukkit.entity.Item;115import org.bukkit.entity.ItemFrame;116import org.bukkit.entity.LeashHitch;117import org.bukkit.entity.LightningStrike;118import org.bukkit.entity.LivingEntity;119import org.bukkit.entity.Llama;120import org.bukkit.entity.Monster;121import org.bukkit.entity.Mule;122import org.bukkit.entity.MushroomCow;123import org.bukkit.entity.Pig;124import org.bukkit.entity.Player;125import org.bukkit.entity.Projectile;126import org.bukkit.entity.PufferFish;127import org.bukkit.entity.Salmon;128import org.bukkit.entity.Sheep;129import org.bukkit.entity.Skeleton;130import org.bukkit.entity.SkeletonHorse;131import org.bukkit.entity.Slime;132import org.bukkit.entity.SpawnCategory;133import org.bukkit.entity.Spider;134import org.bukkit.entity.Stray;135import org.bukkit.entity.Tadpole;136import org.bukkit.entity.TropicalFish;137import org.bukkit.entity.Warden;138import org.bukkit.entity.WaterMob;139import org.bukkit.entity.WitherSkeleton;140import org.bukkit.entity.Wolf;141import org.bukkit.entity.Zombie;142import org.bukkit.entity.ZombieHorse;143import org.bukkit.event.entity.CreatureSpawnEvent;144import org.bukkit.event.entity.EntitySpawnEvent;145import org.bukkit.event.entity.ItemSpawnEvent;146import org.bukkit.event.entity.ProjectileLaunchEvent;147import org.bukkit.event.weather.ThunderChangeEvent;148import org.bukkit.event.weather.WeatherChangeEvent;149import org.bukkit.event.world.TimeSkipEvent;150import org.bukkit.generator.BiomeProvider;151import org.bukkit.generator.BlockPopulator;152import org.bukkit.generator.ChunkGenerator;153import org.bukkit.generator.structure.Structure;154import org.bukkit.inventory.ItemStack;155import org.bukkit.metadata.MetadataValue;156import org.bukkit.persistence.PersistentDataContainer;157import org.bukkit.plugin.Plugin;158import org.bukkit.plugin.messaging.StandardMessenger;159import org.bukkit.util.BoundingBox;160import org.bukkit.util.Consumer;161import org.bukkit.util.RayTraceResult;162import org.bukkit.util.StructureSearchResult;163import org.bukkit.util.Vector;164import org.jetbrains.annotations.NotNull;165import org.jetbrains.annotations.Nullable;166import java.io.File;167import java.util.ArrayList;168import java.util.Collection;169import java.util.HashMap;170import java.util.HashSet;171import java.util.List;172import java.util.Map;173import java.util.Random;174import java.util.Set;175import java.util.UUID;176import java.util.concurrent.CompletableFuture;177import java.util.concurrent.ThreadLocalRandom;178import java.util.function.Predicate;179import java.util.stream.Collectors;180/**181 * A mock world object. Note that it is made to be as simple as possible. It is by no means an efficient implementation.182 */183public class WorldMock implements World184{185 private static final int SEA_LEVEL = 63;186 private final Map<Coordinate, BlockMock> blocks = new HashMap<>();187 private final Map<GameRule<?>, Object> gameRules = new HashMap<>();188 private final MetadataTable metadataTable = new MetadataTable();189 private final Map<ChunkCoordinate, ChunkMock> loadedChunks = new HashMap<>();190 private final PersistentDataContainer persistentDataContainer = new PersistentDataContainerMock();191 private final @Nullable ServerMock server;192 private final Material defaultBlock;193 private final Biome defaultBiome;194 private final int grassHeight;195 private final int minHeight;196 private final int maxHeight;197 private WorldBorderMock worldBorder;198 private final UUID uuid = UUID.randomUUID();199 private Environment environment = Environment.NORMAL;200 private String name = "World";201 private Location spawnLocation;202 private long fullTime = 0;203 private int weatherDuration;204 private boolean thundering;205 private int thunderDuration;206 private boolean storming;207 private int clearWeatherDuration;208 private long seed = 0;209 private @NotNull WorldType worldType = WorldType.NORMAL;210 private final BiomeProviderMock biomeProviderMock = new BiomeProviderMock();211 private final @NotNull Map<Coordinate, Biome> biomes = new HashMap<>();212 private @NotNull Difficulty difficulty = Difficulty.NORMAL;213 private boolean allowAnimals = true;214 private boolean allowMonsters = true;215 /**216 * Creates a new mock world.217 *218 * @param defaultBlock The block that is spawned at locations 1 to {@code grassHeight}219 * @param minHeight The minimum height of the world.220 * @param maxHeight The maximum height of the world.221 * @param grassHeight The last {@code y} at which {@code defaultBlock} will spawn.222 */223 public WorldMock(Material defaultBlock, int minHeight, int maxHeight, int grassHeight)224 {225 this(defaultBlock, Biome.PLAINS, minHeight, maxHeight, grassHeight);226 }227 /**228 * Creates a new mock world.229 *230 * @param defaultBlock The block that is spawned at locations 1 to {@code grassHeight}231 * @param defaultBiome The biome that every block will be in by default.232 * @param minHeight The minimum height of the world.233 * @param maxHeight The maximum height of the world.234 * @param grassHeight The last {@code y} at which {@code defaultBlock} will spawn.235 */236 public WorldMock(Material defaultBlock, Biome defaultBiome, int minHeight, int maxHeight, int grassHeight)237 {238 this.defaultBlock = defaultBlock;239 this.defaultBiome = defaultBiome;240 this.minHeight = minHeight;241 this.maxHeight = maxHeight;242 this.grassHeight = grassHeight;243 this.server = MockBukkit.getMock();244 // Set the default gamerule values.245 gameRules.put(GameRule.ANNOUNCE_ADVANCEMENTS, true);246 gameRules.put(GameRule.COMMAND_BLOCK_OUTPUT, true);247 gameRules.put(GameRule.DISABLE_ELYTRA_MOVEMENT_CHECK, false);248 gameRules.put(GameRule.DO_DAYLIGHT_CYCLE, true);249 gameRules.put(GameRule.DO_ENTITY_DROPS, true);250 gameRules.put(GameRule.DO_FIRE_TICK, true);251 gameRules.put(GameRule.DO_LIMITED_CRAFTING, false);252 gameRules.put(GameRule.DO_MOB_LOOT, true);253 gameRules.put(GameRule.DO_MOB_SPAWNING, true);254 gameRules.put(GameRule.DO_TILE_DROPS, true);255 gameRules.put(GameRule.DO_WEATHER_CYCLE, true);256 gameRules.put(GameRule.KEEP_INVENTORY, false);257 gameRules.put(GameRule.LOG_ADMIN_COMMANDS, true);258 gameRules.put(GameRule.MAX_COMMAND_CHAIN_LENGTH, 65536);259 gameRules.put(GameRule.MAX_ENTITY_CRAMMING, 24);260 gameRules.put(GameRule.MOB_GRIEFING, true);261 gameRules.put(GameRule.NATURAL_REGENERATION, true);262 gameRules.put(GameRule.RANDOM_TICK_SPEED, 3);263 gameRules.put(GameRule.REDUCED_DEBUG_INFO, false);264 gameRules.put(GameRule.SEND_COMMAND_FEEDBACK, true);265 gameRules.put(GameRule.SHOW_DEATH_MESSAGES, true);266 gameRules.put(GameRule.SPAWN_RADIUS, 10);267 gameRules.put(GameRule.SPECTATORS_GENERATE_CHUNKS, true);268 }269 public WorldMock(@NotNull WorldCreator creator)270 {271 this();272 this.name = creator.name();273 this.worldType = creator.type();274 this.seed = creator.seed();275 this.environment = creator.environment();276 }277 /**278 * Creates a new mock world with a specific height from 0.279 *280 * @param defaultBlock The block that is spawned at locations 1 to {@code grassHeight}281 * @param defaultBiome The biome that every block will be in by default.282 * @param maxHeight The maximum height of the world.283 * @param grassHeight The last {@code y} at which {@code defaultBlock} will spawn.284 */285 public WorldMock(Material defaultBlock, Biome defaultBiome, int maxHeight, int grassHeight)286 {287 this(defaultBlock, defaultBiome, 0, maxHeight, grassHeight);288 }289 /**290 * Creates a new mock world with a specific height from 0.291 *292 * @param defaultBlock The block that is spawned at locations 1 to {@code grassHeight}293 * @param maxHeight The maximum height of the world.294 * @param grassHeight The last {@code y} at which {@code defaultBlock} will spawn.295 */296 public WorldMock(Material defaultBlock, int maxHeight, int grassHeight)297 {298 this(defaultBlock, 0, maxHeight, grassHeight);299 }300 /**301 * Creates a new mock world with a height of 128.302 *303 * @param defaultBlock The block that is spawned at locations 1 to {@code grassHeight}304 * @param grassHeight The last {@code y} at which {@code defaultBlock} will spawn.305 */306 public WorldMock(Material defaultBlock, int grassHeight)307 {308 this(defaultBlock, 128, grassHeight);309 }310 /**311 * Creates a new mock world with a height of 128 and will spawn grass until a {@code y} of 4.312 */313 public WorldMock()314 {315 this(Material.GRASS, 4);316 }317 /**318 * Makes sure that a certain block exists on the coordinate. Returns that block.319 *320 * @param c Creates a block on the given coordinate.321 * @return A newly created block at that location.322 */323 public @NotNull BlockMock createBlock(@NotNull Coordinate c)324 {325 if (c.y >= maxHeight)326 {327 throw new ArrayIndexOutOfBoundsException("Y larger than max height");328 }329 else if (c.y < minHeight)330 {331 throw new ArrayIndexOutOfBoundsException("Y smaller than min height");332 }333 Location location = new Location(this, c.x, c.y, c.z);334 BlockMock block;335 if (c.y == minHeight)336 {337 block = new BlockMock(Material.BEDROCK, location);338 }339 else if (c.y <= grassHeight)340 {341 block = new BlockMock(defaultBlock, location);342 }343 else344 {345 block = new BlockMock(location);346 }347 blocks.put(c, block);348 return block;349 }350 @Override351 public int getEntityCount()352 {353 // TODO Auto-generated method stub354 throw new UnimplementedOperationException();355 }356 @Override357 public int getTileEntityCount()358 {359 // TODO Auto-generated method stub360 throw new UnimplementedOperationException();361 }362 @Override363 public int getTickableTileEntityCount()364 {365 // TODO Auto-generated method stub366 throw new UnimplementedOperationException();367 }368 @Override369 public int getChunkCount()370 {371 // TODO Auto-generated method stub372 throw new UnimplementedOperationException();373 }374 @Override375 public int getPlayerCount()376 {377 // TODO Auto-generated method stub378 throw new UnimplementedOperationException();379 }380 @Override381 public @NotNull MoonPhase getMoonPhase()382 {383 // TODO Auto-generated method stub384 throw new UnimplementedOperationException();385 }386 @Override387 public boolean lineOfSightExists(@NotNull Location from, @NotNull Location to)388 {389 // TODO Auto-generated method stub390 throw new UnimplementedOperationException();391 }392 @Override393 public boolean hasCollisionsIn(@NotNull BoundingBox boundingBox)394 {395 // TODO Auto-generated method stub396 throw new UnimplementedOperationException();397 }398 @Override399 public @NotNull BlockMock getBlockAt(int x, int y, int z)400 {401 return getBlockAt(new Coordinate(x, y, z));402 }403 public @NotNull BlockMock getBlockAt(@NotNull Coordinate coordinate)404 {405 if (blocks.containsKey(coordinate))406 {407 return blocks.get(coordinate);408 }409 else410 {411 return createBlock(coordinate);412 }413 }414 @Override415 public @NotNull BlockMock getBlockAt(@NotNull Location location)416 {417 return getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ());418 }419 @Override420 @Deprecated421 public @NotNull Block getBlockAtKey(long key)422 {423 // TODO Auto-generated method stub424 throw new UnimplementedOperationException();425 }426 @Override427 public @NotNull Location getLocationAtKey(long key)428 {429 return World.super.getLocationAtKey(key);430 }431 @Override432 public @NotNull String getName()433 {434 return name;435 }436 /**437 * Give a new name to this world.438 *439 * @param name The new name of this world.440 */441 public void setName(String name)442 {443 this.name = name;444 }445 @Override446 public @NotNull UUID getUID()447 {448 return uuid;449 }450 @Override451 public @NotNull Location getSpawnLocation()452 {453 if (spawnLocation == null)454 {455 setSpawnLocation(0, grassHeight + 1, 0);456 }457 return spawnLocation;458 }459 @Override460 public boolean setSpawnLocation(@NotNull Location location)461 {462 return setSpawnLocation(location.getBlockX(), location.getBlockY(), location.getBlockZ());463 }464 @Override465 public boolean setSpawnLocation(int x, int y, int z)466 {467 if (spawnLocation == null)468 {469 spawnLocation = new Location(this, x, y, z);470 }471 else472 {473 spawnLocation.setX(x);474 spawnLocation.setY(y);475 spawnLocation.setZ(z);476 }477 return true;478 }479 @Override480 public @NotNull List<Entity> getEntities()481 {482 return server.getEntities().stream()483 .filter(entity -> entity.getWorld() == this)484 .filter(EntityMock::isValid)485 .collect(Collectors.toList());486 }487 @Override488 public @NotNull ChunkMock getChunkAt(int x, int z)489 {490 return getChunkAt(new ChunkCoordinate(x, z));491 }492 /**493 * Gets the chunk at a specific chunk coordinate.494 * <p>495 * If there is no chunk recorded at the location, one will be created.496 *497 * @param coordinate The coordinate at which to get the chunk.498 * @return The chunk at the location.499 */500 @NotNull501 public ChunkMock getChunkAt(@NotNull ChunkCoordinate coordinate)502 {503 ChunkMock chunk = loadedChunks.get(coordinate);504 if (chunk == null)505 {506 chunk = new ChunkMock(this, coordinate.getX(), coordinate.getZ());507 loadedChunks.put(coordinate, chunk);508 }509 return chunk;510 }511 @Override512 public void sendPluginMessage(@NotNull Plugin source, @NotNull String channel, byte[] message)513 {514 StandardMessenger.validatePluginMessage(this.server.getMessenger(), source, channel, message);515 for (Player player : this.getPlayers())516 {517 player.sendPluginMessage(source, channel, message);518 }519 }520 @Override521 public @NotNull Set<String> getListeningPluginChannels()522 {523 Set<String> result = new HashSet<>();524 for (Player player : this.getPlayers())525 {526 result.addAll(player.getListeningPluginChannels());527 }528 return result;529 }530 @Override531 public void setMetadata(@NotNull String metadataKey, @NotNull MetadataValue newMetadataValue)532 {533 metadataTable.setMetadata(metadataKey, newMetadataValue);534 }535 @Override536 public @NotNull List<MetadataValue> getMetadata(@NotNull String metadataKey)537 {538 return metadataTable.getMetadata(metadataKey);539 }540 @Override541 public boolean hasMetadata(@NotNull String metadataKey)542 {543 return metadataTable.hasMetadata(metadataKey);544 }545 @Override546 public void removeMetadata(@NotNull String metadataKey, @NotNull Plugin owningPlugin)547 {548 metadataTable.removeMetadata(metadataKey, owningPlugin);549 }550 @Override551 public int getHighestBlockYAt(int x, int z)552 {553 // TODO Auto-generated method stub554 throw new UnimplementedOperationException();555 }556 @Override557 public int getHighestBlockYAt(@NotNull Location location)558 {559 // TODO Auto-generated method stub560 throw new UnimplementedOperationException();561 }562 @Override563 public @NotNull Block getHighestBlockAt(int x, int z)564 {565 // TODO Auto-generated method stub566 throw new UnimplementedOperationException();567 }568 @Override569 public @NotNull Block getHighestBlockAt(Location location)570 {571 // TODO Auto-generated method stub572 throw new UnimplementedOperationException();573 }574 @Override575 @Deprecated576 public int getHighestBlockYAt(int x, int z, @NotNull HeightmapType heightmap) throws UnsupportedOperationException577 {578 // TODO Auto-generated method stub579 throw new UnimplementedOperationException();580 }581 @Override582 public @NotNull Chunk getChunkAt(@NotNull Location location)583 {584 return getChunkAt(location.getBlockX() >> 4, location.getBlockZ() >> 4);585 }586 @Override587 public @NotNull Chunk getChunkAt(@NotNull Block block)588 {589 return getChunkAt(block.getLocation());590 }591 @Override592 public boolean isChunkLoaded(Chunk chunk)593 {594 // TODO Auto-generated method stub595 throw new UnimplementedOperationException();596 }597 @Override598 public Chunk @NotNull [] getLoadedChunks()599 {600 return loadedChunks.values().toArray(new Chunk[0]);601 }602 @Override603 public void loadChunk(@NotNull Chunk chunk)604 {605 loadChunk(chunk.getX(), chunk.getZ());606 }607 @Override608 public boolean isChunkLoaded(int x, int z)609 {610 ChunkCoordinate coordinate = new ChunkCoordinate(x, z);611 return loadedChunks.containsKey(coordinate);612 }613 @Override614 @Deprecated615 public boolean isChunkInUse(int x, int z)616 {617 // TODO Auto-generated method stub618 throw new UnimplementedOperationException();619 }620 @Override621 public void loadChunk(int x, int z)622 {623 loadChunk(x, z, true);624 }625 @Override626 public boolean loadChunk(int x, int z, boolean generate)627 {628 AsyncCatcher.catchOp("chunk load");629 // TODO Auto-generated method stub630 throw new UnimplementedOperationException();631 }632 @Override633 public boolean unloadChunk(@NotNull Chunk chunk)634 {635 return this.unloadChunk(chunk.getX(), chunk.getZ());636 }637 @Override638 public boolean unloadChunk(int x, int z)639 {640 return unloadChunk(x, z, true);641 }642 @Override643 public boolean unloadChunk(int x, int z, boolean save)644 {645 AsyncCatcher.catchOp("chunk unload");646 // TODO Auto-generated method stub647 throw new UnimplementedOperationException();648 }649 @Override650 public boolean unloadChunkRequest(int x, int z)651 {652 AsyncCatcher.catchOp("chunk unload");653 // TODO Auto-generated method stub654 throw new UnimplementedOperationException();655 }656 @Override657 @Deprecated658 public boolean regenerateChunk(int x, int z)659 {660 AsyncCatcher.catchOp("chunk regenerate");661 // TODO Auto-generated method stub662 throw new UnimplementedOperationException();663 }664 @Override665 @Deprecated666 public boolean refreshChunk(int x, int z)667 {668 // TODO Auto-generated method stub669 throw new UnimplementedOperationException();670 }671 @Override672 public @NotNull ItemEntityMock dropItem(@NotNull Location loc, @NotNull ItemStack item, @Nullable Consumer<Item> function)673 {674 Preconditions.checkNotNull(loc, "The provided location must not be null.");675 Preconditions.checkNotNull(item, "Cannot drop items that are null.");676 Preconditions.checkArgument(!item.getType().isAir(), "Cannot drop air.");677 ItemEntityMock entity = new ItemEntityMock(server, UUID.randomUUID(), item);678 entity.setLocation(loc);679 if (function != null)680 {681 function.accept(entity);682 }683 server.registerEntity(entity);684 callSpawnEvent(entity, null);685 return entity;686 }687 @Override688 public @NotNull ItemEntityMock dropItem(@NotNull Location loc, @NotNull ItemStack item)689 {690 return dropItem(loc, item, null);691 }692 @Override693 public @NotNull ItemEntityMock dropItemNaturally(@NotNull Location location, @NotNull ItemStack item, @Nullable Consumer<Item> function)694 {695 Preconditions.checkNotNull(location, "The provided location must not be null.");696 Random random = ThreadLocalRandom.current();697 double xs = random.nextFloat() * 0.5F + 0.25;698 double ys = random.nextFloat() * 0.5F + 0.25;699 double zs = random.nextFloat() * 0.5F + 0.25;700 Location loc = location.clone();701 loc.setX(loc.getX() + xs);702 loc.setY(loc.getY() + ys);703 loc.setZ(loc.getZ() + zs);704 return dropItem(loc, item, function);705 }706 @Override707 public @NotNull ItemEntityMock dropItemNaturally(@NotNull Location loc, @NotNull ItemStack item)708 {709 return dropItemNaturally(loc, item, null);710 }711 @Override712 public @NotNull Arrow spawnArrow(Location location, Vector direction, float speed, float spread)713 {714 // TODO Auto-generated method stub715 throw new UnimplementedOperationException();716 }717 @Override718 public boolean generateTree(Location location, TreeType type)719 {720 // TODO Auto-generated method stub721 throw new UnimplementedOperationException();722 }723 @Override724 @Deprecated725 public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate)726 {727 // TODO Auto-generated method stub728 throw new UnimplementedOperationException();729 }730 @Override731 public boolean generateTree(Location location, Random random, TreeType type, Predicate<BlockState> statePredicate)732 {733 // TODO Auto-generated method stub734 throw new UnimplementedOperationException();735 }736 public <T extends Entity> @NotNull T spawn(@NotNull Location location, @NotNull Class<T> clazz) throws IllegalArgumentException737 {738 return this.spawn(location, clazz, null, CreatureSpawnEvent.SpawnReason.CUSTOM);739 }740 @Override741 public <T extends Entity> @NotNull T spawn(@NotNull Location location, @NotNull Class<T> clazz, Consumer<T> function) throws IllegalArgumentException742 {743 return this.spawn(location, clazz, function, CreatureSpawnEvent.SpawnReason.CUSTOM);744 }745 @Override746 public <T extends Entity> @NotNull T spawn(@NotNull Location location, @NotNull Class<T> clazz, boolean randomizeData, Consumer<T> function) throws IllegalArgumentException747 {748 return this.spawn(location, clazz, function, CreatureSpawnEvent.SpawnReason.CUSTOM, randomizeData);749 }750 public <T extends Entity> @NotNull T spawn(@NotNull Location location, @NotNull Class<T> clazz, Consumer<T> function, CreatureSpawnEvent.@NotNull SpawnReason reason) throws IllegalArgumentException751 {752 return this.spawn(location, clazz, function, reason, true);753 }754 @SuppressWarnings("unchecked")755 public <T extends Entity> @NotNull T spawn(@Nullable Location location, @Nullable Class<T> clazz, @Nullable Consumer<T> function, CreatureSpawnEvent.@NotNull SpawnReason reason, boolean randomizeData) throws IllegalArgumentException756 {757 if (location == null || clazz == null)758 {759 throw new IllegalArgumentException("Location or entity class cannot be null");760 }761 EntityMock entity = this.mockEntity(location, clazz, randomizeData);762 entity.setLocation(location);763 if (entity instanceof MobMock mob)764 {765 mob.finalizeSpawn();766 }767 // CraftBukkit doesn't check this when spawning, it's done when the entity is ticking so768 // it ends up being spawned for one tick before being removed. We don't have a great way769 // to do that, so we just do it here.770 if (entity instanceof Monster && this.getDifficulty() == Difficulty.PEACEFUL)771 {772 entity.remove();773 }774 if (function != null)775 {776 function.accept((T) entity);777 }778 server.registerEntity(entity);779 callSpawnEvent(entity, reason);780 return (T) entity;781 }782 @Override783 public @NotNull Entity spawnEntity(@NotNull Location loc, @NotNull EntityType type)784 {785 return spawn(loc, type.getEntityClass());786 }787 @NotNull788 @Override789 public Entity spawnEntity(@NotNull Location loc, @NotNull EntityType type, boolean randomizeData)790 {791 return this.spawn(loc, type.getEntityClass(), randomizeData, null);792 }793 private <T extends Entity> @NotNull EntityMock mockEntity(@NotNull Location location, @NotNull Class<T> clazz, boolean randomizeData)794 {795 AsyncCatcher.catchOp("entity add");796 if (clazz == ArmorStand.class)797 {798 return new ArmorStandMock(server, UUID.randomUUID());799 }800 else if (clazz == ExperienceOrb.class)801 {802 return new ExperienceOrbMock(server, UUID.randomUUID());803 }804 else if (clazz == Firework.class)805 {806 return new FireworkMock(server, UUID.randomUUID());807 }808 else if (clazz == Hanging.class)809 {810 // LeashHitch has no direction and is always centered811 if (LeashHitch.class.isAssignableFrom(clazz))812 {813 throw new UnimplementedOperationException();814 }815 BlockFace spawnFace = BlockFace.SELF;816 BlockFace[] faces = (ItemFrame.class.isAssignableFrom(clazz))817 ? new BlockFace[]{ BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST, BlockFace.UP, BlockFace.DOWN }818 : new BlockFace[]{ BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST };819 for (BlockFace face : faces)820 {821 Block block = this.getBlockAt(location.add(face.getModX(), face.getModY(), face.getModZ()));822 if (!block.getType().isSolid() && (block.getType() != Material.REPEATER && block.getType() != Material.COMPARATOR))823 continue;824 boolean taken = false;825 // TODO: Check if the entity's bounding box collides with any other hanging entities.826 if (taken)827 continue;828 spawnFace = face;829 break;830 }831 if (spawnFace == BlockFace.SELF)832 {833 spawnFace = BlockFace.SOUTH;834 }835 spawnFace = spawnFace.getOppositeFace();836 // TODO: Spawn entities here.837 throw new UnimplementedOperationException();838 }839 else if (clazz == Item.class)840 {841 throw new IllegalArgumentException("Items must be spawned using World#dropItem(...)");842 }843 else if (clazz == FishHook.class)844 {845 return new FishHookMock(server, UUID.randomUUID());846 }847 else if (clazz == Player.class)848 {849 throw new IllegalArgumentException("Player Entities cannot be spawned, use ServerMock#addPlayer(...)");850 }851 else if (clazz == Zombie.class)852 {853 return new ZombieMock(server, UUID.randomUUID());854 }855 else if (clazz == Enderman.class)856 {857 return new EndermanMock(server, UUID.randomUUID());858 }859 else if (clazz == Horse.class)...

Full Screen

Full Screen

Source:FishHookMockTest.java Github

copy

Full Screen

...20import static org.junit.jupiter.api.Assertions.assertNull;21import static org.junit.jupiter.api.Assertions.assertThrows;22import static org.junit.jupiter.api.Assertions.assertThrowsExactly;23import static org.junit.jupiter.api.Assertions.assertTrue;24class FishHookMockTest25{26 private ServerMock server;27 private WorldMock world;28 private FishHookMock hook;29 @BeforeEach30 void setUp()31 {32 server = MockBukkit.mock();33 world = server.addSimpleWorld("world");34 hook = new FishHookMock(server, UUID.randomUUID());35 }36 @AfterEach37 void tearDown()38 {39 MockBukkit.unmock();40 }41 @Test42 void constructor_DefaultValues()43 {44 assertEquals(100, hook.getMinWaitTime());45 assertEquals(600, hook.getMaxWaitTime());46 assertTrue(hook.getApplyLure());47 assertEquals(FishHook.HookState.UNHOOKED, hook.getState());48 assertNull(hook.getHookedEntity());...

Full Screen

Full Screen

Source:FishHookMock.java Github

copy

Full Screen

...10import org.bukkit.util.Vector;11import org.jetbrains.annotations.NotNull;12import org.jetbrains.annotations.Nullable;13import java.util.UUID;14public class FishHookMock extends ProjectileMock implements FishHook15{16 private int minWaitTime = 100;17 private int maxWaitTime = 600;18 private boolean applyLure = true;19 private double biteChance = -1;20 private @Nullable Entity hookedEntity;21 private @NotNull HookState state = HookState.UNHOOKED;22 public FishHookMock(@NotNull ServerMock server, @NotNull UUID uuid)23 {24 super(server, uuid);25 }26 @Override27 public int getMinWaitTime()28 {29 return this.minWaitTime;30 }31 @Override32 public void setMinWaitTime(int minWaitTime)33 {34 Preconditions.checkArgument(minWaitTime >= 0 && minWaitTime <= this.getMaxWaitTime(), "The minimum wait time should be between 0 and the maximum wait time.");35 this.minWaitTime = minWaitTime;36 }...

Full Screen

Full Screen

FishHookMock

Using AI Code Generation

copy

Full Screen

1import be.seeseemelk.mockbukkit.entity.FishHookMock;2import org.bukkit.entity.FishHook;3import org.bukkit.entity.Player;4import org.bukkit.event.player.PlayerFishEvent;5import org.bukkit.inventory.ItemStack;6import org.bukkit.inventory.PlayerInventory;7import org.mockito.Mockito;8import org.mockito.invocation.InvocationOnMock;9import org.mockito.stubbing.Answer;10import org.powermock.api.mockito.PowerMockito;11import org.powermock.core.classloader.annotations.PrepareForTest;12import org.powermock.modules.junit4.PowerMockRunner;13import org.powermock.modules.junit4.PowerMockRunnerDelegate;14import org.powermock.reflect.Whitebox;15import org.powermock.reflect.exceptions.FieldNotFoundException;16import org.powermock.reflect.exceptions.MethodNotFoundException;17import org.powermock.reflect.exceptions.TooManyFieldsFoundException;18import org.powermock.reflect.exceptions.TooManyMethodsFoundException;19import org.powermock.reflect.internal.WhiteboxImpl;20import org.powermock.reflect.internal.WhiteboxImpl.FieldImpl;21import org.powermock.reflect.internal.WhiteboxImpl.MethodImpl;22import org.powermock.reflect.internal.WhiteboxImpl.MethodInvokerImpl;23import org.powermock.reflect.internal.WhiteboxImpl.MethodParameterImpl;24import org.powermock.reflect.internal.WhiteboxImpl.MethodSignatureImpl;25import org.powermock.reflect.internal.WhiteboxImpl.TypeImpl;26import org.powermock.reflect.internal.WhiteboxImpl.VariableImpl;27import org.powermock.reflect.internal.WhiteboxImpl.VariableSignatureImpl;28import org.powermock.reflect.internal.WhiteboxImpl.VariableTypeImpl;29import org.powermock.reflect.internal.WhiteboxImpl.VariableTypeSignatureImpl;30import org.powermock.reflect.internal.WhiteboxImpl.VariableTypeSignatureImpl.TypeParameterImpl;31import org.powermock.reflect.internal.WhiteboxImpl.VariableTypeSignatureImpl.TypeParameterSignatureImpl;32import org.powermock.reflect.internal.WhiteboxImpl.VariableTypeSignatureImpl.TypeParameterSignatureImpl.TypeBoundImpl;33import org.powermock.reflect.internal.WhiteboxImpl.VariableTypeSignatureImpl.TypeParameterSignatureImpl.TypeBoundSignatureImpl;34import org.powermock.reflect.internal.WhiteboxImpl.VariableTypeSignatureImpl.TypeParameterSignatureImpl.TypeBoundSignatureImpl.TypeArgumentImpl;35import org.powermock.reflect.internal.WhiteboxImpl.VariableTypeSignatureImpl.TypeParameterSignatureImpl.TypeBoundSignatureImpl.TypeArgumentSignatureImpl;36import org.powermock.reflect.internal.WhiteboxImpl.VariableTypeSignatureImpl.TypeParameterSignatureImpl.TypeBoundSignatureImpl.TypeArgumentSignatureImpl.TypeArgumentTypeImpl;37import org.powermock.reflect.internal.WhiteboxImpl.VariableTypeSignatureImpl.TypeParameterSignatureImpl.TypeBoundSignatureImpl.TypeArgumentSignatureImpl.TypeArgumentTypeSignature

Full Screen

Full Screen

FishHookMock

Using AI Code Generation

copy

Full Screen

1import org.junit.jupiter.api.Test;2import org.junit.jupiter.api.extension.ExtendWith;3import org.mockito.Mock;4import org.mockito.junit.jupiter.MockitoExtension;5import org.bukkit.entity.Player;6import org.bukkit.entity.FishHook;7import org.bukkit.Location;8import org.bukkit.World;9import org.bukkit.entity.EntityType;10import org.bukkit.entity.LivingEntity;11import org.bukkit.entity.Entity;12import org.bukkit.entity.Projectile;13import org.bukkit.entity.HumanEntity;14import org.bukkit.entity.Item;15import org.bukkit.inventory.ItemStack;16import org.bukkit.Material;17import org.bukkit.entity.Item;18import org.bukkit.event.entity.EntityDamageByEntityEvent;19import org.bukkit.event.entity.ProjectileHitEvent

Full Screen

Full Screen

FishHookMock

Using AI Code Generation

copy

Full Screen

1package com.example;2import org.bukkit.entity.Entity;3import org.bukkit.entity.FishHook;4import org.bukkit.plugin.java.JavaPlugin;5import org.junit.Test;6import org.junit.runner.RunWith;7import org.mockito.Mock;8import org.mockito.junit.MockitoJUnitRunner;9import be.seeseemelk.mockbukkit.MockBukkit;10import be.seeseemelk.mockbukkit.entity.FishHookMock;11@RunWith(MockitoJUnitRunner.class)12public class FishHookMockTest {13 private JavaPlugin plugin;14 public void testGetShooter() {15 MockBukkit.mock(plugin);16 FishHookMock hook = new FishHookMock(plugin.getServer(), new FishHookMock.FishHookMockData());17 Entity shooter = hook.getShooter();18 }19}20 at be.seeseemelk.mockbukkit.entity.FishHookMock.getShooter(FishHookMock.java:50)21 at com.example.FishHookMockTest.testGetShooter(FishHookMockTest.java:24)

Full Screen

Full Screen

FishHookMock

Using AI Code Generation

copy

Full Screen

1import org.junit.jupiter.api.AfterEach;2import org.junit.jupiter.api.BeforeEach;3import org.junit.jupiter.api.Test;4import org.bukkit.entity.FishHook;5import be.seeseemelk.mockbukkit.entity.FishHookMock;6import static org.junit.jupiter.api.Assertions.*;7{8 private FishHookMock fishHook;9 public void setUp()10 {11 fishHook = new FishHookMock();12 }13 public void tearDown()14 {15 fishHook = null;16 }17 public void testFishHook()18 {19 assertTrue(fishHook instanceof FishHook);20 }21}22import org.junit.jupiter.api.AfterEach;23import org.junit.jupiter.api.BeforeEach;24import org.junit.jupiter.api.Test;25import org.bukkit.entity.FishHook;26import be.seeseemelk.mockbukkit.entity.FishHookMock;27import static org.junit.jupiter.api.Assertions.*;28{29 private FishHookMock fishHook;30 public void setUp()31 {32 fishHook = new FishHookMock();33 }34 public void tearDown()35 {36 fishHook = null;37 }38 public void testFishHook()39 {40 assertTrue(fishHook instanceof FishHook);41 }42}43import org.junit.jupiter.api.AfterEach;44import org.junit.jupiter.api.BeforeEach;45import org.junit.jupiter.api.Test;46import org.bukkit.entity.FishHook;47import be.seeseemelk.mockbukkit.entity.FishHookMock;48import static org.junit.jupiter.api.Assertions.*;49{50 private FishHookMock fishHook;51 public void setUp()52 {53 fishHook = new FishHookMock();54 }55 public void tearDown()56 {57 fishHook = null;58 }59 public void testFishHook()

Full Screen

Full Screen

FishHookMock

Using AI Code Generation

copy

Full Screen

1import be.seeseemelk.mockbukkit.entity.FishHookMock;2import be.seeseemelk.mockbukkit.entity.PlayerMock;3import be.seeseemelk.mockbukkit.MockBukkit;4import be.seeseemelk.mockbukkit.ServerMock;5import org.bukkit.entity.Player;6import org.bukkit.entity.FishHook;7import org.bukkit.event.player.PlayerFishEvent;8import org.bukkit.event.player.PlayerFishEvent.State;9import org.bukkit.event.player.PlayerFishEvent;10import org.bukkit.event.player.PlayerFishEvent.State;11import org.junit.jupiter.api.AfterEach;12import org.junit.jupiter.api.BeforeEach;13import org.junit.jupiter.api.Test;14import static org.junit.jupiter.api.Assertions.*;15public class FishHookMockTest {16 private ServerMock server;17 private PlayerMock player;18 private FishHookMock fishHook;19 public void setUp() {20 server = MockBukkit.mock();21 player = server.addPlayer();22 fishHook = new FishHookMock(server, player);23 }24 public void tearDown() {25 MockBukkit.unmock();26 }27 public void testFishHookMock() {28 FishHook fishHook2 = fishHook;29 org.bukkit.entity.Entity entity = fishHook;30 org.bukkit.entity.Projectile projectile = fishHook;31 org.bukkit.entity.LivingEntity livingEntity = fishHook;32 org.bukkit.entity.Entity entity2 = fishHook;33 org.bukkit.entity.Projectile projectile2 = fishHook;34 org.bukkit.entity.LivingEntity livingEntity2 = fishHook;35 org.bukkit.entity.Entity entity3 = fishHook;36 org.bukkit.entity.Projectile projectile3 = fishHook;

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run MockBukkit automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful