Compare commits

...

3 Commits

Author SHA1 Message Date
benamaurer ddd7286046 Removing `else{}`s from AsyncPlayerChatListener per Etz's comment
__I don't think this is ready to merge__, still getting errors when trying to build the jar to test
2021-05-24 08:16:39 -05:00
mauberries 4721b31092 Update 'src/main/java/xyz/etztech/qol/listeners/AsyncPlayerChatListener.java'
Fixing reference to bukkit.advancement, adding reference for Namespacedkey
2021-05-21 17:42:23 +00:00
benamaurer 354bb77f9d Adding the chat based advancement trigger and trigger criteria to config 2021-05-20 17:08:15 -05:00
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.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.advancement.Advancement;
import org.bukkit.Namespacedkey;
import xyz.etztech.qol.QoL;
import java.util.Arrays;
@ -48,6 +50,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");
}
}
// Escape
if (chat.startsWith("\\")) {
escape = true;

View File

@ -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