From 4950ba21618f83b0a0e8989a3a72cf2f08f92129 Mon Sep 17 00:00:00 2001 From: Matthew Messinger Date: Fri, 16 Jun 2017 01:41:36 -0400 Subject: [PATCH] Add toString method to Pony classes. --- src/main/java/com/minelittlepony/Pony.java | 9 +++++++++ src/main/java/com/minelittlepony/PonyData.java | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/main/java/com/minelittlepony/Pony.java b/src/main/java/com/minelittlepony/Pony.java index ace6d2c7..f4e24fd6 100644 --- a/src/main/java/com/minelittlepony/Pony.java +++ b/src/main/java/com/minelittlepony/Pony.java @@ -1,5 +1,6 @@ package com.minelittlepony; +import com.google.common.base.MoreObjects; import com.minelittlepony.model.PMAPI; import com.minelittlepony.model.PlayerModel; import com.minelittlepony.util.PonyFields; @@ -155,4 +156,12 @@ public class Pony { public PonyData getMetadata() { return metadata; } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("texture", texture) + .add("metadata", metadata) + .toString(); + } } diff --git a/src/main/java/com/minelittlepony/PonyData.java b/src/main/java/com/minelittlepony/PonyData.java index 20b67047..903ac1c2 100644 --- a/src/main/java/com/minelittlepony/PonyData.java +++ b/src/main/java/com/minelittlepony/PonyData.java @@ -1,5 +1,6 @@ package com.minelittlepony; +import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableBiMap; import java.awt.image.BufferedImage; @@ -70,6 +71,17 @@ public class PonyData implements IPonyData { return this.race != null && this.race.hasHorn() && this.glowColor != 0; } + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("race", race) + .add("tailSize", tailSize) + .add("gender", gender) + .add("size", size) + .add("glowColor", "#" + Integer.toHexString(glowColor)) + .toString(); + } + static PonyData parse(BufferedImage image) { int racePx = TriggerPixels.RACE.readColor(image); PonyRace race = RACE_COLORS.getOrDefault(racePx, PonyRace.HUMAN);