std::string MarkerSection::formatSign(std::string format, const mc::SignEntity& sign) const { std::string textp = sign.getText(); std::string text = textp; if (textp.size() > prefix.getValue().size()) text = util::trim(textp.substr(prefix.getValue().size())); format = util::replaceAll(format, "%textp", textp); format = util::replaceAll(format, "%text", text); format = util::replaceAll(format, "%prefix", prefix.getValue()); format = util::replaceAll(format, "%line1", sign.getLines()[0]); format = util::replaceAll(format, "%line2", sign.getLines()[1]); format = util::replaceAll(format, "%line3", sign.getLines()[2]); format = util::replaceAll(format, "%line4", sign.getLines()[3]); format = util::replaceAll(format, "%x", util::str(sign.getPos().x)); format = util::replaceAll(format, "%z", util::str(sign.getPos().z)); format = util::replaceAll(format, "%y", util::str(sign.getPos().y)); return format; }
std::string MarkerSection::formatSign(std::string format, const mc::SignEntity& sign) const { // sign text with prefix std::string textp = sign.getText(); // sign text without prefix std::string text = textp; // remove prefix from sign text // but make sure there is also other text except the prefix, otherwise don't remove prefix if (textp.size() > prefix.getValue().size()) text = util::trim(textp.substr(prefix.getValue().size())); // replace the placeholders with the sign data replacePlaceholder(format, "textp", textp); replacePlaceholder(format, "text", text); replacePlaceholder(format, "prefix", prefix.getValue()); replacePlaceholder(format, "line1", sign.getLines()[0]); replacePlaceholder(format, "line2", sign.getLines()[1]); replacePlaceholder(format, "line3", sign.getLines()[2]); replacePlaceholder(format, "line4", sign.getLines()[3]); replacePlaceholder(format, "x", sign.getPos().x); replacePlaceholder(format, "y", sign.getPos().y); replacePlaceholder(format, "z", sign.getPos().z); return format; }
bool MarkerSection::matchesSign(const mc::SignEntity& sign) const { if (sign.getText().empty() && !match_empty.getValue()) return false; return util::startswith(sign.getText(), prefix.getValue()); }