Skip to content

Commit

Permalink
Change anonymous comments to be not too anonymous
Browse files Browse the repository at this point in the history
  • Loading branch information
zbx1425 committed Sep 18, 2023
1 parent 127a4d8 commit fcaed26
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ public CommentEntry(Player initiator, boolean isAnonymous, int messageType, Stri
id = ServerWorldData.SNOWFLAKE.nextId();
timestamp = System.currentTimeMillis();
level = initiator.level().dimension().location();
this.initiator = initiator.getGameProfile().getId();
if (isAnonymous) {
this.initiator = Util.NIL_UUID;
initiatorName = "";
} else {
this.initiator = initiator.getGameProfile().getId();
initiatorName = initiator.getGameProfile().getName();
}
this.messageType = messageType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class UplinkRequest {
public final Consumer<JsonObject> callback;

public UplinkRequest(String url, JsonObject payload) {
this(url, "GET", payload, null);
this(url, "POST", payload, null);
}

public UplinkRequest(String url, String method, JsonObject payload, Consumer<JsonObject> callback) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ guiGraphics, getX(), getY(), getWidth(), getHeight(),

Component nameComponent = comment.initiatorName.isEmpty() ? Component.translatable("gui.worldcomment.anonymous")
: Component.literal(comment.initiatorName);
String uuidToDisplay = comment.initiatorName.isEmpty()
? (Minecraft.getInstance().player.hasPermissions(3) ? comment.initiator.toString() : "")
: "..." + comment.initiator.toString().substring(24);
guiGraphics.drawString(font, nameComponent,
getX() + 34, getY() + 8, 0xFFFFFFFF, true);

Expand All @@ -120,7 +123,7 @@ guiGraphics, getX(), getY(), getWidth(), getHeight(),
.append(Component.literal(" (" + comment.location.toShortString() + ")").setStyle(Style.EMPTY.withBold(false).withColor(ChatFormatting.WHITE))),
Component.literal(" " + Instant.ofEpochMilli(comment.timestamp).atZone(ZoneId.systemDefault())
.toLocalDateTime().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)).withStyle(Style.EMPTY.withColor(ChatFormatting.GRAY)),
Component.literal(" " + nameComponent.getString() + " ..." + comment.initiator.toString().substring(24)).withStyle(Style.EMPTY.withColor(ChatFormatting.GRAY))
Component.literal(" " + nameComponent.getString() + " " + uuidToDisplay).withStyle(Style.EMPTY.withColor(ChatFormatting.GRAY))
), Optional.empty(), mouseX, mouseY);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public static void send(CommentEntry comment) {
public static void handle(MinecraftServer server, ServerPlayer initiator, FriendlyByteBuf buffer) {
ResourceLocation level = buffer.readResourceLocation();
CommentEntry comment = new CommentEntry(level, buffer, false);
if (!comment.initiator.equals(Util.NIL_UUID)
&& !comment.initiator.equals(initiator.getGameProfile().getId())) {
if (!comment.initiator.equals(initiator.getGameProfile().getId())) {
return;
}
try {
Expand Down

0 comments on commit fcaed26

Please sign in to comment.