Skip to content

Commit 555d005

Browse files
committed
feat: add support for 1.11.2
1 parent 24070a1 commit 555d005

14 files changed

+788
-0
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
fail-fast: true
2727
matrix:
2828
mc_version:
29+
- 1.11.2
2930
- 1.12.2
3031
- 1.13.2
3132
- 1.14.4

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ specific minecraft versions.
1818

1919
| Minecraft Version | Subproject | Supported |
2020
|------------------------|------------|--------------------|
21+
| 1.11.2 | v1_11_2 | :white_check_mark: |
2122
| 1.12.2 | v1_12_2 | :white_check_mark: |
2223
| 1.13.2 | v1_13_2 | :white_check_mark: |
2324
| 1.14.4 | v1_14_4 | :white_check_mark: |

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pluginManagement {
3333
rootProject.name = "cloudnet-bridge-fabric"
3434

3535
include(":common")
36+
include(":v1_11_2")
3637
include(":v1_12_2")
3738
include(":v1_13_2")
3839
include(":v1_14_4")

v1_11_2/build.gradle.kts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
import org.apache.tools.ant.filters.ReplaceTokens
18+
19+
plugins {
20+
alias(libs.plugins.fabricLoom)
21+
alias(libs.plugins.legacyLoom)
22+
}
23+
24+
val minecraftVersion = "1.11.2"
25+
val yarnVersion = "1.11.2+build.571"
26+
val supportedVersionRange = "1.11.2"
27+
28+
dependencies {
29+
shaded(projects.common)
30+
modImplementation(libs.fabricLoader)
31+
minecraft("com.mojang:minecraft:$minecraftVersion")
32+
mappings("net.legacyfabric:yarn:$yarnVersion:v2")
33+
}
34+
35+
loom {
36+
accessWidenerPath = project.file("src/main/resources/cloudnet_version_bridge.accesswidener")
37+
}
38+
39+
tasks.remapJar {
40+
dependsOn(tasks.shadowJar)
41+
inputFile = tasks.shadowJar.flatMap { it.archiveFile }
42+
archiveFileName = "bridge_${minecraftVersion.replace(".", "")}.jar"
43+
}
44+
45+
tasks.processResources {
46+
val tokens = mapOf(
47+
"mc_version" to minecraftVersion,
48+
"mc_version_range" to supportedVersionRange,
49+
"mc_version_dashed" to minecraftVersion.replace('.', '_'),
50+
)
51+
inputs.properties(tokens)
52+
filesMatching("*.json") {
53+
filter(ReplaceTokens::class, mapOf("tokens" to tokens))
54+
}
55+
56+
from(rootProject.layout.projectDirectory.dir(".mod_resources")) {
57+
into("")
58+
include("*.json")
59+
}
60+
}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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_11_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 FabricBridgeManagementv1112 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 FabricBridgeManagementv1112(@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.canUseCommand(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.canUseCommand(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+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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_11_2.forward;
18+
19+
import eu.cloudnetservice.modules.bridge.fabric.BaseMixinConfigPlugin;
20+
import org.jetbrains.annotations.NotNull;
21+
22+
/**
23+
* Mixin plugin to conditionally apply forwarding mixins only if they are actually needed.
24+
*
25+
* @since 2025.08.26
26+
*/
27+
public final class ForwardMixinPlugin extends BaseMixinConfigPlugin {
28+
29+
/**
30+
* If cloudnet ip forwarding support is disabled.
31+
*/
32+
private static final boolean DISABLE_CLOUDNET_FORWARDING = Boolean.getBoolean("cloudnet.ipforward.disabled");
33+
34+
/**
35+
* Conditionally applies the player forwarding mixins if they are enabled.
36+
*
37+
* @param targetClassName fully qualified class name of the target class
38+
* @param mixinClassName fully qualified class name of the mixin
39+
* @return true if the given mixin class should be applied, false otherwise.
40+
*/
41+
@Override
42+
public boolean shouldApplyMixin(@NotNull String targetClassName, @NotNull String mixinClassName) {
43+
var isForwardMixin = mixinClassName.contains(".forward.");
44+
return !isForwardMixin || !DISABLE_CLOUDNET_FORWARDING;
45+
}
46+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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_11_2.forward;
18+
19+
import com.mojang.authlib.GameProfile;
20+
import com.mojang.authlib.properties.Property;
21+
import io.netty.util.AttributeKey;
22+
import java.util.ArrayList;
23+
import java.util.List;
24+
import java.util.UUID;
25+
import org.jetbrains.annotations.NotNull;
26+
27+
/**
28+
* Accumulator for forwarded player data.
29+
*
30+
* @since 2025.08.26
31+
*/
32+
public final class ForwardingDataAccumulator {
33+
34+
/**
35+
* Key to get the forward data accumulator from a netty channel.
36+
*/
37+
public static final AttributeKey<ForwardingDataAccumulator> ACCUMULATOR_KEY =
38+
AttributeKey.valueOf("cloudnet_bridge$forward_data_accumulator");
39+
40+
/**
41+
* List of forwarded properties. Should only be appended to.
42+
*/
43+
public final List<Property> properties = new ArrayList<>();
44+
45+
/**
46+
* The unique id of the forwarded player.
47+
*/
48+
public UUID uniqueId;
49+
50+
/**
51+
* Converts the accumulated data into a game profile.
52+
*
53+
* @param name the name of the player.
54+
* @return the constructed game profile from the accumulated data.
55+
* @throws NullPointerException if the given name is null or this accumulator wasn't filled properly.
56+
*/
57+
public @NotNull GameProfile toGameProfile(@NotNull String name) {
58+
var profile = new GameProfile(this.uniqueId, name);
59+
for (var property : this.properties) {
60+
profile.getProperties().put(property.getName(), property);
61+
}
62+
63+
return profile;
64+
}
65+
}

0 commit comments

Comments
 (0)