Skip to content

v11.0.0

Compare
Choose a tag to compare
@CryptoMorin CryptoMorin released this 08 Jun 16:58
· 106 commits to master since this release

Maven

<dependency>
    <groupId>com.github.cryptomorin</groupId>
    <artifactId>XSeries</artifactId>
    <version>11.0.0</version>
</dependency>

Gradle

repositories {
    mavenCentral()
}
dependencies {
    implementation("com.github.cryptomorin:XSeries:11.0.0") { isTransitive = false }
}

Important

Don't forget to shade the library.


Quick Code Update

I'm very sorry for the class renames. It had to be done at some point.
You could simply do a RegEx replace in this order (unfortunately IntelliJ's Migrate feature doesn't work for nonexisting
classes properly):

  • ReflectionUtils
    1. Replace import (static )?com.cryptomorin.xseries.ReflectionUtils
      with import $1com.cryptomorin.xseries.reflection.XReflection
    2. Replace ReflectionUtils with XReflection
    3. Replace (XReflection.)?sendPacket(Sync)?\( with MinecraftConnection.sendPacket(
    4. For people who want to use the new ClassHandle API:
      1. (?:XReflection\.)?getNMSClass\(([\w."]+), ([\w"]+)\) -> XReflection.ofMinecraft().inPackage(MinecraftPackage.NMS, $1).named($2).unreflect()
      2. (?:XReflection\.)?getCraftClass\("(?:([\w\.]+)(?:\.))?(\w+)"\) -> XReflection.ofMinecraft().inPackage(MinecraftPackage.CB, "$1").named("$2").unreflect()
  • NMSExtras
    1. Replace import (static )?com.cryptomorin.xseries.NMSExtras
      with import $1com.cryptomorin.xseries.reflection.minecraft.NMSExtras
  • SkullUtils
    1. Replace SkullUtils with XSkull
    2. Replace XSkull.applySkin\(([^,]+), ([\w\d_]+)\) with XSkull.of($1).profile($2).apply()

You may have to update some parts manually yourself after this replacement.

XReflection (Former ReflectionUtils)

Completely revamped. ReflectionUtils has been split into so many classes. While I understand this might upset some
people because
they now have to include an entire package for ReflectionUtils-dependent classes to work, the class was becoming
almost unmaintainable from all the clutter. Most of these new features are experimental and might change in the future.

  • Now has a functional API.
  • Added string-based reflection which works specially well in IntelliJ because of the syntax highlighting support. The
    performance of this approach is obviously much worse, but since this should only be done once (even if you're using
    the functional approach, you should cache all reflection calls), the readability advantages far outweigh the
    performance disadvantage.
void functionalAPI() {
    MinecraftClassHandle CraftMetaSkull = XReflection.ofMinecraft()
            .inPackage(MinecraftPackage.CB, "inventory")
            .named("CraftMetaSkull");
    MethodHandle profileGetterMeta = CraftMetaSkull.getterField()
            .named("profile")
            .returns(GameProfile.class)
            .makeAccessible()
            .reflect();
}

void stringAPI() {
    // Normally all classes you pass to a namespace are visible 
    // (classes created from XReflection handle methods or passed to parameter(), return(), etc methods)
    // But sometimes the only way to make these classes visible would be to import them manually here.
    // You can avoid doing this and use fully qualified names instead inside strings.
    ReflectiveNamespace ns = XReflection.namespaced().imports(GameProfile.class);

    // There are shorthand names for packages like "nms", "spigot" and "cb"
    // The "extends CraftMetaItem implements SkullMeta" is completely useless and
    // only included for brevity (doesn't affect anything if the found class doesn't implement the specified classes).
    MinecraftClassHandle CraftMetaSkull = ns.ofMinecraft(
            // This code will be highlighted when used in IntelliJ:
            "package cb.inventory; class CraftMetaSkull extends CraftMetaItem implements SkullMeta {}"
    );
    MethodHandle profileGetterMeta = CraftMetaSkull.field("private GameProfile profile;")
            .map(MinecraftMapping.OBFUSCATED, "a") // You can mix functional and string APIs
            .getter().reflect();
}

XSkull (Former SkullUtils)

XSkull was completely revamped, all thanks to @Condordito

  • It now supports offline mode servers and has a more robust API.
  • Fixed some issues with detecting the correct skin value passed.

XBlock

  • Removed deprecated methods from XBlock.
  • Fixed an issue with setting skulls using XBlock.setType()

Others

  • Fixed Data.NAME_MAPPING for XParticle and XEntityType.
  • Fixed a bug with ParticleDisplay on older versions.
  • Fixed legacy support for XPotion.
  • Fixed an issue with XWorldBorder in outdated servers.
  • Fixed withLocationCaller() for Particles class.
  • Removed the deprecated XMaterial.isOneOf() and XMaterial.matchXMaterial(int id, byte data)
  • Fixed a lot of issues in XParticle thanks to @CJCrafter