Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/main/kotlin/onl/tesseract/core/TesseractCorePlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package onl.tesseract.core

import onl.tesseract.core.achievement.AchievementService
import onl.tesseract.core.afk.AfkManager
import onl.tesseract.core.autochatmessage.AutoChatMessage
import onl.tesseract.core.autochatmessage.AutoChatMessages
import onl.tesseract.core.autochatmessage.GlobalAutoChat
import onl.tesseract.core.boutique.BoutiqueService
import onl.tesseract.core.command.*
import onl.tesseract.core.command.staff.*
Expand Down Expand Up @@ -88,11 +88,10 @@ class TesseractCorePlugin : JavaPlugin() {
registerCommands()

VoteGoalManager.startLoops()
val autoChatMessage = AutoChatMessage()
autoChatMessage.start()
autoChatMessage.addMessage(AutoChatMessages.voteMessage())
autoChatMessage.addMessage(AutoChatMessages.discordMessage())
autoChatMessage.addMessage(AutoChatMessages.recrutementMessage())
GlobalAutoChat.instance.addMessage(AutoChatMessages.voteMessage())
GlobalAutoChat.instance.addMessage(AutoChatMessages.discordMessage())
GlobalAutoChat.instance.addMessage(AutoChatMessages.recrutementMessage())
GlobalAutoChat.startOnce()
}

fun registerCommands() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package onl.tesseract.core.autochatmessage

import net.kyori.adventure.text.Component
import onl.tesseract.core.TesseractCorePlugin
import org.bukkit.Bukkit
import org.bukkit.entity.Player
import org.bukkit.scheduler.BukkitRunnable

/**
* Période d'envoi de message 5*60*20 = 5min
*/
private const val PERIOD = (7.5 * 60 * 20).toInt()

open class AutoChatMessage {

private val messages: MutableList<Component> = ArrayList()
private var currentMessageIndex = 0

fun addMessage(message: Component) {
messages.add(message)
}

fun start() {
object : BukkitRunnable() {
override fun run() {
if (messages.isNotEmpty()) {
val message = messages[currentMessageIndex++]
Bukkit.getOnlinePlayers().forEach { p: Player? -> p!!.sendMessage(message) }
currentMessageIndex %= messages.size
}
}
}.runTaskTimer(TesseractCorePlugin.instance, 0, PERIOD.toLong())
}
}

This file was deleted.

189 changes: 189 additions & 0 deletions src/main/kotlin/onl/tesseract/core/autochatmessage/AutoChatMessages.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
package onl.tesseract.core.autochatmessage

import net.kyori.adventure.text.Component
import net.kyori.adventure.text.event.ClickEvent
import net.kyori.adventure.text.format.NamedTextColor
import net.kyori.adventure.text.format.TextDecoration

private val SPACE_MESSAGE = " "

object AutoChatMessages {
fun voteMessage(): Component {
return Component.text(
SPACE_MESSAGE,
NamedTextColor.GREEN,
TextDecoration.STRIKETHROUGH
)
.append(Component.newline())
.append(
Component.text(" ")
.decoration(TextDecoration.STRIKETHROUGH, false)
.append(
Component.text(
" GAGNEZ DES RÉCOMPENSES EN VOTANT ",
NamedTextColor.GREEN,
TextDecoration.BOLD
)
)
.append(Component.text(" "))
.append(Component.newline())
)
.append(Component.newline())
.append(
Component.text(" ")
.decoration(TextDecoration.STRIKETHROUGH, false)
.append(
Component.text(
"Votez dès maintenant pour soutenir le serveur et " +
"recevez des points boutique pour obtenir des récompenses uniques !",
NamedTextColor.DARK_GREEN
)
)
.append(Component.newline())
.append(Component.newline())
.append(Component.text(" "))
.append(Component.text("Exécutez la commande ou cliquez ci-dessous : ", NamedTextColor.DARK_GREEN))
.append(Component.newline())
.append(Component.text(" "))
.append(
Component.text(" → ", NamedTextColor.DARK_GREEN, TextDecoration.BOLD)
.decoration(TextDecoration.STRIKETHROUGH, false)
.append(Component.text("/vote", NamedTextColor.GREEN, TextDecoration.BOLD))
.append(Component.text(" ← ", NamedTextColor.DARK_GREEN, TextDecoration.BOLD))
.clickEvent(ClickEvent.clickEvent(ClickEvent.Action.RUN_COMMAND, "/vote"))
)
.append(Component.newline())
)
.append(
Component.text(
SPACE_MESSAGE,
NamedTextColor.GREEN,
TextDecoration.STRIKETHROUGH
)
)
}

fun discordMessage(): Component {
return Component.text(
SPACE_MESSAGE,
NamedTextColor.BLUE,
TextDecoration.STRIKETHROUGH
)
.append(Component.newline())
.append(
Component.text(" ")
.decoration(TextDecoration.STRIKETHROUGH, false)
.append(
Component.text(
" DÉCOUVREZ NOTRE COMMUNAUTÉ DISCORD ! ",
NamedTextColor.AQUA,
TextDecoration.BOLD
)
)
.append(Component.text(" "))
.append(Component.newline())
)
.append(Component.newline())
.append(
Component.text(" ")
.decoration(TextDecoration.STRIKETHROUGH, false)
.append(
Component.text(
"Rejoignez notre serveur Discord pour être informés " +
"des dernières nouvelles et interagir avec notre communauté !",
NamedTextColor.DARK_AQUA
)
)
.append(Component.newline())
.append(Component.newline())
.append(Component.text(" "))
.append(Component.text("Exécutez la commande ou cliquez ci-dessous : ", NamedTextColor.BLUE))
.append(Component.newline())
.append(Component.text(" "))
.append(
Component.text(" → ", NamedTextColor.BLUE, TextDecoration.BOLD)
.decoration(TextDecoration.BOLD, false)
.append(Component.text("/discord", NamedTextColor.AQUA, TextDecoration.BOLD))
.clickEvent(
ClickEvent.clickEvent(
ClickEvent.Action.OPEN_URL,
"https://discord.gg/4ajRytDJWK"
)
)
.append(Component.text(" ← ", NamedTextColor.BLUE, TextDecoration.BOLD))
)
)
.append(Component.newline())
.append(
Component.text(
SPACE_MESSAGE,
NamedTextColor.BLUE,
TextDecoration.STRIKETHROUGH
)
)
}

fun recrutementMessage(): Component {
return Component.text(
SPACE_MESSAGE,
NamedTextColor.YELLOW,
TextDecoration.STRIKETHROUGH
)
.append(Component.newline())
.append(
Component.text(" ")
.decoration(TextDecoration.STRIKETHROUGH, false)
.append(
Component.text(" TESSERACT RECRUTE !", NamedTextColor.YELLOW, TextDecoration.BOLD)
.append(Component.text(" ", NamedTextColor.GOLD, TextDecoration.BOLD))
)
.append(Component.newline())
.append(Component.newline())
.append(Component.text(" "))
.append(
Component.text(
"Nous recherchons de nouveaux membres pour contribuer au développement de nos projets ! ",
NamedTextColor.GOLD
)
)
.append(Component.text("Développeur JAVA, Scénariste, Community Manager", NamedTextColor.RED))
.append(Component.text(", et autres nombreux postes s'offrent à vous !", NamedTextColor.GOLD))
.decoration(TextDecoration.STRIKETHROUGH, false)
.append(Component.newline())
.append(Component.newline())
.append(
Component.text(" ")
.append(
Component.text(
"Rejoignez-nous dès maintenant (cliquez ici) : ",
NamedTextColor.GOLD
)
)
.append(Component.newline())
.append(Component.text(" "))
.append(
Component.text(" → ", NamedTextColor.GOLD, TextDecoration.BOLD)
.decoration(TextDecoration.BOLD, false)
.append(
Component.text("Candidater", NamedTextColor.YELLOW, TextDecoration.BOLD)
.clickEvent(
ClickEvent.clickEvent(
ClickEvent.Action.OPEN_URL,
"https://www.tesseract.onl/candidature/"
)
)
)
.append(Component.text(" ← ", NamedTextColor.GOLD, TextDecoration.BOLD))
)
.append(Component.newline())
.append(
Component.text(
SPACE_MESSAGE,
NamedTextColor.YELLOW,
TextDecoration.STRIKETHROUGH
)
)
)
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package onl.tesseract.core.autochatmessage

object GlobalAutoChat {

val instance: AutoChatMessage = AutoChatMessage()
private var started: Boolean = false

@Synchronized
fun startOnce() {
if (!started) {
instance.start()
started = true
}
}
}
Loading