-
Notifications
You must be signed in to change notification settings - Fork 4
Rebuild the logic, RGB color supported now. & Update to 26.2 #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f160ea6
02e3914
84ee531
35b829c
9fb66dc
5961e16
a386370
40ae488
80b0dc5
02ab858
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,6 @@ | ||
| #Tue Jul 21 11:35:40 CST 2026 | ||
| distributionBase=GRADLE_USER_HOME | ||
| distributionPath=wrapper/dists | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-bin.zip | ||
| networkTimeout=10000 | ||
| retries=0 | ||
| retryBackOffMs=500 | ||
| validateDistributionUrl=true | ||
| zipStoreBase=GRADLE_USER_HOME | ||
| zipStorePath=wrapper/dists |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| java_version=25 | ||
|
|
||
| # Fabric Loom | ||
| # - For Minecraft versions <26.1: enable remap | ||
| # - For Minecraft versions >=26.1: disable remap | ||
| fabric_loom_remap=false | ||
|
|
||
| # Fabric Properties | ||
| # check these on https://fabricmc.net/develop | ||
| fabric_loader_version=0.19.3 | ||
| min_fabric_loader_version= | ||
| fabric_api_version=0.152.2 | ||
| # Fabric API mod ID conventions: | ||
| # - For Minecraft versions <1.19.2: use "fabric" | ||
| # - For Minecraft versions >=1.19.2: use "fabric-api" | ||
| # Ref: https://wiki.fabricmc.net/tutorial:setup | ||
| fabric_api_mod_id=fabric-api | ||
|
|
||
| # Mod Compatibility | ||
| ! Dynmap 3.8 | ||
| mod_dynmap_version=4UHHD4t6 | ||
| ! Styled Chat 2.13.0+26.2 | ||
| mod_styled_chat_version=2.13.0+26.2 | ||
| mod_styled_chat_placeholder_api_version=3.1.0-beta.1+26.2 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package cn.revaria.chatplus.format; | ||
|
|
||
| public interface ChatFormat { | ||
| int startingIndex(); | ||
| ChatFormatType formatType(); | ||
| ChatFormat copy(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package cn.revaria.chatplus.format; | ||
|
|
||
| public enum ChatFormatType { | ||
| COLOR, | ||
| FONT, | ||
| INSERT, | ||
| RESET | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| package cn.revaria.chatplus.format.formats; | ||
|
|
||
| import cn.revaria.chatplus.format.ChatFormat; | ||
| import cn.revaria.chatplus.format.ChatFormatType; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| public class ChatColorFormat implements ChatFormat { | ||
|
|
||
| private final int R, G, B; | ||
|
|
||
| private final int startingIndex; | ||
| private final ChatFormatType formatType = ChatFormatType.COLOR; | ||
|
|
||
| public ChatColorFormat(int startingIndex, int R, int G, int B) { | ||
| this.startingIndex = startingIndex; | ||
|
|
||
| this.R = R; | ||
| this.G = G; | ||
| this.B = B; | ||
| } | ||
| public ChatColorFormat(int startingIndex, char colorCode) { | ||
| this.startingIndex = startingIndex; | ||
|
|
||
| if (VANILLA_COLOR_FORMATS.containsKey(colorCode)) { | ||
| this.R = VANILLA_COLOR_FORMATS.get(colorCode).getR(); | ||
| this.G = VANILLA_COLOR_FORMATS.get(colorCode).getG(); | ||
| this.B = VANILLA_COLOR_FORMATS.get(colorCode).getB(); | ||
| } | ||
| else { | ||
| this.R = 0; | ||
| this.G = 0; | ||
| this.B = 0; | ||
| } | ||
| } | ||
|
|
||
| public int getR() { | ||
| return R; | ||
| } | ||
| public int getG() { | ||
| return G; | ||
| } | ||
| public int getB() { | ||
| return B; | ||
| } | ||
|
|
||
| @Override | ||
| public int startingIndex() { | ||
| return this.startingIndex; | ||
| } | ||
| @Override | ||
| public ChatFormatType formatType() { | ||
| return this.formatType; | ||
| } | ||
| @Override | ||
| public ChatColorFormat copy() { | ||
| return new ChatColorFormat(this.startingIndex, this.R, this.G, this.B); | ||
| } | ||
|
|
||
| public static final Map<Character, ChatColorFormat> VANILLA_COLOR_FORMATS = Map.ofEntries( | ||
| Map.entry('0', new ChatColorFormat(0, 0, 0, 0)), | ||
| Map.entry('1', new ChatColorFormat(0, 0, 0, 170)), | ||
| Map.entry('2', new ChatColorFormat(0, 0, 170, 0)), | ||
| Map.entry('3', new ChatColorFormat(0, 0, 170, 170)), | ||
| Map.entry('4', new ChatColorFormat(0, 170, 0, 0)), | ||
| Map.entry('5', new ChatColorFormat(0, 170, 0, 170)), | ||
| Map.entry('6', new ChatColorFormat(0, 255, 170, 0)), | ||
| Map.entry('7', new ChatColorFormat(0, 170, 170, 170)), | ||
| Map.entry('8', new ChatColorFormat(0, 85, 85, 85)), | ||
| Map.entry('9', new ChatColorFormat(0, 85, 85, 255)), | ||
| Map.entry('a', new ChatColorFormat(0, 85, 255, 85)), | ||
| Map.entry('b', new ChatColorFormat(0, 85, 255, 255)), | ||
| Map.entry('c', new ChatColorFormat(0, 255, 85, 85)), | ||
| Map.entry('d', new ChatColorFormat(0, 255, 85, 255)), | ||
| Map.entry('e', new ChatColorFormat(0, 255, 255, 85)), | ||
| Map.entry('f', new ChatColorFormat(0, 255, 255, 255)) | ||
| ); | ||
|
Comment on lines
+60
to
+77
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 不应该硬编码, This shouldn't be hardcoded. You can find these values in |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| package cn.revaria.chatplus.format.formats; | ||
|
|
||
| import cn.revaria.chatplus.format.ChatFormat; | ||
| import cn.revaria.chatplus.format.ChatFormatType; | ||
| import net.minecraft.ChatFormatting; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| public class ChatFontFormat implements ChatFormat { | ||
|
|
||
| private final ChatFormatting fontFormat; | ||
|
|
||
| private final int startingIndex; | ||
| private final ChatFormatType formatType = ChatFormatType.FONT; | ||
|
|
||
| public ChatFontFormat(int startingIndex, ChatFormatting fontFormat) { | ||
| this.startingIndex = startingIndex; | ||
|
|
||
| this.fontFormat = fontFormat; | ||
| } | ||
| public ChatFontFormat(int startingIndex, char fontCode) { | ||
| this.startingIndex = startingIndex; | ||
|
|
||
| this.fontFormat = VANILLA_FONT_FORMATS.getOrDefault(fontCode, ChatFormatting.ITALIC); | ||
| } | ||
|
|
||
| public ChatFormatting getFont() { | ||
| return fontFormat; | ||
| } | ||
|
|
||
| @Override | ||
| public int startingIndex() { | ||
| return startingIndex; | ||
| } | ||
| @Override | ||
| public ChatFormatType formatType() { | ||
| return formatType; | ||
| } | ||
| @Override | ||
| public ChatFontFormat copy() { | ||
| return new ChatFontFormat(this.startingIndex, this.fontFormat); | ||
| } | ||
|
|
||
| public static final Map<Character, ChatFormatting> VANILLA_FONT_FORMATS = Map.ofEntries( | ||
| Map.entry('k', ChatFormatting.OBFUSCATED), | ||
| Map.entry('l', ChatFormatting.BOLD), | ||
| Map.entry('m', ChatFormatting.STRIKETHROUGH), | ||
| Map.entry('n', ChatFormatting.UNDERLINE), | ||
| Map.entry('o', ChatFormatting.ITALIC) | ||
| ); | ||
|
Comment on lines
+44
to
+50
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同上,不应该硬编码 Same as above, this shouldn't be hardcoded. |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package cn.revaria.chatplus.format.formats; | ||
|
|
||
| import cn.revaria.chatplus.format.ChatFormat; | ||
| import net.minecraft.network.chat.MutableComponent; | ||
|
|
||
| public interface ChatInsertFormat extends ChatFormat { | ||
| MutableComponent getInsertComponent(); | ||
| ChatInsertFormat copy(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package cn.revaria.chatplus.format.formats; | ||
|
|
||
| import cn.revaria.chatplus.format.ChatFormat; | ||
| import cn.revaria.chatplus.format.ChatFormatType; | ||
|
|
||
| public class ChatResetFormat implements ChatFormat { | ||
|
|
||
| private final int startingIndex; | ||
| private final ChatFormatType formatType = ChatFormatType.RESET; | ||
|
|
||
| public ChatResetFormat(int startingIndex) { | ||
| this.startingIndex = startingIndex; | ||
| } | ||
|
|
||
| @Override | ||
| public int startingIndex() { | ||
| return startingIndex; | ||
| } | ||
| @Override | ||
| public ChatFormatType formatType() { | ||
| return formatType; | ||
| } | ||
| @Override | ||
| public ChatResetFormat copy() { | ||
| return new ChatResetFormat(this.startingIndex); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package cn.revaria.chatplus.format.formats.insertformats; | ||
|
|
||
| import cn.revaria.chatplus.format.ChatFormatType; | ||
| import cn.revaria.chatplus.format.formats.ChatInsertFormat; | ||
| import net.minecraft.network.chat.MutableComponent; | ||
| import net.minecraft.world.item.ItemStack; | ||
|
|
||
| public class ChatInsertItemFormat implements ChatInsertFormat { | ||
|
|
||
| private final ItemStack item; | ||
|
|
||
| private final int startingIndex; | ||
| private final ChatFormatType formatType = ChatFormatType.INSERT; | ||
|
|
||
| public ChatInsertItemFormat(int startingIndex, ItemStack item) { | ||
| this.startingIndex = startingIndex; | ||
|
|
||
| this.item = item; | ||
| } | ||
|
|
||
| public ItemStack getItem() { | ||
| return item; | ||
| } | ||
|
|
||
| @Override | ||
| public MutableComponent getInsertComponent() { | ||
| return item.getDisplayName().copy(); | ||
| } | ||
| @Override | ||
| public int startingIndex() { | ||
| return startingIndex; | ||
| } | ||
| @Override | ||
| public ChatFormatType formatType() { | ||
| return formatType; | ||
| } | ||
| @Override | ||
| public ChatInsertItemFormat copy() { | ||
| return new ChatInsertItemFormat(this.startingIndex, this.item); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| package cn.revaria.chatplus.format.formats.insertformats; | ||
|
|
||
| import cn.revaria.chatplus.ChatPlus; | ||
| import cn.revaria.chatplus.format.ChatFormatType; | ||
| import cn.revaria.chatplus.format.formats.ChatInsertFormat; | ||
| import net.minecraft.ChatFormatting; | ||
| import net.minecraft.core.Holder; | ||
| import net.minecraft.network.chat.Component; | ||
| import net.minecraft.network.chat.MutableComponent; | ||
| import net.minecraft.network.chat.TextColor; | ||
| import net.minecraft.network.protocol.game.ClientboundSoundPacket; | ||
| import net.minecraft.resources.Identifier; | ||
| import net.minecraft.server.level.ServerPlayer; | ||
| import net.minecraft.sounds.SoundEvent; | ||
| import net.minecraft.sounds.SoundSource; | ||
|
|
||
| public class ChatInsertRemindAllFormat implements ChatInsertFormat { | ||
|
|
||
| private final String reminderText; | ||
| private boolean soundPlayed = false; | ||
|
|
||
| private final int startingIndex; | ||
| private final ChatFormatType formatType = ChatFormatType.INSERT; | ||
|
|
||
| public ChatInsertRemindAllFormat(int startingIndex, String reminderText) { | ||
| this.startingIndex = startingIndex; | ||
|
|
||
| this.reminderText = reminderText; | ||
| } | ||
|
|
||
| @Override | ||
| public MutableComponent getInsertComponent() { | ||
| if (!soundPlayed) { | ||
| soundPlayed = true; | ||
|
|
||
| for (ServerPlayer player : ChatPlus.getServer().getPlayerList().getPlayers()) { | ||
| player.connection.send(new ClientboundSoundPacket( | ||
| Holder.direct(SoundEvent.createVariableRangeEvent(Identifier.fromNamespaceAndPath("minecraft", "entity.experience_orb.pickup"))), | ||
| SoundSource.MASTER, | ||
| player.position().x, | ||
| player.position().y, | ||
| player.position().z, | ||
| 3, | ||
| 1, | ||
| player.level().getRandom().nextLong() | ||
| )); | ||
| } | ||
| } | ||
|
|
||
| return Component.literal("@").append(reminderText) | ||
| .withColor(TextColor.GREEN) | ||
| .withStyle(ChatFormatting.BOLD); | ||
| } | ||
| @Override | ||
| public int startingIndex() { | ||
| return startingIndex; | ||
| } | ||
| @Override | ||
| public ChatFormatType formatType() { | ||
| return formatType; | ||
| } | ||
| @Override | ||
| public ChatInsertFormat copy() { | ||
| return new ChatInsertRemindAllFormat(startingIndex, reminderText); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
一般来说,不应该在 PR 里更新版本号
As a general rule, version numbers shouldn't be bumped in PRs.