v11.0.0
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
- Replace
import (static )?com.cryptomorin.xseries.ReflectionUtils
withimport $1com.cryptomorin.xseries.reflection.XReflection
- Replace
ReflectionUtils
withXReflection
- Replace
(XReflection.)?sendPacket(Sync)?\(
withMinecraftConnection.sendPacket(
- For people who want to use the new ClassHandle API:
(?:XReflection\.)?getNMSClass\(([\w."]+), ([\w"]+)\)
->XReflection.ofMinecraft().inPackage(MinecraftPackage.NMS, $1).named($2).unreflect()
(?:XReflection\.)?getCraftClass\("(?:([\w\.]+)(?:\.))?(\w+)"\)
->XReflection.ofMinecraft().inPackage(MinecraftPackage.CB, "$1").named("$2").unreflect()
- Replace
- NMSExtras
- Replace
import (static )?com.cryptomorin.xseries.NMSExtras
withimport $1com.cryptomorin.xseries.reflection.minecraft.NMSExtras
- Replace
- SkullUtils
- Replace
SkullUtils
withXSkull
- Replace
XSkull.applySkin\(([^,]+), ([\w\d_]+)\)
withXSkull.of($1).profile($2).apply()
- Replace
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
forXParticle
andXEntityType
. - Fixed a bug with
ParticleDisplay
on older versions. - Fixed legacy support for
XPotion
. - Fixed an issue with
XWorldBorder
in outdated servers. - Fixed
withLocationCaller()
forParticles
class. - Removed the deprecated
XMaterial.isOneOf()
andXMaterial.matchXMaterial(int id, byte data)
- Fixed a lot of issues in
XParticle
thanks to @CJCrafter