| 20 | import org.jetbrains.annotations.NotNull; |
| 21 | |
| 22 | public final class TestServer { |
| 23 | |
| 24 | static { |
| 25 | Server instance = mock(withSettings().stubOnly()); |
| 26 | |
| 27 | Thread creatingThread = Thread.currentThread(); |
| 28 | when(instance.isPrimaryThread()).then(mock -> Thread.currentThread().equals(creatingThread)); |
| 29 | |
| 30 | // Paper - remove plugin manager for Paper Plugins |
| 31 | |
| 32 | Logger logger = Logger.getLogger(TestServer.class.getCanonicalName()); |
| 33 | when(instance.getLogger()).thenReturn(logger); |
| 34 | |
| 35 | when(instance.getName()).thenReturn(TestServer.class.getSimpleName()); |
| 36 | |
| 37 | when(instance.getVersion()).thenReturn("Version_" + TestServer.class.getPackage().getImplementationVersion()); |
| 38 | |
| 39 | when(instance.getBukkitVersion()).thenReturn("BukkitVersion_" + TestServer.class.getPackage().getImplementationVersion()); |
| 40 | |
| 41 | // Paper start - RegistryAccess |
| 42 | when(instance.getRegistry(any())).then(invocationOnMock -> { |
| 43 | return io.papermc.paper.registry.RegistryAccess.registryAccess().getRegistry(((Class<Keyed>)invocationOnMock.getArgument(0))); |
| 44 | }); |
| 45 | // Paper end - RegistryAccess |
| 46 | |
| 47 | UnsafeValues unsafeValues = mock(withSettings().stubOnly()); |
| 48 | when(instance.getUnsafe()).thenReturn(unsafeValues); |
| 49 | |
| 50 | // Paper start - testing changes |
| 51 | when(instance.getTag(anyString(), any(NamespacedKey.class), any())).thenAnswer(ignored -> new io.papermc.paper.testing.EmptyTag()); |
| 52 | when(instance.getScoreboardCriteria(anyString())).thenReturn(null); |
| 53 | // Paper end - testing changes |
| 54 | |
| 55 | Bukkit.setServer(instance); |
| 56 | } |
| 57 | |
| 58 | private TestServer() { |
| 59 | } |
| 60 | |
| 61 | public static void setup() { |
| 62 | } |
| 63 | } |
nothing calls this directly
no test coverage detected