use of io.github.bakedlibs.dough.items.CustomItemStack in project Slimefun4 by Slimefun.
the class TestItemSettings method testAlreadyExistingItemSetting.
@Test
@DisplayName("Test Item Settings double-registration")
void testAlreadyExistingItemSetting() {
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_SETTINGS_TEST", new CustomItemStack(Material.DIAMOND, "&cTest"));
ItemSetting<String> setting = new ItemSetting<>(item, "test", "Hello World");
item.addItemSetting(setting);
Assertions.assertThrows(IllegalArgumentException.class, () -> item.addItemSetting(setting));
}
use of io.github.bakedlibs.dough.items.CustomItemStack in project Slimefun4 by Slimefun.
the class TestMaterialTagSetting method testAllowedValue.
@Test
@DisplayName("Test allowed value")
void testAllowedValue() {
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MATERIAL_SETTING_TEST_2", new CustomItemStack(Material.DIAMOND, "&cTest"));
MaterialTagSetting setting = new MaterialTagSetting(item, "test", tag);
item.addItemSetting(setting);
item.register(plugin);
List<String> tagContents = tag.getValues().stream().map(Material::name).collect(Collectors.toList());
Assertions.assertTrue(new HashSet<>(tagContents).equals(new HashSet<>(setting.getValue())));
List<String> materials = Arrays.asList(Material.REDSTONE.name(), Material.DIAMOND.name());
setting.update(materials);
Assertions.assertIterableEquals(materials, setting.getValue());
}
use of io.github.bakedlibs.dough.items.CustomItemStack in project Slimefun4 by Slimefun.
the class TestDoubleRangeSetting method testConstructorValidation.
@Test
@DisplayName("Test Constructor validation")
void testConstructorValidation() {
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "DOUBLE_RANGE_TEST_00", new CustomItemStack(Material.DIAMOND, "&cTest"));
Assertions.assertThrows(IllegalArgumentException.class, () -> new DoubleRangeSetting(item, "test", min, -1.0, max));
}
use of io.github.bakedlibs.dough.items.CustomItemStack in project Slimefun4 by Slimefun.
the class TestDoubleRangeSetting method testAllowedValue.
@Test
@DisplayName("Test allowed value")
void testAllowedValue() {
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "DOUBLE_RANGE_TEST_2", new CustomItemStack(Material.DIAMOND, "&cTest"));
DoubleRangeSetting setting = new DoubleRangeSetting(item, "test", min, 0.25, max);
item.addItemSetting(setting);
item.register(plugin);
Assertions.assertEquals(0.25, setting.getValue());
setting.update(0.75);
Assertions.assertEquals(0.75, setting.getValue());
}
use of io.github.bakedlibs.dough.items.CustomItemStack in project Slimefun4 by Slimefun.
the class HologramProjector method openEditor.
private static void openEditor(@Nonnull Player p, @Nonnull Block projector) {
ChestMenu menu = new ChestMenu(Slimefun.getLocalization().getMessage(p, "machines.HOLOGRAM_PROJECTOR.inventory-title"));
menu.addItem(0, new CustomItemStack(Material.NAME_TAG, "&7Text &e(Click to edit)", "", "&r" + ChatColors.color(BlockStorage.getLocationInfo(projector.getLocation(), "text"))));
menu.addMenuClickHandler(0, (pl, slot, item, action) -> {
pl.closeInventory();
Slimefun.getLocalization().sendMessage(pl, "machines.HOLOGRAM_PROJECTOR.enter-text", true);
ChatUtils.awaitInput(pl, message -> {
ArmorStand hologram = getArmorStand(projector, true);
hologram.setCustomName(ChatColors.color(message));
BlockStorage.addBlockInfo(projector, "text", hologram.getCustomName());
openEditor(pl, projector);
});
return false;
});
menu.addItem(1, new CustomItemStack(Material.CLOCK, "&7Offset: &e" + NumberUtils.roundDecimalNumber(Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), OFFSET_PARAMETER)) + 1.0D), "", "&rLeft Click: &7+0.1", "&rRight Click: &7-0.1"));
menu.addMenuClickHandler(1, (pl, slot, item, action) -> {
double offset = NumberUtils.reparseDouble(Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), OFFSET_PARAMETER)) + (action.isRightClicked() ? -0.1F : 0.1F));
ArmorStand hologram = getArmorStand(projector, true);
Location l = new Location(projector.getWorld(), projector.getX() + 0.5, projector.getY() + offset, projector.getZ() + 0.5);
hologram.teleport(l);
BlockStorage.addBlockInfo(projector, OFFSET_PARAMETER, String.valueOf(offset));
openEditor(pl, projector);
return false;
});
menu.open(p);
}
Aggregations