Replaced the NMS call for setting the CanJoinRaid property on MC 1.15.x

with a corresponding Bukkit API call.

This only works on the very latest versions of MC 1.15.1 and upwards.
master
blablubbabc 2020-01-15 22:49:44 +01:00
parent 84268d871c
commit b984971732
3 changed files with 10 additions and 3 deletions

View File

@ -4,6 +4,7 @@ Date format: (YYYY-MM-DD)
## v2.9.1 (TBA)
### Supported MC versions: 1.15.1, 1.14.4
* Changed: Replaced the NMS call for setting the CanJoinRaid property on MC 1.15.x with a corresponding Bukkit API call. This only works on the very latest versions of MC 1.15.1 and upwards.
## v2.9.0 (2019-12-28)
### Supported MC versions: 1.15.1, 1.14.4

View File

@ -124,8 +124,14 @@ public final class NMSHandler implements NMSCallProvider {
@Override
public void setCanJoinRaid(Raider raider, boolean canJoinRaid) {
EntityRaider nmsRaider = ((CraftRaider) raider).getHandle();
nmsRaider.u(canJoinRaid); // CanJoinRaid
try {
// only works in the latest versions of 1.15.1 and upwards:
raider.setCanJoinRaid(canJoinRaid);
} catch (Throwable t) {
// in case this is not supported by the current Bukkit version yet:
EntityRaider nmsRaider = ((CraftRaider) raider).getHandle();
nmsRaider.u(canJoinRaid); // CanJoinRaid
}
}
@Override

View File

@ -29,7 +29,7 @@ public interface NMSCallProvider {
public void setNoclip(Entity entity);
// TODO replace this once there is a corresponding Bukkit API for this
// TODO replace this once only the latest versions of 1.15.1 and upwards are supported
public void setCanJoinRaid(Raider raider, boolean canJoinRaid);
/**