Archive incari-client (client, 26.3, clean)
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
# shulkertooltips: Shulker Tooltips
|
||||
|
||||
A shulker box's tooltip shows its contents as a grid, on the box's color. ([ADR 0054](../../docs/adr/0054-screen-modules.md))
|
||||
|
||||
| Setting | Kind | Default |
|
||||
| --- | --- | --- |
|
||||
| Box color | on/off | on |
|
||||
| Only with Shift | on/off | off |
|
||||
|
||||
```sh
|
||||
./gradlew :features:shulkertooltips:check
|
||||
```
|
||||
@@ -0,0 +1,16 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
}
|
||||
|
||||
// Shulker Tooltips (ADR 0054): a shulker box's contents shown as a grid of items in its tooltip.
|
||||
// A feature module: it sees the module framework and nothing else.
|
||||
dependencies {
|
||||
api(project(":framework"))
|
||||
|
||||
testImplementation(testFixtures(project(":framework")))
|
||||
testImplementation(platform(libs.junit.bom))
|
||||
testImplementation(libs.junit.jupiter)
|
||||
testImplementation(libs.assertj)
|
||||
testImplementation(libs.archunit)
|
||||
testRuntimeOnly(libs.junit.launcher)
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package incari.features.shulkertooltips;
|
||||
|
||||
import incari.framework.Category;
|
||||
import incari.framework.Module;
|
||||
import incari.framework.event.ContainerTooltip;
|
||||
import incari.framework.event.Events;
|
||||
import incari.framework.setting.BooleanSetting;
|
||||
|
||||
/**
|
||||
* Shulker Tooltips: hovering a shulker box (or anything else holding items) shows what's inside as
|
||||
* a grid of items, nine across as in the box, in place of the game's first five lines of names.
|
||||
*/
|
||||
public final class ShulkerTooltips extends Module {
|
||||
|
||||
final BooleanSetting tinted =
|
||||
settings().bool("tinted", "Box color", true).describedAs("The grid takes the box's dye color.");
|
||||
final BooleanSetting onlyWithShift = settings()
|
||||
.bool("only-with-shift", "Only with Shift", false)
|
||||
.describedAs("Shows the grid only while Shift is held; otherwise the game's lines.");
|
||||
|
||||
/** Shulker Tooltips, off until the player turns it on. */
|
||||
public ShulkerTooltips() {
|
||||
super(
|
||||
"shulkertooltips",
|
||||
"Shulker Tooltips",
|
||||
"Shows a shulker box's contents as a grid in its tooltip.",
|
||||
Category.UTILITY);
|
||||
on(Events.CONTAINER_TOOLTIP, this::onTooltip);
|
||||
}
|
||||
|
||||
private void onTooltip(ContainerTooltip tooltip) {
|
||||
if (onlyWithShift.get() && !tooltip.shiftDown()) {
|
||||
return;
|
||||
}
|
||||
tooltip.setPreview(true);
|
||||
tooltip.setTinted(tinted.get());
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/** Shulker Tooltips (ADR 0054): a shulker box's contents as a grid in its tooltip. */
|
||||
@NullMarked
|
||||
package incari.features.shulkertooltips;
|
||||
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package incari.features.shulkertooltips;
|
||||
|
||||
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes;
|
||||
|
||||
import com.tngtech.archunit.core.importer.ImportOption;
|
||||
import com.tngtech.archunit.junit.AnalyzeClasses;
|
||||
import com.tngtech.archunit.junit.ArchTest;
|
||||
import com.tngtech.archunit.lang.ArchRule;
|
||||
|
||||
/** A feature sees the module framework and the JDK's basics: no game, platform or other feature. */
|
||||
@AnalyzeClasses(packages = "incari.features.shulkertooltips", importOptions = ImportOption.DoNotIncludeTests.class)
|
||||
class BoundaryTest {
|
||||
|
||||
@ArchTest
|
||||
static final ArchRule onlyTheFramework = classes()
|
||||
.should()
|
||||
.onlyDependOnClassesThat()
|
||||
.resideInAnyPackage(
|
||||
"java.lang..",
|
||||
"java.util..",
|
||||
"org.jspecify..",
|
||||
"incari.framework..",
|
||||
"incari.features.shulkertooltips..");
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package incari.features.shulkertooltips;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import incari.framework.event.ContainerTooltip;
|
||||
import incari.framework.setting.BooleanSetting;
|
||||
import incari.framework.testing.TestGame;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class ShulkerTooltipsTest {
|
||||
|
||||
private final ShulkerTooltips module = new ShulkerTooltips();
|
||||
private final TestGame game = new TestGame(module);
|
||||
|
||||
@Test
|
||||
void previewsInTheBoxsColor() {
|
||||
module.setEnabled(true);
|
||||
ContainerTooltip tooltip = game.containerTooltip(false);
|
||||
assertThat(tooltip.preview()).isTrue();
|
||||
assertThat(tooltip.tinted()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void canWaitForShift() {
|
||||
module.setEnabled(true);
|
||||
((BooleanSetting) module.settings().get("only-with-shift")).set(true);
|
||||
assertThat(game.containerTooltip(false).preview()).isFalse();
|
||||
assertThat(game.containerTooltip(true).preview()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void offLeavesTheGamesLines() {
|
||||
assertThat(game.containerTooltip(true).preview()).isFalse();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user