-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: work on the login events and fix some modmode issues
- Loading branch information
Showing
17 changed files
with
333 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
spigot/src/main/kotlin/ltd/matrixstudios/alchemist/profiles/postlog/BukkitPostLoginTask.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package ltd.matrixstudios.alchemist.profiles.postlog | ||
|
||
import org.bukkit.entity.Player | ||
|
||
/** | ||
* Class created on 7/20/2023 | ||
* @author 98ping | ||
* @project Alchemist | ||
* @website https://solo.to/redis | ||
*/ | ||
interface BukkitPostLoginTask { | ||
|
||
fun run(player: Player) | ||
} |
34 changes: 34 additions & 0 deletions
34
spigot/src/main/kotlin/ltd/matrixstudios/alchemist/profiles/postlog/tasks/CheckBanEvasion.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package ltd.matrixstudios.alchemist.profiles.postlog.tasks | ||
|
||
import ltd.matrixstudios.alchemist.Alchemist | ||
import ltd.matrixstudios.alchemist.api.AlchemistAPI | ||
import ltd.matrixstudios.alchemist.packets.StaffGeneralMessagePacket | ||
import ltd.matrixstudios.alchemist.profiles.postlog.BukkitPostLoginTask | ||
import ltd.matrixstudios.alchemist.punishments.PunishmentType | ||
import ltd.matrixstudios.alchemist.redis.AsynchronousRedisSender | ||
import org.bukkit.entity.Player | ||
import java.util.concurrent.CompletableFuture | ||
|
||
/** | ||
* Class created on 7/20/2023 | ||
* @author 98ping | ||
* @project Alchemist | ||
* @website https://solo.to/redis | ||
*/ | ||
object CheckBanEvasion : BukkitPostLoginTask { | ||
override fun run(player: Player) { | ||
val profileId = player.uniqueId | ||
val profile = AlchemistAPI.syncFindProfile(profileId) ?: return | ||
CompletableFuture.supplyAsync { | ||
return@supplyAsync profile.getAltAccounts() | ||
}.thenApply { alts -> | ||
val isBanEvading = alts.size >= 1 && alts.any { it.hasActivePunishment(PunishmentType.BAN) || it.hasActivePunishment( | ||
PunishmentType.BLACKLIST) } | ||
|
||
if (isBanEvading) { | ||
AsynchronousRedisSender.send(StaffGeneralMessagePacket("&b[S] &3[${Alchemist.globalServer.displayName}] ${AlchemistAPI.getRankWithPrefix(profileId)} &3may be using an alt to evade a punishment!")) | ||
} | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
spigot/src/main/kotlin/ltd/matrixstudios/alchemist/profiles/postlog/tasks/LoadPermissions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package ltd.matrixstudios.alchemist.profiles.postlog.tasks | ||
|
||
import ltd.matrixstudios.alchemist.metric.Metric | ||
import ltd.matrixstudios.alchemist.metric.MetricService | ||
import ltd.matrixstudios.alchemist.permissions.AccessiblePermissionHandler | ||
import ltd.matrixstudios.alchemist.profiles.postlog.BukkitPostLoginTask | ||
import ltd.matrixstudios.alchemist.service.profiles.ProfileGameService | ||
import org.bukkit.entity.Player | ||
import java.util.concurrent.CompletableFuture | ||
|
||
/** | ||
* Class created on 7/20/2023 | ||
* @author 98ping | ||
* @project Alchemist | ||
* @website https://solo.to/redis | ||
*/ | ||
object LoadPermissions : BukkitPostLoginTask { | ||
|
||
override fun run(player: Player) { | ||
val profile = ProfileGameService.byId(player.uniqueId) ?: return | ||
|
||
val startPerms = System.currentTimeMillis() | ||
CompletableFuture.runAsync { | ||
AccessiblePermissionHandler.update(player, profile.getPermissions()) | ||
} | ||
|
||
MetricService.addMetric("Permission Handler", Metric("Permission Handler", System.currentTimeMillis().minus(startPerms), System.currentTimeMillis())) | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...ot/src/main/kotlin/ltd/matrixstudios/alchemist/profiles/postlog/tasks/SendStaffWelcome.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package ltd.matrixstudios.alchemist.profiles.postlog.tasks | ||
|
||
import ltd.matrixstudios.alchemist.AlchemistSpigotPlugin | ||
import ltd.matrixstudios.alchemist.api.AlchemistAPI | ||
import ltd.matrixstudios.alchemist.profiles.postlog.BukkitPostLoginTask | ||
import ltd.matrixstudios.alchemist.staff.mode.StaffSuiteManager | ||
import ltd.matrixstudios.alchemist.util.Chat | ||
import org.bukkit.Bukkit | ||
import org.bukkit.entity.Player | ||
import java.text.SimpleDateFormat | ||
import java.util.* | ||
|
||
/** | ||
* Class created on 7/20/2023 | ||
* @author 98ping | ||
* @project Alchemist | ||
* @website https://solo.to/redis | ||
*/ | ||
object SendStaffWelcome : BukkitPostLoginTask { | ||
|
||
override fun run(player: Player) { | ||
Bukkit.getScheduler().runTaskLater(AlchemistSpigotPlugin.instance, { | ||
val config = AlchemistSpigotPlugin.instance.config | ||
val dateFormat = SimpleDateFormat("MM-dd-yyyy", Locale.getDefault()) | ||
|
||
if (player.hasPermission("alchemist.staff")) { | ||
|
||
if (config.getBoolean("staffmode.sendWelcomeMessage")) { | ||
player.sendMessage(" ") | ||
player.sendMessage(Chat.format("&eWelcome back, " + AlchemistAPI.getRankDisplay(player.uniqueId))) | ||
player.sendMessage(Chat.format("&eIt is currently &d" + dateFormat.format(Date(System.currentTimeMillis())))) | ||
player.sendMessage(Chat.format("&eEdit your mod mode with &a/editmodmode")) | ||
player.sendMessage(" ") | ||
} | ||
|
||
if (StaffSuiteManager.isModModeOnJoin(player)) | ||
{ | ||
player.sendMessage(Chat.format("&7&oYou have been put into ModMode automatically")) | ||
StaffSuiteManager.setStaffMode(player) | ||
} | ||
} | ||
}, 10L) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.