From b408c42ea85b284a1b344b1d3415ec6d91024247 Mon Sep 17 00:00:00 2001 From: ohAlee Date: Wed, 10 May 2023 15:49:11 +0200 Subject: [PATCH] Added "minecraftgpt.receive" permission to still receive messages from users using minecraftgpt --- build.gradle | 2 +- .../java/it/ohalee/minecraftgpt/handler/ChatHandler.java | 6 ++++++ src/main/resources/plugin.yml | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index c1a9048..6db7b14 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group = 'it.ohalee.minecraftgpt' -version = '1.2.6' +version = '1.2.7' sourceCompatibility = 1.17 targetCompatibility = 1.17 diff --git a/src/main/java/it/ohalee/minecraftgpt/handler/ChatHandler.java b/src/main/java/it/ohalee/minecraftgpt/handler/ChatHandler.java index 27cd85b..d0c6673 100644 --- a/src/main/java/it/ohalee/minecraftgpt/handler/ChatHandler.java +++ b/src/main/java/it/ohalee/minecraftgpt/handler/ChatHandler.java @@ -5,6 +5,7 @@ import it.ohalee.minecraftgpt.OpenAI; import it.ohalee.minecraftgpt.Type; import it.ohalee.minecraftgpt.util.Messages; import lombok.RequiredArgsConstructor; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -59,8 +60,13 @@ public class ChatHandler implements Listener { } private void sendMessage(String message, Collection players) { + Bukkit.getOnlinePlayers().stream() + .filter(player -> !players.contains(player) && player.hasPermission("minecraftgpt.receive")) + .forEach(player -> player.sendMessage(message)); + for (Player player : players) player.sendMessage(message); + if (plugin.getConfig().getBoolean("send-messages-to-console", true)) plugin.getServer().getConsoleSender().sendMessage(message); } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index b88216f..18f0056 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: MinecraftGPT main: it.ohalee.minecraftgpt.Main -version: 1.2.6 +version: 1.2.7 author: ohAlee description: A Minecraft plugin that uses ChatGPT api-version: 1.16