1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

Add requested changes

Revert change in research test
This commit is contained in:
Martin Brom 2021-04-23 20:55:36 +02:00
parent 227621906c
commit fd12521a0a
3 changed files with 20 additions and 9 deletions

View File

@ -240,6 +240,11 @@ public final class SlimefunRegistry {
return researchFireworks; return researchFireworks;
} }
/**
* Returns whether the research learning animations is disabled
*
* @return Whether the research learning animations is disabled
*/
public boolean isLearningAnimationDisabled() { public boolean isLearningAnimationDisabled() {
return disableLearningAnimation; return disableLearningAnimation;
} }

View File

@ -1,28 +1,34 @@
package io.github.thebusybiscuit.slimefun4.core.guide.options; package io.github.thebusybiscuit.slimefun4.core.guide.options;
import io.github.thebusybiscuit.cscorelib2.data.PersistentDataAPI; import java.util.Optional;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; import javax.annotation.Nonnull;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.Optional; import io.github.thebusybiscuit.cscorelib2.data.PersistentDataAPI;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
public class LearningAnimationOption implements SlimefunGuideOption<Boolean> { public class LearningAnimationOption implements SlimefunGuideOption<Boolean> {
@Nonnull
@Override @Override
public SlimefunAddon getAddon() { public SlimefunAddon getAddon() {
return SlimefunPlugin.instance(); return SlimefunPlugin.instance();
} }
@Nonnull
@Override @Override
public NamespacedKey getKey() { public NamespacedKey getKey() {
return new NamespacedKey(SlimefunPlugin.instance(), "research_learning_animation"); return new NamespacedKey(SlimefunPlugin.instance(), "research_learning_animation");
} }
@Nonnull
@Override @Override
public Optional<ItemStack> getDisplayItem(Player p, ItemStack guide) { public Optional<ItemStack> getDisplayItem(Player p, ItemStack guide) {
if (SlimefunPlugin.getRegistry().isLearningAnimationDisabled()) { if (SlimefunPlugin.getRegistry().isLearningAnimationDisabled()) {
@ -35,20 +41,20 @@ public class LearningAnimationOption implements SlimefunGuideOption<Boolean> {
} }
@Override @Override
public void onClick(Player p, ItemStack guide) { public void onClick(@Nonnull Player p, @Nonnull ItemStack guide) {
setSelectedOption(p, guide, !getSelectedOption(p, guide).orElse(true)); setSelectedOption(p, guide, !getSelectedOption(p, guide).orElse(true));
SlimefunGuideSettings.openSettings(p, guide); SlimefunGuideSettings.openSettings(p, guide);
} }
@Override @Override
public Optional<Boolean> getSelectedOption(Player p, ItemStack guide) { public Optional<Boolean> getSelectedOption(@Nonnull Player p, @Nonnull ItemStack guide) {
NamespacedKey key = getKey(); NamespacedKey key = getKey();
boolean value = !PersistentDataAPI.hasByte(p, key) || PersistentDataAPI.getByte(p, key) == (byte) 1; boolean value = !PersistentDataAPI.hasByte(p, key) || PersistentDataAPI.getByte(p, key) == (byte) 1;
return Optional.of(value); return Optional.of(value);
} }
@Override @Override
public void setSelectedOption(Player p, ItemStack guide, Boolean value) { public void setSelectedOption(@Nonnull Player p, @Nonnull ItemStack guide, @Nonnull Boolean value) {
PersistentDataAPI.setByte(p, getKey(), (byte) (value ? 1 : 0)); PersistentDataAPI.setByte(p, getKey(), (byte) (value ? 1 : 0));
} }

View File

@ -47,7 +47,7 @@ class TestResearchUnlocking {
latch.countDown(); latch.countDown();
}); });
latch.await(instant ? 1 : 10, TimeUnit.SECONDS); latch.await(10, TimeUnit.SECONDS);
return ref.get(); return ref.get();
} }