use of net.minecraft.network.packet.s2c.play.GameMessageS2CPacket in project BleachHack by BleachDrinker420.
the class BetterChat method onPacketRead.
@BleachSubscribe
public void onPacketRead(EventPacket.Read event) {
if (event.getPacket() instanceof GameMessageS2CPacket) {
GameMessageS2CPacket packet = (GameMessageS2CPacket) event.getPacket();
if (packet.getLocation() == MessageType.GAME_INFO)
return;
Text message = packet.getMessage().shallowCopy();
if (getSetting(6).asToggle().getState()) {
message = Texts.forEachWord(message, (string, style) -> {
String stripped = Formatting.strip(string);
if (stripped.matches("['\u00a1-\u00f5]+\u00ff[0-~]+")) {
String decrypted = decrypt(stripped);
if (decrypted != null) {
return new LiteralText("<").styled(s -> s.withColor(BleachHack.watermark.getColor1())).append(new LiteralText(decrypted).styled(s -> s.withColor(0xffffff).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText(string).setStyle(style))))).append(new LiteralText(">").styled(s -> s.withColor(BleachHack.watermark.getColor2())));
}
}
return null;
});
}
if (!filterPatterns.isEmpty() && getSetting(4).asToggle().getState()) {
int mode = getSetting(4).asToggle().getChild(0).asMode().getMode();
if (mode == 0) {
for (Pattern pattern : filterPatterns) {
message = Texts.replaceAll(message, pattern, (string, style) -> new LiteralText(StringUtils.repeat('|', string.length() * 2)).styled(s -> s.withColor(Formatting.GRAY).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText(string).setStyle(style)))));
}
} else {
for (Pattern pat : filterPatterns) {
if (pat.matcher(message.getString()).find()) {
if (mode == 1) {
Text messageCopy = message.shallowCopy();
message = new LiteralText("\u00a77Blocked Message").styled(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, messageCopy)));
break;
} else {
event.setCancelled(true);
return;
}
}
}
}
}
if (getSetting(3).asToggle().getState()) {
DateTimeFormatter formatter = getSetting(3).asToggle().getChild(0).asToggle().getState() ? DateTimeFormatter.ofPattern("HH:mm:ss") : DateTimeFormatter.ofPattern("HH:mm");
message = new LiteralText("\u00a78[\u00a77" + LocalDateTime.now().format(formatter) + "\u00a78] ").append(message);
}
if (!message.equals(packet.getMessage())) {
packet.message = message;
}
}
}
use of net.minecraft.network.packet.s2c.play.GameMessageS2CPacket in project pingspam by BasiqueEvangelist.
the class PingLogic method pingOnlinePlayer.
public static void pingOnlinePlayer(ServerPlayerEntity player, Text message, MessageType type, UUID senderUUID) {
SoundEvent pingSound = PlayerUtils.getPingSound(player);
if (pingSound != null) {
player.playSound(pingSound, SoundCategory.PLAYERS, 1.0F, 1.0F);
}
List<Text> unreadPings = PlayerUtils.getUnreadPingsFor(player);
while (unreadPings.size() >= 100) {
unreadPings.remove(0);
}
unreadPings.add(message);
Text pingMessage = message.shallowCopy().formatted(Formatting.AQUA);
player.networkHandler.sendPacket(new GameMessageS2CPacket(pingMessage, type, senderUUID));
}
use of net.minecraft.network.packet.s2c.play.GameMessageS2CPacket in project pingspam by BasiqueEvangelist.
the class PlayerManagerMixin method onMessageBroadcasted.
@Redirect(method = "broadcastChatMessage", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/PlayerManager;sendToAll(Lnet/minecraft/network/Packet;)V"))
public void onMessageBroadcasted(PlayerManager playerManager, Packet<?> packet) {
GameMessageS2CPacketAccessor access = (GameMessageS2CPacketAccessor) packet;
PingLogic.ProcessedPing result = PingLogic.processPings(playerManager, access.pingspam$getMessage(), access.pingspam$getLocation(), access.pingspam$getSenderUuid());
if (result.pingSucceeded && result.sender != null) {
if (!result.pingedPlayers.getOnlinePlayers().contains(result.sender)) {
result.sender.networkHandler.sendPacket(new GameMessageS2CPacket(access.pingspam$getMessage().shallowCopy().formatted(Formatting.GOLD), access.pingspam$getLocation(), access.pingspam$getSenderUuid()));
result.pingedPlayers.add(result.sender);
}
}
for (ServerPlayerEntity player : players) {
if (!result.pingedPlayers.getOnlinePlayers().contains(player))
player.networkHandler.sendPacket(packet);
}
}
Aggregations