ChatImage
在 Minecraft 中发送图片和 GIF!
功能特性
DiscordSRV 和 EssentialsDiscord 支持
从 Discord 发送的图片和 GIF 将在 Minecraft 聊天窗口中渲染显示!
悬浮图片
发送不会占用聊天空间位置的图片!玩家可以输入 /hideimages,或者在配置文件中将其设为默认开启。
渲染选项
平滑渲染效果几乎适用于所有图片,但对于具有简单色板的扁平化设计,简单渲染的效果可能更好。这两种选项在速度上没有明显差异。
部分透明度支持
发送带有混合透明度级别的图片!
PlaceholderAPI 支持
使用 %chatimage_image% 占位符在任何位置插入图片和 GIF!这可用于将图片放置在物品描述(lore)中。
详情请见下方的 占位符用法。
NSFW 内容过滤
你可以过滤掉任何包含露骨内容的图片和 GIF!此功能默认关闭,但只需在配置中启用即可使用。重复的内容会在插件内部进行缓存,以提高处理速度。
BungeeCord 和 Velocity 支持
本插件在 Spigot、BungeeCord 和 Velocity 上的表现完全一致!唯一的例外是 Velocity 目前不支持 GIF(当 Velocity API 支持对话框时将改变这一情况)。
注意: 仅在你的服务器拥有某种形式的全球聊天时,才将此插件安装在 BungeeCord/Velocity 上。否则,请将该插件安装到每个 Spigot 服务器上。
配置文件
# ============================================= #
# ChatImage 配置 #
# By: ChickenSaysBak #
# #
# 重载配置请使用 /chatimage reload #
# #
# 权限: #
# - chatimage.use (用于渲染图片) #
# - chatimage.admin (用于使用 /chatimage) #
# ============================================= #
# 冷却时间设置 #
# 设置用户在发送另一张图片或 GIF 之前必须等待的时间(以秒为单位)。
cooldown: 3
# 如果发送的是图片 URL(而不是图片本身渲染时),冷却时间将从 0 开始计算。
# 如果启用此项,当用户反复发送 URL 时,冷却时间会延长。这有助于防止频繁刷屏者。
strict_cooldown: false
# 图片设置 #
# 在渲染图片和 GIF 时使用平滑效果。
# 对于照片级真实的图片效果最佳,但对于扁平图形,简单渲染可能看起来更好。
# 其速度几乎与简单渲染一样快。
smooth_render: true
# 去除图片边缘多余的空白区域。
# 不适用于 GIF。
trim_transparency: true
# 聊天中图片的最大尺寸。Minecraft 默认聊天设置下的最大值为 35 x 20。
# 参见 HIDDEN IMAGE SETTINGS 以更改隐藏图片的尺寸。
# 参见 GIF SETTINGS 以更改 GIF 的尺寸。
max_width: 35
max_height: 20
# 隐藏图片设置 #
# 当玩家运行 /hideimages 时,聊天中发送的图片会被最小化,并通过鼠标悬停查看。
# 宽大的图片在隐藏时会比正常状态下显得更小。
hidden_images:
# 默认隐藏图片。玩家可以单独使用 /showimages 覆盖此设置。
# 如果启用此项,建议减少冷却时间,因为此选项已经减少了行刷屏。
auto_hide: false
# 仅针对隐藏图片的最大尺寸。
# 如果你增加宽度,请注意风险:可能会为使用较小窗口大小或较大 GUI 缩放比例的用户造成图片损坏。
# 相反,在较小的 GUI 缩放比例下,你可以渲染更大的图片,但你无法知道谁在使用何种缩放比例。
# 对于标准 854 x 480 或更大的窗口,23 x 24 是一个安全的默认值。
# 如果你不介意可能为某些全屏用户破坏图片,可以将其增加到 26 x 27 以适配全屏用户。
max_width: 23
max_height: 24
# GIF 设置 #
gifs:
# 仅针对 GIF 的最大尺寸。Minecraft 默认设置下的最大值为 22 x 22。
max_width: 22
max_height: 22
# 过滤设置 #
explicit_content:
# 如果发现露骨内容,则阻止图片渲染。不适用于 '/chatimage send'
# 这将影响速度,增加几秒延迟。重复的内容会在插件内部进行缓存以提高速度。
# 功能提供自:https://api4.ai/apis/nsfw
enabled: false
# 如果图片包含露骨内容,包含链接的整条消息将不会被发送。
# 注意:这包括没有渲染图片权限的人发送的消息。
# Velocity 注意事项:你需要像 SignedVelocity 这样的插件才能在 Velocity 服务器上正确工作。
remove_message: false
# 常规设置 #
# 如果玩家的客户端语言不受支持,则使用的默认语言。
# 你可以在 messages 文件夹中添加语言。请考虑在插件的 GitHub 或 SpigotMC 页面上分享这些语言包!
# 添加语言时,请使用有效的游戏内语言代码命名文件:https://minecraft.wiki/w/Language#Languages
language_default: en_us
# 向控制台打印额外消息以帮助查找问题来源。
debug: false
权限
chatimage.use
这是使用 URL 发送图片和 GIF 所必需的权限。它可以作为一个不错的捐赠者特权!
chatimage.admin
这是使用 /chatimage 命令所必需的权限。详见下方 ↓
命令
/hideimages
所有玩家均可使用。启用后,图片将被最小化,玩家需要将鼠标悬停在上方才能查看图片。
/showimages
反转 /hideimages 的效果。
/chatimage reload
在对配置文件进行任何更改后输入此命令以重新加载配置。
/chatimage send <player>|all <url> [smooth] [trim] [width] [height] [text]
向特定玩家或所有玩家发送图片和 GIF。如果未指定末尾的选项,则使用配置文件中的默认值。Trim(裁剪)选项不适用于 GIF。
此外,您可以在图片或 GIF 的右侧/上方附加显示的文本。这支持颜色标签、换行符 <br> 以及 PlaceholderAPI 提供的占位符。该命令具有多种创意用途!
使用的命令
/chatimage send ChickenSaysBak https://images.vexels.com/media/users/3/220947/isolated/preview/e22f7e6fdc024de159849b35e2a82c7a-skull-mouth-open-illustration.png true true 35 20 <br><br><br><br><br><br><br><br><br> <reset> <reset> <reset> <reset> <reset> <reset> <reset> <dark_red><b>YOU<br> <reset> <reset> <reset> <reset> <reset> <reset> <dark_red><b>DIED!!
/chatimage save <name> <url> [smooth] [trim] [width] [height]
与上述命令类似,但会将文本图像保存到插件文件夹中以便日后使用。
/chatimage delete <name>
删除已保存的图片。
/chatimage send <player>|all <name> [text]
向特定玩家或所有玩家发送已保存的图片。文本可以像上面的其他 send 子命令一样附加在末尾。发送已保存的图片比从 URL 发送要快得多,因为通过互联网检索图像是整个过程中耗时最长的步骤。
占位符用法
PlaceholderAPI 用法
ChatImage 为 PlaceholderAPI 提供了一个自定义占位符,用于在任何位置插入图片。您只需安装 PlaceholderAPI 插件和 ChatImage 即可使用该功能。使用方法如下所示:
%chatimage_image: <name> [text]%
%chatimage_image: <url> [smooth] [trim] [width] [height] [text]%
参数与 /chatimage send 命令完全相同。您可以在 text 参数中使用其他占位符,但由于占位符嵌套在另一个占位符内部,因此必须使用花括号而不是百分号。例如:
%chatimage_image: heart n Your Health n {player_health}%
注意: 建议为占位符使用已保存的图片而不是 URL,因为从互联网检索图像会导致 PlaceholderAPI 插件及使用该占位符的任何插件出现卡顿。
开发者 API
API 用法
要使用此 API,请将相应的依赖项添加到您的项目中:
Maven
<dependency>
<groupId>io.github.chickensaysbak</groupId>
<artifactId>chatimage-api</artifactId>
<version>3.0.0-1</version>
</dependency>
Gradle
implementation 'io.github.chickensaysbak:chatimage-api:3.0.0-1'
别忘了将 "ChatImage" 添加到 plugin.yml 的 depend 或 softdepend 部分。
创建图片
Component image = ChatImageAPI.createMediaFromURL("http://url.com/example.png");
您还可以使用其他可选参数。未指定的参数将使用配置文件中的默认值。
createMediaFromURL(String url, String text, boolean smooth, boolean trim, int width, int height)
发送图片
Paper & Velocity
player.sendMessage(media);
Spigot(需要依赖 adventure-platform-bungeecord)
player.spigot().sendMessage(BungeeComponentSerializer.get().serialize(media));
BungeeCord(需要依赖 adventure-platform-bungeecord)
player.sendMessage(BungeeComponentSerializer.get().serialize(media));
检查玩家是否隐藏了图片
if (ChatImageAPI.isHidingImages(player.getUniqueId())) {
// 玩家正在隐藏图片
}
提示
如果您在发送特定图片时遇到问题,请尝试将其上传到 Imgur、Imgbb、Gyazo 甚至 Discord。只需确保复制以 .png、.jpg、.gif 等结尾的直接图片链接即可。
如果您有任何问题、错误或建议,请随时联系我!
ChatImage
Send images and GIFs in Minecraft!
Features
DiscordSRV and EssentialsDiscord Support
Images and GIFs sent from Discord will render in Minecraft chat!
Hover Images
Send images without them taking up space in chat! Players can type /hideimages or it can be enabled by default in the configuration file.
Rendering Options
Smooth rendering looks better for almost all images, however, simple rendering may look better for flat designs with simple color palettes. There is no discernable difference in the speed of these options.
Partial-transparency support
Send images with mixed levels of transparency!
PlaceholderAPI Support
Insert images and GIFs anywhere with the %chatimage_image% placeholder! This can be used to put images on item lore.
See Placeholder Usage below for more details.
NSFW Content Filtration
You can filter out any images and GIFs containing explicit content! This feature is off by default, but you can utilize it simply by enabling it in the config. Duplicated content will cache within the plugin to increase processing speed.
BungeeCord and Velocity Support
This plugin will work exactly the same for Spigot, BungeeCord, and Velocity! The exception is that Velocity does not support GIFs for now (this will change when dialogs are supported by the Velocity API).
Note: Only install this plugin on BungeeCord/Velocity if your server has some form of global-chat. Otherwise, install the plugin on each Spigot server.
Config
# ============================================= #
# ChatImage Configuration #
# By: ChickenSaysBak #
# #
# To reload, use /chatimage reload #
# #
# Permissions: #
# - chatimage.use (to render images) #
# - chatimage.admin (to use /chatimage) #
# ============================================= #
# COOLDOWN SETTINGS #
# Sets how long (in seconds) someone must wait before another image or GIF will render.
cooldown: 3
# Cooldown will start from 0 if an image URL is sent (as opposed to it starting when the image itself renders).
# If enabled, this lengthens the cooldown if the user is repeatedly sending a URL. This can help against avid spammers.
strict_cooldown: false
# IMAGE SETTINGS #
# Uses a smoothing effect when rendering images and GIFs.
# Looks best on photo-realistic images, but simple rendering may look better for flat graphics.
# This is nearly just as fast as simple rendering.
smooth_render: true
# Gets rid of excessive blank space along the edges of images.
# Does not apply to GIFs.
trim_transparency: true
# Maximum dimensions for an image in chat. The maximum for default Minecraft chat settings is 35 x 20.
# See HIDDEN IMAGE SETTINGS for changing the dimensions of hidden images.
# See GIF SETTINGS for changing the dimensions of GIFs.
max_width: 35
max_height: 20
# HIDDEN IMAGE SETTINGS #
# When a player runs /hideimages, images sent in chat are minimized, and they can be viewed by hovering.
# Images that are wide will appear smaller than normal when hidden.
hidden_images:
# Hides images by default. Players can individually override this with /showimages.
# If enabled, consider reducing the cooldown since this option already reduces line spam.
auto_hide: false
# Maximum dimensions for hidden images only.
# If you increase the width, beware that you risk creating broken images for users on a smaller window size or bigger GUI scale.
# Conversely, on a smaller GUI scale, you can render way larger images, but there's no way to know who's using what scale.
# 23 x 24 is a safe default for the standard 854 x 480 window or larger.
# If you don't mind potentially breaking images for some users, you can increase it to 26 x 27 for full-screen users.
max_width: 23
max_height: 24
# GIF SETTINGS #
gifs:
# Maximum dimensions for GIFs only. The maximum for default Minecraft settings is 22 x 22.
max_width: 22
max_height: 22
# FILTRATION SETTINGS #
explicit_content:
# Prevents an image from rendering if explicit content is found. Does not apply to '/chatimage send'
# This will impact speed by a couple seconds. Duplicate images cache within the plugin to increase speed.
# Feature provided by: https://api4.ai/apis/nsfw
enabled: false
# If an image contains explicit content, the entire message with the link will not be sent.
# NOTE: This includes messages from people that do not have permission to render images.
# NOTE for Velocity: You will need a plugin like SignedVelocity for this to work correctly on Velocity servers.
remove_message: false
# GENERAL SETTINGS #
# The default language to use if a player's client language is unsupported.
# You can add languages in the messages folder. Please consider sharing these on the plugin's GitHub or SpigotMC page!
# If adding a language, name the file with a valid in-game language code: https://minecraft.wiki/w/Language#Languages
language_default: en_us
# Prints extra messages to console to help find the source of issues.
debug: false
Permissions
chatimage.use
This is required to send images and GIFs using URLs. It could make for a nice donor perk!
chatimage.admin
This is required to use the /chatimage command. See below ↓
Commands
/hideimages
This can be used by all players. If enabled, images will be minimized and require the player to hover to view the image.
/showimages
Reverses /hideimages.
/chatimage reload
Type this after making any changes to the config file.
/chatimage send <player>|all <url> [smooth] [trim] [width] [height] [text]
Send images and GIFs to specific players or all players. The options at the end will use the config values if they are not specified. Trim does not apply for GIFs.
Additionally, you can append text to display to the right of the image or above GIFs. This supports color tags, line breaks <br>, and placeholders provided by PlaceholderAPI. This command could have a variety of creative uses!
Command Used
/chatimage send ChickenSaysBak https://images.vexels.com/media/users/3/220947/isolated/preview/e22f7e6fdc024de159849b35e2a82c7a-skull-mouth-open-illustration.png true true 35 20 <br><br><br><br><br><br><br><br><br> <reset> <reset> <reset> <reset> <reset> <reset> <reset> <dark_red><b>YOU<br> <reset> <reset> <reset> <reset> <reset> <reset> <dark_red><b>DIED!!
/chatimage save <name> <url> [smooth] [trim] [width] [height]
Similar to the above command, but saves the textual image to the plugin folder for later use.
/chatimage delete <name>
Deletes a saved image.
/chatimage send <player>|all <name> [text]
Sends a saved image to a specific player or all players. Text can be appended at the end just like the other send sub-command above. Sending a saved image is much faster than sending from a URL because retrieving the image over the internet is the longest step in the process.
Placeholder Usage
PlaceholderAPI Usage
ChatImage provides PlaceholderAPI with a custom placeholder for inserting images anywhere. You simply need the PlaceholderAPI plugin installed along with ChatImage and it will be available. To use it, refer to the syntax below:
%chatimage_image: <name> [text]%
%chatimage_image: <url> [smooth] [trim] [width] [height] [text]%
The parameters are identical to the /chatimage send command. You can use other placeholders inside the text parameter, but you must use curly braces instead of percent signs since the placeholder exists inside another placeholder. For example:
%chatimage_image: heart n Your Health n {player_health}%
Note: It is recommended to use saved images for placeholders instead of URLs because retrieving images from the internet will lag the PlaceholderAPI plugin and any plugins using the placeholder.
Developer API
API Usage
To use this API, add the respective dependency to your project:
Maven
<dependency>
<groupId>io.github.chickensaysbak</groupId>
<artifactId>chatimage-api</artifactId>
<version>3.0.0-1</version>
</dependency>
Gradle
implementation 'io.github.chickensaysbak:chatimage-api:3.0.0-1'
Don't forget to add "ChatImage" to the depend or softdepend section of your plugin.yml.
Creating an image
Component image = ChatImageAPI.createMediaFromURL("http://url.com/example.png");
You can also use other optional parameters. Unspecified parameters will use config defaults.
createMediaFromURL(String url, String text, boolean smooth, boolean trim, int width, int height)
Sending an image
Paper & Velocity
player.sendMessage(media);
Spigot (requires dependency adventure-platform-bungeecord)
player.spigot().sendMessage(BungeeComponentSerializer.get().serialize(media));
BungeeCord (requires dependency adventure-platform-bungeecord)
player.sendMessage(BungeeComponentSerializer.get().serialize(media));
Check if a player is hiding images
if (ChatImageAPI.isHidingImages(player.getUniqueId())) {
// player is hiding images
}
Tip
If you're having trouble sending a particular image, try uploading it to Imgur, Imgbb, Gyazo, or even Discord. Just be sure to copy the direct image link ending with .png, .jpg, .gif, etc.
Please feel free to contact me if you have any questions, issues, or suggestions!
评论 0
登录后参与评分
还没有评论,来抢沙发吧