NextAll() private méthode

private NextAll ( ) : string
Résultat string
Exemple #1
1
 static void TrollHandler(Player player, Command cmd)
 {
     string Name = cmd.Next();
     if (Name == null)
     {
         player.Message("Player not found. Please specify valid name.");
         return;
     }
     if (!Player.IsValidName(Name))
         return;
     Player target = Server.FindPlayerOrPrintMatches(player, Name, true, true);
     if (target == null)
         return;
     string options = cmd.Next();
     if (options == null)
     {
         CdTroll.PrintUsage(player);
         return;
     }
     string Message = cmd.NextAll();
     if (Message.Length < 1 && options.ToLower() != "leave")
     {
         player.Message("&WError: Please enter a message for {0}.", target.ClassyName);
         return;
     }
     switch (options.ToLower())
     {
         case "pm":
             if (player.Can(Permission.UseColorCodes) && Message.Contains("%"))
             {
                 Message = Color.ReplacePercentCodes(Message);
             }
             Server.Players.Message("&Pfrom {0}: {1}",
                 target.Name, Message);
             break;
         case "ac":
             Chat.SendAdmin(target, Message);
             break;
         case "st":
         case "staff":
             Chat.SendStaff(target, Message);
             break;
         case "i":
         case "impersonate":
         case "msg":
         case "message":
         case "m":
             Server.Message("{0}&S&F: {1}",
                               target.ClassyName, Message);
             break;
         case "leave":
         case "disconnect":
         case "gtfo":
             Server.Players.Message("&SPlayer {0}&S left the server.",
                 target.ClassyName);
             break;
         default: player.Message("Invalid option. Please choose st, ac, pm, message or leave");
             break;
     }
 }
        internal static void BRB(Player player, Command cmd)
        {
            StreamReader streamReader = new StreamReader("plugins/brbMessage.txt");
            string message = streamReader.ReadToEnd();
            streamReader.Close();

            string msg = cmd.NextAll().Trim();
            if (player.Info.IsMuted)
            {
                player.MessageMuted();
                return;
            }
            if (msg.Length > 0)
            {
                Server.Message("{0}&S &EWill Brb &9({1})",
                                  player.ClassyName, msg);
                player.IsAway = true;
                return;
            }
            else
            {
                Server.Players.Message("&S{0} &EWill Brb &9(" + message + ")", player.ClassyName);
                player.IsAway = true;
            }
        }
Exemple #3
0
        private static void CustomChatHandler(Player player, Command cmd)
        {
            if (player.Info.IsMuted)
            {
                player.MessageMuted();
                return;
            }

            if (player.DetectChatSpam())
            {
                return;
            }

            string message = cmd.NextAll().Trim();

            if (message.Length <= 0)
            {
                return;
            }
            if (player.Can(Permission.UseColorCodes) && message.Contains("%"))
            {
                message = Color.ReplacePercentCodes(message);
            }
            Chat.SendCustom(player, message);
        }
Exemple #4
0
        static void MeHandler(Player player, Command cmd)
        {
            if (player.Info.IsMuted)
            {
                player.MessageMuted();
                return;
            }

            if (player.DetectChatSpam())
            {
                return;
            }

            string msg = cmd.NextAll().Trim();

            if (msg.Length > 0)
            {
                player.Info.ProcessMessageWritten();
                if (player.Can(Permission.UseColorCodes) && msg.Contains("%"))
                {
                    msg = Color.ReplacePercentCodes(msg);
                }
                Chat.SendMe(player, msg);
            }
        }
Exemple #5
0
        static void SayHandler(Player player, Command cmd)
        {
            if (player.Info.IsMuted)
            {
                player.MessageMuted();
                return;
            }

            if (player.DetectChatSpam())
            {
                return;
            }

            if (player.Can(Permission.Say))
            {
                string msg = cmd.NextAll().Trim();
                if (msg.Length > 0)
                {
                    Chat.SendSay(player, msg);
                }
                else
                {
                    CdSay.PrintUsage(player);
                }
            }
            else
            {
                player.MessageNoAccess(Permission.Say);
            }
        }
Exemple #6
0
        internal static void Say(Player player, Command cmd)
        {
            if (player.Info.IsMuted)
            {
                player.MutedMessage();
                return;
            }

            if (player.Can(Permission.Say))
            {
                string msg = cmd.NextAll();
                if (player.Can(Permission.UseColorCodes) && msg.Contains("%"))
                {
                    msg = Color.ReplacePercentCodes(msg);
                }
                if (msg != null && msg.Trim().Length > 0)
                {
                    player.Info.LinesWritten++;
                    Server.SendToAllExceptIgnored(player, "&Y{0}", null, msg.Trim());
                    IRC.SendAction(String.Format("&Y{0}", msg.Trim()));
                }
                else
                {
                    cdSay.PrintUsage(player);
                }
            }
            else
            {
                player.NoAccessMessage(Permission.Say);
            }
        }
        // broken... for now

        /*void ReloadConfig( Player player, Command cmd ) {
         *  if( player.Can( Permissions.SaveAndLoad ) ) {
         *      world.config.LoadDefaults();
         *      world.config.Load( "config.xml" );
         *      world.config.ApplyConfig();
         *  }
         * }*/


        public void Me(Player player, Command cmd)
        {
            string msg = cmd.NextAll().Trim();

            if (msg != null)
            {
                world.SendToAll("*" + Color.Purple + player.name + " " + msg, null);
            }
        }
Exemple #8
0
        private static void QuitHandler(Player player, Command cmd)
        {
            string Msg = cmd.NextAll();

            if (Msg.Length < 1)
            {
                CdQuit.PrintUsage(player);
                return;
            }
            else
            {
                player.Info.LeaveMsg = "left the server: &C" + Msg;
                player.Message("Your quit message is now set to: {0}", Msg);
            }
        }
Exemple #9
0
        static void QuitHandler(Player player, Command cmd)
        {
            string Msg = cmd.NextAll();

            if (Msg.Length < 1)
            {
                CdQuit.PrintUsage(player);
                return;
            }
            else
            {
                player.Info.LeaveMsg = "left the server: &C" + Msg;
                player.Message("Your quit message is now set to: {0}", Msg);
            }
        }
Exemple #10
0
        private static void RageHandler(Player player, Command cmd)
        {
            string reason = cmd.NextAll();

            if (reason.Length < 1)
            {
                Server.Players.Message("{0} &WRagequit from the server.", player.ClassyName);
                player.Kick(Player.Console, "&WRagequit", LeaveReason.RageQuit, false, false, false);
                IRC.SendAction(player.ClassyName + " &WRagequit from the server.");
                return;
            }
            Server.Players.Message("{0} &WRagequit from the server: {1}",
                                   player.ClassyName, reason);
            IRC.SendAction(player.ClassyName + " &WRagequit from the server: " + reason);
            player.Kick(Player.Console, reason, LeaveReason.RageQuit, false, false, false);
        }
 void Say(Player player, Command cmd)
 {
     if (player.Can(Permissions.Say))
     {
         string msg = cmd.NextAll();
         if (msg != null && msg.Trim().Length > 0)
         {
             world.SendToAll(PacketWriter.MakeMessage(Color.Say + msg.Trim()), null);
         }
         else
         {
             player.Message("Usage: " + Color.Help + "/say message");
         }
     }
     else
     {
         world.NoAccessMessage(player);
     }
 }
Exemple #12
0
        static void SayHandler( Player player, Command cmd ) {
            if( player.Info.IsMuted ) {
                player.MessageMuted();
                return;
            }

            if( player.DetectChatSpam() ) return;

            if( player.Can( Permission.Say ) ) {
                string msg = cmd.NextAll().Trim();
                if( msg.Length > 0 ) {
                    Chat.SendSay( player, msg );
                } else {
                    CdSay.PrintUsage( player );
                }
            } else {
                player.MessageNoAccess( Permission.Say );
            }
        }
Exemple #13
0
        internal static void Away(Player player, Command cmd)
        {
            string msg = cmd.NextAll().Trim();

            if (player.Info.IsMuted)
            {
                player.MessageMuted();
                return;
            }
            if (msg.Length > 0)
            {
                Server.Message("{0}&S is away &9({1})",
                               player.ClassyName, msg);
                player.IsAway = true;
                return;
            }
            Server.Players.Message("&S{0} is away &9(Away From Keyboard)", player.ClassyName);
            player.IsAway = true;
        }
Exemple #14
0
        static void StaffHandler(Player player, Command cmd)
        {
            if (player.Info.IsMuted)
            {
                player.MessageMuted();
                return;
            }

            if (player.DetectChatSpam())
            {
                return;
            }

            string message = cmd.NextAll().Trim();

            if (message.Length > 0)
            {
                Chat.SendStaff(player, message);
            }
        }
Exemple #15
0
 static void BanHandler( Player player, Command cmd ) {
     string targetName = cmd.Next();
     if( targetName == null ) {
         CdBan.PrintUsage( player );
         return;
     }
     PlayerInfo target = PlayerDB.FindPlayerInfoOrPrintMatches( player, targetName );
     if( target == null ) return;
     string reason = cmd.NextAll();
     try {
         Player targetPlayer = target.PlayerObject;
         target.Ban( player, reason, true, true );
         WarnIfOtherPlayersOnIP( player, target, targetPlayer );
     } catch( PlayerOpException ex ) {
         player.Message( ex.MessageColored );
         if( ex.ErrorCode == PlayerOpExceptionCode.ReasonRequired ) {
             FreezeIfAllowed( player, target );
         }
     }
 }
Exemple #16
0
        internal static void StaffChat(Player player, Command cmd)
        {
            if (player.Info.IsMuted)
            {
                player.MutedMessage();
                return;
            }

            if (DateTime.UtcNow < player.Info.MutedUntil)
            {
                player.Message("You are muted for another {0:0} seconds.",
                               player.Info.MutedUntil.Subtract(DateTime.UtcNow).TotalSeconds);
                return;
            }


            Player[] plist = Server.PlayerList;

            if (plist.Length > 0)
            {
                player.Info.LinesWritten++;
            }

            string message = cmd.NextAll();

            if (message != null && message.Trim().Length > 0)
            {
                message = message.Trim();
                if (player.Can(Permission.UseColorCodes) && message.Contains("%"))
                {
                    message = Color.ReplacePercentCodes(message);
                }
                for (int i = 0; i < plist.Length; i++)
                {
                    if ((plist[i].Can(Permission.ReadStaffChat) || plist[i] == player) && !plist[i].IsIgnoring(player.Info))
                    {
                        plist[i].Message("{0}(staff){1}{0}: {2}", Color.PM, player.GetClassyName(), message);
                    }
                }
            }
        }
Exemple #17
0
        static void MeHandler(Player player, Command cmd)
        {
            if (player.Info.IsMuted)
            {
                player.MessageMuted();
                return;
            }

            if (player.DetectChatSpam())
            {
                return;
            }

            string msg = cmd.NextAll().Trim();

            if (msg.Length > 0)
            {
                player.Info.ProcessMessageWritten();
                Chat.SendMe(player, msg);
            }
        }
 // Kick a player. One argument (mandatory) - player name (can be partial).
 void Kick(Player player, Command cmd)
 {
     if (player.Can(Permissions.Kick))
     {
         string name = cmd.Next();
         if (name != null)
         {
             string msg      = cmd.NextAll();
             Player offender = world.FindPlayer(name);
             if (offender != null)
             {
                 world.SendToAll(PacketWriter.MakeMessage(
                                     Color.Red + offender.name + " was kicked by " + player.name), offender);
                 if (msg != null && msg != "")
                 {
                     world.log.Log("{0} was kicked by {1}. Message: {2}", LogType.UserActivity, offender.name, player.name, msg);
                     offender.session.Kick("Kicked by " + player.name + ": " + msg);
                 }
                 else
                 {
                     world.log.Log("{0} was kicked by {1}", LogType.UserActivity, offender.name, player.name);
                     offender.session.Kick("You have been kicked by " + player.name);
                 }
             }
             else
             {
                 world.NoPlayerMessage(player, name);
             }
         }
         else
         {
             player.Message("Usage: " + Color.Help + "/kick PlayerName [Message]" +
                            Color.Sys + " or " + Color.Help + "/k PlayerName [Message]");
         }
     }
     else
     {
         world.NoAccessMessage(player);
     }
 }
Exemple #19
0
        internal static void Me(Player player, Command cmd)
        {
            if (player.Info.IsMuted)
            {
                player.MutedMessage();
                return;
            }

            string msg = cmd.NextAll().Trim();

            if (msg.Length > 0)
            {
                player.Info.LinesWritten++;
                if (player.Can(Permission.UseColorCodes) && msg.Contains("%"))
                {
                    msg = Color.ReplacePercentCodes(msg);
                }
                string message = String.Format("{0}*{1} {2}", Color.Me, player.Name, msg);
                Server.SendToAll(message);
                IRC.SendChannelMessage(message);
            }
        }
Exemple #20
0
        internal static void Say( Player player, Command cmd ) {
            if( player.Info.IsMuted ) {
                player.MutedMessage();
                return;
            }

            if( player.Can( Permission.Say ) ) {
                string msg = cmd.NextAll();
                if( player.Can( Permission.UseColorCodes ) && msg.Contains( "%" ) ) {
                    msg = Color.ReplacePercentCodes( msg );
                }
                if( msg != null && msg.Trim().Length > 0 ) {
                    player.Info.LinesWritten++;
                    Server.SendToAllExceptIgnored( player, "&Y{0}", null, msg.Trim() );
                    IRC.SendAction( String.Format( "&Y{0}", msg.Trim() ) );
                } else {
                    cdSay.PrintUsage( player );
                }
            } else {
                player.NoAccessMessage( Permission.Say );
            }
        }
Exemple #21
0
        private static void MeHandler(Player player, Command cmd)
        {
            if (player.Info.IsMuted)
            {
                player.MessageMuted();
                return;
            }

            if (player.DetectChatSpam())
            {
                return;
            }

            string msg = cmd.NextAll().Trim();

            if (msg.Length > 0)
            {
                Chat.SendMe(player, msg);
            }
            else
            {
                CdMe.PrintUsage(player);
            }
        }
Exemple #22
0
        internal static void AdminChat(Player player, Command cmd)
        {
            if (player.Info.IsMuted)
            {
                player.MessageMuted();
                return;
            }
            if (DateTime.UtcNow < player.Info.MutedUntil)
            {
                player.Message("You are muted for another {0:0} seconds.",
                               player.Info.MutedUntil.Subtract(DateTime.UtcNow).TotalSeconds);
                return;
            }
            string message = cmd.NextAll().Trim();

            if (message.Length > 0)
            {
                if (player.Can(Permission.UseColorCodes) && message.Contains("%"))
                {
                    message = Color.ReplacePercentCodes(message);
                }
                Chat.SendAdmin(player, message);
            }
        }
        public static void RankHandler( Player player, Command cmd )
        {
            string name = cmd.Next();
            string newRankName = cmd.Next();

            // Check arguments
            if( name == null || newRankName == null ) {
                CdRank.PrintUsage( player );
                player.Message( "See &H/Ranks&S for list of ranks." );
                return;
            }

            // Parse rank name
            Rank newRank = RankManager.FindRank( newRankName );
            if( newRank == null ) {
                player.MessageNoRank( newRankName );
                return;
            }

            // Parse player name
            if( name == "-" ) {
                if( player.LastUsedPlayerName != null ) {
                    name = player.LastUsedPlayerName;
                } else {
                    player.Message( "Cannot repeat player name: you haven't used any names yet." );
                    return;
                }
            }
            PlayerInfo targetInfo = PlayerDB.FindPlayerInfoExact( name );

            if( targetInfo == null ) {
                if( !player.Can( Permission.EditPlayerDB ) ) {
                    player.MessageNoPlayer( name );
                    return;
                }
                if( !Player.IsValidName( name ) ) {
                    player.MessageInvalidPlayerName( name );
                    CdRank.PrintUsage( player );
                    return;
                }
                if( cmd.IsConfirmed ) {
                    if( newRank > RankManager.DefaultRank ) {
                        targetInfo = PlayerDB.AddFakeEntry( name, RankChangeType.Promoted );
                    } else {
                        targetInfo = PlayerDB.AddFakeEntry( name, RankChangeType.Demoted );
                    }
                } else {
                    player.Confirm( cmd,
                                    "Warning: Player \"{0}\" is not in the database (possible typo). Type the full name or",
                                    name );
                    return;
                }
            }

            try {
                player.LastUsedPlayerName = targetInfo.Name;

                //reset temprank values
                if (targetInfo.isTempRanked)
                {
                    targetInfo.isTempRanked = false;
                    targetInfo.tempRankTime = TimeSpan.FromSeconds(0);
                }
                targetInfo.ChangeRank( player, newRank, cmd.NextAll(), true, true, false );
            } catch( PlayerOpException ex ) {
                player.Message( ex.MessageColored );
            }
        }
Exemple #24
0
        static void TimerHandler(Player player, Command cmd)
        {
            string param = cmd.Next();

            // List timers
            if (param == null)
            {
                ChatTimer[] list = ChatTimer.TimerList.OrderBy(timer => timer.TimeLeft).ToArray();
                if (list.Length == 0)
                {
                    player.Message("No timers running.");
                }
                else
                {
                    player.Message("There are {0} timers running:", list.Length);
                    foreach (ChatTimer timer in list)
                    {
                        player.Message("  #{0} \"{1}&S\" (started by {2}, {3} left)",
                                       timer.Id, timer.Message, timer.StartedBy, timer.TimeLeft.ToMiniString());
                    }
                }
                return;
            }

            // Abort a timer
            if (param.Equals("abort", StringComparison.OrdinalIgnoreCase))
            {
                int timerId;
                if (cmd.NextInt(out timerId))
                {
                    ChatTimer timer = ChatTimer.FindTimerById(timerId);
                    if (timer == null || !timer.IsRunning)
                    {
                        player.Message("Given timer (#{0}) does not exist.", timerId);
                    }
                    else
                    {
                        timer.Stop();
                        string abortMsg = String.Format("&Y(Timer) {0}&Y aborted a timer with {1} left: {2}",
                                                        player.ClassyName, timer.TimeLeft.ToMiniString(), timer.Message);
                        Chat.SendSay(player, abortMsg);
                    }
                }
                else
                {
                    CdTimer.PrintUsage(player);
                }
                return;
            }

            // Start a timer
            if (player.Info.IsMuted)
            {
                player.MessageMuted();
                return;
            }
            if (player.DetectChatSpam())
            {
                return;
            }
            TimeSpan duration;

            if (!param.TryParseMiniTimespan(out duration))
            {
                CdTimer.PrintUsage(player);
                return;
            }
            if (duration > DateTimeUtil.MaxTimeSpan)
            {
                player.MessageMaxTimeSpan();
                return;
            }
            if (duration < ChatTimer.MinDuration)
            {
                player.Message("Timer: Must be at least 1 second.");
                return;
            }

            string sayMessage;
            string message = cmd.NextAll();

            if (String.IsNullOrEmpty(message))
            {
                sayMessage = String.Format("&Y(Timer) {0}&Y started a {1} timer",
                                           player.ClassyName,
                                           duration.ToMiniString());
            }
            else
            {
                sayMessage = String.Format("&Y(Timer) {0}&Y started a {1} timer: {2}",
                                           player.ClassyName,
                                           duration.ToMiniString(),
                                           message);
            }
            Chat.SendSay(player, sayMessage);
            ChatTimer.Start(duration, message, player.Name);
        }
        static void BanXHandler(Player player, Command cmd)
        {
            string ban = cmd.Next();

            if (ban == null)
            {
                player.Message("&WError: Enter a player name to BanX");
                return;
            }

            //parse
            if (ban == "-")
            {
                if (player.LastUsedPlayerName != null)
                {
                    ban = player.LastUsedPlayerName;
                }
                else
                {
                    player.Message("Cannot repeat player name: you haven't used any names yet.");
                    return;
                }
            }
            PlayerInfo target = PlayerDB.FindPlayerInfoOrPrintMatches(player, ban);
            if (target == null) return;
            if (!Player.IsValidName(ban))
            {
                CdBanx.PrintUsage(player);
                return;
            }else{
                UndoPlayerHandler2(player, new Command("/undox " + target.Name + " 100000"));

                string reason = cmd.NextAll();

                if (reason.Length < 1)
                    reason = "Reason Undefined: BanX";
                try{
                    Player targetPlayer = target.PlayerObject;
                    target.Ban(player, reason, false, true);
                }catch (PlayerOpException ex){
                    player.Message(ex.MessageColored);
                    return;
                }
                    if (player.Can(Permission.Demote, target.Rank))
                    {
                        if (target.Rank != RankManager.LowestRank)
                        {
                            player.LastUsedPlayerName = target.Name;
                            target.ChangeRank(player, RankManager.LowestRank, cmd.NextAll(), false, true, false);
                        }
                        Server.Players.Message("{0}&S was BanX'd by {1}&S (with auto-demote):&W {2}", target.ClassyName, player.ClassyName, reason);
                        IRC.PlayerSomethingMessage(player, "BanX'd (with auto-demote)", target, reason);
                        return;
                    }
                    else
                    {
                        player.Message("&WAuto demote failed: You didn't have the permissions to demote the target player");
                        Server.Players.Message("{0}&S was BanX'd by {1}: &W{2}", target.ClassyName, player.ClassyName, reason);
                        IRC.PlayerSomethingMessage(player, "BanX'd", target, reason);
                    }
                player.Message("&SConfirm the undo with &A/ok");
            }
        }
Exemple #26
0
 private static void GuildChatHandler( Player player, Command cmd )
 {
     Guild guild = GuildManager.PlayersGuild( player.Info );
     if ( guild == null ) {
         player.Message( "You do not have a guild" );
         return;
     }
     string msg = cmd.NextAll();
     if ( string.IsNullOrEmpty( msg ) ) {
         player.Message( "&WMessage cannot be null: /Gc [message to send]" );
         return;
     }
     guild.SendGuildMessage( player, msg );
     return;
 }
Exemple #27
0
        private static void GuildHandler( Player player, Command cmd )
        {
            string Param = cmd.Next();
            if ( Param == null ) {
                CdGuild.PrintUsage( player );
                return;
            }

            Param = Param.ToLower();

            PlayerInfo target; //used to store a targetplayer in the switch case

            //this is for stuff which someone without a guild CAN do
            switch ( Param ) {
                case "create":
                    string Name = cmd.NextAll();
                    if ( string.IsNullOrEmpty( Name ) ) {
                        player.Message( "&WGuild name cannot be null: &H/Guild create Name" );
                        return;
                    }
                    if ( Cache.ForbiddenNames.Contains( Name.ToLower() ) ) {
                        player.Message( "&WName is forbidden: You cannot create a guild with this name" );
                        return;
                    }
                    GuildManager.CreateGuild( Name, player );
                    return;

                case "who":
                case "player":
                    string pp = cmd.Next();
                    if ( string.IsNullOrEmpty( pp ) ) {
                        player.Message( "&WPlayer name cannot be null: &h/Guild who playername" );
                        return;
                    }
                    target = PlayerDB.FindPlayerInfoOrPrintMatches( player, pp );
                    if ( target == null )
                        return;
                    player.Message( "{0}&s belongs to {1}", target.Name,
                        GuildManager.PlayersGuild( target ) == null ?
                        "no guild" :
                        "guild \"" + GuildManager.PlayersGuild( target ).Name + "\"" );
                    return;

                case "list":
                    string pro = cmd.Next();
                    if ( pro != null ) {
                        if ( pro.ToLower() == "provisional" ) {
                            player.Message( "Available provisional guilds:" );
                            player.Message( Cache.Guilds.Where( gg => gg.Provisional ).JoinToString() );
                            return;
                        }
                    }
                    player.Message( "Available guilds:" );
                    player.Message( Cache.Guilds.Where( gg => !gg.Provisional ).JoinToString() );
                    return;

                case "info":
                    string gstring = cmd.NextAll();
                    if ( string.IsNullOrEmpty( gstring ) ) {
                        if ( GuildManager.PlayerHasGuild( player.Info ) ) {
                            gstring = GuildManager.PlayersGuild( player.Info ).Name;
                        } else {
                            player.Message( "Guild name cannot be null: &H/Guild Info [GuildName]" );
                            return;
                        }
                    }
                    Guild gui = GuildManager.FindGuildOrPrintResults( player, gstring );
                    if ( gui == null ) {
                        return;
                    }
                    string[] Members = gui.Members.Where( p => gui.GuildMaster != p && !gui.Admins.Contains( p ) ).ToArray();
                    player.Message( "&hGuild \"{0}&h\" ({1}&h): &S\n" +
                        "{2}" +
                        "Guildmaster: {3}&S\n" +
                        "Admins: {4}\n" +
                        "Members: {5}\n" +
                        "Level: {6}\n" +
                        "PvP: {7}",
                        gui.Name,
                        !string.IsNullOrEmpty( gui.Tag ) ? gui.Tag : "No Tag",
                        gui.Open ? "This guild is open for anyone to join\n" : "",
                        gui.GuildMaster,
                        gui.Admins == null || gui.Admins.Length == 0 ? "(No Admins)" : gui.Admins.JoinToString(),
                        Members == null || Members.Length == 0 ? "(No Members)" : Members.JoinToString(),
                        gui.Level,
                        gui.PvP ? "&COn" : "&AOff" );
                    return;

                case "find":
                case "search":
                    string searchterm = cmd.NextAll(); {
                        if ( string.IsNullOrEmpty( searchterm ) ) {
                            player.Message( "&WSearch term cannot be null: &H/Guild search [search term]" );
                            return;
                        }
                        Guild[] FoundGuilds = GuildManager.FindGuilds( searchterm );
                        player.Message( "Guilds found matching {0}: {1}", searchterm, FoundGuilds.JoinToString() );
                    }
                    return;

                case "join":
                    if ( GuildManager.PlayerHasGuild( player.Info ) ) {
                        player.Message( "&HYou already have guild" );
                        return;
                    }
                    string s = cmd.NextAll();
                    if ( string.IsNullOrEmpty( s ) ) {
                        player.Message( "&WGuild to join cannot be null: &H/Guild join [GuildName]" );
                        return;
                    }
                    Guild g = GuildManager.FindGuildOrPrintResults( player, s );
                    if ( g == null )
                        return;
                    g.AcceptInvitationAndJoinGuild( player );
                    return;
            }
            if ( !GuildManager.PlayerHasGuild( player.Info ) ) {
                player.Message( "&HYou do not have a guild. Ask a guildmaster or guild admin to join their guild" );
                return;
            }
            //This is for stuff you NEED a guild for (provisional or not)
            Guild guild = GuildManager.PlayersGuild( player.Info );
            switch ( Param ) {
                case "open":
                    if ( !GuildManager.IsPlayerAnAdmin( player, guild ) ) {
                        player.Message( "&WYou need to be a guildmaster or admin to use this command" );
                        return;
                    }
                    string OpenParam = cmd.Next();
                    if ( string.IsNullOrEmpty( OpenParam ) ) {
                        player.Message( "&WCannot parse toggle: &H/Guild Open [True/False]" );
                        return;
                    }
                    bool OpenStatus;
                    if ( !bool.TryParse( OpenParam, out OpenStatus ) ) {
                        player.Message( "&WCannot parse toggle: &H/Guild Open [True/False]" );
                        return;
                    }
                    if ( guild.Open == OpenStatus )
                        player.Message( "Guild invitation status not changed, currently {0}",
                            OpenStatus == true ? "open" : "closed" );
                    else if ( guild.Open == true )
                        player.Message( "Guild invitation status changed to \"closed\"" );
                    else
                        player.Message( "Guild invitation status changed to \"open for anyone\"" );

                    guild.Open = OpenStatus;
                    return;

                case "pvp":
                    if ( !GuildManager.IsPlayerAnAdmin( player, guild ) ) {
                        player.Message( "&WYou need to be a guildmaster or admin to use this command" );
                        return;
                    }
                    PvP_Perk prk = ( PvP_Perk )GuildManager.FindPerkOrPrintResults( player, "pvp" );
                    if ( prk == null )
                        return;
                    Guild g = guild;
                    if ( g.Level < prk.LevelNeeded ) {
                        player.Message( "You cannot use this perk: Your guild needs level {0}", prk.LevelNeeded );
                        return;
                    }
                    if ( g.PvP ) {
                        prk.StopPerk();
                        guild.SendGuildNotification( "&HGuild PvP has been " + Color.Green + "disabled" );
                    } else {
                        if ( string.IsNullOrEmpty( g.Tag ) ) {
                            player.Message( "&WGuild tag must be set before pvp can be enabled" );
                            return;
                        }
                        prk.StartPerk();
                        guild.SendGuildNotification( "&HGuild PvP has been &Wenabled" );
                    }
                    return;

                case "invite":
                    if ( !GuildManager.IsPlayerAnAdmin( player, guild ) ) {
                        player.Message( "&WYou need to be a guildmaster or admin to use this command" );
                        return;
                    }
                    string playerstr = cmd.Next();
                    if ( String.IsNullOrEmpty( playerstr ) ) {
                        player.Message( "You need to use a name for someone to join your guild: &H/Guild invite PlayerName" );
                        return;
                    }
                    target = PlayerDB.FindPlayerInfoOrPrintMatches( player, playerstr );
                    if ( target == null )
                        return;
                    List<String> lst = guild.PlayersInvited.ToList();
                    if ( GuildManager.PlayerHasGuild( target ) ) {
                        player.Message( "&WThis player is already in a guild! ({0})", GuildManager.PlayersGuild(target));
                        return;
                    }
                    if ( lst.Contains( target.Name ) ) {
                        player.Message( "&WThis player has already been invited to your guild" );
                        return;
                    }
                    lst.Add( target.Name );
                    guild.PlayersInvited = lst.ToArray();
                    player.Message( "Player {0} has been invited to your guild", target.Name );
                    if ( target.IsOnline ) {
                        target.PlayerObject.Message( "&H{0} has invited you to join their guild {1}! Join now, using /Guild Join {1}", player.Name, guild.Name );
                    }
                    return;

                case "exp":
                case "xp":
                case "experience":
                    player.Message( "&HCurrent XP: {0}. Xp needed for next level ({1}): {2}",
                        guild.XP,
                        guild.Level + 1,
                        guild.XPNeededForNextLevel() );
                    return;

                case "leave":
                case "quit":
                    if ( !cmd.IsConfirmed ) {
                        player.Confirm( cmd, "Remove yourself from {0}&S?", GuildManager.PlayersGuild( player.Info ).Name );
                        return;
                    }
                    guild.RemoveMember( player.Info );
                    return;

                case "message":
                case "msg":
                    string msg = cmd.NextAll();
                    if ( string.IsNullOrEmpty( msg ) ) {
                        player.Message( "&WMessage cannot be null: &H/Guild message [message to send]" );
                        return;
                    }
                    guild.SendGuildMessage( player, msg );
                    return;
            }
            if ( guild.Provisional ) {
                GuildManager.MessageProvisionalGuild( player );
                return;
            }
            //this is for stuff a provisional guild cannot do
            switch ( Param ) {
                case "admin":
                case "admins":
                    string s1 = cmd.Next();
                    if ( string.IsNullOrEmpty( s1 ) ) {
                        player.Message( "Guild admins: {0}",
                            guild.Admins.Length == 0 ?
                            "&WThis guild has no admins!" :
                            "(Guildmaster)" + guild.GuildMaster + ", " + guild.Admins.JoinToString() );

                        if ( player.Name == guild.GuildMaster ) {
                            player.Message( "&HYou can add admins using &H/Guild admin [add/remove] [playerName]" );
                        }
                        return;
                    }
                    if ( player.Name != guild.GuildMaster ) {
                        player.Message( "&WOnly the guildmaster ({0}) can manage admins", guild.GuildMaster );
                        return;
                    }
                    string s2 = cmd.Next();
                    if ( string.IsNullOrEmpty( s2 ) ) {
                        player.Message( "Player name cannot be null" );
                        return;
                    }
                    target = PlayerDB.FindPlayerInfoOrPrintMatches( player, s2 );
                    if ( target == null )
                        return;
                    string Name = target.Name;
                    if ( !guild.Members.Contains( Name ) ) {
                        player.Message( "This player is not a member of your guild" );
                        return;
                    }
                    if ( s1.ToLower() == "add" ) {
                        List<string> lst = guild.Admins.ToList();
                        if ( Name == player.Name ) {
                            player.Message( "&WCannot add yourself" );
                            return;
                        }
                        if ( lst.Contains( Name ) ) {
                            player.Message( "{0} is already an admin", Name );
                            return;
                        }
                        lst.Add( Name );
                        guild.Admins = lst.ToArray();
                        player.Message( "Added {0} as an admin", Name );
                        if ( target.IsOnline ) {
                            target.PlayerObject.Message( "&WYou are now an admin of {0}", guild.Name );
                        }
                    }
                    if ( s1.ToLower() == "remove" ) {
                        List<string> lst = guild.Admins.ToList();
                        if ( Name == player.Name ) {
                            player.Message( "&WCannot remove yourself" );
                            return;
                        }
                        if ( !lst.Contains( Name ) ) {
                            player.Message( "&W{0} is not an admin", Name );
                            return;
                        }
                        lst.Remove( Name );
                        guild.Admins = lst.ToArray();
                        player.Message( "Removed {0} as an admin", Name );
                        if ( target.IsOnline ) {
                            target.PlayerObject.Message( "&WYou are no longer an admin of {0}", guild.Name );
                        }
                    }
                    return;

                case "kick":
                    if ( !GuildManager.IsPlayerAnAdmin( player, guild ) ) {
                        player.Message( "&WYou need to be an Admin+ of the guild to use this command" );
                        return;
                    }
                    string TargetName = cmd.Next();
                    if ( string.IsNullOrEmpty( TargetName ) ) {
                        player.Message( "&WPlayer name cannot be null" );
                        return;
                    }
                    target = PlayerDB.FindPlayerInfoOrPrintMatches( player, TargetName );
                    if ( target == null )
                        return;
                    if ( target.Name == guild.GuildMaster ) {
                        player.Message( "&WUnable to kick this player" );
                        return;
                    }
                    if ( !guild.Members.Contains( target.Name ) ) {
                        player.Message( "&WPlayer is not a member of your guild" );
                        return;
                    }
                    guild.RemoveMember( target );
                    guild.SendGuildNotification( target.Name + " was kicked from the guild by " + player.Name );
                    return;

                case "bug":
                case "eb":
                case "explodingbug":
                    ExplodingBugPerk p1 = ( ExplodingBugPerk )GuildManager.FindPerkOrPrintResults( player, "explodingbug" );
                    if ( p1 == null )
                        return;
                    if ( guild.Level < p1.LevelNeeded ) {
                        player.Message( "You cannot use this perk: Your guild needs level {0}", p1.LevelNeeded );
                        return;
                    }
                    string bParam = cmd.Next();
                    if ( string.IsNullOrEmpty( bParam ) ) {
                        object o;
                        if ( player.PublicAuxStateObjects.TryGetValue( "bug", out o ) ) {
                            player.Message( "&WYou already have an exploding bug alive" );
                            return;
                        }
                        if ( Events.IsInRangeOfSpawnpoint( player.World, player.Position ) ) {
                            player.Message( "&WCannot place a bug this close to a spawn point" );
                            return;
                        }
                        p1.SpawnBug( player );
                    } else if ( bParam.ToLower() == "stop" || bParam.ToLower() == "remove" ) {
                        object o;
                        if ( player.PublicAuxStateObjects.TryGetValue( "bug", out o ) ) {
                            ExplodingBug b = ( ExplodingBug )o;
                            b.Stop();
                        } else {
                            player.Message( "&WYou do not have an exploding bug to remove" );
                        }
                    }
                    return;

                case "turret":
                    string tParam = cmd.Next();
                    TurretPerk p2 = ( TurretPerk )GuildManager.FindPerkOrPrintResults( player, "turretperk" );
                    if ( p2 == null )
                        return;
                    if ( guild.Level < p2.LevelNeeded ) {
                        player.Message( "You cannot use this perk: Your guild needs level {0}", p2.LevelNeeded );
                        return;
                    }
                    if ( string.IsNullOrEmpty( tParam ) ) {
                        if ( p2.turret != null ) {
                            player.Message( "&WA turret in your guild already exists: {0} - {1}", p2.turret.world.Name, p2.turret.blocks[0].ToString() );
                            return;
                        }
                        if ( Events.IsInRangeOfSpawnpoint( player.World, player.Position ) ) {
                            player.Message( "&WCannot place a turret this close to a spawn point" );
                            return;
                        }
                        p2.AddTurret( player );
                        return;
                    } else if ( tParam.ToLower() == "stop" || tParam.ToLower() == "remove" ) {
                        if ( p2.turret == null ) {
                            player.Message( "&WA turret in your guild does not exist" );
                            return;
                        }
                        p2.StopPerk();
                        p2.turret = null;
                        player.Message( "Stopping turret..." );
                    }
                    return;

                case "tag":
                    if ( !GuildManager.PlayerHasGuild( player.Info ) ) {
                        player.Message( "You are not in a guild. Create one, or ask someone to join theirs" );
                        return;
                    }
                    if ( !GuildManager.IsPlayerAnAdmin( player, guild ) ) {
                        player.Message( "&WYou need to be a guildmaster or admin to use this command" );
                        return;
                    }
                    string Tag = cmd.NextAll();
                    if ( string.IsNullOrEmpty( Tag ) ) {
                        if ( guild.PvP ) {
                            if ( !cmd.IsConfirmed ) {
                                player.Confirm( cmd, "&WTag cannot be removed when PVP is enabled\n&SDisable PVP?" );
                                return;
                            }
                            guild.PvP = false;
                            guild.SendGuildNotification( "&HGuild PvP has been disabled" );
                            guild.ChangeTagName( player, Tag );
                            return;
                        }
                    }
                    guild.ChangeTagName( player, Tag );
                    return;

                case "bat":
                    TheBatPerk tbp = ( TheBatPerk )GuildManager.FindPerkOrPrintResults( player, "TheBat" );
                    if ( guild.Level < tbp.LevelNeeded ) {
                        player.Message( "Your guild needs to be level {0} to use this perk (Current level: {1})",
                            tbp.LevelNeeded,
                            guild.Level );
                        return;
                    }
                    if ( player.PublicAuxStateObjects.ContainsKey( "bat" ) ) {
                        player.Message( "Bat off" );
                        player.PublicAuxStateObjects.Remove( "bat" );
                    } else {
                        player.Message( "Bat on" );
                        player.PublicAuxStateObjects.Add( "bat", true );
                        Bat b = new Bat( player );
                        b.Start();
                    }
                    return;

                case "reroll":
                    if ( string.IsNullOrEmpty( guild.GuildMaster ) ) {
                        Random rand = new Random();
                        player.Message( "Attempting to reroll guildmaster" );
                        if ( guild.Admins.Length > 0 ) {
                            guild.GuildMaster = guild.Admins[rand.Next(0, guild.Admins.Length )];
                        } else {
                            guild.GuildMaster = guild.Members[rand.Next(0, guild.Members.Length )];
                        }
                        if ( string.IsNullOrEmpty( guild.GuildMaster ) )
                            guild.GuildMaster = player.Name;
                        player.Message( "New guildmaster is: " + guild.GuildMaster );
                    }
                    return;

                case "slapall":
                    if ( !GuildManager.IsPlayerAnAdmin( player, guild ) ) {
                        player.Message( "&WYou need to be a guildmaster or admin to use this command" );
                        return;
                    }
                    SlapAllPerk p = ( SlapAllPerk )GuildManager.FindPerkOrPrintResults( player, "SlapAllPerk" );
                    if ( !Perk.GuildHasPerk( guild, p ) ) {
                        player.Message( "&WYou are unable to use this command: You need the \"SlapAll\" perk" );
                        return;
                    }
                    DateTime now = DateTime.UtcNow;
                    DateTime yesterday = now.AddDays( -1 );
                    if ( p.start != null ) {
                        if ( p.start > yesterday && p.start <= now ) {
                            string op = cmd.NextAll();
                            if ( string.IsNullOrEmpty( op ) ) {
                                player.Message( "&WGuild cannot be null: &H/Guild SlapAll [GuildName]" );
                                return;
                            }
                            Guild gd = GuildManager.FindGuildOrPrintResults( player, op );
                            if ( gd == null )
                                return;
                            int i = 0;
                            foreach ( string s in gd.Members ) {
                                PlayerInfo pla = PlayerDB.FindPlayerInfoExact( s );
                                if ( pla != null ) {
                                    Player pl = pla.PlayerObject;
                                    if ( pl != null ) {
                                        i++;
                                        pl.TeleportTo( new Position( pl.Position.X, pl.Position.Y, pl.World.Map.Height * 32 ) );
                                        pl.Message( "You were slapped sky high from {0}'s guild", guild.GuildMaster );
                                    }
                                }
                            }
                            player.Message( "You slapped {0} members of guild {1} sky high", i, gd.Name );
                        } else
                            player.Message( "&WUnable to slap another guild: The perk is still on cooldown since it was last used (24 hour cooldown)" );
                    }
                    return;

                case "perk":
                case "perks":
                    string str = cmd.NextAll();
                    if ( string.IsNullOrEmpty( str ) ) {
                        player.Message( "Perks your guild currently has: {0}",
                            guild.AvailablePerks().JoinToString() );
                        player.Message( "&HUse /Guild Perk [Name] for info on that perk" );
                    } else {
                        if ( str.ToLower() == "all" ) {
                            player.Message( "All perks: {0}",
                            guild.Perks.JoinToString() );
                            player.Message( "&HUse /Guild Perk [Name] for info on that perk" );
                            return;
                        }
                        Perk perk = GuildManager.FindPerkOrPrintResults( player, str );
                        if ( perk == null )
                            return;
                        player.Message( "Help info on Perk {0}: ", perk.PerkName );
                        player.Message( Perk.GetHelpSection( perk ) );
                    }
                    return;

                default:
                    player.Message( "Unknown param for /Guild: Try {0}",
                        "/Guild [Create | List | Info | Find | Join | Invite | Perks | Xp | SlapAll | Tag | Quit | Message | Bat | Turret | Bug ]" );
                    return;
            }
        }
Exemple #28
0
        static void MeHandler( Player player, Command cmd ) {
            if( player.Info.IsMuted ) {
                player.MessageMuted();
                return;
            }

            if( player.DetectChatSpam() ) return;

            string msg = cmd.NextAll().Trim();
            if( msg.Length > 0 ) {
                Chat.SendMe( player, msg );
            } else {
                CdMe.PrintUsage( player );
            }
        }
        internal static void KillHandler(Player player, Command cmd)
        {
            string name = cmd.Next();
            string reason = cmd.NextAll();
            if (name == null)
            {
                player.Message("Please enter a name");
                return;
            }

            Player target = Server.FindPlayerOrPrintMatches(player, name, false, true);
            if (target == null) return;
            if (target.Immortal)
            {
                player.Message("&SYou failed to kill {0}&S, they are immortal", target.ClassyName);
                return;
            }

            double time = (DateTime.Now - player.Info.LastUsedKill).TotalSeconds;
            if (time < 10)
            {
                player.Message("&WYou can use /Kill again in " + Math.Round(10 - time) + " seconds.");
                return;
            }
            if (target == null)
            {
                player.Message("You need to enter a player name to Kill");
                return;
            }
            else
            {
                if (target == player)
                {
                    player.TeleportTo(player.World.Map.Spawn);
                    player.Info.LastUsedKill = DateTime.Now;
                    Server.Players.CanSee(target).Message("{0}&C killed itself in confusion!", player);
                    return;
                }

                if (player.Can(Permission.Kill, target.Info.Rank) && reason.Length < 1)
                {
                    target.TeleportTo(player.World.Map.Spawn);
                    player.Info.LastUsedKill = DateTime.Now;
                    Server.Players.CanSee(target).Message("{0}&C was &4Killed&C by {1}", target.ClassyName, player.ClassyName);
                    return;
                }
                else if (player.Can(Permission.Kill, target.Info.Rank) && reason != null)
                {
                    target.TeleportTo(player.World.Map.Spawn);
                    player.Info.LastUsedKill = DateTime.Now;
                    Server.Players.CanSee(target).Message("{0}&C was &4Killed&C by {1}&c: {2}", target.ClassyName, player.ClassyName, reason);
                }
                else
                {
                    player.Message("You can only Kill players ranked {0}&S or lower",
                                    player.Info.Rank.GetLimit(Permission.Kill).ClassyName);
                    player.Message("{0}&S is ranked {1}", target.ClassyName, target.Info.Rank.ClassyName);
                }
            }
        }
Exemple #30
0
        public static void VoteParams(Player player, Command cmd)
        {
            string option = cmd.Next();

            if (option == null)
            {
                player.Message("Invalid param"); return;
            }
            switch (option)
            {
            default:
                if (VoteIsOn)
                {
                    if (VoteKickReason == null)
                    {
                        player.Message("Last Question: {0}&C asked: {1}", VoteStarter, Question);
                        player.Message(Usage);
                        return;
                    }
                    else
                    {
                        player.Message("Last VoteKick: &CA VoteKick has started for {0}&C, reason: {1}", TargetName, VoteKickReason);
                    }
                    player.Message(Usage);
                    return;
                }
                else
                {
                    player.Message(option);
                }
                break;

            case "abort":
            case "stop":
                if (!VoteIsOn)
                {
                    player.Message("No vote is currently running");
                    return;
                }

                if (!player.Can(Permission.MakeVotes))
                {
                    player.Message("You do not have Permission to abort votes");
                    return;
                }
                VoteIsOn = false;
                foreach (Player V in Voted)
                {
                    if (V.Info.HasVoted)
                    {
                        V.Info.HasVoted = false;
                    }
                    V.Message("Your vote was cancelled");
                }
                Voted.Clear();
                TargetName = null;
                Server.Players.Message("{0} &Saborted the vote.", player.ClassyName);
                break;

            case "yes":
                if (!VoteIsOn)
                {
                    player.Message("No vote is currently running");
                    return;
                }

                if (player.Info.HasVoted)
                {
                    player.Message("&CYou have already voted");
                    return;
                }
                Voted.Add(player);
                VotedYes++;
                player.Info.HasVoted = true;
                player.Message("&8You have voted for 'Yes'");
                break;

            case "no":
                if (!VoteIsOn)
                {
                    player.Message("No vote is currently running");
                    return;
                }
                if (player.Info.HasVoted)
                {
                    player.Message("&CYou have already voted");
                    return;
                }
                VotedNo++;
                Voted.Add(player);
                player.Info.HasVoted = true;
                player.Message("&8You have voted for 'No'");
                break;

            case "ask":
                string AskQuestion = cmd.NextAll();
                Question = AskQuestion;
                if (!player.Can(Permission.MakeVotes))
                {
                    player.Message("You do not have permissions to ask a question");
                    return;
                }
                if (VoteIsOn)
                {
                    player.Message("A vote has already started. Each vote lasts 1 minute.");
                    return;
                }
                if (Question.Length < 5)
                {
                    player.Message("Invalid question");
                    return;
                }

                VoteThread = new Thread(new ThreadStart(delegate
                {
                    NewVote();
                    VoteStarter = player.ClassyName;
                    Server.Players.Message("{0}&S Asked: {1}", player.ClassyName, Question);
                    Server.Players.Message("&9Vote now! &S/Vote &AYes &Sor /Vote &CNo");
                    VoteIsOn = true;
                    Thread.Sleep(60000);
                    VoteCheck();
                })); VoteThread.Start();
                break;
            }
        }
        static void MassRankHandler( Player player, Command cmd )
        {
            string fromRankName = cmd.Next();
            string toRankName = cmd.Next();
            string reason = cmd.NextAll();
            if( fromRankName == null || toRankName == null ) {
                CdMassRank.PrintUsage( player );
                return;
            }

            Rank fromRank = RankManager.FindRank( fromRankName );
            if( fromRank == null ) {
                player.MessageNoRank( fromRankName );
                return;
            }

            Rank toRank = RankManager.FindRank( toRankName );
            if( toRank == null ) {
                player.MessageNoRank( toRankName );
                return;
            }

            if( fromRank == toRank ) {
                player.Message( "Ranks must be different" );
                return;
            }

            int playerCount = fromRank.PlayerCount;
            string verb = (fromRank > toRank ? "demot" : "promot");

            if( !cmd.IsConfirmed ) {
                player.Confirm( cmd, "About to {0}e {1} players.", verb, playerCount );
                return;
            }

            player.Message( "MassRank: {0}ing {1} players...",
                            verb, playerCount );

            int affected = PlayerDB.MassRankChange( player, fromRank, toRank, reason );
            player.Message( "MassRank: done, {0} records affected.", affected );
        }
Exemple #32
0
        public static void VoteParams(Player player, Command cmd)
        {
            string option = cmd.Next();

            if (option == null)
            {
                player.Message("Invalid param");
                return;
            }
            switch (option)
            {
            default:
                if (VoteIsOn)
                {
                    if (VoteKickReason == null)
                    {
                        player.Message("Last Question: {0}&C asked: {1}", VoteStarter, Question);
                        player.Message(Usage);
                        return;
                    }
                    else
                    {
                        player.Message("Last VoteKick: &CA VoteKick has started for {0}&C, reason: {1}", TargetName,
                                       VoteKickReason);
                    }
                    player.Message(Usage);
                    return;
                }
                else
                {
                    player.Message(option);
                }
                break;

            case "abort":
            case "stop":
                if (!VoteIsOn)
                {
                    player.Message("No vote is currently running");
                    return;
                }

                if (!player.Can(Permission.MakeVotes))
                {
                    player.Message("You do not have Permission to abort votes");
                    return;
                }
                VoteIsOn = false;
                foreach (Player V in Voted)
                {
                    if (V.HasVoted)
                    {
                        V.HasVoted = false;
                    }
                    V.Message("Your vote was cancelled");
                }
                Voted.Clear();
                TargetName = null;
                Server.Players.Message("{0} &Saborted the vote.", player.ClassyName);
                break;

            case "yes":
                if (!VoteIsOn)
                {
                    player.Message("No vote is currently running");
                    return;
                }

                if (player.HasVoted)
                {
                    player.Message("&CYou have already voted");
                    return;
                }
                Voted.Add(player);
                VotedYes++;
                player.HasVoted = true;
                player.Message("&8You have voted for 'Yes'");
                break;

            case "kick":
                string toKick = cmd.Next();
                string Reason = cmd.NextAll();
                VoteKickReason = Reason;
                if (toKick == null)
                {
                    player.Message("Target cannot be empty. " + Usage);
                    return;
                }

                Player target = Server.FindPlayerOrPrintMatches(player, toKick, false, true);

                if (target == null)
                {
                    // FIX: Target is null when no such player is online, this caused crashes
                    return;
                }

                if (!Player.IsValidName(target.Name))
                {
                    return;
                }

                if (!player.Can(Permission.MakeVoteKicks))
                {
                    player.Message("You do not have permissions to start a VoteKick");
                    return;
                }

                if (VoteIsOn)
                {
                    player.Message("A vote has already started. Each vote lasts 1 minute.");
                    return;
                }

                if (VoteKickReason.Length < 3)
                {
                    player.Message("Invalid reason");
                    return;
                }

                if (target == player)
                {
                    player.Message("You cannot VoteKick yourself, lol");
                    return;
                }

                VoteThread = new Thread(new ThreadStart(delegate
                {
                    TargetName = target.Name;
                    if (!Player.IsValidName(TargetName))
                    {
                        player.Message("Invalid name");
                        return;
                    }
                    NewVote();
                    VoteStarter = player.ClassyName;
                    Server.Players.Message("{0}&S started a VoteKick for player: {1}", player.ClassyName,
                                           target.ClassyName);
                    Server.Players.Message("&WReason: {0}", VoteKickReason);
                    Server.Players.Message("&9Vote now! &S/Vote &AYes &Sor /Vote &CNo");
                    VoteIsOn = true;
                    Logger.Log(LogType.SystemActivity, "{0} started a votekick on player {1} reason: {2}",
                               player.Name, target.Name, VoteKickReason);
                    Thread.Sleep(60000);
                    VoteKickCheck();
                }));
                VoteThread.Start();
                break;

            case "no":
                if (!VoteIsOn)
                {
                    player.Message("No vote is currently running");
                    return;
                }
                if (player.HasVoted)
                {
                    player.Message("&CYou have already voted");
                    return;
                }
                VotedNo++;
                Voted.Add(player);
                player.HasVoted = true;
                player.Message("&8You have voted for 'No'");
                break;

            case "1":
                if (PropHunt.IsOn)
                {
                    if (!PropHunt.VoteIsOn)
                    {
                        player.Message("Voting has not yet started.");
                        return;
                    }

                    if (player.HasVoted)
                    {
                        player.Message("&CYou have already voted.");
                        return;
                    }
                    PropHunt.Voted.Add(player);
                    PropHunt.Voted1++;
                    player.HasVoted = true;
                    player.Message("&8You have voted for {0}.", PropHunt.World1.ClassyName);
                }
                break;

            case "2":
                if (PropHunt.IsOn)
                {
                    if (!PropHunt.VoteIsOn)
                    {
                        player.Message("Voting has not yet started.");
                        return;
                    }

                    if (player.HasVoted)
                    {
                        player.Message("&CYou have already voted.");
                        return;
                    }
                    PropHunt.Voted.Add(player);
                    PropHunt.Voted2++;
                    player.HasVoted = true;
                    player.Message("&8You have voted for {0}.", PropHunt.World2.ClassyName);
                }
                break;

            case "3":
                if (PropHunt.IsOn)
                {
                    if (!PropHunt.VoteIsOn)
                    {
                        player.Message("Voting has not yet started.");
                        return;
                    }

                    if (player.HasVoted)
                    {
                        player.Message("&CYou have already voted.");
                        return;
                    }
                    PropHunt.Voted.Add(player);
                    PropHunt.Voted3++;
                    player.HasVoted = true;
                    player.Message("&8You have voted for {0}.", PropHunt.World3.ClassyName);
                }
                break;

            case "ask":
                string AskQuestion = cmd.NextAll();
                Question = AskQuestion;
                if (!player.Can(Permission.MakeVotes))
                {
                    player.Message("You do not have permissions to ask a question");
                    return;
                }
                if (VoteIsOn)
                {
                    player.Message("A vote has already started. Each vote lasts 1 minute.");
                    return;
                }
                if (Question.Length < 5)
                {
                    player.Message("Invalid question");
                    return;
                }

                VoteThread = new Thread(new ThreadStart(delegate
                {
                    NewVote();
                    VoteStarter = player.ClassyName;
                    Server.Players.Message("{0}&S Asked: {1}", player.ClassyName, Question);
                    Server.Players.Message("&9Vote now! &S/Vote &AYes &Sor /Vote &CNo");
                    VoteIsOn = true;
                    Thread.Sleep(60000);
                    VoteCheck();
                }));
                VoteThread.Start();
                break;
            }
        }
Exemple #33
0
 internal static void AdminChat(Player player, Command cmd)
 {
     if (player.Info.IsMuted)
     {
         player.MessageMuted();
         return;
     }
     if (DateTime.UtcNow < player.Info.MutedUntil)
     {
         player.Message("You are muted for another {0:0} seconds.",
                         player.Info.MutedUntil.Subtract(DateTime.UtcNow).TotalSeconds);
         return;
     }
     string message = cmd.NextAll().Trim();
     if (message.Length > 0)
     {
         if (player.Can(Permission.UseColorCodes) && message.Contains("%"))
         {
             message = Color.ReplacePercentCodes(message);
         }
         Chat.SendAdmin(player, message);
     }
 }
Exemple #34
0
        private static void GlobalHandler(Player player, Command cmd)
        {
            var    sendList = Server.Players.Where(p => p.GlobalChatAllowed && !p.IsDeaf);
            string msg      = cmd.NextAll();

            if (!ConfigKey.GlobalChat.Enabled())
            {
                player.Message("&WGlobal Chat is disabled on this server.");
                return;
            }
            if (!GlobalChat.GlobalThread.GcReady)
            {
                player.Message("&WGlobal Chat is not connected.");
                return;
            }
            string reason;

            if (Server.GlobalChatBans.TryGetValue(player.Name.ToLower(), out reason))
            {
                player.Message("You were &cbanned &efrom &gglobal chat&e by &h{0}&e", reason);
                player.Message("You can appeal your ban at &9http://atomiccraft.net");
                return;
            }
            switch (msg)
            {
            case "reconnect":
                if (player.Can(Permission.ManageGlobalChat))
                {
                    if (GlobalChat.GlobalThread.GcReady)
                    {
                        player.Message("&WThis server is currently connected to global chat.");
                        return;
                    }
                    GlobalChat.GlobalThread.GcReady = true;
                    Server.Message(
                        "&WAttempting to connect to AtomicCraft Global Chat Network. This may take a few seconds.");
                    GlobalChat.Init();
                    GlobalChat.Start();
                    return;
                }
                break;

            case "rules":
                if (!player.GlobalChatAllowed)
                {
                    player.Message(
                        "&RRules: No spamming and no advertising. All chat rules that apply to your server apply here.\n" +
                        "&WServer staff have the right to kick you.\n" +
                        "&SBy using the Global Chat, you accept these conditions.\n" +
                        "&SType &H/global accept &Sto connect");
                    return;
                }

                if (player.GlobalChatAllowed)
                {
                    player.Message(
                        "&RRules: No spamming and no advertising. All chat rules that apply to your server apply here.\n" +
                        "&WServer staff have the right to kick you.\n" +
                        "&SBy using the Global Chat, you accept these conditions.");
                    return;
                }
                break;

            case "accept":

                if (!player.GlobalChatAllowed)
                {
                    player.GlobalChatAllowed = true;
                    player.Message("&SThank you for accepting the global chat rules.\n" +
                                   "&WYou now have global chat enabled.");
                    GlobalChat.GlobalThread.SendChannelMessage(player.ClassyName + " &Sjoined global chat.");
                    sendList.Message(player.ClassyName + " &Sjoined global chat.");
                    return;
                }

                if (player.GlobalChatAllowed)
                {
                    player.Message("&WYou have already accepted the global chat rules.");
                    return;
                }
                break;

            case "ignore":
                if (!player.GlobalChatIgnore)
                {
                    player.GlobalChatIgnore = true;
                    player.Message("&WYou have disconnected from global chat.");
                    sendList.Message(player.ClassyName + " &Sdisconnected from global chat.");
                    GlobalChat.GlobalThread.SendChannelMessage(player.ClassyName +
                                                               " &Sdisconnected from global chat.");
                    return;
                }
                break;

            case "help":
                CdGlobal.PrintUsage(player);
                break;
            }
            if (player.Info.IsMuted)
            {
                player.MessageMuted();
                return;
            }

            if ((!player.GlobalChatAllowed) && ((msg.Length < 1) || (msg.Length > 1)))
            {
                player.Message("&WYou must read and accept the global chat rules. Type &H/global rules");
                return;
            }

            if ((player.GlobalChatAllowed) && string.IsNullOrEmpty(msg))
            {
                player.Message("&WYou must enter a message!");
                return;
            }
            if (!player.GlobalChatAllowed)
            {
                return;
            }
            string pMsg = player.ClassyName + Color.White + ": " + msg;

            msg = player.ClassyName + Color.Black + ": " + msg;
            sendList.Message("&g[Global] " + pMsg); //send the white message to Server
            msg = Color.MinecraftToIrcColors(msg);
            msg = Color.ReplacePercentCodes(msg);
            GlobalChat.GlobalThread.SendChannelMessage(msg); //send the black message to GC
        }
        internal static void Basscannon(Player player, Command cmd)
        {
            string name = cmd.Next();
            string reason = cmd.NextAll();

            if (name == null)
            {
                player.Message("Please enter a player name to use the basscannon on.");
                return;
            }

            Player target = Server.FindPlayerOrPrintMatches(player, name, false, true);

            if (target == null)
            {
                return;
            }

            if (ConfigKey.RequireKickReason.Enabled() && String.IsNullOrEmpty(reason))
            {
                player.Message("&WPlease specify a reason: &W/Basscannon PlayerName Reason");
                // freeze the target player to prevent further damage
                return;
            }

            if (player.Can(Permission.Kick, target.Info.Rank))
            {
                target.Info.IsHidden = false;

                try
                {
                    Player targetPlayer = target;
                    target.BassKick(player, reason, LeaveReason.Kick, true, true, true);
                    if (BassText.Count < 1){
                        BassText.Add("Flux Pavillion does not approve of your behavior");
                        BassText.Add("Let the Basscannon KICK IT!");
                        BassText.Add("WUB WUB WUB WUB WUB WUB!");
                        BassText.Add("Basscannon, Basscannon, Basscannon, Basscannon!");
                        BassText.Add("Pow pow POW!!!");
                    }
                    string line = BassText[new Random().Next(0, BassText.Count)].Trim();
                    if (line.Length == 0) return;
                    Server.Message("&9{0}", line);
                }
                catch (PlayerOpException ex)
                {
                    player.Message(ex.MessageColored);
                    if (ex.ErrorCode == PlayerOpExceptionCode.ReasonRequired)
                        return;
                }
            }
            else
            {
                player.Message("You can only use /Basscannon on players ranked {0}&S or lower",
                                player.Info.Rank.GetLimit(Permission.Kick).ClassyName);
                player.Message("{0}&S is ranked {1}", target.ClassyName, target.Info.Rank.ClassyName);
            }
        }
Exemple #36
0
        static void ZoneEditHandler(Player player, Command cmd)
        {
            bool   changesWereMade = false;
            string zoneName        = cmd.Next();

            if (zoneName == null)
            {
                player.Message("No zone name specified. See &H/Help ZEdit");
                return;
            }

            Zone zone = player.WorldMap.Zones.Find(zoneName);

            if (zone == null)
            {
                player.MessageNoZone(zoneName);
                return;
            }

            string name;

            while ((name = cmd.Next()) != null)
            {
                if (name.StartsWith("+"))
                {
                    if (name.Length == 1)
                    {
                        CdZoneEdit.PrintUsage(player);
                        break;
                    }
                    PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches(player, name.Substring(1));
                    if (info == null)
                    {
                        return;
                    }

                    // prevent players from whitelisting themselves to bypass protection
                    if (!player.Info.Rank.AllowSecurityCircumvention && player.Info == info)
                    {
                        if (!zone.Controller.Check(info))
                        {
                            player.Message("You must be {0}+&S to add yourself to this zone's whitelist.",
                                           zone.Controller.MinRank.ClassyName);
                            continue;
                        }
                    }

                    switch (zone.Controller.Include(info))
                    {
                    case PermissionOverride.Deny:
                        player.Message("{0}&S is no longer excluded from zone {1}",
                                       info.ClassyName, zone.ClassyName);
                        changesWereMade = true;
                        break;

                    case PermissionOverride.None:
                        player.Message("{0}&S is now included in zone {1}",
                                       info.ClassyName, zone.ClassyName);
                        changesWereMade = true;
                        break;

                    case PermissionOverride.Allow:
                        player.Message("{0}&S is already included in zone {1}",
                                       info.ClassyName, zone.ClassyName);
                        break;
                    }
                }
                else if (name.StartsWith("-"))
                {
                    if (name.Length == 1)
                    {
                        CdZoneEdit.PrintUsage(player);
                        break;
                    }
                    PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches(player, name.Substring(1));
                    if (info == null)
                    {
                        return;
                    }

                    switch (zone.Controller.Exclude(info))
                    {
                    case PermissionOverride.Deny:
                        player.Message("{0}&S is already excluded from zone {1}",
                                       info.ClassyName, zone.ClassyName);
                        break;

                    case PermissionOverride.None:
                        player.Message("{0}&S is now excluded from zone {1}",
                                       info.ClassyName, zone.ClassyName);
                        changesWereMade = true;
                        break;

                    case PermissionOverride.Allow:
                        player.Message("{0}&S is no longer included in zone {1}",
                                       info.ClassyName, zone.ClassyName);
                        changesWereMade = true;
                        break;
                    }
                }
                else if (name.ToLower().StartsWith("msg="))
                {
                    zone.Message    = name.Substring(4) + " " + (cmd.NextAll() ?? "");
                    changesWereMade = true;
                    player.Message("Zedit: Custom denied messaged changed to '" + zone.Message + "'");
                    break;
                }
                else
                {
                    Rank minRank = RankManager.FindRank(name);

                    if (minRank != null)
                    {
                        // prevent players from lowering rank so bypass protection
                        if (!player.Info.Rank.AllowSecurityCircumvention &&
                            zone.Controller.MinRank > player.Info.Rank && minRank <= player.Info.Rank)
                        {
                            player.Message("You are not allowed to lower the zone's rank.");
                            continue;
                        }

                        if (zone.Controller.MinRank != minRank)
                        {
                            zone.Controller.MinRank = minRank;
                            player.Message("Permission for zone \"{0}\" changed to {1}+",
                                           zone.Name,
                                           minRank.ClassyName);
                            changesWereMade = true;
                        }
                    }
                    else
                    {
                        player.MessageNoRank(name);
                    }
                }
            }
            if (changesWereMade)
            {
                zone.Edit(player.Info);
            }
            else
            {
                player.Message("No changes were made to the zone.");
            }
        }
Exemple #37
0
        private static void MessageBlockH(Player player, Command cmd)
        {
            string option = cmd.Next();
            if (String.IsNullOrEmpty(option))
            {
                CdMessageBlock.PrintUsage(player);
                return;
            }

            switch (option.ToLower())
            {
                case "list":
                    player.Message("__MessageBlocks on {0}__", player.World.Name);
                    foreach (KeyValuePair<string, Tuple<Vector3I, string>> messageBlock in player.World.MessageBlocks)
                    {
                        //block name and location
                        player.Message(messageBlock.Key + " " + messageBlock.Value.Item1.ToString());
                    }
                    break;
                case "remove":
                    string removeTarget = cmd.Next();
                    if (String.IsNullOrEmpty(removeTarget))
                    {
                        player.Message("&ePlease identify which MessageBlock you want to remove.");
                        return;
                    }

                    if (!player.World.MessageBlocks.Keys.Contains(removeTarget))
                    {
                        player.Message("&c'{0}' was not found! Use '/MessageBlock List' to view all MessageBlocks on your world.", removeTarget);
                        return;
                    }

                    player.Message("&a{0} was removed from {1}.", removeTarget, player.World.Name);
                    player.World.MessageBlocks.Remove(removeTarget);
                    break;
                case "create":
                     string addTarget = cmd.Next();
                    if (String.IsNullOrEmpty(addTarget))
                    {
                        player.Message("&ePlease identify the name of the MessageBlock you want to create.");
                        return;
                    }

                    if (player.World.MessageBlocks.Keys.Contains(addTarget))
                    {
                        player.Message("&c{0} is already the name of a current MessageBlock on this world! Use '/MessageBlock List' to view all MessageBlocks on your world.", addTarget);
                        return;
                    }

                    string message = cmd.NextAll();
                    if (String.IsNullOrEmpty(message))
                    {
                        player.Message("&ePlease choose the message for your MessageBlock!");
                        return;
                    }

                    Vector3I pos = new Vector3I(player.Position.ToBlockCoords().X, player.Position.ToBlockCoords().Y, player.Position.ToBlockCoords().Z);

                    //tell the user that the message block is created on the block they are standing on, but the message block is actually on their head
                    player.Message("&a{0} was added.", addTarget);
                    player.World.MessageBlocks.Add(addTarget, new Tuple<Vector3I, string>(pos, message));

                    break;
                case "edit":
                    string editTarget = cmd.Next();
                    if (String.IsNullOrEmpty(editTarget))
                    {
                        player.Message("&ePlease identify which MessageBlock you want to edit.");
                        return;
                    }

                    if (!player.World.MessageBlocks.Keys.Contains(editTarget))
                    {
                        player.Message("&c'{0}' was not found! Use '/MessageBlock List' to view all MessageBlocks on your world.", editTarget);
                        return;
                    }

                    string editMessage = cmd.NextAll();
                    if (String.IsNullOrEmpty(editMessage))
                    {
                        player.Message("&ePlease choose the message for your MessageBlock!");
                        return;
                    }

                    //get the block coord of the message block being edited by finding the tuple of the key
                    Tuple<Vector3I, string> tuple;
                    player.World.MessageBlocks.TryGetValue(editMessage, out tuple);

                    //player.Message("&aMessageBlock was successfully edited.");
                    player.World.MessageBlocks.Remove(editTarget);
                    player.World.MessageBlocks.Add(editTarget, new Tuple<Vector3I, string>(tuple.Item1, editMessage));
                    break;
                default:
                    break;
            }
        }
        static void KickHandler( Player player, Command cmd )
        {
            string name = cmd.Next();
            if( name == null ) {
                player.Message( "Usage: &H/Kick PlayerName [Message]" );
                return;
            }

            // find the target
            Player target = Server.FindPlayerOrPrintMatches( player, name, false, true );
            if( target == null ) return;

            string reason = cmd.NextAll();
            DateTime previousKickDate = target.Info.LastKickDate;
            string previousKickedBy = target.Info.LastKickByClassy;
            string previousKickReason = target.Info.LastKickReason;

            // do the kick
            try {
                Player targetPlayer = target;
                target.Kick( player, reason, LeaveReason.Kick, true, true, true );
                WarnIfOtherPlayersOnIP( player, target.Info, targetPlayer );

            } catch( PlayerOpException ex ) {
                player.Message( ex.MessageColored );
                if( ex.ErrorCode == PlayerOpExceptionCode.ReasonRequired ) {
                    FreezeIfAllowed( player, target.Info );
                }
                return;
            }

            // warn player if target has been kicked before
            if( target.Info.TimesKicked > 1 ) {
                player.Message( "Warning: {0}&S has been kicked {1} times before.",
                                target.ClassyName, target.Info.TimesKicked - 1 );
                if( previousKickDate != DateTime.MinValue ) {
                    player.Message( "Most recent kick was {0} ago, by {1}",
                                    DateTime.UtcNow.Subtract( previousKickDate ).ToMiniString(),
                                    previousKickedBy );
                }
                if( !String.IsNullOrEmpty( previousKickReason ) ) {
                    player.Message( "Most recent kick reason was: {0}",
                                    previousKickReason );
                }
            }
        }
Exemple #39
0
        static void TimerHandler( Player player, Command cmd ) {
            string param = cmd.Next();

            // List timers
            if( param == null ) {
                ChatTimer[] list = ChatTimer.TimerList.OrderBy( timer => timer.TimeLeft ).ToArray();
                if( list.Length == 0 ) {
                    player.Message( "No timers running." );
                } else {
                    player.Message( "There are {0} timers running:", list.Length );
                    foreach( ChatTimer timer in list ) {
                        player.Message( "  #{0} \"{1}&S\" (started by {2}, {3} left)",
                                        timer.Id, timer.Message, timer.StartedBy, timer.TimeLeft.ToMiniString() );
                    }
                }
                return;
            }

            // Abort a timer
            if( param.Equals( "abort", StringComparison.OrdinalIgnoreCase ) ) {
                int timerId;
                if( cmd.NextInt( out timerId ) ) {
                    ChatTimer timer = ChatTimer.FindTimerById( timerId );
                    if( timer == null || !timer.IsRunning ) {
                        player.Message( "Given timer (#{0}) does not exist.", timerId );
                    } else {
                        timer.Stop();
                        string abortMsg = String.Format( "&Y(Timer) {0}&Y aborted a timer with {1} left: {2}",
                                                         player.ClassyName, timer.TimeLeft.ToMiniString(), timer.Message );
                        Chat.SendSay( player, abortMsg );
                    }
                } else {
                    CdTimer.PrintUsage( player );
                }
                return;
            }

            // Start a timer
            if( player.Info.IsMuted ) {
                player.MessageMuted();
                return;
            }
            if( player.DetectChatSpam() ) return;
            TimeSpan duration;
            if( !param.TryParseMiniTimespan( out duration ) ) {
                CdTimer.PrintUsage( player );
                return;
            }
            if( duration > DateTimeUtil.MaxTimeSpan ) {
                player.MessageMaxTimeSpan();
                return;
            }
            if( duration < ChatTimer.MinDuration ) {
                player.Message( "Timer: Must be at least 1 second." );
                return;
            }

            string sayMessage;
            string message = cmd.NextAll();
            if( String.IsNullOrEmpty( message ) ) {
                sayMessage = String.Format( "&Y(Timer) {0}&Y started a {1} timer",
                                            player.ClassyName,
                                            duration.ToMiniString() );
            } else {
                sayMessage = String.Format( "&Y(Timer) {0}&Y started a {1} timer: {2}",
                                            player.ClassyName,
                                            duration.ToMiniString(),
                                            message );
            }
            Chat.SendSay( player, sayMessage );
            ChatTimer.Start( duration, message, player.Name );
        }
        static void Tempban(Player player, Command cmd)
        {
            string targetName = cmd.Next();
            string timeString = cmd.Next();
            TimeSpan duration;
            try{
                if (String.IsNullOrEmpty(targetName) || String.IsNullOrEmpty(timeString) ||
                !timeString.TryParseMiniTimespan(out duration) || duration <= TimeSpan.Zero)
                {
                    CdTempBan.PrintUsage(player);
                    return;
                }
            }catch (OverflowException){
                player.Message("TempBan: Given duration is too long.");
                return;
            }

            // find the target
            PlayerInfo target = PlayerDB.FindPlayerInfoOrPrintMatches(player, targetName);

            if (target == null){
                player.MessageNoPlayer(targetName);
                return;
            };

            if (target.Name == player.Name){
                player.Message("Trying to T-Ban yourself? Fail!");
                return;
            }

            // check permissions
            if (!player.Can(Permission.BanIP, target.Rank)){
                player.Message("You can only Temp-Ban players ranked {0}&S or lower.",
                                player.Info.Rank.GetLimit(Permission.BanIP).ClassyName);
                player.Message("{0}&S is ranked {1}", target.ClassyName, target.Rank.ClassyName);
                return;
            }

            // do the banning
            if (target.Tempban(player.Name, duration)){
                string reason = cmd.NextAll();
                try{
                    Player targetPlayer = target.PlayerObject;
                    target.Ban(player, "You were Banned for " + timeString, false, true);
                    Server.TempBans.Add(targetPlayer);
                }
                catch (PlayerOpException ex){
                    player.Message(ex.MessageColored);
                }
                Scheduler.NewTask(t => Untempban(player, target)).RunOnce(duration);
                Server.Message("&SPlayer {0}&S was Banned by {1}&S for {2}",
                                target.ClassyName, player.ClassyName, duration.ToMiniString());
                if (reason.Length > 0) Server.Message("&Wreason: {0}", reason);
                Logger.Log(LogType.UserActivity, "Player {0} was Banned by {1} for {2}",
                            target.Name, player.Name, duration.ToMiniString());
            }else{
                player.Message("Player {0}&S is already Banned by {1}&S for {2:0} more.",
                                target.ClassyName,
                                target.BannedBy,
                                target.BannedUntil.Subtract(DateTime.UtcNow).ToMiniString());
            }
        }
Exemple #41
0
        static void StaffHandler( Player player, Command cmd ) {
            if( player.Info.IsMuted ) {
                player.MessageMuted();
                return;
            }

            if( player.DetectChatSpam() ) return;

            string message = cmd.NextAll().Trim();
            if( message.Length > 0 ) {
                Chat.SendStaff( player, message );
            }
        }
Exemple #42
0
        public static void VoteParams(Player player, Command cmd)
        {
            string option = cmd.Next();

            if (option == null)
            {
                MessageVoteStatus(player); return;
            }
            switch (option)
            {
            default:
                MessageVoteStatus(player);
                break;

            case "abort":
            case "stop":
                if (!VoteIsOn)
                {
                    player.Message("No vote is currently running");
                    return;
                }

                if (!player.Can(Permission.MakeVotes))
                {
                    player.Message("You do not have Permission to abort votes");
                    return;
                }
                VoteIsOn = false;
                foreach (Player V in Voted)
                {
                    if (V.Info.HasVoted)
                    {
                        V.Info.HasVoted = false;
                    }
                    V.Message("Your vote was cancelled");
                }
                Voted.Clear();
                TargetName = null;
                Server.Players.Message("{0} &Saborted the vote.", player.ClassyName);
                break;

            case "yes":
                if (!VoteIsOn)
                {
                    player.Message("No vote is currently running");
                    return;
                }

                if (player.Info.HasVoted)
                {
                    player.Message("&CYou have already voted");
                    return;
                }
                Voted.Add(player);
                VotedYes++;
                player.Info.HasVoted = true;
                player.Message("&8You have voted for 'Yes'");
                break;

            case "no":
                if (!VoteIsOn)
                {
                    player.Message("No vote is currently running");
                    return;
                }
                if (player.Info.HasVoted)
                {
                    player.Message("&CYou have already voted");
                    return;
                }
                VotedNo++;
                Voted.Add(player);
                player.Info.HasVoted = true;
                player.Message("&8You have voted for 'No'");
                break;

            case "ask":
                string AskQuestion = cmd.NextAll();
                Question = AskQuestion;
                if (!player.Can(Permission.MakeVotes))
                {
                    player.Message("You do not have permissions to ask a question");
                    return;
                }
                if (VoteIsOn)
                {
                    player.Message("A vote has already started. Each vote lasts 1 minute.");
                    return;
                }
                if (Question.Length < 5)
                {
                    player.Message("Invalid question");
                    return;
                }

                NewVote();
                VoteStarter = player.ClassyName;
                Server.Players.Message("{0}&S Asked: {1}", player.ClassyName, Question);
                Server.Players.Message("&9Vote now! &S/Vote &AYes &Sor /Vote &CNo");
                VoteIsOn = true;
                Scheduler.NewTask(VoteCheck).RunOnce(TimeSpan.FromMinutes(1));
                break;
            }
        }
Exemple #43
0
 private static void HiScoreHandler( Player player, Command cmd )
 {
     string Param = cmd.NextAll();
     if ( string.IsNullOrEmpty( Param ) ) {
         string[] a = Cache.PlayerKillScores;
         if ( a.Length == 0 ) {
             player.Message( "Top 10 killers on Au70: None available" );
             return;
         }
         IOrderedEnumerable<string> b = a.OrderByDescending( p => {
             if ( p != null )
                 return int.Parse( p.Split( '$' )[1] );
             else
                 return float.MinValue;
         } );
         List<string> d = new List<string>();
         foreach ( string c in b ) {
             string temp = c.Replace( "$", ": " );
             d.Add( temp );
         }
         player.Message( "Top 10 killers on Au70: " + d.Take( Math.Max( 10, d.Count ) ).JoinToString() );
     } else {
         Guild g = GuildManager.FindGuildOrPrintResults( player, Param );
         if ( g == null )
             return;
         player.Message( "This guild has killed a total of " + Cache.GetGuildKillsTotal( g ) + " enemy guild members" );
     }
 }
Exemple #44
0
        static void ZoneAddHandler(Player player, Command cmd)
        {
            World playerWorld = player.World;

            if (playerWorld == null)
            {
                PlayerOpException.ThrowNoWorld(player);
            }

            string givenZoneName = cmd.Next();

            if (givenZoneName == null)
            {
                CdZoneAdd.PrintUsage(player);
                return;
            }

            if (!player.Info.Rank.AllowSecurityCircumvention)
            {
                SecurityCheckResult buildCheck = playerWorld.BuildSecurity.CheckDetailed(player.Info);
                switch (buildCheck)
                {
                case SecurityCheckResult.BlackListed:
                    player.Message("Cannot add zones to world {0}&S: You are barred from building here.",
                                   playerWorld.ClassyName);
                    return;

                case SecurityCheckResult.RankTooLow:
                    player.Message("Cannot add zones to world {0}&S: You are not allowed to build here.",
                                   playerWorld.ClassyName);
                    return;
                    //case SecurityCheckResult.RankTooHigh:
                }
            }

            Zone           newZone        = new Zone();
            ZoneCollection zoneCollection = player.WorldMap.Zones;

            if (givenZoneName.StartsWith("+"))
            {
                // personal zone (/ZAdd +Name)
                givenZoneName = givenZoneName.Substring(1);

                // Find the target player
                PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches(player, givenZoneName);
                if (info == null)
                {
                    return;
                }

                // Make sure that the name is not taken already.
                // If a zone named after the player already exists, try adding a number after the name (e.g. "Notch2")
                newZone.Name = info.Name;
                for (int i = 2; zoneCollection.Contains(newZone.Name); i++)
                {
                    newZone.Name = givenZoneName + i;
                }

                newZone.Controller.MinRank = info.Rank.NextRankUp ?? info.Rank;
                newZone.Controller.Include(info);
                player.Message("Zone: Creating a {0}+&S zone for player {1}&S.",
                               newZone.Controller.MinRank.ClassyName, info.ClassyName);
            }
            else
            {
                // Adding an ordinary, rank-restricted zone.
                if (!World.IsValidName(givenZoneName))
                {
                    player.Message("\"{0}\" is not a valid zone name", givenZoneName);
                    return;
                }

                if (zoneCollection.Contains(givenZoneName))
                {
                    player.Message("A zone with this name already exists. Use &H/ZEdit&S to edit.");
                    return;
                }

                newZone.Name = givenZoneName;

                string rankName = cmd.Next();
                if (rankName == null)
                {
                    player.Message("No rank was specified. See &H/Help zone");
                    return;
                }
                Rank minRank = RankManager.FindRank(rankName);

                if (minRank != null)
                {
                    string name;
                    while ((name = cmd.Next()) != null)
                    {
                        if (name.Length == 0)
                        {
                            continue;
                        }

                        if (name.ToLower().StartsWith("msg="))
                        {
                            newZone.Message = name.Substring(4) + " " + (cmd.NextAll() ?? "");
                            player.Message("Zone: Custom denied messaged changed to '" + newZone.Message + "'");
                            break;
                        }

                        PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches(player, name.Substring(1));
                        if (info == null)
                        {
                            return;
                        }

                        if (name.StartsWith("+"))
                        {
                            newZone.Controller.Include(info);
                        }
                        else if (name.StartsWith("-"))
                        {
                            newZone.Controller.Exclude(info);
                        }
                    }

                    newZone.Controller.MinRank = minRank;
                }
                else
                {
                    player.MessageNoRank(rankName);
                    return;
                }
            }
            player.Message("Zone " + newZone.ClassyName + "&S: Place a block or type &H/Mark&S to use your location.");
            player.SelectionStart(2, ZoneAddCallback, newZone, CdZoneAdd.Permissions);
        }
 public static void MsgBlockHandler(Player player, Command cmd)
 {
     String message = cmd.NextAll();
     if (message == null)
     {
         CdMessageBlock.PrintUsage(player);
     }
      Vector3I MessageBlock = new Vector3I(player.Position.X / 32, player.Position.Y / 32, (player.Position.Z / 32) - 2);
 }
        static void UnbanIPHandler( Player player, Command cmd )
        {
            string targetNameOrIP = cmd.Next();
            if( targetNameOrIP == null ) {
                CdUnbanIP.PrintUsage( player );
                return;
            }
            string reason = cmd.NextAll();

            try {
                IPAddress targetAddress;
                if( Server.IsIP( targetNameOrIP ) && IPAddress.TryParse( targetNameOrIP, out targetAddress ) ) {
                    targetAddress.UnbanIP( player, reason, true, true );
                } else {
                    PlayerInfo target = PlayerDB.FindPlayerInfoOrPrintMatches( player, targetNameOrIP );
                    if( target == null ) return;
                    if( target.LastIP.Equals( IPAddress.Any ) || target.LastIP.Equals( IPAddress.None ) ) {
                        target.Unban( player, reason, true, true );
                    } else {
                        target.UnbanIP( player, reason, true, true );
                    }
                }
            } catch( PlayerOpException ex ) {
                player.Message( ex.MessageColored );
            }
        }
        static void TitleHandler(Player player, Command cmd)
        {
            string targetName = cmd.Next();
            string titleName = cmd.NextAll();

            if (string.IsNullOrEmpty(targetName))
            {
                CdTitle.PrintUsage(player);
                return;
            }

            PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches(player, targetName);
            if (info == null) return;
            string oldTitle = info.TitleName;
            if (titleName.Length == 0) titleName = null;
            if (titleName == info.TitleName)
            {
                if (titleName == null)
                {
                    player.Message("Title: Title for {0} is not set.",
                                    info.Name);
                }
                else
                {
                    player.Message("Title: Title for {0} is already set to \"{1}&S\"",
                                    info.Name,
                                    titleName);
                }
                return;
            }
            //check the title, is it a title?
            if (titleName != null)
            {
                string StripT = Color.StripColors(titleName);
                if (!StripT.StartsWith("[") && !StripT.EndsWith("]"))
                {
                    titleName = info.Rank.Color + "[" + titleName + info.Rank.Color + "] ";
                }
            }
            info.TitleName = titleName;

            if (oldTitle == null)
            {
                player.Message("Title: Title for {0} set to \"{1}&S\"",
                                info.Name,
                                titleName);
            }
            else if (titleName == null)
            {
                player.Message("Title: Title for {0} was reset (was \"{1}&S\")",
                                info.Name,
                                oldTitle);
            }
            else
            {
                player.Message("Title: Title for {0} changed from \"{1}&S\" to \"{2}&S\"",
                                info.Name,
                                oldTitle,
                                titleName);
            }
        }
        void DoBan(Player player, Command cmd, bool banIP, bool banAll, bool unban)
        {
            if (!banAll && !banIP && player.Can(Permissions.Ban) ||
                !banAll && player.Can(Permissions.BanIP) ||
                player.Can(Permissions.BanAll))
            {
                string     arg    = cmd.Next();
                string     reason = cmd.NextAll();
                IPAddress  address;
                Player     offender = world.FindPlayer(arg);
                PlayerInfo info     = world.db.FindPlayerInfoExact(arg);

                // ban by IP address
                if (banIP && IPAddress.TryParse(arg, out address))
                {
                    if (banIP)
                    {
                        DoIPBan(player, address, reason, null, banAll, unban);
                    }

                    // ban online players
                }
                else if (!unban && offender != null)
                {
                    address = offender.info.lastIP;
                    if (banIP)
                    {
                        DoIPBan(player, address, reason, offender.name, banAll, unban);
                    }
                    if (unban)
                    {
                        if (offender.info.ProcessUnBan(player.name, reason))
                        {
                            world.log.Log("{0} was unbanned by {1}.", LogType.UserActivity, offender.info.name, player.name);
                            world.SendToAll(PacketWriter.MakeMessage(Color.Red + offender.name + " was unbanned by " + player.name), offender);
                        }
                        else
                        {
                            player.Message(offender.name + " is not currently banned.");
                        }
                    }
                    else
                    {
                        if (offender.info.ProcessBan(player.name, reason))
                        {
                            world.log.Log("{0} was banned by {1}.", LogType.UserActivity, offender.info.name, player.name);
                            world.SendToAll(PacketWriter.MakeMessage(Color.Red + offender.name + " was banned by " + player.name), offender);
                            offender.session.Kick("You were banned by " + player.name + "!");
                        }
                        else
                        {
                            player.Message(offender.name + " is already banned.");
                        }
                    }

                    // ban offline players
                }
                else if (info != null)
                {
                    address = info.lastIP;
                    if (banIP)
                    {
                        DoIPBan(player, address, reason, info.name, banAll, unban);
                    }
                    if (unban)
                    {
                        if (info.ProcessUnBan(player.name, reason))
                        {
                            world.log.Log("{0} (offline) was unbanned by {1}", LogType.UserActivity, info.name, player.name);
                            world.SendToAll(PacketWriter.MakeMessage(Color.Red + info.name + " (offline) was unbanned by " + player.name), null);
                        }
                        else
                        {
                            player.Message(info.name + " (offline) is not currenty banned.");
                        }
                    }
                    else
                    {
                        if (info.ProcessBan(player.name, reason))
                        {
                            world.log.Log("{0} (offline) was banned by {1}.", LogType.UserActivity, info.name, player.name);
                            world.SendToAll(PacketWriter.MakeMessage(Color.Red + info.name + " (offline) was banned by " + player.name), null);
                        }
                        else
                        {
                            player.Message(info.name + " (offline) is already banned.");
                        }
                    }
                }
                else
                {
                    world.NoPlayerMessage(player, arg);
                }
            }
            else
            {
                world.NoAccessMessage(player);
            }
        }
        static void BanAllHandler(Player player, Command cmd)
        {
            string targetNameOrIP = cmd.Next();
            if (targetNameOrIP == null)
            {
                CdBanAll.PrintUsage(player);
                return;
            }
            string reason = cmd.NextAll();

            IPAddress targetAddress;
            if (Server.IsIP(targetNameOrIP) && IPAddress.TryParse(targetNameOrIP, out targetAddress))
            {
                try
                {
                    targetAddress.BanAll(player, reason, true, true);
                }
                catch (PlayerOpException ex)
                {
                    player.Message(ex.MessageColored);
                }
            }
            else
            {
                PlayerInfo target = PlayerDB.FindPlayerInfoOrPrintMatches(player, targetNameOrIP);
                if (target == null) return;
                try
                {
                    if (target.LastIP.Equals(IPAddress.Any) || target.LastIP.Equals(IPAddress.None))
                    {
                        target.Ban(player, reason, true, true);
                    }
                    else
                    {
                        target.BanAll(player, reason, true, true);
                        BuildingCommands.UndoAllHandler(player, new Command("/UndoAll " + target.Name));
                    }
                }
                catch (PlayerOpException ex)
                {
                    player.Message(ex.MessageColored);
                    if (ex.ErrorCode == PlayerOpExceptionCode.ReasonRequired)
                    {
                        FreezeIfAllowed(player, target);
                    }
                }
            }
        }
 static void UnbanHandler( Player player, Command cmd )
 {
     string targetName = cmd.Next();
     if( targetName == null ) {
         CdUnban.PrintUsage( player );
         return;
     }
     PlayerInfo target = PlayerDB.FindPlayerInfoOrPrintMatches( player, targetName );
     if( target == null ) return;
     string reason = cmd.NextAll();
     try {
         target.Unban( player, reason, true, true );
     } catch( PlayerOpException ex ) {
         player.Message( ex.MessageColored );
     }
 }
        static void SetInfoHandler( Player player, Command cmd )
        {
            string targetName = cmd.Next();
            string propertyName = cmd.Next();
            string valName = cmd.NextAll();

            if( targetName == null || propertyName == null ) {
                CdSetInfo.PrintUsage( player );
                return;
            }

            PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches( player, targetName );
            if( info == null ) return;

            switch( propertyName.ToLower() ) {
                case "timeskicked":
                    int oldTimesKicked = info.TimesKicked;
                    if( ValidateInt( valName, 0, 9999 ) ) {
                        info.TimesKicked = Int32.Parse( valName );
                        player.Message( "SetInfo: TimesKicked for {0}&S changed from {1} to {2}",
                                        info.ClassyName,
                                        oldTimesKicked,
                                        info.TimesKicked );
                    } else {
                        player.Message( "SetInfo: TimesKicked value acceptible (Acceptible value range: 0-9999)" );
                    }
                    return;

                case "previousrank":
                    Rank newPreviousRank;
                    if( valName.Length > 0 ) {
                        newPreviousRank = RankManager.FindRank( valName );
                        if( newPreviousRank == null ) {
                            player.MessageNoRank( valName );
                            return;
                        }
                    } else {
                        newPreviousRank = null;
                    }

                    Rank oldPreviousRank = info.PreviousRank;

                    if( newPreviousRank == oldPreviousRank ) {
                        if( newPreviousRank == null ) {
                            player.Message( "SetInfo: PreviousRank for {0}&S is not set.",
                                            info.ClassyName );
                        } else {
                            player.Message( "SetInfo: PreviousRank for {0}&S is already set to {1}",
                                            info.ClassyName,
                                            newPreviousRank.ClassyName );
                        }
                        return;
                    }

                    if( oldPreviousRank == null ) {
                        player.Message( "SetInfo: PreviousRank for {0}&S set to {1}&",
                                        info.ClassyName,
                                        newPreviousRank.ClassyName );
                    } else if( newPreviousRank == null ) {
                        player.Message( "SetInfo: PreviousRank for {0}&S was reset (was {1}&S)",
                                        info.ClassyName,
                                        oldPreviousRank.ClassyName );
                    } else {
                        player.Message( "SetInfo: PreviousRank for {0}&S changed from {1}&S to {2}",
                                        info.ClassyName,
                                        oldPreviousRank.ClassyName,
                                        newPreviousRank.ClassyName );
                    }
                    return;

                case "totaltime":
                    TimeSpan newTotalTime;
                    TimeSpan oldTotalTime = info.TotalTime;
                    if( valName.TryParseMiniTimespan( out newTotalTime ) ) {
                        info.TotalTime = newTotalTime;
                        player.Message( "SetInfo: TotalTime for {0}&S changed from {1} ({2}) to {3} ({4})",
                                        info.ClassyName,
                                        oldTotalTime.ToMiniString(),
                                        oldTotalTime.ToCompactString(),
                                        info.TotalTime.ToMiniString(),
                                        info.TotalTime.ToCompactString() );
                    } else {
                        player.Message( "SetInfo: Could not parse value given for TotalTime." );
                    }
                    return;

                case "rankchangetype":
                    RankChangeType oldType = info.RankChangeType;
                    try {
                        info.RankChangeType = (RankChangeType)Enum.Parse( typeof( RankChangeType ), valName, true );
                    } catch( ArgumentException ) {
                        player.Message( "SetInfo: Could not parse RankChangeType. Allowed values: {0}",
                                        String.Join( ", ", Enum.GetNames( typeof( RankChangeType ) ) ) );
                        return;
                    }
                    player.Message( "SetInfo: RankChangeType for {0}&S changed from {1} to {2}",
                                    info.ClassyName,
                                    oldType,
                                    info.RankChangeType );
                    return;

                case "banreason":
                    if( valName.Length == 0 ) valName = null;
                    if( SetPlayerInfoField( player, "BanReason", info, info.BanReason, valName ) ) {
                        info.BanReason = valName;
                    }
                    return;

                case "unbanreason":
                    if( valName.Length == 0 ) valName = null;
                    if( SetPlayerInfoField( player, "UnbanReason", info, info.UnbanReason, valName ) ) {
                        info.UnbanReason = valName;
                    }
                    return;

                case "rankreason":
                    if( valName.Length == 0 ) valName = null;
                    if( SetPlayerInfoField( player, "RankReason", info, info.RankChangeReason, valName ) ) {
                        info.RankChangeReason = valName;
                    }
                    return;

                case "kickreason":
                    if( valName.Length == 0 ) valName = null;
                    if( SetPlayerInfoField( player, "KickReason", info, info.LastKickReason, valName ) ) {
                        info.LastKickReason = valName;
                    }
                    return;

                case "displayedname":
                    string oldDisplayedName = info.DisplayedName;
                    if( player.Can( Permission.UseColorCodes ) ) {
                        valName = Color.ReplacePercentCodes( valName );
                    }
                    if( valName.Length == 0 ) valName = null;
                    if( valName == info.DisplayedName ) {
                        if( valName == null ) {
                            player.Message( "SetInfo: DisplayedName for {0} is not set.",
                                            info.Name );
                        } else {
                            player.Message( "SetInfo: DisplayedName for {0} is already set to \"{1}&S\"",
                                            info.Name,
                                            valName );
                        }
                        return;
                    }
                    info.DisplayedName = valName;

                    if( oldDisplayedName == null ) {
                        player.Message( "SetInfo: DisplayedName for {0} set to \"{1}&S\"",
                                        info.Name,
                                        valName );
                    } else if( valName == null ) {
                        player.Message( "SetInfo: DisplayedName for {0} was reset (was \"{1}&S\")",
                                        info.Name,
                                        oldDisplayedName );
                    } else {
                        player.Message( "SetInfo: DisplayedName for {0} changed from \"{1}&S\" to \"{2}&S\"",
                                        info.Name,
                                        oldDisplayedName,
                                        valName );
                    }
                    return;

                default:
                    player.Message( "Only the following properties are editable: " +
                                    "TimesKicked, PreviousRank, TotalTime, RankChangeType, " +
                                    "BanReason, UnbanReason, RankReason, KickReason, DisplayedName" );
                    return;
            }
        }
Exemple #52
0
        static void GHandler(Player player, Command cmd)
        {
            string Msg = cmd.NextAll();
            if (!ConfigKey.GCKey.Enabled())
            {
                player.Message("Global Chat is disabled on this server.");
                return;
            }
            if (!GlobalChat.GlobalThread.GCReady)
            {
                player.Message("Global Chat is not connected.");
                return;
            }
            if (Msg == "reconnect")
            {
                if (player.Can(Permission.ManageGlobalChat))
                {
                    if (GlobalChat.GlobalThread.GCReady)
                    {
                        player.Message("&cThis server is currently connected to global chat.");
                        return;
                    }
                    else
                    {
                        GlobalChat.GlobalThread.GCReady = true;
                        Server.Message("&eAttempting to connect to LegendCraft Global Chat Network. This may take up to two minutes.");
                        GlobalChat.Init();
                        GlobalChat.Start();
                        return;

                    }
                }
            }

            var SendList = Server.Players.Where(p => p.GlobalChatAllowed && !p.IsDeaf);

            if ((!player.GlobalChatAllowed) && (Msg == "rules"))
            {
                player.Message(" &cRules: No spamming and no advertising. All chat rules that apply to your server apply here.\n" +
                    "&eServer staff have the right to kick you.\n" +
                    "&9By using the Global Chat, you accept these conditions.\n" +
                    "&eType &a/Global accept &eto connect");
                return;
            }

            else if ((player.GlobalChatAllowed) && (Msg == "rules"))
            {
                player.Message(" &cRules: No spamming and no advertising. All chat rules that apply to your server apply here.\n" +
                    "&eServer staff have the right to kick you.\n" +
                    "&9By using the Global Chat, you accept these conditions.");
                return;
            }

            else if ((!player.GlobalChatAllowed) && (Msg == "accept"))
            {
                player.GlobalChatAllowed = true;
                player.Message("&wThank you for accepting the global chat rules.\n" +
                    "&cYou now have global chat enabled.");
                GlobalChat.GlobalThread.SendChannelMessage(player.ClassyName + " &Sjoined global chat.");
                SendList.Message(player.ClassyName + " &Sjoined global chat.");
                return;
            }

            else if ((player.GlobalChatAllowed) && (Msg == "accept"))
            {
                player.Message("&You have already accepted the global chat rules.");
                return;
            }

            else if ((!player.GlobalChatIgnore) && (Msg == "ignore"))
            {
                player.GlobalChatIgnore = true;
                player.Message("&cYou have disconnected from global chat.");
                SendList.Message(player.ClassyName + " &Sdisconnected from global chat.");
                GlobalChat.GlobalThread.SendChannelMessage(player.ClassyName + " &Sdisconnected from global chat.");
                return;
            }

            else if (player.Info.IsMuted)
            {
                player.MessageMuted();
                return;
            }

            if ((!player.GlobalChatAllowed) && ((Msg.Length < 1) || (Msg.Length > 1)))
            {
                player.Message("&WYou must read and accept the global chat rules. Type &a/Global rules.");
                return;
            }

            else if ((player.GlobalChatAllowed) &&((Msg == "") || (Msg == null)))
            {
                player.Message("You must enter a message!");
                return;
            }
            else if (Msg == "help")
            {
                CdGlobal.PrintUsage(player);
                return;
            }

            else if (player.GlobalChatAllowed)
            {
                string pMsg = player.ClassyName + Color.White + ": " + Msg;
                Msg = player.ClassyName + Color.Black + ": " + Msg;
                SendList.Message("&i[Global] " + pMsg); //send the white message to Server
                Msg = Color.MinecraftToIrcColors(Msg);
                Msg = Color.ReplacePercentCodes(Msg);
                GlobalChat.GlobalThread.SendChannelMessage(Msg); //send the black message to GC
            }
        }
        static void RestartHandler( Player player, Command cmd )
        {
            string delayString = cmd.Next();
            TimeSpan delayTime = DefaultShutdownTime;
            string reason = "";

            if( delayString != null ) {
                if( delayString.Equals( "abort", StringComparison.OrdinalIgnoreCase ) ) {
                    if( Server.CancelShutdown() ) {
                        Logger.Log( LogType.UserActivity,
                                    "Restart aborted by {0}.", player.Name );
                        Server.Message( "&WRestart aborted by {0}", player.ClassyName );
                    } else {
                        player.MessageNow( "Cannot abort restart - too late." );
                    }
                    return;
                } else if( !delayString.TryParseMiniTimespan( out delayTime ) ) {
                    CdShutdown.PrintUsage( player );
                    return;
                }
                reason = cmd.NextAll();
            }

            if( delayTime.TotalMilliseconds > Int32.MaxValue - 1 ) {
                player.Message( "Restart: Delay is too long, maximum is {0}",
                                TimeSpan.FromMilliseconds( Int32.MaxValue - 1 ).ToMiniString() );
                return;
            }

            Server.Message( "&WServer restarting in {0}", delayTime.ToMiniString() );

            if( String.IsNullOrEmpty( reason ) ) {
                Logger.Log( LogType.UserActivity,
                            "{0} scheduled a restart ({1} delay).",
                            player.Name, delayTime.ToCompactString() );
                ShutdownParams sp = new ShutdownParams( ShutdownReason.Restarting, delayTime, true, true );
                Server.Shutdown( sp, false );
            } else {
                Server.Message( "&WRestart reason: {0}", reason );
                Logger.Log( LogType.UserActivity,
                            "{0} scheduled a restart ({1} delay). Reason: {2}",
                            player.Name, delayTime.ToCompactString(), reason );
                ShutdownParams sp = new ShutdownParams( ShutdownReason.Restarting, delayTime, true, true, reason, player );
                Server.Shutdown( sp, false );
            }
        }
Exemple #54
0
 static void RageHandler(Player player, Command cmd)
 {
     string reason = cmd.NextAll();
     if (reason.Length < 1)
     {
         Server.Players.Message("{0} &4Ragequit from the server", player.ClassyName);
         player.Kick(Player.Console, "&4Ragequit", LeaveReason.RageQuit, false, false, false);
         IRC.SendAction(player.ClassyName + " &4Ragequit from the server");
         return;
     }
     else
     {
         Server.Players.Message("{0} &4Ragequit from the server: &C{1}",
                         player.ClassyName, reason);
         IRC.SendAction(player.ClassyName + " &WRagequit from the server: " + reason);
         player.Kick(Player.Console, reason, LeaveReason.RageQuit, false, false, false);
     }
 }