Wrote sharedSignature, did more testing with Adventure

This commit is contained in:
Artemis-the-gr8 2022-07-15 20:33:57 +02:00
parent 980fbcb43e
commit dcdb4293c0
4 changed files with 21 additions and 15 deletions

View File

@ -115,12 +115,9 @@ public final class ShareManager {
sharedResults.offer(shareCode);
}
StatResult result = statResultQueue.remove(shareCode);
MyLogger.logMsg("StatResult record exists: " + (result != null));
MyLogger.logMsg("Its TextComponent: " + result.statResult());
MyLogger.logMsg("Its ID: " + result.ID());
MyLogger.logMsg("Its uuid: " + result.uuid());
return result.statResult();
} else {
}
else {
return null;
}
}

View File

@ -306,9 +306,18 @@ public class ComponentFactory {
}
public TextComponent sharedButtonComponent(String playerName) {
return surroundingBracketComponent(
text("Shared!")
.color(CLICKED_MSG));
if (playerName == null) {
return surroundingBracketComponent(
text("Shared!")
.color(CLICKED_MSG));
} else {
return surroundingBracketComponent(
text("Shared by ")
.color(CLICKED_MSG)
.append(text(playerName)
.color(MSG_ACCENT))
.append(text("!")));
}
}
private TextComponent surroundingBracketComponent(TextComponent component) {

View File

@ -193,7 +193,6 @@ public class MessageWriter {
TextComponent list = getTopStatList(topStats, request);
return shareCode -> {
MyLogger.logMsg("Function triggered with shareCode " + shareCode);
TextComponent.Builder topBuilder = Component.text().append(title);
if (shareCode != null) {
topBuilder
@ -201,12 +200,15 @@ public class MessageWriter {
.append(componentFactory.shareButtonComponent(shareCode));
}
topBuilder.append(list);
MyLogger.logMsg(topBuilder.build() + "");
return topBuilder.build();
};
}
public TextComponent sharedButton(String playerName) {
public TextComponent sharedButton() {
return componentFactory.sharedButtonComponent(null);
}
public TextComponent sharedSignature(String playerName) {
return componentFactory.sharedButtonComponent(playerName);
}

View File

@ -5,7 +5,6 @@ import com.gmail.artemis.the.gr8.playerstats.ShareManager;
import com.gmail.artemis.the.gr8.playerstats.config.ConfigHandler;
import com.gmail.artemis.the.gr8.playerstats.enums.StandardMessage;
import com.gmail.artemis.the.gr8.playerstats.models.StatRequest;
import com.gmail.artemis.the.gr8.playerstats.utils.MyLogger;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.TextComponent;
@ -77,12 +76,11 @@ public class OutputManager {
}
public void shareStatResults(CommandSender sender, @NotNull TextComponent statResult) {
MyLogger.logMsg("statResult: " + statResult);
adventure.all()
.filterAudience(player -> !player.get(Identity.NAME)
.orElse("").equalsIgnoreCase(sender.getName())).sendMessage(statResult);
MyLogger.logMsg("SharedButton: " + msg.sharedButton(sender.getName()));
adventure.sender(sender).sendMessage(msg.sharedButton(sender.getName()));
//TODO add sharedSignature
adventure.sender(sender).sendMessage(msg.sharedButton());
}
public void sendPlayerStat(StatRequest request, int playerStat) {