Browse Source

XP event now uses titles for ending and fixed negative number bug

nossr50 6 years ago
parent
commit
5e3a72b30d

+ 1 - 0
Changelog.txt

@@ -46,6 +46,7 @@ Version 2.1.0
  - (Locale) Removed localizations with the following codes for being almost empty: id, HR_hr, et_EE, lv, lt, no, pl_PL, pt_PT, tr_TR
  - (Config) Removed SkillShot's IncreaseLevel & IncreasePercentage (replaced by RankDamageMultiplier)
  - (Config) Removed AxeMastery's MaxBonus & MaxBonusLevel (replaced by RankDamageMultiplier)
+ = (Events) Fixed bug where XP rate could be a negative number
  = (Experience) Fixed a bug where you could set a players levels into the negative and bad things would happen
  = (Plugin Compatibility) mcMMO now fires new custom events relating to changes it makes to player scoreboards, plugin authors can listen to these events to improve compatibility
  = (Items) Chimaera Wing now tracks cooldowns between sessions for players (no more disconnect abuse)

+ 21 - 2
src/main/java/com/gmail/nossr50/commands/XprateCommand.java

@@ -9,6 +9,7 @@ import com.gmail.nossr50.util.StringUtils;
 import com.gmail.nossr50.util.commands.CommandUtils;
 import com.gmail.nossr50.util.player.NotificationManager;
 import com.google.common.collect.ImmutableList;
+import org.bukkit.ChatColor;
 import org.bukkit.command.Command;
 import org.bukkit.command.CommandSender;
 import org.bukkit.command.TabExecutor;
@@ -24,7 +25,7 @@ public class XprateCommand implements TabExecutor {
     public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
         switch (args.length) {
             case 1:
-                if (!args[0].equalsIgnoreCase("reset")) {
+                if (!args[0].equalsIgnoreCase("reset") &&  !args[0].equalsIgnoreCase("clear")) {
                     return false;
                 }
 
@@ -34,7 +35,18 @@ public class XprateCommand implements TabExecutor {
                 }
 
                 if (mcMMO.p.isXPEventEnabled()) {
-                    mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.over"));
+
+                    if(AdvancedConfig.getInstance().useTitlesForXPEvent())
+                    {
+                        NotificationManager.broadcastTitle(mcMMO.p.getServer(),
+                                LocaleLoader.getString("Commands.Event.Stop"),
+                                LocaleLoader.getString("Commands.Event.Stop.Subtitle"),
+                                10, 10*20, 20);
+                    }
+
+                    mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Stop"));
+                    mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Stop.Subtitle"));
+
                     mcMMO.p.toggleXpEventEnabled();
                 }
 
@@ -62,6 +74,13 @@ public class XprateCommand implements TabExecutor {
                 }
 
                 int newXpRate = Integer.parseInt(args[0]);
+
+                if(newXpRate < 0)
+                {
+                    sender.sendMessage(ChatColor.RED+LocaleLoader.getString("Commands.NegativeNumberWarn"));
+                    return true;
+                }
+
                 ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
 
                 if (mcMMO.p.isXPEventEnabled()) {

+ 3 - 0
src/main/resources/locale/locale_en_US.properties

@@ -751,7 +751,10 @@ Commands.xprate.over=[[RED]]mcMMO XP Rate Event is OVER!!
 Commands.xprate.proper.0=[[RED]]Proper usage to change the XP rate is /xprate <integer> <true/false>
 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.NegativeNumberWarn=Don't use negative numbers!
 Commands.Event.Start=[[GREEN]]mcMMO[[GOLD]] Event!
+Commands.Event.Stop=[[GREEN]]mcMMO[[DARK_AQUA]] Event Over!
+Commands.Event.Stop.Subtitle=[[GREEN]]I hope you had fun!
 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!