use of io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation in project Slimefun4 by Slimefun.
the class TestGuideOpening method prepare.
@ParametersAreNonnullByDefault
@Nonnull
private PlayerProfile prepare(SlimefunGuideImplementation guide, Consumer<GuideHistory> consumer) throws InterruptedException {
Player player = server.addPlayer();
PlayerProfile profile = TestUtilities.awaitProfile(player);
GuideHistory history = profile.getGuideHistory();
consumer.accept(history);
history.openLastEntry(guide);
return profile;
}
use of io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation in project Slimefun4 by Slimefun.
the class TestGuideOpening method testOpenMainMenu.
@Test
@DisplayName("Test if the Slimefun Guide Main Menu can be opened from the History")
void testOpenMainMenu() throws InterruptedException {
SlimefunGuideImplementation guide = Mockito.mock(SlimefunGuideImplementation.class);
PlayerProfile profile = prepare(guide, history -> {
});
Mockito.verify(guide).openMainMenu(profile, 1);
}
use of io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation in project Slimefun4 by Slimefun.
the class TestGuideOpening method testOpenSearch.
@Test
@DisplayName("Test if the Slimefun Search can be opened from the History")
void testOpenSearch() throws InterruptedException {
String query = "electric";
SlimefunGuideImplementation guide = Mockito.mock(SlimefunGuideImplementation.class);
PlayerProfile profile = prepare(guide, history -> history.add(query));
Mockito.verify(guide).openSearch(profile, query, false);
}
use of io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation in project Slimefun4 by Slimefun.
the class TestGuideOpening method testOpenItemStack.
@Test
@DisplayName("Test if an ItemStack can be viewed from the History")
void testOpenItemStack() throws InterruptedException {
ItemStack item = new ItemStack(Material.REDSTONE_BLOCK);
SlimefunGuideImplementation guide = Mockito.mock(SlimefunGuideImplementation.class);
PlayerProfile profile = prepare(guide, history -> history.add(item, 1));
Mockito.verify(guide).displayItem(profile, item, 1, false);
}
use of io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation in project Slimefun4 by Slimefun.
the class Research method unlockFromGuide.
/**
* Handle what to do when a {@link Player} clicks on an un-researched item in
* a {@link SlimefunGuideImplementation}.
*
* @param guide
* The {@link SlimefunGuideImplementation} used.
* @param player
* The {@link Player} who clicked on the item.
* @param profile
* The {@link PlayerProfile} of that {@link Player}.
* @param sfItem
* The {@link SlimefunItem} on which the {@link Player} clicked.
* @param itemGroup
* The {@link ItemGroup} where the {@link Player} was.
* @param page
* The page number of where the {@link Player} was in the {@link ItemGroup};
*/
@ParametersAreNonnullByDefault
public void unlockFromGuide(SlimefunGuideImplementation guide, Player player, PlayerProfile profile, SlimefunItem sfItem, ItemGroup itemGroup, int page) {
if (!Slimefun.getRegistry().getCurrentlyResearchingPlayers().contains(player.getUniqueId())) {
if (profile.hasUnlocked(this)) {
guide.openItemGroup(profile, itemGroup, page);
} else {
PlayerPreResearchEvent event = new PlayerPreResearchEvent(player, this, sfItem);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
if (this.canUnlock(player)) {
guide.unlockItem(player, sfItem, pl -> guide.openItemGroup(profile, itemGroup, page));
} else {
Slimefun.getLocalization().sendMessage(player, "messages.not-enough-xp", true);
}
}
}
}
}
Aggregations