Skip to content

Commit

Permalink
Fix some Sonar issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
raoulvdberge committed May 29, 2022
1 parent ebcc946 commit 59cef83
Show file tree
Hide file tree
Showing 23 changed files with 335 additions and 425 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ public int getPriority() {
return priority;
}

// TODO: do we need this? And the composite listener stuff?
@Override
public <T> Optional<Storage<T>> getStorageForChannel(StorageChannelType<T> channelType) {
DiskDriveCompositeStorage<?> composite = compositeStorages.get(channelType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;

public abstract class StorageBlockItem extends BlockItem {
protected StorageBlockItem(Block block, Properties properties) {
public abstract class StorageBlockBlockItem extends BlockItem {
protected StorageBlockBlockItem(Block block, Properties properties) {
super(block, properties);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.refinedmods.refinedstorage2.platform.common.block;

import com.refinedmods.refinedstorage2.platform.api.item.StorageItemHelper;
import com.refinedmods.refinedstorage2.platform.common.block.entity.storage.StorageBlockEntity;
import com.refinedmods.refinedstorage2.platform.common.block.entity.storage.StorageBlockBlockEntity;
import com.refinedmods.refinedstorage2.platform.common.content.LootFunctions;

import java.util.UUID;
Expand Down Expand Up @@ -35,13 +35,13 @@ public LootItemFunctionType getType() {
@Override
public ItemStack apply(ItemStack stack, LootContext lootContext) {
BlockEntity blockEntity = lootContext.getParam(LootContextParams.BLOCK_ENTITY);
if (blockEntity instanceof StorageBlockEntity<?> storageBlockEntity) {
if (blockEntity instanceof StorageBlockBlockEntity<?> storageBlockEntity) {
apply(stack, storageBlockEntity);
}
return stack;
}

private void apply(ItemStack stack, StorageBlockEntity<?> storageBlockEntity) {
private void apply(ItemStack stack, StorageBlockBlockEntity<?> storageBlockEntity) {
UUID storageId = storageBlockEntity.getStorageId();
if (storageId != null) {
LOGGER.info("Transferred storage {} at {} to stack", storageId, storageBlockEntity.getBlockPos());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
import com.refinedmods.refinedstorage2.platform.common.block.entity.BlockEntityWithDrops;
import com.refinedmods.refinedstorage2.platform.common.block.entity.FilterModeSettings;
import com.refinedmods.refinedstorage2.platform.common.block.entity.InternalNetworkNodeContainerBlockEntity;
import com.refinedmods.refinedstorage2.platform.common.containermenu.diskdrive.DiskDriveContainerMenu;
import com.refinedmods.refinedstorage2.platform.common.containermenu.storage.StorageSettingsProvider;
import com.refinedmods.refinedstorage2.platform.common.containermenu.storage.diskdrive.DiskDriveContainerMenu;
import com.refinedmods.refinedstorage2.platform.common.content.BlockEntities;
import com.refinedmods.refinedstorage2.platform.common.util.ContainerUtil;
import com.refinedmods.refinedstorage2.platform.common.util.LevelUtil;
Expand All @@ -35,7 +36,6 @@
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.SimpleContainer;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
Expand All @@ -50,7 +50,7 @@

import static com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil.createTranslation;

public abstract class DiskDriveBlockEntity extends InternalNetworkNodeContainerBlockEntity<DiskDriveNetworkNode> implements MenuProvider, BlockEntityWithDrops, DiskDriveListener, ExtendedMenuProvider {
public abstract class DiskDriveBlockEntity extends InternalNetworkNodeContainerBlockEntity<DiskDriveNetworkNode> implements BlockEntityWithDrops, DiskDriveListener, ExtendedMenuProvider, StorageSettingsProvider {
private static final Logger LOGGER = LogManager.getLogger();

private static final String TAG_PRIORITY = "pri";
Expand Down Expand Up @@ -207,34 +207,51 @@ public SimpleContainer getDiskInventory() {
return diskInventory;
}

@Override
public FilterMode getFilterMode() {
return getNode().getFilterMode();
}

@Override
public void setFilterMode(FilterMode mode) {
getNode().setFilterMode(mode);
setChanged();
}

@Override
public boolean isExactMode() {
return exactMode;
}

@Override
public void setExactMode(boolean exactMode) {
this.exactMode = exactMode;
initializeResourceFilter();
setChanged();
}

@Override
public AccessMode getAccessMode() {
return getNode().getAccessMode();
}

@Override
public void setAccessMode(AccessMode accessMode) {
getNode().setAccessMode(accessMode);
setChanged();
}

@Override
public int getPriority() {
return getNode().getPriority();
}

@Override
public void setPriority(int priority) {
getNode().setPriority(priority);
setChanged();
}

void onDiskChanged(int slot) {
getNode().onDiskChanged(slot);
LevelUtil.updateBlock(level, worldPosition, this.getBlockState());
Expand Down Expand Up @@ -318,15 +335,6 @@ public NonNullList<ItemStack> getDrops() {
return drops;
}

public int getPriority() {
return getNode().getPriority();
}

public void setPriority(int priority) {
getNode().setPriority(priority);
setChanged();
}

@Override
public void onDiskChanged() {
this.syncRequested = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.refinedmods.refinedstorage2.platform.api.resource.ItemResource;
import com.refinedmods.refinedstorage2.platform.api.storage.PlatformLimitedStorage;
import com.refinedmods.refinedstorage2.platform.api.storage.PlatformStorage;
import com.refinedmods.refinedstorage2.platform.common.containermenu.storage.ItemStorageContainerMenu;
import com.refinedmods.refinedstorage2.platform.common.containermenu.storage.block.ItemStorageBlockContainerMenu;
import com.refinedmods.refinedstorage2.platform.common.content.BlockEntities;
import com.refinedmods.refinedstorage2.platform.common.internal.resource.ItemResourceType;
import com.refinedmods.refinedstorage2.platform.common.internal.storage.channel.StorageChannelTypes;
Expand All @@ -25,7 +25,7 @@

import static com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil.createTranslation;

public class ItemStorageBlockEntity extends StorageBlockEntity<ItemResource> {
public class ItemStorageBlockEntity extends StorageBlockBlockEntity<ItemResource> {
private final ItemStorageType.Variant variant;
private final Component displayName;

Expand Down Expand Up @@ -80,7 +80,7 @@ public Component getDisplayName() {

@Override
public AbstractContainerMenu createMenu(int syncId, Inventory inventory, Player player) {
return new ItemStorageContainerMenu(
return new ItemStorageBlockContainerMenu(
syncId,
player,
resourceFilterContainer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.refinedmods.refinedstorage2.platform.common.block.entity.AccessModeSettings;
import com.refinedmods.refinedstorage2.platform.common.block.entity.FilterModeSettings;
import com.refinedmods.refinedstorage2.platform.common.block.entity.InternalNetworkNodeContainerBlockEntity;
import com.refinedmods.refinedstorage2.platform.common.containermenu.storage.StorageSettingsProvider;

import java.util.UUID;

Expand All @@ -27,7 +28,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public abstract class StorageBlockEntity<T> extends InternalNetworkNodeContainerBlockEntity<StorageNetworkNode<T>> implements ExtendedMenuProvider {
public abstract class StorageBlockBlockEntity<T> extends InternalNetworkNodeContainerBlockEntity<StorageNetworkNode<T>> implements ExtendedMenuProvider, StorageSettingsProvider {
private static final Logger LOGGER = LogManager.getLogger();

private static final String TAG_STORAGE_ID = "sid";
Expand All @@ -42,7 +43,7 @@ public abstract class StorageBlockEntity<T> extends InternalNetworkNodeContainer
private UUID storageId;
private boolean exactMode;

protected StorageBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state, StorageNetworkNode<T> node, ResourceType<T> resourceType) {
protected StorageBlockBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state, StorageNetworkNode<T> node, ResourceType<T> resourceType) {
super(type, pos, state, node);
node.setNormalizer(this::normalize);
this.resourceFilterContainer = new FilteredResourceFilterContainer(9, this::resourceFilterContainerChanged, resourceType);
Expand Down Expand Up @@ -165,38 +166,46 @@ public UUID getStorageId() {
return storageId;
}

@Override
public AccessMode getAccessMode() {
return getNode().getAccessMode();
}

@Override
public void setAccessMode(AccessMode accessMode) {
getNode().setAccessMode(accessMode);
setChanged();
}

@Override
public boolean isExactMode() {
return exactMode;
}

@Override
public void setExactMode(boolean exactMode) {
this.exactMode = exactMode;
initializeResourceFilter();
setChanged();
}

@Override
public int getPriority() {
return getNode().getPriority();
}

@Override
public void setPriority(int priority) {
getNode().setPriority(priority);
setChanged();
}

@Override
public FilterMode getFilterMode() {
return getNode().getFilterMode();
}

@Override
public void setFilterMode(FilterMode mode) {
getNode().setFilterMode(mode);
setChanged();
Expand Down

This file was deleted.

Loading

0 comments on commit 59cef83

Please sign in to comment.