mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-24 22:04:34 +00:00
Close #477 Auto-Format code with new formatting settings
This commit is contained in:
1 parent
8e92d16320
commit
5b8b0c78b0
763 files changed
+13174
-8868
No files matched your search
@@ -4,12 +4,20 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.mail;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldSavedData;
|
||||
|
||||
import forestry.api.mail.EnumPostage;
|
||||
import forestry.api.mail.ILetter;
|
||||
import forestry.api.mail.IMailAddress;
|
||||
@@ -20,12 +28,6 @@ import forestry.api.mail.IStamps;
|
||||
import forestry.api.mail.ITradeStation;
|
||||
import forestry.api.mail.PostManager;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldSavedData;
|
||||
|
||||
public class PostOffice extends WorldSavedData implements IPostOffice {
|
||||
|
||||
@@ -49,8 +51,9 @@ public class PostOffice extends WorldSavedData implements IPostOffice {
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
for (int i = 0; i < collectedPostage.length; i++) {
|
||||
if (nbttagcompound.hasKey("CPS" + i))
|
||||
if (nbttagcompound.hasKey("CPS" + i)) {
|
||||
collectedPostage[i] = nbttagcompound.getInteger("CPS" + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,25 +74,31 @@ public class PostOffice extends WorldSavedData implements IPostOffice {
|
||||
|
||||
private void refreshActiveTradeStations(World world) {
|
||||
activeTradeStations = new LinkedHashMap<IMailAddress, ITradeStation>();
|
||||
if (world == null || world.getSaveHandler() == null)
|
||||
if (world == null || world.getSaveHandler() == null) {
|
||||
return;
|
||||
}
|
||||
File worldSave = world.getSaveHandler().getMapFileFromName("dummy");
|
||||
if (worldSave == null)
|
||||
if (worldSave == null) {
|
||||
return;
|
||||
}
|
||||
File file = worldSave.getParentFile();
|
||||
if (!file.exists() || !file.isDirectory())
|
||||
if (!file.exists() || !file.isDirectory()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (String str : file.list()) {
|
||||
if (!str.startsWith(TradeStation.SAVE_NAME))
|
||||
if (!str.startsWith(TradeStation.SAVE_NAME)) {
|
||||
continue;
|
||||
if (!str.endsWith(".dat"))
|
||||
}
|
||||
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)
|
||||
if (trade == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
registerTradeStation(trade);
|
||||
}
|
||||
@@ -97,8 +106,9 @@ public class PostOffice extends WorldSavedData implements IPostOffice {
|
||||
|
||||
@Override
|
||||
public void registerTradeStation(ITradeStation trade) {
|
||||
if (!activeTradeStations.containsKey(trade.getAddress()))
|
||||
if (!activeTradeStations.containsKey(trade.getAddress())) {
|
||||
activeTradeStations.put(trade.getAddress(), trade);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -114,7 +124,7 @@ public class PostOffice extends WorldSavedData implements IPostOffice {
|
||||
|
||||
@Override
|
||||
public ItemStack getAnyStamp(EnumPostage postage, int max) {
|
||||
return getAnyStamp(new EnumPostage[] { postage }, max);
|
||||
return getAnyStamp(new EnumPostage[]{postage}, max);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -123,8 +133,9 @@ public class PostOffice extends WorldSavedData implements IPostOffice {
|
||||
for (EnumPostage postage : postages) {
|
||||
|
||||
int collected;
|
||||
if (collectedPostage[postage.ordinal()] <= 0)
|
||||
if (collectedPostage[postage.ordinal()] <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (max >= collectedPostage[postage.ordinal()]) {
|
||||
collected = collectedPostage[postage.ordinal()];
|
||||
@@ -134,8 +145,9 @@ public class PostOffice extends WorldSavedData implements IPostOffice {
|
||||
collectedPostage[postage.ordinal()] -= max;
|
||||
}
|
||||
|
||||
if (collected > 0)
|
||||
if (collected > 0) {
|
||||
return ForestryItem.stamps.getItemStack(collected, postage.ordinal() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -146,27 +158,33 @@ public class PostOffice extends WorldSavedData implements IPostOffice {
|
||||
public IPostalState lodgeLetter(World world, ItemStack itemstack, boolean doLodge) {
|
||||
ILetter letter = PostManager.postRegistry.getLetter(itemstack);
|
||||
|
||||
if (letter.isProcessed())
|
||||
if (letter.isProcessed()) {
|
||||
return EnumDeliveryState.ALREADY_MAILED;
|
||||
}
|
||||
|
||||
if (!letter.isPostPaid())
|
||||
if (!letter.isPostPaid()) {
|
||||
return EnumDeliveryState.NOT_POSTPAID;
|
||||
}
|
||||
|
||||
if (!letter.isMailable())
|
||||
if (!letter.isMailable()) {
|
||||
return EnumDeliveryState.NOT_MAILABLE;
|
||||
}
|
||||
|
||||
IPostalState state = EnumDeliveryState.NOT_MAILABLE;
|
||||
for (IMailAddress address : letter.getRecipients()) {
|
||||
IPostalCarrier carrier = PostManager.postRegistry.getCarrier(address.getType());
|
||||
if (carrier == null)
|
||||
if (carrier == null) {
|
||||
continue;
|
||||
}
|
||||
state = carrier.deliverLetter(world, this, address, itemstack, doLodge);
|
||||
if (!state.isOk())
|
||||
if (!state.isOk()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!state.isOk())
|
||||
if (!state.isOk()) {
|
||||
return state;
|
||||
}
|
||||
|
||||
collectPostage(letter.getPostage());
|
||||
|
||||
@@ -178,8 +196,9 @@ public class PostOffice extends WorldSavedData implements IPostOffice {
|
||||
@Override
|
||||
public void collectPostage(ItemStack[] stamps) {
|
||||
for (ItemStack stamp : stamps) {
|
||||
if (stamp == null)
|
||||
if (stamp == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (stamp.getItem() instanceof IStamps) {
|
||||
EnumPostage postage = ((IStamps) stamp.getItem()).getPostage(stamp);
|
||||
|
||||
Reference in new issue
Block a user