Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions Plan/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
id("base")
id "org.sonarqube" version "7.3.1.8318"
id "com.gradleup.shadow" version "9.6.1" apply false
id "net.fabricmc.fabric-loom" version "1.17.17" apply false
id "net.fabricmc.fabric-loom-remap" version "1.17.17" apply false
id "net.neoforged.moddev" version "2.0.143" apply false
}

Expand Down Expand Up @@ -150,8 +150,24 @@ subprojects {
}
}

// Fabric + NeoForge on this branch target Minecraft 1.21.1 (Java 21 runtime).
plugins.withId("java") {
if (project.name == "fabric" || project.name == "neoforge") {
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
tasks.withType(JavaCompile).configureEach {
options.release = 21
}
}
}

tasks.withType(JavaCompile).configureEach {
options.release = 25
if (project.name != "fabric" && project.name != "neoforge") {
options.release = 25
}
options.encoding = "UTF-8"
options.fork = true
}
Expand Down
13 changes: 7 additions & 6 deletions Plan/fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

apply plugin: "net.fabricmc.fabric-loom"
apply plugin: "net.fabricmc.fabric-loom-remap"
apply plugin: "com.gradleup.shadow"

configurations {
Expand All @@ -16,9 +16,10 @@ dependencies {

implementation "net.playeranalytics:platform-abstraction-layer-api:$palVersion"

minecraft "com.mojang:minecraft:26.2"
implementation "net.fabricmc:fabric-loader:0.19.3"
implementation("me.lucko:fabric-permissions-api:0.7.0")
minecraft "com.mojang:minecraft:1.21.1"
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:0.16.14"
modImplementation("me.lucko:fabric-permissions-api:0.3.3")

// Fabric API
Set<String> apiModules = [
Expand All @@ -31,15 +32,15 @@ dependencies {
]

apiModules.forEach {
implementation(fabricApi.module(it, "0.153.0+26.2"))
modImplementation(fabricApi.module(it, "0.116.15+1.21.1"))
}

testImplementation(testFixtures(project(":common")))
testImplementation(project(":extensions:adventure"))
}

compileJava {
options.release = 25
options.release = 21
}

processResources {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import net.minecraft.commands.Commands;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component;
import net.minecraft.server.permissions.Permissions;
import com.djrapitops.plan.PlanPlugin;
import net.playeranalytics.plugin.scheduling.RunnableFactory;

Expand All @@ -56,8 +55,15 @@ public FabricCommandManager(CommandDispatcher<CommandSourceStack> dispatcher, Pl

public static boolean checkPermission(CommandSourceStack src, String permission) {
if (isPermissionsApiAvailable()) {
return me.lucko.fabric.api.permissions.v0.Permissions.check(src, permission, 2);
} else if (src.permissions().hasPermission(Permissions.COMMANDS_GAMEMASTER)) {
try {
Class<?> permissions = Class.forName("me.lucko.fabric.api.permissions.v0.Permissions");
return (Boolean) permissions.getMethod("check", CommandSourceStack.class, String.class, int.class)
.invoke(null, src, permission, 2);
} catch (ReflectiveOperationException e) {
// Fall through to vanilla permission levels
}
}
if (src.hasPermission(2)) {
return true;
} else {
return switch (permission) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import net.minecraft.network.chat.Component;
import org.apache.commons.text.TextStringBuilder;

import java.net.URI;
import java.util.Collection;

public class FabricMessageBuilder implements MessageBuilder {
Expand Down Expand Up @@ -59,31 +58,31 @@ public MessageBuilder newLine() {

@Override
public MessageBuilder link(String url) {
builder.withStyle(style -> style.withClickEvent(new ClickEvent.OpenUrl(URI.create(url))));
builder.withStyle(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url)));
return this;
}

@Override
public MessageBuilder command(String command) {
builder.withStyle(style -> style.withClickEvent(new ClickEvent.RunCommand(command.charAt(0) == '/' ? command : '/' + command)));
builder.withStyle(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command.charAt(0) == '/' ? command : '/' + command)));
return this;
}

@Override
public MessageBuilder hover(String message) {
builder.withStyle(style -> style.withHoverEvent(new HoverEvent.ShowText(Component.literal(message))));
builder.withStyle(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal(message))));
return this;
}

@Override
public MessageBuilder hover(String... lines) {
builder.withStyle(style -> style.withHoverEvent(new HoverEvent.ShowText(Component.literal(new TextStringBuilder().appendWithSeparators(lines, "\n").toString()))));
builder.withStyle(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal(new TextStringBuilder().appendWithSeparators(lines, "\n").toString()))));
return this;
}

@Override
public MessageBuilder hover(Collection<String> lines) {
builder.withStyle(style -> style.withHoverEvent(new HoverEvent.ShowText(Component.literal(new TextStringBuilder().appendWithSeparators(lines, "\n").toString()))));
builder.withStyle(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal(new TextStringBuilder().appendWithSeparators(lines, "\n").toString()))));
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public UUID getUUID() {

@Override
public String getName() {
return player.getGameProfile().name();
return player.getGameProfile().getName();
}

@Override
Expand All @@ -56,12 +56,12 @@ public Optional<String> getDisplayName() {

@Override
public Optional<Boolean> isOperator() {
return Optional.of(server.getPlayerList().getOps().get(player.nameAndId()) != null);
return Optional.of(server.getPlayerList().getOps().get(player.getGameProfile()) != null);
}

@Override
public Optional<String> getCurrentWorld() {
return Optional.of(player.level().dimension().identifier().toString());
return Optional.of(player.level().dimension().location().toString());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.network.protocol.handshake.ClientIntentionPacket;
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
import net.minecraft.server.players.NameAndId;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.network.chat.Component;
import net.minecraft.world.level.GameType;
import com.djrapitops.plan.PlanPlugin;
import com.mojang.authlib.GameProfile;
import net.playeranalytics.plan.gathering.FabricPlayerPositionTracker;

import java.net.SocketAddress;
Expand Down Expand Up @@ -173,7 +173,7 @@ public interface OnLogin {
* @param profile the profile of the player
* @param reason the provided kick reason (null if player is permitted to join)
*/
void onLogin(SocketAddress address, NameAndId profile, Component reason);
void onLogin(SocketAddress address, GameProfile profile, Component reason);
}

@FunctionalInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void register() {
return;
}

ServerEntityCombatEvents.AFTER_KILLED_OTHER_ENTITY.register((world, killer, killedEntity, damageSource) ->
ServerEntityCombatEvents.AFTER_KILLED_OTHER_ENTITY.register((world, killer, killedEntity) ->
{
if (!this.isEnabled) {
return;
Expand Down Expand Up @@ -131,7 +131,7 @@ public String findWeapon(Entity killer) {

private String getItemInHand(ServerPlayer killer) {
ItemStack itemInHand = killer.getMainHandItem();
return itemInHand.getItemName().getString();
return itemInHand.getHoverName().getString();
}

private Optional<ServerPlayer> getShooter(Projectile projectile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.djrapitops.plan.settings.config.PlanConfig;
import com.djrapitops.plan.utilities.logging.ErrorContext;
import com.djrapitops.plan.utilities.logging.ErrorLogger;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.fabricmc.fabric.api.message.v1.ServerMessageEvents;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import net.minecraft.server.level.ServerPlayer;
Expand Down Expand Up @@ -84,7 +83,13 @@ private void event(ServerPlayer player) {

private boolean checkPermission(ServerPlayer player, String permission) {
if (FabricCommandManager.isPermissionsApiAvailable()) {
return Permissions.check(player, permission);
try {
Class<?> permissions = Class.forName("me.lucko.fabric.api.permissions.v0.Permissions");
return (Boolean) permissions.getMethod("check", ServerPlayer.class, String.class)
.invoke(null, player, permission);
} catch (ReflectiveOperationException e) {
return false;
}
} else {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private void actOnEvent(ServerPlayer player, GameType newGameMode) {
UUID uuid = player.getUUID();
long time = System.currentTimeMillis();
String gameMode = newGameMode.name();
String worldName = player.level().dimension().identifier().toString();
String worldName = player.level().dimension().location().toString();

dbSystem.getDatabase().executeTransaction(new StoreWorldNameTransaction(serverInfo.getServerUUID(), worldName));
worldAliasSettings.addWorld(worldName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import net.minecraft.network.protocol.handshake.ClientIntent;
import net.minecraft.network.protocol.handshake.ClientIntentionPacket;
import net.minecraft.server.players.NameAndId;
import net.minecraft.server.dedicated.DedicatedServer;
import net.minecraft.server.level.ServerPlayer;
import net.playeranalytics.plan.gathering.FabricPlayerPositionTracker;
Expand Down Expand Up @@ -141,9 +140,9 @@ private void onHandshake(ClientIntentionPacket packet) {
}
}

public void onPlayerLogin(SocketAddress address, NameAndId profile, boolean banned) {
public void onPlayerLogin(SocketAddress address, GameProfile profile, boolean banned) {
try {
UUID playerUUID = profile.id();
UUID playerUUID = profile.getId();
ServerUUID serverUUID = serverInfo.getServerUUID();

String playerJoinAddress = joinAddress.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.djrapitops.plan.storage.database.transactions.events.StoreWorldNameTransaction;
import com.djrapitops.plan.utilities.logging.ErrorContext;
import com.djrapitops.plan.utilities.logging.ErrorLogger;
import net.fabricmc.fabric.api.entity.event.v1.ServerEntityLevelChangeEvents;
import net.fabricmc.fabric.api.entity.event.v1.ServerEntityWorldChangeEvents;
import net.minecraft.server.level.ServerPlayer;
import net.playeranalytics.plan.gathering.listeners.FabricListener;

Expand Down Expand Up @@ -70,7 +70,7 @@ private void actOnEvent(ServerPlayer player) {

UUID uuid = player.getUUID();

String worldName = player.level().dimension().identifier().toString();
String worldName = player.level().dimension().location().toString();
String gameMode = player.gameMode.getGameModeForPlayer().name();

dbSystem.getDatabase().executeTransaction(new StoreWorldNameTransaction(serverInfo.getServerUUID(), worldName));
Expand All @@ -86,7 +86,7 @@ public void register() {
return;
}

ServerEntityLevelChangeEvents.AFTER_PLAYER_CHANGE_LEVEL.register((player, _, _) -> {
ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.register((player, origin, destination) -> {
if (!this.isEnabled) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public MessageBuilder buildMessage() {

@Override
public Optional<String> getPlayerName() {
return getPlayer().map(ServerPlayer::getGameProfile).map(GameProfile::name);
return getPlayer().map(ServerPlayer::getGameProfile).map(GameProfile::getName);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package net.playeranalytics.plan.gathering.mixin;

import net.minecraft.server.players.NameAndId;
import com.mojang.authlib.GameProfile;
import net.minecraft.server.players.PlayerList;
import net.minecraft.network.chat.Component;
import net.playeranalytics.plan.gathering.listeners.events.PlanFabricEvents;
Expand All @@ -31,8 +31,8 @@
public class PlayerListMixin {

@Inject(method = "canPlayerLogin", at = @At(value = "TAIL"))
public void onLogin(SocketAddress address, NameAndId nameAndId, CallbackInfoReturnable<Component> cir) {
PlanFabricEvents.ON_LOGIN.invoker().onLogin(address, nameAndId, cir.getReturnValue());
public void onLogin(SocketAddress address, GameProfile profile, CallbackInfoReturnable<Component> cir) {
PlanFabricEvents.ON_LOGIN.invoker().onLogin(address, profile, cir.getReturnValue());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public FabricServerProperties(DedicatedServer server) {
FabricLoader.getInstance().getModContainer("fabricloader").map(modContainer -> modContainer.getMetadata().getVersion().getFriendlyString()).orElse("Unknown") +
" (loader)",
() -> (server.getLocalIp() == null) ? "" : server.getLocalIp(),
server.getProperties().maxPlayers.get()
server.getMaxPlayers()
);
}
}
8 changes: 4 additions & 4 deletions Plan/fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
"plan.mixins.json"
],
"depends": {
"minecraft": ">=26.1",
"java": ">=25",
"fabricloader": ">=0.18.6",
"minecraft": "~1.21.1",
"java": ">=21",
"fabricloader": ">=0.16.0",
"fabric-api": "*"
},
"suggests": {
"fabric-permissions-api-v0": "^0.7.0",
"fabric-permissions-api-v0": "*",
"luckperms": "*"
}
}
2 changes: 1 addition & 1 deletion Plan/fabric/src/main/resources/plan.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"required": true,
"minVersion": "0.8",
"package": "net.playeranalytics.plan.gathering.mixin",
"compatibilityLevel": "JAVA_25",
"compatibilityLevel": "JAVA_21",
"mixins": [
"ClientToServerHandshakePacketMixin",
"KickCommandMixin",
Expand Down
Loading
Loading