Skip to content

Commit

Permalink
resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
0utplay committed Dec 21, 2024
2 parents 0df0c9d + 9389d89 commit 54f5d05
Show file tree
Hide file tree
Showing 23 changed files with 221 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import net.minestom.server.listener.manager.PacketListenerManager;
import net.minestom.server.monitoring.BenchmarkManager;
import net.minestom.server.network.ConnectionManager;
import net.minestom.server.network.PacketProcessor;
import net.minestom.server.network.packet.PacketParser;
import net.minestom.server.recipe.RecipeManager;
import net.minestom.server.scoreboard.TeamManager;
import net.minestom.server.timer.SchedulerManager;
Expand All @@ -63,7 +63,7 @@ public MinestomPlatformPluginManager() {
layer.install(builder.bind(RecipeManager.class).toInstance(MinecraftServer.getRecipeManager()));
layer.install(builder.bind(BossBarManager.class).toInstance(MinecraftServer.getBossBarManager()));
layer.install(builder.bind(CommandManager.class).toInstance(MinecraftServer.getCommandManager()));
layer.install(builder.bind(PacketProcessor.class).toInstance(MinecraftServer.getPacketProcessor()));
layer.install(builder.bind(PacketParser.class).toInstance(MinecraftServer.getPacketParser()));
layer.install(builder.bind(InstanceManager.class).toInstance(MinecraftServer.getInstanceManager()));
layer.install(builder.bind(ExceptionManager.class).toInstance(MinecraftServer.getExceptionManager()));
layer.install(builder.bind(BenchmarkManager.class).toInstance(MinecraftServer.getBenchmarkManager()));
Expand Down
44 changes: 23 additions & 21 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
[versions]

# plugins
shadow = "8.3.3"
shadow = "8.3.5"
juppiter = "0.4.0"
spotless = "6.25.0"
fabricLoom = "1.8.10"
fabricLoom = "1.9.2"
nexusPublish = "2.0.0"
checkstyleTools = "10.18.2"
checkstyleTools = "10.21.0"

# google libs
gson = "2.11.0"
guava = "33.3.1-jre"
guava = "33.4.0-jre"

# testing
junit = "5.11.2"
junit = "5.11.4"
mockito = "5.14.2"
junitLauncher = "1.11.2"
testcontainers = "1.20.2"
junitLauncher = "1.11.4"
testcontainers = "1.20.4"

# compile time processing
lombok = "1.18.34"
lombok = "1.18.36"
javapoet = "1.13.0"

# console
jline = "3.27.1"
jline = "3.28.0"
cloud = "2.0.0-cn1"
cloudConfirmation = "1.0.0-rc.1"
stringSimilarity = "2.0.0"

# databases
h2 = "1.4.197" # do not update, leads to database incompatibility
xodus = "2.0.1"
mongodb = "5.2.0"
hikariCp = "6.0.0"
mysqlConnector = "9.0.0"
mongodb = "5.2.1"
hikariCp = "6.2.1"
mysqlConnector = "9.1.0"

# general
oshi = "6.6.5"
vavr = "0.10.5"
sshj = "0.39.0"
aerogel = "3.0.0-SNAPSHOT"
awsSdk = "2.28.26"
unirest = "4.4.4"
awsSdk = "2.29.35"
unirest = "4.4.5"
caffeine = "3.1.8"
reflexion = "1.8.0"
geantyref = "2.0.0"
dockerJava = "3.4.0"
dockerJava = "3.4.1"
nightConfig = "3.8.1"
annotations = "26.0.1"
influxClient = "7.2.0"
Expand All @@ -54,14 +54,14 @@ gulf = "1.0.0-SNAPSHOT"

# logging
slf4j = "2.0.16"
logback = "1.5.11"
logback = "1.5.12"

# platform api versions
sponge = "9.0.0"
velocity = "3.3.0-SNAPSHOT"
waterdogpe = "1.2.4"
nukkitX = "1.0-SNAPSHOT"
minestom = "0651c4e401"
minestom = "ccea53ac44"
minestomExtensions = "1.2.0"
spigot = "1.8.8-R0.1-SNAPSHOT"
bungeecord = "1.21-R0.1-SNAPSHOT"
Expand All @@ -71,14 +71,15 @@ limboloohp = "0.7.9-ALPHA"
vault = "1.7.1"
adventure = "4.17.0"
modlauncher = "8.1.3"
npcLib = "3.0.0-beta9"
npcLib = "3.0.0-beta10"
packetEvents = "2.7.0"
placeholderApi = "2.11.6"
adventure-serializer-bungee = "4.3.4"
luckPermsApi = "5.4"

# fabric platform special dependencies
minecraft = "1.21.1"
fabricLoader = "0.16.7"
minecraft = "1.21.4"
fabricLoader = "0.16.9"


[libraries]
Expand Down Expand Up @@ -167,7 +168,7 @@ spigot = { group = "org.spigotmc", name = "spigot-api", version.ref = "spigot" }
sponge = { group = "org.spongepowered", name = "spongeapi", version.ref = "sponge" }
bungeecord = { group = "net.md-5", name = "bungeecord-api", version.ref = "bungeecord" }
minestom = { group = "net.minestom", name = "minestom-snapshots", version.ref = "minestom" }
minestomExtensions = { group = "dev.hollowcube", name = "minestom-ce-extensions", version.ref = "minestomExtensions"}
minestomExtensions = { group = "dev.hollowcube", name = "minestom-ce-extensions", version.ref = "minestomExtensions" }
velocity = { group = "com.velocitypowered", name = "velocity-api", version.ref = "velocity" }
waterdogpe = { group = "dev.waterdog.waterdogpe", name = "waterdog", version.ref = "waterdogpe" }
limboloohp = { group = "com.loohp", name = "Limbo", version.ref = "limboloohp" }
Expand All @@ -185,6 +186,7 @@ bungeecordChat = { group = "net.md-5", name = "bungeecord-chat", version.ref = "
placeholderApi = { group = "me.clip", name = "placeholderapi", version.ref = "placeholderApi" }

npcLib = { group = "io.github.juliarn", name = "npc-lib-bukkit", version.ref = "npcLib" }
packetEvents = { group = "com.github.retrooper", name = "packetevents-spigot", version.ref = "packetEvents" }
npcLibLabymod = { group = "io.github.juliarn", name = "npc-lib-labymod", version.ref = "npcLib" }
luckPermsApi = { group = "net.luckperms", name = "api", version.ref = "luckPermsApi" }

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=31c55713e40233a8303827ceb42ca48a47267a0ad4bab9177123121e71524c26
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionSha256Sum=f397b287023acdba1e9f6fc5ea72d22dd63669d59ed4a289a29b1a76eee151c6
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
9 changes: 5 additions & 4 deletions modules/bridge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,10 @@ tasks.withType<Jar> {
manifest {
attributes["paperweight-mappings-namespace"] = "mojang"
}
}

tasks.withType<RemapJarTask> {
// depend on adventure helper jar task
dependsOn(":ext:adventure-helper:jar")
// base setup
archiveFileName.set(Files.bridge)

duplicatesStrategy = DuplicatesStrategy.EXCLUDE
// includes all dependencies of runtimeImpl but excludes gson because we don't need it
from(configurations.getByName("runtimeImpl").map { if (it.isDirectory) it else zipTree(it) })
Expand All @@ -67,6 +64,10 @@ tasks.withType<RemapJarTask> {
}
}

tasks.withType<RemapJarTask> {
archiveFileName.set(Files.bridge)
}

loom {
accessWidenerPath.set(project.file("src/main/resources/cloudnet_bridge.accesswidener"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@
import jakarta.inject.Inject;
import jakarta.inject.Singleton;
import java.util.Collections;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.function.BiFunction;
import java.util.function.Supplier;
import lombok.NonNull;
import net.minestom.server.MinecraftServer;
import net.minestom.server.command.CommandManager;
Expand All @@ -57,11 +59,10 @@
@ProvidesFor(platform = "minestom", types = {PlatformBridgeManagement.class, BridgeManagement.class})
public final class MinestomBridgeManagement extends PlatformBridgeManagement<Player, NetworkPlayerServerInfo> {

private static final BiFunction<Player, String, Boolean> PERM_FUNCTION = Player::hasPermission;

private final CommandManager commandManager;
private final ConnectionManager connectionManager;
private final PlayerExecutor directGlobalExecutor;
private final Supplier<MinestomPermissionChecker> permissionChecker;

@Inject
public MinestomBridgeManagement(
Expand All @@ -70,6 +71,7 @@ public MinestomBridgeManagement(
@NonNull NetworkClient networkClient,
@NonNull CommandManager commandManager,
@NonNull GlobalEventHandler eventHandler,
@NonNull ServiceRegistry serviceRegistry,
@NonNull ServiceTaskProvider taskProvider,
@NonNull BridgeServiceHelper serviceHelper,
@NonNull ConnectionManager connectionManager,
Expand All @@ -89,7 +91,13 @@ public MinestomBridgeManagement(
// init fields
this.commandManager = commandManager;
this.connectionManager = connectionManager;

this.permissionChecker = () -> Objects.requireNonNullElse(
serviceRegistry.firstProvider(MinestomPermissionChecker.class),
((player, _) -> player.getPermissionLevel() > 0));

this.directGlobalExecutor = new MinestomDirectPlayerExecutor(
this.permissionChecker,
commandManager,
PlayerExecutor.GLOBAL_UNIQUE_ID,
connectionManager::getOnlinePlayers);
Expand Down Expand Up @@ -126,12 +134,15 @@ public void registerServices(@NonNull ServiceRegistry registry) {

@Override
public @NonNull BiFunction<Player, String, Boolean> permissionFunction() {
return PERM_FUNCTION;
return this.permissionChecker.get()::hasPermission;
}

@Override
public boolean isOnAnyFallbackInstance(@NonNull Player player) {
return this.isOnAnyFallbackInstance(this.ownNetworkServiceInfo.serverName(), null, player::hasPermission);
return this.isOnAnyFallbackInstance(
this.ownNetworkServiceInfo.serverName(),
null,
perm -> this.permissionFunction().apply(player, perm));
}

@Override
Expand All @@ -141,7 +152,7 @@ public boolean isOnAnyFallbackInstance(@NonNull Player player) {

@Override
public @NonNull Optional<ServiceInfoSnapshot> fallback(@NonNull Player player, @Nullable String currServer) {
return this.fallback(player.getUuid(), currServer, null, player::hasPermission);
return this.fallback(player.getUuid(), currServer, null, perm -> this.permissionFunction().apply(player, perm));
}

@Override
Expand All @@ -159,6 +170,7 @@ public void removeFallbackProfile(@NonNull Player player) {
return uniqueId.equals(PlayerExecutor.GLOBAL_UNIQUE_ID)
? this.directGlobalExecutor
: new MinestomDirectPlayerExecutor(
this.permissionChecker,
this.commandManager,
uniqueId,
() -> Collections.singleton(this.connectionManager.getOnlinePlayerByUuid(uniqueId)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@

final class MinestomDirectPlayerExecutor extends PlatformPlayerExecutorAdapter<Player> {

private final Supplier<MinestomPermissionChecker> permissionChecker;
private final CommandManager commandManager;

public MinestomDirectPlayerExecutor(
@NonNull Supplier<MinestomPermissionChecker> permissionChecker,
@NonNull CommandManager commandManager,
@NonNull UUID uniqueId,
@NonNull Supplier<? extends Collection<? extends Player>> supplier
) {
super(uniqueId, supplier);
this.permissionChecker = permissionChecker;
this.commandManager = commandManager;
}

Expand Down Expand Up @@ -79,7 +82,7 @@ public void sendTitle(@NonNull Title title) {
@Override
public void sendChatMessage(@NonNull Component message, @Nullable String permission) {
this.forEach(player -> {
if (permission == null || player.hasPermission(permission)) {
if (permission == null || this.permissionChecker.get().hasPermission(player, permission)) {
player.sendMessage(message);
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2019-2024 CloudNetService team & contributors
*
* 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 eu.cloudnetservice.modules.bridge.platform.minestom;

import lombok.NonNull;
import net.minestom.server.entity.Player;

@FunctionalInterface
public interface MinestomPermissionChecker {

boolean hasPermission(@NonNull Player player, @NonNull String permission);

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,14 @@
package eu.cloudnetservice.modules.bridge.platform.minestom;

import eu.cloudnetservice.ext.component.ComponentFormats;
import eu.cloudnetservice.modules.bridge.platform.PlatformBridgeManagement;
import eu.cloudnetservice.modules.bridge.platform.helper.ServerPlatformHelper;
import eu.cloudnetservice.modules.bridge.player.NetworkPlayerServerInfo;
import eu.cloudnetservice.wrapper.holder.ServiceInfoHolder;
import jakarta.inject.Inject;
import jakarta.inject.Singleton;
import lombok.NonNull;
import net.minestom.server.entity.Player;
import net.minestom.server.event.EventFilter;
import net.minestom.server.event.EventNode;
import net.minestom.server.event.GlobalEventHandler;
import net.minestom.server.event.player.AsyncPlayerPreLoginEvent;
import net.minestom.server.event.player.PlayerDisconnectEvent;
import net.minestom.server.event.player.PlayerSpawnEvent;

Expand All @@ -37,33 +33,38 @@ public final class MinestomPlayerManagementListener {

private final ServiceInfoHolder serviceInfoHolder;
private final ServerPlatformHelper serverPlatformHelper;
private final PlatformBridgeManagement<Player, NetworkPlayerServerInfo> management;
private final MinestomBridgeManagement management;

@Inject
public MinestomPlayerManagementListener(
@NonNull GlobalEventHandler eventHandler,
@NonNull ServiceInfoHolder serviceInfoHolder,
@NonNull ServerPlatformHelper serverPlatformHelper,
@NonNull PlatformBridgeManagement<Player, NetworkPlayerServerInfo> management
@NonNull MinestomBridgeManagement management
) {
this.serviceInfoHolder = serviceInfoHolder;
this.serverPlatformHelper = serverPlatformHelper;
this.management = management;
// listen on these events and redirect them into the methods
var node = EventNode.type("cloudnet-bridge", EventFilter.PLAYER);
eventHandler.addChild(node
.addListener(AsyncPlayerPreLoginEvent.class, this::handleLogin)
.addListener(PlayerSpawnEvent.class, this::handleLogin)
.addListener(PlayerSpawnEvent.class, this::handleJoin)
.addListener(PlayerDisconnectEvent.class, this::handleDisconnect));
}

private void handleLogin(@NonNull AsyncPlayerPreLoginEvent event) {
private void handleLogin(@NonNull PlayerSpawnEvent event) {
if (!event.isFirstSpawn()) {
return;
}

var player = event.getPlayer();
var task = this.management.selfTask();
var permissionFunction = this.management.permissionFunction();
// check if the current task is present
if (task != null) {
// check if maintenance is activated
if (task.maintenance() && !player.hasPermission("cloudnet.bridge.maintenance")) {
if (task.maintenance() && !permissionFunction.apply(player, "cloudnet.bridge.maintenance")) {
this.management.configuration().handleMessage(
player.getLocale(),
"server-join-cancel-because-maintenance",
Expand All @@ -73,7 +74,7 @@ private void handleLogin(@NonNull AsyncPlayerPreLoginEvent event) {
}
// check if a custom permission is required to join
var permission = task.propertyHolder().getString("requiredPermission");
if (permission != null && !player.hasPermission(permission)) {
if (permission != null && !permissionFunction.apply(player, permission)) {
this.management.configuration().handleMessage(
player.getLocale(),
"server-join-cancel-because-permission",
Expand Down
Loading

0 comments on commit 54f5d05

Please sign in to comment.