Cleanup /eco help.

This commit is contained in:
UnknownShadow200 2016-08-27 21:58:51 +10:00
parent f2f1889c60
commit c197436b55
8 changed files with 96 additions and 88 deletions

View File

@ -30,29 +30,24 @@ namespace MCGalaxy.Commands {
public override void Use(Player p, string message) { public override void Use(Player p, string message) {
if (Player.IsSuper(p)) { MessageInGameOnly(p); return; } if (Player.IsSuper(p)) { MessageInGameOnly(p); return; }
string[] parts = message.Split(' '); string[] parts = message.Split(' ');
Item item = Economy.GetItem(parts[0]);
if (item == null) { Help(p); return; }
foreach (Item item in Economy.Items)
foreach (string alias in item.Aliases) if (!item.Enabled) {
{ Player.Message(p, "%cThe {0} item is not currently buyable.", item.Name); return;
if (!parts[0].CaselessEq(alias)) continue;
if (!item.Enabled) {
Player.Message(p, "%cThe {0} item is not currently buyable.", item.Name); return;
}
if (p.Rank < item.PurchaseRank) {
Formatter.MessageNeedMinPerm(p, "purchase a " + item.Name, item.PurchaseRank); return;
}
item.OnBuyCommand(this, p, message, parts);
return;
} }
Help(p); if (p.Rank < item.PurchaseRank) {
Formatter.MessageNeedMinPerm(p, "purchase a " + item.Name, item.PurchaseRank); return;
}
item.OnBuyCommand(this, p, message, parts);
} }
public override void Help(Player p) { public override void Help(Player p) {
Player.Message(p, "%T/buy [item] [value] <map name>"); Player.Message(p, "%T/buy [item] [value] <map name>");
Player.Message(p, "%Hmap name is only used for %T/buy map%H."); Player.Message(p, "%Hmap name is only used for %T/buy map%H.");
Player.Message(p, "%HUse %T/store [item] %Hto see more information for an item."); Player.Message(p, "%HUse %T/store [item] %Hto see more information for an item.");
Player.Message(p, "%H Available items: %f" + Economy.GetItemNames(", ")); Player.Message(p, "%H Available items: %S" + Economy.GetItemNames());
} }
} }
} }

View File

@ -1,7 +1,7 @@
/* /*
Copyright 2011 MCForge Copyright 2011 MCForge
Dual-licensed under the Educational Community License, Version 2.0 and Dual-licensed under the Educational Community License, Version 2.0 and
the GNU General Public License, Version 3 (the "Licenses"); you may the GNU General Public License, Version 3 (the "Licenses"); you may
not use this file except in compliance with the Licenses. You may not use this file except in compliance with the Licenses. You may
obtain a copy of the Licenses at obtain a copy of the Licenses at
@ -16,10 +16,8 @@
permissions and limitations under the Licenses. permissions and limitations under the Licenses.
*/ */
using System; using System;
using System.Globalization;
using System.Threading;
using MCGalaxy.Eco; using MCGalaxy.Eco;
using MCGalaxy.SQL;
namespace MCGalaxy.Commands { namespace MCGalaxy.Commands {
/// <summary> Economy Beta v1.0 QuantumHive </summary> /// <summary> Economy Beta v1.0 QuantumHive </summary>
@ -44,60 +42,49 @@ namespace MCGalaxy.Commands {
void HandleSetup(Player p, string[] args) { void HandleSetup(Player p, string[] args) {
if (!CheckExtraPerm(p)) { MessageNeedExtra(p, "setup the economy."); return; } if (!CheckExtraPerm(p)) { MessageNeedExtra(p, "setup the economy."); return; }
switch (args[0].ToLower()) { if (args[0].CaselessEq("apply")) {
case "apply": Economy.Load();
Economy.Load(); Player.Message(p, "%aApplied changes");
Player.Message(p, "%aApplied changes"); } else if (args[0].CaselessEq("enable")) {
return; Player.Message(p, "%aThe economy system is now enabled");
Economy.Enabled = true; Economy.Save();
case "enable": } else if (args[0].CaselessEq("disable")) {
Player.Message(p, "%aThe economy system is now enabled"); Player.Message(p, "%aThe economy system is now disabled");
Economy.Enabled = true; Economy.Enabled = false; Economy.Save();
} else if (args[0].CaselessEq("help")) {
SetupHelp(p, args);
} else {
Item item = Economy.GetItem(args[0]);
if (item != null) {
item.OnSetupCommand(p, args);
Economy.Save(); return; Economy.Save(); return;
}
case "disable":
Player.Message(p, "%aThe economy system is now disabled"); if (args[1] == "") { SetupHelp(p, args); return; }
Economy.Enabled = false; Player.Message(p, "%cThat wasn't a valid command addition!");
Economy.Save();return;
case "help":
SetupHelp(p); return;
default:
foreach (Item item in Economy.Items)
foreach (string alias in item.Aliases)
{
if (args[0].CaselessEq(alias)) {
item.OnSetupCommand(p, args);
Economy.Save(); return;
}
}
if (args[1] == "") { SetupHelp(p); return; }
Player.Message(p, "%cThat wasn't a valid command addition!");
return;
} }
} }
public override void Help(Player p) { public override void Help(Player p) {
Player.Message(p, "%cMost commands have been removed from /economy, " + Player.Message(p, "%cMost commands have been removed from /economy, " +
"use the appropriate command from %T/help economy %cinstead."); "use the appropriate command from %T/help economy %cinstead.");
if (CheckExtraPerm(p)) { if (CheckExtraPerm(p)) {
Player.Message(p, "%f/eco <type> %e- to setup economy"); Player.Message(p, "%T/eco <type> %H- to setup economy");
Player.Message(p, "%f/eco help %e- get more specific help for setting up the economy"); Player.Message(p, "%T/eco help %H- get more specific help for setting up the economy");
} }
} }
void SetupHelp(Player p) { void SetupHelp(Player p, string[] args) {
Player.Message(p, "%4/eco apply %e- reloads changes made to 'economy.properties'"); if (args[1] == "") {
Player.Message(p, "%4/eco [%aenable%4/%cdisable%4] %e- to enable/disable the economy system"); Player.Message(p, "%T/eco apply %H- Reload changes made to 'economy.properties'");
Player.Message(p, "%4/eco [title/color/tcolor/rank/map] [%aenable%4/%cdisable%4] %e- to enable/disable that feature"); Player.Message(p, "%T/eco enable/disable %H- Enables/disables the economy system");
Player.Message(p, "%4/eco [title/color/tcolor] [%3price%4] %e- to setup the prices for these features"); Player.Message(p, "%T/eco help [item] %H- Outputs help for setting up that item");
Player.Message(p, "%4/eco rank price [%frank%4] [%3price%4] %e- to set the price for that rank"); Player.Message(p, " %HAll items: %S" + Economy.Items.Join(item => item.Name));
Player.Message(p, "%4/eco rank maxrank [%frank%4] %e- to set the max buyable rank"); } else {
Player.Message(p, "%4/eco map new [%fname%4] [%fx%4] [%fy%4] [%fz%4] [%ftype%4] [%3price%4] %e- to setup a map preset"); Item item = Economy.GetItem(args[1]);
Player.Message(p, "%4/eco map delete [%fname%4] %e- to delete a map"); if (item == null) { Player.Message(p, "No item by that name, see %T/eco help %Sfor a list of items."); return; }
Player.Message(p, "%4/eco map edit [%fname%4] [name/x/y/z/type/price] [%fvalue%4] %e- to edit a map preset"); item.OnSetupCommandHelp(p);
}
} }
} }
} }

View File

@ -18,7 +18,7 @@
using System; using System;
using MCGalaxy.Eco; using MCGalaxy.Eco;
namespace MCGalaxy.Commands { namespace MCGalaxy.Commands {
public sealed class CmdStore : Command { public sealed class CmdStore : Command {
public override string name { get { return "store"; } } public override string name { get { return "store"; } }
public override string shortcut { get { return "shop"; } } public override string shortcut { get { return "shop"; } }
@ -28,30 +28,24 @@ namespace MCGalaxy.Commands {
public override CommandEnable Enabled { get { return CommandEnable.Economy; } } public override CommandEnable Enabled { get { return CommandEnable.Economy; } }
public override CommandAlias[] Aliases { public override CommandAlias[] Aliases {
get { return new[] { new CommandAlias("item") }; } get { return new[] { new CommandAlias("item") }; }
} }
public override void Use(Player p, string message) { public override void Use(Player p, string message) {
if (message == "") { if (message == "") {
foreach (Item item in Economy.Items) { foreach (Item item in Economy.Items) {
if (!item.Enabled) continue; if (!item.Enabled) continue;
item.OnStoreOverview(p); item.OnStoreOverview(p);
} }
Player.Message(p, "%HUse %T/store [item] %Hto see more information about that item."); Player.Message(p, "%HUse %T/store [item] %Hto see more information about that item.");
return; } else {
} Item item = Economy.GetItem(message);
if (item == null) { Help(p); return; }
foreach (Item item in Economy.Items)
foreach (string alias in item.Aliases) if (!item.Enabled) {
{ Player.Message(p, "%cThe " + item.ShopName + " item is not currently buyable."); return;
if (message.CaselessEq(alias)) {
if (!item.Enabled) {
Player.Message(p, "%cThe " + item.ShopName + " item is not currently buyable."); return;
}
item.OnStoreCommand(p);
return;
} }
item.OnStoreCommand(p);
} }
Help(p);
} }
public override void Help(Player p) { public override void Help(Player p) {
@ -59,7 +53,7 @@ namespace MCGalaxy.Commands {
Player.Message(p, "%HViews information about the specific item, such as its cost."); Player.Message(p, "%HViews information about the specific item, such as its cost.");
Player.Message(p, "%T/store"); Player.Message(p, "%T/store");
Player.Message(p, "%HViews information about all enabled items."); Player.Message(p, "%HViews information about all enabled items.");
Player.Message(p, "%H Available items: %f" + Economy.GetItemNames(", ")); Player.Message(p, "%H Available items: %S" + Economy.GetItemNames());
} }
} }
} }

View File

@ -153,12 +153,16 @@ PRIMARY KEY(player)
public static Item GetItem(string name) { public static Item GetItem(string name) {
foreach (Item item in Items) { foreach (Item item in Items) {
if (name.CaselessEq(item.Name)) return item; if (name.CaselessEq(item.Name)) return item;
foreach (string alias in item.Aliases) {
if (name.CaselessEq(alias)) return item;
}
} }
return null; return null;
} }
public static string GetItemNames(string separator) { public static string GetItemNames() {
string items = Items.Join(x => x.Enabled ? x.ShopName : null, separator); string items = Items.Join(x => x.Enabled ? x.ShopName : null);
return items.Length == 0 ? "(no enabled items)" : items; return items.Length == 0 ? "(no enabled items)" : items;
} }

View File

@ -70,6 +70,13 @@ namespace MCGalaxy.Eco {
} }
protected internal abstract void OnSetupCommandOther(Player p, string[] args); protected internal abstract void OnSetupCommandOther(Player p, string[] args);
protected internal virtual void OnSetupCommandHelp(Player p) {
Player.Message(p, "%T/eco {0} enable/disable", Name.ToLower());
Player.Message(p, "%HEnables/disables purchasing this item.");
Player.Message(p, "%T/eco {0} purchaserank [rank]", Name.ToLower());
Player.Message(p, "%HSets the lowest rank which can purchase this item.");
}
protected internal abstract void OnStoreOverview(Player p); protected internal abstract void OnStoreOverview(Player p);
@ -125,6 +132,12 @@ namespace MCGalaxy.Eco {
} }
} }
protected internal override void OnSetupCommandHelp(Player p) {
base.OnSetupCommandHelp(p);
Player.Message(p, "%T/eco {0} price [amount]", Name.ToLower());
Player.Message(p, "%HSets how many &3{0} %Hthis item costs.", Server.moneys);
}
protected internal override void OnStoreOverview(Player p) { protected internal override void OnStoreOverview(Player p) {
if (p == null || p.Rank >= PurchaseRank) { if (p == null || p.Rank >= PurchaseRank) {
Player.Message(p, "{0} - costs &f{1} &3{2}", Name, Price, Server.moneys); Player.Message(p, "{0} - costs &f{1} &3{2}", Name, Price, Server.moneys);

View File

@ -204,17 +204,24 @@ namespace MCGalaxy.Eco {
break; break;
default: default:
Player.Message(p, "%cThat wasn't a valid command addition!"); Player.Message(p, "Supported properties to edit: name, title, x, y, z, type, price");
break; break;
} }
break; break;
default: default:
Player.Message(p, "%cThat wasn't a valid command addition!"); OnSetupCommandHelp(p); break;
break;
} }
} }
protected internal override void OnSetupCommandHelp(Player p) {
base.OnSetupCommandHelp(p);
Player.Message(p, "%T/eco level add [name] [x] [y] [z] [type] [price]");
Player.Message(p, "%T/eco level remove [name]");
Player.Message(p, "%T/eco level edit [name] [name/x/y/z/type/price] [value]");
Player.Message(p, "%HAdds, removes, or edits a level preset.");
}
protected internal override void OnStoreOverview(Player p) { protected internal override void OnStoreOverview(Player p) {
Player.Message(p, "Maps - see /store maps"); Player.Message(p, "Maps - see /store maps");
} }

View File

@ -110,9 +110,17 @@ namespace MCGalaxy.Eco {
UpdatePrices(); UpdatePrices();
break; break;
default: default:
Player.Message(p, "Supported actions: enable, disable, price [rank] [cost], maxrank [rank]"); break; OnSetupCommandHelp(p); break;
} }
} }
protected internal override void OnSetupCommandHelp(Player p) {
base.OnSetupCommandHelp(p);
Player.Message(p, "%T/eco rank price [rank] [amount]");
Player.Message(p, "%HSets how many &3{0} %Hthat rank costs.", Server.moneys);
Player.Message(p, "%T/eco rank maxrank [rank]");
Player.Message(p, "%HSets the maximum rank that can be bought.", Server.moneys);
}
protected internal override void OnStoreOverview(Player p) { protected internal override void OnStoreOverview(Player p) {
Group maxrank = Group.Find(MaxRank); Group maxrank = Group.Find(MaxRank);

View File

@ -61,7 +61,7 @@ namespace MCGalaxy.Games {
p.Game.BlocksLeft--; p.Game.BlocksLeft--;
if ((p.Game.BlocksLeft % 10) == 0 || (p.Game.BlocksLeft >= 0 && p.Game.BlocksLeft <= 10)) if ((p.Game.BlocksLeft % 10) == 0 || (p.Game.BlocksLeft >= 0 && p.Game.BlocksLeft <= 10))
p.SendMessage("Blocks Left: " + Colors.maroon + p.Game.BlocksLeft); p.SendMessage("Blocks Left: &4" + p.Game.BlocksLeft);
} }
return false; return false;
} }