Skip to content

Commit

Permalink
Add contract and get around return value not used warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinthegreat1 committed Jan 31, 2025
1 parent bcbbb27 commit cd138b3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import java.util.function.Function;

import org.jetbrains.annotations.Contract;

import net.minecraft.client.gui.LayeredDrawer;
import net.minecraft.util.Identifier;

Expand Down Expand Up @@ -65,6 +67,7 @@ public interface LayeredDrawerWrapper {
* @param layer the layer to add
* @return this layered drawer
*/
@Contract("_ -> this")
LayeredDrawerWrapper addLayer(IdentifiedLayer layer);

/**
Expand All @@ -76,6 +79,7 @@ public interface LayeredDrawerWrapper {
* @param layer the layer to add
* @return this layered drawer
*/
@Contract("_, _ -> this")
LayeredDrawerWrapper attachLayerBefore(Identifier beforeThis, IdentifiedLayer layer);

/**
Expand All @@ -88,6 +92,7 @@ public interface LayeredDrawerWrapper {
* @param layer the layer to add
* @return this layered drawer
*/
@Contract("_, _, _ -> this")
default LayeredDrawerWrapper attachLayerBefore(Identifier beforeThis, Identifier identifier, LayeredDrawer.Layer layer) {
return attachLayerBefore(beforeThis, IdentifiedLayer.of(identifier, layer));
}
Expand All @@ -101,6 +106,7 @@ default LayeredDrawerWrapper attachLayerBefore(Identifier beforeThis, Identifier
* @param layer the layer to add
* @return this layered drawer
*/
@Contract("_, _ -> this")
LayeredDrawerWrapper attachLayerAfter(Identifier afterThis, IdentifiedLayer layer);

/**
Expand All @@ -113,6 +119,7 @@ default LayeredDrawerWrapper attachLayerBefore(Identifier beforeThis, Identifier
* @param layer the layer to add
* @return this layered drawer
*/
@Contract("_, _, _ -> this")
default LayeredDrawerWrapper attachLayerAfter(Identifier afterThis, Identifier identifier, LayeredDrawer.Layer layer) {
return attachLayerAfter(afterThis, IdentifiedLayer.of(identifier, layer));
}
Expand All @@ -123,6 +130,7 @@ default LayeredDrawerWrapper attachLayerAfter(Identifier afterThis, Identifier i
* @param identifier the identifier of the layer to remove
* @return this layered drawer
*/
@Contract("_ -> this")
LayeredDrawerWrapper removeLayer(Identifier identifier);

/**
Expand All @@ -134,5 +142,6 @@ default LayeredDrawerWrapper attachLayerAfter(Identifier afterThis, Identifier i
* @param replacer a function that takes the old layer and returns the new layer
* @return this layered drawer
*/
@Contract("_, _ -> this")
LayeredDrawerWrapper replaceLayer(Identifier identifier, Function<IdentifiedLayer, IdentifiedLayer> replacer);
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ void removeLayer() {
.addLayer(testLayer("layer3"))
.addLayer(testLayer("layer4"));

layers.removeLayer(testIdentifier("layer2"));
layers.removeLayer(testIdentifier("layer4"));
layers.removeLayer(testIdentifier("layer2"))
.removeLayer(testIdentifier("layer4"));

assertOrder(base, List.of("layer1", "layer3"));
}
Expand All @@ -95,7 +95,8 @@ void replaceLayer() {
.addLayer(testLayer("layer2"))
.addLayer(testLayer("layer3"));

layers.replaceLayer(testIdentifier("layer2"), layer -> testLayer("replaced"));
layers.replaceLayer(testIdentifier("layer2"), layer -> testLayer("temp"))
.replaceLayer(testIdentifier("temp"), layer -> testLayer("replaced"));

assertOrder(base, List.of("layer1", "replaced", "layer3"));
}
Expand Down

0 comments on commit cd138b3

Please sign in to comment.