49 lines
1.7 KiB
Java
49 lines
1.7 KiB
Java
/*
|
|
* Copyright (c) 2017 univento.eu - All rights reserved
|
|
* You are not allowed to use, distribute or modify this code
|
|
*/
|
|
|
|
package eu.univento.core.api.advancement;
|
|
|
|
import eu.univento.core.Core;
|
|
import eu.univento.core.api.player.CustomPlayer;
|
|
import lombok.Getter;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.Material;
|
|
import org.bukkit.NamespacedKey;
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
/**
|
|
* @author joethei
|
|
* @version 1.0
|
|
*/
|
|
|
|
@Getter
|
|
public enum CustomAdvancement {
|
|
CHAT_T(new Advancement(new NamespacedKey(Core.getInstance(), "chat_t")).withTrigger("minecraft:impossible").withIcon("minecraft:apple")
|
|
.withBackground(Advancement.AdvancementBackground.ADVENTURE).withFrame(Advancement.FrameType.GOAL).withTitle("Chatten").withDescription("Schreibe etwas in den Chat").withItem(new ItemStack(Material.TNT)).withAnnouncement(false).withToast(true));
|
|
|
|
private Advancement advancement;
|
|
|
|
CustomAdvancement(Advancement advancement) {
|
|
this.advancement = advancement;
|
|
}
|
|
|
|
public void load() {
|
|
if(Bukkit.getAdvancement(advancement.getId()) == null)
|
|
Bukkit.getUnsafe().loadAdvancement(advancement.getId(), advancement.getJSON());
|
|
}
|
|
|
|
public void award(CustomPlayer p, String criteria) {
|
|
if(!p.getAdvancementProgress(Bukkit.getAdvancement(advancement.getId())).isDone()) {
|
|
p.getAdvancementProgress(Bukkit.getAdvancement(advancement.getId())).awardCriteria(criteria);
|
|
}
|
|
}
|
|
|
|
public void revoke(CustomPlayer p, String criteria) {
|
|
if(p.getAdvancementProgress(Bukkit.getAdvancement(advancement.getId())).isDone()) {
|
|
p.getAdvancementProgress(Bukkit.getAdvancement(advancement.getId())).revokeCriteria(criteria);
|
|
}
|
|
}
|
|
|
|
} |