Best MockBukkit code snippet using be.seeseemelk.mockbukkit.ServerMock.getCurrentServerTime
Source:ServerMock.java
...196 playerList.addPlayer(player);197 PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(player,198 String.format(JOIN_MESSAGE, player.getDisplayName()));199 Bukkit.getPluginManager().callEvent(playerJoinEvent);200 player.setLastPlayed(getCurrentServerTime());201 registerEntity(player);202 }203 /**204 * Creates a random player and adds it.205 *206 * @return The player that was added.207 */208 public PlayerMock addPlayer()209 {210 assertMainThread();211 PlayerMock player = playerFactory.createRandomPlayer();212 addPlayer(player);213 return player;214 }215 /**216 * Creates a player with a given name and adds it.217 *218 * @param name The name to give to the player.219 * @return The added player.220 */221 public PlayerMock addPlayer(String name)222 {223 assertMainThread();224 PlayerMock player = new PlayerMock(this, name);225 addPlayer(player);226 return player;227 }228 /**229 * Set the numbers of mock players that are on this server. Note that it will remove all players that are already on230 * this server.231 *232 * @param num The number of players that are on this server.233 */234 public void setPlayers(int num)235 {236 assertMainThread();237 playerList.clearOnlinePlayers();238 for (int i = 0; i < num; i++)239 addPlayer();240 }241 /**242 * Set the numbers of mock offline players that are on this server. Note that even players that are online are also243 * considered offline player because an {@link OfflinePlayer} really just refers to anyone that has at some point in244 * time played on the server.245 *246 * @param num The number of players that are on this server.247 */248 public void setOfflinePlayers(int num)249 {250 assertMainThread();251 playerList.clearOfflinePlayers();252 for (PlayerMock player : getOnlinePlayers())253 {254 playerList.addPlayer(player);255 }256 for (int i = 0; i < num; i++)257 {258 OfflinePlayer player = playerFactory.createRandomOfflinePlayer();259 playerList.addOfflinePlayer(player);260 }261 }262 /**263 * Get a specific mock player. A player's number will never change between invocations of {@link #setPlayers(int)}.264 *265 * @param num The number of the player to retrieve.266 * @return The chosen player.267 */268 public PlayerMock getPlayer(int num)269 {270 return playerList.getPlayer(num);271 }272 /**273 * Adds a very simple super flat world with a given name.274 *275 * @param name The name to give to the world.276 * @return The {@link WorldMock} that has been created.277 */278 public WorldMock addSimpleWorld(String name)279 {280 assertMainThread();281 WorldMock world = new WorldMock();282 world.setName(name);283 worlds.add(world);284 return world;285 }286 /**287 * Adds the given mocked world to this server.288 *289 * @param world The world to add.290 */291 public void addWorld(WorldMock world)292 {293 assertMainThread();294 worlds.add(world);295 }296 /**297 * Executes a command as the console.298 *299 * @param command The command to execute.300 * @param args The arguments to pass to the commands.301 * @return The value returned by {@link Command#execute}.302 */303 public CommandResult executeConsole(Command command, String... args)304 {305 assertMainThread();306 return execute(command, getConsoleSender(), args);307 }308 /**309 * Executes a command as the console.310 *311 * @param command The command to execute.312 * @param args The arguments to pass to the commands.313 * @return The value returned by {@link Command#execute}.314 */315 public CommandResult executeConsole(String command, String... args)316 {317 assertMainThread();318 return executeConsole(getCommandMap().getCommand(command), args);319 }320 /**321 * Executes a command as a player.322 *323 * @param command The command to execute.324 * @param args The arguments to pass to the commands.325 * @return The value returned by {@link Command#execute}.326 */327 public CommandResult executePlayer(Command command, String... args)328 {329 assertMainThread();330 if (playerList.isSomeoneOnline())331 return execute(command, getPlayer(0), args);332 else333 throw new IllegalStateException("Need at least one player to run the command");334 }335 /**336 * Executes a command as a player.337 *338 * @param command The command to execute.339 * @param args The arguments to pass to the commands.340 * @return The value returned by {@link Command#execute}.341 */342 public CommandResult executePlayer(String command, String... args)343 {344 assertMainThread();345 return executePlayer(getCommandMap().getCommand(command), args);346 }347 /**348 * Executes a command.349 *350 * @param command The command to execute.351 * @param sender The person that executed the command.352 * @param args The arguments to pass to the commands.353 * @return The value returned by {@link Command#execute}.354 */355 public CommandResult execute(Command command, CommandSender sender, String... args)356 {357 assertMainThread();358 if (!(sender instanceof MessageTarget))359 {360 throw new IllegalArgumentException("Only a MessageTarget can be the sender of the command");361 }362 boolean status = command.execute(sender, command.getName(), args);363 return new CommandResult(status, (MessageTarget) sender);364 }365 /**366 * Executes a command.367 *368 * @param command The command to execute.369 * @param sender The person that executed the command.370 * @param args The arguments to pass to the commands.371 * @return The value returned by {@link Command#execute}.372 */373 public CommandResult execute(String command, CommandSender sender, String... args)374 {375 assertMainThread();376 return execute(getCommandMap().getCommand(command), sender, args);377 }378 @Override379 public String getName()380 {381 return "ServerMock";382 }383 @Override384 public String getVersion()385 {386 return String.format("MockBukkit (MC: %s)", BUKKIT_VERSION);387 }388 @Override389 public String getBukkitVersion()390 {391 return BUKKIT_VERSION;392 }393 @Override394 public Collection<? extends PlayerMock> getOnlinePlayers()395 {396 return playerList.getOnlinePlayers();397 }398 @Override399 public OfflinePlayer[] getOfflinePlayers()400 {401 return playerList.getOfflinePlayers();402 }403 @Override404 public Player getPlayer(String name)405 {406 return playerList.getPlayer(name);407 }408 @Override409 public Player getPlayerExact(String name)410 {411 return playerList.getPlayerExact(name);412 }413 @Override414 public List<Player> matchPlayer(String name)415 {416 return playerList.matchPlayer(name);417 }418 @Override419 public Player getPlayer(UUID id)420 {421 return playerList.getPlayer(id);422 }423 @Override424 public PluginManagerMock getPluginManager()425 {426 return pluginManager;427 }428 @NotNull429 public MockCommandMap getCommandMap()430 {431 return commandMap;432 }433 @Override434 public PluginCommand getPluginCommand(String name)435 {436 assertMainThread();437 Command command = getCommandMap().getCommand(name);438 return command instanceof PluginCommand ? (PluginCommand) command : null;439 }440 @Override441 public Logger getLogger()442 {443 return logger;444 }445 @Override446 public ConsoleCommandSender getConsoleSender()447 {448 if (consoleSender == null)449 {450 consoleSender = new ConsoleCommandSenderMock();451 }452 return consoleSender;453 }454 @NotNull455 public InventoryMock createInventory(InventoryHolder owner, InventoryType type, String title, int size)456 {457 assertMainThread();458 if (!type.isCreatable())459 {460 throw new IllegalArgumentException("Inventory Type is not creatable!");461 }462 switch (type)463 {464 case CHEST:465 return new ChestInventoryMock(owner, size > 0 ? size : 9 * 3);466 case DISPENSER:467 return new DispenserInventoryMock(owner);468 case DROPPER:469 return new DropperInventoryMock(owner);470 case PLAYER:471 if (owner instanceof HumanEntity)472 {473 return new PlayerInventoryMock((HumanEntity) owner);474 }475 else476 {477 throw new IllegalArgumentException("Cannot create a Player Inventory for: " + owner);478 }479 case ENDER_CHEST:480 return new EnderChestInventoryMock(owner);481 case HOPPER:482 return new HopperInventoryMock(owner);483 case SHULKER_BOX:484 return new ShulkerBoxInventoryMock(owner);485 case BARREL:486 return new BarrelInventoryMock(owner);487 case LECTERN:488 return new LecternInventoryMock(owner);489 case GRINDSTONE:490 // TODO: This Inventory Type needs to be implemented491 case STONECUTTER:492 // TODO: This Inventory Type needs to be implemented493 case CARTOGRAPHY:494 // TODO: This Inventory Type needs to be implemented495 case SMOKER:496 // TODO: This Inventory Type needs to be implemented497 case LOOM:498 // TODO: This Inventory Type needs to be implemented499 case BLAST_FURNACE:500 // TODO: This Inventory Type needs to be implemented501 case ANVIL:502 // TODO: This Inventory Type needs to be implemented503 case SMITHING:504 // TODO: This Inventory Type needs to be implemented505 case BEACON:506 // TODO: This Inventory Type needs to be implemented507 case FURNACE:508 // TODO: This Inventory Type needs to be implemented509 case WORKBENCH:510 // TODO: This Inventory Type needs to be implemented511 case ENCHANTING:512 // TODO: This Inventory Type needs to be implemented513 case BREWING:514 // TODO: This Inventory Type needs to be implemented515 case CRAFTING:516 // TODO: This Inventory Type needs to be implemented517 case CREATIVE:518 // TODO: This Inventory Type needs to be implemented519 case MERCHANT:520 // TODO: This Inventory Type needs to be implemented521 default:522 throw new UnimplementedOperationException("Inventory type not yet supported");523 }524 }525 @Override526 public InventoryMock createInventory(InventoryHolder owner, InventoryType type)527 {528 return createInventory(owner, type, "Inventory");529 }530 @Override531 public InventoryMock createInventory(InventoryHolder owner, InventoryType type, String title)532 {533 return createInventory(owner, type, title, -1);534 }535 @Override536 public InventoryMock createInventory(InventoryHolder owner, int size)537 {538 return createInventory(owner, size, "Inventory");539 }540 @Override541 public InventoryMock createInventory(InventoryHolder owner, int size, String title)542 {543 return createInventory(owner, InventoryType.CHEST, title, size);544 }545 @Override546 public ItemFactory getItemFactory()547 {548 return factory;549 }550 @Override551 public List<World> getWorlds()552 {553 return new ArrayList<>(worlds);554 }555 @Override556 public World getWorld(String name)557 {558 return worlds.stream().filter(world -> world.getName().equals(name)).findAny().orElse(null);559 }560 @Override561 public World getWorld(UUID uid)562 {563 return worlds.stream().filter(world -> world.getUID().equals(uid)).findAny().orElse(null);564 }565 @Override566 public BukkitSchedulerMock getScheduler()567 {568 return scheduler;569 }570 @Override571 public int getMaxPlayers()572 {573 return playerList.getMaxPlayers();574 }575 @Override576 public Set<String> getIPBans()577 {578 return this.playerList.getIPBans().getBanEntries().stream().map(BanEntry::getTarget)579 .collect(Collectors.toSet());580 }581 @Override582 public void banIP(String address)583 {584 assertMainThread();585 this.playerList.getIPBans().addBan(address, null, null, null);586 }587 @Override588 public void unbanIP(String address)589 {590 assertMainThread();591 this.playerList.getIPBans().pardon(address);592 }593 @Override594 public BanList getBanList(Type type)595 {596 switch (type)597 {598 case IP:599 return playerList.getIPBans();600 case NAME:601 default:602 return playerList.getProfileBans();603 }604 }605 @Override606 public Set<OfflinePlayer> getOperators()607 {608 return playerList.getOperators();609 }610 @Override611 public GameMode getDefaultGameMode()612 {613 return this.defaultGameMode;614 }615 @Override616 public void setDefaultGameMode(GameMode mode)617 {618 assertMainThread();619 this.defaultGameMode = mode;620 }621 @Override622 public int broadcastMessage(String message)623 {624 Collection<? extends PlayerMock> players = getOnlinePlayers();625 for (Player player : players)626 {627 player.sendMessage(message);628 }629 return players.size();630 }631 @Override632 public int broadcast(String message, String permission)633 {634 Collection<? extends PlayerMock> players = getOnlinePlayers();635 int count = 0;636 for (Player player : players)637 {638 if (player.hasPermission(permission))639 {640 player.sendMessage(message);641 count++;642 }643 }644 return count;645 }646 /**647 * Registers any classes that are serializable with the ConfigurationSerializable system of Bukkit.648 */649 public static void registerSerializables()650 {651 ConfigurationSerialization.registerClass(ItemMetaMock.class);652 }653 @Override654 public boolean addRecipe(Recipe recipe)655 {656 assertMainThread();657 recipes.add(recipe);658 return true;659 }660 @Override661 public List<Recipe> getRecipesFor(@NotNull ItemStack item)662 {663 assertMainThread();664 return recipes.stream().filter(recipe ->665 {666 ItemStack result = recipe.getResult();667 // Amount is explicitly ignored here668 return result.getType() == item.getType() && result.getItemMeta().equals(item.getItemMeta());669 }).collect(Collectors.toList());670 }671 @Override672 public Recipe getRecipe(NamespacedKey key)673 {674 assertMainThread();675 for (Recipe recipe : recipes)676 {677 // Seriously why can't the Recipe interface itself just extend Keyed...678 if (recipe instanceof Keyed && ((Keyed) recipe).getKey().equals(key))679 {680 return recipe;681 }682 }683 return null;684 }685 @Override686 public boolean removeRecipe(NamespacedKey key)687 {688 assertMainThread();689 Iterator<Recipe> iterator = recipeIterator();690 while (iterator.hasNext())691 {692 Recipe recipe = iterator.next();693 // Seriously why can't the Recipe interface itself just extend Keyed...694 if (recipe instanceof Keyed && ((Keyed) recipe).getKey().equals(key))695 {696 iterator.remove();697 return true;698 }699 }700 return false;701 }702 @Override703 public Iterator<Recipe> recipeIterator()704 {705 assertMainThread();706 return recipes.iterator();707 }708 @Override709 public void clearRecipes()710 {711 assertMainThread();712 recipes.clear();713 }714 @Override715 public boolean dispatchCommand(CommandSender sender, String commandLine)716 {717 assertMainThread();718 String[] commands = commandLine.split(" ");719 String commandLabel = commands[0];720 String[] args = Arrays.copyOfRange(commands, 1, commands.length);721 Command command = getCommandMap().getCommand(commandLabel);722 if (command != null)723 {724 return command.execute(sender, commandLabel, args);725 }726 else727 {728 return false;729 }730 }731 @Override732 public HelpMapMock getHelpMap()733 {734 return helpMap;735 }736 @Override737 public void sendPluginMessage(Plugin source, String channel, byte[] message)738 {739 // TODO Auto-generated method stub740 throw new UnimplementedOperationException();741 }742 @Override743 public Set<String> getListeningPluginChannels()744 {745 // TODO Auto-generated method stub746 throw new UnimplementedOperationException();747 }748 @Override749 public int getPort()750 {751 // TODO Auto-generated method stub752 throw new UnimplementedOperationException();753 }754 @Override755 public int getViewDistance()756 {757 // TODO Auto-generated method stub758 throw new UnimplementedOperationException();759 }760 @Override761 public String getIp()762 {763 // TODO Auto-generated method stub764 throw new UnimplementedOperationException();765 }766 @Override767 public String getWorldType()768 {769 // TODO Auto-generated method stub770 throw new UnimplementedOperationException();771 }772 @Override773 public boolean getGenerateStructures()774 {775 // TODO Auto-generated method stub776 throw new UnimplementedOperationException();777 }778 @Override779 public boolean getAllowEnd()780 {781 // TODO Auto-generated method stub782 throw new UnimplementedOperationException();783 }784 @Override785 public boolean getAllowNether()786 {787 // TODO Auto-generated method stub788 throw new UnimplementedOperationException();789 }790 @Override791 public boolean hasWhitelist()792 {793 // TODO Auto-generated method stub794 throw new UnimplementedOperationException();795 }796 @Override797 public void setWhitelist(boolean value)798 {799 // TODO Auto-generated method stub800 throw new UnimplementedOperationException();801 }802 @Override803 public Set<OfflinePlayer> getWhitelistedPlayers()804 {805 // TODO Auto-generated method stub806 throw new UnimplementedOperationException();807 }808 @Override809 public void reloadWhitelist()810 {811 // TODO Auto-generated method stub812 throw new UnimplementedOperationException();813 }814 @Override815 public String getUpdateFolder()816 {817 // TODO Auto-generated method stub818 throw new UnimplementedOperationException();819 }820 @Override821 public File getUpdateFolderFile()822 {823 // TODO Auto-generated method stub824 throw new UnimplementedOperationException();825 }826 @Override827 public long getConnectionThrottle()828 {829 // TODO Auto-generated method stub830 throw new UnimplementedOperationException();831 }832 @Override833 public int getTicksPerAnimalSpawns()834 {835 // TODO Auto-generated method stub836 throw new UnimplementedOperationException();837 }838 @Override839 public int getTicksPerMonsterSpawns()840 {841 // TODO Auto-generated method stub842 throw new UnimplementedOperationException();843 }844 @Override845 public ServicesManagerMock getServicesManager()846 {847 return servicesManager;848 }849 @Override850 public World createWorld(WorldCreator creator)851 {852 // TODO Auto-generated method stub853 throw new UnimplementedOperationException();854 }855 @Override856 public boolean unloadWorld(String name, boolean save)857 {858 // TODO Auto-generated method stub859 throw new UnimplementedOperationException();860 }861 @Override862 public boolean unloadWorld(World world, boolean save)863 {864 // TODO Auto-generated method stub865 throw new UnimplementedOperationException();866 }867 @Override868 public MapView createMap(World world)869 {870 // TODO Auto-generated method stub871 throw new UnimplementedOperationException();872 }873 @Override874 public void reload()875 {876 // TODO Auto-generated method stub877 throw new UnimplementedOperationException();878 }879 @Override880 public void reloadData()881 {882 // TODO Auto-generated method stub883 throw new UnimplementedOperationException();884 }885 @Override886 public void savePlayers()887 {888 // TODO Auto-generated method stub889 throw new UnimplementedOperationException();890 }891 @Override892 public void resetRecipes()893 {894 // TODO Auto-generated method stub895 throw new UnimplementedOperationException();896 }897 @Override898 public Map<String, String[]> getCommandAliases()899 {900 // TODO Auto-generated method stub901 throw new UnimplementedOperationException();902 }903 @Override904 public int getSpawnRadius()905 {906 // TODO Auto-generated method stub907 throw new UnimplementedOperationException();908 }909 @Override910 public void setSpawnRadius(int value)911 {912 // TODO Auto-generated method stub913 throw new UnimplementedOperationException();914 }915 @Override916 public boolean getOnlineMode()917 {918 // TODO Auto-generated method stub919 throw new UnimplementedOperationException();920 }921 @Override922 public boolean getAllowFlight()923 {924 // TODO Auto-generated method stub925 throw new UnimplementedOperationException();926 }927 @Override928 public boolean isHardcore()929 {930 // TODO Auto-generated method stub931 throw new UnimplementedOperationException();932 }933 @Override934 public void shutdown()935 {936 // TODO Auto-generated method stub937 throw new UnimplementedOperationException();938 }939 @Override940 public OfflinePlayer getOfflinePlayer(String name)941 {942 return playerList.getOfflinePlayer(name);943 }944 @Override945 public OfflinePlayer getOfflinePlayer(UUID id)946 {947 OfflinePlayer player = playerList.getOfflinePlayer(id);948 if (player != null)949 {950 return player;951 }952 else953 {954 return playerFactory.createRandomOfflinePlayer();955 }956 }957 @Override958 public Set<OfflinePlayer> getBannedPlayers()959 {960 // TODO Auto-generated method stub961 throw new UnimplementedOperationException();962 }963 @Override964 public File getWorldContainer()965 {966 // TODO Auto-generated method stub967 throw new UnimplementedOperationException();968 }969 @Override970 public Messenger getMessenger()971 {972 // TODO Auto-generated method stub973 throw new UnimplementedOperationException();974 }975 @Override976 public Merchant createMerchant(String title)977 {978 // TODO Auto-generated method stub979 throw new UnimplementedOperationException();980 }981 @Override982 public int getMonsterSpawnLimit()983 {984 // TODO Auto-generated method stub985 throw new UnimplementedOperationException();986 }987 @Override988 public int getAnimalSpawnLimit()989 {990 // TODO Auto-generated method stub991 throw new UnimplementedOperationException();992 }993 @Override994 public int getWaterAnimalSpawnLimit()995 {996 // TODO Auto-generated method stub997 throw new UnimplementedOperationException();998 }999 @Override1000 public int getAmbientSpawnLimit()1001 {1002 // TODO Auto-generated method stub1003 throw new UnimplementedOperationException();1004 }1005 @Override1006 public boolean isPrimaryThread()1007 {1008 return this.isOnMainThread();1009 }1010 @Override1011 public String getMotd()1012 {1013 return MOTD;1014 }1015 @Override1016 public String getShutdownMessage()1017 {1018 // TODO Auto-generated method stub1019 throw new UnimplementedOperationException();1020 }1021 @Override1022 public WarningState getWarningState()1023 {1024 // TODO Auto-generated method stub1025 throw new UnimplementedOperationException();1026 }1027 @Override1028 public ScoreboardManagerMock getScoreboardManager()1029 {1030 return scoreboardManager;1031 }1032 @Override1033 public CachedServerIcon getServerIcon()1034 {1035 // TODO Auto-generated method stub1036 throw new UnimplementedOperationException();1037 }1038 @Override1039 public CachedServerIcon loadServerIcon(File file)1040 {1041 // TODO Auto-generated method stub1042 throw new UnimplementedOperationException();1043 }1044 @Override1045 public CachedServerIcon loadServerIcon(BufferedImage image)1046 {1047 // TODO Auto-generated method stub1048 throw new UnimplementedOperationException();1049 }1050 @Override1051 public void setIdleTimeout(int threshold)1052 {1053 // TODO Auto-generated method stub1054 throw new UnimplementedOperationException();1055 }1056 @Override1057 public int getIdleTimeout()1058 {1059 // TODO Auto-generated method stub1060 throw new UnimplementedOperationException();1061 }1062 @Override1063 public ChunkData createChunkData(World world)1064 {1065 // TODO Auto-generated method stub1066 throw new UnimplementedOperationException();1067 }1068 @Override1069 public BossBar createBossBar(String title, BarColor color, BarStyle style, BarFlag... flags)1070 {1071 return new BossBarMock(title, color, style, flags);1072 }1073 @Override1074 public Entity getEntity(UUID uuid)1075 {1076 // TODO Auto-generated method stub1077 throw new UnimplementedOperationException();1078 }1079 @Override1080 public Advancement getAdvancement(NamespacedKey key)1081 {1082 // TODO Auto-generated method stub1083 throw new UnimplementedOperationException();1084 }1085 @Override1086 public Iterator<Advancement> advancementIterator()1087 {1088 // TODO Auto-generated method stub1089 throw new UnimplementedOperationException();1090 }1091 @Override1092 @Deprecated1093 public UnsafeValues getUnsafe()1094 {1095 return unsafe;1096 }1097 @Override1098 public BlockData createBlockData(Material material)1099 {1100 // TODO Auto-generated method stub1101 throw new UnimplementedOperationException();1102 }1103 @Override1104 public BlockData createBlockData(Material material, Consumer<BlockData> consumer)1105 {1106 // TODO Auto-generated method stub1107 throw new UnimplementedOperationException();1108 }1109 @Override1110 public BlockData createBlockData(String data)1111 {1112 // TODO Auto-generated method stub1113 throw new UnimplementedOperationException();1114 }1115 @Override1116 public BlockData createBlockData(Material material, String data)1117 {1118 // TODO Auto-generated method stub1119 throw new UnimplementedOperationException();1120 }1121 /**1122 * This creates a new Mock {@link Tag} for the {@link Material} class.<br>1123 * Call this in advance before you are gonna access {@link #getTag(String, NamespacedKey, Class)} or any of the1124 * constants defined in {@link Tag}.1125 *1126 * @param key The {@link NamespacedKey} for this {@link Tag}1127 * @param registryKey The name of the {@link TagRegistry}.1128 * @param materials {@link Material Materials} which should be covered by this {@link Tag}1129 *1130 * @return The newly created {@link Tag}1131 */1132 @NotNull1133 public Tag<Material> createMaterialTag(@NotNull NamespacedKey key, @NotNull String registryKey, @NotNull Material... materials)1134 {1135 Validate.notNull(key, "A NamespacedKey must never be null");1136 TagRegistry registry = materialTags.get(registryKey);1137 TagWrapperMock tag = new TagWrapperMock(registry, key);1138 registry.getTags().put(key, tag);1139 return tag;1140 }1141 public void addTagRegistry(@NotNull TagRegistry registry)1142 {1143 materialTags.put(registry.getRegistry(), registry);1144 }1145 @SuppressWarnings("unchecked")1146 @Override1147 public <T extends Keyed> Tag<T> getTag(String registryKey, NamespacedKey key, Class<T> clazz)1148 {1149 if (clazz == Material.class)1150 {1151 TagRegistry registry = materialTags.get(registryKey);1152 if (registry != null)1153 {1154 Tag<Material> tag = registry.getTags().get(key);1155 if (tag != null)1156 {1157 return (Tag<T>) tag;1158 }1159 }1160 }1161 // Per definition this method should return null if the given tag does not exist.1162 return null;1163 }1164 /**1165 * This registers Minecrafts default {@link PotionEffectType PotionEffectTypes}. It also prevents any new effects to1166 * be created afterwards.1167 */1168 private void createPotionEffectTypes()1169 {1170 for (PotionEffectType type : PotionEffectType.values())1171 {1172 // We probably already registered all Potion Effects1173 // otherwise this would be null1174 if (type != null)1175 {1176 // This is not perfect, but it works.1177 return;1178 }1179 }1180 registerPotionEffectType(1, "SPEED", false, 8171462);1181 registerPotionEffectType(2, "SLOWNESS", false, 5926017);1182 registerPotionEffectType(3, "HASTE", false, 14270531);1183 registerPotionEffectType(4, "MINING_FATIGUE", false, 4866583);1184 registerPotionEffectType(5, "STRENGTH", false, 9643043);1185 registerPotionEffectType(6, "INSTANT_HEALTH", true, 16262179);1186 registerPotionEffectType(7, "INSTANT_DAMAGE", true, 4393481);1187 registerPotionEffectType(8, "JUMP_BOOST", false, 2293580);1188 registerPotionEffectType(9, "NAUSEA", false, 5578058);1189 registerPotionEffectType(10, "REGENERATION", false, 13458603);1190 registerPotionEffectType(11, "RESISTANCE", false, 10044730);1191 registerPotionEffectType(12, "FIRE_RESISTANCE", false, 14981690);1192 registerPotionEffectType(13, "WATER_BREATHING", false, 3035801);1193 registerPotionEffectType(14, "INVISIBILITY", false, 8356754);1194 registerPotionEffectType(15, "BLINDNESS", false, 2039587);1195 registerPotionEffectType(16, "NIGHT_VISION", false, 2039713);1196 registerPotionEffectType(17, "HUNGER", false, 5797459);1197 registerPotionEffectType(18, "WEAKNESS", false, 4738376);1198 registerPotionEffectType(19, "POISON", false, 5149489);1199 registerPotionEffectType(20, "WITHER", false, 3484199);1200 registerPotionEffectType(21, "HEALTH_BOOST", false, 16284963);1201 registerPotionEffectType(22, "ABSORPTION", false, 2445989);1202 registerPotionEffectType(23, "SATURATION", true, 16262179);1203 registerPotionEffectType(24, "GLOWING", false, 9740385);1204 registerPotionEffectType(25, "LEVITATION", false, 13565951);1205 registerPotionEffectType(26, "LUCK", false, 3381504);1206 registerPotionEffectType(27, "UNLUCK", false, 12624973);1207 registerPotionEffectType(28, "SLOW_FALLING", false, 16773073);1208 registerPotionEffectType(29, "CONDUIT_POWER", false, 1950417);1209 registerPotionEffectType(30, "DOLPHINS_GRACE", false, 8954814);1210 registerPotionEffectType(31, "BAD_OMEN", false, 745784);1211 registerPotionEffectType(32, "HERO_OF_THE_VILLAGE", false, 45217);1212 PotionEffectType.stopAcceptingRegistrations();1213 }1214 private void registerPotionEffectType(int id, @NotNull String name, boolean instant, int rgb)1215 {1216 PotionEffectType type = new MockPotionEffectType(id, name, instant, Color.fromRGB(rgb));1217 PotionEffectType.registerPotionEffectType(type);1218 }1219 @Override1220 public LootTable getLootTable(NamespacedKey key)1221 {1222 // TODO Auto-generated method stub1223 throw new UnimplementedOperationException();1224 }1225 @Override1226 public ItemStack createExplorerMap(World world, Location location, StructureType structureType)1227 {1228 // TODO Auto-generated method stub1229 throw new UnimplementedOperationException();1230 }1231 @Override1232 public ItemStack createExplorerMap(World world, Location location, StructureType structureType, int radius,1233 boolean findUnexplored)1234 {1235 // TODO Auto-generated method stub1236 throw new UnimplementedOperationException();1237 }1238 @Override1239 public KeyedBossBar createBossBar(NamespacedKey key, String title, BarColor color, BarStyle style, BarFlag... flags)1240 {1241 Validate.notNull(key, "A NamespacedKey must never be null");1242 KeyedBossBarMock bar = new KeyedBossBarMock(key, title, color, style, flags);1243 bossBars.put(key, bar);1244 return bar;1245 }1246 @Override1247 public Iterator<KeyedBossBar> getBossBars()1248 {1249 return bossBars.values().stream().map(bossbar -> (KeyedBossBar) bossbar).iterator();1250 }1251 @Override1252 public KeyedBossBar getBossBar(NamespacedKey key)1253 {1254 Validate.notNull(key, "A NamespacedKey must never be null");1255 return bossBars.get(key);1256 }1257 @Override1258 public boolean removeBossBar(NamespacedKey key)1259 {1260 Validate.notNull(key, "A NamespacedKey must never be null");1261 return bossBars.remove(key, bossBars.get(key));1262 }1263 @Override1264 public List<Entity> selectEntities(CommandSender sender, String selector)1265 {1266 // TODO Auto-generated method stub1267 throw new UnimplementedOperationException();1268 }1269 @Override1270 public MapView getMap(int id)1271 {1272 // TODO Auto-generated method stub1273 throw new UnimplementedOperationException();1274 }1275 @Override1276 public <T extends Keyed> Iterable<Tag<T>> getTags(String registry, Class<T> clazz)1277 {1278 // TODO Auto-generated method stub1279 throw new UnimplementedOperationException();1280 }1281 @Override1282 public int getTicksPerWaterSpawns()1283 {1284 // TODO Auto-generated method stub1285 throw new UnimplementedOperationException();1286 }1287 @Override1288 public int getTicksPerAmbientSpawns()1289 {1290 // TODO Auto-generated method stub1291 throw new UnimplementedOperationException();1292 }1293 /**1294 * This returns the current time of the {@link Server} in milliseconds1295 *1296 * @return The current {@link Server} time1297 */1298 protected long getCurrentServerTime()1299 {1300 return System.currentTimeMillis();1301 }1302 @Override1303 public int getTicksPerWaterAmbientSpawns()1304 {1305 // TODO Auto-generated method stub1306 throw new UnimplementedOperationException();1307 }1308 @Override1309 public int getWaterAmbientSpawnLimit()1310 {1311 // TODO Auto-generated method stub1312 throw new UnimplementedOperationException();...
Source:PlayerMockTest.java
...85 server = MockBukkit.mock(new ServerMock()86 {87 private long ticks = 0;88 @Override89 protected long getCurrentServerTime()90 {91 /*92 * This will force the current server time to always be different to93 * any prior invocations, this is much more elegant than simply doing94 * Thread.sleep!95 */96 ticks++;97 return super.getCurrentServerTime() + ticks;98 }99 });100 uuid = UUID.randomUUID();101 player = new PlayerMock(server, "player", uuid);102 }103 @AfterEach104 public void tearDown()105 {106 MockBukkit.unmock();107 }108 @Test109 void getInventory_Default_NotNull()110 {111 assertNotNull(player.getInventory());...
getCurrentServerTime
Using AI Code Generation
1import org.junit.Test;2import org.junit.runner.RunWith;3import be.seeseemelk.mockbukkit.MockBukkit;4import be.seeseemelk.mockbukkit.ServerMock;5import be.seeseemelk.mockbukkit.UnimplementedOperationException;6import be.seeseemelk.mockbukkit.scheduler.BukkitSchedulerMock;7import be.seeseemelk.mockbukkit.scheduler.BukkitTaskMock;8import be.seeseemelk.mockbukkit.scheduler.SchedulerHandler;9import be.seeseemelk.mockbukkit.scheduler.SchedulerHandlerMock;10import be.seeseemelk.mockbukkit.scheduler.SchedulerMock;11import be.seeseemelk.mockbukkit.scheduler.SchedulerThread;12import be.seeseemelk.mockbukkit.scheduler.SchedulerThreadMock;13import be.seeseemelk.mockbukkit.scheduler.SchedulerThreadMock2;14import be.seeseemelk.mockbukkit.scheduler.SchedulerThreadMock3;15import be.seeseemelk.mockbukkit.scheduler.SchedulerThreadMock4;16import be.seeseemelk.mockbukkit.scheduler.SchedulerThreadMock5;17import be.seeseemelk.mockbukkit.scheduler.SchedulerThreadMock6;18import be.seeseemelk.mockbukkit.scheduler.SchedulerThreadMock7;19import be.seeseemelk.mockbukkit.scheduler.SchedulerThreadMock8;20import be.seeseemelk.mockbukkit.scheduler.SchedulerThreadMock9;21import be.seeseemelk.mockbukkit.scheduler.SchedulerThreadMock10;22import be.seeseemelk.mockbukkit.scheduler.SchedulerThreadMock11;23import be.seeseemelk.mockbukkit.scheduler.SchedulerThreadMock12;24import be.seeseemelk.mockbukkit.scheduler.SchedulerThreadMock13;25import be.seeseemelk.mockbukkit.scheduler.SchedulerThreadMock14;26import be.seeseemelk.mockbukkit.scheduler.SchedulerThreadMock15;27import be.seeseemelk.mockbukkit.scheduler.SchedulerThreadMock16;28import be.seeseemelk.mockbukkit.scheduler.SchedulerThreadMock17;29import be.seeseemelk.mockbukkit.scheduler.SchedulerThreadMock18;30import be.seeseemelk.mockbukkit.scheduler.SchedulerThreadMock19;31import be.seeseemelk.mockbukkit.scheduler.SchedulerThreadMock20;32import be.seeseemelk.mockbukkit.scheduler.SchedulerThread
getCurrentServerTime
Using AI Code Generation
1import be.seeseemelk.mockbukkit.ServerMock;2import be.seeseemelk.mockbukkit.WorldMock;3import be.seeseemelk.mockbukkit.entity.PlayerMock;4import be.seeseemelk.mockbukkit.scheduler.BukkitSchedulerMock;5import be.seeseemelk.mockbukkit.scheduler.BukkitTaskMock;6import org.junit.jupiter.api.BeforeEach;7import org.junit.jupiter.api.Test;8import org.junit.jupiter.api.extension.ExtendWith;9import org.mockito.Mock;10import org.mockito.junit.jupiter.MockitoExtension;11import org.mockito.junit.jupiter.MockitoSettings;12import org.mockito.quality.Strictness;13import org.powermock.reflect.Whitebox;14import org.bukkit.Bukkit;15import org.bukkit.Location;16import org.bukkit.World;17import org.bukkit.entity.Player;18import java.util.Date;19import java.util.List;20import java.util.concurrent.TimeUnit;21import java.util.stream.Collectors;22import java.util.stream.Stream;23import static org.junit.jupiter.api.Assertions.assertEquals;24import static org.junit.jupiter.api.Assertions.assertTrue;25import static org.mockito.Mockito.*;26@ExtendWith(MockitoExtension.class)27@MockitoSettings(strictness = Strictness.STRICT_STUBS)28public class TestClass {29 private ServerMock server;30 private BukkitSchedulerMock scheduler;31 private WorldMock world;32 private PlayerMock player;33 private Player player1;34 private Player player2;35 private Player player3;36 private List<Player> players;37 private Location location;38 private Location location1;39 private Location location2;40 private Location location3;41 private Location location4;42 private Location location5;43 private Location location6;44 private Location location7;45 private Location location8;46 private Location location9;47 private Location location10;48 private Location location11;49 private Location location12;50 private Location location13;51 private Location location14;52 private Location location15;53 private Location location16;54 private Location location17;55 private Location location18;56 private Location location19;57 private Location location20;58 private Location location21;59 private Location location22;60 private Location location23;61 private Location location24;62 private Location location25;63 private Location location26;64 private Location location27;65 private Location location28;66 private Location location29;67 private Location location30;68 private Location location31;69 private Location location32;
getCurrentServerTime
Using AI Code Generation
1import org.junit.jupiter.api.Test;2import org.junit.jupiter.api.extension.ExtendWith;3import org.mockito.junit.jupiter.MockitoExtension;4import be.seeseemelk.mockbukkit.MockBukkit;5@ExtendWith(MockitoExtension.class)6{7 public void testCurrentServerTime()8 {9 MockBukkit.getMock().getCurrentServerTime();10 }11}12import org.junit.jupiter.api.Test;13import org.junit.jupiter.api.extension.ExtendWith;14import org.mockito.junit.jupiter.MockitoExtension;15import be.seeseemelk.mockbukkit.MockBukkit;16@ExtendWith(MockitoExtension.class)17{18 public void testOnlinePlayers()19 {20 MockBukkit.getMock().getOnlinePlayers();21 }22}23import org.junit.jupiter.api.Test;24import org.junit.jupiter.api.extension.ExtendWith;25import org.mockito.junit.jupiter.MockitoExtension;26import be.seeseemelk.mockbukkit.MockBukkit;27@ExtendWith(MockitoExtension.class)28{29 public void testOnlinePlayers()30 {31 MockBukkit.getMock().getOnlinePlayers();32 }33}34import org.junit.jupiter.api.Test;35import org.junit.jupiter.api.extension.ExtendWith;36import org.mockito.junit.jupiter.MockitoExtension;37import be.seeseemelk.mockbukkit.MockBukkit;38@ExtendWith(MockitoExtension.class)39{40 public void testOnlinePlayers()41 {42 MockBukkit.getMock().getOnlinePlayers();43 }44}45import org.junit.jupiter.api.Test;46import org.junit.jupiter.api.extension.ExtendWith;47import org.mockito.junit.jupiter.MockitoExtension;48import be.seeseemelk.mockbukkit.MockBukkit;49@ExtendWith(MockitoExtension.class)50{
getCurrentServerTime
Using AI Code Generation
1package com.example;2import org.junit.Before;3import org.junit.Test;4import org.junit.runner.RunWith;5import org.mockito.Mock;6import org.mockito.junit.MockitoJUnitRunner;7import be.seeseemelk.mockbukkit.MockBukkit;8import be.seeseemelk.mockbukkit.ServerMock;9import static org.junit.Assert.assertEquals;10import static org.mockito.Mockito.*;11@RunWith(MockitoJUnitRunner.class)12{13 private ServerMock server;14 public void setUp()15 {16 server = MockBukkit.mock();17 }18 public void testGetCurrentTime()19 {20 assertEquals(0, server.getCurrentTick());21 assertEquals(0, server.getCurrentTime());22 assertEquals(0, server.getCurrentServerTime());23 server.setCurrentTick(10);24 assertEquals(10, server.getCurrentTick());25 assertEquals(500, server.getCurrentTime());26 assertEquals(500, server.getCurrentServerTime());27 server.setCurrentTick(20);28 assertEquals(20, server.getCurrentTick());29 assertEquals(1000, server.getCurrentTime());30 assertEquals(1000, server.getCurrentServerTime());31 server.setCurrentTick(30);32 assertEquals(30, server.getCurrentTick());33 assertEquals(1500, server.getCurrentTime());34 assertEquals(1500, server.getCurrentServerTime());35 }36}37package com.example;38import org.junit.Before;39import org.junit.Test;40import org.junit.runner.RunWith;41import org.mockito.Mock;42import org.mockito.junit.MockitoJUnitRunner;43import be.seeseemelk.mockbukkit.MockBukkit;44import be.seeseemelk.mockbukkit.ServerMock;45import static org.junit.Assert.assertEquals;46import static org.mockito.Mockito.*;47@RunWith(MockitoJUnitRunner.class)48{49 private ServerMock server;50 public void setUp()51 {52 server = MockBukkit.mock();53 }54 public void testGetCurrentTime()55 {56 assertEquals(0, server.getCurrentTick());57 assertEquals(0, server.getCurrentTime());58 assertEquals(0, server.getCurrentServerTime());59 server.setCurrentTick(10);60 assertEquals(10, server.getCurrentTick());61 assertEquals(500, server.getCurrentTime());62 assertEquals(500, server.getCurrentServerTime());63 server.setCurrentTick(20);64 assertEquals(20, server.getCurrentTick());
getCurrentServerTime
Using AI Code Generation
1package com.example;2import static org.junit.Assert.assertEquals;3import static org.junit.Assert.assertTrue;4import org.bukkit.Bukkit;5import org.bukkit.Server;6import org.junit.Test;7import be.seeseemelk.mockbukkit.MockBukkit;8{9 public void testGetCurrentServerTime()10 {11 MockBukkit.mock();12 Server server = Bukkit.getServer();13 long time = server.getCurrentServerTime();14 assertTrue(time > 0);15 assertEquals(time, server.getCurrentServerTime());16 MockBukkit.unmock();17 }18}19package com.example;20import static org.junit.Assert.assertEquals;21import static org.junit.Assert.assertTrue;22import org.bukkit.Bukkit;23import org.bukkit.Server;24import org.junit.Test;25import be.seeseemelk.mockbukkit.MockBukkit;26{27 public void testGetCurrentServerTime()28 {29 MockBukkit.mock();30 Server server = Bukkit.getServer();31 long time = server.getCurrentServerTime();32 assertTrue(time > 0);33 assertEquals(time, server.getCurrentServerTime());34 MockBukkit.unmock();35 }36}37java.lang.NoSuchMethodError: org.bukkit.Server.getCurrentServerTime()J38dependencies {
getCurrentServerTime
Using AI Code Generation
1package com.example;2import static org.junit.Assert.assertEquals;3import static org.junit.Assert.assertNotNull;4import static org.junit.Assert.assertTrue;5import static org.junit.Assert.fail;6import org.bukkit.Bukkit;7import org.bukkit.Location;8import org.bukkit.Material;9import org.bukkit.World;10import org.bukkit.block.Block;11import org.bukkit.block.BlockFace;12import org.bukkit.block.BlockState;13import org.bukkit.block.data.BlockData;14import org.bukkit.block.data.Directional;15import org.bukkit.block.data.type.WallSign;16import org.bukkit.entity.Player;17import org.bukkit.event.block.BlockPlaceEvent;18import org.bukkit.event.player.PlayerInteractEvent;19import org.bukkit.inventory.EquipmentSlot;20import org.bukkit.inventory.ItemStack;21import org.bukkit.inventory.meta.ItemMeta;22import org.bukkit.material.Sign;23import org.bukkit.plugin.Plugin;24import org.bukkit.plugin.PluginManager;25import org.bukkit.plugin.java.JavaPlugin;26import org.bukkit.scheduler.BukkitScheduler;27import org.bukkit.scheduler.BukkitTask;28import org.bukkit.util.Vector;29import org.junit.Assert;30import org.junit.Before;31import org.junit.Test;32import be.seeseemelk.mockbukkit.MockBukkit;33import be.seeseemelk.mockbukkit.ServerMock;34import be.seeseemelk.mockbukkit.block.BlockMock;35import be.seeseemelk.mockbukkit.block.BlockStateMock;36import be.seeseemelk.mockbukkit.block.data.BlockDataMock;37import be.seeseemelk.mockbukkit.block.data.DirectionalMock;38import be.seeseemelk.mockbukkit.block.data.type.WallSignMock;39import be.seeseemelk.mockbukkit.entity.PlayerMock;40import be.seeseemelk.mockbukkit.inventory.InventoryMock;41import be.seeseemelk.mockbukkit.inventory.InventoryViewMock;42import be.seeseemelk.mockbukkit.inventory.ItemStackBuilder;43import be.seeseemelk.mockbukkit.inventory.meta.ItemMetaMock;44import be.seeseemelk.mockbukkit.scheduler.BukkitSchedulerMock;45import be.seeseemelk.mockbukkit.scheduler.BukkitTaskMock;46public class TestMockBukkit {47 public void setup() {48 MockBukkit.mock();49 }50 public void testGetCurrentServerTime() {51 ServerMock serverMock = MockBukkit.getMock();52 long currentTime = serverMock.getCurrentServerTime();
getCurrentServerTime
Using AI Code Generation
1import org.junit.Test;2import org.junit.Before;3import org.junit.After;4import static org.junit.Assert.*;5import be.seeseemelk.mockbukkit.MockBukkit;6{7 public void test()8 {9 ServerMock server = MockBukkit.mock();10 server.setCurrentServerTime(1000);11 assertEquals(1000, server.getCurrentServerTime());12 server.unmock();13 }14}15import org.junit.Test;16import org.junit.Before;17import org.junit.After;18import static org.junit.Assert.*;19import be.seeseemelk.mockbukkit.MockBukkit;20{21 public void test()22 {23 ServerMock server = MockBukkit.mock();24 server.setCurrentServerTime(1000);25 assertEquals(1000, server.getCurrentServerTime());26 server.unmock();27 }28}29import org.junit.Test;30import org.junit.Before;31import org.junit.After;32import static org.junit.Assert.*;33import be.seeseemelk.mockbukkit.MockBukkit;34{35 public void test()36 {37 ServerMock server = MockBukkit.mock();38 server.setCurrentServerTime(1000);39 assertEquals(1000, server.getCurrentServerTime());40 server.unmock();41 }42}43import org.junit.Test;44import org.junit.Before;45import org.junit.After;46import static org.junit.Assert.*;47import be.seeseemelk.mockbukkit.MockBukkit;48{49 public void test()50 {51 ServerMock server = MockBukkit.mock();52 server.setCurrentServerTime(1000);53 assertEquals(1000, server.getCurrentServerTime());54 server.unmock();55 }56}57import org.junit.Test;58import org.junit.Before;59import org.junit.After;60import static org.junit.Assert.*;61import
getCurrentServerTime
Using AI Code Generation
1package be.seeseemelk.mockbukkit;2import static org.junit.Assert.*;3import java.util.Date;4import org.junit.Test;5import be.seeseemelk.mockbukkit.scheduler.BukkitSchedulerMock;6{7public void testGetCurrentServerTime()8{9ServerMock server = new ServerMock();10BukkitSchedulerMock scheduler = new BukkitSchedulerMock(server);11server.setScheduler(scheduler);12assertEquals(server.getCurrentServerTime(), new Date(0));13}14}15package be.seeseemelk.mockbukkit;16import static org.junit.Assert.*;17import org.junit.Test;18import be.seeseemelk.mockbukkit.scheduler.BukkitSchedulerMock;19{20public void testSetWeatherDuration()21{22ServerMock server = new ServerMock();23BukkitSchedulerMock scheduler = new BukkitSchedulerMock(server);24server.setScheduler(scheduler);25server.setWeatherDuration(10);26assertEquals(server.getWeatherDuration(), 10);27}28}29package be.seeseemelk.mockbukkit;30import static org.junit.Assert.*;31import org.junit.Test;32import be.seeseemelk.mockbukkit.scheduler.BukkitSchedulerMock;33{34public void testGetWeatherDuration()35{36ServerMock server = new ServerMock();37BukkitSchedulerMock scheduler = new BukkitSchedulerMock(server);38server.setScheduler(scheduler);39assertEquals(server.getWeatherDuration(), 0);40}41}42package be.seeseemelk.mockbukkit;43import static org.junit.Assert.*;44import org.junit.Test;45import be.seeseemelk.mockbukkit.scheduler.BukkitSchedulerMock;46{47public void testSetThunderDuration()48{49ServerMock server = new ServerMock();50BukkitSchedulerMock scheduler = new BukkitSchedulerMock(server);51server.setScheduler(scheduler);52server.setThunderDuration(10);53assertEquals(server.getThunderDuration(), 10
getCurrentServerTime
Using AI Code Generation
1import org.junit.jupiter.api.BeforeEach;2import org.junit.jupiter.api.Test;3import org.junit.jupiter.api.extension.ExtendWith;4import org.mockito.junit.jupiter.MockitoExtension;5import org.mockito.Mock;6import org.mockito.MockitoAnnotations;7import static org.junit.jupiter.api.Assertions.assertEquals;8import static org.mockito.Mockito.when;9import static org.mockito.Mockito.mock;10import java.util.Date;11import java.util.Calendar;12import java.util.GregorianCalendar;13import be.seeseemelk.mockbukkit.MockBukkit;14import be.seeseemelk.mockbukkit.ServerMock;15import org.bukkit.Server;16import org.bukkit.World;17import org.bukkit.World.Environment;18import org.bukkit.WorldCreator;19import org.bukkit.WorldType;20@ExtendWith(MockitoExtension.class)21{22 private ServerMock server;23 private World world;24 public void setUp()25 {26 server = MockBukkit.mock();27 world = server.addSimpleWorld("world");28 }29 public void testCurrentServerTime()30 {31 Calendar calendar = new GregorianCalendar(2018, 11, 30, 12, 0, 0);32 Date date = calendar.getTime();33 server.setCurrentServerTime(date.getTime());34 long time = server.getCurrentServerTime();35 assertEquals(date.getTime(), time);36 }37}
getCurrentServerTime
Using AI Code Generation
1import be.seeseemelk.mockbukkit.ServerMock;2import be.seeseemelk.mockbukkit.MockBukkit;3import org.junit.jupiter.api.Test;4import org.junit.jupiter.api.BeforeEach;5import org.junit.jupiter.api.AfterEach;6import org.junit.jupiter.api.DisplayName;7import org.junit.jupiter.api.Assertions;8public class Test2 {9 private ServerMock server;10 public void setUp() {11 server = MockBukkit.mock();12 }13 public void tearDown() {14 MockBukkit.unmock();15 }16 @DisplayName("Test for getCurrentServerTime method of be.seeseemelk.mockbukkit.ServerMock class")17 public void testGetCurrentServerTime() {18 long time = server.getCurrentServerTime();19 System.out.println("Current server time is: " + time);20 Assertions.assertTrue(time > 0);21 }22}
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!!