mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-16 22:43:14 +01:00
#1490: Add method to get Advancement requirements
By: Nothixal <nothixal@gmail.com>
This commit is contained in:
parent
4487df57e1
commit
f642133483
3 changed files with 53 additions and 0 deletions
|
@ -5,6 +5,7 @@ import java.util.Collections;
|
|||
import net.minecraft.advancements.AdvancementHolder;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.advancement.AdvancementDisplay;
|
||||
import org.bukkit.advancement.AdvancementRequirements;
|
||||
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
|
||||
public class CraftAdvancement implements org.bukkit.advancement.Advancement {
|
||||
|
@ -29,6 +30,11 @@ public class CraftAdvancement implements org.bukkit.advancement.Advancement {
|
|||
return Collections.unmodifiableCollection(handle.value().criteria().keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdvancementRequirements getRequirements() {
|
||||
return new CraftAdvancementRequirements(handle.value().requirements());
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdvancementDisplay getDisplay() {
|
||||
if (handle.value().display().isEmpty()) {
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package org.bukkit.craftbukkit.advancement;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.bukkit.advancement.AdvancementRequirement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CraftAdvancementRequirement implements AdvancementRequirement {
|
||||
|
||||
private final List<String> requirements;
|
||||
|
||||
public CraftAdvancementRequirement(List<String> list) {
|
||||
this.requirements = list;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<String> getRequiredCriteria() {
|
||||
return Collections.unmodifiableList(requirements);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStrict() {
|
||||
return requirements.size() == 1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package org.bukkit.craftbukkit.advancement;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.advancements.AdvancementRequirements;
|
||||
import org.bukkit.advancement.AdvancementRequirement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CraftAdvancementRequirements implements org.bukkit.advancement.AdvancementRequirements {
|
||||
|
||||
private final AdvancementRequirements requirements;
|
||||
|
||||
public CraftAdvancementRequirements(AdvancementRequirements requirements) {
|
||||
this.requirements = requirements;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<AdvancementRequirement> getRequirements() {
|
||||
return requirements.requirements().stream().map((requirement) -> (AdvancementRequirement) new CraftAdvancementRequirement(requirement)).toList();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue