public void Execute(IRocketPlayer caller, string[] command) { if (command.Length == 1) { var paycheckIndex = PaycheckHelper.FindBestMatchIndex(command[0]); if (paycheckIndex != null) { UnturnedChat.Say(caller, PaycheckPlugin.Instance.Translate("command_paycheck_deleted", PaycheckPlugin.Config.Paychecks[paycheckIndex.Value].Name), Color.magenta); PaycheckPlugin.Config.Paychecks.RemoveAt(paycheckIndex.Value); PaycheckPlugin.Config.IsDirty = true; return; } UnturnedChat.Say(caller, PaycheckPlugin.Instance.Translate("command_paycheck_not_found", command[0]), Color.yellow); return; } UnturnedChat.Say(caller, $"Use /{Name} {Syntax}", Color.yellow); }
public void Execute(IRocketPlayer caller, string[] command) { List <PaycheckZone> zones; Paycheck paycheck = null; if (command.Length > 0) { paycheck = PaycheckHelper.FindBestMatch(command[0]); if (paycheck == null) { UnturnedChat.Say(caller, PaycheckPlugin.Instance.Translate("command_paycheck_not_found", command[0]), Color.yellow); return; } zones = paycheck.PaycheckZones; } else { zones = PaycheckPlugin.Config.PaycheckZones; } if (zones.Count == 0) { UnturnedChat.Say(caller, command.Length == 0 ? PaycheckPlugin.Instance.Translate("command_default_no_zones") : PaycheckPlugin.Instance.Translate("command_paycheck_no_zones", paycheck?.Name), Color.yellow); return; } var zonesString = new StringBuilder(); for (var i = 0; i < zones.Count; i++) { zonesString.AppendFormat(" [{0}] - {1}x {2} {3}m,", i + 1, zones[i].Multiplier, ZoneHelper.GetLocationString(zones[i]), zones[i].Radius); } zonesString.Remove(zonesString.Length - 1, 1); UnturnedChat.Say(caller, command.Length == 0 ? PaycheckPlugin.Instance.Translate("command_list_default_zones", zonesString.ToString()) : PaycheckPlugin.Instance.Translate("command_list_paycheck_zones", paycheck?.Name, zonesString.ToString()), Color.green); }
public void Execute(IRocketPlayer caller, string[] command) { if (command.Length != 2 && command.Length != 3) { UnturnedChat.Say(caller, $"Use /{Name} {Syntax}", Color.yellow); return; } if (!int.TryParse(command[1], out var experience)) { UnturnedChat.Say(caller, PaycheckPlugin.Instance.Translate("command_no_parse_experience", command[1]), Color.yellow); return; } var zones = new List <PaycheckZone>(); if (command.Length == 3) { var paycheckResult = PaycheckHelper.FindBestMatch(command[2]); if (paycheckResult != null) { zones = paycheckResult.PaycheckZones; } else { UnturnedChat.Say(caller, PaycheckPlugin.Instance.Translate("command_paycheck_not_found", command[2]), Color.yellow); return; } } var paycheck = new Paycheck(command[0].ToLower(), experience, zones); PaycheckPlugin.Config.Paychecks.Add(paycheck); PaycheckPlugin.Config.IsDirty = true; UnturnedChat.Say(caller, PaycheckPlugin.Instance.Translate("command_paycheck_created", paycheck.Name, paycheck.Experience), Color.cyan); }
public void Execute(IRocketPlayer caller, string[] command) { if (command.Length != 1 && command.Length != 2) { UnturnedChat.Say(caller, $"Use /{Name} {Syntax}", Color.yellow); return; } var paycheckIndex = 0; var zones = PaycheckPlugin.Config.PaycheckZones; if (command.Length == 2) { var paycheck = PaycheckHelper.FindBestMatchIndex(command[0]); if (paycheck == null) { UnturnedChat.Say(caller, PaycheckPlugin.Instance.Translate("command_paycheck_not_found", command[0]), Color.yellow); return; } paycheckIndex = paycheck.Value; zones = PaycheckPlugin.Config.Paychecks[paycheckIndex].PaycheckZones; } if (zones.Count == 0) { UnturnedChat.Say(caller, command.Length == 0 ? PaycheckPlugin.Instance.Translate("command_default_no_zones") : PaycheckPlugin.Instance.Translate("command_paycheck_no_zones", PaycheckPlugin.Config.Paychecks[paycheckIndex].Name), Color.yellow); return; } if (!int.TryParse(command[command.Length - 1], out var index)) { var bestMatchIndex = ZoneHelper.FindBestMatchIndex(zones, command[command.Length - 1]); if (bestMatchIndex != null) { index = bestMatchIndex.Value; } else { UnturnedChat.Say(caller, PaycheckPlugin.Instance.Translate("command_delete_zone_no_parse"), Color.yellow); return; } } else { index--; if (index >= zones.Count || index < 0) { UnturnedChat.Say(caller, PaycheckPlugin.Instance.Translate("command_invalid_out_of_bounds", index + 1, 1, zones.Count), Color.yellow); return; } } // ReSharper disable once ConvertIfStatementToSwitchStatement if (command.Length == 1) { UnturnedChat.Say(caller, PaycheckPlugin.Instance.Translate("command_removed_zone_default", ZoneHelper.GetLocationString(PaycheckPlugin.Config.PaycheckZones[index])), Color.magenta); PaycheckPlugin.Config.PaycheckZones.RemoveAt(index); } else if (command.Length == 2) { UnturnedChat.Say(caller, PaycheckPlugin.Instance.Translate("command_removed_zone_paycheck", PaycheckPlugin.Config.Paychecks[paycheckIndex].Name, ZoneHelper.GetLocationString(PaycheckPlugin.Config.Paychecks[paycheckIndex].PaycheckZones[index])), Color.magenta); PaycheckPlugin.Config.Paychecks[paycheckIndex].PaycheckZones.RemoveAt(index); } PaycheckPlugin.Config.IsDirty = true; }
public void Execute(IRocketPlayer caller, string[] command) { if (command.Length != 2 && command.Length != 3 && command.Length != 4) { UnturnedChat.Say(caller, $"Use /{Name} {Syntax}", Color.yellow); return; } if (!float.TryParse(command[command.Length - 1], out var multiplier)) { UnturnedChat.Say(caller, PaycheckPlugin.Instance.Translate("command_no_parse_multiplier", command[command.Length - 1]), Color.yellow); return; } if (!float.TryParse(command[command.Length - 2], out var radius)) { UnturnedChat.Say(caller, PaycheckPlugin.Instance.Translate("command_no_parse_radius", command[command.Length - 2]), Color.yellow); return; } // ReSharper disable once ConvertIfStatementToSwitchStatement if (command.Length == 2) { if (caller.Id == "Console") { UnturnedChat.Say(caller, PaycheckPlugin.Instance.Translate("command_no_console"), Color.yellow); return; } var zone = new PaycheckZone(Vector3Helper.Round(((UnturnedPlayer)caller).Position), radius, multiplier); PaycheckPlugin.Config.PaycheckZones.Add(zone); UnturnedChat.Say(caller, PaycheckPlugin.Instance.Translate("command_created_zone_default", ZoneHelper.GetLocationString(zone), zone.Multiplier + "x", zone.Radius), Color.cyan); } else if (command.Length == 3) { var paycheckIndex = PaycheckHelper.FindBestMatchIndex(command[0]); if (paycheckIndex != null) { if (caller.Id == "Console") { UnturnedChat.Say(caller, PaycheckPlugin.Instance.Translate("command_no_console"), Color.yellow); return; } var zone = new PaycheckZone(Vector3Helper.Round(((UnturnedPlayer)caller).Position), radius, multiplier); PaycheckPlugin.Config.Paychecks[paycheckIndex.Value].PaycheckZones.Add(zone); UnturnedChat.Say(caller, PaycheckPlugin.Instance.Translate("command_created_zone_paycheck", PaycheckPlugin.Config.Paychecks[paycheckIndex.Value].Name, ZoneHelper.GetLocationString(zone), zone.Multiplier + "x", zone.Radius), Color.cyan); } else { var pointResult = Vector3Helper.Parse(command[0]); if (pointResult != null) { var zone = new PaycheckZone(Vector3Helper.Round(pointResult.Value), radius, multiplier); PaycheckPlugin.Config.PaycheckZones.Add(zone); UnturnedChat.Say(caller, PaycheckPlugin.Instance.Translate("command_created_zone_default", ZoneHelper.GetLocationString(zone), zone.Multiplier + "x", zone.Radius), Color.cyan); } else if (NodeHelper.Exists(command[0])) { var zone = new PaycheckZone(command[0], radius, multiplier); PaycheckPlugin.Config.PaycheckZones.Add(zone); UnturnedChat.Say(caller, PaycheckPlugin.Instance.Translate("command_created_zone_default", ZoneHelper.GetLocationString(zone), zone.Multiplier + "x", zone.Radius), Color.cyan); } else { UnturnedChat.Say(caller, PaycheckPlugin.Instance.Translate("command_no_parse_paycheck_or_location", command[0]), Color.yellow); return; } } } else if (command.Length == 4) { var paycheckIndex = PaycheckHelper.FindBestMatchIndex(command[0]); if (paycheckIndex == null) { UnturnedChat.Say(caller, PaycheckPlugin.Instance.Translate("command_created_zone_paycheck", command[0]), Color.yellow); return; } var pointResult = Vector3Helper.Parse(command[1]); if (pointResult != null) { var zone = new PaycheckZone(Vector3Helper.Round(pointResult.Value), radius, multiplier); PaycheckPlugin.Config.Paychecks[paycheckIndex.Value].PaycheckZones.Add(zone); UnturnedChat.Say(caller, PaycheckPlugin.Instance.Translate("command_created_zone_paycheck", PaycheckPlugin.Config.Paychecks[paycheckIndex.Value].Name, ZoneHelper.GetLocationString(zone), zone.Multiplier + "x", zone.Radius), Color.cyan); } else if (NodeHelper.Exists(command[1])) { var zone = new PaycheckZone(command[1], radius, multiplier); PaycheckPlugin.Config.Paychecks[paycheckIndex.Value].PaycheckZones.Add(zone); UnturnedChat.Say(caller, PaycheckPlugin.Instance.Translate("command_created_zone_paycheck", PaycheckPlugin.Config.Paychecks[paycheckIndex.Value].Name, ZoneHelper.GetLocationString(zone), zone.Multiplier + "x", zone.Radius), Color.cyan); } else { UnturnedChat.Say(caller, PaycheckPlugin.Instance.Translate("command_no_parse_location", command[1]), Color.yellow); return; } } PaycheckPlugin.Config.IsDirty = true; }