Use new API

This commit is contained in:
fullwall 2024-03-23 23:46:09 +08:00
parent 45fff0f420
commit 8696a5709e
26 changed files with 37 additions and 155 deletions

View File

@ -651,13 +651,12 @@ public class NPCCommands {
max = 1,
flags = "myno")
public void controllable(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
if (npc.isSpawned()
&& !sender.hasPermission(
"citizens.npc.controllable." + npc.getEntity().getType().name().toLowerCase().replace("_", ""))
if ((npc.isSpawned() && !sender.hasPermission(
"citizens.npc.controllable." + npc.getEntity().getType().name().toLowerCase().replace("_", "")))
|| !sender.hasPermission("citizens.npc.controllable"))
throw new NoPermissionsException();
if (!npc.hasTrait(Controllable.class)) {
npc.addTrait(new Controllable(false));
npc.getOrAddTrait(Controllable.class).setEnabled(false);
}
Controllable trait = npc.getOrAddTrait(Controllable.class);
boolean enabled = trait.toggle();

View File

@ -52,11 +52,6 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
super("controllable");
}
public Controllable(boolean enabled) {
this();
this.enabled = enabled;
}
/**
* Configures the explicit type parameter.
*

View File

@ -172,12 +172,12 @@ public class LookClose extends Trait implements Toggleable {
.map(e -> (Player) e).collect(Collectors.toList())
: CitizensAPI.getLocationLookup().getNearbyPlayers(npcLoc, range);
for (Player player : nearby) {
if (player == lookingAt || !targetNPCs && CitizensAPI.getNPCRegistry().getNPC(player) != null) {
if (player == lookingAt || !targetNPCs && CitizensAPI.getNPCRegistry().getNPC(player) != null)
continue;
}
if (player.getLocation().getWorld() != npcLoc.getWorld() || isInvisible(player)) {
if (isInvisible(player))
continue;
}
options.add(player);
}
return options;

View File

@ -45,8 +45,8 @@ public class PausePathfindingTrait extends Trait {
public void run() {
if (playerRange == -1 || !npc.isSpawned() || unpauseTaskId == -1 && !npc.getNavigator().isNavigating())
return;
if (CitizensAPI.getLocationLookup().getNearbyPlayers(npc.getStoredLocation(), playerRange).iterator()
.hasNext()) {
if (CitizensAPI.getLocationLookup()
.getNearbyVisiblePlayers(npc.getEntity(), npc.getStoredLocation(), playerRange).iterator().hasNext()) {
pause();
}
}

View File

@ -437,6 +437,8 @@ public class ShopTrait extends Trait {
public void onClick(NPCShop shop, Player player, InventoryMultiplexer inventory, boolean shiftClick,
boolean secondClick) {
// TODO: InventoryMultiplexer could be lifted up to transact in apply(), which would be cleaner.
// if this is done, it should probably refresh after every transaction application
if (timesPurchasable > 0 && purchases.getOrDefault(player.getUniqueId(), 0) == timesPurchasable) {
if (alreadyPurchasedMessage != null) {
Messaging.sendColorless(player, placeholders(alreadyPurchasedMessage, player));

View File

@ -6,7 +6,6 @@ import java.util.Map;
import java.util.Random;
import java.util.UUID;
import org.bukkit.GameMode;
import org.bukkit.command.CommandSender;
import org.bukkit.conversations.Conversation;
import org.bukkit.conversations.ConversationFactory;
@ -175,10 +174,7 @@ public class Text extends Trait implements Runnable, Listener {
if (!npc.isSpawned() || !talkClose || text.size() == 0)
return;
for (Player player : CitizensAPI.getLocationLookup().getNearbyPlayers(npc.getEntity().getLocation(), range)) {
if (player.getGameMode() == GameMode.SPECTATOR) {
continue;
}
for (Player player : CitizensAPI.getLocationLookup().getNearbyVisiblePlayers(npc.getEntity(), range)) {
talk(player);
}
}

View File

@ -183,9 +183,9 @@ public class BossBarTrait extends Trait {
for (Player player : CitizensAPI.getLocationLookup().getNearbyPlayers(npc.getEntity().getLocation(),
range > 0 ? range : Setting.BOSSBAR_RANGE.asInt())) {
if (viewPermission != null && !player.hasPermission(viewPermission)) {
if (viewPermission != null && !player.hasPermission(viewPermission))
continue;
}
bar.addPlayer(player);
}
}

View File

@ -42,7 +42,7 @@ public class ChatTrigger implements WaypointTrigger {
}
}
} else {
for (Player player : CitizensAPI.getLocationLookup().getNearbyPlayers(npc.getStoredLocation(), radius)) {
for (Player player : CitizensAPI.getLocationLookup().getNearbyVisiblePlayers(npc.getEntity(), radius)) {
for (String line : lines) {
Messaging.send(player, line);
}

View File

@ -528,16 +528,7 @@ public class NMS {
}
private static Collection<Player> getNearbyPlayers(Entity from, Location location, double radius) {
List<Player> players = Lists.newArrayList();
for (Player player : CitizensAPI.getLocationLookup().getNearbyPlayers(location, radius)) {
if (location.getWorld() != player.getWorld() || location.distance(player.getLocation()) > radius)
continue;
if (from != null && !Util.canSee(player, from))
continue;
players.add(player);
}
return players;
return Lists.newArrayList(CitizensAPI.getLocationLookup().getNearbyVisiblePlayers(from, location, radius));
}
public static NPC getNPC(Entity entity) {

View File

@ -1,12 +1,10 @@
package net.citizensnpcs.util;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import java.util.function.Supplier;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@ -51,19 +49,7 @@ public enum PlayerAnimation {
}
public void play(Player from, int radius) {
play(from, () -> {
Location loc = from.getLocation();
Location cloc = new Location(null, 0, 0, 0);
List<Player> to = Lists.newArrayList();
for (Player player : CitizensAPI.getLocationLookup().getNearbyPlayers(loc, radius)) {
if (loc.getWorld() != player.getWorld() || !player.canSee(from)
|| loc.distance(player.getLocation(cloc)) > radius) {
continue;
}
to.add(player);
}
return to;
});
play(from, () -> Lists.newArrayList(CitizensAPI.getLocationLookup().getNearbyVisiblePlayers(from, radius)));
}
public void play(Player player, Iterable<Player> to) {

View File

@ -105,20 +105,6 @@ public class Util {
return !event.isCancelled() ? event.getCollisionVector() : null;
}
public static boolean canSee(Player player, Entity from) {
if (from instanceof Player)
return player.canSee((Player) from);
if (SUPPORTS_ENTITY_CANSEE) {
try {
return player.canSee(from);
} catch (NoSuchMethodError t) {
SUPPORTS_ENTITY_CANSEE = false;
}
}
return true;
}
/**
* Clamps the rotation angle to [-180, 180]
*/

View File

@ -1,7 +1,6 @@
{
"citizens.changed-implementation" : "Implementation von Citizens wurde geändert, Plugin wird deaktiviert.",
"citizens.commands.citizens.description" : "Zeigt grundlegende Plugin-Informationen",
"citizens.commands.citizens.reload.description" : "Lade Citizens frisch von der Festplatte, ohne vorheriges Speichern",
"citizens.commands.citizens.save.description" : "NPCs speichern",
"citizens.commands.citizens.save.help" : "Benutze -a um asynchron (zum Haupt-Thread) zu speichern.",
"citizens.commands.console-error" : "Bitte melde diesen Fehler: [Siehe Konsole]",
@ -13,7 +12,6 @@
"citizens.commands.invalid.class" : "Ungültige externe Befehlsklasse.",
"citizens.commands.invalid-mobtype" : "{0} ist kein gültiger NPC-Typ.",
"citizens.commands.invalid-number" : "Das ist keine gültige ID.",
"citizens.commands.npc.activationrange.description" : "Legt die Aktivierungsreichweite fest",
"citizens.commands.npc.activationrange.set" : "Aktivierungsreichweite wurde auf [[{0}]] gesetzt.",
"citizens.commands.npc.age.cannot-be-aged" : "Dem NPC-Typ {0} kann kein Alter zugewiesen werden.",
"citizens.commands.npc.age.description" : "Legt das Alter eines NPCs fest",
@ -25,7 +23,6 @@
"citizens.commands.npc.age.set-baby" : "[[{0}]] ist jetzt ein Baby.",
"citizens.commands.npc.age.set-normal" : "[[{0}]] ist nun [[{1}]] Ticks alt.",
"citizens.commands.npc.age.unlocked" : "Alter entsperrt.",
"citizens.commands.npc.aggressive.description" : "Legt den Aggresivitätsstatus der Entität fest",
"citizens.commands.npc.ai.started" : "Nutzt jetzt Minecraft KI.",
"citizens.commands.npc.ai.stopped" : "Nutzt nicht länger Minecraft KI.",
"citizens.commands.npc.allay.dancing-set" : "[[{0}]] tanzt jetzt.",
@ -35,7 +32,6 @@
"citizens.commands.npc.anchor.invalid-name" : "ungültiger Ankername.",
"citizens.commands.npc.anchor.missing" : "Der Anker {1} existiert nicht.",
"citizens.commands.npc.anchor.removed" : "Anker entfernt.",
"citizens.commands.npc.armorstand.description" : "Bearbeite Rüstungsständer Eigenschaften",
"citizens.commands.npc.axolotl.invalid-variant" : "Ungültige Variante. Gültige Varianten sind [[{0}]].",
"citizens.commands.npc.axolotl.playing-dead" : "[[{0}]] spielt jetzt tod.",
"citizens.commands.npc.axolotl.playing-dead-stopped" : "[[{0}]] spielt nicht mehr tod.",
@ -46,7 +42,6 @@
"citizens.commands.npc.bee.invalid-anger" : "Wut sollte über null sein.",
"citizens.commands.npc.bee.no-nectar" : "[[{0}]] hat keinen Nektar",
"citizens.commands.npc.bee.not-stung" : "[[{0}]] hat nicht mehr gestochen.",
"citizens.commands.npc.bossbar.description" : "Bearbeite Bossleisten Eigenschaften",
"citizens.commands.npc.camel.pose-set" : "Pose auf [[{0}]] gesetzt.",
"citizens.commands.npc.cat.collar-color-set" : "Halsbandfarbe auf [[{0}]] gesetzt.",
"citizens.commands.npc.cat.invalid-collar-color" : "Ungültige Halsbandfarbe angegeben. Gültige Möglichkeiten sind [[{0}]].",
@ -67,58 +62,22 @@
"citizens.commands.npc.command.describe-format" : "<br> - {0} [{1}s] [cost:{2}] [exp:{3}] [<click:run_command:/npc cmd remove {4}><hover:show_text:Entferne den Befehl><red><u>-</hover></click>]",
"citizens.commands.npc.command.errors-cleared" : "Fehler gelöscht für [[{0}]].",
"citizens.commands.npc.command.experience-cost-set" : "Setze XP-Level-Kosten per Klick auf [[{0}]].",
"citizens.commands.npc.command.hide-error-messages-set" : "Fehlermeldungen werden jetzt ausgeblendet.",
"citizens.commands.npc.command.hide-error-messages-unset" : "Fehlermeldungen werden nicht mehr ausgeblendet.",
"citizens.commands.npc.command.invalid-player" : "[[{0}]] konnte nicht als Spieler gefunden werden.",
"citizens.commands.npc.command.left-hand-header" : "Befehle zum Ausführen bei [[left click]]:",
"citizens.commands.npc.command.none-added" : "Keine Befehle wurden hinzugefügt.",
"citizens.commands.npc.command.persist-sequence-set" : "Befehlssequenzen werden jetzt über Serverneustarts hinweg gespeichert.",
"citizens.commands.npc.command.persist-sequence-unset" : "Befehlssequenzen werden bei Serverneustarts nicht mehr gespeichert.",
"citizens.commands.npc.command.right-hand-header" : "Befehle zum Auszuführen bei [[right click]] ",
"citizens.commands.npc.commands.random-set" : "Befehle werden jetzt zufällig ausgeführt.",
"citizens.commands.npc.commands.random-unset" : "Befehle werden nicht mehr zufällig ausgeführt.",
"citizens.commands.npc.command.unknown-id" : "Unbekannte Befehl Id [[{0}]] für diesen NPC.",
"citizens.commands.npc.controllable.not-controllable" : "[[{0}]] ist nicht kontrollierbar.",
"citizens.commands.npc.controllable.removed" : "[[{0}]] kann nicht länger kontrolliert werden.",
"citizens.commands.npc.controllable.set" : "[[{0}]] kann nun kontrolliert werden.",
"citizens.commands.npc.copy.copied" : "[[{0}]] wurde kopiert.",
"citizens.commands.npc.copy.description" : "Kopiert einen NPC",
"citizens.commands.npc.create.description" : "Erstellt einen neuen NPC",
"citizens.commands.npc.create.invalid-location" : "Ort konnte nicht geparst werden oder wurde nicht gefunden.",
"citizens.commands.npc.create.invalid-mobtype" : "{0} ist kein gültiger NPC-Typ. Es wird der Standard-Typ verwendet.",
"citizens.commands.npc.create.npc-name-too-long" : "Namen von NPCs können nicht länger als 16 Zeichen sein. Der Name wurde gekürzt.",
"citizens.commands.npc.debug.description" : "Zeige Debug Informationen",
"citizens.commands.npc.description" : "Zeigt grundlegende NPC-Informationen",
"citizens.commands.npc.deselect" : "NPC abgewählt.",
"citizens.commands.npc.despawn.despawned" : "Du hast [[{0}]] despawned.",
"citizens.commands.npc.enderman.angry-set" : "[[{0}]] ist jetzt böse. >:(",
"citizens.commands.npc.enderman.angry-unset" : "[[{0}]] ist nicht mehr böse. :D",
"citizens.commands.npc.follow.set" : "[[{0}]] folgt jetzt [[{1}]].",
"citizens.commands.npc.follow.unset" : "[[{0}]] folgt niemandem mehr.",
"citizens.commands.npc.fox.crouching-set" : "[[{0}]] ist nun in der Hocke.",
"citizens.commands.npc.fox.crouching-unset" : "[[{0}]] ist nun nicht mehr in der Hocke.",
"citizens.commands.npc.fox.sitting-set" : "[[{0}]] sitzt nun.",
"citizens.commands.npc.fox.sitting-unset" : "[[{0}]] sitzt nun nicht mehr.",
"citizens.commands.npc.fox.sleeping-set" : "[[{0}]] schläft nun.",
"citizens.commands.npc.fox.sleeping-unset" : "[[{0}]] ist aufgewacht.",
"citizens.commands.npc.frog.invalid-variant" : "Ungültige Froschvariante. Gültige Varianten sind [[{0}]].",
"citizens.commands.npc.gamemode.description" : "Ändert den Spielmodus",
"citizens.commands.npc.glowing.set" : "[[{0}]] leuchtet nun.",
"citizens.commands.npc.glowing.unset" : "[[{0}]] hat sich abgeleuchtet.",
"citizens.commands.npc.goat.description" : "Setzt die Ziegenmodifizierungen",
"citizens.commands.npc.gravity.disabled" : "Gravitation [[deaktiviert]].",
"citizens.commands.npc.gravity.enabled" : "Gravitation [[aktiviert]].",
"citizens.commands.npc.guardian.elder-set" : "[[{0}]] ist jetzt ein Wächterältester.",
"citizens.commands.npc.guardian.elder-unset" : "[[{0}]] ist nicht mehr ein Wächterältester.",
"citizens.commands.npc.hologram.invalid-text-id" : "Ungültige Zeile.",
"citizens.commands.npc.hologram.line-height-set" : "Zeilenhöhe beträgt nun [[{0}]].",
"citizens.commands.npc.hurt.description" : "Verletzt den NPC",
"citizens.commands.npc.leashable.set" : "[[{0}]] ist nun abseilbar.",
"citizens.commands.npc.leashable.stopped" : "[[{0}]] ist nun nicht mehr abseilbar.",
"citizens.commands.npc.lookclose.headonly-set" : "[[{0}]] wird nun nur den Körper rotieren.",
"citizens.commands.npc.lookclose.headonly-unset" : "[[{0}]] wird nun seinen Körper rotieren lassen.",
"citizens.commands.npc.lookclose.random-set" : "[[{0}]] wird jetzt zufällig durch die Gegend schauen.",
"citizens.commands.npc.lookclose.random-stopped" : "[[{0}]] wird jetzt nicht mehr zufällig durch die Gegend schauen.",
"citizens.commands.npc.lookclose.set" : "[[{0}]] wurd sich nun drehen, wenn Spieler in der Nähe sind.",
"citizens.commands.npc.lookclose.stopped" : "[[{0}]] wird sich nicht mehr drehen, wenn Spieler in der Nähe sind.",
"citizens.commands.npc.mount.failed" : "Kontrolle von [[{0}]] fehlgeschlagen.",

View File

@ -138,6 +138,7 @@
"citizens.commands.traitc.not-configurable" : "Esta plantilla no es configurable.",
"citizens.commands.traitc.not-on-npc" : "Los NPC's no pueden tener esta plantilla.",
"citizens.commands.trait.failed-to-add" : "<7>No se pueden agregar {0}.",
"citizens.commands.trait.failed-to-change" : "<7>No se pueden cambiar {0}.",
"citizens.commands.trait.failed-to-remove" : "<7>No se pueden eliminar {0}.",
"citizens.commands.trait.removed" : "Eliminado {0} satisfactoriamente.",
"citizens.commands.unknown-command" : "Comando desconocido. Querias decir:",

View File

@ -313,6 +313,7 @@
"citizens.commands.npc.tpto.from-not-found" : "Entité source introuvable.",
"citizens.commands.npc.tpto.success" : "Téléportation réalisée avec succès.",
"citizens.commands.npc.tpto.to-not-found" : "Entité de destination introuvable.",
"citizens.commands.npc.trackingdistance.set" : "Distance de suivi fixée à [[{0}]].",
"citizens.commands.npc.tropicalfish.body-color-set" : "Couleur du corps fixée à [[{0}]].",
"citizens.commands.npc.tropicalfish.invalid-color" : "Couleur de poisson invalide. Les couleurs valides sont\\: [[{0}]]",
"citizens.commands.npc.tropicalfish.invalid-pattern" : "Motif de poisson invalide. Les motifs valides sont\\: [[{0}]]",
@ -354,6 +355,7 @@
"citizens.commands.traitc.not-configurable" : "Cette caractéristique n''est pas paramétrable.",
"citizens.commands.traitc.not-on-npc" : "Le PNJ n''a pas cette caractéristique.",
"citizens.commands.trait.failed-to-add" : "<7> impossible d''ajouter {0}.",
"citizens.commands.trait.failed-to-change" : "<7>Impossible de changer {0}.",
"citizens.commands.trait.failed-to-remove" : "<7>Impossible de supprimer {0}.",
"citizens.commands.trait.removed" : "Suppression de {0} avec succès.",
"citizens.commands.unknown-command" : "Commande inconnue. Vouliez vous faire\\:",

View File

@ -78,6 +78,7 @@
"citizens.commands.traitc.not-configurable" : "Dit eigenschap kan niet worden aangepast.",
"citizens.commands.traitc.not-on-npc" : "De NPC heeft deze eigenschap niet.",
"citizens.commands.trait.failed-to-add" : "<7>Kon {0} niet toevoegen.",
"citizens.commands.trait.failed-to-change" : "<7>Kon {0} niet veranderen.",
"citizens.commands.trait.failed-to-remove" : "<7>Kon {0} niet verwijderen.",
"citizens.commands.trait.removed" : "{0} verwijderd.",
"citizens.commands.unknown-command" : "Onbekend commando, bedoelde je:",

View File

@ -253,6 +253,7 @@
"citizens.commands.traitc.not-configurable" : "Nie można konfigurować tej cechy.",
"citizens.commands.traitc.not-on-npc" : "NPC nie ma tej cechy.",
"citizens.commands.trait.failed-to-add" : "<7>Nie udało się dodać {0}.",
"citizens.commands.trait.failed-to-change" : "<7>Nie udało się zmienić {0}.",
"citizens.commands.trait.failed-to-remove" : "<7>Nie udało się usunąć {0}.",
"citizens.commands.trait.removed" : "Pomyślnie usunięto {0}.",
"citizens.commands.unknown-command" : "Nieznana komenda. Myślałeś może o:",

View File

@ -255,6 +255,7 @@
"citizens.commands.traitc.not-configurable" : "無法設定該特徵。",
"citizens.commands.traitc.not-on-npc" : "NPC 沒有該特徵。",
"citizens.commands.trait.failed-to-add" : "<7>無法新增 {0}。",
"citizens.commands.trait.failed-to-change" : "<7>無法變更 {0}。",
"citizens.commands.trait.failed-to-remove" : "<7>無法移除 {0}。",
"citizens.commands.trait.removed" : "成功移除 {0}。",
"citizens.commands.unknown-command" : "未知的指令。您是不是指:",

View File

@ -217,6 +217,7 @@
"citizens.commands.traitc.not-configurable" : "该特征是不可配置的.",
"citizens.commands.traitc.not-on-npc" : "没有这个特征.",
"citizens.commands.trait.failed-to-add" : "<7>无法添加 {0}.",
"citizens.commands.trait.failed-to-change" : "<7>无法更改 {0}.",
"citizens.commands.trait.failed-to-remove" : "<7>无法删除 {0}.",
"citizens.commands.trait.removed" : "已成功删除 {0}.",
"citizens.commands.unknown-command" : "未知命令, 你是否要使用:",

View File

@ -1363,7 +1363,7 @@ public class NMSImpl implements NMSBridge {
PerPlayerMetadata<Long> meta = CitizensAPI.getLocationLookup().registerMetadata("sleeping", null);
if (sleep) {
List<Player> nearbyPlayers = Lists.newArrayList(
Iterables.filter(CitizensAPI.getLocationLookup().getNearbyPlayers(entity.getLocation(), 64), p -> {
Iterables.filter(CitizensAPI.getLocationLookup().getNearbyVisiblePlayers(entity, 64), p -> {
Long time = meta.getMarker(p.getUniqueId(), entity.getUniqueId().toString());
if (time == null || Math.abs(System.currentTimeMillis() - time) > 5000)
return true;
@ -1907,12 +1907,7 @@ public class NMSImpl implements NMSBridge {
public static void sendPacketsNearby(Player from, Location location, Collection<Packet<?>> packets, double radius) {
radius *= radius;
final org.bukkit.World world = location.getWorld();
for (Player player : CitizensAPI.getLocationLookup().getNearbyPlayers(location, radius)) {
if (world != player.getWorld() || from != null && !player.canSee(from)
|| location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius) {
continue;
}
for (Player player : CitizensAPI.getLocationLookup().getNearbyVisiblePlayers(from, location, radius)) {
for (Packet<?> packet : packets) {
NMSImpl.sendPacket(player, packet);
}

View File

@ -1423,7 +1423,7 @@ public class NMSImpl implements NMSBridge {
PerPlayerMetadata<Long> meta = CitizensAPI.getLocationLookup().registerMetadata("sleeping", null);
if (sleep) {
List<Player> nearbyPlayers = Lists.newArrayList(
Iterables.filter(CitizensAPI.getLocationLookup().getNearbyPlayers(entity.getLocation(), 64), p -> {
Iterables.filter(CitizensAPI.getLocationLookup().getNearbyVisiblePlayers(entity, 64), p -> {
Long time = meta.getMarker(p.getUniqueId(), entity.getUniqueId().toString());
if (time == null || Math.abs(System.currentTimeMillis() - time) > 5000)
return true;
@ -1966,12 +1966,7 @@ public class NMSImpl implements NMSBridge {
public static void sendPacketsNearby(Player from, Location location, Collection<Packet<?>> packets, double radius) {
radius *= radius;
final org.bukkit.World world = location.getWorld();
for (Player player : CitizensAPI.getLocationLookup().getNearbyPlayers(location, radius)) {
if (world != player.getWorld() || from != null && !player.canSee(from)
|| location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius) {
continue;
}
for (Player player : CitizensAPI.getLocationLookup().getNearbyVisiblePlayers(from, location, radius)) {
for (Packet<?> packet : packets) {
NMSImpl.sendPacket(player, packet);
}

View File

@ -1430,7 +1430,7 @@ public class NMSImpl implements NMSBridge {
PerPlayerMetadata<Long> meta = CitizensAPI.getLocationLookup().registerMetadata("sleeping", null);
if (sleep) {
List<Player> nearbyPlayers = Lists.newArrayList(
Iterables.filter(CitizensAPI.getLocationLookup().getNearbyPlayers(entity.getLocation(), 64), p -> {
Iterables.filter(CitizensAPI.getLocationLookup().getNearbyVisiblePlayers(entity, 64), p -> {
Long time = meta.getMarker(p.getUniqueId(), entity.getUniqueId().toString());
if (time == null || Math.abs(System.currentTimeMillis() - time) > 5000)
return true;
@ -1973,12 +1973,7 @@ public class NMSImpl implements NMSBridge {
public static void sendPacketsNearby(Player from, Location location, Collection<Packet<?>> packets, double radius) {
radius *= radius;
final org.bukkit.World world = location.getWorld();
for (Player player : CitizensAPI.getLocationLookup().getNearbyPlayers(location, radius)) {
if (world != player.getWorld() || from != null && !player.canSee(from)
|| location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius) {
continue;
}
for (Player player : CitizensAPI.getLocationLookup().getNearbyVisiblePlayers(from, location, radius)) {
for (Packet<?> packet : packets) {
NMSImpl.sendPacket(player, packet);
}

View File

@ -1470,7 +1470,7 @@ public class NMSImpl implements NMSBridge {
PerPlayerMetadata<Long> meta = CitizensAPI.getLocationLookup().registerMetadata("sleeping", null);
if (sleep) {
List<Player> nearbyPlayers = Lists.newArrayList(
Iterables.filter(CitizensAPI.getLocationLookup().getNearbyPlayers(entity.getLocation(), 64), p -> {
Iterables.filter(CitizensAPI.getLocationLookup().getNearbyVisiblePlayers(entity, 64), p -> {
Long time = meta.getMarker(p.getUniqueId(), entity.getUniqueId().toString());
if (time == null || Math.abs(System.currentTimeMillis() - time) > 5000)
return true;
@ -2087,12 +2087,7 @@ public class NMSImpl implements NMSBridge {
public static void sendPacketsNearby(Player from, Location location, Collection<Packet<?>> packets, double radius) {
radius *= radius;
final org.bukkit.World world = location.getWorld();
for (Player player : CitizensAPI.getLocationLookup().getNearbyPlayers(location, radius)) {
if (world != player.getWorld() || from != null && !player.canSee(from)
|| location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius) {
continue;
}
for (Player player : CitizensAPI.getLocationLookup().getNearbyVisiblePlayers(from, location, radius)) {
for (Packet<?> packet : packets) {
NMSImpl.sendPacket(player, packet);
}

View File

@ -2145,11 +2145,7 @@ public class NMSImpl implements NMSBridge {
public static void sendPacketsNearby(Player from, Location location, Collection<Packet<?>> packets, double radius) {
radius *= radius;
final org.bukkit.World world = location.getWorld();
for (Player player : CitizensAPI.getLocationLookup().getNearbyPlayers(location, radius)) {
if (world != player.getWorld() || from != null && !player.canSee(from)
|| location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius) {
continue;
}
for (Player player : CitizensAPI.getLocationLookup().getNearbyVisiblePlayers(from, location, radius)) {
for (Packet<?> packet : packets) {
NMSImpl.sendPacket(player, packet);
}

View File

@ -2209,12 +2209,7 @@ public class NMSImpl implements NMSBridge {
public static void sendPacketsNearby(Player from, Location location, Collection<Packet<?>> packets, double radius) {
radius *= radius;
final org.bukkit.World world = location.getWorld();
for (Player player : CitizensAPI.getLocationLookup().getNearbyPlayers(location, radius)) {
if (world != player.getWorld() || from != null && !player.canSee(from)
|| location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius) {
continue;
}
for (Player player : CitizensAPI.getLocationLookup().getNearbyVisiblePlayers(from, location, radius)) {
for (Packet<?> packet : packets) {
NMSImpl.sendPacket(player, packet);
}

View File

@ -2207,12 +2207,7 @@ public class NMSImpl implements NMSBridge {
public static void sendPacketsNearby(Player from, Location location, Collection<Packet<?>> packets, double radius) {
radius *= radius;
final org.bukkit.World world = location.getWorld();
for (Player player : CitizensAPI.getLocationLookup().getNearbyPlayers(location, radius)) {
if (world != player.getWorld() || from != null && !player.canSee(from)
|| location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius) {
continue;
}
for (Player player : CitizensAPI.getLocationLookup().getNearbyVisiblePlayers(from, location, radius)) {
for (Packet<?> packet : packets) {
NMSImpl.sendPacket(player, packet);
}

View File

@ -1287,7 +1287,7 @@ public class NMSImpl implements NMSBridge {
PerPlayerMetadata<Long> meta = CitizensAPI.getLocationLookup().registerMetadata("sleeping", null);
if (sleep) {
List<Player> nearbyPlayers = Lists.newArrayList(
Iterables.filter(CitizensAPI.getLocationLookup().getNearbyPlayers(entity.getLocation(), 64), p -> {
Iterables.filter(CitizensAPI.getLocationLookup().getNearbyVisiblePlayers(entity, 64), p -> {
Long time = meta.getMarker(p.getUniqueId(), entity.getUniqueId().toString());
if (time == null || Math.abs(System.currentTimeMillis() - time) > 5000)
return true;
@ -1762,12 +1762,7 @@ public class NMSImpl implements NMSBridge {
public static void sendPacketsNearby(Player from, Location location, Collection<Packet<?>> packets, double radius) {
radius *= radius;
final org.bukkit.World world = location.getWorld();
for (Player player : CitizensAPI.getLocationLookup().getNearbyPlayers(location, radius)) {
if (world != player.getWorld() || from != null && !player.canSee(from)
|| location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius) {
continue;
}
for (Player player : CitizensAPI.getLocationLookup().getNearbyVisiblePlayers(from, location, radius)) {
for (Packet<?> packet : packets) {
NMSImpl.sendPacket(player, packet);
}