/* * Decompiled with CFR 0.152. */ package gearth.protocol; import gearth.misc.StringifyAble; import gearth.protocol.HPacket; public class HMessage implements StringifyAble { private HPacket hPacket; private Direction direction; private int index; private boolean isBlocked; public HMessage(String fromString) { this.constructFromString(fromString); } public HMessage(HMessage message) { this.constructFromHMessage(message); } public HMessage(HPacket packet, Direction direction, int index) { this.direction = direction; this.hPacket = packet; this.index = index; this.isBlocked = false; } public int getIndex() { return this.index; } public void setBlocked(boolean block) { this.isBlocked = block; } public boolean isBlocked() { return this.isBlocked; } public HPacket getPacket() { return this.hPacket; } public Direction getDestination() { return this.direction; } public boolean isCorrupted() { return this.hPacket.isCorrupted(); } @Override public String stringify() { String s = (this.isBlocked ? "1" : "0") + "\t" + this.index + "\t" + this.direction.name() + "\t" + this.hPacket.stringify(); return s; } @Override public void constructFromString(String str) { String[] parts = str.split("\t", 4); this.isBlocked = parts[0].equals("1"); this.index = Integer.parseInt(parts[1]); this.direction = parts[2].equals("TOCLIENT") ? Direction.TOCLIENT : Direction.TOSERVER; HPacket p = new HPacket(new byte[0]); p.constructFromString(parts[3]); this.hPacket = p; } public void constructFromHMessage(HMessage message) { this.isBlocked = message.isBlocked(); this.index = message.getIndex(); this.direction = message.getDestination(); this.hPacket = new HPacket(message.getPacket()); } public boolean equals(Object obj) { if (!(obj instanceof HMessage)) { return false; } HMessage message = (HMessage)obj; return message.hPacket.equals(this.hPacket) && this.direction == message.direction && this.index == message.index; } public static enum Direction { TOSERVER, TOCLIENT; } }