Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mezz committed Dec 19, 2015
1 parent 9ce0e45 commit 9c4453a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
27 changes: 11 additions & 16 deletions src/main/java/mezz/jei/ItemRegistry.java
Expand Up @@ -46,24 +46,24 @@ class ItemRegistry implements IItemRegistry {

public ItemRegistry() {
this.modList = new ModList();
List<ItemStack> itemList = new ArrayList<>();
List<ItemStack> fuels = new ArrayList<>();
List<ItemStack> itemListMutable = new ArrayList<>();
List<ItemStack> fuelsMutable = new ArrayList<>();

for (Block block : GameData.getBlockRegistry().typeSafeIterable()) {
addBlockAndSubBlocks(block, itemList, fuels);
addBlockAndSubBlocks(block, itemListMutable, fuelsMutable);
}

for (Item item : GameData.getItemRegistry().typeSafeIterable()) {
addItemAndSubItems(item, itemList, fuels);
addItemAndSubItems(item, itemListMutable, fuelsMutable);
}

addEnchantedBooks(itemList);
addEnchantedBooks(itemListMutable);

this.itemList = ImmutableList.copyOf(itemList);
this.fuels = ImmutableList.copyOf(fuels);
this.itemList = ImmutableList.copyOf(itemListMutable);
this.fuels = ImmutableList.copyOf(fuelsMutable);

ImmutableListMultimap.Builder<String, ItemStack> itemsByModIdBuilder = ImmutableListMultimap.builder();
for (ItemStack itemStack : itemList) {
for (ItemStack itemStack : itemListMutable) {
Item item = itemStack.getItem();
if (item != null) {
String modId = GameRegistry.findUniqueIdentifierFor(item).modId.toLowerCase(Locale.ENGLISH);
Expand Down Expand Up @@ -126,8 +126,8 @@ public ImmutableList<ItemStack> getItemListForModId(@Nullable String modId) {
Log.error("Null modId", new NullPointerException());
return ImmutableList.of();
}
modId = modId.toLowerCase(Locale.ENGLISH);
return itemsByModId.get(modId);
String lowerCaseModId = modId.toLowerCase(Locale.ENGLISH);
return itemsByModId.get(lowerCaseModId);
}

private void addItemAndSubItems(@Nullable Item item, @Nonnull List<ItemStack> itemList, @Nonnull List<ItemStack> fuels) {
Expand Down Expand Up @@ -201,12 +201,7 @@ private void addItemStack(@Nonnull ItemStack stack, @Nonnull List<ItemStack> ite
fuels.add(stack);
}
} catch (RuntimeException e) {
try {
Log.error("Couldn't create unique name for itemStack {}.", stack, e);
} catch (RuntimeException ignored) {

}
Log.error("Couldn't create unique name for itemStack {}.", stack.getClass(), e);
}
}

}
6 changes: 3 additions & 3 deletions src/main/java/mezz/jei/network/PacketHandler.java
Expand Up @@ -19,11 +19,11 @@
import mezz.jei.util.Log;

public class PacketHandler {
public static final String channelId = "JEI";
public static final String CHANNEL_ID = "JEI";
private final FMLEventChannel channel;

public PacketHandler() {
channel = NetworkRegistry.INSTANCE.newEventDrivenChannel(channelId);
channel = NetworkRegistry.INSTANCE.newEventDrivenChannel(CHANNEL_ID);
channel.register(this);
}

Expand All @@ -49,7 +49,7 @@ public void onPacket(FMLNetworkEvent.ServerCustomPacketEvent event) {

checkThreadAndEnqueue(packet, packetBuffer, player, player.getServerForPlayer());
} catch (Exception ex) {
ex.printStackTrace();
Log.error("Packet error", ex);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mezz/jei/network/packets/PacketJEI.java
Expand Up @@ -25,7 +25,7 @@ public final FMLProxyPacket getPacket() {
Log.error("Error creating packet", e);
}

return new FMLProxyPacket(packetBuffer, PacketHandler.channelId);
return new FMLProxyPacket(packetBuffer, PacketHandler.CHANNEL_ID);
}

public abstract IPacketId getPacketId();
Expand Down

0 comments on commit 9c4453a

Please sign in to comment.