예제 #1
0
        public void Handler(Event he)
        {
            if (he.GetCode() == Events.Code_PlayerActionEvent)
            {
                PlayerActionEvent e = (PlayerActionEvent)he;

                if (e.Action == PlayerActionEvent.Actions.Chat)
                {
                    string message = (string)e.Data[0];

                    if (message[0] == '/')
                    {
                        if (IsOwner(e.Player.Name))
                        {
                            e.Player.SendChatMessage(
                                ConsoleReader.HandleCommand(message.Substring(1).Split(' '), e.Player.Name)
                                );

                            e.Cancelled = true;
                        }
                    }
                }

                if (e.Action == PlayerActionEvent.Actions.Born)
                {
                    if (IsOwner(e.Player.Name))
                    {
                        Server.Log("Player {0} owner is!", e.Player.Name);
                    }
                }
            }

            if (he.GetCode() == Events.Code_ConsoleCommandEvent)
            {
                ConsoleCommandEvent e = (ConsoleCommandEvent)he;

                if (e.Command.Length > 1)
                {
                    if (e.Command[0] == "addowner" && !IsOwner(e.Command[1]))
                    {
                        AddOwner(e.Command[1]);

                        e.Metadata = "New owner " + e.Command[1];

                        Server.BroadcastMessage(e.Metadata);

                        e.Cancelled = true;
                    }

                    if (e.Command[0] == "removeowner" && !IsOwner(e.Command[1]))
                    {
                        RemoveOwner(e.Command[1]);

                        e.Metadata = "Deleted owner " + e.Command[1];

                        Server.BroadcastMessage(e.Metadata);

                        e.Cancelled = true;
                    }
                }
            }
        }