Best MockBukkit code snippet using be.seeseemelk.mockbukkit.CachedServerIconMock.CachedServerIconMock
Source:ServerMock.java
...164 private final MockCommandMap commandMap = new MockCommandMap(this);165 private final HelpMapMock helpMap = new HelpMapMock();166 private final StandardMessenger messenger = new StandardMessenger();167 private final Map<Integer, MapViewMock> mapViews = new HashMap<>();168 private CachedServerIconMock serverIcon = new CachedServerIconMock(null);169 private int nextMapId = 1;170 private GameMode defaultGameMode = GameMode.SURVIVAL;171 private ConsoleCommandSenderMock consoleSender;172 private int spawnRadius = 16;173 private @NotNull WarningState warningState = WarningState.DEFAULT;174 private boolean isWhitelistEnabled = false;175 private boolean isWhitelistEnforced = false;176 private final @NotNull Set<OfflinePlayer> whitelistedPlayers = new LinkedHashSet<>();177 public ServerMock()178 {179 ServerMock.registerSerializables();180 // Register default Minecraft Potion Effect Types181 createPotionEffectTypes();182 TagsMock.loadDefaultTags(this, true);183 EnchantmentsMock.registerDefaultEnchantments();184 try185 {186 InputStream stream = ClassLoader.getSystemResourceAsStream("logger.properties");187 LogManager.getLogManager().readConfiguration(stream);188 }189 catch (IOException e)190 {191 logger.warning("Could not load file logger.properties");192 }193 logger.setLevel(Level.ALL);194 try195 {196 buildProperties.load(ClassLoader.getSystemResourceAsStream("build.properties"));197 }198 catch (IOException | NullPointerException e)199 {200 logger.warning("Could not load build properties");201 }202 }203 /**204 * Checks if we are on the main thread. The main thread is the thread used to create this instance of the mock205 * server.206 *207 * @return {@code true} if we are on the main thread, {@code false} if we are running on a different thread.208 */209 public boolean isOnMainThread()210 {211 return mainThread.equals(Thread.currentThread());212 }213 /**214 * Registers an entity so that the server can track it more easily. Should only be used internally.215 *216 * @param entity The entity to register217 */218 public void registerEntity(@NotNull EntityMock entity)219 {220 AsyncCatcher.catchOp("entity add");221 entities.add(entity);222 }223 /**224 * Returns a set of entities that exist on the server instance.225 *226 * @return A set of entities that exist on this server instance.227 */228 @NotNull229 public Set<EntityMock> getEntities()230 {231 return Collections.unmodifiableSet(entities);232 }233 /**234 * Add a specific player to the set.235 *236 * @param player The player to add.237 */238 public void addPlayer(@NotNull PlayerMock player)239 {240 AsyncCatcher.catchOp("player add");241 playerList.addPlayer(player);242 CountDownLatch conditionLatch = new CountDownLatch(1);243 InetSocketAddress address = player.getAddress();244 AsyncPlayerPreLoginEvent preLoginEvent = new AsyncPlayerPreLoginEvent(player.getName(),245 address.getAddress(), player.getUniqueId());246 getPluginManager().callEventAsynchronously(preLoginEvent, (e) -> conditionLatch.countDown());247 try248 {249 conditionLatch.await();250 }251 catch (InterruptedException e)252 {253 getLogger().severe("Interrupted while waiting for AsyncPlayerPreLoginEvent! " +254 (StringUtils.isEmpty(e.getMessage()) ? "" : e.getMessage()));255 Thread.currentThread().interrupt();256 }257 PlayerLoginEvent playerLoginEvent = new PlayerLoginEvent(player, address.getHostString(), address.getAddress());258 Bukkit.getPluginManager().callEvent(playerLoginEvent);259 Component joinMessage = MiniMessage.miniMessage()260 .deserialize("<name> has joined the Server!", Placeholder.component("name", player.displayName()));261 PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(player, joinMessage);262 Bukkit.getPluginManager().callEvent(playerJoinEvent);263 if (isWhitelistEnabled && !whitelistedPlayers.contains(player))264 {265 PlayerConnectionCloseEvent playerConnectionCloseEvent =266 new PlayerConnectionCloseEvent(player.getUniqueId(),267 player.getName(),268 player.getAddress().getAddress(),269 false);270 getPluginManager().callEvent(playerConnectionCloseEvent);271 playerList.disconnectPlayer(player);272 return;273 }274 player.setLastPlayed(getCurrentServerTime());275 registerEntity(player);276 }277 /**278 * Creates a random player and adds it.279 *280 * @return The player that was added.281 */282 public @NotNull PlayerMock addPlayer()283 {284 AsyncCatcher.catchOp("player add");285 PlayerMock player = playerFactory.createRandomPlayer();286 addPlayer(player);287 return player;288 }289 /**290 * Creates a player with a given name and adds it.291 *292 * @param name The name to give to the player.293 * @return The added player.294 */295 public @NotNull PlayerMock addPlayer(@NotNull String name)296 {297 AsyncCatcher.catchOp("player add");298 PlayerMock player = new PlayerMock(this, name);299 addPlayer(player);300 return player;301 }302 /**303 * Set the numbers of mock players that are on this server. Note that it will remove all players that are already on304 * this server.305 *306 * @param num The number of players that are on this server.307 */308 public void setPlayers(int num)309 {310 AsyncCatcher.catchOp("set players");311 playerList.clearOnlinePlayers();312 for (int i = 0; i < num; i++)313 addPlayer();314 }315 /**316 * Set the numbers of mock offline players that are on this server. Note that even players that are online are also317 * considered offline player because an {@link OfflinePlayer} really just refers to anyone that has at some point in318 * time played on the server.319 *320 * @param num The number of players that are on this server.321 */322 public void setOfflinePlayers(int num)323 {324 AsyncCatcher.catchOp("set offline players");325 playerList.clearOfflinePlayers();326 for (PlayerMock player : getOnlinePlayers())327 {328 playerList.addPlayer(player);329 }330 for (int i = 0; i < num; i++)331 {332 OfflinePlayer player = playerFactory.createRandomOfflinePlayer();333 playerList.addOfflinePlayer(player);334 }335 }336 /**337 * Get a specific mock player. A player's number will never change between invocations of {@link #setPlayers(int)}.338 *339 * @param num The number of the player to retrieve.340 * @return The chosen player.341 */342 public @NotNull PlayerMock getPlayer(int num)343 {344 return playerList.getPlayer(num);345 }346 /**347 * Returns the {@link MockPlayerList} instance that is used by this server.348 *349 * @return The {@link MockPlayerList} instance.350 */351 public @NotNull MockPlayerList getPlayerList()352 {353 return playerList;354 }355 @Override356 public @Nullable UUID getPlayerUniqueId(@NotNull String playerName)357 {358 return playerList.getOfflinePlayer(playerName).getUniqueId();359 }360 /**361 * Adds a very simple super flat world with a given name.362 *363 * @param name The name to give to the world.364 * @return The {@link WorldMock} that has been created.365 */366 public @NotNull WorldMock addSimpleWorld(String name)367 {368 AsyncCatcher.catchOp("world creation");369 WorldMock world = new WorldMock();370 world.setName(name);371 worlds.add(world);372 return world;373 }374 /**375 * Adds the given mocked world to this server.376 *377 * @param world The world to add.378 */379 public void addWorld(WorldMock world)380 {381 AsyncCatcher.catchOp("world add");382 worlds.add(world);383 }384 /**385 * Executes a command as the console.386 *387 * @param command The command to execute.388 * @param args The arguments to pass to the commands.389 * @return The value returned by {@link Command#execute}.390 */391 public @NotNull CommandResult executeConsole(@NotNull Command command, String... args)392 {393 return execute(command, getConsoleSender(), args);394 }395 /**396 * Executes a command as the console.397 *398 * @param command The command to execute.399 * @param args The arguments to pass to the commands.400 * @return The value returned by {@link Command#execute}.401 */402 public @NotNull CommandResult executeConsole(@NotNull String command, String... args)403 {404 return executeConsole(getCommandMap().getCommand(command), args);405 }406 /**407 * Executes a command as a player.408 *409 * @param command The command to execute.410 * @param args The arguments to pass to the commands.411 * @return The value returned by {@link Command#execute}.412 */413 public @NotNull CommandResult executePlayer(@NotNull Command command, String... args)414 {415 AsyncCatcher.catchOp("command dispatch");416 if (playerList.isSomeoneOnline())417 return execute(command, getPlayer(0), args);418 else419 throw new IllegalStateException("Need at least one player to run the command");420 }421 /**422 * Executes a command as a player.423 *424 * @param command The command to execute.425 * @param args The arguments to pass to the commands.426 * @return The value returned by {@link Command#execute}.427 */428 public @NotNull CommandResult executePlayer(@NotNull String command, String... args)429 {430 return executePlayer(getCommandMap().getCommand(command), args);431 }432 /**433 * Executes a command.434 *435 * @param command The command to execute.436 * @param sender The person that executed the command.437 * @param args The arguments to pass to the commands.438 * @return The value returned by {@link Command#execute}.439 */440 public @NotNull CommandResult execute(@NotNull Command command, CommandSender sender, String... args)441 {442 AsyncCatcher.catchOp("command dispatch");443 if (!(sender instanceof MessageTarget))444 {445 throw new IllegalArgumentException("Only a MessageTarget can be the sender of the command");446 }447 boolean status = command.execute(sender, command.getName(), args);448 return new CommandResult(status, (MessageTarget) sender);449 }450 /**451 * Executes a command.452 *453 * @param command The command to execute.454 * @param sender The person that executed the command.455 * @param args The arguments to pass to the commands.456 * @return The value returned by {@link Command#execute}.457 */458 public @NotNull CommandResult execute(@NotNull String command, CommandSender sender, String... args)459 {460 AsyncCatcher.catchOp("command dispatch");461 return execute(getCommandMap().getCommand(command), sender, args);462 }463 @Override464 public @NotNull String getName()465 {466 return "ServerMock";467 }468 @Override469 public @NotNull String getVersion()470 {471 return String.format("MockBukkit (MC: %s)", getMinecraftVersion());472 }473 @Override474 public @NotNull String getBukkitVersion()475 {476 Preconditions.checkNotNull(this.buildProperties, "Failed to load build properties!");477 String apiVersion = buildProperties.getProperty("full-api-version");478 Preconditions.checkNotNull(apiVersion, "Failed to get full-api-version from the build properties!");479 return apiVersion;480 }481 @Override482 public @NotNull String getMinecraftVersion()483 {484 return this.getBukkitVersion().split("-")[0];485 }486 @Override487 public @NotNull Collection<? extends PlayerMock> getOnlinePlayers()488 {489 return playerList.getOnlinePlayers();490 }491 @Override492 public OfflinePlayer @NotNull [] getOfflinePlayers()493 {494 return playerList.getOfflinePlayers();495 }496 @Override497 public @Nullable OfflinePlayer getOfflinePlayerIfCached(@NotNull String name)498 {499 //TODO Auto-generated method stub500 throw new UnimplementedOperationException();501 }502 @Override503 public Player getPlayer(@NotNull String name)504 {505 return playerList.getPlayer(name);506 }507 @Override508 public Player getPlayerExact(@NotNull String name)509 {510 return playerList.getPlayerExact(name);511 }512 @Override513 public @NotNull List<Player> matchPlayer(@NotNull String name)514 {515 return playerList.matchPlayer(name);516 }517 @Override518 public Player getPlayer(@NotNull UUID id)519 {520 return playerList.getPlayer(id);521 }522 @Override523 public @NotNull PluginManagerMock getPluginManager()524 {525 return pluginManager;526 }527 @NotNull528 public MockCommandMap getCommandMap()529 {530 return commandMap;531 }532 @Override533 public PluginCommand getPluginCommand(@NotNull String name)534 {535 Command command = getCommandMap().getCommand(name);536 return command instanceof PluginCommand ? (PluginCommand) command : null;537 }538 @Override539 public @NotNull Logger getLogger()540 {541 return logger;542 }543 @Override544 public @NotNull ConsoleCommandSenderMock getConsoleSender()545 {546 if (consoleSender == null)547 {548 consoleSender = new ConsoleCommandSenderMock();549 }550 return consoleSender;551 }552 @Override553 public @NotNull CommandSender createCommandSender(@NotNull Consumer<? super Component> feedback)554 {555 //TODO Auto-generated method stub556 throw new UnimplementedOperationException();557 }558 @NotNull559 @Deprecated560 public InventoryMock createInventory(InventoryHolder owner, @NotNull InventoryType type, String title, int size)561 {562 if (!type.isCreatable())563 {564 throw new IllegalArgumentException("Inventory Type is not creatable!");565 }566 switch (type)567 {568 case CHEST:569 return new ChestInventoryMock(owner, size > 0 ? size : 9 * 3);570 case DISPENSER:571 return new DispenserInventoryMock(owner);572 case DROPPER:573 return new DropperInventoryMock(owner);574 case PLAYER:575 if (owner instanceof HumanEntity)576 {577 return new PlayerInventoryMock((HumanEntity) owner);578 }579 else580 {581 throw new IllegalArgumentException("Cannot create a Player Inventory for: " + owner);582 }583 case ENDER_CHEST:584 return new EnderChestInventoryMock(owner);585 case HOPPER:586 return new HopperInventoryMock(owner);587 case SHULKER_BOX:588 return new ShulkerBoxInventoryMock(owner);589 case BARREL:590 return new BarrelInventoryMock(owner);591 case LECTERN:592 return new LecternInventoryMock(owner);593 case GRINDSTONE:594 return new GrindstoneInventoryMock(owner);595 case STONECUTTER:596 return new StonecutterInventoryMock(owner);597 case CARTOGRAPHY:598 return new CartographyInventoryMock(owner);599 case SMOKER, FURNACE, BLAST_FURNACE:600 return new FurnaceInventoryMock(owner);601 case LOOM:602 return new LoomInventoryMock(owner);603 case ANVIL:604 return new AnvilInventoryMock(owner);605 case SMITHING:606 return new SmithingInventoryMock(owner);607 case BEACON:608 return new BeaconInventoryMock(owner);609 case WORKBENCH:610 return new WorkbenchInventoryMock(owner);611 case ENCHANTING:612 return new EnchantingInventoryMock(owner);613 case BREWING:614 return new BrewerInventoryMock(owner);615 default:616 throw new UnimplementedOperationException("Inventory type not yet supported");617 }618 }619 @Override620 public @NotNull InventoryMock createInventory(InventoryHolder owner, @NotNull InventoryType type)621 {622 return createInventory(owner, type, "Inventory");623 }624 @Override625 public @NotNull InventoryMock createInventory(@Nullable InventoryHolder owner, @NotNull InventoryType type, @NotNull Component title)626 {627 //TODO Auto-generated method stub628 throw new UnimplementedOperationException();629 }630 @Override631 @Deprecated632 public @NotNull InventoryMock createInventory(InventoryHolder owner, @NotNull InventoryType type, String title)633 {634 return createInventory(owner, type, title, -1);635 }636 @Override637 public @NotNull InventoryMock createInventory(InventoryHolder owner, int size)638 {639 return createInventory(owner, size, "Inventory");640 }641 @Override642 public @NotNull InventoryMock createInventory(@Nullable InventoryHolder owner, int size, @NotNull Component title) throws IllegalArgumentException643 {644 //TODO Auto-generated method stub645 throw new UnimplementedOperationException();646 }647 @Override648 @Deprecated649 public @NotNull InventoryMock createInventory(InventoryHolder owner, int size, String title)650 {651 return createInventory(owner, InventoryType.CHEST, title, size);652 }653 @Override654 public @NotNull Merchant createMerchant(@Nullable Component title)655 {656 //TODO Auto-generated method stub657 throw new UnimplementedOperationException();658 }659 @Override660 public @NotNull ItemFactoryMock getItemFactory()661 {662 return factory;663 }664 @Override665 public @NotNull List<World> getWorlds()666 {667 return new ArrayList<>(worlds);668 }669 @Override670 public World getWorld(String name)671 {672 return worlds.stream().filter(world -> world.getName().equals(name)).findAny().orElse(null);673 }674 @Override675 public World getWorld(UUID uid)676 {677 return worlds.stream().filter(world -> world.getUID().equals(uid)).findAny().orElse(null);678 }679 @Override680 public @Nullable World getWorld(@NotNull NamespacedKey worldKey)681 {682 // TODO Auto-generated method stub683 throw new UnimplementedOperationException();684 }685 @NotNull686 @Override687 public WorldBorder createWorldBorder()688 {689 // TODO Auto-generated method stub690 throw new UnimplementedOperationException();691 }692 @Override693 public @NotNull BukkitSchedulerMock getScheduler()694 {695 return scheduler;696 }697 @Override698 public int getMaxPlayers()699 {700 return playerList.getMaxPlayers();701 }702 @Override703 public void setMaxPlayers(int maxPlayers)704 {705 playerList.setMaxPlayers(maxPlayers);706 }707 @Override708 public @NotNull Set<String> getIPBans()709 {710 return this.playerList.getIPBans().getBanEntries().stream().map(BanEntry::getTarget)711 .collect(Collectors.toSet());712 }713 @Override714 public void banIP(@NotNull String address)715 {716 this.playerList.getIPBans().addBan(address, null, null, null);717 }718 @Override719 public void unbanIP(@NotNull String address)720 {721 this.playerList.getIPBans().pardon(address);722 }723 @Override724 public @NotNull BanList getBanList(@NotNull Type type)725 {726 return switch (type)727 {728 case IP -> playerList.getIPBans();729 case NAME -> playerList.getProfileBans();730 };731 }732 @Override733 public @NotNull Set<OfflinePlayer> getOperators()734 {735 return playerList.getOperators();736 }737 @Override738 public @NotNull GameMode getDefaultGameMode()739 {740 return this.defaultGameMode;741 }742 @Override743 public void setDefaultGameMode(GameMode mode)744 {745 this.defaultGameMode = mode;746 }747 @Override748 @Deprecated749 public int broadcastMessage(@NotNull String message)750 {751 Collection<? extends PlayerMock> players = getOnlinePlayers();752 for (Player player : players)753 {754 player.sendMessage(message);755 }756 return players.size();757 }758 @Override759 @Deprecated760 public int broadcast(@NotNull String message, @NotNull String permission)761 {762 Collection<? extends PlayerMock> players = getOnlinePlayers();763 int count = 0;764 for (Player player : players)765 {766 if (player.hasPermission(permission))767 {768 player.sendMessage(message);769 count++;770 }771 }772 return count;773 }774 @Override775 public int broadcast(@NotNull Component message)776 {777 Collection<? extends PlayerMock> players = getOnlinePlayers();778 for (Player player : players)779 {780 player.sendMessage(message);781 }782 return players.size();783 }784 @Override785 public int broadcast(@NotNull Component message, @NotNull String permission)786 {787 Collection<? extends PlayerMock> players = getOnlinePlayers();788 int count = 0;789 for (Player player : players)790 {791 if (player.hasPermission(permission))792 {793 player.sendMessage(message);794 count++;795 }796 }797 return count;798 }799 /**800 * Registers any classes that are serializable with the ConfigurationSerializable system of Bukkit.801 */802 public static void registerSerializables()803 {804 ConfigurationSerialization.registerClass(ItemMetaMock.class);805 }806 @Override807 public boolean addRecipe(Recipe recipe)808 {809 recipes.add(recipe);810 return true;811 }812 @Override813 public @NotNull List<Recipe> getRecipesFor(@NotNull ItemStack item)814 {815 return recipes.stream().filter(recipe ->816 {817 ItemStack result = recipe.getResult();818 // Amount is explicitly ignored here819 return result.getType() == item.getType() && result.getItemMeta().equals(item.getItemMeta());820 }).collect(Collectors.toList());821 }822 @Override823 public Recipe getRecipe(NamespacedKey key)824 {825 for (Recipe recipe : recipes)826 {827 // Seriously why can't the Recipe interface itself just extend Keyed...828 if (recipe instanceof Keyed && ((Keyed) recipe).getKey().equals(key))829 {830 return recipe;831 }832 }833 return null;834 }835 @Nullable836 @Override837 public Recipe getCraftingRecipe(@NotNull ItemStack[] craftingMatrix, @NotNull World world)838 {839 // TODO Auto-generated method stub840 throw new UnimplementedOperationException();841 }842 @NotNull843 @Override844 public ItemStack craftItem(@NotNull ItemStack[] craftingMatrix, @NotNull World world, @NotNull Player player)845 {846 // TODO Auto-generated method stub847 throw new UnimplementedOperationException();848 }849 @Override850 public boolean removeRecipe(NamespacedKey key)851 {852 Iterator<Recipe> iterator = recipeIterator();853 while (iterator.hasNext())854 {855 Recipe recipe = iterator.next();856 // Seriously why can't the Recipe interface itself just extend Keyed...857 if (recipe instanceof Keyed && ((Keyed) recipe).getKey().equals(key))858 {859 iterator.remove();860 return true;861 }862 }863 return false;864 }865 @Override866 public @NotNull Iterator<Recipe> recipeIterator()867 {868 return recipes.iterator();869 }870 @Override871 public void clearRecipes()872 {873 recipes.clear();874 }875 @Override876 public boolean dispatchCommand(@NotNull CommandSender sender, @NotNull String commandLine)877 {878 AsyncCatcher.catchOp("command dispatch");879 String[] commands = commandLine.split(" ");880 String commandLabel = commands[0];881 String[] args = Arrays.copyOfRange(commands, 1, commands.length);882 Command command = getCommandMap().getCommand(commandLabel);883 if (command != null)884 {885 return command.execute(sender, commandLabel, args);886 }887 else888 {889 return false;890 }891 }892 public @NotNull List<String> getCommandTabComplete(@NotNull CommandSender sender, @NotNull String commandLine)893 {894 AsyncCatcher.catchOp("command tabcomplete");895 int idx = commandLine.indexOf(' ');896 String commandLabel = commandLine.substring(0, idx);897 String[] args = commandLine.substring(idx + 1).split(" ", -1);898 Command command = getCommandMap().getCommand(commandLabel);899 if (command != null)900 {901 return command.tabComplete(sender, commandLabel, args);902 }903 else904 {905 return Collections.emptyList();906 }907 }908 @Override909 public @NotNull HelpMapMock getHelpMap()910 {911 return helpMap;912 }913 @Override914 public void sendPluginMessage(@NotNull Plugin source, @NotNull String channel, byte[] message)915 {916 StandardMessenger.validatePluginMessage(this.getMessenger(), source, channel, message);917 for (Player player : this.getOnlinePlayers())918 {919 player.sendPluginMessage(source, channel, message);920 }921 }922 @Override923 public @NotNull Set<String> getListeningPluginChannels()924 {925 Set<String> result = new HashSet<>();926 for (Player player : this.getOnlinePlayers())927 {928 result.addAll(player.getListeningPluginChannels());929 }930 return result;931 }932 @Override933 public int getPort()934 {935 // TODO Auto-generated method stub936 throw new UnimplementedOperationException();937 }938 @Override939 public int getViewDistance()940 {941 // TODO Auto-generated method stub942 throw new UnimplementedOperationException();943 }944 @Override945 public @NotNull String getIp()946 {947 // TODO Auto-generated method stub948 throw new UnimplementedOperationException();949 }950 @Override951 public @NotNull String getWorldType()952 {953 // TODO Auto-generated method stub954 throw new UnimplementedOperationException();955 }956 @Override957 public boolean getGenerateStructures()958 {959 // TODO Auto-generated method stub960 throw new UnimplementedOperationException();961 }962 @Override963 public boolean getAllowEnd()964 {965 // TODO Auto-generated method stub966 throw new UnimplementedOperationException();967 }968 @Override969 public boolean getAllowNether()970 {971 // TODO Auto-generated method stub972 throw new UnimplementedOperationException();973 }974 @NotNull975 @Override976 public String getResourcePack()977 {978 // TODO Auto-generated method stub979 throw new UnimplementedOperationException();980 }981 @NotNull982 @Override983 public String getResourcePackHash()984 {985 // TODO Auto-generated method stub986 throw new UnimplementedOperationException();987 }988 @NotNull989 @Override990 public String getResourcePackPrompt()991 {992 // TODO Auto-generated method stub993 throw new UnimplementedOperationException();994 }995 @Override996 public boolean isResourcePackRequired()997 {998 // TODO Auto-generated method stub999 throw new UnimplementedOperationException();1000 }1001 @Override1002 public boolean hasWhitelist()1003 {1004 return this.isWhitelistEnabled;1005 }1006 @Override1007 public void setWhitelist(boolean value)1008 {1009 this.isWhitelistEnabled = value;1010 WhitelistToggleEvent event = new WhitelistToggleEvent(value);1011 this.getPluginManager().callEvent(event);1012 }1013 @Override1014 public boolean isWhitelistEnforced()1015 {1016 return this.isWhitelistEnforced;1017 }1018 @Override1019 public void setWhitelistEnforced(boolean value)1020 {1021 this.isWhitelistEnforced = value;1022 }1023 @Override1024 public @NotNull Set<OfflinePlayer> getWhitelistedPlayers()1025 {1026 return this.whitelistedPlayers;1027 }1028 @Override1029 public void reloadWhitelist()1030 {1031 //Pretend we load the Whitelist from Disk1032 if (!isWhitelistEnforced && isWhitelistEnabled)1033 {1034 return;1035 }1036 MockBukkit.getMock().getOnlinePlayers().forEach(p ->1037 {1038 if (!MockBukkit.getMock().getWhitelistedPlayers().contains(p))1039 {1040 p.kick();1041 }1042 });1043 }1044 @Override1045 public @NotNull String getUpdateFolder()1046 {1047 // TODO Auto-generated method stub1048 throw new UnimplementedOperationException();1049 }1050 @Override1051 public @NotNull File getUpdateFolderFile()1052 {1053 // TODO Auto-generated method stub1054 throw new UnimplementedOperationException();1055 }1056 @Override1057 public long getConnectionThrottle()1058 {1059 // TODO Auto-generated method stub1060 throw new UnimplementedOperationException();1061 }1062 @Override1063 @Deprecated1064 public int getTicksPerAnimalSpawns()1065 {1066 // TODO Auto-generated method stub1067 throw new UnimplementedOperationException();1068 }1069 @Override1070 @Deprecated1071 public int getTicksPerMonsterSpawns()1072 {1073 // TODO Auto-generated method stub1074 throw new UnimplementedOperationException();1075 }1076 @Override1077 public @NotNull ServicesManagerMock getServicesManager()1078 {1079 return servicesManager;1080 }1081 @Override1082 public World createWorld(@NotNull WorldCreator creator)1083 {1084 WorldMock world = new WorldMock(creator);1085 addWorld(world);1086 return world;1087 }1088 @Override1089 public boolean unloadWorld(String name, boolean save)1090 {1091 // TODO Auto-generated method stub1092 throw new UnimplementedOperationException();1093 }1094 @Override1095 public boolean unloadWorld(World world, boolean save)1096 {1097 // TODO Auto-generated method stub1098 throw new UnimplementedOperationException();1099 }1100 @Override1101 public @NotNull MapViewMock createMap(@NotNull World world)1102 {1103 MapViewMock mapView = new MapViewMock(world, nextMapId++);1104 mapViews.put(mapView.getId(), mapView);1105 new MapInitializeEvent(mapView).callEvent();1106 return mapView;1107 }1108 @Override1109 public void reload()1110 {1111 // TODO Auto-generated method stub1112 throw new UnimplementedOperationException();1113 }1114 @Override1115 public void reloadData()1116 {1117 // TODO Auto-generated method stub1118 throw new UnimplementedOperationException();1119 }1120 @Override1121 public void savePlayers()1122 {1123 // TODO Auto-generated method stub1124 throw new UnimplementedOperationException();1125 }1126 @Override1127 public void resetRecipes()1128 {1129 // TODO Auto-generated method stub1130 throw new UnimplementedOperationException();1131 }1132 @Override1133 public @NotNull Map<String, String[]> getCommandAliases()1134 {1135 // TODO Auto-generated method stub1136 throw new UnimplementedOperationException();1137 }1138 @Override1139 public int getSpawnRadius()1140 {1141 return spawnRadius;1142 }1143 @Override1144 public void setSpawnRadius(int spawnRadius)1145 {1146 this.spawnRadius = spawnRadius;1147 }1148 @Override1149 public boolean shouldSendChatPreviews()1150 {1151 // TODO Auto-generated method stub1152 throw new UnimplementedOperationException();1153 }1154 @Override1155 public boolean isEnforcingSecureProfiles()1156 {1157 // TODO Auto-generated method stub1158 throw new UnimplementedOperationException();1159 }1160 @Override1161 public boolean getOnlineMode()1162 {1163 // TODO Auto-generated method stub1164 throw new UnimplementedOperationException();1165 }1166 @Override1167 public boolean getAllowFlight()1168 {1169 // TODO Auto-generated method stub1170 throw new UnimplementedOperationException();1171 }1172 @Override1173 public boolean isHardcore()1174 {1175 // TODO Auto-generated method stub1176 throw new UnimplementedOperationException();1177 }1178 @Override1179 public void shutdown()1180 {1181 // TODO Auto-generated method stub1182 throw new UnimplementedOperationException();1183 }1184 @Override1185 @Deprecated1186 public @NotNull OfflinePlayer getOfflinePlayer(@NotNull String name)1187 {1188 return playerList.getOfflinePlayer(name);1189 }1190 @Override1191 public @NotNull OfflinePlayer getOfflinePlayer(@NotNull UUID id)1192 {1193 OfflinePlayer player = playerList.getOfflinePlayer(id);1194 if (player != null)1195 {1196 return player;1197 }1198 else1199 {1200 return playerFactory.createOfflinePlayer(id);1201 }1202 }1203 @Override1204 public @NotNull Set<OfflinePlayer> getBannedPlayers()1205 {1206 return this.getBanList(Type.NAME)1207 .getBanEntries()1208 .stream()1209 .map(banEntry -> getOfflinePlayer(banEntry.getTarget()))1210 .collect(Collectors.toSet());1211 }1212 @Override1213 public @NotNull File getWorldContainer()1214 {1215 // TODO Auto-generated method stub1216 throw new UnimplementedOperationException();1217 }1218 @Override1219 public @NotNull Messenger getMessenger()1220 {1221 return this.messenger;1222 }1223 @Override1224 @Deprecated1225 public @NotNull Merchant createMerchant(String title)1226 {1227 // TODO Auto-generated method stub1228 throw new UnimplementedOperationException();1229 }1230 @Override1231 public int getMaxChainedNeighborUpdates()1232 {1233 //TODO Auto-generated method stub1234 throw new UnimplementedOperationException();1235 }1236 @Override1237 @Deprecated1238 public int getMonsterSpawnLimit()1239 {1240 // TODO Auto-generated method stub1241 throw new UnimplementedOperationException();1242 }1243 @Override1244 @Deprecated1245 public int getAnimalSpawnLimit()1246 {1247 // TODO Auto-generated method stub1248 throw new UnimplementedOperationException();1249 }1250 @Override1251 @Deprecated1252 public int getWaterAnimalSpawnLimit()1253 {1254 // TODO Auto-generated method stub1255 throw new UnimplementedOperationException();1256 }1257 @Override1258 @Deprecated1259 public int getAmbientSpawnLimit()1260 {1261 // TODO Auto-generated method stub1262 throw new UnimplementedOperationException();1263 }1264 @Override1265 public boolean isPrimaryThread()1266 {1267 return this.isOnMainThread();1268 }1269 @Override1270 public @NotNull Component motd()1271 {1272 return MOTD;1273 }1274 @Override1275 @Deprecated1276 public @NotNull String getMotd()1277 {1278 return LegacyComponentSerializer.legacySection().serialize(MOTD);1279 }1280 @Override1281 public @Nullable Component shutdownMessage()1282 {1283 // TODO Auto-generated method stub1284 throw new UnimplementedOperationException();1285 }1286 @Override1287 @Deprecated1288 public String getShutdownMessage()1289 {1290 // TODO Auto-generated method stub1291 throw new UnimplementedOperationException();1292 }1293 /**1294 * Sets the return value of {@link #getWarningState}.1295 *1296 * @param warningState The {@link WarningState} to set.1297 */1298 public void setWarningState(@NotNull WarningState warningState)1299 {1300 Preconditions.checkNotNull(warningState, "warningState cannot be null");1301 this.warningState = warningState;1302 }1303 @Override1304 public @NotNull WarningState getWarningState()1305 {1306 return this.warningState;1307 }1308 @Override1309 public @NotNull ScoreboardManagerMock getScoreboardManager()1310 {1311 return scoreboardManager;1312 }1313 @Override1314 public @NotNull Criteria getScoreboardCriteria(@NotNull String name)1315 {1316 // TODO Auto-generated method stub1317 throw new UnimplementedOperationException();1318 }1319 /**1320 * Sets the return value of {@link #getServerIcon()}.1321 *1322 * @param serverIcon The icon to set.1323 */1324 public void setServerIcon(CachedServerIconMock serverIcon)1325 {1326 this.serverIcon = serverIcon;1327 }1328 @Override1329 public CachedServerIconMock getServerIcon()1330 {1331 return this.serverIcon;1332 }1333 @Override1334 public @NotNull CachedServerIconMock loadServerIcon(@NotNull File file) throws IOException1335 {1336 Preconditions.checkNotNull(file, "File cannot be null");1337 Preconditions.checkArgument(file.isFile(), file + " isn't a file");1338 return loadServerIcon(ImageIO.read(file));1339 }1340 @Override1341 public @NotNull CachedServerIconMock loadServerIcon(@NotNull BufferedImage image) throws IOException1342 {1343 Preconditions.checkNotNull(image, "Image cannot be null");1344 Preconditions.checkArgument(image.getWidth() == 64, "Image must be 64 pixels wide");1345 Preconditions.checkArgument(image.getHeight() == 64, "Image must be 64 pixels high");1346 ByteArrayOutputStream out = new ByteArrayOutputStream();1347 ImageIO.write(image, "PNG", out);1348 String encoded = Base64.getEncoder().encodeToString(out.toByteArray());1349 return new CachedServerIconMock(CachedServerIconMock.PNG_BASE64_PREFIX + encoded);1350 }1351 @Override1352 public void setIdleTimeout(int threshold)1353 {1354 // TODO Auto-generated method stub1355 throw new UnimplementedOperationException();1356 }1357 @Override1358 public int getIdleTimeout()1359 {1360 // TODO Auto-generated method stub1361 throw new UnimplementedOperationException();1362 }1363 @Override...
Source:CachedServerIconMockTest.java
...4import org.junit.jupiter.api.Test;5import static org.junit.jupiter.api.Assertions.assertEquals;6import static org.junit.jupiter.api.Assertions.assertNotNull;7import static org.junit.jupiter.api.Assertions.assertNull;8class CachedServerIconMockTest9{10 private ServerMock mock;11 @BeforeEach12 public void setUp()13 {14 mock = MockBukkit.mock();15 }16 @AfterEach17 public void teardown()18 {19 MockBukkit.unmock();20 }21 @Test22 void constructor_NotNull_SetsData()23 {24 CachedServerIconMock icon = new CachedServerIconMock(null);25 assertNull(icon.getData());26 }27 @Test28 void constructor_WithData_SetsData()29 {30 CachedServerIconMock icon = new CachedServerIconMock("mmm yes data");31 assertNotNull(icon.getData());32 assertEquals("mmm yes data", icon.getData());33 }34}
Source:CachedServerIconMock.java
1package be.seeseemelk.mockbukkit;2import org.bukkit.util.CachedServerIcon;3import org.jetbrains.annotations.Nullable;4public class CachedServerIconMock implements CachedServerIcon5{6 public static final String PNG_BASE64_PREFIX = "data:image/png;base64,";7 private final @Nullable String data;8 protected CachedServerIconMock(@Nullable String data)9 {10 this.data = data;11 }12 @Override13 public @Nullable String getData()14 {15 return this.data;16 }17}...
CachedServerIconMock
Using AI Code Generation
1import be.seeseemelk.mockbukkit.MockBukkit;2import be.seeseemelk.mockbukkit.ServerMock;3import be.seeseemelk.mockbukkit.entity.PlayerMock;4import be.seeseemelk.mockbukkit.entity.PlayerMockFactory;5import org.junit.jupiter.api.AfterEach;6import org.junit.jupiter.api.BeforeEach;7import org.junit.jupiter.api.Test;8import org.junit.jupiter.api.TestInstance;9import org.junit.jupiter.api.TestInstance.Lifecycle;10import org.junit.jupiter.api.extension.ExtendWith;11import org.mockito.Mock;12import org.mockito.junit.jupiter.MockitoExtension;13import static org.junit.jupiter.api.Assertions.assertEquals;14import static org.junit.jupiter.api.Assertions.assertNotNull;15import static org.mockito.Mockito.when;16@ExtendWith(MockitoExtension.class)17@TestInstance(Lifecycle.PER_CLASS)18{19 private ServerMock server;20 private PlayerMock player;21 public void setUp()22 {23 server = MockBukkit.mock();24 player = server.addPlayer();25 }26 public void tearDown()27 {28 MockBukkit.unmock();29 }30 public void testCachedServerIconMock()31 {32 assertNotNull(player);33 player.setServerIcon(new CachedServerIconMock());34 assertEquals(new CachedServerIconMock(), player.getServerIcon());35 }36 public void testCachedServerIconMockWithMockito()37 {38 assertNotNull(player);39 CachedServerIconMock icon = new CachedServerIconMock();40 player.setServerIcon(icon);41 assertEquals(icon, player.getServerIcon());42 }43}44import be.seeseemelk.mockbukkit.MockBukkit;45import be.seeseemelk.mockbukkit.ServerMock;46import be.seeseemelk.mockbukkit.entity.PlayerMock;47import be.seeseemelk.mockbukkit.entity.PlayerMockFactory;48import org.junit.jupiter.api.AfterEach;49import org.junit.jupiter.api.BeforeEach;50import org.junit.jupiter.api.Test;51import org.junit.jupiter.api.TestInstance;52import org.junit.jupiter.api.TestInstance.Lifecycle;53import org.junit.jupiter.api.extension.ExtendWith;54import org.mockito.Mock;55import org.mockito.junit.jupiter.MockitoExtension;56import static org.junit.jupiter.api.Assertions.assertEquals;57import static org.junit.jupiter.api.Assertions.assertNotNull;
CachedServerIconMock
Using AI Code Generation
1import be.seeseemelk.mockbukkit.CachedServerIconMock;2import be.seeseemelk.mockbukkit.MockBukkit;3import be.seeseemelk.mockbukkit.ServerMock;4import be.seeseemelk.mockbukkit.entity.PlayerMock;5import be.seeseemelk.mockbukkit.scheduler.BukkitSchedulerMock;6import org.bukkit.Bukkit;7import org.bukkit.entity.Player;8import org.bukkit.scheduler.BukkitScheduler;9import org.junit.jupiter.api.AfterEach;10import org.junit.jupiter.api.BeforeEach;11import org.junit.jupiter.api.Test;12import java.io.File;13import java.io.IOException;14import static org.junit.jupiter.api.Assertions.assertEquals;15import static org.junit.jupiter.api.Assertions.assertNotNull;16import static org.junit.jupiter.api.Assertions.assertTrue;17public class CachedServerIconMockTest {18 private ServerMock server;19 private BukkitScheduler scheduler;20 public void setUp() {21 server = MockBukkit.mock();22 scheduler = server.getScheduler();23 }24 public void tearDown() {25 MockBukkit.unmock();26 }27 public void testCachedServerIconMock() {28 CachedServerIconMock icon = new CachedServerIconMock();29 assertNotNull(icon);30 }31 public void testCachedServerIconMockFile() throws IOException {32 File file = new File("src/test/resources/icon.png");33 assertTrue(file.exists());34 CachedServerIconMock icon = new CachedServerIconMock(file);35 assertNotNull(icon);36 }37 public void testLoadAsync() {38 CachedServerIconMock icon = new CachedServerIconMock();39 icon.loadAsync(server);40 scheduler.advanceTime(1);41 assertTrue(icon.isLoaded());42 }43 public void testLoadAsyncPlayer() {44 CachedServerIconMock icon = new CachedServerIconMock();45 icon.loadAsync(server);46 scheduler.advanceTime(1);47 assertTrue(icon.isLoaded());48 PlayerMock player = server.addPlayer();49 player.setServerIcon(icon);50 assertEquals(icon, player.getServerIcon());51 }52 public void testLoadAsyncPlayerScheduler() {53 CachedServerIconMock icon = new CachedServerIconMock();54 icon.loadAsync(server);55 scheduler.advanceTime(1);56 assertTrue(icon.isLoaded());57 PlayerMock player = server.addPlayer();58 player.setServerIcon(icon);59 assertEquals(icon, player.getServerIcon());
CachedServerIconMock
Using AI Code Generation
1{2 private final BufferedImage image;3 public CachedServerIconMock(BufferedImage image)4 {5 this.image = image;6 }7 public BufferedImage getImage()8 {9 return image;10 }11}12{13 private final BufferedImage image;14 public CachedServerIconMock(BufferedImage image)15 {16 this.image = image;17 }18 public BufferedImage getImage()19 {20 return image;21 }22}23{24 private final BufferedImage image;25 public CachedServerIconMock(BufferedImage image)26 {27 this.image = image;28 }29 public BufferedImage getImage()30 {31 return image;32 }33}34{35 private final BufferedImage image;36 public CachedServerIconMock(BufferedImage image)37 {38 this.image = image;39 }40 public BufferedImage getImage()41 {42 return image;43 }44}45{46 private final BufferedImage image;47 public CachedServerIconMock(BufferedImage image)48 {49 this.image = image;50 }51 public BufferedImage getImage()52 {53 return image;54 }55}56{57 private final BufferedImage image;58 public CachedServerIconMock(BufferedImage image)59 {60 this.image = image;61 }62 public BufferedImage getImage()63 {64 return image;
CachedServerIconMock
Using AI Code Generation
1import be.seeseemelk.mockbukkit.CachedServerIconMock;2import org.bukkit.Server;3import org.bukkit.entity.Player;4import org.bukkit.plugin.Plugin;5import org.bukkit.plugin.PluginDescriptionFile;6import org.bukkit.plugin.PluginLoader;7import org.bukkit.plugin.PluginManager;8import org.bukkit.plugin.UnknownDependencyException;9import org.bukkit.plugin.java.JavaPluginLoader;10import org.bukkit.scheduler.BukkitScheduler;11import org.bukkit.scheduler.BukkitTask;12import org.junit.Assert;13import org.junit.Before;14import org.junit.Test;15import org.junit.runner.RunWith;16import org.mockito.Mock;17import org.mockito.MockitoAnnotations;18import org.mockito.junit.MockitoJUnitRunner;19@RunWith(MockitoJUnitRunner.class)20public class CachedServerIconMockTest {21 private PluginManager pluginManager;22 private BukkitScheduler scheduler;23 private PluginLoader pluginLoader;24 private PluginDescriptionFile description;25 private JavaPluginLoader javaPluginLoader;26 private Plugin plugin;27 private BukkitTask bukkitTask;28 private Player player;29 private Server server;30 public void setUp() {31 MockitoAnnotations.initMocks(this);32 server = new ServerMock(pluginManager, scheduler, pluginLoader, description, javaPluginLoader, plugin, bukkitTask, player);33 }34 public void testCachedServerIconMock() {35 CachedServerIconMock cachedServerIconMock = new CachedServerIconMock();36 Assert.assertNotNull(cachedServerIconMock);37 }38}39import be.seeseemelk.mockbukkit.CachedServerIconMock;40import org.bukkit.Server;41import org.bukkit.entity.Player;42import org.bukkit.plugin.Plugin;43import org.bukkit.plugin.PluginDescriptionFile;44import org.bukkit.plugin.PluginLoader;45import org.bukkit.plugin.PluginManager;46import org.bukkit.plugin.UnknownDependencyException;47import org.bukkit.plugin.java.JavaPluginLoader;48import org.bukkit.scheduler.BukkitScheduler;49import org.bukkit.scheduler.BukkitTask;50import org.junit.Assert;51import org.junit.Before;52import org.junit.Test;53import org.junit.runner.RunWith;54import org.mockito.Mock;55import org.mockito.MockitoAnnotations;56import org.mockito.junit.MockitoJUnitRunner;57@RunWith(MockitoJUnitRunner.class)
CachedServerIconMock
Using AI Code Generation
1package com.example;2import org.bukkit.Server;3import org.bukkit.entity.Player;4import org.bukkit.event.EventHandler;5import org.bukkit.event.Listener;6import org.bukkit.event.player.PlayerJoinEvent;7import org.bukkit.plugin.java.JavaPlugin;8import org.jetbrains.annotations.NotNull;9import be.seeseemelk.mockbukkit.CachedServerIconMock;10public class Main extends JavaPlugin implements Listener {11 public void onEnable() {12 getServer().getPluginManager().registerEvents(this, this);13 }14 public void onPlayerJoin(PlayerJoinEvent event) {15 Player player = event.getPlayer();16 Server server = getServer();17 CachedServerIconMock serverIcon = new CachedServerIconMock();18 server.setIcon(serverIcon);19 }20}
CachedServerIconMock
Using AI Code Generation
1package org.example;2import org.bukkit.Bukkit;3import org.bukkit.Server;4import org.bukkit.entity.Player;5import org.junit.jupiter.api.BeforeEach;6import org.junit.jupiter.api.Test;7import org.junit.jupiter.api.extension.ExtendWith;8import org.mockito.Mock;9import org.mockito.junit.jupiter.MockitoExtension;10import be.seeseemelk.mockbukkit.MockBukkit;11import be.seeseemelk.mockbukkit.ServerMock;12import be.seeseemelk.mockbukkit.entity.PlayerMock;13import be.seeseemelk.mockbukkit.entity.PlayerMockFactory;14import be.seeseemelk.mockbukkit.scheduler.BukkitSchedulerMock;15import be.seeseemelk.mockbukkit.scheduler.BukkitTaskMock;16import be.seeseemelk.mockbukkit.scheduler.SchedulerMock;17import static org.junit.jupiter.api.Assertions.*;18import static org.mockito.Mockito.*;19@ExtendWith(MockitoExtension.class)20public class TestCachedServerIconMock {21 private PlayerMockFactory playerFactory;22 private PlayerMock player;23 private ServerMock server;24 private BukkitSchedulerMock scheduler;25 private BukkitTaskMock task;26 public void setUp() {27 MockBukkit.mock();28 server = MockBukkit.getMock();29 player = server.addPlayer();30 scheduler = server.getScheduler();31 task = scheduler.runTaskTimer(null, null, 0, 0);32 }33 public void testCachedServerIconMock() {34 CachedServerIconMock cachedServerIconMock = new CachedServerIconMock();35 assertSame(cachedServerIconMock, cachedServerIconMock.getCachedServerIconMock());36 }37}38package org.example;39import org.bukkit.Bukkit;40import org.bukkit.Server;41import org.bukkit.entity.Player;42import org.junit.jupiter.api.BeforeEach;43import org.junit.jupiter.api.Test;44import org.junit.jupiter.api.extension.ExtendWith;45import org.mockito.Mock;46import org.mockito.junit.jupiter.MockitoExtension;47import be.seeseemelk.mockbukkit.MockBukkit;48import be.seeseemelk.mockbukkit.ServerMock;49import be.seeseemelk.mockbukkit.entity.PlayerMock;50import be.seeseemelk.mockb
CachedServerIconMock
Using AI Code Generation
1{2 public void test()3 {4 Server server = MockBukkit.mock();5 CachedServerIconMock icon = new CachedServerIconMock();6 server.loadServerIcon(icon);7 assertNotNull(server.getServerIcon());8 }9}10{11 public void test()12 {13 Server server = MockBukkit.mock();14 assertNotNull(server.getServerIcon());15 }16}17{18 public void test()19 {20 Server server = MockBukkit.mock();21 assertNotNull(server.getServerIcon());22 }23}24{25 public void test()26 {27 Server server = MockBukkit.mock();28 assertNotNull(server.getServerIcon());29 }30}31{32 public void test()33 {34 Server server = MockBukkit.mock();35 assertNotNull(server.getServerIcon());36 }37}38{39 public void test()40 {41 Server server = MockBukkit.mock();42 assertNotNull(server.getServerIcon());43 }44}45{46 public void test()47 {48 Server server = MockBukkit.mock();49 assertNotNull(server.getServerIcon());50 }51}52{53 public void test()54 {55 Server server = MockBukkit.mock();
CachedServerIconMock
Using AI Code Generation
1import org.bukkit.Bukkit;2import org.bukkit.Server;3import org.bukkit.plugin.Plugin;4import org.bukkit.plugin.java.JavaPlugin;5import org.bukkit.util.CachedServerIcon;6import be.seeseemelk.mockbukkit.CachedServerIconMock;7public class Main extends JavaPlugin {8 private static Plugin plugin;9 public void onEnable() {10 plugin = this;11 Server server = Bukkit.getServer();12 CachedServerIcon icon = CachedServerIconMock.createMockIcon();13 server.setServerIcon(icon);14 }15}16import org.bukkit.Bukkit;17import org.bukkit.Server;18import org.bukkit.plugin.Plugin;19import org.bukkit.plugin.java.JavaPlugin;20import org.bukkit.util.CachedServerIcon;21import be.seeseemelk.mockbukkit.CachedServerIconMock;22public class Main extends JavaPlugin {23 private static Plugin plugin;24 public void onEnable() {25 plugin = this;26 Server server = Bukkit.getServer();27 CachedServerIcon icon = CachedServerIconMock.createMockIcon();28 server.setServerIcon(icon);29 }30}31import org.bukkit.Bukkit;32import org.bukkit.Server;33import org.bukkit.plugin.Plugin;34import org.bukkit.plugin.java.JavaPlugin;35import org.bukkit.util.CachedServerIcon;36import be.seeseemelk.mockbukkit.CachedServerIconMock;37public class Main extends JavaPlugin {38 private static Plugin plugin;39 public void onEnable() {40 plugin = this;41 Server server = Bukkit.getServer();42 CachedServerIcon icon = CachedServerIconMock.createMockIcon();43 server.setServerIcon(icon);44 }45}46import org.bukkit.Bukkit;47import org.bukkit.Server;48import org.bukkit.plugin.Plugin;49import org
CachedServerIconMock
Using AI Code Generation
1import org.bukkit.Bukkit;2import org.bukkit.Server;3import org.bukkit.World;4import org.bukkit.entity.Player;5import org.bukkit.plugin.Plugin;6import org.bukkit.plugin.PluginManager;7import be.seeseemelk.mockbukkit.MockBukkit;8import be.seeseemelk.mockbukkit.ServerMock;9import be.seeseemelk.mockbukkit.entity.PlayerMock;10import be.seeseemelk.mockbukkit.entity.PlayerMockFactory;11import be.seeseemelk.mockbukkit.plugin.PluginManagerMock;12import be.seeseemelk.mockbukkit.plugin.PluginMock;13import be.seeseemelk.mockbukkit.scheduler.BukkitSchedulerMock;14import be.seeseemelk.mockbukkit.scheduler.CachedServerIconMock;15import be.seeseemelk.mockbukkit.scheduler.ServerIconMock;16import be.seeseemelk.mockbukkit.scheduler.ServerMock;17import be.seeseemelk.mockbukkit.scheduler.WorldMock;18import be.seeseemelk.mockbukkit.scheduler.WorldMockFactory;19import be.seeseemelk.mockbukkit.scheduler.WorldType;20import be.seeseemelk.mockbukkit.scheduler.WorldType;21public class CachedServerIconMockTest {22public static void main(String[] args) {23 ServerMock server = MockBukkit.mock();24 CachedServerIconMock icon = new CachedServerIconMock();25 server.setIcon(icon);26 assertEquals(icon, server.getIcon());27}28}29import org.bukkit.Bukkit;30import org.bukkit.Server;31import org.bukkit.World;32import org.bukkit.entity.Player;33import org.bukkit.plugin.Plugin;34import org.bukkit.plugin.PluginManager;35import be.seeseemelk.mockbukkit.MockBukkit;36import be.seeseemelk.mockbukkit.ServerMock;37import be.seeseemelk.mockbukkit.entity.PlayerMock
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!