Fixes for Fabric 1.19 by Kopo (#2419)

* Gradle 7.4.2
* Build changes for MC 1.19

- Updated loom to minor version 0.12 & moved to root project
- Updated mappings, command API, fabric API & loader version
- Moved Selenium to common module because of a conflict with loom's dependency resolution

* Add remap folder to .gitignore
* Fix version token replacement
* Update to Minecraft 1.19
* Don't forget the pipelines

Affects issues:
- Fixed #2417
This commit is contained in:
Antti Koponen 2022-06-10 16:21:53 +03:00 committed by GitHub
parent f191c47c25
commit 4196141db1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 59 additions and 91 deletions

View File

@ -26,7 +26,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '16'
java-version: '17'
- name: Setup Selenium Webdriver
uses: nanasess/setup-chromedriver@v1
- name: Setup Selenium Webdriver settings

View File

@ -28,7 +28,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '16'
java-version: '17'
- name: Setup Selenium Webdriver
uses: nanasess/setup-chromedriver@v1
- name: Setup Selenium Webdriver settings

View File

@ -20,7 +20,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '16'
java-version: '17'
- name: Build Javadocs 🔧
run: |
cd Plan

30
.gitignore vendored
View File

@ -12,6 +12,9 @@ server.log
**/.gradle
out/
# Fabric
remappedSrc/
# Created by https://www.gitignore.io/api/maven,eclipse,intellij,netbeans,osx,windows,notepadpp,windows,java
### Maven ###
@ -165,33 +168,6 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk
### NotepadPP ###
# Notepad++ backups #
*.bak
### Windows ###
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
### Java ###
*.class

View File

@ -12,6 +12,7 @@ plugins {
id "jacoco"
id "checkstyle"
id "org.sonarqube" version "3.4.0.2513"
id 'fabric-loom' version '0.12.+' apply false
}
apply plugin: 'nebula-aggregate-javadocs'
@ -115,7 +116,6 @@ subprojects {
testImplementation "org.junit.jupiter:junit-jupiter:$junitVersion" // JUnit 5
testImplementation "org.mockito:mockito-core:$mockitoVersion" // Mockito Core
testImplementation "org.mockito:mockito-junit-jupiter:$mockitoVersion" // Mockito JUnit 5 Extension
testImplementation "org.seleniumhq.selenium:selenium-java:4.2.1" // Selenium (Browser tests)
testImplementation "com.jayway.awaitility:awaitility:1.7.0" // Awaitility (Concurrent wait conditions)
// Testing dependencies required by Plan

View File

@ -52,7 +52,7 @@ dependencies {
testImplementation project(":api")
testImplementation "com.google.code.gson:gson:$gsonVersion"
testImplementation "org.seleniumhq.selenium:selenium-java:4.2.1"
testImplementation "org.testcontainers:testcontainers:$testContainersVersion"
testImplementation "org.testcontainers:junit-jupiter:$testContainersVersion"
testImplementation "org.testcontainers:nginx:$testContainersVersion"

View File

@ -1,8 +1,4 @@
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
id 'fabric-loom' version '0.9.+'
}
apply plugin: 'fabric-loom'
dependencies {
shadow "net.playeranalytics:platform-abstraction-layer-api:$palVersion"
@ -11,42 +7,36 @@ dependencies {
compileOnly project(":api")
modImplementation('me.lucko:fabric-permissions-api:0.1-SNAPSHOT')
minecraft "com.mojang:minecraft:1.17.1"
mappings "net.fabricmc:yarn:1.17.1+build.35:v2"
modImplementation "net.fabricmc:fabric-loader:0.11.6"
minecraft "com.mojang:minecraft:1.19"
mappings "net.fabricmc:yarn:1.19+build.1:v2"
modImplementation "net.fabricmc:fabric-loader:0.14.7"
// Fabric API
Set<String> apiModules = [
'fabric-api-base',
'fabric-command-api-v1',
'fabric-command-api-v2',
'fabric-entity-events-v1',
'fabric-lifecycle-events-v1',
'fabric-networking-api-v1'
]
apiModules.forEach {
modImplementation(fabricApi.module(it, "0.37.1+1.17"))
modImplementation(fabricApi.module(it, "0.55.3+1.19"))
}
testImplementation project(path: ":common", configuration: 'testArtifacts')
}
compileJava {
options.release = 16
}
tasks.register('updateVersion', Copy) {
from('src/main/resources') {
include 'fabric.mod.json'
}
into 'build/sources/resources/'
filter(ReplaceTokens, tokens: [version: '' + project.ext.fullVersion])
tasks.withType(JavaCompile).configureEach {
options.release = 17
}
processResources {
dependsOn updateVersion
duplicatesStrategy = DuplicatesStrategy.INCLUDE
from 'build/sources/resources'
inputs.property "version", project.ext.fullVersion
filesMatching("fabric.mod.json") {
expand "version": project.ext.fullVersion
}
}
shadowJar {

View File

@ -26,7 +26,7 @@ import com.djrapitops.plan.settings.locale.Locale;
import com.djrapitops.plan.settings.locale.lang.PluginLang;
import com.djrapitops.plan.settings.theme.PlanColorScheme;
import net.fabricmc.api.DedicatedServerModInitializer;
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.server.dedicated.MinecraftDedicatedServer;
@ -163,7 +163,7 @@ public class PlanFabric implements PlanPlugin, DedicatedServerModInitializer {
onEnable();
});
CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> commandManager = new CommandManager(dispatcher, this));
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> commandManager = new CommandManager(dispatcher, this));
ServerLifecycleEvents.SERVER_STOPPING.register(server -> onDisable());
}

View File

@ -32,7 +32,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.command.CommandSource;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.playeranalytics.plan.PlanFabric;
import net.playeranalytics.plugin.scheduling.RunnableFactory;
@ -82,9 +82,9 @@ public class CommandManager {
subcommand.getExecutor().accept((CMDSender) ctx.getSource(), new Arguments(getCommandArguments(ctx)));
} catch (Exception e) {
if (e instanceof IllegalArgumentException) {
ctx.getSource().sendError(new LiteralText(e.getMessage()));
ctx.getSource().sendError(Text.literal(e.getMessage()));
} else {
ctx.getSource().sendError(new LiteralText("An internal error occurred, see the console for details."));
ctx.getSource().sendError(Text.literal("An internal error occurred, see the console for details."));
plugin.getSystem().getErrorLogger().error(e, ErrorContext.builder()
.related(ctx.getSource().getClass())
.related(subcommand.getPrimaryAlias() + " " + getCommandArguments(ctx))

View File

@ -19,7 +19,10 @@ package net.playeranalytics.plan.commands.use;
import com.djrapitops.plan.commands.use.CMDSender;
import com.djrapitops.plan.commands.use.MessageBuilder;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.*;
import net.minecraft.text.ClickEvent;
import net.minecraft.text.HoverEvent;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import org.apache.commons.text.TextStringBuilder;
import java.util.Collection;
@ -36,7 +39,7 @@ public class FabricMessageBuilder implements MessageBuilder {
FabricMessageBuilder(ServerCommandSource sender, FabricMessageBuilder previous) {
this.sender = sender;
this.builder = new LiteralText("");
this.builder = Text.literal("");
this.previous = previous;
}
@ -67,19 +70,19 @@ public class FabricMessageBuilder implements MessageBuilder {
@Override
public MessageBuilder hover(String message) {
builder.styled(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText(message))));
builder.styled(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal(message))));
return this;
}
@Override
public MessageBuilder hover(String... lines) {
builder.styled(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText(new TextStringBuilder().appendWithSeparators(lines, "\n").toString()))));
builder.styled(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal(new TextStringBuilder().appendWithSeparators(lines, "\n").toString()))));
return this;
}
@Override
public MessageBuilder hover(Collection<String> lines) {
builder.styled(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText(new TextStringBuilder().appendWithSeparators(lines, "\n").toString()))));
builder.styled(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal(new TextStringBuilder().appendWithSeparators(lines, "\n").toString()))));
return this;
}

View File

@ -23,13 +23,13 @@ import net.playeranalytics.plan.gathering.listeners.events.PlanFabricEvents;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(Entity.class)
public class EntityMixin {
@Inject(method = "onKilledOther", at = @At(value = "TAIL"))
public void onDeath(ServerWorld world, LivingEntity other, CallbackInfo ci) {
public void onDeath(ServerWorld world, LivingEntity other, CallbackInfoReturnable<Boolean> cir) {
PlanFabricEvents.ON_KILLED.invoker().onKilled(other, (Entity) (Object) this);
}

View File

@ -23,13 +23,13 @@ import net.playeranalytics.plan.gathering.listeners.events.PlanFabricEvents;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(PlayerEntity.class)
public class PlayerEntityMixin {
@Inject(method = "onKilledOther", at = @At(value = "TAIL"))
public void onDeath(ServerWorld world, LivingEntity other, CallbackInfo ci) {
@Inject(method = "onKilledOther", at = @At("TAIL"))
public void onDeath(ServerWorld world, LivingEntity other, CallbackInfoReturnable<Boolean> cir) {
PlanFabricEvents.ON_KILLED.invoker().onKilled(other, (PlayerEntity) (Object) this);
}

View File

@ -20,7 +20,6 @@ import com.djrapitops.plan.commands.use.*;
import net.minecraft.entity.Entity;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.playeranalytics.plan.commands.CommandManager;
import net.playeranalytics.plan.commands.use.FabricMessageBuilder;
@ -73,7 +72,7 @@ public abstract class ServerCommandSourceMixin implements CMDSender {
@Override
public void send(String message) {
this.sendFeedback(new LiteralText(message), false);
this.sendFeedback(Text.literal(message), false);
}
@Override

View File

@ -28,12 +28,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ServerPlayNetworkHandler.class)
public class ServerPlayNetworkHandlerMixin {
@Inject(method = "onGameMessage", at = @At(value = "INVOKE", target = "Ljava/lang/String;startsWith(Ljava/lang/String;)Z"))
@Inject(method = "onChatMessage", at = @At("TAIL"))
public void onChatMessage(ChatMessageC2SPacket packet, CallbackInfo ci) {
PlanFabricEvents.ON_CHAT.invoker().onChat((ServerPlayNetworkHandler) (Object) this, packet.getChatMessage());
}
@Inject(method = "onPlayerMove", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;getServerWorld()Lnet/minecraft/server/world/ServerWorld;"))
@Inject(method = "onPlayerMove", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;getWorld()Lnet/minecraft/server/world/ServerWorld;"))
public void onPlayerMove(PlayerMoveC2SPacket packet, CallbackInfo ci) {
PlanFabricEvents.ON_MOVE.invoker().onMove((ServerPlayNetworkHandler) (Object) this, packet);
}

View File

@ -72,7 +72,7 @@ public class ChatListener implements FabricListener {
long time = System.currentTimeMillis();
ServerPlayerEntity player = handler.player;
UUID uuid = player.getUuid();
String displayName = player.getDisplayName().asString();
String displayName = player.getDisplayName().getString();
dbSystem.getDatabase().executeTransaction(new NicknameStoreTransaction(
uuid, new Nickname(displayName, time, serverInfo.getServerUUID()),

View File

@ -89,11 +89,11 @@ public class DeathEventListener implements FabricListener {
}
private PlayerKill.Killer getKiller(ServerPlayerEntity killer) {
return new PlayerKill.Killer(killer.getUuid(), killer.getName().asString());
return new PlayerKill.Killer(killer.getUuid(), killer.getName().getString());
}
private PlayerKill.Victim getVictim(ServerPlayerEntity victim) {
return new PlayerKill.Victim(victim.getUuid(), victim.getName().asString());
return new PlayerKill.Victim(victim.getUuid(), victim.getName().getString());
}
public Optional<ServerPlayerEntity> getCause(Entity killer) {
@ -107,12 +107,12 @@ public class DeathEventListener implements FabricListener {
if (killer instanceof ServerPlayerEntity) return getItemInHand((ServerPlayerEntity) killer);
// Projectile, EnderCrystal and all other causes that are not known yet
return new EntityNameFormatter().apply(killer.getType().getName().asString());
return new EntityNameFormatter().apply(killer.getType().getName().getString());
}
private String getItemInHand(ServerPlayerEntity killer) {
ItemStack itemInHand = killer.getMainHandStack();
return itemInHand.getItem().getName().asString();
return itemInHand.getItem().getName().getString();
}
private Optional<ServerPlayerEntity> getShooter(ProjectileEntity projectile) {

View File

@ -72,7 +72,7 @@ public class GameModeChangeListener implements FabricListener {
UUID uuid = player.getUuid();
long time = System.currentTimeMillis();
String gameMode = newGameMode.name();
String worldName = player.getServerWorld().getRegistryKey().getValue().toString();
String worldName = player.getWorld().getRegistryKey().getValue().toString();
dbSystem.getDatabase().executeTransaction(new WorldNameStoreTransaction(serverInfo.getServerUUID(), worldName));
worldAliasSettings.addWorld(worldName);

View File

@ -179,7 +179,7 @@ public class PlayerOnlineListener implements FabricListener {
FabricAFKListener.afkTracker.performedAction(playerUUID, time);
String world = player.getServerWorld().getRegistryKey().getValue().toString();
String world = player.getWorld().getRegistryKey().getValue().toString();
String gm = player.interactionManager.getGameMode().name();
Database database = dbSystem.getDatabase();
@ -188,7 +188,7 @@ public class PlayerOnlineListener implements FabricListener {
Supplier<String> getHostName = () -> getHostname(player);
String playerName = player.getEntityName();
String displayName = player.getDisplayName().asString();
String displayName = player.getDisplayName().getString();
database.executeTransaction(new PlayerServerRegisterTransaction(playerUUID,
@ -199,7 +199,7 @@ public class PlayerOnlineListener implements FabricListener {
gatherGeolocation(player, playerUUID, time, database);
}
database.executeTransaction(new OperatorStatusTransaction(playerUUID, serverUUID, server.getPlayerManager().getOpList().isOp(player.getGameProfile())));
database.executeTransaction(new OperatorStatusTransaction(playerUUID, serverUUID, server.getPlayerManager().getOpList().get(player.getGameProfile()) != null));
ActiveSession session = new ActiveSession(playerUUID, serverUUID, time, world, gm);
session.getExtraData().put(PlayerName.class, new PlayerName(playerName));

View File

@ -67,7 +67,7 @@ public class WorldChangeListener implements FabricListener {
UUID uuid = player.getUuid();
String worldName = player.getServerWorld().getRegistryKey().getValue().toString();
String worldName = player.getWorld().getRegistryKey().getValue().toString();
String gameMode = player.interactionManager.getGameMode().name();
dbSystem.getDatabase().executeTransaction(new WorldNameStoreTransaction(serverInfo.getServerUUID(), worldName));

View File

@ -2,8 +2,7 @@
"schemaVersion": 1,
"id": "plan",
"name": "Plan",
"version": "@version@",
"version": "${version}",
"environment": "server",
"entrypoints": {
"server": [
@ -14,10 +13,10 @@
"plan.mixins.json"
],
"depends": {
"minecraft": ">=1.17",
"java": ">=16",
"minecraft": ">=1.19",
"java": ">=17",
"fabric-api-base": "*",
"fabric-command-api-v1": "*",
"fabric-command-api-v2": "*",
"fabric-entity-events-v1": "*",
"fabric-lifecycle-events-v1": "*",
"fabric-networking-v0": "*"

View File

@ -2,7 +2,7 @@
"required": true,
"minVersion": "0.8",
"package": "net.playeranalytics.plan.gathering.listeners.events.mixin",
"compatibilityLevel": "JAVA_16",
"compatibilityLevel": "JAVA_17",
"mixins": [
"EntityMixin",
"KickCommandMixin",

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -4,6 +4,7 @@ pluginManagement {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
mavenCentral()
gradlePluginPortal()
}
}