mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-05 02:10:10 +01:00
1.8.8 compat
This commit is contained in:
parent
4212921a98
commit
57d27f39ee
@ -48,11 +48,20 @@ public class SleepTrait extends Trait {
|
||||
|
||||
if (npc.getEntity() instanceof Player) {
|
||||
Player player = (Player) npc.getEntity();
|
||||
if ((SUPPORT_BLOCKDATA && at.getBlock().getBlockData() instanceof Bed)
|
||||
|| at.getBlock().getState() instanceof Bed) {
|
||||
player.sleep(at, true);
|
||||
} else {
|
||||
if (!SUPPORT_BLOCKSTATE) {
|
||||
NMS.sleep(player, true);
|
||||
} else {
|
||||
try {
|
||||
if ((SUPPORT_BLOCKDATA && at.getBlock().getBlockData() instanceof Bed)
|
||||
|| at.getBlock().getState() instanceof Bed) {
|
||||
player.sleep(at, true);
|
||||
} else {
|
||||
NMS.sleep(player, true);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
SUPPORT_BLOCKSTATE = false;
|
||||
NMS.sleep(player, true);
|
||||
}
|
||||
}
|
||||
sleeping = true;
|
||||
} else if (npc.getEntity() instanceof Villager) {
|
||||
@ -75,4 +84,5 @@ public class SleepTrait extends Trait {
|
||||
}
|
||||
|
||||
private static Boolean SUPPORT_BLOCKDATA = null;
|
||||
private static boolean SUPPORT_BLOCKSTATE = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user