Skip to content

Commit

Permalink
Fixed #279
Browse files Browse the repository at this point in the history
  • Loading branch information
wdog5734 committed Oct 16, 2024
1 parent 9675c0e commit 2a9c287
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,8 @@ default void pushTeleportCause(PlayerTeleportEvent.TeleportCause cause) {
default boolean bridge$teleportCancelled() {
throw new IllegalStateException("Not implemented");
}

default void detectRateSpam(String s) {
throw new IllegalStateException("Not implemented");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,23 @@ private void broadcastChatMessage(PlayerChatMessage playerchatmessage) {
this.chat(s, playerchatmessage, true);
}
// this.server.getPlayerList().broadcastChatMessage(playerchatmessage, this.player, ChatMessageType.bind(ChatMessageType.CHAT, (Entity) this.player));
this.detectRateSpam();
this.detectRateSpam(s);
}

@Override
public void detectRateSpam(String s) {
boolean counted = true;
for (String exclude : org.spigotmc.SpigotConfig.spamExclusions) {
if (exclude != null && s.startsWith(exclude)) {
counted = false;
break;
}
}
// Spigot end
this.chatSpamTickCount += 20;
if (counted && this.chatSpamTickCount > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {
this.disconnect(Component.translatable("disconnect.spam"));
}
}

@Inject(method = "handlePlayerCommand", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerPlayer;resetLastActionTime()V"))
Expand Down

0 comments on commit 2a9c287

Please sign in to comment.