Skip to content

Commit

Permalink
fix : ipreport is now only online users
Browse files Browse the repository at this point in the history
  • Loading branch information
98ping committed Jan 21, 2024
1 parent 08dd6a2 commit aece67a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ data class GameProfile(
return false
}

fun altHasAnyPunishment() = alternateAccountHasMute() || alternateAccountHasBan() || alternateAccountHasBlacklist()

fun getFirstBlacklistFromAlts(): Punishment?
{
val alts = getAltAccounts().join()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,35 +58,6 @@ object ProfileGameService : GeneralizedService {
}
}

fun ipReportLookup() : CompletableFuture<MutableList<GameProfile>>
{
return CompletableFuture.supplyAsync {
val ret = mutableListOf<GameProfile>()
val allProfiles = handler.retrieveAll()

for (profile in allProfiles)
{
for (alt in profile.getAltAccounts().join())
{
if (alt.hasActivePunishment(PunishmentType.BLACKLIST)
||
alt.hasActivePunishment(PunishmentType.BAN)
||
alt.hasActivePunishment(PunishmentType.MUTE)
)
{
if (!profile.hasActivePunishment(PunishmentType.BAN) && !profile.hasActivePunishment(PunishmentType.BLACKLIST))
{
ret.add(profile)
}
}
}
}

return@supplyAsync ret
}
}

fun getHighestRank(uuid: UUID): Rank {
val current = RankService.FALLBACK_RANK
val profile = byId(uuid) ?: return current
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ class BroadcastEditSpecificsMenu(val player: Player, private val broadcast: Broa
}

override fun getTitle(player: Player): String {
return "Editing a Broadcast..."
return "Editing Broadcast..."
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,6 @@ class ConditionEditorMenu(val player: Player, private val broadcast: BroadcastMe

override fun getTitle(player: Player): String
{
return "Editing Broadcast Conditions"
return "Editing Conditions..."
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import co.aikar.commands.annotation.CommandAlias
import co.aikar.commands.annotation.CommandPermission
import ltd.matrixstudios.alchemist.AlchemistSpigotPlugin
import ltd.matrixstudios.alchemist.models.profile.GameProfile
import ltd.matrixstudios.alchemist.service.profiles.ProfileGameService
import ltd.matrixstudios.alchemist.profiles.getProfile
import ltd.matrixstudios.alchemist.util.Chat
import net.kyori.adventure.text.Component
import net.kyori.adventure.text.event.HoverEvent
import net.kyori.adventure.text.format.NamedTextColor
import org.bukkit.Bukkit
import org.bukkit.command.CommandSender
import java.util.*
import java.util.concurrent.CompletableFuture

class IpReportCommand : BaseCommand()
{
Expand All @@ -20,7 +22,7 @@ class IpReportCommand : BaseCommand()
@CommandPermission("alchemist.ipreport")
fun ipreport(sender: CommandSender)
{
ProfileGameService.ipReportLookup().thenAccept {
loadIpReport().thenAccept {
sender.sendMessage(Chat.format("&7[&f&oMuted Alt&7, &cBanned Alt&7, &4Blacklisted Alt&7]"))
sender.sendMessage(Chat.format("&aEveryone's &ealts (&6${it.size}&e):"))
val finalMessage = Component.text()
Expand All @@ -42,6 +44,11 @@ class IpReportCommand : BaseCommand()
}
}

fun loadIpReport() = CompletableFuture.supplyAsync {
Bukkit.getOnlinePlayers().filter { it.getProfile()?.altHasAnyPunishment() ?: false }
.mapNotNull { it.getProfile() }
}

fun createHover(target: GameProfile): Component
{
val hoverComponent =
Expand Down

0 comments on commit aece67a

Please sign in to comment.