diff --git a/src/main/kotlin/onl/tesseract/core/TesseractCorePlugin.kt b/src/main/kotlin/onl/tesseract/core/TesseractCorePlugin.kt index 34fbe73..a77e2bb 100644 --- a/src/main/kotlin/onl/tesseract/core/TesseractCorePlugin.kt +++ b/src/main/kotlin/onl/tesseract/core/TesseractCorePlugin.kt @@ -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.* @@ -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() { diff --git a/src/main/kotlin/onl/tesseract/core/autochatmessage/AutoChatMessage.java b/src/main/kotlin/onl/tesseract/core/autochatmessage/AutoChatMessage.java deleted file mode 100644 index 6b13ec7..0000000 --- a/src/main/kotlin/onl/tesseract/core/autochatmessage/AutoChatMessage.java +++ /dev/null @@ -1,38 +0,0 @@ -package onl.tesseract.core.autochatmessage; - -import net.kyori.adventure.text.Component; -import onl.tesseract.core.TesseractCorePlugin; -import org.bukkit.Bukkit; -import org.bukkit.scheduler.BukkitRunnable; - -import java.util.ArrayList; -import java.util.List; - -public class AutoChatMessage { - /** - * Période d'envoi de message 5*60*20 = 5min - */ - private static final int PERIOD = (int) (7.5 * 60 * 20); - /** - * Instance - */ - private final List messages = new ArrayList<>(); - private int currentMessageIndex = 0; - - public void addMessage(Component message) { - messages.add(message); - } - - public void start() { - new BukkitRunnable() { - @Override - public void run() { - if (!messages.isEmpty()) { - Component message = messages.get(currentMessageIndex++); - Bukkit.getOnlinePlayers().forEach(p -> p.sendMessage(message)); - currentMessageIndex %= messages.size(); - } - } - }.runTaskTimer(TesseractCorePlugin.instance, 0, PERIOD); - } -} diff --git a/src/main/kotlin/onl/tesseract/core/autochatmessage/AutoChatMessage.kt b/src/main/kotlin/onl/tesseract/core/autochatmessage/AutoChatMessage.kt new file mode 100644 index 0000000..795c4a6 --- /dev/null +++ b/src/main/kotlin/onl/tesseract/core/autochatmessage/AutoChatMessage.kt @@ -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 = 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()) + } +} diff --git a/src/main/kotlin/onl/tesseract/core/autochatmessage/AutoChatMessages.java b/src/main/kotlin/onl/tesseract/core/autochatmessage/AutoChatMessages.java deleted file mode 100644 index fa4157b..0000000 --- a/src/main/kotlin/onl/tesseract/core/autochatmessage/AutoChatMessages.java +++ /dev/null @@ -1,92 +0,0 @@ -package onl.tesseract.core.autochatmessage; - -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.format.NamedTextColor; -import net.kyori.adventure.text.format.TextDecoration; - -public class AutoChatMessages { - - public static Component voteMessage() { - return Component.text(" ", 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(net.kyori.adventure.text.event.ClickEvent.clickEvent(net.kyori.adventure.text.event.ClickEvent.Action.RUN_COMMAND, "/vote"))) - .append(Component.newline())) - .append(Component.text(" ", NamedTextColor.GREEN, TextDecoration.STRIKETHROUGH)); - } - - public static Component discordMessage() { - return Component.text(" ", 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(net.kyori.adventure.text.event.ClickEvent.clickEvent(net.kyori.adventure.text.event.ClickEvent.Action.OPEN_URL, "https://discord.gg/4ajRytDJWK")) - .append(Component.text(" ← ", NamedTextColor.BLUE, TextDecoration.BOLD)))) - .append(Component.newline()) - .append(Component.text(" ", NamedTextColor.BLUE, TextDecoration.STRIKETHROUGH)); - } - - public static Component recrutementMessage() { - return Component.text(" ", 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(net.kyori.adventure.text.event.ClickEvent.clickEvent(net.kyori.adventure.text.event.ClickEvent.Action.OPEN_URL, "https://www.tesseract.onl/candidature/"))) - .append(Component.text(" ← ", NamedTextColor.GOLD, TextDecoration.BOLD))) - .append(Component.newline()) - .append(Component.text(" ", NamedTextColor.YELLOW, TextDecoration.STRIKETHROUGH)))); - } - -} diff --git a/src/main/kotlin/onl/tesseract/core/autochatmessage/AutoChatMessages.kt b/src/main/kotlin/onl/tesseract/core/autochatmessage/AutoChatMessages.kt new file mode 100644 index 0000000..ed607f6 --- /dev/null +++ b/src/main/kotlin/onl/tesseract/core/autochatmessage/AutoChatMessages.kt @@ -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 + ) + ) + ) + ) + } +} diff --git a/src/main/kotlin/onl/tesseract/core/autochatmessage/GlobalAutoChat.kt b/src/main/kotlin/onl/tesseract/core/autochatmessage/GlobalAutoChat.kt new file mode 100644 index 0000000..4152203 --- /dev/null +++ b/src/main/kotlin/onl/tesseract/core/autochatmessage/GlobalAutoChat.kt @@ -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 + } + } +} diff --git a/src/main/kotlin/onl/tesseract/core/command/PWeatherCommand.kt b/src/main/kotlin/onl/tesseract/core/command/PWeatherCommand.kt index 5a7668f..7da6996 100644 --- a/src/main/kotlin/onl/tesseract/core/command/PWeatherCommand.kt +++ b/src/main/kotlin/onl/tesseract/core/command/PWeatherCommand.kt @@ -18,26 +18,25 @@ import org.bukkit.entity.Player args = [Argument(value = "weather", clazz = WeatherNameArg::class)]) class PWeatherCommand : CommandContext() { @CommandBody - fun onCommand(@Env(key = "weather") weather: Weather, sender: Player): Boolean { + fun onCommand(@Env(key = "weather") weather: Weather, sender: Player) { if (weather == Weather.RESET) { sender.resetPlayerWeather() - sender.sendMessage(Component.text("Votre météo a été réinitialisé.", NamedTextColor.GREEN)); - return true + sender.sendMessage(Component.text("Votre météo a été réinitialisée.", NamedTextColor.GREEN)); + return } weather.weatherType?.let { sender.setPlayerWeather(it) } - sender.sendMessage(Component.text("Météo fixé à ${weather.weatherType}", NamedTextColor.GREEN)) - - return true + sender.sendMessage(Component.text("Météo fixée à ${weather.displayName}", NamedTextColor.GREEN)) } - - enum class Weather(val weatherType: WeatherType?) { - RESET(null), - CLEAR(WeatherType.CLEAR), - RAIN(WeatherType.DOWNFALL) + enum class Weather( + val weatherType: WeatherType?, + val displayName: String + ) { + RESET(null, "DEFAUT"), + CLEAR(WeatherType.CLEAR, "CLAIR"), + RAIN(WeatherType.DOWNFALL, "PLUVIEUX") } - } \ No newline at end of file diff --git a/src/main/kotlin/onl/tesseract/core/cosmetics/TeleportationAnimation.java b/src/main/kotlin/onl/tesseract/core/cosmetics/TeleportationAnimation.java index 2ee526f..34a327f 100644 --- a/src/main/kotlin/onl/tesseract/core/cosmetics/TeleportationAnimation.java +++ b/src/main/kotlin/onl/tesseract/core/cosmetics/TeleportationAnimation.java @@ -260,4 +260,10 @@ public Material getIcon() public @NotNull Material getMaterial() { return icon; } + + public static TeleportationAnimation getTpAnimation() { + //ajouter plus tard les animations + return WATER; + } + }