use of forestry.api.mail.ITradeStation in project ForestryMC by ForestryMC.
the class ContainerCatalogue method rebuildStationsList.
private void rebuildStationsList() {
stations.clear();
IPostOffice postOffice = PostManager.postRegistry.getPostOffice(player.world);
Map<IMailAddress, ITradeStation> tradeStations = postOffice.getActiveTradeStations(player.world);
for (ITradeStation station : tradeStations.values()) {
ITradeStationInfo info = station.getTradeInfo();
// Filter out any trade stations which do not actually offer anything.
if (FILTERS.get(currentFilter).contains(info.getState())) {
stations.add(station);
}
}
stationIndex = 0;
updateTradeInfo();
}
use of forestry.api.mail.ITradeStation in project ForestryMC by ForestryMC.
the class PostOffice method refreshActiveTradeStations.
private void refreshActiveTradeStations(World world) {
activeTradeStations = new LinkedHashMap<>();
File worldSave = world.getSaveHandler().getMapFileFromName("dummy");
File file = worldSave.getParentFile();
if (!file.exists() || !file.isDirectory()) {
return;
}
String[] list = file.list();
if (list == null) {
return;
}
for (String str : list) {
if (!str.startsWith(TradeStation.SAVE_NAME)) {
continue;
}
if (!str.endsWith(".dat")) {
continue;
}
MailAddress address = new MailAddress(str.replace(TradeStation.SAVE_NAME, "").replace(".dat", ""));
ITradeStation trade = PostManager.postRegistry.getTradeStation(world, address);
if (trade == null) {
continue;
}
registerTradeStation(trade);
}
}
use of forestry.api.mail.ITradeStation in project ForestryMC by ForestryMC.
the class ContainerCatalogue method updateTradeInfo.
/* Managing Trade info */
private void updateTradeInfo() {
// Updating is done by the server.
if (player.world.isRemote) {
return;
}
if (!stations.isEmpty()) {
ITradeStation station = stations.get(stationIndex);
setTradeInfo(station.getTradeInfo());
} else {
setTradeInfo(null);
}
needsSync = true;
}
use of forestry.api.mail.ITradeStation in project ForestryMC by ForestryMC.
the class ContainerLetter method updateTradeInfo.
/* Managing Trade info */
private void updateTradeInfo(World world, @Nullable IMailAddress address) {
// Updating is done by the server.
if (world.isRemote) {
return;
}
if (address == null) {
setTradeInfo(null);
return;
}
ITradeStation station = PostManager.postRegistry.getTradeStation(world, address);
if (station == null) {
setTradeInfo(null);
return;
}
setTradeInfo(station.getTradeInfo());
}
Aggregations