mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 10:36:10 +01:00
Check for outdated versions of minecraft in SleepTrait
This commit is contained in:
parent
12faab3b53
commit
868c7a463d
@ -40,10 +40,19 @@ public class SleepTrait extends Trait {
|
||||
if (at == null)
|
||||
return;
|
||||
|
||||
if (SUPPORT_BLOCKDATA == null) {
|
||||
try {
|
||||
SUPPORT_BLOCKDATA = true;
|
||||
at.getBlock().getBlockData();
|
||||
} catch (NoSuchMethodError e) {
|
||||
SUPPORT_BLOCKDATA = false;
|
||||
}
|
||||
}
|
||||
npc.teleport(at, TeleportCause.PLUGIN);
|
||||
if (npc.getEntity() instanceof Player) {
|
||||
Player player = (Player) npc.getEntity();
|
||||
if (at.getBlock().getBlockData() instanceof Bed || at.getBlock().getState() instanceof Bed) {
|
||||
if ((SUPPORT_BLOCKDATA && at.getBlock().getBlockData() instanceof Bed)
|
||||
|| at.getBlock().getState() instanceof Bed) {
|
||||
player.sleep(at, true);
|
||||
} else {
|
||||
NMS.sleep(player, true);
|
||||
@ -67,4 +76,6 @@ public class SleepTrait extends Trait {
|
||||
}
|
||||
sleeping = false;
|
||||
}
|
||||
|
||||
private static Boolean SUPPORT_BLOCKDATA = null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user