From d9dd4ea016d249a6627ab7d2067077dd343420ba Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 14 Jan 2019 02:32:02 -0800 Subject: [PATCH] XP events now use the Title API Configurable in advanced.yml --- Changelog.txt | 1 + .../com/gmail/nossr50/commands/XprateCommand.java | 13 +++++++++++-- .../com/gmail/nossr50/config/AdvancedConfig.java | 5 +++++ .../nossr50/util/player/NotificationManager.java | 10 ++++++++++ src/main/resources/advanced.yml | 8 ++++++-- src/main/resources/locale/locale_en_US.properties | 2 ++ 6 files changed, 35 insertions(+), 4 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index d2fb690e0..4f843f7d8 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -15,6 +15,7 @@ Version 2.1.0 + Added links to mcMMO related websites to various commands + Certain elements of mcMMO's UI have been restyled + Added the tagline "Overhaul Era" to various locations until 3.0.0 comes out + + (Events) Starting an XP event will now use the title API (toggle this in advanced.yml) + (Sound) Volume and Pitch of sounds can now be configured in the new sounds.yml file + (MySQL) Added support for SSL for MySQL/MariaDB (On by default) + (Skills) Adding a new subskill to child skills called 'Understanding The Art' this adds nothing new, but tracks your progress in that child skill, which was previous a bit obfuscated. diff --git a/src/main/java/com/gmail/nossr50/commands/XprateCommand.java b/src/main/java/com/gmail/nossr50/commands/XprateCommand.java index fd9a791d3..fa29139ed 100644 --- a/src/main/java/com/gmail/nossr50/commands/XprateCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/XprateCommand.java @@ -3,6 +3,8 @@ package com.gmail.nossr50.commands; import java.util.ArrayList; import java.util.List; +import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.util.player.NotificationManager; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; @@ -65,8 +67,15 @@ public class XprateCommand implements TabExecutor { ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(newXpRate); if (mcMMO.p.isXPEventEnabled()) { - mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.started.0")); - mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.started.1", newXpRate)); + if(AdvancedConfig.getInstance().useTitlesForXPEvent()) + { + NotificationManager.broadcastTitle(mcMMO.p.getServer(), + LocaleLoader.getString("Commands.Event.Start"), + LocaleLoader.getString("Commands.Event.XP", newXpRate), + 10, 10*20, 20); + } + mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Start")); + mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.XP", newXpRate)); } else { sender.sendMessage(LocaleLoader.getString("Commands.xprate.modified", newXpRate)); diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index 995ff6c5d..9afe53c77 100644 --- a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java +++ b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java @@ -707,6 +707,11 @@ public class AdvancedConfig extends AutoUpdateConfigLoader { return config.getBoolean("Feedback.ActionBarNotifications."+notificationType.toString()+".SendCopyOfMessageToChat", false); } + public boolean useTitlesForXPEvent() + { + return config.getBoolean("Feedback.Events.XP.SendTitles", true); + } + /* * JSON Style Settings */ diff --git a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java index 507ba991c..8b904b011 100644 --- a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java +++ b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java @@ -5,12 +5,14 @@ import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.events.skills.McMMOPlayerNotificationEvent; +import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.TextComponentFactory; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.Server; import org.bukkit.entity.Player; public class NotificationManager { @@ -106,4 +108,12 @@ public class NotificationManager { sendNotification(mcMMOPlayer.getPlayer(), customEvent); } + + public static void broadcastTitle(Server server, String title, String subtitle, int i1, int i2, int i3) + { + for(Player player : server.getOnlinePlayers()) + { + player.sendTitle(title, subtitle, i1, i2, i3); + } + } } diff --git a/src/main/resources/advanced.yml b/src/main/resources/advanced.yml index 5bbd6a21f..a982701e8 100644 --- a/src/main/resources/advanced.yml +++ b/src/main/resources/advanced.yml @@ -14,6 +14,10 @@ # Settings for the Skills ### Feedback: + # If sendtitles is true messages will be sent using the title api (BIG TEXT ON SCREEN) + Events: + XP: + SendTitles: true #The actionbar is the message location right above the health bar ## If you disable the action bar messages, mcMMO will send the message to the chat system instead ActionBarNotifications: @@ -22,7 +26,7 @@ Feedback: SendCopyOfMessageToChat: false HardcoreMode: Enabled: true - SendCopyOfMessageToChat: false + SendCopyOfMessageToChat: true RequirementsNotMet: Enabled: true SendCopyOfMessageToChat: false @@ -61,7 +65,7 @@ Feedback: SendCopyOfMessageToChat: false NoPermission: Enabled: true - SendCopyOfMessageToChat: false + SendCopyOfMessageToChat: true PartyMessage: Enabled: true SendCopyOfMessageToChat: true diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index e4368791d..0942436d7 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -744,6 +744,8 @@ Commands.xprate.over=[[RED]]mcMMO XP Rate Event is OVER!! Commands.xprate.proper.0=[[RED]]Proper usage to change the XP rate is /xprate Commands.xprate.proper.1=[[RED]]Proper usage to restore the XP rate to default is /xprate reset Commands.xprate.proper.2=[[RED]]Please specify true or false to indicate if this is an xp event or not +Commands.Event.Start=[[GREEN]]mcMMO[[GOLD]] Event! +Commands.Event.XP=[[DARK_AQUA]]XP Rate is now [[GOLD]]{0}[[DARK_AQUA]]x! Commands.xprate.started.0=[[GOLD]]XP EVENT FOR mcMMO HAS STARTED! Commands.xprate.started.1=[[GOLD]]mcMMO XP RATE IS NOW {0}x! XPRate.Event= [[GOLD]]mcMMO is currently in an XP rate event! XP rate is {0}x!