public override void onPlayerJoin(int playerId)
    {
        PhotonPlayer player = PhotonPlayer.Find(playerId);

        try {
            main.writeChatLogEvent("Player [#" + player.ID + "] " + player.customProperties[PhotonPlayerProperty.name] + " joined");

            if (PhotonNetwork.isMasterClient)
            {
                string name = (string)player.customProperties[PhotonPlayerProperty.name];
                string stripped;

                if (name == null)
                {
                    return;
                }

                stripped = ModMain.stripColorCodes(name).Trim();

                if (main.getModMainThread().isBanned(stripped))
                {
                    main.writeChatLogEvent("Banned player \"" + stripped + "\" was kicked.");
                    PhotonNetwork.CloseConnection(player);
                }
            }
        } catch (System.Exception e) {
            main.log(e);
        }
    }
Exemple #2
0
    public void unban(int index)
    {
        string[] keys = new string[bannedNames.Count];
        bannedNames.Keys.CopyTo(keys, 0);
        BanType       type        = (BanType)this.bannedNames[keys[index]];
        List <object> banHashKeys = new List <object>(FengGameManagerMKII.banHash.Keys);

        foreach (object key in banHashKeys)
        {
            string stripped = ModMain.stripColorCodes((string)FengGameManagerMKII.banHash[key]);

            if (type == BanType.CONTAINS_PART)
            {
                if (stripped.Contains(keys[index]))
                {
                    FengGameManagerMKII.banHash.Remove(key);
                }
            }
            else if (type == BanType.FULL_NAME)
            {
                if (stripped.Equals(keys[index]))
                {
                    FengGameManagerMKII.banHash.Remove(key);
                }
            }
        }


        lock (bannedLock){
            bannedNames.Remove(keys[index]);
        }
    }
Exemple #3
0
    public bool cmd(string[] args, FengGameManagerMKII gm)
    {
        if (args.Length == 0)
        {
            ModMain.instance.sendToPlayer(this.help);
            return(true);
        }

        if (args[0].Equals("add", StringComparison.OrdinalIgnoreCase))
        {
            if (args[1].Equals("-s"))
            {
                string[] temp = new string[args.Length - 2];
                Array.Copy(args, 2, temp, 0, temp.Length);
                ModMain.instance.getModMainThread().addToCrashMap(string.Join(" ", temp), MainModThread.BanType.CONTAINS_PART);
            }
            else
            {
                string name = (string)PhotonPlayer.Find(int.Parse(args[1])).customProperties[PhotonPlayerProperty.name];
                ModMain.instance.getModMainThread().addToCrashMap(ModMain.stripColorCodes(name), MainModThread.BanType.FULL_NAME);
            }
            return(true);
        }
        else if (args[0].Equals("remove", StringComparison.OrdinalIgnoreCase))
        {
            int       i     = int.Parse(args[1]);
            Hashtable table = ModMain.instance.getModMainThread().getCrashTable();
            int       j     = 0;

            foreach (string s in table.Keys)
            {
                if (i == j)
                {
                    ModMain.instance.getModMainThread().removeFromCrash(s);
                    return(true);
                }
                j++;
            }

            return(true);
        }
        if (args[0].Equals("list", StringComparison.OrdinalIgnoreCase))
        {
            Hashtable table = ModMain.instance.getModMainThread().getCrashTable();
            int       i     = 0;

            foreach (string s in table.Keys)
            {
                ModMain.instance.sendToPlayer("" + i + " - " + s + " [" + table[s] + "]");
                i++;
            }
            return(true);
        }
        else
        {
            return(false);
        }
    }
Exemple #4
0
    //private Regex colorPattern = new Regex("\\[[0-f\\-]{6}\\]", RegexOptions.IgnoreCase);
    public NameChanger(ModMain mod)
    {
        ConfigManager cfg   = mod.getConfig();
        List <string> names = cfg.getStringList("NameChangerNames");

        if (names != null)
        {
            this.names = names;
        }
    }
Exemple #5
0
    public bool cmd(string[] args, FengGameManagerMKII gm)
    {
        if (args.Length == 0)
        {
            ModMain.instance.sendToPlayer(this.help);
            return(true);
        }

        int playersFound = 0;

        if (!PhotonNetwork.isMasterClient)
        {
            playersFound = 1;
            string mcName = ModMain.stripColorCodes((string)PhotonNetwork.masterClient.customProperties[PhotonPlayerProperty.name]);
            ModMain.instance.sendToPlayer(Colorizer.colorize("Master client #" + PhotonNetwork.masterClient.ID + " (" + mcName + ")", Colorizer.Color.BLUE, true));
        }

        foreach (PhotonPlayer player in PhotonNetwork.playerList)
        {
            string unstripped = (string)player.customProperties[PhotonPlayerProperty.name];
            if (string.IsNullOrEmpty(unstripped))
            {
                ModMain.instance.sendToPlayer(Colorizer.colorize("Player #" + player.ID + " has a null name (" + unstripped + ").", Colorizer.Color.RED, true));
                playersFound++;
            }
            else
            {
                string stripped = ModMain.stripColorCodes(unstripped);
                if (string.IsNullOrEmpty(stripped))
                {
                    ModMain.instance.sendToPlayer("Player #" + player.ID + " only has colors in his name (" + unstripped + ").");
                    playersFound++;
                }
                else
                {
                    foreach (string s in args)
                    {
                        if (unstripped.Contains(s))
                        {
                            ModMain.instance.sendToPlayer("Found player #" + player.ID + " matching " + s + " (" + stripped + ")");
                            playersFound++;
                            break;
                        }
                    }
                }
            }
        }

        ModMain.instance.sendToPlayer("Found " + playersFound + " matching given names.");

        return(true);
    }
Exemple #6
0
    public bool cmd(string[] args, FengGameManagerMKII gm)
    {
        if (args.Length == 0)
        {
            ModMain.instance.sendToPlayer(this.help);
            return(true);
        }

        if (args[0].Equals("index", System.StringComparison.OrdinalIgnoreCase))
        {
            int i = 0;
            ModMain.instance.sendToPlayer("Banned players: ");
            Hashtable bans = ModMain.instance.getModMainThread().getBannedNames();

            foreach (string s in bans.Keys)
            {
                ModMain.instance.sendToPlayer("" + (i++) + "- " + s + "#" + bans[s]);
            }

            return(true);
        }

        if (args[0].Equals("-r"))
        {
            ModMain.instance.getModMainThread().unban(int.Parse(args[1]));
            ModMain.instance.sendToPlayer("Player unbanned.");
            return(true);
        }
        else if (args[0].Equals("-s"))
        {
            ModMain.instance.getModMainThread().banName(args[1], MainModThread.BanType.CONTAINS_PART);
            return(true);
        }
        else
        {
            try{
                string name = (string)PhotonPlayer.Find(int.Parse(args[0])).customProperties[PhotonPlayerProperty.name];
                ModMain.instance.getModMainThread().banName(ModMain.stripColorCodes(name), MainModThread.BanType.FULL_NAME);
                return(true);
            }catch (System.Exception) {
                return(false);
            }
        }
    }
Exemple #7
0
    public void setMode(NameMode mode)
    {
        this.mode = mode;
        if (mode == NameMode.FADE)
        {
            string nameToUse;
            this.currentColorIndex = 0;
            this.currentColorStep  = 0;

            if (this.target > 0)
            {
                PhotonPlayer player = PhotonPlayer.Find(this.target);

                if (player != null && player.customProperties[PhotonPlayerProperty.name] != null)
                {
                    nameToUse = ModMain.stripColorCodes((string)player.customProperties[PhotonPlayerProperty.name]);
                }
                else
                {
                    nameToUse = ModMain.stripColorCodes((string)PhotonNetwork.player.customProperties[PhotonPlayerProperty.name]);
                }
            }
            else
            {
                nameToUse = ModMain.stripColorCodes((string)PhotonNetwork.player.customProperties[PhotonPlayerProperty.name]);
            }

            char[]   temp  = nameToUse.ToCharArray();
            string[] temp2 = new string[temp.Length];
            for (int i = 0; i < temp.Length; i++)
            {
                temp2[i] = "" + temp[i];
            }

            this.fadeNameParts = temp2;
        }
    }
Exemple #8
0
    public void init(object gm)
    {
        if (File.Exists("log.txt"))
        {
            logOut = File.AppendText("log.txt");
        }
        else
        {
            logOut = File.CreateText("log.txt");
        }
#if DEBUG
        this.debugOut = File.CreateText("debug.log");
#endif

        this.log("====init() was called====");
        try {
            this.fGameManager = (FengGameManagerMKII)gm;
            GameObject go = new GameObject();
            go.name = "ModUI";
            GameObject.DontDestroyOnLoad(go);
            this.modUI = go.AddComponent <ModUI>();

            this.log("----Initializing mod.");
            this.log("Loading the configuration.");
            this.config = ConfigManager.load("config.cfg");
            this.log("Loading settings file.");
            if (File.Exists("settings.json"))
            {
                try {
                    this.settingsObject = JsonObject.fromFile("settings.json");
                    File.Move("settings.json", "settings.json.corrupted" + UnityEngine.Random.Range(0, 10000));
                }catch (JsonException e) {
                    this.log(e);
                    this.settingsObject = new JsonObject();
                }
            }
            else
            {
                this.settingsObject = new JsonObject();
            }

            this.taskManager = new TaskManager();
            gameModInterface = new GameModEventInterface(this);

            this.spawnController = new SpawnController(this.fGameManager, config.get("TitanWaveAmountFunction"), config.get("WaveEndMessage"));

            this.commandBinder = new CommandBinder(this.taskManager);

            this.cManager = new CManager();

            this.nameManager = new NameManager(this.config);
            commandManager   = new CommandManager();

            PhotonNetwork.OnEventCall = this.eventCallback;

            this.averageDamage = float.Parse(config.get("averageDamage"));

            this.log("Initializing extras.");

            this.log("Creating the greeter.");
            greeter = new PlayerGreeter(this);
            this.log("Creating the mod thread.");
            bct  = new MainModThread(this);
            opcm = new OtherPlayerCommandsManager(this.fGameManager);

            thController = new TitanHealthController();

            this.nameChanger = new NameChanger(this);

            this.lagController = new LagController();

            KillCmd.titanName = this.config.get("killTitanName");
            this.setChatLogEnabled(this.getConfig().getBool("chatLogEnabled"));

            this.setUseGas(true);
            this.setUseBlades(true);

            this.log("Registering mod API");
            AoTModAPI.AoTModAPI.setModAPI(this.gameModInterface);

            this.log("Updating values from the settings file.");
            this.log("Starting mod thread.");
            bct.start();
        } catch (System.Exception e) {
            this.log("Error while initializing mod, who knows what will happen.");
            this.log(e);
        }

        this.messagePrefix = this.getConfig().get("messagePrefix");
        this.messageSuffix = this.getConfig().get("messageSuffix");

        this.log("Mod initialized.");

        ModMain.instance = this;
        this.log("Instance: " + ModMain.instance);
        this.commandManager.buildHelpList();
    }
Exemple #9
0
 public PlayerGreeter(ModMain mod)
 {
     message = Colorizer.colorize(mod.getConfig().get("modMessage"), Colorizer.Color.YELLOW, true);
 }
 public GameModEventInterface(global::ModMain main)
 {
     this.main = main;
 }
Exemple #11
0
 public TestMod() : base(new ModInfo("testmod", "The Test Mod", "1.0", "Me"))
 {
     Instance = this;
 }
Exemple #12
0
    private void run()
    {
        this.running = true;
        bool dead = false;

        try{
            while (!this.toStop)
            {
                if (PhotonNetwork.connected)
                {
                    bool hasDeadPlayers = false;

                    if (this.didSomeoneTamperTheScoreboard())
                    {
                        this.updateScoreboardHashtable();
                    }

                    this.doDestroyCheck();

                    foreach (PhotonPlayer player in PhotonNetwork.playerList)
                    {
                        object playerIsDead = player.customProperties[PhotonPlayerProperty.dead];
                        string name         = (string)player.customProperties[PhotonPlayerProperty.name];
                        name = (name == null) ? string.Empty : name;
                        name = name.Trim();
                        string stripped = ModMain.stripColorCodes(name);

                        if (PhotonNetwork.isMasterClient)
                        {
                            if ((name != null && name != string.Empty) || !canPass(player.ID, name))
                            {
                                if (isBanned(stripped) && !FengGameManagerMKII.ignoreList.Contains(player.ID))
                                {
                                    //FengGameManagerMKII.instance.kickPlayerRC(player, true, "[Public Security Mod] Name banned");
                                    PhotonNetwork.CloseConnection(player);
                                    continue;
                                }
                                else if (this.crashListEnabled && !this.currentBeingCrashed.Contains(player.ID) && this.isToCrash(stripped))
                                {
                                    this.currentBeingCrashed.Add(player.ID);
                                    CrashCmd.doCrash3(player.ID);
                                }
                            }
                        }

                        if (this.deathListEnabled)
                        {
                            foreach (int id in this.deathList)
                            {
                                if (PhotonPlayer.Find(id) == null)
                                {
                                    this.deathList.Remove(id);
                                }
                            }

                            if (this.deathList.Count != 0)
                            {
                                ModMain.instance.getTaskManager().addLateUpdateTask(new DeathCheckTask(this.deathList));
                            }
                        }

                        playerIsDead = (playerIsDead == null) ? true : playerIsDead;

                        if (((bool)playerIsDead))
                        {
                            hasDeadPlayers = true;
                        }
                    }

                    if (this.autoRespawnEnabled && hasDeadPlayers)
                    {
                        ModMain.instance.getTaskManager().addLateUpdateTask(new RespawnTask());
                    }
                }

                Thread.Sleep(1000);
            }
        }catch (System.Exception e) {
            int i = 0;
            i   += 10;
            dead = true;
            ModMain.instance.log("Main mod thread died. Exception: ");
            ModMain.instance.log(e);
            ModMain.instance.log("Restarting Thread.");
            Thread.Sleep(500);
        }
        this.running = false;

        if (dead)
        {
            this.start();
        }
    }
Exemple #13
0
 public void banName(string name, BanType type)
 {
     lock (bannedLock){
         bannedNames[ModMain.stripColorCodes(name)] = type;
     }
 }
Exemple #14
0
 public MainModThread(ModMain mod)
 {
     this.mod = mod;
 }