mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-22 17:17:37 +00:00
Tell admins if a player has notes
This commit is contained in:
parent
6c09905a8d
commit
81c656c86e
@ -7,6 +7,9 @@ import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.storage.StorageType;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -84,6 +87,16 @@ public class PlayerListener<T> extends PlexListener
|
||||
{
|
||||
plexPlayer.loadNotes();
|
||||
}
|
||||
|
||||
plugin.getSqlNotes().getNotes(plexPlayer.getUuid()).whenComplete((notes, ex) ->
|
||||
{
|
||||
String plural = notes.size() == 1 ? "note." : "notes.";
|
||||
if (!notes.isEmpty())
|
||||
{
|
||||
PlexUtils.broadcastToAdmins(Component.text(plexPlayer.getName() + " has " + notes.size() + " " + plural).color(NamedTextColor.GOLD));
|
||||
PlexUtils.broadcastToAdmins(Component.text("Click to view their " + plural).clickEvent(ClickEvent.runCommand("/notes " + plexPlayer.getName() + " list")).color(NamedTextColor.GOLD));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// saving the player's data
|
||||
|
@ -43,7 +43,6 @@ public class Punishment
|
||||
|
||||
public static Component generateBanMessage(Punishment punishment)
|
||||
{
|
||||
|
||||
return PlexUtils.messageComponent("banMessage", banUrl, punishment.getReason(),
|
||||
PlexUtils.useTimezone(punishment.getEndDate()),
|
||||
punishment.getPunisher() == null ? "CONSOLE" : MojangUtils.getInfo(punishment.getPunisher().toString()).getUsername());
|
||||
|
@ -96,7 +96,7 @@ public class SQLConnection extends PlexBase
|
||||
"`uuid` VARCHAR(46) NOT NULL," +
|
||||
"`permission` VARCHAR(1000) NOT NULL," +
|
||||
"`allowed` BOOLEAN" +
|
||||
");");
|
||||
");").execute();
|
||||
}
|
||||
catch (SQLException throwables)
|
||||
{
|
||||
|
@ -5,6 +5,7 @@ import com.google.common.reflect.ClassPath;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.PlexBase;
|
||||
import dev.plex.cache.DataUtils;
|
||||
import dev.plex.cache.PlayerCache;
|
||||
import dev.plex.config.Config;
|
||||
import dev.plex.permission.Permission;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
@ -116,7 +117,8 @@ public class PlexUtils extends PlexBase
|
||||
|
||||
public static void updatePermission(PlexPlayer player, String permission, boolean newValue)
|
||||
{
|
||||
player.getPermissions().stream().filter(permission1 -> permission.equalsIgnoreCase(permission)).findFirst().ifPresent(permission1 -> {
|
||||
player.getPermissions().stream().filter(permission1 -> permission.equalsIgnoreCase(permission)).findFirst().ifPresent(permission1 ->
|
||||
{
|
||||
Plex.get().getSqlPermissions().updatePermission(permission1, newValue);
|
||||
});
|
||||
player.getPermissions().removeIf(permission1 -> permission1.getPermission().equalsIgnoreCase(permission));
|
||||
@ -424,6 +426,13 @@ public class PlexUtils extends PlexBase
|
||||
Bukkit.broadcast(component);
|
||||
}
|
||||
|
||||
public static void broadcastToAdmins(Component component)
|
||||
{
|
||||
Bukkit.getOnlinePlayers().stream().filter(pl -> PlayerCache.getPlexPlayer(pl.getUniqueId()).isAdminActive()).forEach(pl ->
|
||||
Bukkit.broadcast(component));
|
||||
}
|
||||
|
||||
|
||||
public static Object simpleGET(String url)
|
||||
{
|
||||
try
|
||||
|
Loading…
Reference in New Issue
Block a user