mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-14 01:04:12 +00:00
Remove EnumAddressee.INVALID
This commit is contained in:
1 parent
dff81eb85c
commit
f13bacfed5
7 files changed
+19
-15
No files matched your search
@@ -32,11 +32,11 @@ public class MailAddress implements INBTTagable, IMailAddress {
|
||||
@EntityNetData
|
||||
private GameProfile gameProfile; // gameProfile is a fake GameProfile for traders, and real for players
|
||||
|
||||
private static final MailAddress invalidAddress = new MailAddress();
|
||||
private static final GameProfile invalidGameProfile = new GameProfile(new UUID(0,0), "");
|
||||
|
||||
public MailAddress() {
|
||||
this.type = EnumAddressee.INVALID;
|
||||
this.gameProfile = new GameProfile(new UUID(0,0), "");
|
||||
this.type = EnumAddressee.PLAYER;
|
||||
this.gameProfile = invalidGameProfile;
|
||||
}
|
||||
|
||||
public MailAddress(GameProfile gameProfile) {
|
||||
@@ -101,20 +101,25 @@ public class MailAddress implements INBTTagable, IMailAddress {
|
||||
return type == EnumAddressee.PLAYER;
|
||||
}
|
||||
|
||||
public boolean isTrader() {
|
||||
return type == EnumAddressee.TRADER;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return type != EnumAddressee.INVALID;
|
||||
return !gameProfile.equals(invalidGameProfile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
type = EnumAddressee.INVALID;
|
||||
type = null;
|
||||
if(nbttagcompound.hasKey("TP")) {
|
||||
String typeName = nbttagcompound.getString("TP");
|
||||
type = EnumAddressee.fromString(typeName);
|
||||
}
|
||||
|
||||
if (!isValid()) {
|
||||
gameProfile = invalidAddress.gameProfile;
|
||||
if (type == null) {
|
||||
type = EnumAddressee.PLAYER;
|
||||
gameProfile = invalidGameProfile;
|
||||
} else if(nbttagcompound.hasKey("profile")) {
|
||||
NBTTagCompound profileTag = nbttagcompound.getCompoundTag("profile");
|
||||
gameProfile = NBTUtil.func_152459_a(profileTag);
|
||||
|
||||
@@ -80,7 +80,7 @@ public class PostRegistry implements IPostRegistry {
|
||||
*/
|
||||
@Override
|
||||
public boolean isValidTradeAddress(World world, IMailAddress address) {
|
||||
return !address.isPlayer() && address.getName().matches("^[a-zA-Z0-9]+$");
|
||||
return address.isTrader() && address.getName().matches("^[a-zA-Z0-9]+$");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -64,8 +64,8 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve
|
||||
// / CONSTRUCTORS
|
||||
public TradeStation(GameProfile owner, IMailAddress address) {
|
||||
super(SAVE_NAME + address);
|
||||
if (address.isPlayer()) {
|
||||
throw new IllegalArgumentException("TradeStation address must not be a player");
|
||||
if (!address.isTrader()) {
|
||||
throw new IllegalArgumentException("TradeStation address must be a trader");
|
||||
}
|
||||
this.owner = owner;
|
||||
this.address = address;
|
||||
|
||||
@@ -139,7 +139,7 @@ public class ContainerLetter extends ContainerItemInventory {
|
||||
}
|
||||
|
||||
public void setRecipient(String recipientName, EnumAddressee type) {
|
||||
if (StringUtils.isBlank(recipientName) || type == EnumAddressee.INVALID)
|
||||
if (StringUtils.isBlank(recipientName) || type == null)
|
||||
return;
|
||||
|
||||
// / Send to server
|
||||
|
||||
@@ -246,7 +246,7 @@ public class GuiLetter extends GuiForestry<TileForestry> {
|
||||
}
|
||||
|
||||
private void setRecipient(String recipientName, EnumAddressee type) {
|
||||
if (this.isProcessedLetter || StringUtils.isBlank(recipientName) || type == null || type == EnumAddressee.INVALID)
|
||||
if (this.isProcessedLetter || StringUtils.isBlank(recipientName) || type == null)
|
||||
return;
|
||||
|
||||
container.setRecipient(recipientName, type);
|
||||
|
||||
@@ -46,11 +46,10 @@ public class PacketLetterInfo extends ForestryPacket {
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
|
||||
if (type == null || type == EnumAddressee.INVALID) {
|
||||
if (type == null) {
|
||||
data.writeShort(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
data.writeShort(0);
|
||||
|
||||
data.writeUTF(type.toString());
|
||||
|
||||
Reference in new issue
Block a user