MineDown
1.0.0
該庫添加了使用 MarkDown 啟發的標記來編寫 Minecraft 聊天組件的功能!
它提供了一種鬆散地基於 MarkDown 的自訂標記語法,增加了使用元件訊息的全部功能的能力,並且與傳統格式化程式碼一樣簡單。 (它仍然可以支援!)它還包括一種直接替換訊息中佔位符的方法,基於字串和基於組件的佔位符!
這需要 kyori-adventure 聊天 API,因此您需要在專案中提供平台庫之一才能使用這些訊息!請參閱此插件的簡單實作。
描述 | 句法 | 更多資訊 | 預覽 |
---|---|---|---|
色彩遺產 | &6Text | 格式化程式碼 | |
顏色 | &gold&Text | 顏色名稱 | |
RGB 十六進位顏色 | &#ff00ff&Text | 完整的十六進位格式 | |
RGB 十六進位顏色 | &#f0f&Text | 短格式(相當於長格式) | |
坡度 | &#f0f-#fff&Text | 內聯漸變 | |
彩虹 | &rainbow&Text | 內嵌彩虹 | |
彩虹相 | &rainbow:20&Text | 帶相位的內聯彩虹 | |
大膽的 | **Text** | ||
斜體 | ##Text## | ||
底線 | __Text__ | ||
刪除線 | ~~Text~~ | ||
混淆的 | ??Text?? |
您可以使用常用的 MarkDown 連結語法定義點擊和懸停事件,並以這種方式指定格式、字體和顏色。
描述 | 句法 |
---|---|
一般文法 | [Text](text-color text-formatting... link hover text) |
簡單連結 | [Text](https://example.com) |
簡單指令 | [Text](/command to run) |
連結+懸停 | [Text](https://example.com Hover Text) |
文字格式 | [Text](blue underline !bold) |
坡度 | [Text](#fff-#000) |
彩虹 | [Text](rainbow) |
階段性彩虹 | [Text](rainbow:20) |
文字格式+連結+懸停 | [Text](#0000ff underline https://example.com Hover Text) |
描述 | 句法 | 更多資訊 |
---|---|---|
一般文法 | [Text](action=value) | ClickEvent.Action、HoverEvent.Action |
關聯 | [Text](open_url=https://example.com) | |
顏色 | [Text](color=red) | 顏色名稱 |
RGB 十六進位顏色 | [Text](color=#ff00ff) | 完整的十六進位格式 |
RGB 十六進位顏色 | [Text](color=#f0f) | 短格式(相當於長格式) |
RGB 顏色漸層 | [Text](color=#fff-#000) | 兩種顏色的漸層。 (支援所有顏色形式) |
RGB 顏色漸層 | [Text](color=#fff-#333-#222) | 三種顏色的漸層。 |
RGB彩虹 | [Text](color=rainbow) | RGB 彩虹。 |
相控 RGB 彩虹 | [Text](color=rainbow:50) | 具有特定相位的 RGB 彩虹。 |
格式化 | [Text](format=underline,bold) | 指定格式 |
禁用格式化 | [Text](format=!underline) | 使用 ! 停用特定格式前綴 |
字體 | [Text](font=custom_font) | 從資源包設定自訂字體 |
運行命令 | [Text](run_command=/command string) | 點擊運行命令 |
建議命令 | [Text](suggest_command=/command) | 建議點擊命令 |
簡單的懸停 | [Text](hover=Hover Text) | 顯示懸停文字 |
懸停文本 | [Text](show_text=Hover Text) | 顯示懸停文字 |
懸停實體資訊 | [Text](show_entity=uuid:pig Name) | 顯示實體資訊。 |
懸停項目資訊 | [Text](show_item=stone*2 nbt...) | 顯示商品信息,需要以 json 中的 nbt 字串形式提供附加信息 |
插入 | [Text](insert=insert into input) | 在 Shift 單擊時插入輸入,可與其他事件組合 |
所有高級設定都可以連結/包含在事件定義中。但是,您不能添加多種不同的顏色或點擊和懸停操作!
此函式庫的主要 API 存取是透過MineDown .class 及其解析方法進行的。
例如,您可以在 Bukkit 插件中像這樣使用它:
BukkitAudiences . create ( plugin ). player ( player ). sendMessage ( new MineDown ( rawMessage ). replace ( replacements ). toComponent ());
或使用靜態方法:
BukkitAudiences . create ( plugin ). player ( player ). sendMessage ( MineDown . parse ( rawMessage , replacements ));
查看MineDown JavaDocs 以取得有關該程式庫和包含的類別的更多詳細資訊。
您可以使用 Maven 輕鬆將此庫包含到您的插件中。確保將其重新定位到您的插件包中!
< repositories >
< repository >
< id >minebench-repo</ id >
< url >https://repo.minebench.de/</ url >
</ repository >
</ repositories >
< dependencies >
< dependency >
< groupId >de.themoep</ groupId >
< artifactId > MineDown -adventure</ artifactId >
< version >1.7.3-SNAPSHOT</ version >
< scope >compile</ scope >
</ dependency >
</ dependencies >
原來的 BungeeCord-chat 函式庫不再維護,並已被這個冒險實作所取代。如果您仍然需要使用舊版本(在legacy
分支上找到),您可以像這樣包含它:
< dependencies >
< dependency >
< groupId >de.themoep</ groupId >
< artifactId > MineDown </ artifactId >
< version >1.7.1-SNAPSHOT</ version >
< scope >compile</ scope >
</ dependency >
</ dependencies >
< build >
< plugins >
< plugin >
< artifactId >maven-shade-plugin</ artifactId >
< version >3.1.0</ version >
< configuration >
< relocations >
< relocation >
< pattern >de.themoep. MineDown </ pattern >
< shadedPattern >your.package.path.libraries. MineDown </ shadedPattern >
</ relocation >
</ relocations >
</ configuration >
< executions >
< execution >
< phase >package</ phase >
< goals >
< goal >shade</ goal >
</ goals >
</ execution >
</ executions >
</ plugin >
</ plugins >
</ build >
或者你也可以直接依賴我的MineDown插件而不是在這個庫中著色! MineDown插件包含該庫的非重定位版本。
MineDown根據 MIT 開源許可證獲得許可:
Copyright (c) 2024 Max Lee (https://github.com/Phoenix616)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.