Some more static imports for consistency.

This commit is contained in:
Florian Nücke
2021-08-03 01:59:28 +02:00
parent ecafd10e6f
commit 343941b0f0
8 changed files with 26 additions and 21 deletions

View File

@@ -5,9 +5,9 @@ import li.cil.oc2.api.bus.device.rpc.RPCMethod;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
@@ -51,7 +51,7 @@ public final class ObjectDevice implements RPCDevice {
* @param typeNames the type names of the device.
*/
public ObjectDevice(final Object object, final String... typeNames) {
this(object, Arrays.asList(typeNames));
this(object, asList(typeNames));
}
/**

View File

@@ -13,9 +13,9 @@ import net.minecraft.util.text.ITextProperties;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import java.util.Arrays;
import java.util.List;
import static java.util.Arrays.asList;
import static li.cil.oc2.common.util.TooltipUtils.withColor;
public abstract class AbstractMachineInventoryScreen<T extends AbstractMachineTerminalContainer> extends AbstractContainerScreen<T> {
@@ -83,7 +83,7 @@ public abstract class AbstractMachineInventoryScreen<T extends AbstractMachineTe
Sprites.ENERGY_BAR.drawFillY(matrixStack, leftPos - Sprites.SIDEBAR_2.width + 4, topPos + ENERGY_TOP + 4, energyStored / (float) energyCapacity);
if (isMouseOver(mouseX, mouseY, -Sprites.SIDEBAR_2.width + 4, ENERGY_TOP + 4, Sprites.ENERGY_BAR.width, Sprites.ENERGY_BAR.height)) {
final List<? extends ITextProperties> tooltip = Arrays.asList(
final List<? extends ITextProperties> tooltip = asList(
new TranslationTextComponent(Constants.TOOLTIP_ENERGY, withColor(energyStored + "/" + energyCapacity, TextFormatting.GREEN)),
new TranslationTextComponent(Constants.TOOLTIP_ENERGY_CONSUMPTION, withColor(String.valueOf(energyConsumption), TextFormatting.GREEN))
);

View File

@@ -14,9 +14,9 @@ import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.fml.client.gui.GuiUtils;
import java.util.Arrays;
import java.util.List;
import static java.util.Arrays.asList;
import static li.cil.oc2.common.util.TooltipUtils.withColor;
public abstract class AbstractMachineTerminalScreen<T extends AbstractMachineTerminalContainer> extends AbstractContainerScreen<T> {
@@ -56,7 +56,7 @@ public abstract class AbstractMachineTerminalScreen<T extends AbstractMachineTer
Sprites.ENERGY_BAR.drawFillY(matrixStack, leftPos - Sprites.SIDEBAR_2.width + 4, topPos + ENERGY_TOP + 4, energyStored / (float) energyCapacity);
if (isMouseOver(mouseX, mouseY, -Sprites.SIDEBAR_2.width + 4, ENERGY_TOP + 4, Sprites.ENERGY_BAR.width, Sprites.ENERGY_BAR.height)) {
final List<? extends ITextProperties> tooltip = Arrays.asList(
final List<? extends ITextProperties> tooltip = asList(
new TranslationTextComponent(Constants.TOOLTIP_ENERGY, withColor(energyStored + "/" + energyCapacity, TextFormatting.GREEN)),
new TranslationTextComponent(Constants.TOOLTIP_ENERGY_CONSUMPTION, withColor(String.valueOf(energyConsumption), TextFormatting.GREEN))
);

View File

@@ -11,10 +11,11 @@ import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.client.gui.GuiUtils;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
public abstract class ImageButton extends AbstractButton {
private static final long PRESS_DURATION = 200;
private static final long TOOLTIP_DELAY = 250;
@@ -40,9 +41,9 @@ public abstract class ImageButton extends AbstractButton {
super(x, y, width, height, caption);
this.parent = parent;
if (description == null) {
this.tooltip = Collections.singletonList(caption);
this.tooltip = singletonList(caption);
} else {
this.tooltip = Arrays.asList(caption, new StringTextComponent("").withStyle(style -> style.withColor(Color.fromLegacyFormat(TextFormatting.GRAY))).append(description));
this.tooltip = asList(caption, new StringTextComponent("").withStyle(style -> style.withColor(Color.fromLegacyFormat(TextFormatting.GRAY))).append(description));
}
this.baseImage = baseImage;
this.pressedImage = pressedImage;

View File

@@ -11,10 +11,11 @@ import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.client.gui.GuiUtils;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
public abstract class ToggleImageButton extends AbstractButton {
private static final long PRESS_DURATION = 200;
private static final long TOOLTIP_DELAY = 250;
@@ -44,9 +45,9 @@ public abstract class ToggleImageButton extends AbstractButton {
super(x, y, width, height, caption);
this.parent = parent;
if (description == null) {
this.tooltip = Collections.singletonList(caption);
this.tooltip = singletonList(caption);
} else {
this.tooltip = Arrays.asList(caption, new StringTextComponent("").withStyle(style -> style.withColor(Color.fromLegacyFormat(TextFormatting.GRAY))).append(description));
this.tooltip = asList(caption, new StringTextComponent("").withStyle(style -> style.withColor(Color.fromLegacyFormat(TextFormatting.GRAY))).append(description));
}
this.baseImage = baseImage;
this.pressedImage = pressedImage;

View File

@@ -4,9 +4,11 @@ import li.cil.oc2.api.bus.device.ItemDevice;
import li.cil.oc2.api.bus.device.rpc.RPCDevice;
import li.cil.oc2.api.bus.device.rpc.RPCMethod;
import java.util.Collections;
import java.util.List;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
public final class TypeNameRPCDevice implements RPCDevice, ItemDevice {
private final String typeName;
@@ -16,11 +18,11 @@ public final class TypeNameRPCDevice implements RPCDevice, ItemDevice {
@Override
public List<String> getTypeNames() {
return Collections.singletonList(typeName);
return singletonList(typeName);
}
@Override
public List<RPCMethod> getMethods() {
return Collections.emptyList();
return emptyList();
}
}

View File

@@ -75,6 +75,7 @@ import java.nio.ByteBuffer;
import java.util.*;
import java.util.function.Consumer;
import static java.util.Collections.singleton;
import static li.cil.oc2.common.Constants.*;
public final class RobotEntity extends Entity implements Robot {
@@ -726,12 +727,12 @@ public final class RobotEntity extends Entity implements Robot {
@Override
public Optional<Collection<LazyOptional<DeviceBusElement>>> getNeighbors() {
return Optional.of(Collections.singleton(LazyOptional.of(() -> deviceItems.busElement)));
return Optional.of(singleton(LazyOptional.of(() -> deviceItems.busElement)));
}
@Override
public Collection<Device> getLocalDevices() {
return Collections.singleton(device);
return singleton(device);
}
@Override

View File

@@ -11,7 +11,6 @@ import net.minecraft.loot.*;
import net.minecraft.loot.functions.CopyNbt;
import net.minecraft.util.ResourceLocation;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
@@ -20,6 +19,7 @@ import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import static java.util.Collections.singletonList;
import static java.util.Objects.requireNonNull;
import static li.cil.oc2.common.Constants.*;
@@ -35,7 +35,7 @@ public final class ModLootTableProvider extends LootTableProvider {
@Override
protected List<Pair<Supplier<Consumer<BiConsumer<ResourceLocation, LootTable.Builder>>>, LootParameterSet>> getTables() {
return Collections.singletonList(Pair.of(ModBlockLootTables::new, LootParameterSets.BLOCK));
return singletonList(Pair.of(ModBlockLootTables::new, LootParameterSets.BLOCK));
}
public static final class ModBlockLootTables extends BlockLootTables {