diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index f56c6a226..8118a6424 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -197,6 +197,8 @@ public class Config extends AutoUpdateConfigLoader { public String getAdminChatPrefix() { return config.getString("Commands.a.Chat_Prefix_Format", "[[AQUA]][[[WHITE]]{0}[[AQUA]]]"); } public boolean getAdminDisplayNames() { return config.getBoolean("Commands.a.Use_Display_Names", true); } + public boolean getMatchOfflinePlayers() { return config.getBoolean("Commands.General.Match_OfflinePlayers", false); } + /* Mob Healthbar */ public MobHealthbarType getMobHealthbarDefault() { try { diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index 26de7991b..43c1396e6 100644 --- a/src/main/java/com/gmail/nossr50/util/Misc.java +++ b/src/main/java/com/gmail/nossr50/util/Misc.java @@ -22,6 +22,7 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.MetadataValue; +import com.gmail.nossr50.config.Config; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.events.items.McMMOItemSpawnEvent; import com.gmail.nossr50.util.player.UserManager; @@ -283,13 +284,23 @@ public final class Misc { * Get a matched player name if one was found in the database. * * @param partialName Name to match + * * @return Matched name or {@code partialName} if no match was found */ public static String getMatchedPlayerName(String partialName) { - List matches = matchPlayer(partialName); + if (Config.getInstance().getMatchOfflinePlayers()) { + List matches = matchPlayer(partialName); - if (matches.size() == 1) { - partialName = matches.get(0); + if (matches.size() == 1) { + partialName = matches.get(0); + } + + } + else { + Player player = mcMMO.p.getServer().getPlayer(partialName); + if (player != null) { + partialName = player.getName(); + } } return partialName; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index ea76e7a14..2a570d176 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -309,6 +309,10 @@ Double_Drops: # Settings for commands ### Commands: + General: + # If true, when using partial names in commands mcMMO will try to look for a match from + # the offline players. Enabling this might slow the server down if there are a lot of offline players. + Match_OfflinePlayers: false mcmmo: Donate_Message: true inspect: