mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 05:03:34 -04:00
You can partially match award names in /award now.
This commit is contained in:
parent
9d390d88d9
commit
885872b017
@ -38,12 +38,9 @@ namespace MCGalaxy.Commands {
|
|||||||
if (plName == null) return;
|
if (plName == null) return;
|
||||||
|
|
||||||
string award = args.Length > 1 ? args[1] : "";
|
string award = args.Length > 1 ? args[1] : "";
|
||||||
award = Awards.Find(award);
|
int matches = 0;
|
||||||
if (award == null) {
|
award = Awards.FindMatches(p, award, out matches);
|
||||||
Player.Message(p, "The award you entered doesn't exist");
|
if (award == null) { Player.Message(p, "Use /awards for a list of awards"); return; }
|
||||||
Player.Message(p, "Use /awards for a list of awards");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!take) {
|
if (!take) {
|
||||||
if (Awards.GiveAward(plName, award)) {
|
if (Awards.GiveAward(plName, award)) {
|
||||||
|
@ -59,10 +59,7 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
static void AwardsListLineProcessor(string key, string value) {
|
static void AwardsListLineProcessor(string key, string value) {
|
||||||
if (value == "") return;
|
if (value == "") return;
|
||||||
Award award = new Award();
|
Add(key, value);
|
||||||
award.Name = key;
|
|
||||||
award.Description = value;
|
|
||||||
AwardsList.Add(award);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PlayerAwardsLineProcessor(string key, string value) {
|
static void PlayerAwardsLineProcessor(string key, string value) {
|
||||||
@ -110,6 +107,7 @@ namespace MCGalaxy {
|
|||||||
pl.Awards.Add(name);
|
pl.Awards.Add(name);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerAward newPl;
|
PlayerAward newPl;
|
||||||
newPl.Name = playerName;
|
newPl.Name = playerName;
|
||||||
newPl.Awards = new List<string>();
|
newPl.Awards = new List<string>();
|
||||||
@ -160,8 +158,8 @@ namespace MCGalaxy {
|
|||||||
if (Exists(name)) return false;
|
if (Exists(name)) return false;
|
||||||
|
|
||||||
Award award = new Award();
|
Award award = new Award();
|
||||||
award.Name = name;
|
award.Name = name.Trim();
|
||||||
award.Description = desc;
|
award.Description = desc.Trim();
|
||||||
AwardsList.Add(award);
|
AwardsList.Add(award);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -184,12 +182,18 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Whether an award with that name exists. </summary>
|
/// <summary> Whether an award with that name exists. </summary>
|
||||||
public static string Find(string name) {
|
public static string FindExact(string name) {
|
||||||
foreach (Award award in AwardsList)
|
foreach (Award award in AwardsList)
|
||||||
if (award.Name.CaselessEq(name)) return award.Name;
|
if (award.Name.CaselessEq(name)) return award.Name;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string FindMatches(Player p, string name, out int matches) {
|
||||||
|
Award award = Utils.FindMatches<Award>(p, name, out matches, AwardsList,
|
||||||
|
a => true, a => a.Name, "awards");
|
||||||
|
return award == null ? null : award.Name;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary> Gets the description of the award matching the given name,
|
/// <summary> Gets the description of the award matching the given name,
|
||||||
/// or an empty string if no matching award was found. </summary>
|
/// or an empty string if no matching award was found. </summary>
|
||||||
public static string GetDescription(string name) {
|
public static string GetDescription(string name) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user