Skip to content

Commit

Permalink
feat(tsl): add DISPLAYING NOTHING syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
iGoodie committed Jun 19, 2020
1 parent 42746b2 commit 5494faf
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
Expand Up @@ -212,6 +212,9 @@ protected void notifyPlayer(ServerPlayerEntity player, String title, String subt
ITextComponent text = ITextComponent.Serializer.fromJsonLenient(title);
ITextComponent subtext = ITextComponent.Serializer.fromJsonLenient(subtitle);

if (subtext != null && subtext.getString().equals("NOTHING_0xDEADC0DE_0xDEADBEEF")) {
return; // Stop here since it was a DISPLAYING NOTHING statement
}

if (ConfigManager.PREFERENCES.messageDisplay == PreferencesConfig.MessageDisplay.TITLES) {
// Form title and subtitle packets
Expand Down
Expand Up @@ -69,6 +69,13 @@ public static JsonArray parseMessage(List<String> words) throws TSLSyntaxError {

String jsonString = words.get(i + 1);

// Yet another hack for backwards compatibility
if (jsonString.equalsIgnoreCase("NOTHING")) {
JsonArray displayNothing = new JsonArray();
displayNothing.add("NOTHING_0xDEADC0DE_0xDEADBEEF"); // <-- Super hyper mega hacker move
return displayNothing;
}

try {
JsonArray parsedMessage = new JsonParser().parse(jsonString).getAsJsonArray();
GsonUtils.removeInvalidTextComponent(parsedMessage); // <-- Will also remove null elements created by trailing comma chars
Expand Down
20 changes: 20 additions & 0 deletions src/main/resources/assets/twitchspawn/default/titles.default.json
Expand Up @@ -9,6 +9,16 @@
"color": "white"
}
],
"royalty point redemption": [
{
"text": "${actor}",
"color": "aqua"
},
{
"text": " redeemed a reward!",
"color": "white"
}
],
"twitch follow": [
{
"text": "${actor}",
Expand Down Expand Up @@ -107,6 +117,16 @@
"color": "white"
}
],
"twitch chat message": [
{
"text": "${actor}",
"color": "aqua"
},
{
"text": " sent something in chat!",
"color": "white"
}
],
"youtube subscription": [
"Incoming youtube subscription"
],
Expand Down

0 comments on commit 5494faf

Please sign in to comment.