-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added support for some basic markdown syntax - Added support for emotes, you can add custom ones in config and use them by typing `:emote_name:` - Added <spoiler> chat tag - Added support for /msg, /teammsg, /say and /me - Added /tellform command - It's like tellraw, but you use same formatting as StyledChat - You can now style pets death message - Enabled more tags by default - You can enable formatting in /msg and /teammsg - You can now hide some messages by empting their value (without removing them), example: `"join": ""` - Updated bundled Placeholder API - Changed default URL color - Bundled required parts of fabric api so it's no longer required dependency - Exposed some new events/methods for better mod compatibility
- Loading branch information
Showing
25 changed files
with
1,200 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package eu.pb4.styledchat; | ||
|
||
import eu.pb4.placeholders.TextParser; | ||
import net.fabricmc.fabric.api.event.Event; | ||
import net.fabricmc.fabric.api.event.EventFactory; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.text.Text; | ||
|
||
import java.util.function.BiConsumer; | ||
|
||
public class StyledChatEvents { | ||
/** | ||
* Event ran for message content before they are formatted (Strings) | ||
*/ | ||
public static final Event<PreMessageEvent> PRE_MESSAGE_CONTENT_SEND = EventFactory.createArrayBacked(PreMessageEvent.class, callbacks -> (message, player, filtered) -> { | ||
for (var callback : callbacks) { | ||
message = callback.onPreMessage(message, player, filtered); | ||
} | ||
|
||
return message; | ||
}); | ||
|
||
/** | ||
* Event ran for message content after it being formatted (Text) | ||
*/ | ||
public static final Event<MessageEvent> MESSAGE_CONTENT_SEND = EventFactory.createArrayBacked(MessageEvent.class, callbacks -> (message, player, filtered) -> { | ||
for (var callback : callbacks) { | ||
message = callback.onMessage(message, player, filtered); | ||
} | ||
|
||
return message; | ||
}); | ||
|
||
/** | ||
* Event ran before message is send to someone, it is fully formatted (including template) | ||
*/ | ||
public static final Event<MessageToEvent> MESSAGE_TO_SEND = EventFactory.createArrayBacked(MessageToEvent.class, callbacks -> (message, sender, receiver, filtered) -> { | ||
for (var callback : callbacks) { | ||
message = callback.onMessageTo(message, sender, receiver, filtered); | ||
} | ||
|
||
return message; | ||
}); | ||
|
||
/** | ||
* This event can be used to allow custom formatting | ||
*/ | ||
public static final Event<FormattingCreationEvent> FORMATTING_CREATION_EVENT = EventFactory.createArrayBacked(FormattingCreationEvent.class, callbacks -> (player, builder) -> { | ||
for (var callback : callbacks) { | ||
callback.onFormattingBuild(player, builder); | ||
} | ||
}); | ||
|
||
public interface FormattingCreationEvent { | ||
void onFormattingBuild(ServerPlayerEntity player, BiConsumer<String, TextParser.TextFormatterHandler> builder); | ||
} | ||
|
||
public interface PreMessageEvent { | ||
String onPreMessage(String message, ServerPlayerEntity player, boolean filtered); | ||
} | ||
|
||
public interface MessageEvent { | ||
Text onMessage(Text message, ServerPlayerEntity player, boolean filtered); | ||
} | ||
|
||
public interface MessageToEvent { | ||
Text onMessageTo(Text message, ServerPlayerEntity sender, ServerPlayerEntity receiver, boolean filtered); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.