|
| 1 | +/* |
| 2 | + * Copyright 2025-present CloudNetService team & contributors |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package eu.cloudnetservice.modules.bridge.fabric.v1_13_2; |
| 18 | + |
| 19 | +import eu.cloudnetservice.driver.service.ServiceInfoSnapshot; |
| 20 | +import eu.cloudnetservice.modules.bridge.fabric.BaseFabricBridgeManagement; |
| 21 | +import eu.cloudnetservice.modules.bridge.fabric.BridgeAccessorSpec; |
| 22 | +import eu.cloudnetservice.modules.bridge.impl.util.BridgeHostAndPortUtil; |
| 23 | +import eu.cloudnetservice.modules.bridge.player.NetworkPlayerServerInfo; |
| 24 | +import eu.cloudnetservice.modules.bridge.player.ServicePlayer; |
| 25 | +import eu.cloudnetservice.modules.bridge.player.executor.PlayerExecutor; |
| 26 | +import java.util.Optional; |
| 27 | +import java.util.UUID; |
| 28 | +import java.util.function.BiFunction; |
| 29 | +import net.minecraft.entity.player.ServerPlayerEntity; |
| 30 | +import org.jetbrains.annotations.NotNull; |
| 31 | +import org.jetbrains.annotations.Nullable; |
| 32 | + |
| 33 | +public final class FabricBridgeManagementv1132 extends BaseFabricBridgeManagement<ServerPlayerEntity> { |
| 34 | + |
| 35 | + /** |
| 36 | + * Constructs a new instance of the bridge management. |
| 37 | + * |
| 38 | + * @param bridgeAccessorSpec the accessor specification for the current server version. |
| 39 | + * @throws NullPointerException if the given accessor spec is null. |
| 40 | + */ |
| 41 | + public FabricBridgeManagementv1132(@NotNull BridgeAccessorSpec<ServerPlayerEntity> bridgeAccessorSpec) { |
| 42 | + super(bridgeAccessorSpec); |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * {@inheritDoc} |
| 47 | + */ |
| 48 | + @Override |
| 49 | + public @NotNull ServicePlayer wrapPlayer(@NotNull ServerPlayerEntity player) { |
| 50 | + return new ServicePlayer(player.getUuid(), player.getGameProfile().getName()); |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * {@inheritDoc} |
| 55 | + */ |
| 56 | + @Override |
| 57 | + public @NotNull NetworkPlayerServerInfo createPlayerInformation(@NotNull ServerPlayerEntity player) { |
| 58 | + return new NetworkPlayerServerInfo( |
| 59 | + player.getUuid(), |
| 60 | + player.getGameProfile().getName(), |
| 61 | + null, |
| 62 | + BridgeHostAndPortUtil.fromSocketAddress(player.networkHandler.getConnection().getAddress()), |
| 63 | + this.ownNetworkServiceInfo); |
| 64 | + } |
| 65 | + |
| 66 | + /** |
| 67 | + * {@inheritDoc} |
| 68 | + */ |
| 69 | + @Override |
| 70 | + public @NotNull BiFunction<ServerPlayerEntity, String, Boolean> permissionFunction() { |
| 71 | + return (player, _) -> player.method_15592(4); |
| 72 | + } |
| 73 | + |
| 74 | + /** |
| 75 | + * {@inheritDoc} |
| 76 | + */ |
| 77 | + @Override |
| 78 | + public @NotNull Optional<ServiceInfoSnapshot> fallback( |
| 79 | + @NotNull ServerPlayerEntity player, |
| 80 | + @Nullable String currServer |
| 81 | + ) { |
| 82 | + return this.fallback(player.getUuid(), currServer, null, _ -> player.method_15592(4)); |
| 83 | + } |
| 84 | + |
| 85 | + /** |
| 86 | + * {@inheritDoc} |
| 87 | + */ |
| 88 | + @Override |
| 89 | + public void handleFallbackConnectionSuccess(@NotNull ServerPlayerEntity player) { |
| 90 | + this.handleFallbackConnectionSuccess(player.getUuid()); |
| 91 | + } |
| 92 | + |
| 93 | + /** |
| 94 | + * {@inheritDoc} |
| 95 | + */ |
| 96 | + @Override |
| 97 | + public void removeFallbackProfile(@NotNull ServerPlayerEntity player) { |
| 98 | + this.removeFallbackProfile(player.getUuid()); |
| 99 | + } |
| 100 | + |
| 101 | + /** |
| 102 | + * {@inheritDoc} |
| 103 | + */ |
| 104 | + @Override |
| 105 | + public @NotNull PlayerExecutor directPlayerExecutor(@NotNull UUID uniqueId) { |
| 106 | + throw new UnsupportedOperationException("not implemented on fabric"); |
| 107 | + } |
| 108 | +} |
0 commit comments