attempt to solve a concurrent modification exception shown in issue
@@ -50,9 +50,7 @@ public class ChatIdentifierService extends ServiceMod {
final String messageOnly = matcher.group(2);
if (!Strings.isNullOrEmpty(messageSender)) {
for (NetworkPlayerInfo data : getLocalPlayer().connection.getPlayerInfoMap()) {
- if (String.CASE_INSENSITIVE_ORDER.compare(
- messageSender, data.getGameProfile().getName())
- == 0) {
+ if (String.CASE_INSENSITIVE_ORDER.compare(messageSender, data.getGameProfile().getName()) == 0) {
callback.accept(data.getGameProfile(), messageOnly);
return true;
}
@@ -71,6 +69,7 @@ public class ChatIdentifierService extends ServiceMod {
SPacketChat packet = (SPacketChat) event.getPacket();
String message = packet.getChatComponent().getUnformattedText();
if (!Strings.isNullOrEmpty(message)) {
+ MC.addScheduledTask(() -> {
// normal public messages
if (extract(
message,
@@ -82,7 +81,8 @@ public class ChatIdentifierService extends ServiceMod {
@Override
public void onSuccess(@Nullable PlayerInfo result) {
if (result != null)
- MinecraftForge.EVENT_BUS.post(ChatMessageEvent.newPublicChat(result, msg));
+ MinecraftForge.EVENT_BUS
+ .post(ChatMessageEvent.newPublicChat(result, msg));
}
@Override
@@ -90,7 +90,8 @@ public class ChatIdentifierService extends ServiceMod {
PlayerInfoHelper.generateOfflineWithCallback(senderProfile.getName(), this);
}
});
- })) return;
+ }))
+ return;
// private messages to the local player
if (extract(
@@ -127,7 +128,8 @@ public class ChatIdentifierService extends ServiceMod {
PlayerInfoHelper.generateOfflineWithCallback(senderProfile.getName(), this);
}
});
- })) return;
+ }))
+ return;
// outgoing pms from local player
if (extract(
@@ -161,12 +163,15 @@ public class ChatIdentifierService extends ServiceMod {
@Override
public void onFailure(Throwable t) {
- PlayerInfoHelper.generateOfflineWithCallback(receiverProfile.getName(), this);
+ PlayerInfoHelper
+ .generateOfflineWithCallback(receiverProfile.getName(), this);
}
});
- })) return;
+ }))
+ return;
// if reached here then the message is unrecognized
+ });
}
}
}
