public void PathByNameTest() { Assert.AreEqual("test1.exe", CommandMgr.GetCommandPathByName("test1"), "Error, getting the path"); Assert.AreEqual("test2.exe", CommandMgr.GetCommandPathByName("test2"), "Error, getting the path"); TestContext.WriteLine($"Expected \"test1.exe\" -> Recived \"{CommandMgr.GetCommandPathByName("test1")}\""); TestContext.WriteLine($"Expected \"test2.exe\" -> Recived \"{CommandMgr.GetCommandPathByName("test2")}\""); }
public bool OnCommand(BaseClient client, string[] args) { if (args.Length > 1) { switch (args[1]) { case "-reload": CommandMgr.LoadCommands(); break; case "-list": CommandMgr.DisplaySyntax(client); break; default: DisplaySyntax(client); break; } } else { DisplaySyntax(client); } return(true); }
private void OnSendClick() { var inputSplit = _consoleInput.Split(' '); if (inputSplit.Length >= 1) { var cmd = CommandMgr.GetCommand(inputSplit[0]); if (cmd != null) { _consoleInput = _consoleInput.Remove(0, inputSplit[0].Length); var result = cmd.Func(inputSplit[0], CommandManager.ParseLine(_consoleInput)); switch (result) { case CommandResult.InvalidArgument: Log(LogType.Warning, "[CMD] Usage: " + cmd.Name + " " + cmd.Usage); break; case CommandResult.Fail: Log(LogType.Error, "[CMD] Unknown error"); break; } } else { Log(LogType.Log, "[CMD] Invalid command: " + _consoleInput); } } else { Log(LogType.Log, "[CMD] Invalid command: " + _consoleInput); } _consoleInput = ""; }
public bool OnCommand(BaseClient client, string[] args) { if (args.Length > 1) { string a; if ((a = args[1]) != null) { if (a == "-reload") { CommandMgr.LoadCommands(); return(true); } if (a == "-list") { CommandMgr.DisplaySyntax(client); return(true); } } this.DisplaySyntax(client); } else { this.DisplaySyntax(client); } return(true); }
public bool OnCommand(BaseClient client, string[] args) { if (args.Length <= 1) { this.DisplaySyntax(client); } else { string str = args[1]; if (str != null) { if (!(str == "-reload")) { if (str == "-list") { CommandMgr.DisplaySyntax(client); goto Label_0049; } } else { CommandMgr.LoadCommands(); goto Label_0049; } } this.DisplaySyntax(client); } Label_0049: return(true); }
public void NameByPathTest() { Assert.AreEqual("test1", CommandMgr.GetCommandNameByPath("test1.exe"), "Error, getting the name"); Assert.AreEqual("test2", CommandMgr.GetCommandNameByPath("test2.exe"), "Error, getting the name"); TestContext.WriteLine($"Expected \"test1\" -> Recived \"{CommandMgr.GetCommandNameByPath("test1.exe")}\""); TestContext.WriteLine($"Expected \"test2\" -> Recived \"{CommandMgr.GetCommandNameByPath("test2.exe")}\""); }
public void HandleCmd(GSPacketIn packet) { try { string cmdLine = packet.ReadString(); bool result = CommandMgr.HandleCommandNoPlvl(this, cmdLine); this.SendCmdResult(cmdLine, result); } catch (Exception ex) { CenterServerConnector.log.Error(ex.Message, ex); } }
public static void F_TEXT(BaseClient client, PacketIn packet) { GameClient cclient = client as GameClient; if (cclient.Plr == null) { return; } byte Unk = packet.GetUint8(); string Text = packet.GetString((int)(packet.Length - packet.Position)); CommandMgr.HandleText(cclient.Plr, Text); }
public void RemoveTest() { var lstCommands = CommandMgr.GetCommands(); Assert.AreEqual(2, lstCommands.Count, "Error, cleaned CommandMgr"); TestContext.WriteLine($"List.Count After = {lstCommands.Count}"); CommandMgr.RemoveCommand(new Command { Name = "test1" }); CommandMgr.RemoveCommand(new Command { Name = "test2" }); Assert.AreEqual(0, CommandMgr.GetCommands().Count, "Error removing commands"); TestContext.WriteLine($"List.Count Before = {CommandMgr.GetCommands().Count}"); }
public void AddTest() { //Clean the files if (File.Exists(XMLTest.XMLPATH)) { File.Delete(XMLTest.XMLPATH); } CommandMgr.Load(XMLTest.XMLPATH); CommandMgr.AddCommand(new Command { Name = "test1", Path = "test1.exe" }); CommandMgr.AddCommand(new Command { Name = "test2", Path = "test2.exe" }); Assert.AreEqual(2, CommandMgr.GetCommands().Count, "Error adding commands"); TestContext.WriteLine($"List.Count Before = {CommandMgr.GetCommands().Count}"); }
public void HandleManagerCmd(GSPacketIn packet) { if (GameServer.ManagerLogined) { string cmd = packet.ReadString(); try { if (!CommandMgr.HandleCommandNoPlvl(this, cmd)) { this.DisplayMessage("Unknown command: " + cmd); } } catch (Exception ex) { this.DisplayMessage("error:" + ex.Message); } } }
public bool OnCommand(BaseClient client, string[] args) { if (args.Length > 1) { string text = args[1]; if (text != null) { if (text == "-reload") { CommandMgr.LoadCommands(); goto IL_37; } } this.DisplaySyntax(client); IL_37 :; } else { this.DisplaySyntax(client); } return(true); }
private void Initialize() { _messages = new List <Message>(); //CommandMgr = new CommandManager<ConsoleCommand, ConsoleCommandFunc>(); CommandMgr.Add(new ConsoleCommand("hide", "", "Hides the console window", (command, args) => { _isVisible = false; return(CommandResult.Ok); })); CommandMgr.Add(new ConsoleCommand("help", "", "Shows help", (command, args) => { if (args.Count == 0) { Log(LogType.Log, "Available commands"); foreach (var cmd in CommandMgr.Commands.Values.OrderBy(a => a.Name)) { Log(LogType.Log, string.Format("\t{0} - {1}", cmd.Name, cmd.Description)); } } else { var cmd = CommandMgr.GetCommand(args[0]); if (cmd == null) { Log(LogType.Error, "[CMD] Invalid command."); } else { Log(LogType.Log, string.Format("\t{0} {1} - {2}", cmd.Name, cmd.Usage, cmd.Description)); } } return(CommandResult.Ok); })); _traceLog = ""; }
// Use this for initialization protected virtual void Start() { _actionMgr = new ActionMgr(); _commandMgr = new CommandMgr(); _buffMgr = new BuffMgr(this); //// Load Mecha Data //UnityFactory.factory.LoadDragonBonesData("DB/hero/hr021_ske"); //UnityFactory.factory.LoadTextureAtlasData("DB/hero/hr021_tex"); //// Build Mecha Armature //ArmatureComp = UnityFactory.factory.BuildArmatureComponent("Hero"); //// //ArmatureComp.CloseCombineMeshs(); //ArmatureComp.sortingOrder = 100; //ArmatureComp.sortingLayerName = "Active"; //ArmatureComp.transform.parent = transform; //ArmatureComp.transform.position = Vector3.zero; _bornPosition = transform.position; InitArmature(); _roleInfo.addListener(EventBase.CHANGE, OnInfoChanged); }
public void Execute(BaseGame game, long tick) { if (this.m_player.IsActive) { eTankCmdType eTankCmdType = (eTankCmdType)this.m_packet.ReadByte(); try { ICommandHandler commandHandler = CommandMgr.LoadCommandHandler((int)eTankCmdType); if (commandHandler != null) { commandHandler.HandleCommand(game, this.m_player, this.m_packet); } else { ProcessPacketAction.log.Error(string.Format("Player Id: {0}", this.m_player.Id)); } } catch (Exception exception) { ProcessPacketAction.log.Error(string.Format("Player Id: {0} cmd:0x{1:X2}", this.m_player.Id, (byte)eTankCmdType), exception); } } }
public void Execute(BaseGame game, long tick) { if (m_player.IsActive) { eTankCmdType type = (eTankCmdType)m_packet.ReadByte(); try { ICommandHandler handleCommand = CommandMgr.LoadCommandHandler((int)type); if (handleCommand != null) { handleCommand.HandleCommand(game, m_player, m_packet); } else { log.Error(string.Format("Player Id: {0}", m_player.Id)); } } catch (Exception ex) { log.Error(string.Format("Player Id: {0} cmd:0x{1:X2}", m_player.Id, (byte)type), ex); } } }
public bool Execute(string[] paramsList) { Console.WriteLine(" 当前有 {0} 个游戏服务器正在运行!", GameServerMgr.GetClientCount()); if (paramsList.Length == 0) { return(true); } string param = CommandMgr.GetParam("-ip", paramsList); if (!string.IsNullOrEmpty(param)) { ServerClient[] list = GameServerMgr.GetAllClient(); for (int i = 0; i < list.Length; i++) { CommandMgr.WriteLine(8, (i + 1).ToString() + ")", 4, list[i].Socket.RemoteEndPoint); } } return(true); }
public void Execute(BaseGame game, long tick) { if (this.m_player.IsActive) { byte a = this.m_packet.ReadByte(); eTankCmdType type = (eTankCmdType)a; try { ICommandHandler handleCommand = CommandMgr.LoadCommandHandler((int)type); if (handleCommand != null) { handleCommand.HandleCommand(game, this.m_player, this.m_packet); } else { ProcessPacketAction.log.Error(string.Format("Player Id: {0}", this.m_player.Id)); } } catch (Exception ex) { ProcessPacketAction.log.Error(string.Format("Player Id: {0} cmd:0x{1:X2}", this.m_player.Id, a), ex); } } }
public bool OnCommand(BaseClient client, string[] args) { if (args.Length > 1) { StringBuilder success = new StringBuilder(); StringBuilder failed = new StringBuilder(); if (args.Contains <string>("/cmd")) { CommandMgr.LoadCommands(); DisplayMessage(client, "Command load success!"); success.Append("/cmd,"); } if (args.Contains <string>("/config")) { GameServer.Instance.Configuration.Refresh(); DisplayMessage(client, "Application config file load success!"); success.Append("/config,"); } if (args.Contains <string>("/property")) { GameProperties.Refresh(); DisplayMessage(client, "Game properties load success!"); success.Append("/property,"); } if (args.Contains <string>("/item")) { if (ItemMgr.ReLoad()) { DisplayMessage(client, "Items load success!"); success.Append("/item,"); } else { DisplayMessage(client, "Items load failed!"); failed.Append("/item,"); } } if (args.Contains <string>("/shop")) { if (ItemMgr.ReLoad()) { DisplayMessage(client, "Shops load success!"); success.Append("/shop,"); } else { DisplayMessage(client, "Shops load failed!"); failed.Append("/shop,"); } } if (success.Length == 0 && failed.Length == 0) { DisplayMessage(client, "Nothing executed!"); DisplaySyntax(client); } else { DisplayMessage(client, "Success Options: " + success.ToString()); if (failed.Length > 0) { DisplayMessage(client, "Faile Options: " + failed.ToString()); return(false); } } return(true); } else { DisplaySyntax(client); } return(true); }
static void Main(string[] args) { CommandMgr.runCommand(args); }
public bool OnCommand(BaseClient client, string[] args) { CommandMgr.DisplaySyntax(client); return(true); }
public static void DoCommand(string CommandName, string[] CommandArgs) { PlayerBussiness bussiness; PlayerInfo userSingleByNickName; Exception exception; string str3; string str4; string str5; ManageBussiness bussiness2; switch (CommandName) { case "exit": GameServer.KeepRunning = false; break; case "cp": { GameClient[] allClients = GameServer.Instance.GetAllClients(); int num = (allClients == null) ? 0 : allClients.Length; GamePlayer[] allPlayers = WorldMgr.GetAllPlayers(); int num2 = (allPlayers == null) ? 0 : allPlayers.Length; List <BaseRoom> allUsingRoom = RoomMgr.GetAllUsingRoom(); int num3 = 0; int num4 = 0; foreach (BaseRoom room in allUsingRoom) { if (!room.IsEmpty) { num3++; if (room.IsPlaying) { num4++; } } } double totalMemory = GC.GetTotalMemory(false); Console.WriteLine(string.Format("Total Clients/Players:{0}/{1}", num, num2)); Console.WriteLine(string.Format("Total Rooms/Games:{0}/{1}", num3, num4)); Console.WriteLine(string.Format("Total Momey Used:{0} MB", (totalMemory / 1024.0) / 1024.0)); break; } case "setlevel": try { string path = Path.Combine(Environment.CurrentDirectory, "LevelList.xml"); if (!File.Exists(path)) { log.Error("LevelList.xml not found!"); } else { int num6; Console.Write("Please enter the level: "); string s = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!int.TryParse(s, out num6)) { log.Error("Level is not valid int!"); } else { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName == null) { log.Error(string.Format("Player not found in db!", new object[0])); break; } if (!IsValidGZip(File.ReadAllBytes(path))) { log.Error("LevelList.xml is not valid!"); } else if (!IsValidXML(GZip.gzuncompress(File.ReadAllBytes(path)))) { log.Error("LevelList.xml is not valid!"); } if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } XmlDocument document = new XmlDocument(); document.LoadXml(GZip.gzuncompress(File.ReadAllBytes(path))); int num7 = -1; int num8 = -1; foreach (XmlNode node in document.SelectNodes("/Result/*")) { if (node.Attributes["Grade"].Value == s) { num7 = int.Parse(s); num8 = int.Parse(node.Attributes["GP"].Value) + 5; break; } } if ((num7 != -1) && (num8 != -1)) { userSingleByNickName.GP = num8; userSingleByNickName.Grade = num7; bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } else { log.Error(string.Format("Level {0} not found!", new object[0])); } } } } } catch (Exception exception1) { exception = exception1; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "addmoney": try { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName != null) { if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } Console.Write("Please enter the amount of money: "); str3 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!IsValidInt(str3)) { log.Error("Money is not valid!"); } else { userSingleByNickName.Money += int.Parse(str3); bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } } else { log.Error(string.Format("Player not found in db!", new object[0])); } } } catch (Exception exception3) { exception = exception3; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "addgold": try { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName != null) { if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } Console.Write("Please enter the amount of gold: "); str4 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!IsValidInt(str4)) { log.Error("Gold is not valid!"); } else { userSingleByNickName.Gold += int.Parse(str4); bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } } else { log.Error(string.Format("Player not found in db!", new object[0])); } } } catch (Exception exception4) { exception = exception4; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "addgift": try { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName != null) { Console.Write("Please enter the amount of gift token: "); str5 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!IsValidInt(str5)) { log.Error("Gold is not valid!"); } else { if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } userSingleByNickName.GiftToken += int.Parse(str5); bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } } else { log.Error(string.Format("Player not found in db!", new object[0])); } } } catch (Exception exception5) { exception = exception5; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "removemoney": try { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName != null) { if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } Console.Write("Please enter the amount of money: "); str3 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!IsValidInt(str3)) { log.Error("Money is not valid!"); } else { userSingleByNickName.Money -= int.Parse(str3); bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } } else { log.Error(string.Format("Player not found in db!", new object[0])); } } } catch (Exception exception6) { exception = exception6; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "removegold": try { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName != null) { if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } Console.Write("Please enter the amount of gold: "); str4 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!IsValidInt(str4)) { log.Error("Gold is not valid!"); } else { userSingleByNickName.Gold -= int.Parse(str4); bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } } else { log.Error(string.Format("Player not found in db!", new object[0])); } } } catch (Exception exception7) { exception = exception7; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "removegift": try { using (bussiness = new PlayerBussiness()) { userSingleByNickName = bussiness.GetUserSingleByNickName((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); if (userSingleByNickName != null) { if (WorldMgr.GetPlayerById(userSingleByNickName.ID) != null) { WorldMgr.GetPlayerById(userSingleByNickName.ID).SaveIntoDatabase(); WorldMgr.GetPlayerById(userSingleByNickName.ID).Disconnect(); } Console.Write("Please enter the amount of gift token: "); str5 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!IsValidInt(str5)) { log.Error("Gold is not valid!"); } else { userSingleByNickName.GiftToken -= int.Parse(str5); bussiness.UpdatePlayer(userSingleByNickName); log.Info(string.Format("Player {0} updated successfully!", userSingleByNickName.NickName)); } } else { log.Error(string.Format("Player not found in db!", new object[0])); } } } catch (Exception exception8) { exception = exception8; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "shutdown": _count = 6; _timer = new System.Threading.Timer(new TimerCallback(ConsoleStart.ShutDownCallBack), null, 0, 0xea60); break; case "addcps": try { Console.Write("Insira o valor dos Cupons:"); int num9 = int.Parse((CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine()); foreach (GamePlayer player in WorldMgr.GetAllPlayers()) { player.AddMoney(num9); player.SendMessage("Parab\x00e9ns, voc\x00ea recebeu " + num9 + " cupons do evento, bom jogo !"); } } catch (Exception exception9) { exception = exception9; log.Error("Error on AddCps", exception); } break; case "bnick": { Console.Clear(); Console.WriteLine("Digite o NickName do personagem: "); string nickName = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); Console.WriteLine("Motivo para banir: "); string msg = (CommandArgs.Length > 1) ? CommandArgs[1] : Console.ReadLine(); DateTime date = new DateTime(0x7e1, 7, 2); using (bussiness2 = new ManageBussiness()) { bussiness2.ForbidPlayerByNickName(nickName, date, false); bussiness2.KitoffUserByNickName(nickName, msg); } Console.WriteLine("O Usu\x00e1rio " + nickName + " Foi Banido do servidor."); foreach (GamePlayer player2 in WorldMgr.GetAllPlayers()) { player2.SendMessage("O Usu\x00e1rio " + nickName + " foi banido do servidor, motivo do BAN: " + msg + "."); } break; } case "buser": { Console.Clear(); Console.WriteLine("Digite o UserName do personagem: "); string userName = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); Console.WriteLine("Motivo para banir: "); string str9 = (CommandArgs.Length > 1) ? CommandArgs[1] : Console.ReadLine(); DateTime time2 = new DateTime(0x7e1, 7, 2); using (bussiness2 = new ManageBussiness()) { bussiness2.ForbidPlayerByUserName(userName, time2, false); bussiness2.KitoffUserByUserName(userName, str9); } Console.WriteLine("O Usu\x00e1rio " + userName + " Foi Banido do servidor."); foreach (GamePlayer player2 in WorldMgr.GetAllPlayers()) { player2.SendMessage("O Usu\x00e1rio " + userName + " foi banido do servidor, motivo do BAN: " + str9 + "."); } break; } case "nkick": { Console.Clear(); Console.WriteLine("Digite o NickName do personagem: "); string name = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); Console.WriteLine("Motivo para kikar: "); string str11 = (CommandArgs.Length > 1) ? CommandArgs[1] : Console.ReadLine(); using (bussiness2 = new ManageBussiness()) { bussiness2.KitoffUserByNickName(name, str11); } foreach (GamePlayer player2 in WorldMgr.GetAllPlayers()) { player2.SendMessage("O Usu\x00e1rio " + name + " foi kikado do servidor, motivo do KICK: " + str11 + "."); } break; } case "ukick": { Console.Clear(); Console.WriteLine("Digite o NickName do personagem: "); string str12 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); Console.WriteLine("Motivo para kikar: "); string str13 = (CommandArgs.Length > 1) ? CommandArgs[1] : Console.ReadLine(); using (bussiness2 = new ManageBussiness()) { bussiness2.KitoffUserByUserName(str12, str13); } foreach (GamePlayer player2 in WorldMgr.GetAllPlayers()) { player2.SendMessage("O Usu\x00e1rio " + str12 + " foi kikado do servidor, motivo do KICK: " + str13 + "."); } break; } case "maint": try { int num10; Console.Write("Enter time in minutes to start maintenance: "); string str14 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); if (!int.TryParse(str14, out num10)) { log.Error("Invalid MainTime!"); } else { new Thread(delegate(object mt) { if (mt is string) { Action <string, string> Sys = delegate(string nick, string Text) { Console.WriteLine(Text); foreach (GamePlayer player in WorldMgr.GetAllPlayers()) { player.SendMessage(string.Format("[{0}] {1}", nick, Text)); } }; Action DisconnectAll = delegate { foreach (GamePlayer player in WorldMgr.GetAllPlayers()) { log.Info(string.Format("Saving Player {0} into Database!", player.PlayerCharacter.NickName)); player.SaveIntoDatabase(); log.Info(string.Format("Disconnecting Player {0}!", player.PlayerCharacter.NickName)); player.Disconnect(); } log.Info("Shutdown Server!"); GameServer.Instance.Shutdown(); LogManager.Shutdown(); }; Sys("Auto Maintenance", "Manuten\x00e7\x00e3o agendada, fiquem atentos aos aviso!"); System.Timers.Timer MainTimer = new System.Timers.Timer { Interval = 1000.0 }; DateTime MainTime = DateTime.Parse(string.Format("{0} 00:00:00", "01/27/2011"), CultureInfo.GetCultureInfo("en-US")); MainTime = MainTime.AddMinutes(double.Parse(mt as string)); string CurrentTime = MainTime.ToString("HH:mm:ss"); MainTimer.Elapsed += delegate(object s, ElapsedEventArgs e) { if (CurrentTime != "00:00:00") { if ((MainTime.Minute != 0) && (MainTime.Second == 0)) { Sys("Auto Maintenance", string.Format("Falta {0} {1} para a manuten\x00e7\x00e3o!", MainTime.Minute, (MainTime.Minute == 1) ? "Minuto" : "Minutos")); } else if (MainTime.Second < 11) { Sys("Auto Maintenance", string.Format("Fechando o servidor em {0}", MainTime.Second)); } CurrentTime = MainTime.AddSeconds(-1.0).ToString("HH:mm:ss"); } else { Sys("Auto Maintenance", "Estamos desconectando todos os usu\x00e1rios para a manuten\x00e7\x00e3o, voltamos daqui a alguns minutos, saiam do servidor para evitar perca de itens!"); log.Info("End!"); DisconnectAll(); MainTimer.Stop(); } }; MainTimer.Start(); } }).Start(str14); } } catch (Exception exception10) { exception = exception10; log.Error("There was an error in command!"); log.Error(exception.Message + Environment.NewLine + exception.StackTrace); } break; case "savemap": break; case "clear": Console.Clear(); break; case "ball&reload": if (BallMgr.ReLoad()) { Console.WriteLine("Ball info is Reload!"); } else { Console.WriteLine("Ball info is Error!"); } break; case "map&reload": if (!MapMgr.ReLoadMap()) { Console.WriteLine("Map info is Error!"); break; } Console.WriteLine("Map info is Reload!"); break; case "mapserver&reload": if (!MapMgr.ReLoadMapServer()) { Console.WriteLine("mapserver info is Error!"); break; } Console.WriteLine("mapserver info is Reload!"); break; case "prop&reload": if (!PropItemMgr.Reload()) { Console.WriteLine("prop info is Error!"); break; } Console.WriteLine("prop info is Reload!"); break; case "item&reload": if (!ItemMgr.ReLoad()) { Console.WriteLine("item info is Error!"); break; } Console.WriteLine("item info is Reload!"); break; case "shop&reload": if (!ShopMgr.ReLoad()) { Console.WriteLine("shop info is Error!"); break; } Console.WriteLine("shop info is Reload!"); break; case "quest&reload": if (!QuestMgr.ReLoad()) { Console.WriteLine("quest info is Error!"); break; } Console.WriteLine("quest info is Reload!"); break; case "fusion&reload": if (!FusionMgr.ReLoad()) { Console.WriteLine("fusion info is Error!"); break; } Console.WriteLine("fusion info is Reload!"); break; case "consortia&reload": if (!ConsortiaMgr.ReLoad()) { Console.WriteLine("consortiaMgr info is Error!"); break; } Console.WriteLine("consortiaMgr info is Reload!"); break; case "rate&reload": if (!RateMgr.ReLoad()) { Console.WriteLine("Rate Rate is Error!"); break; } Console.WriteLine("Rate Rate is Reload!"); break; case "fight&reload": if (!FightRateMgr.ReLoad()) { Console.WriteLine("FightRateMgr is Error!"); break; } Console.WriteLine("FightRateMgr is Reload!"); break; case "dailyaward&reload": if (!AwardMgr.ReLoad()) { Console.WriteLine("dailyaward is Error!"); break; } Console.WriteLine("dailyaward is Reload!"); break; case "language&reload": if (!LanguageMgr.Reload("")) { Console.WriteLine("language is Error!"); break; } Console.WriteLine("language is Reload!"); break; case "treasure&reload": if (!TreasureAwardMgr.ReLoad()) { Console.WriteLine("TreasureAward is Error!"); break; } Console.WriteLine("TreasureAward is Reload!"); break; case "nickname": { Console.WriteLine("Please enter the nickname"); string str15 = (CommandArgs.Length > 0) ? CommandArgs[0] : Console.ReadLine(); Console.WriteLine(WorldMgr.GetPlayerStringByPlayerNickName(str15)); break; } default: { string cmdLine = CommandName + string.Join(" ", CommandArgs); if (cmdLine.Length > 0) { if (cmdLine[0] == '/') { cmdLine = cmdLine.Remove(0, 1).Insert(0, "&"); } try { if (!CommandMgr.HandleCommandNoPlvl(client, cmdLine)) { Console.WriteLine("Unknown command: " + cmdLine); } } catch (Exception exception2) { Console.WriteLine(exception2.ToString()); } } break; } } }
public void OnAction(System.Collections.Hashtable parameters) { System.Console.WriteLine("This server GunnyII, edit and build by MrPhuong!"); System.Console.WriteLine("Starting GameServer ... please wait a moment!"); CenterServer.CreateInstance(new CenterServerConfig()); ConsoleStart.StartServer(); ConsoleClient client = new ConsoleClient(); bool flag = true; while (flag) { try { System.Console.Write("> "); string text = System.Console.ReadLine(); string[] array = text.Split(new char[] { '&' }); string key; switch (key = array[0].ToLower()) { case "exit": flag = false; continue; case "notice": if (array.Length < 2) { System.Console.WriteLine("公告需要公告内容,用&隔开!"); continue; } CenterServer.Instance.SendSystemNotice(array[1]); continue; case "reload": if (array.Length < 2) { System.Console.WriteLine("加载需要指定表,用&隔开!"); continue; } CenterServer.Instance.SendReload(array[1]); continue; case "shutdown": CenterServer.Instance.SendShutdown(); continue; case "help": System.Console.WriteLine(this.HelpStr); continue; case "AAS": if (array.Length < 2) { System.Console.WriteLine("加载需要指定状态true or false,用&隔开!"); continue; } CenterServer.Instance.SendAAS(bool.Parse(array[1])); continue; } if (text.Length > 0) { if (text[0] == '/') { text = text.Remove(0, 1); text = text.Insert(0, "&"); } try { if (!CommandMgr.HandleCommandNoPlvl(client, text)) { System.Console.WriteLine("Unknown command: " + text); } } catch (System.Exception ex) { System.Console.WriteLine(ex.ToString()); } } } catch (System.Exception ex2) { System.Console.WriteLine("Error:" + ex2.ToString()); } } if (CenterServer.Instance != null) { CenterServer.Instance.Stop(); } }
/// <summary> /// Executes a API command on a passing the resulting JsonObject To the Callback Function. /// </summary> /// <param name="cmd">the command to run</param> /// <param name="cb">Function Pointer to callback</param> /// <param name="_params">parameters needed by commands</param> /// <returns></returns> public bool DoCommand <T>(Commands cmd, Func <object, bool> cb, string JsonString = null, object[] _params = null) { return(CommandMgr.ExecCommand <T>(cmd.ToString(), cb, JsonString, _params)); }
/// <summary> /// Handles the server action /// </summary> /// <param name="parameters"></param> public void OnAction(Hashtable parameters) { Console.WriteLine("Starting GameServer ... please wait a moment!"); GameServer.CreateInstance(new GameServerConfig()); GameServer.Instance.Start(); GameServer.KeepRunning = true; Console.WriteLine("Server started!"); ConsoleClient client = new ConsoleClient(); while (GameServer.KeepRunning) { try { handler = ConsoleCtrHandler; SetConsoleCtrlHandler(handler, true); Console.Write("> "); string line = Console.ReadLine(); string[] para = line.Split(' '); switch (para[0]) { case "exit": GameServer.KeepRunning = false; break; case "cp": GameClient[] clients = GameServer.Instance.GetAllClients(); int clientCount = clients == null ? 0 : clients.Length; GamePlayer[] players = WorldMgr.GetAllPlayers(); int playerCount = players == null ? 0 : players.Length; List <BaseRoom> rooms = RoomMgr.GetAllUsingRoom(); int roomCount = 0; int gameCount = 0; foreach (BaseRoom r in rooms) { if (!r.IsEmpty) { roomCount++; if (r.IsPlaying) { gameCount++; } } } double memoryCount = GC.GetTotalMemory(false); Console.WriteLine(string.Format("Total Clients/Players:{0}/{1}", clientCount, playerCount)); Console.WriteLine(string.Format("Total Rooms/Games:{0}/{1}", roomCount, gameCount)); Console.WriteLine(string.Format("Total Momey Used:{0} MB", memoryCount / 1024 / 1024)); break; case "shutdown": _count = 6; //_timer = new Timer(new TimerCallback(GameServer.Instance.ShutDownCallBack), null, 0, 60 * 1000); _timer = new Timer(new TimerCallback(ShutDownCallBack), null, 0, 60 * 1000); break; case "savemap": //TODO: break; case "clear": Console.Clear(); break; case "ball&reload": if (BallMgr.ReLoad()) { Console.WriteLine("Ball info is Reload!"); } else { Console.WriteLine("Ball info is Error!"); } break; case "map&reload": if (MapMgr.ReLoadMap()) { Console.WriteLine("Map info is Reload!"); } else { Console.WriteLine("Map info is Error!"); } break; case "mapserver&reload": if (MapMgr.ReLoadMapServer()) { Console.WriteLine("mapserver info is Reload!"); } else { Console.WriteLine("mapserver info is Error!"); } break; case "prop&reload": if (PropItemMgr.Reload()) { Console.WriteLine("prop info is Reload!"); } else { Console.WriteLine("prop info is Error!"); } break; case "item&reload": if (ItemMgr.ReLoad()) { Console.WriteLine("item info is Reload!"); } else { Console.WriteLine("item info is Error!"); } break; case "shop&reload": if (ShopMgr.ReLoad()) { Console.WriteLine("shop info is Reload!"); } else { Console.WriteLine("shop info is Error!"); } break; case "quest&reload": if (QuestMgr.ReLoad()) { Console.WriteLine("quest info is Reload!"); } else { Console.WriteLine("quest info is Error!"); } break; case "fusion&reload": if (FusionMgr.ReLoad()) { Console.WriteLine("fusion info is Reload!"); } else { Console.WriteLine("fusion info is Error!"); } break; case "consortia&reload": if (ConsortiaMgr.ReLoad()) { Console.WriteLine("consortiaMgr info is Reload!"); } else { Console.WriteLine("consortiaMgr info is Error!"); } break; case "rate&reload": if (RateMgr.ReLoad()) { Console.WriteLine("Rate Rate is Reload!"); } else { Console.WriteLine("Rate Rate is Error!"); } break; case "fight&reload": if (FightRateMgr.ReLoad()) { Console.WriteLine("FightRateMgr is Reload!"); } else { Console.WriteLine("FightRateMgr is Error!"); } break; case "dailyaward&reload": if (AwardMgr.ReLoad()) { Console.WriteLine("dailyaward is Reload!"); } else { Console.WriteLine("dailyaward is Error!"); } break; case "language&reload": if (LanguageMgr.Reload("")) { Console.WriteLine("language is Reload!"); } else { Console.WriteLine("language is Error!"); } break; case "nickname": Console.WriteLine("Please enter the nickname"); string nickname = Console.ReadLine(); string state = WorldMgr.GetPlayerStringByPlayerNickName(nickname); Console.WriteLine(state); break; default: if (line.Length <= 0) { break; } if (line[0] == '/') { line = line.Remove(0, 1); line = line.Insert(0, "&"); } try { bool res = CommandMgr.HandleCommandNoPlvl(client, line); if (!res) { Console.WriteLine("Unknown command: " + line); } } catch (Exception e) { Console.WriteLine(e.ToString()); } break; } } catch (Exception ex) { Console.WriteLine(ex); } } if (GameServer.Instance != null) { GameServer.Instance.Stop(); } LogManager.Shutdown(); }
public void OnAction(Hashtable parameters) { Console.WriteLine("This server GunnyII, edit and build by SkelletonX!"); Console.WriteLine("Starting GameServer ... please wait a moment!"); GameServer.CreateInstance(new GameServerConfig()); GameServer.Instance.Start(); GameServer.KeepRunning = true; Console.WriteLine("Server started!"); ConsoleClient client = new ConsoleClient(); while (GameServer.KeepRunning) { try { ConsoleStart.handler = new ConsoleStart.ConsoleCtrlDelegate(ConsoleStart.ConsoleCtrHandler); ConsoleStart.SetConsoleCtrlHandler(ConsoleStart.handler, true); Console.Write("> "); string text = Console.ReadLine(); string[] array = text.Split(new char[] { ' ' }); string key; switch (key = array[0]) { case "exit": GameServer.KeepRunning = false; continue; //dragonares case "lock": Console.Clear(); Console.WriteLine("Ten tai khoan: "); string bnickname = Console.ReadLine(); Console.WriteLine("Ly do band: "); string breason = Console.ReadLine(); DateTime dt2 = new DateTime(2014, 07, 02); //Tempo de banimento using (ManageBussiness mg = new ManageBussiness()) { mg.ForbidPlayerByNickName(bnickname, dt2, false); } Console.WriteLine("Nguoi dung " + bnickname + " da bi khoa."); break; case "unlock": Console.Clear(); Console.WriteLine("Ten tai khoan: "); string bnickname2 = Console.ReadLine(); DateTime dt22 = new DateTime(2014, 07, 02); //Tempo de banimento using (ManageBussiness mg = new ManageBussiness()) { mg.ForbidPlayerByNickName(bnickname2, dt22, true); } Console.WriteLine("Nguoi dung " + bnickname2 + " da mo khoa."); break; case "thongbao": { Console.WriteLine("Thong bao: "); string value = Console.ReadLine(); Console.WriteLine(string.Format(value)); Console.WriteLine("Thong bao thanh cong ."); continue; } case "cp": { GameClient[] allClients = GameServer.Instance.GetAllClients(); int num2 = (allClients == null) ? 0 : allClients.Length; GamePlayer[] allPlayers = WorldMgr.GetAllPlayers(); int num3 = (allPlayers == null) ? 0 : allPlayers.Length; List <BaseRoom> allUsingRoom = RoomMgr.GetAllUsingRoom(); int num4 = 0; int num5 = 0; foreach (BaseRoom current in allUsingRoom) { if (!current.IsEmpty) { num4++; if (current.IsPlaying) { num5++; } } } double num6 = (double)GC.GetTotalMemory(false); Console.WriteLine(string.Format("Total Clients/Players:{0}/{1}", num2, num3)); Console.WriteLine(string.Format("Total Rooms/Games:{0}/{1}", num4, num5)); Console.WriteLine(string.Format("Total Momey Used:{0} MB", num6 / 1024.0 / 1024.0)); continue; } case "shutdown": ConsoleStart._count = 6; ConsoleStart._timer = new Timer(new TimerCallback(ConsoleStart.ShutDownCallBack), null, 0, 60000); continue; case "savemap": continue; case "clear": Console.Clear(); continue; case "ball&reload": if (BallMgr.ReLoad()) { Console.WriteLine("Ball info is Reload!"); continue; } Console.WriteLine("Ball info is Error!"); continue; case "map&reload": if (MapMgr.ReLoadMap()) { Console.WriteLine("Map info is Reload!"); continue; } Console.WriteLine("Map info is Error!"); continue; case "mapserver&reload": if (MapMgr.ReLoadMapServer()) { Console.WriteLine("mapserver info is Reload!"); continue; } Console.WriteLine("mapserver info is Error!"); continue; case "prop&reload": if (PropItemMgr.Reload()) { Console.WriteLine("prop info is Reload!"); continue; } Console.WriteLine("prop info is Error!"); continue; case "item&reload": if (ItemMgr.ReLoad()) { Console.WriteLine("item info is Reload!"); continue; } Console.WriteLine("item info is Error!"); continue; case "shop&reload": if (ShopMgr.ReLoad()) { Console.WriteLine("shop info is Reload!"); continue; } Console.WriteLine("shop info is Error!"); continue; case "quest&reload": if (QuestMgr.ReLoad()) { Console.WriteLine("quest info is Reload!"); continue; } Console.WriteLine("quest info is Error!"); continue; case "fusion&reload": if (FusionMgr.ReLoad()) { Console.WriteLine("fusion info is Reload!"); continue; } Console.WriteLine("fusion info is Error!"); continue; case "consortia&reload": if (ConsortiaMgr.ReLoad()) { Console.WriteLine("consortiaMgr info is Reload!"); continue; } Console.WriteLine("consortiaMgr info is Error!"); continue; case "rate&reload": if (RateMgr.ReLoad()) { Console.WriteLine("Rate Rate is Reload!"); continue; } Console.WriteLine("Rate Rate is Error!"); continue; case "fight&reload": if (FightRateMgr.ReLoad()) { Console.WriteLine("FightRateMgr is Reload!"); continue; } Console.WriteLine("FightRateMgr is Error!"); continue; case "dailyaward&reload": if (AwardMgr.ReLoad()) { Console.WriteLine("dailyaward is Reload!"); continue; } Console.WriteLine("dailyaward is Error!"); continue; case "language&reload": if (LanguageMgr.Reload("")) { Console.WriteLine("language is Reload!"); continue; } Console.WriteLine("language is Error!"); continue; case "nickname": { Console.WriteLine("Please enter the nickname"); string nickName = Console.ReadLine(); string playerStringByPlayerNickName = WorldMgr.GetPlayerStringByPlayerNickName(nickName); Console.WriteLine(playerStringByPlayerNickName); continue; } } if (text.Length > 0) { if (text[0] == '/') { text = text.Remove(0, 1); text = text.Insert(0, "&"); } try { if (!CommandMgr.HandleCommandNoPlvl(client, text)) { Console.WriteLine("Unknown command: " + text); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } } catch (Exception value) { Console.WriteLine(value); } } if (GameServer.Instance != null) { GameServer.Instance.Stop(); } LogManager.Shutdown(); }
/// <summary> /// Handles the server action /// </summary> /// <param name="parameters"></param> public void OnAction(Hashtable parameters) { Console.WriteLine("Starting GameServer ... please wait a moment!"); CenterServer.CreateInstance(new CenterServerConfig()); StartServer(); ConsoleClient client = new ConsoleClient(); bool run = true; while (run) { try { Console.Write("> "); string line = Console.ReadLine(); string[] para = line.Split('&'); switch (para[0].ToLower()) { case "exit": run = false; break; case "notice": if (para.Length < 2) { Console.WriteLine("公告需要公告内容,用&隔开!"); } else { CenterServer.Instance.SendSystemNotice(para[1]); } break; case "reload": if (para.Length < 2) { Console.WriteLine("加载需要指定表,用&隔开!"); } else { CenterServer.Instance.SendReload(para[1]); } //ServerMgr.ReLoadServerList(); break; case "shutdown": CenterServer.Instance.SendShutdown(); break; case "help": Console.WriteLine(HelpStr); break; case "AAS": if (para.Length < 2) { Console.WriteLine("加载需要指定状态true or false,用&隔开!"); } else { CenterServer.Instance.SendAAS(bool.Parse(para[1])); } break; default: if (line.Length <= 0) { break; } if (line[0] == '/') { line = line.Remove(0, 1); line = line.Insert(0, "&"); } try { bool res = CommandMgr.HandleCommandNoPlvl(client, line); if (!res) { Console.WriteLine("Unknown command: " + line); } } catch (Exception e) { Console.WriteLine(e.ToString()); } break; } } catch (Exception ex) { Console.WriteLine("Error:" + ex.ToString()); } } if (CenterServer.Instance != null) { CenterServer.Instance.Stop(); } }
public TankGameLogicProcessor() { _commandMgr = new CommandMgr(); }