Separate /economy into separate functions. It's still an utter mess though.

This commit is contained in:
UnknownShadow200 2016-03-14 16:47:08 +11:00
parent 21ea77eba9
commit 72e0bdd7fc

View File

@ -14,7 +14,7 @@
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the Licenses for the specific language governing
permissions and limitations under the Licenses.
*/
*/
using System;
using System.Globalization;
using System.Threading;
@ -34,32 +34,36 @@ namespace MCGalaxy.Commands {
}
public override void Use(Player p, string message) {
string[] command = message.Trim().Split(' ');
string par0 = String.Empty;
string par1 = String.Empty;
string par2 = String.Empty;
string par3 = String.Empty;
string par4 = String.Empty;
string par5 = String.Empty;
string par6 = String.Empty;
string par7 = String.Empty;
string par8 = String.Empty;
try {
par0 = command[0].ToLower();
par1 = command[1].ToLower();
par2 = command[2];
par3 = command[3];
par4 = command[4];
par5 = command[5];
par6 = command[6];
par7 = command[7];
par8 = command[8];
} catch { }
string ecoColor = "%3";
switch (par0) {
string[] raw = message.Split(' ');
string[] args = { "", "", "", "", "", "", "", "", "" };
for (int i = 0; i < raw.Length; i++)
args[i] = i < 2 ? raw[i].ToLower() : raw[i];
switch (args[0]) {
case "setup":
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this)) {
switch (par1) {
HandleSetup(p, message, args); break;
case "buy":
HandleBuy(p, message, args); break;
case "stats":
case "balance":
case "amount":
HandleStats(p, message, args); break;
case "info":
case "about":
HandleInfo(p, message, args); break;
case "help":
HandleHelp(p, message, args); break;
default:
Help(p); break;
}
}
void HandleSetup(Player p, string message, string[] args) {
if (p != null && (int)p.group.Permission < CommandOtherPerms.GetPerm(this)) {
Player.SendMessage(p, "%cYou are not allowed to use %f/eco setup"); return;
}
switch (args[1]) {
case "apply":
if (p == null || p.name == Server.server_owner) {
Economy.Load();
@ -72,16 +76,16 @@ namespace MCGalaxy.Commands {
case "levels":
case "map":
case "level":
Economy.Settings.Level lvl = Economy.FindLevel(par3);
switch (par2) {
Economy.Settings.Level lvl = Economy.FindLevel(args[3]);
switch (args[2]) {
case "new":
case "create":
case "add":
if (Economy.FindLevel(par3) != null) { Player.SendMessage(p, "%cThat preset level already exists"); break; } else {
if (Economy.FindLevel(args[3]) != null) { Player.SendMessage(p, "%cThat preset level already exists"); break; } else {
Economy.Settings.Level level = new Economy.Settings.Level();
level.name = par3;
if (isGood(par4) && isGood(par5) && isGood(par6)) { level.x = par4; level.y = par5; level.z = par6; } else { Player.SendMessage(p, "%cDimension must be a power of 2"); break; }
switch (par7.ToLower()) {
level.name = args[3];
if (isGood(args[4]) && isGood(args[5]) && isGood(args[6])) { level.x = args[4]; level.y = args[5]; level.z = args[6]; } else { Player.SendMessage(p, "%cDimension must be a power of 2"); break; }
switch (args[7].ToLower()) {
case "flat":
case "pixel":
case "island":
@ -90,7 +94,7 @@ namespace MCGalaxy.Commands {
case "forest":
case "desert":
case "space":
level.type = par7.ToLower();
level.type = args[7].ToLower();
break;
default:
@ -98,7 +102,7 @@ namespace MCGalaxy.Commands {
break;
}
try {
level.price = int.Parse(par8);
level.price = int.Parse(args[8]);
} catch { Player.SendMessage(p, "%cInvalid price input: that wasn't a number!"); return; }
Economy.Settings.LevelsList.Add(level);
Player.SendMessage(p, "%aSuccessfully added the map preset with the following specs:");
@ -116,37 +120,37 @@ namespace MCGalaxy.Commands {
case "edit":
case "change":
if (lvl == null) { Player.SendMessage(p, "%cThat preset level doesn't exist"); break; } else {
switch (par4) {
switch (args[4]) {
case "name":
case "title":
Economy.Settings.LevelsList.Remove(lvl);
lvl.name = par5;
lvl.name = args[5];
Economy.Settings.LevelsList.Add(lvl);
Player.SendMessage(p, "%aSuccessfully changed preset name to %f" + lvl.name);
break;
case "x":
if (isGood(par5)) {
if (isGood(args[5])) {
Economy.Settings.LevelsList.Remove(lvl);
lvl.x = par5;
lvl.x = args[5];
Economy.Settings.LevelsList.Add(lvl);
Player.SendMessage(p, "%aSuccessfully changed preset x size to %f" + lvl.x);
} else { Player.SendMessage(p, "%cDimension was wrong, it must be a power of 2"); break; }
break;
case "y":
if (isGood(par5)) {
if (isGood(args[5])) {
Economy.Settings.LevelsList.Remove(lvl);
lvl.y = par5;
lvl.y = args[5];
Economy.Settings.LevelsList.Add(lvl);
Player.SendMessage(p, "%aSuccessfully changed preset y size to %f" + lvl.y);
} else { Player.SendMessage(p, "%cDimension was wrong, it must be a power of 2"); break; }
break;
case "z":
if (isGood(par5)) {
if (isGood(args[5])) {
Economy.Settings.LevelsList.Remove(lvl);
lvl.z = par5;
lvl.z = args[5];
Economy.Settings.LevelsList.Add(lvl);
Player.SendMessage(p, "%aSuccessfully changed preset z size to %f" + lvl.z);
} else { Player.SendMessage(p, "%cDimension was wrong, it must be a power of 2"); break; }
@ -154,7 +158,7 @@ namespace MCGalaxy.Commands {
case "type":
Economy.Settings.LevelsList.Remove(lvl);
switch (par5.ToLower()) {
switch (args[5].ToLower()) {
case "flat":
case "pixel":
case "island":
@ -163,7 +167,7 @@ namespace MCGalaxy.Commands {
case "forest":
case "desert":
case "space":
lvl.type = par5.ToLower();
lvl.type = args[5].ToLower();
break;
default:
@ -180,9 +184,9 @@ namespace MCGalaxy.Commands {
case "dimension":
case "size":
Economy.Settings.LevelsList.Remove(lvl);
if (isGood(par4)) { lvl.x = par4; }
if (isGood(par5)) { lvl.y = par5; }
if (isGood(par6)) { lvl.z = par6; } else { Player.SendMessage(p, "A Dimension was wrong, it must a power of 2"); Economy.Settings.LevelsList.Add(lvl); break; }
if (isGood(args[4])) { lvl.x = args[4]; }
if (isGood(args[5])) { lvl.y = args[5]; }
if (isGood(args[6])) { lvl.z = args[6]; } else { Player.SendMessage(p, "A Dimension was wrong, it must a power of 2"); Economy.Settings.LevelsList.Add(lvl); break; }
Economy.Settings.LevelsList.Add(lvl);
Player.SendMessage(p, "Changed preset name");
break;*/
@ -191,7 +195,7 @@ namespace MCGalaxy.Commands {
Economy.Settings.LevelsList.Remove(lvl);
int old = lvl.price;
try {
lvl.price = int.Parse(par5);
lvl.price = int.Parse(args[5]);
} catch {
Economy.Settings.LevelsList.Add(lvl);
Player.SendMessage(p, "%cInvalid amount of %3" + Server.moneys);
@ -223,7 +227,7 @@ namespace MCGalaxy.Commands {
case "titles":
case "title":
switch (par2) {
switch (args[2]) {
case "enable":
if (Economy.Settings.Titles) { Player.SendMessage(p, "%cTitles are already enabled for the economy system"); break; } else { Economy.Settings.Titles = true; Player.SendMessage(p, "%aTitles are now enabled for the economy system"); break; }
@ -232,7 +236,7 @@ namespace MCGalaxy.Commands {
case "price":
try {
Economy.Settings.TitlePrice = int.Parse(par3);
Economy.Settings.TitlePrice = int.Parse(args[3]);
} catch { Player.SendMessage(p, "%cInvalid price input: that wasn't a number!"); return; }
Player.SendMessage(p, "%aSuccessfully changed the title price to: %f" + Economy.Settings.TitlePrice + " %3" + Server.moneys);
break;
@ -247,7 +251,7 @@ namespace MCGalaxy.Commands {
case "colours":
case "color":
case "colour":
switch (par2) {
switch (args[2]) {
case "enable":
if (Economy.Settings.Colors) { Player.SendMessage(p, "%cColors are already enabled for the economy system"); break; } else { Economy.Settings.Colors = true; Player.SendMessage(p, "%aColors are now enabled for the economy system"); break; }
@ -256,7 +260,7 @@ namespace MCGalaxy.Commands {
case "price":
try {
Economy.Settings.ColorPrice = int.Parse(par3);
Economy.Settings.ColorPrice = int.Parse(args[3]);
} catch { Player.SendMessage(p, "%cInvalid price input: that wasn't a number!"); return; }
Player.SendMessage(p, "Successfully changed the color price to %f" + Economy.Settings.ColorPrice + " %3" + Server.moneys);
break;
@ -271,7 +275,7 @@ namespace MCGalaxy.Commands {
case "titlecolor":
case "titlecolors":
case "tc":
switch (par2) {
switch (args[2]) {
case "enable":
if (Economy.Settings.TColors) Player.SendMessage(p, "%cTitleColors are already enabled for the economy system");
else { Economy.Settings.TColors = true; Player.SendMessage(p, "%aTitleColors are now enabled for the economy system"); }
@ -282,7 +286,7 @@ namespace MCGalaxy.Commands {
break;
case "price":
try {
Economy.Settings.TColorPrice = int.Parse(par3);
Economy.Settings.TColorPrice = int.Parse(args[3]);
} catch { Player.SendMessage(p, "%cInvalid price input: that wasn't a number!"); return; }
Player.SendMessage(p, "%aSuccessfully changed the titlecolor price to %f" + Economy.Settings.TColorPrice + " %3" + Server.moneys);
break;
@ -293,7 +297,7 @@ namespace MCGalaxy.Commands {
break;
case "ranks":
case "rank":
switch (par2) {
switch (args[2]) {
case "enable":
if (Economy.Settings.Ranks) { Player.SendMessage(p, "%cRanks are already enabled for the economy system"); break; } else { Economy.Settings.Ranks = true; Player.SendMessage(p, "%aRanks are now enabled for the economy system"); break; }
@ -301,10 +305,10 @@ namespace MCGalaxy.Commands {
if (Economy.Settings.Ranks == false) { Player.SendMessage(p, "%cRanks are already disabled for the economy system"); break; } else { Economy.Settings.Ranks = false; Player.SendMessage(p, "%aRanks are now disabled for the economy system"); break; }
case "price":
Economy.Settings.Rank rnk = Economy.FindRank(par3);
Economy.Settings.Rank rnk = Economy.FindRank(args[3]);
if (rnk == null) { Player.SendMessage(p, "%cThat wasn't a rank or it's past the max rank (maxrank is: " + Group.Find(Economy.Settings.MaxRank).color + Economy.Settings.MaxRank + "%c)"); break; } else {
try {
rnk.price = int.Parse(par4);
rnk.price = int.Parse(args[4]);
} catch { Player.SendMessage(p, "%cInvalid price input: that wasn't a number!"); return; }
Player.SendMessage(p, "%aSuccesfully changed the rank price for " + rnk.group.color + rnk.group.name + " to: %f" + rnk.price + " %3" + Server.moneys);
break;
@ -314,10 +318,10 @@ namespace MCGalaxy.Commands {
case "max":
case "maximum":
case "maximumrank":
Group grp = Group.Find(par3);
Group grp = Group.Find(args[3]);
if (grp == null) { Player.SendMessage(p, "%cThat wasn't a rank!"); } else {
if (p.group.Permission < grp.Permission) { Player.SendMessage(p, "%cCan't set a maxrank that is higher than yours!"); } else {
Economy.Settings.MaxRank = par3.ToLower(); Player.SendMessage(p, "%aSuccessfully set max rank to: " + Group.Find(Economy.Settings.MaxRank).color + Economy.Settings.MaxRank);
Economy.Settings.MaxRank = args[3].ToLower(); Player.SendMessage(p, "%aSuccessfully set max rank to: " + Group.Find(Economy.Settings.MaxRank).color + Economy.Settings.MaxRank);
int lasttrueprice = 0;
foreach (Group group in Group.GroupList) {
if (group.Permission > grp.Permission) { break; }
@ -342,59 +346,55 @@ namespace MCGalaxy.Commands {
break;
case "enable":
if (Economy.Settings.Enabled) { Player.SendMessage(p, "%cThe economy system is already enabled"); return; } else { Economy.Settings.Enabled = true; Player.SendMessage(p, "%aThe economy system is now enabled"); return; }
if (Economy.Settings.Enabled) { Player.SendMessage(p, "%cThe economy system is already enabled"); return; }
else { Economy.Settings.Enabled = true; Player.SendMessage(p, "%aThe economy system is now enabled"); return; }
case "disable":
if (Economy.Settings.Enabled == false) { Player.SendMessage(p, "%cThe economy system is already disabled"); return; } else { Economy.Settings.Enabled = false; Player.SendMessage(p, "%aThe economy system is now disabled"); return; }
if (!Economy.Settings.Enabled) { Player.SendMessage(p, "%cThe economy system is already disabled"); return; }
else { Economy.Settings.Enabled = false; Player.SendMessage(p, "%aThe economy system is now disabled"); return; }
default:
if (par1 == null || par1 == "") {
SetupHelp(p);
return;
}
if (args[1] == "") { SetupHelp(p); return; }
Player.SendMessage(p, "%cThat wasn't a valid command addition!");
return;
}
Economy.Save();
return;
} else { Player.SendMessage(p, "%cYou are not allowed to use %f/eco setup"); return; }
}
case "buy":
void HandleBuy(Player p, string message, string[] args) {
if (p == null) { Player.SendMessage(p, "%cConsole cannot buy any items"); return; }
Economy.EcoStats ecos = Economy.RetrieveEcoStats(p.name);
switch (par1) {
switch (args[1]) {
case "map":
case "level":
case "maps":
case "levels":
Economy.Settings.Level lvl = Economy.FindLevel(par2);
Economy.Settings.Level lvl = Economy.FindLevel(args[2]);
if (lvl == null) { Player.SendMessage(p, "%cThat isn't a level preset"); return; } else {
if (!p.EnoughMoney(lvl.price)) {
Player.SendMessage(p, "%cYou don't have enough %3" + Server.moneys + "%c to buy that map");
return;
} else {
if (par3 == null) { Player.SendMessage(p, "%cYou didn't specify a name for your level"); return; } else {
if (args[3] == null) { Player.SendMessage(p, "%cYou didn't specify a name for your level"); return; } else {
int old = p.money;
int oldTS = ecos.totalSpent;
string oldP = ecos.purchase;
try {
Command.all.Find("newlvl").Use(null, p.name + "_" + par3 + " " + lvl.x + " " + lvl.y + " " + lvl.z + " " + lvl.type);
Player.SendMessage(p, "%aCreating level: '%f" + p.name + "_" + par3 + "%a' . . .");
Command.all.Find("newlvl").Use(null, p.name + "_" + args[3] + " " + lvl.x + " " + lvl.y + " " + lvl.z + " " + lvl.type);
Player.SendMessage(p, "%aCreating level: '%f" + p.name + "_" + args[3] + "%a' . . .");
p.money = p.money - lvl.price;
ecos.money = p.money;
ecos.totalSpent += lvl.price;
ecos.purchase = "%3Map: %f" + lvl.name + "%3 - Price: %f" + lvl.price + " %3" + Server.moneys + " - Date: %f" + ecoColor + DateTime.Now.ToString(CultureInfo.InvariantCulture);
Economy.UpdateEcoStats(ecos);
Command.all.Find("load").Use(null, p.name + "_" + par3);
Command.all.Find("load").Use(null, p.name + "_" + args[3]);
Thread.Sleep(250);
Level level = LevelInfo.Find(p.name + "_" + par3);
Level level = LevelInfo.Find(p.name + "_" + args[3]);
if (level.permissionbuild > p.group.Permission) { level.permissionbuild = p.group.Permission; }
if (level.permissionvisit > p.group.Permission) { level.permissionvisit = p.group.Permission; }
Command.all.Find("goto").Use(p, p.name + "_" + par3);
Command.all.Find("goto").Use(p, p.name + "_" + args[3]);
Player.SendMessage(p, "%aSuccessfully created your map: '%f" + p.name + "_" + par3 + "%a'");
Player.SendMessage(p, "%aSuccessfully created your map: '%f" + p.name + "_" + args[3] + "%a'");
Player.SendMessage(p, "%aYour balance is now %f" + p.money.ToString() + " %3" + Server.moneys);
try {
//safe against SQL injections, but will be replaced soon by a new feature
@ -418,24 +418,24 @@ namespace MCGalaxy.Commands {
Player.SendMessage(p, "%cYou don't have enough %3" + Server.moneys + "%c to buy a color");
return;
}
if (!par2.StartsWith("&") || !par2.StartsWith("%")) {
par2 = Colors.Parse(par2);
if (par2 == "") {
if (!args[2].StartsWith("&") || !args[2].StartsWith("%")) {
args[2] = Colors.Parse(args[2]);
if (args[2] == "") {
Player.SendMessage(p, "%cThat wasn't a color");
return;
}
}
if (par2 == p.color) {
Player.SendMessage(p, "%cYou already have a " + par2 + Colors.Name(par2) + "%c color");
if (args[2] == p.color) {
Player.SendMessage(p, "%cYou already have a " + args[2] + Colors.Name(args[2]) + "%c color");
return;
} else {
Command.all.Find("color").Use(null, p.name + " " + Colors.Name(par2));
Command.all.Find("color").Use(null, p.name + " " + Colors.Name(args[2]));
p.money = p.money - Economy.Settings.ColorPrice;
ecos.money = p.money;
ecos.totalSpent += Economy.Settings.ColorPrice;
ecos.purchase = "%3Color: " + par2 + Colors.Name(par2) + "%3 - Price: %f" + Economy.Settings.ColorPrice + " %3" + Server.moneys + " - Date: %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
ecos.purchase = "%3Color: " + args[2] + Colors.Name(args[2]) + "%3 - Price: %f" + Economy.Settings.ColorPrice + " %3" + Server.moneys + " - Date: %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
Economy.UpdateEcoStats(ecos);
Player.SendMessage(p, "%aYour color has been successfully changed to " + par2 + Colors.Name(par2));
Player.SendMessage(p, "%aYour color has been successfully changed to " + args[2] + Colors.Name(args[2]));
Player.SendMessage(p, "%aYour balance is now %f" + p.money.ToString() + " %3" + Server.moneys);
return;
}
@ -449,24 +449,24 @@ namespace MCGalaxy.Commands {
Player.SendMessage(p, "%cYou don't have enough %3" + Server.moneys + "%c to buy a titlecolor");
return;
}
if (!par2.StartsWith("&") || !par2.StartsWith("%")) {
par2 = Colors.Parse(par2);
if (par2 == "") {
if (!args[2].StartsWith("&") || !args[2].StartsWith("%")) {
args[2] = Colors.Parse(args[2]);
if (args[2] == "") {
Player.SendMessage(p, "%cThat wasn't a color");
return;
}
}
if (par2 == p.titlecolor) {
Player.SendMessage(p, "%cYou already have a " + par2 + Colors.Name(par2) + "%c titlecolor");
if (args[2] == p.titlecolor) {
Player.SendMessage(p, "%cYou already have a " + args[2] + Colors.Name(args[2]) + "%c titlecolor");
return;
} else {
Command.all.Find("tcolor").Use(null, p.name + " " + Colors.Name(par2));
Command.all.Find("tcolor").Use(null, p.name + " " + Colors.Name(args[2]));
p.money = p.money - Economy.Settings.TColorPrice;
ecos.money = p.money;
ecos.totalSpent += Economy.Settings.TColorPrice;
ecos.purchase = "%3Titlecolor: " + par2 + Colors.Name(par2) + "%3 - Price: %f" + Economy.Settings.TColorPrice + " %3" + Server.moneys + " - Date: %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
ecos.purchase = "%3Titlecolor: " + args[2] + Colors.Name(args[2]) + "%3 - Price: %f" + Economy.Settings.TColorPrice + " %3" + Server.moneys + " - Date: %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
Economy.UpdateEcoStats(ecos);
Player.SendMessage(p, "%aYour titlecolor has been successfully changed to " + par2 + Colors.Name(par2));
Player.SendMessage(p, "%aYour titlecolor has been successfully changed to " + args[2] + Colors.Name(args[2]));
Player.SendMessage(p, "%aYour balance is now %f" + p.money + " %3" + Server.moneys);
return;
}
@ -477,43 +477,43 @@ namespace MCGalaxy.Commands {
Player.SendMessage(p, "%cYou don't have enough %3" + Server.moneys + "%c to buy a title");
return;
}
if (par3 != string.Empty) {
if (args[3] != string.Empty) {
Player.SendMessage(p, "%cYour title cannot contain any spaces");
return;
}
if (par2 == p.title) {
if (args[2] == p.title) {
Player.SendMessage(p, "%cYou already have that title");
return;
}
if (par2.Length > 17) {
if (args[2].Length > 17) {
Player.SendMessage(p, "%cTitles cannot be longer than 17 characters");
return;
}
var regex = new System.Text.RegularExpressions.Regex(@"^[a-zA-Z0-9-_\\.]*$");
if (!regex.IsMatch(par2)) {
if (!regex.IsMatch(args[2])) {
Player.SendMessage(p, "%cInvalid title! Titles may only contain alphanumeric characters and .-_");
return;
}
bool free = false;
if (par2 == null || par2 == string.Empty || par2 == "") {
par2 = ""; //just an extra check to make sure it's good
if (args[2] == null || args[2] == string.Empty || args[2] == "") {
args[2] = ""; //just an extra check to make sure it's good
free = true;
}
Command.all.Find("title").Use(null, p.name + " " + par2);
Command.all.Find("title").Use(null, p.name + " " + args[2]);
if (!free) {
p.money = p.money - Economy.Settings.TitlePrice;
ecos.money = p.money;
ecos.totalSpent += Economy.Settings.TitlePrice;
ecos.purchase = "%3Title: %f" + par2 + "%3 - Price: %f" + Economy.Settings.TitlePrice + " %3" + Server.moneys + " - Date: %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
ecos.purchase = "%3Title: %f" + args[2] + "%3 - Price: %f" + Economy.Settings.TitlePrice + " %3" + Server.moneys + " - Date: %f" + DateTime.Now.ToString(CultureInfo.InvariantCulture);
Economy.UpdateEcoStats(ecos);
Player.SendMessage(p, "%aYour title has been successfully changed to [" + p.titlecolor + par2 + "%a]");
Player.SendMessage(p, "%aYour title has been successfully changed to [" + p.titlecolor + args[2] + "%a]");
} else { Player.SendMessage(p, "%aYour title has been successfully removed for free"); }
Player.SendMessage(p, "%aYour balance is now %f" + p.money + " %3" + Server.moneys);
return;
case "ranks":
case "rank":
if (par2 != "" && par2 != null && !string.IsNullOrEmpty(par2) && par2 != string.Empty) {
if (args[2] != "" && args[2] != null && !string.IsNullOrEmpty(args[2]) && args[2] != string.Empty) {
Player.SendMessage(p, "%cYou cannot provide a rank name, use %a/eco buy rank %cto buy the NEXT rank.");
return;
}
@ -542,41 +542,47 @@ namespace MCGalaxy.Commands {
Player.SendMessage(p, "%cThat wasn't a valid command addition!");
return;
}
}
case "stats":
case "balance":
case "amount":
void HandleStats(Player p, string message, string[] args) {
Economy.EcoStats ecostats;
if (par1 != string.Empty && par1 != null && par1 != "") {
Player who = PlayerInfo.Find(par1); //is player online?
if (who == null) { //player is offline
ecostats = Economy.RetrieveEcoStats(par1);
if (p == null && args[1] == "") {
Player.SendMessage(p, "You must provide a name when using the command from console."); return;
}
if (args[1] != "") {
Player who = PlayerInfo.Find(args[1]);
if (who == null) {
ecostats = Economy.RetrieveEcoStats(args[1]);
Player.SendMessage(p, "%3===Economy stats for: %f" + ecostats.playerName + "%7(offline)%3===");
} else { //player is online
} else {
ecostats = Economy.RetrieveEcoStats(who.name);
Player.SendMessage(p, "%3===Economy stats for: " + who.color + who.name + "%3===");
}
} else if (p != null) { //this player
} else {
ecostats = Economy.RetrieveEcoStats(p.name);
Player.SendMessage(p, "%3===Economy stats for: " + p.color + p.name + "%3===");
} else { Player.SendMessage(p, "%cConsole cannot contain any eco stats"); return; }
}
Player.SendMessage(p, "Balance: %f" + ecostats.money + " %3" + Server.moneys);
Player.SendMessage(p, "Total spent: %f" + ecostats.totalSpent + " %3" + Server.moneys);
Player.SendMessage(p, "Recent purchase: " + ecostats.purchase);
Player.SendMessage(p, "Recent payment: " + ecostats.payment);
Player.SendMessage(p, "Recent receivement: " + ecostats.salary);
Player.SendMessage(p, "Recent fine: " + ecostats.fine);
return;
case "info":
case "about":
if (Economy.Settings.Enabled) {
switch (par1) {
}
void HandleInfo(Player p, string message, string[] args) {
if (!Economy.Settings.Enabled) {
Player.SendMessage(p, "%cThe %3Economy System %cis currently disabled!"); return;
}
switch (args[1]) {
case "map":
case "level":
case "maps":
case "levels":
if (Economy.Settings.Levels == false) { Player.SendMessage(p, "%cMaps are not enabled for the economy system"); return; }
Player.SendMessage(p, ecoColor + "%3===Economy info: Maps===");
Player.SendMessage(p, "%3===Economy info: Maps===");
Player.SendMessage(p, "%aAvailable maps to buy:");
if (Economy.Settings.LevelsList.Count == 0)
Player.SendMessage(p, "%8-None-");
@ -589,7 +595,7 @@ namespace MCGalaxy.Commands {
case "title":
case "titles":
if (Economy.Settings.Titles == false) { Player.SendMessage(p, "%cTitles are not enabled for the economy system"); return; }
Player.SendMessage(p, ecoColor + "%3===Economy info: Titles===");
Player.SendMessage(p, "%3===Economy info: Titles===");
Player.SendMessage(p, "Titles cost %f" + Economy.Settings.TitlePrice + " %3" + Server.moneys + Server.DefaultColor + " each");
return;
@ -599,7 +605,7 @@ namespace MCGalaxy.Commands {
case "titlecolors":
case "tc":
if (!Economy.Settings.TColors) { Player.SendMessage(p, "%cTitlecolors are not enabled for the economy system"); return; }
Player.SendMessage(p, ecoColor + "%3===Economy info: Titlecolors===");
Player.SendMessage(p, "%3===Economy info: Titlecolors===");
Player.SendMessage(p, "Titlecolors cost %f" + Economy.Settings.TColorPrice + " %3" + Server.moneys + Server.DefaultColor + " each");
return;
@ -608,14 +614,14 @@ namespace MCGalaxy.Commands {
case "colours":
case "colour":
if (Economy.Settings.Colors == false) { Player.SendMessage(p, "%cColors are not enabled for the economy system"); return; }
Player.SendMessage(p, ecoColor + "%3===Economy info: Colors===");
Player.SendMessage(p, "%3===Economy info: Colors===");
Player.SendMessage(p, "Colors cost %f" + Economy.Settings.ColorPrice + " %3" + Server.moneys + Server.DefaultColor + " each");
return;
case "ranks":
case "rank":
if (Economy.Settings.Ranks == false) { Player.SendMessage(p, "%cRanks are not enabled for the economy system"); return; }
Player.SendMessage(p, ecoColor + "%3===Economy info: Ranks===");
Player.SendMessage(p, "%3===Economy info: Ranks===");
Player.SendMessage(p, "%fThe maximum buyable rank is: " + Group.Find(Economy.Settings.MaxRank).color + Economy.Settings.MaxRank);
Player.SendMessage(p, "%cRanks purchased will be bought in order.");
Player.SendMessage(p, "%fRanks cost:");
@ -630,10 +636,10 @@ namespace MCGalaxy.Commands {
Player.SendMessage(p, "%cThat wasn't a valid command addition!");
return;
}
} else { Player.SendMessage(p, "%cThe %3Economy System %cis currently disabled!"); return; }
}
case "help":
switch (par1) {
void HandleHelp(Player p, string message, string[] args) {
switch (args[1]) {
case "":
Help(p);
return;
@ -665,22 +671,15 @@ namespace MCGalaxy.Commands {
case "setup":
if ((int)p.group.Permission >= CommandOtherPerms.GetPerm(this)) {
SetupHelp(p);
return;
SetupHelp(p); return;
} else { Player.SendMessage(p, "%cYou are not allowed to use %f/eco help setup"); return; }
default:
Player.SendMessage(p, "%cThat wasn't a valid command addition, sending you to help");
Help(p);
return;
Help(p); return;
}
}
default:
//Player.SendMessage(p, "%4That wasn't a valid command addition, Sending you to help:");
Help(p);
return;
}
}
public override void Help(Player p) {
string defaultcolor = Group.findPerm(defaultRank).color;
string othercolor = Group.findPermInt(CommandOtherPerms.GetPerm(this)).color;
@ -709,7 +708,7 @@ namespace MCGalaxy.Commands {
Player.SendMessage(p, "%4/eco setup map edit [%fname%4] [name/x/y/z/type/price] [%fvalue%4] %e- to edit a map preset");
}
public bool isGood(string value) {
static public bool isGood(string value) {
ushort uvalue = ushort.Parse(value);
switch (uvalue) {
case 2: