v0.4.36: suppress command/preload chat broadcast
Command-block and player usage no longer spams chat: - Command feedback (videoPlace/videoDelete/videoMute) now uses sendSuccess(..., false) so only the executor sees it; command blocks write to their own output + server log instead of broadcasting to ops. - Removed client-side [videopreload]/[videocache] notifyChat spam in VideoCache; download status remains in the client log via LOG. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@ org.gradle.configuration-cache=false
|
|||||||
|
|
||||||
# Mod
|
# Mod
|
||||||
mod_id=video_player
|
mod_id=video_player
|
||||||
mod_version=0.4.35
|
mod_version=0.4.36
|
||||||
maven_group=com.ejclaw.videoplayer
|
maven_group=com.ejclaw.videoplayer
|
||||||
archives_base_name=video_player
|
archives_base_name=video_player
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,7 @@ package com.ejclaw.videoplayer.client.playback;
|
|||||||
import com.ejclaw.videoplayer.VideoPlayerMod;
|
import com.ejclaw.videoplayer.VideoPlayerMod;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.ChatFormatting;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
@@ -138,7 +136,6 @@ public final class VideoCache {
|
|||||||
boolean gone = Files.deleteIfExists(p);
|
boolean gone = Files.deleteIfExists(p);
|
||||||
VideoPlayerMod.LOG.info("[{}] purge: {} -> deleted={} ({})",
|
VideoPlayerMod.LOG.info("[{}] purge: {} -> deleted={} ({})",
|
||||||
VideoPlayerMod.MOD_ID, url, gone, p.getFileName());
|
VideoPlayerMod.MOD_ID, url, gone, p.getFileName());
|
||||||
if (gone) notifyChat("[videocache] 캐시 삭제: " + url, ChatFormatting.YELLOW);
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
VideoPlayerMod.LOG.warn("[{}] purge failed for {}: {}",
|
VideoPlayerMod.LOG.warn("[{}] purge failed for {}: {}",
|
||||||
VideoPlayerMod.MOD_ID, url, t.toString());
|
VideoPlayerMod.MOD_ID, url, t.toString());
|
||||||
@@ -202,7 +199,6 @@ public final class VideoCache {
|
|||||||
}
|
}
|
||||||
VideoPlayerMod.LOG.info("[{}] clearAll: deleted={} failed={}",
|
VideoPlayerMod.LOG.info("[{}] clearAll: deleted={} failed={}",
|
||||||
VideoPlayerMod.MOD_ID, deleted, failed);
|
VideoPlayerMod.MOD_ID, deleted, failed);
|
||||||
notifyChat("[videocache] 전체 캐시 삭제: " + deleted + "개 파일", ChatFormatting.YELLOW);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Kick off a background download. No-op if already cached or in flight. */
|
/** Kick off a background download. No-op if already cached or in flight. */
|
||||||
@@ -215,15 +211,13 @@ public final class VideoCache {
|
|||||||
// a stale key would silently block a re-preload.
|
// a stale key would silently block a re-preload.
|
||||||
if (lookup(url) != null) {
|
if (lookup(url) != null) {
|
||||||
VideoPlayerMod.LOG.info("[{}] preload: already cached {}", VideoPlayerMod.MOD_ID, url);
|
VideoPlayerMod.LOG.info("[{}] preload: already cached {}", VideoPlayerMod.MOD_ID, url);
|
||||||
notifyChat("[videopreload] 이미 캐시됨: " + url, ChatFormatting.GRAY);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!IN_FLIGHT.add(url)) {
|
if (!IN_FLIGHT.add(url)) {
|
||||||
VideoPlayerMod.LOG.info("[{}] preload: already downloading {}", VideoPlayerMod.MOD_ID, url);
|
VideoPlayerMod.LOG.info("[{}] preload: already downloading {}", VideoPlayerMod.MOD_ID, url);
|
||||||
notifyChat("[videopreload] 이미 다운로드 중: " + url, ChatFormatting.GRAY);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
notifyChat("[videopreload] 다운로드 대기열 추가: " + url, ChatFormatting.YELLOW);
|
VideoPlayerMod.LOG.info("[{}] preload: queued {}", VideoPlayerMod.MOD_ID, url);
|
||||||
// Capture the current epoch at submit time. The download thread checks against
|
// Capture the current epoch at submit time. The download thread checks against
|
||||||
// CACHE_EPOCH later — any mismatch means clearAll() ran in between and this
|
// CACHE_EPOCH later — any mismatch means clearAll() ran in between and this
|
||||||
// download must abort without publishing.
|
// download must abort without publishing.
|
||||||
@@ -370,7 +364,6 @@ public final class VideoCache {
|
|||||||
}
|
}
|
||||||
VideoPlayerMod.LOG.info("[{}] preload: indexed existing cache {} -> {}",
|
VideoPlayerMod.LOG.info("[{}] preload: indexed existing cache {} -> {}",
|
||||||
VideoPlayerMod.MOD_ID, url, finalPath.getFileName());
|
VideoPlayerMod.MOD_ID, url, finalPath.getFileName());
|
||||||
notifyChat("[videopreload] 기존 캐시 사용: " + url, ChatFormatting.GREEN);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,8 +378,6 @@ public final class VideoCache {
|
|||||||
VideoPlayerMod.LOG.warn(
|
VideoPlayerMod.LOG.warn(
|
||||||
"[{}] preload: total-cache cap reached ({}/{} MB); aborting {}",
|
"[{}] preload: total-cache cap reached ({}/{} MB); aborting {}",
|
||||||
VideoPlayerMod.MOD_ID, usedMb, capMb, url);
|
VideoPlayerMod.MOD_ID, usedMb, capMb, url);
|
||||||
notifyChat("[videopreload] 실패 (전체 캐시 " + capMb + "MB 초과 / 현재 "
|
|
||||||
+ usedMb + "MB): " + url, ChatFormatting.RED);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,7 +391,6 @@ public final class VideoCache {
|
|||||||
if (code >= 400) {
|
if (code >= 400) {
|
||||||
VideoPlayerMod.LOG.warn("[{}] preload: HTTP {} for {}",
|
VideoPlayerMod.LOG.warn("[{}] preload: HTTP {} for {}",
|
||||||
VideoPlayerMod.MOD_ID, code, url);
|
VideoPlayerMod.MOD_ID, code, url);
|
||||||
notifyChat("[videopreload] 실패 (HTTP " + code + "): " + url, ChatFormatting.RED);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -427,8 +417,6 @@ public final class VideoCache {
|
|||||||
VideoPlayerMod.MOD_ID, url, capMb);
|
VideoPlayerMod.MOD_ID, url, capMb);
|
||||||
// Same close-before-delete dance for Windows.
|
// Same close-before-delete dance for Windows.
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
notifyChat("[videopreload] 실패 (단일 영상 " + capMb + "MB 초과): " + url,
|
|
||||||
ChatFormatting.RED);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (existingCacheBytes + total > MAX_CACHE_BYTES) {
|
if (existingCacheBytes + total > MAX_CACHE_BYTES) {
|
||||||
@@ -438,8 +426,6 @@ public final class VideoCache {
|
|||||||
"[{}] preload: total-cache cap exceeded ({}>{} MB); aborting {}",
|
"[{}] preload: total-cache cap exceeded ({}>{} MB); aborting {}",
|
||||||
VideoPlayerMod.MOD_ID, usedMb, capMb, url);
|
VideoPlayerMod.MOD_ID, usedMb, capMb, url);
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
notifyChat("[videopreload] 실패 (전체 캐시 " + capMb + "MB 초과): " + url,
|
|
||||||
ChatFormatting.RED);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
out.write(buf, 0, n);
|
out.write(buf, 0, n);
|
||||||
@@ -475,13 +461,9 @@ public final class VideoCache {
|
|||||||
}
|
}
|
||||||
VideoPlayerMod.LOG.info("[{}] preload: cached {} ({} bytes) -> {}",
|
VideoPlayerMod.LOG.info("[{}] preload: cached {} ({} bytes) -> {}",
|
||||||
VideoPlayerMod.MOD_ID, url, total, finalPath.getFileName());
|
VideoPlayerMod.MOD_ID, url, total, finalPath.getFileName());
|
||||||
long mb = Math.max(1, total / (1024 * 1024));
|
|
||||||
notifyChat("[videopreload] 완료 (" + mb + " MB): " + url, ChatFormatting.GREEN);
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
VideoPlayerMod.LOG.warn("[{}] preload failed for {}: {}",
|
VideoPlayerMod.LOG.warn("[{}] preload failed for {}: {}",
|
||||||
VideoPlayerMod.MOD_ID, url, t.toString());
|
VideoPlayerMod.MOD_ID, url, t.toString());
|
||||||
notifyChat("[videopreload] 실패 (" + t.getClass().getSimpleName() + "): " + url,
|
|
||||||
ChatFormatting.RED);
|
|
||||||
// Best-effort cleanup of any leftover .part on the error path.
|
// Best-effort cleanup of any leftover .part on the error path.
|
||||||
if (partPath != null) {
|
if (partPath != null) {
|
||||||
try { Files.deleteIfExists(partPath); } catch (Throwable ignored) {}
|
try { Files.deleteIfExists(partPath); } catch (Throwable ignored) {}
|
||||||
@@ -494,16 +476,6 @@ public final class VideoCache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Post a status line to the local player's chat. No-op if there's no client/player yet. */
|
|
||||||
private static void notifyChat(String text, ChatFormatting color) {
|
|
||||||
Minecraft mc = Minecraft.getInstance();
|
|
||||||
if (mc == null) return;
|
|
||||||
mc.execute(() -> {
|
|
||||||
if (mc.player == null) return;
|
|
||||||
mc.player.sendSystemMessage(Component.literal(text).withStyle(color));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sum of regular-file sizes under {@code dir}, skipping {@code excludePart} (the .part file
|
* Sum of regular-file sizes under {@code dir}, skipping {@code excludePart} (the .part file
|
||||||
* for the in-flight download — we account for that via the running {@code total} counter).
|
* for the in-flight download — we account for that via the running {@code total} counter).
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public final class VideoDeleteCommand {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
level.setBlock(pos, Blocks.AIR.defaultBlockState(), Block.UPDATE_ALL);
|
level.setBlock(pos, Blocks.AIR.defaultBlockState(), Block.UPDATE_ALL);
|
||||||
src.sendSuccess(() -> Component.literal("anchor deleted at " + pos.toShortString()), true);
|
src.sendSuccess(() -> Component.literal("anchor deleted at " + pos.toShortString()), false);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public final class VideoMuteCommand {
|
|||||||
ServerPlayNetworking.send(p, new SyncAnchorPayload(pos, be.toNbt()));
|
ServerPlayNetworking.send(p, new SyncAnchorPayload(pos, be.toNbt()));
|
||||||
}
|
}
|
||||||
final boolean mFinal = muted;
|
final boolean mFinal = muted;
|
||||||
src.sendSuccess(() -> Component.literal("anchor " + (mFinal ? "muted" : "unmuted")), true);
|
src.sendSuccess(() -> Component.literal("anchor " + (mFinal ? "muted" : "unmuted")), false);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ public final class VideoPlaceCommand {
|
|||||||
ServerPlayNetworking.send(p, new SyncAnchorPayload(pos, nbt));
|
ServerPlayNetworking.send(p, new SyncAnchorPayload(pos, nbt));
|
||||||
}
|
}
|
||||||
final BlockPos fp = pos;
|
final BlockPos fp = pos;
|
||||||
src.sendSuccess(() -> Component.literal("anchor placed at " + fp.toShortString()), true);
|
src.sendSuccess(() -> Component.literal("anchor placed at " + fp.toShortString()), false);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user