Skip to content

Commit

Permalink
LunaChat v3.0.13 : Fixed issue #208
Browse files Browse the repository at this point in the history
  • Loading branch information
ucchyocean committed Sep 6, 2020
1 parent 945a270 commit d403b16
Showing 1 changed file with 43 additions and 47 deletions.
90 changes: 43 additions & 47 deletions src/main/java/com/github/ucchyocean/lc3/channel/BukkitChannel.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,64 +65,60 @@ protected void sendMessage(
if ( isBroadcastChannel() ) {
// ブロードキャストチャンネル

if ( isWorldRange() && player.isOnline() && player.getWorldName() != null ) {

if ( player instanceof ChannelMemberBukkit ) {
// ↑常にtrueだと思うが、念のため。

World w = ((ChannelMemberBukkit)player).getWorld();

if ( getChatRange() > 0 ) {
// 範囲チャット

Location origin = ((ChannelMemberBukkit)player).getLocation();
for ( Player p : Bukkit.getOnlinePlayers() ) {
ChannelMember cp = ChannelMember.getChannelMember(p);
if ( p.getWorld().equals(w) &&
origin.distance(p.getLocation()) <= getChatRange() &&
!getHided().contains(cp) ) {
recipients.add(ChannelMember.getChannelMember(p));
}
}

} else {
// ワールドチャット

for ( Player p : Bukkit.getOnlinePlayers() ) {
ChannelMember cp = ChannelMember.getChannelMember(p);
if ( p.getWorld().equals(w) && !getHided().contains(cp) ) {
recipients.add(ChannelMember.getChannelMember(p));
}
}
}
for ( Player p : Bukkit.getOnlinePlayers() ) {
ChannelMember cp = ChannelMember.getChannelMember(p);
if ( !getHided().contains(cp) ) {
recipients.add(cp);
}
}
} else {
// 通常チャンネル

for ( ChannelMember mem : getMembers() ) {
if ( mem != null && mem.isOnline() && !getHided().contains(mem) ) {
recipients.add(mem);
}
}
}

if ( isWorldRange() && player.isOnline() && player.getWorldName() != null ) {
// ワールドチャットや範囲チャットの場合は、範囲外のプレイヤーをrecipientsから抜く

List<ChannelMember> recipientsNew = new ArrayList<>();

if ( getChatRange() > 0 ) {
// 範囲チャット

// 受信者が自分以外いない場合は、メッセージを表示する
if ( Messages.noRecipientMessage("", "").length > 0 && (
recipients.size() == 0 ||
(recipients.size() == 1 &&
recipients.get(0).getName().equals(player.getName()) ) ) ) {
sendNoRecipientMessage = true;
@Nullable Location origin = ((ChannelMemberBukkit)player).getLocation();
for ( ChannelMember recipient : recipients ) {
@Nullable Location target = ((ChannelMemberBukkit)recipient).getLocation();
if ( origin != null && target != null &&
origin.getWorld().equals(target.getWorld()) &&
origin.distance(target) <= getChatRange() ) {
recipientsNew.add(recipient);
}
}

} else {
// 通常ブロードキャスト(全員へ送信)
// ワールドチャット

for ( Player p : Bukkit.getOnlinePlayers() ) {
ChannelMember cp = ChannelMember.getChannelMember(p);
if ( !getHided().contains(cp) ) {
recipients.add(cp);
@Nullable World w = ((ChannelMemberBukkit)player).getWorld();
for ( ChannelMember recipient : recipients ) {
@Nullable World target = ((ChannelMemberBukkit)recipient).getWorld();
if ( w != null && target != null && w.equals(target) ) {
recipientsNew.add(recipient);
}
}
}

} else {
// 通常チャンネル
recipients = recipientsNew;

for ( ChannelMember mem : getMembers() ) {
if ( mem != null && mem.isOnline() && !getHided().contains(mem) ) {
recipients.add(mem);
}
// 受信者が自分以外いない場合は、メッセージを表示する
if ( Messages.noRecipientMessage("", "").length > 0 && (
recipients.size() == 0 ||
(recipients.size() == 1 &&
recipients.get(0).getName().equals(player.getName()) ) ) ) {
sendNoRecipientMessage = true;
}
}

Expand Down

0 comments on commit d403b16

Please sign in to comment.