Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MockBukkit services are overriden with Paper ones when using PaperWeight #599

Open
2 tasks done
Insprill opened this issue Aug 5, 2022 · 2 comments
Open
2 tasks done
Labels
bug-exception Issue describes a bug in MockBukkit that prevent plugins from being tested.

Comments

@Insprill
Copy link
Contributor

Insprill commented Aug 5, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Are you using the latest version of MockBukkit?

  • I am using the latest version of MockBukkit.

Minecraft Version

1.19

Describe the bug

When using Paperweight, MockBukkit's services get overridden with Paper ones, causing tests to fail.

Reproducible Test

build.gradle:

plugins {
    id 'java'
    id 'io.papermc.paperweight.userdev' version "1.3.8"
}

dependencies {
    paperweightDevelopmentBundle('io.papermc.paper:dev-bundle:1.19.1-R0.1-SNAPSHOT')
    // MockBukkit and JUnit
}

settings.gradle:

pluginManagement {
    repositories {
        gradlePluginPortal()
        maven { url = 'https://papermc.io/repo/repository/maven-public/' }
    }
}

Test:

@Test
void test() {
    LegacyComponentSerializer.legacySection(); // Fails
}

Anything else?

No response

@Insprill Insprill added the bug-exception Issue describes a bug in MockBukkit that prevent plugins from being tested. label Aug 5, 2022
@syldium
Copy link
Contributor

syldium commented Aug 28, 2022

There are several workarounds depending on the project:

  • If NMS classes are not needed for the tests to run, then excluding the paper-server module is the way to go:
configurations.testImplementation {
    exclude(group: "io.papermc.paper", module: "paper-server")
} 
  • If the tests need the paper-server module, then you have to transform the dependency in order to exclude the /META-INF/services/net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer$Provider file. This is feasible, but not very handy.

Now, on the MockBukkit side, it might be better to use reflection instead of Java SPI to set the serializer only if it is not already provided by a service.

@Chaosdave34
Copy link

I am also trying to run MockBukkit with PaperMC paperweight and I get the same Error, but I need the NMS classes.
How could I solve the problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-exception Issue describes a bug in MockBukkit that prevent plugins from being tested.
Projects
None yet
Development

No branches or pull requests

3 participants