Add toString method to Pony classes.

This commit is contained in:
Matthew Messinger 2017-06-16 01:41:36 -04:00
parent 29f2f5ee58
commit 4950ba2161
2 changed files with 21 additions and 0 deletions

View file

@ -1,5 +1,6 @@
package com.minelittlepony; package com.minelittlepony;
import com.google.common.base.MoreObjects;
import com.minelittlepony.model.PMAPI; import com.minelittlepony.model.PMAPI;
import com.minelittlepony.model.PlayerModel; import com.minelittlepony.model.PlayerModel;
import com.minelittlepony.util.PonyFields; import com.minelittlepony.util.PonyFields;
@ -155,4 +156,12 @@ public class Pony {
public PonyData getMetadata() { public PonyData getMetadata() {
return metadata; return metadata;
} }
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("texture", texture)
.add("metadata", metadata)
.toString();
}
} }

View file

@ -1,5 +1,6 @@
package com.minelittlepony; package com.minelittlepony;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableBiMap; import com.google.common.collect.ImmutableBiMap;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
@ -70,6 +71,17 @@ public class PonyData implements IPonyData {
return this.race != null && this.race.hasHorn() && this.glowColor != 0; 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) { static PonyData parse(BufferedImage image) {
int racePx = TriggerPixels.RACE.readColor(image); int racePx = TriggerPixels.RACE.readColor(image);
PonyRace race = RACE_COLORS.getOrDefault(racePx, PonyRace.HUMAN); PonyRace race = RACE_COLORS.getOrDefault(racePx, PonyRace.HUMAN);