Fix #1052 and #1097 bad error messages from Trade Station

This commit is contained in:
mezz committed 2016-05-01 12:52:00 -07:00
1 parent 1d1959b535
commit 92460d1d4a
20 files changed
+274 -155

No files matched your search

@@ -0,0 +1,35 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.mail;
import javax.annotation.Nonnull;
import net.minecraft.util.StatCollector;
public enum EnumTradeStationState implements IPostalState {
OK("for.chat.mail.ok"),
INSUFFICIENT_OFFER("for.chat.mail.insufficient.offer"),
INSUFFICIENT_TRADE_GOOD("for.chat.mail.insufficient.trade.good"),
INSUFFICIENT_BUFFER("for.chat.mail.insufficient.buffer"),
INSUFFICIENT_PAPER("for.chat.mail.insufficient.paper"),
INSUFFICIENT_STAMPS("for.chat.mail.insufficient.stamps");
private final String unlocalizedDescription;
EnumTradeStationState(@Nonnull String unlocalizedDescription) {
this.unlocalizedDescription = unlocalizedDescription;
}
@Override
public boolean isOk() {
return this == OK;
}
@Override
public String getDescription() {
return StatCollector.translateToLocal(unlocalizedDescription);
}
}
@@ -6,9 +6,9 @@
package forestry.api.mail;
public interface IPostalState {
/** Normal states are OK, error states are not OK */
boolean isOk();
String getIdentifier();
int ordinal();
/** Localized description of the postal state */
String getDescription();
}
@@ -19,6 +19,6 @@ public interface ITradeStation extends ILetterHandler, IInventory {
boolean isVirtual();
TradeStationInfo getTradeInfo();
ITradeStationInfo getTradeInfo();
}
@@ -0,0 +1,22 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.mail;
import net.minecraft.item.ItemStack;
import com.mojang.authlib.GameProfile;
public interface ITradeStationInfo {
IMailAddress getAddress();
GameProfile getOwner();
ItemStack getTradegood();
ItemStack[] getRequired();
EnumTradeStationState getState();
}
@@ -1,29 +0,0 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.mail;
import net.minecraft.item.ItemStack;
import com.mojang.authlib.GameProfile;
public class TradeStationInfo {
public final IMailAddress address;
public final GameProfile owner;
public final ItemStack tradegood;
public final ItemStack[] required;
public final IPostalState state;
public TradeStationInfo(IMailAddress address, GameProfile owner, ItemStack tradegood, ItemStack[] required, IPostalState state) {
if (!address.isTrader()) {
throw new IllegalArgumentException("TradeStation address must be a trader");
}
this.address = address;
this.owner = owner;
this.tradegood = tradegood;
this.required = required;
this.state = state;
}
}