inital commit

This commit is contained in:
2026-11-21 16:50:00 -05:00
commit 7f71b5dbea
29 changed files with 2117 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
Manifest-Version: 1.0
+229
View File
@@ -0,0 +1,229 @@
/* */ package com.minehut.filterplugin;
/* */
/* */ import com.minehut.filterplugin.api.FilterAPI;
/* */ import com.minehut.filterplugin.api.FilterCache;
/* */ import com.minehut.filterplugin.api.FilteredAction;
/* */ import com.minehut.filterplugin.api.model.FilterResponse;
/* */ import com.minehut.filterplugin.api.util.FeatureSupport;
/* */ import com.minehut.filterplugin.listener.BookListener;
/* */ import com.minehut.filterplugin.listener.CommandListener;
/* */ import com.minehut.filterplugin.listener.ItemListener;
/* */ import com.minehut.filterplugin.listener.SignListener;
/* */ import com.minehut.filterplugin.listener.chat.PaperChatListener;
/* */ import com.minehut.filterplugin.listener.chat.SpigotChatListener;
/* */ import com.minehut.filterplugin.messaging.AdventureMessenger;
/* */ import com.minehut.filterplugin.messaging.FilterMessenger;
/* */ import com.minehut.filterplugin.messaging.LegacyMessenger;
/* */ import com.minehut.filterplugin.messaging.MiniMessageMessenger;
/* */ import com.minehut.filterplugin.scheduling.BukkitFilterScheduler;
/* */ import com.minehut.filterplugin.scheduling.FilterScheduler;
/* */ import com.minehut.filterplugin.scheduling.FoliaFilterScheduler;
/* */ import java.util.ArrayList;
/* */ import java.util.List;
/* */ import java.util.Map;
/* */ import java.util.Objects;
/* */ import java.util.concurrent.CompletableFuture;
/* */ import java.util.concurrent.ConcurrentHashMap;
/* */ import java.util.logging.Level;
/* */ import org.bukkit.configuration.file.FileConfiguration;
/* */ import org.bukkit.entity.Player;
/* */ import org.bukkit.event.HandlerList;
/* */ import org.bukkit.event.Listener;
/* */ import org.bukkit.plugin.Plugin;
/* */ import org.bukkit.plugin.PluginManager;
/* */ import org.bukkit.plugin.java.JavaPlugin;
/* */ import org.jetbrains.annotations.Nullable;
/* */
/* */ public final class MinehutFilter extends JavaPlugin {
/* 38 */ private final FilterCache cache = new FilterCache();
/* */ private static final int CONFIG_VERSION = 2;
/* 40 */ private final Map<String, CompletableFuture<FilterResponse>> pending = new ConcurrentHashMap<>();
/* */
/* */ private boolean logFilteredMessages;
/* */
/* */ private FilterAPI filterAPI;
/* */ private FilterMessenger messenger;
/* */ private FilterScheduler scheduler;
/* */
/* */ public void onEnable() {
/* 49 */ getConfig().options().copyDefaults(true);
/* 50 */ migrateConfig();
/* 51 */ saveConfig();
/* */
/* 53 */ this.filterAPI = new FilterAPI((Plugin)this);
/* 54 */ this.messenger = createMessenger();
/* 55 */ this.scheduler = createScheduler();
/* 56 */ this.logFilteredMessages = getConfig().getBoolean("log-filtered-messages", true);
/* */
/* 58 */ registerListeners();
/* */ }
/* */
/* */
/* */ public void onDisable() {
/* 63 */ HandlerList.unregisterAll((Plugin)this);
/* */
/* 65 */ if (this.filterAPI != null) {
/* 66 */ this.filterAPI.shutdown();
/* */ }
/* */ }
/* */
/* */
/* */ private void migrateConfig() {
/* 72 */ FileConfiguration config = getConfig();
/* 73 */ if (config.getInt("config-version", 1) >= 2)
/* */ return;
/* 75 */ if (config.isList("filtered-commands")) {
/* 76 */ List<String> commands = new ArrayList<>(config.getStringList("filtered-commands"));
/* 77 */ for (String command : CommandListener.ADDED_IN_CONFIG_VERSION_2) {
/* 78 */ Objects.requireNonNull(command); if (commands.stream().noneMatch(command::equalsIgnoreCase)) {
/* 79 */ commands.add(command);
/* */ }
/* */ }
/* 82 */ config.set("filtered-commands", commands);
/* */ }
/* */
/* 85 */ config.set("config-version", Integer.valueOf(2));
/* */ }
/* */
/* */ private FilterMessenger createMessenger() {
/* 89 */ if (!FeatureSupport.HAS_ADVENTURE) {
/* 90 */ return (FilterMessenger)new LegacyMessenger();
/* */ }
/* */
/* 93 */ if (FeatureSupport.HAS_MINI_MESSAGE) {
/* 94 */ return (FilterMessenger)new MiniMessageMessenger((Plugin)this);
/* */ }
/* */
/* 97 */ return (FilterMessenger)new AdventureMessenger();
/* */ }
/* */
/* */ private FilterScheduler createScheduler() {
/* 101 */ if (FeatureSupport.HAS_FOLIA) {
/* 102 */ return (FilterScheduler)new FoliaFilterScheduler((Plugin)this);
/* */ }
/* */
/* 105 */ return (FilterScheduler)new BukkitFilterScheduler((Plugin)this);
/* */ }
/* */
/* */ public FilterMessenger getMessenger() {
/* 109 */ return this.messenger;
/* */ }
/* */
/* */ public FilterScheduler getScheduler() {
/* 113 */ return this.scheduler;
/* */ }
/* */
/* */ private void registerListeners() {
/* 117 */ PluginManager pluginManager = getServer().getPluginManager();
/* */
/* 119 */ if (FeatureSupport.HAS_PAPER_CHAT) {
/* 120 */ pluginManager.registerEvents((Listener)new PaperChatListener(), (Plugin)this);
/* */ } else {
/* 122 */ pluginManager.registerEvents((Listener)new SpigotChatListener(), (Plugin)this);
/* */ }
/* */
/* 125 */ if (getConfig().getBoolean("feature.items", true)) {
/* 126 */ pluginManager.registerEvents((Listener)new ItemListener(), (Plugin)this);
/* */ }
/* */
/* 129 */ if (getConfig().getBoolean("feature.signs", true)) {
/* 130 */ pluginManager.registerEvents((Listener)new SignListener(), (Plugin)this);
/* */ }
/* */
/* 133 */ if (getConfig().getBoolean("feature.books", true)) {
/* 134 */ pluginManager.registerEvents((Listener)new BookListener(), (Plugin)this);
/* */ }
/* */
/* 137 */ if (getConfig().getBoolean("feature.commands", true)) {
/* 138 */ pluginManager.registerEvents((Listener)new CommandListener(filteredCommands()), (Plugin)this);
/* */ }
/* */ }
/* */
/* */ private List<String> filteredCommands() {
/* 143 */ FileConfiguration config = getConfig();
/* 144 */ if (!config.isList("filtered-commands")) {
/* 145 */ return CommandListener.DEFAULT_COMMANDS;
/* */ }
/* */
/* 148 */ return config.getStringList("filtered-commands");
/* */ }
/* */
/* */ public CompletableFuture<Boolean> allows(Player player, String message, FilteredAction action) {
/* 152 */ return filter(player, message).thenApply(response -> {
/* */ if (response != null && !response.isError() && !response.isBlocked()) {
/* */ return Boolean.valueOf(true);
/* */ }
/* */
/* */ try {
/* */ this.scheduler.run(player, ());
/* 159 */ } catch (RuntimeException exception) {
/* */ getLogger().log(Level.WARNING, "Failed to notify " + player.getName() + " of a filtered message", exception);
/* */ }
/* */ return Boolean.valueOf(false);
/* */ });
/* */ }
/* */
/* */
/* */ private void notifyFiltered(Player player, String message, @Nullable FilterResponse response, FilteredAction action) {
/* 168 */ if (this.logFilteredMessages && response != null && response.isBlocked()) {
/* 169 */ getLogger().info("%s sent a blocked message: \"%s\" (block reason: \"%s\")".formatted(new Object[] { player.getName(), message, response.getBlockedReason() }));
/* */ }
/* 171 */ if (!player.isOnline())
/* */ return;
/* */ try {
/* 174 */ this.messenger.sendFilterMessage(player, response, action);
/* 175 */ } catch (RuntimeException exception) {
/* 176 */ getLogger().log(Level.WARNING, "Failed to notify " + player.getName() + " of a filtered message", exception);
/* */ }
/* */ }
/* */
/* */ public CompletableFuture<FilterResponse> filter(Player player, String message) {
/* 181 */ FilterResponse cached = this.cache.get(message);
/* 182 */ if (cached != null) {
/* 183 */ return CompletableFuture.completedFuture(cached);
/* */ }
/* */
/* 186 */ CompletableFuture<FilterResponse> request = new CompletableFuture<>();
/* 187 */ CompletableFuture<FilterResponse> existing = this.pending.putIfAbsent(message, request);
/* 188 */ if (existing != null) {
/* 189 */ return existing;
/* */ }
/* */
/* 192 */ this.filterAPI.filter(player, message)
/* 193 */ .thenApply(response -> record(player, message, response))
/* 194 */ .whenComplete((response, throwable) -> {
/* */ this.pending.remove(message, request);
/* */ request.complete((throwable == null) ? response : null);
/* */ });
/* 198 */ return request;
/* */ }
/* */ @Nullable
/* */ private FilterResponse record(Player player, String message, @Nullable FilterResponse response) {
/* 202 */ if (response == null) {
/* 203 */ return null;
/* */ }
/* */
/* 206 */ if (response.isError()) {
/* 207 */ if ("rate-limit".equals(response.getErrorReason())) {
/* 208 */ getLogger().warning("Rate limit exceeded filtering message for %s".formatted(new Object[] { player.getName() }));
/* */ } else {
/* 210 */ getLogger().warning("Failed to filter message for %s: %s".formatted(new Object[] { player.getName(), response.getErrorReason() }));
/* */ }
/* */
/* 213 */ return response;
/* */ }
/* */
/* 216 */ this.cache.put(message, response);
/* 217 */ return response;
/* */ }
/* */
/* */ public static MinehutFilter getInstance() {
/* 221 */ return (MinehutFilter)getPlugin(MinehutFilter.class);
/* */ }
/* */ }
/* Location: C:\Users\Xiao\Downloads\MinehutFilter.jar!\com\minehut\filterplugin\MinehutFilter.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.1.3
*/
@@ -0,0 +1,192 @@
/* */ package com.minehut.filterplugin.api;
/* */
/* */ import com.minehut.filterplugin.api.model.FilterRequest;
/* */ import com.minehut.filterplugin.api.model.FilterResponse;
/* */ import java.util.concurrent.CompletableFuture;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ final class Call
/* */ extends Record
/* */ {
/* */ private final FilterRequest body;
/* */ private final long deadline;
/* */ private final CompletableFuture<FilterResponse> result;
/* */
/* */ public CompletableFuture<FilterResponse> result() {
/* 153 */ return this.result; } public long deadline() { return this.deadline; } public FilterRequest body() { return this.body; } public final boolean equals(Object o) { // Byte code:
/* */ // 0: aload_0
/* */ // 1: aload_1
/* */ // 2: <illegal opcode> equals : (Lcom/minehut/filterplugin/api/FilterAPI$Call;Ljava/lang/Object;)Z
/* */ // 7: ireturn
/* */ // Line number table:
/* */ // Java source line number -> byte code offset
/* */ // #153 -> 0
/* */ // Local variable table:
/* */ // start length slot name descriptor
/* */ // 0 8 0 this Lcom/minehut/filterplugin/api/FilterAPI$Call;
/* 153 */ // 0 8 1 o Ljava/lang/Object; } private Call(FilterRequest body, long deadline, CompletableFuture<FilterResponse> result) { this.body = body; this.deadline = deadline; this.result = result; }
/* */ public final int hashCode() { // Byte code:
/* */ // 0: aload_0
/* */ // 1: <illegal opcode> hashCode : (Lcom/minehut/filterplugin/api/FilterAPI$Call;)I
/* */ // 6: ireturn
/* */ // Line number table:
/* */ // Java source line number -> byte code offset
/* */ // #153 -> 0
/* */ // Local variable table:
/* */ // start length slot name descriptor
/* */ // 0 7 0 this Lcom/minehut/filterplugin/api/FilterAPI$Call; }
/* */ public final String toString() { // Byte code:
/* */ // 0: aload_0
/* */ // 1: <illegal opcode> toString : (Lcom/minehut/filterplugin/api/FilterAPI$Call;)Ljava/lang/String;
/* */ // 6: areturn
/* */ // Line number table:
/* */ // Java source line number -> byte code offset
/* */ // #153 -> 0
/* */ // Local variable table:
/* */ // start length slot name descriptor
/* 155 */ // 0 7 0 this Lcom/minehut/filterplugin/api/FilterAPI$Call; } private Call(FilterRequest body, long deadline) { this(body, deadline, new CompletableFuture<>()); }
/* */
/* */ }
/* Location: C:\Users\Xiao\Downloads\MinehutFilter.jar!\com\minehut\filterplugin\api\FilterAPI$Call.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.1.3
*/
+193
View File
@@ -0,0 +1,193 @@
/* */ package com.minehut.filterplugin.api;
/* */
/* */ import com.google.gson.Gson;
/* */ import com.minehut.filterplugin.MinehutFilter;
/* */ import com.minehut.filterplugin.api.model.FilterRequest;
/* */ import com.minehut.filterplugin.api.model.FilterResponse;
/* */ import java.net.URI;
/* */ import java.net.http.HttpClient;
/* */ import java.net.http.HttpRequest;
/* */ import java.net.http.HttpResponse;
/* */ import java.time.Duration;
/* */ import java.util.ArrayDeque;
/* */ import java.util.Deque;
/* */ import java.util.concurrent.CompletableFuture;
/* */ import java.util.concurrent.ExecutorService;
/* */ import java.util.concurrent.Executors;
/* */ import java.util.concurrent.RejectedExecutionException;
/* */ import java.util.concurrent.TimeUnit;
/* */ import org.bukkit.entity.Player;
/* */ import org.bukkit.plugin.Plugin;
/* */ import org.jetbrains.annotations.Nullable;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public final class FilterAPI
/* */ {
/* */ private static final long TIMEOUT_SECONDS = 3L;
/* 34 */ private static final long TIMEOUT_NANOS = TimeUnit.SECONDS.toNanos(3L);
/* */
/* */ private static final int MAX_IN_FLIGHT = 32;
/* */
/* 38 */ private static final Gson GSON = new Gson();
/* */
/* */ private final URI uri;
/* */ private final String auth;
/* 42 */ private final ExecutorService executor = Executors.newSingleThreadExecutor(FilterAPI::createThread);
/* 43 */ private final HttpClient client = HttpClient.newBuilder()
/* */
/* 45 */ .version(HttpClient.Version.HTTP_1_1)
/* */
/* 47 */ .executor(this.executor)
/* 48 */ .build();
/* */
/* */
/* 51 */ private final Deque<Call> queue = new ArrayDeque<>();
/* */ private int inFlight;
/* */
/* */ public FilterAPI(Plugin plugin) {
/* 55 */ String api = plugin.getConfig().getString("api", "http://127.0.0.1:25576");
/* 56 */ String endpoint = plugin.getConfig().getString("endpoint", "/v1/game/filter");
/* 57 */ this.uri = URI.create(api + api);
/* 58 */ this.auth = plugin.getConfig().getString("auth", "");
/* */ }
/* */
/* */ private static Thread createThread(Runnable runnable) {
/* 62 */ Thread thread = new Thread(runnable, "MinehutFilter HTTP");
/* 63 */ thread.setDaemon(true);
/* */
/* 65 */ return thread;
/* */ }
/* */
/* */ public CompletableFuture<FilterResponse> filter(Player player, String message) {
/* 69 */ String name = player.getName();
/* 70 */ Call call = new Call(new FilterRequest(message, name, player.getUniqueId(), ""), System.nanoTime() + TIMEOUT_NANOS);
/* */
/* */ try {
/* 73 */ this.executor.execute(() -> {
/* */ this.queue.add(call);
/* */ drain();
/* */ });
/* 77 */ } catch (RejectedExecutionException exception) {
/* 78 */ call.result.completeExceptionally(exception);
/* */ }
/* */
/* 81 */ return call.result
/* 82 */ .orTimeout(3L, TimeUnit.SECONDS)
/* 83 */ .exceptionally(throwable -> {
/* */ Throwable cause = (throwable instanceof java.util.concurrent.CompletionException) ? throwable.getCause() : throwable;
/* */ String reason = (cause instanceof java.util.concurrent.TimeoutException) ? "no response in 3s" : String.valueOf(cause);
/* */ MinehutFilter.getInstance().getLogger().warning("Failed to run filter for %s: %s".formatted(new Object[] { name, reason }));
/* */ return null;
/* */ });
/* */ }
/* */
/* */ private void drain() {
/* 92 */ while (this.inFlight < 32 && !this.queue.isEmpty()) {
/* 93 */ Call call = this.queue.poll();
/* */
/* 95 */ if (call.result.isDone())
/* */ continue;
/* 97 */ this.inFlight++;
/* 98 */ send(call, GSON.toJson(call.body), true);
/* */ }
/* */ }
/* */
/* */
/* */ private void send(Call call, String json, boolean retry) {
/* 104 */ long remaining = Math.max(call.deadline - System.nanoTime(), TimeUnit.MILLISECONDS.toNanos(1L));
/* */
/* */
/* */
/* */
/* */
/* 110 */ HttpRequest request = HttpRequest.newBuilder(this.uri).timeout(Duration.ofNanos(remaining)).header("Authorization", this.auth).header("Content-Type", "application/json").POST(HttpRequest.BodyPublishers.ofString(json)).build();
/* */
/* 112 */ this.client.<String>sendAsync(request, HttpResponse.BodyHandlers.ofString()).whenCompleteAsync((response, throwable) -> { Throwable cause = (throwable instanceof java.util.concurrent.CompletionException) ? throwable.getCause() : throwable; if (retry && cause instanceof java.io.IOException && !(cause instanceof java.net.http.HttpTimeoutException) && !call.result.isDone()) { send(call, json, false); return; } this.inFlight--; complete(call, response, cause); drain(); }this.executor);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ private void complete(Call call, @Nullable HttpResponse<String> response, @Nullable Throwable cause) {
/* 126 */ if (cause != null) {
/* 127 */ call.result.completeExceptionally(cause);
/* */
/* */ return;
/* */ }
/* 131 */ if (response.statusCode() < 200 || response.statusCode() > 299) {
/* 132 */ MinehutFilter.getInstance().getLogger().warning("failed to filter message (" + response.statusCode() + "): " + (String)response.body());
/* 133 */ call.result.complete(null);
/* */
/* */ return;
/* */ }
/* */ try {
/* 138 */ call.result.complete((FilterResponse)GSON.fromJson(response.body(), FilterResponse.class));
/* 139 */ } catch (RuntimeException exception) {
/* 140 */ call.result.completeExceptionally(exception);
/* */ }
/* */ }
/* */
/* */ public void shutdown() {
/* 145 */ this.executor.shutdownNow();
/* */
/* */ try {
/* 148 */ HttpClient.class.getMethod("shutdownNow", new Class[0]).invoke(this.client, new Object[0]);
/* 149 */ } catch (ReflectiveOperationException reflectiveOperationException) {}
/* */ }
/* */ private static final class Call extends Record { private final FilterRequest body; private final long deadline; private final CompletableFuture<FilterResponse> result;
/* */
/* 153 */ public CompletableFuture<FilterResponse> result() { return this.result; } public long deadline() { return this.deadline; } public FilterRequest body() { return this.body; } public final boolean equals(Object o) { // Byte code:
/* */ // 0: aload_0
/* */ // 1: aload_1
/* */ // 2: <illegal opcode> equals : (Lcom/minehut/filterplugin/api/FilterAPI$Call;Ljava/lang/Object;)Z
/* */ // 7: ireturn
/* */ // Line number table:
/* */ // Java source line number -> byte code offset
/* */ // #153 -> 0
/* */ // Local variable table:
/* */ // start length slot name descriptor
/* */ // 0 8 0 this Lcom/minehut/filterplugin/api/FilterAPI$Call;
/* 153 */ // 0 8 1 o Ljava/lang/Object; } private Call(FilterRequest body, long deadline, CompletableFuture<FilterResponse> result) { this.body = body; this.deadline = deadline; this.result = result; }
/* */ public final int hashCode() { // Byte code:
/* */ // 0: aload_0
/* */ // 1: <illegal opcode> hashCode : (Lcom/minehut/filterplugin/api/FilterAPI$Call;)I
/* */ // 6: ireturn
/* */ // Line number table:
/* */ // Java source line number -> byte code offset
/* */ // #153 -> 0
/* */ // Local variable table:
/* */ // start length slot name descriptor
/* */ // 0 7 0 this Lcom/minehut/filterplugin/api/FilterAPI$Call; }
/* */ public final String toString() { // Byte code:
/* */ // 0: aload_0
/* */ // 1: <illegal opcode> toString : (Lcom/minehut/filterplugin/api/FilterAPI$Call;)Ljava/lang/String;
/* */ // 6: areturn
/* */ // Line number table:
/* */ // Java source line number -> byte code offset
/* */ // #153 -> 0
/* */ // Local variable table:
/* */ // start length slot name descriptor
/* 155 */ // 0 7 0 this Lcom/minehut/filterplugin/api/FilterAPI$Call; } private Call(FilterRequest body, long deadline) { this(body, deadline, new CompletableFuture<>()); }
/* */ }
/* */
/* */ }
/* Location: C:\Users\Xiao\Downloads\MinehutFilter.jar!\com\minehut\filterplugin\api\FilterAPI.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.1.3
*/
@@ -0,0 +1,28 @@
/* */ package com.minehut.filterplugin.api;
/* */
/* */ import java.util.LinkedHashMap;
/* */ import java.util.Map;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ class null
/* */ extends LinkedHashMap<String, FilterCache.CachedResponse>
/* */ {
/* */ null(int arg0, float arg1, boolean arg2) {
/* 17 */ super(arg0, arg1, arg2);
/* */ }
/* */ protected boolean removeEldestEntry(Map.Entry<String, FilterCache.CachedResponse> eldest) {
/* 20 */ return (size() > 512);
/* */ }
/* */ }
/* Location: C:\Users\Xiao\Downloads\MinehutFilter.jar!\com\minehut\filterplugin\api\FilterCache$1.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.1.3
*/
@@ -0,0 +1,79 @@
/* */ package com.minehut.filterplugin.api;
/* */
/* */ import com.minehut.filterplugin.api.model.FilterResponse;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ final class CachedResponse
/* */ extends Record
/* */ {
/* */ private final FilterResponse response;
/* */ private final long expiresAt;
/* */
/* */ public final String toString() {
/* */ // Byte code:
/* */ // 0: aload_0
/* */ // 1: <illegal opcode> toString : (Lcom/minehut/filterplugin/api/FilterCache$CachedResponse;)Ljava/lang/String;
/* */ // 6: areturn
/* */ // Line number table:
/* */ // Java source line number -> byte code offset
/* */ // #42 -> 0
/* */ // Local variable table:
/* */ // start length slot name descriptor
/* */ // 0 7 0 this Lcom/minehut/filterplugin/api/FilterCache$CachedResponse;
/* */ }
/* */
/* */ public final int hashCode() {
/* */ // Byte code:
/* */ // 0: aload_0
/* */ // 1: <illegal opcode> hashCode : (Lcom/minehut/filterplugin/api/FilterCache$CachedResponse;)I
/* */ // 6: ireturn
/* */ // Line number table:
/* */ // Java source line number -> byte code offset
/* */ // #42 -> 0
/* */ // Local variable table:
/* */ // start length slot name descriptor
/* */ // 0 7 0 this Lcom/minehut/filterplugin/api/FilterCache$CachedResponse;
/* */ }
/* */
/* */ public final boolean equals(Object o) {
/* */ // Byte code:
/* */ // 0: aload_0
/* */ // 1: aload_1
/* */ // 2: <illegal opcode> equals : (Lcom/minehut/filterplugin/api/FilterCache$CachedResponse;Ljava/lang/Object;)Z
/* */ // 7: ireturn
/* */ // Line number table:
/* */ // Java source line number -> byte code offset
/* */ // #42 -> 0
/* */ // Local variable table:
/* */ // start length slot name descriptor
/* */ // 0 8 0 this Lcom/minehut/filterplugin/api/FilterCache$CachedResponse;
/* */ // 0 8 1 o Ljava/lang/Object;
/* */ }
/* */
/* */ private CachedResponse(FilterResponse response, long expiresAt) {
/* 42 */ this.response = response; this.expiresAt = expiresAt; } public FilterResponse response() { return this.response; } public long expiresAt() { return this.expiresAt; }
/* */
/* */ }
/* Location: C:\Users\Xiao\Downloads\MinehutFilter.jar!\com\minehut\filterplugin\api\FilterCache$CachedResponse.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.1.3
*/
@@ -0,0 +1,80 @@
/* */ package com.minehut.filterplugin.api;
/* */
/* */ import com.minehut.filterplugin.api.model.FilterResponse;
/* */ import java.util.Collections;
/* */ import java.util.LinkedHashMap;
/* */ import java.util.Map;
/* */ import java.util.concurrent.TimeUnit;
/* */ import org.jetbrains.annotations.Nullable;
/* */
/* */
/* */ public final class FilterCache
/* */ {
/* */ private static final int MAX_ENTRIES = 512;
/* */ private static final int MAX_CONTENT_LENGTH = 2048;
/* 15 */ private static final long EXPIRY_MILLIS = TimeUnit.MINUTES.toMillis(5L);
/* */
/* 17 */ private final Map<String, CachedResponse> entries = Collections.synchronizedMap(new LinkedHashMap<String, CachedResponse>(512, 0.75F, true)
/* */ {
/* */ protected boolean removeEldestEntry(Map.Entry<String, FilterCache.CachedResponse> eldest) {
/* 20 */ return (size() > 512);
/* */ }
/* */ });
/* */ @Nullable
/* */ public FilterResponse get(String content) {
/* 25 */ CachedResponse entry = this.entries.get(content);
/* 26 */ if (entry == null) return null;
/* */
/* 28 */ if (entry.expiresAt() <= System.currentTimeMillis()) {
/* 29 */ this.entries.remove(content);
/* 30 */ return null;
/* */ }
/* */
/* 33 */ return entry.response();
/* */ }
/* */
/* */ public void put(String content, FilterResponse response) {
/* 37 */ if (content.length() > 2048)
/* */ return;
/* 39 */ this.entries.put(content, new CachedResponse(response, System.currentTimeMillis() + EXPIRY_MILLIS));
/* */ }
/* */ private static final class CachedResponse extends Record { private final FilterResponse response; private final long expiresAt;
/* 42 */ private CachedResponse(FilterResponse response, long expiresAt) { this.response = response; this.expiresAt = expiresAt; } public final String toString() { // Byte code:
/* */ // 0: aload_0
/* */ // 1: <illegal opcode> toString : (Lcom/minehut/filterplugin/api/FilterCache$CachedResponse;)Ljava/lang/String;
/* */ // 6: areturn
/* */ // Line number table:
/* */ // Java source line number -> byte code offset
/* */ // #42 -> 0
/* */ // Local variable table:
/* */ // start length slot name descriptor
/* 42 */ // 0 7 0 this Lcom/minehut/filterplugin/api/FilterCache$CachedResponse; } public FilterResponse response() { return this.response; } public final int hashCode() { // Byte code:
/* */ // 0: aload_0
/* */ // 1: <illegal opcode> hashCode : (Lcom/minehut/filterplugin/api/FilterCache$CachedResponse;)I
/* */ // 6: ireturn
/* */ // Line number table:
/* */ // Java source line number -> byte code offset
/* */ // #42 -> 0
/* */ // Local variable table:
/* */ // start length slot name descriptor
/* */ // 0 7 0 this Lcom/minehut/filterplugin/api/FilterCache$CachedResponse; } public final boolean equals(Object o) { // Byte code:
/* */ // 0: aload_0
/* */ // 1: aload_1
/* */ // 2: <illegal opcode> equals : (Lcom/minehut/filterplugin/api/FilterCache$CachedResponse;Ljava/lang/Object;)Z
/* */ // 7: ireturn
/* */ // Line number table:
/* */ // Java source line number -> byte code offset
/* */ // #42 -> 0
/* */ // Local variable table:
/* */ // start length slot name descriptor
/* */ // 0 8 0 this Lcom/minehut/filterplugin/api/FilterCache$CachedResponse;
/* 42 */ // 0 8 1 o Ljava/lang/Object; } public long expiresAt() { return this.expiresAt; }
/* */ }
/* */
/* */ }
/* Location: C:\Users\Xiao\Downloads\MinehutFilter.jar!\com\minehut\filterplugin\api\FilterCache.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.1.3
*/
@@ -0,0 +1,51 @@
/* */ package com.minehut.filterplugin.api;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public enum FilteredAction
/* */ {
/* 11 */ CHAT_MESSAGE("message"),
/* */
/* */
/* */
/* 15 */ ITEM_RENAME("item name"),
/* */
/* */
/* */
/* 19 */ EDIT_SIGN("sign"),
/* */
/* */
/* */
/* 23 */ EDIT_BOOK("book"),
/* */
/* */
/* */
/* 27 */ SIGN_BOOK("book title"),
/* */
/* */
/* */
/* 31 */ COMMAND("command");
/* */
/* */ private final String noun;
/* */
/* */ FilteredAction(String noun) {
/* 36 */ this.noun = noun;
/* */ }
/* */
/* */
/* */
/* */
/* */ public String noun() {
/* 43 */ return this.noun;
/* */ }
/* */ }
/* Location: C:\Users\Xiao\Downloads\MinehutFilter.jar!\com\minehut\filterplugin\api\FilteredAction.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.1.3
*/
@@ -0,0 +1,66 @@
/* */ package com.minehut.filterplugin.api.model;
/* */
/* */ import com.google.gson.annotations.SerializedName;
/* */ import java.util.UUID;
/* */
/* */ public class FilterRequest
/* */ {
/* */ @SerializedName("input")
/* */ private String input;
/* */ @SerializedName("username")
/* */ private String username;
/* */ @SerializedName("uuid")
/* */ private UUID uuid;
/* */ @SerializedName("serverName")
/* */ private String serverName;
/* */
/* */ public FilterRequest(String input, String username, UUID uuid, String serverName) {
/* 18 */ this.input = input;
/* 19 */ this.username = username;
/* 20 */ this.uuid = uuid;
/* 21 */ this.serverName = serverName;
/* */ }
/* */
/* */ public String getInput() {
/* 25 */ return this.input;
/* */ }
/* */
/* */ public void setInput(String input) {
/* 29 */ this.input = input;
/* */ }
/* */
/* */ public String getUsername() {
/* 33 */ return this.username;
/* */ }
/* */
/* */ public void setUsername(String username) {
/* 37 */ this.username = username;
/* */ }
/* */
/* */ public UUID getUuid() {
/* 41 */ return this.uuid;
/* */ }
/* */
/* */ public void setUuid(UUID uuid) {
/* 45 */ this.uuid = uuid;
/* */ }
/* */
/* */ public String getServerName() {
/* 49 */ return this.serverName;
/* */ }
/* */
/* */ public void setServerName(String serverName) {
/* 53 */ this.serverName = serverName;
/* */ }
/* */
/* */
/* */ public String toString() {
/* 58 */ return "FilterRequest{input='" + this.input + "', username='" + this.username + "', uuid=" + String.valueOf(this.uuid) + ", serverName='" + this.serverName + "'}";
/* */ }
/* */ }
/* Location: C:\Users\Xiao\Downloads\MinehutFilter.jar!\com\minehut\filterplugin\api\model\FilterRequest.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.1.3
*/
@@ -0,0 +1,86 @@
/* */ package com.minehut.filterplugin.api.model;
/* */
/* */ import com.google.gson.annotations.SerializedName;
/* */
/* */ public class FilterResponse {
/* */ @SerializedName("error")
/* */ private boolean error;
/* */ @SerializedName("errorReason")
/* */ private String errorReason;
/* */ @SerializedName("blocked")
/* */ private boolean blocked;
/* */ @SerializedName("blockedReason")
/* */ private String blockedReason;
/* */ @SerializedName("wasChanged")
/* */ private boolean wasChanged;
/* */ @SerializedName("output")
/* */ private String output;
/* */
/* */ public FilterResponse(boolean error, String errorReason, boolean blocked, String blockedReason, boolean wasChanged, String output) {
/* 20 */ this.error = error;
/* 21 */ this.errorReason = errorReason;
/* 22 */ this.blocked = blocked;
/* 23 */ this.blockedReason = blockedReason;
/* 24 */ this.wasChanged = wasChanged;
/* 25 */ this.output = output;
/* */ }
/* */
/* */ public boolean isError() {
/* 29 */ return this.error;
/* */ }
/* */
/* */ public void setError(boolean error) {
/* 33 */ this.error = error;
/* */ }
/* */
/* */ public String getErrorReason() {
/* 37 */ return this.errorReason;
/* */ }
/* */
/* */ public void setErrorReason(String errorReason) {
/* 41 */ this.errorReason = errorReason;
/* */ }
/* */
/* */ public boolean isBlocked() {
/* 45 */ return this.blocked;
/* */ }
/* */
/* */ public void setBlocked(boolean blocked) {
/* 49 */ this.blocked = blocked;
/* */ }
/* */
/* */ public String getBlockedReason() {
/* 53 */ return this.blockedReason;
/* */ }
/* */
/* */ public void setBlockedReason(String blockedReason) {
/* 57 */ this.blockedReason = blockedReason;
/* */ }
/* */
/* */ public boolean isWasChanged() {
/* 61 */ return this.wasChanged;
/* */ }
/* */
/* */ public void setWasChanged(boolean wasChanged) {
/* 65 */ this.wasChanged = wasChanged;
/* */ }
/* */
/* */ public String getOutput() {
/* 69 */ return this.output;
/* */ }
/* */
/* */ public void setOutput(String output) {
/* 73 */ this.output = output;
/* */ }
/* */
/* */
/* */ public String toString() {
/* 78 */ return "FilterResponse{error=" + this.error + ", errorReason=" + this.errorReason + ", blocked=" + this.blocked + ", blockedReason='" + this.blockedReason + "', wasChanged=" + this.wasChanged + ", output='" + this.output + "'}";
/* */ }
/* */ }
/* Location: C:\Users\Xiao\Downloads\MinehutFilter.jar!\com\minehut\filterplugin\api\model\FilterResponse.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.1.3
*/
@@ -0,0 +1,41 @@
/* */ package com.minehut.filterplugin.api.util;
/* */
/* */ import org.bukkit.entity.Player;
/* */
/* */ public final class FeatureSupport {
/* 6 */ public static final boolean HAS_ADVENTURE = isAudience();
/* 7 */ public static final boolean HAS_MINI_MESSAGE = isPresent("net.kyori.adventure.text.minimessage.MiniMessage");
/* 8 */ public static final boolean HAS_PAPER_CHAT = isPresent("io.papermc.paper.event.player.AsyncChatEvent");
/* 9 */ public static final boolean HAS_FOLIA = isPresent("io.papermc.paper.threadedregions.RegionizedServer");
/* 10 */ public static final boolean HAS_SIGN_SIDES = isPresent("org.bukkit.block.sign.Side");
/* */
/* */
/* */
/* */ private static boolean isAudience() {
/* */ try {
/* 16 */ Class<?> audience = Class.forName("net.kyori.adventure.audience.Audience", false, classLoader());
/* 17 */ return audience.isAssignableFrom(Player.class);
/* 18 */ } catch (ClassNotFoundException|LinkageError ignored) {
/* 19 */ return false;
/* */ }
/* */ }
/* */
/* */ private static boolean isPresent(String className) {
/* */ try {
/* 25 */ Class.forName(className, false, classLoader());
/* 26 */ return true;
/* 27 */ } catch (ClassNotFoundException|LinkageError ignored) {
/* 28 */ return false;
/* */ }
/* */ }
/* */
/* */ private static ClassLoader classLoader() {
/* 33 */ return FeatureSupport.class.getClassLoader();
/* */ }
/* */ }
/* Location: C:\Users\Xiao\Downloads\MinehutFilter.jar!\com\minehut\filterplugin\ap\\util\FeatureSupport.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.1.3
*/
@@ -0,0 +1,73 @@
/* */ package com.minehut.filterplugin.event;
/* */
/* */ import com.minehut.filterplugin.api.FilteredAction;
/* */ import com.minehut.filterplugin.api.model.FilterResponse;
/* */ import org.bukkit.entity.Player;
/* */ import org.bukkit.event.Cancellable;
/* */ import org.bukkit.event.Event;
/* */ import org.bukkit.event.HandlerList;
/* */ import org.jetbrains.annotations.NotNull;
/* */ import org.jetbrains.annotations.Nullable;
/* */
/* */ public final class MinehutFilteredMessageEvent extends Event implements Cancellable {
/* 13 */ private static final HandlerList HANDLERS = new HandlerList();
/* */
/* */ private final Player player;
/* */
/* */ private final boolean blocked;
/* */
/* */ private final String reason;
/* */
/* */ private final FilteredAction action;
/* */
/* */ private boolean cancelled;
/* */
/* */ public MinehutFilteredMessageEvent(@NotNull Player player, @Nullable FilterResponse response, @NotNull FilteredAction action) {
/* 26 */ super(!player.getServer().isPrimaryThread());
/* 27 */ this.player = player;
/* 28 */ this.blocked = (response != null && response.isBlocked());
/* 29 */ this.reason = (response != null && response.getBlockedReason() != null) ? response.getBlockedReason() : "";
/* 30 */ this.action = action;
/* */ }
/* */ @NotNull
/* */ public Player getPlayer() {
/* 34 */ return this.player;
/* */ }
/* */
/* */ public boolean isBlocked() {
/* 38 */ return this.blocked;
/* */ }
/* */
/* */ public String getReason() {
/* 42 */ return this.reason;
/* */ }
/* */
/* */ public FilteredAction getAction() {
/* 46 */ return this.action;
/* */ }
/* */
/* */
/* */ public HandlerList getHandlers() {
/* 51 */ return HANDLERS;
/* */ }
/* */
/* */ public static HandlerList getHandlerList() {
/* 55 */ return HANDLERS;
/* */ }
/* */
/* */
/* */ public boolean isCancelled() {
/* 60 */ return this.cancelled;
/* */ }
/* */
/* */
/* */ public void setCancelled(boolean cancelled) {
/* 65 */ this.cancelled = cancelled;
/* */ }
/* */ }
/* Location: C:\Users\Xiao\Downloads\MinehutFilter.jar!\com\minehut\filterplugin\event\MinehutFilteredMessageEvent.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.1.3
*/
@@ -0,0 +1,126 @@
/* */ package com.minehut.filterplugin.listener;
/* */
/* */ import com.minehut.filterplugin.MinehutFilter;
/* */ import com.minehut.filterplugin.api.FilteredAction;
/* */ import java.util.concurrent.CompletableFuture;
/* */ import java.util.concurrent.CompletionStage;
/* */ import org.bukkit.ChatColor;
/* */ import org.bukkit.Material;
/* */ import org.bukkit.entity.Player;
/* */ import org.bukkit.event.Event;
/* */ import org.bukkit.event.EventHandler;
/* */ import org.bukkit.event.EventPriority;
/* */ import org.bukkit.event.Listener;
/* */ import org.bukkit.event.player.PlayerEditBookEvent;
/* */ import org.bukkit.inventory.ItemStack;
/* */ import org.bukkit.inventory.PlayerInventory;
/* */ import org.bukkit.inventory.meta.BookMeta;
/* */ import org.bukkit.inventory.meta.ItemMeta;
/* */
/* */
/* */
/* */
/* */
/* */ public class BookListener
/* */ implements Listener
/* */ {
/* 27 */ private final ThreadLocal<Boolean> resending = ThreadLocal.withInitial(() -> Boolean.valueOf(false));
/* */
/* */ @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
/* */ private void onBookModified(PlayerEditBookEvent event) {
/* 31 */ if (((Boolean)this.resending.get()).booleanValue())
/* */ return;
/* 33 */ MinehutFilter plugin = MinehutFilter.getInstance();
/* 34 */ Player player = event.getPlayer();
/* 35 */ BookMeta meta = event.getNewBookMeta();
/* 36 */ boolean signing = (event.isSigning() && meta.hasTitle());
/* */
/* 38 */ BookMeta previous = event.getPreviousBookMeta();
/* 39 */ String oldContent = ChatColor.stripColor(String.join(" ", previous.getPages()));
/* 40 */ String newContent = ChatColor.stripColor(String.join(" ", meta.getPages()));
/* */
/* */
/* 43 */ if (!signing && oldContent.equals(newContent))
/* */ return;
/* 45 */ CompletableFuture<Boolean> verdict = verify(plugin, player, meta, signing, newContent);
/* 46 */ if (verdict.isDone()) {
/* 47 */ boolean allowed = ((Boolean)verdict.join()).booleanValue();
/* 48 */ event.setCancelled(!allowed);
/* */
/* */ return;
/* */ }
/* 52 */ event.setCancelled(true);
/* */
/* 54 */ int slot = event.getSlot();
/* 55 */ boolean signed = event.isSigning();
/* 56 */ verdict.thenAccept(allowed -> {
/* */ if (!allowed.booleanValue()) {
/* */ return;
/* */ }
/* */ plugin.getScheduler().run(player, ());
/* */ });
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ private CompletableFuture<Boolean> verify(MinehutFilter plugin, Player player, BookMeta meta, boolean signing, String content) {
/* 70 */ if (!signing) {
/* 71 */ return verifyContent(plugin, player, content);
/* */ }
/* */
/* 74 */ return plugin.allows(player, meta.getTitle(), FilteredAction.SIGN_BOOK).thenCompose(allowed -> !allowed.booleanValue() ? CompletableFuture.completedFuture(Boolean.valueOf(false)) : verifyContent(plugin, player, content));
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ private CompletableFuture<Boolean> verifyContent(MinehutFilter plugin, Player player, String content) {
/* 85 */ if (content.isBlank()) {
/* 86 */ return CompletableFuture.completedFuture(Boolean.valueOf(true));
/* */ }
/* */
/* 89 */ return plugin.allows(player, content, FilteredAction.EDIT_BOOK);
/* */ }
/* */
/* */ private void resend(Player player, int slot, BookMeta previous, BookMeta meta, boolean signing) {
/* 93 */ if (!player.isOnline()) {
/* */ return;
/* */ }
/* 96 */ PlayerInventory inventory = player.getInventory();
/* 97 */ ItemStack book = (slot == -1) ? inventory.getItemInOffHand() : inventory.getItem(slot);
/* 98 */ if (book == null || book.getType() != Material.WRITABLE_BOOK)
/* */ return;
/* 100 */ ItemMeta itemMeta = book.getItemMeta(); if (itemMeta instanceof BookMeta) { BookMeta current = (BookMeta)itemMeta; if (current.getPages().equals(previous.getPages())) {
/* */
/* 102 */ PlayerEditBookEvent event = new PlayerEditBookEvent(player, slot, previous, meta, signing);
/* 103 */ this.resending.set(Boolean.valueOf(true));
/* */ try {
/* 105 */ player.getServer().getPluginManager().callEvent((Event)event);
/* */ } finally {
/* 107 */ this.resending.set(Boolean.valueOf(false));
/* */ }
/* 109 */ if (event.isCancelled())
/* */ return;
/* 111 */ if (event.isSigning()) {
/* 112 */ book.setType(Material.WRITTEN_BOOK);
/* */ }
/* */
/* 115 */ book.setItemMeta((ItemMeta)event.getNewBookMeta());
/* */ return;
/* */ } }
/* */
/* */ }
/* */ }
/* Location: C:\Users\Xiao\Downloads\MinehutFilter.jar!\com\minehut\filterplugin\listener\BookListener.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.1.3
*/
@@ -0,0 +1,139 @@
/* */ package com.minehut.filterplugin.listener;
/* */
/* */ import com.minehut.filterplugin.MinehutFilter;
/* */ import com.minehut.filterplugin.api.FilteredAction;
/* */ import com.minehut.filterplugin.scheduling.FilterScheduler;
/* */ import java.util.Arrays;
/* */ import java.util.Collection;
/* */ import java.util.List;
/* */ import java.util.Locale;
/* */ import java.util.Map;
/* */ import java.util.Set;
/* */ import java.util.UUID;
/* */ import java.util.concurrent.CompletableFuture;
/* */ import java.util.concurrent.ConcurrentHashMap;
/* */ import java.util.stream.Collectors;
/* */ import org.bukkit.entity.Player;
/* */ import org.bukkit.event.EventHandler;
/* */ import org.bukkit.event.EventPriority;
/* */ import org.bukkit.event.Listener;
/* */ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
/* */ import org.jetbrains.annotations.Nullable;
/* */
/* */ public class CommandListener
/* */ implements Listener {
/* 25 */ public static final List<String> DEFAULT_COMMANDS = List.of(new String[] { "/nick", "/nickname", "/w", "/say", "/me", "/msg", "/tell", "/teammsg", "/tm", "/r", "/reply", "/m", "/t", "/pm", "/whisper", "/etell", "/broadcast", "/bc", "/rename", "/itemname" });
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* 50 */ public static final List<String> ADDED_IN_CONFIG_VERSION_2 = DEFAULT_COMMANDS.subList(6, DEFAULT_COMMANDS.size());
/* */
/* */ private final Set<String> commands;
/* */
/* 54 */ private final Map<UUID, String> approved = new ConcurrentHashMap<>();
/* */
/* */ public CommandListener(Collection<String> commands) {
/* 57 */ this
/* */
/* 59 */ .commands = (Set<String>)commands.stream().map(CommandListener::normalize).collect(Collectors.toUnmodifiableSet());
/* */ }
/* */
/* */
/* */ @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
/* */ private void onCommand(PlayerCommandPreprocessEvent event) {
/* 65 */ Player player = event.getPlayer();
/* 66 */ if (this.approved.remove(player.getUniqueId()) != null)
/* */ return;
/* 68 */ String message = event.getMessage();
/* */
/* 70 */ if (!this.commands.contains(normalize(message.substring(1, labelEnd(message)))))
/* */ return;
/* 72 */ String[] parts = message.substring(1).split("\\s+");
/* 73 */ String content = content(player, parts);
/* 74 */ if (content == null)
/* */ return;
/* 76 */ MinehutFilter plugin = MinehutFilter.getInstance();
/* 77 */ CompletableFuture<Boolean> verdict = plugin.allows(player, content, FilteredAction.COMMAND);
/* 78 */ if (verdict.isDone()) {
/* 79 */ boolean allowed = ((Boolean)verdict.join()).booleanValue();
/* 80 */ event.setCancelled(!allowed);
/* */
/* */ return;
/* */ }
/* 84 */ event.setCancelled(true);
/* */
/* 86 */ FilterScheduler scheduler = plugin.getScheduler();
/* 87 */ verdict.thenAccept(allowed -> {
/* */ if (!allowed.booleanValue())
/* */ return;
/* */ scheduler.run(player, ());
/* */ });
/* */ }
/* */ @Nullable
/* */ private String content(Player player, String[] parts) {
/* 95 */ if (parts.length < 2) return null;
/* */
/* 97 */ boolean targeted = (player.getServer().getPlayerExact(parts[1]) != null);
/* 98 */ int start = targeted ? 2 : 1;
/* 99 */ if (parts.length <= start) return null;
/* */
/* 101 */ return String.join(" ", Arrays.<CharSequence>copyOfRange((CharSequence[])parts, start, parts.length));
/* */ }
/* */
/* */
/* */ private void dispatch(Player player, String message) {
/* 106 */ if (!player.isOnline())
/* */ return;
/* 108 */ UUID uuid = player.getUniqueId();
/* 109 */ this.approved.put(uuid, message);
/* */ try {
/* 111 */ player.chat(message);
/* */ } finally {
/* 113 */ this.approved.remove(uuid, message);
/* */ }
/* */ }
/* */
/* */
/* */ private static int labelEnd(String message) {
/* 119 */ for (int index = 1; index < message.length(); index++) {
/* 120 */ char character = message.charAt(index);
/* 121 */ if (character == ' ' || (character >= '\t' && character <= '\r')) return index;
/* */ }
/* 123 */ return message.length();
/* */ }
/* */
/* */ private static String normalize(String command) {
/* 127 */ String label = command.startsWith("/") ? command.substring(1) : command;
/* 128 */ int namespace = label.indexOf(':');
/* 129 */ String name = (namespace == -1) ? label : label.substring(namespace + 1);
/* */
/* 131 */ return name.toLowerCase(Locale.ROOT);
/* */ }
/* */ }
/* Location: C:\Users\Xiao\Downloads\MinehutFilter.jar!\com\minehut\filterplugin\listener\CommandListener.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.1.3
*/
@@ -0,0 +1,110 @@
/* */ package com.minehut.filterplugin.listener;
/* */
/* */ import com.minehut.filterplugin.MinehutFilter;
/* */ import com.minehut.filterplugin.api.FilteredAction;
/* */ import com.minehut.filterplugin.scheduling.FilterScheduler;
/* */ import java.util.Map;
/* */ import java.util.UUID;
/* */ import java.util.concurrent.CompletableFuture;
/* */ import java.util.concurrent.ConcurrentHashMap;
/* */ import org.bukkit.ChatColor;
/* */ import org.bukkit.entity.HumanEntity;
/* */ import org.bukkit.entity.Player;
/* */ import org.bukkit.event.EventHandler;
/* */ import org.bukkit.event.EventPriority;
/* */ import org.bukkit.event.Listener;
/* */ import org.bukkit.event.inventory.InventoryClickEvent;
/* */ import org.bukkit.event.inventory.InventoryCloseEvent;
/* */ import org.bukkit.event.inventory.InventoryType;
/* */ import org.bukkit.event.inventory.PrepareAnvilEvent;
/* */ import org.bukkit.inventory.Inventory;
/* */ import org.bukkit.inventory.ItemStack;
/* */ import org.bukkit.inventory.meta.ItemMeta;
/* */ import org.jetbrains.annotations.Nullable;
/* */
/* */ public class ItemListener
/* */ implements Listener
/* */ {
/* */ private static final long PREFETCH_DELAY_TICKS = 8L;
/* 29 */ private final Map<UUID, String> pendingNames = new ConcurrentHashMap<>();
/* */ @EventHandler(priority = EventPriority.MONITOR)
/* */ private void onRenameTyped(PrepareAnvilEvent event) {
/* */ Player player;
/* 33 */ HumanEntity humanEntity = event.getView().getPlayer(); if (humanEntity instanceof Player) { player = (Player)humanEntity; }
/* */ else { return; }
/* 35 */ String customName = renamedTo((Inventory)event.getInventory(), event.getResult());
/* 36 */ if (customName == null)
/* */ return;
/* 38 */ this.pendingNames.put(player.getUniqueId(), customName);
/* */
/* 40 */ FilterScheduler scheduler = MinehutFilter.getInstance().getScheduler();
/* 41 */ scheduler.runLater(player, 8L, () -> prefetch(player, customName));
/* */ }
/* */ @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
/* */ private void onItemRename(InventoryClickEvent event) {
/* */ Player player;
/* 46 */ Inventory inventory = event.getInventory();
/* 47 */ if (inventory.getType() != InventoryType.ANVIL)
/* 48 */ return; if (event.getSlotType() != InventoryType.SlotType.RESULT)
/* 49 */ return; HumanEntity humanEntity = event.getWhoClicked(); if (humanEntity instanceof Player) { player = (Player)humanEntity; }
/* */ else { return; }
/* 51 */ String customName = renamedTo(inventory, event.getCurrentItem());
/* 52 */ if (customName == null)
/* */ return;
/* 54 */ MinehutFilter plugin = MinehutFilter.getInstance();
/* 55 */ CompletableFuture<Boolean> verdict = plugin.allows(player, customName, FilteredAction.ITEM_RENAME);
/* 56 */ boolean allowed = (verdict.isDone() && ((Boolean)verdict.join()).booleanValue());
/* 57 */ if (allowed)
/* */ return;
/* 59 */ event.setCancelled(true);
/* */
/* 61 */ FilterScheduler scheduler = plugin.getScheduler();
/* 62 */ scheduler.run(player, () -> resync(player));
/* */ }
/* */
/* */ @EventHandler
/* */ private void onAnvilClose(InventoryCloseEvent event) {
/* 67 */ Inventory inventory = event.getInventory();
/* 68 */ if (inventory.getType() != InventoryType.ANVIL)
/* */ return;
/* 70 */ this.pendingNames.remove(event.getPlayer().getUniqueId());
/* */ }
/* */
/* */ private void prefetch(Player player, String customName) {
/* 74 */ if (!this.pendingNames.remove(player.getUniqueId(), customName))
/* 75 */ return; if (!player.isOnline())
/* */ return;
/* 77 */ MinehutFilter.getInstance().filter(player, customName);
/* */ }
/* */
/* */ private void resync(Player player) {
/* 81 */ if (!player.isOnline())
/* */ return;
/* 83 */ player.updateInventory();
/* 84 */ player.sendExperienceChange(player.getExp(), player.getLevel());
/* */ }
/* */
/* */ @Nullable
/* */ private String renamedTo(Inventory anvil, @Nullable ItemStack result) {
/* 89 */ String name = customName(result);
/* 90 */ if (name == null || name.isBlank()) return null;
/* 91 */ if (name.equals(customName(anvil.getItem(0)))) return null;
/* */
/* 93 */ return name;
/* */ }
/* */ @Nullable
/* */ private String customName(@Nullable ItemStack itemStack) {
/* 97 */ if (itemStack == null) return null;
/* */
/* 99 */ ItemMeta meta = itemStack.getItemMeta();
/* 100 */ if (meta == null || !meta.hasDisplayName()) return null;
/* */
/* 102 */ return ChatColor.stripColor(meta.getDisplayName());
/* */ }
/* */ }
/* Location: C:\Users\Xiao\Downloads\MinehutFilter.jar!\com\minehut\filterplugin\listener\ItemListener.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.1.3
*/
@@ -0,0 +1,119 @@
/* */ package com.minehut.filterplugin.listener;
/* */
/* */ import org.bukkit.block.Block;
/* */ import org.bukkit.block.Sign;
/* */ import org.bukkit.block.sign.Side;
/* */ import org.bukkit.entity.Player;
/* */ import org.bukkit.event.block.SignChangeEvent;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ final class SignSides
/* */ {
/* */ private static Object side(SignChangeEvent event) {
/* 99 */ return event.getSide();
/* */ }
/* */
/* */ private static SignChangeEvent event(Block block, Player player, String[] lines, Object side) {
/* 103 */ return new SignChangeEvent(block, player, lines, (Side)side);
/* */ }
/* */
/* */ private static String[] lines(Sign sign, Object side) {
/* 107 */ return sign.getSide((Side)side).getLines();
/* */ }
/* */
/* */ private static void setLine(Sign sign, Object side, int index, String line) {
/* 111 */ sign.getSide((Side)side).setLine(index, line);
/* */ }
/* */ }
/* Location: C:\Users\Xiao\Downloads\MinehutFilter.jar!\com\minehut\filterplugin\listener\SignListener$SignSides.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.1.3
*/
@@ -0,0 +1,120 @@
/* */ package com.minehut.filterplugin.listener;
/* */
/* */ import com.minehut.filterplugin.MinehutFilter;
/* */ import com.minehut.filterplugin.api.FilteredAction;
/* */ import com.minehut.filterplugin.api.util.FeatureSupport;
/* */ import java.util.Arrays;
/* */ import java.util.concurrent.CompletableFuture;
/* */ import org.bukkit.ChatColor;
/* */ import org.bukkit.block.Block;
/* */ import org.bukkit.block.BlockState;
/* */ import org.bukkit.block.Sign;
/* */ import org.bukkit.block.sign.Side;
/* */ import org.bukkit.entity.Player;
/* */ import org.bukkit.event.Event;
/* */ import org.bukkit.event.EventHandler;
/* */ import org.bukkit.event.EventPriority;
/* */ import org.bukkit.event.Listener;
/* */ import org.bukkit.event.block.SignChangeEvent;
/* */ import org.jetbrains.annotations.Nullable;
/* */
/* */
/* */
/* */
/* */ public class SignListener
/* */ implements Listener
/* */ {
/* 27 */ private final ThreadLocal<Boolean> resending = ThreadLocal.withInitial(() -> Boolean.valueOf(false));
/* */
/* */ @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
/* */ private void onSignChange(SignChangeEvent event) {
/* 31 */ if (((Boolean)this.resending.get()).booleanValue())
/* */ return;
/* 33 */ MinehutFilter plugin = MinehutFilter.getInstance();
/* 34 */ String[] lines = (String[])event.getLines().clone();
/* 35 */ String content = ChatColor.stripColor(String.join(" ", (CharSequence[])lines));
/* 36 */ if (content.isBlank())
/* */ return;
/* 38 */ Player player = event.getPlayer();
/* 39 */ CompletableFuture<Boolean> verdict = plugin.allows(player, content, FilteredAction.EDIT_SIGN);
/* 40 */ if (verdict.isDone()) {
/* 41 */ boolean allowed = ((Boolean)verdict.join()).booleanValue();
/* 42 */ event.setCancelled(!allowed);
/* */
/* */ return;
/* */ }
/* 46 */ Block block = event.getBlock();
/* 47 */ Object side = FeatureSupport.HAS_SIGN_SIDES ? SignSides.side(event) : null;
/* 48 */ String[] previous = currentLines(block, side);
/* 49 */ if (previous == null)
/* */ return;
/* 51 */ event.setCancelled(true);
/* */
/* 53 */ verdict.thenAccept(allowed -> {
/* */ if (!allowed.booleanValue())
/* */ return;
/* */ plugin.getScheduler().run(block, ());
/* */ });
/* */ }
/* */ private void resend(Block block, @Nullable Object side, Player player, String[] previous, String[] lines) {
/* */ Sign sign;
/* 61 */ if (!player.isOnline())
/* */ return;
/* 63 */ BlockState state = block.getState();
/* 64 */ if (state instanceof Sign) { sign = (Sign)state; }
/* */ else { return; }
/* 66 */ if (!Arrays.equals((Object[])currentLines(block, side), (Object[])previous))
/* */ return;
/* 68 */ SignChangeEvent event = (side != null) ? SignSides.event(block, player, lines, side) : new SignChangeEvent(block, player, lines);
/* 69 */ this.resending.set(Boolean.valueOf(true));
/* */ try {
/* 71 */ player.getServer().getPluginManager().callEvent((Event)event);
/* */ } finally {
/* 73 */ this.resending.set(Boolean.valueOf(false));
/* */ }
/* 75 */ if (event.isCancelled())
/* */ return;
/* 77 */ for (int index = 0; index < lines.length; index++) {
/* 78 */ if (side != null) {
/* 79 */ SignSides.setLine(sign, side, index, event.getLine(index));
/* */ } else {
/* 81 */ sign.setLine(index, event.getLine(index));
/* */ }
/* */ }
/* */
/* 85 */ sign.update();
/* */ } @Nullable
/* */ private String[] currentLines(Block block, @Nullable Object side) {
/* */ Sign sign;
/* 89 */ BlockState state = block.getState();
/* 90 */ if (state instanceof Sign) { sign = (Sign)state; } else { return null; }
/* */
/* 92 */ if (side != null) return (String[])SignSides.lines(sign, side).clone();
/* 93 */ return (String[])sign.getLines().clone();
/* */ }
/* */
/* */ private static final class SignSides
/* */ {
/* */ private static Object side(SignChangeEvent event) {
/* 99 */ return event.getSide();
/* */ }
/* */
/* */ private static SignChangeEvent event(Block block, Player player, String[] lines, Object side) {
/* 103 */ return new SignChangeEvent(block, player, lines, (Side)side);
/* */ }
/* */
/* */ private static String[] lines(Sign sign, Object side) {
/* 107 */ return sign.getSide((Side)side).getLines();
/* */ }
/* */
/* */ private static void setLine(Sign sign, Object side, int index, String line) {
/* 111 */ sign.getSide((Side)side).setLine(index, line);
/* */ }
/* */ }
/* */ }
/* Location: C:\Users\Xiao\Downloads\MinehutFilter.jar!\com\minehut\filterplugin\listener\SignListener.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.1.3
*/
@@ -0,0 +1,43 @@
/* */ package com.minehut.filterplugin.listener.chat;
/* */
/* */ import com.minehut.filterplugin.MinehutFilter;
/* */ import com.minehut.filterplugin.api.FilteredAction;
/* */ import io.papermc.paper.event.player.AsyncChatEvent;
/* */ import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
/* */ import org.bukkit.ChatColor;
/* */ import org.bukkit.event.EventHandler;
/* */ import org.bukkit.event.EventPriority;
/* */ import org.bukkit.event.Listener;
/* */
/* */ public class PaperChatListener
/* */ implements Listener {
/* 14 */ private final SyncChatFilter syncChat = new SyncChatFilter();
/* */
/* */ @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
/* */ public void onAsyncChat(AsyncChatEvent event) {
/* 18 */ if (!event.isAsynchronous())
/* */ return;
/* 20 */ MinehutFilter plugin = MinehutFilter.getInstance();
/* 21 */ String message = ChatColor.stripColor(PlainTextComponentSerializer.plainText().serialize(event.message()));
/* */
/* 23 */ boolean allowed = ((Boolean)plugin.allows(event.getPlayer(), message, FilteredAction.CHAT_MESSAGE).join()).booleanValue();
/* 24 */ if (allowed)
/* */ return;
/* 26 */ event.setCancelled(true);
/* */ }
/* */
/* */ @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
/* */ public void onSyncChat(AsyncChatEvent event) {
/* 31 */ if (event.isAsynchronous())
/* */ return;
/* 33 */ String original = PlainTextComponentSerializer.plainText().serialize(event.message());
/* 34 */ if (this.syncChat.hold(event.getPlayer(), original, ChatColor.stripColor(original)))
/* 35 */ event.setCancelled(true);
/* */ }
/* */ }
/* Location: C:\Users\Xiao\Downloads\MinehutFilter.jar!\com\minehut\filterplugin\listener\chat\PaperChatListener.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.1.3
*/
@@ -0,0 +1,41 @@
/* */ package com.minehut.filterplugin.listener.chat;
/* */
/* */ import com.minehut.filterplugin.MinehutFilter;
/* */ import com.minehut.filterplugin.api.FilteredAction;
/* */ import org.bukkit.ChatColor;
/* */ import org.bukkit.event.EventHandler;
/* */ import org.bukkit.event.EventPriority;
/* */ import org.bukkit.event.Listener;
/* */ import org.bukkit.event.player.AsyncPlayerChatEvent;
/* */
/* */ public class SpigotChatListener
/* */ implements Listener {
/* 13 */ private final SyncChatFilter syncChat = new SyncChatFilter();
/* */
/* */ @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
/* */ public void onAsyncChat(AsyncPlayerChatEvent event) {
/* 17 */ if (!event.isAsynchronous())
/* */ return;
/* 19 */ MinehutFilter plugin = MinehutFilter.getInstance();
/* 20 */ String message = ChatColor.stripColor(event.getMessage());
/* */
/* 22 */ boolean allowed = ((Boolean)plugin.allows(event.getPlayer(), message, FilteredAction.CHAT_MESSAGE).join()).booleanValue();
/* 23 */ if (allowed)
/* */ return;
/* 25 */ event.setCancelled(true);
/* */ }
/* */
/* */ @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
/* */ public void onSyncChat(AsyncPlayerChatEvent event) {
/* 30 */ if (event.isAsynchronous())
/* */ return;
/* 32 */ if (this.syncChat.hold(event.getPlayer(), event.getMessage(), ChatColor.stripColor(event.getMessage())))
/* 33 */ event.setCancelled(true);
/* */ }
/* */ }
/* Location: C:\Users\Xiao\Downloads\MinehutFilter.jar!\com\minehut\filterplugin\listener\chat\SpigotChatListener.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.1.3
*/
@@ -0,0 +1,55 @@
/* */ package com.minehut.filterplugin.listener.chat;
/* */
/* */ import com.minehut.filterplugin.MinehutFilter;
/* */ import com.minehut.filterplugin.api.FilteredAction;
/* */ import java.util.Map;
/* */ import java.util.UUID;
/* */ import java.util.concurrent.CompletableFuture;
/* */ import java.util.concurrent.ConcurrentHashMap;
/* */ import org.bukkit.entity.Player;
/* */
/* */
/* */
/* */
/* */
/* */
/* */ final class SyncChatFilter
/* */ {
/* 18 */ private final Map<UUID, String> approved = new ConcurrentHashMap<>();
/* */
/* */
/* */
/* */
/* */ boolean hold(Player player, String original, String content) {
/* 24 */ if (this.approved.remove(player.getUniqueId()) != null) return false;
/* */
/* 26 */ MinehutFilter plugin = MinehutFilter.getInstance();
/* 27 */ CompletableFuture<Boolean> verdict = plugin.allows(player, content, FilteredAction.CHAT_MESSAGE);
/* 28 */ if (verdict.isDone()) return !((Boolean)verdict.join()).booleanValue();
/* */
/* 30 */ verdict.thenAccept(allowed -> {
/* */ if (!allowed.booleanValue())
/* */ return;
/* */ plugin.getScheduler().run(player, ());
/* */ });
/* 35 */ return true;
/* */ }
/* */
/* */ private void send(Player player, String message) {
/* 39 */ if (!player.isOnline())
/* */ return;
/* 41 */ UUID uuid = player.getUniqueId();
/* 42 */ this.approved.put(uuid, message);
/* */ try {
/* 44 */ player.chat(message);
/* */ } finally {
/* 46 */ this.approved.remove(uuid, message);
/* */ }
/* */ }
/* */ }
/* Location: C:\Users\Xiao\Downloads\MinehutFilter.jar!\com\minehut\filterplugin\listener\chat\SyncChatFilter.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.1.3
*/
@@ -0,0 +1,26 @@
/* */ package com.minehut.filterplugin.messaging;
/* */
/* */ import net.kyori.adventure.text.Component;
/* */ import net.kyori.adventure.text.TextComponent;
/* */ import net.kyori.adventure.text.format.NamedTextColor;
/* */ import net.kyori.adventure.text.format.TextColor;
/* */ import net.kyori.adventure.text.format.TextDecoration;
/* */ import org.bukkit.entity.Player;
/* */ import org.jetbrains.annotations.NotNull;
/* */
/* */ public final class AdventureMessenger implements FilterMessenger {
/* */ public void sendBlocked(Player player, @NotNull String reason) {
/* 13 */ player.sendMessage(((TextComponent)((TextComponent)((TextComponent)((TextComponent)Component.empty()
/* 14 */ .append((Component)Component.text("Minehut", (TextColor)NamedTextColor.AQUA)))
/* 15 */ .append((Component)Component.text(" | ", (TextColor)NamedTextColor.DARK_GRAY)))
/* 16 */ .append((Component)Component.text("Your content has been blocked for the following: \"", (TextColor)NamedTextColor.GRAY)))
/* 17 */ .append(((TextComponent)Component.text(reason).color((TextColor)NamedTextColor.RED)).decorate(TextDecoration.UNDERLINED)))
/* 18 */ .append((Component)Component.text("\"", (TextColor)NamedTextColor.GRAY)));
/* */ }
/* */ }
/* Location: C:\Users\Xiao\Downloads\MinehutFilter.jar!\com\minehut\filterplugin\messaging\AdventureMessenger.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.1.3
*/
@@ -0,0 +1,49 @@
/* */ package com.minehut.filterplugin.messaging;
/* */
/* */ import com.minehut.filterplugin.api.FilteredAction;
/* */ import com.minehut.filterplugin.api.model.FilterResponse;
/* */ import com.minehut.filterplugin.event.MinehutFilteredMessageEvent;
/* */ import java.util.Objects;
/* */ import org.bukkit.ChatColor;
/* */ import org.bukkit.entity.Player;
/* */ import org.bukkit.event.Event;
/* */ import org.jetbrains.annotations.NotNull;
/* */ import org.jetbrains.annotations.Nullable;
/* */
/* */
/* */
/* */
/* */
/* */ public interface FilterMessenger
/* */ {
/* 19 */ public static final String ERROR_MESSAGE_FORMAT = ChatColor.translateAlternateColorCodes('&', "&bMinehut&8 | &7Your %s couldn't be checked by the chat filter right now, so it was blocked. Please try again in a moment.");
/* */
/* */ void sendBlocked(Player paramPlayer, @NotNull String paramString);
/* */
/* */ default void sendFilterMessage(Player player, @Nullable FilterResponse response, FilteredAction action) {
/* 24 */ if (response != null && !response.isError() && !response.isBlocked()) {
/* */ return;
/* */ }
/* */
/* */
/* 29 */ MinehutFilteredMessageEvent filterEvent = new MinehutFilteredMessageEvent(player, response, action);
/* */
/* 31 */ player.getServer().getPluginManager().callEvent((Event)filterEvent);
/* 32 */ if (filterEvent.isCancelled()) {
/* */ return;
/* */ }
/* 35 */ if (response == null || response.isError()) {
/* */
/* 37 */ player.sendMessage(ERROR_MESSAGE_FORMAT.formatted(new Object[] { action.noun() }));
/* */
/* */ return;
/* */ }
/* 41 */ sendBlocked(player, Objects.<String>requireNonNullElse(response.getBlockedReason(), ""));
/* */ }
/* */ }
/* Location: C:\Users\Xiao\Downloads\MinehutFilter.jar!\com\minehut\filterplugin\messaging\FilterMessenger.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.1.3
*/
@@ -0,0 +1,23 @@
/* */ package com.minehut.filterplugin.messaging;
/* */
/* */ import org.bukkit.ChatColor;
/* */ import org.bukkit.entity.Player;
/* */ import org.jetbrains.annotations.NotNull;
/* */
/* */ public final class LegacyMessenger
/* */ implements FilterMessenger
/* */ {
/* */ private static final String BLOCKED_MESSAGE_FORMAT = "&bMinehut&8 | &7Your content has been blocked for the following: \"&c&n<blocked>&r&7\"";
/* */
/* */ public void sendBlocked(Player player, @NotNull String reason) {
/* 13 */ String message = ChatColor.translateAlternateColorCodes('&', "&bMinehut&8 | &7Your content has been blocked for the following: \"&c&n<blocked>&r&7\"");
/* */
/* 15 */ player.sendMessage(message.replace("<blocked>", reason));
/* */ }
/* */ }
/* Location: C:\Users\Xiao\Downloads\MinehutFilter.jar!\com\minehut\filterplugin\messaging\LegacyMessenger.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.1.3
*/
@@ -0,0 +1,28 @@
/* */ package com.minehut.filterplugin.messaging;
/* */
/* */ import net.kyori.adventure.text.minimessage.MiniMessage;
/* */ import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
/* */ import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
/* */ import org.bukkit.entity.Player;
/* */ import org.bukkit.plugin.Plugin;
/* */ import org.jetbrains.annotations.NotNull;
/* */
/* */ public final class MiniMessageMessenger implements FilterMessenger {
/* */ private static final String BLOCKED_MESSAGE_FORMAT = "<aqua>Minehut<dark_gray> | <gray>Your content has been blocked for the following: \"<red><u><blocked></u><gray>\"";
/* */ private final String format;
/* */
/* */ public MiniMessageMessenger(Plugin plugin) {
/* 15 */ this.format = plugin.getConfig().getString("blocked-message", "<aqua>Minehut<dark_gray> | <gray>Your content has been blocked for the following: \"<red><u><blocked></u><gray>\"");
/* */ }
/* */
/* */
/* */ public void sendBlocked(Player player, @NotNull String reason) {
/* 20 */ player.sendMessage(MiniMessage.miniMessage().deserialize(this.format, (TagResolver)Placeholder.unparsed("blocked", reason)));
/* */ }
/* */ }
/* Location: C:\Users\Xiao\Downloads\MinehutFilter.jar!\com\minehut\filterplugin\messaging\MiniMessageMessenger.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.1.3
*/
@@ -0,0 +1,34 @@
/* */ package com.minehut.filterplugin.scheduling;
/* */
/* */ import org.bukkit.block.Block;
/* */ import org.bukkit.entity.Player;
/* */ import org.bukkit.plugin.Plugin;
/* */
/* */ public final class BukkitFilterScheduler implements FilterScheduler {
/* */ private final Plugin plugin;
/* */
/* */ public BukkitFilterScheduler(Plugin plugin) {
/* 11 */ this.plugin = plugin;
/* */ }
/* */
/* */
/* */ public void run(Player player, Runnable task) {
/* 16 */ this.plugin.getServer().getScheduler().runTask(this.plugin, task);
/* */ }
/* */
/* */
/* */ public void runLater(Player player, long delayTicks, Runnable task) {
/* 21 */ this.plugin.getServer().getScheduler().runTaskLater(this.plugin, task, delayTicks);
/* */ }
/* */
/* */
/* */ public void run(Block block, Runnable task) {
/* 26 */ this.plugin.getServer().getScheduler().runTask(this.plugin, task);
/* */ }
/* */ }
/* Location: C:\Users\Xiao\Downloads\MinehutFilter.jar!\com\minehut\filterplugin\scheduling\BukkitFilterScheduler.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.1.3
*/
@@ -0,0 +1,18 @@
package com.minehut.filterplugin.scheduling;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
public interface FilterScheduler {
void run(Player paramPlayer, Runnable paramRunnable);
void runLater(Player paramPlayer, long paramLong, Runnable paramRunnable);
void run(Block paramBlock, Runnable paramRunnable);
}
/* Location: C:\Users\Xiao\Downloads\MinehutFilter.jar!\com\minehut\filterplugin\scheduling\FilterScheduler.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.1.3
*/
@@ -0,0 +1,34 @@
/* */ package com.minehut.filterplugin.scheduling;
/* */
/* */ import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
/* */ import org.bukkit.block.Block;
/* */ import org.bukkit.entity.Player;
/* */ import org.bukkit.plugin.Plugin;
/* */
/* */ public final class FoliaFilterScheduler
/* */ implements FilterScheduler {
/* */ public FoliaFilterScheduler(Plugin plugin) {
/* 11 */ this.plugin = plugin;
/* */ }
/* */ private final Plugin plugin;
/* */
/* */ public void run(Player player, Runnable task) {
/* 16 */ player.getScheduler().run(this.plugin, scheduled -> task.run(), null);
/* */ }
/* */
/* */
/* */ public void runLater(Player player, long delayTicks, Runnable task) {
/* 21 */ player.getScheduler().runDelayed(this.plugin, scheduled -> task.run(), null, delayTicks);
/* */ }
/* */
/* */
/* */ public void run(Block block, Runnable task) {
/* 26 */ this.plugin.getServer().getRegionScheduler().run(this.plugin, block.getLocation(), scheduled -> task.run());
/* */ }
/* */ }
/* Location: C:\Users\Xiao\Downloads\MinehutFilter.jar!\com\minehut\filterplugin\scheduling\FoliaFilterScheduler.class
* Java compiler version: 17 (61.0)
* JD-Core Version: 1.1.3
*/
+23
View File
@@ -0,0 +1,23 @@
log-filtered-messages: true
blocked-message: '<aqua>Minehut<dark_gray> | <gray>Your content has been blocked for the following: "<red><u><blocked></u><gray>"'
filtered-commands:
- /nick
- /nickname
- /w
- /say
- /me
- /msg
- /tell
- /teammsg
- /tm
- /r
- /reply
- /m
- /t
- /pm
- /whisper
- /etell
- /broadcast
- /bc
- /rename
- /itemname
+9
View File
@@ -0,0 +1,9 @@
name: MinehutFilter
version: '1.0.2'
main: com.minehut.filterplugin.MinehutFilter
api-version: '1.17'
folia-supported: true
load: STARTUP
authors: [ Minehut ]
description: Free chat filter for Minehut servers
website: https://minehut.com/