Add Ignore in chat

Add Ignore in chat

Postby Mendez » 18 Mar 2013, 18:45

I had a request from staff if they could have an /ignore [Player] command for in the chat, possibly with a notification, (maybe a private notification.)
Default setting Op+.
Their reason was it would solve getting drawn into unnecessary disputes :!:

Would this be reasonably simple, like some other chat sites have, for the next update?

Thanks.
Mendez_Pro
Owner of Mendez Freebuild+LavaS
Mendez
 
Posts: 26
Joined: 26 Dec 2012, 07:34

Re: Add Ignore in chat

Postby lucasds12 » 30 May 2013, 21:18

Ok, I got the code for it.
I saw it from someone in this forum, can't remember who made it.
Anyways tell me if there is a bug cause I have not tested this.
Code: Select all
   using System;
   using System.Collections.Generic;
   using System.Data;
   using System.IO;

   namespace MCDzienny
   {
      public class CmdIgnore : Command
      {
         public override string name { get { return "ignore"; } }
         public override string shortcut { get { return ""; } }
         public override string type { get { return "other"; } }
         public override bool museumUsable { get { return true; } }
         public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
         public CmdIgnore() { }
         public static byte lastused = 0;
         public static string ignore = "";
         public static string ignore2 = "";
   
         public override void Use(Player p, string message)
         {
            if (p == null) { Player.SendMessage(p, "This command can only be used in-game!"); return; }
            if (message.Split(' ')[0] == "all")
            {
               p.ignoreglobal = !p.ignoreglobal;
               p.muteGlobal = p.ignoreglobal;
               if (p.ignoreglobal) Player.globalignores.Add(p.name);
               else Player.globalignores.Remove(p.name);
               Player.SendMessage(p, p.ignoreglobal ? "&cAll chat is now ignored!" : "&aAll chat is no longer ignored!");
               return;
            }
            if (message.Split(' ')[0] == "global")
            {
               p.muteGlobal = !p.muteGlobal;
               Player.SendMessage(p, p.muteGlobal ? "&cGlobal Chat is now ignored!" : "&aGlobal Chat is no longer ignored!");
               return;
            }
            if (message.Split(' ')[0] == "list")
            {
               Player.SendMessage(p, "&cCurrently ignoring the following players:");
               foreach (string ignoring in p.listignored)
               {
                  Player.SendMessage(p, "- " + ignoring);
               }
               return;
            }
            Player who = Player.Find(message.Split(' ')[0]);
            if (who == null)
            {
               Player.SendMessage(p, "Could not find player specified!");
               return;
            }
   
            if (who.name == p.name)
            {
               Player.SendMessage(p, "You cannot ignore yourself!!");
               return;
            }

            if (who.group.Permission >= Server.opchatperm)
            {
               if (p.group.Permission <= who.group.Permission)
               {
                  Player.SendMessage(p, "You cannot ignore an operator of higher rank!");
                  return;
               }
            }
           
     
            if (!Directory.Exists("ranks/ignore"))
            {
               Directory.CreateDirectory("ranks/ignore");
            }
            if (!File.Exists("ranks/ignore/" + p.name + ".txt"))
            {
               File.Create("ranks/ignore/" + p.name + ".txt").Dispose();
            }
            string chosenpath = "ranks/ignore/" + p.name + ".txt";
            if (!File.Exists(chosenpath) || !p.listignored.Contains(who.name))
            {
               p.listignored.Add(who.name);
               Player.SendMessage(p, "Player now ignored: &c" + who.name + "!");
               return;
            }
            if (p.listignored.Contains(who.name))
            {
               p.listignored.Remove(who.name);
               Player.SendMessage(p, "Player is no longer ignored: &a" + who.name + "!");
               return;
            }
            Player.SendMessage(p, "Something is stuffed.... Tell a MCForge Developer!");
         }

         public override void Help(Player p)
         {
            Player.SendMessage(p, "/ignore [Player] - Ignores the specified player.");
            Player.SendMessage(p, "/ignore global - Ignores the global chat.");
            Player.SendMessage(p, "Note: You cannot ignore operators of higher rank!");
         }
      }
   }]

There.
-Lucas
There is only one thing I do in life, that's contributing here.
lucasds12
 
Posts: 334
Joined: 17 Apr 2013, 16:17
Location: In the deep caves.

Re: Add Ignore in chat

Postby Conor » 30 May 2013, 21:34

You are relying on many variables within the Player class here, which I think may not exist in MCDzienny.

The mechanism for ignoring people would be coded in the Player class, as currently there is no event available to use in a custom command plugin to carry out such an effect.

So I don't think this will work Lucas. Dzienny has said to me directly he may create this command in the future though, or allow people to code custom command plugins for it by adding a relevant event.
Conor (Conanza121)
User avatar
Conor
Coder
 
Posts: 390
Joined: 10 Oct 2012, 21:36
Location: @21Conor

Re: Add Ignore in chat

Postby lucasds12 » 30 May 2013, 22:11

Thank you for the advice Conor.
I truly did not know the variables of p class. was not working the same with this software.
-Lucas
There is only one thing I do in life, that's contributing here.
lucasds12
 
Posts: 334
Joined: 17 Apr 2013, 16:17
Location: In the deep caves.


Return to General Suggestions

Who is online

Users browsing this forum: No registered users and 6 guests

cron