mirror of
https://github.com/BG-Software-LLC/WildLoaders.git
synced 2024-11-24 12:15:28 +01:00
Add NPC
metadata tag to chunk loader NPCs (#82)
This commit is contained in:
parent
1e3d79269e
commit
7f504ee2d9
@ -7,7 +7,9 @@ import com.bgsoftware.wildloaders.npc.NPCIdentifier;
|
|||||||
import com.bgsoftware.wildloaders.utils.database.Query;
|
import com.bgsoftware.wildloaders.utils.database.Query;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -34,7 +36,12 @@ public final class NPCHandler implements NPCManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChunkLoaderNPC createNPC(Location location) {
|
public ChunkLoaderNPC createNPC(Location location) {
|
||||||
return npcs.computeIfAbsent(new NPCIdentifier(location), i -> plugin.getNMSAdapter().createNPC(i.getSpawnLocation(), getUUID(i)));
|
return npcs.computeIfAbsent(new NPCIdentifier(location), i -> {
|
||||||
|
ChunkLoaderNPC npc = plugin.getNMSAdapter().createNPC(i.getSpawnLocation(), getUUID(i));
|
||||||
|
Entity npcEntity = npc.getPlayer();
|
||||||
|
npcEntity.setMetadata("NPC", new FixedMetadataValue(plugin, true));
|
||||||
|
return npc;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -54,6 +61,9 @@ public final class NPCHandler implements NPCManager {
|
|||||||
.setLocation(identifier.getSpawnLocation())
|
.setLocation(identifier.getSpawnLocation())
|
||||||
.queue(npc.getUniqueId());
|
.queue(npc.getUniqueId());
|
||||||
|
|
||||||
|
Entity npcEntity = npc.getPlayer();
|
||||||
|
npcEntity.removeMetadata("NPC", plugin);
|
||||||
|
|
||||||
npc.die();
|
npc.die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user