Removed Bukkit stuff I missed from the general use API
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
package com.alttd.chat.managers;
|
||||
|
||||
import com.alttd.chat.ChatAPI;
|
||||
import com.alttd.chat.config.RegexConfig;
|
||||
import com.alttd.chat.objects.ChatFilter;
|
||||
import com.alttd.chat.util.ALogger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import net.luckperms.api.LuckPerms;
|
||||
import net.luckperms.api.cacheddata.CachedPermissionData;
|
||||
import net.luckperms.api.model.user.User;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -26,7 +29,13 @@ public class RegexManager {
|
||||
chatFilters.add(filter);
|
||||
}
|
||||
|
||||
public static String replaceText(Player player, String text) { // TODO loop all objects in the list and check if they violate based on the MATCHER
|
||||
public static String replaceText(String playerName, UUID uuid, String text) { // TODO loop all objects in the list and check if they violate based on the MATCHER
|
||||
User user = ChatAPI.get().getLuckPerms().getUserManager().getUser(uuid);
|
||||
if (user == null) {
|
||||
ALogger.warn("Tried to check chat filters for a user who doesn't exist in LuckPerms");
|
||||
return null;
|
||||
}
|
||||
CachedPermissionData permissionData = user.getCachedData().getPermissionData();
|
||||
for(ChatFilter chatFilter : chatFilters) {
|
||||
switch (chatFilter.getType()) {
|
||||
case CHAT:
|
||||
@@ -35,8 +44,8 @@ public class RegexManager {
|
||||
text = chatFilter.replaceText(text);
|
||||
break;
|
||||
case BLOCK:
|
||||
if(chatFilter.matches(text) && !player.hasPermission("chat.bypass-filter." + chatFilter.getName())) { // todo find a better way to do this?
|
||||
ALogger.info(player.getName() + " triggered the chat filter for " + chatFilter.getName() + ".");
|
||||
if(chatFilter.matches(text) && !permissionData.checkPermission("chat.bypass-filter." + chatFilter.getName()).asBoolean()) { // todo find a better way to do this?
|
||||
ALogger.info(playerName + " triggered the chat filter for " + chatFilter.getName() + ".");
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user