Change donor chat to premium chat
This commit is contained in:
1 parent
528a32bf60
commit
21adeee08c
9 files changed
+51
-55
No files matched your search
@@ -52,8 +52,8 @@ class ChatOG : JavaPlugin() {
|
||||
|
||||
@JvmStatic
|
||||
@Suppress("unused")
|
||||
fun sendDonorMessage(message: String, player: String, uuid: UUID?) {
|
||||
GlobalScope.launch { DiscordBridge.sendDonorMessage(message, player, uuid) }
|
||||
fun sendPremiumMessage(message: String, player: String, uuid: UUID?) {
|
||||
GlobalScope.launch { DiscordBridge.sendPremiumMessage(message, player, uuid) }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@@ -88,8 +88,7 @@ class ChatOG : JavaPlugin() {
|
||||
this.getCommand("translatesettings")?.tabCompleter = TranslateSettingsTabCompleter()
|
||||
this.getCommand("chatconfigreload")?.setExecutor(ChatConfigReload())
|
||||
this.getCommand("sc")?.setExecutor(StaffChat())
|
||||
this.getCommand("dc")?.setExecutor(DonorChat())
|
||||
this.getCommand("d")?.setExecutor(DonorChat())
|
||||
this.getCommand("p")?.setExecutor(PremiumChat())
|
||||
|
||||
if (Config.discordEnabled) {
|
||||
GlobalScope.launch {
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.*
|
||||
object ChatSystemHelper {
|
||||
object ChatType {
|
||||
const val STAFFCHAT = "staffchat"
|
||||
const val DONORCHAT = "donorchat"
|
||||
const val PREMIUMCHAT = "premiumchat"
|
||||
}
|
||||
|
||||
var inChat: MutableMap<UUID, String> = HashMap()
|
||||
@@ -74,19 +74,19 @@ object ChatSystemHelper {
|
||||
}
|
||||
}
|
||||
|
||||
fun sendMessageInDonorChat(player: Player, text: String) {
|
||||
fun sendMessageInPremiumChat(player: Player, text: String) {
|
||||
var chatString = "${ChatOG.chat.getPlayerPrefix(player)}${player.name}"
|
||||
|
||||
if (PlaceholderAPI.setPlaceholders(player, "%simpleclans_clan_color_tag%") != "") {
|
||||
chatString = PlaceholderAPI.setPlaceholders(player, "&8[%simpleclans_clan_color_tag%&8] $chatString")
|
||||
}
|
||||
chatString = "&aDONOR | $chatString"
|
||||
chatString = "&aPREMIUM | $chatString"
|
||||
|
||||
if (Config.donorDiscordEnabled) {
|
||||
if (Config.premiumDiscordEnabled) {
|
||||
val discordMessageString = Helper.convertEmojis(text)
|
||||
|
||||
GlobalScope.launch {
|
||||
DiscordBridge.sendDonorMessage(discordMessageString, removeColor(chatString), player.uniqueId)
|
||||
DiscordBridge.sendPremiumMessage(discordMessageString, removeColor(chatString), player.uniqueId)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,9 +117,9 @@ object ChatSystemHelper {
|
||||
TranslateMessage.chatMessages[randomUUID] = TranslateMessage.SentChatMessage(text, player)
|
||||
|
||||
for (p in Bukkit.getOnlinePlayers()) {
|
||||
if (p.hasPermission("chat-og.donors")) {
|
||||
if (p.hasPermission("chat-og.premium")) {
|
||||
p.sendMessage(textComponent)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,18 +9,18 @@ object Config {
|
||||
lateinit var redisUrl: String
|
||||
var discordEnabled = false
|
||||
var staffDiscordEnabled = false
|
||||
var donorDiscordEnabled = false
|
||||
var premiumDiscordEnabled = false
|
||||
lateinit var status: String
|
||||
lateinit var serverHasStartedMessage: String
|
||||
lateinit var serverHasStoppedMessage: String
|
||||
lateinit var botToken: String
|
||||
lateinit var channelId: String
|
||||
lateinit var staffChannelId: String
|
||||
lateinit var donorChannelId: String
|
||||
lateinit var premiumChannelId: String
|
||||
lateinit var guildId: String
|
||||
lateinit var webhook: String
|
||||
lateinit var staffWebhook: String
|
||||
lateinit var donorWebhook: String
|
||||
lateinit var premiumWebhook: String
|
||||
lateinit var listCommandName: String
|
||||
lateinit var listCommandText: String
|
||||
lateinit var colorCodeRoles: List<String>
|
||||
@@ -66,9 +66,9 @@ object Config {
|
||||
}
|
||||
|
||||
try {
|
||||
donorDiscordEnabled = config.get("donorDiscordEnabled") as Boolean
|
||||
premiumDiscordEnabled = config.get("premiumDiscordEnabled") as Boolean
|
||||
} catch (_: Exception) {
|
||||
ChatOG.plugin.logger.severe("Failed to parse config option \"donorDiscordEnabled\" as a boolean")
|
||||
ChatOG.plugin.logger.severe("Failed to parse config option \"premiumDiscordEnabled\" as a boolean")
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -122,9 +122,9 @@ object Config {
|
||||
}
|
||||
|
||||
try {
|
||||
donorChannelId = (config.get("donorChannelId") as Long).toString()
|
||||
premiumChannelId = (config.get("premiumChannelId") as Long).toString()
|
||||
} catch (_: Exception) {
|
||||
ChatOG.plugin.logger.severe("Failed to parse config option \"donorChannelId\" as a long")
|
||||
ChatOG.plugin.logger.severe("Failed to parse config option \"premiumChannelId\" as a long")
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -143,9 +143,9 @@ object Config {
|
||||
}
|
||||
|
||||
try {
|
||||
donorWebhook = config.get("donorWebhook") as String
|
||||
premiumWebhook = config.get("premiumWebhook") as String
|
||||
} catch (_: Exception) {
|
||||
ChatOG.plugin.logger.severe("Failed to parse config option \"donorWebhook\" as a string")
|
||||
ChatOG.plugin.logger.severe("Failed to parse config option \"premiumWebhook\" as a string")
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ object DiscordBridge {
|
||||
var jda: JDA? = null
|
||||
var webhook: WebhookClient? = null
|
||||
var staffWebhook: WebhookClient? = null
|
||||
var donorWebhook: WebhookClient? = null
|
||||
var premiumWebhook: WebhookClient? = null
|
||||
|
||||
private val urlRegex =
|
||||
Regex("(.*)((https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;()]*[-a-zA-Z0-9+&@#/%=~_|()])(.*)")
|
||||
@@ -54,9 +54,9 @@ object DiscordBridge {
|
||||
ChatOG.plugin.logger.warning("Config option \"staffWebhook\" is invalid")
|
||||
}
|
||||
try {
|
||||
donorWebhook = WebhookClient.withUrl(Config.donorWebhook)
|
||||
premiumWebhook = WebhookClient.withUrl(Config.premiumWebhook)
|
||||
} catch (e: IllegalArgumentException) {
|
||||
ChatOG.plugin.logger.warning("Config option \"donorWebhook\" is invalid")
|
||||
ChatOG.plugin.logger.warning("Config option \"premiumWebhook\" is invalid")
|
||||
}
|
||||
|
||||
jda = light(Config.botToken, enableCoroutines = true) {
|
||||
@@ -97,7 +97,7 @@ object DiscordBridge {
|
||||
}
|
||||
|
||||
jda?.listener<MessageReceivedEvent> {
|
||||
if (it.channel.id != Config.channelId && (if (Config.staffDiscordEnabled) it.channel.id != Config.staffChannelId else true) && (if (Config.donorDiscordEnabled) it.channel.id != Config.donorChannelId else true)) {
|
||||
if (it.channel.id != Config.channelId && (if (Config.staffDiscordEnabled) it.channel.id != Config.staffChannelId else true) && (if (Config.premiumDiscordEnabled) it.channel.id != Config.premiumChannelId else true)) {
|
||||
return@listener
|
||||
}
|
||||
|
||||
@@ -272,12 +272,12 @@ object DiscordBridge {
|
||||
)
|
||||
}
|
||||
|
||||
Config.donorChannelId -> {
|
||||
val donorComponent = Component.text("DONOR | ").color(NamedTextColor.GREEN)
|
||||
Config.premiumChannelId -> {
|
||||
val premiumComponent = Component.text("PREMIUM | ").color(NamedTextColor.GREEN)
|
||||
Component.join(
|
||||
JoinConfiguration.noSeparators(),
|
||||
discordComponent,
|
||||
donorComponent,
|
||||
premiumComponent,
|
||||
replyComponent,
|
||||
userComponent,
|
||||
contentComponent
|
||||
@@ -319,9 +319,9 @@ object DiscordBridge {
|
||||
}
|
||||
}
|
||||
|
||||
Config.donorChannelId -> {
|
||||
Config.premiumChannelId -> {
|
||||
for (p in Bukkit.getOnlinePlayers()) {
|
||||
if (p.hasPermission("chat-og.donors")) {
|
||||
if (p.hasPermission("chat-og.premium")) {
|
||||
p.sendMessage(messageComponent)
|
||||
}
|
||||
}
|
||||
@@ -382,9 +382,9 @@ object DiscordBridge {
|
||||
staffWebhook?.send(webhookMessage.build())
|
||||
}
|
||||
|
||||
suspend fun sendDonorMessage(message: String, player: String, uuid: UUID?) {
|
||||
if (donorWebhook == null) {
|
||||
ChatOG.plugin.logger.warning("donorWebhook has not been set or is invalid")
|
||||
suspend fun sendPremiumMessage(message: String, player: String, uuid: UUID?) {
|
||||
if (premiumWebhook == null) {
|
||||
ChatOG.plugin.logger.warning("premiumWebhook has not been set or is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -395,7 +395,7 @@ object DiscordBridge {
|
||||
webhookMessage.setAvatarUrl("https://minotar.net/helm/$uuid.png")
|
||||
}
|
||||
|
||||
donorWebhook?.send(webhookMessage.build())
|
||||
premiumWebhook?.send(webhookMessage.build())
|
||||
}
|
||||
|
||||
fun sendEmbed(message: String, uuid: UUID?, color: Int) {
|
||||
|
||||
@@ -186,8 +186,8 @@ class Events : Listener {
|
||||
ChatSystemHelper.sendMessageInStaffChat(event.player, oldTextComponent.content())
|
||||
return
|
||||
}
|
||||
if (ChatSystemHelper.inChat[event.player.uniqueId] == ChatType.DONORCHAT) {
|
||||
ChatSystemHelper.sendMessageInDonorChat(event.player, oldTextComponent.content())
|
||||
if (ChatSystemHelper.inChat[event.player.uniqueId] == ChatType.PREMIUMCHAT) {
|
||||
ChatSystemHelper.sendMessageInPremiumChat(event.player, oldTextComponent.content())
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -23,10 +23,10 @@ class ChatConfigReload : CommandExecutor {
|
||||
|
||||
DiscordBridge.webhook = WebhookClient.withUrl(Config.webhook)
|
||||
DiscordBridge.staffWebhook = WebhookClient.withUrl(Config.staffWebhook)
|
||||
DiscordBridge.donorWebhook = WebhookClient.withUrl(Config.donorWebhook)
|
||||
DiscordBridge.premiumWebhook = WebhookClient.withUrl(Config.premiumWebhook)
|
||||
DiscordBridge.jda?.presence?.setPresence(Activity.playing(Config.status), false)
|
||||
|
||||
sender.sendMessage(ChatOG.mm.deserialize("${Config.prefix}<reset>: <green>Successfully reloaded the config."))
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -9,30 +9,30 @@ import org.bukkit.command.CommandExecutor
|
||||
import org.bukkit.command.CommandSender
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
class DonorChat : CommandExecutor {
|
||||
class PremiumChat : CommandExecutor {
|
||||
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>?): Boolean {
|
||||
if (sender !is Player) {
|
||||
sender.sendMessage("You can only execute this command as a player")
|
||||
sender.sendMessage("You can only execute this command as a player.")
|
||||
return true
|
||||
}
|
||||
if (!sender.hasPermission("chat-og.donors")) {
|
||||
if (!sender.hasPermission("chat-og.premium")) {
|
||||
sender.sendMessage(ChatOG.mm.deserialize("${Config.prefix}<reset>: <red>You do not have permission to run this command."))
|
||||
return true
|
||||
}
|
||||
if (args == null || args.isEmpty()) {
|
||||
if (ChatSystemHelper.inChat[sender.uniqueId] == ChatType.DONORCHAT) {
|
||||
if (ChatSystemHelper.inChat[sender.uniqueId] == ChatType.PREMIUMCHAT) {
|
||||
ChatSystemHelper.inChat[sender.uniqueId] = ""
|
||||
|
||||
sender.sendMessage(ChatOG.mm.deserialize("${Config.prefix}<reset>: You are now talking in normal chat."))
|
||||
return true
|
||||
}
|
||||
ChatSystemHelper.inChat[sender.uniqueId] = ChatType.DONORCHAT
|
||||
sender.sendMessage(ChatOG.mm.deserialize("${Config.prefix}<reset>: You are now talking in donor chat."))
|
||||
ChatSystemHelper.inChat[sender.uniqueId] = ChatType.PREMIUMCHAT
|
||||
sender.sendMessage(ChatOG.mm.deserialize("${Config.prefix}<reset>: You are now talking in premium chat."))
|
||||
return true
|
||||
}
|
||||
|
||||
ChatSystemHelper.sendMessageInDonorChat(sender, args.joinToString(separator = " "))
|
||||
ChatSystemHelper.sendMessageInPremiumChat(sender, args.joinToString(separator = " "))
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,10 @@ prefix: <dark_gray>[<green>Chat<white>-<dark_red>OG<dark_gray>]
|
||||
redisUrl: 127.0.0.1:6379
|
||||
|
||||
# ---Discord---
|
||||
# discordEnabled needs to be true for staffDiscordEnabled and donorDiscordEnabled to have any effect
|
||||
# discordEnabled needs to be true for staffDiscordEnabled and premiumDiscordEnabled to have any effect
|
||||
discordEnabled: false
|
||||
staffDiscordEnabled: false
|
||||
donorDiscordEnabled: false
|
||||
premiumDiscordEnabled: false
|
||||
status: Minecraft
|
||||
serverHasStartedMessage: The server has started
|
||||
serverHasStoppedMessage: The server has stopped
|
||||
@@ -17,10 +17,10 @@ botToken: <put the bot token here>
|
||||
guildId: <put the id of the guild here>
|
||||
channelId: <put the id of the channel here>
|
||||
staffChannelId: <put the id of the channel here>
|
||||
donorChannelId: <put the id of the channel here>
|
||||
premiumChannelId: <put the id of the channel here>
|
||||
webhook: <put the webhook here>
|
||||
staffWebhook: <put the webhook here>
|
||||
donorWebhook: <put the webhook here>
|
||||
premiumWebhook: <put the webhook here>
|
||||
listCommandName: list
|
||||
# Available placeholders: %onlineplayers%, %maxplayers%
|
||||
listCommandText: "%onlineplayers% player(s) online:"
|
||||
|
||||
@@ -20,9 +20,6 @@ commands:
|
||||
s:
|
||||
description: Toggle or talk in staff chat
|
||||
usage: /s OR /s <message here>
|
||||
dc:
|
||||
description: Toggle or talk in donor chat
|
||||
usage: /dc OR /dc <message here>
|
||||
d:
|
||||
description: Toggle or talk in donor chat
|
||||
usage: /d OR /d <message here>
|
||||
p:
|
||||
description: Toggle or talk in premium chat
|
||||
usage: /p OR /p <message here>
|
||||
Reference in new issue
Block a user