WIP: Adding the chat based advancement trigger and trigger criteria to config #1

Draft
mauberries wants to merge 3 commits from mauberries/main into main
2 changed files with 16 additions and 0 deletions

View File

@ -6,6 +6,8 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.advancement.Advancement;
import org.bukkit.Namespacedkey;
import xyz.etztech.qol.QoL; import xyz.etztech.qol.QoL;
import java.util.Arrays; import java.util.Arrays;
@ -48,6 +50,16 @@ public class AsyncPlayerChatListener implements Listener {
String chat = event.getMessage(); String chat = event.getMessage();
boolean escape = false; boolean escape = false;
//Checking if player has been awarded the chat advancement, if not, message is searched for triggers
Advancement adv = Bukkit.getAdvancement(new Namespacedkey("canopy", "chat_advancement"));
if (!player.getAdvancementProgress(adv).isDone()) {
List<String> advancementTriggerList = plugin.getConfig().getStringList("chat-advancement-triggers");
if (advancementTriggerList.stream().anyMatch(t -> chat.toLowerCase().contains(t.toLowerCase()))) {
player.getAdvancementProgress(adv).awardCriteria("win");
}
}
// Escape // Escape
if (chat.startsWith("\\")) { if (chat.startsWith("\\")) {
escape = true; escape = true;

View File

@ -104,3 +104,7 @@ dynmap:
defaults: defaults:
map: "surface" map: "surface"
zoom: 5 zoom: 5
# A list of words/phrases which will award the chant advancement to the message author
chat-advancement-triggers:
- chat_advancment_test