From 61e46b6f10704ef861688afcec589cbddb5ecba0 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Thu, 30 May 2019 15:48:29 -0700 Subject: [PATCH] Fixing some tab completion bugs for mcconvert --- Changelog.txt | 2 ++ .../gmail/nossr50/commands/McconvertCommand.java | 4 ++-- .../com/gmail/nossr50/datatypes/party/Party.java | 1 - .../gmail/nossr50/datatypes/player/McMMOPlayer.java | 1 - .../nossr50/datatypes/player/PlayerProfile.java | 1 - .../runnables/database/FormulaConversionTask.java | 13 ++++++------- .../nossr50/util/experience/FormulaManager.java | 5 ----- .../nossr50/util/player/NotificationManager.java | 6 ++++-- 8 files changed, 14 insertions(+), 19 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 8a8109164..aa250c076 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -32,6 +32,8 @@ Version 2.2.0 Added new locale string 'Commands.Reload.Finished' Added new permission 'mcmmo.commands.reload' Lily pads were removed from the Alchemy Ingredient list as they are unused + Experience formula conversion command no longer relies on a file to determine what formula you were using previously, instead it determines this from command parameters + Fixed some tab completion bugs for /mcconvert command Admins will now be notified if a player trips over-fishing exploit detection 3+ times in a row (Locale: "Fishing.OverFishingDetected") Note: Admins are players who are an operator or have adminchat permission. diff --git a/src/main/java/com/gmail/nossr50/commands/McconvertCommand.java b/src/main/java/com/gmail/nossr50/commands/McconvertCommand.java index 3c100003f..ac8f0e1cf 100644 --- a/src/main/java/com/gmail/nossr50/commands/McconvertCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McconvertCommand.java @@ -74,11 +74,11 @@ public class McconvertCommand implements TabExecutor { case 1: return StringUtil.copyPartialMatches(args[0], SUBCOMMANDS, new ArrayList<>(SUBCOMMANDS.size())); case 2: - if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) { + if (args[1].equalsIgnoreCase("database") || args[1].equalsIgnoreCase("db")) { return StringUtil.copyPartialMatches(args[0], DATABASE_TYPES, new ArrayList<>(DATABASE_TYPES.size())); } - if (args[0].equalsIgnoreCase("experience") || args[0].equalsIgnoreCase("xp") || args[0].equalsIgnoreCase("exp")) { + if (args[1].equalsIgnoreCase("experience") || args[1].equalsIgnoreCase("xp") || args[1].equalsIgnoreCase("exp")) { return StringUtil.copyPartialMatches(args[0], FORMULA_TYPES, new ArrayList<>(FORMULA_TYPES.size())); } diff --git a/src/main/java/com/gmail/nossr50/datatypes/party/Party.java b/src/main/java/com/gmail/nossr50/datatypes/party/Party.java index e252c2d09..249864514 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/party/Party.java +++ b/src/main/java/com/gmail/nossr50/datatypes/party/Party.java @@ -14,7 +14,6 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import sun.security.krb5.Config; import java.text.DecimalFormat; import java.util.ArrayList; diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index 3c429120a..bb0d81598 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -56,7 +56,6 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.plugin.Plugin; -import sun.security.krb5.Config; import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java index ade7e8c1c..5641a47d9 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.datatypes.player; import com.gmail.nossr50.datatypes.MobHealthbarType; -import com.gmail.nossr50.datatypes.experience.FormulaType; import com.gmail.nossr50.datatypes.experience.SkillXpGain; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; diff --git a/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java b/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java index 145c6e642..5e20c9749 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java @@ -14,11 +14,11 @@ import org.bukkit.scheduler.BukkitRunnable; public class FormulaConversionTask extends BukkitRunnable { private CommandSender sender; - private FormulaType formulaType; + private FormulaType previousFormula; - public FormulaConversionTask(CommandSender sender, FormulaType formulaType) { + public FormulaConversionTask(CommandSender sender, FormulaType previousFormula) { this.sender = sender; - this.formulaType = formulaType; + this.previousFormula = previousFormula; } @Override @@ -48,9 +48,8 @@ public class FormulaConversionTask extends BukkitRunnable { convertedUsers++; Misc.printProgress(convertedUsers, DatabaseManager.progressInterval, startMillis); } - mcMMO.getFormulaManager().setPreviousFormulaType(formulaType); - sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Finish", formulaType.toString())); + sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Finish", previousFormula.toString())); } private void editValues(PlayerProfile profile) { @@ -59,13 +58,13 @@ public class FormulaConversionTask extends BukkitRunnable { for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) { int oldLevel = profile.getSkillLevel(primarySkillType); int oldXPLevel = profile.getSkillXpLevel(primarySkillType); - int totalOldXP = mcMMO.getFormulaManager().calculateTotalExperience(oldLevel, oldXPLevel); + int totalOldXP = mcMMO.getFormulaManager().calculateTotalExperience(oldLevel, oldXPLevel, previousFormula); if (totalOldXP == 0) { continue; } - int[] newExperienceValues = mcMMO.getFormulaManager().calculateNewLevel(primarySkillType, (int) Math.floor(totalOldXP / 1.0), formulaType); + int[] newExperienceValues = mcMMO.getFormulaManager().calculateNewLevel(primarySkillType, (int) Math.floor(totalOldXP / 1.0), previousFormula); int newLevel = newExperienceValues[0]; int newXPlevel = newExperienceValues[1]; diff --git a/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java b/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java index 15d4771c0..75ead3b25 100644 --- a/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java +++ b/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java @@ -3,16 +3,11 @@ package com.gmail.nossr50.util.experience; import com.gmail.nossr50.datatypes.experience.FormulaType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.mcMMO; -import com.sk89q.worldedit.internal.expression.runtime.For; -import org.bukkit.configuration.file.YamlConfiguration; -import java.io.File; import java.util.HashMap; import java.util.Map; public class FormulaManager { - private static File formulaFile = new File(mcMMO.getFlatFileDirectory() + "formula.yml"); - // Experience needed to reach a level, cached values for speed private Map experienceNeededRetroLinear; private Map experienceNeededStandardLinear; 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 db57edae9..39019f279 100644 --- a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java +++ b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java @@ -9,14 +9,16 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.events.skills.McMMOPlayerNotificationEvent; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Server; +import org.bukkit.SoundCategory; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player;