Adding the chat based advancement trigger and trigger criteria to config
parent
fc163baf51
commit
354bb77f9d
|
@ -6,6 +6,7 @@ import org.bukkit.event.EventHandler;
|
|||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.advancement.Advancement;
|
||||
import xyz.etztech.qol.QoL;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
@ -48,6 +49,16 @@ public class AsyncPlayerChatListener implements Listener {
|
|||
String chat = event.getMessage();
|
||||
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");
|
||||
} else{}
|
||||
} else {}
|
||||
|
||||
// Escape
|
||||
if (chat.startsWith("\\")) {
|
||||
escape = true;
|
||||
|
|
|
@ -104,3 +104,7 @@ dynmap:
|
|||
defaults:
|
||||
map: "surface"
|
||||
zoom: 5
|
||||
|
||||
# A list of words/phrases which will award the chant advancement to the message author
|
||||
chat-advancement-triggers:
|
||||
- chat_advancment_test
|
||||
|
|
Loading…
Reference in New Issue