--- title: 2.2 - 字串處理 tags: content, MCEA, technology --- # 字串處理 如同前面所提及的,Minecraft的指令是先處理完字串,再決定是否要顯示到玩家的聊天欄(commandblockoutput、sendFeedback),所以關掉字串顯示只是少了「字串顯示」的步驟,並不會加速指令本身的執行效能,並且MC對於指令「字串處理」的效率並不是很優良,這也是導致大部分指令會因此變慢的主因之一。 ## 為什麼字串處理會如此的慢? 這要說到很多有關於字串的特性,如必須逐字檢查、逐字複製字串等,這些需要跑遍整個字串的行為,都會是拖慢字串處理的主要原因。 在MC中,其所有可顯示的字串都會被包裝成文字(Text),每個 Text 都會帶有以下格式(Format)。 ## String Handling Method in Text - 複製字串(copy) - 值轉字串(value into string) - 字串轉值(string into value) - 括號括住字串(wrap string with bracket) - ## Text Format 1. **Unformatted Component Text** 2. **Style :** - **color** [Color]<font color=red>*</font> - **bold** [Boolean] - **italic** [Boolean] - **strikethough** [Boolean] - **obfuscated** [Boolean] - **clickEvent** [ClickEvent]<font color=red>*</font> - **hoverEvent** [HoverEvent]<font color=red>*</font> - **insertion** [String] - **fontID** [ResourceLocaiton]<font color=red>*</font> 3.
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up