use of com.minecolonies.coremod.network.messages.client.colony.ColonyVisitorViewDataMessage in project minecolonies by Minecolonies.
the class VisitorManager method sendPackets.
@Override
public void sendPackets(@NotNull final Set<ServerPlayerEntity> closeSubscribers, @NotNull final Set<ServerPlayerEntity> newSubscribers) {
Set<ServerPlayerEntity> players = new HashSet<>(newSubscribers);
players.addAll(closeSubscribers);
Set<IVisitorData> toSend = new HashSet<>();
boolean refresh = !newSubscribers.isEmpty() || this.isDirty;
if (refresh) {
toSend = new HashSet<>(visitorMap.values());
for (final IVisitorData data : visitorMap.values()) {
data.clearDirty();
}
this.clearDirty();
} else {
for (final IVisitorData data : visitorMap.values()) {
if (data.isDirty()) {
toSend.add(data);
}
data.clearDirty();
}
}
if (toSend.isEmpty()) {
return;
}
final ColonyVisitorViewDataMessage message = new ColonyVisitorViewDataMessage(colony, toSend, refresh);
for (final ServerPlayerEntity player : players) {
Network.getNetwork().sendToPlayer(message, player);
}
}
use of com.minecolonies.coremod.network.messages.client.colony.ColonyVisitorViewDataMessage in project minecolonies by ldtteam.
the class VisitorManager method sendPackets.
@Override
public void sendPackets(@NotNull final Set<ServerPlayerEntity> closeSubscribers, @NotNull final Set<ServerPlayerEntity> newSubscribers) {
Set<ServerPlayerEntity> players = new HashSet<>(newSubscribers);
players.addAll(closeSubscribers);
Set<IVisitorData> toSend = new HashSet<>();
boolean refresh = !newSubscribers.isEmpty() || this.isDirty;
if (refresh) {
toSend = new HashSet<>(visitorMap.values());
for (final IVisitorData data : visitorMap.values()) {
data.clearDirty();
}
this.clearDirty();
} else {
for (final IVisitorData data : visitorMap.values()) {
if (data.isDirty()) {
toSend.add(data);
}
data.clearDirty();
}
}
if (toSend.isEmpty()) {
return;
}
final ColonyVisitorViewDataMessage message = new ColonyVisitorViewDataMessage(colony, toSend, refresh);
for (final ServerPlayerEntity player : players) {
Network.getNetwork().sendToPlayer(message, player);
}
}
Aggregations