No longer need to always add 'setup' in /eco.

This commit is contained in:
UnknownShadow200 2016-03-26 08:29:05 +11:00
parent 734ddd5088
commit be4a50e0be
4 changed files with 244 additions and 247 deletions

View File

@ -35,14 +35,10 @@ namespace MCGalaxy.Commands {
public override void Use(Player p, string message) {
string[] raw = message.Split(' ');
string[] args = { "", "", "", "", "", "", "", "", "" };
for (int i = 0; i < raw.Length; i++)
args[i] = i < 2 ? raw[i].ToLower() : raw[i];
if (args[0] == "setup")
string[] args = { "", "", "", "", "", "", "", "" };
for (int i = 0; i < Math.Min(args.Length, raw.Length); i++)
args[i] = raw[i];
HandleSetup(p, message, args);
else
Help(p);
}
void HandleSetup(Player p, string message, string[] args) {
@ -50,7 +46,7 @@ namespace MCGalaxy.Commands {
Player.SendMessage(p, "%cYou are not allowed to use %f/eco setup"); return;
}
switch (args[1]) {
switch (args[0].ToLower()) {
case "apply":
Economy.Load();
Player.SendMessage(p, "%aApplied changes");
@ -58,11 +54,13 @@ namespace MCGalaxy.Commands {
case "enable":
Player.SendMessage(p, "%aThe economy system is now enabled");
Economy.Enabled = true; return;
Economy.Enabled = true;
Economy.Save(); return;
case "disable":
Player.SendMessage(p, "%aThe economy system is now disabled");
Economy.Enabled = false; return;
Economy.Enabled = false;
Economy.Save();return;
case "help":
SetupHelp(p); return;
@ -71,7 +69,7 @@ namespace MCGalaxy.Commands {
foreach (Item item in Economy.Items)
foreach (string alias in item.Aliases)
{
if (args[1].CaselessEq(alias)) {
if (args[0].CaselessEq(alias)) {
item.OnSetupCommand(p, args);
Economy.Save(); return;
}
@ -81,28 +79,27 @@ namespace MCGalaxy.Commands {
Player.SendMessage(p, "%cThat wasn't a valid command addition!");
return;
}
Economy.Save();
}
public override void Help(Player p) {
Player.SendMessage(p, "%cMost commands have been removed from /economy, " +
"use the appropriate command from %T/help economy %cinstead.");
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this)) {
Player.SendMessage(p, "%f/eco setup <type> %e- to setup economy");
Player.SendMessage(p, "%f/eco setup help %e- get more specific help for setting up the economy");
Player.SendMessage(p, "%f/eco <type> %e- to setup economy");
Player.SendMessage(p, "%f/eco help %e- get more specific help for setting up the economy");
}
}
void SetupHelp(Player p) {
Player.SendMessage(p, "%4/eco setup apply %e- reloads changes made to 'economy.properties'");
Player.SendMessage(p, "%4/eco setup [%aenable%4/%cdisable%4] %e- to enable/disable the economy system");
Player.SendMessage(p, "%4/eco setup [title/color/tcolor/rank/map] [%aenable%4/%cdisable%4] %e- to enable/disable that feature");
Player.SendMessage(p, "%4/eco setup [title/color/tcolor] [%3price%4] %e- to setup the prices for these features");
Player.SendMessage(p, "%4/eco setup rank price [%frank%4] [%3price%4] %e- to set the price for that rank");
Player.SendMessage(p, "%4/eco setup rank maxrank [%frank%4] %e- to set the max buyable rank");
Player.SendMessage(p, "%4/eco setup map new [%fname%4] [%fx%4] [%fy%4] [%fz%4] [%ftype%4] [%3price%4] %e- to setup a map preset");
Player.SendMessage(p, "%4/eco setup map delete [%fname%4] %e- to delete a map");
Player.SendMessage(p, "%4/eco setup map edit [%fname%4] [name/x/y/z/type/price] [%fvalue%4] %e- to edit a map preset");
Player.SendMessage(p, "%4/eco apply %e- reloads changes made to 'economy.properties'");
Player.SendMessage(p, "%4/eco [%aenable%4/%cdisable%4] %e- to enable/disable the economy system");
Player.SendMessage(p, "%4/eco [title/color/tcolor/rank/map] [%aenable%4/%cdisable%4] %e- to enable/disable that feature");
Player.SendMessage(p, "%4/eco [title/color/tcolor] [%3price%4] %e- to setup the prices for these features");
Player.SendMessage(p, "%4/eco rank price [%frank%4] [%3price%4] %e- to set the price for that rank");
Player.SendMessage(p, "%4/eco rank maxrank [%frank%4] %e- to set the max buyable rank");
Player.SendMessage(p, "%4/eco map new [%fname%4] [%fx%4] [%fy%4] [%fz%4] [%ftype%4] [%3price%4] %e- to setup a map preset");
Player.SendMessage(p, "%4/eco map delete [%fname%4] %e- to delete a map");
Player.SendMessage(p, "%4/eco map edit [%fname%4] [name/x/y/z/type/price] [%fvalue%4] %e- to edit a map preset");
}
}
}

View File

@ -98,7 +98,7 @@ namespace MCGalaxy.Eco {
protected abstract void OnBuyCommand(Player p, string message, string[] args);
protected internal override void OnSetupCommand(Player p, string[] args) {
switch (args[2]) {
switch (args[1].ToLower()) {
case "enable":
Player.SendMessage(p, "%a" + Name + "s are now enabled for the economy system.");
Enabled = true; break;
@ -107,8 +107,8 @@ namespace MCGalaxy.Eco {
Enabled = false; break;
case "price":
int cost;
if (!int.TryParse(args[3], out cost)) {
Player.SendMessage(p, "\"" + args[3] + "\" is not a valid integer."); return;
if (!int.TryParse(args[2], out cost)) {
Player.SendMessage(p, "\"" + args[2] + "\" is not a valid integer."); return;
}
Player.SendMessage(p, "%aSuccessfully changed the " + Name + " price to %f" + cost + " %3" + Server.moneys);
Price = cost; break;

View File

@ -116,24 +116,24 @@ namespace MCGalaxy.Eco {
}
protected internal override void OnSetupCommand(Player p, string[] args) {
LevelPreset preset = FindPreset(args[3]);
switch (args[2]) {
LevelPreset preset = FindPreset(args[2]);
switch (args[1].ToLower()) {
case "new":
case "create":
case "add":
if (preset != null) { Player.SendMessage(p, "%cThat preset level already exists"); return; }
preset = new LevelPreset();
preset.name = args[3];
if (OkayAxis(args[4]) && OkayAxis(args[5]) && OkayAxis(args[6])) {
preset.x = args[4]; preset.y = args[5]; preset.z = args[6];
preset.name = args[2];
if (OkayAxis(args[3]) && OkayAxis(args[4]) && OkayAxis(args[5])) {
preset.x = args[3]; preset.y = args[4]; preset.z = args[5];
} else { Player.SendMessage(p, "%cDimension must be a power of 2"); break; }
if (!MapGen.IsRecognisedFormat(args[7])) {
if (!MapGen.IsRecognisedFormat(args[6])) {
MapGen.PrintValidFormats(p); return;
}
preset.type = args[7].ToLower();
if (!int.TryParse(args[8], out preset.price)) {
preset.type = args[6].ToLower();
if (!int.TryParse(args[7], out preset.price)) {
Player.SendMessage(p, "\"" + args[9] + "\" is not a valid integer."); return;
}
@ -156,37 +156,37 @@ namespace MCGalaxy.Eco {
case "change":
if (preset == null) { Player.SendMessage(p, "%cThat preset level doesn't exist"); return; }
switch (args[4]) {
switch (args[3]) {
case "name":
case "title":
preset.name = args[5];
preset.name = args[4];
Player.SendMessage(p, "%aSuccessfully changed preset name to %f" + preset.name);
break;
case "x":
if (OkayAxis(args[5])) {
preset.x = args[5];
if (OkayAxis(args[4])) {
preset.x = args[4];
Player.SendMessage(p, "%aSuccessfully changed preset x size to %f" + preset.x);
} else { Player.SendMessage(p, "%cDimension was wrong, it must be a power of 2"); break; }
break;
case "y":
if (OkayAxis(args[5])) {
preset.y = args[5];
if (OkayAxis(args[4])) {
preset.y = args[4];
Player.SendMessage(p, "%aSuccessfully changed preset y size to %f" + preset.y);
} else { Player.SendMessage(p, "%cDimension was wrong, it must be a power of 2"); break; }
break;
case "z":
if (OkayAxis(args[5])) {
preset.z = args[5];
if (OkayAxis(args[4])) {
preset.z = args[4];
Player.SendMessage(p, "%aSuccessfully changed preset z size to %f" + preset.z);
} else { Player.SendMessage(p, "%cDimension was wrong, it must be a power of 2"); break; }
break;
case "type":
if (MapGen.IsRecognisedFormat(args[5])) {
preset.type = args[5].ToLower();
if (MapGen.IsRecognisedFormat(args[4])) {
preset.type = args[4].ToLower();
} else {
MapGen.PrintValidFormats(p); return;
}
@ -195,8 +195,8 @@ namespace MCGalaxy.Eco {
case "price":
int newPrice = 0;
if (!int.TryParse(args[5], out newPrice)) {
Player.SendMessage(p, "\"" + args[5] + "\" is not a valid integer."); return;
if (!int.TryParse(args[4], out newPrice)) {
Player.SendMessage(p, "\"" + args[4] + "\" is not a valid integer."); return;
}
if (newPrice < 0) {
Player.SendMessage(p, "%cAmount of %3" + Server.moneys + "%c cannot be negative"); return;

View File

@ -85,7 +85,7 @@ namespace MCGalaxy.Eco {
}
protected internal override void OnSetupCommand(Player p, string[] args) {
switch (args[2]) {
switch (args[1].ToLower()) {
case "enable":
Player.SendMessage(p, "%a" + Name + "s are now enabled for the economy system.");
Enabled = true; break;
@ -93,12 +93,12 @@ namespace MCGalaxy.Eco {
Player.SendMessage(p, "%a" + Name + "s are now disabled for the economy system.");
Enabled = false; break;
case "price":
Rank rnk = FindRank(args[3]);
Rank rnk = FindRank(args[2]);
if (rnk == null) {
Player.SendMessage(p, "%cThat wasn't a rank or it's past the max rank (maxrank is: " + Group.Find(MaxRank).color + MaxRank + "%c)"); return; }
int cost;
if (!int.TryParse(args[4], out cost)) {
Player.SendMessage(p, "\"" + args[4] + "\" is not a valid integer."); return;
if (!int.TryParse(args[3], out cost)) {
Player.SendMessage(p, "\"" + args[3] + "\" is not a valid integer."); return;
}
Player.SendMessage(p, "%aSuccesfully changed the rank price for " + rnk.group.color + rnk.group.name + " to: %f" + cost + " %3" + Server.moneys);
rnk.price = cost; break;
@ -107,10 +107,10 @@ namespace MCGalaxy.Eco {
case "max":
case "maximum":
case "maximumrank":
Group grp = Group.Find(args[3]);
Group grp = Group.Find(args[2]);
if (grp == null) { Player.SendMessage(p, "%cThat wasn't a rank!"); return; }
if (p.group.Permission < grp.Permission) { Player.SendMessage(p, "%cCan't set a maxrank that is higher than yours!"); return; }
MaxRank = args[3].ToLower();
MaxRank = args[2].ToLower();
Player.SendMessage(p, "%aSuccessfully set max rank to: " + grp.color + grp.name);
UpdatePrices();
break;