Added "minecraftgpt.receive" permission to still receive messages from users using minecraftgpt

This commit is contained in:
ohAlee 2023-05-10 15:49:11 +02:00
parent 62eb8abf71
commit b408c42ea8
3 changed files with 8 additions and 2 deletions

View File

@ -4,7 +4,7 @@ plugins {
} }
group = 'it.ohalee.minecraftgpt' group = 'it.ohalee.minecraftgpt'
version = '1.2.6' version = '1.2.7'
sourceCompatibility = 1.17 sourceCompatibility = 1.17
targetCompatibility = 1.17 targetCompatibility = 1.17

View File

@ -5,6 +5,7 @@ import it.ohalee.minecraftgpt.OpenAI;
import it.ohalee.minecraftgpt.Type; import it.ohalee.minecraftgpt.Type;
import it.ohalee.minecraftgpt.util.Messages; import it.ohalee.minecraftgpt.util.Messages;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -59,8 +60,13 @@ public class ChatHandler implements Listener {
} }
private void sendMessage(String message, Collection<Player> players) { private void sendMessage(String message, Collection<Player> players) {
Bukkit.getOnlinePlayers().stream()
.filter(player -> !players.contains(player) && player.hasPermission("minecraftgpt.receive"))
.forEach(player -> player.sendMessage(message));
for (Player player : players) for (Player player : players)
player.sendMessage(message); player.sendMessage(message);
if (plugin.getConfig().getBoolean("send-messages-to-console", true)) if (plugin.getConfig().getBoolean("send-messages-to-console", true))
plugin.getServer().getConsoleSender().sendMessage(message); plugin.getServer().getConsoleSender().sendMessage(message);
} }

View File

@ -1,6 +1,6 @@
name: MinecraftGPT name: MinecraftGPT
main: it.ohalee.minecraftgpt.Main main: it.ohalee.minecraftgpt.Main
version: 1.2.6 version: 1.2.7
author: ohAlee author: ohAlee
description: A Minecraft plugin that uses ChatGPT description: A Minecraft plugin that uses ChatGPT
api-version: 1.16 api-version: 1.16