Skip to content

Commit

Permalink
chore: fix sonar issues
Browse files Browse the repository at this point in the history
  • Loading branch information
raoulvdberge committed Jul 29, 2024
1 parent d4dfcb2 commit 81e91ac
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.refinedmods.refinedstorage.common.support.widget.CustomCheckboxWidget;
import com.refinedmods.refinedstorage.common.support.widget.HoveredImageButton;

import java.util.HashMap;
import java.util.EnumMap;
import java.util.Map;
import javax.annotation.Nullable;

Expand Down Expand Up @@ -49,7 +49,7 @@ public class PatternGridScreen extends AbstractGridScreen<PatternGridContainerMe
@Nullable
private Button createPatternButton;

private final Map<PatternType, PatternTypeButton> patternTypeButtons = new HashMap<>();
private final Map<PatternType, PatternTypeButton> patternTypeButtons = new EnumMap<>(PatternType.class);

public PatternGridScreen(final PatternGridContainerMenu menu, final Inventory inventory, final Component title) {
super(menu, inventory, title, 177);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.refinedmods.refinedstorage.common.autocrafting;

import com.refinedmods.refinedstorage.api.resource.ResourceAmount;
import com.refinedmods.refinedstorage.common.PlatformProxy;
import com.refinedmods.refinedstorage.common.api.RefinedStorageApi;
import com.refinedmods.refinedstorage.common.api.autocrafting.CraftingPattern;
import com.refinedmods.refinedstorage.common.api.autocrafting.Pattern;
Expand All @@ -23,7 +22,6 @@
import javax.annotation.Nullable;

import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.InteractionHand;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,7 @@ public boolean transfer(final int index) {
}
final TransferDestination key = destinationFactory.apply(slot.container);
final List<TransferDestination> destinations = destinationMap.get(key);
boolean success = false;
if (destinations != null) {
if (transfer(slot, destinations)) {
success = true;
}
}
return success;
return destinations != null && transfer(slot, destinations);
}

private boolean transfer(final Slot slot, final List<TransferDestination> destinations) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;

// A custom checkbox so that we can change the font color.
// A custom checkbox so that we can change the font color and size.
public class CustomCheckboxWidget extends AbstractButton {
private static final ResourceLocation CHECKBOX_SELECTED_HIGHLIGHTED_SPRITE = ResourceLocation.withDefaultNamespace(
"widget/checkbox_selected_highlighted"
Expand All @@ -36,7 +36,7 @@ public CustomCheckboxWidget(final int x,
final Font font,
final boolean selected,
final Size size) {
super(x, y, size.size + 4 + font.width(text), size.size, text);
super(x, y, size.widthHeight + 4 + font.width(text), size.widthHeight, text);
this.selected = selected;
this.size = size;
}
Expand Down Expand Up @@ -80,9 +80,9 @@ public void renderWidget(final GuiGraphics graphics, final int mouseX, final int
} else {
sprite = isFocused() ? CHECKBOX_HIGHLIGHTED_SPRITE : CHECKBOX_SPRITE;
}
graphics.blitSprite(sprite, getX(), getY(), size.size, size.size);
graphics.blitSprite(sprite, getX(), getY(), size.widthHeight, size.widthHeight);
graphics.setColor(1.0F, 1.0F, 1.0F, 1.0F);
final int textX = getX() + size.size + 4;
final int textX = getX() + size.widthHeight + 4;
final int textY = (getY() + (height >> 1)) - (9 >> 1);
graphics.drawString(font, getMessage(), textX, textY, 4210752, false);
}
Expand All @@ -96,10 +96,10 @@ public enum Size {
REGULAR(9 + 8),
SMALL(9);

private final int size;
private final int widthHeight;

Size(final int size) {
this.size = size;
Size(final int widthHeight) {
this.widthHeight = widthHeight;
}
}
}

0 comments on commit 81e91ac

Please sign in to comment.