How to use playerListFooter method of be.seeseemelk.mockbukkit.entity.PlayerMock class

Best MockBukkit code snippet using be.seeseemelk.mockbukkit.entity.PlayerMock.playerListFooter

Source:PlayerMock.java Github

copy

Full Screen

...133 private final @NotNull ServerMock server;134 private @Nullable Component displayName = null;135 private @Nullable Component playerListName = null;136 private @Nullable Component playerListHeader = null;137 private @Nullable Component playerListFooter = null;138 private int expTotal = 0;139 private float exp = 0;140 private boolean sneaking = false;141 private boolean sprinting = false;142 private boolean allowFlight = false;143 private boolean flying = false;144 private Location compassTarget;145 private @Nullable Location bedSpawnLocation;146 private long firstPlayed = 0;147 private long lastPlayed = 0;148 private @Nullable InetSocketAddress address;149 private final PlayerSpigotMock playerSpigotMock = new PlayerSpigotMock();150 private final List<AudioExperience> heardSounds = new LinkedList<>();151 private final Map<UUID, Set<Plugin>> hiddenPlayers = new HashMap<>();152 private final Set<UUID> hiddenPlayersDeprecated = new HashSet<>();153 private final Queue<String> title = new LinkedTransferQueue<>();154 private final Queue<String> subitles = new LinkedTransferQueue<>();155 private Scoreboard scoreboard;156 private final StatisticsMock statistics = new StatisticsMock();157 private final Set<String> channels = new HashSet<>();158 private final List<ItemStack> consumedItems = new LinkedList<>();159 public PlayerMock(@NotNull ServerMock server, @NotNull String name)160 {161 this(server, name, UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(StandardCharsets.UTF_8)));162 this.online = false;163 this.firstPlayed = 0;164 this.scoreboard = server.getScoreboardManager().getMainScoreboard();165 }166 public PlayerMock(@NotNull ServerMock server, @NotNull String name, @NotNull UUID uuid)167 {168 super(server, uuid);169 Preconditions.checkNotNull(name, "Name cannot be null");170 setName(name);171 setDisplayName(name);172 this.online = true;173 this.server = server;174 this.firstPlayed = System.currentTimeMillis();175 if (Bukkit.getWorlds().isEmpty())176 {177 MockBukkit.getMock().addSimpleWorld("world");178 }179 setLocation(Bukkit.getWorlds().get(0).getSpawnLocation().clone());180 setCompassTarget(getLocation());181 closeInventory();182 Random random = ThreadLocalRandom.current();183 address = new InetSocketAddress("192.0.2." + random.nextInt(255), random.nextInt(32768, 65535));184 scoreboard = server.getScoreboardManager().getMainScoreboard();185 }186 /**187 * Simulates a disconnection from the server.188 *189 * @return True if the player was disconnected, false if they were already offline.190 */191 public boolean disconnect()192 {193 if (!online)194 {195 return false;196 }197 this.online = false;198 this.lastPlayed = System.currentTimeMillis();199 Component message = MiniMessage.miniMessage()200 .deserialize("<name> has left the Server!", Placeholder.component("name", this.displayName()));201 PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(this, message, PlayerQuitEvent.QuitReason.DISCONNECTED);202 Bukkit.getPluginManager().callEvent(playerQuitEvent);203 this.server.getPlayerList().disconnectPlayer(this);204 return true;205 }206 /**207 * Simulates a connection to the server.208 *209 * @return True if the player was connected, false if they were already online.210 */211 public boolean reconnect()212 {213 if (firstPlayed == 0)214 {215 throw new IllegalStateException("Player was never online");216 }217 if (server.hasWhitelist() && !server.getWhitelistedPlayers().contains(this))218 {219 return false;220 }221 if (online)222 {223 return false;224 }225 this.online = true;226 this.lastPlayed = System.currentTimeMillis();227 server.addPlayer(this);228 return true;229 }230 /**231 * Simulates a Player consuming an Edible Item232 *233 * @param consumable The Item to consume234 */235 public void simulateConsumeItem(@NotNull ItemStack consumable)236 {237 Preconditions.checkNotNull(consumable, "Consumed Item can't be null");238 Preconditions.checkArgument(consumable.getType().isEdible(), "Item is not Consumable");239 //Since we have no Bukkit way of differentiating between drinks and food, here is a rough estimation of240 //how it would sound like241 //Drinks:Slurp Slurp Slurp242 //Food: Yum Yum Yum243 GenericGameEvent consumeStartEvent =244 new GenericGameEvent(245 GameEvent.ITEM_INTERACT_START,246 this.getLocation(),247 this,248 16,249 !Bukkit.isPrimaryThread());250 Bukkit.getPluginManager().callEvent(consumeStartEvent);251 PlayerItemConsumeEvent event = new PlayerItemConsumeEvent(this, consumable);252 Bukkit.getPluginManager().callEvent(event);253 if (event.isCancelled())254 {255 GenericGameEvent stopConsumeEvent =256 new GenericGameEvent(257 GameEvent.ITEM_INTERACT_FINISH,258 this.getLocation(),259 this,260 16,261 !Bukkit.isPrimaryThread());262 Bukkit.getPluginManager().callEvent(stopConsumeEvent);263 }264 consumedItems.add(consumable);265 }266 /**267 * Asserts a Player has consumed the given Item268 *269 * @param consumable The Item to asserts has been consumed270 */271 public void assertItemConsumed(@NotNull ItemStack consumable)272 {273 Preconditions.checkNotNull(consumable, "Consumed Item can't be null");274 if (!consumedItems.contains(consumable))275 {276 fail();277 }278 }279 @Override280 public @NotNull EntityType getType()281 {282 return EntityType.PLAYER;283 }284 /**285 * Simulates the player damaging a block just like {@link #simulateBlockDamage(Block)}. However, if286 * {@code InstaBreak} is enabled, it will not automatically fire a {@link BlockBreakEvent}. It will also still fire287 * a {@link BlockDamageEvent} even if the player is not in survival mode.288 *289 * @param block The block to damage.290 * @return The event that has been fired.291 */292 protected @NotNull BlockDamageEvent simulateBlockDamagePure(@NotNull Block block)293 {294 Preconditions.checkNotNull(block, "Block cannot be null");295 BlockDamageEvent event = new BlockDamageEvent(this, block, getItemInHand(), false);296 Bukkit.getPluginManager().callEvent(event);297 return event;298 }299 /**300 * Simulates the player damaging a block. Note that this method does not anything unless the player is in survival301 * mode. If {@code InstaBreak} is set to true by an event handler, a {@link BlockBreakEvent} is immediately fired.302 * The result will then still be whether or not the {@link BlockDamageEvent} was cancelled or not, not the later303 * {@link BlockBreakEvent}.304 *305 * @param block The block to damage.306 * @return the event that was fired, {@code null} if the player was not in307 * survival gamemode.308 */309 public @Nullable BlockDamageEvent simulateBlockDamage(@NotNull Block block)310 {311 Preconditions.checkNotNull(block, "Block cannot be null");312 if (gamemode != GameMode.SURVIVAL)313 {314 return null;315 }316 BlockDamageEvent event = simulateBlockDamagePure(block);317 if (event.getInstaBreak())318 {319 BlockBreakEvent breakEvent = new BlockBreakEvent(block, this);320 Bukkit.getPluginManager().callEvent(breakEvent);321 if (!breakEvent.isCancelled())322 block.setType(Material.AIR);323 }324 return event;325 }326 /**327 * Simulates the player breaking a block. This method will not break the block if the player is in adventure or328 * spectator mode. If the player is in survival mode, the player will first damage the block.329 *330 * @param block The block to break.331 * @return The event that was fired, {@code null} if it wasn't or if the player was in adventure mode332 * or in spectator mode.333 */334 public @Nullable BlockBreakEvent simulateBlockBreak(@NotNull Block block)335 {336 Preconditions.checkNotNull(block, "Block cannot be null");337 if ((gamemode == GameMode.SPECTATOR || gamemode == GameMode.ADVENTURE)338 || (gamemode == GameMode.SURVIVAL && simulateBlockDamagePure(block).isCancelled()))339 return null;340 BlockBreakEvent event = new BlockBreakEvent(block, this);341 Bukkit.getPluginManager().callEvent(event);342 if (!event.isCancelled())343 block.setType(Material.AIR);344 return event;345 }346 /**347 * Simulates the player placing a block. This method will not place the block if the player is in adventure or348 * spectator mode.349 *350 * @param material The material of the location to set to351 * @param location The location of the material to set to352 * @return The event that was fired. {@code null} if it wasn't or the player was in adventure353 * mode.354 */355 public @Nullable BlockPlaceEvent simulateBlockPlace(@NotNull Material material, @NotNull Location location)356 {357 Preconditions.checkNotNull(material, "Material cannot be null");358 Preconditions.checkNotNull(location, "Location cannot be null");359 if (gamemode == GameMode.ADVENTURE || gamemode == GameMode.SPECTATOR)360 return null;361 Block block = location.getBlock();362 BlockState blockState = block.getState();363 block.setType(material);364 BlockPlaceEvent event = new BlockPlaceEvent(block, blockState, null, getItemInHand(), this, true, EquipmentSlot.HAND);365 Bukkit.getPluginManager().callEvent(event);366 if (event.isCancelled() || !event.canBuild())367 {368 blockState.update(true, false);369 }370 return event;371 }372 /**373 * Simulates the player clicking an Inventory.374 *375 * @param slot The slot in the player's open inventory376 * @return The event that was fired.377 */378 public @NotNull InventoryClickEvent simulateInventoryClick(int slot)379 {380 return simulateInventoryClick(getOpenInventory(), slot);381 }382 /**383 * Simulates the player clicking an Inventory.384 *385 * @param inventoryView The inventory view we want to click386 * @param slot The slot in the provided Inventory387 * @return The event that was fired.388 */389 public @NotNull InventoryClickEvent simulateInventoryClick(@NotNull InventoryView inventoryView, int slot)390 {391 return simulateInventoryClick(inventoryView, ClickType.LEFT, slot);392 }393 /**394 * Simulates the player clicking an Inventory.395 *396 * @param inventoryView The inventory view we want to click397 * @param clickType The click type we want to fire398 * @param slot The slot in the provided Inventory399 * @return The event that was fired.400 */401 public @NotNull InventoryClickEvent simulateInventoryClick(@NotNull InventoryView inventoryView, @NotNull ClickType clickType, int slot)402 {403 Preconditions.checkNotNull(inventoryView, "InventoryView cannot be null");404 InventoryClickEvent inventoryClickEvent = new InventoryClickEvent(inventoryView, InventoryType.SlotType.CONTAINER, slot, clickType, InventoryAction.UNKNOWN);405 Bukkit.getPluginManager().callEvent(inventoryClickEvent);406 return inventoryClickEvent;407 }408 /**409 * This method simulates the {@link Player} respawning and also calls a {@link PlayerRespawnEvent}. Should the410 * {@link Player} not be dead (when {@link #isDead()} returns false) then this will throw an411 * {@link UnsupportedOperationException}. Otherwise, the {@link Location} will be set to412 * {@link Player#getBedSpawnLocation()} or {@link World#getSpawnLocation()}. Lastly the health of this413 * {@link Player} will be restored and set to the max health.414 */415 public void respawn()416 {417 Location respawnLocation = getBedSpawnLocation();418 boolean isBedSpawn = respawnLocation != null;419 // TODO: Respawn Anchors are not yet supported.420 boolean isAnchorSpawn = false;421 if (!isBedSpawn)422 {423 respawnLocation = getLocation().getWorld().getSpawnLocation();424 }425 PlayerRespawnEvent event = new PlayerRespawnEvent(this, respawnLocation, isBedSpawn, isAnchorSpawn);426 Bukkit.getPluginManager().callEvent(event);427 // Reset location and health428 setHealth(getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());429 setLocation(event.getRespawnLocation().clone());430 alive = true;431 }432 /**433 * This method moves player instantly with respect to PlayerMoveEvent434 *435 * @param moveLocation Location to move player to436 * @return The event that is fired437 */438 public @NotNull PlayerMoveEvent simulatePlayerMove(@NotNull Location moveLocation)439 {440 Preconditions.checkNotNull(moveLocation, "Location cannot be null");441 PlayerMoveEvent event = new PlayerMoveEvent(this, this.getLocation(), moveLocation);442 this.setLocation(event.getTo());443 Bukkit.getPluginManager().callEvent(event);444 if (event.isCancelled())445 this.setLocation(event.getFrom());446 return event;447 }448 @Override449 public @NotNull GameMode getGameMode()450 {451 return this.gamemode;452 }453 @Override454 public void setGameMode(@NotNull GameMode mode)455 {456 Preconditions.checkNotNull(mode, "GameMode cannot be null");457 if (this.gamemode == mode)458 return;459 PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(this, mode, PlayerGameModeChangeEvent.Cause.UNKNOWN, null);460 if (!event.callEvent())461 return;462 this.previousGamemode = this.gamemode;463 this.gamemode = mode;464 }465 @Override466 public boolean isWhitelisted()467 {468 return server.getWhitelistedPlayers().contains(this);469 }470 @Override471 public void setWhitelisted(boolean value)472 {473 if (value)474 {475 server.getWhitelistedPlayers().add(this);476 }477 else478 {479 server.getWhitelistedPlayers().remove(this);480 }481 }482 @Override483 public Player getPlayer()484 {485 return (isOnline()) ? this : null;486 }487 @Override488 public boolean isOnline()489 {490 return getServer().getPlayer(getUniqueId()) != null;491 }492 @Override493 public boolean isBanned()494 {495 return MockBukkit.getMock().getBanList(BanList.Type.NAME).isBanned(getName());496 }497 /**498 * This method is an assertion for the currently open {@link InventoryView} for this {@link Player}. The499 * {@link Predicate} refers to the top inventory, not the {@link PlayerInventory}. It uses the method500 * {@link InventoryView#getTopInventory()}.501 *502 * @param message The message to display upon failure503 * @param type The {@link InventoryType} you are expecting504 * @param predicate A custom {@link Predicate} to check the opened {@link Inventory}.505 */506 public void assertInventoryView(String message, InventoryType type, @NotNull Predicate<Inventory> predicate)507 {508 InventoryView view = getOpenInventory();509 if (view.getType() == type && predicate.test(view.getTopInventory()))510 {511 return;512 }513 fail(message);514 }515 /**516 * This method is an assertion for the currently open {@link InventoryView} for this {@link Player}. The517 * {@link Predicate} refers to the top inventory, not the {@link PlayerInventory}. It uses the method518 * {@link InventoryView#getTopInventory()}.519 *520 * @param type The {@link InventoryType} you are expecting521 * @param predicate A custom {@link Predicate} to check the opened {@link Inventory}.522 */523 public void assertInventoryView(InventoryType type, @NotNull Predicate<Inventory> predicate)524 {525 assertInventoryView("The InventoryView Assertion has failed", type, predicate);526 }527 /**528 * This method is an assertion for the currently open {@link InventoryView} for this {@link Player}.529 *530 * @param type The {@link InventoryType} you are expecting531 */532 public void assertInventoryView(InventoryType type)533 {534 assertInventoryView("The InventoryView Assertion has failed", type, inv -> true);535 }536 /**537 * This method is an assertion for the currently open {@link InventoryView} for this {@link Player}.538 *539 * @param message The message to display upon failure540 * @param type The {@link InventoryType} you are expecting541 */542 public void assertInventoryView(String message, InventoryType type)543 {544 assertInventoryView(message, type, inv -> true);545 }546 @Override547 public void updateInventory()548 {549 // Normally a packet would be sent here to update the player's inventory.550 // We just pretend that this happened!551 }552 @Override553 public boolean performCommand(@NotNull String command)554 {555 Preconditions.checkNotNull(command, "Command cannot be null");556 return Bukkit.dispatchCommand(this, command);557 }558 @Override559 public void showDemoScreen()560 {561 // TODO Auto-generated method stub562 throw new UnimplementedOperationException();563 }564 @Override565 public boolean isAllowingServerListings()566 {567 // TODO Auto-generated method stub568 throw new UnimplementedOperationException();569 }570 @Override571 public double getEyeHeight()572 {573 return getEyeHeight(false);574 }575 @Override576 public double getEyeHeight(boolean ignorePose)577 {578 if (isSneaking() && !ignorePose)579 return 1.54D;580 return 1.62D;581 }582 @Override583 public @Nullable TargetEntityInfo getTargetEntityInfo(int maxDistance, boolean ignoreBlocks)584 {585 // TODO Auto-generated method stub586 throw new UnimplementedOperationException();587 }588 @Override589 public int getNoDamageTicks()590 {591 // TODO Auto-generated method stub592 throw new UnimplementedOperationException();593 }594 @Override595 public void setNoDamageTicks(int ticks)596 {597 // TODO Auto-generated method stub598 throw new UnimplementedOperationException();599 }600 @Override601 public EntityEquipment getEquipment()602 {603 return (EntityEquipment) getInventory();604 }605 @Override606 public boolean isConversing()607 {608 // TODO Auto-generated method stub609 throw new UnimplementedOperationException();610 }611 @Override612 public void acceptConversationInput(@NotNull String input)613 {614 // TODO Auto-generated method stub615 throw new UnimplementedOperationException();616 }617 @Override618 public boolean beginConversation(@NotNull Conversation conversation)619 {620 // TODO Auto-generated method stub621 throw new UnimplementedOperationException();622 }623 @Override624 public void abandonConversation(@NotNull Conversation conversation)625 {626 // TODO Auto-generated method stub627 throw new UnimplementedOperationException();628 }629 @Override630 public void abandonConversation(@NotNull Conversation conversation, @NotNull ConversationAbandonedEvent details)631 {632 // TODO Auto-generated method stub633 throw new UnimplementedOperationException();634 }635 @Override636 public long getFirstPlayed()637 {638 return firstPlayed;639 }640 @Override641 public long getLastPlayed()642 {643 return lastPlayed;644 }645 @Override646 public boolean hasPlayedBefore()647 {648 return firstPlayed > 0;649 }650 public void setLastPlayed(long time)651 {652 if (time > 0)653 {654 lastPlayed = time;655 // Set firstPlayed if this is the first time656 if (firstPlayed == 0)657 {658 firstPlayed = time;659 }660 }661 }662 @Override663 public @NotNull Map<String, Object> serialize()664 {665 Map<String, Object> result = new LinkedHashMap<>();666 result.put("name", getName());667 return result;668 }669 @Override670 public void sendPluginMessage(@NotNull Plugin source, @NotNull String channel, byte[] message)671 {672 Preconditions.checkNotNull(source, "Source cannot be null");673 Preconditions.checkNotNull(channel, "Channel cannot be null");674 StandardMessenger.validatePluginMessage(getServer().getMessenger(), source, channel, message);675 }676 @Override677 public @NotNull Set<String> getListeningPluginChannels()678 {679 return ImmutableSet.copyOf(channels);680 }681 @Override682 public @NotNull Component displayName()683 {684 return this.displayName;685 }686 @Override687 public void displayName(@Nullable Component displayName)688 {689 this.displayName = displayName;690 }691 @Override692 @Deprecated693 public @NotNull String getDisplayName()694 {695 return LegacyComponentSerializer.legacySection().serialize(this.displayName);696 }697 @Override698 @Deprecated699 public void setDisplayName(@NotNull String name)700 {701 this.displayName = LegacyComponentSerializer.legacySection().deserialize(name);702 }703 @Override704 public @NotNull String getScoreboardEntry()705 {706 return getName();707 }708 @Override709 public void playerListName(@Nullable Component name)710 {711 this.playerListName = name;712 }713 @Override714 public @NotNull Component playerListName()715 {716 return this.playerListName == null ? name() : this.playerListName;717 }718 @Override719 public @Nullable Component playerListHeader()720 {721 return this.playerListHeader;722 }723 @Override724 public @Nullable Component playerListFooter()725 {726 return this.playerListFooter;727 }728 @Override729 @Deprecated730 public @NotNull String getPlayerListName()731 {732 return this.playerListName == null ? getName() : LegacyComponentSerializer.legacySection().serialize(this.playerListName);733 }734 @Override735 @Deprecated736 public void setPlayerListName(@Nullable String name)737 {738 this.playerListName = name == null ? null : LegacyComponentSerializer.legacySection().deserialize(name);739 }740 @Override741 public void setCompassTarget(@NotNull Location loc)742 {743 Preconditions.checkNotNull(loc, "Location cannot be null");744 this.compassTarget = loc;745 }746 @NotNull747 @Override748 public Location getCompassTarget()749 {750 return this.compassTarget;751 }752 /**753 * Sets the {@link InetSocketAddress} returned by {@link #getAddress}.754 *755 * @param address The address to set.756 */757 public void setAddress(@Nullable InetSocketAddress address)758 {759 this.address = address;760 }761 @Override762 public @Nullable InetSocketAddress getAddress()763 {764 return (isOnline()) ? address : null;765 }766 @Override767 public int getProtocolVersion()768 {769 // TODO Auto-generated method stub770 throw new UnimplementedOperationException();771 }772 @Override773 public @Nullable InetSocketAddress getVirtualHost()774 {775 // TODO Auto-generated method stub776 throw new UnimplementedOperationException();777 }778 @Override779 public void sendRawMessage(@Nullable String message)780 {781 // TODO Auto-generated method stub782 throw new UnimplementedOperationException();783 }784 @Override785 public void sendRawMessage(@Nullable UUID sender, @NotNull String message)786 {787 // TODO Auto-generated method stub788 throw new UnimplementedOperationException();789 }790 @Override791 @Deprecated792 public void kickPlayer(String message)793 {794 kick(Component.text(message));795 }796 @Override797 public void kick()798 {799 kick(DEFAULT_KICK_COMPONENT);800 }801 @Override802 public void kick(@Nullable Component message)803 {804 kick(message, PlayerKickEvent.Cause.PLUGIN);805 }806 @Override807 public void kick(@Nullable Component message, PlayerKickEvent.@NotNull Cause cause)808 {809 AsyncCatcher.catchOp("player kick");810 if (!isOnline()) return;811 PlayerKickEvent event =812 new PlayerKickEvent(this,813 Component.text("Plugin"),814 message == null ? net.kyori.adventure.text.Component.empty() : message,815 cause);816 Bukkit.getPluginManager().callEvent(event);817 server.getPlayerList().disconnectPlayer(this);818 }819 @Override820 @SuppressWarnings("deprecation")821 public void chat(@NotNull String msg)822 {823 Preconditions.checkNotNull(msg, "Message cannot be null");824 Set<Player> players = new HashSet<>(Bukkit.getOnlinePlayers());825 AsyncPlayerChatEvent asyncEvent = new AsyncPlayerChatEvent(true, this, msg, players);826 AsyncChatEvent asyncChatEvent = new AsyncChatEvent(827 true,828 this,829 new HashSet<>(Bukkit.getOnlinePlayers()),830 ChatRenderer.defaultRenderer(),831 Component.text(msg),832 Component.text(msg)833 );834 PlayerChatEvent syncEvent = new PlayerChatEvent(this, msg);835 server.getScheduler().executeAsyncEvent(asyncChatEvent);836 server.getScheduler().executeAsyncEvent(asyncEvent);837 server.getPluginManager().callEvent(syncEvent);838 }839 @Override840 public boolean isSneaking()841 {842 return sneaking;843 }844 @Override845 public void setSneaking(boolean sneaking)846 {847 this.sneaking = sneaking;848 }849 public @NotNull PlayerToggleSneakEvent simulateSneak(boolean sneak)850 {851 PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(this, sneak);852 Bukkit.getPluginManager().callEvent(event);853 if (!event.isCancelled())854 {855 this.sneaking = event.isSneaking();856 }857 return event;858 }859 @Override860 public boolean isSprinting()861 {862 return sprinting;863 }864 @Override865 public void setSprinting(boolean sprinting)866 {867 this.sprinting = sprinting;868 }869 public @NotNull PlayerToggleSprintEvent simulateSprint(boolean sprint)870 {871 PlayerToggleSprintEvent event = new PlayerToggleSprintEvent(this, sprint);872 Bukkit.getPluginManager().callEvent(event);873 if (!event.isCancelled())874 {875 this.sprinting = event.isSprinting();876 }877 return event;878 }879 @Override880 public void saveData()881 {882 // TODO Auto-generated method stub883 throw new UnimplementedOperationException();884 }885 @Override886 public void loadData()887 {888 // TODO Auto-generated method stub889 throw new UnimplementedOperationException();890 }891 @Override892 public boolean isSleepingIgnored()893 {894 // TODO Auto-generated method stub895 throw new UnimplementedOperationException();896 }897 @Override898 public void setSleepingIgnored(boolean isSleeping)899 {900 // TODO Auto-generated method stub901 throw new UnimplementedOperationException();902 }903 @Override904 @Deprecated905 public void playNote(@NotNull Location loc, byte instrument, byte note)906 {907 playNote(loc, Instrument.getByType(instrument), note);908 }909 @Override910 public void playNote(@NotNull Location loc, @NotNull Instrument instrument, @NotNull Note note)911 {912 playNote(loc, instrument, note.getId());913 }914 private void playNote(@NotNull Location loc, @NotNull Instrument instrument, byte note)915 {916 Preconditions.checkNotNull(loc, "Location cannot be null");917 Preconditions.checkNotNull(instrument, "Instrument cannot be null");918 Sound sound = switch (instrument)919 {920 case BANJO -> Sound.BLOCK_NOTE_BLOCK_BANJO;921 case BASS_DRUM -> Sound.BLOCK_NOTE_BLOCK_BASEDRUM;922 case BASS_GUITAR -> Sound.BLOCK_NOTE_BLOCK_BASS;923 case BELL -> Sound.BLOCK_NOTE_BLOCK_BELL;924 case BIT -> Sound.BLOCK_NOTE_BLOCK_BIT;925 case CHIME -> Sound.BLOCK_NOTE_BLOCK_CHIME;926 case COW_BELL -> Sound.BLOCK_NOTE_BLOCK_COW_BELL;927 case DIDGERIDOO -> Sound.BLOCK_NOTE_BLOCK_DIDGERIDOO;928 case FLUTE -> Sound.BLOCK_NOTE_BLOCK_FLUTE;929 case GUITAR -> Sound.BLOCK_NOTE_BLOCK_GUITAR;930 case IRON_XYLOPHONE -> Sound.BLOCK_NOTE_BLOCK_IRON_XYLOPHONE;931 case PIANO -> Sound.BLOCK_NOTE_BLOCK_HARP;932 case PLING -> Sound.BLOCK_NOTE_BLOCK_PLING;933 case SNARE_DRUM -> Sound.BLOCK_NOTE_BLOCK_SNARE;934 case STICKS -> Sound.BLOCK_NOTE_BLOCK_HAT;935 case XYLOPHONE -> Sound.BLOCK_NOTE_BLOCK_XYLOPHONE;936 default ->937 // This should never be reached unless Mojang adds new instruments938 throw new UnimplementedOperationException("Instrument '" + instrument + "' has no implementation!");939 };940 float pitch = (float) Math.pow(2.0D, (note - 12.0D) / 12.0D);941 playSound(loc, sound, SoundCategory.RECORDS, 3, pitch);942 }943 @Override944 public void playSound(@NotNull Location location, @NotNull String sound, float volume, float pitch)945 {946 Preconditions.checkNotNull(location, "Location cannot be null");947 Preconditions.checkNotNull(sound, "Sound cannot be null");948 heardSounds.add(new AudioExperience(sound, SoundCategory.MASTER, location, volume, pitch));949 }950 @Override951 public void playSound(@NotNull Location location, @NotNull Sound sound, float volume, float pitch)952 {953 playSound(location, sound, SoundCategory.MASTER, volume, pitch);954 }955 @Override956 public void playSound(@NotNull Entity entity, @NotNull Sound sound, float volume, float pitch)957 {958 playSound(entity, sound, SoundCategory.MASTER, volume, pitch);959 }960 @Override961 public void playSound(@NotNull Location location, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch)962 {963 Preconditions.checkNotNull(location, "Location cannot be null");964 Preconditions.checkNotNull(sound, "Sound cannot be null");965 Preconditions.checkNotNull(category, "Category cannot be null");966 heardSounds.add(new AudioExperience(sound, category, location, volume, pitch));967 }968 @Override969 public void playSound(@NotNull Location location, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch)970 {971 Preconditions.checkNotNull(location, "Location cannot be null");972 Preconditions.checkNotNull(sound, "Sound cannot be null");973 Preconditions.checkNotNull(category, "Category cannot be null");974 heardSounds.add(new AudioExperience(sound, category, location, volume, pitch));975 }976 @Override977 public void playSound(@NotNull Entity entity, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch)978 {979 Preconditions.checkNotNull(entity, "Entity cannot be null");980 Preconditions.checkNotNull(sound, "Sound cannot be null");981 Preconditions.checkNotNull(category, "Category cannot be null");982 heardSounds.add(new AudioExperience(sound, category, entity.getLocation(), volume, pitch));983 }984 @Override985 public @NotNull List<AudioExperience> getHeardSounds()986 {987 return heardSounds;988 }989 @Override990 public void addHeardSound(@NotNull AudioExperience audioExperience)991 {992 Preconditions.checkNotNull(audioExperience, "AudioExperience cannot be null");993 SoundReceiver.super.addHeardSound(audioExperience);994 }995 @Override996 public void stopSound(@NotNull Sound sound)997 {998 stopSound(sound, SoundCategory.MASTER);999 }1000 @Override1001 public void stopSound(@NotNull String sound)1002 {1003 stopSound(sound, SoundCategory.MASTER);1004 }1005 @Override1006 public void stopSound(@NotNull Sound sound, @Nullable SoundCategory category)1007 {1008 Preconditions.checkNotNull(sound, "Sound cannot be null");1009 // We will just pretend the Sound has stopped.1010 }1011 @Override1012 public void stopSound(@NotNull String sound, @Nullable SoundCategory category)1013 {1014 Preconditions.checkNotNull(sound, "Sound cannot be null");1015 // We will just pretend the Sound has stopped.1016 }1017 @Override1018 public void stopSound(@NotNull SoundCategory category)1019 {1020 // We will just pretend the Sound has stopped.1021 }1022 @Override1023 public void stopAllSounds()1024 {1025 // We will just pretend all Sounds have stopped.1026 }1027 @Override1028 @Deprecated1029 public void playEffect(@NotNull Location loc, @NotNull Effect effect, int data)1030 {1031 Preconditions.checkNotNull(loc, "Location cannot be null");1032 Preconditions.checkNotNull(effect, "Effect cannot be null");1033 // Pretend packet gets sent.1034 }1035 @Override1036 public <T> void playEffect(@NotNull Location loc, @NotNull Effect effect, @Nullable T data)1037 {1038 Preconditions.checkNotNull(loc, "Location cannot be null");1039 Preconditions.checkNotNull(effect, "Effect cannot be null");1040 if (data != null)1041 {1042 Preconditions.checkArgument(effect.getData() != null && effect.getData().isAssignableFrom(data.getClass()), "Wrong kind of data for this effect!");1043 }1044 else1045 {1046 // The axis is optional for ELECTRIC_SPARK1047 Preconditions.checkArgument(effect.getData() == null || effect == Effect.ELECTRIC_SPARK, "Wrong kind of data for this effect!");1048 }1049 }1050 @Override1051 public boolean breakBlock(@NotNull Block block)1052 {1053 Preconditions.checkNotNull(block, "Block cannot be null");1054 Preconditions.checkArgument(block.getWorld().equals(getWorld()), "Cannot break blocks across worlds");1055 BlockBreakEvent event = new BlockBreakEvent(block, this);1056 boolean swordNoBreak = getGameMode() == GameMode.CREATIVE && getEquipment().getItemInMainHand().getType().name().contains("SWORD");1057 event.setCancelled(swordNoBreak);1058 Bukkit.getPluginManager().callEvent(event);1059 if (!event.isCancelled())1060 {1061 block.setType(Material.AIR);1062 // todo: BlockDropItemEvent when BlockMock#getDrops is implemented.1063 }1064 return !event.isCancelled();1065 }1066 @Override1067 @Deprecated1068 public void sendBlockChange(@NotNull Location loc, @NotNull Material material, byte data)1069 {1070 Preconditions.checkNotNull(loc, "Location cannot be null");1071 Preconditions.checkNotNull(material, "Material cannot be null");1072 // Pretend we sent the block change.1073 }1074 @Override1075 public void sendBlockChange(@NotNull Location loc, @NotNull BlockData block)1076 {1077 Preconditions.checkNotNull(loc, "Location cannot be null");1078 Preconditions.checkNotNull(block, "Block cannot be null");1079 // Pretend we sent the block change.1080 }1081 @Override1082 public void sendSignChange(@NotNull Location loc, @Nullable List<Component> lines, @NotNull DyeColor dyeColor, boolean hasGlowingText) throws IllegalArgumentException1083 {1084 Preconditions.checkNotNull(loc, "Location cannot be null");1085 Preconditions.checkNotNull(dyeColor, "DyeColor cannot be null");1086 if (lines == null)1087 {1088 lines = new ArrayList<>(4);1089 }1090 if (lines.size() < 4)1091 {1092 throw new IllegalArgumentException("Must have at least 4 lines");1093 }1094 }1095 @Override1096 @Deprecated1097 public void sendSignChange(@NotNull Location loc, String[] lines)1098 {1099 this.sendSignChange(loc, lines, DyeColor.BLACK);1100 }1101 @Override1102 public void sendSignChange(@NotNull Location loc, String[] lines, @NotNull DyeColor dyeColor) throws IllegalArgumentException1103 {1104 this.sendSignChange(loc, lines, dyeColor, false);1105 }1106 @Override1107 public void sendSignChange(@NotNull Location loc, @Nullable String @Nullable [] lines, @NotNull DyeColor dyeColor, boolean hasGlowingText) throws IllegalArgumentException1108 {1109 Preconditions.checkNotNull(loc, "Location cannot be null");1110 Preconditions.checkNotNull(dyeColor, "DyeColor cannot be null");1111 if (lines == null)1112 {1113 lines = new String[4];1114 }1115 if (lines.length < 4)1116 {1117 throw new IllegalArgumentException("Must have at least 4 lines");1118 }1119 }1120 @Override1121 public void sendMap(@NotNull MapView map)1122 {1123 Preconditions.checkNotNull(map, "Map cannot be null");1124 if (!(map instanceof MapViewMock mapView))1125 return;1126 mapView.render(this);1127 // Pretend the map packet gets sent.1128 }1129 @Override1130 @Deprecated1131 public void sendActionBar(@NotNull String message)1132 {1133 Preconditions.checkNotNull(message, "Message cannot be null");1134 // Pretend we sent the action bar.1135 }1136 @Override1137 @Deprecated1138 public void sendActionBar(char alternateChar, @NotNull String message)1139 {1140 Preconditions.checkNotNull(message, "Message cannot be null");1141 // Pretend we sent the action bar.1142 }1143 @Override1144 @Deprecated1145 public void sendActionBar(@NotNull BaseComponent... message)1146 {1147 Preconditions.checkNotNull(message, "Message cannot be null");1148 // Pretend we sent the action bar.1149 }1150 @Override1151 @Deprecated1152 public void setPlayerListHeaderFooter(BaseComponent @NotNull [] header, BaseComponent @NotNull [] footer)1153 {1154 this.playerListHeader = BungeeComponentSerializer.get().deserialize(Arrays.stream(header).filter(Objects::nonNull).toArray(BaseComponent[]::new));1155 this.playerListFooter = BungeeComponentSerializer.get().deserialize(Arrays.stream(footer).filter(Objects::nonNull).toArray(BaseComponent[]::new));1156 }1157 @Override1158 @Deprecated1159 public void setPlayerListHeaderFooter(@Nullable BaseComponent header, @Nullable BaseComponent footer)1160 {1161 this.playerListHeader = BungeeComponentSerializer.get().deserialize(new BaseComponent[]{ header });1162 this.playerListFooter = BungeeComponentSerializer.get().deserialize(new BaseComponent[]{ footer });1163 }1164 @Override1165 @Deprecated1166 public void setTitleTimes(int fadeInTicks, int stayTicks, int fadeOutTicks)1167 {1168 // TODO Auto-generated method stub1169 throw new UnimplementedOperationException();1170 }1171 @Override1172 @Deprecated1173 public void setSubtitle(BaseComponent[] subtitle)1174 {1175 // TODO Auto-generated method stub1176 throw new UnimplementedOperationException();1177 }1178 @Override1179 @Deprecated1180 public void setSubtitle(BaseComponent subtitle)1181 {1182 // TODO Auto-generated method stub1183 throw new UnimplementedOperationException();1184 }1185 @Override1186 @Deprecated1187 public void showTitle(@Nullable BaseComponent[] title)1188 {1189 // TODO Auto-generated method stub1190 throw new UnimplementedOperationException();1191 }1192 @Override1193 @Deprecated1194 public void showTitle(@Nullable BaseComponent title)1195 {1196 // TODO Auto-generated method stub1197 throw new UnimplementedOperationException();1198 }1199 @Override1200 @Deprecated1201 public void showTitle(@Nullable BaseComponent[] title, @Nullable BaseComponent[] subtitle, int fadeInTicks, int stayTicks, int fadeOutTicks)1202 {1203 // TODO Auto-generated method stub1204 throw new UnimplementedOperationException();1205 }1206 @Override1207 @Deprecated1208 public void showTitle(@Nullable BaseComponent title, @Nullable BaseComponent subtitle, int fadeInTicks, int stayTicks, int fadeOutTicks)1209 {1210 // TODO Auto-generated method stub1211 throw new UnimplementedOperationException();1212 }1213 @Override1214 @Deprecated1215 public void sendTitle(@NotNull Title title)1216 {1217 Preconditions.checkNotNull(title, "Title is null");1218 }1219 @Override1220 @Deprecated1221 public void updateTitle(@NotNull Title title)1222 {1223 // TODO Auto-generated method stub1224 throw new UnimplementedOperationException();1225 }1226 @Override1227 @Deprecated1228 public void hideTitle()1229 {1230 // TODO Auto-generated method stub1231 throw new UnimplementedOperationException();1232 }1233 @Override1234 public @Nullable GameMode getPreviousGameMode()1235 {1236 return previousGamemode;1237 }1238 @Override1239 public void incrementStatistic(@NotNull Statistic statistic)1240 {1241 statistics.incrementStatistic(statistic, 1);1242 }1243 @Override1244 public void decrementStatistic(@NotNull Statistic statistic)1245 {1246 statistics.decrementStatistic(statistic, 1);1247 }1248 @Override1249 public void incrementStatistic(@NotNull Statistic statistic, int amount)1250 {1251 statistics.incrementStatistic(statistic, amount);1252 }1253 @Override1254 public void decrementStatistic(@NotNull Statistic statistic, int amount)1255 {1256 statistics.decrementStatistic(statistic, amount);1257 }1258 @Override1259 public void setStatistic(@NotNull Statistic statistic, int newValue)1260 {1261 statistics.setStatistic(statistic, newValue);1262 }1263 @Override1264 public int getStatistic(@NotNull Statistic statistic)1265 {1266 return statistics.getStatistic(statistic);1267 }1268 @Override1269 public void incrementStatistic(@NotNull Statistic statistic, @NotNull Material material)1270 {1271 statistics.incrementStatistic(statistic, material, 1);1272 }1273 @Override1274 public void decrementStatistic(@NotNull Statistic statistic, @NotNull Material material)1275 {1276 statistics.decrementStatistic(statistic, material, 1);1277 }1278 @Override1279 public int getStatistic(@NotNull Statistic statistic, @NotNull Material material)1280 {1281 return statistics.getStatistic(statistic, material);1282 }1283 @Override1284 public void incrementStatistic(@NotNull Statistic statistic, @NotNull Material material, int amount)1285 {1286 statistics.incrementStatistic(statistic, material, amount);1287 }1288 @Override1289 public void decrementStatistic(@NotNull Statistic statistic, @NotNull Material material, int amount)1290 {1291 statistics.decrementStatistic(statistic, material, amount);1292 }1293 @Override1294 public void setStatistic(@NotNull Statistic statistic, @NotNull Material material, int newValue)1295 {1296 statistics.setStatistic(statistic, material, newValue);1297 }1298 @Override1299 public void incrementStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType)1300 {1301 statistics.incrementStatistic(statistic, entityType, 1);1302 }1303 @Override1304 public void decrementStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType)1305 {1306 statistics.decrementStatistic(statistic, entityType, 1);1307 }1308 @Override1309 public int getStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType)1310 {1311 return statistics.getStatistic(statistic, entityType);1312 }1313 @Override1314 public void incrementStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType, int amount)1315 {1316 statistics.incrementStatistic(statistic, entityType, amount);1317 }1318 @Override1319 public void decrementStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType, int amount)1320 {1321 statistics.decrementStatistic(statistic, entityType, amount);1322 }1323 @Override1324 public void setStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType, int newValue)1325 {1326 statistics.setStatistic(statistic, entityType, newValue);1327 }1328 @Override1329 public void setPlayerTime(long time, boolean relative)1330 {1331 // TODO Auto-generated method stub1332 throw new UnimplementedOperationException();1333 }1334 @Override1335 public long getPlayerTime()1336 {1337 // TODO Auto-generated method stub1338 throw new UnimplementedOperationException();1339 }1340 @Override1341 public long getPlayerTimeOffset()1342 {1343 // TODO Auto-generated method stub1344 throw new UnimplementedOperationException();1345 }1346 @Override1347 public boolean isPlayerTimeRelative()1348 {1349 // TODO Auto-generated method stub1350 throw new UnimplementedOperationException();1351 }1352 @Override1353 public void resetPlayerTime()1354 {1355 // TODO Auto-generated method stub1356 throw new UnimplementedOperationException();1357 }1358 @Override1359 public WeatherType getPlayerWeather()1360 {1361 // TODO Auto-generated method stub1362 throw new UnimplementedOperationException();1363 }1364 @Override1365 public void setPlayerWeather(@NotNull WeatherType type)1366 {1367 // TODO Auto-generated method stub1368 throw new UnimplementedOperationException();1369 }1370 @Override1371 public void resetPlayerWeather()1372 {1373 // TODO Auto-generated method stub1374 throw new UnimplementedOperationException();1375 }1376 @Override1377 public void giveExp(int amount)1378 {1379 this.exp += (float) amount / (float) this.getExpToLevel();1380 setTotalExperience(this.expTotal + amount);1381 while (this.exp < 0.0F)1382 {1383 float total = this.exp * this.getExpToLevel();1384 boolean shouldContinue = this.expLevel > 0;1385 this.giveExpLevels(-1);1386 if (shouldContinue)1387 {1388 this.exp = 1.0F + (total / this.getExpToLevel());1389 }1390 }1391 while (this.exp >= 1.0F)1392 {1393 this.exp = (this.exp - 1.0F) * this.getExpToLevel();1394 this.giveExpLevels(1);1395 this.exp /= this.getExpToLevel();1396 }1397 }1398 @Override1399 public void giveExp(int amount, boolean applyMending)1400 {1401 // TODO Auto-generated method stub1402 throw new UnimplementedOperationException();1403 }1404 @Override1405 public int applyMending(int amount)1406 {1407 // TODO Auto-generated method stub1408 throw new UnimplementedOperationException();1409 }1410 @Override1411 public void giveExpLevels(int amount)1412 {1413 int oldLevel = this.expLevel;1414 this.expLevel += amount;1415 if (this.expLevel < 0)1416 {1417 this.expLevel = 0;1418 this.exp = 0.0F;1419 }1420 if (oldLevel != this.expLevel)1421 {1422 PlayerLevelChangeEvent event = new PlayerLevelChangeEvent(this, oldLevel, this.expLevel);1423 Bukkit.getPluginManager().callEvent(event);1424 }1425 }1426 @Override1427 public float getExp()1428 {1429 return exp;1430 }1431 @Override1432 public void setExp(float exp)1433 {1434 if (exp < 0.0 || exp > 1.0)1435 throw new IllegalArgumentException("Experience progress must be between 0.0 and 1.0");1436 this.exp = exp;1437 }1438 @Override1439 public int getLevel()1440 {1441 return expLevel;1442 }1443 @Override1444 public void setLevel(int level)1445 {1446 this.expLevel = level;1447 }1448 @Override1449 public int getTotalExperience()1450 {1451 return expTotal;1452 }1453 @Override1454 public void setTotalExperience(int exp)1455 {1456 this.expTotal = Math.max(0, exp);1457 }1458 @Nullable1459 @Override1460 public Location getBedSpawnLocation()1461 {1462 return bedSpawnLocation;1463 }1464 @Override1465 public long getLastLogin()1466 {1467 // TODO Auto-generated method stub1468 throw new UnimplementedOperationException();1469 }1470 @Override1471 public long getLastSeen()1472 {1473 // TODO Auto-generated method stub1474 throw new UnimplementedOperationException();1475 }1476 @Override1477 public void setBedSpawnLocation(@Nullable Location loc)1478 {1479 setBedSpawnLocation(loc, false);1480 }1481 @Override1482 public void setBedSpawnLocation(@Nullable Location loc, boolean force)1483 {1484 if (force || loc == null || Tag.BEDS.isTagged(loc.getBlock().getType()))1485 {1486 this.bedSpawnLocation = loc;1487 }1488 }1489 @Override1490 public boolean getAllowFlight()1491 {1492 return allowFlight;1493 }1494 @Override1495 public void setAllowFlight(boolean flight)1496 {1497 if (this.isFlying() && !flight)1498 {1499 flying = false;1500 }1501 this.allowFlight = flight;1502 }1503 @Override1504 @Deprecated1505 public void hidePlayer(@NotNull Player player)1506 {1507 Preconditions.checkNotNull(player, "Player cannot be null");1508 hiddenPlayersDeprecated.add(player.getUniqueId());1509 }1510 @Override1511 public void hidePlayer(@NotNull Plugin plugin, @NotNull Player player)1512 {1513 Preconditions.checkNotNull(plugin, "Plugin cannot be null");1514 Preconditions.checkNotNull(player, "Player cannot be null");1515 hiddenPlayers.putIfAbsent(player.getUniqueId(), new HashSet<>());1516 Set<Plugin> blockingPlugins = hiddenPlayers.get(player.getUniqueId());1517 blockingPlugins.add(plugin);1518 }1519 @Override1520 @Deprecated1521 public void showPlayer(@NotNull Player player)1522 {1523 Preconditions.checkNotNull(player, "Player cannot be null");1524 hiddenPlayersDeprecated.remove(player.getUniqueId());1525 }1526 @Override1527 public void showPlayer(@NotNull Plugin plugin, @NotNull Player player)1528 {1529 Preconditions.checkNotNull(plugin, "Plugin cannot be null");1530 Preconditions.checkNotNull(player, "Player cannot be null");1531 if (hiddenPlayers.containsKey(player.getUniqueId()))1532 {1533 Set<Plugin> blockingPlugins = hiddenPlayers.get(player.getUniqueId());1534 blockingPlugins.remove(plugin);1535 if (blockingPlugins.isEmpty())1536 {1537 hiddenPlayers.remove(player.getUniqueId());1538 }1539 }1540 }1541 @Override1542 public boolean canSee(@NotNull Player player)1543 {1544 Preconditions.checkNotNull(player, "Player cannot be null");1545 return !hiddenPlayers.containsKey(player.getUniqueId()) &&1546 !hiddenPlayersDeprecated.contains(player.getUniqueId());1547 }1548 @Override1549 @ApiStatus.Experimental1550 public void hideEntity(@NotNull Plugin plugin, @NotNull Entity entity)1551 {1552 // TODO Auto-generated method stub1553 throw new UnimplementedOperationException();1554 }1555 @Override1556 @ApiStatus.Experimental1557 public void showEntity(@NotNull Plugin plugin, @NotNull Entity entity)1558 {1559 // TODO Auto-generated method stub1560 throw new UnimplementedOperationException();1561 }1562 @Override1563 public boolean canSee(@NotNull Entity entity)1564 {1565 // TODO Auto-generated method stub1566 throw new UnimplementedOperationException();1567 }1568 @Override1569 public boolean isFlying()1570 {1571 return flying;1572 }1573 @Override1574 public void setFlying(boolean value)1575 {1576 if (!this.getAllowFlight() && value)1577 {1578 throw new IllegalArgumentException("Cannot make player fly if getAllowFlight() is false");1579 }1580 this.flying = value;1581 }1582 public @NotNull PlayerToggleFlightEvent simulateToggleFlight(boolean fly)1583 {1584 PlayerToggleFlightEvent event = new PlayerToggleFlightEvent(this, fly);1585 Bukkit.getPluginManager().callEvent(event);1586 if (!event.isCancelled())1587 {1588 this.flying = event.isFlying();1589 }1590 return event;1591 }1592 @Override1593 public float getFlySpeed()1594 {1595 // TODO Auto-generated method stub1596 throw new UnimplementedOperationException();1597 }1598 @Override1599 public void setFlySpeed(float value)1600 {1601 // TODO Auto-generated method stub1602 throw new UnimplementedOperationException();1603 }1604 @Override1605 public float getWalkSpeed()1606 {1607 // TODO Auto-generated method stub1608 throw new UnimplementedOperationException();1609 }1610 @Override1611 public void setWalkSpeed(float value)1612 {1613 // TODO Auto-generated method stub1614 throw new UnimplementedOperationException();1615 }1616 @Override1617 @Deprecated1618 public void setTexturePack(@NotNull String url)1619 {1620 // TODO Auto-generated method stub1621 throw new UnimplementedOperationException();1622 }1623 @Override1624 @Deprecated1625 public void setResourcePack(@NotNull String url)1626 {1627 // TODO Auto-generated method stub1628 throw new UnimplementedOperationException();1629 }1630 @Override1631 public void setResourcePack(@NotNull String url, byte[] hash)1632 {1633 // TODO Auto-generated method stub1634 throw new UnimplementedOperationException();1635 }1636 @Override1637 @Deprecated1638 public void setResourcePack(@NotNull String url, @Nullable byte[] hash, @Nullable String prompt)1639 {1640 // TODO Auto-generated method stub1641 throw new UnimplementedOperationException();1642 }1643 @Override1644 public void setResourcePack(@NotNull String url, byte[] hash, boolean force)1645 {1646 // TODO Auto-generated method stub1647 throw new UnimplementedOperationException();1648 }1649 @Override1650 @Deprecated1651 public void setResourcePack(@NotNull String url, @Nullable byte[] hash, @Nullable String prompt, boolean force)1652 {1653 // TODO Auto-generated method stub1654 throw new UnimplementedOperationException();1655 }1656 @Override1657 public void setResourcePack(@NotNull String url, byte @Nullable [] hash, @Nullable Component prompt, boolean force)1658 {1659 // TODO Auto-generated method stub1660 throw new UnimplementedOperationException();1661 }1662 @Override1663 public @NotNull Scoreboard getScoreboard()1664 {1665 return this.scoreboard;1666 }1667 @Override1668 public void setScoreboard(@NotNull Scoreboard scoreboard)1669 {1670 Preconditions.checkNotNull(scoreboard, "Scoreboard cannot be null");1671 this.scoreboard = scoreboard;1672 }1673 @Override1674 public @Nullable WorldBorder getWorldBorder()1675 {1676 // TODO Auto-generated method stub1677 throw new UnimplementedOperationException();1678 }1679 @Override1680 public void setWorldBorder(@Nullable WorldBorder border)1681 {1682 // TODO Auto-generated method stub1683 throw new UnimplementedOperationException();1684 }1685 @Override1686 public void setHealth(double health)1687 {1688 if (health > 0)1689 {1690 this.health = Math.min(health, getMaxHealth());1691 return;1692 }1693 this.health = 0;1694 List<ItemStack> drops = new ArrayList<>(Arrays.asList(getInventory().getContents()));1695 PlayerDeathEvent event = new PlayerDeathEvent(this, drops, 0, getName() + " got killed");1696 Bukkit.getPluginManager().callEvent(event);1697 // Terminate any InventoryView and the cursor item1698 closeInventory();1699 // Clear the Inventory if keep-inventory is not enabled1700 if (!getWorld().getGameRuleValue(GameRule.KEEP_INVENTORY))1701 {1702 getInventory().clear();1703 // Should someone try to provoke a RespawnEvent, they will now find the Inventory to be empty1704 }1705 setLevel(0);1706 setExp(0);1707 setFoodLevel(0);1708 alive = false;1709 }1710 @Override1711 public boolean isHealthScaled()1712 {1713 // TODO Auto-generated method stub1714 throw new UnimplementedOperationException();1715 }1716 @Override1717 public void setHealthScaled(boolean scale)1718 {1719 // TODO Auto-generated method stub1720 throw new UnimplementedOperationException();1721 }1722 @Override1723 public double getHealthScale()1724 {1725 // TODO Auto-generated method stub1726 throw new UnimplementedOperationException();1727 }1728 @Override1729 public void setHealthScale(double scale)1730 {1731 // TODO Auto-generated method stub1732 throw new UnimplementedOperationException();1733 }1734 @Override1735 public void sendHealthUpdate(double health, int foodLevel, float saturationLevel)1736 {1737 // Pretend we sent the health update.1738 }1739 @Override1740 public void sendHealthUpdate()1741 {1742 // Pretend we sent the health update.1743 }1744 @Override1745 public Entity getSpectatorTarget()1746 {1747 // TODO Auto-generated method stub1748 throw new UnimplementedOperationException();1749 }1750 @Override1751 public void setSpectatorTarget(Entity entity)1752 {1753 // TODO Auto-generated method stub1754 throw new UnimplementedOperationException();1755 }1756 @Override1757 @Deprecated1758 public void sendTitle(String title, String subtitle)1759 {1760 this.title.add(title);1761 this.subitles.add(subtitle);1762 }1763 @Override1764 @Deprecated1765 public void sendTitle(String title, String subtitle, int fadeIn, int stay, int fadeOut)1766 {1767 sendTitle(title, subtitle);1768 }1769 public @Nullable String nextTitle()1770 {1771 return title.poll();1772 }1773 public @Nullable String nextSubTitle()1774 {1775 return subitles.poll();1776 }1777 @Override1778 public void resetTitle()1779 {1780 // TODO Auto-generated method stub1781 throw new UnimplementedOperationException();1782 }1783 @Override1784 public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count)1785 {1786 this.spawnParticle(particle, location.getX(), location.getY(), location.getZ(), count);1787 }1788 @Override1789 public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count)1790 {1791 this.spawnParticle(particle, x, y, z, count, null);1792 }1793 @Override1794 public <T> void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, T data)1795 {1796 this.spawnParticle(particle, location.getX(), location.getY(), location.getZ(), count, data);1797 }1798 @Override1799 public <T> void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, T data)1800 {1801 this.spawnParticle(particle, x, y, z, count, 0, 0, 0, data);1802 }1803 @Override1804 public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY,1805 double offsetZ)1806 {1807 this.spawnParticle(particle, location.getX(), location.getY(), location.getZ(), count, offsetX, offsetY, offsetZ);1808 }1809 @Override1810 public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX,1811 double offsetY, double offsetZ)1812 {1813 this.spawnParticle(particle, x, y, z, count, offsetX, offsetY, offsetZ, null);1814 }1815 @Override1816 public <T> void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY,1817 double offsetZ, T data)1818 {1819 this.spawnParticle(particle, location.getX(), location.getY(), location.getZ(), count, offsetX, offsetY, offsetZ, data);1820 }1821 @Override1822 public <T> void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX,1823 double offsetY, double offsetZ, T data)1824 {1825 this.spawnParticle(particle, x, y, z, count, offsetX, offsetY, offsetZ, 1, data);1826 }1827 @Override1828 public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY,1829 double offsetZ, double extra)1830 {1831 this.spawnParticle(particle, location.getX(), location.getY(), location.getZ(), count, offsetX, offsetY, offsetZ, extra);1832 }1833 @Override1834 public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX,1835 double offsetY, double offsetZ, double extra)1836 {1837 this.spawnParticle(particle, x, y, z, count, offsetX, offsetY, offsetZ, extra, null);1838 }1839 @Override1840 public <T> void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY,1841 double offsetZ, double extra, T data)1842 {1843 this.spawnParticle(particle, location.getX(), location.getY(), location.getZ(), count, offsetX, offsetY, offsetZ, data);1844 }1845 @Override1846 public <T> void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX,1847 double offsetY, double offsetZ, double extra, @Nullable T data)1848 {1849 Preconditions.checkNotNull(particle, "Particle cannot be null");1850 if (data != null && !particle.getDataType().isInstance(data))1851 {1852 throw new IllegalArgumentException("data should be " + particle.getDataType() + " got " + data.getClass());1853 }1854 }1855 @Override1856 public @NotNull AdvancementProgress getAdvancementProgress(@NotNull Advancement advancement)1857 {1858 // TODO Auto-generated method stub1859 throw new UnimplementedOperationException();1860 }1861 @Override1862 public @NotNull String getLocale()1863 {1864 // TODO Auto-generated method stub1865 throw new UnimplementedOperationException();1866 }1867 @Override1868 public boolean getAffectsSpawning()1869 {1870 // TODO Auto-generated method stub1871 throw new UnimplementedOperationException();1872 }1873 @Override1874 public void setAffectsSpawning(boolean affects)1875 {1876 // TODO Auto-generated method stub1877 throw new UnimplementedOperationException();1878 }1879 @Override1880 public int getViewDistance()1881 {1882 // TODO Auto-generated method stub1883 throw new UnimplementedOperationException();1884 }1885 @Override1886 public void setViewDistance(int viewDistance)1887 {1888 // TODO Auto-generated method stub1889 throw new UnimplementedOperationException();1890 }1891 @Override1892 public int getSimulationDistance()1893 {1894 // TODO Auto-generated method stub1895 throw new UnimplementedOperationException();1896 }1897 @Override1898 public void setSimulationDistance(int simulationDistance)1899 {1900 // TODO Auto-generated method stub1901 throw new UnimplementedOperationException();1902 }1903 @Override1904 @Deprecated1905 public int getNoTickViewDistance()1906 {1907 // TODO Auto-generated method stub1908 throw new UnimplementedOperationException();1909 }1910 @Override1911 @Deprecated1912 public void setNoTickViewDistance(int viewDistance)1913 {1914 // TODO Auto-generated method stub1915 throw new UnimplementedOperationException();1916 }1917 @Override1918 public int getSendViewDistance()1919 {1920 // TODO Auto-generated method stub1921 throw new UnimplementedOperationException();1922 }1923 @Override1924 public void setSendViewDistance(int viewDistance)1925 {1926 // TODO Auto-generated method stub1927 throw new UnimplementedOperationException();1928 }1929 @Override1930 public String getPlayerListHeader()1931 {1932 return LegacyComponentSerializer.legacySection().serialize(this.playerListHeader);1933 }1934 @Override1935 public void setPlayerListHeader(@Nullable String header)1936 {1937 this.playerListHeader = header == null ? null : LegacyComponentSerializer.legacySection().deserialize(header);1938 }1939 @Override1940 public String getPlayerListFooter()1941 {1942 return LegacyComponentSerializer.legacySection().serialize(this.playerListFooter);1943 }1944 @Override1945 public void setPlayerListFooter(@Nullable String footer)1946 {1947 this.playerListFooter = footer == null ? null : LegacyComponentSerializer.legacySection().deserialize(footer);1948 }1949 @Override1950 public void setPlayerListHeaderFooter(@Nullable String header, @Nullable String footer)1951 {1952 this.playerListHeader = header == null ? null : LegacyComponentSerializer.legacySection().deserialize(header);1953 this.playerListFooter = footer == null ? null : LegacyComponentSerializer.legacySection().deserialize(footer);1954 }1955 @Override1956 public void updateCommands()1957 {1958 // TODO Auto-generated method stub1959 throw new UnimplementedOperationException();1960 }1961 @Override1962 public int getClientViewDistance()1963 {1964 // TODO Auto-generated method stub1965 throw new UnimplementedOperationException();1966 }1967 @Override...

Full Screen

Full Screen

playerListFooter

Using AI Code Generation

copy

Full Screen

1PlayerMock player = server.addPlayer();2player.setPlayerListFooter("This is the footer");3player.sendPacket(new PlayerListFooterPacket("This is the footer"));4assertEquals("This is the footer", player.getPlayerListFooter());5{6 private String footer;7 public PlayerListFooterPacket(String footer)8 {9 this.footer = footer;10 }11 public int getPacketId()12 {13 return 0x47;14 }15 public void write(ByteArrayDataOutput out, int protocolVersion)16 {17 out.writeUTF(footer);18 }19}20{21 private String footer;22 public PlayerListFooterPacket(String footer)23 {24 this.footer = footer;25 }26 public int getPacketId()27 {28 return 0x47;29 }30 public void write(ByteArrayDataOutput out, int protocolVersion)31 {32 out.writeByte(0);33 out.writeUTF(footer);34 }35}36{37 private String footer;38 public PlayerListFooterPacket(String footer)39 {40 this.footer = footer;41 }42 public int getPacketId()43 {44 return 0x47;45 }46 public void write(ByteArrayDataOutput out, int protocolVersion)47 {48 out.writeByte(0);49 out.writeUTF(footer);50 }51}

Full Screen

Full Screen

playerListFooter

Using AI Code Generation

copy

Full Screen

1import org.junit.jupiter.api.Test;2import org.junit.jupiter.api.BeforeEach;3import org.junit.jupiter.api.AfterEach;4import org.junit.jupiter.api.DisplayName;5import org.junit.jupiter.api.BeforeAll;6import org.junit.jupiter.api.AfterAll;7import org.junit.jupiter.api.BeforeEach;8import org.junit.jupiter.api.AfterEach;9import org.junit.jupiter.api.Test;10import org.junit.jupiter.api.DisplayName;11import static org.junit.jupiter.api.Assertions.*;12import org.junit.jupiter.api.extension.ExtendWith;13import org.junit.jupiter.api.Order;14import org.junit.jupiter.api.MethodOrderer;15import org.junit.jupiter.api.TestMethodOrder;16import org.junit.jupiter.api.extension.ExtendWith;

Full Screen

Full Screen

playerListFooter

Using AI Code Generation

copy

Full Screen

1String header = "header";2String footer = "footer";3PlayerMock player = server.addPlayer();4player.setPlayerListHeaderFooter(header, footer);5String[] playerListHeaderFooter = player.getPlayerListHeaderFooter();6String playerListHeader = playerListHeaderFooter[0];7String playerListFooter = playerListHeaderFooter[1];8assertEquals(header, playerListHeader);9assertEquals(footer, playerListFooter);10PlayerMock player = server.addPlayer();11player.setPlayerListHeaderFooter(null, null);12String[] playerListHeaderFooter = player.getPlayerListHeaderFooter();13String playerListHeader = playerListHeaderFooter[0];14String playerListFooter = playerListHeaderFooter[1];15assertEquals(null, playerListHeader);16assertEquals(null, playerListFooter);17PlayerMock player = server.addPlayer();18player.setPlayerListHeaderFooter(null, null);19String[] playerListHeaderFooter = player.getPlayerListHeaderFooter();20String playerListHeader = playerListHeaderFooter[0];21String playerListFooter = playerListHeaderFooter[1];

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.

Most used method in PlayerMock

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful