diff --git a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/api/event/lifecycle/v1/ServerLifecycleEvents.java b/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/api/event/lifecycle/v1/ServerLifecycleEvents.java index f5711bb04..3b3634585 100644 --- a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/api/event/lifecycle/v1/ServerLifecycleEvents.java +++ b/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/api/event/lifecycle/v1/ServerLifecycleEvents.java @@ -65,42 +65,6 @@ public final class ServerLifecycleEvents { } }); - /** - * Gets the currently running primary server. - * - * <p><b>Use of this method is highly discouraged and not recommended since there is no real restriction on whether the game engine could run multiple servers concurrently.</b> - * One should attempt to obtain the server instance from a {@link ServerWorld server world} or via other means. - * - * <p>The server instance returned SHOULD NOT be cached! Call the method every time you need the server. - * - * @return the currently running server - * @throws IllegalStateException if the server is not available - */ - @Deprecated - public static MinecraftServer getPrimaryServer() { - final MinecraftServer server = ServerLifecycleInternals.getServer(); - - if (server != null) { - return server; - } - - throw new IllegalStateException("Server was not available"); - } - - /** - * Checks if the primary server is available. - * The server may not always be available on a {@link net.fabricmc.api.EnvType#CLIENT client}, so it is advised to verify this is {@code true} before calling {@link ServerLifecycleEvents#getPrimaryServer()} - * - * <p><b>Use of this method is highly discouraged and not recommended since there is no real restriction on whether the game engine could run multiple servers concurrently.</b> - * One should attempt to obtain the server instance from a {@link ServerWorld server world} or via other means. - * - * @return true if the server is available. - */ - @Deprecated - public static boolean isPrimaryServerAvailable() { - return ServerLifecycleInternals.getServer() != null; - } - public interface LifecycleCallback { void onChangeLifecycle(MinecraftServer server); } diff --git a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/impl/lifecycle/DedicatedServerLifecycleInternals.java b/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/impl/lifecycle/DedicatedServerLifecycleInternals.java deleted file mode 100644 index e477f3735..000000000 --- a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/impl/lifecycle/DedicatedServerLifecycleInternals.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.impl.lifecycle; - -import net.minecraft.server.MinecraftServer; - -import net.fabricmc.api.DedicatedServerModInitializer; -import net.fabricmc.loader.api.FabricLoader; - -public final class DedicatedServerLifecycleInternals extends ServerLifecycleInternals implements DedicatedServerModInitializer { - public DedicatedServerLifecycleInternals() { - // On a dedicated server, the game instance is the server - super(() -> (MinecraftServer) FabricLoader.getInstance().getGameInstance()); - } - - @Override - public void onInitializeServer() { - } -} diff --git a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/impl/lifecycle/ServerLifecycleInternals.java b/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/impl/lifecycle/ServerLifecycleInternals.java deleted file mode 100644 index 7c413a24d..000000000 --- a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/impl/lifecycle/ServerLifecycleInternals.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.impl.lifecycle; - -import java.util.function.Supplier; - -import net.minecraft.server.MinecraftServer; - -public abstract class ServerLifecycleInternals { - private static Supplier<MinecraftServer> serverSupplier; - - /* @Nullable */ - public static MinecraftServer getServer() { - return serverSupplier.get(); - } - - protected ServerLifecycleInternals(Supplier<MinecraftServer> supplier) { - serverSupplier = supplier; - } -} diff --git a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/impl/lifecycle/client/IntegratedServerLifecycleInternals.java b/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/impl/lifecycle/client/IntegratedServerLifecycleInternals.java deleted file mode 100644 index 02461d690..000000000 --- a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/impl/lifecycle/client/IntegratedServerLifecycleInternals.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.impl.lifecycle.client; - -import net.minecraft.client.MinecraftClient; - -import net.fabricmc.api.ClientModInitializer; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.fabricmc.fabric.impl.lifecycle.ServerLifecycleInternals; -import net.fabricmc.loader.api.FabricLoader; - -@Environment(EnvType.CLIENT) -public final class IntegratedServerLifecycleInternals extends ServerLifecycleInternals implements ClientModInitializer { - public IntegratedServerLifecycleInternals() { - // On an a client, the server is in the client - super(() -> { - // Get the client - final MinecraftClient client = (MinecraftClient) FabricLoader.getInstance().getGameInstance(); - - // And return the client's integrated server - return client.getServer(); - }); - } - - @Override - public void onInitializeClient() { - } -} diff --git a/fabric-lifecycle-events-v1/src/main/resources/fabric.mod.json b/fabric-lifecycle-events-v1/src/main/resources/fabric.mod.json index ea1529646..f0c3745e2 100644 --- a/fabric-lifecycle-events-v1/src/main/resources/fabric.mod.json +++ b/fabric-lifecycle-events-v1/src/main/resources/fabric.mod.json @@ -18,14 +18,6 @@ "mixins": [ "fabric-lifecycle-events-v1.mixins.json" ], - "entrypoints": { - "client": [ - "net.fabricmc.fabric.impl.lifecycle.client.IntegratedServerLifecycleInternals" - ], - "server": [ - "net.fabricmc.fabric.impl.lifecycle.DedicatedServerLifecycleInternals" - ] - }, "depends": { "fabricloader": ">=0.4.0", "fabric-api-base": "*"