mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-10-01 00:27:45 +02:00
Set sleep status every tick for now (only necessary on 1.14 and below)
This commit is contained in:
parent
d9c55b97b0
commit
9d0028541e
@ -2,6 +2,7 @@ package net.citizensnpcs.trait;
|
|||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
|
|
||||||
import net.citizensnpcs.api.CitizensAPI;
|
import net.citizensnpcs.api.CitizensAPI;
|
||||||
import net.citizensnpcs.api.npc.MemoryNPCDataStore;
|
import net.citizensnpcs.api.npc.MemoryNPCDataStore;
|
||||||
@ -53,6 +54,8 @@ public class SitTrait extends Trait {
|
|||||||
if (holder.getEntity() != null && !NMS.getPassengers(holder.getEntity()).contains(npc.getEntity())) {
|
if (holder.getEntity() != null && !NMS.getPassengers(holder.getEntity()).contains(npc.getEntity())) {
|
||||||
NMS.mount(holder.getEntity(), npc.getEntity());
|
NMS.mount(holder.getEntity(), npc.getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
holder.teleport(sittingAt, TeleportCause.PLUGIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSitting(Location at) {
|
public void setSitting(Location at) {
|
||||||
|
@ -4,7 +4,6 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.block.Bed;
|
import org.bukkit.block.Bed;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Villager;
|
import org.bukkit.entity.Villager;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
|
||||||
|
|
||||||
import net.citizensnpcs.api.persistence.Persist;
|
import net.citizensnpcs.api.persistence.Persist;
|
||||||
import net.citizensnpcs.api.trait.Trait;
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
@ -30,17 +29,13 @@ public class SleepTrait extends Trait {
|
|||||||
public void run() {
|
public void run() {
|
||||||
if (!npc.isSpawned())
|
if (!npc.isSpawned())
|
||||||
return;
|
return;
|
||||||
if (sleeping) {
|
|
||||||
if (at == null) {
|
|
||||||
wakeup();
|
|
||||||
} else {
|
|
||||||
npc.teleport(at, TeleportCause.PLUGIN);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (at == null)
|
if (at == null) {
|
||||||
|
if (sleeping) {
|
||||||
|
wakeup();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (SUPPORT_BLOCKDATA == null) {
|
if (SUPPORT_BLOCKDATA == null) {
|
||||||
try {
|
try {
|
||||||
@ -50,6 +45,7 @@ public class SleepTrait extends Trait {
|
|||||||
SUPPORT_BLOCKDATA = false;
|
SUPPORT_BLOCKDATA = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (npc.getEntity() instanceof Player) {
|
if (npc.getEntity() instanceof Player) {
|
||||||
Player player = (Player) npc.getEntity();
|
Player player = (Player) npc.getEntity();
|
||||||
if ((SUPPORT_BLOCKDATA && at.getBlock().getBlockData() instanceof Bed)
|
if ((SUPPORT_BLOCKDATA && at.getBlock().getBlockData() instanceof Bed)
|
||||||
|
Loading…
Reference in New Issue
Block a user