Fix custom npc chat error by detecting fake players from mods throwing chat events. Fixes
@@ -511,11 +511,14 @@ public static void onPostEnd(ForgeToSpongeEventData eventData) {
}
// Chat spam suppression from MC
+ if (!SpongeImplHooks.isFakePlayer(player)) {
+ // We don't want to check fake players.
int chatSpamThresholdCount = ((IMixinNetPlayHandler) player.connection).getChatSpamThresholdCount() + 20;
((IMixinNetPlayHandler) player.connection).setChatSpamThresholdCount(chatSpamThresholdCount);
if (chatSpamThresholdCount > 200 && !SpongeImpl.getServer().getPlayerList().canSendCommands(player.getGameProfile())) {
player.connection.disconnect(new TextComponentTranslation("disconnect.spam"));
}
+ }
// We set the forge component to null here to exit NetHandlerPlayServer#processChatMessage before it sends a message
// This is done since we send our own message via the channel above
forgeEvent.setComponent(null);
