Disable partial name matching for offline players by default

#1482
This commit is contained in:
TfT_02 2013-09-25 14:26:24 +02:00
parent 45dfc13ebd
commit 933b6f278b
3 changed files with 20 additions and 3 deletions

View File

@ -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 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 getAdminDisplayNames() { return config.getBoolean("Commands.a.Use_Display_Names", true); }
public boolean getMatchOfflinePlayers() { return config.getBoolean("Commands.General.Match_OfflinePlayers", false); }
/* Mob Healthbar */ /* Mob Healthbar */
public MobHealthbarType getMobHealthbarDefault() { public MobHealthbarType getMobHealthbarDefault() {
try { try {

View File

@ -22,6 +22,7 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.MetadataValue; import org.bukkit.metadata.MetadataValue;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.events.items.McMMOItemSpawnEvent; import com.gmail.nossr50.events.items.McMMOItemSpawnEvent;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
@ -283,15 +284,25 @@ public final class Misc {
* Get a matched player name if one was found in the database. * Get a matched player name if one was found in the database.
* *
* @param partialName Name to match * @param partialName Name to match
*
* @return Matched name or {@code partialName} if no match was found * @return Matched name or {@code partialName} if no match was found
*/ */
public static String getMatchedPlayerName(String partialName) { public static String getMatchedPlayerName(String partialName) {
if (Config.getInstance().getMatchOfflinePlayers()) {
List<String> matches = matchPlayer(partialName); List<String> matches = matchPlayer(partialName);
if (matches.size() == 1) { if (matches.size() == 1) {
partialName = matches.get(0); partialName = matches.get(0);
} }
}
else {
Player player = mcMMO.p.getServer().getPlayer(partialName);
if (player != null) {
partialName = player.getName();
}
}
return partialName; return partialName;
} }

View File

@ -309,6 +309,10 @@ Double_Drops:
# Settings for commands # Settings for commands
### ###
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: mcmmo:
Donate_Message: true Donate_Message: true
inspect: inspect: