diff --git a/src/main/java/str_exporter/BackendBroadcaster.java b/src/main/java/str_exporter/BackendBroadcaster.java index 9e91712..00d0a6a 100644 --- a/src/main/java/str_exporter/BackendBroadcaster.java +++ b/src/main/java/str_exporter/BackendBroadcaster.java @@ -71,7 +71,7 @@ private void readQueue() { long ts = 0; queueLock.lock(); try { - if ((sendDuplicates || !message.equals(lastMessage)) && message != null) { + if (message != null && (sendDuplicates || !message.equals(lastMessage))) { lastMessage = message; msg = message; ts = messageTimestamp; diff --git a/src/main/java/str_exporter/DeckJSONBuilder.java b/src/main/java/str_exporter/DeckJSONBuilder.java index 2e365be..8b2fe54 100644 --- a/src/main/java/str_exporter/DeckJSONBuilder.java +++ b/src/main/java/str_exporter/DeckJSONBuilder.java @@ -2,6 +2,7 @@ import basemod.BaseMod; import basemod.abstracts.DynamicVariable; +import basemod.patches.whatmod.WhatMod; import com.megacrit.cardcrawl.cards.AbstractCard; import com.megacrit.cardcrawl.cards.CardGroup; import com.megacrit.cardcrawl.cards.DescriptionLine; @@ -71,6 +72,9 @@ private void buildKeywords(StringBuilder sb) { if(iter.hasNext()) sb.append(";;"); } + + if (keywords.size() == 0) + sb.append('-'); } private String getKeywordRepr(String word) { @@ -177,7 +181,7 @@ private void buildCard(StringBuilder sb, AbstractCard card, boolean repr) { // upgradedKeywords = "_"; } else if (!card.canUpgrade() && card.timesUpgraded == 0) { // card cannot be upgraded at all, e.g. a Curse - upgradedName = "null"; + upgradedName = "-"; upgradedDesc = "-"; upgradedKeywords = "-"; } else if (card.canUpgrade() && card.timesUpgraded == 0 && upgradedName.equals(name + '+')) { @@ -188,12 +192,14 @@ private void buildCard(StringBuilder sb, AbstractCard card, boolean repr) { } // for a regular card: - // name ; bottleStatus ; cardToPreview ; cardToPreview upgraded ; nameUpgraded ; upgrades ; keyword upgraded ; descriptionUpgraded ; keywords ; cost ; cost upgraded ; type ; rarity ; color ; description + // name ; bottleStatus ; modName ; cardToPreview ; cardToPreview upgraded ; nameUpgraded ; upgrades ; keyword upgraded ; descriptionUpgraded ; keywords ; cost ; cost upgraded ; type ; rarity ; color ; description sb.append(name); sb.append(";"); sb.append(encodeBottleStatus(card)); sb.append(';'); + sb.append(encodeModName(card)); + sb.append(";"); if (!repr) { sb.append(encodeCardToPreview(card)); sb.append(';'); @@ -277,6 +283,12 @@ private String encodeBottleStatus(AbstractCard card) { } } + private String encodeModName(AbstractCard card) { + String modName = WhatMod.findModName(card.getClass()); + + return modName != null ? modName : "-"; + } + private String sanitize(String s) { return s.replaceAll(";", ":") .replaceAll("\"", "\\\"") @@ -357,7 +369,7 @@ private String parseDescription(AbstractCard card) { sb.append(matcherKeyword.group(1)); } else { // Replace color codes for now - part = part.replaceAll("\\[[a-zA-Z_]*\\]", ""); + part = part.replaceAll("\\[[a-zA-Z_]{2,}\\]", ""); part = part.replaceAll("\\[#[A-Ea-e0-9]*\\]", ""); part = part.replaceAll("\\[\\]", ""); part = part.replaceAll("\\[\\[", "["); diff --git a/src/main/java/str_exporter/TipsJSONBuilder.java b/src/main/java/str_exporter/TipsJSONBuilder.java index c53603e..ee2a6e1 100644 --- a/src/main/java/str_exporter/TipsJSONBuilder.java +++ b/src/main/java/str_exporter/TipsJSONBuilder.java @@ -35,12 +35,13 @@ public class TipsJSONBuilder extends JSONMessageBuilder{ public TipsJSONBuilder(String login, String secret, String version) { super(login, secret, version, 1); + powerTips = new ArrayList<>(40); } @Override public void buildMessage(StringBuilder sb) { - powerTips = new ArrayList<>(40); + powerTips.clear(); String character = "";